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',
43 self.writer.messages = {
44 'doc_back_to_top': {'text': '_test_back_to_top'},
45 'doc_complex_policies_on_windows': {'text': '_test_complex_policies_win'},
46 'doc_data_type': {'text': '_test_data_type'},
47 'doc_description': {'text': '_test_description'},
48 'doc_description_column_title': {
49 'text': '_test_description_column_title'
51 'doc_example_value': {'text': '_test_example_value'},
52 'doc_feature_dynamic_refresh': {'text': '_test_feature_dynamic_refresh'},
53 'doc_feature_can_be_recommended': {'text': '_test_feature_recommended'},
54 'doc_feature_can_be_mandatory': {'text': '_test_feature_mandatory'},
55 'doc_intro': {'text': '_test_intro'},
56 'doc_mac_linux_pref_name': {'text': '_test_mac_linux_pref_name'},
57 'doc_note': {'text': '_test_note'},
58 'doc_name_column_title': {'text': '_test_name_column_title'},
59 'doc_not_supported': {'text': '_test_not_supported'},
60 'doc_since_version': {'text': '_test_since_version'},
61 'doc_supported': {'text': '_test_supported'},
62 'doc_supported_features': {'text': '_test_supported_features'},
63 'doc_supported_on': {'text': '_test_supported_on'},
64 'doc_win_reg_loc': {'text': '_test_win_reg_loc'},
66 'doc_bla': {'text': '_test_bla'},
70 # It is not worth testing the exact content of style attributes.
71 # Therefore we override them here with shorter texts.
72 for key in self.writer._STYLE.keys():
73 self.writer._STYLE[key] = 'style_%s;' % key
74 # Add some more style attributes for additional testing.
75 self.writer._STYLE['key1'] = 'style1;'
76 self.writer._STYLE['key2'] = 'style2;'
78 # Create a DOM document for the tests.
79 dom_impl = minidom.getDOMImplementation('')
80 self.doc = dom_impl.createDocument(None, 'root', None)
81 self.doc_root = self.doc.documentElement
83 def testSkeleton(self):
84 # Test if DocWriter creates the skeleton of the document correctly.
85 self.writer.BeginTemplate()
87 self.writer._main_div.toxml(),
90 '<a name="top"/><br/>_test_intro<br/><br/><br/>'
91 '<table style="style_table;">'
92 '<thead><tr style="style_tr;">'
93 '<td style="style_td;style_td.left;style_thead td;">'
94 '_test_name_column_title'
96 '<td style="style_td;style_td.right;style_thead td;">'
97 '_test_description_column_title'
106 def testGetLocalizedMessage(self):
107 # Test if localized messages are retrieved correctly.
108 self.writer.messages = {
109 'doc_hello_world': {'text': 'hello, vilag!'}
112 self.writer._GetLocalizedMessage('hello_world'),
115 def testMapListToString(self):
116 # Test function DocWriter.MapListToString()
118 self.writer._MapListToString({'a1': 'a2', 'b1': 'b2'}, ['a1', 'b1']),
121 self.writer._MapListToString({'a1': 'a2', 'b1': 'b2'}, []),
123 result = self.writer._MapListToString(
124 {'a': '1', 'b': '2', 'c': '3', 'd': '4'}, ['b', 'd'])
125 expected_result = '2, 4'
130 def testAddStyledElement(self):
131 # Test function DocWriter.AddStyledElement()
133 # Test the case of zero style.
134 e1 = self.writer._AddStyledElement(
135 self.doc_root, 'z', [], {'a': 'b'}, 'text')
140 # Test the case of one style.
141 e2 = self.writer._AddStyledElement(
142 self.doc_root, 'z', ['key1'], {'a': 'b'}, 'text')
145 '<z a="b" style="style1;">text</z>')
147 # Test the case of two styles.
148 e3 = self.writer._AddStyledElement(
149 self.doc_root, 'z', ['key1', 'key2'], {'a': 'b'}, 'text')
152 '<z a="b" style="style1;style2;">text</z>')
154 def testAddDescriptionIntEnum(self):
155 # Test if URLs are replaced and choices of 'int-enum' policies are listed
160 {'value': 0, 'caption': 'Disable foo'},
161 {'value': 2, 'caption': 'Solve your problem'},
162 {'value': 5, 'caption': 'Enable bar'},
164 'desc': '''This policy disables foo, except in case of bar.
165 See http://policy-explanation.example.com for more details.
168 self.writer._AddDescription(self.doc_root, policy)
170 self.doc_root.toxml(),
171 '''<root>This policy disables foo, except in case of bar.
172 See <a href="http://policy-explanation.example.com">http://policy-explanation.example.com</a> for more details.
173 <ul><li>0 = Disable foo</li><li>2 = Solve your problem</li><li>5 = Enable bar</li></ul></root>''')
175 def testAddDescriptionStringEnum(self):
176 # Test if URLs are replaced and choices of 'int-enum' policies are listed
179 'type': 'string-enum',
181 {'value': "one", 'caption': 'Disable foo'},
182 {'value': "two", 'caption': 'Solve your problem'},
183 {'value': "three", 'caption': 'Enable bar'},
185 'desc': '''This policy disables foo, except in case of bar.
186 See http://policy-explanation.example.com for more details.
189 self.writer._AddDescription(self.doc_root, policy)
191 self.doc_root.toxml(),
192 '''<root>This policy disables foo, except in case of bar.
193 See <a href="http://policy-explanation.example.com">http://policy-explanation.example.com</a> for more details.
194 <ul><li>"one" = Disable foo</li><li>"two" = Solve your problem</li><li>"three" = Enable bar</li></ul></root>''')
196 def testAddFeatures(self):
197 # Test if the list of features of a policy is handled correctly.
200 'spaceship_docking': False,
201 'dynamic_refresh': True,
202 'can_be_recommended': True,
205 self.writer._FEATURE_MAP = {
206 'can_be_recommended': 'Can Be Recommended',
207 'dynamic_refresh': 'Dynamic Refresh',
208 'spaceship_docking': 'Spaceship Docking',
210 self.writer._AddFeatures(self.doc_root, policy)
212 self.doc_root.toxml(),
214 'Can Be Recommended: _test_supported, '
215 'Dynamic Refresh: _test_supported, '
216 'Spaceship Docking: _test_not_supported'
219 def testAddListExample(self):
221 'name': 'PolicyName',
222 'example_value': ['Foo', 'Bar'],
223 'supported_on': [ { 'platforms': ['win', 'mac', 'linux'] } ]
225 self.writer._AddListExample(self.doc_root, policy)
227 self.doc_root.toxml(),
229 '<dl style="style_dd dl;">'
231 '<dd style="style_.monospace;style_.pre;">'
232 'MockKey\\PolicyName\\1 = "Foo"\n'
233 'MockKey\\PolicyName\\2 = "Bar"'
236 '<dd style="style_.monospace;">'
237 '["Foo", "Bar"]'
240 '<dd style="style_.monospace;style_.pre;">'
242 ' <string>Foo</string>\n'
243 ' <string>Bar</string>\n'
249 def testBoolExample(self):
250 # Test representation of boolean example values.
252 'name': 'PolicyName',
254 'example_value': True,
255 'supported_on': [ { 'platforms': ['win', 'mac', 'linux'] } ]
257 e1 = self.writer.AddElement(self.doc_root, 'e1')
258 self.writer._AddExample(e1, policy)
261 '<e1>0x00000001 (Windows), true (Linux), <true /> (Mac)</e1>')
264 'name': 'PolicyName',
266 'example_value': False,
267 'supported_on': [ { 'platforms': ['win', 'mac', 'linux'] } ]
269 e2 = self.writer.AddElement(self.doc_root, 'e2')
270 self.writer._AddExample(e2, policy)
273 '<e2>0x00000000 (Windows), false (Linux), <false /> (Mac)</e2>')
275 def testIntEnumExample(self):
276 # Test representation of 'int-enum' example values.
278 'name': 'PolicyName',
281 'supported_on': [ { 'platforms': ['win', 'mac', 'linux'] } ]
283 self.writer._AddExample(self.doc_root, policy)
285 self.doc_root.toxml(),
286 '<root>0x00000010 (Windows), 16 (Linux), 16 (Mac)</root>')
288 def testStringEnumExample(self):
289 # Test representation of 'string-enum' example values.
291 'name': 'PolicyName',
292 'type': 'string-enum',
293 'example_value': "wacky"
295 self.writer._AddExample(self.doc_root, policy)
297 self.doc_root.toxml(),
298 '<root>"wacky"</root>')
300 def testListExample(self):
301 # Test representation of 'list' example values.
303 'name': 'PolicyName',
305 'example_value': ['one', 'two'],
306 'supported_on': [ { 'platforms': ['linux'] } ]
308 self.writer._AddExample(self.doc_root, policy)
310 self.doc_root.toxml(),
311 '<root><dl style="style_dd dl;">'
313 '<dd style="style_.monospace;">'
314 '["one", "two"]'
317 def testStringEnumListExample(self):
318 # Test representation of 'string-enum-list' example values.
320 'name': 'PolicyName',
321 'type': 'string-enum-list',
322 'example_value': ['one', 'two'],
323 'supported_on': [ { 'platforms': ['linux'] } ]
325 self.writer._AddExample(self.doc_root, policy)
327 self.doc_root.toxml(),
328 '<root><dl style="style_dd dl;">'
330 '<dd style="style_.monospace;">'
331 '["one", "two"]'
334 def testStringExample(self):
335 # Test representation of 'string' example values.
337 'name': 'PolicyName',
339 'example_value': 'awesome-example'
341 self.writer._AddExample(self.doc_root, policy)
343 self.doc_root.toxml(),
344 '<root>"awesome-example"</root>')
346 def testIntExample(self):
347 # Test representation of 'int' example values.
349 'name': 'PolicyName',
352 'supported_on': [ { 'platforms': ['win', 'mac', 'linux'] } ]
354 self.writer._AddExample(self.doc_root, policy)
356 self.doc_root.toxml(),
357 '<root>0x0000001a (Windows), 26 (Linux), 26 (Mac)</root>')
359 def testAddPolicyAttribute(self):
360 # Test creating a policy attribute term-definition pair.
361 self.writer._AddPolicyAttribute(
362 self.doc_root, 'bla', 'hello, world', ['key1'])
364 self.doc_root.toxml(),
366 '<dt style="style_dt;">_test_bla</dt>'
367 '<dd style="style1;">hello, world</dd>'
370 def testAddPolicyDetails(self):
371 # Test if the definition list (<dl>) of policy details is created correctly.
374 'name': 'TestPolicyName',
375 'caption': 'TestPolicyCaption',
376 'desc': 'TestPolicyDesc',
379 'platforms': ['win', 'mac', 'linux'],
380 'since_version': '8',
384 'platforms': ['android'],
385 'since_version': '30',
389 'platforms': ['ios'],
390 'since_version': '34',
393 'features': {'dynamic_refresh': False},
394 'example_value': False
396 self.writer.messages['doc_since_version'] = {'text': '...$6...'}
397 self.writer._AddPolicyDetails(self.doc_root, policy)
399 self.doc_root.toxml(),
401 '<dt style="style_dt;">_test_data_type</dt><dd>Boolean (REG_DWORD)</dd>'
402 '<dt style="style_dt;">_test_win_reg_loc</dt>'
403 '<dd style="style_.monospace;">MockKey\TestPolicyName</dd>'
404 '<dt style="style_dt;">_test_mac_linux_pref_name</dt>'
405 '<dd style="style_.monospace;">TestPolicyName</dd>'
406 '<dt style="style_dt;">_test_supported_on</dt>'
408 '<ul style="style_ul;">'
409 '<li>Chrome (Windows, Mac, Linux) ...8...</li>'
410 '<li>Chrome (Android) ...30...</li>'
411 '<li>Chrome (iOS) ...34...</li>'
414 '<dt style="style_dt;">_test_supported_features</dt>'
415 '<dd>_test_feature_dynamic_refresh: _test_not_supported</dd>'
416 '<dt style="style_dt;">_test_description</dt><dd>TestPolicyDesc</dd>'
417 '<dt style="style_dt;">_test_example_value</dt>'
418 '<dd>0x00000000 (Windows), false (Linux), <false /> (Mac)</dd>'
421 def testAddDictPolicyDetails(self):
422 # Test if the definition list (<dl>) of policy details is created correctly
423 # for 'dict' policies.
426 'name': 'TestPolicyName',
427 'caption': 'TestPolicyCaption',
428 'desc': 'TestPolicyDesc',
431 'platforms': ['win', 'mac', 'linux'],
432 'since_version': '8',
435 'features': {'dynamic_refresh': False},
436 'example_value': { 'foo': 123 }
438 self.writer.messages['doc_since_version'] = {'text': '...$6...'}
439 self.writer._AddPolicyDetails(self.doc_root, policy)
441 self.doc_root.toxml(),
443 '<dt style="style_dt;">_test_data_type</dt><dd>Dictionary (REG_SZ; _test_complex_policies_win)</dd>'
444 '<dt style="style_dt;">_test_win_reg_loc</dt>'
445 '<dd style="style_.monospace;">MockKey\TestPolicyName</dd>'
446 '<dt style="style_dt;">_test_mac_linux_pref_name</dt>'
447 '<dd style="style_.monospace;">TestPolicyName</dd>'
448 '<dt style="style_dt;">_test_supported_on</dt>'
450 '<ul style="style_ul;">'
451 '<li>Chrome (Windows, Mac, Linux) ...8...</li>'
454 '<dt style="style_dt;">_test_supported_features</dt>'
455 '<dd>_test_feature_dynamic_refresh: _test_not_supported</dd>'
456 '<dt style="style_dt;">_test_description</dt><dd>TestPolicyDesc</dd>'
457 '<dt style="style_dt;">_test_example_value</dt>'
459 '<dl style="style_dd dl;">'
461 '<dd style="style_.monospace;style_.pre;">MockKey\TestPolicyName = {"foo": 123}</dd>'
463 '<dd style="style_.monospace;">TestPolicyName: {"foo": 123}</dd>'
465 '<dd style="style_.monospace;style_.pre;">'
466 '<key>TestPolicyName</key>\n'
468 ' <key>foo</key>\n'
469 ' <integer>123</integer>\n'
476 def testAddPolicyDetailsRecommendedOnly(self):
479 'name': 'TestPolicyName',
480 'caption': 'TestPolicyCaption',
481 'desc': 'TestPolicyDesc',
484 'platforms': ['win', 'mac', 'linux'],
485 'since_version': '8',
489 'platforms': ['android'],
490 'since_version': '30',
494 'platforms': ['ios'],
495 'since_version': '34',
499 'dynamic_refresh': False,
500 'can_be_mandatory': False,
501 'can_be_recommended': True
503 'example_value': False
505 self.writer.messages['doc_since_version'] = {'text': '...$6...'}
506 self.writer._AddPolicyDetails(self.doc_root, policy)
508 self.doc_root.toxml(),
510 '<dt style="style_dt;">_test_data_type</dt><dd>Boolean (REG_DWORD)</dd>'
511 '<dt style="style_dt;">_test_win_reg_loc</dt>'
512 '<dd style="style_.monospace;">MockKeyRec\TestPolicyName</dd>'
513 '<dt style="style_dt;">_test_mac_linux_pref_name</dt>'
514 '<dd style="style_.monospace;">TestPolicyName</dd>'
515 '<dt style="style_dt;">_test_supported_on</dt>'
517 '<ul style="style_ul;">'
518 '<li>Chrome (Windows, Mac, Linux) ...8...</li>'
519 '<li>Chrome (Android) ...30...</li>'
520 '<li>Chrome (iOS) ...34...</li>'
523 '<dt style="style_dt;">_test_supported_features</dt>'
524 '<dd>_test_feature_mandatory: _test_not_supported,'
525 ' _test_feature_recommended: _test_supported,'
526 ' _test_feature_dynamic_refresh: _test_not_supported</dd>'
527 '<dt style="style_dt;">_test_description</dt><dd>TestPolicyDesc</dd>'
528 '<dt style="style_dt;">_test_example_value</dt>'
529 '<dd>0x00000000 (Windows), false (Linux), <false /> (Mac)</dd>'
532 def testAddPolicyNote(self):
533 # TODO(jkummerow): The functionality tested by this test is currently not
534 # used for anything and will probably soon be removed.
535 # Test if nodes are correctly added to policies.
537 'problem_href': 'http://www.example.com/5'
539 self.writer.messages['doc_note'] = {'text': '...$6...'}
540 self.writer._AddPolicyNote(self.doc_root, policy)
542 self.doc_root.toxml(),
543 '<root><div style="style_div.note;">...'
544 '<a href="http://www.example.com/5">http://www.example.com/5</a>'
547 def testAddPolicyRow(self):
548 # Test if policies are correctly added to the summary table.
550 'name': 'PolicyName',
551 'caption': 'PolicyCaption',
554 self.writer._indent_level = 3
555 self.writer._AddPolicyRow(self.doc_root, policy)
557 self.doc_root.toxml(),
558 '<root><tr style="style_tr;">'
559 '<td style="style_td;style_td.left;padding-left: 49px;">'
560 '<a href="#PolicyName">PolicyName</a>'
562 '<td style="style_td;style_td.right;">PolicyCaption</td>'
566 'name': 'PolicyName',
567 'caption': 'PolicyCaption',
570 self.writer._indent_level = 2
571 self.writer._AddPolicyRow(self.doc_root, policy)
573 self.doc_root.toxml(),
574 '<root><tr style="style_tr;">'
575 '<td colspan="2" style="style_td;style_td.left;padding-left: 35px;">'
576 '<a href="#PolicyName">PolicyCaption</a>'
580 def testAddPolicySection(self):
581 # Test if policy details are correctly added to the document.
583 'name': 'PolicyName',
584 'caption': 'PolicyCaption',
585 'desc': 'PolicyDesc',
589 'platforms': ['win', 'mac'],
590 'since_version': '7',
593 'features': {'dynamic_refresh': False},
594 'example_value': 'False'
596 self.writer.messages['doc_since_version'] = {'text': '..$6..'}
597 self.writer._AddPolicySection(self.doc_root, policy)
599 self.doc_root.toxml(),
601 '<div style="margin-left: 0px">'
602 '<h3><a name="PolicyName"/>PolicyName</h3>'
603 '<span>PolicyCaption</span>'
605 '<dt style="style_dt;">_test_data_type</dt>'
606 '<dd>String (REG_SZ)</dd>'
607 '<dt style="style_dt;">_test_win_reg_loc</dt>'
608 '<dd style="style_.monospace;">MockKey\\PolicyName</dd>'
609 '<dt style="style_dt;">_test_mac_linux_pref_name</dt>'
610 '<dd style="style_.monospace;">PolicyName</dd>'
611 '<dt style="style_dt;">_test_supported_on</dt>'
613 '<ul style="style_ul;">'
614 '<li>Chrome (Windows, Mac) ..7..</li>'
617 '<dt style="style_dt;">_test_supported_features</dt>'
618 '<dd>_test_feature_dynamic_refresh: _test_not_supported</dd>'
619 '<dt style="style_dt;">_test_description</dt>'
620 '<dd>PolicyDesc</dd>'
621 '<dt style="style_dt;">_test_example_value</dt>'
622 '<dd>"False"</dd>'
624 '<a href="#top">_test_back_to_top</a>'
629 policy['type'] = 'group'
630 self.writer._AddPolicySection(self.doc_root, policy)
632 self.doc_root.toxml(),
634 '<div style="margin-left: 0px">'
635 '<h2><a name="PolicyName"/>PolicyCaption</h2>'
636 '<div style="style_div.group_desc;">PolicyDesc</div>'
637 '<a href="#top">_test_back_to_top</a>'
641 def testAddPolicySectionForWindowsOnly(self):
643 'name': 'PolicyName',
644 'caption': 'PolicyCaption',
645 'desc': 'PolicyDesc',
649 'platforms': ['win'],
650 'since_version': '33',
653 'features': {'dynamic_refresh': False},
656 self.writer.messages['doc_since_version'] = {'text': '..$6..'}
657 self.writer._AddPolicySection(self.doc_root, policy)
659 self.doc_root.toxml(),
661 '<div style="margin-left: 0px">'
662 '<h3><a name="PolicyName"/>PolicyName</h3>'
663 '<span>PolicyCaption</span>'
665 '<dt style="style_dt;">_test_data_type</dt>'
666 '<dd>Integer (REG_DWORD)</dd>'
667 '<dt style="style_dt;">_test_win_reg_loc</dt>'
668 '<dd style="style_.monospace;">MockKey\\PolicyName</dd>'
669 '<dt style="style_dt;">_test_supported_on</dt>'
671 '<ul style="style_ul;">'
672 '<li>Chrome (Windows) ..33..</li>'
675 '<dt style="style_dt;">_test_supported_features</dt>'
676 '<dd>_test_feature_dynamic_refresh: _test_not_supported</dd>'
677 '<dt style="style_dt;">_test_description</dt>'
678 '<dd>PolicyDesc</dd>'
679 '<dt style="style_dt;">_test_example_value</dt>'
680 '<dd>0x0000007b (Windows)</dd>'
682 '<a href="#top">_test_back_to_top</a>'
686 def testAddPolicySectionForMacOnly(self):
688 'name': 'PolicyName',
689 'caption': 'PolicyCaption',
690 'desc': 'PolicyDesc',
694 'platforms': ['mac'],
695 'since_version': '33',
698 'features': {'dynamic_refresh': False},
701 self.writer.messages['doc_since_version'] = {'text': '..$6..'}
702 self.writer._AddPolicySection(self.doc_root, policy)
704 self.doc_root.toxml(),
706 '<div style="margin-left: 0px">'
707 '<h3><a name="PolicyName"/>PolicyName</h3>'
708 '<span>PolicyCaption</span>'
710 '<dt style="style_dt;">_test_data_type</dt>'
712 '<dt style="style_dt;">_test_mac_linux_pref_name</dt>'
713 '<dd style="style_.monospace;">PolicyName</dd>'
714 '<dt style="style_dt;">_test_supported_on</dt>'
716 '<ul style="style_ul;">'
717 '<li>Chrome (Mac) ..33..</li>'
720 '<dt style="style_dt;">_test_supported_features</dt>'
721 '<dd>_test_feature_dynamic_refresh: _test_not_supported</dd>'
722 '<dt style="style_dt;">_test_description</dt>'
723 '<dd>PolicyDesc</dd>'
724 '<dt style="style_dt;">_test_example_value</dt>'
727 '<a href="#top">_test_back_to_top</a>'
731 def testAddPolicySectionForLinuxOnly(self):
733 'name': 'PolicyName',
734 'caption': 'PolicyCaption',
735 'desc': 'PolicyDesc',
739 'platforms': ['linux'],
740 'since_version': '33',
743 'features': {'dynamic_refresh': False},
746 self.writer.messages['doc_since_version'] = {'text': '..$6..'}
747 self.writer._AddPolicySection(self.doc_root, policy)
749 self.doc_root.toxml(),
751 '<div style="margin-left: 0px">'
752 '<h3><a name="PolicyName"/>PolicyName</h3>'
753 '<span>PolicyCaption</span>'
755 '<dt style="style_dt;">_test_data_type</dt>'
757 '<dt style="style_dt;">_test_mac_linux_pref_name</dt>'
758 '<dd style="style_.monospace;">PolicyName</dd>'
759 '<dt style="style_dt;">_test_supported_on</dt>'
761 '<ul style="style_ul;">'
762 '<li>Chrome (Linux) ..33..</li>'
765 '<dt style="style_dt;">_test_supported_features</dt>'
766 '<dd>_test_feature_dynamic_refresh: _test_not_supported</dd>'
767 '<dt style="style_dt;">_test_description</dt>'
768 '<dd>PolicyDesc</dd>'
769 '<dt style="style_dt;">_test_example_value</dt>'
770 '<dd>123 (Linux)</dd>'
772 '<a href="#top">_test_back_to_top</a>'
776 def testAddDictionaryExample(self):
778 'name': 'PolicyName',
779 'caption': 'PolicyCaption',
780 'desc': 'PolicyDesc',
784 'platforms': ['win', 'mac', 'linux'],
785 'since_version': '7',
788 'features': {'dynamic_refresh': False},
790 "ProxyMode": "direct",
791 "List": ["1", "2", "3"],
805 self.writer._AddDictionaryExample(self.doc_root, policy)
806 value = json.dumps(policy['example_value']).replace('"', '"')
808 self.doc_root.toxml(),
810 '<dl style="style_dd dl;">'
812 '<dd style="style_.monospace;style_.pre;">MockKey\PolicyName = '
816 '<dd style="style_.monospace;">PolicyName: ' + value + '</dd>'
818 '<dd style="style_.monospace;style_.pre;">'
819 '<key>PolicyName</key>\n'
821 ' <key>DictList</key>\n'
824 ' <key>A</key>\n'
825 ' <integer>1</integer>\n'
826 ' <key>B</key>\n'
827 ' <integer>2</integer>\n'
830 ' <key>C</key>\n'
831 ' <integer>3</integer>\n'
832 ' <key>D</key>\n'
833 ' <integer>4</integer>\n'
836 ' <key>False</key>\n'
838 ' <key>Integer</key>\n'
839 ' <integer>123</integer>\n'
840 ' <key>List</key>\n'
842 ' <string>1</string>\n'
843 ' <string>2</string>\n'
844 ' <string>3</string>\n'
846 ' <key>ProxyMode</key>\n'
847 ' <string>direct</string>\n'
848 ' <key>True</key>\n'
856 if __name__ == '__main__':