206
206
# lensbar should lose focus after activation.
207
207
self.assertThat(lensbar.focused_lens_icon, Eventually(Equals("")))
209
209
def test_focus_returns_to_searchbar(self):
210
210
"""This test makes sure that the focus is returned to the searchbar of the newly
211
211
activated lens."""
212
212
self.dash.ensure_visible()
214
214
for i in range(self.dash.get_num_rows()):
215
215
self.keyboard.press_and_release("Down")
216
216
self.keyboard.press_and_release("Right")
217
217
lensbar = self.dash.view.get_lensbar()
218
218
focused_icon = lensbar.focused_lens_icon
219
219
self.keyboard.press_and_release("Enter")
221
221
self.assertThat(lensbar.active_lens, Eventually(Equals(focused_icon)))
222
222
self.assertThat(lensbar.focused_lens_icon, Eventually(Equals("")))
224
224
# Now we make sure if the newly activated lens searchbar have the focus.
225
225
self.keyboard.type("HasFocus")
227
227
self.assertThat(self.dash.search_string, Eventually(Equals("HasFocus")))
229
229
def test_category_header_keynav(self):
397
397
self.keyboard.press_and_release("Ctrl+v")
399
399
self.assertThat(self.dash.search_string, Eventually(Equals('CutPasteCutPaste')))
401
401
def test_middle_click_paste(self):
402
402
"""Tests if Middle mouse button pastes into searchbar"""
419
419
class DashKeyboardFocusTests(DashTestCase):
420
420
"""Tests that keyboard focus works."""
422
def assertSearchText(self, text):
423
self.assertThat(self.dash.search_string, Eventually(Equals(text)))
422
425
def test_filterbar_expansion_leaves_kb_focus(self):
423
426
"""Expanding or collapsing the filterbar must keave keyboard focus in the
431
434
filter_bar.ensure_expanded()
432
435
self.addCleanup(filter_bar.ensure_collapsed)
433
436
self.keyboard.type(" world")
434
self.assertThat(self.dash.search_string, Eventually(Equals("hello world")))
437
self.assertSearchText("hello world")
439
def test_keep_focus_on_application_opens(self):
440
"""The Dash must keep key focus as well as stay open if an app gets opened from an external source. """
442
self.dash.ensure_visible()
443
self.addCleanup(self.hud.ensure_hidden)
445
self.start_app_window("Calculator")
448
self.keyboard.type("HasFocus")
449
self.assertSearchText("HasFocus")
437
452
class DashLensResultsTests(DashTestCase):
612
627
class PreviewInvocationTests(DashTestCase):
613
"""Tests that dash previews can be opened and closed in different
628
"""Tests that dash previews can be opened and closed in different
618
633
def test_app_lens_preview_open_close(self):
619
"""Right-clicking on an application lens result must show
634
"""Right-clicking on an application lens result must show
832
847
self.assertThat(self.dash.preview_displaying, Eventually(Equals(False)))
850
class DashDBusIfaceTests(DashTestCase):
851
"""Test the Unity dash DBus interface."""
853
def test_dash_hide(self):
854
"""Ensure we can hide the dash via HideDash() dbus method."""
855
self.dash.ensure_visible()
856
self.dash.controller.hide_dash_via_dbus()
857
self.assertThat(self.dash.visible, Eventually(Equals(False)))
858
self.dash.ensure_hidden()
861
class DashCrossMonitorsTests(DashTestCase):
862
"""Multi-monitor dash tests."""
865
super(DashCrossMonitorsTests, self).setUp()
866
if self.screen_geo.get_num_monitors() < 2:
867
self.skipTest("This test requires more than 1 monitor.")
869
def test_dash_stays_on_same_monitor(self):
870
"""If the dash is opened, then the mouse is moved to another monitor and
871
the keyboard is used. The Dash must not move to that monitor.
873
current_monitor = self.dash.ideal_monitor
875
self.dash.ensure_visible()
876
self.addCleanup(self.dash.ensure_hidden)
878
self.screen_geo.move_mouse_to_monitor((current_monitor + 1) % self.screen_geo.get_num_monitors())
879
self.keyboard.type("abc")
881
self.assertThat(self.dash.ideal_monitor, Eventually(Equals(current_monitor)))
883
def test_dash_close_on_cross_monitor_click(self):
884
"""Dash must close when clicking on a window in a different screen."""
886
self.addCleanup(self.dash.ensure_hidden)
888
for monitor in range(self.screen_geo.get_num_monitors()-1):
889
self.screen_geo.move_mouse_to_monitor(monitor)
890
self.dash.ensure_visible()
892
self.screen_geo.move_mouse_to_monitor(monitor+1)
896
self.assertThat(self.dash.visible, Eventually(Equals(False)))