blob: cbef8bce2123debd4a246fddf5f2f796f3f05bc2 [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
Ken Mixter2e32fd42010-03-28 19:25:51 -07007
Chris Sosad6d09422010-03-25 17:17:46 -07008
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
Ken Mixter2e32fd42010-03-28 19:25:51 -070017
18
Chris Sosad6d09422010-03-25 17:17:46 -070019 def setup(self):
20 site_login.setup_autox(self)
Ken Mixter2e32fd42010-03-28 19:25:51 -070021
22
Chris Sosad6d09422010-03-25 17:17:46 -070023 def initialize(self, script='autox_script.json'):
Ken Mixter2e32fd42010-03-28 19:25:51 -070024 # Clean up past state and assume logged out before logging in.
Chris Sosad6d09422010-03-25 17:17:46 -070025 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):
Ken Mixter2e32fd42010-03-28 19:25:51 -070033 raise error.TestFail('Login failed at the beginning of new session')
Chris Sosad6d09422010-03-25 17:17:46 -070034
Ken Mixter2e32fd42010-03-28 19:25:51 -070035
Chris Sosad6d09422010-03-25 17:17:46 -070036 """
37 Logs out when object is deleted
Ken Mixter2e32fd42010-03-28 19:25:51 -070038 """
Chris Sosad6d09422010-03-25 17:17:46 -070039 def cleanup(self):
40 if not site_login.attempt_logout():
Ken Mixter2e32fd42010-03-28 19:25:51 -070041 raise error.TestFail('Could not logout at end of session')