| 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_login, test | 6 from autotest_lib.client.bin import 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(test.test): | 9 class desktopui_WindowManagerFocusNewWindows(site_ui_test.UITest): |
| 10 version = 1 | 10 version = 1 |
| 11 | 11 |
| 12 def setup(self): | |
| 13 site_login.setup_autox(self) | |
| 14 | |
| 15 def __check_active_window(self, id, info): | 12 def __check_active_window(self, id, info): |
| 16 """Check that a particular window is active. | 13 """Check that a particular window is active. |
| 17 | 14 |
| 18 Args: | 15 Args: |
| 19 id: int window ID | 16 id: int window ID |
| 20 info: AutoX.WindowInfo object corresponding to 'id' | 17 info: AutoX.WindowInfo object corresponding to 'id' |
| 21 | 18 |
| 22 Raises: | 19 Raises: |
| 23 error.TestFail: if a condition timed out | 20 error.TestFail: if a condition timed out |
| 24 """ | 21 """ |
| (...skipping 17 matching lines...) Expand all Loading... |
| 42 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, |
| 43 desc='Waiting for window 0x%x to be on top' % id) | 40 desc='Waiting for window 0x%x to be on top' % id) |
| 44 | 41 |
| 45 except self.autox.ConditionTimeoutError as exception: | 42 except self.autox.ConditionTimeoutError as exception: |
| 46 raise error.TestFail( | 43 raise error.TestFail( |
| 47 'Timed out on condition: %s' % exception.__str__()) | 44 'Timed out on condition: %s' % exception.__str__()) |
| 48 | 45 |
| 49 def run_once(self): | 46 def run_once(self): |
| 50 import autox | 47 import autox |
| 51 | 48 |
| 52 # TODO: This should be abstracted out. | |
| 53 if not site_login.logged_in(): | |
| 54 if not site_login.attempt_login(self, 'autox_script.json'): | |
| 55 raise error.TestError('Could not log in') | |
| 56 if not site_login.wait_for_window_manager(): | |
| 57 raise error.TestError('Window manager didn\'t start') | |
| 58 # TODO: This is awful. We need someone (Chrome, the WM, etc.) to | |
| 59 # announce when login is "done" -- that is, the initial Chrome | |
| 60 # window isn't going to pop onscreen in the middle of the test. | |
| 61 # For now, we just sleep a really long time. | |
| 62 time.sleep(20) | |
| 63 | |
| 64 # TODO: Set these in a single, standard place for all tests. | 49 # TODO: Set these in a single, standard place for all tests. |
| 65 os.environ['DISPLAY'] = ':0' | 50 os.environ['DISPLAY'] = ':0' |
| 66 os.environ['XAUTHORITY'] = '/home/chronos/.Xauthority' | 51 os.environ['XAUTHORITY'] = '/home/chronos/.Xauthority' |
| 67 self.autox = autox.AutoX() | 52 self.autox = autox.AutoX() |
| 68 | 53 |
| 69 # Create a window and check that we switch to it. | 54 # Create a window and check that we switch to it. |
| 70 win = self.autox.create_and_map_window( | 55 win = self.autox.create_and_map_window( |
| 71 width=200, height=200, title='test') | 56 width=200, height=200, title='test') |
| 72 info = self.autox.get_window_info(win.id) | 57 info = self.autox.get_window_info(win.id) |
| 73 self.__check_active_window(win.id, info) | 58 self.__check_active_window(win.id, info) |
| 74 | 59 |
| 75 # Create a second window. | 60 # Create a second window. |
| 76 win2 = self.autox.create_and_map_window( | 61 win2 = self.autox.create_and_map_window( |
| 77 width=200, height=200, title='test 2') | 62 width=200, height=200, title='test 2') |
| 78 info2 = self.autox.get_window_info(win2.id) | 63 info2 = self.autox.get_window_info(win2.id) |
| 79 self.__check_active_window(win2.id, info2) | 64 self.__check_active_window(win2.id, info2) |
| 80 | 65 |
| 81 # Cycle backwards to the first window. | 66 # Cycle backwards to the first window. |
| 82 self.autox.send_hotkey('Alt-Shift-Tab') | 67 self.autox.send_hotkey('Alt-Shift-Tab') |
| 83 self.__check_active_window(win.id, info) | 68 self.__check_active_window(win.id, info) |
| 84 | 69 |
| 85 # Cycle forwards to the second window. | 70 # Cycle forwards to the second window. |
| 86 self.autox.send_hotkey('Alt-Tab') | 71 self.autox.send_hotkey('Alt-Tab') |
| 87 self.__check_active_window(win2.id, info2) | 72 self.__check_active_window(win2.id, info2) |
| 88 | 73 |
| 89 # Now destroy the second window and check that the WM goes back | 74 # Now destroy the second window and check that the WM goes back |
| 90 # to the first window. | 75 # to the first window. |
| 91 win2.destroy() | 76 win2.destroy() |
| 92 self.__check_active_window(win.id, info) | 77 self.__check_active_window(win.id, info) |
| OLD | NEW |