Skip to content

Commit

Permalink
feat: implement invokeMethodList
Browse files Browse the repository at this point in the history
  • Loading branch information
littleGnAl committed Mar 10, 2023
1 parent e4e1176 commit 15c6e38
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
8 changes: 8 additions & 0 deletions lib/src/iris_method_channel.dart
Original file line number Diff line number Diff line change
Expand Up @@ -485,6 +485,14 @@ class IrisMethodChannel {
return result;
}

Future<List<CallApiResult>> invokeMethodList(
List<IrisMethodCall> methodCalls) async {
final List<CallApiResult> result =
await messenger.listSend(_ApiCallListRequest(methodCalls));

return result;
}

Future<void> dispose() async {
if (!_initilized) return;
_hotRestartFinalizer.dispose();
Expand Down
26 changes: 26 additions & 0 deletions test/iris_method_channel_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,32 @@ void main() {
await irisMethodChannel.dispose();
});

test('invokeMethodList', () async {
final irisMethodChannel = IrisMethodChannel();
await irisMethodChannel.initilize(nativeBindingsProvider);
const methodCalls = [
IrisMethodCall('a_func_name', 'params'),
IrisMethodCall('a_func_name2', 'params')
];
final callApiResult = await irisMethodChannel.invokeMethodList(methodCalls);

final callRecord1 = messenger.callApiRecords
.where((e) => e.methodCall.funcName == 'a_func_name');
expect(callRecord1.length, 1);

final callRecord2 = messenger.callApiRecords
.where((e) => e.methodCall.funcName == 'a_func_name2');
expect(callRecord2.length, 1);

expect(callApiResult[0].irisReturnCode, 0);
expect(callApiResult[0].data, {});

expect(callApiResult[1].irisReturnCode, 0);
expect(callApiResult[1].data, {});

await irisMethodChannel.dispose();
});

test('registerEventHandler', () async {
final irisMethodChannel = IrisMethodChannel();
await irisMethodChannel.initilize(nativeBindingsProvider);
Expand Down

0 comments on commit 15c6e38

Please sign in to comment.