def test_set_inheritance(self): helper = IdlTestingHelper() builder = InterfaceContextBuilder( 'test', TypeResolver( helper.make_stub_interfaces_info({ 'foo': 'path_to_foo', }))) builder.set_inheritance('foo') self.assertEqual( { 'base_class': 'foo', 'code_generator': 'test', 'header_includes': set(['path_to_foo']), }, builder.build()) builder = InterfaceContextBuilder('test', TypeResolver({})) builder.set_inheritance(None) self.assertEqual( { 'code_generator': 'test', 'header_includes': set(['third_party/blink/renderer/platform/heap/handle.h']), }, builder.build())
def test_add_attribute(self): helper = IdlTestingHelper() builder = InterfaceContextBuilder( 'test', TypeResolver(helper.make_stub_interfaces_info({ 'foo': 'path_to_foo', 'bar': 'path_to_bar' }))) attribute = helper.make_stub_idl_attribute('foo', 'bar') builder.add_attribute(attribute) self.assertEqual({ 'code_generator': 'test', 'cpp_includes': set(['path_to_bar']), 'attributes': [{'name': 'foo', 'type': 'bar'}], }, builder.build())
def test_set_name(self): helper = IdlTestingHelper() builder = InterfaceContextBuilder( 'test', TypeResolver(helper.make_stub_interfaces_info({ 'foo': 'path_to_foo', }))) builder.set_class_name('foo') self.assertEqual({ 'code_generator': 'test', 'cpp_includes': set(['path_to_foo']), 'class_name': { 'snake_case': 'foo', 'macro_case': 'FOO', 'upper_camel_case': 'Foo' }, }, builder.build())
def test_set_name(self): helper = IdlTestingHelper() builder = InterfaceContextBuilder( 'test', TypeResolver( helper.make_stub_interfaces_info({ 'foo': 'path_to_foo', }))) builder.set_class_name('foo') self.assertEqual( { 'code_generator': 'test', 'cpp_includes': set(['path_to_foo']), 'class_name': { 'snake_case': 'foo', 'macro_case': 'FOO', 'upper_camel_case': 'Foo' }, }, builder.build())
def test_add_attribute(self): helper = IdlTestingHelper() builder = InterfaceContextBuilder( 'test', TypeResolver( helper.make_stub_interfaces_info({ 'foo': 'path_to_foo', 'bar': 'path_to_bar' }))) attribute = helper.make_stub_idl_attribute('foo', 'bar') builder.add_attribute(attribute) self.assertEqual( { 'code_generator': 'test', 'cpp_includes': set(['path_to_bar']), 'attributes': [{ 'name': 'foo', 'type': 'bar' }], }, builder.build())
def test_add_method(self): helper = IdlTestingHelper() builder = InterfaceContextBuilder( 'test', TypeResolver( helper.make_stub_interfaces_info({ 'foo': 'path_to_foo', 'bar': 'path_to_bar' }))) operation = helper.make_stub_idl_operation('foo', 'bar') builder.add_operation(operation) self.assertEqual( { 'code_generator': 'test', 'cpp_includes': set(['path_to_bar']), 'methods': [{ 'name': 'foo', 'return_type': 'bar' }], }, builder.build())
def test_add_method(self): helper = IdlTestingHelper() builder = InterfaceContextBuilder( 'test', TypeResolver( helper.make_stub_interfaces_info({ 'foo': 'path_to_foo', 'bar': 'path_to_bar', 'garply': 'path_to_garply', }))) operation = helper.make_stub_idl_operation('foo', 'bar') builder.add_operation(operation) self.assertEqual( { 'code_generator': 'test', 'cpp_includes': set(['path_to_bar']), 'methods': [{ 'arguments': [], 'name': 'Foo', 'type': 'bar' }], }, builder.build()) operation = helper.make_stub_idl_operation('quux', 'garply') operation.arguments = [ helper.make_stub_idl_argument('barBaz', IdlType('qux')) ] builder.add_operation(operation) self.assertEqual( { 'code_generator': 'test', 'cpp_includes': set(['path_to_bar', 'path_to_garply']), 'methods': [{ 'arguments': [], 'name': 'Foo', 'type': 'bar' }, { 'arguments': [{ 'name': 'bar_baz', 'type': 'qux' }], 'name': 'Quux', 'type': 'garply' }], }, builder.build())
def test_set_inheritance(self): helper = IdlTestingHelper() builder = InterfaceContextBuilder( 'test', TypeResolver(helper.make_stub_interfaces_info({ 'foo': 'path_to_foo', }))) builder.set_inheritance('foo') self.assertEqual({ 'base_class': 'foo', 'code_generator': 'test', 'header_includes': set(['path_to_foo']), }, builder.build()) builder = InterfaceContextBuilder('test', TypeResolver({})) builder.set_inheritance(None) self.assertEqual({ 'code_generator': 'test', 'header_includes': set(['platform/heap/Handle.h']), }, builder.build())
def test_add_method(self): helper = IdlTestingHelper() builder = InterfaceContextBuilder( 'test', TypeResolver(helper.make_stub_interfaces_info({ 'foo': 'path_to_foo', 'bar': 'path_to_bar', 'garply': 'path_to_garply', }))) operation = helper.make_stub_idl_operation('foo', 'bar') builder.add_operation(operation) self.assertEqual({ 'code_generator': 'test', 'cpp_includes': set(['path_to_bar']), 'methods': [{ 'arguments': [], 'name': 'Foo', 'type': 'bar' }], }, builder.build()) operation = helper.make_stub_idl_operation('quux', 'garply') operation.arguments = [ helper.make_stub_idl_argument('barBaz', IdlType('qux')) ] builder.add_operation(operation) self.assertEqual({ 'code_generator': 'test', 'cpp_includes': set(['path_to_bar', 'path_to_garply']), 'methods': [ { 'arguments': [], 'name': 'Foo', 'type': 'bar' }, { 'arguments': [ {'name': 'bar_baz', 'type': 'qux'} ], 'name': 'Quux', 'type': 'garply' } ], }, builder.build())
def test_empty(self): builder = InterfaceContextBuilder('test', TypeResolver({})) self.assertEqual({'code_generator': 'test'}, builder.build())
def test_empty(self): builder = InterfaceContextBuilder('test', TypeResolver({})) self.assertEqual({'code_generator': 'test'}, builder.build())