Merge "Add a sysui state for manage menu being expanded" into sc-v2-dev am: a80ecceba9

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/15910586

Change-Id: I0d2ccfefc13c227f6f3997c404ef2053f2b47cd4
This commit is contained in:
Mady Mellor
2021-10-18 19:44:17 +00:00
committed by Automerger Merge Worker
7 changed files with 223 additions and 44 deletions

View File

@@ -120,8 +120,6 @@ public class BubbleStackView extends FrameLayout
private static final int EXPANDED_VIEW_ALPHA_ANIMATION_DURATION = 150;
private static final int MANAGE_MENU_SCRIM_ANIM_DURATION = 150;
private static final float SCRIM_ALPHA = 0.6f;
/**
@@ -894,6 +892,7 @@ public class BubbleStackView extends FrameLayout
updatePointerPosition(false /* forIme */);
mExpandedAnimationController.expandFromStack(() -> {
afterExpandedViewAnimation();
showManageMenu(mShowingManage);
} /* after */);
final float translationY = mPositioner.getExpandedViewY(mExpandedBubble,
getBubbleIndex(mExpandedBubble));
@@ -1253,9 +1252,6 @@ public class BubbleStackView extends FrameLayout
mRelativeStackPositionBeforeRotation = new RelativeStackPosition(
mPositioner.getRestingPosition(),
mStackAnimationController.getAllowableStackPositionRegion());
mManageMenu.setVisibility(View.INVISIBLE);
mShowingManage = false;
addOnLayoutChangeListener(mOrientationChangedListener);
hideFlyoutImmediate();
}
@@ -2555,16 +2551,19 @@ public class BubbleStackView extends FrameLayout
invalidate();
}
private void showManageMenu(boolean show) {
/** Hide or show the manage menu for the currently expanded bubble. */
@VisibleForTesting
public void showManageMenu(boolean show) {
mShowingManage = show;
// This should not happen, since the manage menu is only visible when there's an expanded
// bubble. If we end up in this state, just hide the menu immediately.
if (mExpandedBubble == null || mExpandedBubble.getExpandedView() == null) {
mManageMenu.setVisibility(View.INVISIBLE);
mManageMenuScrim.setVisibility(INVISIBLE);
mBubbleController.getSysuiProxy().onManageMenuExpandChanged(false /* show */);
return;
}
if (show) {
mManageMenuScrim.setVisibility(VISIBLE);
mManageMenuScrim.setTranslationZ(mManageMenu.getElevation() - 1f);
@@ -2576,8 +2575,8 @@ public class BubbleStackView extends FrameLayout
}
};
mBubbleController.getSysuiProxy().onManageMenuExpandChanged(show);
mManageMenuScrim.animate()
.setDuration(MANAGE_MENU_SCRIM_ANIM_DURATION)
.setInterpolator(show ? ALPHA_IN : ALPHA_OUT)
.alpha(show ? SCRIM_ALPHA : 0f)
.withEndAction(endAction)

View File

@@ -284,6 +284,8 @@ public interface Bubbles {
void onStackExpandChanged(boolean shouldExpand);
void onManageMenuExpandChanged(boolean menuExpanded);
void onUnbubbleConversation(String key);
}
}

View File

