Remove timeout from dispatch latch
When debugging event dispatching, the time spent in the dispatch
callback is typically longer than the 5 second timeout. Removing the
timeout is acceptable, as this only affects tests.
Fixes: 157901289
Test: ./gradlew ui:ui-test:cC
Change-Id: I714703e25dd590aed72f00fbe9b0b5bd6865cd26
diff --git a/ui/ui-test/src/main/java/androidx/ui/test/android/AndroidInputDispatcher.kt b/ui/ui-test/src/main/java/androidx/ui/test/android/AndroidInputDispatcher.kt
index 59de9f6..556b1ac 100644
--- a/ui/ui-test/src/main/java/androidx/ui/test/android/AndroidInputDispatcher.kt
+++ b/ui/ui-test/src/main/java/androidx/ui/test/android/AndroidInputDispatcher.kt
@@ -19,6 +19,7 @@
import android.os.Handler
import android.os.Looper
import android.os.SystemClock
+import android.util.Log
import android.view.MotionEvent
import android.view.MotionEvent.ACTION_CANCEL
import android.view.MotionEvent.ACTION_DOWN
@@ -26,11 +27,11 @@
import android.view.MotionEvent.ACTION_POINTER_DOWN
import android.view.MotionEvent.ACTION_POINTER_UP
import android.view.MotionEvent.ACTION_UP
+import androidx.ui.geometry.Offset
import androidx.ui.test.InputDispatcher
import androidx.ui.test.InputDispatcherState
import androidx.ui.test.PartialGesture
import androidx.ui.unit.Duration
-import androidx.ui.geometry.Offset
import androidx.ui.unit.inMilliseconds
import androidx.ui.unit.milliseconds
import androidx.ui.util.lerp
@@ -397,8 +398,10 @@
latch.countDown()
}
}
- check(latch.await(5, TimeUnit.SECONDS)) {
- "Event $event was not dispatched in 5 seconds"
+ if (!latch.await(5, TimeUnit.SECONDS)) {
+ Log.w("AndroidInputDispatcher", "Dispatching of MotionEvent $event took longer than " +
+ "5 seconds to complete. This should typically only take a few milliseconds.")
+ latch.await()
}
}