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

Side by Side Diff: chrome/test/functional/chromeos_onc.py

Issue 9791023: Allow setting of user and device policies in functional tests (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Oops... turns out these constants are reference by other files after all. Created 8 years, 8 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
1 #!/usr/bin/env python 1 #!/usr/bin/env 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 import os 6 import os
7 7
8 import pyauto_functional # must come before pyauto. 8 import pyauto_functional # must come before pyauto.
9 import policy_base 9 import policy_base
10 import pyauto 10 import pyauto
11 11
12 12
13 class ChromeosONC(policy_base.PolicyTestBase): 13 class ChromeosONC(policy_base.PolicyTestBase):
14 """ 14 """
15 Tests for Open Network Configuration (ONC). 15 Tests for Open Network Configuration (ONC).
16 16
17 Open Network Configuration (ONC) files is a json dictionary 17 Open Network Configuration (ONC) files is a json dictionary
18 that contains network configurations and is pulled via policies. 18 that contains network configurations and is pulled via policies.
19 These tests verify that ONC files that are formatted correctly 19 These tests verify that ONC files that are formatted correctly
20 add the network/certificate to the device. 20 add the network/certificate to the device.
21 """ 21 """
22 22
23 ONC_PATH = os.path.join(pyauto.PyUITest.DataDir(), 'chromeos', 'cros') 23 ONC_PATH = os.path.join(pyauto.PyUITest.DataDir(), 'chromeos', 'cros')
24 24
25 def setUp(self): 25 def setUp(self):
26 policy_base.PolicyTestBase.setUp(self) 26 policy_base.PolicyTestBase.setUp(self)
27 self.CleanupFlimflamDirsOnChromeOS() 27 self.CleanupFlimflamDirsOnChromeOS()
28 self.LoginWithTestAccount()
28 29
29 def _ReadONCFileAndSet(self, filename): 30 def _ReadONCFileAndSet(self, filename):
30 """Reads the specified ONC file and sends it as a policy. 31 """Reads the specified ONC file and sends it as a policy.
31 32
32 Inputs: 33 Inputs:
33 filename: The filename of the ONC file. ONC files should 34 filename: The filename of the ONC file. ONC files should
34 all be stored in the path defined by ONC_PATH. 35 all be stored in the path defined by ONC_PATH.
35 """ 36 """
36 with open(os.path.join(self.ONC_PATH, filename)) as fp: 37 with open(os.path.join(self.ONC_PATH, filename)) as fp:
37 self.SetPolicies({'OpenNetworkConfiguration': fp.read()}) 38 self.SetUserPolicy({'OpenNetworkConfiguration': fp.read()})
38 39
39 def _VerifyRememberedWifiNetworks(self, wifi_expect): 40 def _VerifyRememberedWifiNetworks(self, wifi_expect):
40 """Verify the list of remembered networks contains those in wifi_expect. 41 """Verify the list of remembered networks contains those in wifi_expect.
41 42
42 Inputs: 43 Inputs:
43 wifi_expect: A dictionary of wifi networks where the key is the ssid 44 wifi_expect: A dictionary of wifi networks where the key is the ssid
44 and the value is the encryption type of the network. 45 and the value is the encryption type of the network.
45 """ 46 """
46 # Sometimes there is a race condition where upon restarting chrome 47 # Sometimes there is a race condition where upon restarting chrome
47 # NetworkScan has not populated the network lists yet. We should 48 # NetworkScan has not populated the network lists yet. We should
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
112 'ssid-none': '', 113 'ssid-none': '',
113 'ssid-wpa': 'PSK' 114 'ssid-wpa': 'PSK'
114 } 115 }
115 116
116 self._ReadONCFileAndSet('network-multiple-unknown.onc') 117 self._ReadONCFileAndSet('network-multiple-unknown.onc')
117 self._VerifyRememberedWifiNetworks(wifi_networks) 118 self._VerifyRememberedWifiNetworks(wifi_networks)
118 119
119 120
120 if __name__ == '__main__': 121 if __name__ == '__main__':
121 pyauto_functional.Main() 122 pyauto_functional.Main()
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698