Merge "Add assertions for layers become visible" into tm-qpr-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
e4d77e2522
@@ -44,10 +44,58 @@ fun FlickerTestParameter.appPairsDividerBecomesVisible() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun FlickerTestParameter.splitScreenDividerBecomesVisible() {
|
fun FlickerTestParameter.splitScreenDividerBecomesVisible() {
|
||||||
|
layerBecomesVisible(SPLIT_SCREEN_DIVIDER_COMPONENT)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun FlickerTestParameter.layerBecomesVisible(
|
||||||
|
component: FlickerComponentName
|
||||||
|
) {
|
||||||
assertLayers {
|
assertLayers {
|
||||||
this.isInvisible(SPLIT_SCREEN_DIVIDER_COMPONENT)
|
this.isInvisible(component)
|
||||||
.then()
|
.then()
|
||||||
.isVisible(SPLIT_SCREEN_DIVIDER_COMPONENT)
|
.isVisible(component)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun FlickerTestParameter.layerIsVisibleAtEnd(
|
||||||
|
component: FlickerComponentName
|
||||||
|
) {
|
||||||
|
assertLayersEnd {
|
||||||
|
this.isVisible(component)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun FlickerTestParameter.splitAppLayerBoundsBecomesVisible(
|
||||||
|
rotation: Int,
|
||||||
|
component: FlickerComponentName,
|
||||||
|
splitLeftTop: Boolean
|
||||||
|
) {
|
||||||
|
assertLayers {
|
||||||
|
this.isInvisible(component)
|
||||||
|
.then()
|
||||||
|
.invoke("splitAppLayerBoundsBecomesVisible") {
|
||||||
|
val dividerRegion = it.layer(SPLIT_SCREEN_DIVIDER_COMPONENT).visibleRegion.region
|
||||||
|
it.visibleRegion(component).overlaps(if (splitLeftTop) {
|
||||||
|
getSplitLeftTopRegion(dividerRegion, rotation)
|
||||||
|
} else {
|
||||||
|
getSplitRightBottomRegion(dividerRegion, rotation)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun FlickerTestParameter.splitAppLayerBoundsIsVisibleAtEnd(
|
||||||
|
rotation: Int,
|
||||||
|
component: FlickerComponentName,
|
||||||
|
splitLeftTop: Boolean
|
||||||
|
) {
|
||||||
|
assertLayersEnd {
|
||||||
|
val dividerRegion = layer(SPLIT_SCREEN_DIVIDER_COMPONENT).visibleRegion.region
|
||||||
|
visibleRegion(component).overlaps(if (splitLeftTop) {
|
||||||
|
getSplitLeftTopRegion(dividerRegion, rotation)
|
||||||
|
} else {
|
||||||
|
getSplitRightBottomRegion(dividerRegion, rotation)
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -161,4 +209,24 @@ fun getSecondaryRegion(dividerRegion: Region, rotation: Int): Region {
|
|||||||
Region.from(dividerRegion.bounds.right - WindowUtils.dockedStackDividerInset, 0,
|
Region.from(dividerRegion.bounds.right - WindowUtils.dockedStackDividerInset, 0,
|
||||||
displayBounds.bounds.right, displayBounds.bounds.bottom)
|
displayBounds.bounds.right, displayBounds.bounds.bottom)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun getSplitLeftTopRegion(dividerRegion: Region, rotation: Int): Region {
|
||||||
|
val displayBounds = WindowUtils.getDisplayBounds(rotation)
|
||||||
|
return if (displayBounds.width > displayBounds.height) {
|
||||||
|
Region.from(0, 0, dividerRegion.bounds.left, displayBounds.bounds.bottom)
|
||||||
|
} else {
|
||||||
|
Region.from(0, 0, displayBounds.bounds.right, dividerRegion.bounds.top)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun getSplitRightBottomRegion(dividerRegion: Region, rotation: Int): Region {
|
||||||
|
val displayBounds = WindowUtils.getDisplayBounds(rotation)
|
||||||
|
return if (displayBounds.width > displayBounds.height) {
|
||||||
|
Region.from(dividerRegion.bounds.right, 0, displayBounds.bounds.right,
|
||||||
|
displayBounds.bounds.bottom)
|
||||||
|
} else {
|
||||||
|
Region.from(0, dividerRegion.bounds.bottom, displayBounds.bounds.right,
|
||||||
|
displayBounds.bounds.bottom)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -24,10 +24,15 @@ import com.android.server.wm.flicker.FlickerTestParameter
|
|||||||
import com.android.server.wm.flicker.FlickerTestParameterFactory
|
import com.android.server.wm.flicker.FlickerTestParameterFactory
|
||||||
import com.android.server.wm.flicker.annotation.Group1
|
import com.android.server.wm.flicker.annotation.Group1
|
||||||
import com.android.server.wm.flicker.dsl.FlickerBuilder
|
import com.android.server.wm.flicker.dsl.FlickerBuilder
|
||||||
|
import com.android.server.wm.traces.common.Rect
|
||||||
|
import com.android.wm.shell.flicker.layerBecomesVisible
|
||||||
|
import com.android.wm.shell.flicker.layerIsVisibleAtEnd
|
||||||
import com.android.wm.shell.flicker.appWindowBecomesVisible
|
import com.android.wm.shell.flicker.appWindowBecomesVisible
|
||||||
import com.android.wm.shell.flicker.appWindowIsVisibleAtEnd
|
import com.android.wm.shell.flicker.appWindowIsVisibleAtEnd
|
||||||
import com.android.wm.shell.flicker.helpers.SplitScreenHelper
|
import com.android.wm.shell.flicker.helpers.SplitScreenHelper
|
||||||
import com.android.wm.shell.flicker.splitScreenDividerBecomesVisible
|
import com.android.wm.shell.flicker.splitScreenDividerBecomesVisible
|
||||||
|
import com.android.wm.shell.flicker.splitAppLayerBoundsBecomesVisible
|
||||||
|
import com.android.wm.shell.flicker.splitAppLayerBoundsIsVisibleAtEnd
|
||||||
import org.junit.Assume
|
import org.junit.Assume
|
||||||
import org.junit.Before
|
import org.junit.Before
|
||||||
import org.junit.FixMethodOrder
|
import org.junit.FixMethodOrder
|
||||||
@@ -71,6 +76,11 @@ class EnterSplitScreenByDragFromAllApps(
|
|||||||
.getAppIcon(secondaryApp.appName)
|
.getAppIcon(secondaryApp.appName)
|
||||||
.dragToSplitscreen(secondaryApp.component.packageName,
|
.dragToSplitscreen(secondaryApp.component.packageName,
|
||||||
primaryApp.component.packageName)
|
primaryApp.component.packageName)
|
||||||
|
|
||||||
|
endDisplayBounds = wmHelper.currentState.layerState
|
||||||
|
.displays.firstOrNull { !it.isVirtual }
|
||||||
|
?.layerStackSpace
|
||||||
|
?: error("Display not found")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -78,6 +88,24 @@ class EnterSplitScreenByDragFromAllApps(
|
|||||||
@Test
|
@Test
|
||||||
fun dividerBecomesVisible() = testSpec.splitScreenDividerBecomesVisible()
|
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, isAppLeftTop(true))
|
||||||
|
|
||||||
|
@Presubmit
|
||||||
|
@Test
|
||||||
|
fun secondaryAppBoundsBecomesVisible() = testSpec.splitAppLayerBoundsBecomesVisible(
|
||||||
|
testSpec.endRotation, secondaryApp.component, isAppLeftTop(false))
|
||||||
|
|
||||||
@Presubmit
|
@Presubmit
|
||||||
@Test
|
@Test
|
||||||
fun primaryAppWindowIsVisibleAtEnd() = testSpec.appWindowIsVisibleAtEnd(primaryApp.component)
|
fun primaryAppWindowIsVisibleAtEnd() = testSpec.appWindowIsVisibleAtEnd(primaryApp.component)
|
||||||
@@ -87,6 +115,14 @@ class EnterSplitScreenByDragFromAllApps(
|
|||||||
fun secondaryAppWindowBecomesVisible() =
|
fun secondaryAppWindowBecomesVisible() =
|
||||||
testSpec.appWindowBecomesVisible(secondaryApp.component)
|
testSpec.appWindowBecomesVisible(secondaryApp.component)
|
||||||
|
|
||||||
|
private fun isAppLeftTop(primary: Boolean): Boolean {
|
||||||
|
return if (endDisplayBounds.width > endDisplayBounds.height) {
|
||||||
|
!primary
|
||||||
|
} else {
|
||||||
|
primary
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
@Parameterized.Parameters(name = "{0}")
|
@Parameterized.Parameters(name = "{0}")
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
@@ -97,5 +133,7 @@ class EnterSplitScreenByDragFromAllApps(
|
|||||||
supportedNavigationModes =
|
supportedNavigationModes =
|
||||||
listOf(WindowManagerPolicyConstants.NAV_BAR_MODE_GESTURAL_OVERLAY))
|
listOf(WindowManagerPolicyConstants.NAV_BAR_MODE_GESTURAL_OVERLAY))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private lateinit var endDisplayBounds: Rect
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user