Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 690ce0ff authored by Julia Reynolds's avatar Julia Reynolds
Browse files

Remove NotificationTestHelper

We can use kosmos now instead

Test: it's all tests
Fixes: 395857098
Flag: EXEMPT test refactor
Change-Id: I36229f72bba14adaa3d3d384d7f8f30bfa2a326f
parent 8d3c7686
Loading
Loading
Loading
Loading
+5 −5
Original line number Diff line number Diff line
@@ -46,6 +46,7 @@ import android.widget.RemoteViews;
import androidx.test.filters.SmallTest;

import com.android.systemui.SysuiTestCase;
import com.android.systemui.kosmos.KosmosJavaAdapter;
import com.android.systemui.plugins.statusbar.StatusBarStateController;
import com.android.systemui.power.domain.interactor.PowerInteractor;
import com.android.systemui.shade.domain.interactor.ShadeInteractor;
@@ -55,7 +56,6 @@ import com.android.systemui.statusbar.notification.collection.NotificationEntry;
import com.android.systemui.statusbar.notification.collection.NotificationEntryBuilder;
import com.android.systemui.statusbar.notification.collection.render.NotificationVisibilityProvider;
import com.android.systemui.statusbar.notification.row.ExpandableNotificationRow;
import com.android.systemui.statusbar.notification.row.NotificationTestHelper;
import com.android.systemui.statusbar.notification.shared.NotificationBundleUi;
import com.android.systemui.statusbar.policy.RemoteInputUriController;
import com.android.systemui.util.kotlin.JavaAdapter;
@@ -107,7 +107,7 @@ public class NotificationRemoteInputManagerTest extends SysuiTestCase {
    ArgumentCaptor<NotificationRemoteInputManager.ClickHandler> mClickHandlerArgumentCaptor;
    private Context mSpyContext;

    private NotificationTestHelper mTestHelper;
    private final KosmosJavaAdapter mKosmos = new KosmosJavaAdapter(this);
    private TestableNotificationRemoteInputManager mRemoteInputManager;
    private NotificationEntry mEntry;

@@ -125,7 +125,6 @@ public class NotificationRemoteInputManagerTest extends SysuiTestCase {
                any(), any(), anyInt(), anyInt(), anyInt(), any());


        mTestHelper = new NotificationTestHelper(mSpyContext, mDependency);
        mActionClickLogger = spy(new ActionClickLogger(logcatLogBuffer()));

        mRemoteInputManager = new TestableNotificationRemoteInputManager(mContext,
@@ -217,7 +216,8 @@ public class NotificationRemoteInputManagerTest extends SysuiTestCase {

        verify(mRemoteInputListener).releaseNotificationIfKeptForRemoteInputHistory(row.getKey());
        if (NotificationBundleUi.isEnabled()) {
            verify(row.getEntryAdapter()).onNotificationActionClicked();
            verify(mKosmos.getMockNotificationActionClickManager())
                    .onNotificationActionClicked(any());
        } else {
            latch.await(10, TimeUnit.MILLISECONDS);
        }
@@ -239,7 +239,7 @@ public class NotificationRemoteInputManagerTest extends SysuiTestCase {
                .addAction(new Notification.Action(com.android.systemui.res.R.drawable.ic_person,
                        "reply", pi))
                .build();
        ExpandableNotificationRow row = mTestHelper.createRow(n);
        ExpandableNotificationRow row = mKosmos.createRow(n);
        row.onNotificationUpdated();
        row.getPrivateLayout().setExpandedChild(Notification.Builder.recoverBuilder(mSpyContext, n)
                .createBigContentView().apply(
+0 −1
Original line number Diff line number Diff line
@@ -29,7 +29,6 @@ import androidx.test.filters.SmallTest;
import com.android.systemui.SysuiTestCase;
import com.android.systemui.kosmos.KosmosJavaAdapter;
import com.android.systemui.statusbar.notification.row.ExpandableNotificationRow;
import com.android.systemui.statusbar.notification.row.NotificationTestHelper;

import org.junit.Assert;
import org.junit.Before;
+0 −3
Original line number Diff line number Diff line
@@ -34,7 +34,6 @@ import com.android.systemui.statusbar.RankingBuilder
import com.android.systemui.statusbar.notification.collection.buildNotificationEntry
import com.android.systemui.statusbar.notification.collection.makeEntryOfPeopleType
import com.android.systemui.statusbar.notification.row.NotificationRowContentBinderLogger
import com.android.systemui.statusbar.notification.row.NotificationTestHelper
import com.android.systemui.statusbar.notification.row.notificationRowContentBinderLogger
import com.android.systemui.testKosmos
import com.google.common.truth.Truth.assertThat
@@ -49,7 +48,6 @@ class ConversationNotificationProcessorTest : SysuiTestCase() {

    private val kosmos = testKosmos()
    private lateinit var conversationNotificationProcessor: ConversationNotificationProcessor
    private lateinit var testHelper: NotificationTestHelper
    private lateinit var launcherApps: LauncherApps
    private lateinit var logger: NotificationRowContentBinderLogger
    private lateinit var conversationNotificationManager: ConversationNotificationManager
@@ -59,7 +57,6 @@ class ConversationNotificationProcessorTest : SysuiTestCase() {
        launcherApps = kosmos.launcherApps
        conversationNotificationManager = kosmos.conversationNotificationManager
        logger = kosmos.notificationRowContentBinderLogger
        testHelper = NotificationTestHelper(mContext, mDependency)

        conversationNotificationProcessor =
            ConversationNotificationProcessor(
+13 −41
Original line number Diff line number Diff line
@@ -16,26 +16,23 @@

package com.android.systemui.statusbar.notification

import android.app.Notification
import android.platform.test.annotations.DisableFlags
import android.platform.test.annotations.EnableFlags
import android.testing.TestableLooper
import android.view.MotionEvent
import android.view.View
import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.SmallTest
import com.android.systemui.Flags
import com.android.systemui.SysuiTestCase
import com.android.systemui.statusbar.notification.row.NotificationTestHelper
import com.android.systemui.statusbar.notification.collection.provider.mockNotificationDismissibilityProvider
import com.android.systemui.statusbar.notification.row.ExpandableNotificationRow
import com.android.systemui.statusbar.notification.row.createRow
import com.android.systemui.testKosmos
import com.google.common.truth.Truth.assertThat
import org.junit.Test
import org.junit.runner.RunWith
import org.mockito.kotlin.any
import org.mockito.kotlin.doReturn
import org.mockito.kotlin.stub
import com.android.systemui.res.R
import com.android.systemui.statusbar.notification.row.ExpandableNotificationRow
import org.junit.Before
import org.mockito.kotlin.whenever

private fun getCloseButton(row: ExpandableNotificationRow): View {
    val contractedView = row.showingLayout?.contractedChild!!
@@ -45,27 +42,13 @@ private fun getCloseButton(row: ExpandableNotificationRow): View {
@SmallTest
@RunWith(AndroidJUnit4::class)
class NotificationCloseButtonTest : SysuiTestCase() {
    private lateinit var helper: NotificationTestHelper

    @Before
    fun setUp() {
        helper = NotificationTestHelper(
            mContext,
            mDependency,
            TestableLooper.get(this)
        )
    }
    private val kosmos = testKosmos()

    @Test
    @DisableFlags(Flags.FLAG_NOTIFICATION_ADD_X_ON_HOVER_TO_DISMISS)
    fun verifyWhenFeatureDisabled() {
        // Enable the notification row to dismiss.
        helper.dismissibilityProvider.stub {
            on { isDismissable(any()) } doReturn true
        }

        // By default, the close button should be gone.
        val row = createNotificationRow()
        val row = kosmos.createRow()
        val closeButton = getCloseButton(row)
        assertThat(closeButton).isNotNull()
        assertThat(closeButton.visibility).isEqualTo(View.GONE)
@@ -87,13 +70,10 @@ class NotificationCloseButtonTest : SysuiTestCase() {
    @Test
    @EnableFlags(Flags.FLAG_NOTIFICATION_ADD_X_ON_HOVER_TO_DISMISS)
    fun verifyOnDismissableNotification() {
        // Enable the notification row to dismiss.
        helper.dismissibilityProvider.stub {
            on { isDismissable(any()) } doReturn true
        }

        whenever(kosmos.mockNotificationDismissibilityProvider.isDismissable(any()))
            .thenReturn(true)
        // By default, the close button should be gone.
        val row = createNotificationRow()
        val row = kosmos.createRow()
        val closeButton = getCloseButton(row)
        assertThat(closeButton).isNotNull()
        assertThat(closeButton.visibility).isEqualTo(View.GONE)
@@ -129,7 +109,9 @@ class NotificationCloseButtonTest : SysuiTestCase() {
    @EnableFlags(Flags.FLAG_NOTIFICATION_ADD_X_ON_HOVER_TO_DISMISS)
    fun verifyOnUndismissableNotification() {
        // By default, the close button should be gone.
        val row = createNotificationRow()
        whenever(kosmos.mockNotificationDismissibilityProvider.isDismissable(any()))
            .thenReturn(false)
        val row = kosmos.createRow()
        val closeButton = getCloseButton(row)
        assertThat(closeButton).isNotNull()
        assertThat(closeButton.visibility).isEqualTo(View.GONE)
@@ -147,14 +129,4 @@ class NotificationCloseButtonTest : SysuiTestCase() {
        row.onInterceptHoverEvent(hoverEnterEvent)
        assertThat(closeButton.visibility).isEqualTo(View.GONE)
    }

    private fun createNotificationRow(): ExpandableNotificationRow {
        val notification = Notification.Builder(context, "channel")
            .setContentTitle("title")
            .setContentText("text")
            .setSmallIcon(R.drawable.ic_person)
            .build()

       return helper.createRow(notification)
    }
}
 No newline at end of file
+8 −10
Original line number Diff line number Diff line
@@ -48,7 +48,7 @@ import com.android.systemui.statusbar.notification.collection.provider.visualSta
import com.android.systemui.statusbar.notification.collection.render.GroupMembershipManager
import com.android.systemui.statusbar.notification.promoted.PromotedNotificationUi
import com.android.systemui.statusbar.notification.row.ExpandableNotificationRow
import com.android.systemui.statusbar.notification.row.NotificationTestHelper
import com.android.systemui.statusbar.notification.row.createRow
import com.android.systemui.statusbar.notification.shared.NotificationThrottleHun
import com.android.systemui.statusbar.phone.keyguardBypassController
import com.android.systemui.statusbar.policy.configurationController
@@ -94,7 +94,6 @@ class HeadsUpManagerImplTest(flags: FlagsParameterization) : SysuiTestCase() {
    private val executor = kosmos.fakeExecutor
    private val uiEventLoggerFake = kosmos.uiEventLoggerFake

    private lateinit var testHelper: NotificationTestHelper
    private lateinit var avalancheController: AvalancheController
    private lateinit var underTest: HeadsUpManagerImpl

@@ -123,7 +122,6 @@ class HeadsUpManagerImplTest(flags: FlagsParameterization) : SysuiTestCase() {
        }

        allowTestableLooperAsMainThread()
        testHelper = NotificationTestHelper(mContext, mDependency, TestableLooper.get(this))

        whenever(kosmos.keyguardBypassController.bypassEnabled).thenReturn(false)
        kosmos.visualStabilityProvider.isReorderingAllowed = true
@@ -192,7 +190,7 @@ class HeadsUpManagerImplTest(flags: FlagsParameterization) : SysuiTestCase() {
    @Test
    fun pinnedHeadsUpStatuses_pinnedBySystem() {
        val entry = HeadsUpManagerTestUtil.createEntry(/* id= */ 0, mContext)
        entry.row = testHelper.createRow()
        entry.row = kosmos.createRow()
        underTest.showNotification(entry, isPinnedByUser = false)

        assertThat(underTest.hasPinnedHeadsUp()).isTrue()
@@ -203,7 +201,7 @@ class HeadsUpManagerImplTest(flags: FlagsParameterization) : SysuiTestCase() {
    @DisableFlags(PromotedNotificationUi.FLAG_NAME)
    fun pinnedHeadsUpStatuses_pinnedByUser_butFlagOff_returnsNotPinned() {
        val entry = HeadsUpManagerTestUtil.createEntry(/* id= */ 0, mContext)
        entry.row = testHelper.createRow()
        entry.row = kosmos.createRow()
        assertLogsWtfs { underTest.showNotification(entry, isPinnedByUser = true) }
        assertThat(underTest.hasPinnedHeadsUp()).isFalse()
        assertThat(underTest.pinnedHeadsUpStatus()).isEqualTo(PinnedStatus.NotPinned)
@@ -213,7 +211,7 @@ class HeadsUpManagerImplTest(flags: FlagsParameterization) : SysuiTestCase() {
    @EnableFlags(PromotedNotificationUi.FLAG_NAME)
    fun pinnedHeadsUpStatuses_pinnedByUser_flagOn() {
        val entry = HeadsUpManagerTestUtil.createEntry(/* id= */ 0, mContext)
        entry.row = testHelper.createRow()
        entry.row = kosmos.createRow()
        underTest.showNotification(entry, isPinnedByUser = true)

        assertThat(underTest.hasPinnedHeadsUp()).isTrue()
@@ -347,7 +345,7 @@ class HeadsUpManagerImplTest(flags: FlagsParameterization) : SysuiTestCase() {
    fun testReleaseAllImmediately() {
        for (i in 0 until 4) {
            val entry = HeadsUpManagerTestUtil.createEntry(i, mContext)
            entry.row = testHelper.createRow()
            entry.row = kosmos.createRow()
            val isPinnedByUser = i % 2 == 0
            underTest.showNotification(entry, isPinnedByUser)
        }
@@ -466,7 +464,7 @@ class HeadsUpManagerImplTest(flags: FlagsParameterization) : SysuiTestCase() {
        useAccessibilityTimeout(false)

        val entry = HeadsUpManagerTestUtil.createEntry(/* id= */ 0, mContext)
        entry.row = testHelper.createRow()
        entry.row = kosmos.createRow()
        underTest.showNotification(entry, isPinnedByUser = true)

        val removedImmediately =
@@ -491,7 +489,7 @@ class HeadsUpManagerImplTest(flags: FlagsParameterization) : SysuiTestCase() {
        useAccessibilityTimeout(false)

        val entry = HeadsUpManagerTestUtil.createEntry(/* id= */ 0, mContext)
        entry.row = testHelper.createRow()
        entry.row = kosmos.createRow()
        underTest.showNotification(entry, isPinnedByUser = true)

        systemClock.advanceTime(
@@ -751,7 +749,7 @@ class HeadsUpManagerImplTest(flags: FlagsParameterization) : SysuiTestCase() {
        val notif = Notification.Builder(mContext, "").setSmallIcon(R.drawable.ic_person).build()
        notif.flags = FLAG_PROMOTED_ONGOING
        val notifEntry = HeadsUpManagerTestUtil.createEntry(/* id= */ 0, notif)
        val row = testHelper.createRow().apply { setPinnedStatus(PinnedStatus.PinnedBySystem) }
        val row = kosmos.createRow().apply { setPinnedStatus(PinnedStatus.PinnedBySystem) }
        notifEntry.row = row

        underTest.showNotification(notifEntry)
Loading