1 /* 2 * Copyright (C) 2023 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.wm.shell.flicker.utils 18 19 import android.platform.test.annotations.Presubmit 20 import android.tools.common.traces.component.ComponentNameMatcher 21 import android.tools.device.flicker.legacy.LegacyFlickerTest 22 import com.android.server.wm.flicker.entireScreenCovered 23 import com.android.server.wm.flicker.navBarLayerIsVisibleAtStartAndEnd 24 import com.android.server.wm.flicker.navBarLayerPositionAtStartAndEnd 25 import com.android.server.wm.flicker.navBarWindowIsAlwaysVisible 26 import com.android.server.wm.flicker.statusBarLayerIsVisibleAtStartAndEnd 27 import com.android.server.wm.flicker.statusBarLayerPositionAtStartAndEnd 28 import com.android.server.wm.flicker.statusBarWindowIsAlwaysVisible 29 import com.android.server.wm.flicker.taskBarLayerIsVisibleAtStartAndEnd 30 import com.android.server.wm.flicker.taskBarWindowIsAlwaysVisible 31 import org.junit.Assume 32 import org.junit.Test 33 34 interface ICommonAssertions { 35 val flicker: LegacyFlickerTest 36 37 /** Checks that all parts of the screen are covered during the transition */ 38 @Presubmit @Test fun entireScreenCovered() = flicker.entireScreenCovered() 39 40 /** 41 * Checks that the [ComponentNameMatcher.NAV_BAR] layer is visible during the whole transition 42 */ 43 @Presubmit 44 @Test 45 fun navBarLayerIsVisibleAtStartAndEnd() { 46 Assume.assumeFalse(flicker.scenario.isTablet) 47 flicker.navBarLayerIsVisibleAtStartAndEnd() 48 } 49 50 /** 51 * Checks the position of the [ComponentNameMatcher.NAV_BAR] at the start and end of the 52 * transition 53 */ 54 @Presubmit 55 @Test 56 fun navBarLayerPositionAtStartAndEnd() { 57 Assume.assumeFalse(flicker.scenario.isTablet) 58 flicker.navBarLayerPositionAtStartAndEnd() 59 } 60 61 /** 62 * Checks that the [ComponentNameMatcher.NAV_BAR] window is visible during the whole transition 63 * 64 * Note: Phones only 65 */ 66 @Presubmit 67 @Test 68 fun navBarWindowIsAlwaysVisible() { 69 Assume.assumeFalse(flicker.scenario.isTablet) 70 flicker.navBarWindowIsAlwaysVisible() 71 } 72 73 /** 74 * Checks that the [ComponentNameMatcher.TASK_BAR] layer is visible during the whole transition 75 */ 76 @Presubmit 77 @Test 78 fun taskBarLayerIsVisibleAtStartAndEnd() { 79 Assume.assumeTrue(flicker.scenario.isTablet) 80 flicker.taskBarLayerIsVisibleAtStartAndEnd() 81 } 82 83 /** 84 * Checks that the [ComponentNameMatcher.TASK_BAR] window is visible during the whole transition 85 * 86 * Note: Large screen only 87 */ 88 @Presubmit 89 @Test 90 fun taskBarWindowIsAlwaysVisible() { 91 Assume.assumeTrue(flicker.scenario.isTablet) 92 flicker.taskBarWindowIsAlwaysVisible() 93 } 94 95 /** 96 * Checks that the [ComponentNameMatcher.STATUS_BAR] layer is visible during the whole 97 * transition 98 */ 99 @Presubmit 100 @Test 101 fun statusBarLayerIsVisibleAtStartAndEnd() = flicker.statusBarLayerIsVisibleAtStartAndEnd() 102 103 /** 104 * Checks the position of the [ComponentNameMatcher.STATUS_BAR] at the start and end of the 105 * transition 106 */ 107 @Presubmit 108 @Test 109 fun statusBarLayerPositionAtStartAndEnd() = flicker.statusBarLayerPositionAtStartAndEnd() 110 111 /** 112 * Checks that the [ComponentNameMatcher.STATUS_BAR] window is visible during the whole 113 * transition 114 */ 115 @Presubmit @Test fun statusBarWindowIsAlwaysVisible() = flicker.statusBarWindowIsAlwaysVisible() 116 117 /** 118 * Checks that all layers that are visible on the trace, are visible for at least 2 consecutive 119 * entries. 120 */ 121 @Presubmit 122 @Test 123 fun visibleLayersShownMoreThanOneConsecutiveEntry() { 124 flicker.assertLayers { this.visibleLayersShownMoreThanOneConsecutiveEntry() } 125 } 126 127 /** 128 * Checks that all windows that are visible on the trace, are visible for at least 2 consecutive 129 * entries. 130 */ 131 @Presubmit 132 @Test 133 fun visibleWindowsShownMoreThanOneConsecutiveEntry() { 134 flicker.assertWm { this.visibleWindowsShownMoreThanOneConsecutiveEntry() } 135 } 136 } 137