Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(776)

Side by Side Diff: client/site_tests/desktopui_ScreenSaverUnlock/desktopui_ScreenSaverUnlock.py

Issue 1565001: test: Clean up site_login.py a bit. (Closed)
Patch Set: update one more call to attempt_logout() Created 10 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 logging, os, time, utils
6 from autotest_lib.client.bin import site_login, 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 from autotest_lib.client.bin import chromeos_constants 8 from autotest_lib.client.bin import chromeos_constants
9 9
10 class desktopui_ScreenSaverUnlock(test.test): 10 class desktopui_ScreenSaverUnlock(site_ui_test.UITest):
11 version = 1 11 version = 1
12 12
13 def system_as(self, cmd, user='chronos'): 13 def system_as(self, cmd, user='chronos'):
14 utils.system('su %s -c \'%s\'' % (user, cmd)) 14 utils.system('su %s -c \'%s\'' % (user, cmd))
15 15
16 def setup(self):
17 site_login.setup_autox(self)
18
19 def run_once(self): 16 def run_once(self):
20 if site_login.logged_in(): 17 site_login.wait_for_screensaver()
21 if not site_login.attempt_logout():
22 raise error.TestFail('Could not terminate existing session')
23
24 if not site_login.attempt_login(self, 'autox_script.json'):
25 raise error.TestFail('Could not login')
26
27 # first sleep to let the login finish and start xscreensaver
28 time.sleep(10)
29 self.system_as('DISPLAY=:0.0 xscreensaver-command -lock') 18 self.system_as('DISPLAY=:0.0 xscreensaver-command -lock')
30 19
31 # some sleep to let the screen lock 20 # some sleep to let the screen lock
21 # TODO: Sleeping is unreliable and slow. Do something better to
22 # wait for the screen to be locked.
32 time.sleep(5) 23 time.sleep(5)
33 self.system_as('DISPLAY=:0.0 xscreensaver-command -time | ' + 24 self.system_as('DISPLAY=:0.0 xscreensaver-command -time | ' +
34 'grep -q locked') 25 'grep -q locked')
35 26
36 time.sleep(10) 27 time.sleep(10)
37 if not site_login.attempt_login(self, 'autox_unlock.json'): 28 site_login.attempt_login(self, 'autox_unlock.json')
38 raise error.TestFail('Could not unlock screensaver')
39 29
40 # wait for screen to unlock 30 # wait for screen to unlock
41 time.sleep(5) 31 time.sleep(5)
42 self.system_as('DISPLAY=:0.0 xscreensaver-command -time | ' + 32 self.system_as('DISPLAY=:0.0 xscreensaver-command -time | ' +
43 'grep -q non-blanked') 33 'grep -q non-blanked')
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698