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

Commit 93db50e6 authored by Jeff DeCew's avatar Jeff DeCew
Browse files

Update NotificationGutsManagerTest to use the updated NotificationTestHelper

Change-Id: Ic53a451129b6e55e51896eb30751ff26467835fd
parent c74bc460
Loading
Loading
Loading
Loading
+11 −13
Original line number Diff line number Diff line
@@ -23,6 +23,7 @@ import static android.app.NotificationManager.IMPORTANCE_DEFAULT;
import static android.app.NotificationManager.IMPORTANCE_HIGH;
import static android.service.notification.NotificationListenerService.Ranking.USER_SENTIMENT_NEGATIVE;

import static com.android.systemui.concurrency.FakeExecutorKosmosKt.getFakeExecutor;
import static com.android.systemui.statusbar.NotificationEntryHelper.modifyRanking;

import static junit.framework.Assert.assertNotNull;
@@ -124,12 +125,11 @@ public class NotificationGutsManagerTest extends SysuiTestCase {
    private NotificationChannel mTestNotificationChannel = new NotificationChannel(
            TEST_CHANNEL_ID, TEST_CHANNEL_ID, IMPORTANCE_DEFAULT);

    private KosmosJavaAdapter mKosmos = new KosmosJavaAdapter(this);
    private TestScope mTestScope = mKosmos.getTestScope();
    private JavaAdapter mJavaAdapter = new JavaAdapter(mTestScope.getBackgroundScope());
    private FakeExecutor mExecutor = new FakeExecutor(new FakeSystemClock());
    private TestableLooper mTestableLooper;
    private Handler mHandler;
    private final KosmosJavaAdapter mKosmos = new KosmosJavaAdapter(this);
    private final TestScope mTestScope = mKosmos.getTestScope();
    private final JavaAdapter mJavaAdapter = new JavaAdapter(mTestScope.getBackgroundScope());
    private final FakeExecutor mExecutor = mKosmos.getFakeExecutor();
    private final Handler mHandler = mKosmos.getFakeExecutorHandler();
    private NotificationTestHelper mHelper;
    private NotificationGutsManager mGutsManager;

@@ -171,10 +171,8 @@ public class NotificationGutsManagerTest extends SysuiTestCase {

    @Before
    public void setUp() {
        mTestableLooper = TestableLooper.get(this);
        allowTestableLooperAsMainThread();
        mHandler = Handler.createAsync(mTestableLooper.getLooper());
        mHelper = new NotificationTestHelper(mContext, mDependency, TestableLooper.get(this));
        mHelper = new NotificationTestHelper(mContext, mDependency);
        when(mAccessibilityManager.isTouchExplorationEnabled()).thenReturn(false);

        mWindowRootViewVisibilityInteractor = new WindowRootViewVisibilityInteractor(
@@ -248,7 +246,7 @@ public class NotificationGutsManagerTest extends SysuiTestCase {

        assertTrue(mGutsManager.openGutsInternal(row, 0, 0, menuItem));
        assertEquals(View.INVISIBLE, guts.getVisibility());
        mTestableLooper.processAllMessages();
        mExecutor.runAllReady();
        verify(guts).openControls(
                anyInt(),
                anyInt(),
@@ -261,7 +259,7 @@ public class NotificationGutsManagerTest extends SysuiTestCase {

        verify(guts).closeControls(anyBoolean(), anyBoolean(), anyInt(), anyInt(), anyBoolean());
        verify(row, times(1)).setGutsView(any());
        mTestableLooper.processAllMessages();
        mExecutor.runAllReady();
        verify(mHeadsUpManager).setGutsShown(realRow.getEntry(), false);
    }

@@ -352,7 +350,7 @@ public class NotificationGutsManagerTest extends SysuiTestCase {
        when(entry.getGuts()).thenReturn(guts);

        assertTrue(mGutsManager.openGutsInternal(row, 0, 0, menuItem));
        mTestableLooper.processAllMessages();
        mExecutor.runAllReady();
        verify(guts).openControls(
                anyInt(),
                anyInt(),
@@ -365,7 +363,7 @@ public class NotificationGutsManagerTest extends SysuiTestCase {
        row.onDensityOrFontScaleChanged();
        mGutsManager.onDensityOrFontScaleChanged(entry);

        mTestableLooper.processAllMessages();
        mExecutor.runAllReady();

        mGutsManager.closeAndSaveGuts(false, false, false, 0, 0, false);

+9 −14
Original line number Diff line number Diff line
@@ -27,12 +27,11 @@ import android.content.pm.ShortcutManager
import android.content.pm.launcherApps
import android.graphics.Color
import android.os.Binder
import android.os.Handler
import android.os.fakeExecutorHandler
import android.os.userManager
import android.provider.Settings
import android.service.notification.NotificationListenerService.Ranking
import android.testing.AndroidTestingRunner
import android.testing.TestableLooper
import android.testing.TestableLooper.RunWithLooper
import android.util.ArraySet
import android.view.View
@@ -45,6 +44,7 @@ import com.android.internal.logging.metricsLogger
import com.android.internal.logging.testing.UiEventLoggerFake
import com.android.internal.statusbar.statusBarService
import com.android.systemui.SysuiTestCase
import com.android.systemui.concurrency.fakeExecutor
import com.android.systemui.keyguard.data.repository.FakeKeyguardRepository
import com.android.systemui.kosmos.testScope
import com.android.systemui.people.widget.PeopleSpaceWidgetManager
@@ -71,9 +71,7 @@ import com.android.systemui.statusbar.notificationLockscreenUserManager
import com.android.systemui.statusbar.policy.deviceProvisionedController
import com.android.systemui.statusbar.policy.headsUpManager
import com.android.systemui.testKosmos
import com.android.systemui.util.concurrency.FakeExecutor
import com.android.systemui.util.kotlin.JavaAdapter
import com.android.systemui.util.time.FakeSystemClock
import com.android.systemui.wmshell.BubblesManager
import java.util.Optional
import junit.framework.Assert
@@ -106,9 +104,8 @@ class NotificationGutsManagerWithScenesTest : SysuiTestCase() {
    private val kosmos = testKosmos()
    private val testScope = kosmos.testScope
    private val javaAdapter = JavaAdapter(testScope.backgroundScope)
    private val executor = FakeExecutor(FakeSystemClock())
    private lateinit var testableLooper: TestableLooper
    private lateinit var handler: Handler
    private val executor = kosmos.fakeExecutor
    private val handler = kosmos.fakeExecutorHandler
    private lateinit var helper: NotificationTestHelper
    private lateinit var gutsManager: NotificationGutsManager
    private lateinit var windowRootViewVisibilityInteractor: WindowRootViewVisibilityInteractor
@@ -148,10 +145,8 @@ class NotificationGutsManagerWithScenesTest : SysuiTestCase() {
        MockitoAnnotations.initMocks(this)
        val sceneContainerFlags = kosmos.fakeSceneContainerFlags
        sceneContainerFlags.enabled = true
        testableLooper = TestableLooper.get(this)
        allowTestableLooperAsMainThread()
        handler = Handler.createAsync(testableLooper.getLooper())
        helper = NotificationTestHelper(mContext, mDependency, TestableLooper.get(this))
        helper = NotificationTestHelper(mContext, mDependency)
        Mockito.`when`(accessibilityManager.isTouchExplorationEnabled).thenReturn(false)
        windowRootViewVisibilityInteractor =
            WindowRootViewVisibilityInteractor(
@@ -227,7 +222,7 @@ class NotificationGutsManagerWithScenesTest : SysuiTestCase() {
        Mockito.`when`(row.guts).thenReturn(guts)
        Assert.assertTrue(gutsManager.openGutsInternal(row, 0, 0, menuItem))
        assertEquals(View.INVISIBLE.toLong(), guts.visibility.toLong())
        testableLooper.processAllMessages()
        executor.runAllReady()
        verify(guts)
            .openControls(
                ArgumentMatchers.anyInt(),
@@ -247,7 +242,7 @@ class NotificationGutsManagerWithScenesTest : SysuiTestCase() {
                ArgumentMatchers.anyBoolean()
            )
        verify(row, Mockito.times(1)).setGutsView(ArgumentMatchers.any())
        testableLooper.processAllMessages()
        executor.runAllReady()
        verify(headsUpManager).setGutsShown(realRow.entry, false)
    }

@@ -343,7 +338,7 @@ class NotificationGutsManagerWithScenesTest : SysuiTestCase() {
        Mockito.`when`(entry.row).thenReturn(row)
        Mockito.`when`(entry.getGuts()).thenReturn(guts)
        Assert.assertTrue(gutsManager.openGutsInternal(row, 0, 0, menuItem))
        testableLooper.processAllMessages()
        executor.runAllReady()
        verify(guts)
            .openControls(
                ArgumentMatchers.anyInt(),
@@ -356,7 +351,7 @@ class NotificationGutsManagerWithScenesTest : SysuiTestCase() {
        verify(row).setGutsView(ArgumentMatchers.any())
        row.onDensityOrFontScaleChanged()
        gutsManager.onDensityOrFontScaleChanged(entry)
        testableLooper.processAllMessages()
        executor.runAllReady()
        gutsManager.closeAndSaveGuts(false, false, false, 0, 0, false)
        verify(guts)
            .closeControls(
+4 −0
Original line number Diff line number Diff line
@@ -19,6 +19,7 @@
package com.android.systemui.kosmos

import android.content.applicationContext
import android.os.fakeExecutorHandler
import com.android.systemui.SysuiTestCase
import com.android.systemui.bouncer.data.repository.bouncerRepository
import com.android.systemui.bouncer.domain.interactor.simBouncerInteractor
@@ -27,6 +28,7 @@ import com.android.systemui.common.ui.data.repository.fakeConfigurationRepositor
import com.android.systemui.common.ui.domain.interactor.configurationInteractor
import com.android.systemui.communal.data.repository.fakeCommunalRepository
import com.android.systemui.communal.domain.interactor.communalInteractor
import com.android.systemui.concurrency.fakeExecutor
import com.android.systemui.deviceentry.domain.interactor.deviceEntryInteractor
import com.android.systemui.deviceentry.domain.interactor.deviceUnlockedInteractor
import com.android.systemui.flags.fakeFeatureFlagsClassic
@@ -64,6 +66,8 @@ class KosmosJavaAdapter(
    val testScope by lazy { kosmos.testScope }
    val fakeFeatureFlags by lazy { kosmos.fakeFeatureFlagsClassic }
    val fakeSceneContainerFlags by lazy { kosmos.fakeSceneContainerFlags }
    val fakeExecutor by lazy { kosmos.fakeExecutor }
    val fakeExecutorHandler by lazy { kosmos.fakeExecutorHandler }
    val configurationRepository by lazy { kosmos.fakeConfigurationRepository }
    val configurationInteractor by lazy { kosmos.configurationInteractor }
    val bouncerRepository by lazy { kosmos.bouncerRepository }