From 5cc8367e5a95f2a52ec6f763ff1cb0eff2b150ff Mon Sep 17 00:00:00 2001 From: Yaakov Schectman Date: Thu, 7 Nov 2024 14:10:32 -0500 Subject: [PATCH] Comment rationale for code --- dev/bots/suite_runners/run_flutter_driver_android_tests.dart | 3 +++ .../kotlin/com/example/native_driver_test/MainActivity.kt | 5 +++++ .../test_driver/display_cutout_rotation_main_test.dart | 5 +++++ 3 files changed, 13 insertions(+) diff --git a/dev/bots/suite_runners/run_flutter_driver_android_tests.dart b/dev/bots/suite_runners/run_flutter_driver_android_tests.dart index 254e14ef37b..52fe47ef96e 100644 --- a/dev/bots/suite_runners/run_flutter_driver_android_tests.dart +++ b/dev/bots/suite_runners/run_flutter_driver_android_tests.dart @@ -81,6 +81,9 @@ Future runFlutterDriverAndroidTests() async { ); // A simulated cutout overlay is necessary to test display_cutout_rotation. + // Using adb to enable a cutout overlay once the test app is running breaks + // the connection with FlutterDriver; therefore, this setting must be set + // before `flutter drive` is executed. await runCommand( 'adb', [ diff --git a/dev/integration_tests/native_driver_test/android/app/src/main/kotlin/com/example/native_driver_test/MainActivity.kt b/dev/integration_tests/native_driver_test/android/app/src/main/kotlin/com/example/native_driver_test/MainActivity.kt index 05cf7dfba3d..e8e82a5d8c4 100644 --- a/dev/integration_tests/native_driver_test/android/app/src/main/kotlin/com/example/native_driver_test/MainActivity.kt +++ b/dev/integration_tests/native_driver_test/android/app/src/main/kotlin/com/example/native_driver_test/MainActivity.kt @@ -48,6 +48,11 @@ class MainActivity : FlutterActivity() { windowInsetsController.hide(WindowInsetsCompat.Type.systemBars()) actionBar?.hide() + // The default behavior on SDK level 34 and below is for display cutouts to be consumed + // before the insets would reach the engine. In order to receive the display cutouts in the + // engine, the test app must request that it be allowed to draw its content behind cutouts. + // See + // https://developer.android.com/reference/android/view/WindowManager.LayoutParams#layoutInDisplayCutoutMode if (Build.VERSION.SDK_INT >= 30) { window.attributes.layoutInDisplayCutoutMode = WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_ALWAYS diff --git a/dev/integration_tests/native_driver_test/test_driver/display_cutout_rotation_main_test.dart b/dev/integration_tests/native_driver_test/test_driver/display_cutout_rotation_main_test.dart index aea3bb69cc7..04ab8bde6ab 100644 --- a/dev/integration_tests/native_driver_test/test_driver/display_cutout_rotation_main_test.dart +++ b/dev/integration_tests/native_driver_test/test_driver/display_cutout_rotation_main_test.dart @@ -6,6 +6,11 @@ import 'package:flutter_driver/flutter_driver.dart'; import 'package:native_driver/native_driver.dart'; import 'package:test/test.dart'; +// These tests require that the device running them have a single cutout at the +// top of the display. A simulated cutout setting suffices; however, enabling +// one via adb must take place before `flutter drive` starts. Therefore, this +// setup is executed in run_flutter_driver_android_tests.dart, rather than in +// the below setupAll block. void main() async { late final FlutterDriver flutterDriver; late final NativeDriver nativeDriver;