def test_handle_type(self): handle_types = [ (mojom_types_mojom.HandleType.Kind.UNSPECIFIED, False, module.HANDLE), (mojom_types_mojom.HandleType.Kind.MESSAGE_PIPE, False, module.MSGPIPE), (mojom_types_mojom.HandleType.Kind.DATA_PIPE_CONSUMER, False, module.DCPIPE), (mojom_types_mojom.HandleType.Kind.DATA_PIPE_PRODUCER, False, module.DPPIPE), (mojom_types_mojom.HandleType.Kind.SHARED_BUFFER, False, module.SHAREDBUFFER), (mojom_types_mojom.HandleType.Kind.UNSPECIFIED, True, module.NULLABLE_HANDLE), (mojom_types_mojom.HandleType.Kind.MESSAGE_PIPE, True, module.NULLABLE_MSGPIPE), (mojom_types_mojom.HandleType.Kind.DATA_PIPE_CONSUMER, True, module.NULLABLE_DCPIPE), (mojom_types_mojom.HandleType.Kind.DATA_PIPE_PRODUCER, True, module.NULLABLE_DPPIPE), (mojom_types_mojom.HandleType.Kind.SHARED_BUFFER, True, module.NULLABLE_SHAREDBUFFER), ] g = mojom_files_mojom.MojomFileGraph() t = mojom_translator.FileTranslator(g, None) for mojom, nullable, golden in handle_types: h = mojom_types_mojom.Type() h.handle_type = mojom_types_mojom.HandleType(kind=mojom, nullable=nullable) self.assertEquals(golden, t.KindFromMojom(h))
def test_map_type(self): map_types = [ (False, False), (True, False), (False, True), (True, True), ] g = mojom_files_mojom.MojomFileGraph() t = mojom_translator.FileTranslator(g, None) for map_nullable, value_nullable in map_types: m = mojom_types_mojom.Type() m.map_type = mojom_types_mojom.MapType(nullable=map_nullable) m.map_type.key_type = mojom_types_mojom.Type( string_type=mojom_types_mojom.StringType()) m.map_type.value_type = mojom_types_mojom.Type( handle_type=mojom_types_mojom.HandleType( kind=mojom_types_mojom.HandleType.Kind.SHARED_BUFFER, nullable=value_nullable)) result = t.KindFromMojom(m) self.assertTrue(module.IsMapKind(result)) self.assertTrue(module.IsStringKind(result.key_kind)) self.assertTrue(module.IsSharedBufferKind(result.value_kind)) self.assertEquals(map_nullable, module.IsNullableKind(result)) self.assertEquals(value_nullable, module.IsNullableKind(result.value_kind))