1 /* 2 * Copyright (C) 2023 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.launcherDescSelector 20 import android.platform.systemui_tapl.utils.DeviceUtils.launcherResSelector 21 import android.platform.uiautomatorhelpers.DeviceHelpers.waitForObj 22 import com.google.common.truth.Truth.assertThat 23 24 /** 25 * Provides an API for interacting with the expanded bubble bar within launcher in UI automation 26 * tests. 27 * 28 * @see [BubbleBar] 29 */ 30 class ExpandedBubbleBar(val selectedBubble: BubbleBarItem) { 31 32 init { 33 assertThat(bubbles.size).isAtLeast(1) 34 } 35 36 /** @return all the bubbles in the bubble bar. */ 37 val bubbles: List<BubbleBarItem> <lambda>null38 get() = waitForObj(BUBBLE_BAR).children.map { BubbleBarItem(it) } 39 40 /** @return expanded view for the current bubble. */ 41 val expandedBubble: ExpandedBubbleBarBubble 42 get() = ExpandedBubbleBarBubble() 43 44 /** Collapses the bubble bar by tapping on the selected bubble and returns [BubbleBar]. */ collapsenull45 fun collapse(): BubbleBar { 46 selectedBubble.item.click() 47 return BubbleBar() 48 } 49 50 /** 51 * Selects the specified [bubble] by tapping on it and returns a new instance of 52 * [ExpandedBubbleBar]. 53 */ selectnull54 fun select(bubble: BubbleBarItem): ExpandedBubbleBar { 55 assertThat(bubble).isNotEqualTo(selectedBubble) 56 bubble.item.click() 57 return ExpandedBubbleBar(bubble) 58 } 59 60 companion object { 61 private val BUBBLE_BAR = launcherResSelector("taskbar_bubbles") 62 private val OVERFLOW_BUBBLE = launcherDescSelector("Overflow") 63 } 64 } 65