@@ -118,6 +118,8 @@ public class QuickStepContract {
public static final int SYSUI_STATE_DEVICE_DOZING = 1 << 21;
// The home feature is disabled (either by SUW/SysUI/device policy)
public static final int SYSUI_STATE_BACK_DISABLED = 1 << 22;
// The bubble stack is expanded AND the mange menu for bubbles is expanded on top of it.
public static final int SYSUI_STATE_BUBBLES_MANAGE_MENU_EXPANDED = 1 << 23;
@Retention(RetentionPolicy.SOURCE)
@IntDef({SYSUI_STATE_SCREEN_PINNING,
@@ -142,7 +144,8 @@ public class QuickStepContract {
SYSUI_STATE_MAGNIFICATION_OVERLAP,
SYSUI_STATE_IME_SWITCHER_SHOWING,
SYSUI_STATE_DEVICE_DOZING,
SYSUI_STATE_BACK_DISABLED
SYSUI_STATE_BACK_DISABLED,
SYSUI_STATE_BUBBLES_MANAGE_MENU_EXPANDED
})
public @interface SystemUiStateFlags {}
@@ -174,6 +177,8 @@ public class QuickStepContract {
str.add((flags & SYSUI_STATE_IME_SWITCHER_SHOWING) != 0 ? "ime_switcher_showing" : "");
str.add((flags & SYSUI_STATE_DEVICE_DOZING) != 0 ? "device_dozing" : "");
str.add((flags & SYSUI_STATE_BACK_DISABLED) != 0 ? "back_disabled" : "");
str.add((flags & SYSUI_STATE_BUBBLES_MANAGE_MENU_EXPANDED) != 0
? "bubbles_mange_menu_expanded" : "");
return str.toString();
}

View File

@@ -377,9 +377,23 @@ public class BubblesManager implements Dumpable {
sysuiMainExecutor.execute(() -> {
sysUiState.setFlag(QuickStepContract.SYSUI_STATE_BUBBLES_EXPANDED, shouldExpand)
.commitUpdate(mContext.getDisplayId());
if (!shouldExpand) {
sysUiState.setFlag(
QuickStepContract.SYSUI_STATE_BUBBLES_MANAGE_MENU_EXPANDED,
false).commitUpdate(mContext.getDisplayId());
}
});
}
@Override
public void onManageMenuExpandChanged(boolean menuExpanded) {
sysuiMainExecutor.execute(() -> {
sysUiState.setFlag(QuickStepContract.SYSUI_STATE_BUBBLES_MANAGE_MENU_EXPANDED,
menuExpanded).commitUpdate(mContext.getDisplayId());
});
}
@Override
public void onUnbubbleConversation(String key) {
sysuiMainExecutor.execute(() -> {

View File

@@ -20,6 +20,7 @@ import static android.view.Display.DEFAULT_DISPLAY;
import static com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_BOUNCER_SHOWING;
import static com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_BUBBLES_EXPANDED;
import static com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_BUBBLES_MANAGE_MENU_EXPANDED;
import static com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_GLOBAL_ACTIONS_SHOWING;
import static com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_NOTIFICATION_PANEL_EXPANDED;
import static com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_ONE_HANDED_ACTIVE;
@@ -101,6 +102,7 @@ public final class WMShell extends SystemUI
| SYSUI_STATE_BOUNCER_SHOWING
| SYSUI_STATE_NOTIFICATION_PANEL_EXPANDED
| SYSUI_STATE_BUBBLES_EXPANDED
| SYSUI_STATE_BUBBLES_MANAGE_MENU_EXPANDED
| SYSUI_STATE_QUICK_SETTINGS_EXPANDED;
// Shell interfaces

View File

@@ -179,6 +179,7 @@ public class BubblesTest extends SysuiTestCase {
private SysUiState mSysUiState;
private boolean mSysUiStateBubblesExpanded;
private boolean mSysUiStateBubblesManageMenuExpanded;
@Captor
private ArgumentCaptor<NotificationEntryListener> mEntryListenerCaptor;
@@ -295,9 +296,13 @@ public class BubblesTest extends SysuiTestCase {
when(mZenModeController.getConfig()).thenReturn(mZenModeConfig);
mSysUiState = new SysUiState();
mSysUiState.addCallback(sysUiFlags ->
mSysUiStateBubblesExpanded =
(sysUiFlags & QuickStepContract.SYSUI_STATE_BUBBLES_EXPANDED) != 0);
mSysUiState.addCallback(sysUiFlags -> {
mSysUiStateBubblesManageMenuExpanded =
(sysUiFlags
& QuickStepContract.SYSUI_STATE_BUBBLES_MANAGE_MENU_EXPANDED) != 0;
mSysUiStateBubblesExpanded =
(sysUiFlags & QuickStepContract.SYSUI_STATE_BUBBLES_EXPANDED) != 0;
});
// TODO: Fix
mPositioner = new TestableBubblePositioner(mContext, mWindowManager);
@@ -372,8 +377,7 @@ public class BubblesTest extends SysuiTestCase {
public void testAddBubble() {
mBubbleController.updateBubble(mBubbleEntry);
assertTrue(mBubbleController.hasBubbles());
assertFalse(mSysUiStateBubblesExpanded);
assertSysuiStates(false /* stackExpanded */, false /* mangeMenuExpanded */);
}
@Test
@@ -381,7 +385,7 @@ public class BubblesTest extends SysuiTestCase {
assertFalse(mBubbleController.hasBubbles());
mBubbleController.updateBubble(mBubbleEntry);
assertTrue(mBubbleController.hasBubbles());
assertFalse(mSysUiStateBubblesExpanded);
assertSysuiStates(false /* stackExpanded */, false /* mangeMenuExpanded */);
}
@Test
@@ -396,7 +400,7 @@ public class BubblesTest extends SysuiTestCase {
assertNull(mBubbleData.getBubbleInStackWithKey(mRow.getKey()));
verify(mNotificationEntryManager, times(2)).updateNotifications(anyString());
assertFalse(mSysUiStateBubblesExpanded);
assertSysuiStates(false /* stackExpanded */, false /* mangeMenuExpanded */);
}
@Test
@@ -459,7 +463,7 @@ public class BubblesTest extends SysuiTestCase {
verify(mNotificationEntryManager, never()).performRemoveNotification(
eq(mRow.getSbn()), any(), anyInt());
assertFalse(mBubbleController.hasBubbles());
assertFalse(mSysUiStateBubblesExpanded);
assertSysuiStates(false /* stackExpanded */, false /* mangeMenuExpanded */);
assertTrue(mRow.isBubble());
}
@@ -478,7 +482,7 @@ public class BubblesTest extends SysuiTestCase {
assertNull(mBubbleData.getBubbleInStackWithKey(mRow.getKey()));
assertNull(mBubbleData.getBubbleInStackWithKey(mRow2.getKey()));
assertFalse(mSysUiStateBubblesExpanded);
assertSysuiStates(false /* stackExpanded */, false /* mangeMenuExpanded */);
}
@Test
@@ -498,8 +502,7 @@ public class BubblesTest extends SysuiTestCase {
mBubbleData.setExpanded(true);
assertStackExpanded();
verify(mBubbleExpandListener).onBubbleExpandChanged(true, mRow.getKey());
assertTrue(mSysUiStateBubblesExpanded);
assertSysuiStates(true /* stackExpanded */, false /* mangeMenuExpanded */);
// Make sure the notif is suppressed
assertBubbleNotificationSuppressedFromShade(mBubbleEntry);
@@ -508,8 +511,7 @@ public class BubblesTest extends SysuiTestCase {
mBubbleController.collapseStack();
verify(mBubbleExpandListener).onBubbleExpandChanged(false, mRow.getKey());
assertStackCollapsed();
assertFalse(mSysUiStateBubblesExpanded);
assertSysuiStates(false /* stackExpanded */, false /* mangeMenuExpanded */);
}
@Test
@@ -532,8 +534,7 @@ public class BubblesTest extends SysuiTestCase {
assertStackExpanded();
verify(mBubbleExpandListener, atLeastOnce()).onBubbleExpandChanged(
true, mRow2.getKey());
assertTrue(mSysUiStateBubblesExpanded);
assertSysuiStates(true /* stackExpanded */, false /* mangeMenuExpanded */);
// Last added is the one that is expanded
assertEquals(mRow2.getKey(), mBubbleData.getSelectedBubble().getKey());
@@ -557,8 +558,7 @@ public class BubblesTest extends SysuiTestCase {
// Collapse
mBubbleController.collapseStack();
assertStackCollapsed();
assertFalse(mSysUiStateBubblesExpanded);
assertSysuiStates(false /* stackExpanded */, false /* mangeMenuExpanded */);
}
@Test
@@ -578,8 +578,7 @@ public class BubblesTest extends SysuiTestCase {
mBubbleData.setExpanded(true);
assertStackExpanded();
verify(mBubbleExpandListener).onBubbleExpandChanged(true, mRow.getKey());
assertTrue(mSysUiStateBubblesExpanded);
assertSysuiStates(true /* stackExpanded */, false /* mangeMenuExpanded */);
// Notif is suppressed after expansion
assertBubbleNotificationSuppressedFromShade(mBubbleEntry);
@@ -604,8 +603,7 @@ public class BubblesTest extends SysuiTestCase {
mBubbleData.setExpanded(true);
assertStackExpanded();
verify(mBubbleExpandListener).onBubbleExpandChanged(true, mRow.getKey());
assertTrue(mSysUiStateBubblesExpanded);
assertSysuiStates(true /* stackExpanded */, false /* mangeMenuExpanded */);
// Notif is suppressed after expansion
assertBubbleNotificationSuppressedFromShade(mBubbleEntry);
@@ -634,7 +632,7 @@ public class BubblesTest extends SysuiTestCase {
BubbleStackView stackView = mBubbleController.getStackView();
mBubbleData.setExpanded(true);
assertTrue(mSysUiStateBubblesExpanded);
assertSysuiStates(true /* stackExpanded */, false /* mangeMenuExpanded */);
assertStackExpanded();
verify(mBubbleExpandListener).onBubbleExpandChanged(true, mRow2.getKey());
@@ -666,7 +664,7 @@ public class BubblesTest extends SysuiTestCase {
assertEquals(mBubbleData.getSelectedBubble().getKey(), BubbleOverflow.KEY);
verify(mBubbleExpandListener).onBubbleExpandChanged(true, BubbleOverflow.KEY);
assertTrue(mBubbleController.hasBubbles());
assertTrue(mSysUiStateBubblesExpanded);
assertSysuiStates(true /* stackExpanded */, false /* mangeMenuExpanded */);
}
@Test
@@ -679,7 +677,7 @@ public class BubblesTest extends SysuiTestCase {
BubbleStackView stackView = mBubbleController.getStackView();
mBubbleData.setExpanded(true);
assertTrue(mSysUiStateBubblesExpanded);
assertSysuiStates(true /* stackExpanded */, false /* mangeMenuExpanded */);
assertStackExpanded();
verify(mBubbleExpandListener).onBubbleExpandChanged(true, mRow.getKey());
@@ -694,7 +692,7 @@ public class BubblesTest extends SysuiTestCase {
// We should be collapsed
verify(mBubbleExpandListener).onBubbleExpandChanged(false, mRow.getKey());
assertFalse(mBubbleController.hasBubbles());
assertFalse(mSysUiStateBubblesExpanded);
assertSysuiStates(false /* stackExpanded */, false /* mangeMenuExpanded */);
}
@Test
@@ -711,8 +709,7 @@ public class BubblesTest extends SysuiTestCase {
verify(mBubbleExpandListener, never()).onBubbleExpandChanged(false /* expanded */,
mRow.getKey());
assertStackCollapsed();
assertFalse(mSysUiStateBubblesExpanded);
assertSysuiStates(false /* stackExpanded */, false /* mangeMenuExpanded */);
}
@Test
@@ -728,8 +725,7 @@ public class BubblesTest extends SysuiTestCase {
verify(mBubbleExpandListener).onBubbleExpandChanged(true /* expanded */,
mRow.getKey());
assertStackExpanded();
assertTrue(mSysUiStateBubblesExpanded);
assertSysuiStates(true /* stackExpanded */, false /* mangeMenuExpanded */);
}
@Test
@@ -746,8 +742,7 @@ public class BubblesTest extends SysuiTestCase {
// Dot + flyout is hidden because notif is suppressed
assertFalse(mBubbleData.getBubbleInStackWithKey(mRow.getKey()).showDot());
assertFalse(mBubbleData.getBubbleInStackWithKey(mRow.getKey()).showFlyout());
assertFalse(mSysUiStateBubblesExpanded);
assertSysuiStates(false /* stackExpanded */, false /* mangeMenuExpanded */);
}
@Test
@@ -769,8 +764,7 @@ public class BubblesTest extends SysuiTestCase {
// Dot + flyout is hidden because notif is suppressed
assertFalse(mBubbleData.getBubbleInStackWithKey(mRow.getKey()).showDot());
assertFalse(mBubbleData.getBubbleInStackWithKey(mRow.getKey()).showFlyout());
assertFalse(mSysUiStateBubblesExpanded);
assertSysuiStates(false /* stackExpanded */, false /* mangeMenuExpanded */);
}
@Test
@@ -784,7 +778,7 @@ public class BubblesTest extends SysuiTestCase {
mBubbleController.expandStackAndSelectBubble(mBubbleEntry);
assertTrue(mSysUiStateBubblesExpanded);
assertSysuiStates(true /* stackExpanded */, false /* mangeMenuExpanded */);
}
@Test
@@ -1206,6 +1200,63 @@ public class BubblesTest extends SysuiTestCase {
assertNotNull(info);
}
@Test
public void testShowManageMenuChangesSysuiState() {
mBubbleController.updateBubble(mBubbleEntry);
assertTrue(mBubbleController.hasBubbles());
// Expand the stack
BubbleStackView stackView = mBubbleController.getStackView();
mBubbleData.setExpanded(true);
assertStackExpanded();
assertSysuiStates(true /* stackExpanded */, false /* mangeMenuExpanded */);
// Show the menu
stackView.showManageMenu(true);
assertSysuiStates(true /* stackExpanded */, true /* mangeMenuExpanded */);
}
@Test
public void testHideManageMenuChangesSysuiState() {
mBubbleController.updateBubble(mBubbleEntry);
assertTrue(mBubbleController.hasBubbles());
// Expand the stack
BubbleStackView stackView = mBubbleController.getStackView();
mBubbleData.setExpanded(true);
assertStackExpanded();
assertSysuiStates(true /* stackExpanded */, false /* mangeMenuExpanded */);
// Show the menu
stackView.showManageMenu(true);
assertSysuiStates(true /* stackExpanded */, true /* mangeMenuExpanded */);
// Hide the menu
stackView.showManageMenu(false);
assertSysuiStates(true /* stackExpanded */, false /* mangeMenuExpanded */);
}
@Test
public void testCollapseBubbleManageMenuChangesSysuiState() {
mBubbleController.updateBubble(mBubbleEntry);
assertTrue(mBubbleController.hasBubbles());
// Expand the stack
BubbleStackView stackView = mBubbleController.getStackView();
mBubbleData.setExpanded(true);
assertStackExpanded();
assertSysuiStates(true /* stackExpanded */, false /* mangeMenuExpanded */);
// Show the menu
stackView.showManageMenu(true);
assertSysuiStates(true /* stackExpanded */, true /* mangeMenuExpanded */);
// Collapse the stack
mBubbleData.setExpanded(false);
assertSysuiStates(false /* stackExpanded */, false /* mangeMenuExpanded */);
}
/** Creates a bubble using the userId and package. */
private Bubble createBubble(int userId, String pkg) {
final UserHandle userHandle = new UserHandle(userId);
@@ -1303,4 +1354,12 @@ public class BubblesTest extends SysuiTestCase {
assertFalse(mBubbleController.getImplCachedState().isBubbleNotificationSuppressedFromShade(
entry.getKey(), entry.getGroupKey()));
}
/**
* Asserts that the system ui states associated to bubbles are in the correct state.
*/
private void assertSysuiStates(boolean stackExpanded, boolean manageMenuExpanded) {
assertThat(mSysUiStateBubblesExpanded).isEqualTo(stackExpanded);
assertThat(mSysUiStateBubblesManageMenuExpanded).isEqualTo(manageMenuExpanded);
}
}

View File

@@ -68,6 +68,7 @@ import com.android.systemui.flags.FeatureFlags;
import com.android.systemui.keyguard.KeyguardViewMediator;
import com.android.systemui.model.SysUiState;
import com.android.systemui.plugins.statusbar.StatusBarStateController;
import com.android.systemui.shared.system.QuickStepContract;
import com.android.systemui.statusbar.NotificationLockscreenUserManager;
import com.android.systemui.statusbar.RankingBuilder;
import com.android.systemui.statusbar.SysuiStatusBarStateController;
@@ -160,7 +161,9 @@ public class NewNotifPipelineBubblesTest extends SysuiTestCase {
@Mock
private AuthController mAuthController;
private SysUiState mSysUiState = new SysUiState();
private SysUiState mSysUiState;
private boolean mSysUiStateBubblesExpanded;
private boolean mSysUiStateBubblesManageMenuExpanded;
@Captor
private ArgumentCaptor<NotifCollectionListener> mNotifListenerCaptor;
@@ -257,6 +260,15 @@ public class NewNotifPipelineBubblesTest extends SysuiTestCase {
mZenModeConfig.suppressedVisualEffects = 0;
when(mZenModeController.getConfig()).thenReturn(mZenModeConfig);
mSysUiState = new SysUiState();
mSysUiState.addCallback(sysUiFlags -> {
mSysUiStateBubblesManageMenuExpanded =
(sysUiFlags
& QuickStepContract.SYSUI_STATE_BUBBLES_MANAGE_MENU_EXPANDED) != 0;
mSysUiStateBubblesExpanded =
(sysUiFlags & QuickStepContract.SYSUI_STATE_BUBBLES_EXPANDED) != 0;
});
mPositioner = new TestableBubblePositioner(mContext, mWindowManager);
mPositioner.setMaxBubbles(5);
mBubbleData = new BubbleData(mContext, mBubbleLogger, mPositioner, syncExecutor);
@@ -325,6 +337,7 @@ public class NewNotifPipelineBubblesTest extends SysuiTestCase {
public void testAddBubble() {
mBubbleController.updateBubble(mBubbleEntry);
assertTrue(mBubbleController.hasBubbles());
assertSysuiStates(false /* stackExpanded */, false /* mangeMenuExpanded */);
}
@Test
@@ -332,6 +345,7 @@ public class NewNotifPipelineBubblesTest extends SysuiTestCase {
assertFalse(mBubbleController.hasBubbles());
mBubbleController.updateBubble(mBubbleEntry);
assertTrue(mBubbleController.hasBubbles());
assertSysuiStates(false /* stackExpanded */, false /* mangeMenuExpanded */);
}
@Test
@@ -345,6 +359,8 @@ public class NewNotifPipelineBubblesTest extends SysuiTestCase {
mRow.getKey(), Bubbles.DISMISS_USER_GESTURE);
assertNull(mBubbleData.getBubbleInStackWithKey(mRow.getKey()));
verify(mNotifCallback, times(2)).invalidateNotifications(anyString());
assertSysuiStates(false /* stackExpanded */, false /* mangeMenuExpanded */);
}
@Test
@@ -407,6 +423,8 @@ public class NewNotifPipelineBubblesTest extends SysuiTestCase {
verify(mNotifCallback, times(3)).invalidateNotifications(anyString());
assertNull(mBubbleData.getBubbleInStackWithKey(mRow.getKey()));
assertNull(mBubbleData.getBubbleInStackWithKey(mRow2.getKey()));
assertSysuiStates(false /* stackExpanded */, false /* mangeMenuExpanded */);
}
@Test
@@ -425,6 +443,7 @@ public class NewNotifPipelineBubblesTest extends SysuiTestCase {
mBubbleData.setExpanded(true);
assertStackExpanded();
verify(mBubbleExpandListener).onBubbleExpandChanged(true, mRow.getKey());
assertSysuiStates(true /* stackExpanded */, false /* mangeMenuExpanded */);
// Make sure the notif is suppressed
assertBubbleNotificationSuppressedFromShade(mBubbleEntry);
@@ -433,6 +452,7 @@ public class NewNotifPipelineBubblesTest extends SysuiTestCase {
mBubbleController.collapseStack();
verify(mBubbleExpandListener).onBubbleExpandChanged(false, mRow.getKey());
assertStackCollapsed();
assertSysuiStates(false /* stackExpanded */, false /* mangeMenuExpanded */);
}
@Test
@@ -455,6 +475,7 @@ public class NewNotifPipelineBubblesTest extends SysuiTestCase {
assertStackExpanded();
verify(mBubbleExpandListener, atLeastOnce()).onBubbleExpandChanged(
true, mRow2.getKey());
assertSysuiStates(true /* stackExpanded */, false /* mangeMenuExpanded */);
// Last added is the one that is expanded
assertEquals(mRow2.getKey(), mBubbleData.getSelectedBubble().getKey());
@@ -479,6 +500,7 @@ public class NewNotifPipelineBubblesTest extends SysuiTestCase {
// Collapse
mBubbleController.collapseStack();
assertStackCollapsed();
assertSysuiStates(false /* stackExpanded */, false /* mangeMenuExpanded */);
}
@Test
@@ -498,6 +520,7 @@ public class NewNotifPipelineBubblesTest extends SysuiTestCase {
mBubbleData.setExpanded(true);
assertStackExpanded();
verify(mBubbleExpandListener).onBubbleExpandChanged(true, mRow.getKey());
assertSysuiStates(true /* stackExpanded */, false /* mangeMenuExpanded */);
// Notif is suppressed after expansion
assertBubbleNotificationSuppressedFromShade(mBubbleEntry);
@@ -522,6 +545,7 @@ public class NewNotifPipelineBubblesTest extends SysuiTestCase {
mBubbleData.setExpanded(true);
assertStackExpanded();
verify(mBubbleExpandListener).onBubbleExpandChanged(true, mRow.getKey());
assertSysuiStates(true /* stackExpanded */, false /* mangeMenuExpanded */);
// Notif is suppressed after expansion
assertBubbleNotificationSuppressedFromShade(mBubbleEntry);
@@ -550,6 +574,8 @@ public class NewNotifPipelineBubblesTest extends SysuiTestCase {
BubbleStackView stackView = mBubbleController.getStackView();
mBubbleData.setExpanded(true);
assertSysuiStates(true /* stackExpanded */, false /* mangeMenuExpanded */);
assertStackExpanded();
verify(mBubbleExpandListener).onBubbleExpandChanged(true, mRow2.getKey());
@@ -580,6 +606,7 @@ public class NewNotifPipelineBubblesTest extends SysuiTestCase {
assertEquals(mBubbleData.getSelectedBubble().getKey(), BubbleOverflow.KEY);
verify(mBubbleExpandListener).onBubbleExpandChanged(true, BubbleOverflow.KEY);
assertTrue(mBubbleController.hasBubbles());
assertSysuiStates(true /* stackExpanded */, false /* mangeMenuExpanded */);
}
@Test
@@ -592,6 +619,7 @@ public class NewNotifPipelineBubblesTest extends SysuiTestCase {
BubbleStackView stackView = mBubbleController.getStackView();
mBubbleData.setExpanded(true);
assertSysuiStates(true /* stackExpanded */, false /* mangeMenuExpanded */);
assertStackExpanded();
verify(mBubbleExpandListener).onBubbleExpandChanged(true, mRow.getKey());
@@ -606,6 +634,7 @@ public class NewNotifPipelineBubblesTest extends SysuiTestCase {
// We should be collapsed
verify(mBubbleExpandListener).onBubbleExpandChanged(false, mRow.getKey());
assertFalse(mBubbleController.hasBubbles());
assertSysuiStates(false /* stackExpanded */, false /* mangeMenuExpanded */);
}
@@ -623,6 +652,7 @@ public class NewNotifPipelineBubblesTest extends SysuiTestCase {
verify(mBubbleExpandListener, never()).onBubbleExpandChanged(false /* expanded */,
mRow.getKey());
assertStackCollapsed();
assertSysuiStates(false /* stackExpanded */, false /* mangeMenuExpanded */);
}
@Test
@@ -638,6 +668,7 @@ public class NewNotifPipelineBubblesTest extends SysuiTestCase {
verify(mBubbleExpandListener).onBubbleExpandChanged(true /* expanded */,
mRow.getKey());
assertStackExpanded();
assertSysuiStates(true /* stackExpanded */, false /* mangeMenuExpanded */);
}
@Test
@@ -654,6 +685,7 @@ public class NewNotifPipelineBubblesTest extends SysuiTestCase {
// Dot + flyout is hidden because notif is suppressed
assertFalse(mBubbleData.getBubbleInStackWithKey(mRow.getKey()).showDot());
assertFalse(mBubbleData.getBubbleInStackWithKey(mRow.getKey()).showFlyout());
assertSysuiStates(false /* stackExpanded */, false /* mangeMenuExpanded */);
}
@Test
@@ -675,6 +707,7 @@ public class NewNotifPipelineBubblesTest extends SysuiTestCase {
// Dot + flyout is hidden because notif is suppressed
assertFalse(mBubbleData.getBubbleInStackWithKey(mRow.getKey()).showDot());
assertFalse(mBubbleData.getBubbleInStackWithKey(mRow.getKey()).showFlyout());
assertSysuiStates(false /* stackExpanded */, false /* mangeMenuExpanded */);
}
@Test
@@ -980,6 +1013,63 @@ public class NewNotifPipelineBubblesTest extends SysuiTestCase {
verify(mDataRepository, times(1)).loadBubbles(anyInt(), any());
}
@Test
public void testShowManageMenuChangesSysuiState() {
mBubbleController.updateBubble(mBubbleEntry);
assertTrue(mBubbleController.hasBubbles());
// Expand the stack
BubbleStackView stackView = mBubbleController.getStackView();
mBubbleData.setExpanded(true);
assertStackExpanded();
assertSysuiStates(true /* stackExpanded */, false /* mangeMenuExpanded */);
// Show the menu
stackView.showManageMenu(true);
assertSysuiStates(true /* stackExpanded */, true /* mangeMenuExpanded */);
}
@Test
public void testHideManageMenuChangesSysuiState() {
mBubbleController.updateBubble(mBubbleEntry);
assertTrue(mBubbleController.hasBubbles());
// Expand the stack
BubbleStackView stackView = mBubbleController.getStackView();
mBubbleData.setExpanded(true);
assertStackExpanded();
assertSysuiStates(true /* stackExpanded */, false /* mangeMenuExpanded */);
// Show the menu
stackView.showManageMenu(true);
assertSysuiStates(true /* stackExpanded */, true /* mangeMenuExpanded */);
// Hide the menu
stackView.showManageMenu(false);
assertSysuiStates(true /* stackExpanded */, false /* mangeMenuExpanded */);
}
@Test
public void testCollapseBubbleManageMenuChangesSysuiState() {
mBubbleController.updateBubble(mBubbleEntry);
assertTrue(mBubbleController.hasBubbles());
// Expand the stack
BubbleStackView stackView = mBubbleController.getStackView();
mBubbleData.setExpanded(true);
assertStackExpanded();
assertSysuiStates(true /* stackExpanded */, false /* mangeMenuExpanded */);
// Show the menu
stackView.showManageMenu(true);
assertSysuiStates(true /* stackExpanded */, true /* mangeMenuExpanded */);
// Collapse the stack
mBubbleData.setExpanded(false);
assertSysuiStates(false /* stackExpanded */, false /* mangeMenuExpanded */);
}
/**
* Sets the bubble metadata flags for this entry. These flags are normally set by
* NotificationManagerService when the notification is sent, however, these tests do not
@@ -1034,4 +1124,12 @@ public class NewNotifPipelineBubblesTest extends SysuiTestCase {
assertFalse(mBubbleController.getImplCachedState().isBubbleNotificationSuppressedFromShade(
entry.getKey(), entry.getGroupKey()));
}
/**
* Asserts that the system ui states associated to bubbles are in the correct state.
*/
private void assertSysuiStates(boolean stackExpanded, boolean manageMenuExpanded) {
assertThat(mSysUiStateBubblesExpanded).isEqualTo(stackExpanded);
assertThat(mSysUiStateBubblesManageMenuExpanded).isEqualTo(manageMenuExpanded);
}
}