-
Notifications
You must be signed in to change notification settings - Fork 29.7k
Description
In flutter/packages#5159 we needed a binary messenger mock, which makes the test fragile to future changes to that class, and also dependent on some Pigeon internals. What we really want there is a mock of the FlutterApi that we've defined within the plugin, which would be more robust and easier to use. However, in Swift we can't mock without having a protocol.
For Flutter APIs, instead of generating just the class, we should generate a protocol with the methods defined in the Pigeon definition, and then the current class as implementing that protocol. Then unit tests can use an exposed-for-test initializer that passes in a mock API implementation (with the real init calling that helper with the current IosQuickActionsFlutterApi(binaryMessenger: messenger)), and there won't need to be a mock binary messenger at all.