From 31c8b3bd611250331c96e26d9f1b9bc896e62713 Mon Sep 17 00:00:00 2001 From: Dave Miller Date: Thu, 12 May 2016 10:00:06 -0700 Subject: [PATCH] Add some defensive loggin in Android touch handling Reviewed By: andreicoman11 Differential Revision: D3292369 fbshipit-source-id: 43315f7d8e81f1a0ec238c08c3cb689e6648fd0b --- .../react/uimanager/events/TouchEventCoalescingKeyHelper.java | 4 ++++ .../src/test/java/com/facebook/react/RootViewTest.java | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/ReactAndroid/src/main/java/com/facebook/react/uimanager/events/TouchEventCoalescingKeyHelper.java b/ReactAndroid/src/main/java/com/facebook/react/uimanager/events/TouchEventCoalescingKeyHelper.java index e5783e3c5..16fb9ae4a 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/uimanager/events/TouchEventCoalescingKeyHelper.java +++ b/ReactAndroid/src/main/java/com/facebook/react/uimanager/events/TouchEventCoalescingKeyHelper.java @@ -81,6 +81,10 @@ public class TouchEventCoalescingKeyHelper { * Stops tracking a new coalescing key corresponding to the gesture with this down time. */ public static void removeCoalescingKey(long downTime) { + int currentValue = sDownTimeToCoalescingKey.get((int) downTime, -1); + if (currentValue == -1) { + throw new RuntimeException("Tried to remove non-existent cookie"); + } sDownTimeToCoalescingKey.delete((int) downTime); } } diff --git a/ReactAndroid/src/test/java/com/facebook/react/RootViewTest.java b/ReactAndroid/src/test/java/com/facebook/react/RootViewTest.java index 2eb7f5ed8..679ce6edd 100644 --- a/ReactAndroid/src/test/java/com/facebook/react/RootViewTest.java +++ b/ReactAndroid/src/test/java/com/facebook/react/RootViewTest.java @@ -162,7 +162,7 @@ public class RootViewTest { ArgumentCaptor.forClass(JavaOnlyArray.class); rootView.onTouchEvent( - MotionEvent.obtain(50, ts, MotionEvent.ACTION_UP, 0, 0, 0)); + MotionEvent.obtain(100, ts, MotionEvent.ACTION_UP, 0, 0, 0)); verify(eventDispatcher).dispatchEvent(upEventCaptor.capture()); verifyNoMoreInteractions(eventDispatcher);