| 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 291 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 302 self.writer.WritePolicy(string_policy) | 302 self.writer.WritePolicy(string_policy) |
| 303 output = self.GetXMLOfChildren(self._GetPoliciesElement(self.writer._doc)) | 303 output = self.GetXMLOfChildren(self._GetPoliciesElement(self.writer._doc)) |
| 304 expected_output = ( | 304 expected_output = ( |
| 305 '<policy class="TestClass" displayName="$(string.SampleStringPolicy)"' | 305 '<policy class="TestClass" displayName="$(string.SampleStringPolicy)"' |
| 306 ' explainText="$(string.SampleStringPolicy_Explain)"' | 306 ' explainText="$(string.SampleStringPolicy_Explain)"' |
| 307 ' key="Software\\Policies\\Test" name="SampleStringPolicy"' | 307 ' key="Software\\Policies\\Test" name="SampleStringPolicy"' |
| 308 ' presentation="$(presentation.SampleStringPolicy)">\n' | 308 ' presentation="$(presentation.SampleStringPolicy)">\n' |
| 309 ' <parentCategory ref="PolicyGroup"/>\n' | 309 ' <parentCategory ref="PolicyGroup"/>\n' |
| 310 ' <supportedOn ref="SUPPORTED_TESTOS"/>\n' | 310 ' <supportedOn ref="SUPPORTED_TESTOS"/>\n' |
| 311 ' <elements>\n' | 311 ' <elements>\n' |
| 312 ' <text id="SampleStringPolicy" valueName="SampleStringPolicy"/>\n' | 312 ' <text id="SampleStringPolicy" maxLength="1000000"' |
| 313 ' valueName="SampleStringPolicy"/>\n' |
| 313 ' </elements>\n' | 314 ' </elements>\n' |
| 314 '</policy>') | 315 '</policy>') |
| 315 self.AssertXMLEquals(output, expected_output) | 316 self.AssertXMLEquals(output, expected_output) |
| 316 | 317 |
| 317 def testIntPolicy(self): | 318 def testIntPolicy(self): |
| 318 int_policy = { | 319 int_policy = { |
| 319 'name': 'SampleIntPolicy', | 320 'name': 'SampleIntPolicy', |
| 320 'type': 'int', | 321 'type': 'int', |
| 321 } | 322 } |
| 322 self._initWriterForPolicy(self.writer, int_policy) | 323 self._initWriterForPolicy(self.writer, int_policy) |
| (...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 480 output = self.GetXMLOfChildren(self._GetPoliciesElement(self.writer._doc)) | 481 output = self.GetXMLOfChildren(self._GetPoliciesElement(self.writer._doc)) |
| 481 expected_output = ( | 482 expected_output = ( |
| 482 '<policy class="TestClass" displayName="$(string.' | 483 '<policy class="TestClass" displayName="$(string.' |
| 483 'SampleDictionaryPolicy)"' | 484 'SampleDictionaryPolicy)"' |
| 484 ' explainText="$(string.SampleDictionaryPolicy_Explain)"' | 485 ' explainText="$(string.SampleDictionaryPolicy_Explain)"' |
| 485 ' key="Software\\Policies\\Test" name="SampleDictionaryPolicy"' | 486 ' key="Software\\Policies\\Test" name="SampleDictionaryPolicy"' |
| 486 ' presentation="$(presentation.SampleDictionaryPolicy)">\n' | 487 ' presentation="$(presentation.SampleDictionaryPolicy)">\n' |
| 487 ' <parentCategory ref="PolicyGroup"/>\n' | 488 ' <parentCategory ref="PolicyGroup"/>\n' |
| 488 ' <supportedOn ref="SUPPORTED_TESTOS"/>\n' | 489 ' <supportedOn ref="SUPPORTED_TESTOS"/>\n' |
| 489 ' <elements>\n' | 490 ' <elements>\n' |
| 490 ' <text id="SampleDictionaryPolicy" ' | 491 ' <text id="SampleDictionaryPolicy" maxLength="1000000"' |
| 491 'valueName="SampleDictionaryPolicy"/>\n' | 492 ' valueName="SampleDictionaryPolicy"/>\n' |
| 492 ' </elements>\n' | 493 ' </elements>\n' |
| 493 '</policy>') | 494 '</policy>') |
| 494 self.AssertXMLEquals(output, expected_output) | 495 self.AssertXMLEquals(output, expected_output) |
| 495 | 496 |
| 496 def testPlatform(self): | 497 def testPlatform(self): |
| 497 # Test that the writer correctly chooses policies of platform Windows. | 498 # Test that the writer correctly chooses policies of platform Windows. |
| 498 self.assertTrue(self.writer.IsPolicySupported({ | 499 self.assertTrue(self.writer.IsPolicySupported({ |
| 499 'supported_on': [ | 500 'supported_on': [ |
| 500 {'platforms': ['win', 'zzz']}, {'platforms': ['aaa']} | 501 {'platforms': ['win', 'zzz']}, {'platforms': ['aaa']} |
| 501 ] | 502 ] |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 563 ' </item>\n' | 564 ' </item>\n' |
| 564 ' </enum>\n' | 565 ' </enum>\n' |
| 565 ' </elements>\n' | 566 ' </elements>\n' |
| 566 ' </policy>\n' | 567 ' </policy>\n' |
| 567 '</policyDefinitions>') | 568 '</policyDefinitions>') |
| 568 self.AssertXMLEquals(output, expected_output) | 569 self.AssertXMLEquals(output, expected_output) |
| 569 | 570 |
| 570 | 571 |
| 571 if __name__ == '__main__': | 572 if __name__ == '__main__': |
| 572 unittest.main() | 573 unittest.main() |
| OLD | NEW |