Comment rationale for code

This commit is contained in:
Yaakov Schectman 2024-11-07 14:10:32 -05:00
parent c55766fed0
commit 5cc8367e5a
3 changed files with 13 additions and 0 deletions

View File

@ -81,6 +81,9 @@ Future<void> 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',
<String>[

View File

@ -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

View File

@ -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;