Skip to content

Commit

Permalink
integration tests
Browse files Browse the repository at this point in the history
  • Loading branch information
tarrinneal committed Feb 7, 2024
1 parent 4fd43ee commit 679cc3d
Show file tree
Hide file tree
Showing 8 changed files with 77 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,9 @@ protected static FlutterError createConnectionError(@NonNull String channelName)
public enum AnEnum {
ONE(0),
TWO(1),
THREE(2);
THREE(2),
FORTY_TWO(3),
FOUR_HUNDRED_TWENTY_TWO(4);

final int index;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ typedef NS_ENUM(NSUInteger, AnEnum) {
AnEnumOne = 0,
AnEnumTwo = 1,
AnEnumThree = 2,
AnEnumFortyTwo = 3,
AnEnumFourHundredTwentyTwo = 4,
};

/// Wrapper for AnEnum to allow for nullability.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ typedef NS_ENUM(NSUInteger, AnEnum) {
AnEnumOne = 0,
AnEnumTwo = 1,
AnEnumThree = 2,
AnEnumFortyTwo = 3,
AnEnumFourHundredTwentyTwo = 4,
};

/// Wrapper for AnEnum to allow for nullability.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ void runPigeonIntegrationTests(TargetGenerator targetGenerator) {
'd': false,
'e': null
},
anEnum: AnEnum.two,
anEnum: AnEnum.fortyTwo,
anObject: 1,
);

Expand Down Expand Up @@ -166,7 +166,7 @@ void runPigeonIntegrationTests(TargetGenerator targetGenerator) {
],
nullableMapWithAnnotations: <String?, String?>{},
nullableMapWithObject: <String?, Object?>{},
aNullableEnum: AnEnum.two,
aNullableEnum: AnEnum.fourHundredTwentyTwo,
aNullableObject: 0,
);

Expand Down Expand Up @@ -443,6 +443,15 @@ void runPigeonIntegrationTests(TargetGenerator targetGenerator) {
expect(receivedEnum, sentEnum);
});

testWidgets('multi word enums serialize and deserialize correctly',
(WidgetTester _) async {
final HostIntegrationCoreApi api = HostIntegrationCoreApi();

const AnEnum sentEnum = AnEnum.fortyTwo;
final AnEnum receivedEnum = await api.echoEnum(sentEnum);
expect(receivedEnum, sentEnum);
});

testWidgets('required named parameter', (WidgetTester _) async {
final HostIntegrationCoreApi api = HostIntegrationCoreApi();
// This number corresponds with the default value of this method.
Expand Down Expand Up @@ -648,6 +657,15 @@ void runPigeonIntegrationTests(TargetGenerator targetGenerator) {
expect(echoEnum, sentEnum);
});

testWidgets('multi word nullable enums serialize and deserialize correctly',
(WidgetTester _) async {
final HostIntegrationCoreApi api = HostIntegrationCoreApi();

const AnEnum sentEnum = AnEnum.fourHundredTwentyTwo;
final AnEnum? echoEnum = await api.echoNullableEnum(sentEnum);
expect(echoEnum, sentEnum);
});

testWidgets('null lists serialize and deserialize correctly',
(WidgetTester _) async {
final HostIntegrationCoreApi api = HostIntegrationCoreApi();
Expand Down Expand Up @@ -887,6 +905,15 @@ void runPigeonIntegrationTests(TargetGenerator targetGenerator) {
expect(echoEnum, sentEnum);
});

testWidgets('multi word enums serialize and deserialize correctly',
(WidgetTester _) async {
final HostIntegrationCoreApi api = HostIntegrationCoreApi();

const AnEnum sentEnum = AnEnum.fourHundredTwentyTwo;
final AnEnum echoEnum = await api.echoAsyncEnum(sentEnum);
expect(echoEnum, sentEnum);
});

testWidgets('nullable Int async serialize and deserialize correctly',
(WidgetTester _) async {
final HostIntegrationCoreApi api = HostIntegrationCoreApi();
Expand Down Expand Up @@ -1004,6 +1031,15 @@ void runPigeonIntegrationTests(TargetGenerator targetGenerator) {
expect(echoEnum, sentEnum);
});

testWidgets('nullable enums serialize and deserialize correctly',
(WidgetTester _) async {
final HostIntegrationCoreApi api = HostIntegrationCoreApi();

const AnEnum sentEnum = AnEnum.fortyTwo;
final AnEnum? echoEnum = await api.echoAsyncNullableEnum(sentEnum);
expect(echoEnum, sentEnum);
});

testWidgets('null Ints async serialize and deserialize correctly',
(WidgetTester _) async {
final HostIntegrationCoreApi api = HostIntegrationCoreApi();
Expand Down Expand Up @@ -1243,6 +1279,15 @@ void runPigeonIntegrationTests(TargetGenerator targetGenerator) {
expect(echoEnum, sentEnum);
});

testWidgets('multi word enums serialize and deserialize correctly',
(WidgetTester _) async {
final HostIntegrationCoreApi api = HostIntegrationCoreApi();

const AnEnum sentEnum = AnEnum.fortyTwo;
final AnEnum echoEnum = await api.callFlutterEchoEnum(sentEnum);
expect(echoEnum, sentEnum);
});

testWidgets('nullable booleans serialize and deserialize correctly',
(WidgetTester _) async {
final HostIntegrationCoreApi api = HostIntegrationCoreApi();
Expand Down Expand Up @@ -1407,6 +1452,15 @@ void runPigeonIntegrationTests(TargetGenerator targetGenerator) {
expect(echoEnum, sentEnum);
});

testWidgets('multi word nullable enums serialize and deserialize correctly',
(WidgetTester _) async {
final HostIntegrationCoreApi api = HostIntegrationCoreApi();

const AnEnum sentEnum = AnEnum.fourHundredTwentyTwo;
final AnEnum? echoEnum = await api.callFlutterEchoNullableEnum(sentEnum);
expect(echoEnum, sentEnum);
});

testWidgets('null enums serialize and deserialize correctly',
(WidgetTester _) async {
final HostIntegrationCoreApi api = HostIntegrationCoreApi();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,9 @@ class CoreTestsError(
enum class AnEnum(val raw: Int) {
ONE(0),
TWO(1),
THREE(2);
THREE(2),
FORTY_TWO(3),
FOUR_HUNDRED_TWENTY_TWO(4);

companion object {
fun ofRaw(raw: Int): AnEnum? {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ enum AnEnum: Int {
case one = 0
case two = 1
case three = 2
case fortyTwo = 3
case fourHundredTwentyTwo = 4
}

/// A class containing all supported types.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ enum AnEnum: Int {
case one = 0
case two = 1
case three = 2
case fortyTwo = 3
case fourHundredTwentyTwo = 4
}

/// A class containing all supported types.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,13 @@ class ErrorOr {
std::variant<T, FlutterError> v_;
};

enum class AnEnum { one = 0, two = 1, three = 2 };
enum class AnEnum {
one = 0,
two = 1,
three = 2,
fortyTwo = 3,
fourHundredTwentyTwo = 4
};

// A class containing all supported types.
//
Expand Down

0 comments on commit 679cc3d

Please sign in to comment.