Merge "Add CUJ for dragging taskbar icon to split" into tm-qpr-dev

This commit is contained in:
TreeHugger Robot
2022-06-30 05:28:08 +00:00
committed by Android (Google) Code Review
2 changed files with 149 additions and 0 deletions

View File

@@ -25,11 +25,13 @@ import androidx.test.uiautomator.By
import androidx.test.uiautomator.BySelector import androidx.test.uiautomator.BySelector
import androidx.test.uiautomator.UiDevice import androidx.test.uiautomator.UiDevice
import androidx.test.uiautomator.Until import androidx.test.uiautomator.Until
import com.android.launcher3.tapl.LauncherInstrumentation
import com.android.server.wm.traces.common.FlickerComponentName import com.android.server.wm.traces.common.FlickerComponentName
import com.android.server.wm.traces.parser.toFlickerComponent import com.android.server.wm.traces.parser.toFlickerComponent
import com.android.server.wm.traces.parser.windowmanager.WindowManagerStateHelper import com.android.server.wm.traces.parser.windowmanager.WindowManagerStateHelper
import com.android.wm.shell.flicker.SYSTEM_UI_PACKAGE_NAME import com.android.wm.shell.flicker.SYSTEM_UI_PACKAGE_NAME
import com.android.wm.shell.flicker.testapp.Components import com.android.wm.shell.flicker.testapp.Components
import org.junit.Assert
class SplitScreenHelper( class SplitScreenHelper(
instrumentation: Instrumentation, instrumentation: Instrumentation,
@@ -187,5 +189,23 @@ class SplitScreenHelper(
SystemClock.sleep(GESTURE_STEP_MS) SystemClock.sleep(GESTURE_STEP_MS)
} }
} }
fun createShortcutOnHotseatIfNotExist(
taplInstrumentation: LauncherInstrumentation,
appName: String
) {
taplInstrumentation.workspace
.deleteAppIcon(taplInstrumentation.workspace.getHotseatAppIcon(0))
val allApps = taplInstrumentation.workspace.switchToAllApps()
allApps.freeze()
try {
val appIconSrc = allApps.getAppIcon(appName)
Assert.assertNotNull("Unable to find app icon", appIconSrc)
val appIconDest = appIconSrc.dragToHotseat(0)
Assert.assertNotNull("Unable to drag app icon on hotseat", appIconDest)
} finally {
allApps.unfreeze()
}
}
} }
} }

View File

@@ -0,0 +1,129 @@
/*
* Copyright (C) 2022 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.splitscreen
import android.platform.test.annotations.Presubmit
import android.view.WindowManagerPolicyConstants
import androidx.test.filters.RequiresDevice
import com.android.server.wm.flicker.FlickerParametersRunnerFactory
import com.android.server.wm.flicker.FlickerTestParameter
import com.android.server.wm.flicker.FlickerTestParameterFactory
import com.android.server.wm.flicker.annotation.Group1
import com.android.server.wm.flicker.dsl.FlickerBuilder
import com.android.wm.shell.flicker.appWindowBecomesVisible
import com.android.wm.shell.flicker.appWindowIsVisibleAtEnd
import com.android.wm.shell.flicker.helpers.SplitScreenHelper
import com.android.wm.shell.flicker.layerBecomesVisible
import com.android.wm.shell.flicker.layerIsVisibleAtEnd
import com.android.wm.shell.flicker.splitAppLayerBoundsBecomesVisible
import com.android.wm.shell.flicker.splitAppLayerBoundsIsVisibleAtEnd
import com.android.wm.shell.flicker.splitScreenDividerBecomesVisible
import org.junit.Assume
import org.junit.Before
import org.junit.FixMethodOrder
import org.junit.Test
import org.junit.runner.RunWith
import org.junit.runners.MethodSorters
import org.junit.runners.Parameterized
/**
* Test enter split screen by dragging app icon from taskbar.
* This test is only for large screen devices.
*
* To run this test: `atest WMShellFlickerTests:EnterSplitScreenByDragFromTaskbar`
*/
@RequiresDevice
@RunWith(Parameterized::class)
@Parameterized.UseParametersRunnerFactory(FlickerParametersRunnerFactory::class)
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
@Group1
class EnterSplitScreenByDragFromTaskbar(
testSpec: FlickerTestParameter
) : SplitScreenBase(testSpec) {
@Before
fun before() {
Assume.assumeTrue(taplInstrumentation.isTablet)
}
override val transition: FlickerBuilder.() -> Unit
get() = {
super.transition(this)
setup {
eachRun {
taplInstrumentation.goHome()
SplitScreenHelper.createShortcutOnHotseatIfNotExist(
taplInstrumentation, secondaryApp.appName
)
primaryApp.launchViaIntent(wmHelper)
}
}
transitions {
taplInstrumentation.launchedAppState.taskbar
.getAppIcon(secondaryApp.appName)
.dragToSplitscreen(
secondaryApp.component.packageName,
primaryApp.component.packageName
)
}
}
@Presubmit
@Test
fun dividerBecomesVisible() = testSpec.splitScreenDividerBecomesVisible()
@Presubmit
@Test
fun primaryAppLayerIsVisibleAtEnd() = testSpec.layerIsVisibleAtEnd(primaryApp.component)
@Presubmit
@Test
fun secondaryAppLayerBecomesVisible() = testSpec.layerBecomesVisible(secondaryApp.component)
@Presubmit
@Test
fun primaryAppBoundsIsVisibleAtEnd() = testSpec.splitAppLayerBoundsIsVisibleAtEnd(
testSpec.endRotation, primaryApp.component, false /* splitLeftTop */
)
@Presubmit
@Test
fun secondaryAppBoundsBecomesVisible() = testSpec.splitAppLayerBoundsBecomesVisible(
testSpec.endRotation, secondaryApp.component, true /* splitLeftTop */
)
@Presubmit
@Test
fun primaryAppWindowIsVisibleAtEnd() = testSpec.appWindowIsVisibleAtEnd(primaryApp.component)
@Presubmit
@Test
fun secondaryAppWindowBecomesVisible() =
testSpec.appWindowBecomesVisible(secondaryApp.component)
companion object {
@Parameterized.Parameters(name = "{0}")
@JvmStatic
fun getParams(): List<FlickerTestParameter> {
return FlickerTestParameterFactory.getInstance().getConfigNonRotationTests(
repetitions = SplitScreenHelper.TEST_REPETITIONS,
supportedNavigationModes =
listOf(WindowManagerPolicyConstants.NAV_BAR_MODE_GESTURAL_OVERLAY)
)
}
}
}