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 '''Unit tests for grit.format.policy_templates.writers.json_writer''' | 6 '''Unit tests for grit.format.policy_templates.writers.json_writer''' |
7 | 7 |
8 | 8 |
9 import os | 9 import os |
10 import sys | 10 import sys |
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
224 output = self.GetOutput(grd, 'fr', {'_chromium' : '1'}, 'json', 'en') | 224 output = self.GetOutput(grd, 'fr', {'_chromium' : '1'}, 'json', 'en') |
225 expected_output = ( | 225 expected_output = ( |
226 TEMPLATE_HEADER + | 226 TEMPLATE_HEADER + |
227 ' // Example List\n' + | 227 ' // Example List\n' + |
228 HEADER_DELIMETER + | 228 HEADER_DELIMETER + |
229 ' // Example List\n\n' | 229 ' // Example List\n\n' |
230 ' //"ListPolicy": ["foo", "bar"]\n\n' | 230 ' //"ListPolicy": ["foo", "bar"]\n\n' |
231 '}') | 231 '}') |
232 self.CompareOutputs(output, expected_output) | 232 self.CompareOutputs(output, expected_output) |
233 | 233 |
| 234 def testStringEnumListPolicy(self): |
| 235 # Tests a policy group with a single policy of type 'string-enum-list'. |
| 236 grd = self.PrepareTest( |
| 237 '{' |
| 238 ' "policy_definitions": [' |
| 239 ' {' |
| 240 ' "name": "ListPolicy",' |
| 241 ' "type": "string-enum-list",' |
| 242 ' "caption": "Example List",' |
| 243 ' "desc": "Example List",' |
| 244 ' "items": [' |
| 245 ' {"name": "ProxyServerDisabled", "value": "one",' |
| 246 ' "caption": ""},' |
| 247 ' {"name": "ProxyServerAutoDetect", "value": "two",' |
| 248 ' "caption": ""},' |
| 249 ' ],' |
| 250 ' "supported_on": ["chrome.linux:8-"],' |
| 251 ' "example_value": ["one", "two"]' |
| 252 ' },' |
| 253 ' ],' |
| 254 ' "placeholders": [],' |
| 255 ' "messages": {},' |
| 256 '}') |
| 257 output = self.GetOutput(grd, 'fr', {'_chromium' : '1'}, 'json', 'en') |
| 258 expected_output = ( |
| 259 TEMPLATE_HEADER + |
| 260 ' // Example List\n' + |
| 261 HEADER_DELIMETER + |
| 262 ' // Example List\n\n' |
| 263 ' //"ListPolicy": ["one", "two"]\n\n' |
| 264 '}') |
| 265 self.CompareOutputs(output, expected_output) |
| 266 |
234 def testDictionaryPolicy(self): | 267 def testDictionaryPolicy(self): |
235 # Tests a policy group with a single policy of type 'dict'. | 268 # Tests a policy group with a single policy of type 'dict'. |
236 example = { | 269 example = { |
237 'bool': True, | 270 'bool': True, |
238 'dict': { | 271 'dict': { |
239 'a': 1, | 272 'a': 1, |
240 'b': 2, | 273 'b': 2, |
241 }, | 274 }, |
242 'int': 10, | 275 'int': 10, |
243 'list': [1, 2, 3], | 276 'list': [1, 2, 3], |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
331 ' // Policy Two\n' + | 364 ' // Policy Two\n' + |
332 HEADER_DELIMETER + | 365 HEADER_DELIMETER + |
333 ' // Policy Two\n\n' | 366 ' // Policy Two\n\n' |
334 ' //"Policy2": "c"\n\n' | 367 ' //"Policy2": "c"\n\n' |
335 '}') | 368 '}') |
336 self.CompareOutputs(output, expected_output) | 369 self.CompareOutputs(output, expected_output) |
337 | 370 |
338 | 371 |
339 if __name__ == '__main__': | 372 if __name__ == '__main__': |
340 unittest.main() | 373 unittest.main() |
OLD | NEW |