blob: a73bd462dbb05e41500aae1bcd04c3b6c3e00197 [file] [log] [blame]
Chris Sosad6d09422010-03-25 17:17:46 -07001# 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
5from autotest_lib.client.bin import site_login, test as bin_test
6from autotest_lib.client.common_lib import error
7
8
9class UITest(bin_test.test):
10 """
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,
13 tests can override this by setting script="your_script" in the control
14 file running the test
15 """
16 version = 1
17
18
19 def setup(self):
20 site_login.setup_autox(self)
21
22
23 def initialize(self, script='autox_script.json'):
24 # Clean up past state and assume logged out before logging in.
25 if site_login.logged_in():
26 if not site_login.attempt_logout(timeout=10):
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
31 # Test account information embedded into json file.
32 if not site_login.attempt_login(self, script):
33 raise error.TestFail('Login failed at the beginning of new session')
34
35
36 """
37 Logs out when object is deleted
38 """
39 def cleanup(self):
40 if not site_login.attempt_logout():
41 raise error.TestFail('Could not logout at end of session')