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

Commit d89e31ba authored by Bill Lin's avatar Bill Lin
Browse files

1/ Migrate cts SplitScreenTests to wm shell flicker test

This is the initial version to achieve:
1. SplitScreenActivity in test-apps
2. Create SplitScreenTestBase and add a basic test cases to
   ensure SplitScreenActivity enter split screen mode
3. Assert StatusBar/NavBar/SplitScreenActivity showing when
   device enter split screen mode
4. Verify docked apps ending bounds

Bug: 169271943
Bug: 172811376
Test: atest WMShellFlickerTests:EnterSplitScreenTest
Change-Id: I26461b958c578dcbcc5ca2235f9d269559fd9ec5
parent 660f7cd8
Loading
Loading
Loading
Loading
+23 −3
Original line number Original line Diff line number Diff line
@@ -71,6 +71,16 @@ fun LayersAssertion.noUncoveredRegions(
    }
    }
}
}


@JvmOverloads
fun LayersAssertion.statusBarLayerIsAlwaysVisible(
    bugId: Int = 0,
    enabled: Boolean = bugId == 0
) {
    all("statusBarLayerIsAlwaysVisible", bugId, enabled) {
        this.showsLayer(FlickerTestBase.STATUS_BAR_WINDOW_TITLE)
    }
}

