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 | 6 |
7 """Unittests for grit.format.policy_templates.writers.adml_writer.""" | 7 """Unittests for grit.format.policy_templates.writers.adml_writer.""" |
8 | 8 |
9 | 9 |
10 import os | 10 import os |
(...skipping 358 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
369 'supported_on': [ | 369 'supported_on': [ |
370 {'platforms': ['win', 'zzz']}, {'platforms': ['aaa']} | 370 {'platforms': ['win', 'zzz']}, {'platforms': ['aaa']} |
371 ] | 371 ] |
372 })) | 372 })) |
373 self.assertFalse(self.writer.IsPolicySupported({ | 373 self.assertFalse(self.writer.IsPolicySupported({ |
374 'supported_on': [ | 374 'supported_on': [ |
375 {'platforms': ['mac', 'linux']}, {'platforms': ['aaa']} | 375 {'platforms': ['mac', 'linux']}, {'platforms': ['aaa']} |
376 ] | 376 ] |
377 })) | 377 })) |
378 | 378 |
| 379 def testStringEncodings(self): |
| 380 enum_policy_a = { |
| 381 'name': 'EnumPolicy.A', |
| 382 'type': 'string-enum', |
| 383 'caption': 'Enum policy A caption', |
| 384 'label': 'Enum policy A label', |
| 385 'desc': 'This is a test description.', |
| 386 'items': [ |
| 387 { |
| 388 'name': 'tls1.2', |
| 389 'value': 'tls1.2', |
| 390 'caption': 'tls1.2', |
| 391 } |
| 392 ], |
| 393 } |
| 394 enum_policy_b = { |
| 395 'name': 'EnumPolicy.B', |
| 396 'type': 'string-enum', |
| 397 'caption': 'Enum policy B caption', |
| 398 'label': 'Enum policy B label', |
| 399 'desc': 'This is a test description.', |
| 400 'items': [ |
| 401 { |
| 402 'name': 'tls1.2', |
| 403 'value': 'tls1.2', |
| 404 'caption': 'tls1.2', |
| 405 } |
| 406 ], |
| 407 } |
| 408 self. _InitWriterForAddingPolicies(self.writer, enum_policy_a) |
| 409 self.writer.WritePolicy(enum_policy_a) |
| 410 self.writer.WritePolicy(enum_policy_b) |
| 411 # Assert generated string elements. |
| 412 output = self.GetXMLOfChildren(self.writer._string_table_elem) |
| 413 expected_output = ( |
| 414 '<string id="EnumPolicy_A">Enum policy A caption</string>\n' |
| 415 '<string id="EnumPolicy_A_Explain">' |
| 416 'This is a test description.</string>\n' |
| 417 '<string id="tls1_2">tls1.2</string>\n' |
| 418 '<string id="EnumPolicy_B">Enum policy B caption</string>\n' |
| 419 '<string id="EnumPolicy_B_Explain">' |
| 420 'This is a test description.</string>\n') |
| 421 self.AssertXMLEquals(output, expected_output) |
| 422 # Assert generated presentation elements. |
| 423 output = self.GetXMLOfChildren(self.writer._presentation_table_elem) |
| 424 expected_output = ( |
| 425 '<presentation id="EnumPolicy.A">\n' |
| 426 ' <dropdownList refId="EnumPolicy.A">' |
| 427 'Enum policy A label</dropdownList>\n' |
| 428 '</presentation>\n' |
| 429 '<presentation id="EnumPolicy.B">\n' |
| 430 ' <dropdownList refId="EnumPolicy.B">' |
| 431 'Enum policy B label</dropdownList>\n' |
| 432 '</presentation>') |
| 433 self.AssertXMLEquals(output, expected_output) |
| 434 |
379 | 435 |
380 if __name__ == '__main__': | 436 if __name__ == '__main__': |
381 unittest.main() | 437 unittest.main() |
OLD | NEW |