Chromium Code Reviews| 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 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 93 | 93 |
| 94 expected = [{'name':'type', '$ref':'EnumType'}, | 94 expected = [{'name':'type', '$ref':'EnumType'}, |
| 95 {'type':'function', 'name':'cb', | 95 {'type':'function', 'name':'cb', |
| 96 'parameters':[{'name':'type', '$ref':'EnumType'}]}] | 96 'parameters':[{'name':'type', '$ref':'EnumType'}]}] |
| 97 self.assertEquals(expected, getParams(schema, 'function13')) | 97 self.assertEquals(expected, getParams(schema, 'function13')) |
| 98 | 98 |
| 99 expected = [{'items': {'$ref': 'EnumType'}, 'name': 'types', | 99 expected = [{'items': {'$ref': 'EnumType'}, 'name': 'types', |
| 100 'type': 'array'}] | 100 'type': 'array'}] |
| 101 self.assertEquals(expected, getParams(schema, 'function14')) | 101 self.assertEquals(expected, getParams(schema, 'function14')) |
| 102 | 102 |
| 103 def testScopedArguments(self): | |
| 104 schema = self.idl_basics | |
| 105 expected = [{'name':'value', '$ref':'other_namespace.SomeType'}] | |
|
not at google - send to devlin
2014/03/17 14:00:29
nit: spaces after the : (this file is oddly incons
mtomasz
2014/03/28 04:48:31
Done.
| |
| 106 self.assertEquals(expected, getParams(schema, 'function20')) | |
| 107 | |
| 108 expected = [{'items': {'$ref': 'other_namespace.SomeType'}, | |
| 109 'name': 'values', | |
| 110 'type': 'array'}] | |
| 111 self.assertEquals(expected, getParams(schema, 'function21')) | |
| 112 | |
| 113 expected = [{'name':'value', | |
| 114 '$ref':'other_namespace.sub_namespace.SomeType'}] | |
| 115 self.assertEquals(expected, getParams(schema, 'function22')) | |
| 116 | |
| 117 expected = [{'items': {'$ref': 'other_namespace.sub_namespace.SomeType'}, | |
| 118 'name': 'values', | |
| 119 'type': 'array'}] | |
| 120 self.assertEquals(expected, getParams(schema, 'function23')) | |
| 121 | |
| 103 def testNoCompile(self): | 122 def testNoCompile(self): |
| 104 schema = self.idl_basics | 123 schema = self.idl_basics |
| 105 func = getFunction(schema, 'function15') | 124 func = getFunction(schema, 'function15') |
| 106 self.assertTrue(func is not None) | 125 self.assertTrue(func is not None) |
| 107 self.assertTrue(func['nocompile']) | 126 self.assertTrue(func['nocompile']) |
| 108 | 127 |
| 109 def testNoDocOnEnum(self): | 128 def testNoDocOnEnum(self): |
| 110 schema = self.idl_basics | 129 schema = self.idl_basics |
| 111 enum_with_nodoc = getType(schema, 'EnumTypeWithNoDoc') | 130 enum_with_nodoc = getType(schema, 'EnumTypeWithNoDoc') |
| 112 self.assertTrue(enum_with_nodoc is not None) | 131 self.assertTrue(enum_with_nodoc is not None) |
| 113 self.assertTrue(enum_with_nodoc['nodoc']) | 132 self.assertTrue(enum_with_nodoc['nodoc']) |
| 114 | 133 |
| 115 def testInternalNamespace(self): | 134 def testInternalNamespace(self): |
| 116 idl_basics = self.idl_basics | 135 idl_basics = self.idl_basics |
| 117 self.assertEquals('idl_basics', idl_basics['namespace']) | 136 self.assertEquals('idl_basics', idl_basics['namespace']) |
| 118 self.assertTrue(idl_basics['internal']) | 137 self.assertTrue(idl_basics['internal']) |
| 119 self.assertFalse(idl_basics['nodoc']) | 138 self.assertFalse(idl_basics['nodoc']) |
| 120 | 139 |
| 121 def testReturnTypes(self): | 140 def testReturnTypes(self): |
| 122 schema = self.idl_basics | 141 schema = self.idl_basics |
| 123 self.assertEquals({'name': 'function19', 'type': 'integer'}, | 142 self.assertEquals({'name': 'function24', 'type': 'integer'}, |
| 124 getReturns(schema, 'function19')) | 143 getReturns(schema, 'function24')) |
| 125 self.assertEquals({'name': 'function20', '$ref': 'MyType1', | 144 self.assertEquals({'name': 'function25', '$ref': 'MyType1', |
| 126 'optional': True}, | 145 'optional': True}, |
| 127 getReturns(schema, 'function20')) | 146 getReturns(schema, 'function25')) |
| 128 self.assertEquals({'name': 'function21', 'type': 'array', | 147 self.assertEquals({'name': 'function26', 'type': 'array', |
| 129 'items': {'$ref': 'MyType1'}}, | 148 'items': {'$ref': 'MyType1'}}, |
| 130 getReturns(schema, 'function21')) | 149 getReturns(schema, 'function26')) |
| 131 self.assertEquals({'name': 'function22', '$ref': 'EnumType', | 150 self.assertEquals({'name': 'function27', '$ref': 'EnumType', |
| 132 'optional': True}, | 151 'optional': True}, |
| 133 getReturns(schema, 'function22')) | 152 getReturns(schema, 'function27')) |
| 134 self.assertEquals({'name': 'function23', 'type': 'array', | 153 self.assertEquals({'name': 'function28', 'type': 'array', |
| 135 'items': {'$ref': 'EnumType'}}, | 154 'items': {'$ref': 'EnumType'}}, |
| 136 getReturns(schema, 'function23')) | 155 getReturns(schema, 'function28')) |
| 156 self.assertEquals({'name': 'function29', '$ref': 'other_namespace.SomeType', | |
| 157 'optional': True}, | |
| 158 getReturns(schema, 'function29')) | |
| 159 self.assertEquals({'name': 'function30', 'type': 'array', | |
| 160 'items': {'$ref': 'other_namespace.SomeType'}}, | |
| 161 getReturns(schema, 'function30')) | |
| 137 | 162 |
| 138 def testChromeOSPlatformsNamespace(self): | 163 def testChromeOSPlatformsNamespace(self): |
| 139 schema = idl_schema.Load('test/idl_namespace_chromeos.idl')[0] | 164 schema = idl_schema.Load('test/idl_namespace_chromeos.idl')[0] |
| 140 self.assertEquals('idl_namespace_chromeos', schema['namespace']) | 165 self.assertEquals('idl_namespace_chromeos', schema['namespace']) |
| 141 expected = ['chromeos'] | 166 expected = ['chromeos'] |
| 142 self.assertEquals(expected, schema['platforms']) | 167 self.assertEquals(expected, schema['platforms']) |
| 143 | 168 |
| 144 def testAllPlatformsNamespace(self): | 169 def testAllPlatformsNamespace(self): |
| 145 schema = idl_schema.Load('test/idl_namespace_all_platforms.idl')[0] | 170 schema = idl_schema.Load('test/idl_namespace_all_platforms.idl')[0] |
| 146 self.assertEquals('idl_namespace_all_platforms', schema['namespace']) | 171 self.assertEquals('idl_namespace_all_platforms', schema['namespace']) |
| (...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 359 {'type': 'string'} | 384 {'type': 'string'} |
| 360 ] | 385 ] |
| 361 }] | 386 }] |
| 362 }] | 387 }] |
| 363 | 388 |
| 364 self.assertEquals(expected, badabish_params) | 389 self.assertEquals(expected, badabish_params) |
| 365 | 390 |
| 366 | 391 |
| 367 if __name__ == '__main__': | 392 if __name__ == '__main__': |
| 368 unittest.main() | 393 unittest.main() |
| OLD | NEW |