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 344 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
355 'supported_on': [ | 355 'supported_on': [ |
356 {'platforms': ['win', 'zzz']}, {'platforms': ['aaa']} | 356 {'platforms': ['win', 'zzz']}, {'platforms': ['aaa']} |
357 ] | 357 ] |
358 })) | 358 })) |
359 self.assertFalse(self.writer.IsPolicySupported({ | 359 self.assertFalse(self.writer.IsPolicySupported({ |
360 'supported_on': [ | 360 'supported_on': [ |
361 {'platforms': ['mac', 'linux']}, {'platforms': ['aaa']} | 361 {'platforms': ['mac', 'linux']}, {'platforms': ['aaa']} |
362 ] | 362 ] |
363 })) | 363 })) |
364 | 364 |
| 365 def testStringEncodings(self): |
| 366 enum_policy_a = { |
| 367 'name': 'EnumPolicy.A', |
| 368 'type': 'string-enum', |
| 369 'caption': 'Enum policy A caption', |
| 370 'label': 'Enum policy A label', |
| 371 'desc': 'This is a test description.', |
| 372 'items': [ |
| 373 { |
| 374 'name': 'tls1.2', |
| 375 'value': 'tls1.2', |
| 376 'caption': 'tls1.2', |
| 377 } |
| 378 ], |
| 379 } |
| 380 enum_policy_b = { |
| 381 'name': 'EnumPolicy.B', |
| 382 'type': 'string-enum', |
| 383 'caption': 'Enum policy B caption', |
| 384 'label': 'Enum policy B 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 self. _InitWriterForAddingPolicies(self.writer, enum_policy_a) |
| 395 self.writer.WritePolicy(enum_policy_a) |
| 396 self.writer.WritePolicy(enum_policy_b) |
| 397 # Assert generated string elements. |
| 398 output = self.GetXMLOfChildren(self.writer._string_table_elem) |
| 399 expected_output = ( |
| 400 '<string id="EnumPolicy_A">Enum policy A caption</string>\n' |
| 401 '<string id="EnumPolicy_A_Explain">' |
| 402 'This is a test description.</string>\n' |
| 403 '<string id="tls1_2">tls1.2</string>\n' |
| 404 '<string id="EnumPolicy_B">Enum policy B caption</string>\n' |
| 405 '<string id="EnumPolicy_B_Explain">' |
| 406 'This is a test description.</string>\n') |
| 407 self.AssertXMLEquals(output, expected_output) |
| 408 # Assert generated presentation elements. |
| 409 output = self.GetXMLOfChildren(self.writer._presentation_table_elem) |
| 410 expected_output = ( |
| 411 '<presentation id="EnumPolicy.A">\n' |
| 412 ' <dropdownList refId="EnumPolicy.A">' |
| 413 'Enum policy A label</dropdownList>\n' |
| 414 '</presentation>\n' |
| 415 '<presentation id="EnumPolicy.B">\n' |
| 416 ' <dropdownList refId="EnumPolicy.B">' |
| 417 'Enum policy B label</dropdownList>\n' |
| 418 '</presentation>') |
| 419 self.AssertXMLEquals(output, expected_output) |
| 420 |
365 | 421 |
366 if __name__ == '__main__': | 422 if __name__ == '__main__': |
367 unittest.main() | 423 unittest.main() |
OLD | NEW |