~jbicha/unity-2d/fix-launcher-quicklist-naming-lp949636

« back to all changes in this revision

Viewing changes to tests/launcher/menu_tests.rb

Fix right-to-left keyboard navigation in the dash and in the launcher (LP: #886686). Fixes: https://bugs.launchpad.net/bugs/886686. Approved by Albert Astals Cid.

Show diffs side-by-side

added added

removed removed

Lines of Context:
27
27
require 'xdo/keyboard'
28
28
require 'xdo/mouse'
29
29
require 'tmpwindow'
 
30
require $library_path + '/../../launcher/menu_tests_common.rb'
30
31
 
31
32
############################# Test Suite #############################
32
33
context "Launcher Contextual Menu Tests" do
 
34
 
 
35
  def keyboard_tap_right()
 
36
    XDo::Keyboard.right
 
37
  end
 
38
 
 
39
  def keyboard_tap_left()
 
40
    XDo::Keyboard.left
 
41
  end
 
42
 
33
43
  # Run once at the beginning of this test suite
34
44
  startup do
35
45
    $SUT.execute_shell_command 'killall unity-2d-shell'
66
76
 
67
77
  #####################################################################################
68
78
  # Test cases
69
 
 
70
 
  # Test case objectives:
71
 
  #   * Check that the hint is displayed on mouse hover
72
 
  # Pre-conditions
73
 
  #   * Desktop with no running applications
74
 
  # Test steps
75
 
  #   * Hover the cursor over the first application entry
76
 
  #   * Check that the hint is displayed
77
 
  #   * Check that there are two QActions (there is a "ghost" QAction there)
78
 
  # Post-conditions
79
 
  #   * None
80
 
  # References
81
 
  #   * None
82
79
  test "Display launcher item hint" do
83
 
    tiles = ""
84
 
    verify( TIMEOUT, 'Could not find any application tile' ) {
85
 
      tiles = @app.LauncherList( :name => 'main' ).children( { :desktopFile => /^.*.desktop$/ } )
86
 
    }
87
 
    tile = tiles[0]
88
 
    tile.move_mouse()
89
 
    verify(TIMEOUT, 'The launcher item hint is not visible' ) {
90
 
      @app.LauncherContextualMenu()
91
 
    }
92
 
    actions = ""
93
 
    verify( TIMEOUT, 'Could not find any actions in the menu' ) {
94
 
      actions = @app.LauncherContextualMenu().children( { :type => "QAction" } )
95
 
    }
96
 
    verify_equal( 2, TIMEOUT, 'There was an unexpected number of actions in the menu' ) {
97
 
      actions.count
98
 
    }
 
80
    test_display_launcher_item_hint()
99
81
  end
100
82
 
101
 
  # Test case objectives:
102
 
  #   * Check that the menu is displayed on right click
103
 
  # Pre-conditions
104
 
  #   * Desktop with no running applications
105
 
  # Test steps
106
 
  #   * Right click the first application entry
107
 
  #   * Check that the menu is displayed
108
 
  #   * Check that there are at least four QActions (two actions and separator, plus a "ghost" one)
109
 
  # Post-conditions
110
 
  #   * None
111
 
  # References
112
 
  #   * None
113
83
  test "Display launcher menu after right click" do
114
 
    tiles = ""
115
 
    verify( TIMEOUT, 'Could not find any application tile' ) {
116
 
      tiles = @app.LauncherList( :name => 'main' ).children( { :desktopFile => /^.*.desktop$/ } )
117
 
    }
118
 
    tile = tiles[0]
119
 
    tile.move_mouse()
120
 
    tile.tap(1, :Right)
121
 
    verify(TIMEOUT, 'The launcher menu is not visible' ) {
122
 
      @app.LauncherContextualMenu()
123
 
    }
124
 
    actions = ""
125
 
    verify( TIMEOUT, 'Could not find any actions in the menu' ) {
126
 
      actions = @app.LauncherContextualMenu().children( { :type => "QAction" } )
127
 
    }
128
 
    verify_true( TIMEOUT, 'There was not enough actions in the menu' ) {
129
 
      actions.count >= 4
130
 
    }
 
84
    test_display_launcher_menu_after_right_click()
131
85
  end
132
86
 
133
 
  # Test case objectives:
134
 
  #   * Check that the menu is displayed on right key from item
135
 
  # Pre-conditions
136
 
  #   * Desktop with no running applications
137
 
  # Test steps
138
 
  #   * Focus the launcher, go down and right
139
 
  #   * Check that the menu is displayed
140
 
  #   * Check that there are at least four QActions (two actions and separator, plus a "ghost" one)
141
 
  # Post-conditions
142
 
  #   * None
143
 
  # References
144
 
  #   * None
145
87
  test "Display launcher menu with keyboard navigation" do
146
 
    XDo::Keyboard.alt_F1
147
 
    XDo::Keyboard.down
148
 
    XDo::Keyboard.right
149
 
    verify(TIMEOUT, 'The launcher menu is not visible' ) {
150
 
      @app.LauncherContextualMenu()
151
 
    }
152
 
    actions = ""
153
 
    verify( TIMEOUT, 'Could not find any actions in the menu' ) {
154
 
      actions = @app.LauncherContextualMenu().children( { :type => "QAction" } )
155
 
    }
156
 
    verify_true( TIMEOUT, 'There was not enough actions in the menu' ) {
157
 
      actions.count >= 4
158
 
    }
 
88
    test_display_launcher_menu_with_keyboard_navigation()
159
89
  end
160
90
 
161
 
  # Test case objectives:
162
 
  #   * Check that the menu is being closed on Esc
163
 
  # Pre-conditions
164
 
  #   * Desktop with no running applications
165
 
  # Test steps
166
 
  #   * Focus the launcher, go down and right, press Esc
167
 
  #   * Check that the menu is no longer there
168
 
  # Post-conditions
169
 
  #   * None
170
 
  # References
171
 
  #   * None
172
91
  test "Close launcher menu when pressing Esc" do
173
 
    XDo::Keyboard.alt_F1
174
 
    XDo::Keyboard.down
175
 
    XDo::Keyboard.right
176
 
    XDo::Keyboard.escape
177
 
    verify_not(TIMEOUT, 'The launcher menu is not visible' ) {
178
 
      @app.LauncherContextualMenu()
179
 
    }
 
92
    test_close_launcher_menu_when_pressing_esc()
180
93
  end
181
94
 
182
 
  # Test case objectives:
183
 
  #   * Check that the menu is being closed on left key
184
 
  # Pre-conditions
185
 
  #   * Desktop with no running applications
186
 
  # Test steps
187
 
  #   * Focus the launcher, go down and right, then left
188
 
  #   * Check that the menu is no longer there
189
 
  # Post-conditions
190
 
  #   * None
191
 
  # References
192
 
  #   * None
193
95
  test "Close launcher menu when navigating back to the launcher" do
194
 
    XDo::Keyboard.alt_F1
195
 
    XDo::Keyboard.down
196
 
    XDo::Keyboard.right
197
 
    XDo::Keyboard.left
198
 
    verify_not(TIMEOUT, 'The launcher menu is not visible' ) {
199
 
      @app.LauncherContextualMenu()
200
 
    }
 
96
    test_close_launcher_menu_when_navigating_back_to_the_launcher()
201
97
  end
202
98
 
203
 
  # Test case objectives:
204
 
  #   * Check that the focus goes back to the launcher item when menu was dismissed with Esc
205
 
  # Pre-conditions
206
 
  #   * Desktop with no running applications
207
 
  # Test steps
208
 
  #   * Focus the launcher, go down and right, press Esc
209
 
  #   * Check that the launcher item has focus
210
 
  # Post-conditions
211
 
  #   * None
212
 
  # References
213
 
  #   * None
214
99
  test "Verify launcher tile gets focus after dismissing the menu with Esc" do
215
 
    XDo::Keyboard.alt_F1
216
 
    XDo::Keyboard.down
217
 
    XDo::Keyboard.right
218
 
    XDo::Keyboard.escape
219
 
    tiles = ""
220
 
    verify( TIMEOUT, 'Could not find any application tile' ) {
221
 
      tiles = @app.LauncherList( :name => 'main' ).children( { :desktopFile => /^.*.desktop$/ } )
222
 
    }
223
 
    tile = tiles[0]
224
 
    verify_equal( "true", TIMEOUT, 'Launcher item didn\'t regain focus' ) {
225
 
      tile['activeFocus']
226
 
    }
 
100
    test_verify_launcher_tile_gets_focus_after_dismissing_the_menu_with_esc()
227
101
  end
228
102
 
229
 
  # Test case objectives:
230
 
  #   * Check that the focus goes back to the launcher item when menu was dismissed with keyboard navigation
231
 
  # Pre-conditions
232
 
  #   * Desktop with no running applications
233
 
  # Test steps
234
 
  #   * Focus the launcher, go down and right, press Esc
235
 
  #   * Check that the launcher item has focus
236
 
  # Post-conditions
237
 
  #   * None
238
 
  # References
239
 
  #   * None
240
103
  test "Verify launcher tile gets focus after dismissing the menu with keyboard navigation" do
241
 
    XDo::Keyboard.alt_F1
242
 
    XDo::Keyboard.down
243
 
    XDo::Keyboard.right
244
 
    XDo::Keyboard.left
245
 
    tiles = ""
246
 
    verify( TIMEOUT, 'Could not find any application tile' ) {
247
 
      tiles = @app.LauncherList( :name => 'main' ).children( { :desktopFile => /^.*.desktop$/ } )
248
 
    }
249
 
    tile = tiles[0]
250
 
    verify_equal( "true", TIMEOUT, 'Launcher item didn\'t regain focus' ) {
251
 
      tile['activeFocus']
252
 
    }
 
104
    test_verify_launcher_tile_gets_focus_after_dismissing_the_menu_with_keyboard_navigation()
253
105
  end
254
106
 
255
 
  # Test case objectives:
256
 
  #   * Check that the focus goes from launcher menu to dash
257
 
  # Pre-conditions
258
 
  #   * Desktop with no running applications
259
 
  # Test steps
260
 
  #   * Focus the launcher, go right, press Super
261
 
  #   * Check that the dash search entry has focus
262
 
  # Post-conditions
263
 
  #   * None
264
 
  # References
265
 
  #   * None
266
107
  test "Verify dash search entry gets focus after dismissing the menu with Super" do
267
 
    XDo::Keyboard.alt_F1
268
 
    XDo::Keyboard.right
269
 
    XDo::Keyboard.super
270
 
    verify_equal( "true", TIMEOUT, 'Dash search entry doesn\'t have focus' ) {
271
 
      @app.SearchEntry()['activeFocus']
272
 
    }
 
108
    test_verify_dash_search_entry_gets_focus_after_dismissing_the_menu_with_super()
273
109
  end
274
110
end