Skip to content

Commit 02e11f9

Browse files
authored
Add integration test for cutout rotation evaluation (flutter#160354)
Test that the position of a cutout as reported by the Android engine repositions based on screen orientation. Related to flutter/engine#55992 Part of flutter#155658 to test run flutter drive integration_test/display_cutout_test.dart from dev/integration_tests/display_cutout_rotation Pr also force upgrades pub dependencies because I was getting presubmit failure in version solve. ## Pre-launch Checklist - [x] I read the [Contributor Guide] and followed the process outlined there for submitting PRs. - [x] I read the [Tree Hygiene] wiki page, which explains my responsibilities. - [x] I read and followed the [Flutter Style Guide], including [Features we expect every widget to implement]. - [x] I signed the [CLA]. - [x] I listed at least one issue that this PR fixes in the description above. - [x] I updated/added relevant documentation (doc comments with `///`). - [x] I added new tests to check the change I am making, or this PR is [test-exempt]. - [x] I followed the [breaking change policy] and added [Data Driven Fixes] where supported. - [x] All existing and new tests are passing.
1 parent bf7daf2 commit 02e11f9

File tree

27 files changed

+796
-0
lines changed

27 files changed

+796
-0
lines changed
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# Miscellaneous
2+
*.class
3+
*.log
4+
*.pyc
5+
*.swp
6+
.DS_Store
7+
.atom/
8+
.build/
9+
.buildlog/
10+
.history
11+
.svn/
12+
.swiftpm/
13+
migrate_working_dir/
14+
15+
# IntelliJ related
16+
*.iml
17+
*.ipr
18+
*.iws
19+
.idea/
20+
21+
# The .vscode folder contains launch configuration and tasks you configure in
22+
# VS Code which you may wish to be included in version control, so this line
23+
# is commented out by default.
24+
#.vscode/
25+
26+
# Flutter/Dart/Pub related
27+
**/doc/api/
28+
**/ios/Flutter/.last_build_id
29+
.dart_tool/
30+
.flutter-plugins
31+
.flutter-plugins-dependencies
32+
.pub-cache/
33+
.pub/
34+
/build/
35+
36+
# Symbolication related
37+
app.*.symbols
38+
39+
# Obfuscation related
40+
app.*.map.json
41+
42+
# Android Studio will place build artifacts here
43+
/android/app/debug
44+
/android/app/profile
45+
/android/app/release
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# This file tracks properties of this Flutter project.
2+
# Used by Flutter tool to assess capabilities and perform upgrades etc.
3+
#
4+
# This file should be version controlled and should not be manually edited.
5+
6+
version:
7+
revision: "0dc4eb31df6fe16c1bac10bef3904eb378056c35"
8+
channel: "[user-branch]"
9+
10+
project_type: app
11+
12+
# Tracks metadata for the flutter migrate command
13+
migration:
14+
platforms:
15+
- platform: root
16+
create_revision: 0dc4eb31df6fe16c1bac10bef3904eb378056c35
17+
base_revision: 0dc4eb31df6fe16c1bac10bef3904eb378056c35
18+
- platform: android
19+
create_revision: 0dc4eb31df6fe16c1bac10bef3904eb378056c35
20+
base_revision: 0dc4eb31df6fe16c1bac10bef3904eb378056c35
21+
22+
# User provided section
23+
24+
# List of Local paths (relative to this file) that should be
25+
# ignored by the migrate tool.
26+
#
27+
# Files that are not part of the templates will be ignored by default.
28+
unmanaged_files:
29+
- 'lib/main.dart'
30+
- 'ios/Runner.xcodeproj/project.pbxproj'
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# display_cutout_rotation
2+
3+
To run test locally use `flutter drive integration_test/display_cutout_test.dart` from this folder.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
include: ../../analysis_options.yaml
2+
3+
analyzer:
4+
exclude:
5+
- build/**
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
gradle-wrapper.jar
2+
/.gradle
3+
/captures/
4+
/gradlew
5+
/gradlew.bat
6+
/local.properties
7+
GeneratedPluginRegistrant.java
8+
9+
# Remember to never publicly share your keystore.
10+
# See https://flutter.dev/to/reference-keystore
11+
key.properties
12+
**/*.keystore
13+
**/*.jks
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
plugins {
2+
id("com.android.application")
3+
id("kotlin-android")
4+
// The Flutter Gradle Plugin must be applied after the Android and Kotlin Gradle plugins.
5+
id("dev.flutter.flutter-gradle-plugin")
6+
}
7+
8+
android {
9+
namespace = "com.example.display_cutout_rotation"
10+
compileSdk = flutter.compileSdkVersion
11+
12+
compileOptions {
13+
sourceCompatibility = JavaVersion.VERSION_17
14+
targetCompatibility = JavaVersion.VERSION_17
15+
}
16+
17+
kotlinOptions {
18+
jvmTarget = "17"
19+
}
20+
21+
defaultConfig {
22+
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
23+
applicationId = "com.example.display_cutout_rotation"
24+
// You can update the following values to match your application needs.
25+
// For more information, see: https://flutter.dev/to/review-gradle-config.
26+
minSdk = flutter.minSdkVersion
27+
targetSdk = flutter.targetSdkVersion
28+
versionCode = flutter.versionCode
29+
versionName = flutter.versionName
30+
}
31+
32+
buildTypes {
33+
release {
34+
// TODO: Add your own signing config for the release build.
35+
// Signing with the debug keys for now, so `flutter run --release` works.
36+
signingConfig = signingConfigs.getByName("debug")
37+
}
38+
}
39+
}
40+
41+
flutter {
42+
source = "../.."
43+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<!-- Copyright 2014 The Flutter Authors. All rights reserved.
2+
Use of this source code is governed by a BSD-style license that can be
3+
found in the LICENSE file. -->
4+
5+
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
6+
<!-- The INTERNET permission is required for development. Specifically,
7+
the Flutter tool needs it to communicate with the running application
8+
to allow setting breakpoints, to provide hot reload, etc.
9+
-->
10+
<uses-permission android:name="android.permission.INTERNET"/>
11+
</manifest>
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
<!-- Copyright 2014 The Flutter Authors. All rights reserved.
2+
Use of this source code is governed by a BSD-style license that can be
3+
found in the LICENSE file. -->
4+
5+
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
6+
<application
7+
android:label="display_cutout_rotation"
8+
android:name="${applicationName}"
9+
android:icon="@mipmap/ic_launcher">
10+
<activity
11+
android:name=".MainActivity"
12+
android:exported="true"
13+
android:launchMode="singleTop"
14+
android:taskAffinity=""
15+
android:theme="@style/LaunchTheme"
16+
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
17+
android:hardwareAccelerated="true"
18+
android:windowSoftInputMode="adjustResize">
19+
<!-- Specifies an Android theme to apply to this Activity as soon as
20+
the Android process has started. This theme is visible to the user
21+
while the Flutter UI initializes. After that, this theme continues
22+
to determine the Window background behind the Flutter UI. -->
23+
<meta-data
24+
android:name="io.flutter.embedding.android.NormalTheme"
25+
android:resource="@style/NormalTheme"
26+
/>
27+
<intent-filter>
28+
<action android:name="android.intent.action.MAIN"/>
29+
<category android:name="android.intent.category.LAUNCHER"/>
30+
</intent-filter>
31+
</activity>
32+
<!-- Don't delete the meta-data below.
33+
This is used by the Flutter tool to generate GeneratedPluginRegistrant.java -->
34+
<meta-data
35+
android:name="flutterEmbedding"
36+
android:value="2" />
37+
</application>
38+
<!-- Required to query activities that can process text, see:
39+
https://developer.android.com/training/package-visibility and
40+
https://developer.android.com/reference/android/content/Intent#ACTION_PROCESS_TEXT.
41+
42+
In particular, this is used by the Flutter engine in io.flutter.plugin.text.ProcessTextPlugin. -->
43+
<queries>
44+
<intent>
45+
<action android:name="android.intent.action.PROCESS_TEXT"/>
46+
<data android:mimeType="text/plain"/>
47+
</intent>
48+
</queries>
49+
</manifest>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
// Copyright 2014 The Flutter Authors. All rights reserved.
2+
// Use of this source code is governed by a BSD-style license that can be
3+
// found in the LICENSE file.
4+
5+
@file:Suppress("PackageName")
6+
7+
package com.example.display_cutout_rotation
8+
9+
import android.os.Build
10+
import android.os.Bundle
11+
import android.view.WindowManager
12+
import androidx.core.view.WindowCompat
13+
import androidx.core.view.WindowInsetsCompat
14+
import androidx.core.view.WindowInsetsControllerCompat
15+
import io.flutter.embedding.android.FlutterActivity
16+
17+
class MainActivity : FlutterActivity() {
18+
override fun onCreate(savedInstanceState: Bundle?) {
19+
super.onCreate(savedInstanceState)
20+
21+
// https://developer.android.com/training/system-ui
22+
// Set app into fullscreen mode without insets from system bars.
23+
// Matches api 35 default behavior and is required by test which assumes no other inset
24+
// except for a cutout.
25+
val windowInsetsController = WindowCompat.getInsetsController(window, window.decorView)
26+
windowInsetsController.systemBarsBehavior = WindowInsetsControllerCompat.BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE
27+
windowInsetsController.hide(WindowInsetsCompat.Type.systemBars())
28+
29+
// The default behavior on SDK level 34 and below is for display cutouts to be consumed
30+
// before the insets would reach the engine. In order to receive the display cutouts in the
31+
// engine, the test app must request that it be allowed to draw its content behind cutouts.
32+
// See
33+
// https://developer.android.com/reference/android/view/WindowManager.LayoutParams#layoutInDisplayCutoutMode
34+
// LAYOUT_IN_DISPLAY_CUTOUT_MODE_ALWAYS was added in api 30 so we need to check api level
35+
// before setting the value. Not setting this value will prevent flutter from drawing in
36+
// cutout areas which our test is explicitly requires.
37+
if (Build.VERSION.SDK_INT >= 30) {
38+
window.attributes.layoutInDisplayCutoutMode =
39+
WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_ALWAYS
40+
}
41+
}
42+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<!-- Copyright 2014 The Flutter Authors. All rights reserved.
3+
Use of this source code is governed by a BSD-style license that can be
4+
found in the LICENSE file. -->
5+
6+
<!-- Modify this file to customize your launch splash screen -->
7+
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
8+
<item android:drawable="?android:colorBackground" />
9+
10+
<!-- You can insert your own image assets here -->
11+
<!-- <item>
12+
<bitmap
13+
android:gravity="center"
14+
android:src="@mipmap/launch_image" />
15+
</item> -->
16+
</layer-list>
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<!-- Copyright 2014 The Flutter Authors. All rights reserved.
3+
Use of this source code is governed by a BSD-style license that can be
4+
found in the LICENSE file. -->
5+
6+
<!-- Modify this file to customize your launch splash screen -->
7+
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
8+
<item android:drawable="@android:color/white" />
9+
10+
<!-- You can insert your own image assets here -->
11+
<!-- <item>
12+
<bitmap
13+
android:gravity="center"
14+
android:src="@mipmap/launch_image" />
15+
</item> -->
16+
</layer-list>
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<!-- Copyright 2014 The Flutter Authors. All rights reserved.
3+
Use of this source code is governed by a BSD-style license that can be
4+
found in the LICENSE file. -->
5+
6+
<resources>
7+
<!-- Theme applied to the Android Window while the process is starting when the OS's Dark Mode setting is on -->
8+
<style name="LaunchTheme" parent="@android:style/Theme.Black.NoTitleBar">
9+
<!-- Show a splash screen on the activity. Automatically removed when
10+
the Flutter engine draws its first frame -->
11+
<item name="android:windowBackground">@drawable/launch_background</item>
12+
</style>
13+
<!-- Theme applied to the Android Window as soon as the process has started.
14+
This theme determines the color of the Android Window while your
15+
Flutter UI initializes, as well as behind your Flutter UI while its
16+
running.
17+
18+
This Theme is only used starting with V2 of Flutter's Android embedding. -->
19+
<style name="NormalTheme" parent="@android:style/Theme.Black.NoTitleBar">
20+
<item name="android:windowBackground">?android:colorBackground</item>
21+
</style>
22+
</resources>
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<!-- Copyright 2014 The Flutter Authors. All rights reserved.
3+
Use of this source code is governed by a BSD-style license that can be
4+
found in the LICENSE file. -->
5+
6+
<resources>
7+
<!-- Theme applied to the Android Window while the process is starting when the OS's Dark Mode setting is off -->
8+
<style name="LaunchTheme" parent="@android:style/Theme.Light.NoTitleBar">
9+
<!-- Show a splash screen on the activity. Automatically removed when
10+
the Flutter engine draws its first frame -->
11+
<item name="android:windowBackground">@drawable/launch_background</item>
12+
</style>
13+
<!-- Theme applied to the Android Window as soon as the process has started.
14+
This theme determines the color of the Android Window while your
15+
Flutter UI initializes, as well as behind your Flutter UI while its
16+
running.
17+
18+
This Theme is only used starting with V2 of Flutter's Android embedding. -->
19+
<style name="NormalTheme" parent="@android:style/Theme.Light.NoTitleBar">
20+
<item name="android:windowBackground">?android:colorBackground</item>
21+
</style>
22+
</resources>
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<!-- Copyright 2014 The Flutter Authors. All rights reserved.
2+
Use of this source code is governed by a BSD-style license that can be
3+
found in the LICENSE file. -->
4+
5+
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
6+
<!-- The INTERNET permission is required for development. Specifically,
7+
the Flutter tool needs it to communicate with the running application
8+
to allow setting breakpoints, to provide hot reload, etc.
9+
-->
10+
<uses-permission android:name="android.permission.INTERNET"/>
11+
</manifest>
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
allprojects {
2+
repositories {
3+
google()
4+
mavenCentral()
5+
}
6+
}
7+
8+
val newBuildDir: Directory =
9+
rootProject.layout.buildDirectory
10+
.dir("../../build")
11+
.get()
12+
rootProject.layout.buildDirectory.value(newBuildDir)
13+
14+
subprojects {
15+
val newSubprojectBuildDir: Directory = newBuildDir.dir(project.name)
16+
project.layout.buildDirectory.value(newSubprojectBuildDir)
17+
}
18+
subprojects {
19+
project.evaluationDependsOn(":app")
20+
}
21+
22+
tasks.register<Delete>("clean") {
23+
delete(rootProject.layout.buildDirectory)
24+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
org.gradle.jvmargs=-Xmx8G -XX:MaxMetaspaceSize=4G -XX:ReservedCodeCacheSize=512m -XX:+HeapDumpOnOutOfMemoryError
2+
android.useAndroidX=true
3+
android.enableJetifier=true
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
distributionBase=GRADLE_USER_HOME
2+
distributionPath=wrapper/dists
3+
zipStoreBase=GRADLE_USER_HOME
4+
zipStorePath=wrapper/dists
5+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.10.2-all.zip

0 commit comments

Comments
 (0)