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 import os | 7 import os |
8 import sys | 8 import sys |
9 if __name__ == '__main__': | 9 if __name__ == '__main__': |
10 sys.path.append(os.path.join(os.path.dirname(__file__), '../../..')) | 10 sys.path.append(os.path.join(os.path.dirname(__file__), '../../..')) |
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
255 ] | 255 ] |
256 }] | 256 }] |
257 } | 257 } |
258 class LocalMockWriter(mock_writer.MockWriter): | 258 class LocalMockWriter(mock_writer.MockWriter): |
259 def WritePolicy(self, policy): | 259 def WritePolicy(self, policy): |
260 self.tester.assertEquals(policy['items'][0]['caption'], 'string1') | 260 self.tester.assertEquals(policy['items'][0]['caption'], 'string1') |
261 self.tester.assertEquals(policy['items'][1]['caption'], 'string2') | 261 self.tester.assertEquals(policy['items'][1]['caption'], 'string2') |
262 self.tester.assertEquals(policy['items'][2]['caption'], 'string3') | 262 self.tester.assertEquals(policy['items'][2]['caption'], 'string3') |
263 self.do_test(policy_data_mock, LocalMockWriter()) | 263 self.do_test(policy_data_mock, LocalMockWriter()) |
264 | 264 |
| 265 def testStringEnumTexts(self): |
| 266 # Test that GUI messages are assigned correctly to string-enums |
| 267 # (aka dropdown menus). |
| 268 policy_data_mock = { |
| 269 'policy_definitions': [{ |
| 270 'name': 'Policy1', |
| 271 'type': 'string-enum-list', |
| 272 'caption': '', 'desc': '', |
| 273 'supported_on': [], |
| 274 'items': [ |
| 275 {'name': 'item1', 'value': 'one', 'caption': 'string1', 'desc': ''}, |
| 276 {'name': 'item2', 'value': 'two', 'caption': 'string2', 'desc': ''}, |
| 277 {'name': 'item3', 'value': 'three', 'caption': 'string3', 'desc': ''}, |
| 278 ] |
| 279 }] |
| 280 } |
| 281 class LocalMockWriter(mock_writer.MockWriter): |
| 282 def WritePolicy(self, policy): |
| 283 self.tester.assertEquals(policy['items'][0]['caption'], 'string1') |
| 284 self.tester.assertEquals(policy['items'][1]['caption'], 'string2') |
| 285 self.tester.assertEquals(policy['items'][2]['caption'], 'string3') |
| 286 self.do_test(policy_data_mock, LocalMockWriter()) |
| 287 |
265 def testPolicyFiltering(self): | 288 def testPolicyFiltering(self): |
266 # Test that policies are filtered correctly based on their annotations. | 289 # Test that policies are filtered correctly based on their annotations. |
267 policy_data_mock = { | 290 policy_data_mock = { |
268 'policy_definitions': [ | 291 'policy_definitions': [ |
269 { | 292 { |
270 'name': 'Group1', | 293 'name': 'Group1', |
271 'type': 'group', | 294 'type': 'group', |
272 'caption': '', | 295 'caption': '', |
273 'desc': '', | 296 'desc': '', |
274 'policies': [ | 297 'policies': [ |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
363 self.result_list.append(policy['name']) | 386 self.result_list.append(policy['name']) |
364 def Test(self): | 387 def Test(self): |
365 self.tester.assertEquals( | 388 self.tester.assertEquals( |
366 self.result_list, | 389 self.result_list, |
367 ['ap', 'zp']) | 390 ['ap', 'zp']) |
368 self.do_test(policy_data, LocalMockWriter()) | 391 self.do_test(policy_data, LocalMockWriter()) |
369 | 392 |
370 | 393 |
371 if __name__ == '__main__': | 394 if __name__ == '__main__': |
372 unittest.main() | 395 unittest.main() |
OLD | NEW |