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