1 /* 2 * Copyright (C) 2024 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.systemui_tapl.utils.DeviceUtils.sysuiResSelector 20 import android.platform.test.scenario.tapl_common.Gestures 21 import android.platform.uiautomatorhelpers.DeviceHelpers.assertVisibility 22 import android.platform.uiautomatorhelpers.DeviceHelpers.waitForObj 23 import androidx.test.uiautomator.By 24 import androidx.test.uiautomator.UiObject2 25 import androidx.test.uiautomator.Until 26 import com.google.common.truth.Truth.assertThat 27 28 /** System UI test automation object representing a notification hidden's menu (a.k.a. guts). */ 29 class NotificationGuts internal constructor(private val mNotification: UiObject2) { 30 /** Taps the "Done" button on the notification guts. */ closenull31 fun close() { 32 val gutsSelector = sysuiResSelector(GUTS_ID) 33 mNotification.assertVisibility(gutsSelector, visible = true) 34 Gestures.click(mNotification.waitForObj(By.text("Done")), "Done button") 35 assertThat(mNotification.wait(Until.gone(gutsSelector), UI_RESPONSE_TIMEOUT_MSECS)).isTrue() 36 } 37 38 private companion object { 39 const val GUTS_ID = "notification_guts" 40 const val UI_RESPONSE_TIMEOUT_MSECS: Long = 3000 41 } 42 } 43