| 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 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 209 'Windows Registry Editor Version 5.00', | 209 'Windows Registry Editor Version 5.00', |
| 210 '', | 210 '', |
| 211 '[HKEY_LOCAL_MACHINE\\Software\\Policies\\Chromium\\ListPolicy]', | 211 '[HKEY_LOCAL_MACHINE\\Software\\Policies\\Chromium\\ListPolicy]', |
| 212 '"1"="foo"', | 212 '"1"="foo"', |
| 213 '"2"="bar"']) | 213 '"2"="bar"']) |
| 214 | 214 |
| 215 def testDictionaryPolicy(self): | 215 def testDictionaryPolicy(self): |
| 216 # Tests a policy group with a single policy of type 'dict'. | 216 # Tests a policy group with a single policy of type 'dict'. |
| 217 example = { | 217 example = { |
| 218 'bool': True, | 218 'bool': True, |
| 219 'int': 10, | |
| 220 'string': 'abc', | |
| 221 'list': [1, 2, 3], | |
| 222 'dict': { | 219 'dict': { |
| 223 'a': 1, | 220 'a': 1, |
| 224 'b': 2, | 221 'b': 2, |
| 225 } | 222 }, |
| 223 'int': 10, |
| 224 'list': [1, 2, 3], |
| 225 'string': 'abc', |
| 226 } | 226 } |
| 227 grd = self.PrepareTest( | 227 grd = self.PrepareTest( |
| 228 '{' | 228 '{' |
| 229 ' "policy_definitions": [' | 229 ' "policy_definitions": [' |
| 230 ' {' | 230 ' {' |
| 231 ' "name": "DictionaryPolicy",' | 231 ' "name": "DictionaryPolicy",' |
| 232 ' "type": "dict",' | 232 ' "type": "dict",' |
| 233 ' "caption": "",' | 233 ' "caption": "",' |
| 234 ' "desc": "",' | 234 ' "desc": "",' |
| 235 ' "supported_on": ["chrome.win:8-"],' | 235 ' "supported_on": ["chrome.win:8-"],' |
| 236 ' "example_value": ' + str(example) + | 236 ' "example_value": ' + str(example) + |
| 237 ' },' | 237 ' },' |
| 238 ' ],' | 238 ' ],' |
| 239 ' "placeholders": [],' | 239 ' "placeholders": [],' |
| 240 ' "messages": {},' | 240 ' "messages": {},' |
| 241 '}') | 241 '}') |
| 242 output = self.GetOutput(grd, 'fr', {'_chromium' : '1'}, 'reg', 'en') | 242 output = self.GetOutput(grd, 'fr', {'_chromium' : '1'}, 'reg', 'en') |
| 243 expected_output = self.NEWLINE.join([ | 243 expected_output = self.NEWLINE.join([ |
| 244 'Windows Registry Editor Version 5.00', | 244 'Windows Registry Editor Version 5.00', |
| 245 '', | 245 '', |
| 246 '[HKEY_LOCAL_MACHINE\\Software\\Policies\\Chromium]', | 246 '[HKEY_LOCAL_MACHINE\\Software\\Policies\\Chromium]', |
| 247 '"DictionaryPolicy"="{\'bool\': True, \'dict\': {\'a\': 1, ' | 247 '"DictionaryPolicy"="{"bool": true, "dict": {"a": 1, ' |
| 248 '\'b\': 2}, \'int\': 10, \'list\': [1, 2, 3], \'string\': \'abc\'}"']) | 248 '"b": 2}, "int": 10, "list": [1, 2, 3], "string": "abc"}"']) |
| 249 self.CompareOutputs(output, expected_output) | 249 self.CompareOutputs(output, expected_output) |
| 250 | 250 |
| 251 def testNonSupportedPolicy(self): | 251 def testNonSupportedPolicy(self): |
| 252 # 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 |
| 253 # be included in the .REG file. | 253 # be included in the .REG file. |
| 254 grd = self.PrepareTest( | 254 grd = self.PrepareTest( |
| 255 '{' | 255 '{' |
| 256 ' "policy_definitions": [' | 256 ' "policy_definitions": [' |
| 257 ' {' | 257 ' {' |
| 258 ' "name": "NonWindowsPolicy",' | 258 ' "name": "NonWindowsPolicy",' |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 309 '"Policy2"="c"', | 309 '"Policy2"="c"', |
| 310 '', | 310 '', |
| 311 '[HKEY_LOCAL_MACHINE\\Software\\Policies\\Chromium\\Policy1]', | 311 '[HKEY_LOCAL_MACHINE\\Software\\Policies\\Chromium\\Policy1]', |
| 312 '"1"="a"', | 312 '"1"="a"', |
| 313 '"2"="b"']) | 313 '"2"="b"']) |
| 314 self.CompareOutputs(output, expected_output) | 314 self.CompareOutputs(output, expected_output) |
| 315 | 315 |
| 316 | 316 |
| 317 if __name__ == '__main__': | 317 if __name__ == '__main__': |
| 318 unittest.main() | 318 unittest.main() |
| OLD | NEW |