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

Side by Side Diff: grit/format/policy_templates/writers/doc_writer_unittest.py

Issue 544113002: Add optional mandatory policy setting for template generation (Closed) Base URL: https://chromium.googlesource.com/external/grit-i18n.git@master
Patch Set: rebase Created 6 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 grit.format.policy_templates.writers.doc_writer''' 6 '''Unit tests for grit.format.policy_templates.writers.doc_writer'''
7 7
8 8
9 import json 9 import json
10 import os 10 import os
(...skipping 20 matching lines...) Expand all
31 '''Unit tests for DocWriter.''' 31 '''Unit tests for DocWriter.'''
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 'win_reg_mandatory_key_name': 'MockKey', 40 'win_reg_mandatory_key_name': 'MockKey',
41 'win_reg_recommended_key_name': 'MockKeyRec',
41 }) 42 })
42 self.writer.messages = { 43 self.writer.messages = {
43 'doc_back_to_top': {'text': '_test_back_to_top'}, 44 'doc_back_to_top': {'text': '_test_back_to_top'},
44 'doc_complex_policies_on_windows': {'text': '_test_complex_policies_win'}, 45 'doc_complex_policies_on_windows': {'text': '_test_complex_policies_win'},
45 'doc_data_type': {'text': '_test_data_type'}, 46 'doc_data_type': {'text': '_test_data_type'},
46 'doc_description': {'text': '_test_description'}, 47 'doc_description': {'text': '_test_description'},
47 'doc_description_column_title': { 48 'doc_description_column_title': {
48 'text': '_test_description_column_title' 49 'text': '_test_description_column_title'
49 }, 50 },
50 'doc_example_value': {'text': '_test_example_value'}, 51 'doc_example_value': {'text': '_test_example_value'},
51 'doc_feature_dynamic_refresh': {'text': '_test_feature_dynamic_refresh'}, 52 'doc_feature_dynamic_refresh': {'text': '_test_feature_dynamic_refresh'},
52 'doc_feature_can_be_recommended': {'text': '_test_feature_recommended'}, 53 'doc_feature_can_be_recommended': {'text': '_test_feature_recommended'},
54 'doc_feature_can_be_mandatory': {'text': '_test_feature_mandatory'},
53 'doc_intro': {'text': '_test_intro'}, 55 'doc_intro': {'text': '_test_intro'},
54 'doc_mac_linux_pref_name': {'text': '_test_mac_linux_pref_name'}, 56 'doc_mac_linux_pref_name': {'text': '_test_mac_linux_pref_name'},
55 'doc_note': {'text': '_test_note'}, 57 'doc_note': {'text': '_test_note'},
56 'doc_name_column_title': {'text': '_test_name_column_title'}, 58 'doc_name_column_title': {'text': '_test_name_column_title'},
57 'doc_not_supported': {'text': '_test_not_supported'}, 59 'doc_not_supported': {'text': '_test_not_supported'},
58 'doc_since_version': {'text': '_test_since_version'}, 60 'doc_since_version': {'text': '_test_since_version'},
59 'doc_supported': {'text': '_test_supported'}, 61 'doc_supported': {'text': '_test_supported'},
60 'doc_supported_features': {'text': '_test_supported_features'}, 62 'doc_supported_features': {'text': '_test_supported_features'},
61 'doc_supported_on': {'text': '_test_supported_on'}, 63 'doc_supported_on': {'text': '_test_supported_on'},
62 'doc_win_reg_loc': {'text': '_test_win_reg_loc'}, 64 'doc_win_reg_loc': {'text': '_test_win_reg_loc'},
(...skipping 401 matching lines...) Expand 10 before | Expand all | Expand 10 after
464 '<key>TestPolicyName</key>\n' 466 '<key>TestPolicyName</key>\n'
465 '<dict>\n' 467 '<dict>\n'
466 ' <key>foo</key>\n' 468 ' <key>foo</key>\n'
467 ' <integer>123</integer>\n' 469 ' <integer>123</integer>\n'
468 '</dict>' 470 '</dict>'
469 '</dd>' 471 '</dd>'
470 '</dl>' 472 '</dl>'
471 '</dd>' 473 '</dd>'
472 '</dl></root>') 474 '</dl></root>')
473 475
476 def testAddPolicyDetailsRecommendedOnly(self):
477 policy = {
478 'type': 'main',
479 'name': 'TestPolicyName',
480 'caption': 'TestPolicyCaption',
481 'desc': 'TestPolicyDesc',
482 'supported_on': [{
483 'product': 'chrome',
484 'platforms': ['win', 'mac', 'linux'],
485 'since_version': '8',
486 'until_version': '',
487 }, {
488 'product': 'chrome',
489 'platforms': ['android'],
490 'since_version': '30',
491 'until_version': '',
492 }, {
493 'product': 'chrome',
494 'platforms': ['ios'],
495 'since_version': '34',
496 'until_version': '',
497 }],
498 'features': {
499 'dynamic_refresh': False,
500 'can_be_mandatory': False,
501 'can_be_recommended': True
502 },
503 'example_value': False
504 }
505 self.writer.messages['doc_since_version'] = {'text': '...$6...'}
506 self.writer._AddPolicyDetails(self.doc_root, policy)
507 self.assertEquals(
508 self.doc_root.toxml(),
509 '<root><dl>'
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>'
516 '<dd>'
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>'
521 '</ul>'
522 '</dd>'
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), &lt;false /&gt; (Mac)</dd>'
530 '</dl></root>')
531
474 def testAddPolicyNote(self): 532 def testAddPolicyNote(self):
475 # TODO(jkummerow): The functionality tested by this test is currently not 533 # TODO(jkummerow): The functionality tested by this test is currently not
476 # used for anything and will probably soon be removed. 534 # used for anything and will probably soon be removed.
477 # Test if nodes are correctly added to policies. 535 # Test if nodes are correctly added to policies.
478 policy = { 536 policy = {
479 'problem_href': 'http://www.example.com/5' 537 'problem_href': 'http://www.example.com/5'
480 } 538 }
481 self.writer.messages['doc_note'] = {'text': '...$6...'} 539 self.writer.messages['doc_note'] = {'text': '...$6...'}
482 self.writer._AddPolicyNote(self.doc_root, policy) 540 self.writer._AddPolicyNote(self.doc_root, policy)
483 self.assertEquals( 541 self.assertEquals(
(...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after
790 ' &lt;key&gt;True&lt;/key&gt;\n' 848 ' &lt;key&gt;True&lt;/key&gt;\n'
791 ' &lt;true/&gt;\n' 849 ' &lt;true/&gt;\n'
792 '&lt;/dict&gt;' 850 '&lt;/dict&gt;'
793 '</dd>' 851 '</dd>'
794 '</dl>' 852 '</dl>'
795 '</root>') 853 '</root>')
796 854
797 855
798 if __name__ == '__main__': 856 if __name__ == '__main__':
799 unittest.main() 857 unittest.main()
OLDNEW
« no previous file with comments | « grit/format/policy_templates/writers/doc_writer.py ('k') | grit/format/policy_templates/writers/json_writer.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698