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 """Unittests for grit.format.policy_templates.writers.admx_writer.""" | 7 """Unittests for grit.format.policy_templates.writers.admx_writer.""" |
8 | 8 |
9 | 9 |
10 import os | 10 import os |
(...skipping 351 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
362 ' <parentCategory ref="PolicyGroup"/>\n' | 362 ' <parentCategory ref="PolicyGroup"/>\n' |
363 ' <supportedOn ref="SUPPORTED_TESTOS"/>\n' | 363 ' <supportedOn ref="SUPPORTED_TESTOS"/>\n' |
364 ' <elements>\n' | 364 ' <elements>\n' |
365 ' <list id="SampleListPolicyDesc"' | 365 ' <list id="SampleListPolicyDesc"' |
366 ' key="Software\Policies\Test\SampleListPolicy" valuePrefix=""/>\n' | 366 ' key="Software\Policies\Test\SampleListPolicy" valuePrefix=""/>\n' |
367 ' </elements>\n' | 367 ' </elements>\n' |
368 '</policy>') | 368 '</policy>') |
369 | 369 |
370 self.AssertXMLEquals(output, expected_output) | 370 self.AssertXMLEquals(output, expected_output) |
371 | 371 |
| 372 def testStringEnumListPolicy(self): |
| 373 list_policy = { |
| 374 'name': 'SampleListPolicy', |
| 375 'type': 'string-enum-list', |
| 376 'items': [ |
| 377 {'name': 'item_1', 'value': 'one'}, |
| 378 {'name': 'item_2', 'value': 'two'}, |
| 379 ] |
| 380 } |
| 381 self._initWriterForPolicy(self.writer, list_policy) |
| 382 self.writer.WritePolicy(list_policy) |
| 383 output = self.GetXMLOfChildren(self._GetPoliciesElement(self.writer._doc)) |
| 384 expected_output = ( |
| 385 '<policy class="TestClass" displayName="$(string.SampleListPolicy)"' |
| 386 ' explainText="$(string.SampleListPolicy_Explain)"' |
| 387 ' key="Software\\Policies\\Test" name="SampleListPolicy"' |
| 388 ' presentation="$(presentation.SampleListPolicy)">\n' |
| 389 ' <parentCategory ref="PolicyGroup"/>\n' |
| 390 ' <supportedOn ref="SUPPORTED_TESTOS"/>\n' |
| 391 ' <elements>\n' |
| 392 ' <list id="SampleListPolicyDesc"' |
| 393 ' key="Software\Policies\Test\SampleListPolicy" valuePrefix=""/>\n' |
| 394 ' </elements>\n' |
| 395 '</policy>') |
| 396 |
| 397 self.AssertXMLEquals(output, expected_output) |
| 398 |
372 def testDictionaryPolicy(self): | 399 def testDictionaryPolicy(self): |
373 dict_policy = { | 400 dict_policy = { |
374 'name': 'SampleDictionaryPolicy', | 401 'name': 'SampleDictionaryPolicy', |
375 'type': 'dict', | 402 'type': 'dict', |
376 } | 403 } |
377 self._initWriterForPolicy(self.writer, dict_policy) | 404 self._initWriterForPolicy(self.writer, dict_policy) |
378 | 405 |
379 self.writer.WritePolicy(dict_policy) | 406 self.writer.WritePolicy(dict_policy) |
380 output = self.GetXMLOfChildren(self._GetPoliciesElement(self.writer._doc)) | 407 output = self.GetXMLOfChildren(self._GetPoliciesElement(self.writer._doc)) |
381 expected_output = ( | 408 expected_output = ( |
(...skipping 20 matching lines...) Expand all Loading... |
402 })) | 429 })) |
403 self.assertFalse(self.writer.IsPolicySupported({ | 430 self.assertFalse(self.writer.IsPolicySupported({ |
404 'supported_on': [ | 431 'supported_on': [ |
405 {'platforms': ['mac', 'linux']}, {'platforms': ['aaa']} | 432 {'platforms': ['mac', 'linux']}, {'platforms': ['aaa']} |
406 ] | 433 ] |
407 })) | 434 })) |
408 | 435 |
409 | 436 |
410 if __name__ == '__main__': | 437 if __name__ == '__main__': |
411 unittest.main() | 438 unittest.main() |
OLD | NEW |