Skip to content

[pigeon] Add a protocol for Flutter APIs in the Swift generator #136811

@stuartmorgan-g

Description

@stuartmorgan-g

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Important issues not at the top of the work listc: new featureNothing broken; request for a new capabilityp: pigeonrelated to pigeon messaging codegen toolpackageflutter/packages repository. See also p: labels.platform-iosiOS applications specificallyplatform-macBuilding on or for macOS specificallyteam-ecosystemOwned by Ecosystem teamtriaged-ecosystemTriaged by Ecosystem team

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions