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

Unified Diff: components/policy/tools/template_writers/writers/doc_writer_unittest.py

Issue 2653823006: Include 'external' policies in grit output (admx, adm, doc etc.) (Closed)
Patch Set: Whitespace fix 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 side-by-side diff with in-line comments
Download patch
Index: components/policy/tools/template_writers/writers/doc_writer_unittest.py
diff --git a/components/policy/tools/template_writers/writers/doc_writer_unittest.py b/components/policy/tools/template_writers/writers/doc_writer_unittest.py
index 21b18e456ed9146446f2a2de62fdcc4f6364124e..08d13ce7c3f4731b0e7817dacd95d99f1a6d6ca3 100755
--- a/components/policy/tools/template_writers/writers/doc_writer_unittest.py
+++ b/components/policy/tools/template_writers/writers/doc_writer_unittest.py
@@ -593,6 +593,75 @@ See <a href="http://policy-explanation.example.com">http://policy-explanation.ex
'</dd>'
'</dl></root>')
+ def testAddExternalPolicyDetails(self):
+ # Test if the definition list (<dl>) of policy details is created correctly
+ # for 'external' policies.
+ policy = {
+ 'type': 'external',
+ 'name': 'TestPolicyName',
+ 'caption': 'TestPolicyCaption',
+ 'desc': 'TestPolicyDesc',
+ 'supported_on': [{
+ 'product': 'chrome',
+ 'platforms': ['win', 'mac', 'linux'],
+ 'since_version': '8',
+ 'until_version': '',
+ }],
+ 'features': {'dynamic_refresh': False},
+ 'example_value': {
+ "url": "https://example.com/avatar.jpg",
+ "hash": "deadbeef",
+ },
+ }
+ self.writer.messages['doc_since_version'] = {'text': '...$6...'}
+ self.writer._AddPolicyDetails(self.doc_root, policy)
+ self.assertEquals(
+ self.doc_root.toxml(),
+ '<root><dl>'
+ '<dt style="style_dt;">_test_data_type</dt>'
+ '<dd>External data reference [Windows:REG_SZ] (_test_complex_policies_win)</dd>'
+ '<dt style="style_dt;">_test_win_reg_loc</dt>'
+ '<dd style="style_.monospace;">MockKey\TestPolicyName</dd>'
+ '<dt style="style_dt;">_test_mac_linux_pref_name</dt>'
+ '<dd style="style_.monospace;">TestPolicyName</dd>'
+ '<dt style="style_dt;">_test_supported_on</dt>'
+ '<dd>'
+ '<ul style="style_ul;">'
+ '<li>Chrome (Windows, Mac, Linux) ...8...</li>'
+ '</ul>'
+ '</dd>'
+ '<dt style="style_dt;">_test_supported_features</dt>'
+ '<dd>_test_feature_dynamic_refresh: _test_not_supported</dd>'
+ '<dt style="style_dt;">_test_description</dt><dd><p>TestPolicyDesc</p></dd>'
+ '<dt style="style_dt;">_test_example_value</dt>'
+ '<dd>'
+ '<dl style="style_dd dl;">'
+ '<dt>_test_example_value_win</dt>'
+ '<dd style="style_.monospace;style_.pre;">'
+ 'MockKey\TestPolicyName = {'
+ '&quot;url&quot;: &quot;https://example.com/avatar.jpg&quot;, '
+ '&quot;hash&quot;: &quot;deadbeef&quot;}'
+ '</dd>'
+ '<dt>Android/Linux:</dt>'
+ '<dd style="style_.monospace;">'
+ 'TestPolicyName: {'
+ '&quot;url&quot;: &quot;https://example.com/avatar.jpg&quot;, '
+ '&quot;hash&quot;: &quot;deadbeef&quot;}'
+ '</dd>'
+ '<dt>Mac:</dt>'
+ '<dd style="style_.monospace;style_.pre;">'
+ '&lt;key&gt;TestPolicyName&lt;/key&gt;\n'
+ '&lt;dict&gt;\n'
+ ' &lt;key&gt;hash&lt;/key&gt;\n'
+ ' &lt;string&gt;deadbeef&lt;/string&gt;\n'
+ ' &lt;key&gt;url&lt;/key&gt;\n'
+ ' &lt;string&gt;https://example.com/avatar.jpg&lt;/string&gt;\n&lt;'
+ '/dict&gt;'
+ '</dd>'
+ '</dl>'
+ '</dd>'
+ '</dl></root>')
+
def testAddPolicyDetailsRecommendedOnly(self):
policy = {
'type': 'main',
@@ -1026,6 +1095,49 @@ See <a href="http://policy-explanation.example.com">http://policy-explanation.ex
'</dl>'
'</root>')
+ def testAddExternalExample(self):
+ policy = {
+ 'name': 'PolicyName',
+ 'caption': 'PolicyCaption',
+ 'desc': 'PolicyDesc',
+ 'type': 'external',
+ 'supported_on': [{
+ 'product': 'chrome',
+ 'platforms': ['win', 'mac', 'linux'],
+ 'since_version': '7',
+ 'until_version': '',
+ }],
+ 'features': {'dynamic_refresh': False},
+ 'example_value': {
+ "url": "https://example.com/avatar.jpg",
+ "hash": "deadbeef",
+ },
+ }
+ self.writer._AddDictionaryExample(self.doc_root, policy)
+ value = json.dumps(policy['example_value']).replace('"', '&quot;')
+ self.assertEquals(
+ self.doc_root.toxml(),
+ '<root>'
+ '<dl style="style_dd dl;">'
+ '<dt>_test_example_value_win</dt>'
+ '<dd style="style_.monospace;style_.pre;">MockKey\PolicyName = '
+ + value +
+ '</dd>'
+ '<dt>Android/Linux:</dt>'
+ '<dd style="style_.monospace;">PolicyName: ' + value + '</dd>'
+ '<dt>Mac:</dt>'
+ '<dd style="style_.monospace;style_.pre;">'
+ '&lt;key&gt;PolicyName&lt;/key&gt;\n'
+ '&lt;dict&gt;\n'
+ ' &lt;key&gt;hash&lt;/key&gt;\n'
+ ' &lt;string&gt;deadbeef&lt;/string&gt;\n'
+ ' &lt;key&gt;url&lt;/key&gt;\n'
+ ' &lt;string&gt;https://example.com/avatar.jpg&lt;/string&gt;\n'
+ '&lt;/dict&gt;'
+ '</dd>'
+ '</dl>'
+ '</root>')
+
def testParagraphs(self):
text = 'Paragraph 1\n\nParagraph 2\n\nParagraph 3'
self.writer._AddParagraphs(self.doc_root, text)

Powered by Google App Engine
This is Rietveld 408576698