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

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

Issue 3073014: Autotest for ScreenLocker (Closed) Base URL: ssh://git@gitrw.chromium.org/autotest.git
Patch Set: bvt only Created 10 years, 4 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
(Empty)
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
3 # found in the LICENSE file.
4
5 import dbus
6 import gobject
7 import os
8 import time
9
10 from autotest_lib.client.bin import site_ui_test, site_utils
11 from autotest_lib.client.common_lib import error
12 from dbus.mainloop.glib import DBusGMainLoop
13
14 class desktopui_ScreenLocker(site_ui_test.UITest):
15 version = 1
16 _POWER_MANAGER_INTERFACE = 'org.chromium.PowerManager'
17
18 def locked(self):
19 self._locked = True
20
21 def unlocked(self):
22 self._locked = False
23
24 def process_event(self):
25 """Process dbus events"""
26 context = gobject.MainLoop().get_context()
27 while context.iteration(False):
28 pass
29
30 def is_screen_locked(self):
31 self.process_event()
32 return self._locked
33
34 def is_screen_unlocked(self):
35 self.process_event()
36 return self._locked == False
37
38 def run_once(self):
39 self._locked = False
40 self.listen_to_signal(lambda: self.locked(),
41 'ScreenIsLocked',
42 self._POWER_MANAGER_INTERFACE)
43 self.listen_to_signal(lambda: self.unlocked(),
44 'ScreenIsUnlocked',
45 self._POWER_MANAGER_INTERFACE)
46 # wait 2 seconds to make sure chrome registers
47 # the accelerator.
48 time.sleep(5);
49
50 ax = self.get_autox()
51 ax.send_hotkey('Ctrl-Alt-l')
52
53 site_utils.poll_for_condition(
54 condition=lambda: self.is_screen_locked(),
55 desc='screenlocker lock')
56
57 # send an incorrect password
58 ax.send_text('_boguspassword_')
59 ax.send_hotkey('Return')
60
61 # verify that the screen unlock attempt failed
62 try:
63 site_utils.poll_for_condition(
64 condition=lambda: self.is_screen_unlocked(),
65 desc='screen unlock',
66 timeout=5)
67 except error.TestError:
68 pass
69 else:
70 raise error.TestFail('screen locker unlocked with bogus password.')
71
72 # send the correct password
73 ax.send_text(self.password)
74 ax.send_hotkey('Return')
75
76 # wait for screen to unlock
77 site_utils.poll_for_condition(
78 condition=lambda: self.is_screen_unlocked(),
79 desc='screenlocker unlock')
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698