Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3325)

Unified Diff: chrome/test/functional/chromeos_device_policy.py

Issue 10382197: Add PyAuto test for DeviceGuestModeEnabled policy (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Grammar/spelling fixes in comment. Created 8 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/test/functional/chromeos_device_policy.py
diff --git a/chrome/test/functional/chromeos_device_policy.py b/chrome/test/functional/chromeos_device_policy.py
new file mode 100644
index 0000000000000000000000000000000000000000..73d93c1eb3ea5b3bae45ebc4c28ce438ea94fb94
--- /dev/null
+++ b/chrome/test/functional/chromeos_device_policy.py
@@ -0,0 +1,112 @@
+# Copyright (c) 2012 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+import pyauto_functional # Must come before pyauto (and thus, policy_base).
+import policy_base
+
+
+class ChromeosDevicePolicy(policy_base.PolicyTestBase):
+ """Tests various ChromeOS device policies."""
+
+ def _SetDevicePolicyAndOwner(self, policy):
+ self.SetDevicePolicy(device_policy=policy, owner=self._owner)
+
+ def Login(self, as_guest):
+ self.assertFalse(self.GetLoginInfo()['is_logged_in'],
+ msg='Expected to be logged out.')
+ if as_guest:
+ self.LoginAsGuest()
+ else:
+ policy_base.PolicyTestBase.Login(self, self._owner, self._password)
+ self.assertTrue(self.GetLoginInfo()['is_logged_in'],
+ msg='Expected to be logged in.')
+
+ # TODO(bartfab): Remove this after crosbug.com/20709 is fixed.
+ def TryToDisableLocalStateAutoClearing(self):
+ # Try to disable automatic clearing of the local state.
+ self.TryToDisableLocalStateAutoClearingOnChromeOS()
+ self._local_state_auto_clearing = \
+ self.IsLocalStateAutoClearingEnabledOnChromeOS()
+ if not self._local_state_auto_clearing:
+ # Prevent the inherited Logout() method from cleaning up /home/chronos
+ # as this also clears the local state.
+ self.set_clear_profile(False)
+
+ def ExtraChromeFlags(self):
+ """Sets up Chrome to skip OOBE.
+
+ TODO(bartfab): Ensure OOBE is still skipped when crosbug.com/20709 is fixed.
+ Disabling automatic clearing of the local state has the curious side effect
+ of removing a flag that disables OOBE. This method adds back the flag.
+ """
+ flags = policy_base.PolicyTestBase.ExtraChromeFlags(self)
+ flags.append('--login-screen=login')
+ return flags
+
+ def setUp(self):
+ policy_base.PolicyTestBase.setUp(self)
+ # TODO(bartfab): Remove this after crosbug.com/20709 is fixed.
+ self._local_state_auto_clearing = \
+ self.IsLocalStateAutoClearingEnabledOnChromeOS()
+
+ # Cache owner credentials for easy lookup.
+ credentials = self.GetPrivateInfo()['prod_enterprise_test_user']
+ self._owner = credentials['username']
+ self._password = credentials['password']
+
+ def tearDown(self):
+ # TODO(bartfab): Remove this after crosbug.com/20709 is fixed.
+ # Try to re-enable automatic clearing of the local state and /home/chronos.
+ if not self._local_state_auto_clearing:
+ self.TryToEnableLocalStateAutoClearingOnChromeOS()
+ self.set_clear_profile(True)
+ policy_base.PolicyTestBase.tearDown(self)
+
+ def _CheckGuestModeAvailableInLoginWindow(self):
+ return self.ExecuteJavascriptInOOBEWebUI(
+ """window.domAutomationController.send(
+ !document.getElementById('guestSignin').hidden);""")
+
+ def _CheckGuestModeVailableInAccountPicker(self):
+ return self.ExecuteJavascriptInOOBEWebUI(
+ """window.domAutomationController.send(
+ !!document.getElementById('pod-row').
Nirnimesh 2012/05/16 15:44:37 is that a double negation?
bartfab (slow) 2012/05/16 18:07:10 Yes, a common way to cast to bool in JavaScript, u
+ getPodWithUsername_(''));""")
Nirnimesh 2012/05/16 15:44:37 It looks like this fits in the previous line. Does
bartfab (slow) 2012/05/16 18:07:10 If I leave the """ on their own line, the rest fit
+
+ def testGuestModeEnabled(self):
+ self._SetDevicePolicyAndOwner({'guest_mode_enabled': True})
+ self.assertTrue(self._CheckGuestModeAvailableInLoginWindow(),
+ msg='Expected guest mode to be available.')
+ self.Login(as_guest=True)
+ self.Logout()
+
+ self._SetDevicePolicyAndOwner({'guest_mode_enabled': False})
+ self.assertFalse(self._CheckGuestModeAvailableInLoginWindow(),
+ msg='Expected guest mode to not be available.')
+
+ # TODO(bartfab): Remove this after crosbug.com/20709 is fixed.
+ self.TryToDisableLocalStateAutoClearing()
+ if self._local_state_auto_clearing:
+ logging.warn("""Unable to disable local state clearing. Skipping remainder
+ of test.""")
+ return
+
+ # Log in in as a regular so that the pod row contains at least one pod and
Nirnimesh 2012/05/16 15:44:37 remove double 'in'
bartfab (slow) 2012/05/16 18:07:10 Done.
+ # the account picker is shown.
+ self.Login(as_guest=False)
+ self.Logout()
+
+ self._SetDevicePolicyAndOwner({'guest_mode_enabled': True})
+ self.assertTrue(self._CheckGuestModeVailableInAccountPicker(),
+ msg='Expected guest mode to be available.')
+ self.Login(as_guest=True)
+ self.Logout()
+
+ self._SetDevicePolicyAndOwner({'guest_mode_enabled': False})
+ self.assertFalse(self._CheckGuestModeVailableInAccountPicker(),
+ msg='Expected guest mode to not be available.')
+
+
+if __name__ == '__main__':
+ pyauto_functional.Main()

Powered by Google App Engine
This is Rietveld 408576698