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 confirmation dialog after switching to the 26 * guest user. 27 */ 28 class WelcomeBackGuestDialog internal constructor() { 29 /** Click the start over button. https://hsv.googleplex.com/6260902091292672?node=15 */ startOvernull30 fun startOver() { 31 runThenWaitUntilSwitchCompleted { 32 TITLE_SELECTOR.assertVisible { "Welcome back guest dialog is not visible" } 33 waitForObj(START_OVER_BUTTON_SELECTOR).click() 34 } 35 } 36 37 companion object { 38 // https://hsv.googleplex.com/6260902091292672?node=7 39 private val TITLE_SELECTOR = 40 androidResSelector("alertTitle") 41 .text(Pattern.compile("Welcome back, guest!", Pattern.CASE_INSENSITIVE)) 42 43 // https://hsv.googleplex.com/6260902091292672?node=15 44 private val START_OVER_BUTTON_SELECTOR = 45 androidResSelector("button2") 46 .text(Pattern.compile("Start over", Pattern.CASE_INSENSITIVE)) 47 } 48 } 49