• 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.uiautomatorhelpers.DeviceHelpers.assertVisible
19 import android.platform.uiautomatorhelpers.DeviceHelpers.waitForObj
20 import androidx.test.uiautomator.By
21 import java.util.regex.Pattern
22 
23 /**
24  * System UI test automation object representing the dialog for adding the new user from quick
25  * settings.
26  *
27  * https://hsv.googleplex.com/5360066535358464
28  */
29 class AddUserPrompt internal constructor() {
30     /** Clicks on the OK button. https://hsv.googleplex.com/5360066535358464?node=15 */
clickOkToOpenAddUserPanelnull31     fun clickOkToOpenAddUserPanel(): AddUserPanel {
32         TITLE_SELECTOR.assertVisible()
33         waitForObj(OK_SELECTOR) { "OK button not found" }.click()
34         return AddUserPanel()
35     }
36 
37     /** Clicks on the cancel button. https://hsv.googleplex.com/5360066535358464?node=14 */
cancelnull38     fun cancel() {
39         TITLE_SELECTOR.assertVisible()
40         waitForObj(CANCEL_SELECTOR) { "Cancel button not found" }.click()
41     }
42 
43     companion object {
44         // https://hsv.googleplex.com/5360066535358464?node=11
45         private val TITLE_SELECTOR =
46             By.res("com.android.systemui:id/dialog_with_icon_title")
47                 .text(Pattern.compile("Add new user\\?", Pattern.CASE_INSENSITIVE))
48 
49         // https://hsv.googleplex.com/5360066535358464?node=15
50         private val OK_SELECTOR =
51             By.res("com.android.systemui:id/button_ok")
52                 .text(Pattern.compile("Next", Pattern.CASE_INSENSITIVE))
53 
54         // https://hsv.googleplex.com/5360066535358464?node=14
55         private val CANCEL_SELECTOR =
56             By.res("com.android.systemui:id/button_cancel")
57                 .text(Pattern.compile("Cancel", Pattern.CASE_INSENSITIVE))
58     }
59 }
60