Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(110)

Side by Side Diff: components/policy/tools/template_writers/writers/doc_writer_unittest.py

Issue 2481183002: Generate ADMX template for Chrome OS policies (Closed)
Patch Set: Couple of fixes after testing Created 3 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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.doc_writer''' 6 '''Unit tests for writers.doc_writer'''
7 7
8 8
9 import json 9 import json
10 import os 10 import os
(...skipping 21 matching lines...) Expand all
32 32
33 def setUp(self): 33 def setUp(self):
34 # Create a writer for the tests. 34 # Create a writer for the tests.
35 self.writer = doc_writer.GetWriter( 35 self.writer = doc_writer.GetWriter(
36 config={ 36 config={
37 'app_name': 'Chrome', 37 'app_name': 'Chrome',
38 'frame_name': 'Chrome Frame', 38 'frame_name': 'Chrome Frame',
39 'os_name': 'Chrome OS', 39 'os_name': 'Chrome OS',
40 'webview_name': 'WebView', 40 'webview_name': 'WebView',
41 'android_webview_restriction_prefix': 'mock.prefix:', 41 'android_webview_restriction_prefix': 'mock.prefix:',
42 'win_reg_mandatory_key_name': 'MockKey', 42 'win_config' : {
43 'win_reg_recommended_key_name': 'MockKeyRec', 43 'win' : {
44 'reg_mandatory_key_name': 'MockKey',
45 'reg_recommended_key_name': 'MockKeyRec',
46 },
47 'chrome_os' : {
48 'reg_mandatory_key_name': 'MockKeyCrOS',
49 'reg_recommended_key_name': 'MockKeyCrOSRec',
50 },
51 },
44 'build': 'test_product', 52 'build': 'test_product',
45 }) 53 })
46 self.writer.messages = { 54 self.writer.messages = {
47 'doc_back_to_top': {'text': '_test_back_to_top'}, 55 'doc_back_to_top': {'text': '_test_back_to_top'},
48 'doc_complex_policies_on_windows': {'text': '_test_complex_policies_win'}, 56 'doc_complex_policies_on_windows': {'text': '_test_complex_policies_win'},
49 'doc_data_type': {'text': '_test_data_type'}, 57 'doc_data_type': {'text': '_test_data_type'},
50 'doc_description': {'text': '_test_description'}, 58 'doc_description': {'text': '_test_description'},
51 'doc_arc_support': {'text': '_test_arc_support'}, 59 'doc_arc_support': {'text': '_test_arc_support'},
52 'doc_description_column_title': { 60 'doc_description_column_title': {
53 'text': '_test_description_column_title' 61 'text': '_test_description_column_title'
54 }, 62 },
55 'doc_example_value': {'text': '_test_example_value'}, 63 'doc_example_value': {'text': '_test_example_value'},
64 'doc_win_example_value': {'text': '_test_example_value_win'},
65 'doc_chrome_os_example_value': {'text': '_test_example_value_chrome_os'},
56 'doc_feature_dynamic_refresh': {'text': '_test_feature_dynamic_refresh'}, 66 'doc_feature_dynamic_refresh': {'text': '_test_feature_dynamic_refresh'},
57 'doc_feature_can_be_recommended': {'text': '_test_feature_recommended'}, 67 'doc_feature_can_be_recommended': {'text': '_test_feature_recommended'},
58 'doc_feature_can_be_mandatory': {'text': '_test_feature_mandatory'}, 68 'doc_feature_can_be_mandatory': {'text': '_test_feature_mandatory'},
59 'doc_intro': {'text': '_test_intro'}, 69 'doc_intro': {'text': '_test_intro'},
60 'doc_mac_linux_pref_name': {'text': '_test_mac_linux_pref_name'}, 70 'doc_mac_linux_pref_name': {'text': '_test_mac_linux_pref_name'},
61 'doc_android_restriction_name': { 71 'doc_android_restriction_name': {
62 'text': '_test_android_restriction_name' 72 'text': '_test_android_restriction_name'
63 }, 73 },
64 'doc_android_webview_restriction_name': { 74 'doc_android_webview_restriction_name': {
65 'text': '_test_android_webview_restriction_name' 75 'text': '_test_android_webview_restriction_name'
66 }, 76 },
67 'doc_note': {'text': '_test_note'}, 77 'doc_note': {'text': '_test_note'},
68 'doc_name_column_title': {'text': '_test_name_column_title'}, 78 'doc_name_column_title': {'text': '_test_name_column_title'},
69 'doc_not_supported': {'text': '_test_not_supported'}, 79 'doc_not_supported': {'text': '_test_not_supported'},
70 'doc_since_version': {'text': '_test_since_version'}, 80 'doc_since_version': {'text': '_test_since_version'},
71 'doc_supported': {'text': '_test_supported'}, 81 'doc_supported': {'text': '_test_supported'},
72 'doc_supported_features': {'text': '_test_supported_features'}, 82 'doc_supported_features': {'text': '_test_supported_features'},
73 'doc_supported_on': {'text': '_test_supported_on'}, 83 'doc_supported_on': {'text': '_test_supported_on'},
74 'doc_win_reg_loc': {'text': '_test_win_reg_loc'}, 84 'doc_win_reg_loc': {'text': '_test_win_reg_loc'},
85 'doc_chrome_os_reg_loc': {'text': '_test_chrome_os_reg_loc'},
75 86
76 'doc_bla': {'text': '_test_bla'}, 87 'doc_bla': {'text': '_test_bla'},
77 } 88 }
78 self.writer.Init() 89 self.writer.Init()
79 90
80 # It is not worth testing the exact content of style attributes. 91 # It is not worth testing the exact content of style attributes.
81 # Therefore we override them here with shorter texts. 92 # Therefore we override them here with shorter texts.
82 for key in self.writer._STYLE.keys(): 93 for key in self.writer._STYLE.keys():
83 self.writer._STYLE[key] = 'style_%s;' % key 94 self.writer._STYLE[key] = 'style_%s;' % key
84 # Add some more style attributes for additional testing. 95 # Add some more style attributes for additional testing.
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
248 '<root>' 259 '<root>'
249 'Can Be Recommended: _test_supported, ' 260 'Can Be Recommended: _test_supported, '
250 'Dynamic Refresh: _test_supported, ' 261 'Dynamic Refresh: _test_supported, '
251 'Spaceship Docking: _test_not_supported' 262 'Spaceship Docking: _test_not_supported'
252 '</root>') 263 '</root>')
253 264
254 def testAddListExample(self): 265 def testAddListExample(self):
255 policy = { 266 policy = {
256 'name': 'PolicyName', 267 'name': 'PolicyName',
257 'example_value': ['Foo', 'Bar'], 268 'example_value': ['Foo', 'Bar'],
258 'supported_on': [ { 'platforms': ['win', 'mac', 'linux'] } ] 269 'supported_on': [ { 'platforms': ['win', 'mac', 'linux', 'chrome_os'] } ]
259 } 270 }
260 self.writer._AddListExample(self.doc_root, policy) 271 self.writer._AddListExample(self.doc_root, policy)
261 self.assertEquals( 272 self.assertEquals(
262 self.doc_root.toxml(), 273 self.doc_root.toxml(),
263 '<root>' 274 '<root>'
264 '<dl style="style_dd dl;">' 275 '<dl style="style_dd dl;">'
265 '<dt>Windows:</dt>' 276 '<dt>_test_example_value_win</dt>'
266 '<dd style="style_.monospace;style_.pre;">' 277 '<dd style="style_.monospace;style_.pre;">'
267 'MockKey\\PolicyName\\1 = &quot;Foo&quot;\n' 278 'MockKey\\PolicyName\\1 = &quot;Foo&quot;\n'
268 'MockKey\\PolicyName\\2 = &quot;Bar&quot;' 279 'MockKey\\PolicyName\\2 = &quot;Bar&quot;'
269 '</dd>' 280 '</dd>'
281 '<dt>_test_example_value_chrome_os</dt>'
282 '<dd style="style_.monospace;style_.pre;">'
283 'MockKeyCrOS\\PolicyName\\1 = &quot;Foo&quot;\n'
284 'MockKeyCrOS\\PolicyName\\2 = &quot;Bar&quot;'
285 '</dd>'
270 '<dt>Android/Linux:</dt>' 286 '<dt>Android/Linux:</dt>'
271 '<dd style="style_.monospace;">' 287 '<dd style="style_.monospace;">'
272 '[&quot;Foo&quot;, &quot;Bar&quot;]' 288 '[&quot;Foo&quot;, &quot;Bar&quot;]'
273 '</dd>' 289 '</dd>'
274 '<dt>Mac:</dt>' 290 '<dt>Mac:</dt>'
275 '<dd style="style_.monospace;style_.pre;">' 291 '<dd style="style_.monospace;style_.pre;">'
276 '&lt;array&gt;\n' 292 '&lt;array&gt;\n'
277 ' &lt;string&gt;Foo&lt;/string&gt;\n' 293 ' &lt;string&gt;Foo&lt;/string&gt;\n'
278 ' &lt;string&gt;Bar&lt;/string&gt;\n' 294 ' &lt;string&gt;Bar&lt;/string&gt;\n'
279 '&lt;/array&gt;' 295 '&lt;/array&gt;'
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
421 }, { 437 }, {
422 'product': 'chrome', 438 'product': 'chrome',
423 'platforms': ['android'], 439 'platforms': ['android'],
424 'since_version': '30', 440 'since_version': '30',
425 'until_version': '', 441 'until_version': '',
426 }, { 442 }, {
427 'product': 'webview', 443 'product': 'webview',
428 'platforms': ['android'], 444 'platforms': ['android'],
429 'since_version': '47', 445 'since_version': '47',
430 'until_version': '', 446 'until_version': '',
447 }, {
448 'product': 'chrome',
449 'platforms': ['chrome_os'],
450 'since_version': '55',
451 'until_version': '',
431 }], 452 }],
432 'features': {'dynamic_refresh': False}, 453 'features': {'dynamic_refresh': False},
433 'example_value': False, 454 'example_value': False,
434 'arc_support': 'TestArcSupportNote' 455 'arc_support': 'TestArcSupportNote'
435 } 456 }
436 self.writer.messages['doc_since_version'] = {'text': '...$6...'} 457 self.writer.messages['doc_since_version'] = {'text': '...$6...'}
437 self.writer._AddPolicyDetails(self.doc_root, policy) 458 self.writer._AddPolicyDetails(self.doc_root, policy)
438 self.assertEquals( 459 self.assertEquals(
439 self.doc_root.toxml(), 460 self.doc_root.toxml(),
440 '<root><dl>' 461 '<root><dl>'
441 '<dt style="style_dt;">_test_data_type</dt>' 462 '<dt style="style_dt;">_test_data_type</dt>'
442 '<dd>Boolean [Windows:REG_DWORD]</dd>' 463 '<dd>Boolean [Windows:REG_DWORD]</dd>'
443 '<dt style="style_dt;">_test_win_reg_loc</dt>' 464 '<dt style="style_dt;">_test_win_reg_loc</dt>'
444 '<dd style="style_.monospace;">MockKey\TestPolicyName</dd>' 465 '<dd style="style_.monospace;">MockKey\TestPolicyName</dd>'
466 '<dt style="style_dt;">_test_chrome_os_reg_loc</dt>'
467 '<dd style="style_.monospace;">MockKeyCrOS\TestPolicyName</dd>'
445 '<dt style="style_dt;">_test_mac_linux_pref_name</dt>' 468 '<dt style="style_dt;">_test_mac_linux_pref_name</dt>'
446 '<dd style="style_.monospace;">TestPolicyName</dd>' 469 '<dd style="style_.monospace;">TestPolicyName</dd>'
447 '<dt style="style_dt;">_test_android_restriction_name</dt>' 470 '<dt style="style_dt;">_test_android_restriction_name</dt>'
448 '<dd style="style_.monospace;">TestPolicyName</dd>' 471 '<dd style="style_.monospace;">TestPolicyName</dd>'
449 '<dt style="style_dt;">_test_android_webview_restriction_name</dt>' 472 '<dt style="style_dt;">_test_android_webview_restriction_name</dt>'
450 '<dd style="style_.monospace;">mock.prefix:TestPolicyName</dd>' 473 '<dd style="style_.monospace;">mock.prefix:TestPolicyName</dd>'
451 '<dt style="style_dt;">_test_supported_on</dt>' 474 '<dt style="style_dt;">_test_supported_on</dt>'
452 '<dd>' 475 '<dd>'
453 '<ul style="style_ul;">' 476 '<ul style="style_ul;">'
454 '<li>Chrome (Windows, Mac, Linux) ...8...</li>' 477 '<li>Chrome (Windows, Mac, Linux) ...8...</li>'
455 '<li>Chrome (Android) ...30...</li>' 478 '<li>Chrome (Android) ...30...</li>'
456 '<li>WebView (Android) ...47...</li>' 479 '<li>WebView (Android) ...47...</li>'
480 '<li>Chrome (Chrome OS) ...55...</li>'
457 '</ul>' 481 '</ul>'
458 '</dd>' 482 '</dd>'
459 '<dt style="style_dt;">_test_supported_features</dt>' 483 '<dt style="style_dt;">_test_supported_features</dt>'
460 '<dd>_test_feature_dynamic_refresh: _test_not_supported</dd>' 484 '<dd>_test_feature_dynamic_refresh: _test_not_supported</dd>'
461 '<dt style="style_dt;">_test_description</dt><dd><p>TestPolicyDesc</p></dd >' 485 '<dt style="style_dt;">_test_description</dt><dd><p>TestPolicyDesc</p></dd >'
462 '<dt style="style_dt;">_test_arc_support</dt>' 486 '<dt style="style_dt;">_test_arc_support</dt>'
463 '<dd><p>TestArcSupportNote</p></dd>' 487 '<dd><p>TestArcSupportNote</p></dd>'
464 '<dt style="style_dt;">_test_example_value</dt>' 488 '<dt style="style_dt;">_test_example_value</dt>'
465 '<dd>0x00000000 (Windows), false (Linux),' 489 '<dd>0x00000000 (Windows), false (Linux),'
466 ' false (Android), &lt;false /&gt; (Mac)</dd>' 490 ' false (Android), &lt;false /&gt; (Mac)</dd>'
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
509 def testAddDictPolicyDetails(self): 533 def testAddDictPolicyDetails(self):
510 # Test if the definition list (<dl>) of policy details is created correctly 534 # Test if the definition list (<dl>) of policy details is created correctly
511 # for 'dict' policies. 535 # for 'dict' policies.
512 policy = { 536 policy = {
513 'type': 'dict', 537 'type': 'dict',
514 'name': 'TestPolicyName', 538 'name': 'TestPolicyName',
515 'caption': 'TestPolicyCaption', 539 'caption': 'TestPolicyCaption',
516 'desc': 'TestPolicyDesc', 540 'desc': 'TestPolicyDesc',
517 'supported_on': [{ 541 'supported_on': [{
518 'product': 'chrome', 542 'product': 'chrome',
519 'platforms': ['win', 'mac', 'linux'], 543 'platforms': ['win', 'mac', 'linux', 'chrome_os'],
520 'since_version': '8', 544 'since_version': '8',
521 'until_version': '', 545 'until_version': '',
522 }], 546 }],
523 'features': {'dynamic_refresh': False}, 547 'features': {'dynamic_refresh': False},
524 'example_value': { 'foo': 123 } 548 'example_value': { 'foo': 123 }
525 } 549 }
526 self.writer.messages['doc_since_version'] = {'text': '...$6...'} 550 self.writer.messages['doc_since_version'] = {'text': '...$6...'}
527 self.writer._AddPolicyDetails(self.doc_root, policy) 551 self.writer._AddPolicyDetails(self.doc_root, policy)
528 self.assertEquals( 552 self.assertEquals(
529 self.doc_root.toxml(), 553 self.doc_root.toxml(),
530 '<root><dl>' 554 '<root><dl>'
531 '<dt style="style_dt;">_test_data_type</dt>' 555 '<dt style="style_dt;">_test_data_type</dt>'
532 '<dd>Dictionary [Windows:REG_SZ] (_test_complex_policies_win)</dd>' 556 '<dd>Dictionary [Windows:REG_SZ] (_test_complex_policies_win)</dd>'
533 '<dt style="style_dt;">_test_win_reg_loc</dt>' 557 '<dt style="style_dt;">_test_win_reg_loc</dt>'
534 '<dd style="style_.monospace;">MockKey\TestPolicyName</dd>' 558 '<dd style="style_.monospace;">MockKey\TestPolicyName</dd>'
559 '<dt style="style_dt;">_test_chrome_os_reg_loc</dt>'
560 '<dd style="style_.monospace;">MockKeyCrOS\TestPolicyName</dd>'
535 '<dt style="style_dt;">_test_mac_linux_pref_name</dt>' 561 '<dt style="style_dt;">_test_mac_linux_pref_name</dt>'
536 '<dd style="style_.monospace;">TestPolicyName</dd>' 562 '<dd style="style_.monospace;">TestPolicyName</dd>'
537 '<dt style="style_dt;">_test_supported_on</dt>' 563 '<dt style="style_dt;">_test_supported_on</dt>'
538 '<dd>' 564 '<dd>'
539 '<ul style="style_ul;">' 565 '<ul style="style_ul;">'
540 '<li>Chrome (Windows, Mac, Linux) ...8...</li>' 566 '<li>Chrome (Windows, Mac, Linux, Chrome OS) ...8...</li>'
541 '</ul>' 567 '</ul>'
542 '</dd>' 568 '</dd>'
543 '<dt style="style_dt;">_test_supported_features</dt>' 569 '<dt style="style_dt;">_test_supported_features</dt>'
544 '<dd>_test_feature_dynamic_refresh: _test_not_supported</dd>' 570 '<dd>_test_feature_dynamic_refresh: _test_not_supported</dd>'
545 '<dt style="style_dt;">_test_description</dt><dd><p>TestPolicyDesc</p></dd >' 571 '<dt style="style_dt;">_test_description</dt><dd><p>TestPolicyDesc</p></dd >'
546 '<dt style="style_dt;">_test_example_value</dt>' 572 '<dt style="style_dt;">_test_example_value</dt>'
547 '<dd>' 573 '<dd>'
548 '<dl style="style_dd dl;">' 574 '<dl style="style_dd dl;">'
549 '<dt>Windows:</dt>' 575 '<dt>_test_example_value_win</dt>'
550 '<dd style="style_.monospace;style_.pre;">MockKey\TestPolicyName = { &quot;foo&quot;: 123}</dd>' 576 '<dd style="style_.monospace;style_.pre;">'
577 'MockKey\TestPolicyName = {&quot;foo&quot;: 123}</dd>'
578 '<dt>_test_example_value_chrome_os</dt>'
579 '<dd style="style_.monospace;style_.pre;">'
580 'MockKeyCrOS\TestPolicyName = {&quot;foo&quot;: 123}</dd>'
551 '<dt>Android/Linux:</dt>' 581 '<dt>Android/Linux:</dt>'
552 '<dd style="style_.monospace;">TestPolicyName: {&quot;foo&quot;: 123 }</dd>' 582 '<dd style="style_.monospace;">'
583 'TestPolicyName: {&quot;foo&quot;: 123}</dd>'
553 '<dt>Mac:</dt>' 584 '<dt>Mac:</dt>'
554 '<dd style="style_.monospace;style_.pre;">' 585 '<dd style="style_.monospace;style_.pre;">'
555 '&lt;key&gt;TestPolicyName&lt;/key&gt;\n' 586 '&lt;key&gt;TestPolicyName&lt;/key&gt;\n'
556 '&lt;dict&gt;\n' 587 '&lt;dict&gt;\n'
557 ' &lt;key&gt;foo&lt;/key&gt;\n' 588 ' &lt;key&gt;foo&lt;/key&gt;\n'
558 ' &lt;integer&gt;123&lt;/integer&gt;\n' 589 ' &lt;integer&gt;123&lt;/integer&gt;\n'
559 '&lt;/dict&gt;' 590 '&lt;/dict&gt;'
560 '</dd>' 591 '</dd>'
561 '</dl>' 592 '</dl>'
562 '</dd>' 593 '</dd>'
563 '</dl></root>') 594 '</dl></root>')
564 595
565 def testAddPolicyDetailsRecommendedOnly(self): 596 def testAddPolicyDetailsRecommendedOnly(self):
566 policy = { 597 policy = {
567 'type': 'main', 598 'type': 'main',
568 'name': 'TestPolicyName', 599 'name': 'TestPolicyName',
569 'caption': 'TestPolicyCaption', 600 'caption': 'TestPolicyCaption',
570 'desc': 'TestPolicyDesc', 601 'desc': 'TestPolicyDesc',
571 'supported_on': [{ 602 'supported_on': [{
572 'product': 'chrome', 603 'product': 'chrome',
573 'platforms': ['win', 'mac', 'linux'], 604 'platforms': ['win', 'mac', 'linux'],
574 'since_version': '8', 605 'since_version': '8',
575 'until_version': '', 606 'until_version': '',
576 }, { 607 }, {
577 'product': 'chrome', 608 'product': 'chrome',
578 'platforms': ['android'], 609 'platforms': ['android'],
579 'since_version': '30', 610 'since_version': '30',
580 'until_version': '', 611 'until_version': '',
612 }, {
613 'product': 'chrome',
614 'platforms': ['chrome_os'],
615 'since_version': '53',
616 'until_version': '',
581 }], 617 }],
582 'features': { 618 'features': {
583 'dynamic_refresh': False, 619 'dynamic_refresh': False,
584 'can_be_mandatory': False, 620 'can_be_mandatory': False,
585 'can_be_recommended': True 621 'can_be_recommended': True
586 }, 622 },
587 'example_value': False 623 'example_value': False
588 } 624 }
589 self.writer.messages['doc_since_version'] = {'text': '...$6...'} 625 self.writer.messages['doc_since_version'] = {'text': '...$6...'}
590 self.writer._AddPolicyDetails(self.doc_root, policy) 626 self.writer._AddPolicyDetails(self.doc_root, policy)
591 self.assertEquals( 627 self.assertEquals(
592 self.doc_root.toxml(), 628 self.doc_root.toxml(),
593 '<root><dl>' 629 '<root><dl>'
594 '<dt style="style_dt;">_test_data_type</dt>' 630 '<dt style="style_dt;">_test_data_type</dt>'
595 '<dd>Boolean [Windows:REG_DWORD]</dd>' 631 '<dd>Boolean [Windows:REG_DWORD]</dd>'
596 '<dt style="style_dt;">_test_win_reg_loc</dt>' 632 '<dt style="style_dt;">_test_win_reg_loc</dt>'
597 '<dd style="style_.monospace;">MockKeyRec\TestPolicyName</dd>' 633 '<dd style="style_.monospace;">MockKeyRec\TestPolicyName</dd>'
634 '<dt style="style_dt;">_test_chrome_os_reg_loc</dt>'
635 '<dd style="style_.monospace;">MockKeyCrOSRec\TestPolicyName</dd>'
598 '<dt style="style_dt;">_test_mac_linux_pref_name</dt>' 636 '<dt style="style_dt;">_test_mac_linux_pref_name</dt>'
599 '<dd style="style_.monospace;">TestPolicyName</dd>' 637 '<dd style="style_.monospace;">TestPolicyName</dd>'
600 '<dt style="style_dt;">_test_android_restriction_name</dt>' 638 '<dt style="style_dt;">_test_android_restriction_name</dt>'
601 '<dd style="style_.monospace;">TestPolicyName</dd>' 639 '<dd style="style_.monospace;">TestPolicyName</dd>'
602 '<dt style="style_dt;">_test_supported_on</dt>' 640 '<dt style="style_dt;">_test_supported_on</dt>'
603 '<dd>' 641 '<dd>'
604 '<ul style="style_ul;">' 642 '<ul style="style_ul;">'
605 '<li>Chrome (Windows, Mac, Linux) ...8...</li>' 643 '<li>Chrome (Windows, Mac, Linux) ...8...</li>'
606 '<li>Chrome (Android) ...30...</li>' 644 '<li>Chrome (Android) ...30...</li>'
645 '<li>Chrome (Chrome OS) ...53...</li>'
607 '</ul>' 646 '</ul>'
608 '</dd>' 647 '</dd>'
609 '<dt style="style_dt;">_test_supported_features</dt>' 648 '<dt style="style_dt;">_test_supported_features</dt>'
610 '<dd>_test_feature_mandatory: _test_not_supported,' 649 '<dd>_test_feature_mandatory: _test_not_supported,'
611 ' _test_feature_recommended: _test_supported,' 650 ' _test_feature_recommended: _test_supported,'
612 ' _test_feature_dynamic_refresh: _test_not_supported</dd>' 651 ' _test_feature_dynamic_refresh: _test_not_supported</dd>'
613 '<dt style="style_dt;">_test_description</dt><dd><p>TestPolicyDesc</p></dd >' 652 '<dt style="style_dt;">_test_description</dt><dd><p>TestPolicyDesc</p></dd >'
614 '<dt style="style_dt;">_test_example_value</dt>' 653 '<dt style="style_dt;">_test_example_value</dt>'
615 '<dd>0x00000000 (Windows), false (Linux),' 654 '<dd>0x00000000 (Windows), false (Linux),'
616 ' false (Android), &lt;false /&gt; (Mac)</dd>' 655 ' false (Android), &lt;false /&gt; (Mac)</dd>'
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
666 705
667 def testAddPolicySection(self): 706 def testAddPolicySection(self):
668 # Test if policy details are correctly added to the document. 707 # Test if policy details are correctly added to the document.
669 policy = { 708 policy = {
670 'name': 'PolicyName', 709 'name': 'PolicyName',
671 'caption': 'PolicyCaption', 710 'caption': 'PolicyCaption',
672 'desc': 'PolicyDesc', 711 'desc': 'PolicyDesc',
673 'type': 'string', 712 'type': 'string',
674 'supported_on': [{ 713 'supported_on': [{
675 'product': 'chrome', 714 'product': 'chrome',
676 'platforms': ['win', 'mac'], 715 'platforms': ['win', 'mac', 'chrome_os'],
677 'since_version': '7', 716 'since_version': '7',
678 'until_version': '', 717 'until_version': '',
679 }], 718 }],
680 'features': {'dynamic_refresh': False}, 719 'features': {'dynamic_refresh': False},
681 'example_value': 'False' 720 'example_value': 'False'
682 } 721 }
683 self.writer.messages['doc_since_version'] = {'text': '..$6..'} 722 self.writer.messages['doc_since_version'] = {'text': '..$6..'}
684 self.writer._AddPolicySection(self.doc_root, policy) 723 self.writer._AddPolicySection(self.doc_root, policy)
685 self.assertEquals( 724 self.assertEquals(
686 self.doc_root.toxml(), 725 self.doc_root.toxml(),
687 '<root>' 726 '<root>'
688 '<div style="margin-left: 0px">' 727 '<div style="margin-left: 0px">'
689 '<h3><a name="PolicyName"/>PolicyName</h3>' 728 '<h3><a name="PolicyName"/>PolicyName</h3>'
690 '<span>PolicyCaption</span>' 729 '<span>PolicyCaption</span>'
691 '<dl>' 730 '<dl>'
692 '<dt style="style_dt;">_test_data_type</dt>' 731 '<dt style="style_dt;">_test_data_type</dt>'
693 '<dd>String [Windows:REG_SZ]</dd>' 732 '<dd>String [Windows:REG_SZ]</dd>'
694 '<dt style="style_dt;">_test_win_reg_loc</dt>' 733 '<dt style="style_dt;">_test_win_reg_loc</dt>'
695 '<dd style="style_.monospace;">MockKey\\PolicyName</dd>' 734 '<dd style="style_.monospace;">MockKey\\PolicyName</dd>'
735 '<dt style="style_dt;">_test_chrome_os_reg_loc</dt>'
736 '<dd style="style_.monospace;">MockKeyCrOS\\PolicyName</dd>'
696 '<dt style="style_dt;">_test_mac_linux_pref_name</dt>' 737 '<dt style="style_dt;">_test_mac_linux_pref_name</dt>'
697 '<dd style="style_.monospace;">PolicyName</dd>' 738 '<dd style="style_.monospace;">PolicyName</dd>'
698 '<dt style="style_dt;">_test_supported_on</dt>' 739 '<dt style="style_dt;">_test_supported_on</dt>'
699 '<dd>' 740 '<dd>'
700 '<ul style="style_ul;">' 741 '<ul style="style_ul;">'
701 '<li>Chrome (Windows, Mac) ..7..</li>' 742 '<li>Chrome (Windows, Mac, Chrome OS) ..7..</li>'
702 '</ul>' 743 '</ul>'
703 '</dd>' 744 '</dd>'
704 '<dt style="style_dt;">_test_supported_features</dt>' 745 '<dt style="style_dt;">_test_supported_features</dt>'
705 '<dd>_test_feature_dynamic_refresh: _test_not_supported</dd>' 746 '<dd>_test_feature_dynamic_refresh: _test_not_supported</dd>'
706 '<dt style="style_dt;">_test_description</dt>' 747 '<dt style="style_dt;">_test_description</dt>'
707 '<dd><p>PolicyDesc</p></dd>' 748 '<dd><p>PolicyDesc</p></dd>'
708 '<dt style="style_dt;">_test_example_value</dt>' 749 '<dt style="style_dt;">_test_example_value</dt>'
709 '<dd>&quot;False&quot;</dd>' 750 '<dd>&quot;False&quot;</dd>'
710 '</dl>' 751 '</dl>'
711 '<a href="#top">_test_back_to_top</a>' 752 '<a href="#top">_test_back_to_top</a>'
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after
934 }, 975 },
935 ], 976 ],
936 }, 977 },
937 } 978 }
938 self.writer._AddDictionaryExample(self.doc_root, policy) 979 self.writer._AddDictionaryExample(self.doc_root, policy)
939 value = json.dumps(policy['example_value']).replace('"', '&quot;') 980 value = json.dumps(policy['example_value']).replace('"', '&quot;')
940 self.assertEquals( 981 self.assertEquals(
941 self.doc_root.toxml(), 982 self.doc_root.toxml(),
942 '<root>' 983 '<root>'
943 '<dl style="style_dd dl;">' 984 '<dl style="style_dd dl;">'
944 '<dt>Windows:</dt>' 985 '<dt>_test_example_value_win</dt>'
945 '<dd style="style_.monospace;style_.pre;">MockKey\PolicyName = ' 986 '<dd style="style_.monospace;style_.pre;">MockKey\PolicyName = '
946 + value + 987 + value +
947 '</dd>' 988 '</dd>'
948 '<dt>Android/Linux:</dt>' 989 '<dt>Android/Linux:</dt>'
949 '<dd style="style_.monospace;">PolicyName: ' + value + '</dd>' 990 '<dd style="style_.monospace;">PolicyName: ' + value + '</dd>'
950 '<dt>Mac:</dt>' 991 '<dt>Mac:</dt>'
951 '<dd style="style_.monospace;style_.pre;">' 992 '<dd style="style_.monospace;style_.pre;">'
952 '&lt;key&gt;PolicyName&lt;/key&gt;\n' 993 '&lt;key&gt;PolicyName&lt;/key&gt;\n'
953 '&lt;dict&gt;\n' 994 '&lt;dict&gt;\n'
954 ' &lt;key&gt;DictList&lt;/key&gt;\n' 995 ' &lt;key&gt;DictList&lt;/key&gt;\n'
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
987 1028
988 def testParagraphs(self): 1029 def testParagraphs(self):
989 text = 'Paragraph 1\n\nParagraph 2\n\nParagraph 3' 1030 text = 'Paragraph 1\n\nParagraph 2\n\nParagraph 3'
990 self.writer._AddParagraphs(self.doc_root, text) 1031 self.writer._AddParagraphs(self.doc_root, text)
991 self.assertEquals( 1032 self.assertEquals(
992 self.doc_root.toxml(), 1033 self.doc_root.toxml(),
993 '<root><p>Paragraph 1</p><p>Paragraph 2</p><p>Paragraph 3</p></root>') 1034 '<root><p>Paragraph 1</p><p>Paragraph 2</p><p>Paragraph 3</p></root>')
994 1035
995 if __name__ == '__main__': 1036 if __name__ == '__main__':
996 unittest.main() 1037 unittest.main()
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698