Skip to content

Reland hybrid views test#181336

Merged
auto-submit[bot] merged 11 commits into
flutter:masterfrom
gmackall:reland_hybrid_views_test
Jan 23, 2026
Merged

Reland hybrid views test#181336
auto-submit[bot] merged 11 commits into
flutter:masterfrom
gmackall:reland_hybrid_views_test

Conversation

@gmackall

@gmackall gmackall commented Jan 22, 2026

Copy link
Copy Markdown
Member

This test was deleted in #162903 under the claim that it wasn't running, but it was actually (just only in bringup). In fact the glue code and ci.yaml target are still around. It tested stuff that isn't covered by the current testing landscape, like alert dialogue popup and event types being preserved.

The original pr was not a pure deletion so I maintained the good changes (mostly a change to use shared code for the app under test).

Had to make some changes (described in comments below) but the test is passing in its current state.

Text(
'Click count: $nestedViewClickCount',
key: const ValueKey<String>('NestedViewClickCount'),
),

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Before this change the test would hang locally 100% of the time, due to a combination of

  1. the tapChildView button not working
  2. the fact that the next line in main_test.dart tries to find the widget with the text

So because the tap failed, the widget didn't exist, so we would hang forever.

I fixed this by changing the test to just tap on the platform view instead of tapping on a button that then taps on the platform view. But I also figured we should change the above so that the test just fails instead of hanging.

await driver.tap(tapChildView);
final SerializableFinder childView = find.byValueKey('PlatformView');
await driver.tap(childView);
// delay of 1000ms to allow widget to update

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

In my defense this is what the original test was doing (the tapChildView button inserts a delay of 1000ms).

I don't have a ton of experience writing this type of test, my understanding is that:

  1. Because this is a driver test we don't have access to tester.settle/pumpAndSettle, which is what we really want here.
  2. gemini suggested we use driver.waitUntilNoTransientCallbacks(), which is allegedly a driver equivalent, but it only worked some of the time. The delay seems to always work

If you know of a better solution let me know.

@gmackall gmackall marked this pull request as ready for review January 22, 2026 20:25
@gmackall gmackall requested review from a team and jmagman January 22, 2026 20:27

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request re-introduces an integration test for hybrid Android views, focusing on motion event propagation and other platform view interactions. The changes include adding a new devicelab task, the test application code (Dart and Java), and the driver test script. The test logic is sound. I've identified a couple of areas for improvement: one is a refactoring opportunity to remove a redundant platform channel call as indicated by a TODO, and the other is a minor code cleanup to remove unused imports.

Comment on lines +9 to +14
import android.graphics.PixelFormat;
import android.util.Log;
import android.view.Gravity;
import android.view.MotionEvent;
import android.view.View;
import android.view.WindowManager;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

These imports are unused and can be removed to clean up the code. According to the Google Java Style Guide, which this repository follows for Java code, unused imports should be removed.

Suggested change
import android.graphics.PixelFormat;
import android.util.Log;
import android.view.Gravity;
import android.view.MotionEvent;
import android.view.View;
import android.view.WindowManager;
import android.view.MotionEvent;
import android.view.View;
References
  1. Java code should follow the Google Java Style Guide, which includes removing unused imports. (link)

MotionEvent event = MotionEventCodec.decode((HashMap<String, Object>) methodCall.arguments());
getFlutterView().dispatchTouchEvent(event);
// TODO(egarciad): Remove invokeMethod since it is not necessary.
mMethodChannel.invokeMethod("onTouch", MotionEventCodec.encode(event));

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

As the TODO on the previous line suggests, this invokeMethod call is redundant. The synthesizeEvent method is called from Dart, which already has the event data. Sending it back to Dart is an unnecessary round-trip. You can remove this line and adjust the Dart code to use the event data it already possesses. I've added a related comment on the Dart side with a suggested implementation.

