1 /* 2 * Copyright (C) 2021 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package com.android.server.wm.flicker.rotation 18 19 import android.platform.test.annotations.Presubmit 20 import android.tools.common.traces.component.ComponentNameMatcher 21 import android.tools.device.apphelpers.StandardAppHelper 22 import android.tools.device.flicker.legacy.FlickerBuilder 23 import android.tools.device.flicker.legacy.LegacyFlickerTest 24 import com.android.server.wm.flicker.BaseTest 25 import com.android.server.wm.flicker.helpers.setRotation 26 import org.junit.Test 27 28 /** Base class for app rotation tests */ 29 abstract class RotationTransition(flicker: LegacyFlickerTest) : BaseTest(flicker) { 30 protected abstract val testApp: StandardAppHelper 31 32 /** {@inheritDoc} */ 33 override val transition: FlickerBuilder.() -> Unit = { 34 setup { this.setRotation(flicker.scenario.startRotation) } 35 teardown { testApp.exit(wmHelper) } 36 transitions { this.setRotation(flicker.scenario.endRotation) } 37 } 38 39 /** {@inheritDoc} */ 40 @Presubmit 41 @Test 42 override fun visibleLayersShownMoreThanOneConsecutiveEntry() { 43 flicker.assertLayers { 44 this.visibleLayersShownMoreThanOneConsecutiveEntry( 45 ignoreLayers = 46 listOf( 47 ComponentNameMatcher.SPLASH_SCREEN, 48 ComponentNameMatcher.SNAPSHOT, 49 ComponentNameMatcher("", "SecondaryHomeHandle") 50 ) 51 ) 52 } 53 } 54 55 /** Checks that [testApp] layer covers the entire screen at the start of the transition */ 56 @Presubmit 57 @Test 58 open fun appLayerRotates_StartingPos() { 59 flicker.assertLayersStart { 60 this.entry.displays.map { display -> 61 this.visibleRegion(testApp).coversExactly(display.layerStackSpace) 62 } 63 } 64 } 65 66 /** Checks that [testApp] layer covers the entire screen at the end of the transition */ 67 @Presubmit 68 @Test 69 open fun appLayerRotates_EndingPos() { 70 flicker.assertLayersEnd { 71 this.entry.displays.map { display -> 72 this.visibleRegion(testApp).coversExactly(display.layerStackSpace) 73 } 74 } 75 } 76 77 override fun cujCompleted() { 78 super.cujCompleted() 79 appLayerRotates_StartingPos() 80 appLayerRotates_EndingPos() 81 } 82 } 83