| 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 writers.adml_writer.""" | 7 """Unittests for writers.adml_writer.""" |
| 8 | 8 |
| 9 | 9 |
| 10 import os | 10 import os |
| (...skipping 387 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 398 # Assert generated presentation elements. | 398 # Assert generated presentation elements. |
| 399 output = self.GetXMLOfChildren(self.writer._presentation_table_elem) | 399 output = self.GetXMLOfChildren(self.writer._presentation_table_elem) |
| 400 expected_output = ( | 400 expected_output = ( |
| 401 '<presentation id="DictionaryPolicyStub">\n' | 401 '<presentation id="DictionaryPolicyStub">\n' |
| 402 ' <textBox refId="DictionaryPolicyStub">\n' | 402 ' <textBox refId="DictionaryPolicyStub">\n' |
| 403 ' <label>Dictionary policy label</label>\n' | 403 ' <label>Dictionary policy label</label>\n' |
| 404 ' </textBox>\n' | 404 ' </textBox>\n' |
| 405 '</presentation>') | 405 '</presentation>') |
| 406 self.AssertXMLEquals(output, expected_output) | 406 self.AssertXMLEquals(output, expected_output) |
| 407 | 407 |
| 408 def testExternalPolicy(self): |
| 409 external_policy = { |
| 410 'name': 'ExternalPolicyStub', |
| 411 'type': 'external', |
| 412 'caption': 'External policy caption', |
| 413 'label': 'External policy label', |
| 414 'desc': 'This is a test description.', |
| 415 } |
| 416 self._InitWriterForAddingPolicies(self.writer, external_policy) |
| 417 self.writer.WritePolicy(external_policy) |
| 418 # Assert generated string elements. |
| 419 output = self.GetXMLOfChildren(self.writer._string_table_elem) |
| 420 expected_output = ( |
| 421 '<string id="ExternalPolicyStub">External policy caption</string>\n' |
| 422 '<string id="ExternalPolicyStub_Explain">' |
| 423 'This is a test description.</string>') |
| 424 self.AssertXMLEquals(output, expected_output) |
| 425 # Assert generated presentation elements. |
| 426 output = self.GetXMLOfChildren(self.writer._presentation_table_elem) |
| 427 expected_output = ( |
| 428 '<presentation id="ExternalPolicyStub">\n' |
| 429 ' <textBox refId="ExternalPolicyStub">\n' |
| 430 ' <label>External policy label</label>\n' |
| 431 ' </textBox>\n' |
| 432 '</presentation>') |
| 433 self.AssertXMLEquals(output, expected_output) |
| 434 |
| 408 def testPlatform(self): | 435 def testPlatform(self): |
| 409 # Test that the writer correctly chooses policies of platform Windows. | 436 # Test that the writer correctly chooses policies of platform Windows. |
| 410 self.assertTrue(self.writer.IsPolicySupported({ | 437 self.assertTrue(self.writer.IsPolicySupported({ |
| 411 'supported_on': [ | 438 'supported_on': [ |
| 412 {'platforms': ['win', 'zzz']}, {'platforms': ['aaa']} | 439 {'platforms': ['win', 'zzz']}, {'platforms': ['aaa']} |
| 413 ] | 440 ] |
| 414 })) | 441 })) |
| 415 self.assertFalse(self.writer.IsPolicySupported({ | 442 self.assertFalse(self.writer.IsPolicySupported({ |
| 416 'supported_on': [ | 443 'supported_on': [ |
| 417 {'platforms': ['mac', 'linux']}, {'platforms': ['aaa']} | 444 {'platforms': ['mac', 'linux']}, {'platforms': ['aaa']} |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 471 '</presentation>\n' | 498 '</presentation>\n' |
| 472 '<presentation id="EnumPolicy.B">\n' | 499 '<presentation id="EnumPolicy.B">\n' |
| 473 ' <dropdownList refId="EnumPolicy.B">' | 500 ' <dropdownList refId="EnumPolicy.B">' |
| 474 'Enum policy B label</dropdownList>\n' | 501 'Enum policy B label</dropdownList>\n' |
| 475 '</presentation>') | 502 '</presentation>') |
| 476 self.AssertXMLEquals(output, expected_output) | 503 self.AssertXMLEquals(output, expected_output) |
| 477 | 504 |
| 478 | 505 |
| 479 if __name__ == '__main__': | 506 if __name__ == '__main__': |
| 480 unittest.main() | 507 unittest.main() |
| OLD | NEW |