/* * Copyright (C) 2024 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package android.platform.systemui_tapl.ui import android.platform.systemui_tapl.utils.DeviceUtils.sysuiResSelector import android.platform.uiautomatorhelpers.DeviceHelpers.assertInvisible import android.platform.uiautomatorhelpers.DeviceHelpers.waitForObj import android.platform.uiautomatorhelpers.scrollUntilFound import android.view.Display.DEFAULT_DISPLAY import androidx.test.uiautomator.UiObject2 /** Wrapper representing the InternetDialog that opens when the QS Tile is clicked */ class InternetDialog internal constructor(displayId: Int = DEFAULT_DISPLAY) { private val scrollView: UiObject2 = waitForObj( sysuiResSelector(SCROLL_VIEW_RES_ID, displayId) .hasParent(sysuiResSelector(DIALOG_RES_ID, displayId)) ) val doneBtn = sysuiResSelector("done_button", displayId) /** Finds the done button, clicks on it and asserts that the dialog has closed. */ fun clickOnDoneAndClose() { val doneButton = scrollView.scrollUntilFound(doneBtn) ?: error("Done button not found") doneButton.click() doneBtn.assertInvisible(errorProvider = { "Internet dialog is dismissed" }) } private companion object { const val DIALOG_RES_ID = "internet_connectivity_dialog" const val SCROLL_VIEW_RES_ID = "scroll_view" } }