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 from autotest_lib.client.bin import site_login, test as bin_test | 5 from autotest_lib.client.bin import site_login, test as bin_test |
6 from autotest_lib.client.common_lib import error | 6 from autotest_lib.client.common_lib import error |
7 | 7 |
8 | 8 |
9 class UITest(bin_test.test): | 9 class UITest(bin_test.test): |
10 """ | 10 """ |
11 Tests that require the user to be logged in should subclass this test | 11 Tests that require the user to be logged in should subclass this test |
12 This script by default logs in using the default remote account, however, | 12 This script by default logs in using the default remote account, however, |
13 tests can override this by setting script="your_script" in the control | 13 tests can override this by setting script="your_script" in the control |
14 file running the test | 14 file running the test |
15 """ | 15 """ |
16 version = 1 | 16 version = 1 |
17 | 17 |
18 | 18 |
19 def setup(self): | 19 def setup(self): |
20 site_login.setup_autox(self) | 20 site_login.setup_autox(self) |
21 | 21 |
22 | 22 |
23 def initialize(self, script='autox_script.json'): | 23 def initialize(self, script='autox_script.json'): |
24 # Clean up past state and assume logged out before logging in. | 24 # Clean up past state and assume logged out before logging in. |
25 if site_login.logged_in(): | 25 if site_login.logged_in(): |
26 if not site_login.attempt_logout(timeout=10): | 26 site_login.attempt_logout() |
27 raise error.TestFail('Could not logout from previous session') | |
28 if not site_login.wait_for_browser(): | |
29 raise error.TestFail("Login manager did not restart") | |
30 | 27 |
31 # Test account information embedded into json file. | 28 # Test account information embedded into json file. |
32 if not site_login.attempt_login(self, script): | 29 site_login.attempt_login(self, script) |
33 raise error.TestFail('Login failed at the beginning of new session') | 30 site_login.wait_for_initial_chrome_window() |
34 | 31 |
35 | |
36 """ | |
37 Logs out when object is deleted | |
38 """ | |
39 def cleanup(self): | 32 def cleanup(self): |
40 if not site_login.attempt_logout(): | 33 """Logs out when object is deleted""" |
41 raise error.TestFail('Could not logout at end of session') | 34 site_login.attempt_logout() |
OLD | NEW |