Bug 1441982 - Add GeckoSessionTestRule.synthesizeTap() r=jchen
authorJames Willcox <snorp@snorp.net>
Wed, 28 Feb 2018 15:26:34 -0500
changeset 461857 5c570aa49dfb8b5021f6b0ae50f50050d5f9bada
parent 461856 2a6f6866c736060c517778b95e7afcb498c50d03
child 461858 cf7689be97bcac8c139615250dcb59f0ea676275
push id1683
push usersfraser@mozilla.com
push dateThu, 26 Apr 2018 16:43:40 +0000
treeherdermozilla-release@5af6cb21869d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjchen
bugs1441982
milestone60.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1441982 - Add GeckoSessionTestRule.synthesizeTap() r=jchen MozReview-Commit-ID: AFV8i0RbttA
mobile/android/geckoview/src/androidTest/java/org/mozilla/geckoview/test/rule/GeckoSessionTestRule.java
mobile/android/geckoview/src/main/java/org/mozilla/gecko/gfx/NativePanZoomController.java
--- a/mobile/android/geckoview/src/androidTest/java/org/mozilla/geckoview/test/rule/GeckoSessionTestRule.java
+++ b/mobile/android/geckoview/src/androidTest/java/org/mozilla/geckoview/test/rule/GeckoSessionTestRule.java
@@ -1003,9 +1003,21 @@ public class GeckoSessionTestRule extend
      * #delegateDuringNextWait} can temporarily take precedence over delegates for
      * {@link #delegateUntilTestEnd}.
      *
      * @param callback Callback object, or null to clear all previously-set delegates.
      */
     public void delegateDuringNextWait(final Object callback) {
         mWaitScopeDelegates.delegate(callback);
     }
+
+    public void synthesizeTap(int x, int y) {
+        final long downTime = SystemClock.uptimeMillis();
+        final MotionEvent down = MotionEvent.obtain(downTime, SystemClock.uptimeMillis(),
+            MotionEvent.ACTION_DOWN, x, y, 0);
+
+        mSession.getPanZoomController().onTouchEvent(down);
+
+        final MotionEvent up = MotionEvent.obtain(downTime, SystemClock.uptimeMillis(),
+                MotionEvent.ACTION_UP, x, y, 0);
+        mSession.getPanZoomController().onTouchEvent(up);
+    }
 }
--- a/mobile/android/geckoview/src/main/java/org/mozilla/gecko/gfx/NativePanZoomController.java
+++ b/mobile/android/geckoview/src/main/java/org/mozilla/gecko/gfx/NativePanZoomController.java
@@ -454,17 +454,17 @@ public final class NativePanZoomControll
             eventType == MotionEvent.ACTION_HOVER_MOVE)
         {
             mPointerState.pointers.remove(pointerIndex);
         }
     }
 
     @WrapForJNI(calledFrom = "ui")
     private void synthesizeNativeTouchPoint(int pointerId, int eventType, int clientX,
-                                            int clientY, double pressure, int orientation) {
+                                           int clientY, double pressure, int orientation) {
         if (pointerId == PointerInfo.RESERVED_MOUSE_POINTER_ID) {
             throw new IllegalArgumentException("Pointer ID reserved for mouse");
         }
         synthesizeNativePointer(InputDevice.SOURCE_TOUCHSCREEN, pointerId,
                                 eventType, clientX, clientY, pressure, orientation);
     }
 
     @WrapForJNI(calledFrom = "ui")