Loading packages/SystemUI/src/com/android/systemui/statusbar/stack/NotificationChildrenContainer.java +14 −7 Original line number Diff line number Diff line Loading @@ -49,10 +49,14 @@ import java.util.List; */ public class NotificationChildrenContainer extends ViewGroup { private static final int NUMBER_OF_CHILDREN_WHEN_COLLAPSED = 2; private static final int NUMBER_OF_CHILDREN_WHEN_SYSTEM_EXPANDED = 5; private static final int NUMBER_OF_CHILDREN_WHEN_CHILDREN_EXPANDED = 8; private static final int NUMBER_OF_CHILDREN_WHEN_AMBIENT = 1; @VisibleForTesting static final int NUMBER_OF_CHILDREN_WHEN_COLLAPSED = 2; @VisibleForTesting static final int NUMBER_OF_CHILDREN_WHEN_SYSTEM_EXPANDED = 5; @VisibleForTesting static final int NUMBER_OF_CHILDREN_WHEN_CHILDREN_EXPANDED = 8; @VisibleForTesting static final int NUMBER_OF_CHILDREN_WHEN_AMBIENT = 1; private static final AnimationProperties ALPHA_FADE_IN = new AnimationProperties() { private AnimationFilter mAnimationFilter = new AnimationFilter().animateAlpha(); Loading Loading @@ -699,15 +703,18 @@ public class NotificationChildrenContainer extends ViewGroup { return childState.height != intrinsicHeight && !childState.hidden; } private int getMaxAllowedVisibleChildren() { @VisibleForTesting int getMaxAllowedVisibleChildren() { return getMaxAllowedVisibleChildren(false /* likeCollapsed */); } private int getMaxAllowedVisibleChildren(boolean likeCollapsed) { @VisibleForTesting int getMaxAllowedVisibleChildren(boolean likeCollapsed) { if (mContainingNotification.isShowingAmbient()) { return NUMBER_OF_CHILDREN_WHEN_AMBIENT; } if (!likeCollapsed && (mChildrenExpanded || mContainingNotification.isUserLocked())) { if (!likeCollapsed && (mChildrenExpanded || mContainingNotification.isUserLocked()) && !showingAsLowPriority()) { return NUMBER_OF_CHILDREN_WHEN_CHILDREN_EXPANDED; } if (mIsLowPriority || !mContainingNotification.isOnKeyguard() Loading packages/SystemUI/tests/src/com/android/systemui/statusbar/ExpandableNotificationRowTest.java +8 −0 Original line number Diff line number Diff line Loading @@ -308,4 +308,12 @@ public class ExpandableNotificationRowTest extends SysuiTestCase { mGroupRow.resetTranslation(); assertEquals(0, mGroupRow.getEntry().expandedIcon.getScrollX()); } @Test public void testIsExpanded_userExpanded() { mGroupRow.setExpandable(true); Assert.assertFalse(mGroupRow.isExpanded()); mGroupRow.setUserExpanded(true); Assert.assertTrue(mGroupRow.isExpanded()); } } packages/SystemUI/tests/src/com/android/systemui/statusbar/stack/NotificationChildrenContainerTest.java +94 −7 Original line number Diff line number Diff line Loading @@ -40,30 +40,117 @@ public class NotificationChildrenContainerTest extends SysuiTestCase { private ExpandableNotificationRow mGroup; private int mId; private NotificationTestHelper mNotificationTestHelper; private NotificationChildrenContainer mChildrenContainer; @Before public void setUp() throws Exception { mNotificationTestHelper = new NotificationTestHelper(mContext); mGroup = mNotificationTestHelper.createGroup(); mChildrenContainer = mGroup.getChildrenContainer(); } @Test public void testGetMaxAllowedVisibleChildren_ambient() { mGroup.setShowAmbient(true); Assert.assertEquals(mChildrenContainer.getMaxAllowedVisibleChildren(), NotificationChildrenContainer.NUMBER_OF_CHILDREN_WHEN_AMBIENT); } @Test public void testGetMaxAllowedVisibleChildren_lowPriority() { mChildrenContainer.setIsLowPriority(true); Assert.assertEquals(mChildrenContainer.getMaxAllowedVisibleChildren(), NotificationChildrenContainer.NUMBER_OF_CHILDREN_WHEN_SYSTEM_EXPANDED); } @Test public void testGetMaxAllowedVisibleChildren_headsUp() { mGroup.setHeadsUp(true); Assert.assertEquals(mChildrenContainer.getMaxAllowedVisibleChildren(), NotificationChildrenContainer.NUMBER_OF_CHILDREN_WHEN_SYSTEM_EXPANDED); } @Test public void testGetMaxAllowedVisibleChildren_lowPriority_expandedChildren() { mChildrenContainer.setIsLowPriority(true); mChildrenContainer.setChildrenExpanded(true); Assert.assertEquals(mChildrenContainer.getMaxAllowedVisibleChildren(), NotificationChildrenContainer.NUMBER_OF_CHILDREN_WHEN_SYSTEM_EXPANDED); } @Test public void testGetMaxAllowedVisibleChildren_lowPriority_userLocked() { mChildrenContainer.setIsLowPriority(true); mChildrenContainer.setUserLocked(true); Assert.assertEquals(mChildrenContainer.getMaxAllowedVisibleChildren(), NotificationChildrenContainer.NUMBER_OF_CHILDREN_WHEN_SYSTEM_EXPANDED); } @Test public void testGetMaxAllowedVisibleChildren_likeCollapsed() { Assert.assertEquals(mChildrenContainer.getMaxAllowedVisibleChildren(true), NotificationChildrenContainer.NUMBER_OF_CHILDREN_WHEN_COLLAPSED); } @Test public void testGetMaxAllowedVisibleChildren_expandedChildren() { mChildrenContainer.setChildrenExpanded(true); Assert.assertEquals(mChildrenContainer.getMaxAllowedVisibleChildren(), NotificationChildrenContainer.NUMBER_OF_CHILDREN_WHEN_CHILDREN_EXPANDED); } @Test public void testGetMaxAllowedVisibleChildren_userLocked() { mGroup.setUserLocked(true); Assert.assertEquals(mChildrenContainer.getMaxAllowedVisibleChildren(), NotificationChildrenContainer.NUMBER_OF_CHILDREN_WHEN_CHILDREN_EXPANDED); } @Test public void testShowingAsLowPriority_lowPriority() { mChildrenContainer.setIsLowPriority(true); Assert.assertTrue(mChildrenContainer.showingAsLowPriority()); } @Test public void testShowingAsLowPriority_notLowPriority() { Assert.assertFalse(mChildrenContainer.showingAsLowPriority()); } @Test public void testShowingAsLowPriority_lowPriority_expanded() { mChildrenContainer.setIsLowPriority(true); mGroup.setExpandable(true); mGroup.setUserExpanded(true, false); Assert.assertFalse(mChildrenContainer.showingAsLowPriority()); } @Test public void testGetMaxAllowedVisibleChildren_userLocked_expandedChildren_lowPriority() { mGroup.setUserLocked(true); mGroup.setExpandable(true); mGroup.setUserExpanded(true); mChildrenContainer.setIsLowPriority(true); Assert.assertEquals(mChildrenContainer.getMaxAllowedVisibleChildren(), NotificationChildrenContainer.NUMBER_OF_CHILDREN_WHEN_CHILDREN_EXPANDED); } @Test public void testLowPriorityHeaderCleared() { mGroup.setIsLowPriority(true); NotificationChildrenContainer childrenContainer = mGroup.getChildrenContainer(); NotificationHeaderView lowPriorityHeaderView = childrenContainer.getLowPriorityHeaderView(); NotificationHeaderView lowPriorityHeaderView = mChildrenContainer.getLowPriorityHeaderView(); Assert.assertTrue(lowPriorityHeaderView.getVisibility() == View.VISIBLE); Assert.assertTrue(lowPriorityHeaderView.getParent() == childrenContainer); Assert.assertTrue(lowPriorityHeaderView.getParent() == mChildrenContainer); mGroup.setIsLowPriority(false); Assert.assertTrue(lowPriorityHeaderView.getParent() == null); Assert.assertTrue(childrenContainer.getLowPriorityHeaderView() == null); Assert.assertTrue(mChildrenContainer.getLowPriorityHeaderView() == null); } @Test public void testRecreateNotificationHeader_hasHeader() { NotificationChildrenContainer childrenContainer = mGroup.getChildrenContainer(); childrenContainer.recreateNotificationHeader(null); mChildrenContainer.recreateNotificationHeader(null); Assert.assertNotNull("Children container must have a header after recreation", childrenContainer.getCurrentHeaderView()); mChildrenContainer.getCurrentHeaderView()); } } Loading
packages/SystemUI/src/com/android/systemui/statusbar/stack/NotificationChildrenContainer.java +14 −7 Original line number Diff line number Diff line Loading @@ -49,10 +49,14 @@ import java.util.List; */ public class NotificationChildrenContainer extends ViewGroup { private static final int NUMBER_OF_CHILDREN_WHEN_COLLAPSED = 2; private static final int NUMBER_OF_CHILDREN_WHEN_SYSTEM_EXPANDED = 5; private static final int NUMBER_OF_CHILDREN_WHEN_CHILDREN_EXPANDED = 8; private static final int NUMBER_OF_CHILDREN_WHEN_AMBIENT = 1; @VisibleForTesting static final int NUMBER_OF_CHILDREN_WHEN_COLLAPSED = 2; @VisibleForTesting static final int NUMBER_OF_CHILDREN_WHEN_SYSTEM_EXPANDED = 5; @VisibleForTesting static final int NUMBER_OF_CHILDREN_WHEN_CHILDREN_EXPANDED = 8; @VisibleForTesting static final int NUMBER_OF_CHILDREN_WHEN_AMBIENT = 1; private static final AnimationProperties ALPHA_FADE_IN = new AnimationProperties() { private AnimationFilter mAnimationFilter = new AnimationFilter().animateAlpha(); Loading Loading @@ -699,15 +703,18 @@ public class NotificationChildrenContainer extends ViewGroup { return childState.height != intrinsicHeight && !childState.hidden; } private int getMaxAllowedVisibleChildren() { @VisibleForTesting int getMaxAllowedVisibleChildren() { return getMaxAllowedVisibleChildren(false /* likeCollapsed */); } private int getMaxAllowedVisibleChildren(boolean likeCollapsed) { @VisibleForTesting int getMaxAllowedVisibleChildren(boolean likeCollapsed) { if (mContainingNotification.isShowingAmbient()) { return NUMBER_OF_CHILDREN_WHEN_AMBIENT; } if (!likeCollapsed && (mChildrenExpanded || mContainingNotification.isUserLocked())) { if (!likeCollapsed && (mChildrenExpanded || mContainingNotification.isUserLocked()) && !showingAsLowPriority()) { return NUMBER_OF_CHILDREN_WHEN_CHILDREN_EXPANDED; } if (mIsLowPriority || !mContainingNotification.isOnKeyguard() Loading
packages/SystemUI/tests/src/com/android/systemui/statusbar/ExpandableNotificationRowTest.java +8 −0 Original line number Diff line number Diff line Loading @@ -308,4 +308,12 @@ public class ExpandableNotificationRowTest extends SysuiTestCase { mGroupRow.resetTranslation(); assertEquals(0, mGroupRow.getEntry().expandedIcon.getScrollX()); } @Test public void testIsExpanded_userExpanded() { mGroupRow.setExpandable(true); Assert.assertFalse(mGroupRow.isExpanded()); mGroupRow.setUserExpanded(true); Assert.assertTrue(mGroupRow.isExpanded()); } }
packages/SystemUI/tests/src/com/android/systemui/statusbar/stack/NotificationChildrenContainerTest.java +94 −7 Original line number Diff line number Diff line Loading @@ -40,30 +40,117 @@ public class NotificationChildrenContainerTest extends SysuiTestCase { private ExpandableNotificationRow mGroup; private int mId; private NotificationTestHelper mNotificationTestHelper; private NotificationChildrenContainer mChildrenContainer; @Before public void setUp() throws Exception { mNotificationTestHelper = new NotificationTestHelper(mContext); mGroup = mNotificationTestHelper.createGroup(); mChildrenContainer = mGroup.getChildrenContainer(); } @Test public void testGetMaxAllowedVisibleChildren_ambient() { mGroup.setShowAmbient(true); Assert.assertEquals(mChildrenContainer.getMaxAllowedVisibleChildren(), NotificationChildrenContainer.NUMBER_OF_CHILDREN_WHEN_AMBIENT); } @Test public void testGetMaxAllowedVisibleChildren_lowPriority() { mChildrenContainer.setIsLowPriority(true); Assert.assertEquals(mChildrenContainer.getMaxAllowedVisibleChildren(), NotificationChildrenContainer.NUMBER_OF_CHILDREN_WHEN_SYSTEM_EXPANDED); } @Test public void testGetMaxAllowedVisibleChildren_headsUp() { mGroup.setHeadsUp(true); Assert.assertEquals(mChildrenContainer.getMaxAllowedVisibleChildren(), NotificationChildrenContainer.NUMBER_OF_CHILDREN_WHEN_SYSTEM_EXPANDED); } @Test public void testGetMaxAllowedVisibleChildren_lowPriority_expandedChildren() { mChildrenContainer.setIsLowPriority(true); mChildrenContainer.setChildrenExpanded(true); Assert.assertEquals(mChildrenContainer.getMaxAllowedVisibleChildren(), NotificationChildrenContainer.NUMBER_OF_CHILDREN_WHEN_SYSTEM_EXPANDED); } @Test public void testGetMaxAllowedVisibleChildren_lowPriority_userLocked() { mChildrenContainer.setIsLowPriority(true); mChildrenContainer.setUserLocked(true); Assert.assertEquals(mChildrenContainer.getMaxAllowedVisibleChildren(), NotificationChildrenContainer.NUMBER_OF_CHILDREN_WHEN_SYSTEM_EXPANDED); } @Test public void testGetMaxAllowedVisibleChildren_likeCollapsed() { Assert.assertEquals(mChildrenContainer.getMaxAllowedVisibleChildren(true), NotificationChildrenContainer.NUMBER_OF_CHILDREN_WHEN_COLLAPSED); } @Test public void testGetMaxAllowedVisibleChildren_expandedChildren() { mChildrenContainer.setChildrenExpanded(true); Assert.assertEquals(mChildrenContainer.getMaxAllowedVisibleChildren(), NotificationChildrenContainer.NUMBER_OF_CHILDREN_WHEN_CHILDREN_EXPANDED); } @Test public void testGetMaxAllowedVisibleChildren_userLocked() { mGroup.setUserLocked(true); Assert.assertEquals(mChildrenContainer.getMaxAllowedVisibleChildren(), NotificationChildrenContainer.NUMBER_OF_CHILDREN_WHEN_CHILDREN_EXPANDED); } @Test public void testShowingAsLowPriority_lowPriority() { mChildrenContainer.setIsLowPriority(true); Assert.assertTrue(mChildrenContainer.showingAsLowPriority()); } @Test public void testShowingAsLowPriority_notLowPriority() { Assert.assertFalse(mChildrenContainer.showingAsLowPriority()); } @Test public void testShowingAsLowPriority_lowPriority_expanded() { mChildrenContainer.setIsLowPriority(true); mGroup.setExpandable(true); mGroup.setUserExpanded(true, false); Assert.assertFalse(mChildrenContainer.showingAsLowPriority()); } @Test public void testGetMaxAllowedVisibleChildren_userLocked_expandedChildren_lowPriority() { mGroup.setUserLocked(true); mGroup.setExpandable(true); mGroup.setUserExpanded(true); mChildrenContainer.setIsLowPriority(true); Assert.assertEquals(mChildrenContainer.getMaxAllowedVisibleChildren(), NotificationChildrenContainer.NUMBER_OF_CHILDREN_WHEN_CHILDREN_EXPANDED); } @Test public void testLowPriorityHeaderCleared() { mGroup.setIsLowPriority(true); NotificationChildrenContainer childrenContainer = mGroup.getChildrenContainer(); NotificationHeaderView lowPriorityHeaderView = childrenContainer.getLowPriorityHeaderView(); NotificationHeaderView lowPriorityHeaderView = mChildrenContainer.getLowPriorityHeaderView(); Assert.assertTrue(lowPriorityHeaderView.getVisibility() == View.VISIBLE); Assert.assertTrue(lowPriorityHeaderView.getParent() == childrenContainer); Assert.assertTrue(lowPriorityHeaderView.getParent() == mChildrenContainer); mGroup.setIsLowPriority(false); Assert.assertTrue(lowPriorityHeaderView.getParent() == null); Assert.assertTrue(childrenContainer.getLowPriorityHeaderView() == null); Assert.assertTrue(mChildrenContainer.getLowPriorityHeaderView() == null); } @Test public void testRecreateNotificationHeader_hasHeader() { NotificationChildrenContainer childrenContainer = mGroup.getChildrenContainer(); childrenContainer.recreateNotificationHeader(null); mChildrenContainer.recreateNotificationHeader(null); Assert.assertNotNull("Children container must have a header after recreation", childrenContainer.getCurrentHeaderView()); mChildrenContainer.getCurrentHeaderView()); } }