Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 # Copyright (c) 2010 The Chromium OS Authors. All rights reserved. | 1 # Copyright (c) 2010 The Chromium OS Authors. All rights reserved. |
| 2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
| 4 | 4 |
| 5 import os, time | 5 import os, time |
| 6 from autotest_lib.client.bin import site_ui_test, test | 6 from autotest_lib.client.bin import site_login, site_ui_test, test |
| 7 from autotest_lib.client.common_lib import error | 7 from autotest_lib.client.common_lib import error |
| 8 | 8 |
| 9 class desktopui_WindowManagerFocusNewWindows(site_ui_test.UITest): | 9 class desktopui_WindowManagerFocusNewWindows(site_ui_test.UITest): |
| 10 version = 1 | 10 version = 1 |
| 11 | 11 |
| 12 def __check_active_window(self, id, info): | 12 def __check_active_window(self, id, info): |
| 13 """Check that a particular window is active. | 13 """Check that a particular window is active. |
| 14 | 14 |
| 15 Args: | 15 Args: |
| 16 id: int window ID | 16 id: int window ID |
| 17 info: AutoX.WindowInfo object corresponding to 'id' | 17 info: AutoX.WindowInfo object corresponding to 'id' |
| 18 | 18 |
| 19 Raises: | 19 Raises: |
| 20 error.TestFail: if a condition timed out | 20 error.TestFail: if a condition timed out |
| 21 """ | 21 """ |
| 22 try: | 22 try: |
| 23 self.autox.await_condition( | 23 self.autox.await_condition( |
| 24 lambda: self.autox.get_active_window_property() == id, | |
| 25 desc='Waiting for _NET_ACTIVE_WINDOW to contain 0x%x' % id) | |
|
Daniel Erat
2010/09/17 17:31:57
The window manager sets the property before it ass
kmixter1
2010/09/17 20:32:37
Not sure if this reordering is being done to be mo
Daniel Erat
2010/09/17 20:39:21
It's the former. :-)
| |
| 26 self.autox.await_condition( | |
| 24 lambda: info.is_focused, | 27 lambda: info.is_focused, |
| 25 desc='Waiting for window 0x%x to be focused' % id) | 28 desc='Waiting for window 0x%x to be focused' % id) |
| 26 self.autox.await_condition( | |
| 27 lambda: self.autox.get_active_window_property() == id, | |
| 28 desc='Waiting for _NET_ACTIVE_WINDOW to contain 0x%x' % id) | |
| 29 | 29 |
| 30 # get_geometry() returns a tuple, so we need to construct a tuple to | 30 # get_geometry() returns a tuple, so we need to construct a tuple to |
| 31 # compare against it. | 31 # compare against it. |
| 32 fullscreen_dimensions = \ | 32 fullscreen_dimensions = \ |
| 33 tuple([0, 0] + list(self.autox.get_screen_size())) | 33 tuple([0, 0] + list(self.autox.get_screen_size())) |
| 34 self.autox.await_condition( | 34 self.autox.await_condition( |
| 35 lambda: info.get_geometry() == fullscreen_dimensions, | 35 lambda: info.get_geometry() == fullscreen_dimensions, |
| 36 desc='Waiting for window 0x%x to fill the screen' % id) | 36 desc='Waiting for window 0x%x to fill the screen' % id) |
| 37 | 37 |
| 38 self.autox.await_condition( | 38 self.autox.await_condition( |
| 39 lambda: self.autox.get_top_window_id_at_point(200, 200) == id, | 39 lambda: self.autox.get_top_window_id_at_point(200, 200) == id, |
| 40 desc='Waiting for window 0x%x to be on top' % id) | 40 desc='Waiting for window 0x%x to be on top' % id) |
| 41 | 41 |
| 42 except self.autox.ConditionTimeoutError as exception: | 42 except self.autox.ConditionTimeoutError as exception: |
| 43 raise error.TestFail( | 43 raise error.TestFail( |
| 44 'Timed out on condition: %s' % exception.__str__()) | 44 'Timed out on condition: %s' % exception.__str__()) |
| 45 | 45 |
| 46 def run_once(self): | 46 def run_once(self): |
| 47 # Make sure that we don't have the initial browser window popping up in | |
| 48 # the middle of the test. | |
| 49 site_login.wait_for_initial_chrome_window() | |
| 50 | |
| 47 self.autox = self.get_autox() | 51 self.autox = self.get_autox() |
| 48 | 52 |
| 49 # Create a window and check that we switch to it. | 53 # Create a window and check that we switch to it. |
| 50 win = self.autox.create_and_map_window( | 54 win = self.autox.create_and_map_window( |
| 51 width=200, height=200, title='test') | 55 width=200, height=200, title='test') |
| 52 info = self.autox.get_window_info(win.id) | 56 info = self.autox.get_window_info(win.id) |
| 53 self.__check_active_window(win.id, info) | 57 self.__check_active_window(win.id, info) |
| 54 | 58 |
| 55 # Create a second window. | 59 # Create a second window. |
| 56 win2 = self.autox.create_and_map_window( | 60 win2 = self.autox.create_and_map_window( |
| 57 width=200, height=200, title='test 2') | 61 width=200, height=200, title='test 2') |
| 58 info2 = self.autox.get_window_info(win2.id) | 62 info2 = self.autox.get_window_info(win2.id) |
| 59 self.__check_active_window(win2.id, info2) | 63 self.__check_active_window(win2.id, info2) |
| 60 | 64 |
| 61 # Cycle backwards to the first window. | |
| 62 self.autox.send_hotkey('Alt-Shift-Tab') | |
| 63 self.__check_active_window(win.id, info) | |
| 64 | |
| 65 # Cycle forwards to the second window. | |
| 66 self.autox.send_hotkey('Alt-Tab') | |
| 67 self.__check_active_window(win2.id, info2) | |
| 68 | |
| 69 # Now destroy the second window and check that the WM goes back | 65 # Now destroy the second window and check that the WM goes back |
| 70 # to the first window. | 66 # to the first window. |
| 71 win2.destroy() | 67 win2.destroy() |
| 72 self.__check_active_window(win.id, info) | 68 self.__check_active_window(win.id, info) |
| OLD | NEW |