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 import idl_schema | 6 import idl_schema |
7 import unittest | 7 import unittest |
8 | 8 |
9 from json_parse import OrderedDict | 9 from json_parse import OrderedDict |
10 | 10 |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
63 def testArrayOfCallbacks(self): | 63 def testArrayOfCallbacks(self): |
64 schema = idl_schema.Load('test/idl_function_types.idl')[0] | 64 schema = idl_schema.Load('test/idl_function_types.idl')[0] |
65 expected = [{'type': 'array', 'name': 'callbacks', | 65 expected = [{'type': 'array', 'name': 'callbacks', |
66 'items':{'type': 'function', 'name': 'MyCallback', | 66 'items':{'type': 'function', 'name': 'MyCallback', |
67 'parameters':[{'type': 'integer', 'name': 'x'}]}}] | 67 'parameters':[{'type': 'integer', 'name': 'x'}]}}] |
68 self.assertEquals(expected, getParams(schema, 'whatever')) | 68 self.assertEquals(expected, getParams(schema, 'whatever')) |
69 | 69 |
70 def testLegalValues(self): | 70 def testLegalValues(self): |
71 self.assertEquals({ | 71 self.assertEquals({ |
72 'x': {'name': 'x', 'type': 'integer', 'enum': [1,2], | 72 'x': {'name': 'x', 'type': 'integer', 'enum': [1,2], |
73 'description': 'This comment tests "double-quotes".'}, | 73 'description': 'This comment tests "double-quotes".', |
| 74 'jsexterns': None}, |
74 'y': {'name': 'y', 'type': 'string'}, | 75 'y': {'name': 'y', 'type': 'string'}, |
75 'z': {'name': 'z', 'type': 'string'}, | 76 'z': {'name': 'z', 'type': 'string'}, |
76 'a': {'name': 'a', 'type': 'string'}, | 77 'a': {'name': 'a', 'type': 'string'}, |
77 'b': {'name': 'b', 'type': 'string'}, | 78 'b': {'name': 'b', 'type': 'string'}, |
78 'c': {'name': 'c', 'type': 'string'}}, | 79 'c': {'name': 'c', 'type': 'string'}}, |
79 getType(self.idl_basics, 'MyType1')['properties']) | 80 getType(self.idl_basics, 'MyType1')['properties']) |
80 | 81 |
81 def testMemberOrdering(self): | 82 def testMemberOrdering(self): |
82 self.assertEquals( | 83 self.assertEquals( |
83 ['x', 'y', 'z', 'a', 'b', 'c'], | 84 ['x', 'y', 'z', 'a', 'b', 'c'], |
(...skipping 311 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
395 }] | 396 }] |
396 }] | 397 }] |
397 | 398 |
398 self.assertEquals(expected, badabish_params) | 399 self.assertEquals(expected, badabish_params) |
399 | 400 |
400 def testProperties(self): | 401 def testProperties(self): |
401 schema = idl_schema.Load('test/idl_properties.idl')[0] | 402 schema = idl_schema.Load('test/idl_properties.idl')[0] |
402 self.assertEquals(OrderedDict([ | 403 self.assertEquals(OrderedDict([ |
403 ('first', OrderedDict([ | 404 ('first', OrderedDict([ |
404 ('description', 'Integer property.'), | 405 ('description', 'Integer property.'), |
| 406 ('jsexterns', None), |
405 ('type', 'integer'), | 407 ('type', 'integer'), |
406 ('value', 42), | 408 ('value', 42), |
407 ])), | 409 ])), |
408 ('second', OrderedDict([ | 410 ('second', OrderedDict([ |
409 ('description', 'Double property.'), | 411 ('description', 'Double property.'), |
| 412 ('jsexterns', None), |
410 ('type', 'number'), | 413 ('type', 'number'), |
411 ('value', 42.0), | 414 ('value', 42.0), |
412 ])), | 415 ])), |
413 ('third', OrderedDict([ | 416 ('third', OrderedDict([ |
414 ('description', 'String property.'), | 417 ('description', 'String property.'), |
| 418 ('jsexterns', None), |
415 ('type', 'string'), | 419 ('type', 'string'), |
416 ('value', 'hello world'), | 420 ('value', 'hello world'), |
417 ])), | 421 ])), |
418 ('fourth', OrderedDict([ | 422 ('fourth', OrderedDict([ |
419 ('description', 'Unvalued property.'), | 423 ('description', 'Unvalued property.'), |
| 424 ('jsexterns', None), |
420 ('type', 'integer'), | 425 ('type', 'integer'), |
421 ])), | 426 ])), |
422 ]), schema.get('properties')) | 427 ]), schema.get('properties')) |
423 | 428 |
424 | 429 |
425 if __name__ == '__main__': | 430 if __name__ == '__main__': |
426 unittest.main() | 431 unittest.main() |
OLD | NEW |