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

Commit 160b3801 authored by Caitlin Shkuratov's avatar Caitlin Shkuratov
Browse files

Run GenericGestureDetectorTest on main looper.

Fixes: 410582166
Flag: EXEMPT bugfix
Test: Patch ag/33026337 and run `atestGenericGestureDetectorTest` ->
verify test passes

Change-Id: Ieed9e69a0b47b538b3c1a9d5e99587fcf001c724
parent 1837c2e9
Loading
Loading
Loading
Loading
+15 −30
Original line number Diff line number Diff line
@@ -14,7 +14,7 @@ import org.junit.runner.RunWith

@SmallTest
@RunWith(AndroidJUnit4::class)
@TestableLooper.RunWithLooper
@TestableLooper.RunWithLooper(setAsMainLooper = true)
class GenericGestureDetectorTest : SysuiTestCase() {

    private lateinit var gestureDetector: TestGestureDetector
@@ -70,9 +70,7 @@ class GenericGestureDetectorTest : SysuiTestCase() {
    @Test
    fun onInputEvent_meetsGestureCriteria_allCallbacksNotified() {
        var callbackNotified = false
        gestureDetector.addOnGestureDetectedCallback("tag"){
            callbackNotified = true
        }
        gestureDetector.addOnGestureDetectedCallback("tag") { callbackNotified = true }

        gestureDetector.onInputEvent(
            MotionEvent.obtain(0, 0, MotionEvent.ACTION_DOWN, CORRECT_X, 0f, 0)
@@ -84,9 +82,7 @@ class GenericGestureDetectorTest : SysuiTestCase() {
    @Test
    fun onInputEvent_doesNotMeetGestureCriteria_callbackNotNotified() {
        var callbackNotified = false
        gestureDetector.addOnGestureDetectedCallback("tag"){
            callbackNotified = true
        }
        gestureDetector.addOnGestureDetectedCallback("tag") { callbackNotified = true }

        gestureDetector.onInputEvent(
            MotionEvent.obtain(0, 0, MotionEvent.ACTION_DOWN, CORRECT_X - 5, 0f, 0)
@@ -98,30 +94,19 @@ class GenericGestureDetectorTest : SysuiTestCase() {
    @Test
    fun callbackUnregisteredThenGestureDetected_oldCallbackNotNotified() {
        var oldCallbackNotified = false
        gestureDetector.addOnGestureDetectedCallback("tag"){
            oldCallbackNotified = true
        }
        gestureDetector.addOnGestureDetectedCallback("tag") { oldCallbackNotified = true }
        gestureDetector.addOnGestureDetectedCallback("tag2") {}

        gestureDetector.removeOnGestureDetectedCallback("tag")
        gestureDetector.onInputEvent(
            MotionEvent.obtain(
                0,
                0,
                MotionEvent.ACTION_DOWN,
                CORRECT_X,
                0f,
                0
            )
            MotionEvent.obtain(0, 0, MotionEvent.ACTION_DOWN, CORRECT_X, 0f, 0)
        )

        assertThat(oldCallbackNotified).isFalse()
    }

    inner class TestGestureDetector : GenericGestureDetector(
            "fakeTag",
            displayTracker.defaultDisplayId
    ) {
    inner class TestGestureDetector :
        GenericGestureDetector("fakeTag", displayTracker.defaultDisplayId) {
        var isGestureListening = false

        override fun onInputEvent(ev: InputEvent) {