Merge lp:~saviq/unity-2d/test_launcher-menu-focus into lp:unity-2d
- test_launcher-menu-focus
- Merge into trunk
Status: | Merged |
---|---|
Approved by: | Albert Astals Cid |
Approved revision: | 885 |
Merged at revision: | 957 |
Proposed branch: | lp:~saviq/unity-2d/test_launcher-menu-focus |
Merge into: | lp:unity-2d |
Diff against target: |
278 lines (+274/-0) 1 file modified
tests/launcher/menu_tests.rb (+274/-0) |
To merge this branch: | bzr merge lp:~saviq/unity-2d/test_launcher-menu-focus |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Albert Astals Cid (community) | Approve | ||
Gerry Boland (community) | Needs Fixing | ||
Michał Sawicz | Abstain | ||
Review via email: mp+90685@code.launchpad.net |
Commit message
Description of the change
[tests] add launcher contextual menu tests
Albert Astals Cid (aacid) wrote : | # |
Albert Astals Cid (aacid) wrote : | # |
Also maybe for the
verify_equal( "true", 0, 'Launcher item didn\'t regain focus' ) {
it'd make sense to have TIMEOUT
Michał Sawicz (saviq) wrote : | # |
> It's a bit confusing when you say
> "Check that there's only one action"
> and then do
> verify_equal( 2, 0, 'There was an unexpected number of actions in the menu'
> ) {
> actions.count
> }
> The same for the others you say very there's 2 and check against >= 4
Problem is that's actually what we have - check for yourself with tdriver - we have ~2*action_count of QActions. I could maybe check only for those that are active. Let me investigate.
Albert Astals Cid (aacid) wrote : | # |
Well, the separators are counted as actions and also the titles, i'm not saying the test code is wrong, just that the text is a bit confusing, maybe you could add "Check that there's two action, quit and separator" or something like that
- 880. By Michał Sawicz
-
[tests] modify test description to note the "ghost" QActions in the contextual menu
Michał Sawicz (saviq) wrote : | # |
Comments fixed.
Michał Sawicz (saviq) wrote : | # |
Wait for it, I'll have another test here.
- 881. By Michał Sawicz
-
[tests] add test to verify launcher menu -> dash focus change
Plus indentation fixes.
- 882. By Michał Sawicz
-
[test] also kill unity-2d-places for menu tests
Michał Sawicz (saviq) wrote : | # |
Ready for review.
Gerry Boland (gerboland) wrote : | # |
Hey I never noticed this in the queue.
Can you update this please to use "shell"? If you don't have time, just say & someone can take it.
- 883. By Michał Sawicz
-
Merge trunk
- 884. By Michał Sawicz
-
[tests/launcher] adapt for current trunk
Michał Sawicz (saviq) wrote : | # |
Dnia 2012-02-27, pon o godzinie 14:49 +0000, Gerry Boland pisze:
> Can you update this please to use "shell"? If you don't have time,
> just say & someone can take it.
Updated.
--
Michał Sawicz <email address hidden>
Canonical Services Ltd.
Gerry Boland (gerboland) wrote : | # |
You are using verify_* statements with zero timeout frequently. Please replace the 0 with TIMEOUT, to add timing forgiveness in case software running slowly. Helps reduce false negatives
Also, please have the mouse cursor position reset to a position away from the launcher after each test.
Michał Sawicz (saviq) wrote : | # |
Updated.
- 885. By Michał Sawicz
-
[tests] fix timeouts and some cleanup in launcher/
menu_tests. rb
Albert Astals Cid (aacid) wrote : | # |
Looks, good to me tests, pass and seems Gerry concerns were fixed too :-)
Preview Diff
1 | === added file 'tests/launcher/menu_tests.rb' |
2 | --- tests/launcher/menu_tests.rb 1970-01-01 00:00:00 +0000 |
3 | +++ tests/launcher/menu_tests.rb 2012-03-06 10:43:18 +0000 |
4 | @@ -0,0 +1,274 @@ |
5 | +#!/usr/bin/env ruby1.8 |
6 | +=begin |
7 | +/* |
8 | + * This file is part of unity-2d |
9 | + * |
10 | + * Copyright 2012 Canonical Ltd. |
11 | + * |
12 | + * Authors: |
13 | + * - Michał Sawicz <michal.sawicz@canonical.com> |
14 | + * |
15 | + * This program is free software; you can redistribute it and/or modify |
16 | + * it under the terms of the GNU General Public License as published by |
17 | + * the Free Software Foundation; version 3. |
18 | + * |
19 | + * This program is distributed in the hope that it will be useful, |
20 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
21 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
22 | + * GNU General Public License for more details. |
23 | + * |
24 | + * You should have received a copy of the GNU General Public License |
25 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
26 | + */ |
27 | +=end |
28 | + |
29 | +require '../run-tests.rb' unless $INIT_COMPLETED |
30 | +require 'xdo/xwindow' |
31 | +require 'xdo/keyboard' |
32 | +require 'xdo/mouse' |
33 | +require 'tmpwindow' |
34 | + |
35 | +############################# Test Suite ############################# |
36 | +context "Launcher Contextual Menu Tests" do |
37 | + # Run once at the beginning of this test suite |
38 | + startup do |
39 | + $SUT.execute_shell_command 'killall unity-2d-shell' |
40 | + $SUT.execute_shell_command 'killall unity-2d-shell' |
41 | + |
42 | + # Minimize all windows |
43 | + XDo::XWindow.toggle_minimize_all |
44 | + end |
45 | + |
46 | + # Run once at the end of this test suite |
47 | + shutdown do |
48 | + end |
49 | + |
50 | + # Run before each test case begins |
51 | + setup do |
52 | + # Ensure mouse out of the way |
53 | + XDo::Mouse.move(200,200,10,true) |
54 | + |
55 | + # Execute the application |
56 | + @app = $SUT.run( :name => UNITY_2D_SHELL, |
57 | + :arguments => "-testability", |
58 | + :sleeptime => 2) |
59 | + # Make certain application is ready for testing |
60 | + verify{ @app.Launcher() } |
61 | + end |
62 | + |
63 | + # Run after each test case completes |
64 | + teardown do |
65 | + #@app.close |
66 | + #@app.close |
67 | + #Need to kill Shell as it does not shutdown when politely asked |
68 | + $SUT.execute_shell_command 'pkill -nf unity-2d-shell' |
69 | + end |
70 | + |
71 | + ##################################################################################### |
72 | + # Test cases |
73 | + |
74 | + # Test case objectives: |
75 | + # * Check that the hint is displayed on mouse hover |
76 | + # Pre-conditions |
77 | + # * Desktop with no running applications |
78 | + # Test steps |
79 | + # * Hover the cursor over the first application entry |
80 | + # * Check that the hint is displayed |
81 | + # * Check that there are two QActions (there is a "ghost" QAction there) |
82 | + # Post-conditions |
83 | + # * None |
84 | + # References |
85 | + # * None |
86 | + test "Display launcher item hint" do |
87 | + tiles = "" |
88 | + verify( TIMEOUT, 'Could not find any application tile' ) { |
89 | + tiles = @app.LauncherList( :name => 'main' ).children( { :desktopFile => /^.*.desktop$/ } ) |
90 | + } |
91 | + tile = tiles[0] |
92 | + tile.move_mouse() |
93 | + verify(TIMEOUT, 'The launcher item hint is not visible' ) { |
94 | + @app.LauncherContextualMenu() |
95 | + } |
96 | + actions = "" |
97 | + verify( TIMEOUT, 'Could not find any actions in the menu' ) { |
98 | + actions = @app.LauncherContextualMenu().children( { :type => "QAction" } ) |
99 | + } |
100 | + verify_equal( 2, TIMEOUT, 'There was an unexpected number of actions in the menu' ) { |
101 | + actions.count |
102 | + } |
103 | + end |
104 | + |
105 | + # Test case objectives: |
106 | + # * Check that the menu is displayed on right click |
107 | + # Pre-conditions |
108 | + # * Desktop with no running applications |
109 | + # Test steps |
110 | + # * Right click the first application entry |
111 | + # * Check that the menu is displayed |
112 | + # * Check that there are at least four QActions (two actions and separator, plus a "ghost" one) |
113 | + # Post-conditions |
114 | + # * None |
115 | + # References |
116 | + # * None |
117 | + test "Display launcher menu after right click" do |
118 | + tiles = "" |
119 | + verify( TIMEOUT, 'Could not find any application tile' ) { |
120 | + tiles = @app.LauncherList( :name => 'main' ).children( { :desktopFile => /^.*.desktop$/ } ) |
121 | + } |
122 | + tile = tiles[0] |
123 | + tile.move_mouse() |
124 | + tile.tap(1, :Right) |
125 | + verify(TIMEOUT, 'The launcher menu is not visible' ) { |
126 | + @app.LauncherContextualMenu() |
127 | + } |
128 | + actions = "" |
129 | + verify( TIMEOUT, 'Could not find any actions in the menu' ) { |
130 | + actions = @app.LauncherContextualMenu().children( { :type => "QAction" } ) |
131 | + } |
132 | + verify_true( TIMEOUT, 'There was not enough actions in the menu' ) { |
133 | + actions.count >= 4 |
134 | + } |
135 | + end |
136 | + |
137 | + # Test case objectives: |
138 | + # * Check that the menu is displayed on right key from item |
139 | + # Pre-conditions |
140 | + # * Desktop with no running applications |
141 | + # Test steps |
142 | + # * Focus the launcher, go down and right |
143 | + # * Check that the menu is displayed |
144 | + # * Check that there are at least four QActions (two actions and separator, plus a "ghost" one) |
145 | + # Post-conditions |
146 | + # * None |
147 | + # References |
148 | + # * None |
149 | + test "Display launcher menu with keyboard navigation" do |
150 | + XDo::Keyboard.alt_F1 |
151 | + XDo::Keyboard.down |
152 | + XDo::Keyboard.right |
153 | + verify(TIMEOUT, 'The launcher menu is not visible' ) { |
154 | + @app.LauncherContextualMenu() |
155 | + } |
156 | + actions = "" |
157 | + verify( TIMEOUT, 'Could not find any actions in the menu' ) { |
158 | + actions = @app.LauncherContextualMenu().children( { :type => "QAction" } ) |
159 | + } |
160 | + verify_true( TIMEOUT, 'There was not enough actions in the menu' ) { |
161 | + actions.count >= 4 |
162 | + } |
163 | + end |
164 | + |
165 | + # Test case objectives: |
166 | + # * Check that the menu is being closed on Esc |
167 | + # Pre-conditions |
168 | + # * Desktop with no running applications |
169 | + # Test steps |
170 | + # * Focus the launcher, go down and right, press Esc |
171 | + # * Check that the menu is no longer there |
172 | + # Post-conditions |
173 | + # * None |
174 | + # References |
175 | + # * None |
176 | + test "Close launcher menu when pressing Esc" do |
177 | + XDo::Keyboard.alt_F1 |
178 | + XDo::Keyboard.down |
179 | + XDo::Keyboard.right |
180 | + XDo::Keyboard.escape |
181 | + verify_not(TIMEOUT, 'The launcher menu is not visible' ) { |
182 | + @app.LauncherContextualMenu() |
183 | + } |
184 | + end |
185 | + |
186 | + # Test case objectives: |
187 | + # * Check that the menu is being closed on left key |
188 | + # Pre-conditions |
189 | + # * Desktop with no running applications |
190 | + # Test steps |
191 | + # * Focus the launcher, go down and right, then left |
192 | + # * Check that the menu is no longer there |
193 | + # Post-conditions |
194 | + # * None |
195 | + # References |
196 | + # * None |
197 | + test "Close launcher menu when navigating back to the launcher" do |
198 | + XDo::Keyboard.alt_F1 |
199 | + XDo::Keyboard.down |
200 | + XDo::Keyboard.right |
201 | + XDo::Keyboard.left |
202 | + verify_not(TIMEOUT, 'The launcher menu is not visible' ) { |
203 | + @app.LauncherContextualMenu() |
204 | + } |
205 | + end |
206 | + |
207 | + # Test case objectives: |
208 | + # * Check that the focus goes back to the launcher item when menu was dismissed with Esc |
209 | + # Pre-conditions |
210 | + # * Desktop with no running applications |
211 | + # Test steps |
212 | + # * Focus the launcher, go down and right, press Esc |
213 | + # * Check that the launcher item has focus |
214 | + # Post-conditions |
215 | + # * None |
216 | + # References |
217 | + # * None |
218 | + test "Verify launcher tile gets focus after dismissing the menu with Esc" do |
219 | + XDo::Keyboard.alt_F1 |
220 | + XDo::Keyboard.down |
221 | + XDo::Keyboard.right |
222 | + XDo::Keyboard.escape |
223 | + tiles = "" |
224 | + verify( TIMEOUT, 'Could not find any application tile' ) { |
225 | + tiles = @app.LauncherList( :name => 'main' ).children( { :desktopFile => /^.*.desktop$/ } ) |
226 | + } |
227 | + tile = tiles[0] |
228 | + verify_equal( "true", TIMEOUT, 'Launcher item didn\'t regain focus' ) { |
229 | + tile['activeFocus'] |
230 | + } |
231 | + end |
232 | + |
233 | + # Test case objectives: |
234 | + # * Check that the focus goes back to the launcher item when menu was dismissed with keyboard navigation |
235 | + # Pre-conditions |
236 | + # * Desktop with no running applications |
237 | + # Test steps |
238 | + # * Focus the launcher, go down and right, press Esc |
239 | + # * Check that the launcher item has focus |
240 | + # Post-conditions |
241 | + # * None |
242 | + # References |
243 | + # * None |
244 | + test "Verify launcher tile gets focus after dismissing the menu with keyboard navigation" do |
245 | + XDo::Keyboard.alt_F1 |
246 | + XDo::Keyboard.down |
247 | + XDo::Keyboard.right |
248 | + XDo::Keyboard.left |
249 | + tiles = "" |
250 | + verify( TIMEOUT, 'Could not find any application tile' ) { |
251 | + tiles = @app.LauncherList( :name => 'main' ).children( { :desktopFile => /^.*.desktop$/ } ) |
252 | + } |
253 | + tile = tiles[0] |
254 | + verify_equal( "true", TIMEOUT, 'Launcher item didn\'t regain focus' ) { |
255 | + tile['activeFocus'] |
256 | + } |
257 | + end |
258 | + |
259 | + # Test case objectives: |
260 | + # * Check that the focus goes from launcher menu to dash |
261 | + # Pre-conditions |
262 | + # * Desktop with no running applications |
263 | + # Test steps |
264 | + # * Focus the launcher, go right, press Super |
265 | + # * Check that the dash search entry has focus |
266 | + # Post-conditions |
267 | + # * None |
268 | + # References |
269 | + # * None |
270 | + test "Verify dash search entry gets focus after dismissing the menu with Super" do |
271 | + XDo::Keyboard.alt_F1 |
272 | + XDo::Keyboard.right |
273 | + XDo::Keyboard.super |
274 | + verify_equal( "true", TIMEOUT, 'Dash search entry doesn\'t have focus' ) { |
275 | + @app.SearchEntry()['activeFocus'] |
276 | + } |
277 | + end |
278 | +end |
It's a bit confusing when you say
"Check that there's only one action"
and then do
verify_equal( 2, 0, 'There was an unexpected number of actions in the menu' ) {
actions.count
}
The same for the others you say very there's 2 and check against >= 4