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 android.tools.flicker.config 18 19 import android.tools.flicker.AssertionInvocationGroup 20 import android.tools.flicker.assertors.assertions.AppLayerBecomesInvisible 21 import android.tools.flicker.assertors.assertions.AppLayerBecomesVisible 22 import android.tools.flicker.assertors.assertions.AppLayerCoversFullScreenAtEnd 23 import android.tools.flicker.assertors.assertions.AppLayerCoversFullScreenAtStart 24 import android.tools.flicker.assertors.assertions.AppLayerIsInvisibleAtEnd 25 import android.tools.flicker.assertors.assertions.AppLayerIsInvisibleAtStart 26 import android.tools.flicker.assertors.assertions.AppLayerIsVisibleAlways 27 import android.tools.flicker.assertors.assertions.AppLayerIsVisibleAtEnd 28 import android.tools.flicker.assertors.assertions.AppLayerIsVisibleAtStart 29 import android.tools.flicker.assertors.assertions.AppWindowBecomesInvisible 30 import android.tools.flicker.assertors.assertions.AppWindowBecomesTopWindow 31 import android.tools.flicker.assertors.assertions.AppWindowBecomesVisible 32 import android.tools.flicker.assertors.assertions.AppWindowIsInvisibleAtEnd 33 import android.tools.flicker.assertors.assertions.AppWindowIsInvisibleAtStart 34 import android.tools.flicker.assertors.assertions.AppWindowIsTopWindowAtStart 35 import android.tools.flicker.assertors.assertions.AppWindowIsVisibleAlways 36 import android.tools.flicker.assertors.assertions.AppWindowIsVisibleAtEnd 37 import android.tools.flicker.assertors.assertions.AppWindowIsVisibleAtStart 38 import android.tools.flicker.assertors.assertions.AppWindowOnTopAtEnd 39 import android.tools.flicker.assertors.assertions.AppWindowOnTopAtStart 40 import android.tools.flicker.assertors.assertions.EntireScreenCoveredAlways 41 import android.tools.flicker.assertors.assertions.FocusChanges 42 import android.tools.flicker.assertors.assertions.HasAtMostOneWindowMatching 43 import android.tools.flicker.assertors.assertions.LayerBecomesInvisible 44 import android.tools.flicker.assertors.assertions.LayerBecomesVisible 45 import android.tools.flicker.assertors.assertions.LayerReduces 46 import android.tools.flicker.assertors.assertions.ScreenLockedAtStart 47 import android.tools.flicker.assertors.assertions.SplitAppLayerBoundsBecomesVisible 48 import android.tools.flicker.assertors.assertions.VisibleLayersShownMoreThanOneConsecutiveEntry 49 import android.tools.flicker.assertors.assertions.VisibleWindowsShownMoreThanOneConsecutiveEntry 50 import android.tools.flicker.assertors.assertions.WindowBecomesPinned 51 import android.tools.flicker.assertors.assertions.WindowRemainInsideVisibleBounds 52 import android.tools.flicker.config.appclose.Components.CLOSING_APPS 53 import android.tools.flicker.config.applaunch.Components.OPENING_APPS 54 import android.tools.flicker.config.common.Components.LAUNCHER 55 import android.tools.flicker.config.pip.Components.PIP_APP 56 import android.tools.flicker.config.pip.Components.PIP_DISMISS_OVERLAY 57 import android.tools.flicker.config.splitscreen.Components.SPLIT_SCREEN_DIVIDER 58 import android.tools.flicker.config.splitscreen.Components.SPLIT_SCREEN_PRIMARY_APP 59 import android.tools.flicker.config.splitscreen.Components.SPLIT_SCREEN_SECONDARY_APP 60 import android.tools.traces.component.ComponentNameMatcher 61 62 object AssertionTemplates { 63 val ENTIRE_TRACE_ASSERTIONS = 64 mapOf( 65 EntireScreenCoveredAlways() to AssertionInvocationGroup.NON_BLOCKING, 66 VisibleWindowsShownMoreThanOneConsecutiveEntry() to 67 AssertionInvocationGroup.NON_BLOCKING, 68 // Temporarily ignore these layers which might be visible for a single entry 69 // and contain only view level changes during that entry (b/286054008) 70 VisibleLayersShownMoreThanOneConsecutiveEntry( 71 ignore = 72 listOf( 73 ComponentNameMatcher.NOTIFICATION_SHADE, 74 ComponentNameMatcher.VOLUME_DIALOG, 75 ComponentNameMatcher.NAV_BAR, 76 ) 77 ) to AssertionInvocationGroup.NON_BLOCKING, 78 ) 79 80 val COMMON_ASSERTIONS = 81 listOf( 82 EntireScreenCoveredAlways(), 83 VisibleWindowsShownMoreThanOneConsecutiveEntry(), 84 VisibleLayersShownMoreThanOneConsecutiveEntry(), 85 ) <lambda>null86 .associateBy({ it }, { AssertionInvocationGroup.BLOCKING }) 87 88 val APP_LAUNCH_ASSERTIONS = 89 COMMON_ASSERTIONS + 90 listOf( 91 AppLayerIsInvisibleAtStart(OPENING_APPS), 92 AppLayerIsVisibleAtEnd(OPENING_APPS), 93 AppLayerBecomesVisible(OPENING_APPS), 94 AppWindowBecomesVisible(OPENING_APPS), 95 AppWindowBecomesTopWindow(OPENING_APPS), 96 ) <lambda>null97 .associateBy({ it }, { AssertionInvocationGroup.BLOCKING }) 98 99 val APP_CLOSE_ASSERTIONS = <lambda>null100 COMMON_ASSERTIONS.toMutableMap().also { 101 it.remove(VisibleLayersShownMoreThanOneConsecutiveEntry()) 102 } + 103 listOf( 104 AppLayerIsVisibleAtStart(CLOSING_APPS), 105 AppLayerIsInvisibleAtEnd(CLOSING_APPS), 106 AppWindowIsVisibleAtStart(CLOSING_APPS), 107 AppWindowIsInvisibleAtEnd(CLOSING_APPS), 108 AppLayerBecomesInvisible(CLOSING_APPS), 109 AppWindowBecomesInvisible(CLOSING_APPS), 110 AppWindowIsTopWindowAtStart(CLOSING_APPS), 111 VisibleLayersShownMoreThanOneConsecutiveEntry( 112 listOf(ComponentNameMatcher.NAV_BAR) 113 ) 114 ) <lambda>null115 .associateBy({ it }, { AssertionInvocationGroup.BLOCKING }) 116 117 val APP_LAUNCH_FROM_HOME_ASSERTIONS = 118 APP_LAUNCH_ASSERTIONS + 119 listOf( 120 AppLayerIsVisibleAtStart(LAUNCHER), 121 AppLayerIsInvisibleAtEnd(LAUNCHER), 122 ) <lambda>null123 .associateBy({ it }, { AssertionInvocationGroup.BLOCKING }) 124 125 val APP_LAUNCH_FROM_LOCK_ASSERTIONS = 126 APP_LAUNCH_ASSERTIONS + 127 listOf(FocusChanges(toComponent = OPENING_APPS), ScreenLockedAtStart()) <lambda>null128 .associateBy({ it }, { AssertionInvocationGroup.BLOCKING }) 129 130 val APP_CLOSE_TO_HOME_ASSERTIONS = 131 APP_CLOSE_ASSERTIONS + 132 listOf( 133 AppLayerIsInvisibleAtStart(LAUNCHER), 134 AppLayerIsVisibleAtEnd(LAUNCHER), 135 AppWindowIsInvisibleAtStart(LAUNCHER), 136 AppWindowIsVisibleAtEnd(LAUNCHER), 137 AppWindowBecomesTopWindow(LAUNCHER), 138 ) <lambda>null139 .associateBy({ it }, { AssertionInvocationGroup.BLOCKING }) 140 141 val APP_LAUNCH_FROM_NOTIFICATION_ASSERTIONS = COMMON_ASSERTIONS + APP_LAUNCH_ASSERTIONS 142 143 val LAUNCHER_QUICK_SWITCH_ASSERTIONS = 144 COMMON_ASSERTIONS + 145 APP_LAUNCH_ASSERTIONS + 146 APP_CLOSE_ASSERTIONS + 147 listOf( 148 AppLayerCoversFullScreenAtStart(CLOSING_APPS), 149 AppLayerCoversFullScreenAtEnd(OPENING_APPS), 150 AppWindowOnTopAtStart(CLOSING_APPS), 151 AppWindowOnTopAtEnd(OPENING_APPS), 152 AppWindowBecomesInvisible(CLOSING_APPS), 153 AppLayerBecomesInvisible(CLOSING_APPS), 154 AppWindowBecomesVisible(OPENING_APPS), 155 AppLayerBecomesVisible(OPENING_APPS), 156 ) <lambda>null157 .associateBy({ it }, { AssertionInvocationGroup.BLOCKING }) 158 159 val APP_CLOSE_TO_PIP_ASSERTIONS = 160 COMMON_ASSERTIONS + 161 listOf( 162 LayerReduces(PIP_APP), 163 FocusChanges(), 164 AppWindowIsVisibleAlways(PIP_APP), 165 WindowRemainInsideVisibleBounds(PIP_APP), 166 WindowBecomesPinned(PIP_APP), 167 LayerBecomesVisible(LAUNCHER), 168 HasAtMostOneWindowMatching(PIP_DISMISS_OVERLAY) 169 ) <lambda>null170 .associateBy({ it }, { AssertionInvocationGroup.BLOCKING }) 171 172 val ENTER_SPLITSCREEN_ASSERTIONS = 173 COMMON_ASSERTIONS + 174 listOf( 175 LayerBecomesVisible(SPLIT_SCREEN_DIVIDER), 176 AppLayerIsVisibleAtEnd(SPLIT_SCREEN_PRIMARY_APP), 177 AppLayerBecomesVisible(SPLIT_SCREEN_SECONDARY_APP), 178 SplitAppLayerBoundsBecomesVisible( 179 SPLIT_SCREEN_PRIMARY_APP, 180 isPrimaryApp = true 181 ), 182 SplitAppLayerBoundsBecomesVisible( 183 SPLIT_SCREEN_SECONDARY_APP, 184 isPrimaryApp = false 185 ), 186 AppWindowBecomesVisible(SPLIT_SCREEN_PRIMARY_APP), 187 AppWindowBecomesVisible(SPLIT_SCREEN_SECONDARY_APP), 188 ) <lambda>null189 .associateBy({ it }, { AssertionInvocationGroup.BLOCKING }) 190 191 val EXIT_SPLITSCREEN_ASSERTIONS = 192 COMMON_ASSERTIONS + 193 listOf( 194 LayerBecomesInvisible(SPLIT_SCREEN_DIVIDER), 195 AppLayerBecomesInvisible(SPLIT_SCREEN_PRIMARY_APP), 196 AppLayerIsVisibleAlways(SPLIT_SCREEN_SECONDARY_APP), 197 AppWindowBecomesInvisible(SPLIT_SCREEN_PRIMARY_APP), 198 AppWindowIsVisibleAlways(SPLIT_SCREEN_SECONDARY_APP), 199 ) <lambda>null200 .associateBy({ it }, { AssertionInvocationGroup.BLOCKING }) 201 202 val RESIZE_SPLITSCREEN_ASSERTIONS = 203 COMMON_ASSERTIONS + 204 listOf( 205 AppLayerIsVisibleAlways(SPLIT_SCREEN_PRIMARY_APP), 206 AppLayerIsVisibleAlways(SPLIT_SCREEN_SECONDARY_APP), 207 AppWindowIsVisibleAlways(SPLIT_SCREEN_PRIMARY_APP), 208 AppWindowIsVisibleAlways(SPLIT_SCREEN_SECONDARY_APP), 209 ) <lambda>null210 .associateBy({ it }, { AssertionInvocationGroup.BLOCKING }) 211 } 212