| 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 writers.plist_writer''' | 6 '''Unit tests for writers.plist_writer''' |
| 7 | 7 |
| 8 | 8 |
| 9 import os | 9 import os |
| 10 import sys | 10 import sys |
| (...skipping 611 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 622 <key>pfm_targets</key> | 622 <key>pfm_targets</key> |
| 623 <array> | 623 <array> |
| 624 <string>user-managed</string> | 624 <string>user-managed</string> |
| 625 </array> | 625 </array> |
| 626 <key>pfm_type</key> | 626 <key>pfm_type</key> |
| 627 <string>dictionary</string> | 627 <string>dictionary</string> |
| 628 </dict> | 628 </dict> |
| 629 </array>''') | 629 </array>''') |
| 630 self.assertEquals(output.strip(), expected_output.strip()) | 630 self.assertEquals(output.strip(), expected_output.strip()) |
| 631 | 631 |
| 632 def testExternalPolicy(self): |
| 633 # Tests a policy group with a single policy of type 'dict'. |
| 634 policy_json = ''' |
| 635 { |
| 636 'policy_definitions': [ |
| 637 { |
| 638 'name': 'ExternalGroup', |
| 639 'type': 'group', |
| 640 'desc': '', |
| 641 'caption': '', |
| 642 'policies': [{ |
| 643 'name': 'ExternalPolicy', |
| 644 'type': 'external', |
| 645 'supported_on': ['chrome.mac:8-'], |
| 646 'desc': '', |
| 647 'caption': '', |
| 648 }], |
| 649 }, |
| 650 ], |
| 651 'placeholders': [], |
| 652 'messages': {}, |
| 653 }''' |
| 654 output = self.GetOutput( |
| 655 policy_json, |
| 656 {'_chromium' : '1', 'mac_bundle_id': 'com.example.Test'}, |
| 657 'plist') |
| 658 expected_output = self._GetExpectedOutputs( |
| 659 'Chromium', 'com.example.Test', '''<array> |
| 660 <dict> |
| 661 <key>pfm_name</key> |
| 662 <string>ExternalPolicy</string> |
| 663 <key>pfm_description</key> |
| 664 <string/> |
| 665 <key>pfm_title</key> |
| 666 <string/> |
| 667 <key>pfm_targets</key> |
| 668 <array> |
| 669 <string>user-managed</string> |
| 670 </array> |
| 671 <key>pfm_type</key> |
| 672 <string>dictionary</string> |
| 673 </dict> |
| 674 </array>''') |
| 675 self.assertEquals(output.strip(), expected_output.strip()) |
| 676 |
| 632 def testNonSupportedPolicy(self): | 677 def testNonSupportedPolicy(self): |
| 633 # Tests a policy that is not supported on Mac, so it shouldn't | 678 # Tests a policy that is not supported on Mac, so it shouldn't |
| 634 # be included in the plist file. | 679 # be included in the plist file. |
| 635 policy_json = ''' | 680 policy_json = ''' |
| 636 { | 681 { |
| 637 'policy_definitions': [ | 682 'policy_definitions': [ |
| 638 { | 683 { |
| 639 'name': 'NonMacGroup', | 684 'name': 'NonMacGroup', |
| 640 'type': 'group', | 685 'type': 'group', |
| 641 'caption': '', | 686 'caption': '', |
| (...skipping 14 matching lines...) Expand all Loading... |
| 656 policy_json, | 701 policy_json, |
| 657 {'_google_chrome': '1', 'mac_bundle_id': 'com.example.Test2'}, | 702 {'_google_chrome': '1', 'mac_bundle_id': 'com.example.Test2'}, |
| 658 'plist') | 703 'plist') |
| 659 expected_output = self._GetExpectedOutputs( | 704 expected_output = self._GetExpectedOutputs( |
| 660 'Google_Chrome', 'com.example.Test2', '''<array/>''') | 705 'Google_Chrome', 'com.example.Test2', '''<array/>''') |
| 661 self.assertEquals(output.strip(), expected_output.strip()) | 706 self.assertEquals(output.strip(), expected_output.strip()) |
| 662 | 707 |
| 663 | 708 |
| 664 if __name__ == '__main__': | 709 if __name__ == '__main__': |
| 665 unittest.main() | 710 unittest.main() |
| OLD | NEW |