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

Side by Side Diff: grit/format/policy_templates/writers/doc_writer_unittest.py

Issue 347293003: Added support for string-enum-list. (Closed) Base URL: http://grit-i18n.googlecode.com/svn/trunk/
Patch Set: Created 6 years, 6 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 | Annotate | Revision Log
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 264 matching lines...) Expand 10 before | Expand all | Expand 10 after
275 'type': 'int-enum', 275 'type': 'int-enum',
276 'example_value': 16, 276 'example_value': 16,
277 'supported_on': [ { 'platforms': ['win', 'mac', 'linux'] } ] 277 'supported_on': [ { 'platforms': ['win', 'mac', 'linux'] } ]
278 } 278 }
279 self.writer._AddExample(self.doc_root, policy) 279 self.writer._AddExample(self.doc_root, policy)
280 self.assertEquals( 280 self.assertEquals(
281 self.doc_root.toxml(), 281 self.doc_root.toxml(),
282 '<root>0x00000010 (Windows), 16 (Linux), 16 (Mac)</root>') 282 '<root>0x00000010 (Windows), 16 (Linux), 16 (Mac)</root>')
283 283
284 def testStringEnumExample(self): 284 def testStringEnumExample(self):
285 # Test representation of 'int-enum' example values. 285 # Test representation of 'string-enum' example values.
286 policy = { 286 policy = {
287 'name': 'PolicyName', 287 'name': 'PolicyName',
288 'type': 'string-enum', 288 'type': 'string-enum',
289 'example_value': "wacky" 289 'example_value': "wacky"
290 } 290 }
291 self.writer._AddExample(self.doc_root, policy) 291 self.writer._AddExample(self.doc_root, policy)
292 self.assertEquals( 292 self.assertEquals(
293 self.doc_root.toxml(), 293 self.doc_root.toxml(),
294 '<root>&quot;wacky&quot;</root>') 294 '<root>&quot;wacky&quot;</root>')
295 295
296 def testListExample(self):
297 # Test representation of 'list' example values.
298 policy = {
299 'name': 'PolicyName',
300 'type': 'list',
301 'example_value': ['one', 'two'],
302 'supported_on': [ { 'platforms': ['linux'] } ]
303 }
304 self.writer._AddExample(self.doc_root, policy)
305 self.assertEquals(
306 self.doc_root.toxml(),
307 '<root><dl style="style_dd dl;">'
308 '<dt>Linux:</dt>'
309 '<dd style="style_.monospace;">'
310 '[&quot;one&quot;, &quot;two&quot;]'
311 '</dd></dl></root>')
312
313 def testStringEnumListExample(self):
314 # Test representation of 'string-enum-list' example values.
315 policy = {
316 'name': 'PolicyName',
317 'type': 'string-enum-list',
318 'example_value': ['one', 'two'],
319 'supported_on': [ { 'platforms': ['linux'] } ]
320 }
321 self.writer._AddExample(self.doc_root, policy)
322 self.assertEquals(
323 self.doc_root.toxml(),
324 '<root><dl style="style_dd dl;">'
325 '<dt>Linux:</dt>'
326 '<dd style="style_.monospace;">'
327 '[&quot;one&quot;, &quot;two&quot;]'
328 '</dd></dl></root>')
329
296 def testStringExample(self): 330 def testStringExample(self):
297 # Test representation of 'string' example values. 331 # Test representation of 'string' example values.
298 policy = { 332 policy = {
299 'name': 'PolicyName', 333 'name': 'PolicyName',
300 'type': 'string', 334 'type': 'string',
301 'example_value': 'awesome-example' 335 'example_value': 'awesome-example'
302 } 336 }
303 self.writer._AddExample(self.doc_root, policy) 337 self.writer._AddExample(self.doc_root, policy)
304 self.assertEquals( 338 self.assertEquals(
305 self.doc_root.toxml(), 339 self.doc_root.toxml(),
(...skipping 393 matching lines...) Expand 10 before | Expand all | Expand 10 after
699 ' &lt;key&gt;True&lt;/key&gt;\n' 733 ' &lt;key&gt;True&lt;/key&gt;\n'
700 ' &lt;true/&gt;\n' 734 ' &lt;true/&gt;\n'
701 '&lt;/dict&gt;' 735 '&lt;/dict&gt;'
702 '</dd>' 736 '</dd>'
703 '</dl>' 737 '</dl>'
704 '</root>') 738 '</root>')
705 739
706 740
707 if __name__ == '__main__': 741 if __name__ == '__main__':
708 unittest.main() 742 unittest.main()
OLDNEW
« no previous file with comments | « grit/format/policy_templates/writers/doc_writer.py ('k') | grit/format/policy_templates/writers/ios_plist_writer_unittest.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698