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

Commit 1ecab4d0 authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Deflake NotificationTemplateViewWrapperTest" into main

parents b0e7976e 3d5bc263
Loading
Loading
Loading
Loading
+7 −1
Original line number Diff line number Diff line
@@ -38,7 +38,8 @@ import android.widget.ImageView;
import android.widget.ProgressBar;
import android.widget.TextView;

import com.android.internal.annotations.VisibleForTesting;
import androidx.annotation.VisibleForTesting;

import com.android.internal.util.ContrastColorUtil;
import com.android.internal.widget.NotificationActionListLayout;
import com.android.systemui.Dependency;
@@ -454,6 +455,11 @@ public class NotificationTemplateViewWrapper extends NotificationHeaderViewWrapp
            return sUiOffloadThread;
        }

        @VisibleForTesting(otherwise = VisibleForTesting.NONE)
        static void resetUiOffloadThread() {
            sUiOffloadThread = null;
        }

        private final View mView;
        private final Consumer<PendingIntent> mOnCancelledCallback;

+14 −10
Original line number Diff line number Diff line
@@ -67,8 +67,10 @@ class NotificationTemplateViewWrapperTest : SysuiTestCase() {
        // Use main thread instead of UI offload thread to fix flakes.
        mDependency.injectTestDependency(
            UiOffloadThread::class.java,
            TestUiOffloadThread(looper.looper)
            TestUiOffloadThread(looper.looper),
        )
        // Clear statically-cached data, in case this class was used before.
        ActionPendingIntentCancellationHandler.resetUiOffloadThread()

        row = kosmos.createRow()
        // Some code in the view iterates through parents so we need some extra containers around
@@ -178,12 +180,14 @@ class NotificationTemplateViewWrapperTest : SysuiTestCase() {
    @Test
    fun actionViewDetached_pendingIntentListenersDeregistered() {
        val pi =
            Mockito.spy(PendingIntent.getActivity(
            Mockito.spy(
                PendingIntent.getActivity(
                    mContext,
                    System.currentTimeMillis().toInt(),
                    Intent(Intent.ACTION_VIEW),
                PendingIntent.FLAG_IMMUTABLE
            ))
                    PendingIntent.FLAG_IMMUTABLE,
                )
            )
        val mockView = Mockito.mock(View::class.java)
        val handler = ActionPendingIntentCancellationHandler(pi, mockView, null)

@@ -204,7 +208,7 @@ class NotificationTemplateViewWrapperTest : SysuiTestCase() {
                mContext,
                System.currentTimeMillis().toInt(),
                Intent(Intent.ACTION_VIEW),
                PendingIntent.FLAG_IMMUTABLE
                PendingIntent.FLAG_IMMUTABLE,
            )
        val spy = Mockito.spy(pi)
        val action = createActionWithPendingIntent(spy)
@@ -224,7 +228,7 @@ class NotificationTemplateViewWrapperTest : SysuiTestCase() {
                mContext,
                System.currentTimeMillis().toInt(),
                Intent(Intent.ACTION_ALARM_CHANGED),
                PendingIntent.FLAG_IMMUTABLE
                PendingIntent.FLAG_IMMUTABLE,
            )
        action.setTagInternal(R.id.pending_intent_tag, newPi)
        wrapper.onContentUpdated(row)
@@ -246,7 +250,7 @@ class NotificationTemplateViewWrapperTest : SysuiTestCase() {
                mContext,
                System.currentTimeMillis().toInt(),
                Intent(Intent.ACTION_VIEW),
                PendingIntent.FLAG_IMMUTABLE
                PendingIntent.FLAG_IMMUTABLE,
            )
        return createActionWithPendingIntent(pi)
    }