OLD | NEW |
1 # Copyright 2014 The Chromium Authors. All rights reserved. | 1 # Copyright 2014 The Chromium Authors. All rights reserved. |
2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
4 | 4 |
5 import imp | 5 import imp |
6 import os.path | 6 import os.path |
7 import sys | 7 import sys |
8 import unittest | 8 import unittest |
9 | 9 |
10 def _GetDirAbove(dirname): | 10 def _GetDirAbove(dirname): |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
112 #TODO(azani): Init values in module.py. | 112 #TODO(azani): Init values in module.py. |
113 imported_module.values = {} | 113 imported_module.values = {} |
114 imported_data = {'module' : imported_module} | 114 imported_data = {'module' : imported_module} |
115 | 115 |
116 array = mojom.Array(mojom.INT16, length=20) | 116 array = mojom.Array(mojom.INT16, length=20) |
117 imported_module.kinds[array.spec] = array | 117 imported_module.kinds[array.spec] = array |
118 | 118 |
119 map_kind = mojom.Map(mojom.INT16, mojom.INT16) | 119 map_kind = mojom.Map(mojom.INT16, mojom.INT16) |
120 imported_module.kinds[map_kind.spec] = map_kind | 120 imported_module.kinds[map_kind.spec] = map_kind |
121 | 121 |
122 interface_req = mojom.InterfaceRequest(mojom.INT16) | 122 interface = mojom.Interface('TestInterface', module=module) |
| 123 imported_module.kinds[interface.spec] = interface |
| 124 |
| 125 interface_req = mojom.InterfaceRequest(interface) |
123 imported_module.kinds[interface_req.spec] = interface_req | 126 imported_module.kinds[interface_req.spec] = interface_req |
124 | 127 |
125 data.ImportFromData(module, imported_data) | 128 data.ImportFromData(module, imported_data) |
126 | 129 |
127 self.assertNotIn(array.spec, module.kinds) | 130 self.assertNotIn(array.spec, module.kinds) |
128 self.assertNotIn(map_kind.spec, module.kinds) | 131 self.assertNotIn(map_kind.spec, module.kinds) |
129 self.assertNotIn(interface_req.spec, module.kinds) | 132 self.assertNotIn(interface_req.spec, module.kinds) |
| 133 |
| 134 def testNonInterfaceAsInterfaceRequest(self): |
| 135 """Tests that a non-interface cannot be used for interface requests.""" |
| 136 module = mojom.Module('test_module', 'test_namespace') |
| 137 interface = mojom.Interface('TestInterface', module=module) |
| 138 method_dict = { |
| 139 'name': 'Foo', |
| 140 'parameters': [{'name': 'foo', 'kind': 'r:i32'}], |
| 141 } |
| 142 with self.assertRaises(Exception) as e: |
| 143 data.MethodFromData(module, method_dict, interface) |
| 144 self.assertEquals(e.exception.__str__(), |
| 145 'Interface request requires \'i32\' to be an interface.') |
OLD | NEW |