Skip to content

[web] Allow overriding platformViewRegistry for testing. #170143

@ksokolovskyi

Description

@ksokolovskyi

Use case

When developers want to embed an HTML element in the widget hierarchy in Flutter web, they use HtmlElementView. Under the hood, HtmlElementView uses method channels and platformViewRegistry from dart:ui_web.

Let's say a user wants to test that the HTML element is created and configured as expected via HtmlElementView in widgets test on Chrome (by using --platform chrome option).
Mocking of method channels is trivial by using TestDefaultBinaryMessenger.setMockMethodCallHandler. However, mocking of platformViewRegistry is not possible. So the user has to switch to the integration tests in order to test the aforementioned scenario, which might not be an option for some users.

Proposal

Add a visible for testing debugOverridePlatformViewRegistry function to the ui_web to allow users to override platformViewRegistry in tests.

Metadata

Metadata

Assignees

Labels

c: new featureNothing broken; request for a new capabilityc: proposalA detailed proposal for a change to Flutterengineflutter/engine related. See also e: labels.platform-webWeb applications specificallyr: fixedIssue is closed as already fixed in a newer versionteam-webOwned by Web platform team

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions