| |
| // @dart = 2.8 |
| |
| // Ignore unused imports so that GIDL tests can be commented out without error. |
| // ignore_for_file: unused_import |
| |
| import 'dart:typed_data'; |
| |
| import 'package:fidl/fidl.dart' as fidl; |
| import 'package:fidl_conformance/fidl_async.dart'; |
| import 'package:test/test.dart'; |
| import 'package:topaz.lib.gidl/gidl.dart'; |
| import 'package:topaz.lib.gidl/handles.dart'; |
| import 'package:zircon/zircon.dart'; |
| |
| void main() { |
| group('conformance', () { |
| group('encode success cases', () { |
| |
| EncodeSuccessCase.run( |
| Encoders.v1, |
| 'GoldenBoolStruct_v1', |
| GoldenBoolStruct(v: true), |
| kGoldenBoolStruct_Type, |
| Uint8List.fromList([ |
| 0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00, // |
| ])); |
| |
| EncodeSuccessCase.run( |
| Encoders.v1, |
| 'GoldenIntStruct_v1', |
| GoldenIntStruct(v: 0x1), |
| kGoldenIntStruct_Type, |
| Uint8List.fromList([ |
| 0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00, // |
| ])); |
| |
| EncodeSuccessCase.run( |
| Encoders.v1, |
| 'GoldenUintStruct_v1', |
| GoldenUintStruct(v: 0x1), |
| kGoldenUintStruct_Type, |
| Uint8List.fromList([ |
| 0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00, // |
| ])); |
| |
| EncodeSuccessCase.run( |
| Encoders.v1, |
| 'GoldenFloatStruct_v1', |
| GoldenFloatStruct(v: 0), |
| kGoldenFloatStruct_Type, |
| Uint8List.fromList([ |
| 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, // |
| ])); |
| |
| EncodeSuccessCase.run( |
| Encoders.v1, |
| 'GoldenDoubleStruct_v1', |
| GoldenDoubleStruct(v: 0), |
| kGoldenDoubleStruct_Type, |
| Uint8List.fromList([ |
| 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, // |
| ])); |
| |
| EncodeSuccessCase.run( |
| Encoders.v1, |
| 'GoldenStringStruct_v1', |
| GoldenStringStruct(v: 'abcd'), |
| kGoldenStringStruct_Type, |
| Uint8List.fromList([ |
| 0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00, // |
| 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, // |
| 0x61,0x62,0x63,0x64,0x00,0x00,0x00,0x00, // |
| ])); |
| |
| EncodeSuccessCase.run( |
| Encoders.v1, |
| 'GoldenNullableStringStructNonNull_v1', |
| GoldenNullableStringStruct(v: 'abcd'), |
| kGoldenNullableStringStruct_Type, |
| Uint8List.fromList([ |
| 0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00, // |
| 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, // |
| 0x61,0x62,0x63,0x64,0x00,0x00,0x00,0x00, // |
| ])); |
| |
| EncodeSuccessCase.run( |
| Encoders.v1, |
| 'GoldenNullableStringStructNull_v1', |
| GoldenNullableStringStruct(v: null), |
| kGoldenNullableStringStruct_Type, |
| Uint8List.fromList([ |
| 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, // |
| 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, // |
| ])); |
| |
| EncodeSuccessCase.run( |
| Encoders.v1, |
| 'GoldenEnumStruct_v1', |
| GoldenEnumStruct(v: kGoldenEnum_Type.ctor(0x1)), |
| kGoldenEnumStruct_Type, |
| Uint8List.fromList([ |
| 0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00, // |
| ])); |
| |
| EncodeSuccessCase.run( |
| Encoders.v1, |
| 'GoldenBitsStruct_v1', |
| GoldenBitsStruct(v: kGoldenBits_Type.ctor(0x1)), |
| kGoldenBitsStruct_Type, |
| Uint8List.fromList([ |
| 0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00, // |
| ])); |
| |
| EncodeSuccessCase.run( |
| Encoders.v1, |
| 'GoldenTableStruct_v1', |
| GoldenTableStruct(v: GoldenTable(v: 0x1)), |
| kGoldenTableStruct_Type, |
| Uint8List.fromList([ |
| 0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00, // |
| 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, // |
| 0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x00, // |
| 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, // |
| 0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00, // |
| ])); |
| |
| EncodeSuccessCase.run( |
| Encoders.v1, |
| 'GoldenUnionStruct_v1', |
| GoldenUnionStruct(v: GoldenUnion.withV(0x1)), |
| kGoldenUnionStruct_Type, |
| Uint8List.fromList([ |
| 0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00, // |
| 0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x00, // |
| 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, // |
| 0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00, // |
| ])); |
| |
| EncodeSuccessCase.run( |
| Encoders.v1, |
| 'GoldenNullableUnionStructNonNull_v1', |
| GoldenNullableUnionStruct(v: GoldenUnion.withV(0x1)), |
| kGoldenNullableUnionStruct_Type, |
| Uint8List.fromList([ |
| 0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00, // |
| 0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x00, // |
| 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, // |
| 0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00, // |
| ])); |
| |
| EncodeSuccessCase.run( |
| Encoders.v1, |
| 'GoldenNullableUnionStructNull_v1', |
| GoldenNullableUnionStruct(v: null), |
| kGoldenNullableUnionStruct_Type, |
| Uint8List.fromList([ |
| 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, // |
| 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, // |
| 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, // |
| ])); |
| |
| EncodeSuccessCase.run( |
| Encoders.v1, |
| 'GoldenByteArrayStruct_v1', |
| GoldenByteArrayStruct(v: Uint8List.fromList([0x1, 0x2, 0x3, 0x4])), |
| kGoldenByteArrayStruct_Type, |
| Uint8List.fromList([ |
| 0x01,0x02,0x03,0x04,0x00,0x00,0x00,0x00, // |
| ])); |
| |
| EncodeSuccessCase.run( |
| Encoders.v1, |
| 'GoldenStructArrayStruct_v1', |
| GoldenStructArrayStruct(v: [GoldenIntStruct(v: 0x1), GoldenIntStruct(v: 0x2)]), |
| kGoldenStructArrayStruct_Type, |
| Uint8List.fromList([ |
| 0x01,0x00,0x02,0x00,0x00,0x00,0x00,0x00, // |
| ])); |
| |
| EncodeSuccessCase.run( |
| Encoders.v1, |
| 'GoldenByteVectorStruct_v1', |
| GoldenByteVectorStruct(v: Uint8List.fromList([0x1, 0x2, 0x3, 0x4, 0x1, 0x2, 0x3, 0x4, 0x1, 0x2, 0x3, 0x4])), |
| kGoldenByteVectorStruct_Type, |
| Uint8List.fromList([ |
| 0x0c,0x00,0x00,0x00,0x00,0x00,0x00,0x00, // |
| 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, // |
| 0x01,0x02,0x03,0x04,0x01,0x02,0x03,0x04, // |
| 0x01,0x02,0x03,0x04,0x00,0x00,0x00,0x00, // |
| ])); |
| |
| EncodeSuccessCase.run( |
| Encoders.v1, |
| 'GoldenByteNullableVectorStructNonNull_v1', |
| GoldenNullableByteVectorStruct(v: Uint8List.fromList([0x1, 0x2, 0x3, 0x4])), |
| kGoldenNullableByteVectorStruct_Type, |
| Uint8List.fromList([ |
| 0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00, // |
| 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, // |
| 0x01,0x02,0x03,0x04,0x00,0x00,0x00,0x00, // |
| ])); |
| |
| EncodeSuccessCase.run( |
| Encoders.v1, |
| 'GoldenNullableByteVectorStructNull_v1', |
| GoldenNullableByteVectorStruct(v: null), |
| kGoldenNullableByteVectorStruct_Type, |
| Uint8List.fromList([ |
| 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, // |
| 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, // |
| ])); |
| |
| EncodeSuccessCase.run( |
| Encoders.v1, |
| 'GoldenStructVectorStruct_v1', |
| GoldenStructVectorStruct(v: [GoldenIntStruct(v: 0x1), GoldenIntStruct(v: 0x2)]), |
| kGoldenStructVectorStruct_Type, |
| Uint8List.fromList([ |
| 0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00, // |
| 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, // |
| 0x01,0x00,0x02,0x00,0x00,0x00,0x00,0x00, // |
| ])); |
| |
| EncodeSuccessCase.run( |
| Encoders.v1, |
| 'GoldenNullableStructNonNull_v1', |
| GoldenNullableStruct(v: GoldenBoolStruct(v: true)), |
| kGoldenNullableStruct_Type, |
| Uint8List.fromList([ |
| 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, // |
| 0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00, // |
| ])); |
| |
| EncodeSuccessCase.run( |
| Encoders.v1, |
| 'GoldenNullableStructNull_v1', |
| GoldenNullableStruct(v: null), |
| kGoldenNullableStruct_Type, |
| Uint8List.fromList([ |
| 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, // |
| ])); |
| |
| EncodeSuccessCase.runWithHandles( |
| Encoders.v1, |
| 'GoldenHandleBasicRightsStruct_v1', |
| (List<Handle> handles) => GoldenHandleBasicRightsStruct(v: handles[0]), |
| kGoldenHandleBasicRightsStruct_Type, |
| Uint8List.fromList([ |
| 0xff,0xff,0xff,0xff,0x00,0x00,0x00,0x00, // |
| ]), |
| [ |
| HandleDef(HandleSubtype.channel, 61454),// #0 |
| ], |
| [ |
| 0,]); |
| |
| EncodeSuccessCase.runWithHandles( |
| Encoders.v1, |
| 'GoldenNullableHandleStructNonNull_v1', |
| (List<Handle> handles) => GoldenNullableHandleStruct(v: handles[0]), |
| kGoldenNullableHandleStruct_Type, |
| Uint8List.fromList([ |
| 0xff,0xff,0xff,0xff,0x00,0x00,0x00,0x00, // |
| ]), |
| [ |
| HandleDef(HandleSubtype.event, 2147483648),// #0 |
| ], |
| [ |
| 0,]); |
| |
| EncodeSuccessCase.run( |
| Encoders.v1, |
| 'GoldenNullableHandleStructNull_v1', |
| GoldenNullableHandleStruct(v: null), |
| kGoldenNullableHandleStruct_Type, |
| Uint8List.fromList([ |
| 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, // |
| ])); |
| |
| }); |
| |
| group('decode success cases', () { |
| |
| DecodeSuccessCase.run( |
| 'GoldenBoolStruct_v1', |
| fidl.WireFormat.v1, |
| GoldenBoolStruct(v: true), |
| kGoldenBoolStruct_Type, |
| Uint8List.fromList([ |
| 0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00, // |
| ])); |
| |
| DecodeSuccessCase.run( |
| 'GoldenBoolStruct_v2', |
| fidl.WireFormat.v2, |
| GoldenBoolStruct(v: true), |
| kGoldenBoolStruct_Type, |
| Uint8List.fromList([ |
| 0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00, // |
| ])); |
| |
| DecodeSuccessCase.run( |
| 'GoldenIntStruct_v1', |
| fidl.WireFormat.v1, |
| GoldenIntStruct(v: 0x1), |
| kGoldenIntStruct_Type, |
| Uint8List.fromList([ |
| 0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00, // |
| ])); |
| |
| DecodeSuccessCase.run( |
| 'GoldenIntStruct_v2', |
| fidl.WireFormat.v2, |
| GoldenIntStruct(v: 0x1), |
| kGoldenIntStruct_Type, |
| Uint8List.fromList([ |
| 0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00, // |
| ])); |
| |
| DecodeSuccessCase.run( |
| 'GoldenUintStruct_v1', |
| fidl.WireFormat.v1, |
| GoldenUintStruct(v: 0x1), |
| kGoldenUintStruct_Type, |
| Uint8List.fromList([ |
| 0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00, // |
| ])); |
| |
| DecodeSuccessCase.run( |
| 'GoldenUintStruct_v2', |
| fidl.WireFormat.v2, |
| GoldenUintStruct(v: 0x1), |
| kGoldenUintStruct_Type, |
| Uint8List.fromList([ |
| 0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00, // |
| ])); |
| |
| DecodeSuccessCase.run( |
| 'GoldenFloatStruct_v1', |
| fidl.WireFormat.v1, |
| GoldenFloatStruct(v: 0), |
| kGoldenFloatStruct_Type, |
| Uint8List.fromList([ |
| 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, // |
| ])); |
| |
| DecodeSuccessCase.run( |
| 'GoldenFloatStruct_v2', |
| fidl.WireFormat.v2, |
| GoldenFloatStruct(v: 0), |
| kGoldenFloatStruct_Type, |
| Uint8List.fromList([ |
| 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, // |
| ])); |
| |
| DecodeSuccessCase.run( |
| 'GoldenDoubleStruct_v1', |
| fidl.WireFormat.v1, |
| GoldenDoubleStruct(v: 0), |
| kGoldenDoubleStruct_Type, |
| Uint8List.fromList([ |
| 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, // |
| ])); |
| |
| DecodeSuccessCase.run( |
| 'GoldenDoubleStruct_v2', |
| fidl.WireFormat.v2, |
| GoldenDoubleStruct(v: 0), |
| kGoldenDoubleStruct_Type, |
| Uint8List.fromList([ |
| 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, // |
| ])); |
| |
| DecodeSuccessCase.run( |
| 'GoldenStringStruct_v1', |
| fidl.WireFormat.v1, |
| GoldenStringStruct(v: 'abcd'), |
| kGoldenStringStruct_Type, |
| Uint8List.fromList([ |
| 0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00, // |
| 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, // |
| 0x61,0x62,0x63,0x64,0x00,0x00,0x00,0x00, // |
| ])); |
| |
| DecodeSuccessCase.run( |
| 'GoldenStringStruct_v2', |
| fidl.WireFormat.v2, |
| GoldenStringStruct(v: 'abcd'), |
| kGoldenStringStruct_Type, |
| Uint8List.fromList([ |
| 0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00, // |
| 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, // |
| 0x61,0x62,0x63,0x64,0x00,0x00,0x00,0x00, // |
| ])); |
| |
| DecodeSuccessCase.run( |
| 'GoldenNullableStringStructNonNull_v1', |
| fidl.WireFormat.v1, |
| GoldenNullableStringStruct(v: 'abcd'), |
| kGoldenNullableStringStruct_Type, |
| Uint8List.fromList([ |
| 0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00, // |
| 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, // |
| 0x61,0x62,0x63,0x64,0x00,0x00,0x00,0x00, // |
| ])); |
| |
| DecodeSuccessCase.run( |
| 'GoldenNullableStringStructNonNull_v2', |
| fidl.WireFormat.v2, |
| GoldenNullableStringStruct(v: 'abcd'), |
| kGoldenNullableStringStruct_Type, |
| Uint8List.fromList([ |
| 0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00, // |
| 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, // |
| 0x61,0x62,0x63,0x64,0x00,0x00,0x00,0x00, // |
| ])); |
| |
| DecodeSuccessCase.run( |
| 'GoldenNullableStringStructNull_v1', |
| fidl.WireFormat.v1, |
| GoldenNullableStringStruct(v: null), |
| kGoldenNullableStringStruct_Type, |
| Uint8List.fromList([ |
| 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, // |
| 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, // |
| ])); |
| |
| DecodeSuccessCase.run( |
| 'GoldenNullableStringStructNull_v2', |
| fidl.WireFormat.v2, |
| GoldenNullableStringStruct(v: null), |
| kGoldenNullableStringStruct_Type, |
| Uint8List.fromList([ |
| 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, // |
| 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, // |
| ])); |
| |
| DecodeSuccessCase.run( |
| 'GoldenEnumStruct_v1', |
| fidl.WireFormat.v1, |
| GoldenEnumStruct(v: kGoldenEnum_Type.ctor(0x1)), |
| kGoldenEnumStruct_Type, |
| Uint8List.fromList([ |
| 0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00, // |
| ])); |
| |
| DecodeSuccessCase.run( |
| 'GoldenEnumStruct_v2', |
| fidl.WireFormat.v2, |
| GoldenEnumStruct(v: kGoldenEnum_Type.ctor(0x1)), |
| kGoldenEnumStruct_Type, |
| Uint8List.fromList([ |
| 0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00, // |
| ])); |
| |
| DecodeSuccessCase.run( |
| 'GoldenBitsStruct_v1', |
| fidl.WireFormat.v1, |
| GoldenBitsStruct(v: kGoldenBits_Type.ctor(0x1)), |
| kGoldenBitsStruct_Type, |
| Uint8List.fromList([ |
| 0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00, // |
| ])); |
| |
| DecodeSuccessCase.run( |
| 'GoldenBitsStruct_v2', |
| fidl.WireFormat.v2, |
| GoldenBitsStruct(v: kGoldenBits_Type.ctor(0x1)), |
| kGoldenBitsStruct_Type, |
| Uint8List.fromList([ |
| 0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00, // |
| ])); |
| |
| DecodeSuccessCase.run( |
| 'GoldenTableStruct_v1', |
| fidl.WireFormat.v1, |
| GoldenTableStruct(v: GoldenTable(v: 0x1)), |
| kGoldenTableStruct_Type, |
| Uint8List.fromList([ |
| 0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00, // |
| 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, // |
| 0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x00, // |
| 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, // |
| 0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00, // |
| ])); |
| |
| DecodeSuccessCase.run( |
| 'GoldenUnionStruct_v1', |
| fidl.WireFormat.v1, |
| GoldenUnionStruct(v: GoldenUnion.withV(0x1)), |
| kGoldenUnionStruct_Type, |
| Uint8List.fromList([ |
| 0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00, // |
| 0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x00, // |
| 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, // |
| 0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00, // |
| ])); |
| |
| DecodeSuccessCase.run( |
| 'GoldenUnionStruct_v2', |
| fidl.WireFormat.v2, |
| GoldenUnionStruct(v: GoldenUnion.withV(0x1)), |
| kGoldenUnionStruct_Type, |
| Uint8List.fromList([ |
| 0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00, // |
| 0x01,0x00,0x00,0x00,0x00,0x00,0x01,0x00, // |
| ])); |
| |
| DecodeSuccessCase.run( |
| 'GoldenNullableUnionStructNonNull_v1', |
| fidl.WireFormat.v1, |
| GoldenNullableUnionStruct(v: GoldenUnion.withV(0x1)), |
| kGoldenNullableUnionStruct_Type, |
| Uint8List.fromList([ |
| 0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00, // |
| 0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x00, // |
| 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, // |
| 0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00, // |
| ])); |
| |
| DecodeSuccessCase.run( |
| 'GoldenNullableUnionStructNonNull_v2', |
| fidl.WireFormat.v2, |
| GoldenNullableUnionStruct(v: GoldenUnion.withV(0x1)), |
| kGoldenNullableUnionStruct_Type, |
| Uint8List.fromList([ |
| 0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00, // |
| 0x01,0x00,0x00,0x00,0x00,0x00,0x01,0x00, // |
| ])); |
| |
| DecodeSuccessCase.run( |
| 'GoldenNullableUnionStructNull_v1', |
| fidl.WireFormat.v1, |
| GoldenNullableUnionStruct(v: null), |
| kGoldenNullableUnionStruct_Type, |
| Uint8List.fromList([ |
| 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, // |
| 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, // |
| 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, // |
| ])); |
| |
| DecodeSuccessCase.run( |
| 'GoldenNullableUnionStructNull_v2', |
| fidl.WireFormat.v2, |
| GoldenNullableUnionStruct(v: null), |
| kGoldenNullableUnionStruct_Type, |
| Uint8List.fromList([ |
| 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, // |
| 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, // |
| ])); |
| |
| DecodeSuccessCase.run( |
| 'GoldenByteArrayStruct_v1', |
| fidl.WireFormat.v1, |
| GoldenByteArrayStruct(v: Uint8List.fromList([0x1, 0x2, 0x3, 0x4])), |
| kGoldenByteArrayStruct_Type, |
| Uint8List.fromList([ |
| 0x01,0x02,0x03,0x04,0x00,0x00,0x00,0x00, // |
| ])); |
| |
| DecodeSuccessCase.run( |
| 'GoldenByteArrayStruct_v2', |
| fidl.WireFormat.v2, |
| GoldenByteArrayStruct(v: Uint8List.fromList([0x1, 0x2, 0x3, 0x4])), |
| kGoldenByteArrayStruct_Type, |
| Uint8List.fromList([ |
| 0x01,0x02,0x03,0x04,0x00,0x00,0x00,0x00, // |
| ])); |
| |
| DecodeSuccessCase.run( |
| 'GoldenStructArrayStruct_v1', |
| fidl.WireFormat.v1, |
| GoldenStructArrayStruct(v: [GoldenIntStruct(v: 0x1), GoldenIntStruct(v: 0x2)]), |
| kGoldenStructArrayStruct_Type, |
| Uint8List.fromList([ |
| 0x01,0x00,0x02,0x00,0x00,0x00,0x00,0x00, // |
| ])); |
| |
| DecodeSuccessCase.run( |
| 'GoldenStructArrayStruct_v2', |
| fidl.WireFormat.v2, |
| GoldenStructArrayStruct(v: [GoldenIntStruct(v: 0x1), GoldenIntStruct(v: 0x2)]), |
| kGoldenStructArrayStruct_Type, |
| Uint8List.fromList([ |
| 0x01,0x00,0x02,0x00,0x00,0x00,0x00,0x00, // |
| ])); |
| |
| DecodeSuccessCase.run( |
| 'GoldenByteVectorStruct_v1', |
| fidl.WireFormat.v1, |
| GoldenByteVectorStruct(v: Uint8List.fromList([0x1, 0x2, 0x3, 0x4, 0x1, 0x2, 0x3, 0x4, 0x1, 0x2, 0x3, 0x4])), |
| kGoldenByteVectorStruct_Type, |
| Uint8List.fromList([ |
| 0x0c,0x00,0x00,0x00,0x00,0x00,0x00,0x00, // |
| 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, // |
| 0x01,0x02,0x03,0x04,0x01,0x02,0x03,0x04, // |
| 0x01,0x02,0x03,0x04,0x00,0x00,0x00,0x00, // |
| ])); |
| |
| DecodeSuccessCase.run( |
| 'GoldenByteVectorStruct_v2', |
| fidl.WireFormat.v2, |
| GoldenByteVectorStruct(v: Uint8List.fromList([0x1, 0x2, 0x3, 0x4, 0x1, 0x2, 0x3, 0x4, 0x1, 0x2, 0x3, 0x4])), |
| kGoldenByteVectorStruct_Type, |
| Uint8List.fromList([ |
| 0x0c,0x00,0x00,0x00,0x00,0x00,0x00,0x00, // |
| 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, // |
| 0x01,0x02,0x03,0x04,0x01,0x02,0x03,0x04, // |
| 0x01,0x02,0x03,0x04,0x00,0x00,0x00,0x00, // |
| ])); |
| |
| DecodeSuccessCase.run( |
| 'GoldenByteNullableVectorStructNonNull_v1', |
| fidl.WireFormat.v1, |
| GoldenNullableByteVectorStruct(v: Uint8List.fromList([0x1, 0x2, 0x3, 0x4])), |
| kGoldenNullableByteVectorStruct_Type, |
| Uint8List.fromList([ |
| 0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00, // |
| 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, // |
| 0x01,0x02,0x03,0x04,0x00,0x00,0x00,0x00, // |
| ])); |
| |
| DecodeSuccessCase.run( |
| 'GoldenByteNullableVectorStructNonNull_v2', |
| fidl.WireFormat.v2, |
| GoldenNullableByteVectorStruct(v: Uint8List.fromList([0x1, 0x2, 0x3, 0x4])), |
| kGoldenNullableByteVectorStruct_Type, |
| Uint8List.fromList([ |
| 0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00, // |
| 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, // |
| 0x01,0x02,0x03,0x04,0x00,0x00,0x00,0x00, // |
| ])); |
| |
| DecodeSuccessCase.run( |
| 'GoldenNullableByteVectorStructNull_v1', |
| fidl.WireFormat.v1, |
| GoldenNullableByteVectorStruct(v: null), |
| kGoldenNullableByteVectorStruct_Type, |
| Uint8List.fromList([ |
| 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, // |
| 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, // |
| ])); |
| |
| DecodeSuccessCase.run( |
| 'GoldenNullableByteVectorStructNull_v2', |
| fidl.WireFormat.v2, |
| GoldenNullableByteVectorStruct(v: null), |
| kGoldenNullableByteVectorStruct_Type, |
| Uint8List.fromList([ |
| 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, // |
| 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, // |
| ])); |
| |
| DecodeSuccessCase.run( |
| 'GoldenStructVectorStruct_v1', |
| fidl.WireFormat.v1, |
| GoldenStructVectorStruct(v: [GoldenIntStruct(v: 0x1), GoldenIntStruct(v: 0x2)]), |
| kGoldenStructVectorStruct_Type, |
| Uint8List.fromList([ |
| 0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00, // |
| 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, // |
| 0x01,0x00,0x02,0x00,0x00,0x00,0x00,0x00, // |
| ])); |
| |
| DecodeSuccessCase.run( |
| 'GoldenStructVectorStruct_v2', |
| fidl.WireFormat.v2, |
| GoldenStructVectorStruct(v: [GoldenIntStruct(v: 0x1), GoldenIntStruct(v: 0x2)]), |
| kGoldenStructVectorStruct_Type, |
| Uint8List.fromList([ |
| 0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00, // |
| 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, // |
| 0x01,0x00,0x02,0x00,0x00,0x00,0x00,0x00, // |
| ])); |
| |
| DecodeSuccessCase.run( |
| 'GoldenNullableStructNonNull_v1', |
| fidl.WireFormat.v1, |
| GoldenNullableStruct(v: GoldenBoolStruct(v: true)), |
| kGoldenNullableStruct_Type, |
| Uint8List.fromList([ |
| 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, // |
| 0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00, // |
| ])); |
| |
| DecodeSuccessCase.run( |
| 'GoldenNullableStructNonNull_v2', |
| fidl.WireFormat.v2, |
| GoldenNullableStruct(v: GoldenBoolStruct(v: true)), |
| kGoldenNullableStruct_Type, |
| Uint8List.fromList([ |
| 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, // |
| 0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00, // |
| ])); |
| |
| DecodeSuccessCase.run( |
| 'GoldenNullableStructNull_v1', |
| fidl.WireFormat.v1, |
| GoldenNullableStruct(v: null), |
| kGoldenNullableStruct_Type, |
| Uint8List.fromList([ |
| 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, // |
| ])); |
| |
| DecodeSuccessCase.run( |
| 'GoldenNullableStructNull_v2', |
| fidl.WireFormat.v2, |
| GoldenNullableStruct(v: null), |
| kGoldenNullableStruct_Type, |
| Uint8List.fromList([ |
| 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, // |
| ])); |
| |
| DecodeSuccessCase.runWithHandles( |
| 'GoldenNullableHandleStructNonNull_v1', |
| fidl.WireFormat.v1, |
| (List<Handle> handles) => GoldenNullableHandleStruct(v: handles[0]), |
| kGoldenNullableHandleStruct_Type, |
| Uint8List.fromList([ |
| 0xff,0xff,0xff,0xff,0x00,0x00,0x00,0x00, // |
| ]), |
| [ |
| HandleDef(HandleSubtype.event, 2147483648),// #0 |
| ], |
| [ |
| 0,], |
| [ |
| 0,]); |
| |
| DecodeSuccessCase.runWithHandles( |
| 'GoldenNullableHandleStructNonNull_v2', |
| fidl.WireFormat.v2, |
| (List<Handle> handles) => GoldenNullableHandleStruct(v: handles[0]), |
| kGoldenNullableHandleStruct_Type, |
| Uint8List.fromList([ |
| 0xff,0xff,0xff,0xff,0x00,0x00,0x00,0x00, // |
| ]), |
| [ |
| HandleDef(HandleSubtype.event, 2147483648),// #0 |
| ], |
| [ |
| 0,], |
| [ |
| 0,]); |
| |
| DecodeSuccessCase.run( |
| 'GoldenNullableHandleStructNull_v1', |
| fidl.WireFormat.v1, |
| GoldenNullableHandleStruct(v: null), |
| kGoldenNullableHandleStruct_Type, |
| Uint8List.fromList([ |
| 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, // |
| ])); |
| |
| DecodeSuccessCase.run( |
| 'GoldenNullableHandleStructNull_v2', |
| fidl.WireFormat.v2, |
| GoldenNullableHandleStruct(v: null), |
| kGoldenNullableHandleStruct_Type, |
| Uint8List.fromList([ |
| 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, // |
| ])); |
| |
| }); |
| |
| group('encode failure cases', () { |
| |
| }); |
| |
| group('decode failure cases', () { |
| |
| DecodeFailureCase.run( |
| 'GoldenStringStructNullBody_v1', |
| fidl.WireFormat.v1, |
| kGoldenStringStruct_Type, |
| Uint8List.fromList([ |
| 0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00, // |
| 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, // |
| ]), |
| fidl.FidlErrorCode.fidlNonEmptyStringWithNullBody); |
| |
| DecodeFailureCase.run( |
| 'GoldenStringStructNullBody_v2', |
| fidl.WireFormat.v2, |
| kGoldenStringStruct_Type, |
| Uint8List.fromList([ |
| 0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00, // |
| 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, // |
| ]), |
| fidl.FidlErrorCode.fidlNonEmptyStringWithNullBody); |
| |
| }); |
| }); |
| } |