Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 16bd6102 authored by Wei Sheng Shih's avatar Wei Sheng Shih Committed by Android (Google) Code Review
Browse files

Merge "Add flicker test for transfer splash screen window to client." into main

parents 3881bede a4977809
Loading
Loading
Loading
Loading
+32 −0
Original line number Diff line number Diff line
/*
 * 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.helpers

import android.app.Instrumentation
import android.tools.common.traces.component.ComponentNameMatcher
import android.tools.device.apphelpers.StandardAppHelper
import android.tools.device.traces.parsers.toFlickerComponent
import com.android.server.wm.flicker.testapp.ActivityOptions

class TransferSplashscreenAppHelper
@JvmOverloads
constructor(
    instr: Instrumentation,
    launcherName: String = ActivityOptions.TransferSplashscreenActivity.LABEL,
    component: ComponentNameMatcher =
        ActivityOptions.TransferSplashscreenActivity.COMPONENT.toFlickerComponent()
) : StandardAppHelper(instr, launcherName, component)
 No newline at end of file
+3 −1
Original line number Diff line number Diff line
@@ -53,7 +53,8 @@ import org.junit.runners.Parameterized
@RunWith(Parameterized::class)
@Parameterized.UseParametersRunnerFactory(FlickerParametersRunnerFactory::class)
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
class OpenAppFromIconColdTest(flicker: LegacyFlickerTest) : OpenAppFromLauncherTransition(flicker) {
open class OpenAppFromIconColdTest(flicker: LegacyFlickerTest) :
        OpenAppFromLauncherTransition(flicker) {
    /** {@inheritDoc} */
    override val transition: FlickerBuilder.() -> Unit
        get() = {
@@ -87,6 +88,7 @@ class OpenAppFromIconColdTest(flicker: LegacyFlickerTest) : OpenAppFromLauncherT
    override fun appWindowReplacesLauncherAsTopWindow() {
        super.appWindowReplacesLauncherAsTopWindow()
    }

    @FlakyTest(bugId = 240916028)
    @Test
    override fun appWindowAsTopWindowAtEnd() {
+88 −0
Original line number Diff line number Diff line
/*
 * 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.launch

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.LegacyFlickerTest
import android.tools.device.flicker.legacy.LegacyFlickerTestFactory
import androidx.test.filters.RequiresDevice
import com.android.server.wm.flicker.helpers.TransferSplashscreenAppHelper
import org.junit.FixMethodOrder
import org.junit.Test
import org.junit.runner.RunWith
import org.junit.runners.MethodSorters
import org.junit.runners.Parameterized

/**
 * Test cold launching an app from launcher
 *
 * To run this test: `atest FlickerTests:OpenTransferSplashscreenAppFromLauncherTransition`
 *
 * Actions:
 * ```
 *     Inherit from OpenAppFromIconColdTest, Launch an app [testApp] with an animated splash screen
 *     by clicking it's icon on all apps, and wait for transfer splash screen complete
 * ```
 *
 * Notes:
 * ```
 *     1. Some default assertions (e.g., nav bar, status bar and screen covered)
 *        are inherited [OpenAppTransition]
 *     2. Verify no flickering when transfer splash screen to app window.
 * ```
 */

@RequiresDevice
@RunWith(Parameterized::class)
@Parameterized.UseParametersRunnerFactory(FlickerParametersRunnerFactory::class)
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
class OpenTransferSplashscreenAppFromLauncherTransition(flicker: LegacyFlickerTest) :
        OpenAppFromIconColdTest(flicker) {
    override val testApp = TransferSplashscreenAppHelper(instrumentation)

    /**
     * Checks that [ComponentNameMatcher.LAUNCHER] window is the top window at the start of the
     * transition, and is replaced by [ComponentNameMatcher.SPLASH_SCREEN], then [testApp] remains
     * visible until the end
     */
    @Presubmit
    @Test
    fun appWindowAfterSplash() {
        flicker.assertWm {
            this.isAppWindowOnTop(ComponentNameMatcher.LAUNCHER)
                    .then()
                    .isAppWindowOnTop(ComponentNameMatcher.SPLASH_SCREEN)
                    .then()
                    .isAppWindowOnTop(testApp)
                    .isAppWindowInvisible(ComponentNameMatcher.SPLASH_SCREEN)
        }
    }

    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()
    }
}
 No newline at end of file
+3 −0
Original line number Diff line number Diff line
@@ -24,6 +24,9 @@ package {
android_test {
    name: "FlickerTestApp",
    srcs: ["**/*.java"],
    resource_dirs: [
        "res",
    ],
    sdk_version: "current",
    test_suites: ["device-tests"],
    static_libs: [
+11 −0
Original line number Diff line number Diff line
@@ -347,6 +347,17 @@
            android:exported="false"
            android:theme="@style/CutoutShortEdges"
            android:resizeableActivity="true"/>
        <activity
            android:name=".TransferSplashscreenActivity"
            android:taskAffinity="com.android.server.wm.flicker.testapp.TransferSplashscreenActivity"
            android:label="TransferSplashscreenActivity"
            android:theme="@style/SplashscreenAppTheme"
            android:exported="true">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER"/>
            </intent-filter>
        </activity>
        <service
            android:name=".AssistantInteractionSessionService"
            android:exported="true"
Loading