Don't let everyone reach into NotificationData.Entry for its row
Test: atest SystemUITests
Change-Id: I0b4b66769afcf39c35800d293c22263e31790788
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/HeadsUpAppearanceControllerTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/HeadsUpAppearanceControllerTest.java
index 10b0d83..c99e766 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/HeadsUpAppearanceControllerTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/HeadsUpAppearanceControllerTest.java
@@ -81,12 +81,12 @@
mFirst.setPinned(true);
when(mHeadsUpManager.hasPinnedHeadsUp()).thenReturn(true);
when(mHeadsUpManager.getTopEntry()).thenReturn(mFirst.getEntry());
- mHeadsUpAppearanceController.onHeadsUpPinned(mFirst);
+ mHeadsUpAppearanceController.onHeadsUpPinned(mFirst.getEntry());
Assert.assertEquals(mFirst.getEntry(), mHeadsUpStatusBarView.getShowingEntry());
mFirst.setPinned(false);
when(mHeadsUpManager.hasPinnedHeadsUp()).thenReturn(false);
- mHeadsUpAppearanceController.onHeadsUpUnPinned(mFirst);
+ mHeadsUpAppearanceController.onHeadsUpUnPinned(mFirst.getEntry());
Assert.assertEquals(null, mHeadsUpStatusBarView.getShowingEntry());
}
@@ -95,12 +95,12 @@
mFirst.setPinned(true);
when(mHeadsUpManager.hasPinnedHeadsUp()).thenReturn(true);
when(mHeadsUpManager.getTopEntry()).thenReturn(mFirst.getEntry());
- mHeadsUpAppearanceController.onHeadsUpPinned(mFirst);
+ mHeadsUpAppearanceController.onHeadsUpPinned(mFirst.getEntry());
Assert.assertTrue(mHeadsUpAppearanceController.isShown());
mFirst.setPinned(false);
when(mHeadsUpManager.hasPinnedHeadsUp()).thenReturn(false);
- mHeadsUpAppearanceController.onHeadsUpUnPinned(mFirst);
+ mHeadsUpAppearanceController.onHeadsUpUnPinned(mFirst.getEntry());
Assert.assertFalse(mHeadsUpAppearanceController.isShown());
}
@@ -109,12 +109,12 @@
mFirst.setPinned(true);
when(mHeadsUpManager.hasPinnedHeadsUp()).thenReturn(true);
when(mHeadsUpManager.getTopEntry()).thenReturn(mFirst.getEntry());
- mHeadsUpAppearanceController.onHeadsUpPinned(mFirst);
+ mHeadsUpAppearanceController.onHeadsUpPinned(mFirst.getEntry());
Assert.assertEquals(mFirst.getHeaderVisibleAmount(), 0.0f, 0.0f);
mFirst.setPinned(false);
when(mHeadsUpManager.hasPinnedHeadsUp()).thenReturn(false);
- mHeadsUpAppearanceController.onHeadsUpUnPinned(mFirst);
+ mHeadsUpAppearanceController.onHeadsUpUnPinned(mFirst.getEntry());
Assert.assertEquals(mFirst.getHeaderVisibleAmount(), 1.0f, 0.0f);
}
@@ -125,12 +125,12 @@
mFirst.setPinned(true);
when(mHeadsUpManager.hasPinnedHeadsUp()).thenReturn(true);
when(mHeadsUpManager.getTopEntry()).thenReturn(mFirst.getEntry());
- mHeadsUpAppearanceController.onHeadsUpPinned(mFirst);
+ mHeadsUpAppearanceController.onHeadsUpPinned(mFirst.getEntry());
Assert.assertEquals(View.INVISIBLE, mOperatorNameView.getVisibility());
mFirst.setPinned(false);
when(mHeadsUpManager.hasPinnedHeadsUp()).thenReturn(false);
- mHeadsUpAppearanceController.onHeadsUpUnPinned(mFirst);
+ mHeadsUpAppearanceController.onHeadsUpUnPinned(mFirst.getEntry());
Assert.assertEquals(View.VISIBLE, mOperatorNameView.getVisibility());
}
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/HeadsUpManagerPhoneTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/HeadsUpManagerPhoneTest.java
index 1070795..44deb10 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/HeadsUpManagerPhoneTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/HeadsUpManagerPhoneTest.java
@@ -97,7 +97,7 @@
@Test
public void testCanRemoveImmediately_notTopEntry() {
NotificationData.Entry laterEntry = new NotificationData.Entry(createNewNotification(1));
- laterEntry.row = mRow;
+ laterEntry.setRow(mRow);
mHeadsUpManager.showNotification(mEntry);
mHeadsUpManager.showNotification(laterEntry);
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/NotificationGroupAlertTransferHelperTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/NotificationGroupAlertTransferHelperTest.java
index 96c57f2..c3bc511 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/NotificationGroupAlertTransferHelperTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/NotificationGroupAlertTransferHelperTest.java
@@ -149,7 +149,8 @@
Entry summaryEntry = mGroupTestHelper.createSummaryNotification();
mHeadsUpManager.showNotification(summaryEntry);
Entry childEntry = mGroupTestHelper.createChildNotification();
- when(childEntry.row.isInflationFlagSet(mHeadsUpManager.getContentFlag())).thenReturn(false);
+ when(childEntry.getRow().isInflationFlagSet(mHeadsUpManager.getContentFlag()))
+ .thenReturn(false);
mGroupManager.onEntryAdded(summaryEntry);
mGroupManager.onEntryAdded(childEntry);
@@ -166,12 +167,14 @@
Entry summaryEntry = mGroupTestHelper.createSummaryNotification();
mHeadsUpManager.showNotification(summaryEntry);
Entry childEntry = mGroupTestHelper.createChildNotification();
- when(childEntry.row.isInflationFlagSet(mHeadsUpManager.getContentFlag())).thenReturn(false);
+ when(childEntry.getRow().isInflationFlagSet(mHeadsUpManager.getContentFlag()))
+ .thenReturn(false);
mGroupManager.onEntryAdded(summaryEntry);
mGroupManager.onEntryAdded(childEntry);
- when(childEntry.row.isInflationFlagSet(mHeadsUpManager.getContentFlag())).thenReturn(true);
+ when(childEntry.getRow().isInflationFlagSet(mHeadsUpManager.getContentFlag()))
+ .thenReturn(true);
mGroupAlertTransferHelper.onInflationFinished(childEntry);
// Alert is immediately removed from summary, and we show child as its content is inflated.
@@ -185,7 +188,8 @@
mGroupTestHelper.createSummaryNotification(Notification.GROUP_ALERT_SUMMARY);
NotificationData.Entry childEntry =
mGroupTestHelper.createChildNotification(Notification.GROUP_ALERT_SUMMARY);
- when(childEntry.row.isInflationFlagSet(mHeadsUpManager.getContentFlag())).thenReturn(false);
+ when(childEntry.getRow().isInflationFlagSet(mHeadsUpManager.getContentFlag()))
+ .thenReturn(false);
NotificationData.Entry childEntry2 =
mGroupTestHelper.createChildNotification(Notification.GROUP_ALERT_SUMMARY);
mHeadsUpManager.showNotification(summaryEntry);
@@ -199,10 +203,12 @@
mGroupManager.onEntryAdded(childEntry2);
// Child entry finishes its inflation.
- when(childEntry.row.isInflationFlagSet(mHeadsUpManager.getContentFlag())).thenReturn(true);
+ when(childEntry.getRow().isInflationFlagSet(mHeadsUpManager.getContentFlag()))
+ .thenReturn(true);
mGroupAlertTransferHelper.onInflationFinished(childEntry);
- verify(childEntry.row, times(1)).freeContentViewWhenSafe(mHeadsUpManager.getContentFlag());
+ verify(childEntry.getRow(), times(1)).freeContentViewWhenSafe(mHeadsUpManager
+ .getContentFlag());
assertFalse(mHeadsUpManager.isAlerting(childEntry.key));
}
@@ -212,7 +218,8 @@
mGroupTestHelper.createSummaryNotification(Notification.GROUP_ALERT_SUMMARY);
NotificationData.Entry childEntry =
mGroupTestHelper.createChildNotification(Notification.GROUP_ALERT_SUMMARY);
- when(childEntry.row.isInflationFlagSet(mHeadsUpManager.getContentFlag())).thenReturn(false);
+ when(childEntry.getRow().isInflationFlagSet(mHeadsUpManager.getContentFlag()))
+ .thenReturn(false);
mHeadsUpManager.showNotification(summaryEntry);
// Trigger a transfer of alert state from summary to child.
mGroupManager.onEntryAdded(summaryEntry);
@@ -229,7 +236,8 @@
mGroupTestHelper.createSummaryNotification(Notification.GROUP_ALERT_SUMMARY);
NotificationData.Entry childEntry =
mGroupTestHelper.createChildNotification(Notification.GROUP_ALERT_SUMMARY);
- when(childEntry.row.isInflationFlagSet(mHeadsUpManager.getContentFlag())).thenReturn(false);
+ when(childEntry.getRow().isInflationFlagSet(mHeadsUpManager.getContentFlag()))
+ .thenReturn(false);
mHeadsUpManager.showNotification(summaryEntry);
// Trigger a transfer of alert state from summary to child.
mGroupManager.onEntryAdded(summaryEntry);
@@ -251,7 +259,8 @@
mGroupTestHelper.createSummaryNotification(Notification.GROUP_ALERT_SUMMARY);
NotificationData.Entry childEntry =
mGroupTestHelper.createChildNotification(Notification.GROUP_ALERT_SUMMARY);
- when(childEntry.row.isInflationFlagSet(mHeadsUpManager.getContentFlag())).thenReturn(false);
+ when(childEntry.getRow().isInflationFlagSet(mHeadsUpManager.getContentFlag()))
+ .thenReturn(false);
mHeadsUpManager.showNotification(summaryEntry);
// Trigger a transfer of alert state from summary to child.
mGroupManager.onEntryAdded(summaryEntry);
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/NotificationGroupManagerTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/NotificationGroupManagerTest.java
index 1483ae5..b0bd1fb 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/NotificationGroupManagerTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/NotificationGroupManagerTest.java
@@ -100,7 +100,7 @@
mGroupManager.onEntryAdded(mGroupTestHelper.createChildNotification());
assertTrue(mGroupManager.isSummaryOfGroup(summaryEntry.notification));
- assertEquals(summaryEntry.row, mGroupManager.getGroupSummary(childEntry.notification));
+ assertEquals(summaryEntry, mGroupManager.getGroupSummary(childEntry.notification));
}
@Test
@@ -143,9 +143,8 @@
// Child entries that are heads upped should be considered separate groups visually even if
// they are the same group logically
- assertEquals(childEntry.row, mGroupManager.getGroupSummary(childEntry.notification));
- assertEquals(summaryEntry.row,
- mGroupManager.getLogicalGroupSummary(childEntry.notification));
+ assertEquals(childEntry, mGroupManager.getGroupSummary(childEntry.notification));
+ assertEquals(summaryEntry, mGroupManager.getLogicalGroupSummary(childEntry.notification));
}
@Test
@@ -161,8 +160,7 @@
// Child entries that are heads upped should be considered separate groups visually even if
// they are the same group logically
- assertEquals(childEntry.row, mGroupManager.getGroupSummary(childEntry.notification));
- assertEquals(summaryEntry.row,
- mGroupManager.getLogicalGroupSummary(childEntry.notification));
+ assertEquals(childEntry, mGroupManager.getGroupSummary(childEntry.notification));
+ assertEquals(summaryEntry, mGroupManager.getLogicalGroupSummary(childEntry.notification));
}
}
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/NotificationGroupTestHelper.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/NotificationGroupTestHelper.java
index 01f44fd4..7ad68eb 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/NotificationGroupTestHelper.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/NotificationGroupTestHelper.java
@@ -81,7 +81,7 @@
0 /* postTime */);
NotificationData.Entry entry = new NotificationData.Entry(sbn);
ExpandableNotificationRow row = mock(ExpandableNotificationRow.class);
- entry.row = row;
+ entry.setRow(row);
when(row.getEntry()).thenReturn(entry);
when(row.getStatusBarNotification()).thenReturn(sbn);
when(row.isInflationFlagSet(anyInt())).thenReturn(true);