• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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.platform.systemui_tapl.ui
18 
19 import android.platform.helpers.ui.UiAutomatorUtils.getUiDevice
20 import android.platform.systemui_tapl.utils.DeviceUtils.androidResSelector
21 import android.platform.systemui_tapl.utils.DeviceUtils.sysuiResSelector
22 import android.platform.uiautomatorhelpers.DeviceHelpers.assertInvisible
23 import android.platform.uiautomatorhelpers.DeviceHelpers.assertVisible
24 import android.platform.uiautomatorhelpers.DeviceHelpers.waitForObj
25 import android.platform.uiautomatorhelpers.stableBounds
26 import com.google.common.truth.Truth.assertThat
27 
28 /**
29  * System UI test automation object representing a media projection app selector. App selector is
30  * launched when sharing a single app.
31  */
32 class MediaProjectionAppSelector internal constructor() {
33 
34     init {
35         CHOOSER_HEADER.assertVisible()
36     }
37 
38     /** Dismiss app selector by pressing back. Make sure it is no longer visible */
dismissnull39     fun dismiss() {
40         getUiDevice().pressBack()
41         CHOOSER_HEADER.assertInvisible()
42     }
43 
44     /** Make sure app selector is fully expanded */
verifyIsExpandednull45     fun verifyIsExpanded() {
46         // Assert full expansion when the top of the drawer touches the bottom of the status bar
47         val headerTop = waitForObj(CHOOSER_HEADER).stableBounds.top
48         val statusBarBottom = waitForObj(STATUS_BAR).stableBounds.bottom
49         assertThat(headerTop).isEqualTo(statusBarBottom)
50     }
51 
52     /** Width of the app selector drawer */
53     val width: Int
54         get() = waitForObj(CHOOSER_HEADER).stableBounds.width()
55 
56     companion object {
57         private val CHOOSER_HEADER = androidResSelector("chooser_header")
58         private val STATUS_BAR = sysuiResSelector("status_bar_container")
59     }
60 }
61