diff options
Diffstat (limited to 'tests')
178 files changed, 6269 insertions, 782 deletions
diff --git a/tests/BatteryStatsPerfTest/src/com/android/internal/os/BatteryUsageStatsPerfTest.java b/tests/BatteryStatsPerfTest/src/com/android/internal/os/BatteryUsageStatsPerfTest.java index fe2fe0b40891..08430f2f2744 100644 --- a/tests/BatteryStatsPerfTest/src/com/android/internal/os/BatteryUsageStatsPerfTest.java +++ b/tests/BatteryStatsPerfTest/src/com/android/internal/os/BatteryUsageStatsPerfTest.java @@ -159,7 +159,7 @@ public class BatteryUsageStatsPerfTest { private static BatteryUsageStats buildBatteryUsageStats() { final BatteryUsageStats.Builder builder = - new BatteryUsageStats.Builder(new String[]{"FOO"}, true, false) + new BatteryUsageStats.Builder(new String[]{"FOO"}, true, false, 0) .setBatteryCapacity(4000) .setDischargePercentage(20) .setDischargedPowerRange(1000, 2000) diff --git a/tests/FlickerTests/Android.bp b/tests/FlickerTests/Android.bp index 4ba538ed9d45..2ccc0fa9e1e7 100644 --- a/tests/FlickerTests/Android.bp +++ b/tests/FlickerTests/Android.bp @@ -23,14 +23,66 @@ package { default_applicable_licenses: ["frameworks_base_license"], } -android_test { - name: "FlickerTests", +filegroup { + name: "FlickerTestsBase-src", + srcs: ["src/com/android/server/wm/flicker/*.kt"], +} + +filegroup { + name: "FlickerTestsAppClose-src", + srcs: ["src/**/close/*.kt"], +} + +filegroup { + name: "FlickerTestsActivityEmbedding-src", srcs: [ - "src/**/*.java", - "src/**/*.kt", + "src/**/activityembedding/*.kt", + "src/**/activityembedding/open/*.kt", + "src/**/activityembedding/close/*.kt", + "src/**/activityembedding/layoutchange/*.kt", + "src/**/activityembedding/pip/*.kt", + "src/**/activityembedding/rotation/*.kt", + "src/**/activityembedding/rtl/*.kt", + "src/**/activityembedding/splitscreen/*.kt", + ], +} + +filegroup { + name: "FlickerTestsIme-src", + srcs: ["src/**/ime/*.kt"], +} + +filegroup { + name: "FlickerTestsAppLaunch-src", + srcs: ["src/**/launch/*.kt"], +} + +filegroup { + name: "FlickerTestsNotification-src", + srcs: ["src/**/notification/*.kt"], +} + +filegroup { + name: "FlickerTestsQuickswitch-src", + srcs: ["src/**/quickswitch/*.kt"], +} + +filegroup { + name: "FlickerTestsRotation-src", + srcs: ["src/**/rotation/*.kt"], +} + +filegroup { + name: "FlickerServiceTests-src", + srcs: [ + "src/com/android/server/wm/flicker/service/**/*.kt", ], - manifest: "AndroidManifest.xml", - test_config: "AndroidTest.xml", +} + +java_defaults { + name: "FlickerTestsDefault", + manifest: "manifests/AndroidManifest.xml", + test_config_template: "AndroidTestTemplate.xml", platform_apis: true, certificate: "platform", optimize: { @@ -42,16 +94,128 @@ android_test { "androidx.test.ext.junit", "flickertestapplib", "flickerlib", - "flickerlib-apphelpers", "flickerlib-helpers", - "truth-prebuilt", - "launcher-helper-lib", - "launcher-aosp-tapl", "platform-test-annotations", - "wm-flicker-window-extensions", + "wm-flicker-common-app-helpers", + "wm-shell-flicker-utils", ], data: [ ":FlickerTestApp", + "trace_config/*", + ], +} + +android_test { + name: "FlickerTestsOther", + defaults: ["FlickerTestsDefault"], + additional_manifests: ["manifests/AndroidManifestOther.xml"], + package_name: "com.android.server.wm.flicker", + instrumentation_target_package: "com.android.server.wm.flicker", + srcs: [ + "src/**/*.java", + "src/**/*.kt", + ], + exclude_srcs: [ + ":FlickerTestsAppClose-src", + ":FlickerTestsIme-src", + ":FlickerTestsAppLaunch-src", + ":FlickerTestsQuickswitch-src", + ":FlickerTestsRotation-src", + ":FlickerTestsNotification-src", + ":FlickerServiceTests-src", + ], +} + +android_test { + name: "FlickerTestsAppClose", + defaults: ["FlickerTestsDefault"], + additional_manifests: ["manifests/AndroidManifestAppClose.xml"], + package_name: "com.android.server.wm.flicker.close", + instrumentation_target_package: "com.android.server.wm.flicker.close", + srcs: [ + ":FlickerTestsBase-src", + ":FlickerTestsAppClose-src", + ], + exclude_srcs: [ + ":FlickerTestsActivityEmbedding-src", + ], +} + +android_test { + name: "FlickerTestsIme", + defaults: ["FlickerTestsDefault"], + additional_manifests: ["manifests/AndroidManifestIme.xml"], + package_name: "com.android.server.wm.flicker.ime", + instrumentation_target_package: "com.android.server.wm.flicker.ime", + srcs: [ + ":FlickerTestsBase-src", + ":FlickerTestsIme-src", + ], +} + +android_test { + name: "FlickerTestsAppLaunch", + defaults: ["FlickerTestsDefault"], + additional_manifests: ["manifests/AndroidManifestAppLaunch.xml"], + package_name: "com.android.server.wm.flicker.launch", + instrumentation_target_package: "com.android.server.wm.flicker.launch", + srcs: [ + ":FlickerTestsBase-src", + ":FlickerTestsAppLaunch-src", + ], + exclude_srcs: [ + ":FlickerTestsActivityEmbedding-src", + ], +} + +android_test { + name: "FlickerTestsNotification", + defaults: ["FlickerTestsDefault"], + additional_manifests: ["manifests/AndroidManifestNotification.xml"], + package_name: "com.android.server.wm.flicker.notification", + instrumentation_target_package: "com.android.server.wm.flicker.notification", + srcs: [ + ":FlickerTestsBase-src", + ":FlickerTestsNotification-src", + ], +} + +android_test { + name: "FlickerTestsQuickswitch", + defaults: ["FlickerTestsDefault"], + additional_manifests: ["manifests/AndroidManifestQuickswitch.xml"], + package_name: "com.android.server.wm.flicker.quickswitch", + instrumentation_target_package: "com.android.server.wm.flicker.quickswitch", + srcs: [ + ":FlickerTestsBase-src", + ":FlickerTestsQuickswitch-src", + ], +} + +android_test { + name: "FlickerTestsRotation", + defaults: ["FlickerTestsDefault"], + additional_manifests: ["manifests/AndroidManifestRotation.xml"], + package_name: "com.android.server.wm.flicker.rotation", + instrumentation_target_package: "com.android.server.wm.flicker.rotation", + srcs: [ + ":FlickerTestsBase-src", + ":FlickerTestsRotation-src", + ], + exclude_srcs: [ + ":FlickerTestsActivityEmbedding-src", + ], +} + +android_test { + name: "FlickerServiceTests", + defaults: ["FlickerTestsDefault"], + additional_manifests: ["manifests/AndroidManifestService.xml"], + package_name: "com.android.server.wm.flicker.service", + instrumentation_target_package: "com.android.server.wm.flicker.service", + srcs: [ + ":FlickerTestsBase-src", + ":FlickerServiceTests-src", ], } diff --git a/tests/FlickerTests/AndroidTest.xml b/tests/FlickerTests/AndroidTest.xml deleted file mode 100644 index 32ff243921ec..000000000000 --- a/tests/FlickerTests/AndroidTest.xml +++ /dev/null @@ -1,53 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<!-- - * Copyright 2018 Google Inc. All Rights Reserved. - --> -<configuration description="Runs WindowManager Flicker Tests"> - <option name="test-tag" value="FlickerTests" /> - <target_preparer class="com.android.tradefed.targetprep.DeviceSetup"> - <!-- keeps the screen on during tests --> - <option name="screen-always-on" value="on" /> - <!-- prevents the phone from restarting --> - <option name="force-skip-system-props" value="true" /> - <!-- set WM tracing verbose level to all --> - <option name="run-command" value="cmd window tracing level all" /> - <!-- set WM tracing to frame (avoid incomplete states) --> - <option name="run-command" value="cmd window tracing frame" /> - <!-- ensure lock screen mode is swipe --> - <option name="run-command" value="locksettings set-disabled false" /> - <!-- disable betterbug as it's log collection dialogues cause flakes in e2e tests --> - <option name="run-command" value="pm disable com.google.android.internal.betterbug" /> - <!-- restart launcher to activate TAPL --> - <option name="run-command" value="setprop ro.test_harness 1 ; am force-stop com.google.android.apps.nexuslauncher" /> - <!-- Ensure output directory is empty at the start --> - <option name="run-command" value="rm -rf /sdcard/flicker" /> - <!-- Increase trace size: 20mb for WM and 80mb for SF --> - <option name="run-command" value="cmd window tracing size 20480" /> - <option name="run-command" value="su root service call SurfaceFlinger 1029 i32 81920" /> - </target_preparer> - <target_preparer class="com.android.tradefed.targetprep.RunCommandTargetPreparer"> - <option name="run-command" value="settings put secure show_ime_with_hard_keyboard 1" /> - <option name="run-command" value="settings put system show_touches 1" /> - <option name="run-command" value="settings put system pointer_location 1" /> - <option name="teardown-command" value="settings delete secure show_ime_with_hard_keyboard" /> - <option name="teardown-command" value="settings delete system show_touches" /> - <option name="teardown-command" value="settings delete system pointer_location" /> - <option name="teardown-command" value="cmd overlay enable com.android.internal.systemui.navbar.gestural" /> - </target_preparer> - <target_preparer class="com.android.tradefed.targetprep.suite.SuiteApkInstaller"> - <option name="cleanup-apks" value="true"/> - <option name="test-file-name" value="FlickerTests.apk"/> - <option name="test-file-name" value="FlickerTestApp.apk" /> - </target_preparer> - <test class="com.android.tradefed.testtype.AndroidJUnitTest"> - <option name="package" value="com.android.server.wm.flicker"/> - <option name="shell-timeout" value="6600s" /> - <option name="test-timeout" value="6600s" /> - <option name="hidden-api-checks" value="false" /> - </test> - <metrics_collector class="com.android.tradefed.device.metric.FilePullerLogCollector"> - <option name="directory-keys" value="/sdcard/flicker" /> - <option name="collect-on-run-ended-only" value="true" /> - <option name="clean-up" value="true" /> - </metrics_collector> -</configuration> diff --git a/tests/FlickerTests/AndroidTestTemplate.xml b/tests/FlickerTests/AndroidTestTemplate.xml new file mode 100644 index 000000000000..44a824513b91 --- /dev/null +++ b/tests/FlickerTests/AndroidTestTemplate.xml @@ -0,0 +1,95 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- + * Copyright 2018 Google Inc. All Rights Reserved. + --> +<configuration description="Runs WindowManager {MODULE}"> + <option name="test-tag" value="FlickerTests"/> + <!-- Needed for storing the perfetto trace files in the sdcard/test_results--> + <option name="isolated-storage" value="false"/> + + <target_preparer class="com.android.tradefed.targetprep.DeviceSetup"> + <!-- keeps the screen on during tests --> + <option name="screen-always-on" value="on"/> + <!-- prevents the phone from restarting --> + <option name="force-skip-system-props" value="true"/> + <!-- set WM tracing verbose level to all --> + <option name="run-command" value="cmd window tracing level all"/> + <!-- set WM tracing to frame (avoid incomplete states) --> + <option name="run-command" value="cmd window tracing frame"/> + <!-- ensure lock screen mode is swipe --> + <option name="run-command" value="locksettings set-disabled false"/> + <!-- disable betterbug as it's log collection dialogues cause flakes in e2e tests --> + <option name="run-command" value="pm disable com.google.android.internal.betterbug"/> + <!-- restart launcher to activate TAPL --> + <option name="run-command" + value="setprop ro.test_harness 1 ; am force-stop com.google.android.apps.nexuslauncher"/> + <!-- Increase trace size: 20mb for WM and 80mb for SF --> + <option name="run-command" value="cmd window tracing size 20480"/> + <option name="run-command" value="su root service call SurfaceFlinger 1029 i32 81920"/> + </target_preparer> + <target_preparer class="com.android.tradefed.targetprep.RunCommandTargetPreparer"> + <option name="test-user-token" value="%TEST_USER%"/> + <option name="run-command" value="rm -rf /data/user/%TEST_USER%/files/*"/> + <option name="run-command" value="settings put secure show_ime_with_hard_keyboard 1"/> + <option name="run-command" value="settings put system show_touches 1"/> + <option name="run-command" value="settings put system pointer_location 1"/> + <option name="teardown-command" + value="settings delete secure show_ime_with_hard_keyboard"/> + <option name="teardown-command" value="settings delete system show_touches"/> + <option name="teardown-command" value="settings delete system pointer_location"/> + <option name="teardown-command" + value="cmd overlay enable com.android.internal.systemui.navbar.gestural"/> + </target_preparer> + <target_preparer class="com.android.tradefed.targetprep.suite.SuiteApkInstaller"> + <option name="cleanup-apks" value="true"/> + <option name="test-file-name" value="{MODULE}.apk"/> + <option name="test-file-name" value="FlickerTestApp.apk"/> + </target_preparer> + <!-- Needed for pushing the trace config file --> + <target_preparer class="com.android.tradefed.targetprep.RootTargetPreparer"/> + <target_preparer class="com.android.tradefed.targetprep.PushFilePreparer"> + <option name="push-file" + key="trace_config.textproto" + value="/data/misc/perfetto-traces/trace_config.textproto" + /> + <!--Install the content provider automatically when we push some file in sdcard folder.--> + <!--Needed to avoid the installation during the test suite.--> + <option name="push-file" key="trace_config.textproto" value="/sdcard/sample.textproto"/> + </target_preparer> + <test class="com.android.tradefed.testtype.AndroidJUnitTest"> + <option name="package" value="{PACKAGE}"/> + <option name="shell-timeout" value="6600s"/> + <option name="test-timeout" value="6600s"/> + <option name="hidden-api-checks" value="false"/> + <option name="device-listeners" value="android.device.collectors.PerfettoListener"/> + <!-- PerfettoListener related arguments --> + <option name="instrumentation-arg" key="perfetto_config_text_proto" value="true"/> + <option name="instrumentation-arg" + key="perfetto_config_file" + value="trace_config.textproto" + /> + <option name="instrumentation-arg" key="per_run" value="true"/> + </test> + <!-- Needed for pulling the collected trace config on to the host --> + <metrics_collector class="com.android.tradefed.device.metric.FilePullerLogCollector"> + <option name="pull-pattern-keys" value="perfetto_file_path"/> + <option name="directory-keys" + value="/data/user/0/com.android.server.wm.flicker/files"/> + <option name="directory-keys" + value="/data/user/0/com.android.server.wm.flicker.close/files"/> + <option name="directory-keys" + value="/data/user/0/com.android.server.wm.flicker.ime/files"/> + <option name="directory-keys" + value="/data/user/0/com.android.server.wm.flicker.launch/files"/> + <option name="directory-keys" + value="/data/user/0/com.android.server.wm.flicker.quickswitch/files"/> + <option name="directory-keys" + value="/data/user/0/com.android.server.wm.flicker.rotation/files"/> + <option name="directory-keys" + value="/data/user/0/com.android.server.wm.flicker.notification/files"/> + <option name="directory-keys" + value="/data/user/0/com.android.server.wm.flicker.service/files"/> + <option name="collect-on-run-ended-only" value="true"/> + <option name="clean-up" value="true"/> + </metrics_collector> +</configuration> diff --git a/tests/FlickerTests/AndroidManifest.xml b/tests/FlickerTests/manifests/AndroidManifest.xml index 462f91bc081c..1a34d9ea0f83 100644 --- a/tests/FlickerTests/AndroidManifest.xml +++ b/tests/FlickerTests/manifests/AndroidManifest.xml @@ -1,20 +1,22 @@ <?xml version="1.0" encoding="utf-8"?> -<!-- Copyright (C) 2018 The Android Open Source Project - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. ---> +<!-- + ~ Copyright (C) 2023 The Android Open Source Project + ~ + ~ Licensed under the Apache License, Version 2.0 (the "License"); + ~ you may not use this file except in compliance with the License. + ~ You may obtain a copy of the License at + ~ + ~ http://www.apache.org/licenses/LICENSE-2.0 + ~ + ~ Unless required by applicable law or agreed to in writing, software + ~ distributed under the License is distributed on an "AS IS" BASIS, + ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + ~ See the License for the specific language governing permissions and + ~ limitations under the License. + --> <manifest xmlns:android="http://schemas.android.com/apk/res/android" + xmlns:tools="http://schemas.android.com/tools" package="com.android.server.wm.flicker"> <uses-sdk android:minSdkVersion="29" android:targetSdkVersion="29"/> @@ -46,10 +48,11 @@ <application android:requestLegacyExternalStorage="true" android:largeHeap="true"> <uses-library android:name="android.test.runner"/> <uses-library android:name="androidx.window.extensions" android:required="false"/> - </application> - <instrumentation android:name="androidx.test.runner.AndroidJUnitRunner" - android:targetPackage="com.android.server.wm.flicker" - android:label="WindowManager Flicker Tests"> - </instrumentation> + <!-- (b/197936012) Remove startup provider due to test timeout issue --> + <provider + android:name="androidx.startup.InitializationProvider" + android:authorities="${applicationId}.androidx-startup" + tools:node="remove" /> + </application> </manifest> diff --git a/tests/FlickerTests/manifests/AndroidManifestAppClose.xml b/tests/FlickerTests/manifests/AndroidManifestAppClose.xml new file mode 100644 index 000000000000..4cdcb903b498 --- /dev/null +++ b/tests/FlickerTests/manifests/AndroidManifestAppClose.xml @@ -0,0 +1,24 @@ +<!-- + ~ Copyright (C) 2023 The Android Open Source Project + ~ + ~ Licensed under the Apache License, Version 2.0 (the "License"); + ~ you may not use this file except in compliance with the License. + ~ You may obtain a copy of the License at + ~ + ~ http://www.apache.org/licenses/LICENSE-2.0 + ~ + ~ Unless required by applicable law or agreed to in writing, software + ~ distributed under the License is distributed on an "AS IS" BASIS, + ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + ~ See the License for the specific language governing permissions and + ~ limitations under the License. + --> + +<manifest xmlns:android="http://schemas.android.com/apk/res/android" + package="com.android.server.wm.flicker.close"> + + <instrumentation android:name="androidx.test.runner.AndroidJUnitRunner" + android:targetPackage="com.android.server.wm.flicker.close" + android:label="WindowManager Flicker Tests"> + </instrumentation> +</manifest> diff --git a/tests/FlickerTests/manifests/AndroidManifestAppLaunch.xml b/tests/FlickerTests/manifests/AndroidManifestAppLaunch.xml new file mode 100644 index 000000000000..659a745ba480 --- /dev/null +++ b/tests/FlickerTests/manifests/AndroidManifestAppLaunch.xml @@ -0,0 +1,24 @@ +<!-- + ~ Copyright (C) 2023 The Android Open Source Project + ~ + ~ Licensed under the Apache License, Version 2.0 (the "License"); + ~ you may not use this file except in compliance with the License. + ~ You may obtain a copy of the License at + ~ + ~ http://www.apache.org/licenses/LICENSE-2.0 + ~ + ~ Unless required by applicable law or agreed to in writing, software + ~ distributed under the License is distributed on an "AS IS" BASIS, + ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + ~ See the License for the specific language governing permissions and + ~ limitations under the License. + --> + +<manifest xmlns:android="http://schemas.android.com/apk/res/android" + package="com.android.server.wm.flicker.launch"> + + <instrumentation android:name="androidx.test.runner.AndroidJUnitRunner" + android:targetPackage="com.android.server.wm.flicker.launch" + android:label="WindowManager Flicker Tests"> + </instrumentation> +</manifest> diff --git a/tests/FlickerTests/manifests/AndroidManifestIme.xml b/tests/FlickerTests/manifests/AndroidManifestIme.xml new file mode 100644 index 000000000000..abd03af4888a --- /dev/null +++ b/tests/FlickerTests/manifests/AndroidManifestIme.xml @@ -0,0 +1,24 @@ +<!-- + ~ Copyright (C) 2023 The Android Open Source Project + ~ + ~ Licensed under the Apache License, Version 2.0 (the "License"); + ~ you may not use this file except in compliance with the License. + ~ You may obtain a copy of the License at + ~ + ~ http://www.apache.org/licenses/LICENSE-2.0 + ~ + ~ Unless required by applicable law or agreed to in writing, software + ~ distributed under the License is distributed on an "AS IS" BASIS, + ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + ~ See the License for the specific language governing permissions and + ~ limitations under the License. + --> + +<manifest xmlns:android="http://schemas.android.com/apk/res/android" + package="com.android.server.wm.flicker.ime"> + + <instrumentation android:name="androidx.test.runner.AndroidJUnitRunner" + android:targetPackage="com.android.server.wm.flicker.ime" + android:label="WindowManager Flicker Tests"> + </instrumentation> +</manifest> diff --git a/tests/FlickerTests/manifests/AndroidManifestNotification.xml b/tests/FlickerTests/manifests/AndroidManifestNotification.xml new file mode 100644 index 000000000000..ad33deef8cc3 --- /dev/null +++ b/tests/FlickerTests/manifests/AndroidManifestNotification.xml @@ -0,0 +1,24 @@ +<!-- + ~ Copyright (C) 2023 The Android Open Source Project + ~ + ~ Licensed under the Apache License, Version 2.0 (the "License"); + ~ you may not use this file except in compliance with the License. + ~ You may obtain a copy of the License at + ~ + ~ http://www.apache.org/licenses/LICENSE-2.0 + ~ + ~ Unless required by applicable law or agreed to in writing, software + ~ distributed under the License is distributed on an "AS IS" BASIS, + ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + ~ See the License for the specific language governing permissions and + ~ limitations under the License. + --> + +<manifest xmlns:android="http://schemas.android.com/apk/res/android" + package="com.android.server.wm.flicker.close"> + + <instrumentation android:name="androidx.test.runner.AndroidJUnitRunner" + android:targetPackage="com.android.server.wm.flicker.notification" + android:label="WindowManager Flicker Tests"> + </instrumentation> +</manifest> diff --git a/tests/FlickerTests/manifests/AndroidManifestOther.xml b/tests/FlickerTests/manifests/AndroidManifestOther.xml new file mode 100644 index 000000000000..47749b8133b1 --- /dev/null +++ b/tests/FlickerTests/manifests/AndroidManifestOther.xml @@ -0,0 +1,24 @@ +<!-- + ~ Copyright (C) 2023 The Android Open Source Project + ~ + ~ Licensed under the Apache License, Version 2.0 (the "License"); + ~ you may not use this file except in compliance with the License. + ~ You may obtain a copy of the License at + ~ + ~ http://www.apache.org/licenses/LICENSE-2.0 + ~ + ~ Unless required by applicable law or agreed to in writing, software + ~ distributed under the License is distributed on an "AS IS" BASIS, + ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + ~ See the License for the specific language governing permissions and + ~ limitations under the License. + --> + +<manifest xmlns:android="http://schemas.android.com/apk/res/android" + package="com.android.server.wm.flicker"> + + <instrumentation android:name="androidx.test.runner.AndroidJUnitRunner" + android:targetPackage="com.android.server.wm.flicker" + android:label="WindowManager Flicker Tests"> + </instrumentation> +</manifest> diff --git a/tests/FlickerTests/manifests/AndroidManifestQuickswitch.xml b/tests/FlickerTests/manifests/AndroidManifestQuickswitch.xml new file mode 100644 index 000000000000..203035d30584 --- /dev/null +++ b/tests/FlickerTests/manifests/AndroidManifestQuickswitch.xml @@ -0,0 +1,24 @@ +<!-- + ~ Copyright (C) 2023 The Android Open Source Project + ~ + ~ Licensed under the Apache License, Version 2.0 (the "License"); + ~ you may not use this file except in compliance with the License. + ~ You may obtain a copy of the License at + ~ + ~ http://www.apache.org/licenses/LICENSE-2.0 + ~ + ~ Unless required by applicable law or agreed to in writing, software + ~ distributed under the License is distributed on an "AS IS" BASIS, + ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + ~ See the License for the specific language governing permissions and + ~ limitations under the License. + --> + +<manifest xmlns:android="http://schemas.android.com/apk/res/android" + package="com.android.server.wm.flicker.quickswitch"> + + <instrumentation android:name="androidx.test.runner.AndroidJUnitRunner" + android:targetPackage="com.android.server.wm.flicker.quickswitch" + android:label="WindowManager Flicker Tests"> + </instrumentation> +</manifest> diff --git a/tests/FlickerTests/manifests/AndroidManifestRotation.xml b/tests/FlickerTests/manifests/AndroidManifestRotation.xml new file mode 100644 index 000000000000..2852cf23a35b --- /dev/null +++ b/tests/FlickerTests/manifests/AndroidManifestRotation.xml @@ -0,0 +1,24 @@ +<!-- + ~ Copyright (C) 2023 The Android Open Source Project + ~ + ~ Licensed under the Apache License, Version 2.0 (the "License"); + ~ you may not use this file except in compliance with the License. + ~ You may obtain a copy of the License at + ~ + ~ http://www.apache.org/licenses/LICENSE-2.0 + ~ + ~ Unless required by applicable law or agreed to in writing, software + ~ distributed under the License is distributed on an "AS IS" BASIS, + ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + ~ See the License for the specific language governing permissions and + ~ limitations under the License. + --> + +<manifest xmlns:android="http://schemas.android.com/apk/res/android" + package="com.android.server.wm.flicker.rotation"> + + <instrumentation android:name="androidx.test.runner.AndroidJUnitRunner" + android:targetPackage="com.android.server.wm.flicker.rotation" + android:label="WindowManager Flicker Tests"> + </instrumentation> +</manifest> diff --git a/tests/FlickerTests/manifests/AndroidManifestService.xml b/tests/FlickerTests/manifests/AndroidManifestService.xml new file mode 100644 index 000000000000..3a7bc5095c08 --- /dev/null +++ b/tests/FlickerTests/manifests/AndroidManifestService.xml @@ -0,0 +1,24 @@ +<!-- + ~ Copyright (C) 2023 The Android Open Source Project + ~ + ~ Licensed under the Apache License, Version 2.0 (the "License"); + ~ you may not use this file except in compliance with the License. + ~ You may obtain a copy of the License at + ~ + ~ http://www.apache.org/licenses/LICENSE-2.0 + ~ + ~ Unless required by applicable law or agreed to in writing, software + ~ distributed under the License is distributed on an "AS IS" BASIS, + ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + ~ See the License for the specific language governing permissions and + ~ limitations under the License. + --> + +<manifest xmlns:android="http://schemas.android.com/apk/res/android" + package="com.android.server.wm.flicker.service"> + + <instrumentation android:name="androidx.test.runner.AndroidJUnitRunner" + android:targetPackage="com.android.server.wm.flicker.service" + android:label="WindowManager Flicker Service Tests"> + </instrumentation> +</manifest> diff --git a/tests/FlickerTests/src/com/android/server/wm/flicker/BaseTest.kt b/tests/FlickerTests/src/com/android/server/wm/flicker/BaseTest.kt index efd9b004f8fd..7c9c05d7da85 100644 --- a/tests/FlickerTests/src/com/android/server/wm/flicker/BaseTest.kt +++ b/tests/FlickerTests/src/com/android/server/wm/flicker/BaseTest.kt @@ -21,7 +21,7 @@ import android.platform.test.annotations.Presubmit import android.tools.common.traces.component.ComponentNameMatcher import android.tools.device.flicker.junit.FlickerBuilderProvider import android.tools.device.flicker.legacy.FlickerBuilder -import android.tools.device.flicker.legacy.FlickerTest +import android.tools.device.flicker.legacy.LegacyFlickerTest import android.util.Log import androidx.test.platform.app.InstrumentationRegistry import com.android.launcher3.tapl.LauncherInstrumentation @@ -37,7 +37,7 @@ import org.junit.Test abstract class BaseTest @JvmOverloads constructor( - protected val flicker: FlickerTest, + protected val flicker: LegacyFlickerTest, protected val instrumentation: Instrumentation = InstrumentationRegistry.getInstrumentation(), protected val tapl: LauncherInstrumentation = LauncherInstrumentation() ) { diff --git a/tests/FlickerTests/src/com/android/server/wm/flicker/CommonAssertions.kt b/tests/FlickerTests/src/com/android/server/wm/flicker/CommonAssertions.kt index ed9e14fd86da..b18a1a84c61b 100644 --- a/tests/FlickerTests/src/com/android/server/wm/flicker/CommonAssertions.kt +++ b/tests/FlickerTests/src/com/android/server/wm/flicker/CommonAssertions.kt @@ -23,14 +23,14 @@ import android.tools.common.flicker.subject.region.RegionSubject import android.tools.common.traces.component.ComponentNameMatcher import android.tools.common.traces.component.IComponentNameMatcher import android.tools.common.traces.wm.WindowManagerTrace -import android.tools.device.flicker.legacy.FlickerTest +import android.tools.device.flicker.legacy.LegacyFlickerTest import android.tools.device.helpers.WindowUtils /** * Checks that [ComponentNameMatcher.STATUS_BAR] window is visible and above the app windows in all * WM trace entries */ -fun FlickerTest.statusBarWindowIsAlwaysVisible() { +fun LegacyFlickerTest.statusBarWindowIsAlwaysVisible() { assertWm { this.isAboveAppWindowVisible(ComponentNameMatcher.STATUS_BAR) } } @@ -38,7 +38,7 @@ fun FlickerTest.statusBarWindowIsAlwaysVisible() { * Checks that [ComponentNameMatcher.NAV_BAR] window is visible and above the app windows in all WM * trace entries */ -fun FlickerTest.navBarWindowIsAlwaysVisible() { +fun LegacyFlickerTest.navBarWindowIsAlwaysVisible() { assertWm { this.isAboveAppWindowVisible(ComponentNameMatcher.NAV_BAR) } } @@ -46,7 +46,7 @@ fun FlickerTest.navBarWindowIsAlwaysVisible() { * Checks that [ComponentNameMatcher.NAV_BAR] window is visible and above the app windows at the * start and end of the WM trace */ -fun FlickerTest.navBarWindowIsVisibleAtStartAndEnd() { +fun LegacyFlickerTest.navBarWindowIsVisibleAtStartAndEnd() { this.navBarWindowIsVisibleAtStart() this.navBarWindowIsVisibleAtEnd() } @@ -55,7 +55,7 @@ fun FlickerTest.navBarWindowIsVisibleAtStartAndEnd() { * Checks that [ComponentNameMatcher.NAV_BAR] window is visible and above the app windows at the * start of the WM trace */ -fun FlickerTest.navBarWindowIsVisibleAtStart() { +fun LegacyFlickerTest.navBarWindowIsVisibleAtStart() { assertWmStart { this.isAboveAppWindowVisible(ComponentNameMatcher.NAV_BAR) } } @@ -63,7 +63,7 @@ fun FlickerTest.navBarWindowIsVisibleAtStart() { * Checks that [ComponentNameMatcher.NAV_BAR] window is visible and above the app windows at the end * of the WM trace */ -fun FlickerTest.navBarWindowIsVisibleAtEnd() { +fun LegacyFlickerTest.navBarWindowIsVisibleAtEnd() { assertWmEnd { this.isAboveAppWindowVisible(ComponentNameMatcher.NAV_BAR) } } @@ -71,7 +71,7 @@ fun FlickerTest.navBarWindowIsVisibleAtEnd() { * Checks that [ComponentNameMatcher.TASK_BAR] window is visible and above the app windows in all WM * trace entries */ -fun FlickerTest.taskBarWindowIsAlwaysVisible() { +fun LegacyFlickerTest.taskBarWindowIsAlwaysVisible() { assertWm { this.isAboveAppWindowVisible(ComponentNameMatcher.TASK_BAR) } } @@ -79,7 +79,7 @@ fun FlickerTest.taskBarWindowIsAlwaysVisible() { * Checks that [ComponentNameMatcher.TASK_BAR] window is visible and above the app windows in all WM * trace entries */ -fun FlickerTest.taskBarWindowIsVisibleAtEnd() { +fun LegacyFlickerTest.taskBarWindowIsVisibleAtEnd() { assertWmEnd { this.isAboveAppWindowVisible(ComponentNameMatcher.TASK_BAR) } } @@ -93,43 +93,45 @@ fun FlickerTest.taskBarWindowIsVisibleAtEnd() { * @param allStates if all states should be checked, othersie, just initial and final */ @JvmOverloads -fun FlickerTest.entireScreenCovered(allStates: Boolean = true) { +fun LegacyFlickerTest.entireScreenCovered(allStates: Boolean = true) { if (allStates) { assertLayers { this.invoke("entireScreenCovered") { entry -> - entry.entry.displays.filter { it.isOn }.forEach { display -> - entry.visibleRegion().coversAtLeast(display.layerStackSpace) - } + entry.entry.displays + .filter { it.isOn } + .forEach { display -> + entry.visibleRegion().coversAtLeast(display.layerStackSpace) + } } } } else { assertLayersStart { - this.entry.displays.filter { it.isOn }.forEach { display -> - this.visibleRegion().coversAtLeast(display.layerStackSpace) - } + this.entry.displays + .filter { it.isOn } + .forEach { display -> this.visibleRegion().coversAtLeast(display.layerStackSpace) } } assertLayersEnd { - this.entry.displays.filter { it.isOn }.forEach { display -> - this.visibleRegion().coversAtLeast(display.layerStackSpace) - } + this.entry.displays + .filter { it.isOn } + .forEach { display -> this.visibleRegion().coversAtLeast(display.layerStackSpace) } } } } /** Checks that [ComponentNameMatcher.NAV_BAR] layer is visible at the start of the SF trace */ -fun FlickerTest.navBarLayerIsVisibleAtStart() { +fun LegacyFlickerTest.navBarLayerIsVisibleAtStart() { assertLayersStart { this.isVisible(ComponentNameMatcher.NAV_BAR) } } /** Checks that [ComponentNameMatcher.NAV_BAR] layer is visible at the end of the SF trace */ -fun FlickerTest.navBarLayerIsVisibleAtEnd() { +fun LegacyFlickerTest.navBarLayerIsVisibleAtEnd() { assertLayersEnd { this.isVisible(ComponentNameMatcher.NAV_BAR) } } /** * Checks that [ComponentNameMatcher.NAV_BAR] layer is visible at the start and end of the SF trace */ -fun FlickerTest.navBarLayerIsVisibleAtStartAndEnd() { +fun LegacyFlickerTest.navBarLayerIsVisibleAtStartAndEnd() { this.navBarLayerIsVisibleAtStart() this.navBarLayerIsVisibleAtEnd() } @@ -137,18 +139,18 @@ fun FlickerTest.navBarLayerIsVisibleAtStartAndEnd() { /** * Checks that [ComponentNameMatcher.TASK_BAR] layer is visible at the start and end of the SF trace */ -fun FlickerTest.taskBarLayerIsVisibleAtStartAndEnd() { +fun LegacyFlickerTest.taskBarLayerIsVisibleAtStartAndEnd() { this.taskBarLayerIsVisibleAtStart() this.taskBarLayerIsVisibleAtEnd() } /** Checks that [ComponentNameMatcher.TASK_BAR] layer is visible at the start of the SF trace */ -fun FlickerTest.taskBarLayerIsVisibleAtStart() { +fun LegacyFlickerTest.taskBarLayerIsVisibleAtStart() { assertLayersStart { this.isVisible(ComponentNameMatcher.TASK_BAR) } } /** Checks that [ComponentNameMatcher.TASK_BAR] layer is visible at the end of the SF trace */ -fun FlickerTest.taskBarLayerIsVisibleAtEnd() { +fun LegacyFlickerTest.taskBarLayerIsVisibleAtEnd() { assertLayersEnd { this.isVisible(ComponentNameMatcher.TASK_BAR) } } @@ -156,7 +158,7 @@ fun FlickerTest.taskBarLayerIsVisibleAtEnd() { * Checks that [ComponentNameMatcher.STATUS_BAR] layer is visible at the start and end of the SF * trace */ -fun FlickerTest.statusBarLayerIsVisibleAtStartAndEnd() { +fun LegacyFlickerTest.statusBarLayerIsVisibleAtStartAndEnd() { assertLayersStart { this.isVisible(ComponentNameMatcher.STATUS_BAR) } assertLayersEnd { this.isVisible(ComponentNameMatcher.STATUS_BAR) } } @@ -165,7 +167,7 @@ fun FlickerTest.statusBarLayerIsVisibleAtStartAndEnd() { * Asserts that the [ComponentNameMatcher.NAV_BAR] layer is at the correct position at the start of * the SF trace */ -fun FlickerTest.navBarLayerPositionAtStart() { +fun LegacyFlickerTest.navBarLayerPositionAtStart() { assertLayersStart { val display = this.entry.displays.firstOrNull { !it.isVirtual } ?: error("There is no display!") @@ -180,7 +182,7 @@ fun FlickerTest.navBarLayerPositionAtStart() { * Asserts that the [ComponentNameMatcher.NAV_BAR] layer is at the correct position at the end of * the SF trace */ -fun FlickerTest.navBarLayerPositionAtEnd() { +fun LegacyFlickerTest.navBarLayerPositionAtEnd() { assertLayersEnd { val display = this.entry.displays.minByOrNull { it.id } @@ -196,7 +198,7 @@ fun FlickerTest.navBarLayerPositionAtEnd() { * Asserts that the [ComponentNameMatcher.NAV_BAR] layer is at the correct position at the start and * end of the SF trace */ -fun FlickerTest.navBarLayerPositionAtStartAndEnd() { +fun LegacyFlickerTest.navBarLayerPositionAtStartAndEnd() { navBarLayerPositionAtStart() navBarLayerPositionAtEnd() } @@ -205,7 +207,7 @@ fun FlickerTest.navBarLayerPositionAtStartAndEnd() { * Asserts that the [ComponentNameMatcher.STATUS_BAR] layer is at the correct position at the start * of the SF trace */ -fun FlickerTest.statusBarLayerPositionAtStart( +fun LegacyFlickerTest.statusBarLayerPositionAtStart( wmTrace: WindowManagerTrace? = this.reader.readWmTrace() ) { // collect navbar position for the equivalent WM state @@ -221,7 +223,7 @@ fun FlickerTest.statusBarLayerPositionAtStart( * Asserts that the [ComponentNameMatcher.STATUS_BAR] layer is at the correct position at the end of * the SF trace */ -fun FlickerTest.statusBarLayerPositionAtEnd( +fun LegacyFlickerTest.statusBarLayerPositionAtEnd( wmTrace: WindowManagerTrace? = this.reader.readWmTrace() ) { // collect navbar position for the equivalent WM state @@ -237,7 +239,7 @@ fun FlickerTest.statusBarLayerPositionAtEnd( * Asserts that the [ComponentNameMatcher.STATUS_BAR] layer is at the correct position at the start * and end of the SF trace */ -fun FlickerTest.statusBarLayerPositionAtStartAndEnd() { +fun LegacyFlickerTest.statusBarLayerPositionAtStartAndEnd() { statusBarLayerPositionAtStart() statusBarLayerPositionAtEnd() } @@ -246,25 +248,25 @@ fun FlickerTest.statusBarLayerPositionAtStartAndEnd() { * Asserts that the visibleRegion of the [ComponentNameMatcher.SNAPSHOT] layer can cover the * visibleRegion of the given app component exactly */ -fun FlickerTest.snapshotStartingWindowLayerCoversExactlyOnApp(component: IComponentNameMatcher) { +fun LegacyFlickerTest.snapshotStartingWindowLayerCoversExactlyOnApp( + component: IComponentNameMatcher +) { assertLayers { invoke("snapshotStartingWindowLayerCoversExactlyOnApp") { val snapshotLayers = it.subjects.filter { subject -> - subject.name.contains(ComponentNameMatcher.SNAPSHOT.toLayerName()) && + ComponentNameMatcher.SNAPSHOT.layerMatchesAnyOf(subject.layer) && subject.isVisible } + val visibleAreas = + snapshotLayers + .mapNotNull { snapshotLayer -> snapshotLayer.layer.visibleRegion } + .toTypedArray() + val snapshotRegion = RegionSubject(visibleAreas, timestamp) // Verify the size of snapshotRegion covers appVisibleRegion exactly in animation. - if (snapshotLayers.isNotEmpty()) { - val visibleAreas = - snapshotLayers - .mapNotNull { snapshotLayer -> snapshotLayer.layer.visibleRegion } - .toTypedArray() - val snapshotRegion = RegionSubject(visibleAreas, timestamp) + if (snapshotRegion.region.isNotEmpty) { val appVisibleRegion = it.visibleRegion(component) - if (snapshotRegion.region.isNotEmpty) { - snapshotRegion.coversExactly(appVisibleRegion.region) - } + snapshotRegion.coversExactly(appVisibleRegion.region) } } } @@ -307,7 +309,7 @@ fun FlickerTest.snapshotStartingWindowLayerCoversExactlyOnApp(component: ICompon * otherwise we won't and the layer must appear immediately. * ``` */ -fun FlickerTest.replacesLayer( +fun LegacyFlickerTest.replacesLayer( originalLayer: IComponentNameMatcher, newLayer: IComponentNameMatcher, ignoreEntriesWithRotationLayer: Boolean = false, diff --git a/tests/FlickerTests/src/com/android/server/wm/flicker/activityembedding/ActivityEmbeddingTestBase.kt b/tests/FlickerTests/src/com/android/server/wm/flicker/activityembedding/ActivityEmbeddingTestBase.kt index 7ef4d939fee2..45176448a9f4 100644 --- a/tests/FlickerTests/src/com/android/server/wm/flicker/activityembedding/ActivityEmbeddingTestBase.kt +++ b/tests/FlickerTests/src/com/android/server/wm/flicker/activityembedding/ActivityEmbeddingTestBase.kt @@ -16,12 +16,15 @@ package com.android.server.wm.flicker.activityembedding -import android.tools.device.flicker.legacy.FlickerTest +import android.tools.device.flicker.legacy.LegacyFlickerTest +import android.platform.test.annotations.Presubmit +import android.tools.common.traces.component.ComponentNameMatcher import com.android.server.wm.flicker.BaseTest import com.android.server.wm.flicker.helpers.ActivityEmbeddingAppHelper import org.junit.Before +import org.junit.Test -abstract class ActivityEmbeddingTestBase(flicker: FlickerTest) : BaseTest(flicker) { +abstract class ActivityEmbeddingTestBase(flicker: LegacyFlickerTest) : BaseTest(flicker) { val testApp = ActivityEmbeddingAppHelper(instrumentation) @Before @@ -29,4 +32,14 @@ abstract class ActivityEmbeddingTestBase(flicker: FlickerTest) : BaseTest(flicke // The test should only be run on devices that support ActivityEmbedding. ActivityEmbeddingAppHelper.assumeActivityEmbeddingSupportedDevice() } + + /** Asserts the background animation layer is never visible during bounds change transition. */ + @Presubmit + @Test + fun backgroundLayerNeverVisible() { + val backgroundColorLayer = ComponentNameMatcher("", "Animation Background") + flicker.assertLayers { + isInvisible(backgroundColorLayer) + } + } } diff --git a/tests/FlickerTests/src/com/android/server/wm/flicker/activityembedding/close/CloseSecondaryActivityInSplitTest.kt b/tests/FlickerTests/src/com/android/server/wm/flicker/activityembedding/close/CloseSecondaryActivityInSplitTest.kt new file mode 100644 index 000000000000..0c36c59a8a83 --- /dev/null +++ b/tests/FlickerTests/src/com/android/server/wm/flicker/activityembedding/close/CloseSecondaryActivityInSplitTest.kt @@ -0,0 +1,136 @@ +/* + * Copyright (C) 2023 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.server.wm.flicker.activityembedding.close + +import android.platform.test.annotations.Presubmit +import android.tools.common.datatypes.Rect +import android.tools.common.traces.component.ComponentNameMatcher +import android.tools.device.flicker.junit.FlickerParametersRunnerFactory +import android.tools.device.flicker.legacy.FlickerBuilder +import android.tools.device.flicker.legacy.LegacyFlickerTest +import android.tools.device.flicker.legacy.LegacyFlickerTestFactory +import androidx.test.filters.RequiresDevice +import com.android.server.wm.flicker.activityembedding.ActivityEmbeddingTestBase +import com.android.server.wm.flicker.helpers.ActivityEmbeddingAppHelper +import org.junit.FixMethodOrder +import org.junit.Test +import org.junit.runner.RunWith +import org.junit.runners.MethodSorters +import org.junit.runners.Parameterized + +/** + * Test closing a secondary activity in a split. + * + * Setup: Launch A|B in split with B being the secondary activity. Transitions: Finish B and expect + * A to become fullscreen. + * + * To run this test: `atest FlickerTestsOther:CloseSecondaryActivityInSplitTest` + */ +@RequiresDevice +@RunWith(Parameterized::class) +@Parameterized.UseParametersRunnerFactory(FlickerParametersRunnerFactory::class) +@FixMethodOrder(MethodSorters.NAME_ASCENDING) +class CloseSecondaryActivityInSplitTest(flicker: LegacyFlickerTest) : + ActivityEmbeddingTestBase(flicker) { + + override val transition: FlickerBuilder.() -> Unit = { + setup { + tapl.setExpectedRotationCheckEnabled(false) + // Launches fullscreen A. + testApp.launchViaIntent(wmHelper) + // Launches a split A|B and waits for both activities to show. + testApp.launchSecondaryActivity(wmHelper) + // Get fullscreen bounds + startDisplayBounds = + wmHelper.currentState.layerState.physicalDisplayBounds + ?: error("Can't get display bounds") + } + transitions { + // Finish secondary activity B. + testApp.finishSecondaryActivity(wmHelper) + // Expect the main activity A to expand into fullscreen. + wmHelper.StateSyncBuilder().withFullScreenApp(testApp).waitForAndVerify() + } + teardown { + tapl.goHome() + testApp.exit(wmHelper) + } + } + + /** Main activity is always visible and becomes fullscreen in the end. */ + @Presubmit + @Test + fun mainActivityWindowBecomesFullScreen() { + flicker.assertWm { isAppWindowVisible(ActivityEmbeddingAppHelper.MAIN_ACTIVITY_COMPONENT) } + flicker.assertWmEnd { + this.visibleRegion(ActivityEmbeddingAppHelper.MAIN_ACTIVITY_COMPONENT) + .coversExactly(startDisplayBounds) + } + } + + /** Main activity surface is animated from split to fullscreen. */ + @Presubmit + @Test + fun mainActivityLayerIsAlwaysVisible() { + flicker.assertLayers { + isVisible( + ActivityEmbeddingAppHelper.MAIN_ACTIVITY_COMPONENT.or( + ComponentNameMatcher.TRANSITION_SNAPSHOT + ) + ) + } + flicker.assertLayersEnd { + isVisible(ActivityEmbeddingAppHelper.MAIN_ACTIVITY_COMPONENT) + .isInvisible(ComponentNameMatcher.TRANSITION_SNAPSHOT) + } + } + + /** Secondary activity should destroy and become invisible. */ + @Presubmit + @Test + fun secondaryActivityWindowFinishes() { + flicker.assertWm { + contains(ActivityEmbeddingAppHelper.SECONDARY_ACTIVITY_COMPONENT) + .then() + .notContains(ActivityEmbeddingAppHelper.SECONDARY_ACTIVITY_COMPONENT) + } + } + + @Presubmit + @Test + fun secondaryActivityLayerFinishes() { + flicker.assertLayers { + isVisible(ActivityEmbeddingAppHelper.SECONDARY_ACTIVITY_COMPONENT) + .then() + .isInvisible(ActivityEmbeddingAppHelper.SECONDARY_ACTIVITY_COMPONENT) + } + } + + companion object { + /** {@inheritDoc} */ + private var startDisplayBounds = Rect.EMPTY + /** + * Creates the test configurations. + * + * See [LegacyFlickerTestFactory.nonRotationTests] for configuring screen orientation and + * navigation modes. + */ + @Parameterized.Parameters(name = "{0}") + @JvmStatic + fun getParams() = LegacyFlickerTestFactory.nonRotationTests() + } +} diff --git a/tests/FlickerTests/src/com/android/server/wm/flicker/activityembedding/layoutchange/HorizontalSplitChangeRatioTest.kt b/tests/FlickerTests/src/com/android/server/wm/flicker/activityembedding/layoutchange/HorizontalSplitChangeRatioTest.kt new file mode 100644 index 000000000000..cfc0d8b5f33b --- /dev/null +++ b/tests/FlickerTests/src/com/android/server/wm/flicker/activityembedding/layoutchange/HorizontalSplitChangeRatioTest.kt @@ -0,0 +1,153 @@ +/* + * Copyright (C) 2023 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.server.wm.flicker.activityembedding.layoutchange + +import android.platform.test.annotations.Presubmit +import android.tools.common.datatypes.Rect +import android.tools.device.flicker.junit.FlickerParametersRunnerFactory +import android.tools.device.flicker.legacy.FlickerBuilder +import android.tools.device.flicker.legacy.LegacyFlickerTest +import android.tools.device.flicker.legacy.LegacyFlickerTestFactory +import com.android.server.wm.flicker.activityembedding.ActivityEmbeddingTestBase +import com.android.server.wm.flicker.helpers.ActivityEmbeddingAppHelper +import androidx.test.filters.RequiresDevice +import org.junit.FixMethodOrder +import org.junit.Test +import org.junit.runner.RunWith +import org.junit.runners.MethodSorters +import org.junit.runners.Parameterized + +/** + * Test changing split ratio at runtime on a horizona split. + * + * Setup: Launch A|B in horizontal split with B being the secondary activity, by default A and B + * windows are equal in size. B is on the top and A is on the bottom. + * Transitions: + * Change the split ratio to A:B=0.7:0.3, expect bounds change for both A and B. + * + * To run this test: `atest FlickerTestsOther:HorizontalSplitChangeRatioTest` + */ +@RequiresDevice +@RunWith(Parameterized::class) +@Parameterized.UseParametersRunnerFactory(FlickerParametersRunnerFactory::class) +@FixMethodOrder(MethodSorters.NAME_ASCENDING) +class HorizontalSplitChangeRatioTest(flicker: LegacyFlickerTest) : + ActivityEmbeddingTestBase(flicker) { + /** {@inheritDoc} */ + override val transition: FlickerBuilder.() -> Unit = { + setup { + tapl.setExpectedRotationCheckEnabled(false) + testApp.launchViaIntent(wmHelper) + testApp.launchSecondaryActivityHorizontally(wmHelper) + startDisplayBounds = + wmHelper.currentState.layerState.physicalDisplayBounds + ?: error("Display not found") + } + transitions { + testApp.changeSecondaryActivityRatio(wmHelper) + } + teardown { + tapl.goHome() + testApp.exit(wmHelper) + } + } + + /** Assert the Main activity window is always visible. */ + @Presubmit + @Test + fun mainActivityWindowIsAlwaysVisible() { + flicker.assertWm { isAppWindowVisible(ActivityEmbeddingAppHelper.MAIN_ACTIVITY_COMPONENT) } + } + + /** Assert the Main activity window is always visible. */ + @Presubmit + @Test + fun mainActivityLayerIsAlwaysVisible() { + flicker.assertLayers { isVisible(ActivityEmbeddingAppHelper.MAIN_ACTIVITY_COMPONENT) } + } + + /** Assert the Secondary activity window is always visible. */ + @Presubmit + @Test + fun secondaryActivityWindowIsAlwaysVisible() { + flicker.assertWm { + isAppWindowVisible(ActivityEmbeddingAppHelper.SECONDARY_ACTIVITY_COMPONENT) } + } + + /** Assert the Secondary activity window is always visible. */ + @Presubmit + @Test + fun secondaryActivityLayerIsAlwaysVisible() { + flicker.assertLayers { isVisible(ActivityEmbeddingAppHelper.SECONDARY_ACTIVITY_COMPONENT) } + } + + /** Assert the Main and Secondary activity change height during the transition. */ + @Presubmit + @Test + fun secondaryActivityAdjustsHeightRuntime() { + flicker.assertLayersStart { + val topLayerRegion = + this.visibleRegion(ActivityEmbeddingAppHelper.SECONDARY_ACTIVITY_COMPONENT) + val bottomLayerRegion = + this.visibleRegion(ActivityEmbeddingAppHelper.MAIN_ACTIVITY_COMPONENT) + // Compare dimensions of two splits, given we're using default split attributes, + // both activities take up the same visible size on the display. + check { "height" } + .that(topLayerRegion.region.height).isEqual(bottomLayerRegion.region.height) + check { "width" } + .that(topLayerRegion.region.width).isEqual(bottomLayerRegion.region.width) + topLayerRegion.notOverlaps(bottomLayerRegion.region) + // Layers of two activities sum to be fullscreen size on display. + topLayerRegion.plus(bottomLayerRegion.region).coversExactly(startDisplayBounds) + } + + flicker.assertLayersEnd { + val topLayerRegion = + this.visibleRegion(ActivityEmbeddingAppHelper.SECONDARY_ACTIVITY_COMPONENT) + val bottomLayerRegion = + this.visibleRegion(ActivityEmbeddingAppHelper.MAIN_ACTIVITY_COMPONENT) + // Compare dimensions of two splits, given we're using default split attributes, + // both activities take up the same visible size on the display. + check { "height" } + .that(topLayerRegion.region.height).isLower(bottomLayerRegion.region.height) + check { "height" } + .that( + topLayerRegion.region.height / 0.3f - + bottomLayerRegion.region.height / 0.7f) + .isLower(0.1f) + check { "width" } + .that(topLayerRegion.region.width).isEqual(bottomLayerRegion.region.width) + topLayerRegion.notOverlaps(bottomLayerRegion.region) + // Layers of two activities sum to be fullscreen size on display. + topLayerRegion.plus(bottomLayerRegion.region).coversExactly(startDisplayBounds) + } + } + + companion object { + /** {@inheritDoc} */ + private var startDisplayBounds = Rect.EMPTY + /** + * Creates the test configurations. + * + * See [LegacyFlickerTestFactory.nonRotationTests] for configuring screen orientation and + * navigation modes. + */ + @Parameterized.Parameters(name = "{0}") + @JvmStatic + fun getParams() = LegacyFlickerTestFactory.nonRotationTests() + } +}
\ No newline at end of file diff --git a/tests/FlickerTests/src/com/android/server/wm/flicker/activityembedding/open/MainActivityStartsSecondaryWithAlwaysExpandTest.kt b/tests/FlickerTests/src/com/android/server/wm/flicker/activityembedding/open/MainActivityStartsSecondaryWithAlwaysExpandTest.kt new file mode 100644 index 000000000000..b0ae7383cf61 --- /dev/null +++ b/tests/FlickerTests/src/com/android/server/wm/flicker/activityembedding/open/MainActivityStartsSecondaryWithAlwaysExpandTest.kt @@ -0,0 +1,144 @@ +/* + * Copyright (C) 2023 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.server.wm.flicker.activityembedding.open + +import android.platform.test.annotations.FlakyTest +import android.platform.test.annotations.Presubmit +import android.tools.common.datatypes.Rect +import android.tools.device.flicker.junit.FlickerParametersRunnerFactory +import android.tools.device.flicker.legacy.FlickerBuilder +import android.tools.device.flicker.legacy.LegacyFlickerTest +import android.tools.device.flicker.legacy.LegacyFlickerTestFactory +import androidx.test.filters.RequiresDevice +import com.android.server.wm.flicker.activityembedding.ActivityEmbeddingTestBase +import com.android.server.wm.flicker.helpers.ActivityEmbeddingAppHelper +import org.junit.FixMethodOrder +import org.junit.Ignore +import org.junit.Test +import org.junit.runner.RunWith +import org.junit.runners.MethodSorters +import org.junit.runners.Parameterized + +/** + * Test launching an activity with AlwaysExpand rule. + * + * Setup: Launch A|B in split with B being the secondary activity. Transitions: A start C with + * alwaysExpand=true, expect C to launch in fullscreen and cover split A|B. + * + * To run this test: `atest FlickerTestsOther:MainActivityStartsSecondaryWithAlwaysExpandTest` + */ +@RequiresDevice +@RunWith(Parameterized::class) +@Parameterized.UseParametersRunnerFactory(FlickerParametersRunnerFactory::class) +@FixMethodOrder(MethodSorters.NAME_ASCENDING) +class MainActivityStartsSecondaryWithAlwaysExpandTest(flicker: LegacyFlickerTest) : + ActivityEmbeddingTestBase(flicker) { + + /** {@inheritDoc} */ + override val transition: FlickerBuilder.() -> Unit = { + setup { + tapl.setExpectedRotationCheckEnabled(false) + // Launch a split + testApp.launchViaIntent(wmHelper) + testApp.launchSecondaryActivity(wmHelper) + startDisplayBounds = + wmHelper.currentState.layerState.physicalDisplayBounds ?: error("Display not found") + } + transitions { + // Launch C with alwaysExpand + testApp.launchAlwaysExpandActivity(wmHelper) + } + teardown { + tapl.goHome() + testApp.exit(wmHelper) + } + } + + @Ignore("Not applicable to this CUJ.") override fun navBarWindowIsVisibleAtStartAndEnd() {} + + @Ignore("Not applicable to this CUJ.") override fun statusBarWindowIsAlwaysVisible() {} + + @Ignore("Not applicable to this CUJ.") override fun statusBarLayerPositionAtStartAndEnd() {} + + /** Transition begins with a split. */ + @FlakyTest(bugId = 286952194) + @Test + fun startsWithSplit() { + flicker.assertWmStart { + this.isAppWindowVisible(ActivityEmbeddingAppHelper.MAIN_ACTIVITY_COMPONENT) + } + flicker.assertWmStart { + this.isAppWindowVisible(ActivityEmbeddingAppHelper.SECONDARY_ACTIVITY_COMPONENT) + } + } + + /** Main activity should become invisible after being covered by always expand activity. */ + @FlakyTest(bugId = 286952194) + @Test + fun mainActivityLayerBecomesInvisible() { + flicker.assertLayers { + isVisible(ActivityEmbeddingAppHelper.MAIN_ACTIVITY_COMPONENT) + .then() + .isInvisible(ActivityEmbeddingAppHelper.MAIN_ACTIVITY_COMPONENT) + } + } + + /** Secondary activity should become invisible after being covered by always expand activity. */ + @FlakyTest(bugId = 286952194) + @Test + fun secondaryActivityLayerBecomesInvisible() { + flicker.assertLayers { + isVisible(ActivityEmbeddingAppHelper.SECONDARY_ACTIVITY_COMPONENT) + .then() + .isInvisible(ActivityEmbeddingAppHelper.SECONDARY_ACTIVITY_COMPONENT) + } + } + + /** At the end of transition always expand activity is in fullscreen. */ + @FlakyTest(bugId = 286952194) + @Test + fun endsWithAlwaysExpandActivityCoveringFullScreen() { + flicker.assertWmEnd { + this.visibleRegion(ActivityEmbeddingAppHelper.ALWAYS_EXPAND_ACTIVITY_COMPONENT) + .coversExactly(startDisplayBounds) + } + } + + /** Always expand activity is on top of the split. */ + @FlakyTest(bugId = 286952194) + @Presubmit + @Test + fun endsWithAlwaysExpandActivityOnTop() { + flicker.assertWmEnd { + this.isAppWindowOnTop(ActivityEmbeddingAppHelper.ALWAYS_EXPAND_ACTIVITY_COMPONENT) + } + } + + companion object { + /** {@inheritDoc} */ + private var startDisplayBounds = Rect.EMPTY + /** + * Creates the test configurations. + * + * See [LegacyFlickerTestFactory.nonRotationTests] for configuring screen orientation and + * navigation modes. + */ + @Parameterized.Parameters(name = "{0}") + @JvmStatic + fun getParams() = LegacyFlickerTestFactory.nonRotationTests() + } +} diff --git a/tests/FlickerTests/src/com/android/server/wm/flicker/activityembedding/OpenActivityEmbeddingPlaceholderSplitTest.kt b/tests/FlickerTests/src/com/android/server/wm/flicker/activityembedding/open/OpenActivityEmbeddingPlaceholderSplitTest.kt index ed17059e79e7..48edf6ddeba6 100644 --- a/tests/FlickerTests/src/com/android/server/wm/flicker/activityembedding/OpenActivityEmbeddingPlaceholderSplitTest.kt +++ b/tests/FlickerTests/src/com/android/server/wm/flicker/activityembedding/open/OpenActivityEmbeddingPlaceholderSplitTest.kt @@ -14,14 +14,15 @@ * limitations under the License. */ -package com.android.server.wm.flicker.activityembedding +package com.android.server.wm.flicker.activityembedding.open import android.platform.test.annotations.Presubmit import android.tools.device.flicker.junit.FlickerParametersRunnerFactory import android.tools.device.flicker.legacy.FlickerBuilder -import android.tools.device.flicker.legacy.FlickerTest -import android.tools.device.flicker.legacy.FlickerTestFactory +import android.tools.device.flicker.legacy.LegacyFlickerTest +import android.tools.device.flicker.legacy.LegacyFlickerTestFactory import androidx.test.filters.RequiresDevice +import com.android.server.wm.flicker.activityembedding.ActivityEmbeddingTestBase import com.android.server.wm.flicker.helpers.ActivityEmbeddingAppHelper import org.junit.FixMethodOrder import org.junit.Test @@ -33,13 +34,13 @@ import org.junit.runners.Parameterized * Test opening an activity that will launch another activity as ActivityEmbedding placeholder in * split. * - * To run this test: `atest FlickerTests:OpenActivityEmbeddingPlaceholderSplitTest` + * To run this test: `atest FlickerTestsOther:OpenActivityEmbeddingPlaceholderSplitTest` */ @RequiresDevice @RunWith(Parameterized::class) @Parameterized.UseParametersRunnerFactory(FlickerParametersRunnerFactory::class) @FixMethodOrder(MethodSorters.NAME_ASCENDING) -class OpenActivityEmbeddingPlaceholderSplitTest(flicker: FlickerTest) : +class OpenActivityEmbeddingPlaceholderSplitTest(flicker: LegacyFlickerTest) : ActivityEmbeddingTestBase(flicker) { /** {@inheritDoc} */ @@ -117,13 +118,11 @@ class OpenActivityEmbeddingPlaceholderSplitTest(flicker: FlickerTest) : /** * Creates the test configurations. * - * See [FlickerTestFactory.nonRotationTests] for configuring screen orientation and + * See [LegacyFlickerTestFactory.nonRotationTests] for configuring screen orientation and * navigation modes. */ @Parameterized.Parameters(name = "{0}") @JvmStatic - fun getParams(): Collection<FlickerTest> { - return FlickerTestFactory.nonRotationTests() - } + fun getParams() = LegacyFlickerTestFactory.nonRotationTests() } } diff --git a/tests/FlickerTests/src/com/android/server/wm/flicker/activityembedding/OpenActivityEmbeddingSecondaryToSplitTest.kt b/tests/FlickerTests/src/com/android/server/wm/flicker/activityembedding/open/OpenActivityEmbeddingSecondaryToSplitTest.kt index 863828881d36..365782012c54 100644 --- a/tests/FlickerTests/src/com/android/server/wm/flicker/activityembedding/OpenActivityEmbeddingSecondaryToSplitTest.kt +++ b/tests/FlickerTests/src/com/android/server/wm/flicker/activityembedding/open/OpenActivityEmbeddingSecondaryToSplitTest.kt @@ -14,15 +14,16 @@ * limitations under the License. */ -package com.android.server.wm.flicker.activityembedding +package com.android.server.wm.flicker.activityembedding.open import android.platform.test.annotations.Presubmit import android.tools.common.traces.component.ComponentNameMatcher import android.tools.device.flicker.junit.FlickerParametersRunnerFactory import android.tools.device.flicker.legacy.FlickerBuilder -import android.tools.device.flicker.legacy.FlickerTest -import android.tools.device.flicker.legacy.FlickerTestFactory +import android.tools.device.flicker.legacy.LegacyFlickerTest +import android.tools.device.flicker.legacy.LegacyFlickerTestFactory import androidx.test.filters.RequiresDevice +import com.android.server.wm.flicker.activityembedding.ActivityEmbeddingTestBase import com.android.server.wm.flicker.helpers.ActivityEmbeddingAppHelper import org.junit.FixMethodOrder import org.junit.Test @@ -33,13 +34,13 @@ import org.junit.runners.Parameterized /** * Test opening a secondary activity that will split with the main activity. * - * To run this test: `atest FlickerTests:OpenActivityEmbeddingSecondaryToSplitTest` + * To run this test: `atest FlickerTestsOther:OpenActivityEmbeddingSecondaryToSplitTest` */ @RequiresDevice @RunWith(Parameterized::class) @Parameterized.UseParametersRunnerFactory(FlickerParametersRunnerFactory::class) @FixMethodOrder(MethodSorters.NAME_ASCENDING) -class OpenActivityEmbeddingSecondaryToSplitTest(flicker: FlickerTest) : +class OpenActivityEmbeddingSecondaryToSplitTest(flicker: LegacyFlickerTest) : ActivityEmbeddingTestBase(flicker) { /** {@inheritDoc} */ @@ -110,13 +111,11 @@ class OpenActivityEmbeddingSecondaryToSplitTest(flicker: FlickerTest) : /** * Creates the test configurations. * - * See [FlickerTestFactory.nonRotationTests] for configuring screen orientation and + * See [LegacyFlickerTestFactory.nonRotationTests] for configuring screen orientation and * navigation modes. */ @Parameterized.Parameters(name = "{0}") @JvmStatic - fun getParams(): Collection<FlickerTest> { - return FlickerTestFactory.nonRotationTests() - } + fun getParams() = LegacyFlickerTestFactory.nonRotationTests() } } diff --git a/tests/FlickerTests/src/com/android/server/wm/flicker/activityembedding/open/OpenThirdActivityOverSplitTest.kt b/tests/FlickerTests/src/com/android/server/wm/flicker/activityembedding/open/OpenThirdActivityOverSplitTest.kt new file mode 100644 index 000000000000..5551aa6b2fea --- /dev/null +++ b/tests/FlickerTests/src/com/android/server/wm/flicker/activityembedding/open/OpenThirdActivityOverSplitTest.kt @@ -0,0 +1,158 @@ +/* + * Copyright (C) 2023 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.server.wm.flicker.activityembedding.open + +import android.platform.test.annotations.Presubmit +import android.tools.common.datatypes.Rect +import android.tools.common.traces.component.ComponentNameMatcher +import android.tools.device.flicker.junit.FlickerParametersRunnerFactory +import android.tools.device.flicker.legacy.FlickerBuilder +import android.tools.device.flicker.legacy.LegacyFlickerTest +import android.tools.device.flicker.legacy.LegacyFlickerTestFactory +import androidx.test.filters.RequiresDevice +import com.android.server.wm.flicker.activityembedding.ActivityEmbeddingTestBase +import com.android.server.wm.flicker.helpers.ActivityEmbeddingAppHelper +import org.junit.FixMethodOrder +import org.junit.Test +import org.junit.runner.RunWith +import org.junit.runners.MethodSorters +import org.junit.runners.Parameterized + +/** + * Test launching a secondary activity over an existing split. By default the new secondary activity + * will stack over the previous secondary activity. + * + * Setup: From Activity A launch a split A|B. + * + * Transitions: Let B start C, expect C to cover B and end up in split A|C. + * + * To run this test: `atest FlickerTestsOther:OpenThirdActivityOverSplitTest` + */ +@RequiresDevice +@RunWith(Parameterized::class) +@Parameterized.UseParametersRunnerFactory(FlickerParametersRunnerFactory::class) +@FixMethodOrder(MethodSorters.NAME_ASCENDING) +class OpenThirdActivityOverSplitTest(flicker: LegacyFlickerTest) : + ActivityEmbeddingTestBase(flicker) { + /** {@inheritDoc} */ + override val transition: FlickerBuilder.() -> Unit = { + setup { + tapl.setExpectedRotationCheckEnabled(false) + // Launch a split. + testApp.launchViaIntent(wmHelper) + testApp.launchSecondaryActivity(wmHelper) + + startDisplayBounds = + wmHelper.currentState.layerState.physicalDisplayBounds + ?: error("Can't get display bounds") + } + transitions { testApp.launchThirdActivity(wmHelper) } + teardown { + tapl.goHome() + testApp.exit(wmHelper) + } + } + + /** Main activity remains visible throughout the transition. */ + @Presubmit + @Test + fun mainActivityWindowAlwaysVisible() { + flicker.assertWm { isAppWindowVisible(ActivityEmbeddingAppHelper.MAIN_ACTIVITY_COMPONENT) } + } + + /** Main activity remains visible throughout the transition and takes up half of the screen. */ + @Presubmit + @Test + fun mainActivityLayersAlwaysVisible() { + flicker.assertLayers { isVisible(ActivityEmbeddingAppHelper.MAIN_ACTIVITY_COMPONENT) } + + flicker.assertLayersStart { + val display = + this.entry.displays.firstOrNull { it.isOn && !it.isVirtual } + ?: error("No non-virtual and on display found") + val mainActivityRegion = + this.visibleRegion(ActivityEmbeddingAppHelper.MAIN_ACTIVITY_COMPONENT) + val secondaryActivityRegion = + this.visibleRegion(ActivityEmbeddingAppHelper.SECONDARY_ACTIVITY_COMPONENT).region + mainActivityRegion.plus(secondaryActivityRegion).coversExactly(display.layerStackSpace) + } + + flicker.assertLayersEnd { + val display = + this.entry.displays.firstOrNull { it.isOn && !it.isVirtual } + ?: error("No non-virtual and on display found") + val mainActivityRegion = + this.visibleRegion(ActivityEmbeddingAppHelper.MAIN_ACTIVITY_COMPONENT) + val secondaryActivityRegion = + this.visibleRegion(ActivityEmbeddingAppHelper.SECONDARY_ACTIVITY_COMPONENT) + secondaryActivityRegion.isEmpty() + val thirdActivityRegion = + this.visibleRegion(ActivityEmbeddingAppHelper.THIRD_ACTIVITY_COMPONENT) + mainActivityRegion + .plus(thirdActivityRegion.region) + .coversExactly(display.layerStackSpace) + } + } + + /** Third activity launches during the transition and covers up secondary activity. */ + @Presubmit + @Test + fun thirdActivityWindowLaunchesIntoSplit() { + flicker.assertWm { + isAppWindowVisible(ActivityEmbeddingAppHelper.SECONDARY_ACTIVITY_COMPONENT) + .isAppWindowInvisible(ActivityEmbeddingAppHelper.THIRD_ACTIVITY_COMPONENT) + .then() + .isAppWindowVisible(ActivityEmbeddingAppHelper.SECONDARY_ACTIVITY_COMPONENT) + .isAppWindowVisible(ActivityEmbeddingAppHelper.THIRD_ACTIVITY_COMPONENT) + .then() + .isAppWindowVisible(ActivityEmbeddingAppHelper.THIRD_ACTIVITY_COMPONENT) + .isAppWindowInvisible( + ActivityEmbeddingAppHelper.SECONDARY_ACTIVITY_COMPONENT + ) // expectation + } + } + + /** Third activity launches during the transition and covers up secondary activity. */ + @Presubmit + @Test + fun thirdActivityLayerLaunchesIntoSplit() { + flicker.assertLayers { + isVisible(ActivityEmbeddingAppHelper.SECONDARY_ACTIVITY_COMPONENT) + .isInvisible(ActivityEmbeddingAppHelper.THIRD_ACTIVITY_COMPONENT) + .then() + .isVisible(ActivityEmbeddingAppHelper.SECONDARY_ACTIVITY_COMPONENT) + .isVisible(ActivityEmbeddingAppHelper.THIRD_ACTIVITY_COMPONENT) + .then() + .isVisible(ActivityEmbeddingAppHelper.THIRD_ACTIVITY_COMPONENT) + .isInvisible(ActivityEmbeddingAppHelper.SECONDARY_ACTIVITY_COMPONENT) + } + } + + companion object { + /** {@inheritDoc} */ + private var startDisplayBounds = Rect.EMPTY + /** + * Creates the test configurations. + * + * See [LegacyFlickerTestFactory.nonRotationTests] for configuring screen orientation and + * navigation modes. + */ + @Parameterized.Parameters(name = "{0}") + @JvmStatic + fun getParams() = LegacyFlickerTestFactory.nonRotationTests() + } +} diff --git a/tests/FlickerTests/src/com/android/server/wm/flicker/activityembedding/open/OpenTrampolineActivityTest.kt b/tests/FlickerTests/src/com/android/server/wm/flicker/activityembedding/open/OpenTrampolineActivityTest.kt new file mode 100644 index 000000000000..6432f1f10cf1 --- /dev/null +++ b/tests/FlickerTests/src/com/android/server/wm/flicker/activityembedding/open/OpenTrampolineActivityTest.kt @@ -0,0 +1,221 @@ +/* + * Copyright (C) 2023 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.server.wm.flicker.activityembedding.open + +import android.platform.test.annotations.FlakyTest +import android.platform.test.annotations.Presubmit +import android.tools.common.datatypes.Rect +import android.tools.common.datatypes.Region +import android.tools.common.flicker.subject.region.RegionSubject +import android.tools.common.traces.component.ComponentNameMatcher +import android.tools.device.flicker.junit.FlickerParametersRunnerFactory +import android.tools.device.flicker.legacy.FlickerBuilder +import android.tools.device.flicker.legacy.LegacyFlickerTest +import android.tools.device.flicker.legacy.LegacyFlickerTestFactory +import androidx.test.filters.RequiresDevice +import com.android.server.wm.flicker.activityembedding.ActivityEmbeddingTestBase +import com.android.server.wm.flicker.helpers.ActivityEmbeddingAppHelper +import org.junit.FixMethodOrder +import org.junit.Test +import org.junit.runner.RunWith +import org.junit.runners.MethodSorters +import org.junit.runners.Parameterized + +/** + * Test launching a trampoline activity and resulting in a split state. + * + * Setup: Launch Activity A in fullscreen. + * + * Transitions: From A launch a trampoline Activity T, T launches secondary Activity B and + * finishes itself, end up in split A|B. + * + * To run this test: `atest FlickerTestsOther:OpenTrampolineActivityTest` + */ +@RequiresDevice +@RunWith(Parameterized::class) +@Parameterized.UseParametersRunnerFactory(FlickerParametersRunnerFactory::class) +@FixMethodOrder(MethodSorters.NAME_ASCENDING) +class OpenTrampolineActivityTest(flicker: LegacyFlickerTest) : ActivityEmbeddingTestBase(flicker) { + override val transition: FlickerBuilder.() -> Unit = { + setup { + tapl.setExpectedRotationCheckEnabled(false) + testApp.launchViaIntent(wmHelper) + startDisplayBounds = + wmHelper.currentState.layerState.physicalDisplayBounds + ?: error("Can't get display bounds") + } + transitions { + testApp.launchTrampolineActivity(wmHelper) + } + teardown { + tapl.goHome() + testApp.exit(wmHelper) + } + } + + /** Trampoline activity should finish itself before the end of this test. */ + @Presubmit + @Test + fun trampolineActivityFinishes() { + flicker.assertWmEnd { + notContains(ActivityEmbeddingAppHelper.TRAMPOLINE_ACTIVITY_COMPONENT) + } + } + + @Presubmit + @Test + fun trampolineLayerNeverVisible() { + flicker.assertLayers { + isInvisible(ActivityEmbeddingAppHelper.TRAMPOLINE_ACTIVITY_COMPONENT) + } + } + + /** Main activity is always visible throughout this test. */ + @Presubmit + @Test + fun mainActivityWindowAlwaysVisible() { + flicker.assertWm { + isAppWindowVisible(ActivityEmbeddingAppHelper.MAIN_ACTIVITY_COMPONENT) + } + } + + // TODO(b/289140963): After this is fixed, assert the main Activity window is visible + // throughout the test instead. + /** Main activity layer is visible before and after the transition. */ + @Presubmit + @Test + fun mainActivityLayerAlwaysVisible() { + flicker.assertLayersStart { + isVisible(ActivityEmbeddingAppHelper.MAIN_ACTIVITY_COMPONENT) + } + flicker.assertLayersEnd { + isVisible(ActivityEmbeddingAppHelper.MAIN_ACTIVITY_COMPONENT) + } + } + + /** Secondary activity is launched from the trampoline activity. */ + @Presubmit + @Test + fun secondaryActivityWindowLaunchedFromTrampoline() { + flicker.assertWm { + notContains(ActivityEmbeddingAppHelper.SECONDARY_ACTIVITY_COMPONENT) + .then() + .isAppWindowInvisible(ActivityEmbeddingAppHelper.SECONDARY_ACTIVITY_COMPONENT) + .then() + .isAppWindowVisible(ActivityEmbeddingAppHelper.SECONDARY_ACTIVITY_COMPONENT) + } + } + + /** Secondary activity is launched from the trampoline activity. */ + @Presubmit + @Test + fun secondaryActivityLayerLaunchedFromTrampoline() { + flicker.assertLayers { + isInvisible(ActivityEmbeddingAppHelper.SECONDARY_ACTIVITY_COMPONENT) + .then() + .isVisible(ActivityEmbeddingAppHelper.SECONDARY_ACTIVITY_COMPONENT) + } + } + + /** Main activity should go from fullscreen to being a split with secondary activity. */ + @Presubmit + @Test + fun mainActivityWindowGoesFromFullscreenToSplit() { + flicker.assertWm { + this.invoke("mainActivityStartsInFullscreen") { + it.visibleRegion(ActivityEmbeddingAppHelper.MAIN_ACTIVITY_COMPONENT) + .coversExactly(startDisplayBounds) + } + // Begin of transition. + .then() + .isAppWindowInvisible(ActivityEmbeddingAppHelper.SECONDARY_ACTIVITY_COMPONENT) + .then() + .invoke("mainAndSecondaryInSplit") { + val mainActivityRegion = + RegionSubject( + it.visibleRegion( + ActivityEmbeddingAppHelper + .MAIN_ACTIVITY_COMPONENT).region, + it.timestamp) + val secondaryActivityRegion = + RegionSubject( + it.visibleRegion( + ActivityEmbeddingAppHelper + .SECONDARY_ACTIVITY_COMPONENT).region, + it.timestamp) + check { "height" } + .that(mainActivityRegion.region.height) + .isEqual(secondaryActivityRegion.region.height) + check { "width" } + .that(mainActivityRegion.region.width) + .isEqual(secondaryActivityRegion.region.width) + mainActivityRegion + .plus(secondaryActivityRegion.region) + .coversExactly(startDisplayBounds) + } + } + } + + @FlakyTest(bugId = 290736037) + /** Main activity should go from fullscreen to being a split with secondary activity. */ + @Presubmit + @Test + fun mainActivityLayerGoesFromFullscreenToSplit() { + flicker.assertLayers { + this.invoke("mainActivityStartsInFullscreen") { + it.visibleRegion(ActivityEmbeddingAppHelper.MAIN_ACTIVITY_COMPONENT) + .coversExactly(startDisplayBounds) + } + .then() + .isInvisible(ActivityEmbeddingAppHelper.SECONDARY_ACTIVITY_COMPONENT) + .then() + .isVisible(ActivityEmbeddingAppHelper.SECONDARY_ACTIVITY_COMPONENT) + } + flicker.assertLayersEnd { + val leftLayerRegion = visibleRegion( + ActivityEmbeddingAppHelper.MAIN_ACTIVITY_COMPONENT) + val rightLayerRegion = + visibleRegion(ActivityEmbeddingAppHelper.SECONDARY_ACTIVITY_COMPONENT) + // Compare dimensions of two splits, given we're using default split attributes, + // both activities take up the same visible size on the display. + check { "height" } + .that(leftLayerRegion.region.height) + .isEqual(rightLayerRegion.region.height) + check { "width" } + .that(leftLayerRegion.region.width) + .isEqual(rightLayerRegion.region.width) + leftLayerRegion.notOverlaps(rightLayerRegion.region) + // Layers of two activities sum to be fullscreen size on display. + leftLayerRegion.plus(rightLayerRegion.region).coversExactly(startDisplayBounds) + } + } + + companion object { + /** {@inheritDoc} */ + private var startDisplayBounds = Rect.EMPTY + + /** + * Creates the test configurations. + * + * See [LegacyFlickerTestFactory.nonRotationTests] for configuring screen orientation and + * navigation modes. + */ + @Parameterized.Parameters(name = "{0}") + @JvmStatic + fun getParams() = LegacyFlickerTestFactory.nonRotationTests() + } +}
\ No newline at end of file diff --git a/tests/FlickerTests/src/com/android/server/wm/flicker/activityembedding/pip/SecondaryActivityEnterPipTest.kt b/tests/FlickerTests/src/com/android/server/wm/flicker/activityembedding/pip/SecondaryActivityEnterPipTest.kt new file mode 100644 index 000000000000..9ad3eddd1c4f --- /dev/null +++ b/tests/FlickerTests/src/com/android/server/wm/flicker/activityembedding/pip/SecondaryActivityEnterPipTest.kt @@ -0,0 +1,189 @@ +/* + * Copyright (C) 2023 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.server.wm.flicker.activityembedding.pip + +import android.platform.test.annotations.Presubmit +import android.tools.common.datatypes.Rect +import android.tools.common.traces.component.ComponentNameMatcher +import android.tools.common.traces.component.ComponentNameMatcher.Companion.TRANSITION_SNAPSHOT +import android.tools.device.flicker.junit.FlickerParametersRunnerFactory +import android.tools.device.flicker.legacy.FlickerBuilder +import android.tools.device.flicker.legacy.LegacyFlickerTest +import android.tools.device.flicker.legacy.LegacyFlickerTestFactory +import androidx.test.filters.RequiresDevice +import com.android.server.wm.flicker.activityembedding.ActivityEmbeddingTestBase +import com.android.server.wm.flicker.helpers.ActivityEmbeddingAppHelper +import org.junit.FixMethodOrder +import org.junit.Test +import org.junit.runner.RunWith +import org.junit.runners.MethodSorters +import org.junit.runners.Parameterized + +/** + * Test launching a secondary Activity into Picture-In-Picture mode. + * + * Setup: Start from a split A|B. + * Transition: B enters PIP, observe the window shrink to the bottom right corner on screen. + * + * To run this test: `atest FlickerTestsOther:SecondaryActivityEnterPipTest` + * + */ +@RequiresDevice +@RunWith(Parameterized::class) +@Parameterized.UseParametersRunnerFactory(FlickerParametersRunnerFactory::class) +@FixMethodOrder(MethodSorters.NAME_ASCENDING) +class SecondaryActivityEnterPipTest (flicker: LegacyFlickerTest) : + ActivityEmbeddingTestBase(flicker) { + override val transition: FlickerBuilder.() -> Unit = { + setup { + tapl.setExpectedRotationCheckEnabled(false) + testApp.launchViaIntent(wmHelper) + testApp.launchSecondaryActivity(wmHelper) + startDisplayBounds = + wmHelper.currentState.layerState.physicalDisplayBounds + ?: error("Can't get display bounds") + } + transitions { + testApp.secondaryActivityEnterPip(wmHelper) + } + teardown { + tapl.goHome() + testApp.exit(wmHelper) + } + } + + /** + * Main and secondary activity start from a split each taking half of the screen. + */ + @Presubmit + @Test + fun layersStartFromEqualSplit() { + flicker.assertLayersStart { + val leftLayerRegion = + visibleRegion(ActivityEmbeddingAppHelper.MAIN_ACTIVITY_COMPONENT) + val rightLayerRegion = + visibleRegion(ActivityEmbeddingAppHelper.SECONDARY_ACTIVITY_COMPONENT) + // Compare dimensions of two splits, given we're using default split attributes, + // both activities take up the same visible size on the display. + check { "height" } + .that(leftLayerRegion.region.height).isEqual(rightLayerRegion.region.height) + check { "width" } + .that(leftLayerRegion.region.width).isEqual(rightLayerRegion.region.width) + leftLayerRegion.notOverlaps(rightLayerRegion.region) + leftLayerRegion.plus(rightLayerRegion.region).coversExactly(startDisplayBounds) + } + flicker.assertLayersEnd { + visibleRegion(ActivityEmbeddingAppHelper.MAIN_ACTIVITY_COMPONENT) + .coversExactly(startDisplayBounds) + } + } + + /** + * Main Activity is visible throughout the transition and becomes fullscreen. + */ + @Presubmit + @Test + fun mainActivityWindowBecomesFullScreen() { + flicker.assertWm { isAppWindowVisible(ActivityEmbeddingAppHelper.MAIN_ACTIVITY_COMPONENT) } + flicker.assertWmEnd { + visibleRegion(ActivityEmbeddingAppHelper.MAIN_ACTIVITY_COMPONENT) + .coversExactly(startDisplayBounds) + } + } + + /** + * Main Activity is visible throughout the transition and becomes fullscreen. + */ + @Presubmit + @Test + fun mainActivityLayerBecomesFullScreen() { + flicker.assertLayers { + isVisible(ActivityEmbeddingAppHelper.MAIN_ACTIVITY_COMPONENT) + .then() + .isVisible(TRANSITION_SNAPSHOT) + .isInvisible(ActivityEmbeddingAppHelper.MAIN_ACTIVITY_COMPONENT) + .then() + .isVisible(ActivityEmbeddingAppHelper.MAIN_ACTIVITY_COMPONENT) + } + flicker.assertLayersEnd { + visibleRegion(ActivityEmbeddingAppHelper.MAIN_ACTIVITY_COMPONENT) + .coversExactly(startDisplayBounds) + } + } + + /** + * Secondary Activity is visible throughout the transition and shrinks to the bottom right + * corner. + */ + @Presubmit + @Test + fun secondaryWindowShrinks() { + flicker.assertWm { + isAppWindowVisible(ActivityEmbeddingAppHelper.SECONDARY_ACTIVITY_COMPONENT) + } + flicker.assertWmEnd { + val pipWindowRegion = + visibleRegion(ActivityEmbeddingAppHelper.SECONDARY_ACTIVITY_COMPONENT) + check{"height"} + .that(pipWindowRegion.region.height) + .isLower(startDisplayBounds.height / 2) + check{"width"} + .that(pipWindowRegion.region.width).isLower(startDisplayBounds.width) + } + } + + /** + * During the transition Secondary Activity shrinks to the bottom right corner. + */ + @Presubmit + @Test + fun secondaryLayerShrinks() { + flicker.assertLayers { + val pipLayerList = layers { + ComponentNameMatcher.PIP_CONTENT_OVERLAY.layerMatchesAnyOf(it) && it.isVisible + } + pipLayerList.zipWithNext { previous, current -> + // TODO(b/290987990): Add checks for visibleRegion. + current.screenBounds.isToTheRightBottom(previous.screenBounds.region, 3) + current.screenBounds.notBiggerThan(previous.screenBounds.region) + } + } + flicker.assertLayersEnd { + val pipRegion = visibleRegion( + ActivityEmbeddingAppHelper.SECONDARY_ACTIVITY_COMPONENT) + check { "height" } + .that(pipRegion.region.height) + .isLower(startDisplayBounds.height / 2) + check { "width" } + .that(pipRegion.region.width).isLower(startDisplayBounds.width) + } + } + + companion object { + /** {@inheritDoc} */ + private var startDisplayBounds = Rect.EMPTY + /** + * Creates the test configurations. + * + * See [LegacyFlickerTestFactory.nonRotationTests] for configuring screen orientation and + * navigation modes. + */ + @Parameterized.Parameters(name = "{0}") + @JvmStatic + fun getParams() = LegacyFlickerTestFactory.nonRotationTests() + } +}
\ No newline at end of file diff --git a/tests/FlickerTests/src/com/android/server/wm/flicker/activityembedding/rotation/RotateSplitNoChangeTest.kt b/tests/FlickerTests/src/com/android/server/wm/flicker/activityembedding/rotation/RotateSplitNoChangeTest.kt new file mode 100644 index 000000000000..4f7d8a474da1 --- /dev/null +++ b/tests/FlickerTests/src/com/android/server/wm/flicker/activityembedding/rotation/RotateSplitNoChangeTest.kt @@ -0,0 +1,147 @@ +/* + * Copyright (C) 2023 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.server.wm.flicker.activityembedding.rotation + +import android.platform.test.annotations.Presubmit +import android.tools.common.traces.component.ComponentNameMatcher +import android.tools.device.flicker.junit.FlickerParametersRunnerFactory +import android.tools.device.flicker.legacy.FlickerBuilder +import android.tools.device.flicker.legacy.LegacyFlickerTest +import android.tools.device.flicker.legacy.LegacyFlickerTestFactory +import androidx.test.filters.RequiresDevice +import com.android.server.wm.flicker.activityembedding.ActivityEmbeddingTestBase +import com.android.server.wm.flicker.helpers.ActivityEmbeddingAppHelper +import com.android.server.wm.flicker.rotation.RotationTransition +import org.junit.FixMethodOrder +import org.junit.Test +import org.junit.runner.RunWith +import org.junit.runners.MethodSorters +import org.junit.runners.Parameterized + +/** + * Tests rotating two activities in an Activity Embedding split. + * + * Setup: Launch A|B in split with B being the secondary activity. Transitions: Rotate display, and + * expect A and B to split evenly in new rotation. + * + * To run this test: `atest FlickerTestsOther:RotateSplitNoChangeTest` + */ +@RequiresDevice +@RunWith(Parameterized::class) +@Parameterized.UseParametersRunnerFactory(FlickerParametersRunnerFactory::class) +@FixMethodOrder(MethodSorters.NAME_ASCENDING) +open class RotateSplitNoChangeTest(flicker: LegacyFlickerTest) : RotationTransition(flicker) { + + override val testApp = ActivityEmbeddingAppHelper(instrumentation) + override val transition: FlickerBuilder.() -> Unit + get() = { + super.transition(this) + setup { + testApp.launchViaIntent(wmHelper) + testApp.launchSecondaryActivity(wmHelper) + } + } + + /** + * Checks that the [ComponentNameMatcher.ROTATION] layer appears during the transition, doesn't + * flicker, and disappears before the transition is complete + */ + @Presubmit + @Test + fun rotationLayerAppearsAndVanishes() { + flicker.assertLayers { + this.isVisible(testApp) + .then() + .isVisible(ComponentNameMatcher.ROTATION) + .then() + .isVisible(testApp) + .isInvisible(ComponentNameMatcher.ROTATION) + } + } + + /** + * Overrides inherited assertion because in AE Split, the main and secondary activity are + * separate layers, each covering up exactly half of the display. + */ + @Presubmit + @Test + override fun appLayerRotates_StartingPos() { + flicker.assertLayersStart { + this.entry.displays.map { display -> + val leftLayerRegion = + this.visibleRegion(ActivityEmbeddingAppHelper.MAIN_ACTIVITY_COMPONENT) + val rightLayerRegion = + this.visibleRegion(ActivityEmbeddingAppHelper.SECONDARY_ACTIVITY_COMPONENT) + // Compare dimensions of two splits, given we're using default split attributes, + // both activities take up the same visible size on the display. + check { "height" } + .that(leftLayerRegion.region.height) + .isEqual(rightLayerRegion.region.height) + check { "width" } + .that(leftLayerRegion.region.width) + .isEqual(rightLayerRegion.region.width) + leftLayerRegion.notOverlaps(rightLayerRegion.region) + // Layers of two activities sum to be fullscreen size on display. + leftLayerRegion.plus(rightLayerRegion.region).coversExactly(display.layerStackSpace) + } + } + } + + /** Verifies dimensions of both split activities hold their invariance after transition too. */ + @Presubmit + @Test + override fun appLayerRotates_EndingPos() { + flicker.assertLayersEnd { + this.entry.displays.map { display -> + val leftLayerRegion = + this.visibleRegion(ActivityEmbeddingAppHelper.MAIN_ACTIVITY_COMPONENT) + val rightLayerRegion = + this.visibleRegion(ActivityEmbeddingAppHelper.SECONDARY_ACTIVITY_COMPONENT) + check { "height" } + .that(leftLayerRegion.region.height) + .isEqual(rightLayerRegion.region.height) + check { "width" } + .that(leftLayerRegion.region.width) + .isEqual(rightLayerRegion.region.width) + leftLayerRegion.notOverlaps(rightLayerRegion.region) + leftLayerRegion.plus(rightLayerRegion.region).coversExactly(display.layerStackSpace) + } + } + } + + /** Both activities in split should remain visible during rotation. */ + @Presubmit + @Test + fun bothActivitiesAreAlwaysVisible() { + flicker.assertWm { isAppWindowVisible(ActivityEmbeddingAppHelper.MAIN_ACTIVITY_COMPONENT) } + flicker.assertWm { + isAppWindowVisible(ActivityEmbeddingAppHelper.SECONDARY_ACTIVITY_COMPONENT) + } + } + + companion object { + /** + * Creates the test configurations. + * + * See [LegacyFlickerTestFactory.nonRotationTests] for configuring screen orientation and + * navigation modes. + */ + @Parameterized.Parameters(name = "{0}") + @JvmStatic + fun getParams() = LegacyFlickerTestFactory.rotationTests() + } +} diff --git a/tests/FlickerTests/src/com/android/server/wm/flicker/activityembedding/rtl/RTLStartSecondaryWithPlaceholderTest.kt b/tests/FlickerTests/src/com/android/server/wm/flicker/activityembedding/rtl/RTLStartSecondaryWithPlaceholderTest.kt new file mode 100644 index 000000000000..6be78f829b34 --- /dev/null +++ b/tests/FlickerTests/src/com/android/server/wm/flicker/activityembedding/rtl/RTLStartSecondaryWithPlaceholderTest.kt @@ -0,0 +1,207 @@ +/* + * Copyright (C) 2023 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.server.wm.flicker.activityembedding.rtl + +import android.platform.test.annotations.Presubmit +import android.tools.device.flicker.junit.FlickerParametersRunnerFactory +import android.tools.device.flicker.legacy.FlickerBuilder +import android.tools.device.flicker.legacy.LegacyFlickerTest +import android.tools.device.flicker.legacy.LegacyFlickerTestFactory +import androidx.test.filters.RequiresDevice +import com.android.server.wm.flicker.activityembedding.ActivityEmbeddingTestBase +import com.android.server.wm.flicker.helpers.ActivityEmbeddingAppHelper +import org.junit.FixMethodOrder +import org.junit.Test +import org.junit.runner.RunWith +import org.junit.runners.MethodSorters +import org.junit.runners.Parameterized + +/** + * Test launching a placeholder split over a normal split, both splits are configured in RTL. + * + * Setup: From A launch a split in RTL - resulting in B|A. Transitions: From A start + * PlaceholderPrimary, which is configured to launch with PlaceholderSecondary in RTL. Expect split + * PlaceholderSecondary|PlaceholderPrimary covering split B|A. + * + * To run this test: `atest FlickerTestsOther:RTLStartSecondaryWithPlaceholderTest` + */ +@RequiresDevice +@RunWith(Parameterized::class) +@Parameterized.UseParametersRunnerFactory(FlickerParametersRunnerFactory::class) +@FixMethodOrder(MethodSorters.NAME_ASCENDING) +class RTLStartSecondaryWithPlaceholderTest(flicker: LegacyFlickerTest) : + ActivityEmbeddingTestBase(flicker) { + + /** {@inheritDoc} */ + override val transition: FlickerBuilder.() -> Unit = { + setup { + tapl.setExpectedRotationCheckEnabled(false) + testApp.launchViaIntent(wmHelper) + testApp.launchSecondaryActivityRTL(wmHelper) + } + transitions { testApp.launchPlaceholderSplitRTL(wmHelper) } + teardown { + tapl.goHome() + testApp.exit(wmHelper) + } + } + + /** + * Main activity and Secondary activity will become invisible because they are covered by + * PlaceholderPrimary activity and PlaceholderSecondary activity. + */ + @Presubmit + @Test + fun assertWindowVisibilities() { + flicker.assertWm { + isAppWindowVisible(ActivityEmbeddingAppHelper.MAIN_ACTIVITY_COMPONENT) + .then() + .isAppWindowInvisible(ActivityEmbeddingAppHelper.MAIN_ACTIVITY_COMPONENT) + } + flicker.assertWm { + isAppWindowVisible(ActivityEmbeddingAppHelper.SECONDARY_ACTIVITY_COMPONENT) + .then() + .isAppWindowInvisible(ActivityEmbeddingAppHelper.SECONDARY_ACTIVITY_COMPONENT) + } + flicker.assertWm { + isAppWindowInvisible(ActivityEmbeddingAppHelper.PLACEHOLDER_PRIMARY_COMPONENT) + .then() + .isAppWindowVisible(ActivityEmbeddingAppHelper.PLACEHOLDER_PRIMARY_COMPONENT) + } + flicker.assertWm { + isAppWindowInvisible(ActivityEmbeddingAppHelper.PLACEHOLDER_SECONDARY_COMPONENT) + .then() + .isAppWindowVisible(ActivityEmbeddingAppHelper.PLACEHOLDER_SECONDARY_COMPONENT) + } + } + + /** + * Main activity and Secondary activity will become invisible because they are covered by + * PlaceholderPrimary activity and PlaceholderSecondary activity. + */ + @Presubmit + @Test + fun assertLayerVisibilities() { + flicker.assertLayers { + this.isVisible(ActivityEmbeddingAppHelper.MAIN_ACTIVITY_COMPONENT) + .then() + .isInvisible(ActivityEmbeddingAppHelper.MAIN_ACTIVITY_COMPONENT) + } + flicker.assertLayers { + this.isVisible(ActivityEmbeddingAppHelper.SECONDARY_ACTIVITY_COMPONENT) + .then() + .isInvisible(ActivityEmbeddingAppHelper.SECONDARY_ACTIVITY_COMPONENT) + } + flicker.assertLayers { + isInvisible(ActivityEmbeddingAppHelper.PLACEHOLDER_PRIMARY_COMPONENT) + .then() + .isVisible(ActivityEmbeddingAppHelper.PLACEHOLDER_PRIMARY_COMPONENT) + } + flicker.assertLayers { + isInvisible(ActivityEmbeddingAppHelper.PLACEHOLDER_SECONDARY_COMPONENT) + .then() + .isVisible(ActivityEmbeddingAppHelper.PLACEHOLDER_SECONDARY_COMPONENT) + } + } + + /** Main activity and Secondary activity split is in right-to-left layout direction. */ + @Presubmit + @Test + fun assertWMRTLBeforeTransition() { + flicker.assertWmStart { + val mainActivityRegion = + this.visibleRegion(ActivityEmbeddingAppHelper.MAIN_ACTIVITY_COMPONENT) + val secondaryActivityRegion = + this.visibleRegion(ActivityEmbeddingAppHelper.SECONDARY_ACTIVITY_COMPONENT) + mainActivityRegion.notOverlaps(secondaryActivityRegion.region) + // secondary activity is on the left, main activity is on the right. + check { "isRTLBeforeTransition" } + .that(mainActivityRegion.region.bounds.left) + .isEqual(secondaryActivityRegion.region.bounds.right) + } + } + + /** Main activity and Secondary activity split is in right-to-left layout direction. */ + @Presubmit + @Test + fun assertLayerRTLBeforeTransition() { + flicker.assertLayersStart { + val mainActivityRegion = + this.visibleRegion(ActivityEmbeddingAppHelper.MAIN_ACTIVITY_COMPONENT) + val secondaryActivityRegion = + this.visibleRegion(ActivityEmbeddingAppHelper.SECONDARY_ACTIVITY_COMPONENT) + mainActivityRegion.notOverlaps(secondaryActivityRegion.region) + // secondary activity is on the left, main activity is on the right. + check { "isRTLBeforeTransition" } + .that(mainActivityRegion.region.bounds.left) + .isEqual(secondaryActivityRegion.region.bounds.right) + } + } + + /** + * PlaceholderPrimary activity and PlaceholderSecondary activity split are in right-to-left + * layout direction. + */ + @Presubmit + @Test + fun assertWMRTLAfterTransition() { + flicker.assertWmEnd { + val mainActivityRegion = + this.visibleRegion(ActivityEmbeddingAppHelper.MAIN_ACTIVITY_COMPONENT) + val secondaryActivityRegion = + this.visibleRegion(ActivityEmbeddingAppHelper.SECONDARY_ACTIVITY_COMPONENT) + mainActivityRegion.notOverlaps(secondaryActivityRegion.region) + // secondary activity is on the left, main activity is on the right. + check { "isRTLBeforeTransition" } + .that(mainActivityRegion.region.bounds.left) + .isEqual(secondaryActivityRegion.region.bounds.right) + } + } + + /** + * PlaceholderPrimary activity and PlaceholderSecondary activity split are in right-to-left + * layout direction. + */ + @Presubmit + @Test + fun assertLayerRTLAfterTransition() { + flicker.assertLayersEnd { + val mainActivityRegion = + this.visibleRegion(ActivityEmbeddingAppHelper.PLACEHOLDER_PRIMARY_COMPONENT) + val secondaryActivityRegion = + this.visibleRegion(ActivityEmbeddingAppHelper.PLACEHOLDER_SECONDARY_COMPONENT) + mainActivityRegion.notOverlaps(secondaryActivityRegion.region) + // Placeholder secondary activity is on the left, placeholder primary activity is on the + // right. + check { "isRTLAfterTransition" } + .that(mainActivityRegion.region.bounds.left) + .isEqual(secondaryActivityRegion.region.bounds.right) + } + } + + companion object { + /** + * Creates the test configurations. + * + * See [LegacyFlickerTestFactory.nonRotationTests] for configuring screen orientation and + * navigation modes. + */ + @Parameterized.Parameters(name = "{0}") + @JvmStatic + fun getParams() = LegacyFlickerTestFactory.nonRotationTests() + } +} diff --git a/tests/FlickerTests/src/com/android/server/wm/flicker/activityembedding/splitscreen/EnterSystemSplitTest.kt b/tests/FlickerTests/src/com/android/server/wm/flicker/activityembedding/splitscreen/EnterSystemSplitTest.kt new file mode 100644 index 000000000000..87231c86ef19 --- /dev/null +++ b/tests/FlickerTests/src/com/android/server/wm/flicker/activityembedding/splitscreen/EnterSystemSplitTest.kt @@ -0,0 +1,189 @@ +/* + * Copyright (C) 2023 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.server.wm.flicker.activityembedding.splitscreen + +import android.platform.test.annotations.Presubmit +import android.platform.test.annotations.RequiresDevice +import android.tools.common.datatypes.Rect +import android.tools.device.flicker.junit.FlickerParametersRunnerFactory +import android.tools.device.flicker.legacy.FlickerBuilder +import android.tools.device.flicker.legacy.LegacyFlickerTest +import android.tools.device.flicker.legacy.LegacyFlickerTestFactory +import android.tools.device.traces.parsers.toFlickerComponent +import com.android.server.wm.flicker.helpers.ActivityEmbeddingAppHelper +import com.android.server.wm.flicker.activityembedding.ActivityEmbeddingTestBase +import com.android.server.wm.flicker.testapp.ActivityOptions +import com.android.wm.shell.flicker.utils.* +import org.junit.FixMethodOrder +import org.junit.Ignore +import org.junit.Test +import org.junit.runner.RunWith +import org.junit.runners.MethodSorters +import org.junit.runners.Parameterized + +/*** + * Test entering System SplitScreen with Activity Embedding Split and another app. + * + * Setup: Launch A|B in split and secondaryApp, return to home. + * Transitions: Let AE Split A|B enter splitscreen with secondaryApp. Resulting in A|B|secondaryApp. + * + * To run this test: `atest FlickerTestsOther:EnterSystemSplitTest` + */ +@RequiresDevice +@RunWith(Parameterized::class) +@Parameterized.UseParametersRunnerFactory(FlickerParametersRunnerFactory::class) +@FixMethodOrder(MethodSorters.NAME_ASCENDING) +class EnterSystemSplitTest(flicker: LegacyFlickerTest) : + ActivityEmbeddingTestBase(flicker) { + + private val secondaryApp = SplitScreenUtils.getPrimary(instrumentation) + override val transition: FlickerBuilder.() -> Unit = { + setup { + testApp.launchViaIntent(wmHelper) + testApp.launchSecondaryActivity(wmHelper) + secondaryApp.launchViaIntent(wmHelper) + tapl.goHome() + wmHelper + .StateSyncBuilder() + .withAppTransitionIdle() + .withHomeActivityVisible() + .waitForAndVerify() + startDisplayBounds = + wmHelper.currentState.layerState.physicalDisplayBounds ?: + error("Display not found") + } + transitions { + SplitScreenUtils.enterSplit(wmHelper, tapl, device, testApp, secondaryApp) + SplitScreenUtils.waitForSplitComplete(wmHelper, testApp, secondaryApp) + } + } + + @Presubmit + @Test + fun splitScreenDividerBecomesVisible() = flicker.splitScreenDividerBecomesVisible() + + @Presubmit + @Test + fun activityEmbeddingSplitLayerBecomesVisible() { + flicker.splitAppLayerBoundsIsVisibleAtEnd( + testApp, landscapePosLeft = tapl.isTablet, portraitPosTop = false) + } + + @Presubmit + @Test + fun activityEmbeddingSplitWindowBecomesVisible() = flicker.appWindowIsVisibleAtEnd(testApp) + + @Presubmit + @Test + fun secondaryLayerBecomesVisible() { + flicker.splitAppLayerBoundsIsVisibleAtEnd( + secondaryApp, landscapePosLeft = !tapl.isTablet, portraitPosTop = true) + } + + @Presubmit + @Test + fun secondaryAppWindowBecomesVisible() = flicker.appWindowIsVisibleAtEnd(secondaryApp) + + /** + * After the transition there should be both ActivityEmbedding activities, + * SplitScreenPrimaryActivity and the system split divider on screen. + * Verify the layers are in expected sizes. + */ + @Presubmit + @Test + fun activityEmbeddingSplitSurfaceAreEven() { + flicker.assertLayersEnd { + val leftAELayerRegion = + visibleRegion(ActivityEmbeddingAppHelper.MAIN_ACTIVITY_COMPONENT) + val rightAELayerRegion = + visibleRegion(ActivityEmbeddingAppHelper.SECONDARY_ACTIVITY_COMPONENT) + val secondaryAppLayerRegion = + visibleRegion( + ActivityOptions.SplitScreen.Primary.COMPONENT.toFlickerComponent()) + val systemDivider = visibleRegion(SPLIT_SCREEN_DIVIDER_COMPONENT) + leftAELayerRegion + .plus(rightAELayerRegion.region) + .plus(secondaryAppLayerRegion.region) + .plus(systemDivider.region) + .coversExactly(startDisplayBounds) + check { "ActivityEmbeddingSplitHeight" } + .that(leftAELayerRegion.region.height) + .isEqual(rightAELayerRegion.region.height) + check { "SystemSplitHeight" } + .that(rightAELayerRegion.region.height) + .isEqual(secondaryAppLayerRegion.region.height) + // TODO(b/292283182): Remove this special case handling. + check { "ActivityEmbeddingSplitWidth" } + .that(Math.abs( + leftAELayerRegion.region.width - rightAELayerRegion.region.width)) + .isLower(2) + check { "SystemSplitWidth" } + .that(Math.abs(secondaryAppLayerRegion.region.width - + 2 * rightAELayerRegion.region.width)) + .isLower(2) + } + } + + /** + * Verify the windows are in expected sizes. + */ + @Presubmit + @Test + fun activityEmbeddingSplitWindowsAreEven() { + flicker.assertWmEnd { + val leftAEWindowRegion = + visibleRegion(ActivityEmbeddingAppHelper.MAIN_ACTIVITY_COMPONENT) + val rightAEWindowRegion = + visibleRegion(ActivityEmbeddingAppHelper.SECONDARY_ACTIVITY_COMPONENT) + // There's no window for the divider bar. + val secondaryAppLayerRegion = + visibleRegion( + ActivityOptions.SplitScreen.Primary.COMPONENT.toFlickerComponent()) + check { "ActivityEmbeddingSplitHeight" } + .that(leftAEWindowRegion.region.height) + .isEqual(rightAEWindowRegion.region.height) + check { "SystemSplitHeight" } + .that(rightAEWindowRegion.region.height) + .isEqual(secondaryAppLayerRegion.region.height) + check { "ActivityEmbeddingSplitWidth" } + .that(Math.abs( + leftAEWindowRegion.region.width - rightAEWindowRegion.region.width)) + .isLower(2) + check { "SystemSplitWidth" } + .that(Math.abs(secondaryAppLayerRegion.region.width - + 2 * rightAEWindowRegion.region.width)) + .isLower(2) + } + } + + @Ignore("Not applicable to this CUJ.") + override fun visibleLayersShownMoreThanOneConsecutiveEntry() {} + + companion object { + /** {@inheritDoc} */ + private var startDisplayBounds = Rect.EMPTY + /** + * Creates the test configurations. + * + * See [LegacyFlickerTestFactory.nonRotationTests] for configuring screen orientation and + * navigation modes. + */ + @Parameterized.Parameters(name = "{0}") + @JvmStatic + fun getParams() = LegacyFlickerTestFactory.nonRotationTests() + } +}
\ No newline at end of file diff --git a/tests/FlickerTests/src/com/android/server/wm/flicker/close/CloseAppBackButtonTest.kt b/tests/FlickerTests/src/com/android/server/wm/flicker/close/CloseAppBackButtonTest.kt index 10b71ff1efd7..dbbc771809de 100644 --- a/tests/FlickerTests/src/com/android/server/wm/flicker/close/CloseAppBackButtonTest.kt +++ b/tests/FlickerTests/src/com/android/server/wm/flicker/close/CloseAppBackButtonTest.kt @@ -17,11 +17,11 @@ package com.android.server.wm.flicker.close import android.platform.test.annotations.FlakyTest -import android.tools.device.flicker.annotation.FlickerServiceCompatible +import android.tools.common.flicker.annotation.FlickerServiceCompatible import android.tools.device.flicker.junit.FlickerParametersRunnerFactory import android.tools.device.flicker.legacy.FlickerBuilder -import android.tools.device.flicker.legacy.FlickerTest -import android.tools.device.flicker.legacy.FlickerTestFactory +import android.tools.device.flicker.legacy.LegacyFlickerTest +import android.tools.device.flicker.legacy.LegacyFlickerTestFactory import androidx.test.filters.RequiresDevice import org.junit.FixMethodOrder import org.junit.Test @@ -76,7 +76,7 @@ import org.junit.runners.Parameterized @RunWith(Parameterized::class) @Parameterized.UseParametersRunnerFactory(FlickerParametersRunnerFactory::class) @FixMethodOrder(MethodSorters.NAME_ASCENDING) -open class CloseAppBackButtonTest(flicker: FlickerTest) : CloseAppTransition(flicker) { +open class CloseAppBackButtonTest(flicker: LegacyFlickerTest) : CloseAppTransition(flicker) { /** {@inheritDoc} */ override val transition: FlickerBuilder.() -> Unit get() = { @@ -96,13 +96,11 @@ open class CloseAppBackButtonTest(flicker: FlickerTest) : CloseAppTransition(fli /** * Creates the test configurations. * - * See [FlickerTestFactory.nonRotationTests] for configuring screen orientation and + * See [LegacyFlickerTestFactory.nonRotationTests] for configuring screen orientation and * navigation modes. */ @Parameterized.Parameters(name = "{0}") @JvmStatic - fun getParams(): List<FlickerTest> { - return FlickerTestFactory.nonRotationTests() - } + fun getParams() = LegacyFlickerTestFactory.nonRotationTests() } } diff --git a/tests/FlickerTests/src/com/android/server/wm/flicker/close/CloseAppBackButtonTestCfArm.kt b/tests/FlickerTests/src/com/android/server/wm/flicker/close/CloseAppBackButtonTestCfArm.kt index 9fa840190fbf..566f393efaea 100644 --- a/tests/FlickerTests/src/com/android/server/wm/flicker/close/CloseAppBackButtonTestCfArm.kt +++ b/tests/FlickerTests/src/com/android/server/wm/flicker/close/CloseAppBackButtonTestCfArm.kt @@ -16,10 +16,10 @@ package com.android.server.wm.flicker.close -import android.tools.device.flicker.annotation.FlickerServiceCompatible +import android.tools.common.flicker.annotation.FlickerServiceCompatible import android.tools.device.flicker.junit.FlickerParametersRunnerFactory -import android.tools.device.flicker.legacy.FlickerTest -import android.tools.device.flicker.legacy.FlickerTestFactory +import android.tools.device.flicker.legacy.LegacyFlickerTest +import android.tools.device.flicker.legacy.LegacyFlickerTestFactory import org.junit.FixMethodOrder import org.junit.runner.RunWith import org.junit.runners.MethodSorters @@ -29,18 +29,16 @@ import org.junit.runners.Parameterized @RunWith(Parameterized::class) @Parameterized.UseParametersRunnerFactory(FlickerParametersRunnerFactory::class) @FixMethodOrder(MethodSorters.NAME_ASCENDING) -class CloseAppBackButtonTestCfArm(flicker: FlickerTest) : CloseAppBackButtonTest(flicker) { +class CloseAppBackButtonTestCfArm(flicker: LegacyFlickerTest) : CloseAppBackButtonTest(flicker) { companion object { /** * Creates the test configurations. * - * See [FlickerTestFactory.nonRotationTests] for configuring screen orientation and + * See [LegacyFlickerTestFactory.nonRotationTests] for configuring screen orientation and * navigation modes. */ @Parameterized.Parameters(name = "{0}") @JvmStatic - fun getParams(): List<FlickerTest> { - return FlickerTestFactory.nonRotationTests() - } + fun getParams() = LegacyFlickerTestFactory.nonRotationTests() } } diff --git a/tests/FlickerTests/src/com/android/server/wm/flicker/close/CloseAppHomeButtonTest.kt b/tests/FlickerTests/src/com/android/server/wm/flicker/close/CloseAppHomeButtonTest.kt index e5bd350019c8..ed930fc8c236 100644 --- a/tests/FlickerTests/src/com/android/server/wm/flicker/close/CloseAppHomeButtonTest.kt +++ b/tests/FlickerTests/src/com/android/server/wm/flicker/close/CloseAppHomeButtonTest.kt @@ -17,11 +17,11 @@ package com.android.server.wm.flicker.close import android.platform.test.annotations.FlakyTest -import android.tools.device.flicker.annotation.FlickerServiceCompatible +import android.tools.common.flicker.annotation.FlickerServiceCompatible import android.tools.device.flicker.junit.FlickerParametersRunnerFactory import android.tools.device.flicker.legacy.FlickerBuilder -import android.tools.device.flicker.legacy.FlickerTest -import android.tools.device.flicker.legacy.FlickerTestFactory +import android.tools.device.flicker.legacy.LegacyFlickerTest +import android.tools.device.flicker.legacy.LegacyFlickerTestFactory import androidx.test.filters.RequiresDevice import org.junit.FixMethodOrder import org.junit.Test @@ -76,7 +76,7 @@ import org.junit.runners.Parameterized @RunWith(Parameterized::class) @Parameterized.UseParametersRunnerFactory(FlickerParametersRunnerFactory::class) @FixMethodOrder(MethodSorters.NAME_ASCENDING) -open class CloseAppHomeButtonTest(flicker: FlickerTest) : CloseAppTransition(flicker) { +open class CloseAppHomeButtonTest(flicker: LegacyFlickerTest) : CloseAppTransition(flicker) { /** {@inheritDoc} */ override val transition: FlickerBuilder.() -> Unit get() = { @@ -101,8 +101,6 @@ open class CloseAppHomeButtonTest(flicker: FlickerTest) : CloseAppTransition(fli /** Creates the test configurations. */ @Parameterized.Parameters(name = "{0}") @JvmStatic - fun getParams(): Collection<FlickerTest> { - return FlickerTestFactory.nonRotationTests() - } + fun getParams() = LegacyFlickerTestFactory.nonRotationTests() } } diff --git a/tests/FlickerTests/src/com/android/server/wm/flicker/close/CloseAppHomeButtonTestCfArm.kt b/tests/FlickerTests/src/com/android/server/wm/flicker/close/CloseAppHomeButtonTestCfArm.kt index 136995a78fd7..49ed183c2ccf 100644 --- a/tests/FlickerTests/src/com/android/server/wm/flicker/close/CloseAppHomeButtonTestCfArm.kt +++ b/tests/FlickerTests/src/com/android/server/wm/flicker/close/CloseAppHomeButtonTestCfArm.kt @@ -16,10 +16,10 @@ package com.android.server.wm.flicker.close -import android.tools.device.flicker.annotation.FlickerServiceCompatible +import android.tools.common.flicker.annotation.FlickerServiceCompatible import android.tools.device.flicker.junit.FlickerParametersRunnerFactory -import android.tools.device.flicker.legacy.FlickerTest -import android.tools.device.flicker.legacy.FlickerTestFactory +import android.tools.device.flicker.legacy.LegacyFlickerTest +import android.tools.device.flicker.legacy.LegacyFlickerTestFactory import org.junit.FixMethodOrder import org.junit.runner.RunWith import org.junit.runners.MethodSorters @@ -29,13 +29,11 @@ import org.junit.runners.Parameterized @RunWith(Parameterized::class) @Parameterized.UseParametersRunnerFactory(FlickerParametersRunnerFactory::class) @FixMethodOrder(MethodSorters.NAME_ASCENDING) -class CloseAppHomeButtonTestCfArm(flicker: FlickerTest) : CloseAppHomeButtonTest(flicker) { +class CloseAppHomeButtonTestCfArm(flicker: LegacyFlickerTest) : CloseAppHomeButtonTest(flicker) { companion object { /** Creates the test configurations. */ @Parameterized.Parameters(name = "{0}") @JvmStatic - fun getParams(): Collection<FlickerTest> { - return FlickerTestFactory.nonRotationTests() - } + fun getParams() = LegacyFlickerTestFactory.nonRotationTests() } } diff --git a/tests/FlickerTests/src/com/android/server/wm/flicker/close/CloseAppTransition.kt b/tests/FlickerTests/src/com/android/server/wm/flicker/close/CloseAppTransition.kt index 4570fa23dc43..8737edb445f1 100644 --- a/tests/FlickerTests/src/com/android/server/wm/flicker/close/CloseAppTransition.kt +++ b/tests/FlickerTests/src/com/android/server/wm/flicker/close/CloseAppTransition.kt @@ -16,11 +16,14 @@ package com.android.server.wm.flicker.close +import android.platform.test.annotations.FlakyTest import android.platform.test.annotations.Presubmit +import android.tools.common.flicker.subject.layers.LayersTraceSubject.Companion.VISIBLE_FOR_MORE_THAN_ONE_ENTRY_IGNORE_LAYERS +import android.tools.common.traces.component.ComponentNameMatcher import android.tools.common.traces.component.ComponentNameMatcher.Companion.LAUNCHER import android.tools.device.apphelpers.StandardAppHelper import android.tools.device.flicker.legacy.FlickerBuilder -import android.tools.device.flicker.legacy.FlickerTest +import android.tools.device.flicker.legacy.LegacyFlickerTest import com.android.server.wm.flicker.BaseTest import com.android.server.wm.flicker.helpers.SimpleAppHelper import com.android.server.wm.flicker.helpers.setRotation @@ -28,7 +31,7 @@ import com.android.server.wm.flicker.replacesLayer import org.junit.Test /** Base test class for transitions that close an app back to the launcher screen */ -abstract class CloseAppTransition(flicker: FlickerTest) : BaseTest(flicker) { +abstract class CloseAppTransition(flicker: LegacyFlickerTest) : BaseTest(flicker) { protected open val testApp: StandardAppHelper = SimpleAppHelper(instrumentation) /** {@inheritDoc} */ @@ -71,4 +74,21 @@ abstract class CloseAppTransition(flicker: FlickerTest) : BaseTest(flicker) { ignoreEntriesWithRotationLayer = flicker.scenario.isLandscapeOrSeascapeAtStart ) } + + /** {@inheritDoc} */ + @Presubmit + @Test + override fun visibleLayersShownMoreThanOneConsecutiveEntry() { + flicker.assertLayers { + this.visibleLayersShownMoreThanOneConsecutiveEntry( + VISIBLE_FOR_MORE_THAN_ONE_ENTRY_IGNORE_LAYERS + listOf(ComponentNameMatcher.NAV_BAR) + ) + } + } + + @FlakyTest(bugId = 288369951) + @Test + fun visibleLayersShownMoreThanOneConsecutiveEntryWithNavBar() { + flicker.assertLayers { this.visibleLayersShownMoreThanOneConsecutiveEntry() } + } } diff --git a/tests/FlickerTests/src/com/android/server/wm/flicker/helpers/ActivityEmbeddingAppHelper.kt b/tests/FlickerTests/src/com/android/server/wm/flicker/helpers/ActivityEmbeddingAppHelper.kt index daecfe7e4c4d..883c7e6d5785 100644 --- a/tests/FlickerTests/src/com/android/server/wm/flicker/helpers/ActivityEmbeddingAppHelper.kt +++ b/tests/FlickerTests/src/com/android/server/wm/flicker/helpers/ActivityEmbeddingAppHelper.kt @@ -45,20 +45,151 @@ constructor( * based on the split pair rule. */ fun launchSecondaryActivity(wmHelper: WindowManagerStateHelper) { + launchSecondaryActivityFromButton(wmHelper, "launch_secondary_activity_button") + } + + /** + * Clicks the button to launch the secondary activity in RTL, which should split with the main + * activity based on the split pair rule. + */ + fun launchSecondaryActivityRTL(wmHelper: WindowManagerStateHelper) { + launchSecondaryActivityFromButton(wmHelper, "launch_secondary_activity_rtl_button") + } + + /** + * Clicks the button to launch the secondary activity in a horizontal split. + */ + fun launchSecondaryActivityHorizontally(wmHelper: WindowManagerStateHelper) { + launchSecondaryActivityFromButton(wmHelper, "launch_secondary_activity_horizontally_button") + } + + /** Clicks the button to launch a third activity over a secondary activity. */ + fun launchThirdActivity(wmHelper: WindowManagerStateHelper) { val launchButton = uiDevice.wait( - Until.findObject(By.res(getPackage(), "launch_secondary_activity_button")), + Until.findObject(By.res(getPackage(), "launch_third_activity_button")), FIND_TIMEOUT ) - require(launchButton != null) { "Can't find launch secondary activity button on screen." } + require(launchButton != null) { "Can't find launch third activity button on screen." } launchButton.click() wmHelper .StateSyncBuilder() - .withActivityState(SECONDARY_ACTIVITY_COMPONENT, PlatformConsts.STATE_RESUMED) .withActivityState(MAIN_ACTIVITY_COMPONENT, PlatformConsts.STATE_RESUMED) + .withActivityState(SECONDARY_ACTIVITY_COMPONENT, PlatformConsts.STATE_STOPPED) + .withActivityState(THIRD_ACTIVITY_COMPONENT, PlatformConsts.STATE_RESUMED) + .waitForAndVerify() + } + + /** + * Clicks the button to launch the trampoline activity, which should launch the secondary + * activity and finish itself. + */ + fun launchTrampolineActivity(wmHelper: WindowManagerStateHelper) { + val launchButton = + uiDevice.wait( + Until.findObject(By.res(getPackage(), "launch_trampoline_button")), + FIND_TIMEOUT + ) + require(launchButton != null) { "Can't find launch trampoline activity button on screen." } + launchButton.click() + wmHelper + .StateSyncBuilder() + .withActivityState(SECONDARY_ACTIVITY_COMPONENT, PlatformConsts.STATE_RESUMED) + .withActivityRemoved(TRAMPOLINE_ACTIVITY_COMPONENT) + .waitForAndVerify() + } + + /** + * Clicks the button to finishes the secondary activity launched through + * [launchSecondaryActivity], waits for the main activity to resume. + */ + fun finishSecondaryActivity(wmHelper: WindowManagerStateHelper) { + val finishButton = + uiDevice.wait( + Until.findObject(By.res(getPackage(), "finish_secondary_activity_button")), + FIND_TIMEOUT + ) + require(finishButton != null) { "Can't find finish secondary activity button on screen." } + finishButton.click() + wmHelper + .StateSyncBuilder() + .withActivityRemoved(SECONDARY_ACTIVITY_COMPONENT) + .waitForAndVerify() + } + + /** + * Clicks the button to toggle the split ratio of secondary activity. + */ + fun changeSecondaryActivityRatio(wmHelper: WindowManagerStateHelper) { + val launchButton = + uiDevice.wait( + Until.findObject( + By.res(getPackage(), + "toggle_split_ratio_button")), + FIND_TIMEOUT + ) + require(launchButton != null) { + "Can't find toggle ratio for secondary activity button on screen." + } + launchButton.click() + wmHelper + .StateSyncBuilder() + .withAppTransitionIdle() + .withTransitionSnapshotGone() + .waitForAndVerify() + } + + fun secondaryActivityEnterPip(wmHelper: WindowManagerStateHelper) { + val pipButton = + uiDevice.wait( + Until.findObject(By.res(getPackage(), "secondary_enter_pip_button")), + FIND_TIMEOUT + ) + require(pipButton != null) { "Can't find enter pip button on screen." } + pipButton.click() + wmHelper + .StateSyncBuilder() + .withAppTransitionIdle() + .withPipShown() + .waitForAndVerify() + } + + /** + * Clicks the button to launch a secondary activity with alwaysExpand enabled, which will launch + * a fullscreen window on top of the visible region. + */ + fun launchAlwaysExpandActivity(wmHelper: WindowManagerStateHelper) { + val launchButton = + uiDevice.wait( + Until.findObject(By.res(getPackage(), "launch_always_expand_activity_button")), + FIND_TIMEOUT + ) + require(launchButton != null) { + "Can't find launch always expand activity button on screen." + } + launchButton.click() + wmHelper + .StateSyncBuilder() + .withActivityState(ALWAYS_EXPAND_ACTIVITY_COMPONENT, PlatformConsts.STATE_RESUMED) + .withActivityState(MAIN_ACTIVITY_COMPONENT, PlatformConsts.STATE_PAUSED) .waitForAndVerify() } + private fun launchSecondaryActivityFromButton( + wmHelper: WindowManagerStateHelper, buttonName: String) { + val launchButton = + uiDevice.wait(Until.findObject(By.res(getPackage(), buttonName)), FIND_TIMEOUT) + require(launchButton != null) { + "Can't find launch secondary activity button : " + buttonName + "on screen." + } + launchButton.click() + wmHelper + .StateSyncBuilder() + .withActivityState(SECONDARY_ACTIVITY_COMPONENT, PlatformConsts.STATE_RESUMED) + .withActivityState(MAIN_ACTIVITY_COMPONENT, PlatformConsts.STATE_RESUMED) + .waitForAndVerify() + } + /** * Clicks the button to launch the placeholder primary activity, which should launch the * placeholder secondary activity based on the placeholder rule. @@ -78,6 +209,25 @@ constructor( .waitForAndVerify() } + /** + * Clicks the button to launch the placeholder primary activity in RTL, which should launch the + * placeholder secondary activity based on the placeholder rule. + */ + fun launchPlaceholderSplitRTL(wmHelper: WindowManagerStateHelper) { + val launchButton = + uiDevice.wait( + Until.findObject(By.res(getPackage(), "launch_placeholder_split_rtl_button")), + FIND_TIMEOUT + ) + require(launchButton != null) { "Can't find launch placeholder split button on screen." } + launchButton.click() + wmHelper + .StateSyncBuilder() + .withActivityState(PLACEHOLDER_PRIMARY_COMPONENT, PlatformConsts.STATE_RESUMED) + .withActivityState(PLACEHOLDER_SECONDARY_COMPONENT, PlatformConsts.STATE_RESUMED) + .waitForAndVerify() + } + companion object { private const val TAG = "ActivityEmbeddingAppHelper" @@ -87,6 +237,12 @@ constructor( val SECONDARY_ACTIVITY_COMPONENT = ActivityOptions.ActivityEmbedding.SecondaryActivity.COMPONENT.toFlickerComponent() + val THIRD_ACTIVITY_COMPONENT = + ActivityOptions.ActivityEmbedding.ThirdActivity.COMPONENT.toFlickerComponent() + + val ALWAYS_EXPAND_ACTIVITY_COMPONENT = + ActivityOptions.ActivityEmbedding.AlwaysExpandActivity.COMPONENT.toFlickerComponent() + val PLACEHOLDER_PRIMARY_COMPONENT = ActivityOptions.ActivityEmbedding.PlaceholderPrimaryActivity.COMPONENT .toFlickerComponent() @@ -95,6 +251,9 @@ constructor( ActivityOptions.ActivityEmbedding.PlaceholderSecondaryActivity.COMPONENT .toFlickerComponent() + val TRAMPOLINE_ACTIVITY_COMPONENT = + ActivityOptions.ActivityEmbedding.TrampolineActivity.COMPONENT.toFlickerComponent() + @JvmStatic fun getWindowExtensions(): WindowExtensions? { try { diff --git a/tests/FlickerTests/src/com/android/server/wm/flicker/helpers/FlickerExtensions.kt b/tests/FlickerTests/src/com/android/server/wm/flicker/helpers/FlickerExtensions.kt index 9227e07f5b11..5c8cbe49d7cf 100644 --- a/tests/FlickerTests/src/com/android/server/wm/flicker/helpers/FlickerExtensions.kt +++ b/tests/FlickerTests/src/com/android/server/wm/flicker/helpers/FlickerExtensions.kt @@ -19,7 +19,7 @@ package com.android.server.wm.flicker.helpers import android.tools.common.Rotation -import android.tools.device.flicker.legacy.IFlickerTestData +import android.tools.device.flicker.legacy.FlickerTestData import android.tools.device.flicker.rules.ChangeDisplayOrientationRule /** @@ -27,7 +27,7 @@ import android.tools.device.flicker.rules.ChangeDisplayOrientationRule * * @param rotation New device rotation */ -fun IFlickerTestData.setRotation(rotation: Rotation) = +fun FlickerTestData.setRotation(rotation: Rotation) = ChangeDisplayOrientationRule.setRotation( rotation, instrumentation, diff --git a/tests/FlickerTests/src/com/android/server/wm/flicker/helpers/GestureHelper.java b/tests/FlickerTests/src/com/android/server/wm/flicker/helpers/GestureHelper.java index a8f1b3de564e..eeee7b4dfc6b 100644 --- a/tests/FlickerTests/src/com/android/server/wm/flicker/helpers/GestureHelper.java +++ b/tests/FlickerTests/src/com/android/server/wm/flicker/helpers/GestureHelper.java @@ -62,6 +62,33 @@ public class GestureHelper { } /** + * Injects a series of {@link MotionEvent}s to simulate tapping. + * + * @param point coordinates of pointer to tap + * @param times the number of times to tap + */ + public boolean tap(@NonNull Tuple point, int times) throws InterruptedException { + PointerProperties ptrProp = getPointerProp(0, MotionEvent.TOOL_TYPE_FINGER); + PointerCoords ptrCoord = getPointerCoord(point.x, point.y, 1, 1); + + for (int i = 0; i <= times; i++) { + // If already tapped, inject delay in between movements + if (times > 0) { + SystemClock.sleep(50L); + } + if (!primaryPointerDown(ptrProp, ptrCoord, SystemClock.uptimeMillis())) { + return false; + } + // Delay before releasing tap + SystemClock.sleep(100L); + if (!primaryPointerUp(ptrProp, ptrCoord, SystemClock.uptimeMillis())) { + return false; + } + } + return true; + } + + /** * Injects a series of {@link MotionEvent}s to simulate a drag gesture without pointer release. * * Simulates a drag gesture without releasing the primary pointer. The primary pointer info diff --git a/tests/FlickerTests/src/com/android/server/wm/flicker/helpers/LetterboxAppHelper.kt b/tests/FlickerTests/src/com/android/server/wm/flicker/helpers/LetterboxAppHelper.kt index a670d68cabd9..d83b6d39fcd8 100644 --- a/tests/FlickerTests/src/com/android/server/wm/flicker/helpers/LetterboxAppHelper.kt +++ b/tests/FlickerTests/src/com/android/server/wm/flicker/helpers/LetterboxAppHelper.kt @@ -17,6 +17,8 @@ package com.android.server.wm.flicker.helpers import android.app.Instrumentation +import android.tools.common.datatypes.Rect +import android.tools.common.datatypes.Region import android.tools.common.traces.component.ComponentNameMatcher import android.tools.device.apphelpers.StandardAppHelper import android.tools.device.helpers.FIND_TIMEOUT @@ -36,6 +38,8 @@ constructor( ActivityOptions.NonResizeablePortraitActivity.COMPONENT.toFlickerComponent() ) : StandardAppHelper(instr, launcherName, component) { + private val gestureHelper: GestureHelper = GestureHelper(mInstrumentation) + fun clickRestart(wmHelper: WindowManagerStateHelper) { val restartButton = uiDevice.wait( @@ -56,4 +60,74 @@ constructor( ?: error("Restart dialog button not found") wmHelper.StateSyncBuilder().withAppTransitionIdle().waitForAndVerify() } + + fun repositionHorizontally(displayBounds: Rect, right: Boolean) { + val x = if (right) displayBounds.right - BOUNDS_OFFSET else BOUNDS_OFFSET + reposition(x.toFloat(), displayBounds.centerY().toFloat()) + } + + fun repositionVertically(displayBounds: Rect, bottom: Boolean) { + val y = if (bottom) displayBounds.bottom - BOUNDS_OFFSET else BOUNDS_OFFSET + reposition(displayBounds.centerX().toFloat(), y.toFloat()) + } + + private fun reposition(x: Float, y: Float) { + val coords = GestureHelper.Tuple(x, y) + require(gestureHelper.tap(coords, 2)) { "Failed to reposition letterbox app" } + } + + fun waitForAppToMoveHorizontallyTo( + wmHelper: WindowManagerStateHelper, + displayBounds: Rect, + right: Boolean + ) { + wmHelper + .StateSyncBuilder() + .add("letterboxAppRepositioned") { + val letterboxAppWindow = getWindowRegion(wmHelper) + val appRegionBounds = letterboxAppWindow.bounds + val appWidth = appRegionBounds.width + return@add if (right) + appRegionBounds.left == displayBounds.right - appWidth && + appRegionBounds.right == displayBounds.right + else + appRegionBounds.left == displayBounds.left && + appRegionBounds.right == displayBounds.left + appWidth + } + .waitForAndVerify() + } + + fun waitForAppToMoveVerticallyTo( + wmHelper: WindowManagerStateHelper, + displayBounds: Rect, + navBarHeight: Int, + bottom: Boolean + ) { + wmHelper + .StateSyncBuilder() + .add("letterboxAppRepositioned") { + val letterboxAppWindow = getWindowRegion(wmHelper) + val appRegionBounds = letterboxAppWindow.bounds + val appHeight = appRegionBounds.height + return@add if (bottom) + appRegionBounds.bottom == displayBounds.bottom && + appRegionBounds.top == (displayBounds.bottom - appHeight + navBarHeight) + else + appRegionBounds.top == displayBounds.top && + appRegionBounds.bottom == displayBounds.top + appHeight + } + .waitForAndVerify() + } + + private fun getWindowRegion(wmHelper: WindowManagerStateHelper): Region { + val windowRegion = wmHelper.getWindowRegion(this) + require(!windowRegion.isEmpty) { + "Unable to find letterbox app window in the current state" + } + return windowRegion + } + + companion object { + private const val BOUNDS_OFFSET: Int = 100 + } } diff --git a/tests/FlickerTests/src/com/android/server/wm/flicker/helpers/PipAppHelper.kt b/tests/FlickerTests/src/com/android/server/wm/flicker/helpers/PipAppHelper.kt index 24e231c73a0f..c6b86f2689f0 100644 --- a/tests/FlickerTests/src/com/android/server/wm/flicker/helpers/PipAppHelper.kt +++ b/tests/FlickerTests/src/com/android/server/wm/flicker/helpers/PipAppHelper.kt @@ -250,10 +250,13 @@ open class PipAppHelper(instrumentation: Instrumentation) : waitConditions = arrayOf(ConditionsFactory.hasPipWindow()) ) + val windowRegion = wmHelper.getWindowRegion(this) + wmHelper .StateSyncBuilder() .withWindowSurfaceAppeared(this) .withPipShown() + .withSurfaceVisibleRegion(this, windowRegion) .waitForAndVerify() } @@ -383,8 +386,11 @@ open class PipAppHelper(instrumentation: Instrumentation) : it.wmState.visibleWindows.firstOrNull { window -> this.windowMatchesAnyOf(window) } - ?: return@add false + Log.d(TAG, "window " + pipAppWindow) + if (pipAppWindow == null) return@add false val pipRegion = pipAppWindow.frameRegion + Log.d(TAG, "region " + pipRegion + + " covers " + windowRect.coversMoreThan(pipRegion)) return@add windowRect.coversMoreThan(pipRegion) } .waitForAndVerify() diff --git a/tests/FlickerTests/src/com/android/server/wm/flicker/ime/CloseImeOnDismissPopupDialogTest.kt b/tests/FlickerTests/src/com/android/server/wm/flicker/ime/CloseImeOnDismissPopupDialogTest.kt index 7e0632d216ea..98446c1a76b2 100644 --- a/tests/FlickerTests/src/com/android/server/wm/flicker/ime/CloseImeOnDismissPopupDialogTest.kt +++ b/tests/FlickerTests/src/com/android/server/wm/flicker/ime/CloseImeOnDismissPopupDialogTest.kt @@ -22,8 +22,8 @@ import android.tools.common.flicker.subject.region.RegionSubject import android.tools.common.traces.component.ComponentNameMatcher import android.tools.device.flicker.junit.FlickerParametersRunnerFactory import android.tools.device.flicker.legacy.FlickerBuilder -import android.tools.device.flicker.legacy.FlickerTest -import android.tools.device.flicker.legacy.FlickerTestFactory +import android.tools.device.flicker.legacy.LegacyFlickerTest +import android.tools.device.flicker.legacy.LegacyFlickerTestFactory import androidx.test.filters.RequiresDevice import com.android.server.wm.flicker.BaseTest import com.android.server.wm.flicker.helpers.ImeEditorPopupDialogAppHelper @@ -37,7 +37,7 @@ import org.junit.runners.Parameterized @RunWith(Parameterized::class) @Parameterized.UseParametersRunnerFactory(FlickerParametersRunnerFactory::class) @FixMethodOrder(MethodSorters.NAME_ASCENDING) -open class CloseImeOnDismissPopupDialogTest(flicker: FlickerTest) : BaseTest(flicker) { +open class CloseImeOnDismissPopupDialogTest(flicker: LegacyFlickerTest) : BaseTest(flicker) { private val imeTestApp = ImeEditorPopupDialogAppHelper(instrumentation) /** {@inheritDoc} */ @@ -101,10 +101,9 @@ open class CloseImeOnDismissPopupDialogTest(flicker: FlickerTest) : BaseTest(fli companion object { @Parameterized.Parameters(name = "{0}") @JvmStatic - fun getParams(): Collection<FlickerTest> { - return FlickerTestFactory.nonRotationTests( + fun getParams() = + LegacyFlickerTestFactory.nonRotationTests( supportedRotations = listOf(Rotation.ROTATION_0) ) - } } } diff --git a/tests/FlickerTests/src/com/android/server/wm/flicker/ime/CloseImeOnDismissPopupDialogTestCfArm.kt b/tests/FlickerTests/src/com/android/server/wm/flicker/ime/CloseImeOnDismissPopupDialogTestCfArm.kt index c355e2708657..d87a1daebd79 100644 --- a/tests/FlickerTests/src/com/android/server/wm/flicker/ime/CloseImeOnDismissPopupDialogTestCfArm.kt +++ b/tests/FlickerTests/src/com/android/server/wm/flicker/ime/CloseImeOnDismissPopupDialogTestCfArm.kt @@ -18,8 +18,8 @@ package com.android.server.wm.flicker.ime import android.tools.common.Rotation import android.tools.device.flicker.junit.FlickerParametersRunnerFactory -import android.tools.device.flicker.legacy.FlickerTest -import android.tools.device.flicker.legacy.FlickerTestFactory +import android.tools.device.flicker.legacy.LegacyFlickerTest +import android.tools.device.flicker.legacy.LegacyFlickerTestFactory import org.junit.FixMethodOrder import org.junit.runner.RunWith import org.junit.runners.MethodSorters @@ -28,15 +28,14 @@ import org.junit.runners.Parameterized @RunWith(Parameterized::class) @Parameterized.UseParametersRunnerFactory(FlickerParametersRunnerFactory::class) @FixMethodOrder(MethodSorters.NAME_ASCENDING) -class CloseImeOnDismissPopupDialogTestCfArm(flicker: FlickerTest) : +class CloseImeOnDismissPopupDialogTestCfArm(flicker: LegacyFlickerTest) : CloseImeOnDismissPopupDialogTest(flicker) { companion object { @Parameterized.Parameters(name = "{0}") @JvmStatic - fun getParams(): Collection<FlickerTest> { - return FlickerTestFactory.nonRotationTests( + fun getParams() = + LegacyFlickerTestFactory.nonRotationTests( supportedRotations = listOf(Rotation.ROTATION_0) ) - } } } diff --git a/tests/FlickerTests/src/com/android/server/wm/flicker/ime/CloseImeOnGoHomeTest.kt b/tests/FlickerTests/src/com/android/server/wm/flicker/ime/CloseImeOnGoHomeTest.kt index 537238b1d626..b995d3df8055 100644 --- a/tests/FlickerTests/src/com/android/server/wm/flicker/ime/CloseImeOnGoHomeTest.kt +++ b/tests/FlickerTests/src/com/android/server/wm/flicker/ime/CloseImeOnGoHomeTest.kt @@ -22,8 +22,8 @@ import android.tools.common.Rotation import android.tools.common.traces.component.ComponentNameMatcher import android.tools.device.flicker.junit.FlickerParametersRunnerFactory import android.tools.device.flicker.legacy.FlickerBuilder -import android.tools.device.flicker.legacy.FlickerTest -import android.tools.device.flicker.legacy.FlickerTestFactory +import android.tools.device.flicker.legacy.LegacyFlickerTest +import android.tools.device.flicker.legacy.LegacyFlickerTestFactory import androidx.test.filters.RequiresDevice import com.android.server.wm.flicker.BaseTest import com.android.server.wm.flicker.helpers.ImeAppHelper @@ -41,7 +41,7 @@ import org.junit.runners.Parameterized @RunWith(Parameterized::class) @Parameterized.UseParametersRunnerFactory(FlickerParametersRunnerFactory::class) @FixMethodOrder(MethodSorters.NAME_ASCENDING) -open class CloseImeOnGoHomeTest(flicker: FlickerTest) : BaseTest(flicker) { +open class CloseImeOnGoHomeTest(flicker: LegacyFlickerTest) : BaseTest(flicker) { private val testApp = ImeAppHelper(instrumentation) /** {@inheritDoc} */ @@ -115,10 +115,9 @@ open class CloseImeOnGoHomeTest(flicker: FlickerTest) : BaseTest(flicker) { companion object { @Parameterized.Parameters(name = "{0}") @JvmStatic - fun getParams(): Collection<FlickerTest> { - return FlickerTestFactory.nonRotationTests( + fun getParams() = + LegacyFlickerTestFactory.nonRotationTests( supportedRotations = listOf(Rotation.ROTATION_0) ) - } } } diff --git a/tests/FlickerTests/src/com/android/server/wm/flicker/ime/CloseImeOnGoHomeTestCfArm.kt b/tests/FlickerTests/src/com/android/server/wm/flicker/ime/CloseImeOnGoHomeTestCfArm.kt index 0fe52df5bb25..3b5bfa986119 100644 --- a/tests/FlickerTests/src/com/android/server/wm/flicker/ime/CloseImeOnGoHomeTestCfArm.kt +++ b/tests/FlickerTests/src/com/android/server/wm/flicker/ime/CloseImeOnGoHomeTestCfArm.kt @@ -17,7 +17,7 @@ package com.android.server.wm.flicker.ime import android.tools.device.flicker.junit.FlickerParametersRunnerFactory -import android.tools.device.flicker.legacy.FlickerTest +import android.tools.device.flicker.legacy.LegacyFlickerTest import org.junit.FixMethodOrder import org.junit.runner.RunWith import org.junit.runners.MethodSorters @@ -26,4 +26,4 @@ import org.junit.runners.Parameterized @RunWith(Parameterized::class) @Parameterized.UseParametersRunnerFactory(FlickerParametersRunnerFactory::class) @FixMethodOrder(MethodSorters.NAME_ASCENDING) -class CloseImeOnGoHomeTestCfArm(flicker: FlickerTest) : CloseImeOnGoHomeTest(flicker) +class CloseImeOnGoHomeTestCfArm(flicker: LegacyFlickerTest) : CloseImeOnGoHomeTest(flicker) diff --git a/tests/FlickerTests/src/com/android/server/wm/flicker/ime/CloseImeShownOnAppStartOnGoHomeTest.kt b/tests/FlickerTests/src/com/android/server/wm/flicker/ime/CloseImeShownOnAppStartOnGoHomeTest.kt index cbe03dcd932a..765bb4cf3067 100644 --- a/tests/FlickerTests/src/com/android/server/wm/flicker/ime/CloseImeShownOnAppStartOnGoHomeTest.kt +++ b/tests/FlickerTests/src/com/android/server/wm/flicker/ime/CloseImeShownOnAppStartOnGoHomeTest.kt @@ -21,8 +21,8 @@ import android.tools.common.Rotation import android.tools.common.traces.component.ComponentNameMatcher import android.tools.device.flicker.junit.FlickerParametersRunnerFactory import android.tools.device.flicker.legacy.FlickerBuilder -import android.tools.device.flicker.legacy.FlickerTest -import android.tools.device.flicker.legacy.FlickerTestFactory +import android.tools.device.flicker.legacy.LegacyFlickerTest +import android.tools.device.flicker.legacy.LegacyFlickerTestFactory import androidx.test.filters.RequiresDevice import com.android.server.wm.flicker.BaseTest import com.android.server.wm.flicker.helpers.ImeShownOnAppStartHelper @@ -49,7 +49,7 @@ import org.junit.runners.Parameterized @RunWith(Parameterized::class) @Parameterized.UseParametersRunnerFactory(FlickerParametersRunnerFactory::class) @FixMethodOrder(MethodSorters.NAME_ASCENDING) -open class CloseImeShownOnAppStartOnGoHomeTest(flicker: FlickerTest) : BaseTest(flicker) { +open class CloseImeShownOnAppStartOnGoHomeTest(flicker: LegacyFlickerTest) : BaseTest(flicker) { private val testApp = ImeShownOnAppStartHelper(instrumentation, flicker.scenario.startRotation) /** {@inheritDoc} */ @@ -94,11 +94,10 @@ open class CloseImeShownOnAppStartOnGoHomeTest(flicker: FlickerTest) : BaseTest( companion object { @Parameterized.Parameters(name = "{0}") @JvmStatic - fun getParams(): Collection<FlickerTest> { - return FlickerTestFactory.nonRotationTests( + fun getParams() = + LegacyFlickerTestFactory.nonRotationTests( // b/190352379 (IME doesn't show on app launch in 90 degrees) supportedRotations = listOf(Rotation.ROTATION_0) ) - } } } diff --git a/tests/FlickerTests/src/com/android/server/wm/flicker/ime/CloseImeShownOnAppStartOnGoHomeTestCfArm.kt b/tests/FlickerTests/src/com/android/server/wm/flicker/ime/CloseImeShownOnAppStartOnGoHomeTestCfArm.kt index 5aacb3011e79..58411cc63004 100644 --- a/tests/FlickerTests/src/com/android/server/wm/flicker/ime/CloseImeShownOnAppStartOnGoHomeTestCfArm.kt +++ b/tests/FlickerTests/src/com/android/server/wm/flicker/ime/CloseImeShownOnAppStartOnGoHomeTestCfArm.kt @@ -17,7 +17,7 @@ package com.android.server.wm.flicker.ime import android.tools.device.flicker.junit.FlickerParametersRunnerFactory -import android.tools.device.flicker.legacy.FlickerTest +import android.tools.device.flicker.legacy.LegacyFlickerTest import org.junit.FixMethodOrder import org.junit.runner.RunWith import org.junit.runners.MethodSorters @@ -26,5 +26,5 @@ import org.junit.runners.Parameterized @RunWith(Parameterized::class) @Parameterized.UseParametersRunnerFactory(FlickerParametersRunnerFactory::class) @FixMethodOrder(MethodSorters.NAME_ASCENDING) -open class CloseImeShownOnAppStartOnGoHomeTestCfArm(flicker: FlickerTest) : +open class CloseImeShownOnAppStartOnGoHomeTestCfArm(flicker: LegacyFlickerTest) : CloseImeShownOnAppStartOnGoHomeTest(flicker) diff --git a/tests/FlickerTests/src/com/android/server/wm/flicker/ime/CloseImeShownOnAppStartToAppOnPressBackTest.kt b/tests/FlickerTests/src/com/android/server/wm/flicker/ime/CloseImeShownOnAppStartToAppOnPressBackTest.kt index 82c390b77d59..c87217b30783 100644 --- a/tests/FlickerTests/src/com/android/server/wm/flicker/ime/CloseImeShownOnAppStartToAppOnPressBackTest.kt +++ b/tests/FlickerTests/src/com/android/server/wm/flicker/ime/CloseImeShownOnAppStartToAppOnPressBackTest.kt @@ -21,8 +21,8 @@ import android.tools.common.Rotation import android.tools.common.traces.component.ComponentNameMatcher import android.tools.device.flicker.junit.FlickerParametersRunnerFactory import android.tools.device.flicker.legacy.FlickerBuilder -import android.tools.device.flicker.legacy.FlickerTest -import android.tools.device.flicker.legacy.FlickerTestFactory +import android.tools.device.flicker.legacy.LegacyFlickerTest +import android.tools.device.flicker.legacy.LegacyFlickerTestFactory import androidx.test.filters.RequiresDevice import com.android.server.wm.flicker.BaseTest import com.android.server.wm.flicker.helpers.ImeShownOnAppStartHelper @@ -49,7 +49,8 @@ import org.junit.runners.Parameterized @RunWith(Parameterized::class) @Parameterized.UseParametersRunnerFactory(FlickerParametersRunnerFactory::class) @FixMethodOrder(MethodSorters.NAME_ASCENDING) -open class CloseImeShownOnAppStartToAppOnPressBackTest(flicker: FlickerTest) : BaseTest(flicker) { +open class CloseImeShownOnAppStartToAppOnPressBackTest(flicker: LegacyFlickerTest) : + BaseTest(flicker) { private val testApp = ImeShownOnAppStartHelper(instrumentation, flicker.scenario.startRotation) /** {@inheritDoc} */ @@ -88,11 +89,10 @@ open class CloseImeShownOnAppStartToAppOnPressBackTest(flicker: FlickerTest) : B companion object { @Parameterized.Parameters(name = "{0}") @JvmStatic - fun getParams(): Collection<FlickerTest> { - return FlickerTestFactory.nonRotationTests( + fun getParams() = + LegacyFlickerTestFactory.nonRotationTests( // b/190352379 (IME doesn't show on app launch in 90 degrees) supportedRotations = listOf(Rotation.ROTATION_0) ) - } } } diff --git a/tests/FlickerTests/src/com/android/server/wm/flicker/ime/CloseImeShownOnAppStartToAppOnPressBackTestCfArm.kt b/tests/FlickerTests/src/com/android/server/wm/flicker/ime/CloseImeShownOnAppStartToAppOnPressBackTestCfArm.kt index eb81aed35011..41b06c0b4bd3 100644 --- a/tests/FlickerTests/src/com/android/server/wm/flicker/ime/CloseImeShownOnAppStartToAppOnPressBackTestCfArm.kt +++ b/tests/FlickerTests/src/com/android/server/wm/flicker/ime/CloseImeShownOnAppStartToAppOnPressBackTestCfArm.kt @@ -17,7 +17,7 @@ package com.android.server.wm.flicker.ime import android.tools.device.flicker.junit.FlickerParametersRunnerFactory -import android.tools.device.flicker.legacy.FlickerTest +import android.tools.device.flicker.legacy.LegacyFlickerTest import org.junit.FixMethodOrder import org.junit.runner.RunWith import org.junit.runners.MethodSorters @@ -26,5 +26,5 @@ import org.junit.runners.Parameterized @RunWith(Parameterized::class) @Parameterized.UseParametersRunnerFactory(FlickerParametersRunnerFactory::class) @FixMethodOrder(MethodSorters.NAME_ASCENDING) -class CloseImeShownOnAppStartToAppOnPressBackTestCfArm(flicker: FlickerTest) : +class CloseImeShownOnAppStartToAppOnPressBackTestCfArm(flicker: LegacyFlickerTest) : CloseImeShownOnAppStartToAppOnPressBackTest(flicker) diff --git a/tests/FlickerTests/src/com/android/server/wm/flicker/ime/CloseImeToAppOnPressBackTest.kt b/tests/FlickerTests/src/com/android/server/wm/flicker/ime/CloseImeToAppOnPressBackTest.kt index 8d8075927076..c74870bef102 100644 --- a/tests/FlickerTests/src/com/android/server/wm/flicker/ime/CloseImeToAppOnPressBackTest.kt +++ b/tests/FlickerTests/src/com/android/server/wm/flicker/ime/CloseImeToAppOnPressBackTest.kt @@ -21,8 +21,8 @@ import android.platform.test.annotations.Presubmit import android.tools.common.traces.component.ComponentNameMatcher import android.tools.device.flicker.junit.FlickerParametersRunnerFactory import android.tools.device.flicker.legacy.FlickerBuilder -import android.tools.device.flicker.legacy.FlickerTest -import android.tools.device.flicker.legacy.FlickerTestFactory +import android.tools.device.flicker.legacy.LegacyFlickerTest +import android.tools.device.flicker.legacy.LegacyFlickerTestFactory import androidx.test.filters.RequiresDevice import com.android.server.wm.flicker.BaseTest import com.android.server.wm.flicker.helpers.ImeAppHelper @@ -42,7 +42,7 @@ import org.junit.runners.Parameterized @RunWith(Parameterized::class) @Parameterized.UseParametersRunnerFactory(FlickerParametersRunnerFactory::class) @FixMethodOrder(MethodSorters.NAME_ASCENDING) -open class CloseImeToAppOnPressBackTest(flicker: FlickerTest) : BaseTest(flicker) { +open class CloseImeToAppOnPressBackTest(flicker: LegacyFlickerTest) : BaseTest(flicker) { private val testApp = ImeAppHelper(instrumentation) /** {@inheritDoc} */ @@ -115,8 +115,6 @@ open class CloseImeToAppOnPressBackTest(flicker: FlickerTest) : BaseTest(flicker companion object { @Parameterized.Parameters(name = "{0}") @JvmStatic - fun getParams(): Collection<FlickerTest> { - return FlickerTestFactory.nonRotationTests() - } + fun getParams() = LegacyFlickerTestFactory.nonRotationTests() } } diff --git a/tests/FlickerTests/src/com/android/server/wm/flicker/ime/CloseImeToAppOnPressBackTestCfArm.kt b/tests/FlickerTests/src/com/android/server/wm/flicker/ime/CloseImeToAppOnPressBackTestCfArm.kt index db1440b0c5b8..104af225ee2e 100644 --- a/tests/FlickerTests/src/com/android/server/wm/flicker/ime/CloseImeToAppOnPressBackTestCfArm.kt +++ b/tests/FlickerTests/src/com/android/server/wm/flicker/ime/CloseImeToAppOnPressBackTestCfArm.kt @@ -17,7 +17,7 @@ package com.android.server.wm.flicker.ime import android.tools.device.flicker.junit.FlickerParametersRunnerFactory -import android.tools.device.flicker.legacy.FlickerTest +import android.tools.device.flicker.legacy.LegacyFlickerTest import org.junit.FixMethodOrder import org.junit.runner.RunWith import org.junit.runners.MethodSorters @@ -26,5 +26,5 @@ import org.junit.runners.Parameterized @RunWith(Parameterized::class) @Parameterized.UseParametersRunnerFactory(FlickerParametersRunnerFactory::class) @FixMethodOrder(MethodSorters.NAME_ASCENDING) -class CloseImeToAppOnPressBackTestCfArm(flicker: FlickerTest) : +class CloseImeToAppOnPressBackTestCfArm(flicker: LegacyFlickerTest) : CloseImeToAppOnPressBackTest(flicker) diff --git a/tests/FlickerTests/src/com/android/server/wm/flicker/ime/CloseImeToHomeOnFinishActivityTest.kt b/tests/FlickerTests/src/com/android/server/wm/flicker/ime/CloseImeToHomeOnFinishActivityTest.kt index 15262959332e..21fd590025bc 100644 --- a/tests/FlickerTests/src/com/android/server/wm/flicker/ime/CloseImeToHomeOnFinishActivityTest.kt +++ b/tests/FlickerTests/src/com/android/server/wm/flicker/ime/CloseImeToHomeOnFinishActivityTest.kt @@ -22,8 +22,8 @@ import android.platform.test.annotations.Presubmit import android.tools.common.Rotation import android.tools.device.flicker.junit.FlickerParametersRunnerFactory import android.tools.device.flicker.legacy.FlickerBuilder -import android.tools.device.flicker.legacy.FlickerTest -import android.tools.device.flicker.legacy.FlickerTestFactory +import android.tools.device.flicker.legacy.LegacyFlickerTest +import android.tools.device.flicker.legacy.LegacyFlickerTestFactory import androidx.test.filters.RequiresDevice import com.android.server.wm.flicker.BaseTest import com.android.server.wm.flicker.helpers.ImeAppHelper @@ -44,7 +44,7 @@ import org.junit.runners.Parameterized @RunWith(Parameterized::class) @Parameterized.UseParametersRunnerFactory(FlickerParametersRunnerFactory::class) @FixMethodOrder(MethodSorters.NAME_ASCENDING) -open class CloseImeToHomeOnFinishActivityTest(flicker: FlickerTest) : BaseTest(flicker) { +open class CloseImeToHomeOnFinishActivityTest(flicker: LegacyFlickerTest) : BaseTest(flicker) { private val simpleApp = SimpleAppHelper(instrumentation) private val testApp = ImeAppHelper(instrumentation) @@ -90,10 +90,9 @@ open class CloseImeToHomeOnFinishActivityTest(flicker: FlickerTest) : BaseTest(f companion object { @Parameterized.Parameters(name = "{0}") @JvmStatic - fun getParams(): Collection<FlickerTest> { - return FlickerTestFactory.nonRotationTests( + fun getParams() = + LegacyFlickerTestFactory.nonRotationTests( supportedRotations = listOf(Rotation.ROTATION_0) ) - } } } diff --git a/tests/FlickerTests/src/com/android/server/wm/flicker/ime/CloseImeToHomeOnFinishActivityTestCfArm.kt b/tests/FlickerTests/src/com/android/server/wm/flicker/ime/CloseImeToHomeOnFinishActivityTestCfArm.kt index 405ab6bcd9d6..0e1838570bab 100644 --- a/tests/FlickerTests/src/com/android/server/wm/flicker/ime/CloseImeToHomeOnFinishActivityTestCfArm.kt +++ b/tests/FlickerTests/src/com/android/server/wm/flicker/ime/CloseImeToHomeOnFinishActivityTestCfArm.kt @@ -17,7 +17,7 @@ package com.android.server.wm.flicker.ime import android.tools.device.flicker.junit.FlickerParametersRunnerFactory -import android.tools.device.flicker.legacy.FlickerTest +import android.tools.device.flicker.legacy.LegacyFlickerTest import org.junit.FixMethodOrder import org.junit.runner.RunWith import org.junit.runners.MethodSorters @@ -26,5 +26,5 @@ import org.junit.runners.Parameterized @RunWith(Parameterized::class) @Parameterized.UseParametersRunnerFactory(FlickerParametersRunnerFactory::class) @FixMethodOrder(MethodSorters.NAME_ASCENDING) -open class CloseImeToHomeOnFinishActivityTestCfArm(flicker: FlickerTest) : +open class CloseImeToHomeOnFinishActivityTestCfArm(flicker: LegacyFlickerTest) : CloseImeToHomeOnFinishActivityTest(flicker) diff --git a/tests/FlickerTests/src/com/android/server/wm/flicker/ime/CommonAssertions.kt b/tests/FlickerTests/src/com/android/server/wm/flicker/ime/CommonAssertions.kt index 8e3371986056..777231e001f7 100644 --- a/tests/FlickerTests/src/com/android/server/wm/flicker/ime/CommonAssertions.kt +++ b/tests/FlickerTests/src/com/android/server/wm/flicker/ime/CommonAssertions.kt @@ -19,21 +19,21 @@ package com.android.server.wm.flicker.ime import android.tools.common.traces.component.ComponentNameMatcher -import android.tools.device.flicker.legacy.FlickerTest +import android.tools.device.flicker.legacy.LegacyFlickerTest -fun FlickerTest.imeLayerBecomesVisible() { +fun LegacyFlickerTest.imeLayerBecomesVisible() { assertLayers { this.isInvisible(ComponentNameMatcher.IME).then().isVisible(ComponentNameMatcher.IME) } } -fun FlickerTest.imeLayerBecomesInvisible() { +fun LegacyFlickerTest.imeLayerBecomesInvisible() { assertLayers { this.isVisible(ComponentNameMatcher.IME).then().isInvisible(ComponentNameMatcher.IME) } } -fun FlickerTest.imeWindowIsAlwaysVisible(rotatesScreen: Boolean = false) { +fun LegacyFlickerTest.imeWindowIsAlwaysVisible(rotatesScreen: Boolean = false) { if (rotatesScreen) { assertWm { this.isNonAppWindowVisible(ComponentNameMatcher.IME) @@ -47,7 +47,7 @@ fun FlickerTest.imeWindowIsAlwaysVisible(rotatesScreen: Boolean = false) { } } -fun FlickerTest.imeWindowBecomesVisible() { +fun LegacyFlickerTest.imeWindowBecomesVisible() { assertWm { this.isNonAppWindowInvisible(ComponentNameMatcher.IME) .then() @@ -55,7 +55,7 @@ fun FlickerTest.imeWindowBecomesVisible() { } } -fun FlickerTest.imeWindowBecomesInvisible() { +fun LegacyFlickerTest.imeWindowBecomesInvisible() { assertWm { this.isNonAppWindowVisible(ComponentNameMatcher.IME) .then() diff --git a/tests/FlickerTests/src/com/android/server/wm/flicker/ime/OpenImeWindowToFixedPortraitAppTest.kt b/tests/FlickerTests/src/com/android/server/wm/flicker/ime/OpenImeWindowToFixedPortraitAppTest.kt index 19bbf0cb92b0..976ac82c8bb5 100644 --- a/tests/FlickerTests/src/com/android/server/wm/flicker/ime/OpenImeWindowToFixedPortraitAppTest.kt +++ b/tests/FlickerTests/src/com/android/server/wm/flicker/ime/OpenImeWindowToFixedPortraitAppTest.kt @@ -22,8 +22,8 @@ import android.tools.common.flicker.subject.region.RegionSubject import android.tools.common.traces.component.ComponentNameMatcher import android.tools.device.flicker.junit.FlickerParametersRunnerFactory import android.tools.device.flicker.legacy.FlickerBuilder -import android.tools.device.flicker.legacy.FlickerTest -import android.tools.device.flicker.legacy.FlickerTestFactory +import android.tools.device.flicker.legacy.LegacyFlickerTest +import android.tools.device.flicker.legacy.LegacyFlickerTestFactory import android.tools.device.helpers.WindowUtils import androidx.test.filters.RequiresDevice import com.android.server.wm.flicker.BaseTest @@ -42,7 +42,7 @@ import org.junit.runners.Parameterized @RunWith(Parameterized::class) @Parameterized.UseParametersRunnerFactory(FlickerParametersRunnerFactory::class) @FixMethodOrder(MethodSorters.NAME_ASCENDING) -class OpenImeWindowToFixedPortraitAppTest(flicker: FlickerTest) : BaseTest(flicker) { +class OpenImeWindowToFixedPortraitAppTest(flicker: LegacyFlickerTest) : BaseTest(flicker) { private val testApp = ImeShownOnAppStartHelper(instrumentation, flicker.scenario.startRotation) /** {@inheritDoc} */ @@ -99,19 +99,18 @@ class OpenImeWindowToFixedPortraitAppTest(flicker: FlickerTest) : BaseTest(flick /** * Creates the test configurations. * - * See [FlickerTestFactory.nonRotationTests] for configuring screen orientation and + * See [LegacyFlickerTestFactory.nonRotationTests] for configuring screen orientation and * navigation modes. */ @Parameterized.Parameters(name = "{0}") @JvmStatic - fun getParams(): Collection<FlickerTest> { - return FlickerTestFactory.nonRotationTests( + fun getParams() = + LegacyFlickerTestFactory.nonRotationTests( supportedRotations = listOf( Rotation.ROTATION_90, ), supportedNavigationModes = listOf(NavBar.MODE_3BUTTON, NavBar.MODE_GESTURAL) ) - } } } diff --git a/tests/FlickerTests/src/com/android/server/wm/flicker/ime/ShowImeOnAppStartWhenLaunchingAppCfArmTest.kt b/tests/FlickerTests/src/com/android/server/wm/flicker/ime/ShowImeOnAppStartWhenLaunchingAppCfArmTest.kt index 03f21f95e61e..db80001ccd78 100644 --- a/tests/FlickerTests/src/com/android/server/wm/flicker/ime/ShowImeOnAppStartWhenLaunchingAppCfArmTest.kt +++ b/tests/FlickerTests/src/com/android/server/wm/flicker/ime/ShowImeOnAppStartWhenLaunchingAppCfArmTest.kt @@ -17,7 +17,7 @@ package com.android.server.wm.flicker.ime import android.tools.device.flicker.junit.FlickerParametersRunnerFactory -import android.tools.device.flicker.legacy.FlickerTest +import android.tools.device.flicker.legacy.LegacyFlickerTest import org.junit.FixMethodOrder import org.junit.runner.RunWith import org.junit.runners.MethodSorters @@ -26,5 +26,5 @@ import org.junit.runners.Parameterized @RunWith(Parameterized::class) @Parameterized.UseParametersRunnerFactory(FlickerParametersRunnerFactory::class) @FixMethodOrder(MethodSorters.NAME_ASCENDING) -class ShowImeOnAppStartWhenLaunchingAppCfArmTest(flicker: FlickerTest) : +class ShowImeOnAppStartWhenLaunchingAppCfArmTest(flicker: LegacyFlickerTest) : ShowImeOnAppStartWhenLaunchingAppTest(flicker) diff --git a/tests/FlickerTests/src/com/android/server/wm/flicker/ime/ShowImeOnAppStartWhenLaunchingAppFromFixedOrientationTest.kt b/tests/FlickerTests/src/com/android/server/wm/flicker/ime/ShowImeOnAppStartWhenLaunchingAppFromFixedOrientationTest.kt index 496165ab5b09..44bd8c8688e9 100644 --- a/tests/FlickerTests/src/com/android/server/wm/flicker/ime/ShowImeOnAppStartWhenLaunchingAppFromFixedOrientationTest.kt +++ b/tests/FlickerTests/src/com/android/server/wm/flicker/ime/ShowImeOnAppStartWhenLaunchingAppFromFixedOrientationTest.kt @@ -16,17 +16,17 @@ package com.android.server.wm.flicker.ime +import android.platform.test.annotations.Postsubmit import android.platform.test.annotations.Presubmit import android.tools.common.Rotation -import android.platform.test.annotations.Postsubmit import android.tools.common.Timestamp -import android.tools.common.traces.component.ComponentNameMatcher import android.tools.common.flicker.subject.exceptions.ExceptionMessageBuilder import android.tools.common.flicker.subject.exceptions.InvalidPropertyException +import android.tools.common.traces.component.ComponentNameMatcher import android.tools.device.flicker.junit.FlickerParametersRunnerFactory import android.tools.device.flicker.legacy.FlickerBuilder -import android.tools.device.flicker.legacy.FlickerTest -import android.tools.device.flicker.legacy.FlickerTestFactory +import android.tools.device.flicker.legacy.LegacyFlickerTest +import android.tools.device.flicker.legacy.LegacyFlickerTestFactory import androidx.test.filters.RequiresDevice import com.android.server.wm.flicker.BaseTest import com.android.server.wm.flicker.helpers.ImeShownOnAppStartHelper @@ -47,7 +47,7 @@ import org.junit.runners.Parameterized @RunWith(Parameterized::class) @Parameterized.UseParametersRunnerFactory(FlickerParametersRunnerFactory::class) @FixMethodOrder(MethodSorters.NAME_ASCENDING) -open class ShowImeOnAppStartWhenLaunchingAppFromFixedOrientationTest(flicker: FlickerTest) : +open class ShowImeOnAppStartWhenLaunchingAppFromFixedOrientationTest(flicker: LegacyFlickerTest) : BaseTest(flicker) { private val imeTestApp = ImeShownOnAppStartHelper(instrumentation, flicker.scenario.startRotation) @@ -93,33 +93,35 @@ open class ShowImeOnAppStartWhenLaunchingAppFromFixedOrientationTest(flicker: Fl layerTraceEntries.zipWithNext { prev, next -> val prevSnapshotLayerVisible = - ComponentNameMatcher.SNAPSHOT.layerMatchesAnyOf(prev.visibleLayers) + ComponentNameMatcher.SNAPSHOT.layerMatchesAnyOf(prev.visibleLayers) val nextSnapshotLayerVisible = - ComponentNameMatcher.SNAPSHOT.layerMatchesAnyOf(next.visibleLayers) + ComponentNameMatcher.SNAPSHOT.layerMatchesAnyOf(next.visibleLayers) - if (imeSnapshotRemovedTimestamp == null && - (prevSnapshotLayerVisible && !nextSnapshotLayerVisible)) { + if ( + imeSnapshotRemovedTimestamp == null && + (prevSnapshotLayerVisible && !nextSnapshotLayerVisible) + ) { imeSnapshotRemovedTimestamp = next.timestamp } } // if so, make an assertion imeSnapshotRemovedTimestamp?.let { timestamp -> - val stateAfterSnapshot = layerTrace?.getEntryAt(timestamp) - ?: error("State not found for $timestamp") + val stateAfterSnapshot = + layerTrace?.getEntryAt(timestamp) ?: error("State not found for $timestamp") - val imeLayers = ComponentNameMatcher.IME - .filterLayers(stateAfterSnapshot.visibleLayers.toList()) + val imeLayers = + ComponentNameMatcher.IME.filterLayers(stateAfterSnapshot.visibleLayers.toList()) require(imeLayers.isNotEmpty()) { "IME layer not found" } if (imeLayers.any { it.color.a != 1.0f }) { - val errorMsgBuilder = ExceptionMessageBuilder() + val errorMsgBuilder = + ExceptionMessageBuilder() .setTimestamp(timestamp) .forInvalidProperty("IME layer alpha") .setExpected("is 1.0") .setActual("not 1.0") - .addExtraDescription("Filter", - ComponentNameMatcher.IME.toLayerIdentifier()) + .addExtraDescription("Filter", ComponentNameMatcher.IME.toLayerIdentifier()) throw InvalidPropertyException(errorMsgBuilder) } } @@ -129,15 +131,14 @@ open class ShowImeOnAppStartWhenLaunchingAppFromFixedOrientationTest(flicker: Fl /** * Creates the test configurations. * - * See [FlickerTestFactory.nonRotationTests] for configuring screen orientation and + * See [LegacyFlickerTestFactory.nonRotationTests] for configuring screen orientation and * navigation modes. */ @Parameterized.Parameters(name = "{0}") @JvmStatic - fun getParams(): Collection<FlickerTest> { - return FlickerTestFactory.nonRotationTests( + fun getParams() = + LegacyFlickerTestFactory.nonRotationTests( supportedRotations = listOf(Rotation.ROTATION_90) ) - } } } diff --git a/tests/FlickerTests/src/com/android/server/wm/flicker/ime/ShowImeOnAppStartWhenLaunchingAppFromFixedOrientationTestCfArm.kt b/tests/FlickerTests/src/com/android/server/wm/flicker/ime/ShowImeOnAppStartWhenLaunchingAppFromFixedOrientationTestCfArm.kt index 3aca2a07f7cd..6d9ea2209d91 100644 --- a/tests/FlickerTests/src/com/android/server/wm/flicker/ime/ShowImeOnAppStartWhenLaunchingAppFromFixedOrientationTestCfArm.kt +++ b/tests/FlickerTests/src/com/android/server/wm/flicker/ime/ShowImeOnAppStartWhenLaunchingAppFromFixedOrientationTestCfArm.kt @@ -17,7 +17,7 @@ package com.android.server.wm.flicker.ime import android.tools.device.flicker.junit.FlickerParametersRunnerFactory -import android.tools.device.flicker.legacy.FlickerTest +import android.tools.device.flicker.legacy.LegacyFlickerTest import org.junit.FixMethodOrder import org.junit.runner.RunWith import org.junit.runners.MethodSorters @@ -26,5 +26,5 @@ import org.junit.runners.Parameterized @RunWith(Parameterized::class) @Parameterized.UseParametersRunnerFactory(FlickerParametersRunnerFactory::class) @FixMethodOrder(MethodSorters.NAME_ASCENDING) -class ShowImeOnAppStartWhenLaunchingAppFromFixedOrientationTestCfArm(flicker: FlickerTest) : +class ShowImeOnAppStartWhenLaunchingAppFromFixedOrientationTestCfArm(flicker: LegacyFlickerTest) : ShowImeOnAppStartWhenLaunchingAppFromFixedOrientationTest(flicker) diff --git a/tests/FlickerTests/src/com/android/server/wm/flicker/ime/ShowImeOnAppStartWhenLaunchingAppFromOverviewTest.kt b/tests/FlickerTests/src/com/android/server/wm/flicker/ime/ShowImeOnAppStartWhenLaunchingAppFromOverviewTest.kt index f64ad53bf2f7..ae05e37a84cc 100644 --- a/tests/FlickerTests/src/com/android/server/wm/flicker/ime/ShowImeOnAppStartWhenLaunchingAppFromOverviewTest.kt +++ b/tests/FlickerTests/src/com/android/server/wm/flicker/ime/ShowImeOnAppStartWhenLaunchingAppFromOverviewTest.kt @@ -21,8 +21,8 @@ import android.tools.common.Rotation import android.tools.common.traces.component.ComponentNameMatcher import android.tools.device.flicker.junit.FlickerParametersRunnerFactory import android.tools.device.flicker.legacy.FlickerBuilder -import android.tools.device.flicker.legacy.FlickerTest -import android.tools.device.flicker.legacy.FlickerTestFactory +import android.tools.device.flicker.legacy.LegacyFlickerTest +import android.tools.device.flicker.legacy.LegacyFlickerTestFactory import android.tools.device.helpers.reopenAppFromOverview import androidx.test.filters.RequiresDevice import com.android.server.wm.flicker.BaseTest @@ -41,7 +41,7 @@ import org.junit.runners.Parameterized @RunWith(Parameterized::class) @Parameterized.UseParametersRunnerFactory(FlickerParametersRunnerFactory::class) @FixMethodOrder(MethodSorters.NAME_ASCENDING) -open class ShowImeOnAppStartWhenLaunchingAppFromOverviewTest(flicker: FlickerTest) : +open class ShowImeOnAppStartWhenLaunchingAppFromOverviewTest(flicker: LegacyFlickerTest) : BaseTest(flicker) { private val testApp = ImeShownOnAppStartHelper(instrumentation, flicker.scenario.startRotation) @@ -140,10 +140,9 @@ open class ShowImeOnAppStartWhenLaunchingAppFromOverviewTest(flicker: FlickerTes companion object { @Parameterized.Parameters(name = "{0}") @JvmStatic - fun getParams(): Collection<FlickerTest> { - return FlickerTestFactory.nonRotationTests( + fun getParams() = + LegacyFlickerTestFactory.nonRotationTests( supportedRotations = listOf(Rotation.ROTATION_0) ) - } } } diff --git a/tests/FlickerTests/src/com/android/server/wm/flicker/ime/ShowImeOnAppStartWhenLaunchingAppFromOverviewTestCfArm.kt b/tests/FlickerTests/src/com/android/server/wm/flicker/ime/ShowImeOnAppStartWhenLaunchingAppFromOverviewTestCfArm.kt index e1aa4182c331..92b3968216e5 100644 --- a/tests/FlickerTests/src/com/android/server/wm/flicker/ime/ShowImeOnAppStartWhenLaunchingAppFromOverviewTestCfArm.kt +++ b/tests/FlickerTests/src/com/android/server/wm/flicker/ime/ShowImeOnAppStartWhenLaunchingAppFromOverviewTestCfArm.kt @@ -18,8 +18,8 @@ package com.android.server.wm.flicker.ime import android.tools.common.Rotation import android.tools.device.flicker.junit.FlickerParametersRunnerFactory -import android.tools.device.flicker.legacy.FlickerTest -import android.tools.device.flicker.legacy.FlickerTestFactory +import android.tools.device.flicker.legacy.LegacyFlickerTest +import android.tools.device.flicker.legacy.LegacyFlickerTestFactory import org.junit.FixMethodOrder import org.junit.runner.RunWith import org.junit.runners.MethodSorters @@ -28,16 +28,15 @@ import org.junit.runners.Parameterized @RunWith(Parameterized::class) @Parameterized.UseParametersRunnerFactory(FlickerParametersRunnerFactory::class) @FixMethodOrder(MethodSorters.NAME_ASCENDING) -class ShowImeOnAppStartWhenLaunchingAppFromOverviewTestCfArm(flicker: FlickerTest) : +class ShowImeOnAppStartWhenLaunchingAppFromOverviewTestCfArm(flicker: LegacyFlickerTest) : ShowImeOnAppStartWhenLaunchingAppFromOverviewTest(flicker) { companion object { @Parameterized.Parameters(name = "{0}") @JvmStatic - fun getParams(): Collection<FlickerTest> { - return FlickerTestFactory.nonRotationTests( + fun getParams() = + LegacyFlickerTestFactory.nonRotationTests( supportedRotations = listOf(Rotation.ROTATION_0) ) - } } } diff --git a/tests/FlickerTests/src/com/android/server/wm/flicker/ime/ShowImeOnAppStartWhenLaunchingAppFromQuickSwitchTest.kt b/tests/FlickerTests/src/com/android/server/wm/flicker/ime/ShowImeOnAppStartWhenLaunchingAppFromQuickSwitchTest.kt index 11bc7b9f29c0..c991651a9d08 100644 --- a/tests/FlickerTests/src/com/android/server/wm/flicker/ime/ShowImeOnAppStartWhenLaunchingAppFromQuickSwitchTest.kt +++ b/tests/FlickerTests/src/com/android/server/wm/flicker/ime/ShowImeOnAppStartWhenLaunchingAppFromQuickSwitchTest.kt @@ -22,8 +22,8 @@ import android.tools.common.Rotation import android.tools.common.traces.component.ComponentNameMatcher import android.tools.device.flicker.junit.FlickerParametersRunnerFactory import android.tools.device.flicker.legacy.FlickerBuilder -import android.tools.device.flicker.legacy.FlickerTest -import android.tools.device.flicker.legacy.FlickerTestFactory +import android.tools.device.flicker.legacy.LegacyFlickerTest +import android.tools.device.flicker.legacy.LegacyFlickerTestFactory import androidx.test.filters.RequiresDevice import com.android.server.wm.flicker.BaseTest import com.android.server.wm.flicker.helpers.ImeShownOnAppStartHelper @@ -44,7 +44,7 @@ import org.junit.runners.Parameterized @Parameterized.UseParametersRunnerFactory(FlickerParametersRunnerFactory::class) @FixMethodOrder(MethodSorters.NAME_ASCENDING) @Presubmit -open class ShowImeOnAppStartWhenLaunchingAppFromQuickSwitchTest(flicker: FlickerTest) : +open class ShowImeOnAppStartWhenLaunchingAppFromQuickSwitchTest(flicker: LegacyFlickerTest) : BaseTest(flicker) { private val testApp = SimpleAppHelper(instrumentation) private val imeTestApp = @@ -121,12 +121,11 @@ open class ShowImeOnAppStartWhenLaunchingAppFromQuickSwitchTest(flicker: Flicker companion object { @Parameterized.Parameters(name = "{0}") @JvmStatic - fun getParams(): Collection<FlickerTest> { - return FlickerTestFactory.nonRotationTests( + fun getParams() = + LegacyFlickerTestFactory.nonRotationTests( supportedNavigationModes = listOf(NavBar.MODE_GESTURAL), supportedRotations = listOf(Rotation.ROTATION_0) ) - } private const val TAG_IME_VISIBLE = "imeVisible" private const val TAG_IME_INVISIBLE = "imeInVisible" diff --git a/tests/FlickerTests/src/com/android/server/wm/flicker/ime/ShowImeOnAppStartWhenLaunchingAppFromQuickSwitchTestCfArm.kt b/tests/FlickerTests/src/com/android/server/wm/flicker/ime/ShowImeOnAppStartWhenLaunchingAppFromQuickSwitchTestCfArm.kt index 0f57467c0449..09bfacc582e5 100644 --- a/tests/FlickerTests/src/com/android/server/wm/flicker/ime/ShowImeOnAppStartWhenLaunchingAppFromQuickSwitchTestCfArm.kt +++ b/tests/FlickerTests/src/com/android/server/wm/flicker/ime/ShowImeOnAppStartWhenLaunchingAppFromQuickSwitchTestCfArm.kt @@ -18,7 +18,7 @@ package com.android.server.wm.flicker.ime import android.platform.test.annotations.Presubmit import android.tools.device.flicker.junit.FlickerParametersRunnerFactory -import android.tools.device.flicker.legacy.FlickerTest +import android.tools.device.flicker.legacy.LegacyFlickerTest import org.junit.FixMethodOrder import org.junit.runner.RunWith import org.junit.runners.MethodSorters @@ -28,5 +28,5 @@ import org.junit.runners.Parameterized @Parameterized.UseParametersRunnerFactory(FlickerParametersRunnerFactory::class) @FixMethodOrder(MethodSorters.NAME_ASCENDING) @Presubmit -open class ShowImeOnAppStartWhenLaunchingAppFromQuickSwitchTestCfArm(flicker: FlickerTest) : +open class ShowImeOnAppStartWhenLaunchingAppFromQuickSwitchTestCfArm(flicker: LegacyFlickerTest) : ShowImeOnAppStartWhenLaunchingAppFromQuickSwitchTest(flicker) diff --git a/tests/FlickerTests/src/com/android/server/wm/flicker/ime/ShowImeOnAppStartWhenLaunchingAppTest.kt b/tests/FlickerTests/src/com/android/server/wm/flicker/ime/ShowImeOnAppStartWhenLaunchingAppTest.kt index 46967db55086..976352146fc0 100644 --- a/tests/FlickerTests/src/com/android/server/wm/flicker/ime/ShowImeOnAppStartWhenLaunchingAppTest.kt +++ b/tests/FlickerTests/src/com/android/server/wm/flicker/ime/ShowImeOnAppStartWhenLaunchingAppTest.kt @@ -21,8 +21,8 @@ import android.tools.common.Rotation import android.tools.common.traces.component.ComponentNameMatcher import android.tools.device.flicker.junit.FlickerParametersRunnerFactory import android.tools.device.flicker.legacy.FlickerBuilder -import android.tools.device.flicker.legacy.FlickerTest -import android.tools.device.flicker.legacy.FlickerTestFactory +import android.tools.device.flicker.legacy.LegacyFlickerTest +import android.tools.device.flicker.legacy.LegacyFlickerTestFactory import androidx.test.filters.RequiresDevice import com.android.server.wm.flicker.BaseTest import com.android.server.wm.flicker.helpers.ImeShownOnAppStartHelper @@ -79,7 +79,7 @@ import org.junit.runners.Parameterized @RunWith(Parameterized::class) @Parameterized.UseParametersRunnerFactory(FlickerParametersRunnerFactory::class) @FixMethodOrder(MethodSorters.NAME_ASCENDING) -open class ShowImeOnAppStartWhenLaunchingAppTest(flicker: FlickerTest) : BaseTest(flicker) { +open class ShowImeOnAppStartWhenLaunchingAppTest(flicker: LegacyFlickerTest) : BaseTest(flicker) { private val testApp = ImeShownOnAppStartHelper(instrumentation, flicker.scenario.startRotation) private val initializeApp = ImeStateInitializeHelper(instrumentation) @@ -123,15 +123,14 @@ open class ShowImeOnAppStartWhenLaunchingAppTest(flicker: FlickerTest) : BaseTes /** * Creates the test configurations. * - * See [FlickerTestFactory.nonRotationTests] for configuring screen orientation and + * See [LegacyFlickerTestFactory.nonRotationTests] for configuring screen orientation and * navigation modes. */ @Parameterized.Parameters(name = "{0}") @JvmStatic - fun getParams(): Collection<FlickerTest> { - return FlickerTestFactory.nonRotationTests( + fun getParams() = + LegacyFlickerTestFactory.nonRotationTests( supportedRotations = listOf(Rotation.ROTATION_0) ) - } } } diff --git a/tests/FlickerTests/src/com/android/server/wm/flicker/ime/ShowImeWhenFocusingOnInputFieldTest.kt b/tests/FlickerTests/src/com/android/server/wm/flicker/ime/ShowImeWhenFocusingOnInputFieldTest.kt index 827110dd4572..7bd58252d3ba 100644 --- a/tests/FlickerTests/src/com/android/server/wm/flicker/ime/ShowImeWhenFocusingOnInputFieldTest.kt +++ b/tests/FlickerTests/src/com/android/server/wm/flicker/ime/ShowImeWhenFocusingOnInputFieldTest.kt @@ -21,8 +21,8 @@ import android.platform.test.annotations.Presubmit import android.tools.common.Rotation import android.tools.device.flicker.junit.FlickerParametersRunnerFactory import android.tools.device.flicker.legacy.FlickerBuilder -import android.tools.device.flicker.legacy.FlickerTest -import android.tools.device.flicker.legacy.FlickerTestFactory +import android.tools.device.flicker.legacy.LegacyFlickerTest +import android.tools.device.flicker.legacy.LegacyFlickerTestFactory import androidx.test.filters.RequiresDevice import com.android.server.wm.flicker.BaseTest import com.android.server.wm.flicker.helpers.ImeAppHelper @@ -37,7 +37,7 @@ import org.junit.runners.Parameterized @RunWith(Parameterized::class) @Parameterized.UseParametersRunnerFactory(FlickerParametersRunnerFactory::class) @FixMethodOrder(MethodSorters.NAME_ASCENDING) -open class ShowImeWhenFocusingOnInputFieldTest(flicker: FlickerTest) : BaseTest(flicker) { +open class ShowImeWhenFocusingOnInputFieldTest(flicker: LegacyFlickerTest) : BaseTest(flicker) { private val testApp = ImeAppHelper(instrumentation) /** {@inheritDoc} */ @@ -79,10 +79,9 @@ open class ShowImeWhenFocusingOnInputFieldTest(flicker: FlickerTest) : BaseTest( companion object { @Parameterized.Parameters(name = "{0}") @JvmStatic - fun getParams(): Collection<FlickerTest> { - return FlickerTestFactory.nonRotationTests( + fun getParams() = + LegacyFlickerTestFactory.nonRotationTests( supportedRotations = listOf(Rotation.ROTATION_0) ) - } } } diff --git a/tests/FlickerTests/src/com/android/server/wm/flicker/ime/ShowImeWhenFocusingOnInputFieldTestCfArm.kt b/tests/FlickerTests/src/com/android/server/wm/flicker/ime/ShowImeWhenFocusingOnInputFieldTestCfArm.kt index f5b22949e6b4..f8c814988200 100644 --- a/tests/FlickerTests/src/com/android/server/wm/flicker/ime/ShowImeWhenFocusingOnInputFieldTestCfArm.kt +++ b/tests/FlickerTests/src/com/android/server/wm/flicker/ime/ShowImeWhenFocusingOnInputFieldTestCfArm.kt @@ -17,7 +17,7 @@ package com.android.server.wm.flicker.ime import android.tools.device.flicker.junit.FlickerParametersRunnerFactory -import android.tools.device.flicker.legacy.FlickerTest +import android.tools.device.flicker.legacy.LegacyFlickerTest import org.junit.FixMethodOrder import org.junit.runner.RunWith import org.junit.runners.MethodSorters @@ -26,5 +26,5 @@ import org.junit.runners.Parameterized @RunWith(Parameterized::class) @Parameterized.UseParametersRunnerFactory(FlickerParametersRunnerFactory::class) @FixMethodOrder(MethodSorters.NAME_ASCENDING) -class ShowImeWhenFocusingOnInputFieldTestCfArm(flicker: FlickerTest) : +class ShowImeWhenFocusingOnInputFieldTestCfArm(flicker: LegacyFlickerTest) : ShowImeWhenFocusingOnInputFieldTest(flicker) diff --git a/tests/FlickerTests/src/com/android/server/wm/flicker/ime/ShowImeWhileDismissingThemedPopupDialogTest.kt b/tests/FlickerTests/src/com/android/server/wm/flicker/ime/ShowImeWhileDismissingThemedPopupDialogTest.kt index 277b91558416..0b168baa6622 100644 --- a/tests/FlickerTests/src/com/android/server/wm/flicker/ime/ShowImeWhileDismissingThemedPopupDialogTest.kt +++ b/tests/FlickerTests/src/com/android/server/wm/flicker/ime/ShowImeWhileDismissingThemedPopupDialogTest.kt @@ -21,8 +21,8 @@ import android.tools.common.Rotation import android.tools.common.traces.component.ComponentNameMatcher import android.tools.device.flicker.junit.FlickerParametersRunnerFactory import android.tools.device.flicker.legacy.FlickerBuilder -import android.tools.device.flicker.legacy.FlickerTest -import android.tools.device.flicker.legacy.FlickerTestFactory +import android.tools.device.flicker.legacy.LegacyFlickerTest +import android.tools.device.flicker.legacy.LegacyFlickerTestFactory import android.view.WindowInsets.Type.ime import android.view.WindowInsets.Type.navigationBars import android.view.WindowInsets.Type.statusBars @@ -45,7 +45,8 @@ import org.junit.runners.Parameterized @RunWith(Parameterized::class) @Parameterized.UseParametersRunnerFactory(FlickerParametersRunnerFactory::class) @FixMethodOrder(MethodSorters.NAME_ASCENDING) -open class ShowImeWhileDismissingThemedPopupDialogTest(flicker: FlickerTest) : BaseTest(flicker) { +open class ShowImeWhileDismissingThemedPopupDialogTest(flicker: LegacyFlickerTest) : + BaseTest(flicker) { private val testApp = ImeShownOnAppStartHelper(instrumentation, flicker.scenario.startRotation) /** {@inheritDoc} */ @@ -84,15 +85,14 @@ open class ShowImeWhileDismissingThemedPopupDialogTest(flicker: FlickerTest) : B /** * Creates the test configurations. * - * See [FlickerTestFactory.nonRotationTests] for configuring screen orientation and + * See [LegacyFlickerTestFactory.nonRotationTests] for configuring screen orientation and * navigation modes. */ @Parameterized.Parameters(name = "{0}") @JvmStatic - fun getParams(): Collection<FlickerTest> { - return FlickerTestFactory.nonRotationTests( + fun getParams() = + LegacyFlickerTestFactory.nonRotationTests( supportedRotations = listOf(Rotation.ROTATION_0) ) - } } } diff --git a/tests/FlickerTests/src/com/android/server/wm/flicker/ime/ShowImeWhileDismissingThemedPopupDialogTestCfArm.kt b/tests/FlickerTests/src/com/android/server/wm/flicker/ime/ShowImeWhileDismissingThemedPopupDialogTestCfArm.kt index 8891d26c9e54..ad41b81a6664 100644 --- a/tests/FlickerTests/src/com/android/server/wm/flicker/ime/ShowImeWhileDismissingThemedPopupDialogTestCfArm.kt +++ b/tests/FlickerTests/src/com/android/server/wm/flicker/ime/ShowImeWhileDismissingThemedPopupDialogTestCfArm.kt @@ -18,8 +18,8 @@ package com.android.server.wm.flicker.ime import android.tools.common.Rotation import android.tools.device.flicker.junit.FlickerParametersRunnerFactory -import android.tools.device.flicker.legacy.FlickerTest -import android.tools.device.flicker.legacy.FlickerTestFactory +import android.tools.device.flicker.legacy.LegacyFlickerTest +import android.tools.device.flicker.legacy.LegacyFlickerTestFactory import org.junit.FixMethodOrder import org.junit.runner.RunWith import org.junit.runners.MethodSorters @@ -28,21 +28,20 @@ import org.junit.runners.Parameterized @RunWith(Parameterized::class) @Parameterized.UseParametersRunnerFactory(FlickerParametersRunnerFactory::class) @FixMethodOrder(MethodSorters.NAME_ASCENDING) -class ShowImeWhileDismissingThemedPopupDialogTestCfArm(flicker: FlickerTest) : +class ShowImeWhileDismissingThemedPopupDialogTestCfArm(flicker: LegacyFlickerTest) : ShowImeWhileDismissingThemedPopupDialogTest(flicker) { companion object { /** * Creates the test configurations. * - * See [FlickerTestFactory.nonRotationTests] for configuring screen orientation and + * See [LegacyFlickerTestFactory.nonRotationTests] for configuring screen orientation and * navigation modes. */ @Parameterized.Parameters(name = "{0}") @JvmStatic - fun getParams(): Collection<FlickerTest> { - return FlickerTestFactory.nonRotationTests( + fun getParams() = + LegacyFlickerTestFactory.nonRotationTests( supportedRotations = listOf(Rotation.ROTATION_0) ) - } } } diff --git a/tests/FlickerTests/src/com/android/server/wm/flicker/ime/ShowImeWhileEnteringOverviewTest.kt b/tests/FlickerTests/src/com/android/server/wm/flicker/ime/ShowImeWhileEnteringOverviewTest.kt index 9275d6a2f17f..7722c934d11b 100644 --- a/tests/FlickerTests/src/com/android/server/wm/flicker/ime/ShowImeWhileEnteringOverviewTest.kt +++ b/tests/FlickerTests/src/com/android/server/wm/flicker/ime/ShowImeWhileEnteringOverviewTest.kt @@ -21,8 +21,8 @@ import android.tools.common.traces.ConditionsFactory import android.tools.common.traces.component.ComponentNameMatcher import android.tools.device.flicker.junit.FlickerParametersRunnerFactory import android.tools.device.flicker.legacy.FlickerBuilder -import android.tools.device.flicker.legacy.FlickerTest -import android.tools.device.flicker.legacy.FlickerTestFactory +import android.tools.device.flicker.legacy.LegacyFlickerTest +import android.tools.device.flicker.legacy.LegacyFlickerTestFactory import android.tools.device.traces.parsers.WindowManagerStateHelper import androidx.test.filters.RequiresDevice import com.android.server.wm.flicker.BaseTest @@ -45,7 +45,7 @@ import org.junit.runners.Parameterized @RunWith(Parameterized::class) @Parameterized.UseParametersRunnerFactory(FlickerParametersRunnerFactory::class) @FixMethodOrder(MethodSorters.NAME_ASCENDING) -open class ShowImeWhileEnteringOverviewTest(flicker: FlickerTest) : BaseTest(flicker) { +open class ShowImeWhileEnteringOverviewTest(flicker: LegacyFlickerTest) : BaseTest(flicker) { private val imeTestApp = ImeShownOnAppStartHelper(instrumentation, flicker.scenario.startRotation) @@ -205,13 +205,11 @@ open class ShowImeWhileEnteringOverviewTest(flicker: FlickerTest) : BaseTest(fli /** * Creates the test configurations. * - * See [FlickerTestFactory.nonRotationTests] for configuring screen orientation and + * See [LegacyFlickerTestFactory.nonRotationTests] for configuring screen orientation and * navigation modes. */ @Parameterized.Parameters(name = "{0}") @JvmStatic - fun getParams(): Collection<FlickerTest> { - return FlickerTestFactory.nonRotationTests() - } + fun getParams() = LegacyFlickerTestFactory.nonRotationTests() } } diff --git a/tests/FlickerTests/src/com/android/server/wm/flicker/ime/ShowImeWhileEnteringOverviewTestCfArm.kt b/tests/FlickerTests/src/com/android/server/wm/flicker/ime/ShowImeWhileEnteringOverviewTestCfArm.kt index fc3971351db7..90fbbf9bb240 100644 --- a/tests/FlickerTests/src/com/android/server/wm/flicker/ime/ShowImeWhileEnteringOverviewTestCfArm.kt +++ b/tests/FlickerTests/src/com/android/server/wm/flicker/ime/ShowImeWhileEnteringOverviewTestCfArm.kt @@ -17,7 +17,7 @@ package com.android.server.wm.flicker.ime import android.tools.device.flicker.junit.FlickerParametersRunnerFactory -import android.tools.device.flicker.legacy.FlickerTest +import android.tools.device.flicker.legacy.LegacyFlickerTest import org.junit.FixMethodOrder import org.junit.runner.RunWith import org.junit.runners.MethodSorters @@ -26,5 +26,5 @@ import org.junit.runners.Parameterized @RunWith(Parameterized::class) @Parameterized.UseParametersRunnerFactory(FlickerParametersRunnerFactory::class) @FixMethodOrder(MethodSorters.NAME_ASCENDING) -class ShowImeWhileEnteringOverviewTestCfArm(flicker: FlickerTest) : +class ShowImeWhileEnteringOverviewTestCfArm(flicker: LegacyFlickerTest) : ShowImeWhileEnteringOverviewTest(flicker) diff --git a/tests/FlickerTests/src/com/android/server/wm/flicker/launch/ActivitiesTransitionTest.kt b/tests/FlickerTests/src/com/android/server/wm/flicker/launch/ActivityTransitionTest.kt index e6594c969373..3461907f71dd 100644 --- a/tests/FlickerTests/src/com/android/server/wm/flicker/launch/ActivitiesTransitionTest.kt +++ b/tests/FlickerTests/src/com/android/server/wm/flicker/launch/ActivityTransitionTest.kt @@ -20,8 +20,8 @@ import android.platform.test.annotations.Presubmit import android.tools.common.traces.component.ComponentNameMatcher import android.tools.device.flicker.junit.FlickerParametersRunnerFactory import android.tools.device.flicker.legacy.FlickerBuilder -import android.tools.device.flicker.legacy.FlickerTest -import android.tools.device.flicker.legacy.FlickerTestFactory +import android.tools.device.flicker.legacy.LegacyFlickerTest +import android.tools.device.flicker.legacy.LegacyFlickerTestFactory import android.tools.device.traces.parsers.toFlickerComponent import androidx.test.filters.RequiresDevice import com.android.server.wm.flicker.BaseTest @@ -57,7 +57,7 @@ import org.junit.runners.Parameterized @RunWith(Parameterized::class) @Parameterized.UseParametersRunnerFactory(FlickerParametersRunnerFactory::class) @FixMethodOrder(MethodSorters.NAME_ASCENDING) -open class ActivitiesTransitionTest(flicker: FlickerTest) : BaseTest(flicker) { +open class ActivityTransitionTest(flicker: LegacyFlickerTest) : BaseTest(flicker) { private val testApp: TwoActivitiesAppHelper = TwoActivitiesAppHelper(instrumentation) /** {@inheritDoc} */ @@ -119,13 +119,11 @@ open class ActivitiesTransitionTest(flicker: FlickerTest) : BaseTest(flicker) { /** * Creates the test configurations. * - * See [FlickerTestFactory.nonRotationTests] for configuring screen orientation and + * See [LegacyFlickerTestFactory.nonRotationTests] for configuring screen orientation and * navigation modes. */ @Parameterized.Parameters(name = "{0}") @JvmStatic - fun getParams(): Collection<FlickerTest> { - return FlickerTestFactory.nonRotationTests() - } + fun getParams() = LegacyFlickerTestFactory.nonRotationTests() } } diff --git a/tests/FlickerTests/src/com/android/server/wm/flicker/launch/OpenAppAfterCameraTestCfArm.kt b/tests/FlickerTests/src/com/android/server/wm/flicker/launch/ActivityTransitionTestCfArm.kt index ac05c7687311..6bbf40ea10f9 100644 --- a/tests/FlickerTests/src/com/android/server/wm/flicker/launch/OpenAppAfterCameraTestCfArm.kt +++ b/tests/FlickerTests/src/com/android/server/wm/flicker/launch/ActivityTransitionTestCfArm.kt @@ -17,8 +17,8 @@ package com.android.server.wm.flicker.launch import android.tools.device.flicker.junit.FlickerParametersRunnerFactory -import android.tools.device.flicker.legacy.FlickerTest -import android.tools.device.flicker.legacy.FlickerTestFactory +import android.tools.device.flicker.legacy.LegacyFlickerTest +import android.tools.device.flicker.legacy.LegacyFlickerTestFactory import org.junit.FixMethodOrder import org.junit.runner.RunWith import org.junit.runners.MethodSorters @@ -27,18 +27,16 @@ import org.junit.runners.Parameterized @RunWith(Parameterized::class) @Parameterized.UseParametersRunnerFactory(FlickerParametersRunnerFactory::class) @FixMethodOrder(MethodSorters.NAME_ASCENDING) -class OpenAppAfterCameraTestCfArm(flicker: FlickerTest) : OpenAppAfterCameraTest(flicker) { +class ActivityTransitionTestCfArm(flicker: LegacyFlickerTest) : ActivityTransitionTest(flicker) { companion object { /** * Creates the test configurations. * - * See [FlickerTestFactory.nonRotationTests] for configuring screen orientation and + * See [LegacyFlickerTestFactory.nonRotationTests] for configuring screen orientation and * navigation modes. */ @Parameterized.Parameters(name = "{0}") @JvmStatic - fun getParams(): Collection<FlickerTest> { - return FlickerTestFactory.nonRotationTests() - } + fun getParams() = LegacyFlickerTestFactory.nonRotationTests() } } diff --git a/tests/FlickerTests/src/com/android/server/wm/flicker/launch/OpenAppColdFromIcon.kt b/tests/FlickerTests/src/com/android/server/wm/flicker/launch/OpenAppFromIconColdTest.kt index 3a80c6649833..ae1f78a5a4ef 100644 --- a/tests/FlickerTests/src/com/android/server/wm/flicker/launch/OpenAppColdFromIcon.kt +++ b/tests/FlickerTests/src/com/android/server/wm/flicker/launch/OpenAppFromIconColdTest.kt @@ -20,8 +20,8 @@ import android.platform.test.annotations.FlakyTest import android.tools.common.Rotation import android.tools.device.flicker.junit.FlickerParametersRunnerFactory import android.tools.device.flicker.legacy.FlickerBuilder -import android.tools.device.flicker.legacy.FlickerTest -import android.tools.device.flicker.legacy.FlickerTestFactory +import android.tools.device.flicker.legacy.LegacyFlickerTest +import android.tools.device.flicker.legacy.LegacyFlickerTestFactory import android.tools.device.flicker.rules.RemoveAllTasksButHomeRule import androidx.test.filters.RequiresDevice import org.junit.FixMethodOrder @@ -55,7 +55,8 @@ import org.junit.runners.Parameterized @RunWith(Parameterized::class) @Parameterized.UseParametersRunnerFactory(FlickerParametersRunnerFactory::class) @FixMethodOrder(MethodSorters.NAME_ASCENDING) -open class OpenAppColdFromIcon(flicker: FlickerTest) : OpenAppFromLauncherTransition(flicker) { +open class OpenAppFromIconColdTest(flicker: LegacyFlickerTest) : + OpenAppFromLauncherTransition(flicker) { /** {@inheritDoc} */ override val transition: FlickerBuilder.() -> Unit get() = { @@ -207,13 +208,11 @@ open class OpenAppColdFromIcon(flicker: FlickerTest) : OpenAppFromLauncherTransi /** * Creates the test configurations. * - * See [FlickerTestFactory.nonRotationTests] for configuring screen orientation and + * See [LegacyFlickerTestFactory.nonRotationTests] for configuring screen orientation and * navigation modes. */ @Parameterized.Parameters(name = "{0}") @JvmStatic - fun getParams(): Collection<FlickerTest> { - return FlickerTestFactory.nonRotationTests() - } + fun getParams() = LegacyFlickerTestFactory.nonRotationTests() } } diff --git a/tests/FlickerTests/src/com/android/server/wm/flicker/launch/OpenAppColdFromIconCfArm.kt b/tests/FlickerTests/src/com/android/server/wm/flicker/launch/OpenAppFromIconColdTestCfArm.kt index d33a2724ca44..4fd4a61e4adc 100644 --- a/tests/FlickerTests/src/com/android/server/wm/flicker/launch/OpenAppColdFromIconCfArm.kt +++ b/tests/FlickerTests/src/com/android/server/wm/flicker/launch/OpenAppFromIconColdTestCfArm.kt @@ -17,10 +17,10 @@ package com.android.server.wm.flicker.launch import android.platform.test.annotations.FlakyTest -import android.tools.device.flicker.annotation.FlickerServiceCompatible +import android.tools.common.flicker.annotation.FlickerServiceCompatible import android.tools.device.flicker.junit.FlickerParametersRunnerFactory -import android.tools.device.flicker.legacy.FlickerTest -import android.tools.device.flicker.legacy.FlickerTestFactory +import android.tools.device.flicker.legacy.LegacyFlickerTest +import android.tools.device.flicker.legacy.LegacyFlickerTestFactory import org.junit.FixMethodOrder import org.junit.Test import org.junit.runner.RunWith @@ -32,7 +32,7 @@ import org.junit.runners.Parameterized @RunWith(Parameterized::class) @Parameterized.UseParametersRunnerFactory(FlickerParametersRunnerFactory::class) @FixMethodOrder(MethodSorters.NAME_ASCENDING) -class OpenAppColdFromIconCfArm(flicker: FlickerTest) : OpenAppColdFromIcon(flicker) { +class OpenAppFromIconColdTestCfArm(flicker: LegacyFlickerTest) : OpenAppFromIconColdTest(flicker) { @Test @FlakyTest override fun visibleLayersShownMoreThanOneConsecutiveEntry() { @@ -43,13 +43,11 @@ class OpenAppColdFromIconCfArm(flicker: FlickerTest) : OpenAppColdFromIcon(flick /** * Creates the test configurations. * - * See [FlickerTestFactory.nonRotationTests] for configuring screen orientation and + * See [LegacyFlickerTestFactory.nonRotationTests] for configuring screen orientation and * navigation modes. */ @Parameterized.Parameters(name = "{0}") @JvmStatic - fun getParams(): Collection<FlickerTest> { - return FlickerTestFactory.nonRotationTests() - } + fun getParams() = LegacyFlickerTestFactory.nonRotationTests() } } diff --git a/tests/FlickerTests/src/com/android/server/wm/flicker/launch/OpenAppAfterCameraTest.kt b/tests/FlickerTests/src/com/android/server/wm/flicker/launch/OpenAppFromIntentColdAfterCameraTest.kt index 549183f407e2..c95c548e7221 100644 --- a/tests/FlickerTests/src/com/android/server/wm/flicker/launch/OpenAppAfterCameraTest.kt +++ b/tests/FlickerTests/src/com/android/server/wm/flicker/launch/OpenAppFromIntentColdAfterCameraTest.kt @@ -19,8 +19,8 @@ package com.android.server.wm.flicker.launch import android.tools.device.apphelpers.CameraAppHelper import android.tools.device.flicker.junit.FlickerParametersRunnerFactory import android.tools.device.flicker.legacy.FlickerBuilder -import android.tools.device.flicker.legacy.FlickerTest -import android.tools.device.flicker.legacy.FlickerTestFactory +import android.tools.device.flicker.legacy.LegacyFlickerTest +import android.tools.device.flicker.legacy.LegacyFlickerTestFactory import androidx.test.filters.RequiresDevice import org.junit.FixMethodOrder import org.junit.runner.RunWith @@ -38,7 +38,8 @@ import org.junit.runners.Parameterized @RunWith(Parameterized::class) @Parameterized.UseParametersRunnerFactory(FlickerParametersRunnerFactory::class) @FixMethodOrder(MethodSorters.NAME_ASCENDING) -open class OpenAppAfterCameraTest(flicker: FlickerTest) : OpenAppFromLauncherTransition(flicker) { +open class OpenAppFromIntentColdAfterCameraTest(flicker: LegacyFlickerTest) : + OpenAppFromLauncherTransition(flicker) { private val cameraApp = CameraAppHelper(instrumentation) /** {@inheritDoc} */ override val transition: FlickerBuilder.() -> Unit @@ -61,13 +62,11 @@ open class OpenAppAfterCameraTest(flicker: FlickerTest) : OpenAppFromLauncherTra /** * Creates the test configurations. * - * See [FlickerTestFactory.nonRotationTests] for configuring screen orientation and + * See [LegacyFlickerTestFactory.nonRotationTests] for configuring screen orientation and * navigation modes. */ @Parameterized.Parameters(name = "{0}") @JvmStatic - fun getParams(): Collection<FlickerTest> { - return FlickerTestFactory.nonRotationTests() - } + fun getParams() = LegacyFlickerTestFactory.nonRotationTests() } } diff --git a/tests/FlickerTests/src/com/android/server/wm/flicker/launch/ActivitiesTransitionTestCfArm.kt b/tests/FlickerTests/src/com/android/server/wm/flicker/launch/OpenAppFromIntentColdAfterCameraTestCfArm.kt index 8b89a8b4c40d..117cff203ff7 100644 --- a/tests/FlickerTests/src/com/android/server/wm/flicker/launch/ActivitiesTransitionTestCfArm.kt +++ b/tests/FlickerTests/src/com/android/server/wm/flicker/launch/OpenAppFromIntentColdAfterCameraTestCfArm.kt @@ -17,8 +17,8 @@ package com.android.server.wm.flicker.launch import android.tools.device.flicker.junit.FlickerParametersRunnerFactory -import android.tools.device.flicker.legacy.FlickerTest -import android.tools.device.flicker.legacy.FlickerTestFactory +import android.tools.device.flicker.legacy.LegacyFlickerTest +import android.tools.device.flicker.legacy.LegacyFlickerTestFactory import org.junit.FixMethodOrder import org.junit.runner.RunWith import org.junit.runners.MethodSorters @@ -27,18 +27,17 @@ import org.junit.runners.Parameterized @RunWith(Parameterized::class) @Parameterized.UseParametersRunnerFactory(FlickerParametersRunnerFactory::class) @FixMethodOrder(MethodSorters.NAME_ASCENDING) -class ActivitiesTransitionTestCfArm(flicker: FlickerTest) : ActivitiesTransitionTest(flicker) { +class OpenAppFromIntentColdAfterCameraTestCfArm(flicker: LegacyFlickerTest) : + OpenAppFromIntentColdAfterCameraTest(flicker) { companion object { /** * Creates the test configurations. * - * See [FlickerTestFactory.nonRotationTests] for configuring screen orientation and + * See [LegacyFlickerTestFactory.nonRotationTests] for configuring screen orientation and * navigation modes. */ @Parameterized.Parameters(name = "{0}") @JvmStatic - fun getParams(): Collection<FlickerTest> { - return FlickerTestFactory.nonRotationTests() - } + fun getParams() = LegacyFlickerTestFactory.nonRotationTests() } } diff --git a/tests/FlickerTests/src/com/android/server/wm/flicker/launch/OpenAppColdTest.kt b/tests/FlickerTests/src/com/android/server/wm/flicker/launch/OpenAppFromIntentColdTest.kt index 26f88d23cda0..e39a578fd321 100644 --- a/tests/FlickerTests/src/com/android/server/wm/flicker/launch/OpenAppColdTest.kt +++ b/tests/FlickerTests/src/com/android/server/wm/flicker/launch/OpenAppFromIntentColdTest.kt @@ -18,11 +18,11 @@ package com.android.server.wm.flicker.launch import android.platform.test.annotations.Postsubmit import android.platform.test.annotations.Presubmit -import android.tools.device.flicker.annotation.FlickerServiceCompatible +import android.tools.common.flicker.annotation.FlickerServiceCompatible import android.tools.device.flicker.junit.FlickerParametersRunnerFactory import android.tools.device.flicker.legacy.FlickerBuilder -import android.tools.device.flicker.legacy.FlickerTest -import android.tools.device.flicker.legacy.FlickerTestFactory +import android.tools.device.flicker.legacy.LegacyFlickerTest +import android.tools.device.flicker.legacy.LegacyFlickerTestFactory import android.tools.device.flicker.rules.RemoveAllTasksButHomeRule.Companion.removeAllTasksButHome import androidx.test.filters.RequiresDevice import com.android.server.wm.flicker.helpers.setRotation @@ -58,7 +58,8 @@ import org.junit.runners.Parameterized @RunWith(Parameterized::class) @Parameterized.UseParametersRunnerFactory(FlickerParametersRunnerFactory::class) @FixMethodOrder(MethodSorters.NAME_ASCENDING) -open class OpenAppColdTest(flicker: FlickerTest) : OpenAppFromLauncherTransition(flicker) { +open class OpenAppFromIntentColdTest(flicker: LegacyFlickerTest) : + OpenAppFromLauncherTransition(flicker) { /** {@inheritDoc} */ override val transition: FlickerBuilder.() -> Unit get() = { @@ -82,13 +83,11 @@ open class OpenAppColdTest(flicker: FlickerTest) : OpenAppFromLauncherTransition /** * Creates the test configurations. * - * See [FlickerTestFactory.nonRotationTests] for configuring screen orientation and + * See [LegacyFlickerTestFactory.nonRotationTests] for configuring screen orientation and * navigation modes. */ @Parameterized.Parameters(name = "{0}") @JvmStatic - fun getParams(): Collection<FlickerTest> { - return FlickerTestFactory.nonRotationTests() - } + fun getParams() = LegacyFlickerTestFactory.nonRotationTests() } } diff --git a/tests/FlickerTests/src/com/android/server/wm/flicker/launch/OpenAppColdTestCfArm.kt b/tests/FlickerTests/src/com/android/server/wm/flicker/launch/OpenAppFromIntentColdTestCfArm.kt index d9a99dadbd3d..6d0b6f48d7c6 100644 --- a/tests/FlickerTests/src/com/android/server/wm/flicker/launch/OpenAppColdTestCfArm.kt +++ b/tests/FlickerTests/src/com/android/server/wm/flicker/launch/OpenAppFromIntentColdTestCfArm.kt @@ -17,10 +17,10 @@ package com.android.server.wm.flicker.launch import android.platform.test.annotations.FlakyTest -import android.tools.device.flicker.annotation.FlickerServiceCompatible +import android.tools.common.flicker.annotation.FlickerServiceCompatible import android.tools.device.flicker.junit.FlickerParametersRunnerFactory -import android.tools.device.flicker.legacy.FlickerTest -import android.tools.device.flicker.legacy.FlickerTestFactory +import android.tools.device.flicker.legacy.LegacyFlickerTest +import android.tools.device.flicker.legacy.LegacyFlickerTestFactory import org.junit.FixMethodOrder import org.junit.Test import org.junit.runner.RunWith @@ -31,7 +31,8 @@ import org.junit.runners.Parameterized @RunWith(Parameterized::class) @Parameterized.UseParametersRunnerFactory(FlickerParametersRunnerFactory::class) @FixMethodOrder(MethodSorters.NAME_ASCENDING) -class OpenAppColdTestCfArm(flicker: FlickerTest) : OpenAppColdTest(flicker) { +class OpenAppFromIntentColdTestCfArm(flicker: LegacyFlickerTest) : + OpenAppFromIntentColdTest(flicker) { @FlakyTest(bugId = 273696733) @Test override fun appLayerReplacesLauncher() = super.appLayerReplacesLauncher() @@ -40,13 +41,11 @@ class OpenAppColdTestCfArm(flicker: FlickerTest) : OpenAppColdTest(flicker) { /** * Creates the test configurations. * - * See [FlickerTestFactory.nonRotationTests] for configuring screen orientation and + * See [LegacyFlickerTestFactory.nonRotationTests] for configuring screen orientation and * navigation modes. */ @Parameterized.Parameters(name = "{0}") @JvmStatic - fun getParams(): Collection<FlickerTest> { - return FlickerTestFactory.nonRotationTests() - } + fun getParams() = LegacyFlickerTestFactory.nonRotationTests() } } diff --git a/tests/FlickerTests/src/com/android/server/wm/flicker/launch/OpenAppWarmTest.kt b/tests/FlickerTests/src/com/android/server/wm/flicker/launch/OpenAppFromIntentWarmTest.kt index 3385830ee77f..d2c38076e72d 100644 --- a/tests/FlickerTests/src/com/android/server/wm/flicker/launch/OpenAppWarmTest.kt +++ b/tests/FlickerTests/src/com/android/server/wm/flicker/launch/OpenAppFromIntentWarmTest.kt @@ -18,11 +18,11 @@ package com.android.server.wm.flicker.launch import android.platform.test.annotations.FlakyTest import android.platform.test.annotations.Presubmit -import android.tools.device.flicker.annotation.FlickerServiceCompatible +import android.tools.common.flicker.annotation.FlickerServiceCompatible import android.tools.device.flicker.junit.FlickerParametersRunnerFactory import android.tools.device.flicker.legacy.FlickerBuilder -import android.tools.device.flicker.legacy.FlickerTest -import android.tools.device.flicker.legacy.FlickerTestFactory +import android.tools.device.flicker.legacy.LegacyFlickerTest +import android.tools.device.flicker.legacy.LegacyFlickerTestFactory import androidx.test.filters.RequiresDevice import com.android.server.wm.flicker.helpers.setRotation import org.junit.FixMethodOrder @@ -58,7 +58,8 @@ import org.junit.runners.Parameterized @RunWith(Parameterized::class) @Parameterized.UseParametersRunnerFactory(FlickerParametersRunnerFactory::class) @FixMethodOrder(MethodSorters.NAME_ASCENDING) -open class OpenAppWarmTest(flicker: FlickerTest) : OpenAppFromLauncherTransition(flicker) { +open class OpenAppFromIntentWarmTest(flicker: LegacyFlickerTest) : + OpenAppFromLauncherTransition(flicker) { /** Defines the transition used to run the test */ override val transition: FlickerBuilder.() -> Unit get() = { @@ -93,13 +94,11 @@ open class OpenAppWarmTest(flicker: FlickerTest) : OpenAppFromLauncherTransition /** * Creates the test configurations. * - * See [FlickerTestFactory.nonRotationTests] for configuring screen orientation and + * See [LegacyFlickerTestFactory.nonRotationTests] for configuring screen orientation and * navigation modes. */ @Parameterized.Parameters(name = "{0}") @JvmStatic - fun getParams(): Collection<FlickerTest> { - return FlickerTestFactory.nonRotationTests() - } + fun getParams() = LegacyFlickerTestFactory.nonRotationTests() } } diff --git a/tests/FlickerTests/src/com/android/server/wm/flicker/launch/OpenAppWarmTestCfArm.kt b/tests/FlickerTests/src/com/android/server/wm/flicker/launch/OpenAppFromIntentWarmTestCfArm.kt index d8b38b30cf13..3e0958a27aaf 100644 --- a/tests/FlickerTests/src/com/android/server/wm/flicker/launch/OpenAppWarmTestCfArm.kt +++ b/tests/FlickerTests/src/com/android/server/wm/flicker/launch/OpenAppFromIntentWarmTestCfArm.kt @@ -16,10 +16,10 @@ package com.android.server.wm.flicker.launch -import android.tools.device.flicker.annotation.FlickerServiceCompatible +import android.tools.common.flicker.annotation.FlickerServiceCompatible import android.tools.device.flicker.junit.FlickerParametersRunnerFactory -import android.tools.device.flicker.legacy.FlickerTest -import android.tools.device.flicker.legacy.FlickerTestFactory +import android.tools.device.flicker.legacy.LegacyFlickerTest +import android.tools.device.flicker.legacy.LegacyFlickerTestFactory import org.junit.FixMethodOrder import org.junit.runner.RunWith import org.junit.runners.MethodSorters @@ -29,18 +29,17 @@ import org.junit.runners.Parameterized @RunWith(Parameterized::class) @Parameterized.UseParametersRunnerFactory(FlickerParametersRunnerFactory::class) @FixMethodOrder(MethodSorters.NAME_ASCENDING) -class OpenAppWarmTestCfArm(flicker: FlickerTest) : OpenAppWarmTest(flicker) { +class OpenAppFromIntentWarmTestCfArm(flicker: LegacyFlickerTest) : + OpenAppFromIntentWarmTest(flicker) { companion object { /** * Creates the test configurations. * - * See [FlickerTestFactory.nonRotationTests] for configuring screen orientation and + * See [LegacyFlickerTestFactory.nonRotationTests] for configuring screen orientation and * navigation modes. */ @Parameterized.Parameters(name = "{0}") @JvmStatic - fun getParams(): Collection<FlickerTest> { - return FlickerTestFactory.nonRotationTests() - } + fun getParams() = LegacyFlickerTestFactory.nonRotationTests() } } diff --git a/tests/FlickerTests/src/com/android/server/wm/flicker/launch/OpenAppFromLauncherTransition.kt b/tests/FlickerTests/src/com/android/server/wm/flicker/launch/OpenAppFromLauncherTransition.kt index 3d5a8e309b10..62fb5704b2e8 100644 --- a/tests/FlickerTests/src/com/android/server/wm/flicker/launch/OpenAppFromLauncherTransition.kt +++ b/tests/FlickerTests/src/com/android/server/wm/flicker/launch/OpenAppFromLauncherTransition.kt @@ -18,12 +18,13 @@ package com.android.server.wm.flicker.launch import android.platform.test.annotations.Presubmit import android.tools.common.traces.component.ComponentNameMatcher -import android.tools.device.flicker.legacy.FlickerTest +import android.tools.device.flicker.legacy.LegacyFlickerTest import com.android.server.wm.flicker.replacesLayer import org.junit.Test /** Base class for app launch tests */ -abstract class OpenAppFromLauncherTransition(flicker: FlickerTest) : OpenAppTransition(flicker) { +abstract class OpenAppFromLauncherTransition(flicker: LegacyFlickerTest) : + OpenAppTransition(flicker) { /** Checks that the focus changes from the [ComponentNameMatcher.LAUNCHER] to [testApp] */ @Presubmit diff --git a/tests/FlickerTests/src/com/android/server/wm/flicker/launch/OpenAppFromLockTransition.kt b/tests/FlickerTests/src/com/android/server/wm/flicker/launch/OpenAppFromLockscreenTransition.kt index eae9ca10c711..687bc1958a5a 100644 --- a/tests/FlickerTests/src/com/android/server/wm/flicker/launch/OpenAppFromLockTransition.kt +++ b/tests/FlickerTests/src/com/android/server/wm/flicker/launch/OpenAppFromLockscreenTransition.kt @@ -20,7 +20,7 @@ import android.platform.test.annotations.FlakyTest import android.platform.test.annotations.Presubmit import android.tools.common.traces.component.ComponentNameMatcher import android.tools.device.flicker.legacy.FlickerBuilder -import android.tools.device.flicker.legacy.FlickerTest +import android.tools.device.flicker.legacy.LegacyFlickerTest import com.android.server.wm.flicker.navBarLayerPositionAtEnd import com.android.server.wm.flicker.statusBarLayerPositionAtEnd import org.junit.Assume @@ -28,7 +28,8 @@ import org.junit.Ignore import org.junit.Test /** Base class for app launch tests from lock screen */ -abstract class OpenAppFromLockTransition(flicker: FlickerTest) : OpenAppTransition(flicker) { +abstract class OpenAppFromLockscreenTransition(flicker: LegacyFlickerTest) : + OpenAppTransition(flicker) { /** Defines the transition used to run the test */ override val transition: FlickerBuilder.() -> Unit = { diff --git a/tests/FlickerTests/src/com/android/server/wm/flicker/launch/OpenAppNonResizeableTest.kt b/tests/FlickerTests/src/com/android/server/wm/flicker/launch/OpenAppFromLockscreenViaIntentTest.kt index 1383ae39f760..7a16060e3370 100644 --- a/tests/FlickerTests/src/com/android/server/wm/flicker/launch/OpenAppNonResizeableTest.kt +++ b/tests/FlickerTests/src/com/android/server/wm/flicker/launch/OpenAppFromLockscreenViaIntentTest.kt @@ -20,11 +20,11 @@ import android.platform.test.annotations.FlakyTest import android.platform.test.annotations.Presubmit import android.tools.common.NavBar import android.tools.common.Rotation +import android.tools.common.flicker.annotation.FlickerServiceCompatible import android.tools.common.traces.component.ComponentNameMatcher -import android.tools.device.flicker.annotation.FlickerServiceCompatible import android.tools.device.flicker.junit.FlickerParametersRunnerFactory -import android.tools.device.flicker.legacy.FlickerTest -import android.tools.device.flicker.legacy.FlickerTestFactory +import android.tools.device.flicker.legacy.LegacyFlickerTest +import android.tools.device.flicker.legacy.LegacyFlickerTestFactory import androidx.test.filters.RequiresDevice import com.android.server.wm.flicker.helpers.NonResizeableAppHelper import org.junit.Assume @@ -63,7 +63,8 @@ import org.junit.runners.Parameterized @RunWith(Parameterized::class) @Parameterized.UseParametersRunnerFactory(FlickerParametersRunnerFactory::class) @FixMethodOrder(MethodSorters.NAME_ASCENDING) -open class OpenAppNonResizeableTest(flicker: FlickerTest) : OpenAppFromLockTransition(flicker) { +open class OpenAppFromLockscreenViaIntentTest(flicker: LegacyFlickerTest) : + OpenAppFromLockscreenTransition(flicker) { override val testApp = NonResizeableAppHelper(instrumentation) /** @@ -209,16 +210,15 @@ open class OpenAppNonResizeableTest(flicker: FlickerTest) : OpenAppFromLockTrans /** * Creates the test configurations. * - * See [FlickerTestFactory.nonRotationTests] for configuring screen orientation and + * See [LegacyFlickerTestFactory.nonRotationTests] for configuring screen orientation and * navigation modes. */ @Parameterized.Parameters(name = "{0}") @JvmStatic - fun getParams(): Collection<FlickerTest> { - return FlickerTestFactory.nonRotationTests( + fun getParams() = + LegacyFlickerTestFactory.nonRotationTests( supportedNavigationModes = listOf(NavBar.MODE_GESTURAL), supportedRotations = listOf(Rotation.ROTATION_0) ) - } } } diff --git a/tests/FlickerTests/src/com/android/server/wm/flicker/launch/OpenAppFromOverviewTest.kt b/tests/FlickerTests/src/com/android/server/wm/flicker/launch/OpenAppFromOverviewTest.kt index 8e1b059b2bc7..eec6bfde8b9f 100644 --- a/tests/FlickerTests/src/com/android/server/wm/flicker/launch/OpenAppFromOverviewTest.kt +++ b/tests/FlickerTests/src/com/android/server/wm/flicker/launch/OpenAppFromOverviewTest.kt @@ -19,11 +19,11 @@ package com.android.server.wm.flicker.launch import android.platform.test.annotations.FlakyTest import android.platform.test.annotations.Presubmit import android.tools.common.Rotation -import android.tools.device.flicker.annotation.FlickerServiceCompatible +import android.tools.common.flicker.annotation.FlickerServiceCompatible import android.tools.device.flicker.junit.FlickerParametersRunnerFactory import android.tools.device.flicker.legacy.FlickerBuilder -import android.tools.device.flicker.legacy.FlickerTest -import android.tools.device.flicker.legacy.FlickerTestFactory +import android.tools.device.flicker.legacy.LegacyFlickerTest +import android.tools.device.flicker.legacy.LegacyFlickerTestFactory import androidx.test.filters.RequiresDevice import com.android.server.wm.flicker.helpers.setRotation import org.junit.FixMethodOrder @@ -60,7 +60,8 @@ import org.junit.runners.Parameterized @RunWith(Parameterized::class) @Parameterized.UseParametersRunnerFactory(FlickerParametersRunnerFactory::class) @FixMethodOrder(MethodSorters.NAME_ASCENDING) -open class OpenAppFromOverviewTest(flicker: FlickerTest) : OpenAppFromLauncherTransition(flicker) { +open class OpenAppFromOverviewTest(flicker: LegacyFlickerTest) : + OpenAppFromLauncherTransition(flicker) { /** Defines the transition used to run the test */ override val transition: FlickerBuilder.() -> Unit @@ -106,13 +107,11 @@ open class OpenAppFromOverviewTest(flicker: FlickerTest) : OpenAppFromLauncherTr /** * Creates the test configurations. * - * See [FlickerTestFactory.nonRotationTests] for configuring screen orientation and + * See [LegacyFlickerTestFactory.nonRotationTests] for configuring screen orientation and * navigation modes. */ @Parameterized.Parameters(name = "{0}") @JvmStatic - fun getParams(): Collection<FlickerTest> { - return FlickerTestFactory.nonRotationTests() - } + fun getParams() = LegacyFlickerTestFactory.nonRotationTests() } } diff --git a/tests/FlickerTests/src/com/android/server/wm/flicker/launch/OpenAppFromOverviewTestCfArm.kt b/tests/FlickerTests/src/com/android/server/wm/flicker/launch/OpenAppFromOverviewTestCfArm.kt index ff24190a7aef..ab6a1ea36222 100644 --- a/tests/FlickerTests/src/com/android/server/wm/flicker/launch/OpenAppFromOverviewTestCfArm.kt +++ b/tests/FlickerTests/src/com/android/server/wm/flicker/launch/OpenAppFromOverviewTestCfArm.kt @@ -16,10 +16,10 @@ package com.android.server.wm.flicker.launch -import android.tools.device.flicker.annotation.FlickerServiceCompatible +import android.tools.common.flicker.annotation.FlickerServiceCompatible import android.tools.device.flicker.junit.FlickerParametersRunnerFactory -import android.tools.device.flicker.legacy.FlickerTest -import android.tools.device.flicker.legacy.FlickerTestFactory +import android.tools.device.flicker.legacy.LegacyFlickerTest +import android.tools.device.flicker.legacy.LegacyFlickerTestFactory import org.junit.FixMethodOrder import org.junit.runner.RunWith import org.junit.runners.MethodSorters @@ -30,18 +30,17 @@ import org.junit.runners.Parameterized @RunWith(Parameterized::class) @Parameterized.UseParametersRunnerFactory(FlickerParametersRunnerFactory::class) @FixMethodOrder(MethodSorters.NAME_ASCENDING) -open class OpenAppFromOverviewTestCfArm(flicker: FlickerTest) : OpenAppFromOverviewTest(flicker) { +open class OpenAppFromOverviewTestCfArm(flicker: LegacyFlickerTest) : + OpenAppFromOverviewTest(flicker) { companion object { /** * Creates the test configurations. * - * See [FlickerTestFactory.nonRotationTests] for configuring screen orientation and + * See [LegacyFlickerTestFactory.nonRotationTests] for configuring screen orientation and * navigation modes. */ @Parameterized.Parameters(name = "{0}") @JvmStatic - fun getParams(): Collection<FlickerTest> { - return FlickerTestFactory.nonRotationTests() - } + fun getParams() = LegacyFlickerTestFactory.nonRotationTests() } } diff --git a/tests/FlickerTests/src/com/android/server/wm/flicker/launch/OpenAppTransition.kt b/tests/FlickerTests/src/com/android/server/wm/flicker/launch/OpenAppTransition.kt index 87a14c69e3ac..bb11be5bb520 100644 --- a/tests/FlickerTests/src/com/android/server/wm/flicker/launch/OpenAppTransition.kt +++ b/tests/FlickerTests/src/com/android/server/wm/flicker/launch/OpenAppTransition.kt @@ -20,7 +20,7 @@ import android.platform.test.annotations.Presubmit import android.tools.common.traces.component.ComponentNameMatcher import android.tools.device.apphelpers.StandardAppHelper import android.tools.device.flicker.legacy.FlickerBuilder -import android.tools.device.flicker.legacy.FlickerTest +import android.tools.device.flicker.legacy.LegacyFlickerTest import android.tools.device.helpers.wakeUpAndGoToHomeScreen import com.android.server.wm.flicker.BaseTest import com.android.server.wm.flicker.helpers.SimpleAppHelper @@ -28,7 +28,7 @@ import com.android.server.wm.flicker.helpers.setRotation import org.junit.Test /** Base class for app launch tests */ -abstract class OpenAppTransition(flicker: FlickerTest) : BaseTest(flicker) { +abstract class OpenAppTransition(flicker: LegacyFlickerTest) : BaseTest(flicker) { protected open val testApp: StandardAppHelper = SimpleAppHelper(instrumentation) /** {@inheritDoc} */ diff --git a/tests/FlickerTests/src/com/android/server/wm/flicker/launch/OpenCameraOnDoubleClickPowerButton.kt b/tests/FlickerTests/src/com/android/server/wm/flicker/launch/OpenCameraFromHomeOnDoubleClickPowerButtonTest.kt index ae9ca8007dc8..1bdb6e717b12 100644 --- a/tests/FlickerTests/src/com/android/server/wm/flicker/launch/OpenCameraOnDoubleClickPowerButton.kt +++ b/tests/FlickerTests/src/com/android/server/wm/flicker/launch/OpenCameraFromHomeOnDoubleClickPowerButtonTest.kt @@ -18,12 +18,14 @@ package com.android.server.wm.flicker.launch import android.os.SystemClock import android.platform.test.annotations.Postsubmit +import android.tools.common.flicker.subject.layers.LayersTraceSubject +import android.tools.common.traces.component.ComponentNameMatcher import android.tools.device.apphelpers.CameraAppHelper import android.tools.device.apphelpers.StandardAppHelper import android.tools.device.flicker.junit.FlickerParametersRunnerFactory import android.tools.device.flicker.legacy.FlickerBuilder -import android.tools.device.flicker.legacy.FlickerTest -import android.tools.device.flicker.legacy.FlickerTestFactory +import android.tools.device.flicker.legacy.LegacyFlickerTest +import android.tools.device.flicker.legacy.LegacyFlickerTestFactory import android.tools.device.flicker.rules.RemoveAllTasksButHomeRule import android.view.KeyEvent import androidx.test.filters.RequiresDevice @@ -60,7 +62,7 @@ import org.junit.runners.Parameterized @RunWith(Parameterized::class) @Parameterized.UseParametersRunnerFactory(FlickerParametersRunnerFactory::class) @FixMethodOrder(MethodSorters.NAME_ASCENDING) -class OpenCameraOnDoubleClickPowerButton(flicker: FlickerTest) : +class OpenCameraFromHomeOnDoubleClickPowerButtonTest(flicker: LegacyFlickerTest) : OpenAppFromLauncherTransition(flicker) { private val cameraApp = CameraAppHelper(instrumentation) override val testApp: StandardAppHelper @@ -137,8 +139,14 @@ class OpenCameraOnDoubleClickPowerButton(flicker: FlickerTest) : @Postsubmit @Test - override fun visibleLayersShownMoreThanOneConsecutiveEntry() = - super.visibleLayersShownMoreThanOneConsecutiveEntry() + override fun visibleLayersShownMoreThanOneConsecutiveEntry() { + flicker.assertLayers { + this.visibleLayersShownMoreThanOneConsecutiveEntry( + LayersTraceSubject.VISIBLE_FOR_MORE_THAN_ONE_ENTRY_IGNORE_LAYERS + + listOf(CAMERA_BACKGROUND) + ) + } + } @Postsubmit @Test @@ -155,13 +163,18 @@ class OpenCameraOnDoubleClickPowerButton(flicker: FlickerTest) : /** * Creates the test configurations. * - * See [FlickerTestFactory.nonRotationTests] for configuring screen orientation and + * See [LegacyFlickerTestFactory.nonRotationTests] for configuring screen orientation and * navigation modes. */ @Parameterized.Parameters(name = "{0}") @JvmStatic - fun getParams(): Collection<FlickerTest> { - return FlickerTestFactory.nonRotationTests() - } + fun getParams() = LegacyFlickerTestFactory.nonRotationTests() + + private val CAMERA_BACKGROUND = + ComponentNameMatcher( + "Background for SurfaceView" + + "[com.google.android.GoogleCamera/" + + "com.google.android.apps.camera.legacy.app.activity.main.CameraActivity]" + ) } } diff --git a/tests/FlickerTests/src/com/android/server/wm/flicker/launch/OverrideTaskTransitionTest.kt b/tests/FlickerTests/src/com/android/server/wm/flicker/launch/OverrideTaskTransitionTest.kt index b48611edd738..98e3646f4083 100644 --- a/tests/FlickerTests/src/com/android/server/wm/flicker/launch/OverrideTaskTransitionTest.kt +++ b/tests/FlickerTests/src/com/android/server/wm/flicker/launch/OverrideTaskTransitionTest.kt @@ -25,8 +25,8 @@ import android.tools.common.traces.component.ComponentNameMatcher import android.tools.device.flicker.junit.FlickerBuilderProvider import android.tools.device.flicker.junit.FlickerParametersRunnerFactory import android.tools.device.flicker.legacy.FlickerBuilder -import android.tools.device.flicker.legacy.FlickerTest -import android.tools.device.flicker.legacy.FlickerTestFactory +import android.tools.device.flicker.legacy.LegacyFlickerTest +import android.tools.device.flicker.legacy.LegacyFlickerTestFactory import android.tools.device.flicker.rules.RemoveAllTasksButHomeRule import android.tools.device.helpers.wakeUpAndGoToHomeScreen import androidx.test.filters.RequiresDevice @@ -54,7 +54,7 @@ import org.junit.runners.Parameterized @RunWith(Parameterized::class) @Parameterized.UseParametersRunnerFactory(FlickerParametersRunnerFactory::class) @FixMethodOrder(MethodSorters.NAME_ASCENDING) -class OverrideTaskTransitionTest(val flicker: FlickerTest) { +class OverrideTaskTransitionTest(val flicker: LegacyFlickerTest) { private val instrumentation: Instrumentation = InstrumentationRegistry.getInstrumentation() private val testApp = SimpleAppHelper(instrumentation) @@ -121,8 +121,6 @@ class OverrideTaskTransitionTest(val flicker: FlickerTest) { companion object { @Parameterized.Parameters(name = "{0}") @JvmStatic - fun getParams(): Collection<FlickerTest> { - return FlickerTestFactory.nonRotationTests() - } + fun getParams() = LegacyFlickerTestFactory.nonRotationTests() } } diff --git a/tests/FlickerTests/src/com/android/server/wm/flicker/launch/TaskTransitionTest.kt b/tests/FlickerTests/src/com/android/server/wm/flicker/launch/TaskTransitionTest.kt index d0fd73207c42..39c8ca089dbd 100644 --- a/tests/FlickerTests/src/com/android/server/wm/flicker/launch/TaskTransitionTest.kt +++ b/tests/FlickerTests/src/com/android/server/wm/flicker/launch/TaskTransitionTest.kt @@ -28,8 +28,8 @@ import android.tools.common.traces.component.ComponentSplashScreenMatcher import android.tools.common.traces.component.IComponentMatcher import android.tools.device.flicker.junit.FlickerParametersRunnerFactory import android.tools.device.flicker.legacy.FlickerBuilder -import android.tools.device.flicker.legacy.FlickerTest -import android.tools.device.flicker.legacy.FlickerTestFactory +import android.tools.device.flicker.legacy.LegacyFlickerTest +import android.tools.device.flicker.legacy.LegacyFlickerTestFactory import android.tools.device.helpers.WindowUtils import android.tools.device.traces.parsers.toFlickerComponent import androidx.test.filters.RequiresDevice @@ -58,7 +58,7 @@ import org.junit.runners.Parameterized @RunWith(Parameterized::class) @Parameterized.UseParametersRunnerFactory(FlickerParametersRunnerFactory::class) @FixMethodOrder(MethodSorters.NAME_ASCENDING) -class TaskTransitionTest(flicker: FlickerTest) : BaseTest(flicker) { +class TaskTransitionTest(flicker: LegacyFlickerTest) : BaseTest(flicker) { private val launchNewTaskApp = NewTasksAppHelper(instrumentation) private val simpleApp = SimpleAppHelper(instrumentation) private val wallpaper by lazy { getWallpaperPackage(instrumentation) } @@ -214,8 +214,6 @@ class TaskTransitionTest(flicker: FlickerTest) : BaseTest(flicker) { @Parameterized.Parameters(name = "{0}") @JvmStatic - fun getParams(): Collection<FlickerTest> { - return FlickerTestFactory.nonRotationTests() - } + fun getParams() = LegacyFlickerTestFactory.nonRotationTests() } } diff --git a/tests/FlickerTests/src/com/android/server/wm/flicker/launch/OpenAppFromLockNotificationCold.kt b/tests/FlickerTests/src/com/android/server/wm/flicker/notification/OpenAppFromLockscreenNotificationColdTest.kt index b21777b30b21..6f5daeb22bed 100644 --- a/tests/FlickerTests/src/com/android/server/wm/flicker/launch/OpenAppFromLockNotificationCold.kt +++ b/tests/FlickerTests/src/com/android/server/wm/flicker/notification/OpenAppFromLockscreenNotificationColdTest.kt @@ -1,5 +1,5 @@ /* - * Copyright (C) 2022 The Android Open Source Project + * Copyright (C) 2023 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,15 +14,15 @@ * limitations under the License. */ -package com.android.server.wm.flicker.launch +package com.android.server.wm.flicker.notification import android.platform.test.annotations.Postsubmit import android.platform.test.rule.SettingOverrideRule import android.provider.Settings import android.tools.device.flicker.junit.FlickerParametersRunnerFactory import android.tools.device.flicker.legacy.FlickerBuilder -import android.tools.device.flicker.legacy.FlickerTest -import android.tools.device.flicker.legacy.FlickerTestFactory +import android.tools.device.flicker.legacy.LegacyFlickerTest +import android.tools.device.flicker.legacy.LegacyFlickerTestFactory import androidx.test.filters.RequiresDevice import org.junit.ClassRule import org.junit.FixMethodOrder @@ -44,8 +44,8 @@ import org.junit.runners.Parameterized @Parameterized.UseParametersRunnerFactory(FlickerParametersRunnerFactory::class) @FixMethodOrder(MethodSorters.NAME_ASCENDING) @Postsubmit -open class OpenAppFromLockNotificationCold(flicker: FlickerTest) : - OpenAppFromNotificationCold(flicker) { +open class OpenAppFromLockscreenNotificationColdTest(flicker: LegacyFlickerTest) : + OpenAppFromNotificationColdTest(flicker) { override val openingNotificationsFromLockScreen = true @@ -111,14 +111,12 @@ open class OpenAppFromLockNotificationCold(flicker: FlickerTest) : /** * Creates the test configurations. * - * See [FlickerTestFactory.nonRotationTests] for configuring screen orientation and + * See [LegacyFlickerTestFactory.nonRotationTests] for configuring screen orientation and * navigation modes. */ @Parameterized.Parameters(name = "{0}") @JvmStatic - fun getParams(): Collection<FlickerTest> { - return FlickerTestFactory.nonRotationTests() - } + fun getParams() = LegacyFlickerTestFactory.nonRotationTests() /** * Ensures that posted notifications will be visible on the lockscreen and not suppressed diff --git a/tests/FlickerTests/src/com/android/server/wm/flicker/launch/OpenAppFromLockNotificationWarm.kt b/tests/FlickerTests/src/com/android/server/wm/flicker/notification/OpenAppFromLockscreenNotificationWarmTest.kt index ec92ca65f80a..483caa71abee 100644 --- a/tests/FlickerTests/src/com/android/server/wm/flicker/launch/OpenAppFromLockNotificationWarm.kt +++ b/tests/FlickerTests/src/com/android/server/wm/flicker/notification/OpenAppFromLockscreenNotificationWarmTest.kt @@ -1,5 +1,5 @@ /* - * Copyright (C) 2022 The Android Open Source Project + * Copyright (C) 2023 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,7 +14,7 @@ * limitations under the License. */ -package com.android.server.wm.flicker.launch +package com.android.server.wm.flicker.notification import android.platform.test.annotations.FlakyTest import android.platform.test.annotations.Presubmit @@ -23,8 +23,8 @@ import android.provider.Settings import android.tools.common.traces.component.ComponentNameMatcher import android.tools.device.flicker.junit.FlickerParametersRunnerFactory import android.tools.device.flicker.legacy.FlickerBuilder -import android.tools.device.flicker.legacy.FlickerTest -import android.tools.device.flicker.legacy.FlickerTestFactory +import android.tools.device.flicker.legacy.LegacyFlickerTest +import android.tools.device.flicker.legacy.LegacyFlickerTestFactory import androidx.test.filters.RequiresDevice import com.android.server.wm.flicker.statusBarLayerPositionAtEnd import org.junit.ClassRule @@ -46,7 +46,8 @@ import org.junit.runners.Parameterized @RunWith(Parameterized::class) @Parameterized.UseParametersRunnerFactory(FlickerParametersRunnerFactory::class) @FixMethodOrder(MethodSorters.NAME_ASCENDING) -class OpenAppFromLockNotificationWarm(flicker: FlickerTest) : OpenAppFromNotificationWarm(flicker) { +class OpenAppFromLockscreenNotificationWarmTest(flicker: LegacyFlickerTest) : + OpenAppFromNotificationWarmTest(flicker) { override val openingNotificationsFromLockScreen = true @@ -142,14 +143,12 @@ class OpenAppFromLockNotificationWarm(flicker: FlickerTest) : OpenAppFromNotific /** * Creates the test configurations. * - * See [FlickerTestFactory.nonRotationTests] for configuring screen orientation and + * See [LegacyFlickerTestFactory.nonRotationTests] for configuring screen orientation and * navigation modes. */ @Parameterized.Parameters(name = "{0}") @JvmStatic - fun getParams(): Collection<FlickerTest> { - return FlickerTestFactory.nonRotationTests() - } + fun getParams() = LegacyFlickerTestFactory.nonRotationTests() /** * Ensures that posted notifications will be visible on the lockscreen and not suppressed diff --git a/tests/FlickerTests/src/com/android/server/wm/flicker/launch/OpenAppFromLockNotificationWithLockOverlayApp.kt b/tests/FlickerTests/src/com/android/server/wm/flicker/notification/OpenAppFromLockscreenNotificationWithOverlayAppTest.kt index 009d61797fe0..4e8a697d8902 100644 --- a/tests/FlickerTests/src/com/android/server/wm/flicker/launch/OpenAppFromLockNotificationWithLockOverlayApp.kt +++ b/tests/FlickerTests/src/com/android/server/wm/flicker/notification/OpenAppFromLockscreenNotificationWithOverlayAppTest.kt @@ -1,5 +1,5 @@ /* - * Copyright (C) 2022 The Android Open Source Project + * Copyright (C) 2023 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,7 +14,7 @@ * limitations under the License. */ -package com.android.server.wm.flicker.launch +package com.android.server.wm.flicker.notification import android.platform.test.annotations.FlakyTest import android.platform.test.annotations.Postsubmit @@ -22,12 +22,13 @@ import android.platform.test.annotations.Presubmit import android.tools.common.traces.component.ComponentNameMatcher import android.tools.device.flicker.junit.FlickerParametersRunnerFactory import android.tools.device.flicker.legacy.FlickerBuilder -import android.tools.device.flicker.legacy.FlickerTest -import android.tools.device.flicker.legacy.FlickerTestFactory +import android.tools.device.flicker.legacy.LegacyFlickerTest +import android.tools.device.flicker.legacy.LegacyFlickerTestFactory import android.tools.device.helpers.wakeUpAndGoToHomeScreen import androidx.test.filters.RequiresDevice import com.android.server.wm.flicker.helpers.ShowWhenLockedAppHelper import org.junit.FixMethodOrder +import org.junit.Ignore import org.junit.Test import org.junit.runner.RunWith import org.junit.runners.MethodSorters @@ -37,6 +38,8 @@ import org.junit.runners.Parameterized * Test cold launching an app from a notification from the lock screen when there is an app overlaid * on the lock screen. * + * This test assumes the device doesn't have AOD enabled + * * To run this test: `atest FlickerTests:OpenAppFromLockNotificationWithLockOverlayApp` */ @RequiresDevice @@ -44,8 +47,8 @@ import org.junit.runners.Parameterized @Parameterized.UseParametersRunnerFactory(FlickerParametersRunnerFactory::class) @FixMethodOrder(MethodSorters.NAME_ASCENDING) @Postsubmit -class OpenAppFromLockNotificationWithLockOverlayApp(flicker: FlickerTest) : - OpenAppFromLockNotificationCold(flicker) { +class OpenAppFromLockscreenNotificationWithOverlayAppTest(flicker: LegacyFlickerTest) : + OpenAppFromLockscreenNotificationColdTest(flicker) { private val showWhenLockedApp = ShowWhenLockedAppHelper(instrumentation) // Although we are technically still locked here, the overlay app means we should open the @@ -104,9 +107,9 @@ class OpenAppFromLockNotificationWithLockOverlayApp(flicker: FlickerTest) : super.visibleLayersShownMoreThanOneConsecutiveEntry() /** {@inheritDoc} */ - @FlakyTest(bugId = 209599395) @Test - override fun navBarLayerIsVisibleAtStartAndEnd() = super.navBarLayerIsVisibleAtStartAndEnd() + @Ignore("Not applicable to this CUJ. Display starts off and app is full screen at the end") + override fun navBarLayerIsVisibleAtStartAndEnd() {} /** {@inheritDoc} */ @Presubmit @@ -124,13 +127,11 @@ class OpenAppFromLockNotificationWithLockOverlayApp(flicker: FlickerTest) : /** * Creates the test configurations. * - * See [FlickerTestFactory.nonRotationTests] for configuring screen orientation and + * See [LegacyFlickerTestFactory.nonRotationTests] for configuring screen orientation and * navigation modes. */ @Parameterized.Parameters(name = "{0}") @JvmStatic - fun getParams(): Collection<FlickerTest> { - return FlickerTestFactory.nonRotationTests() - } + fun getParams() = LegacyFlickerTestFactory.nonRotationTests() } } diff --git a/tests/FlickerTests/src/com/android/server/wm/flicker/launch/OpenAppFromNotificationCold.kt b/tests/FlickerTests/src/com/android/server/wm/flicker/notification/OpenAppFromNotificationColdTest.kt index 7bcb91070ecf..50dec3bf2f02 100644 --- a/tests/FlickerTests/src/com/android/server/wm/flicker/launch/OpenAppFromNotificationCold.kt +++ b/tests/FlickerTests/src/com/android/server/wm/flicker/notification/OpenAppFromNotificationColdTest.kt @@ -1,5 +1,5 @@ /* - * Copyright (C) 2022 The Android Open Source Project + * Copyright (C) 2023 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,15 +14,15 @@ * limitations under the License. */ -package com.android.server.wm.flicker.launch +package com.android.server.wm.flicker.notification import android.platform.test.annotations.Postsubmit import android.platform.test.annotations.Presubmit import android.tools.common.traces.component.ComponentNameMatcher import android.tools.device.flicker.junit.FlickerParametersRunnerFactory import android.tools.device.flicker.legacy.FlickerBuilder -import android.tools.device.flicker.legacy.FlickerTest -import android.tools.device.flicker.legacy.FlickerTestFactory +import android.tools.device.flicker.legacy.LegacyFlickerTest +import android.tools.device.flicker.legacy.LegacyFlickerTestFactory import androidx.test.filters.RequiresDevice import com.android.server.wm.flicker.statusBarLayerPositionAtEnd import org.junit.FixMethodOrder @@ -35,8 +35,6 @@ import org.junit.runners.Parameterized /** * Test cold launching an app from a notification. * - * This test assumes the device doesn't have AOD enabled - * * To run this test: `atest FlickerTests:OpenAppFromNotificationCold` */ @RequiresDevice @@ -44,8 +42,8 @@ import org.junit.runners.Parameterized @Parameterized.UseParametersRunnerFactory(FlickerParametersRunnerFactory::class) @FixMethodOrder(MethodSorters.NAME_ASCENDING) @Postsubmit -open class OpenAppFromNotificationCold(flicker: FlickerTest) : - OpenAppFromNotificationWarm(flicker) { +open class OpenAppFromNotificationColdTest(flicker: LegacyFlickerTest) : + OpenAppFromNotificationWarmTest(flicker) { /** {@inheritDoc} */ override val transition: FlickerBuilder.() -> Unit get() = { @@ -101,13 +99,11 @@ open class OpenAppFromNotificationCold(flicker: FlickerTest) : /** * Creates the test configurations. * - * See [FlickerTestFactory.nonRotationTests] for configuring screen orientation and + * See [LegacyFlickerTestFactory.nonRotationTests] for configuring screen orientation and * navigation modes. */ @Parameterized.Parameters(name = "{0}") @JvmStatic - fun getParams(): Collection<FlickerTest> { - return FlickerTestFactory.nonRotationTests() - } + fun getParams() = LegacyFlickerTestFactory.nonRotationTests() } } diff --git a/tests/FlickerTests/src/com/android/server/wm/flicker/launch/OpenAppFromNotificationColdCfArm.kt b/tests/FlickerTests/src/com/android/server/wm/flicker/notification/OpenAppFromNotificationColdTestCfArm.kt index 8b4a613305c0..a147171ed936 100644 --- a/tests/FlickerTests/src/com/android/server/wm/flicker/launch/OpenAppFromNotificationColdCfArm.kt +++ b/tests/FlickerTests/src/com/android/server/wm/flicker/notification/OpenAppFromNotificationColdTestCfArm.kt @@ -14,12 +14,12 @@ * limitations under the License. */ -package com.android.server.wm.flicker.launch +package com.android.server.wm.flicker.notification import android.platform.test.annotations.Postsubmit import android.tools.device.flicker.junit.FlickerParametersRunnerFactory -import android.tools.device.flicker.legacy.FlickerTest -import android.tools.device.flicker.legacy.FlickerTestFactory +import android.tools.device.flicker.legacy.LegacyFlickerTest +import android.tools.device.flicker.legacy.LegacyFlickerTestFactory import org.junit.FixMethodOrder import org.junit.runner.RunWith import org.junit.runners.MethodSorters @@ -29,19 +29,17 @@ import org.junit.runners.Parameterized @Parameterized.UseParametersRunnerFactory(FlickerParametersRunnerFactory::class) @FixMethodOrder(MethodSorters.NAME_ASCENDING) @Postsubmit -class OpenAppFromNotificationColdCfArm(flicker: FlickerTest) : - OpenAppFromNotificationCold(flicker) { +class OpenAppFromNotificationColdTestCfArm(flicker: LegacyFlickerTest) : + OpenAppFromNotificationColdTest(flicker) { companion object { /** * Creates the test configurations. * - * See [FlickerTestFactory.nonRotationTests] for configuring screen orientation and + * See [LegacyFlickerTestFactory.nonRotationTests] for configuring screen orientation and * navigation modes. */ @Parameterized.Parameters(name = "{0}") @JvmStatic - fun getParams(): Collection<FlickerTest> { - return FlickerTestFactory.nonRotationTests() - } + fun getParams() = LegacyFlickerTestFactory.nonRotationTests() } } diff --git a/tests/FlickerTests/src/com/android/server/wm/flicker/launch/OpenAppFromNotificationWarm.kt b/tests/FlickerTests/src/com/android/server/wm/flicker/notification/OpenAppFromNotificationWarmTest.kt index 425e674dec3a..19a070b1a402 100644 --- a/tests/FlickerTests/src/com/android/server/wm/flicker/launch/OpenAppFromNotificationWarm.kt +++ b/tests/FlickerTests/src/com/android/server/wm/flicker/notification/OpenAppFromNotificationWarmTest.kt @@ -1,5 +1,5 @@ /* - * Copyright (C) 2022 The Android Open Source Project + * Copyright (C) 2023 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,15 +14,15 @@ * limitations under the License. */ -package com.android.server.wm.flicker.launch +package com.android.server.wm.flicker.notification import android.platform.test.annotations.Postsubmit import android.platform.test.annotations.Presubmit import android.tools.common.traces.component.ComponentNameMatcher import android.tools.device.flicker.junit.FlickerParametersRunnerFactory import android.tools.device.flicker.legacy.FlickerBuilder -import android.tools.device.flicker.legacy.FlickerTest -import android.tools.device.flicker.legacy.FlickerTestFactory +import android.tools.device.flicker.legacy.LegacyFlickerTest +import android.tools.device.flicker.legacy.LegacyFlickerTestFactory import android.tools.device.helpers.wakeUpAndGoToHomeScreen import android.view.WindowInsets import android.view.WindowManager @@ -47,15 +47,14 @@ import org.junit.runners.Parameterized /** * Test cold launching an app from a notification. * - * This test assumes the device doesn't have AOD enabled - * * To run this test: `atest FlickerTests:OpenAppFromNotificationWarm` */ @RequiresDevice @RunWith(Parameterized::class) @Parameterized.UseParametersRunnerFactory(FlickerParametersRunnerFactory::class) @FixMethodOrder(MethodSorters.NAME_ASCENDING) -open class OpenAppFromNotificationWarm(flicker: FlickerTest) : OpenAppTransition(flicker) { +open class OpenAppFromNotificationWarmTest(flicker: LegacyFlickerTest) : + OpenAppTransition(flicker) { override val testApp: NotificationAppHelper = NotificationAppHelper(instrumentation) open val openingNotificationsFromLockScreen = false @@ -195,13 +194,11 @@ open class OpenAppFromNotificationWarm(flicker: FlickerTest) : OpenAppTransition /** * Creates the test configurations. * - * See [FlickerTestFactory.nonRotationTests] for configuring screen orientation and + * See [LegacyFlickerTestFactory.nonRotationTests] for configuring screen orientation and * navigation modes. */ @Parameterized.Parameters(name = "{0}") @JvmStatic - fun getParams(): Collection<FlickerTest> { - return FlickerTestFactory.nonRotationTests() - } + fun getParams() = LegacyFlickerTestFactory.nonRotationTests() } } diff --git a/tests/FlickerTests/src/com/android/server/wm/flicker/launch/OpenAppFromNotificationWarmCfArm.kt b/tests/FlickerTests/src/com/android/server/wm/flicker/notification/OpenAppFromNotificationWarmTestCfArm.kt index 43d28fa60e51..98356d7d1e87 100644 --- a/tests/FlickerTests/src/com/android/server/wm/flicker/launch/OpenAppFromNotificationWarmCfArm.kt +++ b/tests/FlickerTests/src/com/android/server/wm/flicker/notification/OpenAppFromNotificationWarmTestCfArm.kt @@ -14,11 +14,11 @@ * limitations under the License. */ -package com.android.server.wm.flicker.launch +package com.android.server.wm.flicker.notification import android.tools.device.flicker.junit.FlickerParametersRunnerFactory -import android.tools.device.flicker.legacy.FlickerTest -import android.tools.device.flicker.legacy.FlickerTestFactory +import android.tools.device.flicker.legacy.LegacyFlickerTest +import android.tools.device.flicker.legacy.LegacyFlickerTestFactory import org.junit.FixMethodOrder import org.junit.runner.RunWith import org.junit.runners.MethodSorters @@ -27,19 +27,17 @@ import org.junit.runners.Parameterized @RunWith(Parameterized::class) @Parameterized.UseParametersRunnerFactory(FlickerParametersRunnerFactory::class) @FixMethodOrder(MethodSorters.NAME_ASCENDING) -class OpenAppFromNotificationWarmCfArm(flicker: FlickerTest) : - OpenAppFromNotificationWarm(flicker) { +class OpenAppFromNotificationWarmTestCfArm(flicker: LegacyFlickerTest) : + OpenAppFromNotificationWarmTest(flicker) { companion object { /** * Creates the test configurations. * - * See [FlickerTestFactory.nonRotationTests] for configuring screen orientation and + * See [LegacyFlickerTestFactory.nonRotationTests] for configuring screen orientation and * navigation modes. */ @Parameterized.Parameters(name = "{0}") @JvmStatic - fun getParams(): Collection<FlickerTest> { - return FlickerTestFactory.nonRotationTests() - } + fun getParams() = LegacyFlickerTestFactory.nonRotationTests() } } diff --git a/tests/FlickerTests/src/com/android/server/wm/flicker/notification/OpenAppTransition.kt b/tests/FlickerTests/src/com/android/server/wm/flicker/notification/OpenAppTransition.kt new file mode 100644 index 000000000000..684b4b70f950 --- /dev/null +++ b/tests/FlickerTests/src/com/android/server/wm/flicker/notification/OpenAppTransition.kt @@ -0,0 +1,136 @@ +/* + * Copyright (C) 2021 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.server.wm.flicker.notification + +import android.platform.test.annotations.Presubmit +import android.tools.common.traces.component.ComponentNameMatcher +import android.tools.device.apphelpers.StandardAppHelper +import android.tools.device.flicker.legacy.FlickerBuilder +import android.tools.device.flicker.legacy.LegacyFlickerTest +import android.tools.device.helpers.wakeUpAndGoToHomeScreen +import com.android.server.wm.flicker.BaseTest +import com.android.server.wm.flicker.helpers.SimpleAppHelper +import com.android.server.wm.flicker.helpers.setRotation +import org.junit.Test + +/** Base class for app launch tests */ +abstract class OpenAppTransition(flicker: LegacyFlickerTest) : BaseTest(flicker) { + protected open val testApp: StandardAppHelper = SimpleAppHelper(instrumentation) + + /** {@inheritDoc} */ + override val transition: FlickerBuilder.() -> Unit = { + setup { + tapl.setExpectedRotation(flicker.scenario.startRotation.value) + device.wakeUpAndGoToHomeScreen() + this.setRotation(flicker.scenario.startRotation) + } + teardown { testApp.exit(wmHelper) } + } + + /** + * Checks that the [testApp] layer doesn't exist or is invisible at the start of the transition, + * but is created and/or becomes visible during the transition. + */ + @Presubmit + @Test + open fun appLayerBecomesVisible() { + appLayerBecomesVisible_coldStart() + } + + protected fun appLayerBecomesVisible_coldStart() { + flicker.assertLayers { + this.notContains(testApp) + .then() + .isInvisible(testApp, isOptional = true) + .then() + .isVisible(ComponentNameMatcher.SNAPSHOT, isOptional = true) + .then() + .isVisible(ComponentNameMatcher.SPLASH_SCREEN, isOptional = true) + .then() + .isVisible(testApp) + } + } + + protected fun appLayerBecomesVisible_warmStart() { + flicker.assertLayers { + this.isInvisible(testApp) + .then() + .isVisible(ComponentNameMatcher.SNAPSHOT, isOptional = true) + .then() + .isVisible(ComponentNameMatcher.SPLASH_SCREEN, isOptional = true) + .then() + .isVisible(testApp) + } + } + + /** + * Checks that the [testApp] window doesn't exist at the start of the transition, that it is + * created (invisible - optional) and becomes visible during the transition + * + * The `isAppWindowInvisible` step is optional because we log once per frame, upon logging, the + * window may be visible or not depending on what was processed until that moment. + */ + @Presubmit @Test open fun appWindowBecomesVisible() = appWindowBecomesVisible_coldStart() + + protected fun appWindowBecomesVisible_coldStart() { + flicker.assertWm { + this.notContains(testApp) + .then() + .isAppWindowInvisible(testApp, isOptional = true) + .then() + .isAppWindowVisible(testApp) + } + } + + protected fun appWindowBecomesVisible_warmStart() { + flicker.assertWm { + this.isAppWindowInvisible(testApp) + .then() + .isAppWindowVisible(ComponentNameMatcher.SNAPSHOT, isOptional = true) + .then() + .isAppWindowVisible(ComponentNameMatcher.SPLASH_SCREEN, isOptional = true) + .then() + .isAppWindowVisible(testApp) + } + } + + /** + * Checks that [testApp] window is not on top at the start of the transition, and then becomes + * the top visible window until the end of the transition. + */ + @Presubmit + @Test + open fun appWindowBecomesTopWindow() { + flicker.assertWm { + this.isAppWindowNotOnTop(testApp) + .then() + .isAppWindowOnTop( + testApp.or(ComponentNameMatcher.SNAPSHOT).or(ComponentNameMatcher.SPLASH_SCREEN) + ) + } + } + + /** + * Checks that [testApp] window is not on top at the start of the transition, and then becomes + * the top visible window until the end of the transition. + */ + @Presubmit + @Test + open fun appWindowIsTopWindowAtEnd() { + flicker.assertWmEnd { this.isAppWindowOnTop(testApp) } + } +} diff --git a/tests/FlickerTests/src/com/android/server/wm/flicker/quickswitch/QuickSwitchBetweenTwoAppsBackTest.kt b/tests/FlickerTests/src/com/android/server/wm/flicker/quickswitch/QuickSwitchBetweenTwoAppsBackTest.kt index a8b80ad1d16c..7883910323de 100644 --- a/tests/FlickerTests/src/com/android/server/wm/flicker/quickswitch/QuickSwitchBetweenTwoAppsBackTest.kt +++ b/tests/FlickerTests/src/com/android/server/wm/flicker/quickswitch/QuickSwitchBetweenTwoAppsBackTest.kt @@ -23,8 +23,8 @@ import android.tools.common.datatypes.Rect import android.tools.common.traces.component.ComponentNameMatcher import android.tools.device.flicker.junit.FlickerParametersRunnerFactory import android.tools.device.flicker.legacy.FlickerBuilder -import android.tools.device.flicker.legacy.FlickerTest -import android.tools.device.flicker.legacy.FlickerTestFactory +import android.tools.device.flicker.legacy.LegacyFlickerTest +import android.tools.device.flicker.legacy.LegacyFlickerTestFactory import androidx.test.filters.RequiresDevice import com.android.server.wm.flicker.BaseTest import com.android.server.wm.flicker.helpers.NonResizeableAppHelper @@ -52,7 +52,7 @@ import org.junit.runners.Parameterized @RunWith(Parameterized::class) @Parameterized.UseParametersRunnerFactory(FlickerParametersRunnerFactory::class) @FixMethodOrder(MethodSorters.NAME_ASCENDING) -open class QuickSwitchBetweenTwoAppsBackTest(flicker: FlickerTest) : BaseTest(flicker) { +open class QuickSwitchBetweenTwoAppsBackTest(flicker: LegacyFlickerTest) : BaseTest(flicker) { private val testApp1 = SimpleAppHelper(instrumentation) private val testApp2 = NonResizeableAppHelper(instrumentation) @@ -243,10 +243,9 @@ open class QuickSwitchBetweenTwoAppsBackTest(flicker: FlickerTest) : BaseTest(fl @Parameterized.Parameters(name = "{0}") @JvmStatic - fun getParams(): Collection<FlickerTest> { - return FlickerTestFactory.nonRotationTests( + fun getParams() = + LegacyFlickerTestFactory.nonRotationTests( supportedNavigationModes = listOf(NavBar.MODE_GESTURAL) ) - } } } diff --git a/tests/FlickerTests/src/com/android/server/wm/flicker/quickswitch/QuickSwitchBetweenTwoAppsBackTestCfArm.kt b/tests/FlickerTests/src/com/android/server/wm/flicker/quickswitch/QuickSwitchBetweenTwoAppsBackTestCfArm.kt index f970a79abcb8..f68cd5c4293c 100644 --- a/tests/FlickerTests/src/com/android/server/wm/flicker/quickswitch/QuickSwitchBetweenTwoAppsBackTestCfArm.kt +++ b/tests/FlickerTests/src/com/android/server/wm/flicker/quickswitch/QuickSwitchBetweenTwoAppsBackTestCfArm.kt @@ -18,8 +18,8 @@ package com.android.server.wm.flicker.quickswitch import android.tools.common.NavBar import android.tools.device.flicker.junit.FlickerParametersRunnerFactory -import android.tools.device.flicker.legacy.FlickerTest -import android.tools.device.flicker.legacy.FlickerTestFactory +import android.tools.device.flicker.legacy.LegacyFlickerTest +import android.tools.device.flicker.legacy.LegacyFlickerTestFactory import org.junit.FixMethodOrder import org.junit.runner.RunWith import org.junit.runners.MethodSorters @@ -28,15 +28,14 @@ import org.junit.runners.Parameterized @RunWith(Parameterized::class) @Parameterized.UseParametersRunnerFactory(FlickerParametersRunnerFactory::class) @FixMethodOrder(MethodSorters.NAME_ASCENDING) -class QuickSwitchBetweenTwoAppsBackTestCfArm(flicker: FlickerTest) : +class QuickSwitchBetweenTwoAppsBackTestCfArm(flicker: LegacyFlickerTest) : QuickSwitchBetweenTwoAppsBackTest(flicker) { companion object { @Parameterized.Parameters(name = "{0}") @JvmStatic - fun getParams(): Collection<FlickerTest> { - return FlickerTestFactory.nonRotationTests( + fun getParams() = + LegacyFlickerTestFactory.nonRotationTests( supportedNavigationModes = listOf(NavBar.MODE_GESTURAL) ) - } } } diff --git a/tests/FlickerTests/src/com/android/server/wm/flicker/quickswitch/QuickSwitchBetweenTwoAppsForwardTest.kt b/tests/FlickerTests/src/com/android/server/wm/flicker/quickswitch/QuickSwitchBetweenTwoAppsForwardTest.kt index 96cd8ffa3eff..1c4c7cd89e42 100644 --- a/tests/FlickerTests/src/com/android/server/wm/flicker/quickswitch/QuickSwitchBetweenTwoAppsForwardTest.kt +++ b/tests/FlickerTests/src/com/android/server/wm/flicker/quickswitch/QuickSwitchBetweenTwoAppsForwardTest.kt @@ -23,8 +23,8 @@ import android.tools.common.datatypes.Rect import android.tools.common.traces.component.ComponentNameMatcher import android.tools.device.flicker.junit.FlickerParametersRunnerFactory import android.tools.device.flicker.legacy.FlickerBuilder -import android.tools.device.flicker.legacy.FlickerTest -import android.tools.device.flicker.legacy.FlickerTestFactory +import android.tools.device.flicker.legacy.LegacyFlickerTest +import android.tools.device.flicker.legacy.LegacyFlickerTestFactory import androidx.test.filters.RequiresDevice import com.android.server.wm.flicker.BaseTest import com.android.server.wm.flicker.helpers.NonResizeableAppHelper @@ -53,7 +53,7 @@ import org.junit.runners.Parameterized @RunWith(Parameterized::class) @Parameterized.UseParametersRunnerFactory(FlickerParametersRunnerFactory::class) @FixMethodOrder(MethodSorters.NAME_ASCENDING) -open class QuickSwitchBetweenTwoAppsForwardTest(flicker: FlickerTest) : BaseTest(flicker) { +open class QuickSwitchBetweenTwoAppsForwardTest(flicker: LegacyFlickerTest) : BaseTest(flicker) { private val testApp1 = SimpleAppHelper(instrumentation) private val testApp2 = NonResizeableAppHelper(instrumentation) @@ -261,10 +261,9 @@ open class QuickSwitchBetweenTwoAppsForwardTest(flicker: FlickerTest) : BaseTest @Parameterized.Parameters(name = "{0}") @JvmStatic - fun getParams(): Collection<FlickerTest> { - return FlickerTestFactory.nonRotationTests( + fun getParams() = + LegacyFlickerTestFactory.nonRotationTests( supportedNavigationModes = listOf(NavBar.MODE_GESTURAL) ) - } } } diff --git a/tests/FlickerTests/src/com/android/server/wm/flicker/quickswitch/QuickSwitchBetweenTwoAppsForwardTestCfArm.kt b/tests/FlickerTests/src/com/android/server/wm/flicker/quickswitch/QuickSwitchBetweenTwoAppsForwardTestCfArm.kt index 9f48cdae20f1..3de58acccd79 100644 --- a/tests/FlickerTests/src/com/android/server/wm/flicker/quickswitch/QuickSwitchBetweenTwoAppsForwardTestCfArm.kt +++ b/tests/FlickerTests/src/com/android/server/wm/flicker/quickswitch/QuickSwitchBetweenTwoAppsForwardTestCfArm.kt @@ -18,8 +18,8 @@ package com.android.server.wm.flicker.quickswitch import android.tools.common.NavBar import android.tools.device.flicker.junit.FlickerParametersRunnerFactory -import android.tools.device.flicker.legacy.FlickerTest -import android.tools.device.flicker.legacy.FlickerTestFactory +import android.tools.device.flicker.legacy.LegacyFlickerTest +import android.tools.device.flicker.legacy.LegacyFlickerTestFactory import org.junit.FixMethodOrder import org.junit.runner.RunWith import org.junit.runners.MethodSorters @@ -28,15 +28,14 @@ import org.junit.runners.Parameterized @RunWith(Parameterized::class) @Parameterized.UseParametersRunnerFactory(FlickerParametersRunnerFactory::class) @FixMethodOrder(MethodSorters.NAME_ASCENDING) -class QuickSwitchBetweenTwoAppsForwardTestCfArm(flicker: FlickerTest) : +class QuickSwitchBetweenTwoAppsForwardTestCfArm(flicker: LegacyFlickerTest) : QuickSwitchBetweenTwoAppsForwardTest(flicker) { companion object { @Parameterized.Parameters(name = "{0}") @JvmStatic - fun getParams(): Collection<FlickerTest> { - return FlickerTestFactory.nonRotationTests( + fun getParams() = + LegacyFlickerTestFactory.nonRotationTests( supportedNavigationModes = listOf(NavBar.MODE_GESTURAL) ) - } } } diff --git a/tests/FlickerTests/src/com/android/server/wm/flicker/quickswitch/QuickSwitchFromLauncherTest.kt b/tests/FlickerTests/src/com/android/server/wm/flicker/quickswitch/QuickSwitchFromLauncherTest.kt index 7e935f03aeb1..641745693187 100644 --- a/tests/FlickerTests/src/com/android/server/wm/flicker/quickswitch/QuickSwitchFromLauncherTest.kt +++ b/tests/FlickerTests/src/com/android/server/wm/flicker/quickswitch/QuickSwitchFromLauncherTest.kt @@ -24,8 +24,8 @@ import android.tools.common.datatypes.Rect import android.tools.common.traces.component.ComponentNameMatcher import android.tools.device.flicker.junit.FlickerParametersRunnerFactory import android.tools.device.flicker.legacy.FlickerBuilder -import android.tools.device.flicker.legacy.FlickerTest -import android.tools.device.flicker.legacy.FlickerTestFactory +import android.tools.device.flicker.legacy.LegacyFlickerTest +import android.tools.device.flicker.legacy.LegacyFlickerTestFactory import androidx.test.filters.RequiresDevice import com.android.server.wm.flicker.BaseTest import com.android.server.wm.flicker.helpers.SimpleAppHelper @@ -52,7 +52,7 @@ import org.junit.runners.Parameterized @RunWith(Parameterized::class) @Parameterized.UseParametersRunnerFactory(FlickerParametersRunnerFactory::class) @FixMethodOrder(MethodSorters.NAME_ASCENDING) -open class QuickSwitchFromLauncherTest(flicker: FlickerTest) : BaseTest(flicker) { +open class QuickSwitchFromLauncherTest(flicker: LegacyFlickerTest) : BaseTest(flicker) { private val testApp = SimpleAppHelper(instrumentation) /** {@inheritDoc} */ @@ -272,12 +272,11 @@ open class QuickSwitchFromLauncherTest(flicker: FlickerTest) : BaseTest(flicker) @Parameterized.Parameters(name = "{0}") @JvmStatic - fun getParams(): Collection<FlickerTest> { - return FlickerTestFactory.nonRotationTests( + fun getParams() = + LegacyFlickerTestFactory.nonRotationTests( supportedNavigationModes = listOf(NavBar.MODE_GESTURAL), // TODO: Test with 90 rotation supportedRotations = listOf(Rotation.ROTATION_0) ) - } } } diff --git a/tests/FlickerTests/src/com/android/server/wm/flicker/quickswitch/QuickSwitchFromLauncherTestCfArm.kt b/tests/FlickerTests/src/com/android/server/wm/flicker/quickswitch/QuickSwitchFromLauncherTestCfArm.kt index af671df194ae..84fc75445175 100644 --- a/tests/FlickerTests/src/com/android/server/wm/flicker/quickswitch/QuickSwitchFromLauncherTestCfArm.kt +++ b/tests/FlickerTests/src/com/android/server/wm/flicker/quickswitch/QuickSwitchFromLauncherTestCfArm.kt @@ -19,8 +19,8 @@ package com.android.server.wm.flicker.quickswitch import android.tools.common.NavBar import android.tools.common.Rotation import android.tools.device.flicker.junit.FlickerParametersRunnerFactory -import android.tools.device.flicker.legacy.FlickerTest -import android.tools.device.flicker.legacy.FlickerTestFactory +import android.tools.device.flicker.legacy.LegacyFlickerTest +import android.tools.device.flicker.legacy.LegacyFlickerTestFactory import org.junit.FixMethodOrder import org.junit.runner.RunWith import org.junit.runners.MethodSorters @@ -29,17 +29,16 @@ import org.junit.runners.Parameterized @RunWith(Parameterized::class) @Parameterized.UseParametersRunnerFactory(FlickerParametersRunnerFactory::class) @FixMethodOrder(MethodSorters.NAME_ASCENDING) -open class QuickSwitchFromLauncherTestCfArm(flicker: FlickerTest) : +open class QuickSwitchFromLauncherTestCfArm(flicker: LegacyFlickerTest) : QuickSwitchFromLauncherTest(flicker) { companion object { @Parameterized.Parameters(name = "{0}") @JvmStatic - fun getParams(): Collection<FlickerTest> { - return FlickerTestFactory.nonRotationTests( + fun getParams() = + LegacyFlickerTestFactory.nonRotationTests( supportedNavigationModes = listOf(NavBar.MODE_GESTURAL), // TODO: Test with 90 rotation supportedRotations = listOf(Rotation.ROTATION_0) ) - } } } diff --git a/tests/FlickerTests/src/com/android/server/wm/flicker/rotation/ChangeAppRotationTest.kt b/tests/FlickerTests/src/com/android/server/wm/flicker/rotation/ChangeAppRotationTest.kt index ef75c6105b53..842ece38c282 100644 --- a/tests/FlickerTests/src/com/android/server/wm/flicker/rotation/ChangeAppRotationTest.kt +++ b/tests/FlickerTests/src/com/android/server/wm/flicker/rotation/ChangeAppRotationTest.kt @@ -21,8 +21,8 @@ import android.platform.test.annotations.Presubmit import android.tools.common.traces.component.ComponentNameMatcher import android.tools.device.flicker.junit.FlickerParametersRunnerFactory import android.tools.device.flicker.legacy.FlickerBuilder -import android.tools.device.flicker.legacy.FlickerTest -import android.tools.device.flicker.legacy.FlickerTestFactory +import android.tools.device.flicker.legacy.LegacyFlickerTest +import android.tools.device.flicker.legacy.LegacyFlickerTestFactory import androidx.test.filters.RequiresDevice import com.android.server.wm.flicker.helpers.SimpleAppHelper import org.junit.FixMethodOrder @@ -34,7 +34,7 @@ import org.junit.runners.Parameterized /** * Test opening an app and cycling through app rotations * - * Currently runs: + * Currently, runs: * ``` * 0 -> 90 degrees * 90 -> 0 degrees @@ -85,7 +85,7 @@ import org.junit.runners.Parameterized @RunWith(Parameterized::class) @Parameterized.UseParametersRunnerFactory(FlickerParametersRunnerFactory::class) @FixMethodOrder(MethodSorters.NAME_ASCENDING) -open class ChangeAppRotationTest(flicker: FlickerTest) : RotationTransition(flicker) { +open class ChangeAppRotationTest(flicker: LegacyFlickerTest) : RotationTransition(flicker) { override val testApp = SimpleAppHelper(instrumentation) override val transition: FlickerBuilder.() -> Unit get() = { @@ -140,13 +140,11 @@ open class ChangeAppRotationTest(flicker: FlickerTest) : RotationTransition(flic /** * Creates the test configurations. * - * See [FlickerTestFactory.rotationTests] for configuring screen orientation and navigation - * modes. + * See [LegacyFlickerTestFactory.rotationTests] for configuring screen orientation and + * navigation modes. */ @Parameterized.Parameters(name = "{0}") @JvmStatic - fun getParams(): Collection<FlickerTest> { - return FlickerTestFactory.rotationTests() - } + fun getParams() = LegacyFlickerTestFactory.rotationTests() } } diff --git a/tests/FlickerTests/src/com/android/server/wm/flicker/rotation/ChangeAppRotationTestCfArm.kt b/tests/FlickerTests/src/com/android/server/wm/flicker/rotation/ChangeAppRotationTestCfArm.kt index 0e6b20fc21c6..1ab5c5ad77b5 100644 --- a/tests/FlickerTests/src/com/android/server/wm/flicker/rotation/ChangeAppRotationTestCfArm.kt +++ b/tests/FlickerTests/src/com/android/server/wm/flicker/rotation/ChangeAppRotationTestCfArm.kt @@ -17,8 +17,8 @@ package com.android.server.wm.flicker.rotation import android.tools.device.flicker.junit.FlickerParametersRunnerFactory -import android.tools.device.flicker.legacy.FlickerTest -import android.tools.device.flicker.legacy.FlickerTestFactory +import android.tools.device.flicker.legacy.LegacyFlickerTest +import android.tools.device.flicker.legacy.LegacyFlickerTestFactory import org.junit.FixMethodOrder import org.junit.runner.RunWith import org.junit.runners.MethodSorters @@ -27,18 +27,16 @@ import org.junit.runners.Parameterized @RunWith(Parameterized::class) @Parameterized.UseParametersRunnerFactory(FlickerParametersRunnerFactory::class) @FixMethodOrder(MethodSorters.NAME_ASCENDING) -class ChangeAppRotationTestCfArm(flicker: FlickerTest) : ChangeAppRotationTest(flicker) { +class ChangeAppRotationTestCfArm(flicker: LegacyFlickerTest) : ChangeAppRotationTest(flicker) { companion object { /** * Creates the test configurations. * - * See [FlickerTestFactory.rotationTests] for configuring screen orientation and navigation - * modes. + * See [LegacyFlickerTestFactory.rotationTests] for configuring screen orientation and + * navigation modes. */ @Parameterized.Parameters(name = "{0}") @JvmStatic - fun getParams(): Collection<FlickerTest> { - return FlickerTestFactory.rotationTests() - } + fun getParams() = LegacyFlickerTestFactory.rotationTests() } } diff --git a/tests/FlickerTests/src/com/android/server/wm/flicker/rotation/RotationTransition.kt b/tests/FlickerTests/src/com/android/server/wm/flicker/rotation/RotationTransition.kt index fe9da335a675..b0ca4d230e12 100644 --- a/tests/FlickerTests/src/com/android/server/wm/flicker/rotation/RotationTransition.kt +++ b/tests/FlickerTests/src/com/android/server/wm/flicker/rotation/RotationTransition.kt @@ -20,13 +20,13 @@ import android.platform.test.annotations.Presubmit import android.tools.common.traces.component.ComponentNameMatcher import android.tools.device.apphelpers.StandardAppHelper import android.tools.device.flicker.legacy.FlickerBuilder -import android.tools.device.flicker.legacy.FlickerTest +import android.tools.device.flicker.legacy.LegacyFlickerTest import com.android.server.wm.flicker.BaseTest import com.android.server.wm.flicker.helpers.setRotation import org.junit.Test /** Base class for app rotation tests */ -abstract class RotationTransition(flicker: FlickerTest) : BaseTest(flicker) { +abstract class RotationTransition(flicker: LegacyFlickerTest) : BaseTest(flicker) { protected abstract val testApp: StandardAppHelper /** {@inheritDoc} */ diff --git a/tests/FlickerTests/src/com/android/server/wm/flicker/rotation/SeamlessAppRotationTest.kt b/tests/FlickerTests/src/com/android/server/wm/flicker/rotation/SeamlessAppRotationTest.kt index f654bdd48e89..b6ad3cc7fc50 100644 --- a/tests/FlickerTests/src/com/android/server/wm/flicker/rotation/SeamlessAppRotationTest.kt +++ b/tests/FlickerTests/src/com/android/server/wm/flicker/rotation/SeamlessAppRotationTest.kt @@ -19,11 +19,12 @@ package com.android.server.wm.flicker.rotation import android.platform.test.annotations.PlatinumTest import android.platform.test.annotations.Presubmit import android.tools.common.ScenarioBuilder +import android.tools.common.ScenarioImpl import android.tools.common.traces.component.ComponentNameMatcher import android.tools.device.flicker.junit.FlickerParametersRunnerFactory import android.tools.device.flicker.legacy.FlickerBuilder -import android.tools.device.flicker.legacy.FlickerTest -import android.tools.device.flicker.legacy.FlickerTestFactory +import android.tools.device.flicker.legacy.LegacyFlickerTest +import android.tools.device.flicker.legacy.LegacyFlickerTestFactory import android.view.WindowManager import androidx.test.filters.RequiresDevice import com.android.server.wm.flicker.helpers.SeamlessRotationAppHelper @@ -91,7 +92,7 @@ import org.junit.runners.Parameterized @RunWith(Parameterized::class) @Parameterized.UseParametersRunnerFactory(FlickerParametersRunnerFactory::class) @FixMethodOrder(MethodSorters.NAME_ASCENDING) -open class SeamlessAppRotationTest(flicker: FlickerTest) : RotationTransition(flicker) { +open class SeamlessAppRotationTest(flicker: LegacyFlickerTest) : RotationTransition(flicker) { override val testApp = SeamlessRotationAppHelper(instrumentation) /** {@inheritDoc} */ @@ -236,43 +237,50 @@ open class SeamlessAppRotationTest(flicker: FlickerTest) : RotationTransition(fl } companion object { - private val FlickerTest.starveUiThread + private val LegacyFlickerTest.starveUiThread get() = - getConfigValue<Boolean>(ActivityOptions.SeamlessRotation.EXTRA_STARVE_UI_THREAD) + scenario.getConfigValue<Boolean>( + ActivityOptions.SeamlessRotation.EXTRA_STARVE_UI_THREAD + ) ?: false @JvmStatic protected fun createConfig( - sourceConfig: FlickerTest, + sourceConfig: LegacyFlickerTest, starveUiThread: Boolean - ): FlickerTest { - val originalScenario = sourceConfig.initialize("createConfig") + ): LegacyFlickerTest { + val originalScenario = sourceConfig.initialize("createConfig") as ScenarioImpl val nameExt = if (starveUiThread) "_BUSY_UI_THREAD" else "" val newConfig = ScenarioBuilder() - .fromScenario(originalScenario) + .forClass(originalScenario.testClass) + .withStartRotation(originalScenario.startRotation) + .withEndRotation(originalScenario.endRotation) + .withNavBarMode(originalScenario.navBarMode) + .withExtraConfigs(originalScenario.extraConfig) + .withDescriptionOverride(originalScenario.description) .withExtraConfig( ActivityOptions.SeamlessRotation.EXTRA_STARVE_UI_THREAD, starveUiThread ) .withDescriptionOverride("${originalScenario.description}$nameExt") - return FlickerTest(newConfig) + return LegacyFlickerTest(newConfig) } /** * Creates the test configurations for seamless rotation based on the default rotation tests - * from [FlickerTestFactory.rotationTests], but adding a flag ( + * from [LegacyFlickerTestFactory.rotationTests], but adding a flag ( * [ActivityOptions.SeamlessRotation.EXTRA_STARVE_UI_THREAD]) to indicate if the app should * starve the UI thread of not */ @Parameterized.Parameters(name = "{0}") @JvmStatic - fun getParams(): Collection<FlickerTest> { - return FlickerTestFactory.rotationTests().flatMap { sourceConfig -> - val defaultRun = createConfig(sourceConfig, starveUiThread = false) - val busyUiRun = createConfig(sourceConfig, starveUiThread = true) + fun getParams() = + LegacyFlickerTestFactory.rotationTests().flatMap { sourceCfg -> + val legacyCfg = sourceCfg as LegacyFlickerTest + val defaultRun = createConfig(legacyCfg, starveUiThread = false) + val busyUiRun = createConfig(legacyCfg, starveUiThread = true) listOf(defaultRun, busyUiRun) } - } } } diff --git a/tests/FlickerTests/src/com/android/server/wm/flicker/rotation/SeamlessAppRotationTestCfArm.kt b/tests/FlickerTests/src/com/android/server/wm/flicker/rotation/SeamlessAppRotationTestCfArm.kt index b236d87616ab..592be05c8182 100644 --- a/tests/FlickerTests/src/com/android/server/wm/flicker/rotation/SeamlessAppRotationTestCfArm.kt +++ b/tests/FlickerTests/src/com/android/server/wm/flicker/rotation/SeamlessAppRotationTestCfArm.kt @@ -17,8 +17,8 @@ package com.android.server.wm.flicker.rotation import android.tools.device.flicker.junit.FlickerParametersRunnerFactory -import android.tools.device.flicker.legacy.FlickerTest -import android.tools.device.flicker.legacy.FlickerTestFactory +import android.tools.device.flicker.legacy.LegacyFlickerTest +import android.tools.device.flicker.legacy.LegacyFlickerTestFactory import com.android.server.wm.flicker.testapp.ActivityOptions import org.junit.FixMethodOrder import org.junit.runner.RunWith @@ -29,22 +29,23 @@ import org.junit.runners.Parameterized @RunWith(Parameterized::class) @Parameterized.UseParametersRunnerFactory(FlickerParametersRunnerFactory::class) @FixMethodOrder(MethodSorters.NAME_ASCENDING) -open class SeamlessAppRotationTestCfArm(flicker: FlickerTest) : SeamlessAppRotationTest(flicker) { +open class SeamlessAppRotationTestCfArm(flicker: LegacyFlickerTest) : + SeamlessAppRotationTest(flicker) { companion object { /** * Creates the test configurations for seamless rotation based on the default rotation tests - * from [FlickerTestFactory.rotationTests], but adding a flag ( + * from [LegacyFlickerTestFactory.rotationTests], but adding a flag ( * [ActivityOptions.SeamlessRotation.EXTRA_STARVE_UI_THREAD]) to indicate if the app should * starve the UI thread of not */ @Parameterized.Parameters(name = "{0}") @JvmStatic - fun getParams(): Collection<FlickerTest> { - return FlickerTestFactory.rotationTests().flatMap { sourceConfig -> - val defaultRun = createConfig(sourceConfig, starveUiThread = false) - val busyUiRun = createConfig(sourceConfig, starveUiThread = true) + fun getParams() = + LegacyFlickerTestFactory.rotationTests().flatMap { sourceCfg -> + val legacyCfg = sourceCfg as LegacyFlickerTest + val defaultRun = createConfig(legacyCfg, starveUiThread = false) + val busyUiRun = createConfig(legacyCfg, starveUiThread = true) listOf(defaultRun, busyUiRun) } - } } } diff --git a/tests/FlickerTests/src/com/android/server/wm/flicker/service/Utils.kt b/tests/FlickerTests/src/com/android/server/wm/flicker/service/Utils.kt new file mode 100644 index 000000000000..8242e9a31992 --- /dev/null +++ b/tests/FlickerTests/src/com/android/server/wm/flicker/service/Utils.kt @@ -0,0 +1,53 @@ +/* + * Copyright (C) 2023 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.server.wm.flicker.service + +import android.app.Instrumentation +import android.platform.test.rule.NavigationModeRule +import android.platform.test.rule.PressHomeRule +import android.platform.test.rule.UnlockScreenRule +import android.tools.common.NavBar +import android.tools.common.Rotation +import android.tools.device.apphelpers.MessagingAppHelper +import android.tools.device.flicker.rules.ChangeDisplayOrientationRule +import android.tools.device.flicker.rules.LaunchAppRule +import android.tools.device.flicker.rules.RemoveAllTasksButHomeRule +import androidx.test.platform.app.InstrumentationRegistry +import org.junit.rules.RuleChain + +object Utils { + private val instrumentation: Instrumentation = InstrumentationRegistry.getInstrumentation() + + fun testSetupRule(navigationMode: NavBar, rotation: Rotation): RuleChain { + return RuleChain.outerRule(UnlockScreenRule()) + .around( + NavigationModeRule(navigationMode.value, /* changeNavigationModeAfterTest */ false) + ) + .around( + LaunchAppRule(MessagingAppHelper(instrumentation), clearCacheAfterParsing = false) + ) + .around(RemoveAllTasksButHomeRule()) + .around( + ChangeDisplayOrientationRule( + rotation, + resetOrientationAfterTest = false, + clearCacheAfterParsing = false + ) + ) + .around(PressHomeRule()) + } +} diff --git a/tests/FlickerTests/src/com/android/server/wm/flicker/service/close/flicker/CloseAppBackButton3ButtonLandscape.kt b/tests/FlickerTests/src/com/android/server/wm/flicker/service/close/flicker/CloseAppBackButton3ButtonLandscape.kt new file mode 100644 index 000000000000..030b29269e48 --- /dev/null +++ b/tests/FlickerTests/src/com/android/server/wm/flicker/service/close/flicker/CloseAppBackButton3ButtonLandscape.kt @@ -0,0 +1,44 @@ +/* + * Copyright (C) 2023 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.server.wm.flicker.service.close.flicker + +import android.tools.common.NavBar +import android.tools.common.Rotation +import android.tools.common.flicker.FlickerConfig +import android.tools.common.flicker.annotation.ExpectedScenarios +import android.tools.common.flicker.annotation.FlickerConfigProvider +import android.tools.common.flicker.config.FlickerConfig +import android.tools.common.flicker.config.FlickerServiceConfig +import android.tools.device.flicker.junit.FlickerServiceJUnit4ClassRunner +import com.android.server.wm.flicker.service.close.scenarios.CloseAppBackButton +import org.junit.Test +import org.junit.runner.RunWith + +@RunWith(FlickerServiceJUnit4ClassRunner::class) +class CloseAppBackButton3ButtonLandscape : + CloseAppBackButton(NavBar.MODE_3BUTTON, Rotation.ROTATION_90) { + @ExpectedScenarios(["APP_CLOSE_TO_HOME"]) + @Test + override fun closeAppBackButtonTest() = super.closeAppBackButtonTest() + + companion object { + @JvmStatic + @FlickerConfigProvider + fun flickerConfigProvider(): FlickerConfig = + FlickerConfig().use(FlickerServiceConfig.DEFAULT) + } +} diff --git a/tests/FlickerTests/src/com/android/server/wm/flicker/service/close/flicker/CloseAppBackButton3ButtonPortrait.kt b/tests/FlickerTests/src/com/android/server/wm/flicker/service/close/flicker/CloseAppBackButton3ButtonPortrait.kt new file mode 100644 index 000000000000..770da143b184 --- /dev/null +++ b/tests/FlickerTests/src/com/android/server/wm/flicker/service/close/flicker/CloseAppBackButton3ButtonPortrait.kt @@ -0,0 +1,44 @@ +/* + * Copyright (C) 2023 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.server.wm.flicker.service.close.flicker + +import android.tools.common.NavBar +import android.tools.common.Rotation +import android.tools.common.flicker.FlickerConfig +import android.tools.common.flicker.annotation.ExpectedScenarios +import android.tools.common.flicker.annotation.FlickerConfigProvider +import android.tools.common.flicker.config.FlickerConfig +import android.tools.common.flicker.config.FlickerServiceConfig +import android.tools.device.flicker.junit.FlickerServiceJUnit4ClassRunner +import com.android.server.wm.flicker.service.close.scenarios.CloseAppBackButton +import org.junit.Test +import org.junit.runner.RunWith + +@RunWith(FlickerServiceJUnit4ClassRunner::class) +class CloseAppBackButton3ButtonPortrait : + CloseAppBackButton(NavBar.MODE_3BUTTON, Rotation.ROTATION_0) { + @ExpectedScenarios(["APP_CLOSE_TO_HOME"]) + @Test + override fun closeAppBackButtonTest() = super.closeAppBackButtonTest() + + companion object { + @JvmStatic + @FlickerConfigProvider + fun flickerConfigProvider(): FlickerConfig = + FlickerConfig().use(FlickerServiceConfig.DEFAULT) + } +} diff --git a/tests/FlickerTests/src/com/android/server/wm/flicker/service/close/flicker/CloseAppBackButtonGesturalNavLandscape.kt b/tests/FlickerTests/src/com/android/server/wm/flicker/service/close/flicker/CloseAppBackButtonGesturalNavLandscape.kt new file mode 100644 index 000000000000..4b2206d78276 --- /dev/null +++ b/tests/FlickerTests/src/com/android/server/wm/flicker/service/close/flicker/CloseAppBackButtonGesturalNavLandscape.kt @@ -0,0 +1,44 @@ +/* + * Copyright (C) 2023 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.server.wm.flicker.service.close.flicker + +import android.tools.common.NavBar +import android.tools.common.Rotation +import android.tools.common.flicker.FlickerConfig +import android.tools.common.flicker.annotation.ExpectedScenarios +import android.tools.common.flicker.annotation.FlickerConfigProvider +import android.tools.common.flicker.config.FlickerConfig +import android.tools.common.flicker.config.FlickerServiceConfig +import android.tools.device.flicker.junit.FlickerServiceJUnit4ClassRunner +import com.android.server.wm.flicker.service.close.scenarios.CloseAppBackButton +import org.junit.Test +import org.junit.runner.RunWith + +@RunWith(FlickerServiceJUnit4ClassRunner::class) +class CloseAppBackButtonGesturalNavLandscape : + CloseAppBackButton(NavBar.MODE_GESTURAL, Rotation.ROTATION_90) { + @ExpectedScenarios(["APP_CLOSE_TO_HOME"]) + @Test + override fun closeAppBackButtonTest() = super.closeAppBackButtonTest() + + companion object { + @JvmStatic + @FlickerConfigProvider + fun flickerConfigProvider(): FlickerConfig = + FlickerConfig().use(FlickerServiceConfig.DEFAULT) + } +} diff --git a/tests/FlickerTests/src/com/android/server/wm/flicker/service/close/flicker/CloseAppBackButtonGesturalNavPortrait.kt b/tests/FlickerTests/src/com/android/server/wm/flicker/service/close/flicker/CloseAppBackButtonGesturalNavPortrait.kt new file mode 100644 index 000000000000..54b471e5ab28 --- /dev/null +++ b/tests/FlickerTests/src/com/android/server/wm/flicker/service/close/flicker/CloseAppBackButtonGesturalNavPortrait.kt @@ -0,0 +1,44 @@ +/* + * Copyright (C) 2023 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.server.wm.flicker.service.close.flicker + +import android.tools.common.NavBar +import android.tools.common.Rotation +import android.tools.common.flicker.FlickerConfig +import android.tools.common.flicker.annotation.ExpectedScenarios +import android.tools.common.flicker.annotation.FlickerConfigProvider +import android.tools.common.flicker.config.FlickerConfig +import android.tools.common.flicker.config.FlickerServiceConfig +import android.tools.device.flicker.junit.FlickerServiceJUnit4ClassRunner +import com.android.server.wm.flicker.service.close.scenarios.CloseAppBackButton +import org.junit.Test +import org.junit.runner.RunWith + +@RunWith(FlickerServiceJUnit4ClassRunner::class) +class CloseAppBackButtonGesturalNavPortrait : + CloseAppBackButton(NavBar.MODE_GESTURAL, Rotation.ROTATION_0) { + @ExpectedScenarios(["APP_CLOSE_TO_HOME"]) + @Test + override fun closeAppBackButtonTest() = super.closeAppBackButtonTest() + + companion object { + @JvmStatic + @FlickerConfigProvider + fun flickerConfigProvider(): FlickerConfig = + FlickerConfig().use(FlickerServiceConfig.DEFAULT) + } +} diff --git a/tests/FlickerTests/src/com/android/server/wm/flicker/service/close/flicker/CloseAppHomeButton3ButtonLandscape.kt b/tests/FlickerTests/src/com/android/server/wm/flicker/service/close/flicker/CloseAppHomeButton3ButtonLandscape.kt new file mode 100644 index 000000000000..47c25294f66e --- /dev/null +++ b/tests/FlickerTests/src/com/android/server/wm/flicker/service/close/flicker/CloseAppHomeButton3ButtonLandscape.kt @@ -0,0 +1,42 @@ +/* + * Copyright (C) 2023 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.server.wm.flicker.service.close.flicker + +import android.tools.common.Rotation +import android.tools.common.flicker.FlickerConfig +import android.tools.common.flicker.annotation.ExpectedScenarios +import android.tools.common.flicker.annotation.FlickerConfigProvider +import android.tools.common.flicker.config.FlickerConfig +import android.tools.common.flicker.config.FlickerServiceConfig +import android.tools.device.flicker.junit.FlickerServiceJUnit4ClassRunner +import com.android.server.wm.flicker.service.close.scenarios.CloseAppHomeButton +import org.junit.Test +import org.junit.runner.RunWith + +@RunWith(FlickerServiceJUnit4ClassRunner::class) +class CloseAppHomeButton3ButtonLandscape : CloseAppHomeButton(Rotation.ROTATION_90) { + @ExpectedScenarios(["APP_CLOSE_TO_HOME"]) + @Test + override fun closeAppHomeButton() = super.closeAppHomeButton() + + companion object { + @JvmStatic + @FlickerConfigProvider + fun flickerConfigProvider(): FlickerConfig = + FlickerConfig().use(FlickerServiceConfig.DEFAULT) + } +} diff --git a/tests/FlickerTests/src/com/android/server/wm/flicker/service/close/flicker/CloseAppHomeButton3ButtonPortrait.kt b/tests/FlickerTests/src/com/android/server/wm/flicker/service/close/flicker/CloseAppHomeButton3ButtonPortrait.kt new file mode 100644 index 000000000000..b18148f97759 --- /dev/null +++ b/tests/FlickerTests/src/com/android/server/wm/flicker/service/close/flicker/CloseAppHomeButton3ButtonPortrait.kt @@ -0,0 +1,42 @@ +/* + * Copyright (C) 2023 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.server.wm.flicker.service.close.flicker + +import android.tools.common.Rotation +import android.tools.common.flicker.FlickerConfig +import android.tools.common.flicker.annotation.ExpectedScenarios +import android.tools.common.flicker.annotation.FlickerConfigProvider +import android.tools.common.flicker.config.FlickerConfig +import android.tools.common.flicker.config.FlickerServiceConfig +import android.tools.device.flicker.junit.FlickerServiceJUnit4ClassRunner +import com.android.server.wm.flicker.service.close.scenarios.CloseAppHomeButton +import org.junit.Test +import org.junit.runner.RunWith + +@RunWith(FlickerServiceJUnit4ClassRunner::class) +class CloseAppHomeButton3ButtonPortrait : CloseAppHomeButton(Rotation.ROTATION_0) { + @ExpectedScenarios(["APP_CLOSE_TO_HOME"]) + @Test + override fun closeAppHomeButton() = super.closeAppHomeButton() + + companion object { + @JvmStatic + @FlickerConfigProvider + fun flickerConfigProvider(): FlickerConfig = + FlickerConfig().use(FlickerServiceConfig.DEFAULT) + } +} diff --git a/tests/FlickerTests/src/com/android/server/wm/flicker/service/close/flicker/CloseAppSwipeToHomeGesturalNavLandscape.kt b/tests/FlickerTests/src/com/android/server/wm/flicker/service/close/flicker/CloseAppSwipeToHomeGesturalNavLandscape.kt new file mode 100644 index 000000000000..85430154e202 --- /dev/null +++ b/tests/FlickerTests/src/com/android/server/wm/flicker/service/close/flicker/CloseAppSwipeToHomeGesturalNavLandscape.kt @@ -0,0 +1,42 @@ +/* + * Copyright (C) 2023 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.server.wm.flicker.service.close.flicker + +import android.tools.common.Rotation +import android.tools.common.flicker.FlickerConfig +import android.tools.common.flicker.annotation.ExpectedScenarios +import android.tools.common.flicker.annotation.FlickerConfigProvider +import android.tools.common.flicker.config.FlickerConfig +import android.tools.common.flicker.config.FlickerServiceConfig +import android.tools.device.flicker.junit.FlickerServiceJUnit4ClassRunner +import com.android.server.wm.flicker.service.close.scenarios.CloseAppSwipeToHome +import org.junit.Test +import org.junit.runner.RunWith + +@RunWith(FlickerServiceJUnit4ClassRunner::class) +class CloseAppSwipeToHomeGesturalNavLandscape : CloseAppSwipeToHome(Rotation.ROTATION_90) { + @ExpectedScenarios(["APP_CLOSE_TO_HOME"]) + @Test + override fun closeAppSwipeToHome() = super.closeAppSwipeToHome() + + companion object { + @JvmStatic + @FlickerConfigProvider + fun flickerConfigProvider(): FlickerConfig = + FlickerConfig().use(FlickerServiceConfig.DEFAULT) + } +} diff --git a/tests/FlickerTests/src/com/android/server/wm/flicker/service/close/flicker/CloseAppSwipeToHomeGesturalNavPortrait.kt b/tests/FlickerTests/src/com/android/server/wm/flicker/service/close/flicker/CloseAppSwipeToHomeGesturalNavPortrait.kt new file mode 100644 index 000000000000..f88963b7a341 --- /dev/null +++ b/tests/FlickerTests/src/com/android/server/wm/flicker/service/close/flicker/CloseAppSwipeToHomeGesturalNavPortrait.kt @@ -0,0 +1,42 @@ +/* + * Copyright (C) 2023 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.server.wm.flicker.service.close.flicker + +import android.tools.common.Rotation +import android.tools.common.flicker.FlickerConfig +import android.tools.common.flicker.annotation.ExpectedScenarios +import android.tools.common.flicker.annotation.FlickerConfigProvider +import android.tools.common.flicker.config.FlickerConfig +import android.tools.common.flicker.config.FlickerServiceConfig +import android.tools.device.flicker.junit.FlickerServiceJUnit4ClassRunner +import com.android.server.wm.flicker.service.close.scenarios.CloseAppSwipeToHome +import org.junit.Test +import org.junit.runner.RunWith + +@RunWith(FlickerServiceJUnit4ClassRunner::class) +class CloseAppSwipeToHomeGesturalNavPortrait : CloseAppSwipeToHome(Rotation.ROTATION_0) { + @ExpectedScenarios(["APP_CLOSE_TO_HOME"]) + @Test + override fun closeAppSwipeToHome() = super.closeAppSwipeToHome() + + companion object { + @JvmStatic + @FlickerConfigProvider + fun flickerConfigProvider(): FlickerConfig = + FlickerConfig().use(FlickerServiceConfig.DEFAULT) + } +} diff --git a/tests/FlickerTests/src/com/android/server/wm/flicker/service/close/scenarios/CloseAppBackButton.kt b/tests/FlickerTests/src/com/android/server/wm/flicker/service/close/scenarios/CloseAppBackButton.kt new file mode 100644 index 000000000000..2aaacde52547 --- /dev/null +++ b/tests/FlickerTests/src/com/android/server/wm/flicker/service/close/scenarios/CloseAppBackButton.kt @@ -0,0 +1,61 @@ +/* + * Copyright (C) 2020 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.server.wm.flicker.service.close.scenarios + +import android.app.Instrumentation +import android.tools.common.NavBar +import android.tools.common.Rotation +import android.tools.device.traces.parsers.WindowManagerStateHelper +import androidx.test.platform.app.InstrumentationRegistry +import com.android.launcher3.tapl.LauncherInstrumentation +import com.android.server.wm.flicker.helpers.SimpleAppHelper +import com.android.server.wm.flicker.service.Utils +import org.junit.After +import org.junit.Before +import org.junit.Ignore +import org.junit.Rule +import org.junit.Test + +@Ignore("Base Test Class") +abstract class CloseAppBackButton( + val gestureMode: NavBar = NavBar.MODE_GESTURAL, + val rotation: Rotation = Rotation.ROTATION_0 +) { + private val instrumentation: Instrumentation = InstrumentationRegistry.getInstrumentation() + private val tapl = LauncherInstrumentation() + private val wmHelper = WindowManagerStateHelper(instrumentation) + private val testApp = SimpleAppHelper(instrumentation) + + @Rule @JvmField val testSetupRule = Utils.testSetupRule(gestureMode, rotation) + + @Before + fun setup() { + tapl.setExpectedRotation(rotation.value) + testApp.launchViaIntent(wmHelper) + } + + @Test + open fun closeAppBackButtonTest() { + tapl.pressBack() + wmHelper.StateSyncBuilder().withHomeActivityVisible().waitForAndVerify() + } + + @After + fun teardown() { + testApp.exit(wmHelper) + } +} diff --git a/tests/FlickerTests/src/com/android/server/wm/flicker/service/close/scenarios/CloseAppHomeButton.kt b/tests/FlickerTests/src/com/android/server/wm/flicker/service/close/scenarios/CloseAppHomeButton.kt new file mode 100644 index 000000000000..08683a3ab43d --- /dev/null +++ b/tests/FlickerTests/src/com/android/server/wm/flicker/service/close/scenarios/CloseAppHomeButton.kt @@ -0,0 +1,59 @@ +/* + * Copyright (C) 2020 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.server.wm.flicker.service.close.scenarios + +import android.app.Instrumentation +import android.tools.common.NavBar +import android.tools.common.Rotation +import android.tools.device.traces.parsers.WindowManagerStateHelper +import androidx.test.platform.app.InstrumentationRegistry +import com.android.launcher3.tapl.LauncherInstrumentation +import com.android.server.wm.flicker.helpers.SimpleAppHelper +import com.android.server.wm.flicker.service.Utils +import org.junit.After +import org.junit.Before +import org.junit.Ignore +import org.junit.Rule +import org.junit.Test + +@Ignore("Base Test Class") +abstract class CloseAppHomeButton(val rotation: Rotation = Rotation.ROTATION_0) { + private val instrumentation: Instrumentation = InstrumentationRegistry.getInstrumentation() + private val tapl = LauncherInstrumentation() + private val wmHelper = WindowManagerStateHelper(instrumentation) + private val testApp = SimpleAppHelper(instrumentation) + + @Rule @JvmField val testSetupRule = Utils.testSetupRule(NavBar.MODE_3BUTTON, rotation) + + @Before + fun setup() { + tapl.setExpectedRotation(rotation.value) + testApp.launchViaIntent(wmHelper) + tapl.setExpectedRotationCheckEnabled(false) + } + + @Test + open fun closeAppHomeButton() { + tapl.goHome() + wmHelper.StateSyncBuilder().withHomeActivityVisible().waitForAndVerify() + } + + @After + fun teardown() { + testApp.exit(wmHelper) + } +} diff --git a/tests/FlickerTests/src/com/android/server/wm/flicker/service/close/scenarios/CloseAppSwipeToHome.kt b/tests/FlickerTests/src/com/android/server/wm/flicker/service/close/scenarios/CloseAppSwipeToHome.kt new file mode 100644 index 000000000000..360e11408c92 --- /dev/null +++ b/tests/FlickerTests/src/com/android/server/wm/flicker/service/close/scenarios/CloseAppSwipeToHome.kt @@ -0,0 +1,59 @@ +/* + * Copyright (C) 2020 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.server.wm.flicker.service.close.scenarios + +import android.app.Instrumentation +import android.tools.common.NavBar +import android.tools.common.Rotation +import android.tools.device.traces.parsers.WindowManagerStateHelper +import androidx.test.platform.app.InstrumentationRegistry +import com.android.launcher3.tapl.LauncherInstrumentation +import com.android.server.wm.flicker.helpers.SimpleAppHelper +import com.android.server.wm.flicker.service.Utils +import org.junit.After +import org.junit.Before +import org.junit.Ignore +import org.junit.Rule +import org.junit.Test + +@Ignore("Base Test Class") +abstract class CloseAppSwipeToHome(val rotation: Rotation = Rotation.ROTATION_0) { + private val instrumentation: Instrumentation = InstrumentationRegistry.getInstrumentation() + private val tapl = LauncherInstrumentation() + private val wmHelper = WindowManagerStateHelper(instrumentation) + private val testApp = SimpleAppHelper(instrumentation) + + @Rule @JvmField val testSetupRule = Utils.testSetupRule(NavBar.MODE_GESTURAL, rotation) + + @Before + fun setup() { + tapl.setExpectedRotation(rotation.value) + testApp.launchViaIntent(wmHelper) + tapl.setExpectedRotationCheckEnabled(false) + } + + @Test + open fun closeAppSwipeToHome() { + tapl.goHome() + wmHelper.StateSyncBuilder().withHomeActivityVisible().waitForAndVerify() + } + + @After + fun teardown() { + testApp.exit(wmHelper) + } +} diff --git a/tests/FlickerTests/src/com/android/server/wm/flicker/service/notification/flicker/OpenAppFromLockscreenNotificationCold3ButtonNavLandscape.kt b/tests/FlickerTests/src/com/android/server/wm/flicker/service/notification/flicker/OpenAppFromLockscreenNotificationCold3ButtonNavLandscape.kt new file mode 100644 index 000000000000..bb18770a8e7c --- /dev/null +++ b/tests/FlickerTests/src/com/android/server/wm/flicker/service/notification/flicker/OpenAppFromLockscreenNotificationCold3ButtonNavLandscape.kt @@ -0,0 +1,45 @@ +/* + * Copyright (C) 2023 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.server.wm.flicker.service.notification.flicker + +import android.tools.common.NavBar +import android.tools.common.Rotation +import android.tools.common.flicker.FlickerConfig +import android.tools.common.flicker.annotation.ExpectedScenarios +import android.tools.common.flicker.annotation.FlickerConfigProvider +import android.tools.common.flicker.config.FlickerConfig +import android.tools.common.flicker.config.FlickerServiceConfig +import android.tools.device.flicker.junit.FlickerServiceJUnit4ClassRunner +import com.android.server.wm.flicker.service.notification.scenarios.OpenAppFromLockscreenNotificationCold +import org.junit.Test +import org.junit.runner.RunWith + +@RunWith(FlickerServiceJUnit4ClassRunner::class) +class OpenAppFromLockscreenNotificationCold3ButtonNavLandscape : + OpenAppFromLockscreenNotificationCold(NavBar.MODE_3BUTTON, Rotation.ROTATION_90) { + @ExpectedScenarios(["APP_LAUNCH_FROM_NOTIFICATION"]) + @Test + override fun openAppFromLockscreenNotificationCold() = + super.openAppFromLockscreenNotificationCold() + + companion object { + @JvmStatic + @FlickerConfigProvider + fun flickerConfigProvider(): FlickerConfig = + FlickerConfig().use(FlickerServiceConfig.DEFAULT) + } +} diff --git a/tests/FlickerTests/src/com/android/server/wm/flicker/service/notification/flicker/OpenAppFromLockscreenNotificationCold3ButtonNavPortrait.kt b/tests/FlickerTests/src/com/android/server/wm/flicker/service/notification/flicker/OpenAppFromLockscreenNotificationCold3ButtonNavPortrait.kt new file mode 100644 index 000000000000..1c3cc2188c7c --- /dev/null +++ b/tests/FlickerTests/src/com/android/server/wm/flicker/service/notification/flicker/OpenAppFromLockscreenNotificationCold3ButtonNavPortrait.kt @@ -0,0 +1,45 @@ +/* + * Copyright (C) 2023 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.server.wm.flicker.service.notification.flicker + +import android.tools.common.NavBar +import android.tools.common.Rotation +import android.tools.common.flicker.FlickerConfig +import android.tools.common.flicker.annotation.ExpectedScenarios +import android.tools.common.flicker.annotation.FlickerConfigProvider +import android.tools.common.flicker.config.FlickerConfig +import android.tools.common.flicker.config.FlickerServiceConfig +import android.tools.device.flicker.junit.FlickerServiceJUnit4ClassRunner +import com.android.server.wm.flicker.service.notification.scenarios.OpenAppFromLockscreenNotificationCold +import org.junit.Test +import org.junit.runner.RunWith + +@RunWith(FlickerServiceJUnit4ClassRunner::class) +class OpenAppFromLockscreenNotificationCold3ButtonNavPortrait : + OpenAppFromLockscreenNotificationCold(NavBar.MODE_3BUTTON, Rotation.ROTATION_0) { + @ExpectedScenarios(["APP_LAUNCH_FROM_NOTIFICATION"]) + @Test + override fun openAppFromLockscreenNotificationCold() = + super.openAppFromLockscreenNotificationCold() + + companion object { + @JvmStatic + @FlickerConfigProvider + fun flickerConfigProvider(): FlickerConfig = + FlickerConfig().use(FlickerServiceConfig.DEFAULT) + } +} diff --git a/tests/FlickerTests/src/com/android/server/wm/flicker/service/notification/flicker/OpenAppFromLockscreenNotificationColdGesturalNavLandscape.kt b/tests/FlickerTests/src/com/android/server/wm/flicker/service/notification/flicker/OpenAppFromLockscreenNotificationColdGesturalNavLandscape.kt new file mode 100644 index 000000000000..46d36dbd6b09 --- /dev/null +++ b/tests/FlickerTests/src/com/android/server/wm/flicker/service/notification/flicker/OpenAppFromLockscreenNotificationColdGesturalNavLandscape.kt @@ -0,0 +1,45 @@ +/* + * Copyright (C) 2023 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.server.wm.flicker.service.notification.flicker + +import android.tools.common.NavBar +import android.tools.common.Rotation +import android.tools.common.flicker.FlickerConfig +import android.tools.common.flicker.annotation.ExpectedScenarios +import android.tools.common.flicker.annotation.FlickerConfigProvider +import android.tools.common.flicker.config.FlickerConfig +import android.tools.common.flicker.config.FlickerServiceConfig +import android.tools.device.flicker.junit.FlickerServiceJUnit4ClassRunner +import com.android.server.wm.flicker.service.notification.scenarios.OpenAppFromLockscreenNotificationCold +import org.junit.Test +import org.junit.runner.RunWith + +@RunWith(FlickerServiceJUnit4ClassRunner::class) +class OpenAppFromLockscreenNotificationColdGesturalNavLandscape : + OpenAppFromLockscreenNotificationCold(NavBar.MODE_GESTURAL, Rotation.ROTATION_90) { + @ExpectedScenarios(["APP_LAUNCH_FROM_NOTIFICATION"]) + @Test + override fun openAppFromLockscreenNotificationCold() = + super.openAppFromLockscreenNotificationCold() + + companion object { + @JvmStatic + @FlickerConfigProvider + fun flickerConfigProvider(): FlickerConfig = + FlickerConfig().use(FlickerServiceConfig.DEFAULT) + } +} diff --git a/tests/FlickerTests/src/com/android/server/wm/flicker/service/notification/flicker/OpenAppFromLockscreenNotificationColdGesturalNavPortrait.kt b/tests/FlickerTests/src/com/android/server/wm/flicker/service/notification/flicker/OpenAppFromLockscreenNotificationColdGesturalNavPortrait.kt new file mode 100644 index 000000000000..f6a668feeed6 --- /dev/null +++ b/tests/FlickerTests/src/com/android/server/wm/flicker/service/notification/flicker/OpenAppFromLockscreenNotificationColdGesturalNavPortrait.kt @@ -0,0 +1,45 @@ +/* + * Copyright (C) 2023 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.server.wm.flicker.service.notification.flicker + +import android.tools.common.NavBar +import android.tools.common.Rotation +import android.tools.common.flicker.FlickerConfig +import android.tools.common.flicker.annotation.ExpectedScenarios +import android.tools.common.flicker.annotation.FlickerConfigProvider +import android.tools.common.flicker.config.FlickerConfig +import android.tools.common.flicker.config.FlickerServiceConfig +import android.tools.device.flicker.junit.FlickerServiceJUnit4ClassRunner +import com.android.server.wm.flicker.service.notification.scenarios.OpenAppFromLockscreenNotificationCold +import org.junit.Test +import org.junit.runner.RunWith + +@RunWith(FlickerServiceJUnit4ClassRunner::class) +class OpenAppFromLockscreenNotificationColdGesturalNavPortrait : + OpenAppFromLockscreenNotificationCold(NavBar.MODE_GESTURAL, Rotation.ROTATION_0) { + @ExpectedScenarios(["APP_LAUNCH_FROM_NOTIFICATION"]) + @Test + override fun openAppFromLockscreenNotificationCold() = + super.openAppFromLockscreenNotificationCold() + + companion object { + @JvmStatic + @FlickerConfigProvider + fun flickerConfigProvider(): FlickerConfig = + FlickerConfig().use(FlickerServiceConfig.DEFAULT) + } +} diff --git a/tests/FlickerTests/src/com/android/server/wm/flicker/service/notification/flicker/OpenAppFromLockscreenNotificationWarm3ButtonNavLandscape.kt b/tests/FlickerTests/src/com/android/server/wm/flicker/service/notification/flicker/OpenAppFromLockscreenNotificationWarm3ButtonNavLandscape.kt new file mode 100644 index 000000000000..93200ba1b6fe --- /dev/null +++ b/tests/FlickerTests/src/com/android/server/wm/flicker/service/notification/flicker/OpenAppFromLockscreenNotificationWarm3ButtonNavLandscape.kt @@ -0,0 +1,45 @@ +/* + * Copyright (C) 2023 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.server.wm.flicker.service.notification.flicker + +import android.tools.common.NavBar +import android.tools.common.Rotation +import android.tools.common.flicker.FlickerConfig +import android.tools.common.flicker.annotation.ExpectedScenarios +import android.tools.common.flicker.annotation.FlickerConfigProvider +import android.tools.common.flicker.config.FlickerConfig +import android.tools.common.flicker.config.FlickerServiceConfig +import android.tools.device.flicker.junit.FlickerServiceJUnit4ClassRunner +import com.android.server.wm.flicker.service.notification.scenarios.OpenAppFromLockscreenNotificationWarm +import org.junit.Test +import org.junit.runner.RunWith + +@RunWith(FlickerServiceJUnit4ClassRunner::class) +class OpenAppFromLockscreenNotificationWarm3ButtonNavLandscape : + OpenAppFromLockscreenNotificationWarm(NavBar.MODE_3BUTTON, Rotation.ROTATION_90) { + @ExpectedScenarios(["APP_LAUNCH_FROM_NOTIFICATION"]) + @Test + override fun openAppFromLockscreenNotificationWarm() = + super.openAppFromLockscreenNotificationWarm() + + companion object { + @JvmStatic + @FlickerConfigProvider + fun flickerConfigProvider(): FlickerConfig = + FlickerConfig().use(FlickerServiceConfig.DEFAULT) + } +} diff --git a/tests/FlickerTests/src/com/android/server/wm/flicker/service/notification/flicker/OpenAppFromLockscreenNotificationWarm3ButtonNavPortrait.kt b/tests/FlickerTests/src/com/android/server/wm/flicker/service/notification/flicker/OpenAppFromLockscreenNotificationWarm3ButtonNavPortrait.kt new file mode 100644 index 000000000000..f5d41d250b1e --- /dev/null +++ b/tests/FlickerTests/src/com/android/server/wm/flicker/service/notification/flicker/OpenAppFromLockscreenNotificationWarm3ButtonNavPortrait.kt @@ -0,0 +1,45 @@ +/* + * Copyright (C) 2023 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.server.wm.flicker.service.notification.flicker + +import android.tools.common.NavBar +import android.tools.common.Rotation +import android.tools.common.flicker.FlickerConfig +import android.tools.common.flicker.annotation.ExpectedScenarios +import android.tools.common.flicker.annotation.FlickerConfigProvider +import android.tools.common.flicker.config.FlickerConfig +import android.tools.common.flicker.config.FlickerServiceConfig +import android.tools.device.flicker.junit.FlickerServiceJUnit4ClassRunner +import com.android.server.wm.flicker.service.notification.scenarios.OpenAppFromLockscreenNotificationWarm +import org.junit.Test +import org.junit.runner.RunWith + +@RunWith(FlickerServiceJUnit4ClassRunner::class) +class OpenAppFromLockscreenNotificationWarm3ButtonNavPortrait : + OpenAppFromLockscreenNotificationWarm(NavBar.MODE_3BUTTON, Rotation.ROTATION_0) { + @ExpectedScenarios(["APP_LAUNCH_FROM_NOTIFICATION"]) + @Test + override fun openAppFromLockscreenNotificationWarm() = + super.openAppFromLockscreenNotificationWarm() + + companion object { + @JvmStatic + @FlickerConfigProvider + fun flickerConfigProvider(): FlickerConfig = + FlickerConfig().use(FlickerServiceConfig.DEFAULT) + } +} diff --git a/tests/FlickerTests/src/com/android/server/wm/flicker/service/notification/flicker/OpenAppFromLockscreenNotificationWarmGesturalNavLandscape.kt b/tests/FlickerTests/src/com/android/server/wm/flicker/service/notification/flicker/OpenAppFromLockscreenNotificationWarmGesturalNavLandscape.kt new file mode 100644 index 000000000000..28f322bee130 --- /dev/null +++ b/tests/FlickerTests/src/com/android/server/wm/flicker/service/notification/flicker/OpenAppFromLockscreenNotificationWarmGesturalNavLandscape.kt @@ -0,0 +1,45 @@ +/* + * Copyright (C) 2023 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.server.wm.flicker.service.notification.flicker + +import android.tools.common.NavBar +import android.tools.common.Rotation +import android.tools.common.flicker.FlickerConfig +import android.tools.common.flicker.annotation.ExpectedScenarios +import android.tools.common.flicker.annotation.FlickerConfigProvider +import android.tools.common.flicker.config.FlickerConfig +import android.tools.common.flicker.config.FlickerServiceConfig +import android.tools.device.flicker.junit.FlickerServiceJUnit4ClassRunner +import com.android.server.wm.flicker.service.notification.scenarios.OpenAppFromLockscreenNotificationWarm +import org.junit.Test +import org.junit.runner.RunWith + +@RunWith(FlickerServiceJUnit4ClassRunner::class) +class OpenAppFromLockscreenNotificationWarmGesturalNavLandscape : + OpenAppFromLockscreenNotificationWarm(NavBar.MODE_GESTURAL, Rotation.ROTATION_90) { + @ExpectedScenarios(["APP_LAUNCH_FROM_NOTIFICATION"]) + @Test + override fun openAppFromLockscreenNotificationWarm() = + super.openAppFromLockscreenNotificationWarm() + + companion object { + @JvmStatic + @FlickerConfigProvider + fun flickerConfigProvider(): FlickerConfig = + FlickerConfig().use(FlickerServiceConfig.DEFAULT) + } +} diff --git a/tests/FlickerTests/src/com/android/server/wm/flicker/service/notification/flicker/OpenAppFromLockscreenNotificationWarmGesturalNavPortrait.kt b/tests/FlickerTests/src/com/android/server/wm/flicker/service/notification/flicker/OpenAppFromLockscreenNotificationWarmGesturalNavPortrait.kt new file mode 100644 index 000000000000..beb3fae8be48 --- /dev/null +++ b/tests/FlickerTests/src/com/android/server/wm/flicker/service/notification/flicker/OpenAppFromLockscreenNotificationWarmGesturalNavPortrait.kt @@ -0,0 +1,45 @@ +/* + * Copyright (C) 2023 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.server.wm.flicker.service.notification.flicker + +import android.tools.common.NavBar +import android.tools.common.Rotation +import android.tools.common.flicker.FlickerConfig +import android.tools.common.flicker.annotation.ExpectedScenarios +import android.tools.common.flicker.annotation.FlickerConfigProvider +import android.tools.common.flicker.config.FlickerConfig +import android.tools.common.flicker.config.FlickerServiceConfig +import android.tools.device.flicker.junit.FlickerServiceJUnit4ClassRunner +import com.android.server.wm.flicker.service.notification.scenarios.OpenAppFromLockscreenNotificationWarm +import org.junit.Test +import org.junit.runner.RunWith + +@RunWith(FlickerServiceJUnit4ClassRunner::class) +class OpenAppFromLockscreenNotificationWarmGesturalNavPortrait : + OpenAppFromLockscreenNotificationWarm(NavBar.MODE_GESTURAL, Rotation.ROTATION_0) { + @ExpectedScenarios(["APP_LAUNCH_FROM_NOTIFICATION"]) + @Test + override fun openAppFromLockscreenNotificationWarm() = + super.openAppFromLockscreenNotificationWarm() + + companion object { + @JvmStatic + @FlickerConfigProvider + fun flickerConfigProvider(): FlickerConfig = + FlickerConfig().use(FlickerServiceConfig.DEFAULT) + } +} diff --git a/tests/FlickerTests/src/com/android/server/wm/flicker/service/notification/flicker/OpenAppFromLockscreenNotificationWithOverlayApp3ButtonNavLandscape.kt b/tests/FlickerTests/src/com/android/server/wm/flicker/service/notification/flicker/OpenAppFromLockscreenNotificationWithOverlayApp3ButtonNavLandscape.kt new file mode 100644 index 000000000000..4adcc8bf5f0b --- /dev/null +++ b/tests/FlickerTests/src/com/android/server/wm/flicker/service/notification/flicker/OpenAppFromLockscreenNotificationWithOverlayApp3ButtonNavLandscape.kt @@ -0,0 +1,47 @@ +/* + * Copyright (C) 2023 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.server.wm.flicker.service.notification.flicker + +import android.tools.common.NavBar +import android.tools.common.Rotation +import android.tools.common.flicker.FlickerConfig +import android.tools.common.flicker.annotation.ExpectedScenarios +import android.tools.common.flicker.annotation.FlickerConfigProvider +import android.tools.common.flicker.config.FlickerConfig +import android.tools.common.flicker.config.FlickerServiceConfig +import android.tools.device.flicker.junit.FlickerServiceJUnit4ClassRunner +import com.android.server.wm.flicker.service.notification.scenarios.OpenAppFromLockscreenNotificationWithOverlayApp +import org.junit.Ignore +import org.junit.Test +import org.junit.runner.RunWith + +@RunWith(FlickerServiceJUnit4ClassRunner::class) +@Ignore("b/294418322: no notification launch animation exists when keyguard is occluded") +class OpenAppFromLockscreenNotificationWithOverlayApp3ButtonNavLandscape : + OpenAppFromLockscreenNotificationWithOverlayApp(NavBar.MODE_3BUTTON, Rotation.ROTATION_90) { + @ExpectedScenarios(["APP_LAUNCH_FROM_NOTIFICATION"]) + @Test + override fun openAppFromLockscreenNotificationWithOverlayApp() = + super.openAppFromLockscreenNotificationWithOverlayApp() + + companion object { + @JvmStatic + @FlickerConfigProvider + fun flickerConfigProvider(): FlickerConfig = + FlickerConfig().use(FlickerServiceConfig.DEFAULT) + } +} diff --git a/tests/FlickerTests/src/com/android/server/wm/flicker/service/notification/flicker/OpenAppFromLockscreenNotificationWithOverlayApp3ButtonNavPortrait.kt b/tests/FlickerTests/src/com/android/server/wm/flicker/service/notification/flicker/OpenAppFromLockscreenNotificationWithOverlayApp3ButtonNavPortrait.kt new file mode 100644 index 000000000000..f7211e7287cf --- /dev/null +++ b/tests/FlickerTests/src/com/android/server/wm/flicker/service/notification/flicker/OpenAppFromLockscreenNotificationWithOverlayApp3ButtonNavPortrait.kt @@ -0,0 +1,47 @@ +/* + * Copyright (C) 2023 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.server.wm.flicker.service.notification.flicker + +import android.tools.common.NavBar +import android.tools.common.Rotation +import android.tools.common.flicker.FlickerConfig +import android.tools.common.flicker.annotation.ExpectedScenarios +import android.tools.common.flicker.annotation.FlickerConfigProvider +import android.tools.common.flicker.config.FlickerConfig +import android.tools.common.flicker.config.FlickerServiceConfig +import android.tools.device.flicker.junit.FlickerServiceJUnit4ClassRunner +import com.android.server.wm.flicker.service.notification.scenarios.OpenAppFromLockscreenNotificationWithOverlayApp +import org.junit.Ignore +import org.junit.Test +import org.junit.runner.RunWith + +@RunWith(FlickerServiceJUnit4ClassRunner::class) +@Ignore("b/294418322: no notification launch animation exists when keyguard is occluded") +class OpenAppFromLockscreenNotificationWithOverlayApp3ButtonNavPortrait : + OpenAppFromLockscreenNotificationWithOverlayApp(NavBar.MODE_3BUTTON, Rotation.ROTATION_0) { + @ExpectedScenarios(["APP_LAUNCH_FROM_NOTIFICATION"]) + @Test + override fun openAppFromLockscreenNotificationWithOverlayApp() = + super.openAppFromLockscreenNotificationWithOverlayApp() + + companion object { + @JvmStatic + @FlickerConfigProvider + fun flickerConfigProvider(): FlickerConfig = + FlickerConfig().use(FlickerServiceConfig.DEFAULT) + } +} diff --git a/tests/FlickerTests/src/com/android/server/wm/flicker/service/notification/flicker/OpenAppFromLockscreenNotificationWithOverlayAppGesturalNavLandscape.kt b/tests/FlickerTests/src/com/android/server/wm/flicker/service/notification/flicker/OpenAppFromLockscreenNotificationWithOverlayAppGesturalNavLandscape.kt new file mode 100644 index 000000000000..1ade9560d90f --- /dev/null +++ b/tests/FlickerTests/src/com/android/server/wm/flicker/service/notification/flicker/OpenAppFromLockscreenNotificationWithOverlayAppGesturalNavLandscape.kt @@ -0,0 +1,47 @@ +/* + * Copyright (C) 2023 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.server.wm.flicker.service.notification.flicker + +import android.tools.common.NavBar +import android.tools.common.Rotation +import android.tools.common.flicker.FlickerConfig +import android.tools.common.flicker.annotation.ExpectedScenarios +import android.tools.common.flicker.annotation.FlickerConfigProvider +import android.tools.common.flicker.config.FlickerConfig +import android.tools.common.flicker.config.FlickerServiceConfig +import android.tools.device.flicker.junit.FlickerServiceJUnit4ClassRunner +import com.android.server.wm.flicker.service.notification.scenarios.OpenAppFromLockscreenNotificationWithOverlayApp +import org.junit.Ignore +import org.junit.Test +import org.junit.runner.RunWith + +@RunWith(FlickerServiceJUnit4ClassRunner::class) +@Ignore("b/294418322: no notification launch animation exists when keyguard is occluded") +class OpenAppFromLockscreenNotificationWithOverlayAppGesturalNavLandscape : + OpenAppFromLockscreenNotificationWithOverlayApp(NavBar.MODE_GESTURAL, Rotation.ROTATION_90) { + @ExpectedScenarios(["APP_LAUNCH_FROM_NOTIFICATION"]) + @Test + override fun openAppFromLockscreenNotificationWithOverlayApp() = + super.openAppFromLockscreenNotificationWithOverlayApp() + + companion object { + @JvmStatic + @FlickerConfigProvider + fun flickerConfigProvider(): FlickerConfig = + FlickerConfig().use(FlickerServiceConfig.DEFAULT) + } +} diff --git a/tests/FlickerTests/src/com/android/server/wm/flicker/service/notification/flicker/OpenAppFromLockscreenNotificationWithOverlayAppGesturalNavPortrait.kt b/tests/FlickerTests/src/com/android/server/wm/flicker/service/notification/flicker/OpenAppFromLockscreenNotificationWithOverlayAppGesturalNavPortrait.kt new file mode 100644 index 000000000000..ea26f0867c7f --- /dev/null +++ b/tests/FlickerTests/src/com/android/server/wm/flicker/service/notification/flicker/OpenAppFromLockscreenNotificationWithOverlayAppGesturalNavPortrait.kt @@ -0,0 +1,47 @@ +/* + * Copyright (C) 2023 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.server.wm.flicker.service.notification.flicker + +import android.tools.common.NavBar +import android.tools.common.Rotation +import android.tools.common.flicker.FlickerConfig +import android.tools.common.flicker.annotation.ExpectedScenarios +import android.tools.common.flicker.annotation.FlickerConfigProvider +import android.tools.common.flicker.config.FlickerConfig +import android.tools.common.flicker.config.FlickerServiceConfig +import android.tools.device.flicker.junit.FlickerServiceJUnit4ClassRunner +import com.android.server.wm.flicker.service.notification.scenarios.OpenAppFromLockscreenNotificationWithOverlayApp +import org.junit.Ignore +import org.junit.Test +import org.junit.runner.RunWith + +@RunWith(FlickerServiceJUnit4ClassRunner::class) +@Ignore("b/294418322: no notification launch animation exists when keyguard is occluded") +class OpenAppFromLockscreenNotificationWithOverlayAppGesturalNavPortrait : + OpenAppFromLockscreenNotificationWithOverlayApp(NavBar.MODE_GESTURAL, Rotation.ROTATION_0) { + @ExpectedScenarios(["APP_LAUNCH_FROM_NOTIFICATION"]) + @Test + override fun openAppFromLockscreenNotificationWithOverlayApp() = + super.openAppFromLockscreenNotificationWithOverlayApp() + + companion object { + @JvmStatic + @FlickerConfigProvider + fun flickerConfigProvider(): FlickerConfig = + FlickerConfig().use(FlickerServiceConfig.DEFAULT) + } +} diff --git a/tests/FlickerTests/src/com/android/server/wm/flicker/service/notification/flicker/OpenAppFromNotificationCold3ButtonNavLandscape.kt b/tests/FlickerTests/src/com/android/server/wm/flicker/service/notification/flicker/OpenAppFromNotificationCold3ButtonNavLandscape.kt new file mode 100644 index 000000000000..866190f78827 --- /dev/null +++ b/tests/FlickerTests/src/com/android/server/wm/flicker/service/notification/flicker/OpenAppFromNotificationCold3ButtonNavLandscape.kt @@ -0,0 +1,44 @@ +/* + * Copyright (C) 2023 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.server.wm.flicker.service.notification.flicker + +import android.tools.common.NavBar +import android.tools.common.Rotation +import android.tools.common.flicker.FlickerConfig +import android.tools.common.flicker.annotation.ExpectedScenarios +import android.tools.common.flicker.annotation.FlickerConfigProvider +import android.tools.common.flicker.config.FlickerConfig +import android.tools.common.flicker.config.FlickerServiceConfig +import android.tools.device.flicker.junit.FlickerServiceJUnit4ClassRunner +import com.android.server.wm.flicker.service.notification.scenarios.OpenAppFromNotificationCold +import org.junit.Test +import org.junit.runner.RunWith + +@RunWith(FlickerServiceJUnit4ClassRunner::class) +class OpenAppFromNotificationCold3ButtonNavLandscape : + OpenAppFromNotificationCold(NavBar.MODE_3BUTTON, Rotation.ROTATION_90) { + @ExpectedScenarios(["APP_LAUNCH_FROM_NOTIFICATION"]) + @Test + override fun openAppFromNotificationCold() = super.openAppFromNotificationCold() + + companion object { + @JvmStatic + @FlickerConfigProvider + fun flickerConfigProvider(): FlickerConfig = + FlickerConfig().use(FlickerServiceConfig.DEFAULT) + } +} diff --git a/tests/FlickerTests/src/com/android/server/wm/flicker/service/notification/flicker/OpenAppFromNotificationCold3ButtonNavPortrait.kt b/tests/FlickerTests/src/com/android/server/wm/flicker/service/notification/flicker/OpenAppFromNotificationCold3ButtonNavPortrait.kt new file mode 100644 index 000000000000..a8d628328ed9 --- /dev/null +++ b/tests/FlickerTests/src/com/android/server/wm/flicker/service/notification/flicker/OpenAppFromNotificationCold3ButtonNavPortrait.kt @@ -0,0 +1,44 @@ +/* + * Copyright (C) 2023 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.server.wm.flicker.service.notification.flicker + +import android.tools.common.NavBar +import android.tools.common.Rotation +import android.tools.common.flicker.FlickerConfig +import android.tools.common.flicker.annotation.ExpectedScenarios +import android.tools.common.flicker.annotation.FlickerConfigProvider +import android.tools.common.flicker.config.FlickerConfig +import android.tools.common.flicker.config.FlickerServiceConfig +import android.tools.device.flicker.junit.FlickerServiceJUnit4ClassRunner +import com.android.server.wm.flicker.service.notification.scenarios.OpenAppFromNotificationCold +import org.junit.Test +import org.junit.runner.RunWith + +@RunWith(FlickerServiceJUnit4ClassRunner::class) +class OpenAppFromNotificationCold3ButtonNavPortrait : + OpenAppFromNotificationCold(NavBar.MODE_3BUTTON, Rotation.ROTATION_0) { + @ExpectedScenarios(["APP_LAUNCH_FROM_NOTIFICATION"]) + @Test + override fun openAppFromNotificationCold() = super.openAppFromNotificationCold() + + companion object { + @JvmStatic + @FlickerConfigProvider + fun flickerConfigProvider(): FlickerConfig = + FlickerConfig().use(FlickerServiceConfig.DEFAULT) + } +} diff --git a/tests/FlickerTests/src/com/android/server/wm/flicker/service/notification/flicker/OpenAppFromNotificationColdGesturalNavLandscape.kt b/tests/FlickerTests/src/com/android/server/wm/flicker/service/notification/flicker/OpenAppFromNotificationColdGesturalNavLandscape.kt new file mode 100644 index 000000000000..ef84c3f1177e --- /dev/null +++ b/tests/FlickerTests/src/com/android/server/wm/flicker/service/notification/flicker/OpenAppFromNotificationColdGesturalNavLandscape.kt @@ -0,0 +1,44 @@ +/* + * Copyright (C) 2023 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.server.wm.flicker.service.notification.flicker + +import android.tools.common.NavBar +import android.tools.common.Rotation +import android.tools.common.flicker.FlickerConfig +import android.tools.common.flicker.annotation.ExpectedScenarios +import android.tools.common.flicker.annotation.FlickerConfigProvider +import android.tools.common.flicker.config.FlickerConfig +import android.tools.common.flicker.config.FlickerServiceConfig +import android.tools.device.flicker.junit.FlickerServiceJUnit4ClassRunner +import com.android.server.wm.flicker.service.notification.scenarios.OpenAppFromNotificationCold +import org.junit.Test +import org.junit.runner.RunWith + +@RunWith(FlickerServiceJUnit4ClassRunner::class) +class OpenAppFromNotificationColdGesturalNavLandscape : + OpenAppFromNotificationCold(NavBar.MODE_GESTURAL, Rotation.ROTATION_90) { + @ExpectedScenarios(["APP_LAUNCH_FROM_NOTIFICATION"]) + @Test + override fun openAppFromNotificationCold() = super.openAppFromNotificationCold() + + companion object { + @JvmStatic + @FlickerConfigProvider + fun flickerConfigProvider(): FlickerConfig = + FlickerConfig().use(FlickerServiceConfig.DEFAULT) + } +} diff --git a/tests/FlickerTests/src/com/android/server/wm/flicker/service/notification/flicker/OpenAppFromNotificationColdGesturalNavPortrait.kt b/tests/FlickerTests/src/com/android/server/wm/flicker/service/notification/flicker/OpenAppFromNotificationColdGesturalNavPortrait.kt new file mode 100644 index 000000000000..5bb6b3713e9f --- /dev/null +++ b/tests/FlickerTests/src/com/android/server/wm/flicker/service/notification/flicker/OpenAppFromNotificationColdGesturalNavPortrait.kt @@ -0,0 +1,44 @@ +/* + * Copyright (C) 2023 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.server.wm.flicker.service.notification.flicker + +import android.tools.common.NavBar +import android.tools.common.Rotation +import android.tools.common.flicker.FlickerConfig +import android.tools.common.flicker.annotation.ExpectedScenarios +import android.tools.common.flicker.annotation.FlickerConfigProvider +import android.tools.common.flicker.config.FlickerConfig +import android.tools.common.flicker.config.FlickerServiceConfig +import android.tools.device.flicker.junit.FlickerServiceJUnit4ClassRunner +import com.android.server.wm.flicker.service.notification.scenarios.OpenAppFromNotificationCold +import org.junit.Test +import org.junit.runner.RunWith + +@RunWith(FlickerServiceJUnit4ClassRunner::class) +class OpenAppFromNotificationColdGesturalNavPortrait : + OpenAppFromNotificationCold(NavBar.MODE_GESTURAL, Rotation.ROTATION_0) { + @ExpectedScenarios(["APP_LAUNCH_FROM_NOTIFICATION"]) + @Test + override fun openAppFromNotificationCold() = super.openAppFromNotificationCold() + + companion object { + @JvmStatic + @FlickerConfigProvider + fun flickerConfigProvider(): FlickerConfig = + FlickerConfig().use(FlickerServiceConfig.DEFAULT) + } +} diff --git a/tests/FlickerTests/src/com/android/server/wm/flicker/service/notification/flicker/OpenAppFromNotificationWarm3ButtonNavLandscape.kt b/tests/FlickerTests/src/com/android/server/wm/flicker/service/notification/flicker/OpenAppFromNotificationWarm3ButtonNavLandscape.kt new file mode 100644 index 000000000000..39f25e97f04c --- /dev/null +++ b/tests/FlickerTests/src/com/android/server/wm/flicker/service/notification/flicker/OpenAppFromNotificationWarm3ButtonNavLandscape.kt @@ -0,0 +1,44 @@ +/* + * Copyright (C) 2023 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.server.wm.flicker.service.notification.flicker + +import android.tools.common.NavBar +import android.tools.common.Rotation +import android.tools.common.flicker.FlickerConfig +import android.tools.common.flicker.annotation.ExpectedScenarios +import android.tools.common.flicker.annotation.FlickerConfigProvider +import android.tools.common.flicker.config.FlickerConfig +import android.tools.common.flicker.config.FlickerServiceConfig +import android.tools.device.flicker.junit.FlickerServiceJUnit4ClassRunner +import com.android.server.wm.flicker.service.notification.scenarios.OpenAppFromNotificationWarm +import org.junit.Test +import org.junit.runner.RunWith + +@RunWith(FlickerServiceJUnit4ClassRunner::class) +class OpenAppFromNotificationWarm3ButtonNavLandscape : + OpenAppFromNotificationWarm(NavBar.MODE_3BUTTON, Rotation.ROTATION_90) { + @ExpectedScenarios(["APP_LAUNCH_FROM_NOTIFICATION"]) + @Test + override fun openAppFromNotificationWarm() = super.openAppFromNotificationWarm() + + companion object { + @JvmStatic + @FlickerConfigProvider + fun flickerConfigProvider(): FlickerConfig = + FlickerConfig().use(FlickerServiceConfig.DEFAULT) + } +} diff --git a/tests/FlickerTests/src/com/android/server/wm/flicker/service/notification/flicker/OpenAppFromNotificationWarm3ButtonNavPortrait.kt b/tests/FlickerTests/src/com/android/server/wm/flicker/service/notification/flicker/OpenAppFromNotificationWarm3ButtonNavPortrait.kt new file mode 100644 index 000000000000..28816bcba2a1 --- /dev/null +++ b/tests/FlickerTests/src/com/android/server/wm/flicker/service/notification/flicker/OpenAppFromNotificationWarm3ButtonNavPortrait.kt @@ -0,0 +1,44 @@ +/* + * Copyright (C) 2023 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.server.wm.flicker.service.notification.flicker + +import android.tools.common.NavBar +import android.tools.common.Rotation +import android.tools.common.flicker.FlickerConfig +import android.tools.common.flicker.annotation.ExpectedScenarios +import android.tools.common.flicker.annotation.FlickerConfigProvider +import android.tools.common.flicker.config.FlickerConfig +import android.tools.common.flicker.config.FlickerServiceConfig +import android.tools.device.flicker.junit.FlickerServiceJUnit4ClassRunner +import com.android.server.wm.flicker.service.notification.scenarios.OpenAppFromNotificationWarm +import org.junit.Test +import org.junit.runner.RunWith + +@RunWith(FlickerServiceJUnit4ClassRunner::class) +class OpenAppFromNotificationWarm3ButtonNavPortrait : + OpenAppFromNotificationWarm(NavBar.MODE_3BUTTON, Rotation.ROTATION_0) { + @ExpectedScenarios(["APP_LAUNCH_FROM_NOTIFICATION"]) + @Test + override fun openAppFromNotificationWarm() = super.openAppFromNotificationWarm() + + companion object { + @JvmStatic + @FlickerConfigProvider + fun flickerConfigProvider(): FlickerConfig = + FlickerConfig().use(FlickerServiceConfig.DEFAULT) + } +} diff --git a/tests/FlickerTests/src/com/android/server/wm/flicker/service/notification/flicker/OpenAppFromNotificationWarmGesturalNavLandscape.kt b/tests/FlickerTests/src/com/android/server/wm/flicker/service/notification/flicker/OpenAppFromNotificationWarmGesturalNavLandscape.kt new file mode 100644 index 000000000000..94ffe4e57994 --- /dev/null +++ b/tests/FlickerTests/src/com/android/server/wm/flicker/service/notification/flicker/OpenAppFromNotificationWarmGesturalNavLandscape.kt @@ -0,0 +1,44 @@ +/* + * Copyright (C) 2023 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.server.wm.flicker.service.notification.flicker + +import android.tools.common.NavBar +import android.tools.common.Rotation +import android.tools.common.flicker.FlickerConfig +import android.tools.common.flicker.annotation.ExpectedScenarios +import android.tools.common.flicker.annotation.FlickerConfigProvider +import android.tools.common.flicker.config.FlickerConfig +import android.tools.common.flicker.config.FlickerServiceConfig +import android.tools.device.flicker.junit.FlickerServiceJUnit4ClassRunner +import com.android.server.wm.flicker.service.notification.scenarios.OpenAppFromNotificationWarm +import org.junit.Test +import org.junit.runner.RunWith + +@RunWith(FlickerServiceJUnit4ClassRunner::class) +class OpenAppFromNotificationWarmGesturalNavLandscape : + OpenAppFromNotificationWarm(NavBar.MODE_GESTURAL, Rotation.ROTATION_90) { + @ExpectedScenarios(["APP_LAUNCH_FROM_NOTIFICATION"]) + @Test + override fun openAppFromNotificationWarm() = super.openAppFromNotificationWarm() + + companion object { + @JvmStatic + @FlickerConfigProvider + fun flickerConfigProvider(): FlickerConfig = + FlickerConfig().use(FlickerServiceConfig.DEFAULT) + } +} diff --git a/tests/FlickerTests/src/com/android/server/wm/flicker/service/notification/flicker/OpenAppFromNotificationWarmGesturalNavPortrait.kt b/tests/FlickerTests/src/com/android/server/wm/flicker/service/notification/flicker/OpenAppFromNotificationWarmGesturalNavPortrait.kt new file mode 100644 index 000000000000..e5f5ec4a6fe8 --- /dev/null +++ b/tests/FlickerTests/src/com/android/server/wm/flicker/service/notification/flicker/OpenAppFromNotificationWarmGesturalNavPortrait.kt @@ -0,0 +1,44 @@ +/* + * Copyright (C) 2023 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.server.wm.flicker.service.notification.flicker + +import android.tools.common.NavBar +import android.tools.common.Rotation +import android.tools.common.flicker.FlickerConfig +import android.tools.common.flicker.annotation.ExpectedScenarios +import android.tools.common.flicker.annotation.FlickerConfigProvider +import android.tools.common.flicker.config.FlickerConfig +import android.tools.common.flicker.config.FlickerServiceConfig +import android.tools.device.flicker.junit.FlickerServiceJUnit4ClassRunner +import com.android.server.wm.flicker.service.notification.scenarios.OpenAppFromNotificationWarm +import org.junit.Test +import org.junit.runner.RunWith + +@RunWith(FlickerServiceJUnit4ClassRunner::class) +class OpenAppFromNotificationWarmGesturalNavPortrait : + OpenAppFromNotificationWarm(NavBar.MODE_GESTURAL, Rotation.ROTATION_0) { + @ExpectedScenarios(["APP_LAUNCH_FROM_NOTIFICATION"]) + @Test + override fun openAppFromNotificationWarm() = super.openAppFromNotificationWarm() + + companion object { + @JvmStatic + @FlickerConfigProvider + fun flickerConfigProvider(): FlickerConfig = + FlickerConfig().use(FlickerServiceConfig.DEFAULT) + } +} diff --git a/tests/FlickerTests/src/com/android/server/wm/flicker/service/notification/scenarios/NotificationUtils.kt b/tests/FlickerTests/src/com/android/server/wm/flicker/service/notification/scenarios/NotificationUtils.kt new file mode 100644 index 000000000000..ac4e16969bad --- /dev/null +++ b/tests/FlickerTests/src/com/android/server/wm/flicker/service/notification/scenarios/NotificationUtils.kt @@ -0,0 +1,66 @@ +/* + * Copyright (C) 2023 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.server.wm.flicker.service.notification.scenarios + +import android.app.Instrumentation +import android.tools.device.traces.parsers.WindowManagerStateHelper +import android.view.WindowInsets +import android.view.WindowManager +import androidx.test.platform.app.InstrumentationRegistry +import androidx.test.uiautomator.By +import androidx.test.uiautomator.UiDevice +import androidx.test.uiautomator.Until +import com.android.launcher3.tapl.LauncherInstrumentation + +object NotificationUtils { + private val instrumentation: Instrumentation = InstrumentationRegistry.getInstrumentation() + private val tapl = LauncherInstrumentation() + private val wmHelper = WindowManagerStateHelper(instrumentation) + private val device = UiDevice.getInstance(instrumentation) + + fun openNotification(openingNotificationsFromLockScreen: Boolean) { + var startY = 10 + var endY = 3 * device.displayHeight / 4 + var steps = 25 + if (openingNotificationsFromLockScreen) { + val wm: WindowManager = + instrumentation.context.getSystemService(WindowManager::class.java) + ?: error("Unable to connect to WindowManager service") + val metricInsets = wm.currentWindowMetrics.windowInsets + val insets = + metricInsets.getInsetsIgnoringVisibility( + WindowInsets.Type.statusBars() or WindowInsets.Type.displayCutout() + ) + + startY = insets.top + 100 + endY = device.displayHeight / 2 + steps = 4 + } + + // Swipe down to show the notification shade + val x = device.displayWidth / 2 + device.swipe(x, startY, x, endY, steps) + device.waitForIdle(2000) + instrumentation.uiAutomation.syncInputTransactions() + + // Launch the activity by clicking the notification + val notification = + device.wait(Until.findObject(By.text("Flicker Test Notification")), 2000L) + notification?.click() ?: error("Notification not found") + instrumentation.uiAutomation.syncInputTransactions() + } +} diff --git a/tests/FlickerTests/src/com/android/server/wm/flicker/service/notification/scenarios/OpenAppFromLockscreenNotificationCold.kt b/tests/FlickerTests/src/com/android/server/wm/flicker/service/notification/scenarios/OpenAppFromLockscreenNotificationCold.kt new file mode 100644 index 000000000000..9c53ab30e8cd --- /dev/null +++ b/tests/FlickerTests/src/com/android/server/wm/flicker/service/notification/scenarios/OpenAppFromLockscreenNotificationCold.kt @@ -0,0 +1,81 @@ +/* + * Copyright (C) 2023 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.server.wm.flicker.service.notification.scenarios + +import android.app.Instrumentation +import android.tools.common.NavBar +import android.tools.common.Rotation +import android.tools.device.helpers.wakeUpAndGoToHomeScreen +import android.tools.device.traces.parsers.WindowManagerStateHelper +import androidx.test.platform.app.InstrumentationRegistry +import androidx.test.uiautomator.UiDevice +import com.android.launcher3.tapl.LauncherInstrumentation +import com.android.server.wm.flicker.helpers.NotificationAppHelper +import com.android.server.wm.flicker.service.Utils +import org.junit.After +import org.junit.Before +import org.junit.Rule +import org.junit.Test + +abstract class OpenAppFromLockscreenNotificationCold( + val gestureMode: NavBar = NavBar.MODE_GESTURAL, + val rotation: Rotation = Rotation.ROTATION_0 +) { + private val instrumentation: Instrumentation = InstrumentationRegistry.getInstrumentation() + private val tapl = LauncherInstrumentation() + private val wmHelper = WindowManagerStateHelper(instrumentation) + private val device = UiDevice.getInstance(instrumentation) + private val testApp: NotificationAppHelper = NotificationAppHelper(instrumentation) + + val openingNotificationsFromLockScreen = true + + @Rule @JvmField val testSetupRule = Utils.testSetupRule(gestureMode, rotation) + + @Before + fun setup() { + device.wakeUpAndGoToHomeScreen() + testApp.launchViaIntent(wmHelper) + wmHelper.StateSyncBuilder().withFullScreenApp(testApp).waitForAndVerify() + testApp.postNotification(wmHelper) + device.pressHome() + wmHelper.StateSyncBuilder().withHomeActivityVisible().waitForAndVerify() + + // Close the app that posted the notification to trigger a cold start next time + // it is open - can't just kill it because that would remove the notification. + tapl.setExpectedRotationCheckEnabled(false) + tapl.goHome() + tapl.workspace.switchToOverview() + tapl.overview.dismissAllTasks() + + device.sleep() + wmHelper.StateSyncBuilder().withoutTopVisibleAppWindows().waitForAndVerify() + } + + @Test + open fun openAppFromLockscreenNotificationCold() { + device.wakeUp() + + NotificationUtils.openNotification(openingNotificationsFromLockScreen) + // Wait for the app to launch + wmHelper.StateSyncBuilder().withFullScreenApp(testApp).waitForAndVerify() + } + + @After + fun teardown() { + testApp.exit(wmHelper) + } +} diff --git a/tests/FlickerTests/src/com/android/server/wm/flicker/service/notification/scenarios/OpenAppFromLockscreenNotificationWarm.kt b/tests/FlickerTests/src/com/android/server/wm/flicker/service/notification/scenarios/OpenAppFromLockscreenNotificationWarm.kt new file mode 100644 index 000000000000..31f55d9d2e99 --- /dev/null +++ b/tests/FlickerTests/src/com/android/server/wm/flicker/service/notification/scenarios/OpenAppFromLockscreenNotificationWarm.kt @@ -0,0 +1,74 @@ +/* + * Copyright (C) 2023 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.server.wm.flicker.service.notification.scenarios + +import android.app.Instrumentation +import android.tools.common.NavBar +import android.tools.common.Rotation +import android.tools.device.helpers.wakeUpAndGoToHomeScreen +import android.tools.device.traces.parsers.WindowManagerStateHelper +import androidx.test.platform.app.InstrumentationRegistry +import androidx.test.uiautomator.UiDevice +import com.android.launcher3.tapl.LauncherInstrumentation +import com.android.server.wm.flicker.helpers.NotificationAppHelper +import com.android.server.wm.flicker.service.Utils +import org.junit.After +import org.junit.Before +import org.junit.Rule +import org.junit.Test + +abstract class OpenAppFromLockscreenNotificationWarm( + val gestureMode: NavBar = NavBar.MODE_GESTURAL, + val rotation: Rotation = Rotation.ROTATION_0 +) { + private val instrumentation: Instrumentation = InstrumentationRegistry.getInstrumentation() + private val tapl = LauncherInstrumentation() + private val wmHelper = WindowManagerStateHelper(instrumentation) + private val device = UiDevice.getInstance(instrumentation) + private val testApp: NotificationAppHelper = NotificationAppHelper(instrumentation) + + private val openingNotificationsFromLockScreen = true + + @Rule @JvmField val testSetupRule = Utils.testSetupRule(gestureMode, rotation) + + @Before + fun setup() { + device.wakeUpAndGoToHomeScreen() + testApp.launchViaIntent(wmHelper) + wmHelper.StateSyncBuilder().withFullScreenApp(testApp).waitForAndVerify() + testApp.postNotification(wmHelper) + device.pressHome() + wmHelper.StateSyncBuilder().withHomeActivityVisible().waitForAndVerify() + + device.sleep() + wmHelper.StateSyncBuilder().withoutTopVisibleAppWindows().waitForAndVerify() + } + + @Test + open fun openAppFromLockscreenNotificationWarm() { + device.wakeUp() + + NotificationUtils.openNotification(openingNotificationsFromLockScreen) + // Wait for the app to launch + wmHelper.StateSyncBuilder().withFullScreenApp(testApp).waitForAndVerify() + } + + @After + fun teardown() { + testApp.exit(wmHelper) + } +} diff --git a/tests/FlickerTests/src/com/android/server/wm/flicker/service/notification/scenarios/OpenAppFromLockscreenNotificationWithOverlayApp.kt b/tests/FlickerTests/src/com/android/server/wm/flicker/service/notification/scenarios/OpenAppFromLockscreenNotificationWithOverlayApp.kt new file mode 100644 index 000000000000..b971555f2747 --- /dev/null +++ b/tests/FlickerTests/src/com/android/server/wm/flicker/service/notification/scenarios/OpenAppFromLockscreenNotificationWithOverlayApp.kt @@ -0,0 +1,94 @@ +/* + * Copyright (C) 2023 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.server.wm.flicker.service.notification.scenarios + +import android.app.Instrumentation +import android.tools.common.NavBar +import android.tools.common.Rotation +import android.tools.device.helpers.wakeUpAndGoToHomeScreen +import android.tools.device.traces.parsers.WindowManagerStateHelper +import androidx.test.platform.app.InstrumentationRegistry +import androidx.test.uiautomator.UiDevice +import com.android.launcher3.tapl.LauncherInstrumentation +import com.android.server.wm.flicker.helpers.NotificationAppHelper +import com.android.server.wm.flicker.helpers.ShowWhenLockedAppHelper +import com.android.server.wm.flicker.service.Utils +import org.junit.After +import org.junit.Before +import org.junit.Rule +import org.junit.Test + +abstract class OpenAppFromLockscreenNotificationWithOverlayApp( + val gestureMode: NavBar = NavBar.MODE_GESTURAL, + val rotation: Rotation = Rotation.ROTATION_0 +) { + private val instrumentation: Instrumentation = InstrumentationRegistry.getInstrumentation() + private val tapl = LauncherInstrumentation() + private val wmHelper = WindowManagerStateHelper(instrumentation) + private val device = UiDevice.getInstance(instrumentation) + private val showWhenLockedApp = ShowWhenLockedAppHelper(instrumentation) + private val testApp: NotificationAppHelper = NotificationAppHelper(instrumentation) + + // Although we are technically still locked here, the overlay app means we should open the + // notification shade as if we were unlocked. + private val openingNotificationsFromLockScreen = false + + @Rule @JvmField val testSetupRule = Utils.testSetupRule(gestureMode, rotation) + + @Before + fun setup() { + device.wakeUpAndGoToHomeScreen() + testApp.launchViaIntent(wmHelper) + wmHelper.StateSyncBuilder().withFullScreenApp(testApp).waitForAndVerify() + testApp.postNotification(wmHelper) + device.pressHome() + wmHelper.StateSyncBuilder().withHomeActivityVisible().waitForAndVerify() + + // Close the app that posted the notification to trigger a cold start next time + // it is open - can't just kill it because that would remove the notification. + tapl.setExpectedRotationCheckEnabled(false) + tapl.goHome() + tapl.workspace.switchToOverview() + tapl.overview.dismissAllTasks() + + device.sleep() + wmHelper.StateSyncBuilder().withoutTopVisibleAppWindows().waitForAndVerify() + + device.wakeUpAndGoToHomeScreen() + + // Launch an activity that is shown when the device is locked + showWhenLockedApp.launchViaIntent(wmHelper) + wmHelper.StateSyncBuilder().withFullScreenApp(showWhenLockedApp).waitForAndVerify() + + device.sleep() + wmHelper.StateSyncBuilder().withoutTopVisibleAppWindows().waitForAndVerify() + } + + @Test + open fun openAppFromLockscreenNotificationWithOverlayApp() { + device.wakeUp() + NotificationUtils.openNotification(openingNotificationsFromLockScreen) + // Wait for the app to launch + wmHelper.StateSyncBuilder().withFullScreenApp(testApp).waitForAndVerify() + } + + @After + fun teardown() { + testApp.exit(wmHelper) + showWhenLockedApp.exit(wmHelper) + } +} diff --git a/tests/FlickerTests/src/com/android/server/wm/flicker/service/notification/scenarios/OpenAppFromNotificationCold.kt b/tests/FlickerTests/src/com/android/server/wm/flicker/service/notification/scenarios/OpenAppFromNotificationCold.kt new file mode 100644 index 000000000000..fed077ed0e50 --- /dev/null +++ b/tests/FlickerTests/src/com/android/server/wm/flicker/service/notification/scenarios/OpenAppFromNotificationCold.kt @@ -0,0 +1,76 @@ +/* + * Copyright (C) 2023 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.server.wm.flicker.service.notification.scenarios + +import android.app.Instrumentation +import android.tools.common.NavBar +import android.tools.common.Rotation +import android.tools.device.helpers.wakeUpAndGoToHomeScreen +import android.tools.device.traces.parsers.WindowManagerStateHelper +import androidx.test.platform.app.InstrumentationRegistry +import androidx.test.uiautomator.UiDevice +import com.android.launcher3.tapl.LauncherInstrumentation +import com.android.server.wm.flicker.helpers.NotificationAppHelper +import com.android.server.wm.flicker.service.Utils +import org.junit.After +import org.junit.Before +import org.junit.Rule +import org.junit.Test + +abstract class OpenAppFromNotificationCold( + val gestureMode: NavBar = NavBar.MODE_GESTURAL, + val rotation: Rotation = Rotation.ROTATION_0 +) { + private val instrumentation: Instrumentation = InstrumentationRegistry.getInstrumentation() + private val tapl = LauncherInstrumentation() + private val device = UiDevice.getInstance(instrumentation) + private val wmHelper = WindowManagerStateHelper(instrumentation) + private val testApp: NotificationAppHelper = NotificationAppHelper(instrumentation) + + @Rule @JvmField val testSetupRule = Utils.testSetupRule(gestureMode, rotation) + + private val openingNotificationsFromLockScreen = false + + @Before + fun setup() { + device.wakeUpAndGoToHomeScreen() + testApp.launchViaIntent(wmHelper) + wmHelper.StateSyncBuilder().withFullScreenApp(testApp).waitForAndVerify() + testApp.postNotification(wmHelper) + device.pressHome() + wmHelper.StateSyncBuilder().withHomeActivityVisible().waitForAndVerify() + + // Close the app that posted the notification to trigger a cold start next time + // it is open - can't just kill it because that would remove the notification. + tapl.setExpectedRotationCheckEnabled(false) + tapl.goHome() + tapl.workspace.switchToOverview() + tapl.overview.dismissAllTasks() + } + + @Test + open fun openAppFromNotificationCold() { + NotificationUtils.openNotification(openingNotificationsFromLockScreen) + // Wait for the app to launch + wmHelper.StateSyncBuilder().withFullScreenApp(testApp).waitForAndVerify() + } + + @After + fun teardown() { + testApp.exit(wmHelper) + } +} diff --git a/tests/FlickerTests/src/com/android/server/wm/flicker/service/notification/scenarios/OpenAppFromNotificationWarm.kt b/tests/FlickerTests/src/com/android/server/wm/flicker/service/notification/scenarios/OpenAppFromNotificationWarm.kt new file mode 100644 index 000000000000..403790e904d8 --- /dev/null +++ b/tests/FlickerTests/src/com/android/server/wm/flicker/service/notification/scenarios/OpenAppFromNotificationWarm.kt @@ -0,0 +1,69 @@ +/* + * Copyright (C) 2023 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.server.wm.flicker.service.notification.scenarios + +import android.app.Instrumentation +import android.tools.common.NavBar +import android.tools.common.Rotation +import android.tools.device.helpers.wakeUpAndGoToHomeScreen +import android.tools.device.traces.parsers.WindowManagerStateHelper +import androidx.test.platform.app.InstrumentationRegistry +import androidx.test.uiautomator.UiDevice +import com.android.launcher3.tapl.LauncherInstrumentation +import com.android.server.wm.flicker.helpers.NotificationAppHelper +import com.android.server.wm.flicker.service.Utils +import org.junit.After +import org.junit.Before +import org.junit.Rule +import org.junit.Test + +abstract class OpenAppFromNotificationWarm( + val gestureMode: NavBar = NavBar.MODE_GESTURAL, + val rotation: Rotation = Rotation.ROTATION_0 +) { + private val instrumentation: Instrumentation = InstrumentationRegistry.getInstrumentation() + private val tapl = LauncherInstrumentation() + private val device = UiDevice.getInstance(instrumentation) + private val wmHelper = WindowManagerStateHelper(instrumentation) + private val testApp: NotificationAppHelper = NotificationAppHelper(instrumentation) + + private val openingNotificationsFromLockScreen = false + + @Rule @JvmField val testSetupRule = Utils.testSetupRule(gestureMode, rotation) + + @Before + fun setup() { + device.wakeUpAndGoToHomeScreen() + testApp.launchViaIntent(wmHelper) + wmHelper.StateSyncBuilder().withFullScreenApp(testApp).waitForAndVerify() + testApp.postNotification(wmHelper) + device.pressHome() + wmHelper.StateSyncBuilder().withHomeActivityVisible().waitForAndVerify() + } + + @Test + open fun openAppFromNotificationWarm() { + NotificationUtils.openNotification(openingNotificationsFromLockScreen) + // Wait for the app to launch + wmHelper.StateSyncBuilder().withFullScreenApp(testApp).waitForAndVerify() + } + + @After + fun teardown() { + testApp.exit(wmHelper) + } +} diff --git a/tests/FlickerTests/src/com/android/server/wm/flicker/service/quickswitch/flicker/QuickSwitchBetweenTwoAppsBackGesturalNavLandscape.kt b/tests/FlickerTests/src/com/android/server/wm/flicker/service/quickswitch/flicker/QuickSwitchBetweenTwoAppsBackGesturalNavLandscape.kt new file mode 100644 index 000000000000..d611a420edcb --- /dev/null +++ b/tests/FlickerTests/src/com/android/server/wm/flicker/service/quickswitch/flicker/QuickSwitchBetweenTwoAppsBackGesturalNavLandscape.kt @@ -0,0 +1,43 @@ +/* + * Copyright (C) 2023 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.server.wm.flicker.service.quickswitch.flicker + +import android.tools.common.Rotation +import android.tools.common.flicker.FlickerConfig +import android.tools.common.flicker.annotation.ExpectedScenarios +import android.tools.common.flicker.annotation.FlickerConfigProvider +import android.tools.common.flicker.config.FlickerConfig +import android.tools.common.flicker.config.FlickerServiceConfig +import android.tools.device.flicker.junit.FlickerServiceJUnit4ClassRunner +import com.android.server.wm.flicker.service.quickswitch.scenarios.QuickSwitchBetweenTwoAppsBack +import org.junit.Test +import org.junit.runner.RunWith + +@RunWith(FlickerServiceJUnit4ClassRunner::class) +class QuickSwitchBetweenTwoAppsBackGesturalNavLandscape : + QuickSwitchBetweenTwoAppsBack(Rotation.ROTATION_90) { + @ExpectedScenarios(["QUICKSWITCH"]) + @Test + override fun quickSwitchBetweenTwoAppsBack() = super.quickSwitchBetweenTwoAppsBack() + + companion object { + @JvmStatic + @FlickerConfigProvider + fun flickerConfigProvider(): FlickerConfig = + FlickerConfig().use(FlickerServiceConfig.DEFAULT) + } +} diff --git a/tests/FlickerTests/src/com/android/server/wm/flicker/service/quickswitch/flicker/QuickSwitchBetweenTwoAppsBackGesturalNavPortrait.kt b/tests/FlickerTests/src/com/android/server/wm/flicker/service/quickswitch/flicker/QuickSwitchBetweenTwoAppsBackGesturalNavPortrait.kt new file mode 100644 index 000000000000..e6bcbba661f3 --- /dev/null +++ b/tests/FlickerTests/src/com/android/server/wm/flicker/service/quickswitch/flicker/QuickSwitchBetweenTwoAppsBackGesturalNavPortrait.kt @@ -0,0 +1,43 @@ +/* + * Copyright (C) 2023 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.server.wm.flicker.service.quickswitch.flicker + +import android.tools.common.Rotation +import android.tools.common.flicker.FlickerConfig +import android.tools.common.flicker.annotation.ExpectedScenarios +import android.tools.common.flicker.annotation.FlickerConfigProvider +import android.tools.common.flicker.config.FlickerConfig +import android.tools.common.flicker.config.FlickerServiceConfig +import android.tools.device.flicker.junit.FlickerServiceJUnit4ClassRunner +import com.android.server.wm.flicker.service.quickswitch.scenarios.QuickSwitchBetweenTwoAppsBack +import org.junit.Test +import org.junit.runner.RunWith + +@RunWith(FlickerServiceJUnit4ClassRunner::class) +class QuickSwitchBetweenTwoAppsBackGesturalNavPortrait : + QuickSwitchBetweenTwoAppsBack(Rotation.ROTATION_0) { + @ExpectedScenarios(["QUICKSWITCH"]) + @Test + override fun quickSwitchBetweenTwoAppsBack() = super.quickSwitchBetweenTwoAppsBack() + + companion object { + @JvmStatic + @FlickerConfigProvider + fun flickerConfigProvider(): FlickerConfig = + FlickerConfig().use(FlickerServiceConfig.DEFAULT) + } +} diff --git a/tests/FlickerTests/src/com/android/server/wm/flicker/service/quickswitch/flicker/QuickSwitchBetweenTwoAppsForwardGesturalNavLandscape.kt b/tests/FlickerTests/src/com/android/server/wm/flicker/service/quickswitch/flicker/QuickSwitchBetweenTwoAppsForwardGesturalNavLandscape.kt new file mode 100644 index 000000000000..2a26d633adaf --- /dev/null +++ b/tests/FlickerTests/src/com/android/server/wm/flicker/service/quickswitch/flicker/QuickSwitchBetweenTwoAppsForwardGesturalNavLandscape.kt @@ -0,0 +1,43 @@ +/* + * Copyright (C) 2023 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.server.wm.flicker.service.quickswitch.flicker + +import android.tools.common.Rotation +import android.tools.common.flicker.FlickerConfig +import android.tools.common.flicker.annotation.ExpectedScenarios +import android.tools.common.flicker.annotation.FlickerConfigProvider +import android.tools.common.flicker.config.FlickerConfig +import android.tools.common.flicker.config.FlickerServiceConfig +import android.tools.device.flicker.junit.FlickerServiceJUnit4ClassRunner +import com.android.server.wm.flicker.service.quickswitch.scenarios.QuickSwitchBetweenTwoAppsForward +import org.junit.Test +import org.junit.runner.RunWith + +@RunWith(FlickerServiceJUnit4ClassRunner::class) +class QuickSwitchBetweenTwoAppsForwardGesturalNavLandscape : + QuickSwitchBetweenTwoAppsForward(Rotation.ROTATION_90) { + @ExpectedScenarios(["QUICKSWITCH"]) + @Test + override fun quickSwitchBetweenTwoAppsForward() = super.quickSwitchBetweenTwoAppsForward() + + companion object { + @JvmStatic + @FlickerConfigProvider + fun flickerConfigProvider(): FlickerConfig = + FlickerConfig().use(FlickerServiceConfig.DEFAULT) + } +} diff --git a/tests/FlickerTests/src/com/android/server/wm/flicker/service/quickswitch/flicker/QuickSwitchBetweenTwoAppsForwardGesturalNavPortrait.kt b/tests/FlickerTests/src/com/android/server/wm/flicker/service/quickswitch/flicker/QuickSwitchBetweenTwoAppsForwardGesturalNavPortrait.kt new file mode 100644 index 000000000000..5ce714371db0 --- /dev/null +++ b/tests/FlickerTests/src/com/android/server/wm/flicker/service/quickswitch/flicker/QuickSwitchBetweenTwoAppsForwardGesturalNavPortrait.kt @@ -0,0 +1,43 @@ +/* + * Copyright (C) 2023 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.server.wm.flicker.service.quickswitch.flicker + +import android.tools.common.Rotation +import android.tools.common.flicker.FlickerConfig +import android.tools.common.flicker.annotation.ExpectedScenarios +import android.tools.common.flicker.annotation.FlickerConfigProvider +import android.tools.common.flicker.config.FlickerConfig +import android.tools.common.flicker.config.FlickerServiceConfig +import android.tools.device.flicker.junit.FlickerServiceJUnit4ClassRunner +import com.android.server.wm.flicker.service.quickswitch.scenarios.QuickSwitchBetweenTwoAppsForward +import org.junit.Test +import org.junit.runner.RunWith + +@RunWith(FlickerServiceJUnit4ClassRunner::class) +class QuickSwitchBetweenTwoAppsForwardGesturalNavPortrait : + QuickSwitchBetweenTwoAppsForward(Rotation.ROTATION_0) { + @ExpectedScenarios(["QUICKSWITCH"]) + @Test + override fun quickSwitchBetweenTwoAppsForward() = super.quickSwitchBetweenTwoAppsForward() + + companion object { + @JvmStatic + @FlickerConfigProvider + fun flickerConfigProvider(): FlickerConfig = + FlickerConfig().use(FlickerServiceConfig.DEFAULT) + } +} diff --git a/tests/FlickerTests/src/com/android/server/wm/flicker/service/quickswitch/flicker/QuickSwitchFromLauncherGesturalNavLandscape.kt b/tests/FlickerTests/src/com/android/server/wm/flicker/service/quickswitch/flicker/QuickSwitchFromLauncherGesturalNavLandscape.kt new file mode 100644 index 000000000000..cff47bb8cc19 --- /dev/null +++ b/tests/FlickerTests/src/com/android/server/wm/flicker/service/quickswitch/flicker/QuickSwitchFromLauncherGesturalNavLandscape.kt @@ -0,0 +1,42 @@ +/* + * Copyright (C) 2023 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.server.wm.flicker.service.quickswitch.flicker + +import android.tools.common.Rotation +import android.tools.common.flicker.FlickerConfig +import android.tools.common.flicker.annotation.ExpectedScenarios +import android.tools.common.flicker.annotation.FlickerConfigProvider +import android.tools.common.flicker.config.FlickerConfig +import android.tools.common.flicker.config.FlickerServiceConfig +import android.tools.device.flicker.junit.FlickerServiceJUnit4ClassRunner +import com.android.server.wm.flicker.service.quickswitch.scenarios.QuickSwitchFromLauncher +import org.junit.Test +import org.junit.runner.RunWith + +@RunWith(FlickerServiceJUnit4ClassRunner::class) +class QuickSwitchFromLauncherGesturalNavLandscape : QuickSwitchFromLauncher(Rotation.ROTATION_90) { + @ExpectedScenarios(["QUICKSWITCH"]) + @Test + override fun quickSwitchFromLauncher() = super.quickSwitchFromLauncher() + + companion object { + @JvmStatic + @FlickerConfigProvider + fun flickerConfigProvider(): FlickerConfig = + FlickerConfig().use(FlickerServiceConfig.DEFAULT) + } +} diff --git a/tests/FlickerTests/src/com/android/server/wm/flicker/service/quickswitch/flicker/QuickSwitchFromLauncherGesturalNavPortrait.kt b/tests/FlickerTests/src/com/android/server/wm/flicker/service/quickswitch/flicker/QuickSwitchFromLauncherGesturalNavPortrait.kt new file mode 100644 index 000000000000..33095a6ac078 --- /dev/null +++ b/tests/FlickerTests/src/com/android/server/wm/flicker/service/quickswitch/flicker/QuickSwitchFromLauncherGesturalNavPortrait.kt @@ -0,0 +1,42 @@ +/* + * Copyright (C) 2023 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.server.wm.flicker.service.quickswitch.flicker + +import android.tools.common.Rotation +import android.tools.common.flicker.FlickerConfig +import android.tools.common.flicker.annotation.ExpectedScenarios +import android.tools.common.flicker.annotation.FlickerConfigProvider +import android.tools.common.flicker.config.FlickerConfig +import android.tools.common.flicker.config.FlickerServiceConfig +import android.tools.device.flicker.junit.FlickerServiceJUnit4ClassRunner +import com.android.server.wm.flicker.service.quickswitch.scenarios.QuickSwitchFromLauncher +import org.junit.Test +import org.junit.runner.RunWith + +@RunWith(FlickerServiceJUnit4ClassRunner::class) +class QuickSwitchFromLauncherGesturalNavPortrait : QuickSwitchFromLauncher(Rotation.ROTATION_0) { + @ExpectedScenarios(["QUICKSWITCH"]) + @Test + override fun quickSwitchFromLauncher() = super.quickSwitchFromLauncher() + + companion object { + @JvmStatic + @FlickerConfigProvider + fun flickerConfigProvider(): FlickerConfig = + FlickerConfig().use(FlickerServiceConfig.DEFAULT) + } +} diff --git a/tests/FlickerTests/src/com/android/server/wm/flicker/service/quickswitch/scenarios/QuickSwitchBetweenTwoAppsBack.kt b/tests/FlickerTests/src/com/android/server/wm/flicker/service/quickswitch/scenarios/QuickSwitchBetweenTwoAppsBack.kt new file mode 100644 index 000000000000..93130c4680ff --- /dev/null +++ b/tests/FlickerTests/src/com/android/server/wm/flicker/service/quickswitch/scenarios/QuickSwitchBetweenTwoAppsBack.kt @@ -0,0 +1,68 @@ +/* + * Copyright (C) 2021 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.server.wm.flicker.service.quickswitch.scenarios + +import android.app.Instrumentation +import android.tools.common.NavBar +import android.tools.common.Rotation +import android.tools.device.traces.parsers.WindowManagerStateHelper +import androidx.test.platform.app.InstrumentationRegistry +import com.android.launcher3.tapl.LauncherInstrumentation +import com.android.server.wm.flicker.helpers.NonResizeableAppHelper +import com.android.server.wm.flicker.helpers.SimpleAppHelper +import com.android.server.wm.flicker.service.Utils +import org.junit.After +import org.junit.Before +import org.junit.Ignore +import org.junit.Rule +import org.junit.Test + +@Ignore("Base Test Class") +abstract class QuickSwitchBetweenTwoAppsBack(val rotation: Rotation = Rotation.ROTATION_0) { + private val instrumentation: Instrumentation = InstrumentationRegistry.getInstrumentation() + private val tapl = LauncherInstrumentation() + private val wmHelper = WindowManagerStateHelper(instrumentation) + private val testApp1 = SimpleAppHelper(instrumentation) + private val testApp2 = NonResizeableAppHelper(instrumentation) + + @Rule @JvmField val testSetupRule = Utils.testSetupRule(NavBar.MODE_GESTURAL, rotation) + + @Before + fun setup() { + tapl.setExpectedRotation(rotation.value) + tapl.setIgnoreTaskbarVisibility(true) + testApp1.launchViaIntent(wmHelper) + testApp2.launchViaIntent(wmHelper) + } + + @Test + open fun quickSwitchBetweenTwoAppsBack() { + tapl.launchedAppState.quickSwitchToPreviousApp() + wmHelper + .StateSyncBuilder() + .withFullScreenApp(testApp1) + .withNavOrTaskBarVisible() + .withStatusBarVisible() + .waitForAndVerify() + } + + @After + fun teardown() { + testApp1.exit(wmHelper) + testApp2.exit(wmHelper) + } +} diff --git a/tests/FlickerTests/src/com/android/server/wm/flicker/service/quickswitch/scenarios/QuickSwitchBetweenTwoAppsForward.kt b/tests/FlickerTests/src/com/android/server/wm/flicker/service/quickswitch/scenarios/QuickSwitchBetweenTwoAppsForward.kt new file mode 100644 index 000000000000..4941eea12129 --- /dev/null +++ b/tests/FlickerTests/src/com/android/server/wm/flicker/service/quickswitch/scenarios/QuickSwitchBetweenTwoAppsForward.kt @@ -0,0 +1,75 @@ +/* + * Copyright (C) 2021 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.server.wm.flicker.service.quickswitch.scenarios + +import android.app.Instrumentation +import android.tools.common.NavBar +import android.tools.common.Rotation +import android.tools.device.traces.parsers.WindowManagerStateHelper +import androidx.test.platform.app.InstrumentationRegistry +import com.android.launcher3.tapl.LauncherInstrumentation +import com.android.server.wm.flicker.helpers.NonResizeableAppHelper +import com.android.server.wm.flicker.helpers.SimpleAppHelper +import com.android.server.wm.flicker.service.Utils +import org.junit.After +import org.junit.Before +import org.junit.Ignore +import org.junit.Rule +import org.junit.Test + +@Ignore("Base Test Class") +abstract class QuickSwitchBetweenTwoAppsForward(val rotation: Rotation = Rotation.ROTATION_0) { + private val instrumentation: Instrumentation = InstrumentationRegistry.getInstrumentation() + private val tapl = LauncherInstrumentation() + private val wmHelper = WindowManagerStateHelper(instrumentation) + private val testApp1 = SimpleAppHelper(instrumentation) + private val testApp2 = NonResizeableAppHelper(instrumentation) + + @Rule @JvmField val testSetupRule = Utils.testSetupRule(NavBar.MODE_GESTURAL, rotation) + + @Before + fun setup() { + tapl.setExpectedRotation(rotation.value) + + testApp1.launchViaIntent(wmHelper) + testApp2.launchViaIntent(wmHelper) + tapl.launchedAppState.quickSwitchToPreviousApp() + wmHelper + .StateSyncBuilder() + .withFullScreenApp(testApp1) + .withNavOrTaskBarVisible() + .withStatusBarVisible() + .waitForAndVerify() + } + + @Test + open fun quickSwitchBetweenTwoAppsForward() { + tapl.launchedAppState.quickSwitchToPreviousAppSwipeLeft() + wmHelper + .StateSyncBuilder() + .withFullScreenApp(testApp2) + .withNavOrTaskBarVisible() + .withStatusBarVisible() + .waitForAndVerify() + } + + @After + fun teardown() { + testApp1.exit(wmHelper) + testApp2.exit(wmHelper) + } +} diff --git a/tests/FlickerTests/src/com/android/server/wm/flicker/service/quickswitch/scenarios/QuickSwitchFromLauncher.kt b/tests/FlickerTests/src/com/android/server/wm/flicker/service/quickswitch/scenarios/QuickSwitchFromLauncher.kt new file mode 100644 index 000000000000..7afe5268ede4 --- /dev/null +++ b/tests/FlickerTests/src/com/android/server/wm/flicker/service/quickswitch/scenarios/QuickSwitchFromLauncher.kt @@ -0,0 +1,72 @@ +/* + * Copyright (C) 2021 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.server.wm.flicker.service.quickswitch.scenarios + +import android.app.Instrumentation +import android.tools.common.NavBar +import android.tools.common.Rotation +import android.tools.device.traces.parsers.WindowManagerStateHelper +import androidx.test.platform.app.InstrumentationRegistry +import com.android.launcher3.tapl.LauncherInstrumentation +import com.android.server.wm.flicker.helpers.SimpleAppHelper +import com.android.server.wm.flicker.service.Utils +import org.junit.After +import org.junit.Before +import org.junit.Ignore +import org.junit.Rule +import org.junit.Test + +@Ignore("Base Test Class") +abstract class QuickSwitchFromLauncher(val rotation: Rotation = Rotation.ROTATION_0) { + private val instrumentation: Instrumentation = InstrumentationRegistry.getInstrumentation() + private val tapl = LauncherInstrumentation() + private val wmHelper = WindowManagerStateHelper(instrumentation) + private val testApp = SimpleAppHelper(instrumentation) + + @Rule @JvmField val testSetupRule = Utils.testSetupRule(NavBar.MODE_GESTURAL, rotation) + + @Before + fun setup() { + tapl.setExpectedRotationCheckEnabled(false) + + tapl.setExpectedRotation(rotation.value) + + testApp.launchViaIntent(wmHelper) + tapl.goHome() + wmHelper + .StateSyncBuilder() + .withHomeActivityVisible() + .withWindowSurfaceDisappeared(testApp) + .waitForAndVerify() + } + + @Test + open fun quickSwitchFromLauncher() { + tapl.workspace.quickSwitchToPreviousApp() + wmHelper + .StateSyncBuilder() + .withFullScreenApp(testApp) + .withNavOrTaskBarVisible() + .withStatusBarVisible() + .waitForAndVerify() + } + + @After + fun teardown() { + testApp.exit(wmHelper) + } +} diff --git a/tests/FlickerTests/test-apps/flickerapp/AndroidManifest.xml b/tests/FlickerTests/test-apps/flickerapp/AndroidManifest.xml index 1ec9ec9b0eda..ff9799a1c710 100644 --- a/tests/FlickerTests/test-apps/flickerapp/AndroidManifest.xml +++ b/tests/FlickerTests/test-apps/flickerapp/AndroidManifest.xml @@ -22,7 +22,9 @@ <application android:allowBackup="false" android:supportsRtl="true"> <uses-library android:name="androidx.window.extensions" android:required="false"/> - + <property + android:name="android.window.PROPERTY_ACTIVITY_EMBEDDING_SPLITS_ENABLED" + android:value="true" /> <activity android:name=".SimpleActivity" android:taskAffinity="com.android.server.wm.flicker.testapp.SimpleActivity" android:theme="@style/CutoutShortEdges" @@ -100,6 +102,24 @@ <category android:name="android.intent.category.LAUNCHER"/> </intent-filter> </activity> + <activity android:name=".LaunchTransparentActivity" + android:resizeableActivity="false" + android:screenOrientation="portrait" + android:theme="@android:style/Theme" + android:taskAffinity="com.android.server.wm.flicker.testapp.LaunchTransparentActivity" + android:label="LaunchTransparentActivity" + android:exported="true"> + <intent-filter> + <action android:name="android.intent.action.MAIN"/> + <category android:name="android.intent.category.LAUNCHER"/> + </intent-filter> + </activity> + <activity android:name=".TransparentActivity" + android:theme="@style/TransparentTheme" + android:taskAffinity="com.android.server.wm.flicker.testapp.TransparentActivity" + android:label="TransparentActivity" + android:exported="false"> + </activity> <activity android:name=".LaunchNewActivity" android:taskAffinity="com.android.server.wm.flicker.testapp.LaunchNewActivity" android:theme="@style/CutoutShortEdges" @@ -191,11 +211,34 @@ </intent-filter> </activity> <activity + android:name=".ActivityEmbeddingTrampolineActivity" + android:label="ActivityEmbedding Trampoline" + android:taskAffinity="com.android.server.wm.flicker.testapp.ActivityEmbedding" + android:theme="@style/CutoutShortEdges" + android:configChanges="orientation|screenSize|smallestScreenSize|screenLayout" + android:exported="false"> + </activity> + <activity android:name=".ActivityEmbeddingSecondaryActivity" android:label="ActivityEmbedding Secondary" android:taskAffinity="com.android.server.wm.flicker.testapp.ActivityEmbedding" android:theme="@style/CutoutShortEdges" android:configChanges="orientation|screenSize|smallestScreenSize|screenLayout" + android:supportsPictureInPicture="true" + android:exported="false"/> + <activity + android:name=".ActivityEmbeddingThirdActivity" + android:label="ActivityEmbedding Third" + android:taskAffinity="com.android.server.wm.flicker.testapp.ActivityEmbedding" + android:theme="@style/CutoutShortEdges" + android:configChanges="orientation|screenSize|smallestScreenSize|screenLayout" + android:exported="false"/> + <activity + android:name=".ActivityEmbeddingAlwaysExpandActivity" + android:label="ActivityEmbedding AlwaysExpand" + android:taskAffinity="com.android.server.wm.flicker.testapp.ActivityEmbedding" + android:theme="@style/CutoutShortEdges" + android:configChanges="orientation|screenSize|smallestScreenSize|screenLayout" android:exported="false"/> <activity android:name=".ActivityEmbeddingPlaceholderPrimaryActivity" diff --git a/tests/FlickerTests/test-apps/flickerapp/res/layout/activity_embedding_base_layout.xml b/tests/FlickerTests/test-apps/flickerapp/res/layout/activity_embedding_base_layout.xml index 3a02cadc90dd..f0dfdfce035f 100644 --- a/tests/FlickerTests/test-apps/flickerapp/res/layout/activity_embedding_base_layout.xml +++ b/tests/FlickerTests/test-apps/flickerapp/res/layout/activity_embedding_base_layout.xml @@ -20,5 +20,4 @@ android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical"> - </LinearLayout> diff --git a/tests/FlickerTests/test-apps/flickerapp/res/layout/activity_embedding_main_layout.xml b/tests/FlickerTests/test-apps/flickerapp/res/layout/activity_embedding_main_layout.xml index d78b9a836a37..86c21906163f 100644 --- a/tests/FlickerTests/test-apps/flickerapp/res/layout/activity_embedding_main_layout.xml +++ b/tests/FlickerTests/test-apps/flickerapp/res/layout/activity_embedding_main_layout.xml @@ -25,16 +25,55 @@ android:id="@+id/launch_secondary_activity_button" android:layout_width="wrap_content" android:layout_height="48dp" - android:layout_centerHorizontal="true" android:onClick="launchSecondaryActivity" + android:tag="LEFT_TO_RIGHT" android:text="Launch Secondary Activity" /> <Button + android:id="@+id/launch_secondary_activity_rtl_button" + android:layout_width="wrap_content" + android:layout_height="48dp" + android:onClick="launchSecondaryActivity" + android:tag="RIGHT_TO_LEFT" + android:text="Launch Secondary Activity in RTL" /> + + <Button + android:id="@+id/launch_secondary_activity_horizontally_button" + android:layout_width="wrap_content" + android:layout_height="48dp" + android:onClick="launchSecondaryActivity" + android:tag="BOTTOM_TO_TOP" + android:text="Launch Secondary Activity Horizontally" /> + + <Button android:id="@+id/launch_placeholder_split_button" android:layout_width="wrap_content" android:layout_height="48dp" - android:layout_centerHorizontal="true" android:onClick="launchPlaceholderSplit" + android:tag="LEFT_TO_RIGHT" android:text="Launch Placeholder Split" /> + <Button + android:id="@+id/launch_always_expand_activity_button" + android:layout_width="wrap_content" + android:layout_height="48dp" + android:onClick="launchAlwaysExpandActivity" + android:text="Launch Always Expand Activity" /> + + <Button + android:id="@+id/launch_placeholder_split_rtl_button" + android:layout_width="wrap_content" + android:layout_height="48dp" + android:onClick="launchPlaceholderSplit" + android:tag="RIGHT_TO_LEFT" + android:text="Launch Placeholder Split in RTL" /> + + <Button + android:id="@+id/launch_trampoline_button" + android:layout_width="wrap_content" + android:layout_height="48dp" + android:onClick="launchTrampolineActivity" + android:tag="LEFT_TO_RIGHT" + android:text="Launch Trampoline Activity" /> + </LinearLayout> diff --git a/tests/FlickerTests/test-apps/flickerapp/res/layout/activity_embedding_secondary_activity_layout.xml b/tests/FlickerTests/test-apps/flickerapp/res/layout/activity_embedding_secondary_activity_layout.xml new file mode 100644 index 000000000000..6d4de995bd73 --- /dev/null +++ b/tests/FlickerTests/test-apps/flickerapp/res/layout/activity_embedding_secondary_activity_layout.xml @@ -0,0 +1,52 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- + Copyright 2023 The Android Open Source Project + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +--> +<LinearLayout + xmlns:android="http://schemas.android.com/apk/res/android" + android:id="@+id/secondary_activity_layout" + android:layout_width="match_parent" + android:layout_height="match_parent" + android:orientation="vertical"> + + <Button + android:id="@+id/finish_secondary_activity_button" + android:layout_width="wrap_content" + android:layout_height="48dp" + android:text="Finish" /> + + <Button + android:id="@+id/launch_third_activity_button" + android:layout_width="wrap_content" + android:layout_height="48dp" + android:layout_centerHorizontal="true" + android:onClick="launchThirdActivity" + android:text="Launch a third activity" /> + + <ToggleButton + android:id="@+id/toggle_split_ratio_button" + android:layout_width="wrap_content" + android:layout_height="48dp" + android:textOn="Ratio 0.5" + android:textOff="Ratio 0.3" + android:checked="false" /> + + <Button + android:id="@+id/secondary_enter_pip_button" + android:layout_width="wrap_content" + android:layout_height="48dp" + android:text="Enter pip" /> + +</LinearLayout>
\ No newline at end of file diff --git a/tests/FlickerTests/test-apps/flickerapp/res/layout/activity_transparent.xml b/tests/FlickerTests/test-apps/flickerapp/res/layout/activity_transparent.xml new file mode 100644 index 000000000000..0730ded66ce4 --- /dev/null +++ b/tests/FlickerTests/test-apps/flickerapp/res/layout/activity_transparent.xml @@ -0,0 +1,21 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- + ~ Copyright (C) 2023 The Android Open Source Project + ~ + ~ Licensed under the Apache License, Version 2.0 (the "License"); + ~ you may not use this file except in compliance with the License. + ~ You may obtain a copy of the License at + ~ + ~ http://www.apache.org/licenses/LICENSE-2.0 + ~ + ~ Unless required by applicable law or agreed to in writing, software + ~ distributed under the License is distributed on an "AS IS" BASIS, + ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + ~ See the License for the specific language governing permissions and + ~ limitations under the License. + --> +<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" + android:layout_width="match_parent" + android:layout_height="match_parent"> + +</FrameLayout> diff --git a/tests/FlickerTests/test-apps/flickerapp/res/layout/activity_transparent_launch.xml b/tests/FlickerTests/test-apps/flickerapp/res/layout/activity_transparent_launch.xml new file mode 100644 index 000000000000..ff4ead95f16e --- /dev/null +++ b/tests/FlickerTests/test-apps/flickerapp/res/layout/activity_transparent_launch.xml @@ -0,0 +1,37 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- + ~ Copyright (C) 2023 The Android Open Source Project + ~ + ~ Licensed under the Apache License, Version 2.0 (the "License"); + ~ you may not use this file except in compliance with the License. + ~ You may obtain a copy of the License at + ~ + ~ http://www.apache.org/licenses/LICENSE-2.0 + ~ + ~ Unless required by applicable law or agreed to in writing, software + ~ distributed under the License is distributed on an "AS IS" BASIS, + ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + ~ See the License for the specific language governing permissions and + ~ limitations under the License. + --> +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" + android:layout_width="match_parent" + android:layout_height="match_parent" + android:orientation="vertical" + android:background="@android:color/black"> + + <Button + android:id="@+id/button_launch_transparent" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_centerHorizontal="true" + android:layout_centerVertical="true" + android:text="Launch Transparent" /> + <Button + android:id="@+id/button_request_permission" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_centerHorizontal="true" + android:layout_centerVertical="true" + android:text="Request Permission" /> +</LinearLayout> diff --git a/tests/FlickerTests/test-apps/flickerapp/res/values/styles.xml b/tests/FlickerTests/test-apps/flickerapp/res/values/styles.xml index 1d21fd56a487..e51ed29adebf 100644 --- a/tests/FlickerTests/test-apps/flickerapp/res/values/styles.xml +++ b/tests/FlickerTests/test-apps/flickerapp/res/values/styles.xml @@ -43,6 +43,13 @@ <item name="android:windowSoftInputMode">stateUnchanged</item> </style> + <style name="TransparentTheme" parent="@android:style/Theme.DeviceDefault"> + <item name="android:windowIsTranslucent">true</item> + <item name="android:windowBackground">@android:color/transparent</item> + <item name="android:windowContentOverlay">@null</item> + <item name="android:backgroundDimEnabled">false</item> + </style> + <style name="no_starting_window" parent="@android:style/Theme.DeviceDefault"> <item name="android:windowDisablePreview">true</item> </style> diff --git a/tests/FlickerTests/test-apps/flickerapp/src/com/android/server/wm/flicker/testapp/ActivityEmbeddingAlwaysExpandActivity.java b/tests/FlickerTests/test-apps/flickerapp/src/com/android/server/wm/flicker/testapp/ActivityEmbeddingAlwaysExpandActivity.java new file mode 100644 index 000000000000..d9b24ed23424 --- /dev/null +++ b/tests/FlickerTests/test-apps/flickerapp/src/com/android/server/wm/flicker/testapp/ActivityEmbeddingAlwaysExpandActivity.java @@ -0,0 +1,33 @@ +/* + * Copyright (C) 2023 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.android.server.wm.flicker.testapp; + +import android.app.Activity; +import android.graphics.Color; +import android.os.Bundle; + +/** + * Activity with alwaysExpand=true (launched via R.id.launch_always_expand_activity_button) + */ +public class ActivityEmbeddingAlwaysExpandActivity extends Activity { + @Override + public void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_embedding_base_layout); + findViewById(R.id.root_activity_layout).setBackgroundColor(Color.GREEN); + } + +} diff --git a/tests/FlickerTests/test-apps/flickerapp/src/com/android/server/wm/flicker/testapp/ActivityEmbeddingMainActivity.java b/tests/FlickerTests/test-apps/flickerapp/src/com/android/server/wm/flicker/testapp/ActivityEmbeddingMainActivity.java index 6a7a2ccd3378..23fa91c37728 100644 --- a/tests/FlickerTests/test-apps/flickerapp/src/com/android/server/wm/flicker/testapp/ActivityEmbeddingMainActivity.java +++ b/tests/FlickerTests/test-apps/flickerapp/src/com/android/server/wm/flicker/testapp/ActivityEmbeddingMainActivity.java @@ -16,87 +16,149 @@ package com.android.server.wm.flicker.testapp; +import androidx.annotation.NonNull; import android.app.Activity; import android.content.Intent; import android.os.Bundle; -import android.util.ArraySet; -import android.util.Log; import android.view.View; -import androidx.window.extensions.embedding.ActivityEmbeddingComponent; -import androidx.window.extensions.embedding.EmbeddingRule; -import androidx.window.extensions.embedding.SplitPairRule; -import androidx.window.extensions.embedding.SplitPlaceholderRule; - -import com.android.server.wm.flicker.helpers.ActivityEmbeddingAppHelper; +import androidx.annotation.NonNull; +import androidx.window.embedding.ActivityFilter; +import androidx.window.embedding.ActivityRule; +import androidx.window.embedding.EmbeddingAspectRatio; +import androidx.window.embedding.RuleController; +import androidx.window.embedding.SplitAttributes; +import androidx.window.embedding.SplitAttributes.LayoutDirection; +import androidx.window.embedding.SplitController; +import androidx.window.embedding.SplitPairFilter; +import androidx.window.embedding.SplitPairRule; +import androidx.window.embedding.SplitPlaceholderRule; +import androidx.window.embedding.SplitRule; +import java.util.HashSet; import java.util.Set; /** Main activity of the ActivityEmbedding test app to launch other embedding activities. */ public class ActivityEmbeddingMainActivity extends Activity { private static final String TAG = "ActivityEmbeddingMainActivity"; private static final float DEFAULT_SPLIT_RATIO = 0.5f; + private RuleController mRuleController; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_embedding_main_layout); + final SplitController.SplitSupportStatus status = SplitController.getInstance( + this).getSplitSupportStatus(); + if (status != SplitController.SplitSupportStatus.SPLIT_AVAILABLE) { + throw new RuntimeException( + "Unable to initiate SplitController in ActivityEmbeddingMainActivity, " + + "splitSupportStatus = " + status); + } + mRuleController = RuleController.getInstance(this); + } + + /** R.id.launch_trampoline_button onClick */ + public void launchTrampolineActivity(View view) { + final String layoutDirection = view.getTag().toString(); + mRuleController.clearRules(); + mRuleController.addRule(createSplitPairRules(layoutDirection)); + startActivity(new Intent().setComponent( + ActivityOptions.ActivityEmbedding.TrampolineActivity.COMPONENT)); } /** R.id.launch_secondary_activity_button onClick */ public void launchSecondaryActivity(View view) { - initializeSplitRules(createSplitPairRules()); + final String layoutDirection = view.getTag().toString(); + mRuleController.clearRules(); + mRuleController.addRule(createSplitPairRules(layoutDirection)); startActivity(new Intent().setComponent( ActivityOptions.ActivityEmbedding.SecondaryActivity.COMPONENT)); } + /** R.id.launch_always_expand_activity_button onClick */ + public void launchAlwaysExpandActivity(View view) { + final Set<ActivityFilter> activityFilters = new HashSet<>(); + activityFilters.add( + new ActivityFilter(ActivityOptions.ActivityEmbedding.AlwaysExpandActivity.COMPONENT, + null)); + final ActivityRule activityRule = new ActivityRule.Builder(activityFilters) + .setAlwaysExpand(true) + .build(); + + RuleController rc = RuleController.getInstance(this); + + rc.addRule(activityRule); + startActivity(new Intent().setComponent( + ActivityOptions.ActivityEmbedding.AlwaysExpandActivity.COMPONENT)); + } + /** R.id.launch_placeholder_split_button onClick */ public void launchPlaceholderSplit(View view) { - initializeSplitRules(createSplitPlaceholderRules()); + final String layoutDirection = view.getTag().toString(); + mRuleController.clearRules(); + mRuleController.addRule(createSplitPlaceholderRules(layoutDirection)); startActivity(new Intent().setComponent( ActivityOptions.ActivityEmbedding.PlaceholderPrimaryActivity.COMPONENT)); } - private void initializeSplitRules(Set<EmbeddingRule> rules) { - ActivityEmbeddingComponent embeddingComponent = - ActivityEmbeddingAppHelper.getActivityEmbeddingComponent(); - if (embeddingComponent == null) { - // Embedding not supported - Log.d(TAG, "ActivityEmbedding is not supported on this device"); - finish(); - return; - } - embeddingComponent.setEmbeddingRules(rules); + private static SplitPairRule createSplitPairRules(@NonNull String layoutDirection) { + final Set<SplitPairFilter> pairFilters = new HashSet<>(); + final SplitPairFilter activitiesPair = new SplitPairFilter( + ActivityOptions.ActivityEmbedding.MainActivity.COMPONENT, + ActivityOptions.ActivityEmbedding.SecondaryActivity.COMPONENT, + null /* secondaryActivityIntentAction */); + pairFilters.add(activitiesPair); + final SplitAttributes splitAttributes = new SplitAttributes.Builder() + .setSplitType(SplitAttributes.SplitType.SPLIT_TYPE_EQUAL) + .setLayoutDirection(parseLayoutDirection(layoutDirection)) + .build(); + // Setting thresholds to ALWAYS_ALLOW values to make it easy for running on all devices. + final SplitPairRule rule = new SplitPairRule.Builder(pairFilters) + .setDefaultSplitAttributes(splitAttributes) + .setMinWidthDp(SplitRule.SPLIT_MIN_DIMENSION_ALWAYS_ALLOW) + .setMinHeightDp(SplitRule.SPLIT_MIN_DIMENSION_ALWAYS_ALLOW) + .setMinSmallestWidthDp(SplitRule.SPLIT_MIN_DIMENSION_ALWAYS_ALLOW) + .setMaxAspectRatioInPortrait(EmbeddingAspectRatio.ALWAYS_ALLOW) + .setMaxAspectRatioInLandscape(EmbeddingAspectRatio.ALWAYS_ALLOW) + .build(); + return rule; } - private Set<EmbeddingRule> createSplitPairRules() { - final Set<EmbeddingRule> rules = new ArraySet<>(); - final SplitPairRule rule = new SplitPairRule.Builder( - activitiesPair -> activitiesPair.first instanceof ActivityEmbeddingMainActivity - && activitiesPair.second instanceof ActivityEmbeddingSecondaryActivity, - activityIntentPair -> - activityIntentPair.first instanceof ActivityEmbeddingMainActivity - && activityIntentPair.second.getComponent().equals(ActivityOptions - .ActivityEmbedding.SecondaryActivity.COMPONENT), - windowMetrics -> true) - .setSplitRatio(DEFAULT_SPLIT_RATIO) + private static SplitPlaceholderRule createSplitPlaceholderRules( + @NonNull String layoutDirection) { + final Set<ActivityFilter> activityFilters = new HashSet<>(); + activityFilters.add(new ActivityFilter( + ActivityOptions.ActivityEmbedding.PlaceholderPrimaryActivity.COMPONENT, + null /* intentAction */)); + final Intent intent = new Intent(); + intent.setComponent( + ActivityOptions.ActivityEmbedding.PlaceholderSecondaryActivity.COMPONENT); + final SplitAttributes splitAttributes = new SplitAttributes.Builder() + .setSplitType(SplitAttributes.SplitType.SPLIT_TYPE_EQUAL) + .setLayoutDirection(parseLayoutDirection(layoutDirection)) + .build(); + final SplitPlaceholderRule rule = new SplitPlaceholderRule.Builder(activityFilters, intent) + .setDefaultSplitAttributes(splitAttributes) + .setMinWidthDp(SplitRule.SPLIT_MIN_DIMENSION_ALWAYS_ALLOW) + .setMinHeightDp(SplitRule.SPLIT_MIN_DIMENSION_ALWAYS_ALLOW) + .setMinSmallestWidthDp(SplitRule.SPLIT_MIN_DIMENSION_ALWAYS_ALLOW) + .setMaxAspectRatioInPortrait(EmbeddingAspectRatio.ALWAYS_ALLOW) + .setMaxAspectRatioInLandscape(EmbeddingAspectRatio.ALWAYS_ALLOW) .build(); - rules.add(rule); - return rules; + return rule; } - private Set<EmbeddingRule> createSplitPlaceholderRules() { - final Set<EmbeddingRule> rules = new ArraySet<>(); - final SplitPlaceholderRule rule = new SplitPlaceholderRule.Builder( - new Intent().setComponent( - ActivityOptions.ActivityEmbedding.PlaceholderSecondaryActivity.COMPONENT), - activity -> activity instanceof ActivityEmbeddingPlaceholderPrimaryActivity, - intent -> intent.getComponent().equals( - ActivityOptions.ActivityEmbedding.PlaceholderPrimaryActivity.COMPONENT), - windowMetrics -> true) - .setSplitRatio(DEFAULT_SPLIT_RATIO) - .build(); - rules.add(rule); - return rules; + private static LayoutDirection parseLayoutDirection(@NonNull String layoutDirectionStr) { + if (layoutDirectionStr.equals(LayoutDirection.LEFT_TO_RIGHT.toString())) { + return LayoutDirection.LEFT_TO_RIGHT; + } + if (layoutDirectionStr.equals(LayoutDirection.BOTTOM_TO_TOP.toString())) { + return LayoutDirection.BOTTOM_TO_TOP; + } + if (layoutDirectionStr.equals(LayoutDirection.RIGHT_TO_LEFT.toString())) { + return LayoutDirection.RIGHT_TO_LEFT; + } + return LayoutDirection.LOCALE; } } diff --git a/tests/FlickerTests/test-apps/flickerapp/src/com/android/server/wm/flicker/testapp/ActivityEmbeddingSecondaryActivity.java b/tests/FlickerTests/test-apps/flickerapp/src/com/android/server/wm/flicker/testapp/ActivityEmbeddingSecondaryActivity.java index 00f4c2576eb1..29cbf01dc6da 100644 --- a/tests/FlickerTests/test-apps/flickerapp/src/com/android/server/wm/flicker/testapp/ActivityEmbeddingSecondaryActivity.java +++ b/tests/FlickerTests/test-apps/flickerapp/src/com/android/server/wm/flicker/testapp/ActivityEmbeddingSecondaryActivity.java @@ -16,15 +16,73 @@ package com.android.server.wm.flicker.testapp; +import android.app.Activity; +import android.content.Intent; +import android.app.PictureInPictureParams; import android.graphics.Color; +import android.os.Bundle; +import android.view.View; +import android.widget.ToggleButton; + +import androidx.window.embedding.SplitAttributes; +import androidx.window.embedding.SplitAttributesCalculatorParams; +import androidx.window.embedding.SplitController; /** * Activity to be used as the secondary activity to split with * {@link ActivityEmbeddingMainActivity}. */ -public class ActivityEmbeddingSecondaryActivity extends ActivityEmbeddingBaseActivity { +public class ActivityEmbeddingSecondaryActivity extends Activity { + + private SplitController mSplitController; + @Override - int getBackgroundColor() { - return Color.YELLOW; + public void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_embedding_secondary_activity_layout); + findViewById(R.id.secondary_activity_layout).setBackgroundColor(Color.YELLOW); + findViewById(R.id.finish_secondary_activity_button).setOnClickListener( + new View.OnClickListener() { + @Override + public void onClick(View v) { + finish(); + } + }); + mSplitController = SplitController.getInstance(this); + final ToggleButton splitRatio = findViewById(R.id.toggle_split_ratio_button); + mSplitController.setSplitAttributesCalculator(params -> { + return new SplitAttributes.Builder() + .setSplitType( + SplitAttributes.SplitType.ratio( + splitRatio.isChecked() ? 0.7f : 0.5f) + ) + .setLayoutDirection( + params.getDefaultSplitAttributes() + .getLayoutDirection()) + .build(); + }); + splitRatio.setOnClickListener( + new View.OnClickListener() { + @Override + public void onClick(View v) { + // This triggers a recalcuation of splitatributes. + mSplitController.invalidateTopVisibleSplitAttributes(); + } + }); + findViewById(R.id.secondary_enter_pip_button).setOnClickListener( + new View.OnClickListener() { + @Override + public void onClick(View v) { + PictureInPictureParams.Builder picInPicParamsBuilder = + new PictureInPictureParams.Builder(); + enterPictureInPictureMode(picInPicParamsBuilder.build()); + } + } + ); + } + + public void launchThirdActivity(View view) { + startActivity(new Intent().setComponent( + ActivityOptions.ActivityEmbedding.ThirdActivity.COMPONENT)); } } diff --git a/tests/FlickerTests/test-apps/flickerapp/src/com/android/server/wm/flicker/testapp/ActivityEmbeddingThirdActivity.java b/tests/FlickerTests/test-apps/flickerapp/src/com/android/server/wm/flicker/testapp/ActivityEmbeddingThirdActivity.java new file mode 100644 index 000000000000..3bd72818d894 --- /dev/null +++ b/tests/FlickerTests/test-apps/flickerapp/src/com/android/server/wm/flicker/testapp/ActivityEmbeddingThirdActivity.java @@ -0,0 +1,34 @@ +/* + * Copyright (C) 2023 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.server.wm.flicker.testapp; + +import android.app.Activity; +import android.graphics.Color; +import android.os.Bundle; + +/** + * Activity to be used also as a secondary activity to split with + * {@link ActivityEmbeddingMainActivity}. + */ +public class ActivityEmbeddingThirdActivity extends Activity { + @Override + public void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_embedding_base_layout); + findViewById(R.id.root_activity_layout).setBackgroundColor(Color.RED); + } +} diff --git a/tests/FlickerTests/test-apps/flickerapp/src/com/android/server/wm/flicker/testapp/ActivityEmbeddingTrampolineActivity.java b/tests/FlickerTests/test-apps/flickerapp/src/com/android/server/wm/flicker/testapp/ActivityEmbeddingTrampolineActivity.java new file mode 100644 index 000000000000..67eac2ea1730 --- /dev/null +++ b/tests/FlickerTests/test-apps/flickerapp/src/com/android/server/wm/flicker/testapp/ActivityEmbeddingTrampolineActivity.java @@ -0,0 +1,36 @@ +/* + * Copyright (C) 2023 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.server.wm.flicker.testapp; + +import android.app.Activity; +import android.content.Intent; +import android.os.Bundle; + +/** + * A Trampoline Activity that launches {@link ActivityEmbeddingSecondaryActivity} and then + * finishes itself. + */ +public class ActivityEmbeddingTrampolineActivity extends Activity { + @Override + public void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + // Trampoline activity doesn't have a view. + startActivity(new Intent().setComponent( + ActivityOptions.ActivityEmbedding.SecondaryActivity.COMPONENT)); + finish(); + } +} diff --git a/tests/FlickerTests/test-apps/flickerapp/src/com/android/server/wm/flicker/testapp/ActivityOptions.java b/tests/FlickerTests/test-apps/flickerapp/src/com/android/server/wm/flicker/testapp/ActivityOptions.java index 9c3226b5292c..2795a6c43015 100644 --- a/tests/FlickerTests/test-apps/flickerapp/src/com/android/server/wm/flicker/testapp/ActivityOptions.java +++ b/tests/FlickerTests/test-apps/flickerapp/src/com/android/server/wm/flicker/testapp/ActivityOptions.java @@ -73,6 +73,18 @@ public class ActivityOptions { FLICKER_APP_PACKAGE + ".NonResizeablePortraitActivity"); } + public static class TransparentActivity { + public static final String LABEL = "TransparentActivity"; + public static final ComponentName COMPONENT = new ComponentName(FLICKER_APP_PACKAGE, + FLICKER_APP_PACKAGE + ".TransparentActivity"); + } + + public static class LaunchTransparentActivity { + public static final String LABEL = "LaunchTransparentActivity"; + public static final ComponentName COMPONENT = new ComponentName(FLICKER_APP_PACKAGE, + FLICKER_APP_PACKAGE + ".LaunchTransparentActivity"); + } + public static class DialogThemedActivity { public static final String LABEL = "DialogThemedActivity"; public static final ComponentName COMPONENT = new ComponentName(FLICKER_APP_PACKAGE, @@ -99,6 +111,18 @@ public class ActivityOptions { FLICKER_APP_PACKAGE + ".ActivityEmbeddingSecondaryActivity"); } + public static class ThirdActivity { + public static final String LABEL = "ActivityEmbeddingThirdActivity"; + public static final ComponentName COMPONENT = new ComponentName(FLICKER_APP_PACKAGE, + FLICKER_APP_PACKAGE + ".ActivityEmbeddingThirdActivity"); + } + + public static class AlwaysExpandActivity { + public static final String LABEL = "ActivityEmbeddingAlwaysExpandActivity"; + public static final ComponentName COMPONENT = new ComponentName(FLICKER_APP_PACKAGE, + FLICKER_APP_PACKAGE + ".ActivityEmbeddingAlwaysExpandActivity"); + } + public static class PlaceholderPrimaryActivity { public static final String LABEL = "ActivityEmbeddingPlaceholderPrimaryActivity"; public static final ComponentName COMPONENT = new ComponentName(FLICKER_APP_PACKAGE, @@ -110,6 +134,12 @@ public class ActivityOptions { public static final ComponentName COMPONENT = new ComponentName(FLICKER_APP_PACKAGE, FLICKER_APP_PACKAGE + ".ActivityEmbeddingPlaceholderSecondaryActivity"); } + + public static class TrampolineActivity { + public static final String LABEL = "ActivityEmbeddingTrampolineActivity"; + public static final ComponentName COMPONENT = new ComponentName(FLICKER_APP_PACKAGE, + FLICKER_APP_PACKAGE + ".ActivityEmbeddingTrampolineActivity"); + } } public static class Notification { @@ -180,6 +210,8 @@ public class ActivityOptions { public static final String LABEL = "SplitScreenPrimaryActivity"; public static final ComponentName COMPONENT = new ComponentName(FLICKER_APP_PACKAGE, FLICKER_APP_PACKAGE + ".SplitScreenActivity"); + + public static final String EXTRA_LAUNCH_ADJACENT = "launch_adjacent"; } public static class Secondary { diff --git a/tests/FlickerTests/test-apps/flickerapp/src/com/android/server/wm/flicker/testapp/LaunchTransparentActivity.java b/tests/FlickerTests/test-apps/flickerapp/src/com/android/server/wm/flicker/testapp/LaunchTransparentActivity.java new file mode 100644 index 000000000000..7c161fd8e611 --- /dev/null +++ b/tests/FlickerTests/test-apps/flickerapp/src/com/android/server/wm/flicker/testapp/LaunchTransparentActivity.java @@ -0,0 +1,36 @@ +/* + * Copyright (C) 2023 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.server.wm.flicker.testapp; + +import android.app.Activity; +import android.content.Intent; +import android.os.Bundle; + +public class LaunchTransparentActivity extends Activity { + + @Override + protected void onCreate(Bundle icicle) { + super.onCreate(icicle); + setContentView(R.layout.activity_transparent_launch); + findViewById(R.id.button_launch_transparent) + .setOnClickListener(v -> launchTransparentActivity()); + } + + private void launchTransparentActivity() { + startActivity(new Intent(this, TransparentActivity.class)); + } +} diff --git a/tests/FlickerTests/test-apps/flickerapp/src/com/android/server/wm/flicker/testapp/SplitScreenActivity.java b/tests/FlickerTests/test-apps/flickerapp/src/com/android/server/wm/flicker/testapp/SplitScreenActivity.java index 70196aee9ff1..8a27252e3483 100644 --- a/tests/FlickerTests/test-apps/flickerapp/src/com/android/server/wm/flicker/testapp/SplitScreenActivity.java +++ b/tests/FlickerTests/test-apps/flickerapp/src/com/android/server/wm/flicker/testapp/SplitScreenActivity.java @@ -16,9 +16,14 @@ package com.android.server.wm.flicker.testapp; +import static com.android.server.wm.flicker.testapp.ActivityOptions.SplitScreen.Primary.EXTRA_LAUNCH_ADJACENT; + import android.app.Activity; +import android.content.Intent; import android.os.Bundle; +import androidx.annotation.Nullable; + public class SplitScreenActivity extends Activity { @Override @@ -26,4 +31,17 @@ public class SplitScreenActivity extends Activity { super.onCreate(icicle); setContentView(R.layout.activity_splitscreen); } + + @Override + protected void onPostCreate(@Nullable Bundle savedInstanceState) { + super.onPostCreate(savedInstanceState); + final boolean startSecondaryActivity = getIntent().hasExtra(EXTRA_LAUNCH_ADJACENT); + if (startSecondaryActivity) { + final Intent intent = new Intent(this, SplitScreenSecondaryActivity.class); + intent.addCategory(Intent.CATEGORY_LAUNCHER); + intent.addFlags(Intent.FLAG_ACTIVITY_LAUNCH_ADJACENT | Intent.FLAG_ACTIVITY_NEW_TASK + | Intent.FLAG_ACTIVITY_MULTIPLE_TASK); + startActivity(intent); + } + } } diff --git a/tests/FlickerTests/test-apps/flickerapp/src/com/android/server/wm/flicker/testapp/TransparentActivity.java b/tests/FlickerTests/test-apps/flickerapp/src/com/android/server/wm/flicker/testapp/TransparentActivity.java new file mode 100644 index 000000000000..1bac8bdb003a --- /dev/null +++ b/tests/FlickerTests/test-apps/flickerapp/src/com/android/server/wm/flicker/testapp/TransparentActivity.java @@ -0,0 +1,29 @@ +/* + * Copyright (C) 2023 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.server.wm.flicker.testapp; + +import android.app.Activity; +import android.os.Bundle; + +public class TransparentActivity extends Activity { + + @Override + protected void onCreate(Bundle icicle) { + super.onCreate(icicle); + setContentView(R.layout.activity_transparent); + } +} diff --git a/tests/FlickerTests/trace_config/trace_config.textproto b/tests/FlickerTests/trace_config/trace_config.textproto new file mode 100644 index 000000000000..c9a35aca9085 --- /dev/null +++ b/tests/FlickerTests/trace_config/trace_config.textproto @@ -0,0 +1,77 @@ +# Copyright (C) 2023 The Android Open Source Project +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# proto-message: TraceConfig + +# Enable periodic flushing of the trace buffer into the output file. +write_into_file: true + +# Writes the userspace buffer into the file every 1s. +file_write_period_ms: 2500 + +# See b/126487238 - we need to guarantee ordering of events. +flush_period_ms: 30000 + +# The trace buffers needs to be big enough to hold |file_write_period_ms| of +# trace data. The trace buffer sizing depends on the number of trace categories +# enabled and the device activity. + +# RSS events +buffers: { + size_kb: 63488 + fill_policy: RING_BUFFER +} + +data_sources { + config { + name: "linux.process_stats" + target_buffer: 0 + # polled per-process memory counters and process/thread names. + # If you don't want the polled counters, remove the "process_stats_config" + # section, but keep the data source itself as it still provides on-demand + # thread/process naming for ftrace data below. + process_stats_config { + scan_all_processes_on_start: true + } + } +} + +data_sources: { + config { + name: "linux.ftrace" + ftrace_config { + ftrace_events: "ftrace/print" + ftrace_events: "task/task_newtask" + ftrace_events: "task/task_rename" + atrace_categories: "ss" + atrace_categories: "wm" + atrace_categories: "am" + atrace_categories: "aidl" + atrace_categories: "input" + atrace_categories: "binder_driver" + atrace_categories: "sched_process_exit" + atrace_apps: "com.android.server.wm.flicker" + atrace_apps: "com.android.server.wm.flicker.other" + atrace_apps: "com.android.server.wm.flicker.close" + atrace_apps: "com.android.server.wm.flicker.ime" + atrace_apps: "com.android.server.wm.flicker.launch" + atrace_apps: "com.android.server.wm.flicker.quickswitch" + atrace_apps: "com.android.server.wm.flicker.rotation" + atrace_apps: "com.android.server.wm.flicker.testapp" + atrace_apps: "com.android.systemui" + atrace_apps: "com.google.android.apps.nexuslauncher" + } + } +} + diff --git a/tests/Input/src/com/android/test/input/MotionPredictorTest.kt b/tests/Input/src/com/android/test/input/MotionPredictorTest.kt index 24a567130ff0..d3eeac147c2a 100644 --- a/tests/Input/src/com/android/test/input/MotionPredictorTest.kt +++ b/tests/Input/src/com/android/test/input/MotionPredictorTest.kt @@ -129,7 +129,7 @@ class MotionPredictorTest { // Prediction will happen for t=12 (since it is the next input interval after the requested // time, 8, plus the model offset, 1). assertEquals(12, predicted!!.eventTime) - assertEquals(30f, predicted.x, /*delta=*/5f) + assertEquals(30f, predicted.x, /*delta=*/10f) assertEquals(60f, predicted.y, /*delta=*/15f) } } diff --git a/tests/InputMethodStressTest/src/com/android/inputmethod/stresstest/AutoShowTest.java b/tests/InputMethodStressTest/src/com/android/inputmethod/stresstest/AutoShowTest.java index 807f0c63668c..e60d8efdbfa4 100644 --- a/tests/InputMethodStressTest/src/com/android/inputmethod/stresstest/AutoShowTest.java +++ b/tests/InputMethodStressTest/src/com/android/inputmethod/stresstest/AutoShowTest.java @@ -23,6 +23,7 @@ import static com.android.inputmethod.stresstest.ImeStressTestUtil.UNFOCUSABLE_V import static com.android.inputmethod.stresstest.ImeStressTestUtil.callOnMainSync; import static com.android.inputmethod.stresstest.ImeStressTestUtil.getWindowAndSoftInputFlagParameters; import static com.android.inputmethod.stresstest.ImeStressTestUtil.hasUnfocusableWindowFlags; +import static com.android.inputmethod.stresstest.ImeStressTestUtil.requestFocusAndVerify; import static com.android.inputmethod.stresstest.ImeStressTestUtil.verifyImeAlwaysHiddenWithWindowFlagSet; import static com.android.inputmethod.stresstest.ImeStressTestUtil.verifyImeIsAlwaysHidden; import static com.android.inputmethod.stresstest.ImeStressTestUtil.verifyWindowAndViewFocus; @@ -225,7 +226,7 @@ public final class AutoShowTest { Intent intent1 = createIntent(mWindowFocusFlags, mSoftInputFlags, Collections.emptyList()); TestActivity firstActivity = TestActivity.start(intent1); // Request view focus after app starts - mInstrumentation.runOnMainSync(firstActivity::requestFocus); + requestFocusAndVerify(firstActivity); Intent intent2 = createIntent( @@ -252,7 +253,7 @@ public final class AutoShowTest { Intent intent1 = createIntent(mWindowFocusFlags, mSoftInputFlags, Collections.emptyList()); TestActivity activity = TestActivity.start(intent1); // Request view focus after app starts - mInstrumentation.runOnMainSync(activity::requestFocus); + requestFocusAndVerify(activity); // Create second TestActivity Intent intent2 = @@ -284,7 +285,7 @@ public final class AutoShowTest { Intent intent = createIntent(mWindowFocusFlags, mSoftInputFlags, Collections.emptyList()); TestActivity activity = TestActivity.start(intent); // Request view focus after app starts - mInstrumentation.runOnMainSync(activity::requestFocus); + requestFocusAndVerify(activity); // Find the editText and click it UiObject2 editTextUiObject = diff --git a/tests/InputMethodStressTest/src/com/android/inputmethod/stresstest/DefaultImeVisibilityTest.java b/tests/InputMethodStressTest/src/com/android/inputmethod/stresstest/DefaultImeVisibilityTest.java index 0c267b27490b..2ac25f2696d3 100644 --- a/tests/InputMethodStressTest/src/com/android/inputmethod/stresstest/DefaultImeVisibilityTest.java +++ b/tests/InputMethodStressTest/src/com/android/inputmethod/stresstest/DefaultImeVisibilityTest.java @@ -17,20 +17,27 @@ package com.android.inputmethod.stresstest; import static android.view.WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE; -import static android.view.WindowManager.LayoutParams.SOFT_INPUT_STATE_UNSPECIFIED; +import static android.view.WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN; +import static com.android.compatibility.common.util.SystemUtil.eventually; import static com.android.inputmethod.stresstest.ImeStressTestUtil.REQUEST_FOCUS_ON_CREATE; import static com.android.inputmethod.stresstest.ImeStressTestUtil.TestActivity.createIntent; import static com.android.inputmethod.stresstest.ImeStressTestUtil.callOnMainSync; +import static com.android.inputmethod.stresstest.ImeStressTestUtil.requestFocusAndVerify; import static com.android.inputmethod.stresstest.ImeStressTestUtil.verifyWindowAndViewFocus; import static com.android.inputmethod.stresstest.ImeStressTestUtil.waitOnMainUntilImeIsHidden; import static com.android.inputmethod.stresstest.ImeStressTestUtil.waitOnMainUntilImeIsShown; +import static com.google.common.truth.Truth.assertWithMessage; + import android.content.Intent; import android.platform.test.annotations.RootPermissionTest; import android.platform.test.rule.UnlockScreenRule; +import android.support.test.uiautomator.UiDevice; import android.widget.EditText; +import androidx.test.platform.app.InstrumentationRegistry; + import org.junit.Rule; import org.junit.Test; import org.junit.runner.RunWith; @@ -39,6 +46,7 @@ import org.junit.runners.Parameterized; import java.util.Arrays; import java.util.Collections; import java.util.List; +import java.util.concurrent.TimeUnit; /** * Test IME visibility by using system default IME to ensure the behavior is consistent @@ -59,8 +67,12 @@ public final class DefaultImeVisibilityTest { public ScreenCaptureRule mScreenCaptureRule = new ScreenCaptureRule("/sdcard/InputMethodStressTest"); + private static final long TIMEOUT = TimeUnit.SECONDS.toMillis(3); + private static final int NUM_TEST_ITERATIONS = 10; + private final boolean mIsPortrait; + @Parameterized.Parameters(name = "isPortrait={0}") public static List<Boolean> isPortraitCases() { // Test in both portrait and landscape mode. @@ -68,6 +80,7 @@ public final class DefaultImeVisibilityTest { } public DefaultImeVisibilityTest(boolean isPortrait) { + mIsPortrait = isPortrait; mImeStressTestRule.setIsPortrait(isPortrait); } @@ -75,14 +88,26 @@ public final class DefaultImeVisibilityTest { public void showHideDefaultIme() { Intent intent = createIntent( - 0x0, /* No window focus flags */ - SOFT_INPUT_STATE_UNSPECIFIED | SOFT_INPUT_ADJUST_RESIZE, + 0x0 /* No window focus flags */, + SOFT_INPUT_STATE_HIDDEN | SOFT_INPUT_ADJUST_RESIZE, Collections.singletonList(REQUEST_FOCUS_ON_CREATE)); ImeStressTestUtil.TestActivity activity = ImeStressTestUtil.TestActivity.start(intent); EditText editText = activity.getEditText(); + + UiDevice uiDevice = UiDevice.getInstance(InstrumentationRegistry.getInstrumentation()); + eventually( + () -> + assertWithMessage("Display rotation should have been updated") + .that(uiDevice.getDisplayRotation()) + .isEqualTo(mIsPortrait ? 0 : 1), + TIMEOUT); + for (int i = 0; i < NUM_TEST_ITERATIONS; i++) { - callOnMainSync(activity::showImeWithInputMethodManager); + // TODO(b/291752364): Remove the explicit focus request once the issue with view focus + // change between fullscreen IME and actual editText is fixed. + requestFocusAndVerify(activity); verifyWindowAndViewFocus(editText, true, true); + callOnMainSync(activity::showImeWithInputMethodManager); waitOnMainUntilImeIsShown(editText); callOnMainSync(activity::hideImeWithInputMethodManager); diff --git a/tests/InputMethodStressTest/src/com/android/inputmethod/stresstest/ImeOpenCloseStressTest.java b/tests/InputMethodStressTest/src/com/android/inputmethod/stresstest/ImeOpenCloseStressTest.java index 5c0212400ff1..5368025ff898 100644 --- a/tests/InputMethodStressTest/src/com/android/inputmethod/stresstest/ImeOpenCloseStressTest.java +++ b/tests/InputMethodStressTest/src/com/android/inputmethod/stresstest/ImeOpenCloseStressTest.java @@ -29,6 +29,7 @@ import static com.android.inputmethod.stresstest.ImeStressTestUtil.callOnMainSyn import static com.android.inputmethod.stresstest.ImeStressTestUtil.getWindowAndSoftInputFlagParameters; import static com.android.inputmethod.stresstest.ImeStressTestUtil.hasUnfocusableWindowFlags; import static com.android.inputmethod.stresstest.ImeStressTestUtil.isImeShown; +import static com.android.inputmethod.stresstest.ImeStressTestUtil.requestFocusAndVerify; import static com.android.inputmethod.stresstest.ImeStressTestUtil.verifyImeAlwaysHiddenWithWindowFlagSet; import static com.android.inputmethod.stresstest.ImeStressTestUtil.verifyImeIsAlwaysHidden; import static com.android.inputmethod.stresstest.ImeStressTestUtil.verifyWindowAndViewFocus; @@ -38,6 +39,9 @@ import static com.android.inputmethod.stresstest.ImeStressTestUtil.waitOnMainUnt import static com.google.common.truth.Truth.assertThat; +import static org.junit.Assume.assumeFalse; +import static org.junit.Assume.assumeTrue; + import android.app.Instrumentation; import android.content.Intent; import android.os.Build; @@ -96,7 +100,8 @@ public final class ImeOpenCloseStressTest { Intent intent = createIntent(mWindowFocusFlags, mSoftInputFlags, Collections.emptyList()); TestActivity activity = TestActivity.start(intent); // Request focus after app starts to avoid triggering auto-show behavior. - mInstrumentation.runOnMainSync(activity::requestFocus); + requestFocusAndVerify(activity); + // Test only once if window flags set to save time. int iterNum = hasUnfocusableWindowFlags(activity) ? 1 : NUM_TEST_ITERATIONS; for (int i = 0; i < iterNum; i++) { @@ -106,21 +111,19 @@ public final class ImeOpenCloseStressTest { verifyShowBehavior(activity); callOnMainSync(activity::hideImeWithInputMethodManager); - verifyHideBehavior(activity); } } @Test public void testShowHideWithInputMethodManager_waitingAnimationEnd() { + assumeFalse("Has unfocusable window flags", hasUnfocusableWindowFlags(mWindowFocusFlags)); + Intent intent = createIntent(mWindowFocusFlags, mSoftInputFlags, Collections.emptyList()); TestActivity activity = TestActivity.start(intent); // Request focus after app starts to avoid triggering auto-show behavior. - mInstrumentation.runOnMainSync(activity::requestFocus); + requestFocusAndVerify(activity); - if (hasUnfocusableWindowFlags(activity)) { - return; // Skip to save time. - } activity.enableAnimationMonitoring(); EditText editText = activity.getEditText(); for (int i = 0; i < NUM_TEST_ITERATIONS; i++) { @@ -128,12 +131,12 @@ public final class ImeOpenCloseStressTest { Log.i(TAG, msgPrefix + "start"); callOnMainSync(activity::showImeWithInputMethodManager); waitOnMainUntil( - msgPrefix + "IME should be visible", + msgPrefix + "IME should have been shown", () -> !activity.isAnimating() && isImeShown(editText)); callOnMainSync(activity::hideImeWithInputMethodManager); waitOnMainUntil( - msgPrefix + "IME should be hidden", + msgPrefix + "IME should have been hidden", () -> !activity.isAnimating() && !isImeShown(editText)); } } @@ -141,13 +144,13 @@ public final class ImeOpenCloseStressTest { @Test public void testShowHideWithInputMethodManager_intervalAfterHide() { // Regression test for b/221483132 + assumeFalse("Has unfocusable window flags", hasUnfocusableWindowFlags(mWindowFocusFlags)); + Intent intent = createIntent(mWindowFocusFlags, mSoftInputFlags, Collections.emptyList()); TestActivity activity = TestActivity.start(intent); // Request focus after app starts to avoid triggering auto-show behavior. - mInstrumentation.runOnMainSync(activity::requestFocus); - if (hasUnfocusableWindowFlags(activity)) { - return; // Skip to save time. - } + requestFocusAndVerify(activity); + // Intervals = 10, 20, 30, ..., 100, 150, 200, ... List<Integer> intervals = new ArrayList<>(); for (int i = 10; i < 100; i += 10) intervals.add(i); @@ -165,14 +168,12 @@ public final class ImeOpenCloseStressTest { @Test public void testShowHideWithInputMethodManager_inSameFrame() { + assumeFalse("Has unfocusable window flags", hasUnfocusableWindowFlags(mWindowFocusFlags)); Intent intent = createIntent(mWindowFocusFlags, mSoftInputFlags, Collections.emptyList()); TestActivity activity = TestActivity.start(intent); // Request focus after app starts to avoid triggering auto-show behavior. - mInstrumentation.runOnMainSync(activity::requestFocus); + requestFocusAndVerify(activity); - if (hasUnfocusableWindowFlags(activity)) { - return; // Skip to save time. - } // hidden -> show -> hide mInstrumentation.runOnMainSync( () -> { @@ -256,13 +257,12 @@ public final class ImeOpenCloseStressTest { @Test public void testShowHideWithWindowInsetsController_waitingVisibilityChange() { - if (Build.VERSION.SDK_INT < Build.VERSION_CODES.R) { - return; - } + assumeTrue("Is at least Android R", Build.VERSION.SDK_INT >= Build.VERSION_CODES.R); Intent intent = createIntent(mWindowFocusFlags, mSoftInputFlags, Collections.emptyList()); TestActivity activity = TestActivity.start(intent); // Request focus after app starts to avoid triggering auto-show behavior. - mInstrumentation.runOnMainSync(activity::requestFocus); + requestFocusAndVerify(activity); + // Test only once if window flags set to save time. int iterNum = hasUnfocusableWindowFlags(activity) ? 1 : NUM_TEST_ITERATIONS; for (int i = 0; i < iterNum; i++) { @@ -277,17 +277,13 @@ public final class ImeOpenCloseStressTest { @Test public void testShowHideWithWindowInsetsController_waitingAnimationEnd() { - if (Build.VERSION.SDK_INT < Build.VERSION_CODES.R) { - return; - } + assumeTrue("Is at least Android R", Build.VERSION.SDK_INT >= Build.VERSION_CODES.R); + assumeFalse("Has unfocusable window flags", hasUnfocusableWindowFlags(mWindowFocusFlags)); Intent intent = createIntent(mWindowFocusFlags, mSoftInputFlags, Collections.emptyList()); TestActivity activity = TestActivity.start(intent); // Request focus after app starts to avoid triggering auto-show behavior. - mInstrumentation.runOnMainSync(activity::requestFocus); + requestFocusAndVerify(activity); - if (hasUnfocusableWindowFlags(activity)) { - return; // Skip to save time. - } activity.enableAnimationMonitoring(); EditText editText = activity.getEditText(); for (int i = 0; i < NUM_TEST_ITERATIONS; i++) { @@ -295,29 +291,25 @@ public final class ImeOpenCloseStressTest { Log.i(TAG, msgPrefix + "start"); mInstrumentation.runOnMainSync(activity::showImeWithWindowInsetsController); waitOnMainUntil( - msgPrefix + "IME should be visible", + msgPrefix + "IME should have been shown", () -> !activity.isAnimating() && isImeShown(editText)); mInstrumentation.runOnMainSync(activity::hideImeWithWindowInsetsController); waitOnMainUntil( - msgPrefix + "IME should be hidden", + msgPrefix + "IME should have been hidden", () -> !activity.isAnimating() && !isImeShown(editText)); } } @Test public void testShowHideWithWindowInsetsController_intervalAfterHide() { - if (Build.VERSION.SDK_INT < Build.VERSION_CODES.R) { - return; - } + assumeTrue("Is at least Android R", Build.VERSION.SDK_INT >= Build.VERSION_CODES.R); + assumeFalse("Has unfocusable window flags", hasUnfocusableWindowFlags(mWindowFocusFlags)); Intent intent = createIntent(mWindowFocusFlags, mSoftInputFlags, Collections.emptyList()); TestActivity activity = TestActivity.start(intent); // Request focus after app starts to avoid triggering auto-show behavior. - mInstrumentation.runOnMainSync(activity::requestFocus); + requestFocusAndVerify(activity); - if (hasUnfocusableWindowFlags(activity)) { - return; // Skip to save time. - } // Intervals = 10, 20, 30, ..., 100, 150, 200, ... List<Integer> intervals = new ArrayList<>(); for (int i = 10; i < 100; i += 10) intervals.add(i); @@ -335,17 +327,13 @@ public final class ImeOpenCloseStressTest { @Test public void testShowHideWithWindowInsetsController_inSameFrame() { - if (Build.VERSION.SDK_INT < Build.VERSION_CODES.R) { - return; - } + assumeTrue("Is at least Android R", Build.VERSION.SDK_INT >= Build.VERSION_CODES.R); + assumeFalse("Has unfocusable window flags", hasUnfocusableWindowFlags(mWindowFocusFlags)); Intent intent = createIntent(mWindowFocusFlags, mSoftInputFlags, Collections.emptyList()); TestActivity activity = TestActivity.start(intent); // Request focus after app starts to avoid triggering auto-show behavior. - mInstrumentation.runOnMainSync(activity::requestFocus); + requestFocusAndVerify(activity); - if (hasUnfocusableWindowFlags(activity)) { - return; // Skip to save time. - } // hidden -> show -> hide mInstrumentation.runOnMainSync( () -> { @@ -377,9 +365,7 @@ public final class ImeOpenCloseStressTest { @Test public void testShowWithWindowInsetsController_onCreate_requestFocus() { - if (Build.VERSION.SDK_INT < Build.VERSION_CODES.R) { - return; - } + assumeTrue("Is at least Android R", Build.VERSION.SDK_INT >= Build.VERSION_CODES.R); // Show with InputMethodManager at onCreate() Intent intent = createIntent( @@ -394,10 +380,8 @@ public final class ImeOpenCloseStressTest { @Test public void testShowWithWindowInsetsController_onCreate_notRequestFocus() { - if (Build.VERSION.SDK_INT < Build.VERSION_CODES.R) { - return; - } - // Show and hide with InputMethodManager at onCreate() + assumeTrue("Is at least Android R", Build.VERSION.SDK_INT >= Build.VERSION_CODES.R); + // Show and hide with WindowInsetsController at onCreate() Intent intent = createIntent( mWindowFocusFlags, @@ -411,10 +395,8 @@ public final class ImeOpenCloseStressTest { @Test public void testShowWithWindowInsetsController_afterStart_notRequestFocus() { - if (Build.VERSION.SDK_INT < Build.VERSION_CODES.R) { - return; - } - // Show and hide with InputMethodManager at onCreate() + assumeTrue("Is at least Android R", Build.VERSION.SDK_INT >= Build.VERSION_CODES.R); + // Show and hide with WindowInsetsController at onCreate() Intent intent = createIntent(mWindowFocusFlags, mSoftInputFlags, Collections.emptyList()); TestActivity activity = TestActivity.start(intent); mInstrumentation.runOnMainSync(activity::showImeWithWindowInsetsController); @@ -425,7 +407,8 @@ public final class ImeOpenCloseStressTest { /** * Test IME hidden by calling show and hide IME consecutively with - * {@link android.view.WindowInsetsController} APIs in {@link android.app.Activity#onCreate}. + * {@link android.view.WindowInsetsController} APIs in + * {@link android.app.Activity#onCreate}. * * <p> Note for developers: Use {@link WindowManager.LayoutParams#SOFT_INPUT_STATE_UNCHANGED} * window flag to avoid some softInputMode visibility flags may take presence over @@ -436,13 +419,11 @@ public final class ImeOpenCloseStressTest { */ @Test public void testHideWithWindowInsetsController_onCreate_requestFocus() { - if (Build.VERSION.SDK_INT < Build.VERSION_CODES.R) { - return; - } + assumeTrue("Is at least Android R", Build.VERSION.SDK_INT >= Build.VERSION_CODES.R); if (mSoftInputFlags != SOFT_INPUT_STATE_UNCHANGED) { return; } - // Show and hide with InputMethodManager at onCreate() + // Show and hide with WindowInsetsController at onCreate() Intent intent = createIntent( mWindowFocusFlags, diff --git a/tests/InputMethodStressTest/src/com/android/inputmethod/stresstest/ImeStressTestRule.java b/tests/InputMethodStressTest/src/com/android/inputmethod/stresstest/ImeStressTestRule.java index 12104b298dac..c7463218b646 100644 --- a/tests/InputMethodStressTest/src/com/android/inputmethod/stresstest/ImeStressTestRule.java +++ b/tests/InputMethodStressTest/src/com/android/inputmethod/stresstest/ImeStressTestRule.java @@ -20,9 +20,9 @@ import android.app.Instrumentation; import android.os.RemoteException; import android.support.test.uiautomator.UiDevice; +import androidx.annotation.NonNull; import androidx.test.platform.app.InstrumentationRegistry; -import org.checkerframework.checker.nullness.qual.NonNull; import org.junit.rules.TestWatcher; import org.junit.runner.Description; @@ -35,8 +35,6 @@ import java.io.IOException; public class ImeStressTestRule extends TestWatcher { private static final String LOCK_SCREEN_OFF_COMMAND = "locksettings set-disabled true"; private static final String LOCK_SCREEN_ON_COMMAND = "locksettings set-disabled false"; - private static final String SET_PORTRAIT_MODE_COMMAND = "settings put system user_rotation 0"; - private static final String SET_LANDSCAPE_MODE_COMMAND = "settings put system user_rotation 1"; private static final String SIMPLE_IME_ID = "com.android.apps.inputmethod.simpleime/.SimpleInputMethodService"; private static final String ENABLE_IME_COMMAND = "ime enable " + SIMPLE_IME_ID; @@ -44,8 +42,10 @@ public class ImeStressTestRule extends TestWatcher { private static final String DISABLE_IME_COMMAND = "ime disable " + SIMPLE_IME_ID; private static final String RESET_IME_COMMAND = "ime reset"; - @NonNull private final Instrumentation mInstrumentation; - @NonNull private final UiDevice mUiDevice; + @NonNull + private final Instrumentation mInstrumentation; + @NonNull + private final UiDevice mUiDevice; // Whether the screen orientation is set to portrait. private boolean mIsPortrait; // Whether to use a simple test Ime or system default Ime for test. @@ -105,12 +105,13 @@ public class ImeStressTestRule extends TestWatcher { private void setOrientation() { try { mUiDevice.freezeRotation(); - executeShellCommand( - mIsPortrait ? SET_PORTRAIT_MODE_COMMAND : SET_LANDSCAPE_MODE_COMMAND); - } catch (IOException e) { - throw new RuntimeException("Could not set screen orientation.", e); + if (mIsPortrait) { + mUiDevice.setOrientationNatural(); + } else { + mUiDevice.setOrientationLeft(); + } } catch (RemoteException e) { - throw new RuntimeException("Could not freeze rotation.", e); + throw new RuntimeException("Could not freeze rotation or set screen orientation.", e); } } @@ -147,7 +148,8 @@ public class ImeStressTestRule extends TestWatcher { } } - private @NonNull String executeShellCommand(@NonNull String cmd) throws IOException { + @NonNull + private String executeShellCommand(@NonNull String cmd) throws IOException { return mUiDevice.executeShellCommand(cmd); } } diff --git a/tests/InputMethodStressTest/src/com/android/inputmethod/stresstest/ImeStressTestUtil.java b/tests/InputMethodStressTest/src/com/android/inputmethod/stresstest/ImeStressTestUtil.java index f3c81942ae42..c0c60eff0f9f 100644 --- a/tests/InputMethodStressTest/src/com/android/inputmethod/stresstest/ImeStressTestUtil.java +++ b/tests/InputMethodStressTest/src/com/android/inputmethod/stresstest/ImeStressTestUtil.java @@ -40,6 +40,7 @@ import android.view.inputmethod.InputMethodManager; import android.widget.EditText; import android.widget.LinearLayout; +import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.test.platform.app.InstrumentationRegistry; @@ -149,19 +150,27 @@ public final class ImeStressTestUtil { } /** + * Requests EditText view focus on the main thread, and assert this returns {@code true}. + */ + public static void requestFocusAndVerify(TestActivity activity) { + boolean result = callOnMainSync(activity::requestFocus); + assertWithMessage("View focus request should have succeeded").that(result).isTrue(); + } + + /** * Waits until {@code pred} returns true, or throws on timeout. * * <p>The given {@code pred} will be called on the main thread. */ public static void waitOnMainUntil(String message, Callable<Boolean> pred) { - eventually(() -> assertWithMessage(message).that(pred.call()).isTrue(), TIMEOUT); + eventually(() -> assertWithMessage(message).that(callOnMainSync(pred)).isTrue(), TIMEOUT); } /** Waits until IME is shown, or throws on timeout. */ public static void waitOnMainUntilImeIsShown(View view) { eventually( () -> - assertWithMessage("IME should be shown") + assertWithMessage("IME should have been shown") .that(callOnMainSync(() -> isImeShown(view))) .isTrue(), TIMEOUT); @@ -171,27 +180,28 @@ public final class ImeStressTestUtil { public static void waitOnMainUntilImeIsHidden(View view) { eventually( () -> - assertWithMessage("IME should be hidden") + assertWithMessage("IME should have been hidden") .that(callOnMainSync(() -> isImeShown(view))) .isFalse(), TIMEOUT); } - /** Waits until window get focus, or throws on timeout. */ + /** Waits until window gains focus, or throws on timeout. */ public static void waitOnMainUntilWindowGainsFocus(View view) { eventually( () -> - assertWithMessage("Window should gain focus") + assertWithMessage( + "Window should have gained focus; value of hasWindowFocus:") .that(callOnMainSync(view::hasWindowFocus)) .isTrue(), TIMEOUT); } - /** Waits until view get focus, or throws on timeout. */ + /** Waits until view gains focus, or throws on timeout. */ public static void waitOnMainUntilViewGainsFocus(View view) { eventually( () -> - assertWithMessage("View should gain focus") + assertWithMessage("View should have gained focus; value of hasFocus:") .that(callOnMainSync(view::hasFocus)) .isTrue(), TIMEOUT); @@ -201,7 +211,7 @@ public final class ImeStressTestUtil { public static void verifyImeIsAlwaysHidden(View view) { always( () -> - assertWithMessage("IME should be hidden") + assertWithMessage("IME should have been hidden") .that(callOnMainSync(() -> isImeShown(view))) .isFalse(), TIMEOUT); @@ -211,7 +221,8 @@ public final class ImeStressTestUtil { public static void verifyWindowNeverGainsFocus(View view) { always( () -> - assertWithMessage("window should never gain focus") + assertWithMessage( + "Window should not have gained focus; value of hasWindowFocus:") .that(callOnMainSync(view::hasWindowFocus)) .isFalse(), TIMEOUT); @@ -221,7 +232,7 @@ public final class ImeStressTestUtil { public static void verifyViewNeverGainsFocus(View view) { always( () -> - assertWithMessage("view should never gain ime focus") + assertWithMessage("View should not have gained focus; value of hasFocus:") .that(callOnMainSync(view::hasFocus)) .isFalse(), TIMEOUT); @@ -254,8 +265,23 @@ public final class ImeStressTestUtil { } } + /** + * Returns {@code true} if the activity can't receive IME focus, based on its window flags, + * and {@code false} otherwise. + * + * @param activity the activity to check. + */ public static boolean hasUnfocusableWindowFlags(Activity activity) { - int windowFlags = activity.getWindow().getAttributes().flags; + return hasUnfocusableWindowFlags(activity.getWindow().getAttributes().flags); + } + + /** + * Returns {@code true} if the activity can't receive IME focus, based on its window flags, + * and {@code false} otherwise. + * + * @param windowFlags the window flags to check. + */ + public static boolean hasUnfocusableWindowFlags(int windowFlags) { return (windowFlags & LayoutParams.FLAG_NOT_FOCUSABLE) != 0 || (windowFlags & LayoutParams.FLAG_ALT_FOCUSABLE_IM) != 0 || (windowFlags & LayoutParams.FLAG_LOCAL_FOCUS_MODE) != 0; @@ -302,22 +328,26 @@ public final class ImeStressTestUtil { private final WindowInsetsAnimation.Callback mWindowInsetsAnimationCallback = new WindowInsetsAnimation.Callback(DISPATCH_MODE_STOP) { + @NonNull @Override public WindowInsetsAnimation.Bounds onStart( - WindowInsetsAnimation animation, WindowInsetsAnimation.Bounds bounds) { + @NonNull WindowInsetsAnimation animation, + @NonNull WindowInsetsAnimation.Bounds bounds) { mIsAnimating = true; return super.onStart(animation, bounds); } @Override - public void onEnd(WindowInsetsAnimation animation) { + public void onEnd(@NonNull WindowInsetsAnimation animation) { super.onEnd(animation); mIsAnimating = false; } + @NonNull @Override public WindowInsets onProgress( - WindowInsets insets, List<WindowInsetsAnimation> runningAnimations) { + @NonNull WindowInsets insets, + @NonNull List<WindowInsetsAnimation> runningAnimations) { return insets; } }; @@ -392,9 +422,9 @@ public final class ImeStressTestUtil { public boolean showImeWithInputMethodManager() { boolean showResult = getInputMethodManager() - .showSoftInput(mEditText, InputMethodManager.SHOW_IMPLICIT); + .showSoftInput(mEditText, 0 /* flags */); if (showResult) { - Log.i(TAG, "IMM#showSoftInput successfully"); + Log.i(TAG, "IMM#showSoftInput succeeded"); } else { Log.i(TAG, "IMM#showSoftInput failed"); } @@ -404,9 +434,10 @@ public final class ImeStressTestUtil { /** Hide IME with InputMethodManager. */ public boolean hideImeWithInputMethodManager() { boolean hideResult = - getInputMethodManager().hideSoftInputFromWindow(mEditText.getWindowToken(), 0); + getInputMethodManager() + .hideSoftInputFromWindow(mEditText.getWindowToken(), 0 /* flags */); if (hideResult) { - Log.i(TAG, "IMM#hideSoftInput successfully"); + Log.i(TAG, "IMM#hideSoftInput succeeded"); } else { Log.i(TAG, "IMM#hideSoftInput failed"); } @@ -420,7 +451,7 @@ public final class ImeStressTestUtil { } Log.i(TAG, "showImeWithWIC()"); WindowInsetsController windowInsetsController = mEditText.getWindowInsetsController(); - assertWithMessage("WindowInsetsController shouldn't be null.") + assertWithMessage("WindowInsetsController") .that(windowInsetsController) .isNotNull(); windowInsetsController.show(WindowInsets.Type.ime()); @@ -433,7 +464,7 @@ public final class ImeStressTestUtil { } Log.i(TAG, "hideImeWithWIC()"); WindowInsetsController windowInsetsController = mEditText.getWindowInsetsController(); - assertWithMessage("WindowInsetsController shouldn't be null.") + assertWithMessage("WindowInsetsController") .that(windowInsetsController) .isNotNull(); windowInsetsController.hide(WindowInsets.Type.ime()); @@ -481,13 +512,14 @@ public final class ImeStressTestUtil { return mIsAnimating; } - public void requestFocus() { - boolean requestFocusResult = getEditText().requestFocus(); + public boolean requestFocus() { + boolean requestFocusResult = mEditText.requestFocus(); if (requestFocusResult) { - Log.i(TAG, "Request focus successfully"); + Log.i(TAG, "View#requestFocus succeeded"); } else { - Log.i(TAG, "Request focus failed"); + Log.i(TAG, "View#requestFocus failed"); } + return requestFocusResult; } } } diff --git a/tests/Internal/src/com/android/internal/app/LocaleStoreTest.java b/tests/Internal/src/com/android/internal/app/LocaleStoreTest.java index f6568816b4f7..c0d7cb402636 100644 --- a/tests/Internal/src/com/android/internal/app/LocaleStoreTest.java +++ b/tests/Internal/src/com/android/internal/app/LocaleStoreTest.java @@ -63,6 +63,25 @@ public class LocaleStoreTest { } @Test + public void testTransformImeLanguageTagToLocaleInfo_duplicateTagFilter() { + List<InputMethodSubtype> list = List.of( + new InputMethodSubtypeBuilder().setLanguageTag("en-US").build(), + new InputMethodSubtypeBuilder().setLanguageTag("en-US").build(), + new InputMethodSubtypeBuilder().setLanguageTag("en-US").build(), + new InputMethodSubtypeBuilder().setLanguageTag("zh-TW").build(), + new InputMethodSubtypeBuilder().setLanguageTag("ja-JP").build()); + + Set<LocaleInfo> localeSet = LocaleStore.transformImeLanguageTagToLocaleInfo(list); + + Set<String> expectedLanguageTag = Set.of("en-US", "zh-TW", "ja-JP"); + assertEquals(localeSet.size(), expectedLanguageTag.size()); + for (LocaleInfo info : localeSet) { + assertEquals(info.mSuggestionFlags, LocaleInfo.SUGGESTION_TYPE_IME_LANGUAGE); + assertTrue(expectedLanguageTag.contains(info.getId())); + } + } + + @Test public void convertExplicitLocales_noExplicitLcoales_returnEmptyHashMap() { Collection<LocaleInfo> supportedLocale = getFakeSupportedLocales(); diff --git a/tests/testables/src/android/testing/TestableLooper.java b/tests/testables/src/android/testing/TestableLooper.java index edd6dd3468ef..82e40b1eee6b 100644 --- a/tests/testables/src/android/testing/TestableLooper.java +++ b/tests/testables/src/android/testing/TestableLooper.java @@ -32,6 +32,7 @@ import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; import java.lang.reflect.Field; import java.util.Map; +import java.util.concurrent.atomic.AtomicBoolean; /** * This is a wrapper around {@link TestLooperManager} to make it easier to manage @@ -55,7 +56,6 @@ public class TestableLooper { private MessageHandler mMessageHandler; private Handler mHandler; - private Runnable mEmptyMessage; private TestLooperManager mQueueWrapper; static { @@ -121,8 +121,12 @@ public class TestableLooper { * @param num Number of messages to parse */ public int processMessages(int num) { + return processMessagesInternal(num, null); + } + + private int processMessagesInternal(int num, Runnable barrierRunnable) { for (int i = 0; i < num; i++) { - if (!parseMessageInt()) { + if (!processSingleMessage(barrierRunnable)) { return i + 1; } } @@ -130,6 +134,27 @@ public class TestableLooper { } /** + * Process up to a certain number of messages, not blocking if the queue has less messages than + * that + * @param num the maximum number of messages to process + * @return the number of messages processed. This will be at most {@code num}. + */ + + public int processMessagesNonBlocking(int num) { + final AtomicBoolean reachedBarrier = new AtomicBoolean(false); + Runnable barrierRunnable = () -> { + reachedBarrier.set(true); + }; + mHandler.post(barrierRunnable); + waitForMessage(mQueueWrapper, mHandler, barrierRunnable); + try { + return processMessagesInternal(num, barrierRunnable) + (reachedBarrier.get() ? -1 : 0); + } finally { + mHandler.removeCallbacks(barrierRunnable); + } + } + + /** * Process messages in the queue until no more are found. */ public void processAllMessages() { @@ -165,19 +190,20 @@ public class TestableLooper { private int processQueuedMessages() { int count = 0; - mEmptyMessage = () -> { }; - mHandler.post(mEmptyMessage); - waitForMessage(mQueueWrapper, mHandler, mEmptyMessage); - while (parseMessageInt()) count++; + Runnable barrierRunnable = () -> { }; + mHandler.post(barrierRunnable); + waitForMessage(mQueueWrapper, mHandler, barrierRunnable); + while (processSingleMessage(barrierRunnable)) count++; return count; } - private boolean parseMessageInt() { + private boolean processSingleMessage(Runnable barrierRunnable) { try { Message result = mQueueWrapper.next(); if (result != null) { // This is a break message. - if (result.getCallback() == mEmptyMessage) { + if (result.getCallback() == barrierRunnable) { + mQueueWrapper.execute(result); mQueueWrapper.recycle(result); return false; } diff --git a/tests/testables/src/android/testing/TestableResources.java b/tests/testables/src/android/testing/TestableResources.java index 27d5b66b355e..0ec106e329f6 100644 --- a/tests/testables/src/android/testing/TestableResources.java +++ b/tests/testables/src/android/testing/TestableResources.java @@ -15,9 +15,11 @@ package android.testing; import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; import static org.mockito.Mockito.withSettings; import android.content.Context; +import android.content.res.Configuration; import android.content.res.Resources; import android.util.Log; import android.util.SparseArray; @@ -54,6 +56,16 @@ public class TestableResources { } /** + * Sets a configuration for {@link #getResources()} to return to allow custom configs to + * be set and tested. + * + * @param configuration the configuration to return from resources. + */ + public void overrideConfiguration(Configuration configuration) { + when(mResources.getConfiguration()).thenReturn(configuration); + } + + /** * Sets the return value for the specified resource id. * <p> * Since resource ids are unique there is a single addOverride that will override the value diff --git a/tests/testables/src/com/android/internal/config/sysui/TestableFlagResolver.java b/tests/testables/src/com/android/internal/config/sysui/TestableFlagResolver.java index a8815dc1f0ee..6a6ab00e33ff 100644 --- a/tests/testables/src/com/android/internal/config/sysui/TestableFlagResolver.java +++ b/tests/testables/src/com/android/internal/config/sysui/TestableFlagResolver.java @@ -27,7 +27,9 @@ public class TestableFlagResolver implements SystemUiSystemPropertiesFlags.FlagR return mOverrides.getOrDefault(flag.mSysPropKey, flag.mDefaultValue); } - public void setFlagOverride(SystemUiSystemPropertiesFlags.Flag flag, boolean isEnabled) { + public TestableFlagResolver setFlagOverride(SystemUiSystemPropertiesFlags.Flag flag, + boolean isEnabled) { mOverrides.put(flag.mSysPropKey, isEnabled); + return this; } } diff --git a/tests/testables/tests/src/android/testing/TestableLooperTest.java b/tests/testables/tests/src/android/testing/TestableLooperTest.java index 0f491b86626c..a02eb6b176dc 100644 --- a/tests/testables/tests/src/android/testing/TestableLooperTest.java +++ b/tests/testables/tests/src/android/testing/TestableLooperTest.java @@ -27,12 +27,6 @@ import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.InOrder; - import android.os.Handler; import android.os.Looper; import android.os.Message; @@ -40,6 +34,11 @@ import android.test.suitebuilder.annotation.SmallTest; import android.testing.TestableLooper.MessageHandler; import android.testing.TestableLooper.RunWithLooper; +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.InOrder; + @SmallTest @RunWith(AndroidTestingRunner.class) @RunWithLooper @@ -240,4 +239,33 @@ public class TestableLooperTest { inOrder.verify(handler).dispatchMessage(messageC); } + @Test + public void testProcessMessagesNonBlocking_onlyArgNumber() { + Handler h = new Handler(mTestableLooper.getLooper()); + Runnable r = mock(Runnable.class); + + h.post(r); + h.post(r); + h.post(r); + + int processed = mTestableLooper.processMessagesNonBlocking(2); + + verify(r, times(2)).run(); + assertEquals(2, processed); + } + + @Test + public void testProcessMessagesNonBlocking_lessMessagesThanArg() { + Handler h = new Handler(mTestableLooper.getLooper()); + Runnable r = mock(Runnable.class); + + h.post(r); + h.post(r); + h.post(r); + + int processed = mTestableLooper.processMessagesNonBlocking(5); + + verify(r, times(3)).run(); + assertEquals(3, processed); + } } |