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 266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
277 '<string id="ListPolicyStubDesc">List policy caption</string>') | 277 '<string id="ListPolicyStubDesc">List policy caption</string>') |
278 self.AssertXMLEquals(output, expected_output) | 278 self.AssertXMLEquals(output, expected_output) |
279 # Assert generated presentation elements. | 279 # Assert generated presentation elements. |
280 output = self.GetXMLOfChildren(self.writer._presentation_table_elem) | 280 output = self.GetXMLOfChildren(self.writer._presentation_table_elem) |
281 expected_output = ( | 281 expected_output = ( |
282 '<presentation id="ListPolicyStub">\n' | 282 '<presentation id="ListPolicyStub">\n' |
283 ' <listBox refId="ListPolicyStubDesc">List policy label</listBox>\n' | 283 ' <listBox refId="ListPolicyStubDesc">List policy label</listBox>\n' |
284 '</presentation>') | 284 '</presentation>') |
285 self.AssertXMLEquals(output, expected_output) | 285 self.AssertXMLEquals(output, expected_output) |
286 | 286 |
| 287 def testStringEnumListPolicy(self): |
| 288 list_policy = { |
| 289 'name': 'ListPolicyStub', |
| 290 'type': 'string-enum-list', |
| 291 'caption': 'List policy caption', |
| 292 'label': 'List policy label', |
| 293 'desc': 'This is a test description.', |
| 294 'items': [ |
| 295 { |
| 296 'name': 'item 1', |
| 297 'value': 'value 1', |
| 298 'caption': 'Caption Item 1', |
| 299 }, |
| 300 { |
| 301 'name': 'item 2', |
| 302 'value': 'value 2', |
| 303 'caption': 'Caption Item 2', |
| 304 }, |
| 305 ], |
| 306 } |
| 307 self. _InitWriterForAddingPolicies(self.writer, list_policy) |
| 308 self.writer.WritePolicy(list_policy) |
| 309 # Assert generated string elements. |
| 310 output = self.GetXMLOfChildren(self.writer._string_table_elem) |
| 311 expected_output = ( |
| 312 '<string id="ListPolicyStub">List policy caption</string>\n' |
| 313 '<string id="ListPolicyStub_Explain">' |
| 314 'This is a test description.</string>\n' |
| 315 '<string id="ListPolicyStubDesc">List policy caption</string>') |
| 316 self.AssertXMLEquals(output, expected_output) |
| 317 # Assert generated presentation elements. |
| 318 output = self.GetXMLOfChildren(self.writer._presentation_table_elem) |
| 319 expected_output = ( |
| 320 '<presentation id="ListPolicyStub">\n' |
| 321 ' <listBox refId="ListPolicyStubDesc">List policy label</listBox>\n' |
| 322 '</presentation>') |
| 323 self.AssertXMLEquals(output, expected_output) |
| 324 |
287 def testDictionaryPolicy(self): | 325 def testDictionaryPolicy(self): |
288 dict_policy = { | 326 dict_policy = { |
289 'name': 'DictionaryPolicyStub', | 327 'name': 'DictionaryPolicyStub', |
290 'type': 'dict', | 328 'type': 'dict', |
291 'caption': 'Dictionary policy caption', | 329 'caption': 'Dictionary policy caption', |
292 'label': 'Dictionary policy label', | 330 'label': 'Dictionary policy label', |
293 'desc': 'This is a test description.', | 331 'desc': 'This is a test description.', |
294 } | 332 } |
295 self. _InitWriterForAddingPolicies(self.writer, dict_policy) | 333 self. _InitWriterForAddingPolicies(self.writer, dict_policy) |
296 self.writer.WritePolicy(dict_policy) | 334 self.writer.WritePolicy(dict_policy) |
(...skipping 23 matching lines...) Expand all Loading... |
320 })) | 358 })) |
321 self.assertFalse(self.writer.IsPolicySupported({ | 359 self.assertFalse(self.writer.IsPolicySupported({ |
322 'supported_on': [ | 360 'supported_on': [ |
323 {'platforms': ['mac', 'linux']}, {'platforms': ['aaa']} | 361 {'platforms': ['mac', 'linux']}, {'platforms': ['aaa']} |
324 ] | 362 ] |
325 })) | 363 })) |
326 | 364 |
327 | 365 |
328 if __name__ == '__main__': | 366 if __name__ == '__main__': |
329 unittest.main() | 367 unittest.main() |
OLD | NEW |