diff --git a/test/ch934x_serial_method_channel_test.dart b/test/ch934x_serial_method_channel_test.dart index e74b841..efa93f3 100644 --- a/test/ch934x_serial_method_channel_test.dart +++ b/test/ch934x_serial_method_channel_test.dart @@ -23,8 +23,8 @@ void main() { void mockCall(Future Function(MethodCall) handler) { TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger .setMockMethodCallHandler(channel, (MethodCall call) async { - return handler(call); - }); + return handler(call); + }); } test('getDeviceList 解析为 Ch934xDeviceInfo 列表', () async { @@ -102,6 +102,31 @@ void main() { expect(written, 0); }); + test('setSerialParameter 透传全部串口参数和流控开关', () async { + mockCall((call) async { + expect(call.method, 'setSerialParameter'); + expect(call.arguments, { + 'baud': 115200, + 'dataBit': 8, + 'stopBit': 1, + 'parityBit': 0, + 'flow': false, + }); + return true; + }); + + expect( + await platform.setSerialParameter( + baud: 115200, + dataBit: 8, + stopBit: 1, + parityBit: 0, + flow: false, + ), + isTrue, + ); + }); + test('getModemStatus 默认回退到 0', () async { mockCall((_) async => null); expect(await platform.getModemStatus(), 0);