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
4 # found in the LICENSE file.
6 '''Unit tests for grit.format.policy_templates.writers.adm_writer'''
11 if __name__ == '__main__':
12 sys.path.append(os.path.join(os.path.dirname(__file__), '../../../..'))
16 from grit.format.policy_templates.writers import writer_unittest_common
19 class AdmWriterUnittest(writer_unittest_common.WriterUnittestCommon):
20 '''Unit tests for AdmWriter.'''
22 def ConstructOutput(self, classes, body, strings):
25 result.append('CLASS ' + clazz)
27 result.append(strings)
28 return ''.join(result)
30 def CompareOutputs(self, output, expected_output):
31 '''Compares the output of the adm_writer with its expected output.
34 output: The output of the adm writer as returned by grit.
35 expected_output: The expected output.
38 AssertionError: if the two strings are not equivalent.
42 expected_output.strip().replace('\n', '\r\n'))
45 # Test PListWriter in case of empty polices.
46 grd = self.PrepareTest('''
48 'policy_definitions': [],
51 'win_supported_winxpsp2': {
52 'text': 'At least "Windows 3.11', 'desc': 'blah'
55 'text': 'Recommended', 'desc': 'bleh'
59 output = self.GetOutput(grd, 'fr', {'_chromium': '1',}, 'adm', 'en')
60 expected_output = self.ConstructOutput(
61 ['MACHINE', 'USER'], '''
63 KEYNAME "Software\\Policies\\Chromium"
67 CATEGORY !!chromium_recommended
68 KEYNAME "Software\\Policies\\Chromium\\Recommended"
74 SUPPORTED_WINXPSP2="At least "Windows 3.11"
76 chromium_recommended="Chromium - Recommended"''')
77 self.CompareOutputs(output, expected_output)
79 def testVersionAnnotation(self):
80 # Test PListWriter in case of empty polices.
81 grd = self.PrepareTest('''
83 'policy_definitions': [],
86 'win_supported_winxpsp2': {
87 'text': 'At least "Windows 3.11', 'desc': 'blah'
90 'text': 'Recommended', 'desc': 'bleh'
94 output = self.GetOutput(
95 grd, 'fr', {'_chromium': '1', 'version':'39.0.0.0'}, 'adm', 'en')
96 expected_output = '; chromium version: 39.0.0.0\n' + \
97 self.ConstructOutput(['MACHINE', 'USER'], '''
99 KEYNAME "Software\\Policies\\Chromium"
103 CATEGORY !!chromium_recommended
104 KEYNAME "Software\\Policies\\Chromium\\Recommended"
110 SUPPORTED_WINXPSP2="At least "Windows 3.11"
112 chromium_recommended="Chromium - Recommended"''')
113 self.CompareOutputs(output, expected_output)
115 def testMainPolicy(self):
116 # Tests a policy group with a single policy of type 'main'.
117 grd = self.PrepareTest('''
119 'policy_definitions': [
121 'name': 'MainPolicy',
123 'supported_on': ['chrome.win:8-'],
124 'features': { 'can_be_recommended': True },
125 'caption': 'Caption of main.',
126 'desc': 'Description of main.',
131 'win_supported_winxpsp2': {
132 'text': 'At least Windows 3.12', 'desc': 'blah'
135 'text': 'Recommended', 'desc': 'bleh'
139 output = self.GetOutput(grd, 'fr', {'_google_chrome' : '1'}, 'adm', 'en')
140 expected_output = self.ConstructOutput(
141 ['MACHINE', 'USER'], '''
143 CATEGORY !!googlechrome
144 KEYNAME "Software\\Policies\\Google\\Chrome"
146 POLICY !!MainPolicy_Policy
148 SUPPORTED !!SUPPORTED_WINXPSP2
150 EXPLAIN !!MainPolicy_Explain
151 VALUENAME "MainPolicy"
160 CATEGORY !!googlechrome_recommended
161 KEYNAME "Software\\Policies\\Google\\Chrome\\Recommended"
163 POLICY !!MainPolicy_Policy
165 SUPPORTED !!SUPPORTED_WINXPSP2
167 EXPLAIN !!MainPolicy_Explain
168 VALUENAME "MainPolicy"
178 SUPPORTED_WINXPSP2="At least Windows 3.12"
180 googlechrome="Google Chrome"
181 googlechrome_recommended="Google Chrome - Recommended"
182 MainPolicy_Policy="Caption of main."
183 MainPolicy_Explain="Description of main."''')
184 self.CompareOutputs(output, expected_output)
186 def testMainPolicyRecommendedOnly(self):
187 # Tests a policy group with a single policy of type 'main'.
188 grd = self.PrepareTest('''
190 'policy_definitions': [
192 'name': 'MainPolicy',
194 'supported_on': ['chrome.win:8-'],
196 'can_be_recommended': True,
197 'can_be_mandatory': False
199 'caption': 'Caption of main.',
200 'desc': 'Description of main.',
205 'win_supported_winxpsp2': {
206 'text': 'At least Windows 3.12', 'desc': 'blah'
209 'text': 'Recommended', 'desc': 'bleh'
213 output = self.GetOutput(grd, 'fr', {'_google_chrome' : '1'}, 'adm', 'en')
214 expected_output = self.ConstructOutput(
215 ['MACHINE', 'USER'], '''
217 CATEGORY !!googlechrome
218 KEYNAME "Software\\Policies\\Google\\Chrome"
224 CATEGORY !!googlechrome_recommended
225 KEYNAME "Software\\Policies\\Google\\Chrome\\Recommended"
227 POLICY !!MainPolicy_Policy
229 SUPPORTED !!SUPPORTED_WINXPSP2
231 EXPLAIN !!MainPolicy_Explain
232 VALUENAME "MainPolicy"
242 SUPPORTED_WINXPSP2="At least Windows 3.12"
244 googlechrome="Google Chrome"
245 googlechrome_recommended="Google Chrome - Recommended"
246 MainPolicy_Policy="Caption of main."
247 MainPolicy_Explain="Description of main."''')
248 self.CompareOutputs(output, expected_output)
250 def testStringPolicy(self):
251 # Tests a policy group with a single policy of type 'string'.
252 grd = self.PrepareTest('''
254 'policy_definitions': [
256 'name': 'StringPolicy',
258 'supported_on': ['chrome.win:8-'],
259 'features': { 'can_be_recommended': True },
260 'desc': """Description of group.
262 'caption': 'Caption of policy.',
267 'win_supported_winxpsp2': {
268 'text': 'At least Windows 3.13', 'desc': 'blah'
271 'text': 'Recommended', 'desc': 'bleh'
275 output = self.GetOutput(grd, 'fr', {'_chromium' : '1'}, 'adm', 'en')
276 expected_output = self.ConstructOutput(
277 ['MACHINE', 'USER'], '''
279 KEYNAME "Software\\Policies\\Chromium"
281 POLICY !!StringPolicy_Policy
283 SUPPORTED !!SUPPORTED_WINXPSP2
285 EXPLAIN !!StringPolicy_Explain
287 PART !!StringPolicy_Part EDITTEXT
288 VALUENAME "StringPolicy"
295 CATEGORY !!chromium_recommended
296 KEYNAME "Software\\Policies\\Chromium\\Recommended"
298 POLICY !!StringPolicy_Policy
300 SUPPORTED !!SUPPORTED_WINXPSP2
302 EXPLAIN !!StringPolicy_Explain
304 PART !!StringPolicy_Part EDITTEXT
305 VALUENAME "StringPolicy"
314 SUPPORTED_WINXPSP2="At least Windows 3.13"
316 chromium_recommended="Chromium - Recommended"
317 StringPolicy_Policy="Caption of policy."
318 StringPolicy_Explain="Description of group.\\nWith a newline."
319 StringPolicy_Part="Caption of policy."
321 self.CompareOutputs(output, expected_output)
323 def testIntPolicy(self):
324 # Tests a policy group with a single policy of type 'string'.
325 grd = self.PrepareTest('''
327 'policy_definitions': [
331 'caption': 'Caption of policy.',
332 'features': { 'can_be_recommended': True },
333 'desc': 'Description of policy.',
334 'supported_on': ['chrome.win:8-']
339 'win_supported_winxpsp2': {
340 'text': 'At least Windows 3.13', 'desc': 'blah'
343 'text': 'Recommended', 'desc': 'bleh'
347 output = self.GetOutput(grd, 'fr', {'_chromium' : '1'}, 'adm', 'en')
348 expected_output = self.ConstructOutput(
349 ['MACHINE', 'USER'], '''
351 KEYNAME "Software\\Policies\\Chromium"
353 POLICY !!IntPolicy_Policy
355 SUPPORTED !!SUPPORTED_WINXPSP2
357 EXPLAIN !!IntPolicy_Explain
359 PART !!IntPolicy_Part NUMERIC
360 VALUENAME "IntPolicy"
367 CATEGORY !!chromium_recommended
368 KEYNAME "Software\\Policies\\Chromium\\Recommended"
370 POLICY !!IntPolicy_Policy
372 SUPPORTED !!SUPPORTED_WINXPSP2
374 EXPLAIN !!IntPolicy_Explain
376 PART !!IntPolicy_Part NUMERIC
377 VALUENAME "IntPolicy"
386 SUPPORTED_WINXPSP2="At least Windows 3.13"
388 chromium_recommended="Chromium - Recommended"
389 IntPolicy_Policy="Caption of policy."
390 IntPolicy_Explain="Description of policy."
391 IntPolicy_Part="Caption of policy."
393 self.CompareOutputs(output, expected_output)
395 def testIntEnumPolicy(self):
396 # Tests a policy group with a single policy of type 'int-enum'.
397 grd = self.PrepareTest('''
399 'policy_definitions': [
401 'name': 'EnumPolicy',
405 'name': 'ProxyServerDisabled',
407 'caption': 'Option1',
410 'name': 'ProxyServerAutoDetect',
412 'caption': 'Option2',
415 'desc': 'Description of policy.',
416 'caption': 'Caption of policy.',
417 'supported_on': ['chrome.win:8-'],
418 'features': { 'can_be_recommended': True },
423 'win_supported_winxpsp2': {
424 'text': 'At least Windows 3.14', 'desc': 'blah'
427 'text': 'Recommended', 'desc': 'bleh'
431 output = self.GetOutput(grd, 'fr', {'_google_chrome': '1'}, 'adm', 'en')
432 expected_output = self.ConstructOutput(
433 ['MACHINE', 'USER'], '''
435 CATEGORY !!googlechrome
436 KEYNAME "Software\\Policies\\Google\\Chrome"
438 POLICY !!EnumPolicy_Policy
440 SUPPORTED !!SUPPORTED_WINXPSP2
442 EXPLAIN !!EnumPolicy_Explain
444 PART !!EnumPolicy_Part DROPDOWNLIST
445 VALUENAME "EnumPolicy"
447 NAME !!ProxyServerDisabled_DropDown VALUE NUMERIC 0
448 NAME !!ProxyServerAutoDetect_DropDown VALUE NUMERIC 1
457 CATEGORY !!googlechrome_recommended
458 KEYNAME "Software\\Policies\\Google\\Chrome\\Recommended"
460 POLICY !!EnumPolicy_Policy
462 SUPPORTED !!SUPPORTED_WINXPSP2
464 EXPLAIN !!EnumPolicy_Explain
466 PART !!EnumPolicy_Part DROPDOWNLIST
467 VALUENAME "EnumPolicy"
469 NAME !!ProxyServerDisabled_DropDown VALUE NUMERIC 0
470 NAME !!ProxyServerAutoDetect_DropDown VALUE NUMERIC 1
480 SUPPORTED_WINXPSP2="At least Windows 3.14"
482 googlechrome="Google Chrome"
483 googlechrome_recommended="Google Chrome - Recommended"
484 EnumPolicy_Policy="Caption of policy."
485 EnumPolicy_Explain="Description of policy."
486 EnumPolicy_Part="Caption of policy."
487 ProxyServerDisabled_DropDown="Option1"
488 ProxyServerAutoDetect_DropDown="Option2"
490 self.CompareOutputs(output, expected_output)
492 def testStringEnumPolicy(self):
493 # Tests a policy group with a single policy of type 'int-enum'.
494 grd = self.PrepareTest('''
496 'policy_definitions': [
498 'name': 'EnumPolicy',
499 'type': 'string-enum',
500 'caption': 'Caption of policy.',
501 'desc': 'Description of policy.',
503 {'name': 'ProxyServerDisabled', 'value': 'one',
504 'caption': 'Option1'},
505 {'name': 'ProxyServerAutoDetect', 'value': 'two',
506 'caption': 'Option2'},
508 'supported_on': ['chrome.win:8-'],
509 'features': { 'can_be_recommended': True },
514 'win_supported_winxpsp2': {
515 'text': 'At least Windows 3.14', 'desc': 'blah'
518 'text': 'Recommended', 'desc': 'bleh'
522 output = self.GetOutput(grd, 'fr', {'_google_chrome': '1'}, 'adm', 'en')
523 expected_output = self.ConstructOutput(
524 ['MACHINE', 'USER'], '''
526 CATEGORY !!googlechrome
527 KEYNAME "Software\\Policies\\Google\\Chrome"
529 POLICY !!EnumPolicy_Policy
531 SUPPORTED !!SUPPORTED_WINXPSP2
533 EXPLAIN !!EnumPolicy_Explain
535 PART !!EnumPolicy_Part DROPDOWNLIST
536 VALUENAME "EnumPolicy"
538 NAME !!ProxyServerDisabled_DropDown VALUE "one"
539 NAME !!ProxyServerAutoDetect_DropDown VALUE "two"
548 CATEGORY !!googlechrome_recommended
549 KEYNAME "Software\\Policies\\Google\\Chrome\\Recommended"
551 POLICY !!EnumPolicy_Policy
553 SUPPORTED !!SUPPORTED_WINXPSP2
555 EXPLAIN !!EnumPolicy_Explain
557 PART !!EnumPolicy_Part DROPDOWNLIST
558 VALUENAME "EnumPolicy"
560 NAME !!ProxyServerDisabled_DropDown VALUE "one"
561 NAME !!ProxyServerAutoDetect_DropDown VALUE "two"
571 SUPPORTED_WINXPSP2="At least Windows 3.14"
573 googlechrome="Google Chrome"
574 googlechrome_recommended="Google Chrome - Recommended"
575 EnumPolicy_Policy="Caption of policy."
576 EnumPolicy_Explain="Description of policy."
577 EnumPolicy_Part="Caption of policy."
578 ProxyServerDisabled_DropDown="Option1"
579 ProxyServerAutoDetect_DropDown="Option2"
581 self.CompareOutputs(output, expected_output)
583 def testListPolicy(self):
584 # Tests a policy group with a single policy of type 'list'.
585 grd = self.PrepareTest('''
587 'policy_definitions': [
589 'name': 'ListPolicy',
591 'supported_on': ['chrome.win:8-'],
592 'features': { 'can_be_recommended': True },
593 'desc': """Description of list policy.
595 'caption': 'Caption of list policy.',
596 'label': 'Label of list policy.'
601 'win_supported_winxpsp2': {
602 'text': 'At least Windows 3.15', 'desc': 'blah'
605 'text': 'Recommended', 'desc': 'bleh'
609 output = self.GetOutput(grd, 'fr', {'_chromium' : '1'}, 'adm', 'en')
610 expected_output = self.ConstructOutput(
611 ['MACHINE', 'USER'], '''
613 KEYNAME "Software\\Policies\\Chromium"
615 POLICY !!ListPolicy_Policy
617 SUPPORTED !!SUPPORTED_WINXPSP2
619 EXPLAIN !!ListPolicy_Explain
621 PART !!ListPolicy_Part LISTBOX
622 KEYNAME "Software\\Policies\\Chromium\\ListPolicy"
629 CATEGORY !!chromium_recommended
630 KEYNAME "Software\\Policies\\Chromium\\Recommended"
632 POLICY !!ListPolicy_Policy
634 SUPPORTED !!SUPPORTED_WINXPSP2
636 EXPLAIN !!ListPolicy_Explain
638 PART !!ListPolicy_Part LISTBOX
639 KEYNAME "Software\\Policies\\Chromium\\Recommended\\ListPolicy"
648 SUPPORTED_WINXPSP2="At least Windows 3.15"
650 chromium_recommended="Chromium - Recommended"
651 ListPolicy_Policy="Caption of list policy."
652 ListPolicy_Explain="Description of list policy.\\nWith a newline."
653 ListPolicy_Part="Label of list policy."
655 self.CompareOutputs(output, expected_output)
657 def testStringEnumListPolicy(self):
658 # Tests a policy group with a single policy of type 'string-enum-list'.
659 grd = self.PrepareTest('''
661 'policy_definitions': [
663 'name': 'ListPolicy',
664 'type': 'string-enum-list',
665 'supported_on': ['chrome.win:8-'],
666 'features': { 'can_be_recommended': True },
667 'desc': """Description of list policy.
670 {'name': 'ProxyServerDisabled', 'value': 'one',
671 'caption': 'Option1'},
672 {'name': 'ProxyServerAutoDetect', 'value': 'two',
673 'caption': 'Option2'},
675 'caption': 'Caption of list policy.',
676 'label': 'Label of list policy.'
681 'win_supported_winxpsp2': {
682 'text': 'At least Windows 3.15', 'desc': 'blah'
685 'text': 'Recommended', 'desc': 'bleh'
689 output = self.GetOutput(grd, 'fr', {'_chromium' : '1'}, 'adm', 'en')
690 expected_output = self.ConstructOutput(
691 ['MACHINE', 'USER'], '''
693 KEYNAME "Software\\Policies\\Chromium"
695 POLICY !!ListPolicy_Policy
697 SUPPORTED !!SUPPORTED_WINXPSP2
699 EXPLAIN !!ListPolicy_Explain
701 PART !!ListPolicy_Part LISTBOX
702 KEYNAME "Software\\Policies\\Chromium\\ListPolicy"
709 CATEGORY !!chromium_recommended
710 KEYNAME "Software\\Policies\\Chromium\\Recommended"
712 POLICY !!ListPolicy_Policy
714 SUPPORTED !!SUPPORTED_WINXPSP2
716 EXPLAIN !!ListPolicy_Explain
718 PART !!ListPolicy_Part LISTBOX
719 KEYNAME "Software\\Policies\\Chromium\\Recommended\\ListPolicy"
728 SUPPORTED_WINXPSP2="At least Windows 3.15"
730 chromium_recommended="Chromium - Recommended"
731 ListPolicy_Policy="Caption of list policy."
732 ListPolicy_Explain="Description of list policy.\\nWith a newline."
733 ListPolicy_Part="Label of list policy."
735 self.CompareOutputs(output, expected_output)
737 def testDictionaryPolicy(self):
738 # Tests a policy group with a single policy of type 'dict'.
739 grd = self.PrepareTest('''
741 'policy_definitions': [
743 'name': 'DictionaryPolicy',
745 'supported_on': ['chrome.win:8-'],
746 'features': { 'can_be_recommended': True },
747 'desc': 'Description of group.',
748 'caption': 'Caption of policy.',
753 'win_supported_winxpsp2': {
754 'text': 'At least Windows 3.13', 'desc': 'blah'
757 'text': 'Recommended', 'desc': 'bleh'
761 output = self.GetOutput(grd, 'fr', {'_chromium' : '1'}, 'adm', 'en')
762 expected_output = self.ConstructOutput(
763 ['MACHINE', 'USER'], '''
765 KEYNAME "Software\\Policies\\Chromium"
767 POLICY !!DictionaryPolicy_Policy
769 SUPPORTED !!SUPPORTED_WINXPSP2
771 EXPLAIN !!DictionaryPolicy_Explain
773 PART !!DictionaryPolicy_Part EDITTEXT
774 VALUENAME "DictionaryPolicy"
781 CATEGORY !!chromium_recommended
782 KEYNAME "Software\\Policies\\Chromium\\Recommended"
784 POLICY !!DictionaryPolicy_Policy
786 SUPPORTED !!SUPPORTED_WINXPSP2
788 EXPLAIN !!DictionaryPolicy_Explain
790 PART !!DictionaryPolicy_Part EDITTEXT
791 VALUENAME "DictionaryPolicy"
800 SUPPORTED_WINXPSP2="At least Windows 3.13"
802 chromium_recommended="Chromium - Recommended"
803 DictionaryPolicy_Policy="Caption of policy."
804 DictionaryPolicy_Explain="Description of group."
805 DictionaryPolicy_Part="Caption of policy."
807 self.CompareOutputs(output, expected_output)
809 def testNonSupportedPolicy(self):
810 # Tests a policy that is not supported on Windows, so it shouldn't
811 # be included in the ADM file.
812 grd = self.PrepareTest('''
814 'policy_definitions': [
816 'name': 'NonWinGroup',
819 'name': 'NonWinPolicy',
821 'supported_on': ['chrome.linux:8-', 'chrome.mac:8-'],
822 'caption': 'Caption of list policy.',
823 'desc': 'Desc of list policy.',
825 'caption': 'Group caption.',
826 'desc': 'Group description.',
831 'win_supported_winxpsp2': {
832 'text': 'At least Windows 3.16', 'desc': 'blah'
835 'text': 'Recommended', 'desc': 'bleh'
839 output = self.GetOutput(grd, 'fr', {'_chromium' : '1'}, 'adm', 'en')
840 expected_output = self.ConstructOutput(
841 ['MACHINE', 'USER'], '''
843 KEYNAME "Software\\Policies\\Chromium"
847 CATEGORY !!chromium_recommended
848 KEYNAME "Software\\Policies\\Chromium\\Recommended"
854 SUPPORTED_WINXPSP2="At least Windows 3.16"
856 chromium_recommended="Chromium - Recommended"
858 self.CompareOutputs(output, expected_output)
860 def testNonRecommendedPolicy(self):
861 # Tests a policy that is not recommended, so it should be included.
862 grd = self.PrepareTest('''
864 'policy_definitions': [
866 'name': 'MainPolicy',
868 'supported_on': ['chrome.win:8-'],
869 'caption': 'Caption of main.',
870 'desc': 'Description of main.',
875 'win_supported_winxpsp2': {
876 'text': 'At least Windows 3.12', 'desc': 'blah'
879 'text': 'Recommended', 'desc': 'bleh'
883 output = self.GetOutput(grd, 'fr', {'_google_chrome' : '1'}, 'adm', 'en')
884 expected_output = self.ConstructOutput(
885 ['MACHINE', 'USER'], '''
887 CATEGORY !!googlechrome
888 KEYNAME "Software\\Policies\\Google\\Chrome"
890 POLICY !!MainPolicy_Policy
892 SUPPORTED !!SUPPORTED_WINXPSP2
894 EXPLAIN !!MainPolicy_Explain
895 VALUENAME "MainPolicy"
904 CATEGORY !!googlechrome_recommended
905 KEYNAME "Software\\Policies\\Google\\Chrome\\Recommended"
912 SUPPORTED_WINXPSP2="At least Windows 3.12"
914 googlechrome="Google Chrome"
915 googlechrome_recommended="Google Chrome - Recommended"
916 MainPolicy_Policy="Caption of main."
917 MainPolicy_Explain="Description of main."''')
918 self.CompareOutputs(output, expected_output)
920 def testPolicyGroup(self):
921 # Tests a policy group that has more than one policies.
922 grd = self.PrepareTest('''
924 'policy_definitions': [
928 'desc': 'Description of group.',
929 'caption': 'Caption of group.',
933 'supported_on': ['chrome.win:8-'],
934 'features': { 'can_be_recommended': True },
935 'caption': 'Caption of policy1.',
936 'desc': """Description of policy1.
941 'supported_on': ['chrome.win:8-'],
942 'caption': 'Caption of policy2.',
943 'desc': """Description of policy2.
950 'win_supported_winxpsp2': {
951 'text': 'At least Windows 3.16', 'desc': 'blah'
954 'text': 'Recommended', 'desc': 'bleh'
958 output = self.GetOutput(grd, 'fr', {'_chromium' : '1'}, 'adm', 'en')
959 expected_output = self.ConstructOutput(
960 ['MACHINE', 'USER'], '''
962 KEYNAME "Software\\Policies\\Chromium"
964 CATEGORY !!Group1_Category
965 POLICY !!Policy1_Policy
967 SUPPORTED !!SUPPORTED_WINXPSP2
969 EXPLAIN !!Policy1_Explain
971 PART !!Policy1_Part LISTBOX
972 KEYNAME "Software\\Policies\\Chromium\\Policy1"
977 POLICY !!Policy2_Policy
979 SUPPORTED !!SUPPORTED_WINXPSP2
981 EXPLAIN !!Policy2_Explain
983 PART !!Policy2_Part EDITTEXT
993 CATEGORY !!chromium_recommended
994 KEYNAME "Software\\Policies\\Chromium\\Recommended"
996 CATEGORY !!Group1_Category
997 POLICY !!Policy1_Policy
999 SUPPORTED !!SUPPORTED_WINXPSP2
1001 EXPLAIN !!Policy1_Explain
1003 PART !!Policy1_Part LISTBOX
1004 KEYNAME "Software\\Policies\\Chromium\\Recommended\\Policy1"
1015 SUPPORTED_WINXPSP2="At least Windows 3.16"
1017 chromium_recommended="Chromium - Recommended"
1018 Group1_Category="Caption of group."
1019 Policy1_Policy="Caption of policy1."
1020 Policy1_Explain="Description of policy1.\\nWith a newline."
1021 Policy1_Part="Caption of policy1."
1022 Policy2_Policy="Caption of policy2."
1023 Policy2_Explain="Description of policy2.\\nWith a newline."
1024 Policy2_Part="Caption of policy2."
1026 self.CompareOutputs(output, expected_output)
1028 def testDuplicatedStringEnumPolicy(self):
1029 # Verifies that duplicated enum constants get merged, and that
1030 # string constants get escaped.
1031 grd = self.PrepareTest('''
1033 'policy_definitions': [
1035 'name': 'EnumPolicy.A',
1036 'type': 'string-enum',
1037 'caption': 'Caption of policy A.',
1038 'desc': 'Description of policy A.',
1040 {'name': 'tls1.2', 'value': 'tls1.2', 'caption': 'tls1.2' },
1042 'supported_on': ['chrome.win:39-'],
1045 'name': 'EnumPolicy.B',
1046 'type': 'string-enum',
1047 'caption': 'Caption of policy B.',
1048 'desc': 'Description of policy B.',
1050 {'name': 'tls1.2', 'value': 'tls1.2', 'caption': 'tls1.2' },
1052 'supported_on': ['chrome.win:39-'],
1057 'win_supported_winxpsp2': {
1058 'text': 'At least Windows 3.14', 'desc': 'blah'
1060 'doc_recommended': {
1061 'text': 'Recommended', 'desc': 'bleh'
1065 output = self.GetOutput(grd, 'fr', {'_google_chrome': '1'}, 'adm', 'en')
1066 expected_output = self.ConstructOutput(
1067 ['MACHINE', 'USER'], '''
1069 CATEGORY !!googlechrome
1070 KEYNAME "Software\\Policies\\Google\\Chrome"
1072 POLICY !!EnumPolicy_A_Policy
1074 SUPPORTED !!SUPPORTED_WINXPSP2
1076 EXPLAIN !!EnumPolicy_A_Explain
1078 PART !!EnumPolicy_A_Part DROPDOWNLIST
1079 VALUENAME "EnumPolicy.A"
1081 NAME !!tls1_2_DropDown VALUE "tls1.2"
1086 POLICY !!EnumPolicy_B_Policy
1088 SUPPORTED !!SUPPORTED_WINXPSP2
1090 EXPLAIN !!EnumPolicy_B_Explain
1092 PART !!EnumPolicy_B_Part DROPDOWNLIST
1093 VALUENAME "EnumPolicy.B"
1095 NAME !!tls1_2_DropDown VALUE "tls1.2"
1104 CATEGORY !!googlechrome_recommended
1105 KEYNAME "Software\\Policies\\Google\\Chrome\\Recommended"
1112 SUPPORTED_WINXPSP2="At least Windows 3.14"
1114 googlechrome="Google Chrome"
1115 googlechrome_recommended="Google Chrome - Recommended"
1116 EnumPolicy_A_Policy="Caption of policy A."
1117 EnumPolicy_A_Explain="Description of policy A."
1118 EnumPolicy_A_Part="Caption of policy A."
1119 tls1_2_DropDown="tls1.2"
1120 EnumPolicy_B_Policy="Caption of policy B."
1121 EnumPolicy_B_Explain="Description of policy B."
1122 EnumPolicy_B_Part="Caption of policy B."
1124 self.CompareOutputs(output, expected_output)
1126 if __name__ == '__main__':