| 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, random, re, shutil, time | 5 import os, random, re, shutil, time |
| 6 from autotest_lib.client.bin import site_ui_test, site_utils, test, utils | 6 from autotest_lib.client.bin import site_login, site_ui_test, site_utils, \ |
| 7 test, utils |
| 7 from autotest_lib.client.common_lib import error | 8 from autotest_lib.client.common_lib import error |
| 8 | 9 |
| 9 class desktopui_WindowManagerHotkeys(site_ui_test.UITest): | 10 class desktopui_WindowManagerHotkeys(site_ui_test.UITest): |
| 10 version = 1 | 11 version = 1 |
| 11 | 12 |
| 12 def run_once(self): | 13 def run_once(self): |
| 14 # Make sure that we don't have the initial browser window popping up in |
| 15 # the middle of the test. |
| 16 site_login.wait_for_initial_chrome_window() |
| 17 |
| 13 ax = self.get_autox() | 18 ax = self.get_autox() |
| 14 | 19 |
| 15 # Start a terminal and wait for it to get the focus. | 20 # Start a terminal and wait for it to get the focus. |
| 16 orig_active_win_xid = ax.get_active_window_property() | 21 orig_active_win_xid = ax.get_active_window_property() |
| 17 ax.send_hotkey('Ctrl-Alt-t') | 22 ax.send_hotkey('Ctrl-Alt-t') |
| 18 ax.await_condition( | 23 ax.await_condition( |
| 19 lambda: ax.get_active_window_property() != orig_active_win_xid, | 24 lambda: ax.get_active_window_property() != orig_active_win_xid, |
| 20 desc='Waiting for terminal to become active window') | 25 desc='Waiting for terminal to become active window') |
| 21 | 26 |
| 22 # Press the Print Screen key and check that a screenshot is written. | 27 # Press the Print Screen key and check that a screenshot is written. |
| 23 screenshot_dir = '/home/chronos/user/Downloads/Screenshots' | 28 screenshot_dir = '/home/chronos/user/Downloads/Screenshots' |
| 24 shutil.rmtree(screenshot_dir, ignore_errors=True) | 29 shutil.rmtree(screenshot_dir, ignore_errors=True) |
| 25 ax.send_hotkey('Print') | 30 ax.send_hotkey('Print') |
| 26 site_utils.poll_for_condition( | 31 site_utils.poll_for_condition( |
| 27 lambda: os.access(screenshot_dir, os.F_OK) and \ | 32 lambda: os.access(screenshot_dir, os.F_OK) and \ |
| 28 os.listdir(screenshot_dir), | 33 os.listdir(screenshot_dir), |
| 29 error.TestFail( | 34 error.TestFail( |
| 30 'Waiting for screenshot in %s' % screenshot_dir)) | 35 'Waiting for screenshot in %s' % screenshot_dir)) |
| 31 shutil.rmtree(screenshot_dir, ignore_errors=True) | 36 shutil.rmtree(screenshot_dir, ignore_errors=True) |
| OLD | NEW |