| OLD | NEW |
| 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 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 212 # Ugly hack: session manager won't spawn chrome if this file exists. That's | 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 | 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 | 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 | 215 # after session manager and chrome have restarted, and will setup the |
| 216 # automation channel. | 216 # automation channel. |
| 217 restore_magic_file = False | 217 restore_magic_file = False |
| 218 if os.path.exists(constants.DISABLE_BROWSER_RESTART_MAGIC_FILE): | 218 if os.path.exists(constants.DISABLE_BROWSER_RESTART_MAGIC_FILE): |
| 219 logging.debug('DISABLE_BROWSER_RESTART_MAGIC_FILE found. ' | 219 logging.debug('DISABLE_BROWSER_RESTART_MAGIC_FILE found. ' |
| 220 'Removing temporarily for the next restart.') | 220 'Removing temporarily for the next restart.') |
| 221 restore_magic_file = True | 221 restore_magic_file = True |
| 222 os.path.remove(constants.DISABLE_BROWSER_RESTART_MAGIC_FILE) | 222 os.remove(constants.DISABLE_BROWSER_RESTART_MAGIC_FILE) |
| 223 assert not os.path.exists(constants.DISABLE_BROWSER_RESTART_MAGIC_FILE) | 223 assert not os.path.exists(constants.DISABLE_BROWSER_RESTART_MAGIC_FILE) |
| 224 | 224 |
| 225 logging.debug('Starting session manager again') | 225 logging.debug('Starting session manager again') |
| 226 cros_ui.start() | 226 cros_ui.start() |
| 227 | 227 |
| 228 # cros_ui.start() waits for the login prompt to be visible, so chrome has | 228 # cros_ui.start() waits for the login prompt to be visible, so chrome has |
| 229 # already started once it returns. | 229 # already started once it returns. |
| 230 if restore_magic_file: | 230 if restore_magic_file: |
| 231 open(constants.DISABLE_BROWSER_RESTART_MAGIC_FILE, 'w').close() | 231 open(constants.DISABLE_BROWSER_RESTART_MAGIC_FILE, 'w').close() |
| 232 assert os.path.exists(constants.DISABLE_BROWSER_RESTART_MAGIC_FILE) | 232 assert os.path.exists(constants.DISABLE_BROWSER_RESTART_MAGIC_FILE) |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 300 | 300 |
| 301 This policies will have been installed after this call returns. | 301 This policies will have been installed after this call returns. |
| 302 """ | 302 """ |
| 303 if self.IsChromeOS(): | 303 if self.IsChromeOS(): |
| 304 self._SetCloudPolicies(user_mandatory=user_policy, device=device_policy) | 304 self._SetCloudPolicies(user_mandatory=user_policy, device=device_policy) |
| 305 self.RefreshPolicies() | 305 self.RefreshPolicies() |
| 306 elif not self.GetBrowserInfo()['properties']['is_official']: | 306 elif not self.GetBrowserInfo()['properties']['is_official']: |
| 307 pyauto.PyUITest.SetPolicies(self, managed_platform=user_policy) | 307 pyauto.PyUITest.SetPolicies(self, managed_platform=user_policy) |
| 308 else: | 308 else: |
| 309 raise AssertionError('Not available on this platform and build.') | 309 raise AssertionError('Not available on this platform and build.') |
| OLD | NEW |