29
33
self.assertFalse(self.dash.get_is_visible())
31
35
def test_dash_keyboard_focus(self):
33
Dash must put keyboard focus on the search bar at all times.
35
self.dash.ensure_hidden()
37
self.assertFalse(self.dash.get_is_visible())
36
"""Dash must put keyboard focus on the search bar at all times."""
37
self.dash.ensure_visible()
39
self.dash.toggle_reveal()
42
self.assertEqual(self.dash.get_search_string(), u'Hello')
43
self.dash.toggle_reveal()
41
searchbar = self.dash.get_searchbar()
42
self.assertEqual(searchbar.search_string, u'Hello')
44
def test_application_lens_shortcut(self):
45
"""Application lense must reveal when Super+a is pressed."""
46
self.dash.reveal_application_lens()
47
lensbar = self.dash.view.get_lensbar()
48
self.assertEqual(lensbar.active_lens, u'applications.lens')
50
def test_music_lens_shortcut(self):
51
"""Music lense must reveal when Super+w is pressed."""
52
self.dash.reveal_music_lens()
53
lensbar = self.dash.view.get_lensbar()
54
self.assertEqual(lensbar.active_lens, u'music.lens')
56
def test_file_lens_shortcut(self):
57
"""File lense must reveal when Super+f is pressed."""
58
self.dash.reveal_file_lens()
59
lensbar = self.dash.view.get_lensbar()
60
self.assertEqual(lensbar.active_lens, u'files.lens')
62
def test_command_lens_shortcut(self):
63
"""Run Command lens must reveat on alt+F2."""
64
self.dash.reveal_command_lens()
65
lensbar = self.dash.view.get_lensbar()
66
self.assertEqual(lensbar.active_lens, u'commands.lens')
68
def test_alt_f4_close_dash(self):
69
"""Dash must close on alt+F4."""
70
self.dash.ensure_visible()
71
self.dash.close_with_alt_f4()
44
73
self.assertFalse(self.dash.get_is_visible())
76
class DashKeyNavTests(AutopilotTestCase):
77
"""Test the unity Dash keyboard navigation."""
80
super(DashKeyNavTests, self).setUp()
81
self.dash.ensure_hidden()
84
super(DashKeyNavTests, self).tearDown()
85
self.dash.ensure_hidden()
87
def test_lensbar_gets_keyfocus(self):
88
"""Test that the lensbar gets key focus after using Down keypresses."""
89
self.dash.ensure_visible()
91
# Make sure that the lens bar can get the focus
92
for i in range(self.dash.get_num_rows()):
93
kb.press_and_release("Down")
94
lensbar = self.dash.view.get_lensbar()
95
self.assertIsNot(lensbar.focused_lens_icon, '')
97
def test_lensbar_focus_changes(self):
98
"""Lensbar focused icon should change with Left and Right keypresses."""
99
self.dash.ensure_visible()
101
#put KB focus on lensbar again:
102
for i in range(self.dash.get_num_rows()):
103
kb.press_and_release("Down")
105
lensbar = self.dash.view.get_lensbar()
106
current_focused_icon = lensbar.focused_lens_icon
107
kb.press_and_release("Right");
108
lensbar.refresh_state()
109
self.assertNotEqual(lensbar.focused_lens_icon, current_focused_icon)
110
kb.press_and_release("Left")
111
lensbar.refresh_state()
112
self.assertEqual(lensbar.focused_lens_icon, current_focused_icon)
114
def test_lensbar_enter_activation(self):
115
"""Must be able to activate LensBar icons that have focus with an Enter keypress."""
116
self.dash.ensure_visible()
118
#put KB focus on lensbar again:
119
for i in range(self.dash.get_num_rows()):
120
kb.press_and_release("Down")
121
kb.press_and_release("Right");
122
lensbar = self.dash.view.get_lensbar()
123
focused_icon = lensbar.focused_lens_icon
124
kb.press_and_release("Enter");
125
lensbar.refresh_state()
126
self.assertEqual(lensbar.active_lens, focused_icon)
127
self.assertEqual(lensbar.focused_lens_icon, "")
129
def test_category_header_keynav_autoscroll(self):
130
"""Test that the dash autoscroll when a category header gets
133
self.dash.reveal_application_lens()
134
app_lens = self.dash.get_current_lens()
139
# Expand the first category
140
kb.press_and_release("Down")
141
kb.press_and_release("Enter")
142
category = app_lens.get_focused_category()
144
# Get the geometry of that category header.
145
x = category.header_x
146
y = category.header_y
147
w = category.header_width
149
# Manually scroll the dash.
150
mouse.move(x+w+10, y+w+10, True)
157
# Focus the search bar with the mouse
158
searchbar = self.dash.get_searchbar()
159
mouse.move(searchbar.x + 100,
160
searchbar.y + searchbar.height / 2,
165
# Then focus again the first category header
166
kb.press_and_release("Down")
167
kb.press_and_release("Enter")
168
category = app_lens.get_focused_category()
169
y = category.header_y
171
# Make sure the dash autoscroll
172
self.assertTrue(abs(y - cached_y) < 30)
174
def test_category_header_keynav(self):
175
""" This test makes sure that:
176
1. A category header can get the focus.
177
2. A category header stays highlight when it loses the focus
178
and mouse is close to it (but not inside).
180
self.dash.reveal_application_lens()
185
# Make sure that a category have the focus.
186
kb.press_and_release("Down")
187
app_lens = self.dash.get_current_lens()
188
category = app_lens.get_focused_category()
189
self.assertIsNot(category, None)
191
# Make sure that the category is highlighted.
192
self.assertTrue(category.header_is_highlighted)
194
# Get the geometry of that category header.
195
x = category.header_x
196
y = category.header_y
197
w = category.header_width
198
h = category.header_height
200
# Move the mouse close the view, and press down.
201
mouse.move(x + w + 10,
205
kb.press_and_release("Down")
207
category = app_lens.get_focused_category()
208
self.assertEqual(category, None)
210
def test_cltr_tab(self):
211
""" This test makes sure that Ctlr + Tab works well."""
212
self.dash.toggle_reveal()
215
lensbar = self.dash.view.get_lensbar()
218
kb.press_and_release('Tab')
219
kb.release('Control')
220
lensbar.refresh_state()
221
self.assertEqual(lensbar.active_lens, u'applications.lens')
225
kb.press_and_release('Tab')
226
kb.release('Control')
229
lensbar.refresh_state()
230
self.assertEqual(lensbar.active_lens, u'home.lens')
233
""" This test makes sure that Tab works well."""
234
self.dash.reveal_application_lens()
235
app_lens = self.dash.get_current_lens()
239
for i in range(app_lens.get_num_visible_categories()):
240
kb.press_and_release('Tab')
241
category = app_lens.get_focused_category()
242
self.assertIsNot(category, None)
244
kb.press_and_release('Tab')
245
searchbar = self.dash.get_searchbar()
246
self.assertTrue(searchbar.expander_has_focus)
248
if not searchbar.showing_filters:
249
kb.press_and_release('Enter')
250
searchbar.refresh_state()
251
self.assertTrue(searchbar.showing_filters)
253
filter_bar = app_lens.get_filterbar()
254
for i in range(filter_bar.get_num_filters()):
255
kb.press_and_release('Tab')
256
new_focused_filter = filter_bar.get_focused_filter()
257
self.assertIsNotNone(new_focused_filter)
259
kb.press_and_release('Tab')
260
category = app_lens.get_focused_category()
261
self.assertIsNot(category, None)
264
class DashClipboardTests(AutopilotTestCase):
265
"""Test the Unity clipboard"""
268
super(DashClipboardTests, self).setUp()
269
self.dash.ensure_hidden()
272
super(DashClipboardTests, self).tearDown()
273
self.dash.ensure_hidden()
275
def test_ctrl_a(self):
276
""" This test if ctrl+a selects all text """
277
self.dash.toggle_reveal()
283
kb.press_and_release("Ctrl+a")
284
kb.press_and_release("Delete")
286
searchbar = self.dash.get_searchbar()
287
self.assertEqual(searchbar.search_string, u'')
289
def test_ctrl_c(self):
290
""" This test if ctrl+c copies text into the clipboard """
291
self.dash.toggle_reveal()
297
kb.press_and_release("Ctrl+a")
298
kb.press_and_release("Ctrl+c")
300
cb = Clipboard(selection="CLIPBOARD")
302
searchbar = self.dash.get_searchbar()
303
self.assertEqual(searchbar.search_string, cb.wait_for_text())
305
def test_ctrl_x(self):
306
""" This test if ctrl+x deletes all text and copys it """
307
self.dash.toggle_reveal()
313
kb.press_and_release("Ctrl+a")
314
kb.press_and_release("Ctrl+x")
317
searchbar = self.dash.get_searchbar()
318
self.assertEqual(searchbar.search_string, u'')
320
cb = Clipboard(selection="CLIPBOARD")
321
self.assertEqual(cb.wait_for_text(), u'Cut')
323
def test_ctrl_c_v(self):
324
""" This test if ctrl+c and ctrl+v copies and pastes text"""
325
self.dash.toggle_reveal()
331
kb.press_and_release("Ctrl+a")
332
kb.press_and_release("Ctrl+c")
333
kb.press_and_release("Ctrl+v")
334
kb.press_and_release("Ctrl+v")
336
searchbar = self.dash.get_searchbar()
337
self.assertEqual(searchbar.search_string, u'CopyPasteCopyPaste')
339
def test_ctrl_x_v(self):
340
""" This test if ctrl+x and ctrl+v cuts and pastes text"""
341
self.dash.toggle_reveal()
347
kb.press_and_release("Ctrl+a")
348
kb.press_and_release("Ctrl+x")
349
kb.press_and_release("Ctrl+v")
350
kb.press_and_release("Ctrl+v")
352
searchbar = self.dash.get_searchbar()
353
self.assertEqual(searchbar.search_string, u'CutPasteCutPaste')
356
class DashKeyboardFocusTests(AutopilotTestCase):
357
"""Tests that keyboard focus works."""
360
super(DashKeyboardFocusTests, self).setUp()
361
self.dash.ensure_hidden()
364
super(DashKeyboardFocusTests, self).tearDown()
365
self.dash.ensure_hidden()
367
def test_filterbar_expansion_leaves_kb_focus(self):
368
"""Expanding or collapsing the filterbar must keave keyboard focus in the
371
self.dash.reveal_application_lens()
372
filter_bar = self.dash.get_current_lens().get_filterbar()
373
filter_bar.ensure_collapsed()
377
filter_bar.ensure_expanded()
380
searchbar = self.dash.get_searchbar()
381
self.assertEqual("hello world", searchbar.search_string)
383
class DashLensResultsTests(AutopilotTestCase):
384
""" Tests results from the lens view """
387
super(DashLensResultsTests, self).setUp()
388
self.dash.ensure_hidden()
391
super(DashLensResultsTests, self).tearDown()
392
self.dash.ensure_hidden()
394
def test_results_message_empty_search(self):
395
""" This tests a message is not shown when there is no text"""
396
self.dash.reveal_application_lens()
397
lens = self.dash.get_current_lens()
400
self.assertFalse(lens.no_results_active)
402
def test_results_message(self):
403
""" This test no mesage will be shown when results are there"""
404
self.dash.reveal_application_lens()
405
lens = self.dash.get_current_lens()
412
self.assertFalse(lens.no_results_active)
414
def test_no_results_message(self):
415
""" This test shows a message will appear in the lens"""
416
self.dash.reveal_application_lens()
417
lens = self.dash.get_current_lens()
420
kb.type("qwerlkjzvxc")
424
self.assertTrue(lens.no_results_active)
426
class DashVisualTests(AutopilotTestCase):
427
"""Tests that the dash visual is correct."""
429
super(DashVisualTests, self).setUp()
430
self.dash.ensure_hidden()
433
super(DashVisualTests, self).tearDown()
434
self.dash.ensure_hidden()
436
def test_see_more_result_alignment(self):
437
"""The see more results label should be baseline aligned
438
with the category name label.
440
self.dash.reveal_application_lens()
442
lens = self.dash.get_current_lens()
443
groups = lens.get_groups()
446
if (group.is_visible):
447
self.assertTrue(not group.expand_label_is_visible or
448
(group.expand_label_y + group.expand_label_baseline == group.name_label_y + group.name_label_baseline))
450
class DashSpecialKeysTests(AutopilotTestCase):
451
"""Tests composition sequences, dead keys or any other special keys."""
453
super(DashSpecialKeysTests, self).setUp()
454
self.dash.ensure_hidden()
457
super(DashSpecialKeysTests, self).tearDown()
458
self.dash.ensure_hidden()
460
def test_multi_key(self):
461
"""Pressing 'Multi_key' must not add any characters to the search."""
462
self.dash.reveal_application_lens()
465
kb.press_and_release('Multi_key')
469
searchbar = self.dash.get_searchbar()
470
self.assertEqual("", searchbar.search_string)
472
def test_multi_key_o(self):
473
"""Pressing the sequences 'Multi_key' + '^' + 'o' must produce 'ô'."""
474
self.dash.reveal_application_lens()
477
kb.press_and_release('Multi_key')
481
searchbar = self.dash.get_searchbar()
482
self.assertEqual("ô", searchbar.search_string)
484
def test_multi_key_copyright(self):
485
"""Pressing the sequences 'Multi_key' + 'c' + 'o' must produce '©'."""
486
self.dash.reveal_application_lens()
489
kb.press_and_release('Multi_key')
493
searchbar = self.dash.get_searchbar()
494
self.assertEqual("©", searchbar.search_string)
496
def test_multi_key_delete(self):
497
"""Pressing 'Multi_key' must not get stuck looking for a sequence."""
498
self.dash.reveal_application_lens()
503
kb.press_and_release('Multi_key')
504
kb.press_and_release('BackSpace')
505
kb.press_and_release('BackSpace')
508
searchbar = self.dash.get_searchbar()
509
self.assertEqual("d", searchbar.search_string)