Loading tests/FlickerTests/Android.bp +14 −0 Original line number Diff line number Diff line Loading @@ -55,3 +55,17 @@ android_test { "platform-test-annotations", ], } java_library { name: "wm-flicker-common-assertions", platform_apis: true, srcs: ["src/**/*Assertions.java", "src/**/*Assertions.kt"], exclude_srcs: [ "**/helpers/*", ], static_libs: [ "flickerlib", "truth-prebuilt", "app-helpers-core" ], } No newline at end of file tests/FlickerTests/src/com/android/server/wm/flicker/CommonAssertions.kt +13 −9 Original line number Diff line number Diff line Loading @@ -21,13 +21,17 @@ import com.android.server.wm.flicker.dsl.LayersAssertion import com.android.server.wm.flicker.dsl.WmAssertion import com.android.server.wm.flicker.helpers.WindowUtils const val NAVIGATION_BAR_WINDOW_TITLE = "NavigationBar" const val STATUS_BAR_WINDOW_TITLE = "StatusBar" const val DOCKED_STACK_DIVIDER = "DockedStackDivider" @JvmOverloads fun WmAssertion.statusBarWindowIsAlwaysVisible( bugId: Int = 0, enabled: Boolean = bugId == 0 ) { all("statusBarWindowIsAlwaysVisible", enabled, bugId) { this.showsAboveAppWindow(FlickerTestBase.STATUS_BAR_WINDOW_TITLE) this.showsAboveAppWindow(STATUS_BAR_WINDOW_TITLE) } } Loading @@ -37,7 +41,7 @@ fun WmAssertion.navBarWindowIsAlwaysVisible( enabled: Boolean = bugId == 0 ) { all("navBarWindowIsAlwaysVisible", enabled, bugId) { this.showsAboveAppWindow(FlickerTestBase.NAVIGATION_BAR_WINDOW_TITLE) this.showsAboveAppWindow(NAVIGATION_BAR_WINDOW_TITLE) } } Loading Loading @@ -77,7 +81,7 @@ fun LayersAssertion.navBarLayerIsAlwaysVisible( enabled: Boolean = bugId == 0 ) { all("navBarLayerIsAlwaysVisible", enabled, bugId) { this.showsLayer(FlickerTestBase.NAVIGATION_BAR_WINDOW_TITLE) this.showsLayer(NAVIGATION_BAR_WINDOW_TITLE) } } Loading @@ -87,7 +91,7 @@ fun LayersAssertion.statusBarLayerIsAlwaysVisible( enabled: Boolean = bugId == 0 ) { all("statusBarLayerIsAlwaysVisible", enabled, bugId) { this.showsLayer(FlickerTestBase.STATUS_BAR_WINDOW_TITLE) this.showsLayer(STATUS_BAR_WINDOW_TITLE) } } Loading @@ -102,15 +106,15 @@ fun LayersAssertion.navBarLayerRotatesAndScales( val endingPos = WindowUtils.getNavigationBarPosition(endRotation) start("navBarLayerRotatesAndScales_StartingPos", enabled, bugId) { this.hasVisibleRegion(FlickerTestBase.NAVIGATION_BAR_WINDOW_TITLE, startingPos) this.hasVisibleRegion(NAVIGATION_BAR_WINDOW_TITLE, startingPos) } end("navBarLayerRotatesAndScales_EndingPost", enabled, bugId) { this.hasVisibleRegion(FlickerTestBase.NAVIGATION_BAR_WINDOW_TITLE, endingPos) this.hasVisibleRegion(NAVIGATION_BAR_WINDOW_TITLE, endingPos) } if (startingPos == endingPos) { all("navBarLayerRotatesAndScales", enabled = false, bugId = 167747321) { this.hasVisibleRegion(FlickerTestBase.NAVIGATION_BAR_WINDOW_TITLE, startingPos) this.hasVisibleRegion(NAVIGATION_BAR_WINDOW_TITLE, startingPos) } } } Loading @@ -126,10 +130,10 @@ fun LayersAssertion.statusBarLayerRotatesScales( val endingPos = WindowUtils.getStatusBarPosition(endRotation) start("statusBarLayerRotatesScales_StartingPos", enabled, bugId) { this.hasVisibleRegion(FlickerTestBase.STATUS_BAR_WINDOW_TITLE, startingPos) this.hasVisibleRegion(STATUS_BAR_WINDOW_TITLE, startingPos) } end("statusBarLayerRotatesScales_EndingPos", enabled, bugId) { this.hasVisibleRegion(FlickerTestBase.STATUS_BAR_WINDOW_TITLE, endingPos) this.hasVisibleRegion(STATUS_BAR_WINDOW_TITLE, endingPos) } } Loading tests/FlickerTests/src/com/android/server/wm/flicker/FlickerTestBase.ktdeleted 100644 → 0 +0 −129 Original line number 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.server.wm.flicker import android.os.RemoteException import android.os.SystemClock import android.platform.helpers.IAppHelper import android.view.Surface import androidx.test.platform.app.InstrumentationRegistry import androidx.test.uiautomator.UiDevice /** * Base class of all Flicker test that performs common functions for all flicker tests: * * * - Caches transitions so that a transition is run once and the transition results are used by * tests multiple times. This is needed for parameterized tests which call the BeforeClass methods * multiple times. * - Keeps track of all test artifacts and deletes ones which do not need to be reviewed. * - Fails tests if results are not available for any test due to jank. */ abstract class FlickerTestBase { val instrumentation by lazy { InstrumentationRegistry.getInstrumentation() } val uiDevice by lazy { UiDevice.getInstance(instrumentation) } /** * Build a test tag for the test * @param testName Name of the transition(s) being tested * @param app App being launcher * @param rotation Initial screen rotation * * @return test tag with pattern <NAME>__<APP>__<ROTATION> </ROTATION></APP></NAME> */ protected fun buildTestTag(testName: String, app: IAppHelper, rotation: Int): String { return buildTestTag( testName, app, rotation, rotation, app2 = null, extraInfo = "") } /** * Build a test tag for the test * @param testName Name of the transition(s) being tested * @param app App being launcher * @param beginRotation Initial screen rotation * @param endRotation End screen rotation (if any, otherwise use same as initial) * * @return test tag with pattern <NAME>__<APP>__<BEGIN_ROTATION>-<END_ROTATION> </END_ROTATION></BEGIN_ROTATION></APP></NAME> */ protected fun buildTestTag( testName: String, app: IAppHelper, beginRotation: Int, endRotation: Int ): String { return buildTestTag( testName, app, beginRotation, endRotation, app2 = null, extraInfo = "") } /** * Build a test tag for the test * @param testName Name of the transition(s) being tested * @param app App being launcher * @param app2 Second app being launched (if any) * @param beginRotation Initial screen rotation * @param endRotation End screen rotation (if any, otherwise use same as initial) * @param extraInfo Additional information to append to the tag * * @return test tag with pattern <NAME>__<APP></APP>(S)>__<ROTATION></ROTATION>(S)>[__<EXTRA>] </EXTRA></NAME> */ protected fun buildTestTag( testName: String, app: IAppHelper, beginRotation: Int, endRotation: Int, app2: IAppHelper?, extraInfo: String ): String { var testTag = "${testName}__${app.launcherName}" if (app2 != null) { testTag += "-${app2.launcherName}" } testTag += "__${Surface.rotationToString(beginRotation)}" if (endRotation != beginRotation) { testTag += "-${Surface.rotationToString(endRotation)}" } if (extraInfo.isNotEmpty()) { testTag += "__$extraInfo" } return testTag } protected fun Flicker.setRotation(rotation: Int) { try { when (rotation) { Surface.ROTATION_270 -> device.setOrientationLeft() Surface.ROTATION_90 -> device.setOrientationRight() Surface.ROTATION_0 -> device.setOrientationNatural() else -> device.setOrientationNatural() } // Wait for animation to complete SystemClock.sleep(1000) } catch (e: RemoteException) { throw RuntimeException(e) } } companion object { const val NAVIGATION_BAR_WINDOW_TITLE = "NavigationBar" const val STATUS_BAR_WINDOW_TITLE = "StatusBar" const val DOCKED_STACK_DIVIDER = "DockedStackDivider" } } No newline at end of file tests/FlickerTests/src/com/android/server/wm/flicker/NonRotationTestBase.ktdeleted 100644 → 0 +0 −36 Original line number 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.server.wm.flicker import android.view.Surface import org.junit.runners.Parameterized abstract class NonRotationTestBase( protected val rotationName: String, protected val rotation: Int ) : FlickerTestBase() { companion object { const val SCREENSHOT_LAYER = "RotationLayer" @Parameterized.Parameters(name = "{0}") @JvmStatic fun getParams(): Collection<Array<Any>> { val supportedRotations = intArrayOf(Surface.ROTATION_0, Surface.ROTATION_90) return supportedRotations.map { arrayOf(Surface.rotationToString(it), it) } } } } No newline at end of file tests/FlickerTests/src/com/android/server/wm/flicker/RotationTestBase.ktdeleted 100644 → 0 +0 −49 Original line number 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.server.wm.flicker import android.view.Surface import org.junit.runners.Parameterized abstract class RotationTestBase( beginRotationName: String, endRotationName: String, protected val beginRotation: Int, protected val endRotation: Int ) : FlickerTestBase() { companion object { @Parameterized.Parameters(name = "{0}-{1}") @JvmStatic fun getParams(): Collection<Array<Any>> { val supportedRotations = intArrayOf(Surface.ROTATION_0, Surface.ROTATION_90) val params: MutableCollection<Array<Any>> = mutableListOf() for (begin in supportedRotations) { for (end in supportedRotations) { if (begin != end) { params.add(arrayOf( Surface.rotationToString(begin), Surface.rotationToString(end), begin, end )) } } } return params } } } No newline at end of file Loading
tests/FlickerTests/Android.bp +14 −0 Original line number Diff line number Diff line Loading @@ -55,3 +55,17 @@ android_test { "platform-test-annotations", ], } java_library { name: "wm-flicker-common-assertions", platform_apis: true, srcs: ["src/**/*Assertions.java", "src/**/*Assertions.kt"], exclude_srcs: [ "**/helpers/*", ], static_libs: [ "flickerlib", "truth-prebuilt", "app-helpers-core" ], } No newline at end of file
tests/FlickerTests/src/com/android/server/wm/flicker/CommonAssertions.kt +13 −9 Original line number Diff line number Diff line Loading @@ -21,13 +21,17 @@ import com.android.server.wm.flicker.dsl.LayersAssertion import com.android.server.wm.flicker.dsl.WmAssertion import com.android.server.wm.flicker.helpers.WindowUtils const val NAVIGATION_BAR_WINDOW_TITLE = "NavigationBar" const val STATUS_BAR_WINDOW_TITLE = "StatusBar" const val DOCKED_STACK_DIVIDER = "DockedStackDivider" @JvmOverloads fun WmAssertion.statusBarWindowIsAlwaysVisible( bugId: Int = 0, enabled: Boolean = bugId == 0 ) { all("statusBarWindowIsAlwaysVisible", enabled, bugId) { this.showsAboveAppWindow(FlickerTestBase.STATUS_BAR_WINDOW_TITLE) this.showsAboveAppWindow(STATUS_BAR_WINDOW_TITLE) } } Loading @@ -37,7 +41,7 @@ fun WmAssertion.navBarWindowIsAlwaysVisible( enabled: Boolean = bugId == 0 ) { all("navBarWindowIsAlwaysVisible", enabled, bugId) { this.showsAboveAppWindow(FlickerTestBase.NAVIGATION_BAR_WINDOW_TITLE) this.showsAboveAppWindow(NAVIGATION_BAR_WINDOW_TITLE) } } Loading Loading @@ -77,7 +81,7 @@ fun LayersAssertion.navBarLayerIsAlwaysVisible( enabled: Boolean = bugId == 0 ) { all("navBarLayerIsAlwaysVisible", enabled, bugId) { this.showsLayer(FlickerTestBase.NAVIGATION_BAR_WINDOW_TITLE) this.showsLayer(NAVIGATION_BAR_WINDOW_TITLE) } } Loading @@ -87,7 +91,7 @@ fun LayersAssertion.statusBarLayerIsAlwaysVisible( enabled: Boolean = bugId == 0 ) { all("statusBarLayerIsAlwaysVisible", enabled, bugId) { this.showsLayer(FlickerTestBase.STATUS_BAR_WINDOW_TITLE) this.showsLayer(STATUS_BAR_WINDOW_TITLE) } } Loading @@ -102,15 +106,15 @@ fun LayersAssertion.navBarLayerRotatesAndScales( val endingPos = WindowUtils.getNavigationBarPosition(endRotation) start("navBarLayerRotatesAndScales_StartingPos", enabled, bugId) { this.hasVisibleRegion(FlickerTestBase.NAVIGATION_BAR_WINDOW_TITLE, startingPos) this.hasVisibleRegion(NAVIGATION_BAR_WINDOW_TITLE, startingPos) } end("navBarLayerRotatesAndScales_EndingPost", enabled, bugId) { this.hasVisibleRegion(FlickerTestBase.NAVIGATION_BAR_WINDOW_TITLE, endingPos) this.hasVisibleRegion(NAVIGATION_BAR_WINDOW_TITLE, endingPos) } if (startingPos == endingPos) { all("navBarLayerRotatesAndScales", enabled = false, bugId = 167747321) { this.hasVisibleRegion(FlickerTestBase.NAVIGATION_BAR_WINDOW_TITLE, startingPos) this.hasVisibleRegion(NAVIGATION_BAR_WINDOW_TITLE, startingPos) } } } Loading @@ -126,10 +130,10 @@ fun LayersAssertion.statusBarLayerRotatesScales( val endingPos = WindowUtils.getStatusBarPosition(endRotation) start("statusBarLayerRotatesScales_StartingPos", enabled, bugId) { this.hasVisibleRegion(FlickerTestBase.STATUS_BAR_WINDOW_TITLE, startingPos) this.hasVisibleRegion(STATUS_BAR_WINDOW_TITLE, startingPos) } end("statusBarLayerRotatesScales_EndingPos", enabled, bugId) { this.hasVisibleRegion(FlickerTestBase.STATUS_BAR_WINDOW_TITLE, endingPos) this.hasVisibleRegion(STATUS_BAR_WINDOW_TITLE, endingPos) } } Loading
tests/FlickerTests/src/com/android/server/wm/flicker/FlickerTestBase.ktdeleted 100644 → 0 +0 −129 Original line number 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.server.wm.flicker import android.os.RemoteException import android.os.SystemClock import android.platform.helpers.IAppHelper import android.view.Surface import androidx.test.platform.app.InstrumentationRegistry import androidx.test.uiautomator.UiDevice /** * Base class of all Flicker test that performs common functions for all flicker tests: * * * - Caches transitions so that a transition is run once and the transition results are used by * tests multiple times. This is needed for parameterized tests which call the BeforeClass methods * multiple times. * - Keeps track of all test artifacts and deletes ones which do not need to be reviewed. * - Fails tests if results are not available for any test due to jank. */ abstract class FlickerTestBase { val instrumentation by lazy { InstrumentationRegistry.getInstrumentation() } val uiDevice by lazy { UiDevice.getInstance(instrumentation) } /** * Build a test tag for the test * @param testName Name of the transition(s) being tested * @param app App being launcher * @param rotation Initial screen rotation * * @return test tag with pattern <NAME>__<APP>__<ROTATION> </ROTATION></APP></NAME> */ protected fun buildTestTag(testName: String, app: IAppHelper, rotation: Int): String { return buildTestTag( testName, app, rotation, rotation, app2 = null, extraInfo = "") } /** * Build a test tag for the test * @param testName Name of the transition(s) being tested * @param app App being launcher * @param beginRotation Initial screen rotation * @param endRotation End screen rotation (if any, otherwise use same as initial) * * @return test tag with pattern <NAME>__<APP>__<BEGIN_ROTATION>-<END_ROTATION> </END_ROTATION></BEGIN_ROTATION></APP></NAME> */ protected fun buildTestTag( testName: String, app: IAppHelper, beginRotation: Int, endRotation: Int ): String { return buildTestTag( testName, app, beginRotation, endRotation, app2 = null, extraInfo = "") } /** * Build a test tag for the test * @param testName Name of the transition(s) being tested * @param app App being launcher * @param app2 Second app being launched (if any) * @param beginRotation Initial screen rotation * @param endRotation End screen rotation (if any, otherwise use same as initial) * @param extraInfo Additional information to append to the tag * * @return test tag with pattern <NAME>__<APP></APP>(S)>__<ROTATION></ROTATION>(S)>[__<EXTRA>] </EXTRA></NAME> */ protected fun buildTestTag( testName: String, app: IAppHelper, beginRotation: Int, endRotation: Int, app2: IAppHelper?, extraInfo: String ): String { var testTag = "${testName}__${app.launcherName}" if (app2 != null) { testTag += "-${app2.launcherName}" } testTag += "__${Surface.rotationToString(beginRotation)}" if (endRotation != beginRotation) { testTag += "-${Surface.rotationToString(endRotation)}" } if (extraInfo.isNotEmpty()) { testTag += "__$extraInfo" } return testTag } protected fun Flicker.setRotation(rotation: Int) { try { when (rotation) { Surface.ROTATION_270 -> device.setOrientationLeft() Surface.ROTATION_90 -> device.setOrientationRight() Surface.ROTATION_0 -> device.setOrientationNatural() else -> device.setOrientationNatural() } // Wait for animation to complete SystemClock.sleep(1000) } catch (e: RemoteException) { throw RuntimeException(e) } } companion object { const val NAVIGATION_BAR_WINDOW_TITLE = "NavigationBar" const val STATUS_BAR_WINDOW_TITLE = "StatusBar" const val DOCKED_STACK_DIVIDER = "DockedStackDivider" } } No newline at end of file
tests/FlickerTests/src/com/android/server/wm/flicker/NonRotationTestBase.ktdeleted 100644 → 0 +0 −36 Original line number 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.server.wm.flicker import android.view.Surface import org.junit.runners.Parameterized abstract class NonRotationTestBase( protected val rotationName: String, protected val rotation: Int ) : FlickerTestBase() { companion object { const val SCREENSHOT_LAYER = "RotationLayer" @Parameterized.Parameters(name = "{0}") @JvmStatic fun getParams(): Collection<Array<Any>> { val supportedRotations = intArrayOf(Surface.ROTATION_0, Surface.ROTATION_90) return supportedRotations.map { arrayOf(Surface.rotationToString(it), it) } } } } No newline at end of file
tests/FlickerTests/src/com/android/server/wm/flicker/RotationTestBase.ktdeleted 100644 → 0 +0 −49 Original line number 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.server.wm.flicker import android.view.Surface import org.junit.runners.Parameterized abstract class RotationTestBase( beginRotationName: String, endRotationName: String, protected val beginRotation: Int, protected val endRotation: Int ) : FlickerTestBase() { companion object { @Parameterized.Parameters(name = "{0}-{1}") @JvmStatic fun getParams(): Collection<Array<Any>> { val supportedRotations = intArrayOf(Surface.ROTATION_0, Surface.ROTATION_90) val params: MutableCollection<Array<Any>> = mutableListOf() for (begin in supportedRotations) { for (end in supportedRotations) { if (begin != end) { params.add(arrayOf( Surface.rotationToString(begin), Surface.rotationToString(end), begin, end )) } } } return params } } } No newline at end of file