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

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: Adds support for new template writers 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 os 9 import os
10 import sys 10 import sys
(...skipping 19 matching lines...) Expand all
30 '''Unit tests for DocWriter.''' 30 '''Unit tests for DocWriter.'''
31 31
32 def setUp(self): 32 def setUp(self):
33 # Create a writer for the tests. 33 # Create a writer for the tests.
34 self.writer = doc_writer.GetWriter( 34 self.writer = doc_writer.GetWriter(
35 config={ 35 config={
36 'app_name': 'Chrome', 36 'app_name': 'Chrome',
37 'frame_name': 'Chrome Frame', 37 'frame_name': 'Chrome Frame',
38 'os_name': 'Chrome OS', 38 'os_name': 'Chrome OS',
39 'win_reg_mandatory_key_name': 'MockKey', 39 'win_reg_mandatory_key_name': 'MockKey',
40 'win_reg_recommended_key_name': 'MockKeyRec',
40 }) 41 })
41 self.writer.messages = { 42 self.writer.messages = {
42 'doc_back_to_top': {'text': '_test_back_to_top'}, 43 'doc_back_to_top': {'text': '_test_back_to_top'},
43 'doc_data_type': {'text': '_test_data_type'}, 44 'doc_data_type': {'text': '_test_data_type'},
44 'doc_description': {'text': '_test_description'}, 45 'doc_description': {'text': '_test_description'},
45 'doc_description_column_title': { 46 'doc_description_column_title': {
46 'text': '_test_description_column_title' 47 'text': '_test_description_column_title'
47 }, 48 },
48 'doc_example_value': {'text': '_test_example_value'}, 49 'doc_example_value': {'text': '_test_example_value'},
49 'doc_feature_dynamic_refresh': {'text': '_test_feature_dynamic_refresh'}, 50 'doc_feature_dynamic_refresh': {'text': '_test_feature_dynamic_refresh'},
50 'doc_feature_can_be_recommended': {'text': '_test_feature_recommended'}, 51 'doc_feature_can_be_recommended': {'text': '_test_feature_recommended'},
52 'doc_feature_can_be_mandatory': {'text': '_test_feature_mandatory'},
51 'doc_intro': {'text': '_test_intro'}, 53 'doc_intro': {'text': '_test_intro'},
52 'doc_mac_linux_pref_name': {'text': '_test_mac_linux_pref_name'}, 54 'doc_mac_linux_pref_name': {'text': '_test_mac_linux_pref_name'},
53 'doc_note': {'text': '_test_note'}, 55 'doc_note': {'text': '_test_note'},
54 'doc_name_column_title': {'text': '_test_name_column_title'}, 56 'doc_name_column_title': {'text': '_test_name_column_title'},
55 'doc_not_supported': {'text': '_test_not_supported'}, 57 'doc_not_supported': {'text': '_test_not_supported'},
56 'doc_since_version': {'text': '_test_since_version'}, 58 'doc_since_version': {'text': '_test_since_version'},
57 'doc_supported': {'text': '_test_supported'}, 59 'doc_supported': {'text': '_test_supported'},
58 'doc_supported_features': {'text': '_test_supported_features'}, 60 'doc_supported_features': {'text': '_test_supported_features'},
59 'doc_supported_on': {'text': '_test_supported_on'}, 61 'doc_supported_on': {'text': '_test_supported_on'},
60 'doc_win_reg_loc': {'text': '_test_win_reg_loc'}, 62 'doc_win_reg_loc': {'text': '_test_win_reg_loc'},
(...skipping 346 matching lines...) Expand 10 before | Expand all | Expand 10 after
407 '<li>Chrome (iOS) ...34...</li>' 409 '<li>Chrome (iOS) ...34...</li>'
408 '</ul>' 410 '</ul>'
409 '</dd>' 411 '</dd>'
410 '<dt style="style_dt;">_test_supported_features</dt>' 412 '<dt style="style_dt;">_test_supported_features</dt>'
411 '<dd>_test_feature_dynamic_refresh: _test_not_supported</dd>' 413 '<dd>_test_feature_dynamic_refresh: _test_not_supported</dd>'
412 '<dt style="style_dt;">_test_description</dt><dd>TestPolicyDesc</dd>' 414 '<dt style="style_dt;">_test_description</dt><dd>TestPolicyDesc</dd>'
413 '<dt style="style_dt;">_test_example_value</dt>' 415 '<dt style="style_dt;">_test_example_value</dt>'
414 '<dd>0x00000000 (Windows), false (Linux), &lt;false /&gt; (Mac)</dd>' 416 '<dd>0x00000000 (Windows), false (Linux), &lt;false /&gt; (Mac)</dd>'
415 '</dl></root>') 417 '</dl></root>')
416 418
419 def testAddPolicyDetailsRecommendedOnly(self):
420 policy = {
421 'type': 'main',
422 'name': 'TestPolicyName',
423 'caption': 'TestPolicyCaption',
424 'desc': 'TestPolicyDesc',
425 'supported_on': [{
426 'product': 'chrome',
427 'platforms': ['win', 'mac', 'linux'],
428 'since_version': '8',
429 'until_version': '',
430 }, {
431 'product': 'chrome',
432 'platforms': ['android'],
433 'since_version': '30',
434 'until_version': '',
435 }, {
436 'product': 'chrome',
437 'platforms': ['ios'],
438 'since_version': '34',
439 'until_version': '',
440 }],
441 'features': {
442 'dynamic_refresh': False,
443 'can_be_mandatory': False,
444 'can_be_recommended': True
445 },
446 'example_value': False
447 }
448 self.writer.messages['doc_since_version'] = {'text': '...$6...'}
449 self.writer._AddPolicyDetails(self.doc_root, policy)
450 self.assertEquals(
451 self.doc_root.toxml(),
452 '<root><dl>'
453 '<dt style="style_dt;">_test_data_type</dt><dd>Boolean (REG_DWORD)</dd>'
454 '<dt style="style_dt;">_test_win_reg_loc</dt>'
455 '<dd style="style_.monospace;">MockKeyRec\TestPolicyName</dd>'
456 '<dt style="style_dt;">_test_mac_linux_pref_name</dt>'
457 '<dd style="style_.monospace;">TestPolicyName</dd>'
458 '<dt style="style_dt;">_test_supported_on</dt>'
459 '<dd>'
460 '<ul style="style_ul;">'
461 '<li>Chrome (Windows, Mac, Linux) ...8...</li>'
462 '<li>Chrome (Android) ...30...</li>'
463 '<li>Chrome (iOS) ...34...</li>'
464 '</ul>'
465 '</dd>'
466 '<dt style="style_dt;">_test_supported_features</dt>'
467 '<dd>_test_feature_mandatory: _test_not_supported,'
468 ' _test_feature_recommended: _test_supported,'
469 ' _test_feature_dynamic_refresh: _test_not_supported</dd>'
470 '<dt style="style_dt;">_test_description</dt><dd>TestPolicyDesc</dd>'
471 '<dt style="style_dt;">_test_example_value</dt>'
472 '<dd>0x00000000 (Windows), false (Linux), &lt;false /&gt; (Mac)</dd>'
473 '</dl></root>')
474
417 def testAddPolicyNote(self): 475 def testAddPolicyNote(self):
418 # TODO(jkummerow): The functionality tested by this test is currently not 476 # TODO(jkummerow): The functionality tested by this test is currently not
419 # used for anything and will probably soon be removed. 477 # used for anything and will probably soon be removed.
420 # Test if nodes are correctly added to policies. 478 # Test if nodes are correctly added to policies.
421 policy = { 479 policy = {
422 'problem_href': 'http://www.example.com/5' 480 'problem_href': 'http://www.example.com/5'
423 } 481 }
424 self.writer.messages['doc_note'] = {'text': '...$6...'} 482 self.writer.messages['doc_note'] = {'text': '...$6...'}
425 self.writer._AddPolicyNote(self.doc_root, policy) 483 self.writer._AddPolicyNote(self.doc_root, policy)
426 self.assertEquals( 484 self.assertEquals(
(...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after
733 ' &lt;key&gt;True&lt;/key&gt;\n' 791 ' &lt;key&gt;True&lt;/key&gt;\n'
734 ' &lt;true/&gt;\n' 792 ' &lt;true/&gt;\n'
735 '&lt;/dict&gt;' 793 '&lt;/dict&gt;'
736 '</dd>' 794 '</dd>'
737 '</dl>' 795 '</dl>'
738 '</root>') 796 '</root>')
739 797
740 798
741 if __name__ == '__main__': 799 if __name__ == '__main__':
742 unittest.main() 800 unittest.main()
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698