Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(100)

Side by Side Diff: tools/json_schema_compiler/idl_schema_test.py

Issue 2650733002: Revert of Update json_schema_compiler to handle the Automation extension API (Closed)
Patch Set: Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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},
75 'y': {'name': 'y', 'type': 'string'}, 74 'y': {'name': 'y', 'type': 'string'},
76 'z': {'name': 'z', 'type': 'string'}, 75 'z': {'name': 'z', 'type': 'string'},
77 'a': {'name': 'a', 'type': 'string'}, 76 'a': {'name': 'a', 'type': 'string'},
78 'b': {'name': 'b', 'type': 'string'}, 77 'b': {'name': 'b', 'type': 'string'},
79 'c': {'name': 'c', 'type': 'string'}}, 78 'c': {'name': 'c', 'type': 'string'}},
80 getType(self.idl_basics, 'MyType1')['properties']) 79 getType(self.idl_basics, 'MyType1')['properties'])
81 80
82 def testMemberOrdering(self): 81 def testMemberOrdering(self):
83 self.assertEquals( 82 self.assertEquals(
84 ['x', 'y', 'z', 'a', 'b', 'c'], 83 ['x', 'y', 'z', 'a', 'b', 'c'],
(...skipping 311 matching lines...) Expand 10 before | Expand all | Expand 10 after
396 }] 395 }]
397 }] 396 }]
398 397
399 self.assertEquals(expected, badabish_params) 398 self.assertEquals(expected, badabish_params)
400 399
401 def testProperties(self): 400 def testProperties(self):
402 schema = idl_schema.Load('test/idl_properties.idl')[0] 401 schema = idl_schema.Load('test/idl_properties.idl')[0]
403 self.assertEquals(OrderedDict([ 402 self.assertEquals(OrderedDict([
404 ('first', OrderedDict([ 403 ('first', OrderedDict([
405 ('description', 'Integer property.'), 404 ('description', 'Integer property.'),
406 ('jsexterns', None),
407 ('type', 'integer'), 405 ('type', 'integer'),
408 ('value', 42), 406 ('value', 42),
409 ])), 407 ])),
410 ('second', OrderedDict([ 408 ('second', OrderedDict([
411 ('description', 'Double property.'), 409 ('description', 'Double property.'),
412 ('jsexterns', None),
413 ('type', 'number'), 410 ('type', 'number'),
414 ('value', 42.0), 411 ('value', 42.0),
415 ])), 412 ])),
416 ('third', OrderedDict([ 413 ('third', OrderedDict([
417 ('description', 'String property.'), 414 ('description', 'String property.'),
418 ('jsexterns', None),
419 ('type', 'string'), 415 ('type', 'string'),
420 ('value', 'hello world'), 416 ('value', 'hello world'),
421 ])), 417 ])),
422 ('fourth', OrderedDict([ 418 ('fourth', OrderedDict([
423 ('description', 'Unvalued property.'), 419 ('description', 'Unvalued property.'),
424 ('jsexterns', None),
425 ('type', 'integer'), 420 ('type', 'integer'),
426 ])), 421 ])),
427 ]), schema.get('properties')) 422 ]), schema.get('properties'))
428 423
429 424
430 if __name__ == '__main__': 425 if __name__ == '__main__':
431 unittest.main() 426 unittest.main()
OLDNEW
« no previous file with comments | « tools/json_schema_compiler/idl_schema.py ('k') | tools/json_schema_compiler/js_externs_generator.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698