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.doc_writer'''
12 if __name__ == '__main__':
13 sys.path.append(os.path.join(os.path.dirname(__file__), '../../../..'))
16 from xml.dom import minidom
18 from grit.format.policy_templates.writers import writer_unittest_common
19 from grit.format.policy_templates.writers import doc_writer
22 class MockMessageDictionary:
23 '''A mock dictionary passed to a writer as the dictionary of
27 # Dictionary of messages.
30 class DocWriterUnittest(writer_unittest_common.WriterUnittestCommon):
31 '''Unit tests for DocWriter.'''
34 # Create a writer for the tests.
35 self.writer = doc_writer.GetWriter(
38 'frame_name': 'Chrome Frame',
39 'os_name': 'Chrome OS',
40 'win_reg_mandatory_key_name': 'MockKey',
41 'win_reg_recommended_key_name': 'MockKeyRec',
42 'build': 'test_product',
44 self.writer.messages = {
45 'doc_back_to_top': {'text': '_test_back_to_top'},
46 'doc_complex_policies_on_windows': {'text': '_test_complex_policies_win'},
47 'doc_data_type': {'text': '_test_data_type'},
48 'doc_description': {'text': '_test_description'},
49 'doc_description_column_title': {
50 'text': '_test_description_column_title'
52 'doc_example_value': {'text': '_test_example_value'},
53 'doc_feature_dynamic_refresh': {'text': '_test_feature_dynamic_refresh'},
54 'doc_feature_can_be_recommended': {'text': '_test_feature_recommended'},
55 'doc_feature_can_be_mandatory': {'text': '_test_feature_mandatory'},
56 'doc_intro': {'text': '_test_intro'},
57 'doc_mac_linux_pref_name': {'text': '_test_mac_linux_pref_name'},
58 'doc_note': {'text': '_test_note'},
59 'doc_name_column_title': {'text': '_test_name_column_title'},
60 'doc_not_supported': {'text': '_test_not_supported'},
61 'doc_since_version': {'text': '_test_since_version'},
62 'doc_supported': {'text': '_test_supported'},
63 'doc_supported_features': {'text': '_test_supported_features'},
64 'doc_supported_on': {'text': '_test_supported_on'},
65 'doc_win_reg_loc': {'text': '_test_win_reg_loc'},
67 'doc_bla': {'text': '_test_bla'},
71 # It is not worth testing the exact content of style attributes.
72 # Therefore we override them here with shorter texts.
73 for key in self.writer._STYLE.keys():
74 self.writer._STYLE[key] = 'style_%s;' % key
75 # Add some more style attributes for additional testing.
76 self.writer._STYLE['key1'] = 'style1;'
77 self.writer._STYLE['key2'] = 'style2;'
79 # Create a DOM document for the tests.
80 dom_impl = minidom.getDOMImplementation('')
81 self.doc = dom_impl.createDocument(None, 'root', None)
82 self.doc_root = self.doc.documentElement
84 def testSkeleton(self):
85 # Test if DocWriter creates the skeleton of the document correctly.
86 self.writer.BeginTemplate()
88 self.writer._main_div.toxml(),
91 '<a name="top"/><br/>_test_intro<br/><br/><br/>'
92 '<table style="style_table;">'
93 '<thead><tr style="style_tr;">'
94 '<td style="style_td;style_td.left;style_thead td;">'
95 '_test_name_column_title'
97 '<td style="style_td;style_td.right;style_thead td;">'
98 '_test_description_column_title'
107 def testVersionAnnotation(self):
108 # Test if DocWriter creates the skeleton of the document correctly.
109 self.writer.config['version'] = '39.0.0.0'
110 self.writer.BeginTemplate()
112 self.writer._main_div.toxml(),
114 '<!--test_product version: 39.0.0.0-->'
116 '<a name="top"/><br/>_test_intro<br/><br/><br/>'
117 '<table style="style_table;">'
118 '<thead><tr style="style_tr;">'
119 '<td style="style_td;style_td.left;style_thead td;">'
120 '_test_name_column_title'
122 '<td style="style_td;style_td.right;style_thead td;">'
123 '_test_description_column_title'
132 def testGetLocalizedMessage(self):
133 # Test if localized messages are retrieved correctly.
134 self.writer.messages = {
135 'doc_hello_world': {'text': 'hello, vilag!'}
138 self.writer._GetLocalizedMessage('hello_world'),
141 def testMapListToString(self):
142 # Test function DocWriter.MapListToString()
144 self.writer._MapListToString({'a1': 'a2', 'b1': 'b2'}, ['a1', 'b1']),
147 self.writer._MapListToString({'a1': 'a2', 'b1': 'b2'}, []),
149 result = self.writer._MapListToString(
150 {'a': '1', 'b': '2', 'c': '3', 'd': '4'}, ['b', 'd'])
151 expected_result = '2, 4'
156 def testAddStyledElement(self):
157 # Test function DocWriter.AddStyledElement()
159 # Test the case of zero style.
160 e1 = self.writer._AddStyledElement(
161 self.doc_root, 'z', [], {'a': 'b'}, 'text')
166 # Test the case of one style.
167 e2 = self.writer._AddStyledElement(
168 self.doc_root, 'z', ['key1'], {'a': 'b'}, 'text')
171 '<z a="b" style="style1;">text</z>')
173 # Test the case of two styles.
174 e3 = self.writer._AddStyledElement(
175 self.doc_root, 'z', ['key1', 'key2'], {'a': 'b'}, 'text')
178 '<z a="b" style="style1;style2;">text</z>')
180 def testAddDescriptionIntEnum(self):
181 # Test if URLs are replaced and choices of 'int-enum' policies are listed
186 {'value': 0, 'caption': 'Disable foo'},
187 {'value': 2, 'caption': 'Solve your problem'},
188 {'value': 5, 'caption': 'Enable bar'},
190 'desc': '''This policy disables foo, except in case of bar.
191 See http://policy-explanation.example.com for more details.
194 self.writer._AddDescription(self.doc_root, policy)
196 self.doc_root.toxml(),
197 '''<root>This policy disables foo, except in case of bar.
198 See <a href="http://policy-explanation.example.com">http://policy-explanation.example.com</a> for more details.
199 <ul><li>0 = Disable foo</li><li>2 = Solve your problem</li><li>5 = Enable bar</li></ul></root>''')
201 def testAddDescriptionStringEnum(self):
202 # Test if URLs are replaced and choices of 'int-enum' policies are listed
205 'type': 'string-enum',
207 {'value': "one", 'caption': 'Disable foo'},
208 {'value': "two", 'caption': 'Solve your problem'},
209 {'value': "three", 'caption': 'Enable bar'},
211 'desc': '''This policy disables foo, except in case of bar.
212 See http://policy-explanation.example.com for more details.
215 self.writer._AddDescription(self.doc_root, policy)
217 self.doc_root.toxml(),
218 '''<root>This policy disables foo, except in case of bar.
219 See <a href="http://policy-explanation.example.com">http://policy-explanation.example.com</a> for more details.
220 <ul><li>"one" = Disable foo</li><li>"two" = Solve your problem</li><li>"three" = Enable bar</li></ul></root>''')
222 def testAddFeatures(self):
223 # Test if the list of features of a policy is handled correctly.
226 'spaceship_docking': False,
227 'dynamic_refresh': True,
228 'can_be_recommended': True,
231 self.writer._FEATURE_MAP = {
232 'can_be_recommended': 'Can Be Recommended',
233 'dynamic_refresh': 'Dynamic Refresh',
234 'spaceship_docking': 'Spaceship Docking',
236 self.writer._AddFeatures(self.doc_root, policy)
238 self.doc_root.toxml(),
240 'Can Be Recommended: _test_supported, '
241 'Dynamic Refresh: _test_supported, '
242 'Spaceship Docking: _test_not_supported'
245 def testAddListExample(self):
247 'name': 'PolicyName',
248 'example_value': ['Foo', 'Bar'],
249 'supported_on': [ { 'platforms': ['win', 'mac', 'linux'] } ]
251 self.writer._AddListExample(self.doc_root, policy)
253 self.doc_root.toxml(),
255 '<dl style="style_dd dl;">'
257 '<dd style="style_.monospace;style_.pre;">'
258 'MockKey\\PolicyName\\1 = "Foo"\n'
259 'MockKey\\PolicyName\\2 = "Bar"'
262 '<dd style="style_.monospace;">'
263 '["Foo", "Bar"]'
266 '<dd style="style_.monospace;style_.pre;">'
268 ' <string>Foo</string>\n'
269 ' <string>Bar</string>\n'
275 def testBoolExample(self):
276 # Test representation of boolean example values.
278 'name': 'PolicyName',
280 'example_value': True,
281 'supported_on': [ { 'platforms': ['win', 'mac', 'linux'] } ]
283 e1 = self.writer.AddElement(self.doc_root, 'e1')
284 self.writer._AddExample(e1, policy)
287 '<e1>0x00000001 (Windows), true (Linux), <true /> (Mac)</e1>')
290 'name': 'PolicyName',
292 'example_value': False,
293 'supported_on': [ { 'platforms': ['win', 'mac', 'linux'] } ]
295 e2 = self.writer.AddElement(self.doc_root, 'e2')
296 self.writer._AddExample(e2, policy)
299 '<e2>0x00000000 (Windows), false (Linux), <false /> (Mac)</e2>')
301 def testIntEnumExample(self):
302 # Test representation of 'int-enum' example values.
304 'name': 'PolicyName',
307 'supported_on': [ { 'platforms': ['win', 'mac', 'linux'] } ]
309 self.writer._AddExample(self.doc_root, policy)
311 self.doc_root.toxml(),
312 '<root>0x00000010 (Windows), 16 (Linux), 16 (Mac)</root>')
314 def testStringEnumExample(self):
315 # Test representation of 'string-enum' example values.
317 'name': 'PolicyName',
318 'type': 'string-enum',
319 'example_value': "wacky"
321 self.writer._AddExample(self.doc_root, policy)
323 self.doc_root.toxml(),
324 '<root>"wacky"</root>')
326 def testListExample(self):
327 # Test representation of 'list' example values.
329 'name': 'PolicyName',
331 'example_value': ['one', 'two'],
332 'supported_on': [ { 'platforms': ['linux'] } ]
334 self.writer._AddExample(self.doc_root, policy)
336 self.doc_root.toxml(),
337 '<root><dl style="style_dd dl;">'
339 '<dd style="style_.monospace;">'
340 '["one", "two"]'
343 def testStringEnumListExample(self):
344 # Test representation of 'string-enum-list' example values.
346 'name': 'PolicyName',
347 'type': 'string-enum-list',
348 'example_value': ['one', 'two'],
349 'supported_on': [ { 'platforms': ['linux'] } ]
351 self.writer._AddExample(self.doc_root, policy)
353 self.doc_root.toxml(),
354 '<root><dl style="style_dd dl;">'
356 '<dd style="style_.monospace;">'
357 '["one", "two"]'
360 def testStringExample(self):
361 # Test representation of 'string' example values.
363 'name': 'PolicyName',
365 'example_value': 'awesome-example'
367 self.writer._AddExample(self.doc_root, policy)
369 self.doc_root.toxml(),
370 '<root>"awesome-example"</root>')
372 def testIntExample(self):
373 # Test representation of 'int' example values.
375 'name': 'PolicyName',
378 'supported_on': [ { 'platforms': ['win', 'mac', 'linux'] } ]
380 self.writer._AddExample(self.doc_root, policy)
382 self.doc_root.toxml(),
383 '<root>0x0000001a (Windows), 26 (Linux), 26 (Mac)</root>')
385 def testAddPolicyAttribute(self):
386 # Test creating a policy attribute term-definition pair.
387 self.writer._AddPolicyAttribute(
388 self.doc_root, 'bla', 'hello, world', ['key1'])
390 self.doc_root.toxml(),
392 '<dt style="style_dt;">_test_bla</dt>'
393 '<dd style="style1;">hello, world</dd>'
396 def testAddPolicyDetails(self):
397 # Test if the definition list (<dl>) of policy details is created correctly.
400 'name': 'TestPolicyName',
401 'caption': 'TestPolicyCaption',
402 'desc': 'TestPolicyDesc',
405 'platforms': ['win', 'mac', 'linux'],
406 'since_version': '8',
410 'platforms': ['android'],
411 'since_version': '30',
415 'platforms': ['ios'],
416 'since_version': '34',
419 'features': {'dynamic_refresh': False},
420 'example_value': False
422 self.writer.messages['doc_since_version'] = {'text': '...$6...'}
423 self.writer._AddPolicyDetails(self.doc_root, policy)
425 self.doc_root.toxml(),
427 '<dt style="style_dt;">_test_data_type</dt><dd>Boolean (REG_DWORD)</dd>'
428 '<dt style="style_dt;">_test_win_reg_loc</dt>'
429 '<dd style="style_.monospace;">MockKey\TestPolicyName</dd>'
430 '<dt style="style_dt;">_test_mac_linux_pref_name</dt>'
431 '<dd style="style_.monospace;">TestPolicyName</dd>'
432 '<dt style="style_dt;">_test_supported_on</dt>'
434 '<ul style="style_ul;">'
435 '<li>Chrome (Windows, Mac, Linux) ...8...</li>'
436 '<li>Chrome (Android) ...30...</li>'
437 '<li>Chrome (iOS) ...34...</li>'
440 '<dt style="style_dt;">_test_supported_features</dt>'
441 '<dd>_test_feature_dynamic_refresh: _test_not_supported</dd>'
442 '<dt style="style_dt;">_test_description</dt><dd>TestPolicyDesc</dd>'
443 '<dt style="style_dt;">_test_example_value</dt>'
444 '<dd>0x00000000 (Windows), false (Linux), <false /> (Mac)</dd>'
447 def testAddDictPolicyDetails(self):
448 # Test if the definition list (<dl>) of policy details is created correctly
449 # for 'dict' policies.
452 'name': 'TestPolicyName',
453 'caption': 'TestPolicyCaption',
454 'desc': 'TestPolicyDesc',
457 'platforms': ['win', 'mac', 'linux'],
458 'since_version': '8',
461 'features': {'dynamic_refresh': False},
462 'example_value': { 'foo': 123 }
464 self.writer.messages['doc_since_version'] = {'text': '...$6...'}
465 self.writer._AddPolicyDetails(self.doc_root, policy)
467 self.doc_root.toxml(),
469 '<dt style="style_dt;">_test_data_type</dt><dd>Dictionary (REG_SZ; _test_complex_policies_win)</dd>'
470 '<dt style="style_dt;">_test_win_reg_loc</dt>'
471 '<dd style="style_.monospace;">MockKey\TestPolicyName</dd>'
472 '<dt style="style_dt;">_test_mac_linux_pref_name</dt>'
473 '<dd style="style_.monospace;">TestPolicyName</dd>'
474 '<dt style="style_dt;">_test_supported_on</dt>'
476 '<ul style="style_ul;">'
477 '<li>Chrome (Windows, Mac, Linux) ...8...</li>'
480 '<dt style="style_dt;">_test_supported_features</dt>'
481 '<dd>_test_feature_dynamic_refresh: _test_not_supported</dd>'
482 '<dt style="style_dt;">_test_description</dt><dd>TestPolicyDesc</dd>'
483 '<dt style="style_dt;">_test_example_value</dt>'
485 '<dl style="style_dd dl;">'
487 '<dd style="style_.monospace;style_.pre;">MockKey\TestPolicyName = {"foo": 123}</dd>'
489 '<dd style="style_.monospace;">TestPolicyName: {"foo": 123}</dd>'
491 '<dd style="style_.monospace;style_.pre;">'
492 '<key>TestPolicyName</key>\n'
494 ' <key>foo</key>\n'
495 ' <integer>123</integer>\n'
502 def testAddPolicyDetailsRecommendedOnly(self):
505 'name': 'TestPolicyName',
506 'caption': 'TestPolicyCaption',
507 'desc': 'TestPolicyDesc',
510 'platforms': ['win', 'mac', 'linux'],
511 'since_version': '8',
515 'platforms': ['android'],
516 'since_version': '30',
520 'platforms': ['ios'],
521 'since_version': '34',
525 'dynamic_refresh': False,
526 'can_be_mandatory': False,
527 'can_be_recommended': True
529 'example_value': False
531 self.writer.messages['doc_since_version'] = {'text': '...$6...'}
532 self.writer._AddPolicyDetails(self.doc_root, policy)
534 self.doc_root.toxml(),
536 '<dt style="style_dt;">_test_data_type</dt><dd>Boolean (REG_DWORD)</dd>'
537 '<dt style="style_dt;">_test_win_reg_loc</dt>'
538 '<dd style="style_.monospace;">MockKeyRec\TestPolicyName</dd>'
539 '<dt style="style_dt;">_test_mac_linux_pref_name</dt>'
540 '<dd style="style_.monospace;">TestPolicyName</dd>'
541 '<dt style="style_dt;">_test_supported_on</dt>'
543 '<ul style="style_ul;">'
544 '<li>Chrome (Windows, Mac, Linux) ...8...</li>'
545 '<li>Chrome (Android) ...30...</li>'
546 '<li>Chrome (iOS) ...34...</li>'
549 '<dt style="style_dt;">_test_supported_features</dt>'
550 '<dd>_test_feature_mandatory: _test_not_supported,'
551 ' _test_feature_recommended: _test_supported,'
552 ' _test_feature_dynamic_refresh: _test_not_supported</dd>'
553 '<dt style="style_dt;">_test_description</dt><dd>TestPolicyDesc</dd>'
554 '<dt style="style_dt;">_test_example_value</dt>'
555 '<dd>0x00000000 (Windows), false (Linux), <false /> (Mac)</dd>'
558 def testAddPolicyNote(self):
559 # TODO(jkummerow): The functionality tested by this test is currently not
560 # used for anything and will probably soon be removed.
561 # Test if nodes are correctly added to policies.
563 'problem_href': 'http://www.example.com/5'
565 self.writer.messages['doc_note'] = {'text': '...$6...'}
566 self.writer._AddPolicyNote(self.doc_root, policy)
568 self.doc_root.toxml(),
569 '<root><div style="style_div.note;">...'
570 '<a href="http://www.example.com/5">http://www.example.com/5</a>'
573 def testAddPolicyRow(self):
574 # Test if policies are correctly added to the summary table.
576 'name': 'PolicyName',
577 'caption': 'PolicyCaption',
580 self.writer._indent_level = 3
581 self.writer._AddPolicyRow(self.doc_root, policy)
583 self.doc_root.toxml(),
584 '<root><tr style="style_tr;">'
585 '<td style="style_td;style_td.left;padding-left: 49px;">'
586 '<a href="#PolicyName">PolicyName</a>'
588 '<td style="style_td;style_td.right;">PolicyCaption</td>'
592 'name': 'PolicyName',
593 'caption': 'PolicyCaption',
596 self.writer._indent_level = 2
597 self.writer._AddPolicyRow(self.doc_root, policy)
599 self.doc_root.toxml(),
600 '<root><tr style="style_tr;">'
601 '<td colspan="2" style="style_td;style_td.left;padding-left: 35px;">'
602 '<a href="#PolicyName">PolicyCaption</a>'
606 def testAddPolicySection(self):
607 # Test if policy details are correctly added to the document.
609 'name': 'PolicyName',
610 'caption': 'PolicyCaption',
611 'desc': 'PolicyDesc',
615 'platforms': ['win', 'mac'],
616 'since_version': '7',
619 'features': {'dynamic_refresh': False},
620 'example_value': 'False'
622 self.writer.messages['doc_since_version'] = {'text': '..$6..'}
623 self.writer._AddPolicySection(self.doc_root, policy)
625 self.doc_root.toxml(),
627 '<div style="margin-left: 0px">'
628 '<h3><a name="PolicyName"/>PolicyName</h3>'
629 '<span>PolicyCaption</span>'
631 '<dt style="style_dt;">_test_data_type</dt>'
632 '<dd>String (REG_SZ)</dd>'
633 '<dt style="style_dt;">_test_win_reg_loc</dt>'
634 '<dd style="style_.monospace;">MockKey\\PolicyName</dd>'
635 '<dt style="style_dt;">_test_mac_linux_pref_name</dt>'
636 '<dd style="style_.monospace;">PolicyName</dd>'
637 '<dt style="style_dt;">_test_supported_on</dt>'
639 '<ul style="style_ul;">'
640 '<li>Chrome (Windows, Mac) ..7..</li>'
643 '<dt style="style_dt;">_test_supported_features</dt>'
644 '<dd>_test_feature_dynamic_refresh: _test_not_supported</dd>'
645 '<dt style="style_dt;">_test_description</dt>'
646 '<dd>PolicyDesc</dd>'
647 '<dt style="style_dt;">_test_example_value</dt>'
648 '<dd>"False"</dd>'
650 '<a href="#top">_test_back_to_top</a>'
655 policy['type'] = 'group'
656 self.writer._AddPolicySection(self.doc_root, policy)
658 self.doc_root.toxml(),
660 '<div style="margin-left: 0px">'
661 '<h2><a name="PolicyName"/>PolicyCaption</h2>'
662 '<div style="style_div.group_desc;">PolicyDesc</div>'
663 '<a href="#top">_test_back_to_top</a>'
667 def testAddPolicySectionForWindowsOnly(self):
669 'name': 'PolicyName',
670 'caption': 'PolicyCaption',
671 'desc': 'PolicyDesc',
675 'platforms': ['win'],
676 'since_version': '33',
679 'features': {'dynamic_refresh': False},
682 self.writer.messages['doc_since_version'] = {'text': '..$6..'}
683 self.writer._AddPolicySection(self.doc_root, policy)
685 self.doc_root.toxml(),
687 '<div style="margin-left: 0px">'
688 '<h3><a name="PolicyName"/>PolicyName</h3>'
689 '<span>PolicyCaption</span>'
691 '<dt style="style_dt;">_test_data_type</dt>'
692 '<dd>Integer (REG_DWORD)</dd>'
693 '<dt style="style_dt;">_test_win_reg_loc</dt>'
694 '<dd style="style_.monospace;">MockKey\\PolicyName</dd>'
695 '<dt style="style_dt;">_test_supported_on</dt>'
697 '<ul style="style_ul;">'
698 '<li>Chrome (Windows) ..33..</li>'
701 '<dt style="style_dt;">_test_supported_features</dt>'
702 '<dd>_test_feature_dynamic_refresh: _test_not_supported</dd>'
703 '<dt style="style_dt;">_test_description</dt>'
704 '<dd>PolicyDesc</dd>'
705 '<dt style="style_dt;">_test_example_value</dt>'
706 '<dd>0x0000007b (Windows)</dd>'
708 '<a href="#top">_test_back_to_top</a>'
712 def testAddPolicySectionForMacOnly(self):
714 'name': 'PolicyName',
715 'caption': 'PolicyCaption',
716 'desc': 'PolicyDesc',
720 'platforms': ['mac'],
721 'since_version': '33',
724 'features': {'dynamic_refresh': False},
727 self.writer.messages['doc_since_version'] = {'text': '..$6..'}
728 self.writer._AddPolicySection(self.doc_root, policy)
730 self.doc_root.toxml(),
732 '<div style="margin-left: 0px">'
733 '<h3><a name="PolicyName"/>PolicyName</h3>'
734 '<span>PolicyCaption</span>'
736 '<dt style="style_dt;">_test_data_type</dt>'
738 '<dt style="style_dt;">_test_mac_linux_pref_name</dt>'
739 '<dd style="style_.monospace;">PolicyName</dd>'
740 '<dt style="style_dt;">_test_supported_on</dt>'
742 '<ul style="style_ul;">'
743 '<li>Chrome (Mac) ..33..</li>'
746 '<dt style="style_dt;">_test_supported_features</dt>'
747 '<dd>_test_feature_dynamic_refresh: _test_not_supported</dd>'
748 '<dt style="style_dt;">_test_description</dt>'
749 '<dd>PolicyDesc</dd>'
750 '<dt style="style_dt;">_test_example_value</dt>'
753 '<a href="#top">_test_back_to_top</a>'
757 def testAddPolicySectionForLinuxOnly(self):
759 'name': 'PolicyName',
760 'caption': 'PolicyCaption',
761 'desc': 'PolicyDesc',
765 'platforms': ['linux'],
766 'since_version': '33',
769 'features': {'dynamic_refresh': False},
772 self.writer.messages['doc_since_version'] = {'text': '..$6..'}
773 self.writer._AddPolicySection(self.doc_root, policy)
775 self.doc_root.toxml(),
777 '<div style="margin-left: 0px">'
778 '<h3><a name="PolicyName"/>PolicyName</h3>'
779 '<span>PolicyCaption</span>'
781 '<dt style="style_dt;">_test_data_type</dt>'
783 '<dt style="style_dt;">_test_mac_linux_pref_name</dt>'
784 '<dd style="style_.monospace;">PolicyName</dd>'
785 '<dt style="style_dt;">_test_supported_on</dt>'
787 '<ul style="style_ul;">'
788 '<li>Chrome (Linux) ..33..</li>'
791 '<dt style="style_dt;">_test_supported_features</dt>'
792 '<dd>_test_feature_dynamic_refresh: _test_not_supported</dd>'
793 '<dt style="style_dt;">_test_description</dt>'
794 '<dd>PolicyDesc</dd>'
795 '<dt style="style_dt;">_test_example_value</dt>'
796 '<dd>123 (Linux)</dd>'
798 '<a href="#top">_test_back_to_top</a>'
802 def testAddDictionaryExample(self):
804 'name': 'PolicyName',
805 'caption': 'PolicyCaption',
806 'desc': 'PolicyDesc',
810 'platforms': ['win', 'mac', 'linux'],
811 'since_version': '7',
814 'features': {'dynamic_refresh': False},
816 "ProxyMode": "direct",
817 "List": ["1", "2", "3"],
831 self.writer._AddDictionaryExample(self.doc_root, policy)
832 value = json.dumps(policy['example_value']).replace('"', '"')
834 self.doc_root.toxml(),
836 '<dl style="style_dd dl;">'
838 '<dd style="style_.monospace;style_.pre;">MockKey\PolicyName = '
842 '<dd style="style_.monospace;">PolicyName: ' + value + '</dd>'
844 '<dd style="style_.monospace;style_.pre;">'
845 '<key>PolicyName</key>\n'
847 ' <key>DictList</key>\n'
850 ' <key>A</key>\n'
851 ' <integer>1</integer>\n'
852 ' <key>B</key>\n'
853 ' <integer>2</integer>\n'
856 ' <key>C</key>\n'
857 ' <integer>3</integer>\n'
858 ' <key>D</key>\n'
859 ' <integer>4</integer>\n'
862 ' <key>False</key>\n'
864 ' <key>Integer</key>\n'
865 ' <integer>123</integer>\n'
866 ' <key>List</key>\n'
868 ' <string>1</string>\n'
869 ' <string>2</string>\n'
870 ' <string>3</string>\n'
872 ' <key>ProxyMode</key>\n'
873 ' <string>direct</string>\n'
874 ' <key>True</key>\n'
882 if __name__ == '__main__':