[pigeon] Minor addition to integration tests (#2905)
* sanity test to make sure I know what's going on
* accidental } delete
* fix windows
* comment clarity
* actually fix windows
* the actual test...
* Change wrapped bool test to echoAsyncBool
* Multiple arguments test
* echo int integration test
* Change echoAsyncBool to not async
* ObjCSelector
* error
* format
* no need to changelog
* nits and formats
* format
* more format
* windows returns
* more windows bugs
* more bugs
* Formatting
* Remove cruft from previous version
Co-authored-by: stuartmorgan <stuartmorgan@google.com>
diff --git a/packages/pigeon/pigeons/core_tests.dart b/packages/pigeon/pigeons/core_tests.dart
index 3adf890..0aa5cba 100644
--- a/packages/pigeon/pigeons/core_tests.dart
+++ b/packages/pigeon/pigeons/core_tests.dart
@@ -56,6 +56,18 @@
@ObjCSelector('createNestedObjectWithString:')
AllTypesWrapper createNestedString(String string);
+ /// Returns passed in arguments of multiple types.
+ @ObjCSelector('sendMultipleTypesABool:anInt:aString:')
+ AllTypes sendMultipleTypes(bool aBool, int anInt, String aString);
+
+ /// Returns passed in int.
+ @ObjCSelector('echoInt:')
+ int echoInt(int anInt);
+
+ /// Returns the passed in boolean asynchronously.
+ @ObjCSelector('echoBool:')
+ bool echoBool(bool aBool);
+
// ========== Asyncronous method tests ==========
/// A no-op function taking no arguments and returning no value, to sanity
diff --git a/packages/pigeon/platform_tests/alternate_language_test_plugin/android/src/main/java/com/example/alternate_language_test_plugin/AlternateLanguageTestPlugin.java b/packages/pigeon/platform_tests/alternate_language_test_plugin/android/src/main/java/com/example/alternate_language_test_plugin/AlternateLanguageTestPlugin.java
index a4057b7..bfc0e56 100644
--- a/packages/pigeon/platform_tests/alternate_language_test_plugin/android/src/main/java/com/example/alternate_language_test_plugin/AlternateLanguageTestPlugin.java
+++ b/packages/pigeon/platform_tests/alternate_language_test_plugin/android/src/main/java/com/example/alternate_language_test_plugin/AlternateLanguageTestPlugin.java
@@ -53,6 +53,24 @@
}
@Override
+ public @NonNull AllTypes sendMultipleTypes(
+ @NonNull Boolean aBool, @NonNull Long anInt, @NonNull String aString) {
+ AllTypes someThings =
+ new AllTypes.Builder().setABool(aBool).setAnInt(anInt).setAString(aString).build();
+ return someThings;
+ }
+
+ @Override
+ public Long echoInt(@NonNull Long anInt) {
+ return anInt;
+ }
+
+ @Override
+ public Boolean echoBool(@NonNull Boolean aBool) {
+ return aBool;
+ }
+
+ @Override
public void noopAsync(Result<Void> result) {
result.success(null);
}
diff --git a/packages/pigeon/platform_tests/alternate_language_test_plugin/ios/Classes/AlternateLanguageTestPlugin.m b/packages/pigeon/platform_tests/alternate_language_test_plugin/ios/Classes/AlternateLanguageTestPlugin.m
index 4f22b7d..8f8a62e 100644
--- a/packages/pigeon/platform_tests/alternate_language_test_plugin/ios/Classes/AlternateLanguageTestPlugin.m
+++ b/packages/pigeon/platform_tests/alternate_language_test_plugin/ios/Classes/AlternateLanguageTestPlugin.m
@@ -48,6 +48,25 @@
return [AllTypesWrapper makeWithValues:innerObject];
}
+- (nullable AllTypes *)sendMultipleTypesABool:(NSNumber *)aBool
+ anInt:(NSNumber *)anInt
+ aString:(NSString *)aString
+ error:(FlutterError *_Nullable *_Nonnull)error {
+ AllTypes *someTypes = [[AllTypes alloc] init];
+ someTypes.aBool = aBool;
+ someTypes.anInt = anInt;
+ someTypes.aString = aString;
+ return someTypes;
+}
+
+- (nullable NSNumber *)echoInt:(NSNumber *)anInt error:(FlutterError *_Nullable *_Nonnull)error {
+ return anInt;
+}
+
+- (nullable NSNumber *)echoBool:(NSNumber *)aBool error:(FlutterError *_Nullable *_Nonnull)error {
+ return aBool;
+}
+
- (void)noopAsyncWithCompletion:(void (^)(FlutterError *_Nullable))completion {
completion(nil);
}
diff --git a/packages/pigeon/platform_tests/flutter_null_safe_unit_tests/lib/core_tests.gen.dart b/packages/pigeon/platform_tests/flutter_null_safe_unit_tests/lib/core_tests.gen.dart
index 701b435..7f7a4d3 100644
--- a/packages/pigeon/platform_tests/flutter_null_safe_unit_tests/lib/core_tests.gen.dart
+++ b/packages/pigeon/platform_tests/flutter_null_safe_unit_tests/lib/core_tests.gen.dart
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
-// Autogenerated from Pigeon (v4.2.7), do not edit directly.
+// Autogenerated from Pigeon (v4.2.10), do not edit directly.
// See also: https://pub.dev/packages/pigeon
// ignore_for_file: public_member_api_docs, non_constant_identifier_names, avoid_as, unused_import, unnecessary_parenthesis, prefer_null_aware_operators, omit_local_variable_types, unused_shown_name, unnecessary_import
import 'dart:async';
@@ -84,6 +84,27 @@
}
}
+class AllTypesWrapper {
+ AllTypesWrapper({
+ required this.values,
+ });
+
+ AllTypes values;
+
+ Object encode() {
+ final Map<Object?, Object?> pigeonMap = <Object?, Object?>{};
+ pigeonMap['values'] = values.encode();
+ return pigeonMap;
+ }
+
+ static AllTypesWrapper decode(Object message) {
+ final Map<Object?, Object?> pigeonMap = message as Map<Object?, Object?>;
+ return AllTypesWrapper(
+ values: AllTypes.decode(pigeonMap['values']!),
+ );
+ }
+}
+
class _HostIntegrationCoreApiCodec extends StandardMessageCodec {
const _HostIntegrationCoreApiCodec();
@override
@@ -91,6 +112,9 @@
if (value is AllTypes) {
buffer.putUint8(128);
writeValue(buffer, value.encode());
+ } else if (value is AllTypesWrapper) {
+ buffer.putUint8(129);
+ writeValue(buffer, value.encode());
} else {
super.writeValue(buffer, value);
}
@@ -102,6 +126,9 @@
case 128:
return AllTypes.decode(readValue(buffer)!);
+ case 129:
+ return AllTypesWrapper.decode(readValue(buffer)!);
+
default:
return super.readValueOfType(type, buffer);
}
@@ -175,6 +202,290 @@
return (replyMap['result'] as AllTypes?)!;
}
}
+
+ /// Returns an error, to test error handling.
+ Future<void> throwError() async {
+ final BasicMessageChannel<Object?> channel = BasicMessageChannel<Object?>(
+ 'dev.flutter.pigeon.HostIntegrationCoreApi.throwError', codec,
+ binaryMessenger: _binaryMessenger);
+ final Map<Object?, Object?>? replyMap =
+ await channel.send(null) as Map<Object?, Object?>?;
+ if (replyMap == null) {
+ throw PlatformException(
+ code: 'channel-error',
+ message: 'Unable to establish connection on channel.',
+ );
+ } else if (replyMap['error'] != null) {
+ final Map<Object?, Object?> error =
+ (replyMap['error'] as Map<Object?, Object?>?)!;
+ throw PlatformException(
+ code: (error['code'] as String?)!,
+ message: error['message'] as String?,
+ details: error['details'],
+ );
+ } else {
+ return;
+ }
+ }
+
+ /// Returns the inner `aString` value from the wrapped object, to test
+ /// sending of nested objects.
+ Future<String?> extractNestedString(AllTypesWrapper arg_wrapper) async {
+ final BasicMessageChannel<Object?> channel = BasicMessageChannel<Object?>(
+ 'dev.flutter.pigeon.HostIntegrationCoreApi.extractNestedString', codec,
+ binaryMessenger: _binaryMessenger);
+ final Map<Object?, Object?>? replyMap =
+ await channel.send(<Object?>[arg_wrapper]) as Map<Object?, Object?>?;
+ if (replyMap == null) {
+ throw PlatformException(
+ code: 'channel-error',
+ message: 'Unable to establish connection on channel.',
+ );
+ } else if (replyMap['error'] != null) {
+ final Map<Object?, Object?> error =
+ (replyMap['error'] as Map<Object?, Object?>?)!;
+ throw PlatformException(
+ code: (error['code'] as String?)!,
+ message: error['message'] as String?,
+ details: error['details'],
+ );
+ } else {
+ return (replyMap['result'] as String?);
+ }
+ }
+
+ /// Returns the inner `aString` value from the wrapped object, to test
+ /// sending of nested objects.
+ Future<AllTypesWrapper> createNestedString(String arg_string) async {
+ final BasicMessageChannel<Object?> channel = BasicMessageChannel<Object?>(
+ 'dev.flutter.pigeon.HostIntegrationCoreApi.createNestedString', codec,
+ binaryMessenger: _binaryMessenger);
+ final Map<Object?, Object?>? replyMap =
+ await channel.send(<Object?>[arg_string]) as Map<Object?, Object?>?;
+ if (replyMap == null) {
+ throw PlatformException(
+ code: 'channel-error',
+ message: 'Unable to establish connection on channel.',
+ );
+ } else if (replyMap['error'] != null) {
+ final Map<Object?, Object?> error =
+ (replyMap['error'] as Map<Object?, Object?>?)!;
+ throw PlatformException(
+ code: (error['code'] as String?)!,
+ message: error['message'] as String?,
+ details: error['details'],
+ );
+ } else if (replyMap['result'] == null) {
+ throw PlatformException(
+ code: 'null-error',
+ message: 'Host platform returned null value for non-null return value.',
+ );
+ } else {
+ return (replyMap['result'] as AllTypesWrapper?)!;
+ }
+ }
+
+ /// Returns passed in arguments of multiple types.
+ Future<AllTypes> sendMultipleTypes(
+ bool arg_aBool, int arg_anInt, String arg_aString) async {
+ final BasicMessageChannel<Object?> channel = BasicMessageChannel<Object?>(
+ 'dev.flutter.pigeon.HostIntegrationCoreApi.sendMultipleTypes', codec,
+ binaryMessenger: _binaryMessenger);
+ final Map<Object?, Object?>? replyMap =
+ await channel.send(<Object?>[arg_aBool, arg_anInt, arg_aString])
+ as Map<Object?, Object?>?;
+ if (replyMap == null) {
+ throw PlatformException(
+ code: 'channel-error',
+ message: 'Unable to establish connection on channel.',
+ );
+ } else if (replyMap['error'] != null) {
+ final Map<Object?, Object?> error =
+ (replyMap['error'] as Map<Object?, Object?>?)!;
+ throw PlatformException(
+ code: (error['code'] as String?)!,
+ message: error['message'] as String?,
+ details: error['details'],
+ );
+ } else if (replyMap['result'] == null) {
+ throw PlatformException(
+ code: 'null-error',
+ message: 'Host platform returned null value for non-null return value.',
+ );
+ } else {
+ return (replyMap['result'] as AllTypes?)!;
+ }
+ }
+
+ /// Returns passed in int.
+ Future<int> echoInt(int arg_anInt) async {
+ final BasicMessageChannel<Object?> channel = BasicMessageChannel<Object?>(
+ 'dev.flutter.pigeon.HostIntegrationCoreApi.echoInt', codec,
+ binaryMessenger: _binaryMessenger);
+ final Map<Object?, Object?>? replyMap =
+ await channel.send(<Object?>[arg_anInt]) as Map<Object?, Object?>?;
+ if (replyMap == null) {
+ throw PlatformException(
+ code: 'channel-error',
+ message: 'Unable to establish connection on channel.',
+ );
+ } else if (replyMap['error'] != null) {
+ final Map<Object?, Object?> error =
+ (replyMap['error'] as Map<Object?, Object?>?)!;
+ throw PlatformException(
+ code: (error['code'] as String?)!,
+ message: error['message'] as String?,
+ details: error['details'],
+ );
+ } else if (replyMap['result'] == null) {
+ throw PlatformException(
+ code: 'null-error',
+ message: 'Host platform returned null value for non-null return value.',
+ );
+ } else {
+ return (replyMap['result'] as int?)!;
+ }
+ }
+
+ /// Returns the passed in boolean asynchronously.
+ Future<bool> echoBool(bool arg_aBool) async {
+ final BasicMessageChannel<Object?> channel = BasicMessageChannel<Object?>(
+ 'dev.flutter.pigeon.HostIntegrationCoreApi.echoBool', codec,
+ binaryMessenger: _binaryMessenger);
+ final Map<Object?, Object?>? replyMap =
+ await channel.send(<Object?>[arg_aBool]) as Map<Object?, Object?>?;
+ if (replyMap == null) {
+ throw PlatformException(
+ code: 'channel-error',
+ message: 'Unable to establish connection on channel.',
+ );
+ } else if (replyMap['error'] != null) {
+ final Map<Object?, Object?> error =
+ (replyMap['error'] as Map<Object?, Object?>?)!;
+ throw PlatformException(
+ code: (error['code'] as String?)!,
+ message: error['message'] as String?,
+ details: error['details'],
+ );
+ } else if (replyMap['result'] == null) {
+ throw PlatformException(
+ code: 'null-error',
+ message: 'Host platform returned null value for non-null return value.',
+ );
+ } else {
+ return (replyMap['result'] as bool?)!;
+ }
+ }
+
+ /// A no-op function taking no arguments and returning no value, to sanity
+ /// test basic asynchronous calling.
+ Future<void> noopAsync() async {
+ final BasicMessageChannel<Object?> channel = BasicMessageChannel<Object?>(
+ 'dev.flutter.pigeon.HostIntegrationCoreApi.noopAsync', codec,
+ binaryMessenger: _binaryMessenger);
+ final Map<Object?, Object?>? replyMap =
+ await channel.send(null) as Map<Object?, Object?>?;
+ if (replyMap == null) {
+ throw PlatformException(
+ code: 'channel-error',
+ message: 'Unable to establish connection on channel.',
+ );
+ } else if (replyMap['error'] != null) {
+ final Map<Object?, Object?> error =
+ (replyMap['error'] as Map<Object?, Object?>?)!;
+ throw PlatformException(
+ code: (error['code'] as String?)!,
+ message: error['message'] as String?,
+ details: error['details'],
+ );
+ } else {
+ return;
+ }
+ }
+
+ /// Returns the passed string asynchronously.
+ Future<String> echoAsyncString(String arg_aString) async {
+ final BasicMessageChannel<Object?> channel = BasicMessageChannel<Object?>(
+ 'dev.flutter.pigeon.HostIntegrationCoreApi.echoAsyncString', codec,
+ binaryMessenger: _binaryMessenger);
+ final Map<Object?, Object?>? replyMap =
+ await channel.send(<Object?>[arg_aString]) as Map<Object?, Object?>?;
+ if (replyMap == null) {
+ throw PlatformException(
+ code: 'channel-error',
+ message: 'Unable to establish connection on channel.',
+ );
+ } else if (replyMap['error'] != null) {
+ final Map<Object?, Object?> error =
+ (replyMap['error'] as Map<Object?, Object?>?)!;
+ throw PlatformException(
+ code: (error['code'] as String?)!,
+ message: error['message'] as String?,
+ details: error['details'],
+ );
+ } else if (replyMap['result'] == null) {
+ throw PlatformException(
+ code: 'null-error',
+ message: 'Host platform returned null value for non-null return value.',
+ );
+ } else {
+ return (replyMap['result'] as String?)!;
+ }
+ }
+
+ Future<void> callFlutterNoop() async {
+ final BasicMessageChannel<Object?> channel = BasicMessageChannel<Object?>(
+ 'dev.flutter.pigeon.HostIntegrationCoreApi.callFlutterNoop', codec,
+ binaryMessenger: _binaryMessenger);
+ final Map<Object?, Object?>? replyMap =
+ await channel.send(null) as Map<Object?, Object?>?;
+ if (replyMap == null) {
+ throw PlatformException(
+ code: 'channel-error',
+ message: 'Unable to establish connection on channel.',
+ );
+ } else if (replyMap['error'] != null) {
+ final Map<Object?, Object?> error =
+ (replyMap['error'] as Map<Object?, Object?>?)!;
+ throw PlatformException(
+ code: (error['code'] as String?)!,
+ message: error['message'] as String?,
+ details: error['details'],
+ );
+ } else {
+ return;
+ }
+ }
+
+ Future<String> callFlutterEchoString(String arg_aString) async {
+ final BasicMessageChannel<Object?> channel = BasicMessageChannel<Object?>(
+ 'dev.flutter.pigeon.HostIntegrationCoreApi.callFlutterEchoString',
+ codec,
+ binaryMessenger: _binaryMessenger);
+ final Map<Object?, Object?>? replyMap =
+ await channel.send(<Object?>[arg_aString]) as Map<Object?, Object?>?;
+ if (replyMap == null) {
+ throw PlatformException(
+ code: 'channel-error',
+ message: 'Unable to establish connection on channel.',
+ );
+ } else if (replyMap['error'] != null) {
+ final Map<Object?, Object?> error =
+ (replyMap['error'] as Map<Object?, Object?>?)!;
+ throw PlatformException(
+ code: (error['code'] as String?)!,
+ message: error['message'] as String?,
+ details: error['details'],
+ );
+ } else if (replyMap['result'] == null) {
+ throw PlatformException(
+ code: 'null-error',
+ message: 'Host platform returned null value for non-null return value.',
+ );
+ } else {
+ return (replyMap['result'] as String?)!;
+ }
+ }
}
class _FlutterIntegrationCoreApiCodec extends StandardMessageCodec {
@@ -212,6 +523,9 @@
/// Returns the passed object, to test serialization and deserialization.
AllTypes echoAllTypes(AllTypes everything);
+
+ /// Returns the passed string, to test serialization and deserialization.
+ String echoString(String aString);
static void setup(FlutterIntegrationCoreApi? api,
{BinaryMessenger? binaryMessenger}) {
{
@@ -247,6 +561,25 @@
});
}
}
+ {
+ final BasicMessageChannel<Object?> channel = BasicMessageChannel<Object?>(
+ 'dev.flutter.pigeon.FlutterIntegrationCoreApi.echoString', codec,
+ binaryMessenger: binaryMessenger);
+ if (api == null) {
+ channel.setMessageHandler(null);
+ } else {
+ channel.setMessageHandler((Object? message) async {
+ assert(message != null,
+ 'Argument for dev.flutter.pigeon.FlutterIntegrationCoreApi.echoString was null.');
+ final List<Object?> args = (message as List<Object?>?)!;
+ final String? arg_aString = (args[0] as String?);
+ assert(arg_aString != null,
+ 'Argument for dev.flutter.pigeon.FlutterIntegrationCoreApi.echoString was null, expected non-null String.');
+ final String output = api.echoString(arg_aString!);
+ return output;
+ });
+ }
+ }
}
}
diff --git a/packages/pigeon/platform_tests/shared_test_plugin_code/lib/integration_tests.dart b/packages/pigeon/platform_tests/shared_test_plugin_code/lib/integration_tests.dart
index 08a9930..fcd2e61 100644
--- a/packages/pigeon/platform_tests/shared_test_plugin_code/lib/integration_tests.dart
+++ b/packages/pigeon/platform_tests/shared_test_plugin_code/lib/integration_tests.dart
@@ -27,7 +27,7 @@
/// The iOS Objective-C generator.
objc,
- /// The iOS or macOS Objective-C generator.
+ /// The iOS or macOS Swift generator.
swift,
}
@@ -123,6 +123,40 @@
await api.createNestedString(sentString);
expect(receivedObject.values.aString, sentString);
});
+
+ testWidgets(
+ 'Arguments of multiple types serialize and deserialize correctly',
+ (WidgetTester _) async {
+ final HostIntegrationCoreApi api = HostIntegrationCoreApi();
+ const String aString = 'this is aString';
+ const bool aBool = false;
+ const int anInt = 42;
+
+ final AllTypes echoObject =
+ await api.sendMultipleTypes(aBool, anInt, aString);
+ expect(echoObject.anInt, anInt);
+ expect(echoObject.aBool, aBool);
+ expect(echoObject.aString, aString);
+ });
+
+ testWidgets('Ints serialize and deserialize correctly',
+ (WidgetTester _) async {
+ final HostIntegrationCoreApi api = HostIntegrationCoreApi();
+
+ const int inInt = -13;
+ final int anInt = await api.echoInt(inInt);
+ expect(anInt, inInt);
+ });
+
+ testWidgets('booleans serialize and deserialize correctly',
+ (WidgetTester _) async {
+ final HostIntegrationCoreApi api = HostIntegrationCoreApi();
+
+ for (final bool sentBool in <bool>[true, false]) {
+ final bool receivedBool = await api.echoBool(sentBool);
+ expect(receivedBool, sentBool);
+ }
+ });
});
group('Host async API tests', () {
diff --git a/packages/pigeon/platform_tests/shared_test_plugin_code/lib/src/generated/core_tests.gen.dart b/packages/pigeon/platform_tests/shared_test_plugin_code/lib/src/generated/core_tests.gen.dart
index 1b027d8..7f7a4d3 100644
--- a/packages/pigeon/platform_tests/shared_test_plugin_code/lib/src/generated/core_tests.gen.dart
+++ b/packages/pigeon/platform_tests/shared_test_plugin_code/lib/src/generated/core_tests.gen.dart
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
-// Autogenerated from Pigeon (v4.2.9), do not edit directly.
+// Autogenerated from Pigeon (v4.2.10), do not edit directly.
// See also: https://pub.dev/packages/pigeon
// ignore_for_file: public_member_api_docs, non_constant_identifier_names, avoid_as, unused_import, unnecessary_parenthesis, prefer_null_aware_operators, omit_local_variable_types, unused_shown_name, unnecessary_import
import 'dart:async';
@@ -285,6 +285,98 @@
}
}
+ /// Returns passed in arguments of multiple types.
+ Future<AllTypes> sendMultipleTypes(
+ bool arg_aBool, int arg_anInt, String arg_aString) async {
+ final BasicMessageChannel<Object?> channel = BasicMessageChannel<Object?>(
+ 'dev.flutter.pigeon.HostIntegrationCoreApi.sendMultipleTypes', codec,
+ binaryMessenger: _binaryMessenger);
+ final Map<Object?, Object?>? replyMap =
+ await channel.send(<Object?>[arg_aBool, arg_anInt, arg_aString])
+ as Map<Object?, Object?>?;
+ if (replyMap == null) {
+ throw PlatformException(
+ code: 'channel-error',
+ message: 'Unable to establish connection on channel.',
+ );
+ } else if (replyMap['error'] != null) {
+ final Map<Object?, Object?> error =
+ (replyMap['error'] as Map<Object?, Object?>?)!;
+ throw PlatformException(
+ code: (error['code'] as String?)!,
+ message: error['message'] as String?,
+ details: error['details'],
+ );
+ } else if (replyMap['result'] == null) {
+ throw PlatformException(
+ code: 'null-error',
+ message: 'Host platform returned null value for non-null return value.',
+ );
+ } else {
+ return (replyMap['result'] as AllTypes?)!;
+ }
+ }
+
+ /// Returns passed in int.
+ Future<int> echoInt(int arg_anInt) async {
+ final BasicMessageChannel<Object?> channel = BasicMessageChannel<Object?>(
+ 'dev.flutter.pigeon.HostIntegrationCoreApi.echoInt', codec,
+ binaryMessenger: _binaryMessenger);
+ final Map<Object?, Object?>? replyMap =
+ await channel.send(<Object?>[arg_anInt]) as Map<Object?, Object?>?;
+ if (replyMap == null) {
+ throw PlatformException(
+ code: 'channel-error',
+ message: 'Unable to establish connection on channel.',
+ );
+ } else if (replyMap['error'] != null) {
+ final Map<Object?, Object?> error =
+ (replyMap['error'] as Map<Object?, Object?>?)!;
+ throw PlatformException(
+ code: (error['code'] as String?)!,
+ message: error['message'] as String?,
+ details: error['details'],
+ );
+ } else if (replyMap['result'] == null) {
+ throw PlatformException(
+ code: 'null-error',
+ message: 'Host platform returned null value for non-null return value.',
+ );
+ } else {
+ return (replyMap['result'] as int?)!;
+ }
+ }
+
+ /// Returns the passed in boolean asynchronously.
+ Future<bool> echoBool(bool arg_aBool) async {
+ final BasicMessageChannel<Object?> channel = BasicMessageChannel<Object?>(
+ 'dev.flutter.pigeon.HostIntegrationCoreApi.echoBool', codec,
+ binaryMessenger: _binaryMessenger);
+ final Map<Object?, Object?>? replyMap =
+ await channel.send(<Object?>[arg_aBool]) as Map<Object?, Object?>?;
+ if (replyMap == null) {
+ throw PlatformException(
+ code: 'channel-error',
+ message: 'Unable to establish connection on channel.',
+ );
+ } else if (replyMap['error'] != null) {
+ final Map<Object?, Object?> error =
+ (replyMap['error'] as Map<Object?, Object?>?)!;
+ throw PlatformException(
+ code: (error['code'] as String?)!,
+ message: error['message'] as String?,
+ details: error['details'],
+ );
+ } else if (replyMap['result'] == null) {
+ throw PlatformException(
+ code: 'null-error',
+ message: 'Host platform returned null value for non-null return value.',
+ );
+ } else {
+ return (replyMap['result'] as bool?)!;
+ }
+ }
+
/// A no-op function taking no arguments and returning no value, to sanity
/// test basic asynchronous calling.
Future<void> noopAsync() async {
diff --git a/packages/pigeon/platform_tests/test_plugin/android/src/main/kotlin/com/example/test_plugin/TestPlugin.kt b/packages/pigeon/platform_tests/test_plugin/android/src/main/kotlin/com/example/test_plugin/TestPlugin.kt
index 9a2961b..73d9a71 100644
--- a/packages/pigeon/platform_tests/test_plugin/android/src/main/kotlin/com/example/test_plugin/TestPlugin.kt
+++ b/packages/pigeon/platform_tests/test_plugin/android/src/main/kotlin/com/example/test_plugin/TestPlugin.kt
@@ -48,6 +48,19 @@
return AllTypesWrapper(AllTypes(aString = string))
}
+ override fun sendMultipleTypes(aBool: Boolean, anInt: Long, aString: String): AllTypes {
+ var someThings = AllTypes(aBool = aBool, anInt = anInt, aString = aString)
+ return someThings
+ }
+
+ override fun echoInt(anInt: Long): Long {
+ return anInt
+ }
+
+ override fun echoBool(aBool: Boolean): Boolean {
+ return aBool
+ }
+
override fun noopAsync(callback: () -> Unit) {
callback()
}
diff --git a/packages/pigeon/platform_tests/test_plugin/ios/Classes/TestPlugin.swift b/packages/pigeon/platform_tests/test_plugin/ios/Classes/TestPlugin.swift
index 73fc349..441d980 100644
--- a/packages/pigeon/platform_tests/test_plugin/ios/Classes/TestPlugin.swift
+++ b/packages/pigeon/platform_tests/test_plugin/ios/Classes/TestPlugin.swift
@@ -43,6 +43,19 @@
return AllTypesWrapper(values: AllTypes(aString: string))
}
+ func sendMultipleTypes(aBool: Bool, anInt: Int32, aString: String) -> AllTypes {
+ let someThings = AllTypes(aBool: aBool, anInt: anInt, aString: aString)
+ return someThings
+ }
+
+ func echoInt(anInt: Int32) -> Int32 {
+ return anInt
+ }
+
+ func echoBool(aBool: Bool) -> Bool {
+ return aBool
+ }
+
func noopAsync(completion: @escaping () -> Void) {
completion()
}
diff --git a/packages/pigeon/platform_tests/test_plugin/macos/Classes/TestPlugin.swift b/packages/pigeon/platform_tests/test_plugin/macos/Classes/TestPlugin.swift
index a9da20c..2b22866 100644
--- a/packages/pigeon/platform_tests/test_plugin/macos/Classes/TestPlugin.swift
+++ b/packages/pigeon/platform_tests/test_plugin/macos/Classes/TestPlugin.swift
@@ -43,6 +43,19 @@
return AllTypesWrapper(values: AllTypes(aString: string))
}
+ func sendMultipleTypes(aBool: Bool, anInt: Int32, aString: String) -> AllTypes {
+ let someThings = AllTypes(aBool: aBool, anInt: anInt, aString: aString)
+ return someThings
+ }
+
+ func echoInt(anInt: Int32) -> Int32 {
+ return anInt
+ }
+
+ func echoBool(aBool: Bool) -> Bool {
+ return aBool
+ }
+
func noopAsync(completion: @escaping () -> Void) {
completion()
}
diff --git a/packages/pigeon/platform_tests/test_plugin/windows/test_plugin.cpp b/packages/pigeon/platform_tests/test_plugin/windows/test_plugin.cpp
index 43dbd0b..e6a4221 100644
--- a/packages/pigeon/platform_tests/test_plugin/windows/test_plugin.cpp
+++ b/packages/pigeon/platform_tests/test_plugin/windows/test_plugin.cpp
@@ -65,6 +65,19 @@
return wrapper;
}
+ErrorOr<AllTypes> TestPlugin::SendMultipleTypes(bool a_bool, int64_t an_int,
+ const std::string& a_string) {
+ AllTypes someTypes;
+ someTypes.set_a_bool(a_bool);
+ someTypes.set_an_int(an_int);
+ someTypes.set_a_string(a_string);
+ return someTypes;
+};
+
+ErrorOr<int64_t> TestPlugin::EchoInt(int64_t an_int) { return an_int; }
+
+ErrorOr<bool> TestPlugin::EchoBool(bool a_bool) { return a_bool; }
+
void TestPlugin::NoopAsync(
std::function<void(std::optional<FlutterError> reply)> result) {
result(std::nullopt);
diff --git a/packages/pigeon/platform_tests/test_plugin/windows/test_plugin.h b/packages/pigeon/platform_tests/test_plugin/windows/test_plugin.h
index 0b162d0..4c4bfac 100644
--- a/packages/pigeon/platform_tests/test_plugin/windows/test_plugin.h
+++ b/packages/pigeon/platform_tests/test_plugin/windows/test_plugin.h
@@ -41,6 +41,11 @@
const core_tests_pigeontest::AllTypesWrapper& wrapper) override;
core_tests_pigeontest::ErrorOr<core_tests_pigeontest::AllTypesWrapper>
CreateNestedString(const std::string& string) override;
+ core_tests_pigeontest::ErrorOr<core_tests_pigeontest::AllTypes>
+ SendMultipleTypes(bool a_bool, int64_t an_int,
+ const std::string& a_string) override;
+ core_tests_pigeontest::ErrorOr<int64_t> EchoInt(int64_t an_int) override;
+ core_tests_pigeontest::ErrorOr<bool> EchoBool(bool a_bool) override;
void NoopAsync(std::function<
void(std::optional<core_tests_pigeontest::FlutterError> reply)>
result) override;