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

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

Merge "Update flaky test to be more targeted" into main

parents 3f9bb2e1 3be3260a
Loading
Loading
Loading
Loading
+10 −15
Original line number Diff line number Diff line
@@ -27,7 +27,6 @@ import android.view.View
import android.view.ViewGroup
import android.widget.FrameLayout
import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.FlakyTest
import androidx.test.filters.SmallTest
import com.android.internal.R
import com.android.systemui.SysuiTestCase
@@ -171,29 +170,25 @@ class NotificationTemplateViewWrapperTest : SysuiTestCase() {
    }

    @Test
    @FlakyTest
    fun actionViewDetached_pendingIntentListenersDeregistered() {
        ViewUtils.detachView(root)
        val pi =
            PendingIntent.getActivity(
            Mockito.spy(PendingIntent.getActivity(
                mContext,
                System.currentTimeMillis().toInt(),
                Intent(Intent.ACTION_VIEW),
                PendingIntent.FLAG_IMMUTABLE
            )
        val spy = Mockito.spy(pi)
        createActionWithPendingIntent(spy)
        val wrapper = NotificationTemplateViewWrapper(mContext, view, row)
        wrapper.onContentUpdated(row)
        ViewUtils.attachView(root)
        looper.processAllMessages()
            ))
        val mockView = Mockito.mock(View::class.java)
        val handler = ActionPendingIntentCancellationHandler(pi, mockView, null)

        ViewUtils.detachView(root)
        handler.onViewAttachedToWindow(mockView)
        looper.processAllMessages()

        val captor = ArgumentCaptor.forClass(CancelListener::class.java)
        verify(spy, times(1)).registerCancelListener(captor.capture())
        verify(spy, times(1)).unregisterCancelListener(captor.value)
        verify(pi, times(1)).registerCancelListener(captor.capture())

        handler.onViewDetachedFromWindow(mockView)
        looper.processAllMessages()
        verify(pi, times(1)).unregisterCancelListener(captor.value)
    }

    @Test