• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2022 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 package android.platform.systemui_tapl.ui
17 
18 import android.platform.systemui_tapl.utils.DeviceUtils.androidResSelector
19 import android.platform.systemui_tapl.utils.UserUtils.runThenWaitUntilSwitchCompleted
20 import android.platform.uiautomatorhelpers.DeviceHelpers.assertVisible
21 import android.platform.uiautomatorhelpers.DeviceHelpers.waitForObj
22 import java.util.regex.Pattern
23 
24 /**
25  * System UI test automation object representing the exit confirmation dialog when either switching
26  * from an ephemeral guest user, or pressing "Exit guest" when device is configured with
27  * config_guestUserAutoCreated.
28  *
29  * https://hsv.googleplex.com/5025959268843520
30  */
31 class ExitGuestPrompt internal constructor() {
32     /** Click the exit button. https://hsv.googleplex.com/5025959268843520?node=16 */
confirmExitnull33     fun confirmExit() {
34         runThenWaitUntilSwitchCompleted {
35             TITLE_SELECTOR.assertVisible { "Exit guest prompt prompt dialog is not visible" }
36             waitForObj(EXIT_SELECTOR) { "Exit button not found" }.click()
37         }
38     }
39 
40     companion object {
41 
42         // https://hsv.googleplex.com/6067368607350784?node=10
43         private val TITLE_SELECTOR =
44             androidResSelector("alertTitle")
45                 .text(Pattern.compile("Exit guest mode\\?", Pattern.CASE_INSENSITIVE))
46 
47         // https://hsv.googleplex.com/6067368607350784?node=19
48         private val EXIT_SELECTOR =
49             androidResSelector("button1").text(Pattern.compile("Exit", Pattern.CASE_INSENSITIVE))
50     }
51 }
52