OLD | NEW |
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 22 matching lines...) Expand all Loading... |
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 }) | 40 }) |
41 self.writer.messages = { | 41 self.writer.messages = { |
42 'doc_back_to_top': {'text': '_test_back_to_top'}, | 42 'doc_back_to_top': {'text': '_test_back_to_top'}, |
| 43 'doc_complex_policies_on_windows': {'text': '_test_complex_policies_win'}, |
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'}, |
51 'doc_intro': {'text': '_test_intro'}, | 52 'doc_intro': {'text': '_test_intro'}, |
52 'doc_mac_linux_pref_name': {'text': '_test_mac_linux_pref_name'}, | 53 'doc_mac_linux_pref_name': {'text': '_test_mac_linux_pref_name'}, |
(...skipping 354 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
407 '<li>Chrome (iOS) ...34...</li>' | 408 '<li>Chrome (iOS) ...34...</li>' |
408 '</ul>' | 409 '</ul>' |
409 '</dd>' | 410 '</dd>' |
410 '<dt style="style_dt;">_test_supported_features</dt>' | 411 '<dt style="style_dt;">_test_supported_features</dt>' |
411 '<dd>_test_feature_dynamic_refresh: _test_not_supported</dd>' | 412 '<dd>_test_feature_dynamic_refresh: _test_not_supported</dd>' |
412 '<dt style="style_dt;">_test_description</dt><dd>TestPolicyDesc</dd>' | 413 '<dt style="style_dt;">_test_description</dt><dd>TestPolicyDesc</dd>' |
413 '<dt style="style_dt;">_test_example_value</dt>' | 414 '<dt style="style_dt;">_test_example_value</dt>' |
414 '<dd>0x00000000 (Windows), false (Linux), <false /> (Mac)</dd>' | 415 '<dd>0x00000000 (Windows), false (Linux), <false /> (Mac)</dd>' |
415 '</dl></root>') | 416 '</dl></root>') |
416 | 417 |
| 418 def testAddDictPolicyDetails(self): |
| 419 # Test if the definition list (<dl>) of policy details is created correctly |
| 420 # for 'dict' policies. |
| 421 policy = { |
| 422 'type': 'dict', |
| 423 'name': 'TestPolicyName', |
| 424 'caption': 'TestPolicyCaption', |
| 425 'desc': 'TestPolicyDesc', |
| 426 'supported_on': [{ |
| 427 'product': 'chrome', |
| 428 'platforms': ['win', 'mac', 'linux'], |
| 429 'since_version': '8', |
| 430 'until_version': '', |
| 431 }], |
| 432 'features': {'dynamic_refresh': False}, |
| 433 'example_value': { 'foo': 123 } |
| 434 } |
| 435 self.writer.messages['doc_since_version'] = {'text': '...$6...'} |
| 436 self.writer._AddPolicyDetails(self.doc_root, policy) |
| 437 self.assertEquals( |
| 438 self.doc_root.toxml(), |
| 439 '<root><dl>' |
| 440 '<dt style="style_dt;">_test_data_type</dt><dd>Dictionary (REG_SZ; _test_c
omplex_policies_win)</dd>' |
| 441 '<dt style="style_dt;">_test_win_reg_loc</dt>' |
| 442 '<dd style="style_.monospace;">MockKey\TestPolicyName</dd>' |
| 443 '<dt style="style_dt;">_test_mac_linux_pref_name</dt>' |
| 444 '<dd style="style_.monospace;">TestPolicyName</dd>' |
| 445 '<dt style="style_dt;">_test_supported_on</dt>' |
| 446 '<dd>' |
| 447 '<ul style="style_ul;">' |
| 448 '<li>Chrome (Windows, Mac, Linux) ...8...</li>' |
| 449 '</ul>' |
| 450 '</dd>' |
| 451 '<dt style="style_dt;">_test_supported_features</dt>' |
| 452 '<dd>_test_feature_dynamic_refresh: _test_not_supported</dd>' |
| 453 '<dt style="style_dt;">_test_description</dt><dd>TestPolicyDesc</dd>' |
| 454 '<dt style="style_dt;">_test_example_value</dt>' |
| 455 '<dd>' |
| 456 '<dl style="style_dd dl;">' |
| 457 '<dt>Windows:</dt>' |
| 458 '<dd style="style_.monospace;style_.pre;">MockKey\TestPolicyName = {
"foo": 123}</dd>' |
| 459 '<dt>Linux:</dt>' |
| 460 '<dd style="style_.monospace;">TestPolicyName: {"foo": 123
}</dd>' |
| 461 '<dt>Mac:</dt>' |
| 462 '<dd style="style_.monospace;style_.pre;">' |
| 463 '<key>TestPolicyName</key>\n' |
| 464 '<dict>\n' |
| 465 ' <key>foo</key>\n' |
| 466 ' <integer>123</integer>\n' |
| 467 '</dict>' |
| 468 '</dd>' |
| 469 '</dl>' |
| 470 '</dd>' |
| 471 '</dl></root>') |
| 472 |
417 def testAddPolicyNote(self): | 473 def testAddPolicyNote(self): |
418 # TODO(jkummerow): The functionality tested by this test is currently not | 474 # TODO(jkummerow): The functionality tested by this test is currently not |
419 # used for anything and will probably soon be removed. | 475 # used for anything and will probably soon be removed. |
420 # Test if nodes are correctly added to policies. | 476 # Test if nodes are correctly added to policies. |
421 policy = { | 477 policy = { |
422 'problem_href': 'http://www.example.com/5' | 478 'problem_href': 'http://www.example.com/5' |
423 } | 479 } |
424 self.writer.messages['doc_note'] = {'text': '...$6...'} | 480 self.writer.messages['doc_note'] = {'text': '...$6...'} |
425 self.writer._AddPolicyNote(self.doc_root, policy) | 481 self.writer._AddPolicyNote(self.doc_root, policy) |
426 self.assertEquals( | 482 self.assertEquals( |
(...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
733 ' <key>True</key>\n' | 789 ' <key>True</key>\n' |
734 ' <true/>\n' | 790 ' <true/>\n' |
735 '</dict>' | 791 '</dict>' |
736 '</dd>' | 792 '</dd>' |
737 '</dl>' | 793 '</dl>' |
738 '</root>') | 794 '</root>') |
739 | 795 |
740 | 796 |
741 if __name__ == '__main__': | 797 if __name__ == '__main__': |
742 unittest.main() | 798 unittest.main() |
OLD | NEW |