~unity-team/unity/unity.fix-sc-icon-to-launcher-animation-981168

« back to all changes in this revision

Viewing changes to tests/autopilot/autopilot/tests/test_switcher.py

  • Committer: Tarmac
  • Author(s): Marco Trevisan (Treviño), Brandon Schaefer, Tim Penhey
  • Date: 2012-04-16 11:19:06 UTC
  • mfrom: (1776.4.46 3v1n0-quick-alt+tab-fixes)
  • Revision ID: tarmac-20120416111906-i6zpg21y6rtk7n5z
Fix the behaviour of alt-tab and clicking on the launcher icon to just raise the most recently used window, not all for that app.


BamfLauncherIcon's activation related code has been updated to be more multimonitor aware (for free I've fixed also some bugs that caused the windows not to be put in spread mode in multi-monitor), and to support both the "Launcher only on Primary Monitor" and "Launcher on all monitors" options.

PluginAdapter's FocusWindowGroup method has been updated to optionally only unminimize / raise and activate only the top window. This code would have been more optimized using a reverse iterator to fetch the top_window, but not to change the whole logic and to allow to keep the previous behavior (that initially we wanted for "long alt+tab") without duplicating code, I've just hacked that.
Implemented also GetWindowMonitor to workaround the mismatch we had with the compiz' window->outputDevice() and the UScreen values that now we use in the whole unity.

Screencast of the fixed version: http://ubuntuone.com/7YaWciQnaZHfzr35asSz0N. Fixes: https://bugs.launchpad.net/bugs/861250, https://bugs.launchpad.net/bugs/959339, https://bugs.launchpad.net/bugs/981795. Approved by Thomi Richards, Tim Penhey.

Show diffs side-by-side

added added

removed removed

Lines of Context:
21
21
    def setUp(self):
22
22
        super(SwitcherTests, self).setUp()
23
23
 
24
 
        self.start_app('Character Map')
25
 
        self.start_app('Calculator')
26
 
        self.start_app('Mahjongg')
 
24
        self.char_map = self.start_app('Character Map')
 
25
        self.calc = self.start_app('Calculator')
 
26
        self.mahjongg = self.start_app('Mahjongg')
27
27
 
28
28
    def tearDown(self):
29
29
        super(SwitcherTests, self).tearDown()
197
197
 
198
198
        self.assertThat(self.switcher.get_is_visible(), Equals(False))
199
199
 
 
200
    def test_switcher_appears_on_monitor_with_focused_window(self):
 
201
        num_monitors = self.screen_geo.get_num_monitors()
 
202
        if num_monitors == 1:
 
203
            self.skip("No point testing this on one monitor")
 
204
 
 
205
        [calc_win] = self.calc.get_windows()
 
206
        for monitor in range(num_monitors):
 
207
            self.screen_geo.drag_window_to_monitor(calc_win, monitor)
 
208
            self.switcher.initiate()
 
209
            sleep(1)
 
210
            self.assertThat(self.switcher.get_monitor(), Equals(monitor))
 
211
            self.switcher.terminate()
 
212
 
 
213
 
 
214
class SwitcherWindowsManagementTests(AutopilotTestCase):
 
215
    """Test the switcher window management."""
 
216
 
 
217
    def test_switcher_raises_only_last_focused_window(self):
 
218
        """Tests that when we do an alt+tab only the previously focused window
 
219
        is raised.
 
220
        This is tests by opening 2 Calculators and a Mahjongg.
 
221
        Then we do a quick alt+tab twice.
 
222
        Then we close the currently focused window.
 
223
        """
 
224
        self.close_all_app("Mahjongg")
 
225
        self.close_all_app("Calculator")
 
226
 
 
227
        mahj = self.start_app("Mahjongg")
 
228
        [mah_win1] = mahj.get_windows()
 
229
        self.assertTrue(mah_win1.is_focused)
 
230
 
 
231
        calc = self.start_app("Calculator")
 
232
        [calc_win] = calc.get_windows()
 
233
        self.assertTrue(calc_win.is_focused)
 
234
 
 
235
        self.start_app("Mahjongg")
 
236
        # Sleeping due to the start_app only waiting for the bamf model to be
 
237
        # updated with the application.  Since the app has already started,
 
238
        # and we are just waiting on a second window, however a defined sleep
 
239
        # here is likely to be problematic.
 
240
        # TODO: fix bamf emulator to enable waiting for new windows.
 
241
        sleep(1)
 
242
        [mah_win2] = [w for w in mahj.get_windows() if w.x_id != mah_win1.x_id]
 
243
        self.assertTrue(mah_win2.is_focused)
 
244
 
 
245
        self.assertVisibleWindowStack([mah_win2, calc_win, mah_win1])
 
246
 
 
247
        self.keybinding("switcher/reveal_normal")
 
248
        sleep(1)
 
249
        self.assertTrue(calc_win.is_focused)
 
250
        self.assertVisibleWindowStack([calc_win, mah_win2, mah_win1])
 
251
 
 
252
        self.keybinding("switcher/reveal_normal")
 
253
        sleep(1)
 
254
        self.assertTrue(mah_win2.is_focused)
 
255
        self.assertVisibleWindowStack([mah_win2, calc_win, mah_win1])
 
256
 
 
257
        self.keybinding("window/close")
 
258
        sleep(1)
 
259
 
 
260
        self.assertTrue(calc_win.is_focused)
 
261
        self.assertVisibleWindowStack([calc_win, mah_win1])
 
262
 
200
263
 
201
264
class SwitcherDetailsTests(AutopilotTestCase):
202
265
    """Test the details mode for the switcher."""
364
427
        # current workspace and ask that one if it is hidden.
365
428
        self.assertFalse(wins[0].is_hidden)
366
429
        self.assertFalse(wins[1].is_hidden)
367