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

Unified Diff: tools/grit/grit/format/policy_templates/writers/doc_writer_unittest.py

Issue 6134006: Integrate user strings into the JSON policy template file (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: " Created 9 years, 11 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: tools/grit/grit/format/policy_templates/writers/doc_writer_unittest.py
diff --git a/tools/grit/grit/format/policy_templates/writers/doc_writer_unittest.py b/tools/grit/grit/format/policy_templates/writers/doc_writer_unittest.py
index 9aafd118ae3b8386b565c14baa4ef82beeb91fe5..56f02f31c85084724919e2b2aa881ccfcf776637 100644
--- a/tools/grit/grit/format/policy_templates/writers/doc_writer_unittest.py
+++ b/tools/grit/grit/format/policy_templates/writers/doc_writer_unittest.py
@@ -31,29 +31,6 @@ class MockMessageDictionary:
# Dictionary of messages.
msg_dict = {}
- def __getitem__(self, msg_id):
- '''Returns a message for an identifier. The identifier is transformed
- back from IDS_POLICY_DOC... style names to the keys that the writer used.
- If it is then key in self.msg_dict, then the message comes from there.
- Otherwise the returned message is just the transformed version of the
- identifier. This makes things more simple for testing.
-
- Args:
- msg_id: The message identifier.
-
- Returns:
- The mock message for msg_id.
- '''
- # Do some trickery to get the original message id issued in DocWriter.
- expected_prefix = 'IDS_POLICY_DOC_'
- assert msg_id.startswith(expected_prefix)
- original_msg_id = msg_id[len(expected_prefix):].lower()
-
- if original_msg_id in self.msg_dict:
- return self.msg_dict[original_msg_id]
- return '_test_' + original_msg_id
-
-
class DocWriterUnittest(writer_unittest_common.WriterUnittestCommon):
'''Unit tests for DocWriter.'''
@@ -65,8 +42,29 @@ class DocWriterUnittest(writer_unittest_common.WriterUnittestCommon):
'frame_name': 'Chrome Frame',
'os_name': 'Chrome OS',
'win_reg_key_name': 'MockKey',
+ })
+ self.writer.messages = {
+ 'doc_back_to_top': {'text': '_test_back_to_top'},
+ 'doc_data_type': {'text': '_test_data_type'},
+ 'doc_description': {'text': '_test_description'},
+ 'doc_description_column_title': {
+ 'text': '_test_description_column_title'
},
- messages=MockMessageDictionary())
+ 'doc_example_value': {'text': '_test_example_value'},
+ 'doc_feature_dynamic_refresh': {'text': '_test_feature_dynamic_refresh'},
+ 'doc_intro': {'text': '_test_intro'},
+ 'doc_mac_linux_pref_name': {'text': '_test_mac_linux_pref_name'},
+ 'doc_note': {'text': '_test_note'},
+ 'doc_name_column_title': {'text': '_test_name_column_title'},
+ 'doc_not_supported': {'text': '_test_not_supported'},
+ 'doc_since_version': {'text': '_test_since_version'},
+ 'doc_supported': {'text': '_test_supported'},
+ 'doc_supported_features': {'text': '_test_supported_features'},
+ 'doc_supported_on': {'text': '_test_supported_on'},
+ 'doc_win_reg_loc': {'text': '_test_win_reg_loc'},
+
+ 'doc_bla': {'text': '_test_bla'},
+ }
self.writer.Init()
# It is not worth testing the exact content of style attributes.
@@ -108,7 +106,7 @@ class DocWriterUnittest(writer_unittest_common.WriterUnittestCommon):
def testGetLocalizedMessage(self):
# Test if localized messages are retrieved correctly.
self.writer.messages = {
- 'IDS_POLICY_DOC_HELLO_WORLD': 'hello, vilag!'
+ 'doc_hello_world': {'text': 'hello, vilag!'}
}
self.assertEquals(
self.writer._GetLocalizedMessage('hello_world'),
@@ -358,7 +356,7 @@ See <a href="http://policy-explanation.example.com">http://policy-explanation.ex
'example_value': False
}
}
- self.writer.messages.msg_dict['since_version'] = '...$6...'
+ self.writer.messages['doc_since_version'] = {'text': '...$6...'}
self.writer._AddPolicyDetails(self.doc_root, policy)
self.assertEquals(
self.doc_root.toxml(),
@@ -388,7 +386,7 @@ See <a href="http://policy-explanation.example.com">http://policy-explanation.ex
'problem_href': 'http://www.example.com/5'
}
}
- self.writer.messages.msg_dict['note'] = '...$6...'
+ self.writer.messages['doc_note'] = {'text': '...$6...'}
self.writer._AddPolicyNote(self.doc_root, policy)
self.assertEquals(
self.doc_root.toxml(),
@@ -447,7 +445,7 @@ See <a href="http://policy-explanation.example.com">http://policy-explanation.ex
'example_value': False
}
}
- self.writer.messages.msg_dict['since_version'] = '..$6..'
+ self.writer.messages['doc_since_version'] = {'text': '..$6..'}
self.writer._AddPolicySection(self.doc_root, policy)
self.assertEquals(
self.doc_root.toxml(),

Powered by Google App Engine
This is Rietveld 408576698