Skip to content
This repository has been archived by the owner on Feb 22, 2023. It is now read-only.

[video_player] Eliminate platform channel from mock platform #4588

Merged

Conversation

stuartmorgan
Copy link
Contributor

When video_player was federated, the existing unit tests in the
app-facing package--which were based on mocking out the method
channel--were left as-is. Because of the use of Pigeon, and thus
Pigeon-generated mocks, this creates a dependency from the test code in
the app-facing package on test code that is published from the platform
interface package, which causes unwanted dependencies in the platform
interface.

This updates the tests in the app-facing package to follow best
practices for federated plugins, which is for the app-facing tests to
directly mock/fake the platform interface, not depend on the
method-channel-based implementation. This simplifies the tests, ensures
that they aren't also testing code from another package, and allows for
removing the test code from the public interface of the platform
interface package (in a seperate follow-up PR).

In order to allow the tests to work, the controller's caching of the
platform instance is changed to allow it to notice changes.

Part of flutter/flutter#83562

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 relevant style guides and ran the auto-formatter. (Unlike the flutter/flutter repo, the flutter/plugins repo does use dart format.)
  • I signed the CLA.
  • The title of the PR starts with the name of the plugin surrounded by square brackets, e.g. [shared_preferences]
  • I listed at least one issue that this PR fixes in the description above.
  • I updated pubspec.yaml with an appropriate new version according to the pub versioning philosophy, or this PR is exempt from version changes.
  • I updated CHANGELOG.md to add a description of the change, following repository CHANGELOG style.
  • I updated/added relevant documentation (doc comments with ///).
  • I added new tests to check the change I am making, or this PR is test-exempt.
  • All existing and new tests are passing.

When video_player was federated, the existing unit tests in the
app-facing package--which were based on mocking out the method
channel--were left as-is. Because of the use of Pigeon, and thus
Pigeon-generated mocks, this creates a dependency from the test code in
the app-facing package on test code that is published from the platform
interface package, which causes unwanted dependencies in the platform
interface.

This updates the tests in the app-facing package to follow best
practices for federated plugins, which is for the app-facing tests to
directly mock/fake the platform interface, not depend on the
method-channel-based implementation. This simplifies the tests, ensures
that they aren't also testing code from another package, and allows for
removing the test code from the public interface of the platform
interface package (in a seperate follow-up PR).

In order to allow the tests to work, the controller's caching of the
platform instance is changed to allow it to notice changes.

Part of flutter/flutter#83562
@flutter-dashboard

This comment has been minimized.

@flutter-dashboard flutter-dashboard bot changed the base branch from master to main December 7, 2021 16:22
@stuartmorgan stuartmorgan changed the base branch from main to master December 7, 2021 19:34
Copy link
Contributor

@bparrishMines bparrishMines left a comment

Choose a reason for hiding this comment

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

LGTM

@stuartmorgan stuartmorgan added the waiting for tree to go green (Use "autosubmit") This PR is approved and tested, but waiting for the tree to be green to land. label Dec 16, 2021
@fluttergithubbot fluttergithubbot merged commit ee97b65 into flutter:master Dec 16, 2021
KyleFin pushed a commit to KyleFin/plugins that referenced this pull request Dec 21, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
p: video_player waiting for tree to go green (Use "autosubmit") This PR is approved and tested, but waiting for the tree to be green to land.
Projects
None yet
3 participants