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

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

Issue 9617010: Move chrome.downloads out of experimental to dev (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: comments Created 8 years, 6 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 | Annotate | Revision Log
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 def getFunction(schema, name): 9 def getFunction(schema, name):
10 for item in schema['functions']: 10 for item in schema['functions']:
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
51 51
52 def testArrayOfCallbacks(self): 52 def testArrayOfCallbacks(self):
53 schema = idl_schema.Load('test/idl_callback_arrays.idl')[0] 53 schema = idl_schema.Load('test/idl_callback_arrays.idl')[0]
54 expected = [{'type':'array', 'name':'callbacks', 54 expected = [{'type':'array', 'name':'callbacks',
55 'items':{'type':'function', 'name':'MyCallback', 55 'items':{'type':'function', 'name':'MyCallback',
56 'parameters':[{'type':'integer', 'name':'x'}]}}] 56 'parameters':[{'type':'integer', 'name':'x'}]}}]
57 self.assertEquals(expected, getParams(schema, 'whatever')) 57 self.assertEquals(expected, getParams(schema, 'whatever'))
58 58
59 def testEnum(self): 59 def testEnum(self):
60 schema = self.idl_basics 60 schema = self.idl_basics
61 expected = {'enum': ['name1', 'name2'], 61 expected = {'enum': ['name1', 'name2'], 'description': 'Enum description',
62 'type': 'string', 'id': 'idl_basics.EnumType'} 62 'type': 'string', 'id': 'idl_basics.EnumType'}
63 self.assertEquals(expected, getType(schema, 'idl_basics.EnumType')) 63 self.assertEquals(expected, getType(schema, expected['id']))
64
65 expected = {'enum': [0, 42], 'description': 'IntegerEnum description',
66 'type': 'integer', 'id': 'idl_basics.IntegerEnumType'}
67 self.assertEquals(expected, getType(schema, expected['id']))
68
69 expected = {'enum': [3.14159265, 6.0221415e23, 6.626068e-34],
70 'description': 'DoubleEnumType description',
71 'type': 'double', 'id': 'idl_basics.DoubleEnumType'}
72 self.assertEquals(expected, getType(schema, expected['id']))
64 73
65 expected = [{'name':'type', '$ref':'idl_basics.EnumType'}, 74 expected = [{'name':'type', '$ref':'idl_basics.EnumType'},
66 {'type':'function', 'name':'Callback5', 75 {'type':'function', 'name':'Callback5',
67 'parameters':[{'name':'type', '$ref':'idl_basics.EnumType'}]}] 76 'parameters':[{'name':'type', '$ref':'idl_basics.EnumType'}]}]
68 self.assertEquals(expected, getParams(schema, 'function13')) 77 self.assertEquals(expected, getParams(schema, 'function13'))
69 78
70 expected = [{'items': {'$ref': 'idl_basics.EnumType'}, 'name': 'types', 79 expected = [{'items': {'$ref': 'idl_basics.EnumType'}, 'name': 'types',
71 'type': 'array'}] 80 'type': 'array'}]
72 self.assertEquals(expected, getParams(schema, 'function14')) 81 self.assertEquals(expected, getParams(schema, 'function14'))
73 82
74 def testNoCompile(self): 83 def testNoCompile(self):
75 schema = self.idl_basics 84 schema = self.idl_basics
76 func = getFunction(schema, 'function15') 85 func = getFunction(schema, 'function15')
77 self.assertTrue(func is not None) 86 self.assertTrue(func is not None)
78 self.assertTrue(func['nocompile']) 87 self.assertTrue(func['nocompile'])
79 88
80 if __name__ == '__main__': 89 if __name__ == '__main__':
81 unittest.main() 90 unittest.main()
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698