OLD | NEW |
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 | 6 |
7 '''Unit tests for grit.format.policy_templates.writers.reg_writer''' | 7 '''Unit tests for grit.format.policy_templates.writers.reg_writer''' |
8 | 8 |
9 | 9 |
10 import os | 10 import os |
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
217 example = { | 217 example = { |
218 'bool': True, | 218 'bool': True, |
219 'int': 10, | 219 'int': 10, |
220 'string': 'abc', | 220 'string': 'abc', |
221 'list': [1, 2, 3], | 221 'list': [1, 2, 3], |
222 'dict': { | 222 'dict': { |
223 'a': 1, | 223 'a': 1, |
224 'b': 2, | 224 'b': 2, |
225 } | 225 } |
226 } | 226 } |
227 # Encode |value| here, to make sure the string encoded within the reg_writer | |
228 # and the expected value are the same. | |
229 value = str(example) | |
230 grd = self.PrepareTest( | 227 grd = self.PrepareTest( |
231 '{' | 228 '{' |
232 ' "policy_definitions": [' | 229 ' "policy_definitions": [' |
233 ' {' | 230 ' {' |
234 ' "name": "DictionaryPolicy",' | 231 ' "name": "DictionaryPolicy",' |
235 ' "type": "dict",' | 232 ' "type": "dict",' |
236 ' "caption": "",' | 233 ' "caption": "",' |
237 ' "desc": "",' | 234 ' "desc": "",' |
238 ' "supported_on": ["chrome.win:8-"],' | 235 ' "supported_on": ["chrome.win:8-"],' |
239 ' "example_value": ' + value + | 236 ' "example_value": ' + str(example) + |
240 ' },' | 237 ' },' |
241 ' ],' | 238 ' ],' |
242 ' "placeholders": [],' | 239 ' "placeholders": [],' |
243 ' "messages": {},' | 240 ' "messages": {},' |
244 '}') | 241 '}') |
245 output = self.GetOutput(grd, 'fr', {'_chromium' : '1'}, 'reg', 'en') | 242 output = self.GetOutput(grd, 'fr', {'_chromium' : '1'}, 'reg', 'en') |
246 expected_output = self.NEWLINE.join([ | 243 expected_output = self.NEWLINE.join([ |
247 'Windows Registry Editor Version 5.00', | 244 'Windows Registry Editor Version 5.00', |
248 '', | 245 '', |
249 '[HKEY_LOCAL_MACHINE\\Software\\Policies\\Chromium]', | 246 '[HKEY_LOCAL_MACHINE\\Software\\Policies\\Chromium]', |
250 '"DictionaryPolicy"="%s"' % str(eval(value))]) | 247 '"DictionaryPolicy"="{\'bool\': True, \'dict\': {\'a\': 1, ' |
| 248 '\'b\': 2}, \'int\': 10, \'list\': [1, 2, 3], \'string\': \'abc\'}"']) |
251 self.CompareOutputs(output, expected_output) | 249 self.CompareOutputs(output, expected_output) |
252 | 250 |
253 def testNonSupportedPolicy(self): | 251 def testNonSupportedPolicy(self): |
254 # Tests a policy that is not supported on Windows, so it shouldn't | 252 # Tests a policy that is not supported on Windows, so it shouldn't |
255 # be included in the .REG file. | 253 # be included in the .REG file. |
256 grd = self.PrepareTest( | 254 grd = self.PrepareTest( |
257 '{' | 255 '{' |
258 ' "policy_definitions": [' | 256 ' "policy_definitions": [' |
259 ' {' | 257 ' {' |
260 ' "name": "NonWindowsPolicy",' | 258 ' "name": "NonWindowsPolicy",' |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
311 '"Policy2"="c"', | 309 '"Policy2"="c"', |
312 '', | 310 '', |
313 '[HKEY_LOCAL_MACHINE\\Software\\Policies\\Chromium\\Policy1]', | 311 '[HKEY_LOCAL_MACHINE\\Software\\Policies\\Chromium\\Policy1]', |
314 '"1"="a"', | 312 '"1"="a"', |
315 '"2"="b"']) | 313 '"2"="b"']) |
316 self.CompareOutputs(output, expected_output) | 314 self.CompareOutputs(output, expected_output) |
317 | 315 |
318 | 316 |
319 if __name__ == '__main__': | 317 if __name__ == '__main__': |
320 unittest.main() | 318 unittest.main() |
OLD | NEW |