~marcobiscaro2112/unity/custom-bg

« back to all changes in this revision

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

  • Committer: Marco Biscaro
  • Date: 2012-07-12 12:05:07 UTC
  • mfrom: (2353.2.144 unity)
  • Revision ID: marcobiscaro2112@gmail.com-20120712120507-7u9sb43bqon88ifl
Merge with trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
35
35
        launcher = self.launcher.get_launcher_for_monitor(0)
36
36
        launcher.click_launcher_icon(launcher_icon, button=3)
37
37
        self.addCleanup(self.keyboard.press_and_release, "Escape")
38
 
        for i in range(10):
39
 
            ql = launcher_icon.get_quicklist()
40
 
            if ql:
41
 
                return ql
42
 
            sleep(1)
 
38
        self.assertThat(launcher_icon.get_quicklist, Eventually(NotEquals(None)))
 
39
        return launcher_icon.get_quicklist()
43
40
 
44
41
    def test_quicklist_actions(self):
45
42
        """Test that all actions present in the destop file are shown in the quicklist."""
50
47
        desktop_file = os.path.join('/usr/share/applications', desktop_id)
51
48
        de = DesktopEntry(desktop_file)
52
49
        # get the launcher icon from the launcher:
53
 
        launcher_icon = self.launcher.model.get_icon_by_desktop_id(desktop_id)
 
50
        launcher_icon = self.launcher.model.get_icon(desktop_id=desktop_id)
54
51
        self.assertThat(launcher_icon, NotEquals(None))
55
52
 
56
53
        # open the icon quicklist, and get all the text labels:
75
72
        Then we activate the Calculator quicklist item.
76
73
        Then we actiavte the Mahjongg launcher icon.
77
74
        """
78
 
        mahj = self.start_app("Mahjongg")
79
 
        [mah_win1] = mahj.get_windows()
80
 
        self.assertTrue(mah_win1.is_focused)
81
 
 
82
 
        calc = self.start_app("Calculator")
83
 
        [calc_win] = calc.get_windows()
84
 
        self.assertTrue(calc_win.is_focused)
85
 
 
86
 
        self.start_app("Mahjongg")
87
 
        # Sleeping due to the start_app only waiting for the bamf model to be
88
 
        # updated with the application.  Since the app has already started,
89
 
        # and we are just waiting on a second window, however a defined sleep
90
 
        # here is likely to be problematic.
91
 
        # TODO: fix bamf emulator to enable waiting for new windows.
92
 
        sleep(1)
93
 
        [mah_win2] = [w for w in mahj.get_windows() if w.x_id != mah_win1.x_id]
94
 
        self.assertTrue(mah_win2.is_focused)
 
75
        mah_win1 = self.start_app_window("Mahjongg")
 
76
        calc_win = self.start_app_window("Calculator")
 
77
        mah_win2 = self.start_app_window("Mahjongg")
95
78
 
96
79
        self.assertVisibleWindowStack([mah_win2, calc_win, mah_win1])
97
80
 
98
 
        mahj_icon = self.launcher.model.get_icon_by_desktop_id(mahj.desktop_file)
99
 
        calc_icon = self.launcher.model.get_icon_by_desktop_id(calc.desktop_file)
 
81
        mahj_icon = self.launcher.model.get_icon(
 
82
            desktop_id=mah_win1.application.desktop_file)
 
83
        calc_icon = self.launcher.model.get_icon(
 
84
            desktop_id=calc_win.application.desktop_file)
100
85
 
101
86
        calc_ql = self.open_quicklist_for_icon(calc_icon)
102
 
        calc_ql.get_quicklist_application_item(calc.name).mouse_click()
103
 
        sleep(1)
104
 
        self.assertTrue(calc_win.is_focused)
 
87
        calc_ql.get_quicklist_application_item(calc_win.application.name).mouse_click()
 
88
 
 
89
        self.assertProperty(calc_win, is_focused=True)
105
90
        self.assertVisibleWindowStack([calc_win, mah_win2, mah_win1])
106
91
 
107
92
        mahj_ql = self.open_quicklist_for_icon(mahj_icon)
108
 
        mahj_ql.get_quicklist_application_item(mahj.name).mouse_click()
109
 
        sleep(1)
110
 
        self.assertTrue(mah_win2.is_focused)
 
93
        mahj_ql.get_quicklist_application_item(mah_win1.application.name).mouse_click()
 
94
 
 
95
        self.assertProperty(mah_win2, is_focused=True)
111
96
        self.assertVisibleWindowStack([mah_win2, calc_win, mah_win1])
112
97
 
113
98
    def test_quicklist_application_item_initiate_spread(self):
114
99
        """This tests shows that when you activate a quicklist application item
115
100
        when an application window is focused, the spread is initiated.
