| Index: tools/telemetry/telemetry/core/backends/chrome/cros_unittest.py
|
| diff --git a/tools/telemetry/telemetry/core/backends/chrome/cros_unittest.py b/tools/telemetry/telemetry/core/backends/chrome/cros_unittest.py
|
| index d3d5a2109fd4ab195d0c29ce62278e092cf4fca9..89afa7f44701abf587ca48dc7d14984a88acba2f 100644
|
| --- a/tools/telemetry/telemetry/core/backends/chrome/cros_unittest.py
|
| +++ b/tools/telemetry/telemetry/core/backends/chrome/cros_unittest.py
|
| @@ -14,7 +14,7 @@ from telemetry.core import util
|
| from telemetry.core.backends.chrome import cros_interface
|
| from telemetry.unittest import options_for_unittests
|
|
|
| -class CrOSTest(unittest.TestCase):
|
| +class CrOSTestCase(unittest.TestCase):
|
| def setUp(self):
|
| options = options_for_unittests.GetCopy()
|
| self._cri = cros_interface.CrOSInterface(options.cros_remote,
|
| @@ -63,6 +63,21 @@ class CrOSTest(unittest.TestCase):
|
| return self._cri.RunCmdOnDevice(
|
| ['/usr/sbin/cryptohome', '--action=is_mounted'])[0].strip() == 'true'
|
|
|
| + def _GetLoginStatus(self, browser):
|
| + extension = self._GetAutotestExtension(browser)
|
| + self.assertTrue(extension.EvaluateJavaScript(
|
| + "typeof('chrome.autotestPrivate') != 'undefined'"))
|
| + extension.ExecuteJavaScript('''
|
| + window.__login_status = null;
|
| + chrome.autotestPrivate.loginStatus(function(s) {
|
| + window.__login_status = s;
|
| + });
|
| + ''')
|
| + return util.WaitFor(
|
| + lambda: extension.EvaluateJavaScript('window.__login_status'), 10)
|
| +
|
| +
|
| +class CrOSCryptohomeTest(CrOSTestCase):
|
| @test.Enabled('chromeos')
|
| def testCryptohome(self):
|
| """Verifies cryptohome mount status for regular and guest user and when
|
| @@ -86,19 +101,8 @@ class CrOSTest(unittest.TestCase):
|
| self.assertEquals(self._cri.FilesystemMountedAt('/home/chronos/user'),
|
| '/dev/mapper/encstateful')
|
|
|
| - def _GetLoginStatus(self, browser):
|
| - extension = self._GetAutotestExtension(browser)
|
| - self.assertTrue(extension.EvaluateJavaScript(
|
| - "typeof('chrome.autotestPrivate') != 'undefined'"))
|
| - extension.ExecuteJavaScript('''
|
| - window.__login_status = null;
|
| - chrome.autotestPrivate.loginStatus(function(s) {
|
| - window.__login_status = s;
|
| - });
|
| - ''')
|
| - return util.WaitFor(
|
| - lambda: extension.EvaluateJavaScript('window.__login_status'), 10)
|
|
|
| +class CrOSLoginTest(CrOSTestCase):
|
| @test.Enabled('chromeos')
|
| def testLoginStatus(self):
|
| """Tests autotestPrivate.loginStatus"""
|
| @@ -113,6 +117,22 @@ class CrOSTest(unittest.TestCase):
|
| self.assertEquals(login_status['email'], self._username)
|
| self.assertFalse(login_status['isScreenLocked'])
|
|
|
| + @test.Enabled('chromeos')
|
| + def testLogout(self):
|
| + """Tests autotestPrivate.logout"""
|
| + if self._is_guest:
|
| + return
|
| + with self._CreateBrowser(autotest_ext=True) as b:
|
| + extension = self._GetAutotestExtension(b)
|
| + try:
|
| + extension.ExecuteJavaScript('chrome.autotestPrivate.logout();')
|
| + except (exceptions.BrowserConnectionGoneException,
|
| + exceptions.BrowserGoneException):
|
| + pass
|
| + util.WaitFor(lambda: not self._IsCryptohomeMounted(), 20)
|
| +
|
| +
|
| +class CrOSScreenLockerTest(CrOSTestCase):
|
| def _IsScreenLocked(self, browser):
|
| return self._GetLoginStatus(browser)['isScreenLocked']
|
|
|
| @@ -164,17 +184,3 @@ class CrOSTest(unittest.TestCase):
|
| self._LockScreen(browser)
|
| self._AttemptUnlockBadPassword(browser)
|
| self._UnlockScreen(browser)
|
| -
|
| - @test.Enabled('chromeos')
|
| - def testLogout(self):
|
| - """Tests autotestPrivate.logout"""
|
| - if self._is_guest:
|
| - return
|
| - with self._CreateBrowser(autotest_ext=True) as b:
|
| - extension = self._GetAutotestExtension(b)
|
| - try:
|
| - extension.ExecuteJavaScript('chrome.autotestPrivate.logout();')
|
| - except (exceptions.BrowserConnectionGoneException,
|
| - exceptions.BrowserGoneException):
|
| - pass
|
| - util.WaitFor(lambda: not self._IsCryptohomeMounted(), 20)
|
|
|