1 # Copyright (c) 2013 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 from autotest_lib.client.bin import test 6 from autotest_lib.client.common_lib import error 7 from autotest_lib.client.common_lib.cros import chrome 8 9 10 class telemetry_LoginTest(test.test): 11 """This is a client side Telemetry Login Test.""" 12 version = 1 13 14 15 def _get_login_status(self, cr): 16 login_status = cr.login_status 17 if not login_status: 18 raise error.TestFail('Failed to get LoginStatus') 19 20 if type(login_status) != dict: 21 raise error.TestFail('LoginStatus type mismatch %r' 22 % type(login_status)) 23 24 is_regular_user = login_status['isRegularUser'] 25 is_guest = login_status['isGuest'] 26 email = login_status['email'] 27 if is_regular_user == is_guest: 28 raise error.TestFail('isRegularUser == isGuest') 29 return (is_regular_user, email) 30 31 32 def run_once(self, arc_mode=None): 33 """Test chrome login status. 34 35 This test uses telemetry via chrome.py to log in as a regular user, 36 and then checks chrome login status via the private extension api 37 autotestPrivate.loginStatus. 38 """ 39 with chrome.Chrome(logged_in=True, autotest_ext=True, 40 arc_mode=arc_mode) as cr: 41 (is_regular_user, email) = self._get_login_status(cr) 42 if not is_regular_user: 43 raise error.TestFail('isRegularUser should be True') 44 if email != cr.username: 45 raise error.TestFail('user email mismatch %s' % email) 46