| 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 json | 9 import json |
| 10 import os | 10 import os |
| (...skipping 19 matching lines...) Expand all Loading... |
| 30 class DocWriterUnittest(writer_unittest_common.WriterUnittestCommon): | 30 class DocWriterUnittest(writer_unittest_common.WriterUnittestCommon): |
| 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 'webview_name': 'WebView', |
| 41 'android_webview_restriction_prefix': 'mock.prefix:', |
| 40 'win_reg_mandatory_key_name': 'MockKey', | 42 'win_reg_mandatory_key_name': 'MockKey', |
| 41 'win_reg_recommended_key_name': 'MockKeyRec', | 43 'win_reg_recommended_key_name': 'MockKeyRec', |
| 42 'build': 'test_product', | 44 'build': 'test_product', |
| 43 }) | 45 }) |
| 44 self.writer.messages = { | 46 self.writer.messages = { |
| 45 'doc_back_to_top': {'text': '_test_back_to_top'}, | 47 'doc_back_to_top': {'text': '_test_back_to_top'}, |
| 46 'doc_complex_policies_on_windows': {'text': '_test_complex_policies_win'}, | 48 'doc_complex_policies_on_windows': {'text': '_test_complex_policies_win'}, |
| 47 'doc_data_type': {'text': '_test_data_type'}, | 49 'doc_data_type': {'text': '_test_data_type'}, |
| 48 'doc_description': {'text': '_test_description'}, | 50 'doc_description': {'text': '_test_description'}, |
| 49 'doc_description_column_title': { | 51 'doc_description_column_title': { |
| 50 'text': '_test_description_column_title' | 52 'text': '_test_description_column_title' |
| 51 }, | 53 }, |
| 52 'doc_example_value': {'text': '_test_example_value'}, | 54 'doc_example_value': {'text': '_test_example_value'}, |
| 53 'doc_feature_dynamic_refresh': {'text': '_test_feature_dynamic_refresh'}, | 55 'doc_feature_dynamic_refresh': {'text': '_test_feature_dynamic_refresh'}, |
| 54 'doc_feature_can_be_recommended': {'text': '_test_feature_recommended'}, | 56 'doc_feature_can_be_recommended': {'text': '_test_feature_recommended'}, |
| 55 'doc_feature_can_be_mandatory': {'text': '_test_feature_mandatory'}, | 57 'doc_feature_can_be_mandatory': {'text': '_test_feature_mandatory'}, |
| 56 'doc_intro': {'text': '_test_intro'}, | 58 'doc_intro': {'text': '_test_intro'}, |
| 57 'doc_mac_linux_pref_name': {'text': '_test_mac_linux_pref_name'}, | 59 'doc_mac_linux_pref_name': {'text': '_test_mac_linux_pref_name'}, |
| 58 'doc_android_restriction_name': { | 60 'doc_android_restriction_name': { |
| 59 'text': '_test_android_restriction_name' | 61 'text': '_test_android_restriction_name' |
| 60 }, | 62 }, |
| 63 'doc_android_webview_restriction_name': { |
| 64 'text': '_test_android_webview_restriction_name' |
| 65 }, |
| 61 'doc_note': {'text': '_test_note'}, | 66 'doc_note': {'text': '_test_note'}, |
| 62 'doc_name_column_title': {'text': '_test_name_column_title'}, | 67 'doc_name_column_title': {'text': '_test_name_column_title'}, |
| 63 'doc_not_supported': {'text': '_test_not_supported'}, | 68 'doc_not_supported': {'text': '_test_not_supported'}, |
| 64 'doc_since_version': {'text': '_test_since_version'}, | 69 'doc_since_version': {'text': '_test_since_version'}, |
| 65 'doc_supported': {'text': '_test_supported'}, | 70 'doc_supported': {'text': '_test_supported'}, |
| 66 'doc_supported_features': {'text': '_test_supported_features'}, | 71 'doc_supported_features': {'text': '_test_supported_features'}, |
| 67 'doc_supported_on': {'text': '_test_supported_on'}, | 72 'doc_supported_on': {'text': '_test_supported_on'}, |
| 68 'doc_win_reg_loc': {'text': '_test_win_reg_loc'}, | 73 'doc_win_reg_loc': {'text': '_test_win_reg_loc'}, |
| 69 | 74 |
| 70 'doc_bla': {'text': '_test_bla'}, | 75 'doc_bla': {'text': '_test_bla'}, |
| (...skipping 340 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 411 'product': 'chrome', | 416 'product': 'chrome', |
| 412 'platforms': ['win', 'mac', 'linux'], | 417 'platforms': ['win', 'mac', 'linux'], |
| 413 'since_version': '8', | 418 'since_version': '8', |
| 414 'until_version': '', | 419 'until_version': '', |
| 415 }, { | 420 }, { |
| 416 'product': 'chrome', | 421 'product': 'chrome', |
| 417 'platforms': ['android'], | 422 'platforms': ['android'], |
| 418 'since_version': '30', | 423 'since_version': '30', |
| 419 'until_version': '', | 424 'until_version': '', |
| 420 }, { | 425 }, { |
| 426 'product': 'webview', |
| 427 'platforms': ['android'], |
| 428 'since_version': '47', |
| 429 'until_version': '', |
| 430 }, { |
| 421 'product': 'chrome', | 431 'product': 'chrome', |
| 422 'platforms': ['ios'], | 432 'platforms': ['ios'], |
| 423 'since_version': '34', | 433 'since_version': '34', |
| 424 'until_version': '', | 434 'until_version': '', |
| 425 }], | 435 }], |
| 426 'features': {'dynamic_refresh': False}, | 436 'features': {'dynamic_refresh': False}, |
| 427 'example_value': False | 437 'example_value': False |
| 428 } | 438 } |
| 429 self.writer.messages['doc_since_version'] = {'text': '...$6...'} | 439 self.writer.messages['doc_since_version'] = {'text': '...$6...'} |
| 430 self.writer._AddPolicyDetails(self.doc_root, policy) | 440 self.writer._AddPolicyDetails(self.doc_root, policy) |
| 431 self.assertEquals( | 441 self.assertEquals( |
| 432 self.doc_root.toxml(), | 442 self.doc_root.toxml(), |
| 433 '<root><dl>' | 443 '<root><dl>' |
| 434 '<dt style="style_dt;">_test_data_type</dt>' | 444 '<dt style="style_dt;">_test_data_type</dt>' |
| 435 '<dd>Boolean [Windows:REG_DWORD]</dd>' | 445 '<dd>Boolean [Windows:REG_DWORD]</dd>' |
| 436 '<dt style="style_dt;">_test_win_reg_loc</dt>' | 446 '<dt style="style_dt;">_test_win_reg_loc</dt>' |
| 437 '<dd style="style_.monospace;">MockKey\TestPolicyName</dd>' | 447 '<dd style="style_.monospace;">MockKey\TestPolicyName</dd>' |
| 438 '<dt style="style_dt;">_test_mac_linux_pref_name</dt>' | 448 '<dt style="style_dt;">_test_mac_linux_pref_name</dt>' |
| 439 '<dd style="style_.monospace;">TestPolicyName</dd>' | 449 '<dd style="style_.monospace;">TestPolicyName</dd>' |
| 440 '<dt style="style_dt;">_test_android_restriction_name</dt>' | 450 '<dt style="style_dt;">_test_android_restriction_name</dt>' |
| 441 '<dd style="style_.monospace;">TestPolicyName</dd>' | 451 '<dd style="style_.monospace;">TestPolicyName</dd>' |
| 452 '<dt style="style_dt;">_test_android_webview_restriction_name</dt>' |
| 453 '<dd style="style_.monospace;">mock.prefix:TestPolicyName</dd>' |
| 442 '<dt style="style_dt;">_test_supported_on</dt>' | 454 '<dt style="style_dt;">_test_supported_on</dt>' |
| 443 '<dd>' | 455 '<dd>' |
| 444 '<ul style="style_ul;">' | 456 '<ul style="style_ul;">' |
| 445 '<li>Chrome (Windows, Mac, Linux) ...8...</li>' | 457 '<li>Chrome (Windows, Mac, Linux) ...8...</li>' |
| 446 '<li>Chrome (Android) ...30...</li>' | 458 '<li>Chrome (Android) ...30...</li>' |
| 459 '<li>WebView (Android) ...47...</li>' |
| 447 '<li>Chrome (iOS) ...34...</li>' | 460 '<li>Chrome (iOS) ...34...</li>' |
| 448 '</ul>' | 461 '</ul>' |
| 449 '</dd>' | 462 '</dd>' |
| 450 '<dt style="style_dt;">_test_supported_features</dt>' | 463 '<dt style="style_dt;">_test_supported_features</dt>' |
| 451 '<dd>_test_feature_dynamic_refresh: _test_not_supported</dd>' | 464 '<dd>_test_feature_dynamic_refresh: _test_not_supported</dd>' |
| 452 '<dt style="style_dt;">_test_description</dt><dd><p>TestPolicyDesc</p></dd
>' | 465 '<dt style="style_dt;">_test_description</dt><dd><p>TestPolicyDesc</p></dd
>' |
| 453 '<dt style="style_dt;">_test_example_value</dt>' | 466 '<dt style="style_dt;">_test_example_value</dt>' |
| 454 '<dd>0x00000000 (Windows), false (Linux),' | 467 '<dd>0x00000000 (Windows), false (Linux),' |
| 455 ' false (Android), <false /> (Mac)</dd>' | 468 ' false (Android), <false /> (Mac)</dd>' |
| 456 '</dl></root>') | 469 '</dl></root>') |
| (...skipping 485 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 942 | 955 |
| 943 def testParagraphs(self): | 956 def testParagraphs(self): |
| 944 text = 'Paragraph 1\n\nParagraph 2\n\nParagraph 3' | 957 text = 'Paragraph 1\n\nParagraph 2\n\nParagraph 3' |
| 945 self.writer._AddParagraphs(self.doc_root, text) | 958 self.writer._AddParagraphs(self.doc_root, text) |
| 946 self.assertEquals( | 959 self.assertEquals( |
| 947 self.doc_root.toxml(), | 960 self.doc_root.toxml(), |
| 948 '<root><p>Paragraph 1</p><p>Paragraph 2</p><p>Paragraph 3</p></root>') | 961 '<root><p>Paragraph 1</p><p>Paragraph 2</p><p>Paragraph 3</p></root>') |
| 949 | 962 |
| 950 if __name__ == '__main__': | 963 if __name__ == '__main__': |
| 951 unittest.main() | 964 unittest.main() |
| OLD | NEW |