xref: /aosp_15_r20/frameworks/base/tests/FlickerTests/IME/src/com/android/server/wm/flicker/ime/common/CommonAssertions.kt (revision d57664e9bc4670b3ecf6748a746a57c557b6bc9e)
1 /*
2  * Copyright (C) 2020 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 @file:JvmName("CommonAssertions")
18 
19 package com.android.server.wm.flicker.ime
20 
21 import android.tools.flicker.legacy.LegacyFlickerTest
22 import android.tools.traces.component.ComponentNameMatcher
23 
LegacyFlickerTestnull24 fun LegacyFlickerTest.imeLayerBecomesVisible() {
25     assertLayers {
26         this.isInvisible(ComponentNameMatcher.IME).then().isVisible(ComponentNameMatcher.IME)
27     }
28 }
29 
LegacyFlickerTestnull30 fun LegacyFlickerTest.imeLayerBecomesInvisible() {
31     assertLayers {
32         this.isVisible(ComponentNameMatcher.IME).then().isInvisible(ComponentNameMatcher.IME)
33     }
34 }
35 
imeWindowIsAlwaysVisiblenull36 fun LegacyFlickerTest.imeWindowIsAlwaysVisible(rotatesScreen: Boolean = false) {
37     if (rotatesScreen) {
38         assertWm {
39             this.isNonAppWindowVisible(ComponentNameMatcher.IME)
40                 .then()
41                 .isNonAppWindowInvisible(ComponentNameMatcher.IME)
42                 .then()
43                 .isNonAppWindowVisible(ComponentNameMatcher.IME)
44         }
45     } else {
46         assertWm { this.isNonAppWindowVisible(ComponentNameMatcher.IME) }
47     }
48 }
49 
LegacyFlickerTestnull50 fun LegacyFlickerTest.imeWindowBecomesVisible() {
51     assertWm {
52         this.isNonAppWindowInvisible(ComponentNameMatcher.IME)
53             .then()
54             .isNonAppWindowVisible(ComponentNameMatcher.IME)
55     }
56 }
57 
LegacyFlickerTestnull58 fun LegacyFlickerTest.imeWindowBecomesInvisible() {
59     assertWm {
60         this.isNonAppWindowVisible(ComponentNameMatcher.IME)
61             .then()
62             .isNonAppWindowInvisible(ComponentNameMatcher.IME)
63     }
64 }
65