Comment on lines +126 to +130
await viewChannel!.invokeMethod<void>('pipeTouchEvents');
print('replaying ${recordedEvents.length} motion events');
for (final Map<String, dynamic> event in recordedEvents.reversed) {
await channel.invokeMethod<void>('synthesizeEvent', event);
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

To address the redundant platform channel call in MainActivity.java, you can populate flutterViewEvents directly from recordedEvents here. This also requires clearing embeddedViewEvents to ensure a clean state for each test run.

      setState(() {
        flutterViewEvents = recordedEvents;
        embeddedViewEvents.clear();
      });
      await viewChannel!.invokeMethod<void>('pipeTouchEvents');
      print('replaying ${recordedEvents.length} motion events');
      for (final Map<String, dynamic> event in recordedEvents.reversed) {
        await channel.invokeMethod<void>('synthesizeEvent', event);
      }

@reidbaker reidbaker left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

RSLGTM

@gmackall gmackall added the autosubmit Merge PR when tree becomes green via auto submit App label Jan 23, 2026
@auto-submit auto-submit Bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Jan 23, 2026
@auto-submit

auto-submit Bot commented Jan 23, 2026

Copy link
Copy Markdown
Contributor

autosubmit label was removed for flutter/flutter/181336, because - The status or check suite Linux analyze has failed. Please fix the issues identified (or deflake) before re-applying this label.

@gmackall gmackall added the autosubmit Merge PR when tree becomes green via auto submit App label Jan 23, 2026
@auto-submit auto-submit Bot added this pull request to the merge queue Jan 23, 2026
Merged via the queue into flutter:master with commit 112f170 Jan 23, 2026
148 of 149 checks passed
@flutter-dashboard flutter-dashboard Bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Jan 23, 2026
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jan 23, 2026
auto-submit Bot pushed a commit to flutter/packages that referenced this pull request Jan 23, 2026
Roll Flutter from 48c2475 to bfc9041eb118 (173 revisions)

flutter/flutter@48c2475...bfc9041

2026-01-23 [email protected] No longer exiting the application when the RegularWindow is destroyed + resolving the window created promise after runWidget (flutter/flutter#181339)
2026-01-23 [email protected] Remove unnecessary Material import from dialog_test.dart (flutter/flutter#181249)
2026-01-23 [email protected] Roll Skia from 8e516fe6828f to db10db8bd55f (1 revision) (flutter/flutter#181379)
2026-01-23 [email protected] Reset TextFormField to initial value after state change (flutter/flutter#181199)
2026-01-23 [email protected] Roll Dart SDK from 980b2b41d36e to e82d7ad1855e (1 revision) (flutter/flutter#181375)
2026-01-23 [email protected] Roll Skia from 3e86f377d300 to 8e516fe6828f (4 revisions) (flutter/flutter#181370)
2026-01-23 [email protected] Remove unnecessary Material import from sliver_visibility_test (flutter/flutter#181248)
2026-01-23 [email protected] Add bottom navigation bar item semantics label (flutter/flutter#180577)
2026-01-23 [email protected] Make topGap not required for CupertinoSheetTransition (flutter/flutter#181269)
2026-01-23 [email protected] Roll Fuchsia Linux SDK from b4cLyhuxciUC-4zCJ... to n7NohL9DPpEuPjNt9... (flutter/flutter#181365)
2026-01-23 [email protected] Roll Dart SDK from 806f04638561 to 980b2b41d36e (1 revision) (flutter/flutter#181364)
2026-01-23 [email protected] Reland hybrid views test (flutter/flutter#181336)
2026-01-23 [email protected] Revert DropdownMenu non-nullable breaking change (flutter/flutter#181074)
2026-01-23 [email protected] Fix leaks in `flutter_test` tests (flutter/flutter#180879)
2026-01-23 [email protected] Re-enable fragment_shader_tests.dart 'Shader Compiler appropriately pads vec3 uniform arrays' test on Vulkan (flutter/flutter#181292)
2026-01-23 [email protected] [ Tool ] Fix `update-packages` failing due to mismatched dependencies between flutter_tools and the framework (flutter/flutter#181335)
2026-01-23 [email protected] [Impeller] Make dynamically created shader metadata for runtime effects consistent with metadata for built-in shaders (flutter/flutter#181201)
2026-01-23 [email protected] Broaden the applicability of `Color` fix_data rules from flutter/painting.dart (flutter/flutter#181093)
2026-01-23 [email protected] Fixes macOS App.framework not being codesigned or find framework (flutter/flutter#181348)
2026-01-22 [email protected] Roll Fuchsia GN SDK from NAEC5tfgSl8g94nwp... to JLBh4Z9PKsjIJcqDU... (flutter/flutter#181139)
2026-01-22 [email protected] Roll Dart SDK from ab4640ea82e9 to 806f04638561 (2 revisions) (flutter/flutter#181347)
2026-01-22 [email protected] Add ExpansibleController.toggle method. (flutter/flutter#181320)
2026-01-22 [email protected] Fixes Typo in codebase (flutter/flutter#181256)
2026-01-22 [email protected] Roll Skia from 4766615bcc96 to 3e86f377d300 (3 revisions) (flutter/flutter#181346)
2026-01-22 [email protected] Make sure that a Hero doesn't crash in 0x0 environment (flutter/flutter#180954)
2026-01-22 [email protected] Reland "Fix capitalization of the path to FlutterWindowControllerTest.mm in the macOS platform build script" (flutter/flutter#181200)
2026-01-22 [email protected] Roll Skia from 6e9746be8c4a to 4766615bcc96 (3 revisions) (flutter/flutter#181331)
2026-01-22 [email protected] Fix remove material import textfield (flutter/flutter#181254)
2026-01-22 [email protected] Add FlutterFramework as an Xcode SwiftPM local package override (flutter/flutter#179512)
2026-01-22 [email protected] Roll Dart SDK from 7bd4c68b625c to ab4640ea82e9 (1 revision) (flutter/flutter#181324)
2026-01-22 [email protected] Roll Packages from d80c60e to 9010299 (9 revisions) (flutter/flutter#181323)
2026-01-22 [email protected] Roll Dart SDK from 2d53a77adc5d to 7bd4c68b625c (2 revisions) (flutter/flutter#181316)
2026-01-22 [email protected] Roll Skia from 3f6949bc5780 to 6e9746be8c4a (2 revisions) (flutter/flutter#181311)
2026-01-22 [email protected] Roll Skia from ef6efc358b4a to 3f6949bc5780 (2 revisions) (flutter/flutter#181307)
2026-01-22 [email protected] Roll Dart SDK from 5d7c8faf2e41 to 2d53a77adc5d (1 revision) (flutter/flutter#181305)
2026-01-22 [email protected] [Material] update hourFormat to use Dart 3 switch expression (flutter/flutter#181041)
2026-01-22 [email protected] Use null-aware elements in cupertino/nav_bar.dart (flutter/flutter#181237)
2026-01-22 [email protected] Roll Fuchsia Linux SDK from b2KIEXVAlEqImQ9VO... to b4cLyhuxciUC-4zCJ... (flutter/flutter#181297)
2026-01-22 [email protected] Roll pub packages (flutter/flutter#181295)
2026-01-22 [email protected] Enables fragment shader test for impeller (fixes mat2 on vulkan) (flutter/flutter#181013)
2026-01-21 [email protected] Roll Dart SDK from 366200db1aa1 to 5d7c8faf2e41 (4 revisions) (flutter/flutter#181290)
2026-01-21 [email protected] Roll Skia from b5ec89e31f59 to ef6efc358b4a (19 revisions) (flutter/flutter#181289)
2026-01-21 [email protected] fix description for semantics finders (flutter/flutter#181214)
2026-01-21 [email protected] Make sure that an Icon doesn't crash in 0x0 environment (flutter/flutter#181021)
2026-01-21 [email protected] Make sure that a GridPaper doesn't crash in 0x0 environment (flutter/flutter#180906)
2026-01-21 [email protected] Bring Linux coverage out of bringup (flutter/flutter#181280)
...
flutter-zl pushed a commit to flutter-zl/flutter that referenced this pull request Feb 10, 2026
This test was deleted in flutter#162903
under the claim that it wasn't running, but it was actually (just only
in bringup). In fact the [glue
code](https://github.com/flutter/flutter/blob/dbed04aa32e5f0319898d29c8996919ee6ae8e2e/dev/devicelab/lib/tasks/integration_tests.dart#L75)
and
[ci.yaml](https://github.com/flutter/flutter/blob/master/.ci.yaml#L2874)
target are still around. It tested stuff that isn't covered by the
current testing landscape, like alert dialogue popup and event types
being preserved.

The original pr was not a pure deletion so I maintained the good changes
(mostly a change to use shared code for the app under test).

Had to make some changes (described in comments below) but the test is
passing in its current state.

---------

Co-authored-by: Gray Mackall <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants