OLD | NEW |
1 #!/usr/bin/python | 1 #!/usr/bin/python |
2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2012 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 269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
280 | 280 |
281 self._WriteUserPolicyToken(user_dmtoken) | 281 self._WriteUserPolicyToken(user_dmtoken) |
282 # The browser has to be reloaded to make the user policy token cache | 282 # The browser has to be reloaded to make the user policy token cache |
283 # reload the file just written. The file can also be written only after | 283 # reload the file just written. The file can also be written only after |
284 # the cryptohome is mounted, after login. | 284 # the cryptohome is mounted, after login. |
285 self.RestartBrowser(clear_profile=False) | 285 self.RestartBrowser(clear_profile=False) |
286 | 286 |
287 def tearDown(self): | 287 def tearDown(self): |
288 """Cleans up the files created by setUp.""" | 288 """Cleans up the files created by setUp.""" |
289 if self.IsChromeOS(): | 289 if self.IsChromeOS(): |
| 290 pyauto.PyUITest.Logout(self) |
| 291 |
| 292 pyauto.PyUITest.tearDown(self) |
| 293 |
| 294 if self.IsChromeOS(): |
290 self.StopHTTPServer(self._http_server) | 295 self.StopHTTPServer(self._http_server) |
291 pyauto_utils.RemovePath(self._temp_data_dir) | 296 pyauto_utils.RemovePath(self._temp_data_dir) |
292 pyauto.PyUITest.tearDown(self) | |
293 | 297 |
294 def SetPolicies(self, user_policy=None, device_policy=None): | 298 def SetPolicies(self, user_policy=None, device_policy=None): |
295 """Enforces the policies given in the arguments as dictionaries. | 299 """Enforces the policies given in the arguments as dictionaries. |
296 | 300 |
297 device_policy will be applied on ChromeOS only, and ignored on other | 301 device_policy will be applied on ChromeOS only, and ignored on other |
298 platforms. | 302 platforms. |
299 | 303 |
300 On other platforms, this call is only available on non-official builds. | 304 On other platforms, this call is only available on non-official builds. |
301 | 305 |
302 This policies will have been installed after this call returns. | 306 This policies will have been installed after this call returns. |
303 """ | 307 """ |
304 if self.IsChromeOS(): | 308 if self.IsChromeOS(): |
305 self._SetCloudPolicies(user_mandatory=user_policy, device=device_policy) | 309 self._SetCloudPolicies(user_mandatory=user_policy, device=device_policy) |
306 self.RefreshPolicies() | 310 self.RefreshPolicies() |
307 elif not self.GetBrowserInfo()['properties']['is_official']: | 311 elif not self.GetBrowserInfo()['properties']['is_official']: |
308 pyauto.PyUITest.SetPolicies(self, managed_platform=user_policy) | 312 pyauto.PyUITest.SetPolicies(self, managed_platform=user_policy) |
309 else: | 313 else: |
310 raise AssertionError('Not available on this platform and build.') | 314 raise AssertionError('Not available on this platform and build.') |
OLD | NEW |