@JvmOverloads
@JvmOverloads
fun LayersAssertion.navBarLayerIsAlwaysVisible(
fun LayersAssertion.navBarLayerIsAlwaysVisible(
    bugId: Int = 0,
    bugId: Int = 0,
@@ -82,12 +92,22 @@ fun LayersAssertion.navBarLayerIsAlwaysVisible(
}
}


@JvmOverloads
@JvmOverloads
fun LayersAssertion.statusBarLayerIsAlwaysVisible(
fun LayersAssertion.dockedStackDividerIsVisible(
    bugId: Int = 0,
    bugId: Int = 0,
    enabled: Boolean = bugId == 0
    enabled: Boolean = bugId == 0
) {
) {
    all("statusBarLayerIsAlwaysVisible", bugId, enabled) {
    end("dockedStackDividerIsVisible", bugId, enabled) {
        this.showsLayer(FlickerTestBase.STATUS_BAR_WINDOW_TITLE)
        this.showsLayer(FlickerTestBase.DOCKED_STACK_DIVIDER)
    }
}

@JvmOverloads
fun LayersAssertion.dockedStackDividerIsInvisible(
    bugId: Int = 0,
    enabled: Boolean = bugId == 0
) {
    end("dockedStackDividerIsInvisible", bugId, enabled) {
        this.hasNotLayer(FlickerTestBase.DOCKED_STACK_DIVIDER)
    }
    }
}
}


+12 −2
Original line number Original line Diff line number Diff line
@@ -20,17 +20,27 @@ import android.content.ComponentName


const val IME_WINDOW_NAME = "InputMethod"
const val IME_WINDOW_NAME = "InputMethod"
const val PIP_WINDOW_NAME = "PipMenuActivity"
const val PIP_WINDOW_NAME = "PipMenuActivity"
const val SPLITSCREEN_PRIMARY_WINDOW_NAME = "SplitScreenActivity"
const val SPLITSCREEN_SECONDARY_WINDOW_NAME = "SplitScreenSecondaryActivity"


// Test App
const val SYSTEM_UI_PACKAGE_NAME = "com.android.systemui"
const val TEST_APP_PACKAGE_NAME = "com.android.wm.shell.flicker.testapp"
const val TEST_APP_PACKAGE_NAME = "com.android.wm.shell.flicker.testapp"

// Test App > Pip Activity
// Test App > Pip Activity
val TEST_APP_PIP_ACTIVITY_COMPONENT_NAME: ComponentName = ComponentName.createRelative(
val TEST_APP_PIP_ACTIVITY_COMPONENT_NAME: ComponentName = ComponentName.createRelative(
        TEST_APP_PACKAGE_NAME, ".PipActivity")
        TEST_APP_PACKAGE_NAME, ".PipActivity")
const val TEST_APP_PIP_ACTIVITY_LABEL = "PipApp"
const val TEST_APP_PIP_ACTIVITY_LABEL = "PipApp"
const val TEST_APP_PIP_ACTIVITY_WINDOW_NAME = "PipActivity"
const val TEST_APP_PIP_ACTIVITY_WINDOW_NAME = "PipActivity"

// Test App > Ime Activity
// Test App > Ime Activity
val TEST_APP_IME_ACTIVITY_COMPONENT_NAME: ComponentName = ComponentName.createRelative(
val TEST_APP_IME_ACTIVITY_COMPONENT_NAME: ComponentName = ComponentName.createRelative(
        TEST_APP_PACKAGE_NAME, ".ImeActivity")
        TEST_APP_PACKAGE_NAME, ".ImeActivity")
const val TEST_APP_IME_ACTIVITY_LABEL = "ImeApp"
const val TEST_APP_IME_ACTIVITY_LABEL = "ImeApp"


const val SYSTEM_UI_PACKAGE_NAME = "com.android.systemui"
// Test App > SplitScreen Activity
 No newline at end of file
val TEST_APP_SPLITSCREEN_PRIMARY_COMPONENT_NAME: ComponentName = ComponentName.createRelative(
        TEST_APP_PACKAGE_NAME, ".$SPLITSCREEN_PRIMARY_WINDOW_NAME")
val TEST_APP_SPLITSCREEN_SECONDARY_COMPONENT_NAME: ComponentName = ComponentName.createRelative(
        TEST_APP_PACKAGE_NAME, ".$SPLITSCREEN_SECONDARY_WINDOW_NAME")
const val TEST_APP_SPLITSCREEN_PRIMARY_LABEL = "SplitScreenPrimaryApp"
const val TEST_APP_SPLITSCREEN_SECONDARY_LABEL = "SplitScreenSecondaryApp"
+1 −0
Original line number Original line Diff line number Diff line
@@ -130,5 +130,6 @@ abstract class FlickerTestBase {
        const val NAVIGATION_BAR_WINDOW_TITLE = "NavigationBar"
        const val NAVIGATION_BAR_WINDOW_TITLE = "NavigationBar"
        const val STATUS_BAR_WINDOW_TITLE = "StatusBar"
        const val STATUS_BAR_WINDOW_TITLE = "StatusBar"
        const val DOCKED_STACK_DIVIDER = "DockedStackDivider"
        const val DOCKED_STACK_DIVIDER = "DockedStackDivider"
        const val IMAGE_WALLPAPER = "ImageWallpaper"
    }
    }
}
}
+6 −1
Original line number Original line Diff line number Diff line
@@ -56,6 +56,9 @@ abstract class BaseAppHelper(
            hasSystemFeature(FEATURE_LEANBACK) || hasSystemFeature(FEATURE_LEANBACK_ONLY)
            hasSystemFeature(FEATURE_LEANBACK) || hasSystemFeature(FEATURE_LEANBACK_ONLY)
        }
        }


    val defaultWindowName: String
        get() = launcherActivityComponent.className

    val label: String
    val label: String
        get() = context.packageManager.run {
        get() = context.packageManager.run {
            getApplicationLabel(getApplicationInfo(packageName, 0)).toString()
            getApplicationLabel(getApplicationInfo(packageName, 0)).toString()
@@ -74,7 +77,9 @@ abstract class BaseAppHelper(
        return uiDevice.wait(Until.gone(appSelector), APP_CLOSE_WAIT_TIME_MS)
        return uiDevice.wait(Until.gone(appSelector), APP_CLOSE_WAIT_TIME_MS)
    }
    }


    fun forceStop() = activityManager?.forceStopPackage(packageName)
    fun forceStop() {
        activityManager?.forceStopPackage(packageName)
    }


    override fun getOpenAppIntent(): Intent {
    override fun getOpenAppIntent(): Intent {
        val intent = Intent()
        val intent = Intent()
+64 −0
Original line number Original line Diff line number Diff line
/*
 * 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.wm.shell.flicker.helpers

import android.app.Instrumentation
import android.content.ComponentName
import android.graphics.Region
import android.os.SystemClock
import com.android.server.wm.flicker.helpers.WindowUtils

class SplitScreenHelper(
    instrumentation: Instrumentation,
    activityLabel: String,
    componentName: ComponentName
) : BaseAppHelper(
        instrumentation,
        activityLabel,
        componentName
) {

    /**
     * Reopens the first device window from the list of recent apps (overview)
     */
    fun reopenAppFromOverview() {
        val x = uiDevice.displayWidth / 2
        val y = uiDevice.displayHeight / 2
        uiDevice.click(x, y)
        // Wait for animation to complete.
        SystemClock.sleep(TIMEOUT_MS)
    }

    fun getPrimaryBounds(dividerBounds: Region): android.graphics.Region {
        val primaryAppBounds = Region(0, 0, dividerBounds.bounds.right,
                dividerBounds.bounds.bottom + WindowUtils.dockedStackDividerInset)
        return primaryAppBounds
    }

    fun getSecondaryBounds(dividerBounds: Region): android.graphics.Region {
        val displayBounds = WindowUtils.displayBounds
        val secondaryAppBounds = Region(0,
                dividerBounds.bounds.bottom - WindowUtils.dockedStackDividerInset,
                displayBounds.right, displayBounds.bottom - WindowUtils.navigationBarHeight)
        return secondaryAppBounds
    }

    companion object {
        const val TEST_REPETITIONS = 1
        const val TIMEOUT_MS = 3_000L
    }
}
Loading