Loading packages/SystemUI/tests/src/com/android/systemui/statusbar/gesture/GenericGestureDetectorTest.kt +15 −30 Original line number Diff line number Diff line Loading @@ -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 Loading Loading @@ -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) Loading @@ -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) Loading @@ -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) { Loading Loading
packages/SystemUI/tests/src/com/android/systemui/statusbar/gesture/GenericGestureDetectorTest.kt +15 −30 Original line number Diff line number Diff line Loading @@ -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 Loading Loading @@ -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) Loading @@ -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) Loading @@ -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) { Loading