Merge lp:~dyams/unity-2d/update-pips into lp:unity-2d
- update-pips
- Merge into trunk
Status: | Rejected |
---|---|
Rejected by: | Gerry Boland |
Proposed branch: | lp:~dyams/unity-2d/update-pips |
Merge into: | lp:unity-2d |
Diff against target: |
505 lines (+357/-1) 9 files modified
launcher/LauncherItem.qml (+1/-1) launcher/LauncherList.qml (+19/-0) libunity-2d-private/src/launcherapplication.cpp (+32/-0) libunity-2d-private/src/launcherapplication.h (+4/-0) libunity-2d-private/src/launcheritem.cpp (+6/-0) libunity-2d-private/src/launcheritem.h (+2/-0) libunity-2d-private/src/unity2ddeclarativeview.cpp (+1/-0) libunity-2d-private/src/unity2ddeclarativeview.h (+1/-0) tests/launcher/update_pips_tests.rb (+291/-0) |
To merge this branch: | bzr merge lp:~dyams/unity-2d/update-pips |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Gerry Boland (community) | Disapprove | ||
Review via email: mp+89189@code.launchpad.net |
Commit message
Description of the change
Launcher tile pips are also used to indicate whether the application windows belong to the same workspace(or screen) or not. Now If all windows of an application belong to different workspace(or screen), launcher should indicate the same with an empty triangle(pip) besides the application tile.
Gerry Boland (gerboland) wrote : | # |
Gerry Boland (gerboland) wrote : | # |
+ objectName: "pips-" + item.name+index
Why do you need this? Won't your test work with
@app.Unity2dPanel() \
.LauncherList( :name => 'main' ) \
.QDeclarativeItem( :name => 'Calculator' ) \
.QDeclarativeImage( :name => 'pips')['source']
- 852. By Lohith D Shivamurthy
-
[launcher] Part to changes to update pips to indicate apps on different screen is removed.
Lohith D Shivamurthy (dyams) wrote : | # |
> + objectName: "pips-" + item.name+index
>
> Why do you need this? Won't your test work with
>
> @app.Unity2dPanel() \
> .LauncherList( :name => 'main' ) \
> .QDeclarativeItem( :name => 'Calculator' ) \
> .QDeclarativeImage( :name => 'pips')['source']
No. There can be more than one pip for the same tile. Testability will not identify the objects if they don't have unique object names.
Gerry Boland (gerboland) wrote : | # |
Aha, the pips are drawn by a repeater, so the original objectName isn't good. Do change it, but still no need for the item.name IMO.
Gerry Boland (gerboland) wrote : | # |
About your test suite: this makes a big change so it needs several tests.
First off can you please add a good test-description as a comment to the top of each test-case, like
https:/
I'd also prefer you split the test cases just a little, so you get tests for:
1. One app on this workspace only
2. One app on other workspace only
3. Two apps on this workspace
4. Two apps, both on other workspace
5. Two apps, one on this workspace, one on other
6. Three apps all on this workspace
7. Three apps, all but one on this workspace
I know it's a lot, but these are all the possible cases that I see your code influencing.
This code isn't perfect:
+ Timeout.
When you've one calculator open, this will return immediately. It is possible then that
+ return XDo::XWindow.
will return the first calculator XId.
This is the reason I was using terminals with unique titlebars in other tests. At least then you can uniquely identify the window. Hacky, I know. If you know of a way to run a program & get the XId of the window reliably, I'd love to hear it! (via PID is a good idea, except for Terminal:) )
Have a look at tests/misc/
@number_
+ width = %x{xrandr --current | grep \'\*+\' | uniq | awk \'{print $1}\' | cut -d \'x\' -f1}
It would be great if you added this to the XDoTool Ruby bindings for everyone to use. Parsing the output with Ruby would probably be quicker?? :)
Small "puts" comments in your test suite are not necessary either. And there's some extra blank lines.
- 853. By Lohith D Shivamurthy
-
[launcher] Refined objectName for pips
Gerry Boland (gerboland) wrote : | # |
Minor things:
if (!m_application)
return windowCount;
Doesn't follow our coding guidelines.
QRect desktopRect = ScreenInfo:
if (totalWindows && !windowsInCurre
Question: Why LauncherItem:
Gerry Boland (gerboland) wrote : | # |
Functionally the code works well and is looking good!
- 854. By Lohith D Shivamurthy
-
[launcher] Included few review comments
Lohith D Shivamurthy (dyams) wrote : | # |
> About your test suite: this makes a big change so it needs several tests.
>
> First off can you please add a good test-description as a comment to the top
> of each test-case, like
> https:/
> 2d/trunk/
>
Done
> I'd also prefer you split the test cases just a little, so you get tests for:
> 1. One app on this workspace only
> 2. One app on other workspace only
> 3. Two apps on this workspace
> 4. Two apps, both on other workspace
> 5. Two apps, one on this workspace, one on other
> 6. Three apps all on this workspace
> 7. Three apps, all but one on this workspace
> I know it's a lot, but these are all the possible cases that I see your code
> influencing.
Actually current test suite considers them all. By Two apps you mean an app with two windows not two different applications. no?
Well, current tests already have separate tests for app with only one window and app with more than one window.
When testing with more than one window, i have also tested by moving each window to different workspace individually.
1) Two windows on current workspace
2) One window on current workspace and another window on different workspace
3) Both windows on different workspace than current
>
>
> This code isn't perfect:
> + Timeout.
> When you've one calculator open, this will return immediately. It is possible
> then that
> + return XDo::XWindow.
> will return the first calculator XId.
>
There is a 'sleep 2' in between the two statements, which helped me to address the issue you have mentioned.
> This is the reason I was using terminals with unique titlebars in other tests.
> At least then you can uniquely identify the window. Hacky, I know. If you know
> of a way to run a program & get the XId of the window reliably, I'd love to
> hear it! (via PID is a good idea, except for Terminal:) )
I can borrow the same idea. If you don't like the 'sleep 2' :)
>
> Have a look at tests/misc/
> cleanup method so that if a test fails, you don't have non-closed windows to
> worry about. It will mean you can remove "kill" statements from the start of
> test-cases. Call the cleanup method in the teardown, it's
>
No, this kill statements are not for cleaning the residues of the test case. Instead it is a prerequisite. If there are more than one window then pip image is different than when there is only one window. So we need to ensure there is no running windows of the test application.
>
> @number_
>
If I remove that @ I got this error
.update_
> + width = %x{xrandr --current | grep \'\*+\' | uniq | awk \'{print $1}\' | cut
> -d \'x\' -f1}
> It would be great if you added this to the XDoTool Ruby bindings for everyone
> to use. Parsing the output with Ruby would probably be quicker?? :)
>
This is part of multi-monitor stuff, which is totally removed from this MR already
>
> Small "puts" comment...
Lohith D Shivamurthy (dyams) wrote : | # |
> Minor things:
>
> if (!m_application)
> return windowCount;
> Doesn't follow our coding guidelines.
>
>
> QRect desktopRect = ScreenInfo:
> character
>
>
> if (totalWindows && !windowsInCurre
> integers, is clearer to be a liite more verbose: (totalWindows > 0) etc..
>
>
Done
>
> Question: Why LauncherItem:
> false?
It is virtual funtion, So LauncherApplica
Lohith D Shivamurthy (dyams) wrote : | # |
> > Small "puts" comments in your test suite are not necessary either. And
> there's
> > some extra blank lines.
> I have removed 'puts'. I thought they would inform what the test case is doing
> while we are waiting for them to finish. Unfortunately they did serve the
> purpose it seems;)>
I have removed 'puts'. I added them with the intention of informing the nature of tests being executed.
Unfortunately they didn't serve the purpose, it seems :)
Gerry Boland (gerboland) wrote : | # |
I recommend you make one commit for every comment considered. It makes reviewing your changes easier.
Gerry Boland (gerboland) wrote : | # |
> Actually current test suite considers them all. By Two apps you mean an app
> with two windows not two different applications. no?
> Well, current tests already have separate tests for app with only one window
> and app with more than one window.
> When testing with more than one window, i have also tested by moving each
> window to different workspace individually.
> 1) Two windows on current workspace
> 2) One window on current workspace and another window on different workspace
> 3) Both windows on different workspace than current
Indeed I noticed that. I just think that each of your test cases are doing too much in one go. Hence I wanted the split.
> > This code isn't perfect:
> > + Timeout.
> > When you've one calculator open, this will return immediately. It is
> possible
> > then that
> > + return XDo::XWindow.
> > will return the first calculator XId.
> >
> There is a 'sleep 2' in between the two statements, which helped me to address
> the issue you have mentioned.
Helps, but not a cure. We cannot assume the machine isn't slow, we don't want failures because of it.
> I can borrow the same idea. If you don't like the 'sleep 2' :)
Please use the tmpwindow lib. It's a bit safer.
>
> >
> > Have a look at tests/misc/
> > cleanup method so that if a test fails, you don't have non-closed windows to
> > worry about. It will mean you can remove "kill" statements from the start of
> > test-cases. Call the cleanup method in the teardown, it's
> >
> No, this kill statements are not for cleaning the residues of the test case.
> Instead it is a prerequisite. If there are more than one window then pip image
> is different than when there is only one window. So we need to ensure there is
> no running windows of the test application.
Ok, in which case, it should be part of "setup" - or maybe "startup" and then being sure that "teardown" closes all windows created during tests.
> > @number_
> >
> If I remove that @ I got this error
> .update_
> `number_
Oh you use it in the shutdown, I missed that. Apologies.
> > + width = %x{xrandr --current | grep \'\*+\' | uniq | awk \'{print $1}\' |
> cut
> > -d \'x\' -f1}
> > It would be great if you added this to the XDoTool Ruby bindings for
> everyone
> > to use. Parsing the output with Ruby would probably be quicker?? :)
> >
> This is part of multi-monitor stuff, which is totally removed from this MR
> already
Ok.
> I have removed 'puts'. I thought they would inform what the test case is doing
> while we are waiting for them to finish. Unfortunately they did serve the
> purpose it seems;)
I don't care what test is happening, until it fails, in which case the error tells you what test failed. These comments are nice, but will litter log files, so I prefer to not have them.
- 855. By Lohith D Shivamurthy
-
[launcher] moved the cleanup and setup code to corresponding functiions
- 856. By Lohith D Shivamurthy
-
[launcher] split test cases into smalled pieces
- 857. By Lohith D Shivamurthy
-
[launcher] Refined the method open_window.
Gerry Boland (gerboland) wrote : | # |
Since we're reviewing a MR for this exact feature to go into shell, this MR is obselete, no?
Gerry Boland (gerboland) wrote : | # |
This has been merged into shell, so I consider this branch obselete and thus rejecting.
Works well in shell tho, nice work.
Unmerged revisions
- 857. By Lohith D Shivamurthy
-
[launcher] Refined the method open_window.
- 856. By Lohith D Shivamurthy
-
[launcher] split test cases into smalled pieces
- 855. By Lohith D Shivamurthy
-
[launcher] moved the cleanup and setup code to corresponding functiions
- 854. By Lohith D Shivamurthy
-
[launcher] Included few review comments
- 853. By Lohith D Shivamurthy
-
[launcher] Refined objectName for pips
- 852. By Lohith D Shivamurthy
-
[launcher] Part to changes to update pips to indicate apps on different screen is removed.
- 851. By Lohith D Shivamurthy
-
[launcher] Added tests to verify windows on different screen. Using verfy_equal instead of asserts
- 850. By Lohith D Shivamurthy
-
[launcher] Tests added
- 849. By Lohith D Shivamurthy
-
[launcher] update pips to indicate whether the application windows belongs to current workspace/screen or not
Preview Diff
1 | === modified file 'launcher/LauncherItem.qml' |
2 | --- launcher/LauncherItem.qml 2011-12-21 09:52:15 +0000 |
3 | +++ launcher/LauncherItem.qml 2012-01-23 06:35:28 +0000 |
4 | @@ -156,7 +156,7 @@ |
5 | Repeater { |
6 | model: item.pips |
7 | delegate: Image { |
8 | - objectName: "pips" |
9 | + objectName: "pips-" + index |
10 | /* FIXME: It seems that when the image is created (or re-used) by the Repeater |
11 | for a moment it doesn't have any parent, and therefore warnings are |
12 | printed for the following two anchor assignements. This fixes the |
13 | |
14 | === modified file 'launcher/LauncherList.qml' |
15 | --- launcher/LauncherList.qml 2011-12-21 09:52:15 +0000 |
16 | +++ launcher/LauncherList.qml 2012-01-23 06:35:28 +0000 |
17 | @@ -89,6 +89,16 @@ |
18 | } |
19 | } |
20 | |
21 | + function updatePipSource() { |
22 | + if (item.belongsToDifferentWorkspace()) { |
23 | + launcherItem.pips = 1 |
24 | + launcherItem.pipSource = "artwork/launcher_arrow_outline_ltr.png"; |
25 | + } else { |
26 | + launcherItem.pips = Math.min(item.windowCount, 3) |
27 | + launcherItem.pipSource = ("artwork/launcher_" + ((pips <= 1) ? "arrow" : "pip") + "_ltr.png") |
28 | + } |
29 | + } |
30 | + |
31 | Accessible.name: accessibleDescription() |
32 | name: item.name |
33 | |
34 | @@ -103,6 +113,7 @@ |
35 | urgent: item.urgent |
36 | launching: item.launching |
37 | pips: Math.min(item.windowCount, 3) |
38 | + pipSource: updatePipSource() |
39 | |
40 | counter: item.counter |
41 | counterVisible: item.counterVisible |
42 | @@ -286,6 +297,9 @@ |
43 | Connections { |
44 | target: item |
45 | onWindowAdded: item.setIconGeometry(x + panel.x, y + panel.y, width, height, xid) |
46 | + onWindowCountChanged: updatePipSource() |
47 | + onWindowWorkspaceChanged: updatePipSource() |
48 | + |
49 | /* Not all items are applications. */ |
50 | ignoreUnknownSignals: true |
51 | } |
52 | @@ -328,5 +342,10 @@ |
53 | } |
54 | } |
55 | } |
56 | + |
57 | + Connections { |
58 | + target: declarativeView |
59 | + onActiveWorkspaceChanged: updatePipSource() |
60 | + } |
61 | } |
62 | } |
63 | |
64 | === added file 'launcher/artwork/launcher_arrow_outline_ltr.png' |
65 | Binary files launcher/artwork/launcher_arrow_outline_ltr.png 1970-01-01 00:00:00 +0000 and launcher/artwork/launcher_arrow_outline_ltr.png 2012-01-23 06:35:28 +0000 differ |
66 | === modified file 'libunity-2d-private/src/launcherapplication.cpp' |
67 | --- libunity-2d-private/src/launcherapplication.cpp 2012-01-18 11:50:32 +0000 |
68 | +++ libunity-2d-private/src/launcherapplication.cpp 2012-01-23 06:35:28 +0000 |
69 | @@ -501,6 +501,8 @@ |
70 | for (int i = 0; i < size; ++i) { |
71 | WnckWindow* window = wnck_window_get(xids->at(i)); |
72 | wnck_window_set_icon_geometry(window, x, y, width, height); |
73 | + g_signal_connect(G_OBJECT(window), "workspace-changed", |
74 | + G_CALLBACK(LauncherApplication::windowWorkspaceChangedCB), this); |
75 | } |
76 | } |
77 | |
78 | @@ -599,6 +601,11 @@ |
79 | LauncherApplication::windowCountOnCurrentWorkspace() |
80 | { |
81 | int windowCount = 0; |
82 | + |
83 | + if (!m_application) { |
84 | + return windowCount; |
85 | + } |
86 | + |
87 | WnckWorkspace *current = wnck_screen_get_active_workspace(wnck_screen_get_default()); |
88 | |
89 | QScopedPointer<BamfWindowList> windows(m_application->windows()); |
90 | @@ -937,6 +944,18 @@ |
91 | } |
92 | } |
93 | |
94 | +bool |
95 | +LauncherApplication::belongsToDifferentWorkspace() |
96 | +{ |
97 | + int totalWindows = windowCount(); |
98 | + int windowsInCurrentWorkspace = windowCountOnCurrentWorkspace(); |
99 | + if (totalWindows > 0 && windowsInCurrentWorkspace == 0) { |
100 | + return true; |
101 | + } |
102 | + |
103 | + return false; |
104 | +} |
105 | + |
106 | void |
107 | LauncherApplication::onIndicatorMenuUpdated() |
108 | { |
109 | @@ -1053,4 +1072,17 @@ |
110 | setDynamicQuicklistImporter(newOwner); |
111 | } |
112 | |
113 | +void |
114 | +LauncherApplication::windowWorkspaceChangedCB(WnckWindow *window, gpointer user_data) |
115 | +{ |
116 | + Q_UNUSED(window); |
117 | + ((LauncherApplication*)user_data)->updateWindowWorkspaceChanged(); |
118 | +} |
119 | + |
120 | +void |
121 | +LauncherApplication::updateWindowWorkspaceChanged() |
122 | +{ |
123 | + Q_EMIT windowWorkspaceChanged(); |
124 | +} |
125 | + |
126 | #include "launcherapplication.moc" |
127 | |
128 | === modified file 'libunity-2d-private/src/launcherapplication.h' |
129 | --- libunity-2d-private/src/launcherapplication.h 2012-01-13 15:05:44 +0000 |
130 | +++ libunity-2d-private/src/launcherapplication.h 2012-01-23 06:35:28 +0000 |
131 | @@ -104,6 +104,7 @@ |
132 | Q_INVOKABLE virtual void launchNewInstance(); |
133 | |
134 | Q_INVOKABLE virtual void createMenuActions(); |
135 | + Q_INVOKABLE virtual bool belongsToDifferentWorkspace(); |
136 | |
137 | void updateOverlaysState(const QString& sender, const QMap<QString, QVariant>& properties); |
138 | |
139 | @@ -174,6 +175,9 @@ |
140 | bool updateOverlayState(const QMap<QString, QVariant>& properties, |
141 | const QString& propertyName, T* member); |
142 | |
143 | + static void windowWorkspaceChangedCB(WnckWindow *window, gpointer user_data); |
144 | + void updateWindowWorkspaceChanged(); |
145 | + |
146 | QString m_dynamicQuicklistPath; |
147 | QScopedPointer<DBusMenuImporter> m_dynamicQuicklistImporter; |
148 | QDBusServiceWatcher* m_dynamicQuicklistServiceWatcher; |
149 | |
150 | === modified file 'libunity-2d-private/src/launcheritem.cpp' |
151 | --- libunity-2d-private/src/launcheritem.cpp 2011-07-29 13:49:34 +0000 |
152 | +++ libunity-2d-private/src/launcheritem.cpp 2012-01-23 06:35:28 +0000 |
153 | @@ -87,6 +87,12 @@ |
154 | } |
155 | |
156 | bool |
157 | +LauncherItem::belongsToDifferentWorkspace() |
158 | +{ |
159 | + return false; |
160 | +} |
161 | + |
162 | +bool |
163 | LauncherItem::progressBarVisible() const |
164 | { |
165 | return false; |
166 | |
167 | === modified file 'libunity-2d-private/src/launcheritem.h' |
168 | --- libunity-2d-private/src/launcheritem.h 2011-07-29 13:49:34 +0000 |
169 | +++ libunity-2d-private/src/launcheritem.h 2012-01-23 06:35:28 +0000 |
170 | @@ -79,6 +79,7 @@ |
171 | Q_INVOKABLE virtual void activate() = 0; |
172 | Q_INVOKABLE virtual void createMenuActions() = 0; |
173 | Q_INVOKABLE virtual void launchNewInstance(); |
174 | + Q_INVOKABLE virtual bool belongsToDifferentWorkspace(); |
175 | |
176 | protected: |
177 | LauncherContextualMenu* m_menu; |
178 | @@ -100,6 +101,7 @@ |
179 | void counterChanged(int); |
180 | void emblemVisibleChanged(bool); |
181 | void emblemChanged(QString); |
182 | + void windowWorkspaceChanged(); |
183 | |
184 | public Q_SLOTS: |
185 | /* Default implementation of drag’n’drop handling, should be overridden in |
186 | |
187 | === modified file 'libunity-2d-private/src/unity2ddeclarativeview.cpp' |
188 | --- libunity-2d-private/src/unity2ddeclarativeview.cpp 2011-12-08 19:41:38 +0000 |
189 | +++ libunity-2d-private/src/unity2ddeclarativeview.cpp 2012-01-23 06:35:28 +0000 |
190 | @@ -263,6 +263,7 @@ |
191 | void Unity2DDeclarativeView::onActiveWorkspaceChanged() |
192 | { |
193 | m_last_focused_window = None; |
194 | + Q_EMIT activeWorkspaceChanged(); |
195 | } |
196 | |
197 | #include <unity2ddeclarativeview.moc> |
198 | |
199 | === modified file 'libunity-2d-private/src/unity2ddeclarativeview.h' |
200 | --- libunity-2d-private/src/unity2ddeclarativeview.h 2011-12-08 19:41:38 +0000 |
201 | +++ libunity-2d-private/src/unity2ddeclarativeview.h 2012-01-23 06:35:28 +0000 |
202 | @@ -44,6 +44,7 @@ |
203 | void useOpenGLChanged(bool); |
204 | void transparentBackgroundChanged(bool); |
205 | void globalPositionChanged(QPoint); |
206 | + void activeWorkspaceChanged(); |
207 | |
208 | protected: |
209 | void setupViewport(); |
210 | |
211 | === added file 'tests/launcher/update_pips_tests.rb' |
212 | --- tests/launcher/update_pips_tests.rb 1970-01-01 00:00:00 +0000 |
213 | +++ tests/launcher/update_pips_tests.rb 2012-01-23 06:35:28 +0000 |
214 | @@ -0,0 +1,291 @@ |
215 | +#!/usr/bin/env ruby1.8 |
216 | +=begin |
217 | +/* |
218 | + * This file is part of unity-2d |
219 | + * |
220 | + * Copyright 2011 Canonical Ltd. |
221 | + * |
222 | + * Authors: |
223 | + * - Lohith DS <lohith.shivamurthy@canonical.com> |
224 | + * |
225 | + * This program is free software; you can redistribute it and/or modify |
226 | + * it under the terms of the GNU General Public License as published by |
227 | + * the Free Software Foundation; version 3. |
228 | + * |
229 | + * This program is distributed in the hope that it will be useful, |
230 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
231 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
232 | + * GNU General Public License for more details. |
233 | + * |
234 | + * You should have received a copy of the GNU General Public License |
235 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
236 | + */ |
237 | +=end |
238 | + |
239 | +require '../run-tests.rb' unless $INIT_COMPLETED |
240 | +require 'xdo/xwindow' |
241 | +require 'xdo/keyboard' |
242 | +require 'xdo/mouse' |
243 | +require 'timeout' |
244 | +require 'tmpdir' |
245 | + |
246 | +def open_window() |
247 | + window_id = -1 |
248 | + o = [('a'..'z'),('A'..'Z')].map{|i| i.to_a}.flatten; |
249 | + title_string = (0..50).map{ o[rand(o.length)] }.join; |
250 | + if (@@title_string.empty?) |
251 | + @@title_string = title_string |
252 | + end |
253 | + title_string = title_string |
254 | + puts (title_string) |
255 | + # Open xman with random title |
256 | + system "xman -title #{title_string} &" |
257 | + Timeout.timeout(30){ window_id = XDo::XWindow.wait_for_window(title_string)} |
258 | + Kernel.raise(SystemCallError, "Unable to open xman") if window_id == -1 |
259 | + return XDo::XWindow.new(window_id) |
260 | +end |
261 | + |
262 | +def change_window_workspace(xid) |
263 | + new_workspace = 0 |
264 | + if xid.desktop > 0 |
265 | + new_workspace=0 |
266 | + else |
267 | + new_workspace=1 |
268 | + end |
269 | + |
270 | + xid.desktop=new_workspace |
271 | + verify_true(10, 'Change window workspace failed') { |
272 | + xid.desktop==new_workspace |
273 | + } |
274 | +end |
275 | + |
276 | +def reset_current_workspace |
277 | + XDo::XWindow.desktop=@@current_workspace |
278 | + verify_true(10, 'Reset active workspace failed') { |
279 | + XDo::XWindow.desktop==@@current_workspace |
280 | + } |
281 | +end |
282 | + |
283 | +############################# Test Suite ############################# |
284 | +context "Launcher pips tests" do |
285 | + # Run once at the beginning of this test suite |
286 | + startup do |
287 | + system 'killall unity-2d-launcher > /dev/null 2>&1' |
288 | + system 'killall unity-2d-launcher > /dev/null 2>&1' |
289 | + |
290 | + # Minimize all windows |
291 | + XDo::XWindow.toggle_minimize_all |
292 | + |
293 | + @number_of_workspaces = XDo::XWindow.desktop_num |
294 | + @reset_num_workspaces = false |
295 | + if @number_of_workspaces < 2 |
296 | + puts ("Setting number of workspaces to minimum(two) to enable the test suite") |
297 | + XDo::XWindow.desktop_num = 2 |
298 | + @reset_num_workspaces = true |
299 | + end |
300 | + |
301 | + system 'killall xman > /dev/null 2>&1' |
302 | + @@current_workspace = XDo::XWindow.desktop |
303 | + @@title_string = "" |
304 | + @@xid_list=Array.new |
305 | + |
306 | + end |
307 | + |
308 | + # Run once at the end of this test suite |
309 | + shutdown do |
310 | + if @reset_num_workspaces == true |
311 | + puts ("\nResetting number of workspaces to " + @number_of_workspaces.to_s ) |
312 | + XDo::XWindow.desktop_num=@number_of_workspaces |
313 | + end |
314 | + @@xid_list.each { |
315 | + |xid| |
316 | + if (xid.exists?) |
317 | + xid.close! |
318 | + end |
319 | + } |
320 | + end |
321 | + |
322 | + # Run before each test case begins |
323 | + setup do |
324 | + #Ensure mouse out of the way |
325 | + |
326 | + # Execute the application |
327 | + @sut = TDriver.sut(:Id => "sut_qt") |
328 | + @app = @sut.run( :name => UNITY_2D_LAUNCHER, |
329 | + :arguments => "-testability", |
330 | + :sleeptime => 2 ) |
331 | + # Make certain application is ready for testing |
332 | + verify(10){ @app.Unity2dPanel() } |
333 | + |
334 | + end |
335 | + |
336 | + # Run after each test case completes |
337 | + teardown do |
338 | + reset_current_workspace |
339 | + #@app.close |
340 | + #Need to kill Launcher as it does not shutdown when politely asked |
341 | + system "pkill -nf unity-2d-launcher" |
342 | + end |
343 | + |
344 | + ##################################################################################### |
345 | + # Test cases |
346 | + |
347 | + # Test case objectives: |
348 | + # * Check pips are updated properly when the app is in current workspace |
349 | + # * |
350 | + # Pre-conditions |
351 | + # * This test case assumes that the test app will have only one window |
352 | + # * For eg, xman is choosen |
353 | + # * To ensure there is calculator windows running, kill all the calculator windows if any |
354 | + # * |
355 | + # Test steps |
356 | + # * Open a calculator window |
357 | + # * Verify the launcher tile pip image matches with the expected one |
358 | + # * |
359 | + # Post-conditions |
360 | + # * Reset the current workspace to initial workspace |
361 | + # * |
362 | + # References |
363 | + # * lp:#883172 |
364 | + # * |
365 | + |
366 | + test "Update launcher pips to indicate a window in current workspace" do |
367 | + xid = open_window() |
368 | + @@xid_list << xid |
369 | + |
370 | + expected_pip_image = 'image://blended/artwork/launcher_arrow_ltr.pngcolor=lightgreyalpha=1' |
371 | + |
372 | + verify_equal(expected_pip_image, 10, 'pip not matching with launcher_arrow_ltr.png'){ |
373 | + @app.Unity2dPanel() \ |
374 | + .LauncherList( :name => 'main' ) \ |
375 | + .QDeclarativeItem( :name => @@title_string ) \ |
376 | + .QDeclarativeImage( :name => 'pips-0')['source'] |
377 | + } |
378 | + end |
379 | + |
380 | + # Test case objectives: |
381 | + # * Check pips are updated properly when the app is moved to different workspace |
382 | + # * |
383 | + # Pre-conditions |
384 | + # * The same window created in above test-case is re-used |
385 | + # * |
386 | + # Test steps |
387 | + # * Move the window to a differnt workspace |
388 | + # * Verify the launcher tile pip image matches with the expected one |
389 | + # * |
390 | + # Post-conditions |
391 | + # * Reset the current workspace to initial workspace |
392 | + # * |
393 | + # References |
394 | + # * lp:#883172 |
395 | + # * |
396 | + test "Update launcher pips to indicate an app that belongs to different workspace" do |
397 | + xid = @@xid_list[0] |
398 | + |
399 | + change_window_workspace(xid) |
400 | + |
401 | + expected_pip_image = 'image://blended/artwork/launcher_arrow_outline_ltr.pngcolor=lightgreyalpha=1' |
402 | + |
403 | + verify_equal(expected_pip_image, 10, 'pip not matching with launcher_arrow_outline_ltr.png'){ |
404 | + @app.Unity2dPanel() \ |
405 | + .LauncherList( :name => 'main' ) \ |
406 | + .QDeclarativeItem( :name => @@title_string ) \ |
407 | + .QDeclarativeImage( :name => 'pips-0')['source'] |
408 | + } |
409 | + end |
410 | + |
411 | + # Test case objectives: |
412 | + # * Check pips are updated properly with app with more than one window |
413 | + # * |
414 | + # Pre-conditions |
415 | + # * The same window created in first test case is re-used |
416 | + # * |
417 | + # Test steps |
418 | + # * Open another window alogn with first window from the testcase one. |
419 | + # * Verify the launcher tile pip images matches with the expected one |
420 | + # * |
421 | + # Post-conditions |
422 | + # * Reset the current workspace to initial workspace |
423 | + # * |
424 | + # References |
425 | + # * lp:#883172 |
426 | + # * |
427 | + |
428 | + test "Update launcher pips to indicate an app with two windows on two different workspaces" do |
429 | + xid = open_window() |
430 | + @@xid_list << xid |
431 | + |
432 | + expected_pip_image = 'image://blended/artwork/launcher_pip_ltr.pngcolor=lightgreyalpha=1' |
433 | + |
434 | + verify_equal(expected_pip_image, 10, 'Pip not matching expected image launcher_pip_ltr.png'){ |
435 | + @app.Unity2dPanel() \ |
436 | + .LauncherList( :name => 'main' ) \ |
437 | + .QDeclarativeItem( :name => @@title_string ) \ |
438 | + .QDeclarativeImage( :name => 'pips-0')['source'] |
439 | + } |
440 | + end |
441 | + |
442 | + # Test case objectives: |
443 | + # * Check pips are updated properly when the app is moved to another workspace |
444 | + # * |
445 | + # Pre-conditions |
446 | + # * The same windows created above are re-used |
447 | + # * |
448 | + # Test steps |
449 | + # * Move the second window too to a differnt workspace |
450 | + # * Verify the launcher tile pip image matches with the expected one |
451 | + # * |
452 | + # Post-conditions |
453 | + # * Reset the current workspace to initial workspace |
454 | + # * |
455 | + # References |
456 | + # * lp:#883172 |
457 | + # * |
458 | + test "Update launcher pips to indicate an app completely belonging to different workspace." do |
459 | + xid1= @@xid_list[1] |
460 | + |
461 | + change_window_workspace(xid1) |
462 | + |
463 | + expected_pip_image = 'image://blended/artwork/launcher_arrow_outline_ltr.pngcolor=lightgreyalpha=1' |
464 | + |
465 | + verify_equal(expected_pip_image, 10, 'pip not matching expected image launcher_arrow_outline_ltr.png'){ |
466 | + @app.Unity2dPanel() \ |
467 | + .LauncherList( :name => 'main' ) \ |
468 | + .QDeclarativeItem( :name => @@title_string ) \ |
469 | + .QDeclarativeImage( :name => 'pips-0')['source'] |
470 | + } |
471 | + end |
472 | + |
473 | + # Test case objectives: |
474 | + # * Check pips are updated properly when the app is moved to another workspace |
475 | + # * |
476 | + # Pre-conditions |
477 | + # * The same windows created above are resued. |
478 | + # * |
479 | + # Test steps |
480 | + # * Close one of the app window and move the last window back to its original workspace |
481 | + # * Verify the launcher tile pip image matches with the expected one |
482 | + # * |
483 | + # Post-conditions |
484 | + # * Reset the current workspace to initial workspace |
485 | + # * |
486 | + # References |
487 | + # * lp:#883172 |
488 | + # * |
489 | + test "Update launcher pips to indicate when a app window is closed." do |
490 | + xid0 = @@xid_list[0] |
491 | + xid1 = @@xid_list[1] |
492 | + |
493 | + xid1.close! |
494 | + change_window_workspace(xid0) |
495 | + |
496 | + expected_pip_image = 'image://blended/artwork/launcher_arrow_outline_ltr.pngcolor=lightgreyalpha=1' |
497 | + |
498 | + verify_equal(expected_pip_image, 10, 'pip not matching expected image launcher_arrow_outline_ltr.png'){ |
499 | + @app.Unity2dPanel() \ |
500 | + .LauncherList( :name => 'main' ) \ |
501 | + .QDeclarativeItem( :name => @@title_string ) \ |
502 | + .QDeclarativeImage( :name => 'pips-0')['source'] |
503 | + } |
504 | + end |
505 | +end |
You have some Multi-monitor specific code in this that isn't really quite necessary just now. Just target this MR to indicating if applications are on the current workspace (i.e. visible on all monitors) or not.