| 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.adm_writer''' | 6 '''Unit tests for writers.adm_writer''' |
| 7 | 7 |
| 8 | 8 |
| 9 import os | 9 import os |
| 10 import sys | 10 import sys |
| (...skipping 788 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 799 ''', '''[Strings] | 799 ''', '''[Strings] |
| 800 SUPPORTED_WINXPSP2="At least Windows 3.13" | 800 SUPPORTED_WINXPSP2="At least Windows 3.13" |
| 801 chromium="Chromium" | 801 chromium="Chromium" |
| 802 chromium_recommended="Chromium - Recommended" | 802 chromium_recommended="Chromium - Recommended" |
| 803 DictionaryPolicy_Policy="Caption of policy." | 803 DictionaryPolicy_Policy="Caption of policy." |
| 804 DictionaryPolicy_Explain="Description of group." | 804 DictionaryPolicy_Explain="Description of group." |
| 805 DictionaryPolicy_Part="Caption of policy." | 805 DictionaryPolicy_Part="Caption of policy." |
| 806 ''') | 806 ''') |
| 807 self.CompareOutputs(output, expected_output) | 807 self.CompareOutputs(output, expected_output) |
| 808 | 808 |
| 809 def testExternalPolicy(self): |
| 810 # Tests a policy group with a single policy of type 'external'. |
| 811 policy_json = ''' |
| 812 { |
| 813 'policy_definitions': [ |
| 814 { |
| 815 'name': 'ExternalPolicy', |
| 816 'type': 'external', |
| 817 'supported_on': ['chrome.win:8-'], |
| 818 'features': { 'can_be_recommended': True }, |
| 819 'desc': 'Description of group.', |
| 820 'caption': 'Caption of policy.', |
| 821 }, |
| 822 ], |
| 823 'placeholders': [], |
| 824 'messages': { |
| 825 'win_supported_winxpsp2': { |
| 826 'text': 'At least Windows 3.13', 'desc': 'blah' |
| 827 }, |
| 828 'doc_recommended': { |
| 829 'text': 'Recommended', 'desc': 'bleh' |
| 830 } |
| 831 } |
| 832 }''' |
| 833 output = self.GetOutput(policy_json, {'_chromium' : '1'}, 'adm') |
| 834 expected_output = self.ConstructOutput( |
| 835 ['MACHINE', 'USER'], ''' |
| 836 CATEGORY !!chromium |
| 837 KEYNAME "Software\\Policies\\Chromium" |
| 838 |
| 839 POLICY !!ExternalPolicy_Policy |
| 840 #if version >= 4 |
| 841 SUPPORTED !!SUPPORTED_WINXPSP2 |
| 842 #endif |
| 843 EXPLAIN !!ExternalPolicy_Explain |
| 844 |
| 845 PART !!ExternalPolicy_Part EDITTEXT |
| 846 VALUENAME "ExternalPolicy" |
| 847 MAXLEN 1000000 |
| 848 END PART |
| 849 END POLICY |
| 850 |
| 851 END CATEGORY |
| 852 |
| 853 CATEGORY !!chromium_recommended |
| 854 KEYNAME "Software\\Policies\\Chromium\\Recommended" |
| 855 |
| 856 POLICY !!ExternalPolicy_Policy |
| 857 #if version >= 4 |
| 858 SUPPORTED !!SUPPORTED_WINXPSP2 |
| 859 #endif |
| 860 EXPLAIN !!ExternalPolicy_Explain |
| 861 |
| 862 PART !!ExternalPolicy_Part EDITTEXT |
| 863 VALUENAME "ExternalPolicy" |
| 864 MAXLEN 1000000 |
| 865 END PART |
| 866 END POLICY |
| 867 |
| 868 END CATEGORY |
| 869 |
| 870 |
| 871 ''', '''[Strings] |
| 872 SUPPORTED_WINXPSP2="At least Windows 3.13" |
| 873 chromium="Chromium" |
| 874 chromium_recommended="Chromium - Recommended" |
| 875 ExternalPolicy_Policy="Caption of policy." |
| 876 ExternalPolicy_Explain="Description of group." |
| 877 ExternalPolicy_Part="Caption of policy." |
| 878 ''') |
| 879 self.CompareOutputs(output, expected_output) |
| 880 |
| 809 def testNonSupportedPolicy(self): | 881 def testNonSupportedPolicy(self): |
| 810 # Tests a policy that is not supported on Windows, so it shouldn't | 882 # Tests a policy that is not supported on Windows, so it shouldn't |
| 811 # be included in the ADM file. | 883 # be included in the ADM file. |
| 812 policy_json = ''' | 884 policy_json = ''' |
| 813 { | 885 { |
| 814 'policy_definitions': [ | 886 'policy_definitions': [ |
| 815 { | 887 { |
| 816 'name': 'NonWinGroup', | 888 'name': 'NonWinGroup', |
| 817 'type': 'group', | 889 'type': 'group', |
| 818 'policies': [{ | 890 'policies': [{ |
| (...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1118 EnumPolicy_A_Part="Caption of policy A." | 1190 EnumPolicy_A_Part="Caption of policy A." |
| 1119 tls1_2_DropDown="tls1.2" | 1191 tls1_2_DropDown="tls1.2" |
| 1120 EnumPolicy_B_Policy="Caption of policy B." | 1192 EnumPolicy_B_Policy="Caption of policy B." |
| 1121 EnumPolicy_B_Explain="Description of policy B." | 1193 EnumPolicy_B_Explain="Description of policy B." |
| 1122 EnumPolicy_B_Part="Caption of policy B." | 1194 EnumPolicy_B_Part="Caption of policy B." |
| 1123 ''') | 1195 ''') |
| 1124 self.CompareOutputs(output, expected_output) | 1196 self.CompareOutputs(output, expected_output) |
| 1125 | 1197 |
| 1126 if __name__ == '__main__': | 1198 if __name__ == '__main__': |
| 1127 unittest.main() | 1199 unittest.main() |
| OLD | NEW |