Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(165)

Unified Diff: remoting/android/javatests/src/org/chromium/chromoting/SwipePinchDetectorTest.java

Issue 115953003: Add unit instrumentation tests for Chromoting Android code. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Update targetSdkVersion, also add JavaDoc to silence presubmit Created 7 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « remoting/android/javatests/AndroidManifest.xml ('k') | remoting/remoting.gyp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: remoting/android/javatests/src/org/chromium/chromoting/SwipePinchDetectorTest.java
diff --git a/remoting/android/javatests/src/org/chromium/chromoting/SwipePinchDetectorTest.java b/remoting/android/javatests/src/org/chromium/chromoting/SwipePinchDetectorTest.java
new file mode 100644
index 0000000000000000000000000000000000000000..43cd3e09f5a9353a443c8aa5885a88930ecd686a
--- /dev/null
+++ b/remoting/android/javatests/src/org/chromium/chromoting/SwipePinchDetectorTest.java
@@ -0,0 +1,59 @@
+// Copyright 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+package org.chromium.chromoting;
Sergey Ulanov 2013/12/19 19:45:27 Not related to this CL: I think we should rename i
+
+import android.os.SystemClock;
+import android.test.InstrumentationTestCase;
+import android.test.suitebuilder.annotation.SmallTest;
+import android.view.InputDevice;
+import android.view.MotionEvent;
+
+import org.chromium.base.test.util.Feature;
+
+/** Tests for {@link SwipePinchDetector}. */
+public class SwipePinchDetectorTest extends InstrumentationTestCase {
+ private SwipePinchDetector mDetector;
+ private MotionEvent.PointerProperties[] mPointers;
+
+ @Override
+ public void setUp() {
+ mDetector = new SwipePinchDetector(getInstrumentation().getTargetContext());
+ MotionEvent.PointerProperties pointer0 = new MotionEvent.PointerProperties();
+ pointer0.id = 0;
+ MotionEvent.PointerProperties pointer1 = new MotionEvent.PointerProperties();
+ pointer1.id = 1;
+ mPointers = new MotionEvent.PointerProperties[] {pointer0, pointer1};
+ }
+
+ /** Verify that a simple swipe gesture is recognized as a swipe. */
+ @SmallTest
+ @Feature({"Chromoting"})
Sergey Ulanov 2013/12/19 19:45:27 RemotingClientUI?
Lambros 2013/12/20 02:52:01 Guidance here: http://www.chromium.org/developers/
+ public void testSwipeRecognition() throws Exception {
+ final long eventTime = SystemClock.uptimeMillis();
+ MotionEvent.PointerCoords p0 = new MotionEvent.PointerCoords();
+ MotionEvent.PointerCoords p1 = new MotionEvent.PointerCoords();
+ p0.x = 0;
+ p0.y = 0;
Sergey Ulanov 2013/12/19 19:45:27 nit: x and y should be initialized to 0 by default
Lambros 2013/12/20 02:52:01 Done. I've kept the p1.y = 0 because it looks real
+ p1.x = 50;
+ p1.y = 0;
+ MotionEvent.PointerCoords[] pointerCoords = {p0, p1};
+ MotionEvent event = MotionEvent.obtain(eventTime, eventTime,
+ MotionEvent.ACTION_POINTER_DOWN, 2, mPointers, pointerCoords, 0, 0, 1, 1, 0, 0,
+ InputDevice.SOURCE_TOUCHSCREEN , 0);
+ mDetector.onTouchEvent(event);
+ assertFalse(mDetector.isSwiping());
+ assertFalse(mDetector.isPinching());
+
+ // Any distance greater than the touch-slop threshold should work.
+ p0.y += 100;
+ p1.y += 100;
+
+ event = MotionEvent.obtain(eventTime, eventTime, MotionEvent.ACTION_MOVE, 2, mPointers,
+ pointerCoords, 0, 0, 1, 1, 0, 0, InputDevice.SOURCE_TOUCHSCREEN , 0);
+ mDetector.onTouchEvent(event);
+ assertTrue(mDetector.isSwiping());
+ assertFalse(mDetector.isPinching());
+ }
+}
« no previous file with comments | « remoting/android/javatests/AndroidManifest.xml ('k') | remoting/remoting.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698