116
101
        """
117
 
        calc = self.start_app("Calculator")
118
 
        [calc_win1] = calc.get_windows()
119
 
        self.assertTrue(calc_win1.is_focused)
120
 
 
121
 
        self.start_app("Calculator")
122
 
        # Sleeping due to the start_app only waiting for the bamf model to be
123
 
        # updated with the application.  Since the app has already started,
124
 
        # and we are just waiting on a second window, however a defined sleep
125
 
        # here is likely to be problematic.
126
 
        # TODO: fix bamf emulator to enable waiting for new windows.
127
 
        sleep(1)
128
 
        [calc_win2] = [w for w in calc.get_windows() if w.x_id != calc_win1.x_id]
 
102
        calc_win1 = self.start_app_window("Calculator")
 
103
        calc_win2 = self.start_app_window("Calculator")
 
104
        calc_app = calc_win1.application
129
105
 
130
106
        self.assertVisibleWindowStack([calc_win2, calc_win1])
131
 
        self.assertTrue(calc_win2.is_focused)
 
107
        self.assertProperty(calc_win2, is_focused=True)
132
108
 
133
 
        calc_icon = self.launcher.model.get_icon_by_desktop_id(calc.desktop_file)
 
109
        calc_icon = self.launcher.model.get_icon(desktop_id=calc_app.desktop_file)
134
110
 
135
111
        calc_ql = self.open_quicklist_for_icon(calc_icon)
136
 
        app_item = calc_ql.get_quicklist_application_item(calc.name)
 
112
        app_item = calc_ql.get_quicklist_application_item(calc_app.name)
137
113
 
138
114
        self.addCleanup(self.keybinding, "spread/cancel")
139
115
        app_item.mouse_click()
140
116
        self.assertThat(self.window_manager.scale_active, Eventually(Equals(True)))
141
117
        self.assertThat(self.window_manager.scale_active_for_group, Eventually(Equals(True)))
142
118
 
 
119
    def test_quicklist_item_triggered_closes_dash(self):
 
120
        """When any quicklist item is triggered it must close the dash."""
 
121
 
 
122
        calc_win = self.start_app_window("Calculator")
 
123
        self.assertProperty(calc_win, is_focused=True)
 
124
 
 
125
        self.dash.ensure_visible()
 
126
        self.addCleanup(self.dash.ensure_hidden)
 
127
 
 
128
        calc_icon = self.launcher.model.get_icon(
 
129
            desktop_id=calc_win.application.desktop_file)
 
130
        self.open_quicklist_for_icon(calc_icon)
 
131
 
 
132
        self.keyboard.press_and_release("Down")
 
133
        self.keyboard.press_and_release("Enter")
 
134
        self.assertThat(self.dash.visible, Eventually(Equals(False)))
 
135
 
 
136
    def test_quicklist_closes_when_hud_opens(self):
 
137
        """When a quicklist is open you must still be able to open the Hud."""
 
138
        calc = self.start_app("Calculator")
 
139
 
 
140
        calc_icon = self.launcher.model.get_icon(desktop_id=calc.desktop_file)
 
141
        calc_ql = self.open_quicklist_for_icon(calc_icon)
 
142
 
 
143
        self.hud.ensure_visible()
 
144
        self.addCleanup(self.hud.ensure_hidden)
 
145
        self.assertThat(self.hud.visible, Eventually(Equals(True)))
 
146
 
 
147
    def test_quicklist_closes_when_dash_opens(self):
 
148
        """When the quicklist is open you must still be able to open the dash."""
 
149
        calc = self.start_app("Calculator")
 
150
 
 
151
        calc_icon = self.launcher.model.get_icon(desktop_id=calc.desktop_file)
 
152
        calc_ql = self.open_quicklist_for_icon(calc_icon)
 
153
 
 
154
        self.dash.ensure_visible()
 
155
        self.addCleanup(self.dash.ensure_hidden)
 
156
        self.assertThat(self.dash.visible, Eventually(Equals(True)))
 
157
 
143
158
 
144
159
class QuicklistKeyNavigationTests(UnityTestCase):
145
160
    """Tests for the quicklist key navigation."""
149
164
 
150
165
        self.ql_app = self.start_app("Text Editor")
151
166
 
152
 
        self.ql_launcher_icon = self.launcher.model.get_icon_by_desktop_id(self.ql_app.desktop_file)
 
167
        self.ql_launcher_icon = self.launcher.model.get_icon(
 
168
            desktop_id=self.ql_app.desktop_file)
153
169
        self.assertThat(self.ql_launcher_icon, NotEquals(None))
154
170
 
155
171
        self.ql_launcher = self.launcher.get_launcher_for_monitor(0)
169
185
        self.ql_launcher.key_nav_start()
170
186
        self.addCleanup(self.ql_launcher.key_nav_cancel)
171
187
 
172
 
        self.launcher.keyboard_select_icon(tooltip_text=self.ql_app.name)
 
188
        self.ql_launcher.keyboard_select_icon(tooltip_text=self.ql_app.name)
173
189
        self.keybinding("launcher/keynav/open-quicklist")
174
190
        self.addCleanup(self.keybinding, "launcher/keynav/close-quicklist")
 
191
 
 
192
        self.assertThat(self.ql_launcher_icon.get_quicklist, Eventually(NotEquals(None)))
175
193
        self.quicklist = self.ql_launcher_icon.get_quicklist()
176
 
 
177
 
        self.assertThat(self.quicklist, NotEquals(None))
178
 
        self.assertThat(self.quicklist.selected_item, NotEquals(None))
 
194
        self.assertThat(lambda: self.quicklist.selected_item, Eventually(NotEquals(None)))
179
195
 
180
196
    def test_keynav_selects_first_item_when_unselected(self):
181
197
        """Home key MUST select the first selectable item in a quicklist."""