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

Commit 13da4cf8 authored by Jeff DeCew's avatar Jeff DeCew Committed by Android (Google) Code Review
Browse files

Merge changes I2ed2843e,Ic53a4511 into main

* changes:
  Update notification wrapper tests to use the latest NotificationTestHelper
  Update NotificationGutsManagerTest to use the updated NotificationTestHelper
parents 1a9530df 8ff4e94e
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(
+1 −8
Original line number Diff line number Diff line
@@ -25,8 +25,6 @@ import android.graphics.drawable.AnimatedImageDrawable;
import android.graphics.drawable.Icon;
import android.os.Bundle;
import android.testing.AndroidTestingRunner;
import android.testing.TestableLooper;
import android.testing.TestableLooper.RunWithLooper;
import android.view.LayoutInflater;
import android.view.View;

@@ -44,7 +42,6 @@ import org.junit.runner.RunWith;

@RunWith(AndroidTestingRunner.class)
@SmallTest
@RunWithLooper
public class NotificationBigPictureTemplateViewWrapperTest extends SysuiTestCase {

    private View mView;
@@ -53,11 +50,7 @@ public class NotificationBigPictureTemplateViewWrapperTest extends SysuiTestCase

    @Before
    public void setup() throws Exception {
        allowTestableLooperAsMainThread();
        NotificationTestHelper helper = new NotificationTestHelper(
                mContext,
                mDependency,
                TestableLooper.get(this));
        NotificationTestHelper helper = new NotificationTestHelper(mContext, mDependency);
        mView = LayoutInflater.from(mContext).inflate(
                com.android.internal.R.layout.notification_template_material_big_picture, null);
        mRow = helper.createRow();
+1 −5
Original line number Diff line number Diff line
@@ -18,8 +18,6 @@ package com.android.systemui.statusbar.notification.row.wrapper

import android.graphics.drawable.AnimatedImageDrawable
import android.testing.AndroidTestingRunner
import android.testing.TestableLooper
import android.testing.TestableLooper.RunWithLooper
import android.view.View
import androidx.test.filters.SmallTest
import com.android.internal.R
@@ -41,7 +39,6 @@ import org.mockito.Mockito.`when` as whenever

@SmallTest
@RunWith(AndroidTestingRunner::class)
@RunWithLooper
class NotificationConversationTemplateViewWrapperTest : SysuiTestCase() {

    private lateinit var mRow: ExpandableNotificationRow
@@ -49,8 +46,7 @@ class NotificationConversationTemplateViewWrapperTest : SysuiTestCase() {

    @Before
    fun setUp() {
        allowTestableLooperAsMainThread()
        helper = NotificationTestHelper(mContext, mDependency, TestableLooper.get(this))
        helper = NotificationTestHelper(mContext, mDependency)
        mRow = helper.createRow()
    }

+1 −8
Original line number Diff line number Diff line
@@ -17,8 +17,6 @@
package com.android.systemui.statusbar.notification.row.wrapper;

import android.testing.AndroidTestingRunner;
import android.testing.TestableLooper;
import android.testing.TestableLooper.RunWithLooper;
import android.view.View;
import android.widget.RemoteViews;

@@ -36,18 +34,13 @@ import org.junit.runner.RunWith;

@SmallTest
@RunWith(AndroidTestingRunner.class)
@RunWithLooper
public class NotificationCustomViewWrapperTest extends SysuiTestCase {

    private ExpandableNotificationRow mRow;

    @Before
    public void setUp() throws Exception {
        allowTestableLooperAsMainThread();
        NotificationTestHelper helper = new NotificationTestHelper(
                mContext,
                mDependency,
                TestableLooper.get(this));
        NotificationTestHelper helper = new NotificationTestHelper(mContext, mDependency);
        mRow = helper.createRow();
    }

Loading