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

Commit ed556951 authored by Mateusz Cicheński's avatar Mateusz Cicheński
Browse files

Add YouTube flicker test base

Test: atest YouTubeEnterPipTest
Bug: 282758103

Change-Id: I828a8b6b9374e3bf240e17a4827cf5aa181ccdee
parent 6f37abf3
Loading
Loading
Loading
Loading
+78 −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.wm.shell.flicker.pip.apps

import android.tools.common.traces.component.ComponentNameMatcher
import android.tools.device.apphelpers.YouTubeAppHelper
import android.tools.device.flicker.junit.FlickerParametersRunnerFactory
import android.tools.device.flicker.legacy.FlickerBuilder
import android.tools.device.flicker.legacy.LegacyFlickerTest
import androidx.test.filters.RequiresDevice
import org.junit.FixMethodOrder
import org.junit.runner.RunWith
import org.junit.runners.MethodSorters
import org.junit.runners.Parameterized

/**
 * Test entering pip from YouTube app by interacting with the app UI
 *
 * To run this test: `atest WMShellFlickerTests:YouTubeEnterPipTest`
 *
 * Actions:
 * ```
 *     Launch YouTube and start playing a video
 *     Go home to enter PiP
 * ```
 *
 * Notes:
 * ```
 *     1. Some default assertions (e.g., nav bar, status bar and screen covered)
 *        are inherited from [PipTransition]
 *     2. Part of the test setup occurs automatically via
 *        [android.tools.device.flicker.legacy.runner.TransitionRunner],
 *        including configuring navigation mode, initial orientation and ensuring no
 *        apps are running before setup
 * ```
 */
@RequiresDevice
@RunWith(Parameterized::class)
@Parameterized.UseParametersRunnerFactory(FlickerParametersRunnerFactory::class)
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
open class YouTubeEnterPipTest(flicker: LegacyFlickerTest) : AppsEnterPipTransition(flicker) {
    override val standardAppHelper: YouTubeAppHelper = YouTubeAppHelper(instrumentation)

    override val defaultEnterPip: FlickerBuilder.() -> Unit = {
        setup {
            standardAppHelper.launchViaIntent(
                wmHelper,
                YouTubeAppHelper.getYoutubeVideoIntent("HPcEAtoXXLA"),
                ComponentNameMatcher(YouTubeAppHelper.PACKAGE_NAME, "")
            )
            standardAppHelper.waitForVideoPlaying()
        }
    }

    override val defaultTeardown: FlickerBuilder.() -> Unit = {
        teardown {
            standardAppHelper.exit(wmHelper)
        }
    }

    override val thisTransition: FlickerBuilder.() -> Unit = {
        transitions { tapl.goHome() }
    }
}