Loading packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/policy/BaseHeadsUpManagerTest.java +30 −60 Original line number Diff line number Diff line Loading @@ -212,41 +212,6 @@ public class BaseHeadsUpManagerTest extends SysuiTestCase { } } protected StatusBarNotification createSbn(int id, Notification n) { return new StatusBarNotification( TEST_PACKAGE_NAME /* pkg */, TEST_PACKAGE_NAME, id, null /* tag */, TEST_UID, 0 /* initialPid */, n, new UserHandle(ActivityManager.getCurrentUser()), null /* overrideGroupKey */, 0 /* postTime */); } protected StatusBarNotification createSbn(int id, Notification.Builder n) { return createSbn(id, n.build()); } protected StatusBarNotification createSbn(int id) { final Notification.Builder b = new Notification.Builder(mContext, "") .setSmallIcon(R.drawable.ic_person) .setContentTitle("Title") .setContentText("Text"); return createSbn(id, b); } protected NotificationEntry createEntry(int id, Notification n) { return new NotificationEntryBuilder().setSbn(createSbn(id, n)).build(); } protected NotificationEntry createEntry(int id) { return new NotificationEntryBuilder().setSbn(createSbn(id)).build(); } private BaseHeadsUpManager createHeadsUpManager() { return new TestableHeadsUpManager(mContext, mLogger, mExecutor, mGlobalSettings, mSystemClock, mAccessibilityMgr, mUiEventLoggerFake); Loading @@ -257,7 +222,7 @@ public class BaseHeadsUpManagerTest extends SysuiTestCase { .setSmallIcon(R.drawable.ic_person) .setFullScreenIntent(mock(PendingIntent.class), /* highPriority */ true) .build(); return createEntry(id, notif); return HeadsUpManagerTestUtil.createEntry(id, notif); } private NotificationEntry createStickyForSomeTimeEntry(int id) { Loading @@ -265,7 +230,7 @@ public class BaseHeadsUpManagerTest extends SysuiTestCase { .setSmallIcon(R.drawable.ic_person) .setFlag(FLAG_FSI_REQUESTED_BUT_DENIED, true) .build(); return createEntry(id, notif); return HeadsUpManagerTestUtil.createEntry(id, notif); } private PendingIntent createFullScreenIntent() { Loading @@ -279,7 +244,7 @@ public class BaseHeadsUpManagerTest extends SysuiTestCase { .setSmallIcon(R.drawable.ic_person) .setFullScreenIntent(createFullScreenIntent(), /* highPriority */ true) .build(); return createEntry(id, notif); return HeadsUpManagerTestUtil.createEntry(id, notif); } Loading @@ -296,7 +261,7 @@ public class BaseHeadsUpManagerTest extends SysuiTestCase { @Test public void testShowNotification_addsEntry() { final BaseHeadsUpManager alm = createHeadsUpManager(); final NotificationEntry entry = createEntry(/* id = */ 0); final NotificationEntry entry = HeadsUpManagerTestUtil.createEntry(/* id = */ 0, mContext); alm.showNotification(entry); Loading @@ -308,7 +273,7 @@ public class BaseHeadsUpManagerTest extends SysuiTestCase { @Test public void testShowNotification_autoDismisses() { final BaseHeadsUpManager alm = createHeadsUpManager(); final NotificationEntry entry = createEntry(/* id = */ 0); final NotificationEntry entry = HeadsUpManagerTestUtil.createEntry(/* id = */ 0, mContext); alm.showNotification(entry); mSystemClock.advanceTime(TEST_AUTO_DISMISS_TIME * 3 / 2); Loading @@ -319,7 +284,7 @@ public class BaseHeadsUpManagerTest extends SysuiTestCase { @Test public void testRemoveNotification_removeDeferred() { final BaseHeadsUpManager alm = createHeadsUpManager(); final NotificationEntry entry = createEntry(/* id = */ 0); final NotificationEntry entry = HeadsUpManagerTestUtil.createEntry(/* id = */ 0, mContext); alm.showNotification(entry); Loading @@ -332,7 +297,7 @@ public class BaseHeadsUpManagerTest extends SysuiTestCase { @Test public void testRemoveNotification_forceRemove() { final BaseHeadsUpManager alm = createHeadsUpManager(); final NotificationEntry entry = createEntry(/* id = */ 0); final NotificationEntry entry = HeadsUpManagerTestUtil.createEntry(/* id = */ 0, mContext); alm.showNotification(entry); Loading @@ -346,7 +311,7 @@ public class BaseHeadsUpManagerTest extends SysuiTestCase { public void testReleaseAllImmediately() { final BaseHeadsUpManager alm = createHeadsUpManager(); for (int i = 0; i < TEST_NUM_NOTIFICATIONS; i++) { final NotificationEntry entry = createEntry(i); final NotificationEntry entry = HeadsUpManagerTestUtil.createEntry(i, mContext); entry.setRow(mRow); alm.showNotification(entry); } Loading @@ -359,7 +324,7 @@ public class BaseHeadsUpManagerTest extends SysuiTestCase { @Test public void testCanRemoveImmediately_notShownLongEnough() { final BaseHeadsUpManager alm = createHeadsUpManager(); final NotificationEntry entry = createEntry(/* id = */ 0); final NotificationEntry entry = HeadsUpManagerTestUtil.createEntry(/* id = */ 0, mContext); alm.showNotification(entry); Loading @@ -370,7 +335,8 @@ public class BaseHeadsUpManagerTest extends SysuiTestCase { @Test public void testHunRemovedLogging() { final BaseHeadsUpManager hum = createHeadsUpManager(); final NotificationEntry notifEntry = createEntry(/* id = */ 0); final NotificationEntry notifEntry = HeadsUpManagerTestUtil.createEntry(/* id = */ 0, mContext); final BaseHeadsUpManager.HeadsUpEntry headsUpEntry = mock( BaseHeadsUpManager.HeadsUpEntry.class); headsUpEntry.mEntry = notifEntry; Loading Loading @@ -413,7 +379,7 @@ public class BaseHeadsUpManagerTest extends SysuiTestCase { @Test public void testShouldHeadsUpBecomePinned_noFSI_false() { final BaseHeadsUpManager hum = createHeadsUpManager(); final NotificationEntry entry = createEntry(/* id = */ 0); final NotificationEntry entry = HeadsUpManagerTestUtil.createEntry(/* id = */ 0, mContext); assertFalse(hum.shouldHeadsUpBecomePinned(entry)); } Loading @@ -422,7 +388,7 @@ public class BaseHeadsUpManagerTest extends SysuiTestCase { @Test public void testShowNotification_autoDismissesIncludingTouchAcceptanceDelay() { final BaseHeadsUpManager hum = createHeadsUpManager(); final NotificationEntry entry = createEntry(/* id = */ 0); final NotificationEntry entry = HeadsUpManagerTestUtil.createEntry(/* id = */ 0, mContext); useAccessibilityTimeout(false); hum.showNotification(entry); Loading @@ -435,7 +401,7 @@ public class BaseHeadsUpManagerTest extends SysuiTestCase { @Test public void testShowNotification_autoDismissesWithDefaultTimeout() { final BaseHeadsUpManager hum = createHeadsUpManager(); final NotificationEntry entry = createEntry(/* id = */ 0); final NotificationEntry entry = HeadsUpManagerTestUtil.createEntry(/* id = */ 0, mContext); useAccessibilityTimeout(false); hum.showNotification(entry); Loading Loading @@ -476,7 +442,7 @@ public class BaseHeadsUpManagerTest extends SysuiTestCase { @Test public void testShowNotification_autoDismissesWithAccessibilityTimeout() { final BaseHeadsUpManager hum = createHeadsUpManager(); final NotificationEntry entry = createEntry(/* id = */ 0); final NotificationEntry entry = HeadsUpManagerTestUtil.createEntry(/* id = */ 0, mContext); useAccessibilityTimeout(true); hum.showNotification(entry); Loading Loading @@ -504,7 +470,7 @@ public class BaseHeadsUpManagerTest extends SysuiTestCase { @Test public void testRemoveNotification_beforeMinimumDisplayTime() { final BaseHeadsUpManager hum = createHeadsUpManager(); final NotificationEntry entry = createEntry(/* id = */ 0); final NotificationEntry entry = HeadsUpManagerTestUtil.createEntry(/* id = */ 0, mContext); useAccessibilityTimeout(false); hum.showNotification(entry); Loading @@ -523,7 +489,7 @@ public class BaseHeadsUpManagerTest extends SysuiTestCase { @Test public void testRemoveNotification_afterMinimumDisplayTime() { final BaseHeadsUpManager hum = createHeadsUpManager(); final NotificationEntry entry = createEntry(/* id = */ 0); final NotificationEntry entry = HeadsUpManagerTestUtil.createEntry(/* id = */ 0, mContext); useAccessibilityTimeout(false); hum.showNotification(entry); Loading @@ -541,7 +507,7 @@ public class BaseHeadsUpManagerTest extends SysuiTestCase { @Test public void testRemoveNotification_releaseImmediately() { final BaseHeadsUpManager hum = createHeadsUpManager(); final NotificationEntry entry = createEntry(/* id = */ 0); final NotificationEntry entry = HeadsUpManagerTestUtil.createEntry(/* id = */ 0, mContext); hum.showNotification(entry); Loading @@ -555,7 +521,8 @@ public class BaseHeadsUpManagerTest extends SysuiTestCase { @Test public void testIsSticky_rowPinnedAndExpanded_true() { final BaseHeadsUpManager hum = createHeadsUpManager(); final NotificationEntry notifEntry = createEntry(/* id = */ 0); final NotificationEntry notifEntry = HeadsUpManagerTestUtil.createEntry(/* id = */ 0, mContext); when(mRow.isPinned()).thenReturn(true); notifEntry.setRow(mRow); Loading @@ -571,7 +538,8 @@ public class BaseHeadsUpManagerTest extends SysuiTestCase { @Test public void testIsSticky_remoteInputActive_true() { final BaseHeadsUpManager hum = createHeadsUpManager(); final NotificationEntry notifEntry = createEntry(/* id = */ 0); final NotificationEntry notifEntry = HeadsUpManagerTestUtil.createEntry(/* id = */ 0, mContext); hum.showNotification(notifEntry); Loading Loading @@ -607,7 +575,8 @@ public class BaseHeadsUpManagerTest extends SysuiTestCase { @Test public void testIsSticky_false() { final BaseHeadsUpManager hum = createHeadsUpManager(); final NotificationEntry notifEntry = createEntry(/* id = */ 0); final NotificationEntry notifEntry = HeadsUpManagerTestUtil.createEntry(/* id = */ 0, mContext); hum.showNotification(notifEntry); Loading Loading @@ -653,14 +622,14 @@ public class BaseHeadsUpManagerTest extends SysuiTestCase { final BaseHeadsUpManager.HeadsUpEntry ongoingCall = hum.new HeadsUpEntry(); ongoingCall.setEntry(new NotificationEntryBuilder() .setSbn(createSbn(/* id = */ 0, .setSbn(HeadsUpManagerTestUtil.createSbn(/* id = */ 0, new Notification.Builder(mContext, "") .setCategory(Notification.CATEGORY_CALL) .setOngoing(true))) .build()); final BaseHeadsUpManager.HeadsUpEntry activeRemoteInput = hum.new HeadsUpEntry(); activeRemoteInput.setEntry(createEntry(/* id = */ 1)); activeRemoteInput.setEntry(HeadsUpManagerTestUtil.createEntry(/* id = */ 1, mContext)); activeRemoteInput.mRemoteInputActive = true; assertThat(ongoingCall.compareTo(activeRemoteInput)).isLessThan(0); Loading @@ -675,14 +644,14 @@ public class BaseHeadsUpManagerTest extends SysuiTestCase { final Person person = new Person.Builder().setName("person").build(); final PendingIntent intent = mock(PendingIntent.class); incomingCall.setEntry(new NotificationEntryBuilder() .setSbn(createSbn(/* id = */ 0, .setSbn(HeadsUpManagerTestUtil.createSbn(/* id = */ 0, new Notification.Builder(mContext, "") .setStyle(Notification.CallStyle .forIncomingCall(person, intent, intent)))) .build()); final BaseHeadsUpManager.HeadsUpEntry activeRemoteInput = hum.new HeadsUpEntry(); activeRemoteInput.setEntry(createEntry(/* id = */ 1)); activeRemoteInput.setEntry(HeadsUpManagerTestUtil.createEntry(/* id = */ 1, mContext)); activeRemoteInput.mRemoteInputActive = true; assertThat(incomingCall.compareTo(activeRemoteInput)).isLessThan(0); Loading Loading @@ -712,7 +681,8 @@ public class BaseHeadsUpManagerTest extends SysuiTestCase { @Test public void testSetUserActionMayIndirectlyRemove() { final BaseHeadsUpManager hum = createHeadsUpManager(); final NotificationEntry notifEntry = createEntry(/* id = */ 0); final NotificationEntry notifEntry = HeadsUpManagerTestUtil.createEntry(/* id = */ 0, mContext); hum.showNotification(notifEntry); Loading packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/policy/HeadsUpManagerPhoneTest.java +8 −6 Original line number Diff line number Diff line Loading @@ -150,7 +150,7 @@ public class HeadsUpManagerPhoneTest extends BaseHeadsUpManagerTest { @Test public void testSnooze() { final HeadsUpManager hmp = createHeadsUpManagerPhone(); final NotificationEntry entry = createEntry(/* id = */ 0); final NotificationEntry entry = HeadsUpManagerTestUtil.createEntry(/* id = */ 0, mContext); hmp.showNotification(entry); hmp.snooze(); Loading @@ -161,7 +161,7 @@ public class HeadsUpManagerPhoneTest extends BaseHeadsUpManagerTest { @Test public void testSwipedOutNotification() { final HeadsUpManager hmp = createHeadsUpManagerPhone(); final NotificationEntry entry = createEntry(/* id = */ 0); final NotificationEntry entry = HeadsUpManagerTestUtil.createEntry(/* id = */ 0, mContext); hmp.showNotification(entry); hmp.addSwipedOutNotification(entry.getKey()); Loading @@ -177,7 +177,7 @@ public class HeadsUpManagerPhoneTest extends BaseHeadsUpManagerTest { @Test public void testCanRemoveImmediately_swipedOut() { final HeadsUpManager hmp = createHeadsUpManagerPhone(); final NotificationEntry entry = createEntry(/* id = */ 0); final NotificationEntry entry = HeadsUpManagerTestUtil.createEntry(/* id = */ 0, mContext); hmp.showNotification(entry); hmp.addSwipedOutNotification(entry.getKey()); Loading @@ -190,8 +190,10 @@ public class HeadsUpManagerPhoneTest extends BaseHeadsUpManagerTest { @Test public void testCanRemoveImmediately_notTopEntry() { final HeadsUpManager hmp = createHeadsUpManagerPhone(); final NotificationEntry earlierEntry = createEntry(/* id = */ 0); final NotificationEntry laterEntry = createEntry(/* id = */ 1); final NotificationEntry earlierEntry = HeadsUpManagerTestUtil.createEntry(/* id = */ 0, mContext); final NotificationEntry laterEntry = HeadsUpManagerTestUtil.createEntry(/* id = */ 1, mContext); laterEntry.setRow(mRow); hmp.showNotification(earlierEntry); Loading @@ -204,7 +206,7 @@ public class HeadsUpManagerPhoneTest extends BaseHeadsUpManagerTest { @Test public void testExtendHeadsUp() { final HeadsUpManagerPhone hmp = createHeadsUpManagerPhone(); final NotificationEntry entry = createEntry(/* id = */ 0); final NotificationEntry entry = HeadsUpManagerTestUtil.createEntry(/* id = */ 0, mContext); hmp.showNotification(entry); hmp.extendHeadsUp(); Loading packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/policy/HeadsUpManagerTestUtil.java 0 → 100644 +70 −0 Original line number Diff line number Diff line /* * Copyright (C) 2024 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.android.systemui.statusbar.policy; import android.app.ActivityManager; import android.os.UserHandle; import android.content.Context; import android.service.notification.StatusBarNotification; import android.app.Notification; import com.android.systemui.statusbar.notification.collection.NotificationEntry; import com.android.systemui.statusbar.notification.collection.NotificationEntryBuilder; /** * Test helper class for HeadsUpEntry creation. */ public class HeadsUpManagerTestUtil { private static final String TEST_PACKAGE_NAME = "HeadsUpManagerTestUtil"; private static final int TEST_UID = 0; protected static StatusBarNotification createSbn(int id, Notification.Builder n) { return createSbn(id, n.build()); } protected static StatusBarNotification createSbn(int id, Context context) { final Notification.Builder b = new Notification.Builder(context, "") .setSmallIcon(com.android.systemui.res.R.drawable.ic_person) .setContentTitle("Title") .setContentText("Text"); return createSbn(id, b); } protected static StatusBarNotification createSbn(int id, Notification n) { return new StatusBarNotification( TEST_PACKAGE_NAME /* pkg */, TEST_PACKAGE_NAME, id, null /* tag */, TEST_UID, 0 /* initialPid */, n, new UserHandle(ActivityManager.getCurrentUser()), null /* overrideGroupKey */, 0 /* postTime */); } protected static NotificationEntry createEntry(int id, Notification n) { return new NotificationEntryBuilder().setSbn(createSbn(id, n)).build(); } protected static NotificationEntry createEntry(int id, Context context) { return new NotificationEntryBuilder().setSbn( HeadsUpManagerTestUtil.createSbn(id, context)).build(); } } Loading
packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/policy/BaseHeadsUpManagerTest.java +30 −60 Original line number Diff line number Diff line Loading @@ -212,41 +212,6 @@ public class BaseHeadsUpManagerTest extends SysuiTestCase { } } protected StatusBarNotification createSbn(int id, Notification n) { return new StatusBarNotification( TEST_PACKAGE_NAME /* pkg */, TEST_PACKAGE_NAME, id, null /* tag */, TEST_UID, 0 /* initialPid */, n, new UserHandle(ActivityManager.getCurrentUser()), null /* overrideGroupKey */, 0 /* postTime */); } protected StatusBarNotification createSbn(int id, Notification.Builder n) { return createSbn(id, n.build()); } protected StatusBarNotification createSbn(int id) { final Notification.Builder b = new Notification.Builder(mContext, "") .setSmallIcon(R.drawable.ic_person) .setContentTitle("Title") .setContentText("Text"); return createSbn(id, b); } protected NotificationEntry createEntry(int id, Notification n) { return new NotificationEntryBuilder().setSbn(createSbn(id, n)).build(); } protected NotificationEntry createEntry(int id) { return new NotificationEntryBuilder().setSbn(createSbn(id)).build(); } private BaseHeadsUpManager createHeadsUpManager() { return new TestableHeadsUpManager(mContext, mLogger, mExecutor, mGlobalSettings, mSystemClock, mAccessibilityMgr, mUiEventLoggerFake); Loading @@ -257,7 +222,7 @@ public class BaseHeadsUpManagerTest extends SysuiTestCase { .setSmallIcon(R.drawable.ic_person) .setFullScreenIntent(mock(PendingIntent.class), /* highPriority */ true) .build(); return createEntry(id, notif); return HeadsUpManagerTestUtil.createEntry(id, notif); } private NotificationEntry createStickyForSomeTimeEntry(int id) { Loading @@ -265,7 +230,7 @@ public class BaseHeadsUpManagerTest extends SysuiTestCase { .setSmallIcon(R.drawable.ic_person) .setFlag(FLAG_FSI_REQUESTED_BUT_DENIED, true) .build(); return createEntry(id, notif); return HeadsUpManagerTestUtil.createEntry(id, notif); } private PendingIntent createFullScreenIntent() { Loading @@ -279,7 +244,7 @@ public class BaseHeadsUpManagerTest extends SysuiTestCase { .setSmallIcon(R.drawable.ic_person) .setFullScreenIntent(createFullScreenIntent(), /* highPriority */ true) .build(); return createEntry(id, notif); return HeadsUpManagerTestUtil.createEntry(id, notif); } Loading @@ -296,7 +261,7 @@ public class BaseHeadsUpManagerTest extends SysuiTestCase { @Test public void testShowNotification_addsEntry() { final BaseHeadsUpManager alm = createHeadsUpManager(); final NotificationEntry entry = createEntry(/* id = */ 0); final NotificationEntry entry = HeadsUpManagerTestUtil.createEntry(/* id = */ 0, mContext); alm.showNotification(entry); Loading @@ -308,7 +273,7 @@ public class BaseHeadsUpManagerTest extends SysuiTestCase { @Test public void testShowNotification_autoDismisses() { final BaseHeadsUpManager alm = createHeadsUpManager(); final NotificationEntry entry = createEntry(/* id = */ 0); final NotificationEntry entry = HeadsUpManagerTestUtil.createEntry(/* id = */ 0, mContext); alm.showNotification(entry); mSystemClock.advanceTime(TEST_AUTO_DISMISS_TIME * 3 / 2); Loading @@ -319,7 +284,7 @@ public class BaseHeadsUpManagerTest extends SysuiTestCase { @Test public void testRemoveNotification_removeDeferred() { final BaseHeadsUpManager alm = createHeadsUpManager(); final NotificationEntry entry = createEntry(/* id = */ 0); final NotificationEntry entry = HeadsUpManagerTestUtil.createEntry(/* id = */ 0, mContext); alm.showNotification(entry); Loading @@ -332,7 +297,7 @@ public class BaseHeadsUpManagerTest extends SysuiTestCase { @Test public void testRemoveNotification_forceRemove() { final BaseHeadsUpManager alm = createHeadsUpManager(); final NotificationEntry entry = createEntry(/* id = */ 0); final NotificationEntry entry = HeadsUpManagerTestUtil.createEntry(/* id = */ 0, mContext); alm.showNotification(entry); Loading @@ -346,7 +311,7 @@ public class BaseHeadsUpManagerTest extends SysuiTestCase { public void testReleaseAllImmediately() { final BaseHeadsUpManager alm = createHeadsUpManager(); for (int i = 0; i < TEST_NUM_NOTIFICATIONS; i++) { final NotificationEntry entry = createEntry(i); final NotificationEntry entry = HeadsUpManagerTestUtil.createEntry(i, mContext); entry.setRow(mRow); alm.showNotification(entry); } Loading @@ -359,7 +324,7 @@ public class BaseHeadsUpManagerTest extends SysuiTestCase { @Test public void testCanRemoveImmediately_notShownLongEnough() { final BaseHeadsUpManager alm = createHeadsUpManager(); final NotificationEntry entry = createEntry(/* id = */ 0); final NotificationEntry entry = HeadsUpManagerTestUtil.createEntry(/* id = */ 0, mContext); alm.showNotification(entry); Loading @@ -370,7 +335,8 @@ public class BaseHeadsUpManagerTest extends SysuiTestCase { @Test public void testHunRemovedLogging() { final BaseHeadsUpManager hum = createHeadsUpManager(); final NotificationEntry notifEntry = createEntry(/* id = */ 0); final NotificationEntry notifEntry = HeadsUpManagerTestUtil.createEntry(/* id = */ 0, mContext); final BaseHeadsUpManager.HeadsUpEntry headsUpEntry = mock( BaseHeadsUpManager.HeadsUpEntry.class); headsUpEntry.mEntry = notifEntry; Loading Loading @@ -413,7 +379,7 @@ public class BaseHeadsUpManagerTest extends SysuiTestCase { @Test public void testShouldHeadsUpBecomePinned_noFSI_false() { final BaseHeadsUpManager hum = createHeadsUpManager(); final NotificationEntry entry = createEntry(/* id = */ 0); final NotificationEntry entry = HeadsUpManagerTestUtil.createEntry(/* id = */ 0, mContext); assertFalse(hum.shouldHeadsUpBecomePinned(entry)); } Loading @@ -422,7 +388,7 @@ public class BaseHeadsUpManagerTest extends SysuiTestCase { @Test public void testShowNotification_autoDismissesIncludingTouchAcceptanceDelay() { final BaseHeadsUpManager hum = createHeadsUpManager(); final NotificationEntry entry = createEntry(/* id = */ 0); final NotificationEntry entry = HeadsUpManagerTestUtil.createEntry(/* id = */ 0, mContext); useAccessibilityTimeout(false); hum.showNotification(entry); Loading @@ -435,7 +401,7 @@ public class BaseHeadsUpManagerTest extends SysuiTestCase { @Test public void testShowNotification_autoDismissesWithDefaultTimeout() { final BaseHeadsUpManager hum = createHeadsUpManager(); final NotificationEntry entry = createEntry(/* id = */ 0); final NotificationEntry entry = HeadsUpManagerTestUtil.createEntry(/* id = */ 0, mContext); useAccessibilityTimeout(false); hum.showNotification(entry); Loading Loading @@ -476,7 +442,7 @@ public class BaseHeadsUpManagerTest extends SysuiTestCase { @Test public void testShowNotification_autoDismissesWithAccessibilityTimeout() { final BaseHeadsUpManager hum = createHeadsUpManager(); final NotificationEntry entry = createEntry(/* id = */ 0); final NotificationEntry entry = HeadsUpManagerTestUtil.createEntry(/* id = */ 0, mContext); useAccessibilityTimeout(true); hum.showNotification(entry); Loading Loading @@ -504,7 +470,7 @@ public class BaseHeadsUpManagerTest extends SysuiTestCase { @Test public void testRemoveNotification_beforeMinimumDisplayTime() { final BaseHeadsUpManager hum = createHeadsUpManager(); final NotificationEntry entry = createEntry(/* id = */ 0); final NotificationEntry entry = HeadsUpManagerTestUtil.createEntry(/* id = */ 0, mContext); useAccessibilityTimeout(false); hum.showNotification(entry); Loading @@ -523,7 +489,7 @@ public class BaseHeadsUpManagerTest extends SysuiTestCase { @Test public void testRemoveNotification_afterMinimumDisplayTime() { final BaseHeadsUpManager hum = createHeadsUpManager(); final NotificationEntry entry = createEntry(/* id = */ 0); final NotificationEntry entry = HeadsUpManagerTestUtil.createEntry(/* id = */ 0, mContext); useAccessibilityTimeout(false); hum.showNotification(entry); Loading @@ -541,7 +507,7 @@ public class BaseHeadsUpManagerTest extends SysuiTestCase { @Test public void testRemoveNotification_releaseImmediately() { final BaseHeadsUpManager hum = createHeadsUpManager(); final NotificationEntry entry = createEntry(/* id = */ 0); final NotificationEntry entry = HeadsUpManagerTestUtil.createEntry(/* id = */ 0, mContext); hum.showNotification(entry); Loading @@ -555,7 +521,8 @@ public class BaseHeadsUpManagerTest extends SysuiTestCase { @Test public void testIsSticky_rowPinnedAndExpanded_true() { final BaseHeadsUpManager hum = createHeadsUpManager(); final NotificationEntry notifEntry = createEntry(/* id = */ 0); final NotificationEntry notifEntry = HeadsUpManagerTestUtil.createEntry(/* id = */ 0, mContext); when(mRow.isPinned()).thenReturn(true); notifEntry.setRow(mRow); Loading @@ -571,7 +538,8 @@ public class BaseHeadsUpManagerTest extends SysuiTestCase { @Test public void testIsSticky_remoteInputActive_true() { final BaseHeadsUpManager hum = createHeadsUpManager(); final NotificationEntry notifEntry = createEntry(/* id = */ 0); final NotificationEntry notifEntry = HeadsUpManagerTestUtil.createEntry(/* id = */ 0, mContext); hum.showNotification(notifEntry); Loading Loading @@ -607,7 +575,8 @@ public class BaseHeadsUpManagerTest extends SysuiTestCase { @Test public void testIsSticky_false() { final BaseHeadsUpManager hum = createHeadsUpManager(); final NotificationEntry notifEntry = createEntry(/* id = */ 0); final NotificationEntry notifEntry = HeadsUpManagerTestUtil.createEntry(/* id = */ 0, mContext); hum.showNotification(notifEntry); Loading Loading @@ -653,14 +622,14 @@ public class BaseHeadsUpManagerTest extends SysuiTestCase { final BaseHeadsUpManager.HeadsUpEntry ongoingCall = hum.new HeadsUpEntry(); ongoingCall.setEntry(new NotificationEntryBuilder() .setSbn(createSbn(/* id = */ 0, .setSbn(HeadsUpManagerTestUtil.createSbn(/* id = */ 0, new Notification.Builder(mContext, "") .setCategory(Notification.CATEGORY_CALL) .setOngoing(true))) .build()); final BaseHeadsUpManager.HeadsUpEntry activeRemoteInput = hum.new HeadsUpEntry(); activeRemoteInput.setEntry(createEntry(/* id = */ 1)); activeRemoteInput.setEntry(HeadsUpManagerTestUtil.createEntry(/* id = */ 1, mContext)); activeRemoteInput.mRemoteInputActive = true; assertThat(ongoingCall.compareTo(activeRemoteInput)).isLessThan(0); Loading @@ -675,14 +644,14 @@ public class BaseHeadsUpManagerTest extends SysuiTestCase { final Person person = new Person.Builder().setName("person").build(); final PendingIntent intent = mock(PendingIntent.class); incomingCall.setEntry(new NotificationEntryBuilder() .setSbn(createSbn(/* id = */ 0, .setSbn(HeadsUpManagerTestUtil.createSbn(/* id = */ 0, new Notification.Builder(mContext, "") .setStyle(Notification.CallStyle .forIncomingCall(person, intent, intent)))) .build()); final BaseHeadsUpManager.HeadsUpEntry activeRemoteInput = hum.new HeadsUpEntry(); activeRemoteInput.setEntry(createEntry(/* id = */ 1)); activeRemoteInput.setEntry(HeadsUpManagerTestUtil.createEntry(/* id = */ 1, mContext)); activeRemoteInput.mRemoteInputActive = true; assertThat(incomingCall.compareTo(activeRemoteInput)).isLessThan(0); Loading Loading @@ -712,7 +681,8 @@ public class BaseHeadsUpManagerTest extends SysuiTestCase { @Test public void testSetUserActionMayIndirectlyRemove() { final BaseHeadsUpManager hum = createHeadsUpManager(); final NotificationEntry notifEntry = createEntry(/* id = */ 0); final NotificationEntry notifEntry = HeadsUpManagerTestUtil.createEntry(/* id = */ 0, mContext); hum.showNotification(notifEntry); Loading
packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/policy/HeadsUpManagerPhoneTest.java +8 −6 Original line number Diff line number Diff line Loading @@ -150,7 +150,7 @@ public class HeadsUpManagerPhoneTest extends BaseHeadsUpManagerTest { @Test public void testSnooze() { final HeadsUpManager hmp = createHeadsUpManagerPhone(); final NotificationEntry entry = createEntry(/* id = */ 0); final NotificationEntry entry = HeadsUpManagerTestUtil.createEntry(/* id = */ 0, mContext); hmp.showNotification(entry); hmp.snooze(); Loading @@ -161,7 +161,7 @@ public class HeadsUpManagerPhoneTest extends BaseHeadsUpManagerTest { @Test public void testSwipedOutNotification() { final HeadsUpManager hmp = createHeadsUpManagerPhone(); final NotificationEntry entry = createEntry(/* id = */ 0); final NotificationEntry entry = HeadsUpManagerTestUtil.createEntry(/* id = */ 0, mContext); hmp.showNotification(entry); hmp.addSwipedOutNotification(entry.getKey()); Loading @@ -177,7 +177,7 @@ public class HeadsUpManagerPhoneTest extends BaseHeadsUpManagerTest { @Test public void testCanRemoveImmediately_swipedOut() { final HeadsUpManager hmp = createHeadsUpManagerPhone(); final NotificationEntry entry = createEntry(/* id = */ 0); final NotificationEntry entry = HeadsUpManagerTestUtil.createEntry(/* id = */ 0, mContext); hmp.showNotification(entry); hmp.addSwipedOutNotification(entry.getKey()); Loading @@ -190,8 +190,10 @@ public class HeadsUpManagerPhoneTest extends BaseHeadsUpManagerTest { @Test public void testCanRemoveImmediately_notTopEntry() { final HeadsUpManager hmp = createHeadsUpManagerPhone(); final NotificationEntry earlierEntry = createEntry(/* id = */ 0); final NotificationEntry laterEntry = createEntry(/* id = */ 1); final NotificationEntry earlierEntry = HeadsUpManagerTestUtil.createEntry(/* id = */ 0, mContext); final NotificationEntry laterEntry = HeadsUpManagerTestUtil.createEntry(/* id = */ 1, mContext); laterEntry.setRow(mRow); hmp.showNotification(earlierEntry); Loading @@ -204,7 +206,7 @@ public class HeadsUpManagerPhoneTest extends BaseHeadsUpManagerTest { @Test public void testExtendHeadsUp() { final HeadsUpManagerPhone hmp = createHeadsUpManagerPhone(); final NotificationEntry entry = createEntry(/* id = */ 0); final NotificationEntry entry = HeadsUpManagerTestUtil.createEntry(/* id = */ 0, mContext); hmp.showNotification(entry); hmp.extendHeadsUp(); Loading
packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/policy/HeadsUpManagerTestUtil.java 0 → 100644 +70 −0 Original line number Diff line number Diff line /* * Copyright (C) 2024 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.android.systemui.statusbar.policy; import android.app.ActivityManager; import android.os.UserHandle; import android.content.Context; import android.service.notification.StatusBarNotification; import android.app.Notification; import com.android.systemui.statusbar.notification.collection.NotificationEntry; import com.android.systemui.statusbar.notification.collection.NotificationEntryBuilder; /** * Test helper class for HeadsUpEntry creation. */ public class HeadsUpManagerTestUtil { private static final String TEST_PACKAGE_NAME = "HeadsUpManagerTestUtil"; private static final int TEST_UID = 0; protected static StatusBarNotification createSbn(int id, Notification.Builder n) { return createSbn(id, n.build()); } protected static StatusBarNotification createSbn(int id, Context context) { final Notification.Builder b = new Notification.Builder(context, "") .setSmallIcon(com.android.systemui.res.R.drawable.ic_person) .setContentTitle("Title") .setContentText("Text"); return createSbn(id, b); } protected static StatusBarNotification createSbn(int id, Notification n) { return new StatusBarNotification( TEST_PACKAGE_NAME /* pkg */, TEST_PACKAGE_NAME, id, null /* tag */, TEST_UID, 0 /* initialPid */, n, new UserHandle(ActivityManager.getCurrentUser()), null /* overrideGroupKey */, 0 /* postTime */); } protected static NotificationEntry createEntry(int id, Notification n) { return new NotificationEntryBuilder().setSbn(createSbn(id, n)).build(); } protected static NotificationEntry createEntry(int id, Context context) { return new NotificationEntryBuilder().setSbn( HeadsUpManagerTestUtil.createSbn(id, context)).build(); } }