22
22
super(SwitcherTests, self).setUp()
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')
28
28
def tearDown(self):
29
29
super(SwitcherTests, self).tearDown()
198
198
self.assertThat(self.switcher.get_is_visible(), Equals(False))
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")
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()
210
self.assertThat(self.switcher.get_monitor(), Equals(monitor))
211
self.switcher.terminate()
214
class SwitcherWindowsManagementTests(AutopilotTestCase):
215
"""Test the switcher window management."""
217
def test_switcher_raises_only_last_focused_window(self):
218
"""Tests that when we do an alt+tab only the previously focused window
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.
224
self.close_all_app("Mahjongg")
225
self.close_all_app("Calculator")
227
mahj = self.start_app("Mahjongg")
228
[mah_win1] = mahj.get_windows()
229
self.assertTrue(mah_win1.is_focused)
231
calc = self.start_app("Calculator")
232
[calc_win] = calc.get_windows()
233
self.assertTrue(calc_win.is_focused)
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.
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)
245
self.assertVisibleWindowStack([mah_win2, calc_win, mah_win1])
247
self.keybinding("switcher/reveal_normal")
249
self.assertTrue(calc_win.is_focused)
250
self.assertVisibleWindowStack([calc_win, mah_win2, mah_win1])
252
self.keybinding("switcher/reveal_normal")
254
self.assertTrue(mah_win2.is_focused)
255
self.assertVisibleWindowStack([mah_win2, calc_win, mah_win1])
257
self.keybinding("window/close")
260
self.assertTrue(calc_win.is_focused)
261
self.assertVisibleWindowStack([calc_win, mah_win1])
201
264
class SwitcherDetailsTests(AutopilotTestCase):
202
265
"""Test the details mode for the switcher."""