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 grit.format.policy_templates.writers.adm_writer''' | 6 '''Unit tests for grit.format.policy_templates.writers.adm_writer''' |
7 | 7 |
8 | 8 |
9 import os | 9 import os |
10 import sys | 10 import sys |
(...skipping 966 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
977 Group1_Category="Caption of group." | 977 Group1_Category="Caption of group." |
978 Policy1_Policy="Caption of policy1." | 978 Policy1_Policy="Caption of policy1." |
979 Policy1_Explain="Description of policy1.\\nWith a newline." | 979 Policy1_Explain="Description of policy1.\\nWith a newline." |
980 Policy1_Part="Caption of policy1." | 980 Policy1_Part="Caption of policy1." |
981 Policy2_Policy="Caption of policy2." | 981 Policy2_Policy="Caption of policy2." |
982 Policy2_Explain="Description of policy2.\\nWith a newline." | 982 Policy2_Explain="Description of policy2.\\nWith a newline." |
983 Policy2_Part="Caption of policy2." | 983 Policy2_Part="Caption of policy2." |
984 ''') | 984 ''') |
985 self.CompareOutputs(output, expected_output) | 985 self.CompareOutputs(output, expected_output) |
986 | 986 |
| 987 def testDuplicatedStringEnumPolicy(self): |
| 988 # Verifies that duplicated enum constants get merged, and that |
| 989 # string constants get escaped. |
| 990 grd = self.PrepareTest(''' |
| 991 { |
| 992 'policy_definitions': [ |
| 993 { |
| 994 'name': 'EnumPolicy.A', |
| 995 'type': 'string-enum', |
| 996 'caption': 'Caption of policy A.', |
| 997 'desc': 'Description of policy A.', |
| 998 'items': [ |
| 999 {'name': 'tls1.2', 'value': 'tls1.2', 'caption': 'tls1.2' }, |
| 1000 ], |
| 1001 'supported_on': ['chrome.win:39-'], |
| 1002 }, |
| 1003 { |
| 1004 'name': 'EnumPolicy.B', |
| 1005 'type': 'string-enum', |
| 1006 'caption': 'Caption of policy B.', |
| 1007 'desc': 'Description of policy B.', |
| 1008 'items': [ |
| 1009 {'name': 'tls1.2', 'value': 'tls1.2', 'caption': 'tls1.2' }, |
| 1010 ], |
| 1011 'supported_on': ['chrome.win:39-'], |
| 1012 }, |
| 1013 ], |
| 1014 'placeholders': [], |
| 1015 'messages': { |
| 1016 'win_supported_winxpsp2': { |
| 1017 'text': 'At least Windows 3.14', 'desc': 'blah' |
| 1018 }, |
| 1019 'doc_recommended': { |
| 1020 'text': 'Recommended', 'desc': 'bleh' |
| 1021 } |
| 1022 } |
| 1023 }''') |
| 1024 output = self.GetOutput(grd, 'fr', {'_google_chrome': '1'}, 'adm', 'en') |
| 1025 expected_output = self.ConstructOutput( |
| 1026 ['MACHINE', 'USER'], ''' |
| 1027 CATEGORY !!google |
| 1028 CATEGORY !!googlechrome |
| 1029 KEYNAME "Software\\Policies\\Google\\Chrome" |
| 1030 |
| 1031 POLICY !!EnumPolicy_A_Policy |
| 1032 #if version >= 4 |
| 1033 SUPPORTED !!SUPPORTED_WINXPSP2 |
| 1034 #endif |
| 1035 EXPLAIN !!EnumPolicy_A_Explain |
| 1036 |
| 1037 PART !!EnumPolicy_A_Part DROPDOWNLIST |
| 1038 VALUENAME "EnumPolicy.A" |
| 1039 ITEMLIST |
| 1040 NAME !!tls1_2_DropDown VALUE "tls1.2" |
| 1041 END ITEMLIST |
| 1042 END PART |
| 1043 END POLICY |
| 1044 |
| 1045 POLICY !!EnumPolicy_B_Policy |
| 1046 #if version >= 4 |
| 1047 SUPPORTED !!SUPPORTED_WINXPSP2 |
| 1048 #endif |
| 1049 EXPLAIN !!EnumPolicy_B_Explain |
| 1050 |
| 1051 PART !!EnumPolicy_B_Part DROPDOWNLIST |
| 1052 VALUENAME "EnumPolicy.B" |
| 1053 ITEMLIST |
| 1054 NAME !!tls1_2_DropDown VALUE "tls1.2" |
| 1055 END ITEMLIST |
| 1056 END PART |
| 1057 END POLICY |
| 1058 |
| 1059 END CATEGORY |
| 1060 END CATEGORY |
| 1061 |
| 1062 CATEGORY !!google |
| 1063 CATEGORY !!googlechrome_recommended |
| 1064 KEYNAME "Software\\Policies\\Google\\Chrome\\Recommended" |
| 1065 |
| 1066 END CATEGORY |
| 1067 END CATEGORY |
| 1068 |
| 1069 |
| 1070 ''', '''[Strings] |
| 1071 SUPPORTED_WINXPSP2="At least Windows 3.14" |
| 1072 google="Google" |
| 1073 googlechrome="Google Chrome" |
| 1074 googlechrome_recommended="Google Chrome - Recommended" |
| 1075 EnumPolicy_A_Policy="Caption of policy A." |
| 1076 EnumPolicy_A_Explain="Description of policy A." |
| 1077 EnumPolicy_A_Part="Caption of policy A." |
| 1078 tls1_2_DropDown="tls1.2" |
| 1079 EnumPolicy_B_Policy="Caption of policy B." |
| 1080 EnumPolicy_B_Explain="Description of policy B." |
| 1081 EnumPolicy_B_Part="Caption of policy B." |
| 1082 ''') |
| 1083 self.CompareOutputs(output, expected_output) |
| 1084 |
987 if __name__ == '__main__': | 1085 if __name__ == '__main__': |
988 unittest.main() | 1086 unittest.main() |
OLD | NEW |