Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Conversation

@jpnurmi
Copy link
Member

@jpnurmi jpnurmi commented Apr 13, 2022

This is a preparation step split off from #32618 that will eventually fix light
vs. dark theme detection on Linux (flutter/flutter#101438).

GMock doesn't support mocking plain C-functions but GTypeInterface calls
can be forwarded to a mock object in a way that looks a lot like mocking
plain C-functions:

testing::flutter::MockBinaryMessenger mock;
FlBinaryMessenger* messenger = fl_binary_messenger_new_mock(mock);

EXPECT_CALL(mock, fl_binary_messenger_send_on_channel(...)).WillOnce(...);

do_something(messenger);

Pre-launch Checklist

  • I read the Contributor Guide and followed the process outlined there for submitting PRs.
  • I read the Tree Hygiene wiki page, which explains my responsibilities.
  • I read and followed the Flutter Style Guide and the C++, Objective-C, Java style guides.
  • I listed at least one issue that this PR fixes in the description above.
  • I added new tests to check the change I am making or feature I am adding, or Hixie said the PR is test-exempt. See testing the engine for instructions on
    writing and running engine tests.
  • I updated/added relevant documentation (doc comments with ///).
  • I signed the CLA.
  • All existing and new tests are passing.

If you need help, consider asking for advice on the #hackers-new channel on Discord.

jpnurmi added 2 commits April 13, 2022 17:29
This follows the common naming convention for fake implementations,
and makes room for a GMock-based mock implementation that registers
calls and allows settings expectations.
GMock doesn't support mocking plain C-functions but GTypeInterface calls
can be forwarded to a mock object in a way that looks a lot like mocking
plain C-functions:

```c
testing::flutter::MockBinaryMessenger mock;
FlBinaryMessenger* messenger = fl_binary_messenger_new_mock(mock);

EXPECT_CALL(mock, fl_binary_messenger_send_on_channel(...)).WillOnce(...);

do_something(messenger);
```
Copy link
Contributor

@robert-ancell robert-ancell left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@chinmaygarde chinmaygarde added the waiting for tree to go green This PR is approved and tested, but waiting for the tree to be green to land. label Apr 14, 2022
@fluttergithubbot
Copy link
Contributor

This pull request is not suitable for automatic merging in its current state.

  • Please get at least one approved review if you are already a member or two member reviews if you are not a member before re-applying this label. Reviewers: If you left a comment approving, please use the "approve" review action instead.

@fluttergithubbot fluttergithubbot removed the waiting for tree to go green This PR is approved and tested, but waiting for the tree to be green to land. label Apr 14, 2022
@chinmaygarde chinmaygarde added the waiting for tree to go green This PR is approved and tested, but waiting for the tree to be green to land. label Apr 14, 2022
@fluttergithubbot fluttergithubbot merged commit 97fbf34 into flutter:main Apr 14, 2022
@jpnurmi jpnurmi deleted the mock-messenger branch April 14, 2022 20:21
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Apr 14, 2022
justinmc pushed a commit to justinmc/engine that referenced this pull request Apr 20, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

platform-linux waiting for tree to go green This PR is approved and tested, but waiting for the tree to be green to land.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants