1 /* 2 * Copyright (C) 2025 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 com.android.documentsui.bots 17 18 import android.content.Context 19 import androidx.test.uiautomator.UiDevice 20 import androidx.test.uiautomator.UiObject 21 import junit.framework.Assert.assertFalse 22 import junit.framework.Assert.assertTrue 23 24 /** 25 * A test helper class that provides support for controlling the peek overlay 26 * and making assertions against the state of it. 27 */ 28 class PeekBot( 29 device: UiDevice, 30 context: Context, 31 timeout: Int 32 ) : Bots.BaseBot(device, context, timeout) { 33 34 private val mOverlayId: String = "$mTargetPackage:id/peek_overlay" 35 private val mContainerId: String = "$mTargetPackage:id/peek_container" 36 assertPeekActivenull37 fun assertPeekActive() { 38 val peekContainer = findPeekContainer() 39 assertTrue(peekContainer.exists()) 40 } 41 assertPeekHiddennull42 fun assertPeekHidden() { 43 val peekContainer = findPeekContainer() 44 assertFalse(peekContainer.exists()) 45 } 46 findPeekContainernull47 fun findPeekContainer(): UiObject { 48 return findObject(mOverlayId, mContainerId) 49 } 50 } 51