~unity-team/unity/trunk

« back to all changes in this revision

Viewing changes to tests/autopilot/unity/tests/test_dash.py

  • Committer: Daniel van Vugt
  • Date: 2012-09-13 10:56:42 UTC
  • mfrom: (2684 unity)
  • mto: This revision was merged to the branch mainline in revision 2698.
  • Revision ID: daniel.van.vugt@canonical.com-20120913105642-9on2ald55h54j1zn
Merge latest lp:unity and fix conflicts

Show diffs side-by-side

added added

removed removed

Lines of Context:
205
205
 
206
206
        # lensbar should lose focus after activation.
207
207
        self.assertThat(lensbar.focused_lens_icon, Eventually(Equals("")))
208
 
        
 
208
 
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()
213
 
        
 
213
 
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")
220
 
        
 
220
 
221
221
        self.assertThat(lensbar.active_lens, Eventually(Equals(focused_icon)))
222
222
        self.assertThat(lensbar.focused_lens_icon, Eventually(Equals("")))
223
 
        
 
223
 
224
224
        # Now we make sure if the newly activated lens searchbar have the focus.
225
225
        self.keyboard.type("HasFocus")
226
 
        
 
226
 
227
227
        self.assertThat(self.dash.search_string, Eventually(Equals("HasFocus")))
228
228
 
229
229
    def test_category_header_keynav(self):
397
397
        self.keyboard.press_and_release("Ctrl+v")
398
398
 
399
399
        self.assertThat(self.dash.search_string, Eventually(Equals('CutPasteCutPaste')))
400
 
        
 
400
 
401
401
    def test_middle_click_paste(self):
402
402
        """Tests if Middle mouse button pastes into searchbar"""
403
403
 
419
419
class DashKeyboardFocusTests(DashTestCase):
420
420
    """Tests that keyboard focus works."""
421
421
 
 
422
    def assertSearchText(self, text):
 
423
        self.assertThat(self.dash.search_string, Eventually(Equals(text)))
 
424
 
422
425
    def test_filterbar_expansion_leaves_kb_focus(self):
423
426
        """Expanding or collapsing the filterbar must keave keyboard focus in the
424
427
        search bar.
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")
 
438
 
 
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. """
 
441
        
 
442
        self.dash.ensure_visible()
 
443
        self.addCleanup(self.hud.ensure_hidden)
 
444
 
 
445
        self.start_app_window("Calculator")
 
446
        sleep(1)
 
447
 
 
448
        self.keyboard.type("HasFocus")
 
449
        self.assertSearchText("HasFocus")
435
450
 
436
451
 
437
452
class DashLensResultsTests(DashTestCase):
610
625
 
611
626
 
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
614
629
    lenses.
615
630
 
616
631
    """
617
 
    
 
632
 
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
620
635
        its preview.
621
636
 
622
637
        """
666
681
        # of failing.
667
682
        if category is None:
668
683
            self.skipTest("This lens is probably empty")
669
 
        
 
684
 
670
685
        results = category.get_results()
671
686
 
672
687
        result = results[0]
694
709
            category = lens.get_category_by_name("Online")
695
710
            if category is None:
696
711
                self.skipTest("This lens is probably empty")
697
 
        
 
712
 
698
713
        results = category.get_results()
699
714
 
700
715
        result = results[0]
831
846
 
832
847
        self.assertThat(self.dash.preview_displaying, Eventually(Equals(False)))
833
848
 
 
849
 
 
850
class DashDBusIfaceTests(DashTestCase):
 
851
    """Test the Unity dash DBus interface."""
 
852
 
 
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()
 
859
 
 
860
 
 
861
class DashCrossMonitorsTests(DashTestCase):
 
862
    """Multi-monitor dash tests."""
 
863
 
 
864
    def setUp(self):
 
865
        super(DashCrossMonitorsTests, self).setUp()
 
866
        if self.screen_geo.get_num_monitors() < 2:
 
867
            self.skipTest("This test requires more than 1 monitor.")
 
868
 
 
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.
 
872
        """
 
873
        current_monitor = self.dash.ideal_monitor
 
874
 
 
875
        self.dash.ensure_visible()
 
876
        self.addCleanup(self.dash.ensure_hidden)
 
877
 
 
878
        self.screen_geo.move_mouse_to_monitor((current_monitor + 1) % self.screen_geo.get_num_monitors())
 
879
        self.keyboard.type("abc")
 
880
 
 
881
        self.assertThat(self.dash.ideal_monitor, Eventually(Equals(current_monitor)))
 
882
 
 
883
    def test_dash_close_on_cross_monitor_click(self):
 
884
        """Dash must close when clicking on a window in a different screen."""  
 
885
 
 
886
        self.addCleanup(self.dash.ensure_hidden)
 
887
 
 
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()
 
891
 
 
892
            self.screen_geo.move_mouse_to_monitor(monitor+1)
 
893
            sleep(.5)
 
894
            self.mouse.click()
 
895
            
 
896
            self.assertThat(self.dash.visible, Eventually(Equals(False)))