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 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 Loading... |
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, 'idl_basics.EnumType')) |
64 | 64 |
65 expected = [{'name':'type', '$ref':'idl_basics.EnumType'}, | 65 expected = [{'name':'type', '$ref':'idl_basics.EnumType'}, |
66 {'type':'function', 'name':'Callback5', | 66 {'type':'function', 'name':'Callback5', |
67 'parameters':[{'name':'type', '$ref':'idl_basics.EnumType'}]}] | 67 'parameters':[{'name':'type', '$ref':'idl_basics.EnumType'}]}] |
68 self.assertEquals(expected, getParams(schema, 'function13')) | 68 self.assertEquals(expected, getParams(schema, 'function13')) |
69 | 69 |
70 expected = [{'items': {'$ref': 'idl_basics.EnumType'}, 'name': 'types', | 70 expected = [{'items': {'$ref': 'idl_basics.EnumType'}, 'name': 'types', |
71 'type': 'array'}] | 71 'type': 'array'}] |
72 self.assertEquals(expected, getParams(schema, 'function14')) | 72 self.assertEquals(expected, getParams(schema, 'function14')) |
73 | 73 |
74 def testNoCompile(self): | 74 def testNoCompile(self): |
75 schema = self.idl_basics | 75 schema = self.idl_basics |
76 func = getFunction(schema, 'function15') | 76 func = getFunction(schema, 'function15') |
77 self.assertTrue(func is not None) | 77 self.assertTrue(func is not None) |
78 self.assertTrue(func['nocompile']) | 78 self.assertTrue(func['nocompile']) |
79 | 79 |
80 if __name__ == '__main__': | 80 if __name__ == '__main__': |
81 unittest.main() | 81 unittest.main() |
OLD | NEW |