Merge "Fix ActivityLaunchAnimatorTest crash" into sc-dev am: 94240f3acd

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/15283591

Change-Id: Ifcd086ad37722e227889fced6a080d4b64f7f9b5
This commit is contained in:
Jordan Demeulenaere
2021-07-16 01:47:55 +00:00
committed by Automerger Merge Worker

View File

@@ -10,6 +10,7 @@ import android.graphics.Rect
import android.os.Looper import android.os.Looper
import android.testing.AndroidTestingRunner import android.testing.AndroidTestingRunner
import android.testing.TestableLooper.RunWithLooper import android.testing.TestableLooper.RunWithLooper
import android.util.Log
import android.view.IRemoteAnimationFinishedCallback import android.view.IRemoteAnimationFinishedCallback
import android.view.RemoteAnimationAdapter import android.view.RemoteAnimationAdapter
import android.view.RemoteAnimationTarget import android.view.RemoteAnimationTarget
@@ -27,6 +28,7 @@ import junit.framework.Assert.assertNotNull
import junit.framework.Assert.assertNull import junit.framework.Assert.assertNull
import junit.framework.Assert.assertTrue import junit.framework.Assert.assertTrue
import junit.framework.AssertionFailedError import junit.framework.AssertionFailedError
import kotlin.concurrent.thread
import org.junit.Before import org.junit.Before
import org.junit.Rule import org.junit.Rule
import org.junit.Test import org.junit.Test
@@ -39,7 +41,6 @@ import org.mockito.Mockito.never
import org.mockito.Mockito.verify import org.mockito.Mockito.verify
import org.mockito.Spy import org.mockito.Spy
import org.mockito.junit.MockitoJUnit import org.mockito.junit.MockitoJUnit
import kotlin.concurrent.thread
@SmallTest @SmallTest
@RunWith(AndroidTestingRunner::class) @RunWith(AndroidTestingRunner::class)
@@ -50,6 +51,7 @@ class ActivityLaunchAnimatorTest : SysuiTestCase() {
@Spy private val controller = TestLaunchAnimatorController(launchContainer) @Spy private val controller = TestLaunchAnimatorController(launchContainer)
@Mock lateinit var iCallback: IRemoteAnimationFinishedCallback @Mock lateinit var iCallback: IRemoteAnimationFinishedCallback
@Mock lateinit var startingSurface: StartingSurface @Mock lateinit var startingSurface: StartingSurface
@Mock lateinit var failHandler: Log.TerribleFailureHandler
private lateinit var activityLaunchAnimator: ActivityLaunchAnimator private lateinit var activityLaunchAnimator: ActivityLaunchAnimator
@get:Rule val rule = MockitoJUnit.rule() @get:Rule val rule = MockitoJUnit.rule()
@@ -179,8 +181,10 @@ class ActivityLaunchAnimatorTest : SysuiTestCase() {
} }
@Test @Test
fun controllerFromOrphanViewReturnsNull() { fun controllerFromOrphanViewReturnsNullAndIsATerribleFailure() {
Log.setWtfHandler(failHandler)
assertNull(ActivityLaunchAnimator.Controller.fromView(View(mContext))) assertNull(ActivityLaunchAnimator.Controller.fromView(View(mContext)))
verify(failHandler).onTerribleFailure(any(), any(), anyBoolean())
} }
private fun fakeWindow(): RemoteAnimationTarget { private fun fakeWindow(): RemoteAnimationTarget {