| 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 logging, os, time, utils | 5 import time |
| 6 from autotest_lib.client.bin import site_login, site_ui_test, test | 6 from autotest_lib.client.bin import site_ui_test, site_utils |
| 7 from autotest_lib.client.common_lib import error | 7 |
| 8 from autotest_lib.client.bin import chromeos_constants | |
| 9 | 8 |
| 10 class desktopui_ScreenSaverUnlock(site_ui_test.UITest): | 9 class desktopui_ScreenSaverUnlock(site_ui_test.UITest): |
| 11 version = 1 | 10 version = 1 |
| 12 | 11 |
| 13 def system_as(self, cmd, user='chronos'): | |
| 14 utils.system('su %s -c \'%s\'' % (user, cmd)) | |
| 15 | 12 |
| 16 def run_once(self): | 13 def run_once(self): |
| 17 site_login.wait_for_screensaver() | 14 self.wait_for_screensaver() |
| 18 self.system_as('DISPLAY=:0.0 xscreensaver-command -lock') | 15 self.xsystem('xscreensaver-command -lock') |
| 19 | 16 |
| 20 # some sleep to let the screen lock | 17 site_utils.poll_for_condition( |
| 21 # TODO: Sleeping is unreliable and slow. Do something better to | 18 lambda: self.is_screensaver_locked(), |
| 22 # wait for the screen to be locked. | 19 desc='screensaver lock') |
| 23 time.sleep(5) | |
| 24 self.system_as('DISPLAY=:0.0 xscreensaver-command -time | ' + | |
| 25 'grep -q locked') | |
| 26 | 20 |
| 27 time.sleep(10) | 21 ax = self.get_autox() |
| 28 site_login.attempt_login(self, 'autox_unlock.json') | 22 ax.send_hotkey('Return') |
| 23 # wait for the screensaver to wakeup and present the login dialog |
| 24 # TODO: a less brittle way to do this would be nice |
| 25 time.sleep(2) |
| 26 ax.send_text(self.password) |
| 27 ax.send_hotkey('Return') |
| 29 | 28 |
| 30 # wait for screen to unlock | 29 # wait for screen to unlock |
| 31 time.sleep(5) | 30 site_utils.poll_for_condition( |
| 32 self.system_as('DISPLAY=:0.0 xscreensaver-command -time | ' + | 31 lambda: self.is_screensaver_unlocked(), |
| 33 'grep -q non-blanked') | 32 desc='screensaver unlock') |
| OLD | NEW |