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

Side by Side Diff: chrome/test/pyautolib/policy_base.py

Issue 8852002: Moved the policy functional tests to their own suite on ChromeOS. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebased Created 9 years 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 | Annotate | Revision Log
« no previous file with comments | « chrome/test/functional/PYAUTO_TESTS ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/python 1 #!/usr/bin/python
2 # Copyright (c) 2011 The Chromium Authors. All rights reserved. 2 # Copyright (c) 2011 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be 3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file. 4 # found in the LICENSE file.
5 5
6 """Base class for tests that need to update the policies enforced by Chrome. 6 """Base class for tests that need to update the policies enforced by Chrome.
7 7
8 Subclasses can call SetPolicies with a dictionary of policies to install. 8 Subclasses can call SetPolicies with a dictionary of policies to install.
9 SetPolicies can also be used to set the device policies on ChromeOS. 9 SetPolicies can also be used to set the device policies on ChromeOS.
10 10
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after
201 assert fetch_response.new_public_key 201 assert fetch_response.new_public_key
202 return fetch_response 202 return fetch_response
203 203
204 def _WriteDevicePolicyWithSessionManagerStopped(self, policy): 204 def _WriteDevicePolicyWithSessionManagerStopped(self, policy):
205 """Writes the device policy blob while the Session Manager is stopped.""" 205 """Writes the device policy blob while the Session Manager is stopped."""
206 assert pyauto.PyUITest.IsChromeOS() 206 assert pyauto.PyUITest.IsChromeOS()
207 logging.debug('Stopping session manager') 207 logging.debug('Stopping session manager')
208 cros_ui.stop() 208 cros_ui.stop()
209 logging.debug('Writing device policy cache') 209 logging.debug('Writing device policy cache')
210 self._WriteDevicePolicy(policy) 210 self._WriteDevicePolicy(policy)
211
212 # Ugly hack: session manager won't spawn chrome if this file exists. That's
213 # usually a good thing (to keep the automation channel open), but in this
214 # case we really want to restart chrome. PyUITest.setUp() will be called
215 # after session manager and chrome have restarted, and will setup the
216 # automation channel.
217 restore_magic_file = False
218 if os.path.exists(constants.DISABLE_BROWSER_RESTART_MAGIC_FILE):
219 logging.debug('DISABLE_BROWSER_RESTART_MAGIC_FILE found. '
220 'Removing temporarily for the next restart.')
221 restore_magic_file = True
222 os.path.remove(constants.DISABLE_BROWSER_RESTART_MAGIC_FILE)
223 assert not os.path.exists(constants.DISABLE_BROWSER_RESTART_MAGIC_FILE)
224
211 logging.debug('Starting session manager again') 225 logging.debug('Starting session manager again')
212 cros_ui.start() 226 cros_ui.start()
213 227
228 # cros_ui.start() waits for the login prompt to be visible, so chrome has
229 # already started once it returns.
230 if restore_magic_file:
231 open(constants.DISABLE_BROWSER_RESTART_MAGIC_FILE, 'w').close()
232 assert os.path.exists(constants.DISABLE_BROWSER_RESTART_MAGIC_FILE)
233
214 def ExtraChromeFlags(self): 234 def ExtraChromeFlags(self):
215 """Sets up Chrome to use cloud policies on ChromeOS.""" 235 """Sets up Chrome to use cloud policies on ChromeOS."""
216 flags = pyauto.PyUITest.ExtraChromeFlags(self) 236 flags = pyauto.PyUITest.ExtraChromeFlags(self)
217 if self.IsChromeOS(): 237 if self.IsChromeOS():
218 url = self._GetHttpURLForDeviceManagement() 238 url = self._GetHttpURLForDeviceManagement()
219 flag = '--device-management-url=' + url 239 flag = '--device-management-url=' + url
220 flags += [flag] 240 flags += [flag]
221 return flags 241 return flags
222 242
223 def setUp(self): 243 def setUp(self):
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
280 300
281 This policies will have been installed after this call returns. 301 This policies will have been installed after this call returns.
282 """ 302 """
283 if self.IsChromeOS(): 303 if self.IsChromeOS():
284 self._SetCloudPolicies(user_mandatory=user_policy, device=device_policy) 304 self._SetCloudPolicies(user_mandatory=user_policy, device=device_policy)
285 self.RefreshPolicies() 305 self.RefreshPolicies()
286 elif not self.GetBrowserInfo()['properties']['is_official']: 306 elif not self.GetBrowserInfo()['properties']['is_official']:
287 pyauto.PyUITest.SetPolicies(self, managed_platform=user_policy) 307 pyauto.PyUITest.SetPolicies(self, managed_platform=user_policy)
288 else: 308 else:
289 raise AssertionError('Not available on this platform and build.') 309 raise AssertionError('Not available on this platform and build.')
OLDNEW
« no previous file with comments | « chrome/test/functional/PYAUTO_TESTS ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698