Loading libs/WindowManager/Shell/multivalentTests/src/com/android/wm/shell/bubbles/bar/BubbleBarExpandedViewTest.kt +33 −1 Original line number Diff line number Diff line Loading @@ -18,6 +18,7 @@ package com.android.wm.shell.bubbles.bar import android.app.ActivityManager import android.content.Context import android.content.pm.ShortcutInfo import android.graphics.Insets import android.graphics.Rect import android.view.LayoutInflater Loading Loading @@ -45,11 +46,14 @@ import com.android.wm.shell.shared.handles.RegionSamplingHelper import com.android.wm.shell.taskview.TaskView import com.android.wm.shell.taskview.TaskViewTaskController import com.google.common.truth.Truth.assertThat import com.google.common.util.concurrent.MoreExecutors.directExecutor import org.junit.After import org.junit.Before import org.junit.Test import org.junit.runner.RunWith import org.mockito.kotlin.mock import org.mockito.kotlin.spy import org.mockito.kotlin.verify import org.mockito.kotlin.whenever import java.util.Collections import java.util.concurrent.Executor Loading @@ -72,14 +76,18 @@ class BubbleBarExpandedViewTest { private lateinit var expandedViewManager: BubbleExpandedViewManager private lateinit var positioner: BubblePositioner private lateinit var bubbleTaskView: BubbleTaskView private lateinit var bubble: Bubble private lateinit var bubbleExpandedView: BubbleBarExpandedView private var testableRegionSamplingHelper: TestableRegionSamplingHelper? = null private var regionSamplingProvider: TestRegionSamplingProvider? = null private val bubbleLogger = spy(BubbleLogger(UiEventLoggerFake())) @Before fun setUp() { ProtoLog.REQUIRE_PROTOLOGTOOL = false ProtoLog.init() mainExecutor = TestExecutor() bgExecutor = TestExecutor() positioner = BubblePositioner(context, windowManager) Loading Loading @@ -108,7 +116,7 @@ class BubbleBarExpandedViewTest { bubbleExpandedView.initialize( expandedViewManager, positioner, BubbleLogger(UiEventLoggerFake()), bubbleLogger, false /* isOverflow */, bubbleTaskView, mainExecutor, Loading @@ -121,6 +129,20 @@ class BubbleBarExpandedViewTest { // Helper should be created once attached to window testableRegionSamplingHelper = regionSamplingProvider!!.helper }) bubble = Bubble( "key", ShortcutInfo.Builder(context, "id").build(), 100 /* desiredHeight */, 0 /* desiredHeightResId */, "title", 0 /* taskId */, null /* locus */, true /* isDismissable */, directExecutor(), directExecutor() ) {} bubbleExpandedView.update(bubble) } @After Loading Loading @@ -194,6 +216,16 @@ class BubbleBarExpandedViewTest { assertThat(testableRegionSamplingHelper!!.isStopped).isTrue() } @Test fun testEventLogging_dismissBubbleViaAppMenu() { getInstrumentation().runOnMainSync { bubbleExpandedView.handleView.performClick() } val dismissMenuItem = bubbleExpandedView.findViewWithTag<View>(BubbleBarMenuView.DISMISS_ACTION_TAG) assertThat(dismissMenuItem).isNotNull() getInstrumentation().runOnMainSync { dismissMenuItem.performClick() } verify(bubbleLogger).log(bubble, BubbleLogger.Event.BUBBLE_BAR_BUBBLE_DISMISSED_APP_MENU) } private inner class FakeBubbleTaskViewFactory : BubbleTaskViewFactory { override fun create(): BubbleTaskView { val taskViewTaskController = mock<TaskViewTaskController>() Loading libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/bar/BubbleBarExpandedView.java +1 −0 Original line number Diff line number Diff line Loading @@ -252,6 +252,7 @@ public class BubbleBarExpandedView extends FrameLayout implements BubbleTaskView @Override public void onDismissBubble(Bubble bubble) { mManager.dismissBubble(bubble, Bubbles.DISMISS_USER_GESTURE); mBubbleLogger.log(bubble, BubbleLogger.Event.BUBBLE_BAR_BUBBLE_DISMISSED_APP_MENU); } @Override Loading libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/bar/BubbleBarMenuView.java +18 −0 Original line number Diff line number Diff line Loading @@ -16,6 +16,7 @@ package com.android.wm.shell.bubbles.bar; import android.annotation.ColorInt; import android.annotation.Nullable; import android.content.Context; import android.content.res.ColorStateList; import android.content.res.TypedArray; Loading @@ -41,6 +42,9 @@ import java.util.ArrayList; * Bubble bar expanded view menu */ public class BubbleBarMenuView extends LinearLayout { public static final Object DISMISS_ACTION_TAG = new Object(); private ViewGroup mBubbleSectionView; private ViewGroup mActionsSectionView; private ImageView mBubbleIconView; Loading Loading @@ -119,6 +123,9 @@ public class BubbleBarMenuView extends LinearLayout { R.layout.bubble_bar_menu_item, mActionsSectionView, false); itemView.update(action.mIcon, action.mTitle, action.mTint); itemView.setOnClickListener(action.mOnClick); if (action.mTag != null) { itemView.setTag(action.mTag); } mActionsSectionView.addView(itemView); } } Loading Loading @@ -159,6 +166,8 @@ public class BubbleBarMenuView extends LinearLayout { private Icon mIcon; private @ColorInt int mTint; private String mTitle; @Nullable private Object mTag; private OnClickListener mOnClick; MenuAction(Icon icon, String title, OnClickListener onClick) { Loading @@ -171,5 +180,14 @@ public class BubbleBarMenuView extends LinearLayout { this.mTint = tint; this.mOnClick = onClick; } MenuAction(Icon icon, String title, @ColorInt int tint, @Nullable Object tag, OnClickListener onClick) { this.mIcon = icon; this.mTitle = title; this.mTint = tint; this.mTag = tag; this.mOnClick = onClick; } } } libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/bar/BubbleBarMenuViewController.java +1 −0 Original line number Diff line number Diff line Loading @@ -212,6 +212,7 @@ class BubbleBarMenuViewController { Icon.createWithResource(resources, R.drawable.ic_remove_no_shadow), resources.getString(R.string.bubble_dismiss_text), tintColor, BubbleBarMenuView.DISMISS_ACTION_TAG, view -> { hideMenu(true /* animated */); if (mListener != null) { Loading Loading
libs/WindowManager/Shell/multivalentTests/src/com/android/wm/shell/bubbles/bar/BubbleBarExpandedViewTest.kt +33 −1 Original line number Diff line number Diff line Loading @@ -18,6 +18,7 @@ package com.android.wm.shell.bubbles.bar import android.app.ActivityManager import android.content.Context import android.content.pm.ShortcutInfo import android.graphics.Insets import android.graphics.Rect import android.view.LayoutInflater Loading Loading @@ -45,11 +46,14 @@ import com.android.wm.shell.shared.handles.RegionSamplingHelper import com.android.wm.shell.taskview.TaskView import com.android.wm.shell.taskview.TaskViewTaskController import com.google.common.truth.Truth.assertThat import com.google.common.util.concurrent.MoreExecutors.directExecutor import org.junit.After import org.junit.Before import org.junit.Test import org.junit.runner.RunWith import org.mockito.kotlin.mock import org.mockito.kotlin.spy import org.mockito.kotlin.verify import org.mockito.kotlin.whenever import java.util.Collections import java.util.concurrent.Executor Loading @@ -72,14 +76,18 @@ class BubbleBarExpandedViewTest { private lateinit var expandedViewManager: BubbleExpandedViewManager private lateinit var positioner: BubblePositioner private lateinit var bubbleTaskView: BubbleTaskView private lateinit var bubble: Bubble private lateinit var bubbleExpandedView: BubbleBarExpandedView private var testableRegionSamplingHelper: TestableRegionSamplingHelper? = null private var regionSamplingProvider: TestRegionSamplingProvider? = null private val bubbleLogger = spy(BubbleLogger(UiEventLoggerFake())) @Before fun setUp() { ProtoLog.REQUIRE_PROTOLOGTOOL = false ProtoLog.init() mainExecutor = TestExecutor() bgExecutor = TestExecutor() positioner = BubblePositioner(context, windowManager) Loading Loading @@ -108,7 +116,7 @@ class BubbleBarExpandedViewTest { bubbleExpandedView.initialize( expandedViewManager, positioner, BubbleLogger(UiEventLoggerFake()), bubbleLogger, false /* isOverflow */, bubbleTaskView, mainExecutor, Loading @@ -121,6 +129,20 @@ class BubbleBarExpandedViewTest { // Helper should be created once attached to window testableRegionSamplingHelper = regionSamplingProvider!!.helper }) bubble = Bubble( "key", ShortcutInfo.Builder(context, "id").build(), 100 /* desiredHeight */, 0 /* desiredHeightResId */, "title", 0 /* taskId */, null /* locus */, true /* isDismissable */, directExecutor(), directExecutor() ) {} bubbleExpandedView.update(bubble) } @After Loading Loading @@ -194,6 +216,16 @@ class BubbleBarExpandedViewTest { assertThat(testableRegionSamplingHelper!!.isStopped).isTrue() } @Test fun testEventLogging_dismissBubbleViaAppMenu() { getInstrumentation().runOnMainSync { bubbleExpandedView.handleView.performClick() } val dismissMenuItem = bubbleExpandedView.findViewWithTag<View>(BubbleBarMenuView.DISMISS_ACTION_TAG) assertThat(dismissMenuItem).isNotNull() getInstrumentation().runOnMainSync { dismissMenuItem.performClick() } verify(bubbleLogger).log(bubble, BubbleLogger.Event.BUBBLE_BAR_BUBBLE_DISMISSED_APP_MENU) } private inner class FakeBubbleTaskViewFactory : BubbleTaskViewFactory { override fun create(): BubbleTaskView { val taskViewTaskController = mock<TaskViewTaskController>() Loading
libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/bar/BubbleBarExpandedView.java +1 −0 Original line number Diff line number Diff line Loading @@ -252,6 +252,7 @@ public class BubbleBarExpandedView extends FrameLayout implements BubbleTaskView @Override public void onDismissBubble(Bubble bubble) { mManager.dismissBubble(bubble, Bubbles.DISMISS_USER_GESTURE); mBubbleLogger.log(bubble, BubbleLogger.Event.BUBBLE_BAR_BUBBLE_DISMISSED_APP_MENU); } @Override Loading
libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/bar/BubbleBarMenuView.java +18 −0 Original line number Diff line number Diff line Loading @@ -16,6 +16,7 @@ package com.android.wm.shell.bubbles.bar; import android.annotation.ColorInt; import android.annotation.Nullable; import android.content.Context; import android.content.res.ColorStateList; import android.content.res.TypedArray; Loading @@ -41,6 +42,9 @@ import java.util.ArrayList; * Bubble bar expanded view menu */ public class BubbleBarMenuView extends LinearLayout { public static final Object DISMISS_ACTION_TAG = new Object(); private ViewGroup mBubbleSectionView; private ViewGroup mActionsSectionView; private ImageView mBubbleIconView; Loading Loading @@ -119,6 +123,9 @@ public class BubbleBarMenuView extends LinearLayout { R.layout.bubble_bar_menu_item, mActionsSectionView, false); itemView.update(action.mIcon, action.mTitle, action.mTint); itemView.setOnClickListener(action.mOnClick); if (action.mTag != null) { itemView.setTag(action.mTag); } mActionsSectionView.addView(itemView); } } Loading Loading @@ -159,6 +166,8 @@ public class BubbleBarMenuView extends LinearLayout { private Icon mIcon; private @ColorInt int mTint; private String mTitle; @Nullable private Object mTag; private OnClickListener mOnClick; MenuAction(Icon icon, String title, OnClickListener onClick) { Loading @@ -171,5 +180,14 @@ public class BubbleBarMenuView extends LinearLayout { this.mTint = tint; this.mOnClick = onClick; } MenuAction(Icon icon, String title, @ColorInt int tint, @Nullable Object tag, OnClickListener onClick) { this.mIcon = icon; this.mTitle = title; this.mTint = tint; this.mTag = tag; this.mOnClick = onClick; } } }
libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/bar/BubbleBarMenuViewController.java +1 −0 Original line number Diff line number Diff line Loading @@ -212,6 +212,7 @@ class BubbleBarMenuViewController { Icon.createWithResource(resources, R.drawable.ic_remove_no_shadow), resources.getString(R.string.bubble_dismiss_text), tintColor, BubbleBarMenuView.DISMISS_ACTION_TAG, view -> { hideMenu(true /* animated */); if (mListener != null) { Loading