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 264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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>"wacky"</root>') | 294 '<root>"wacky"</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 '["one", "two"]' |
| 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 '["one", "two"]' |
| 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 Loading... |
699 ' <key>True</key>\n' | 733 ' <key>True</key>\n' |
700 ' <true/>\n' | 734 ' <true/>\n' |
701 '</dict>' | 735 '</dict>' |
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() |
OLD | NEW |