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 488 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
499 'supported_on': [ | 499 'supported_on': [ |
500 {'platforms': ['win', 'zzz']}, {'platforms': ['aaa']} | 500 {'platforms': ['win', 'zzz']}, {'platforms': ['aaa']} |
501 ] | 501 ] |
502 })) | 502 })) |
503 self.assertFalse(self.writer.IsPolicySupported({ | 503 self.assertFalse(self.writer.IsPolicySupported({ |
504 'supported_on': [ | 504 'supported_on': [ |
505 {'platforms': ['mac', 'linux']}, {'platforms': ['aaa']} | 505 {'platforms': ['mac', 'linux']}, {'platforms': ['aaa']} |
506 ] | 506 ] |
507 })) | 507 })) |
508 | 508 |
| 509 def testStringEncodings(self): |
| 510 enum_policy_a = { |
| 511 'name': 'SampleEnumPolicy.A', |
| 512 'type': 'string-enum', |
| 513 'items': [ |
| 514 {'name': 'tls1.2', 'value': 'tls1.2'} |
| 515 ] |
| 516 } |
| 517 enum_policy_b = { |
| 518 'name': 'SampleEnumPolicy.B', |
| 519 'type': 'string-enum', |
| 520 'items': [ |
| 521 {'name': 'tls1.2', 'value': 'tls1.2'} |
| 522 ] |
| 523 } |
| 524 |
| 525 dom_impl = minidom.getDOMImplementation('') |
| 526 self.writer._doc = dom_impl.createDocument(None, 'policyDefinitions', None) |
| 527 self.writer._active_policies_elem = self.writer._doc.documentElement |
| 528 self.writer._active_mandatory_policy_group_name = 'PolicyGroup' |
| 529 self.writer.WritePolicy(enum_policy_a) |
| 530 self.writer.WritePolicy(enum_policy_b) |
| 531 output = self.writer.GetTemplateText() |
| 532 expected_output = ( |
| 533 '<?xml version="1.0" ?>\n' |
| 534 '<policyDefinitions>\n' |
| 535 ' <policy class="TestClass" displayName="$(string.SampleEnumPolicy_A)"' |
| 536 ' explainText="$(string.SampleEnumPolicy_A_Explain)"' |
| 537 ' key="Software\\Policies\\Test" name="SampleEnumPolicy.A"' |
| 538 ' presentation="$(presentation.SampleEnumPolicy.A)">\n' |
| 539 ' <parentCategory ref="PolicyGroup"/>\n' |
| 540 ' <supportedOn ref="SUPPORTED_TESTOS"/>\n' |
| 541 ' <elements>\n' |
| 542 ' <enum id="SampleEnumPolicy.A" valueName="SampleEnumPolicy.A">\n' |
| 543 ' <item displayName="$(string.tls1_2)">\n' |
| 544 ' <value>\n' |
| 545 ' <string>tls1.2</string>\n' |
| 546 ' </value>\n' |
| 547 ' </item>\n' |
| 548 ' </enum>\n' |
| 549 ' </elements>\n' |
| 550 ' </policy>\n' |
| 551 ' <policy class="TestClass" displayName="$(string.SampleEnumPolicy_B)"' |
| 552 ' explainText="$(string.SampleEnumPolicy_B_Explain)"' |
| 553 ' key="Software\\Policies\\Test" name="SampleEnumPolicy.B"' |
| 554 ' presentation="$(presentation.SampleEnumPolicy.B)">\n' |
| 555 ' <parentCategory ref="PolicyGroup"/>\n' |
| 556 ' <supportedOn ref="SUPPORTED_TESTOS"/>\n' |
| 557 ' <elements>\n' |
| 558 ' <enum id="SampleEnumPolicy.B" valueName="SampleEnumPolicy.B">\n' |
| 559 ' <item displayName="$(string.tls1_2)">\n' |
| 560 ' <value>\n' |
| 561 ' <string>tls1.2</string>\n' |
| 562 ' </value>\n' |
| 563 ' </item>\n' |
| 564 ' </enum>\n' |
| 565 ' </elements>\n' |
| 566 ' </policy>\n' |
| 567 '</policyDefinitions>') |
| 568 self.AssertXMLEquals(output, expected_output) |
| 569 |
509 | 570 |
510 if __name__ == '__main__': | 571 if __name__ == '__main__': |
511 unittest.main() | 572 unittest.main() |
OLD | NEW |