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 Jun 14, 2022

Let MockBinaryMessenger internally manage the FlBinaryMessenger wrapper
instance and provide it via operator FlBinaryMessenger*() to avoid
having to create two objects in every test. The same technique was used
for MockSettings in #32618.

This helps to reduce the boilerplate required in the upcoming text input
tests
that heavily rely on MockBinaryMessenger.

Before:

::testing::NiceMock<flutter::testing::MockBinaryMessenger> mock_messenger;
g_autoptr(FlBinaryMessenger) messenger =
    fl_binary_messenger_new_mock(&mock_messenger);
// ...
mock.ReceiveMessage(messenger, "flutter/foo", message);

After:

::testing::NiceMock<flutter::testing::MockBinaryMessenger> messenger;
// ...
messenger.ReceiveMessage("flutter/foo", message);

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.
  • I updated/added relevant documentation (doc comments with ///).
  • I signed the [CLA].
  • All existing and new tests are passing.

Let MockBinaryMessenger internally manage the FlBinaryMessenger wrapper
instance and provide it via operator FlBinaryMessenger*() to avoid
having to create two objects in every test. The same technique was used
for MockSettings in flutter#32618.
@jpnurmi jpnurmi force-pushed the mock-binary-messenger branch from 5f6122d to bf50fb0 Compare June 14, 2022 12:21
@jpnurmi
Copy link
Member Author

jpnurmi commented Jun 20, 2022

Ping @robert-ancell. I'm ready to open a PR with tests for text input after this.

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

@robert-ancell robert-ancell merged commit 9dabcb5 into flutter:main Jun 20, 2022
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Jun 21, 2022
@jpnurmi jpnurmi deleted the mock-binary-messenger branch June 21, 2022 05:22
houhuayong pushed a commit to houhuayong/engine that referenced this pull request Jun 21, 2022
…ter#34029)

Let MockBinaryMessenger internally manage the FlBinaryMessenger wrapper
instance and provide it via operator FlBinaryMessenger*() to avoid
having to create two objects in every test. The same technique was used
for MockSettings in flutter#32618.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants