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

Side by Side 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 unified diff | Download patch
OLDNEW
(Empty)
1 # Copyright (c) 2012 The Chromium 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 import pyauto_functional # Must come before pyauto (and thus, policy_base).
6 import policy_base
7
8
9 class ChromeosDevicePolicy(policy_base.PolicyTestBase):
10 """Tests various ChromeOS device policies."""
11
12 def _SetDevicePolicyAndOwner(self, policy):
13 self.SetDevicePolicy(device_policy=policy, owner=self._owner)
14
15 def Login(self, as_guest):
16 self.assertFalse(self.GetLoginInfo()['is_logged_in'],
17 msg='Expected to be logged out.')
18 if as_guest:
19 self.LoginAsGuest()
20 else:
21 policy_base.PolicyTestBase.Login(self, self._owner, self._password)
22 self.assertTrue(self.GetLoginInfo()['is_logged_in'],
23 msg='Expected to be logged in.')
24
25 # TODO(bartfab): Remove this after crosbug.com/20709 is fixed.
26 def TryToDisableLocalStateAutoClearing(self):
27 # Try to disable automatic clearing of the local state.
28 self.TryToDisableLocalStateAutoClearingOnChromeOS()
29 self._local_state_auto_clearing = \
30 self.IsLocalStateAutoClearingEnabledOnChromeOS()
31 if not self._local_state_auto_clearing:
32 # Prevent the inherited Logout() method from cleaning up /home/chronos
33 # as this also clears the local state.
34 self.set_clear_profile(False)
35
36 def ExtraChromeFlags(self):
37 """Sets up Chrome to skip OOBE.
38
39 TODO(bartfab): Ensure OOBE is still skipped when crosbug.com/20709 is fixed.
40 Disabling automatic clearing of the local state has the curious side effect
41 of removing a flag that disables OOBE. This method adds back the flag.
42 """
43 flags = policy_base.PolicyTestBase.ExtraChromeFlags(self)
44 flags.append('--login-screen=login')
45 return flags
46
47 def setUp(self):
48 policy_base.PolicyTestBase.setUp(self)
49 # TODO(bartfab): Remove this after crosbug.com/20709 is fixed.
50 self._local_state_auto_clearing = \
51 self.IsLocalStateAutoClearingEnabledOnChromeOS()
52
53 # Cache owner credentials for easy lookup.
54 credentials = self.GetPrivateInfo()['prod_enterprise_test_user']
55 self._owner = credentials['username']
56 self._password = credentials['password']
57
58 def tearDown(self):
59 # TODO(bartfab): Remove this after crosbug.com/20709 is fixed.
60 # Try to re-enable automatic clearing of the local state and /home/chronos.
61 if not self._local_state_auto_clearing:
62 self.TryToEnableLocalStateAutoClearingOnChromeOS()
63 self.set_clear_profile(True)
64 policy_base.PolicyTestBase.tearDown(self)
65
66 def _CheckGuestModeAvailableInLoginWindow(self):
67 return self.ExecuteJavascriptInOOBEWebUI(
68 """window.domAutomationController.send(
69 !document.getElementById('guestSignin').hidden);""")
70
71 def _CheckGuestModeVailableInAccountPicker(self):
72 return self.ExecuteJavascriptInOOBEWebUI(
73 """window.domAutomationController.send(
74 !!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
75 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
76
77 def testGuestModeEnabled(self):
78 self._SetDevicePolicyAndOwner({'guest_mode_enabled': True})
79 self.assertTrue(self._CheckGuestModeAvailableInLoginWindow(),
80 msg='Expected guest mode to be available.')
81 self.Login(as_guest=True)
82 self.Logout()
83
84 self._SetDevicePolicyAndOwner({'guest_mode_enabled': False})
85 self.assertFalse(self._CheckGuestModeAvailableInLoginWindow(),
86 msg='Expected guest mode to not be available.')
87
88 # TODO(bartfab): Remove this after crosbug.com/20709 is fixed.
89 self.TryToDisableLocalStateAutoClearing()
90 if self._local_state_auto_clearing:
91 logging.warn("""Unable to disable local state clearing. Skipping remainder
92 of test.""")
93 return
94
95 # 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.
96 # the account picker is shown.
97 self.Login(as_guest=False)
98 self.Logout()
99
100 self._SetDevicePolicyAndOwner({'guest_mode_enabled': True})
101 self.assertTrue(self._CheckGuestModeVailableInAccountPicker(),
102 msg='Expected guest mode to be available.')
103 self.Login(as_guest=True)
104 self.Logout()
105
106 self._SetDevicePolicyAndOwner({'guest_mode_enabled': False})
107 self.assertFalse(self._CheckGuestModeVailableInAccountPicker(),
108 msg='Expected guest mode to not be available.')
109
110
111 if __name__ == '__main__':
112 pyauto_functional.Main()
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698