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

Side by Side 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: fix nit 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « remoting/android/javatests/AndroidManifest.xml ('k') | remoting/remoting.gyp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 package org.chromium.chromoting;
6
7 import android.os.SystemClock;
8 import android.test.InstrumentationTestCase;
9 import android.test.suitebuilder.annotation.SmallTest;
10 import android.view.InputDevice;
11 import android.view.MotionEvent;
12
13 import org.chromium.base.test.util.Feature;
14
15 /** Tests for {@link SwipePinchDetector}. */
16 public class SwipePinchDetectorTest extends InstrumentationTestCase {
17 private SwipePinchDetector mDetector;
18 private MotionEvent.PointerProperties[] mPointers;
19
20 @Override
21 public void setUp() {
22 mDetector = new SwipePinchDetector(getInstrumentation().getTargetContext ());
23 MotionEvent.PointerProperties pointer0 = new MotionEvent.PointerProperti es();
24 pointer0.id = 0;
25 MotionEvent.PointerProperties pointer1 = new MotionEvent.PointerProperti es();
26 pointer1.id = 1;
27 mPointers = new MotionEvent.PointerProperties[] {pointer0, pointer1};
28 }
29
30 /** Verify that a simple swipe gesture is recognized as a swipe. */
31 @SmallTest
32 @Feature({"Chromoting"})
33 public void testSwipeRecognition() throws Exception {
34 final long eventTime = SystemClock.uptimeMillis();
35 MotionEvent.PointerCoords p0 = new MotionEvent.PointerCoords();
36 MotionEvent.PointerCoords p1 = new MotionEvent.PointerCoords();
37 p1.x = 50;
38 p1.y = 0;
39 MotionEvent.PointerCoords[] pointerCoords = {p0, p1};
40 MotionEvent event = MotionEvent.obtain(eventTime, eventTime,
41 MotionEvent.ACTION_POINTER_DOWN, 2, mPointers, pointerCoords, 0, 0, 1, 1, 0, 0,
42 InputDevice.SOURCE_TOUCHSCREEN , 0);
43 mDetector.onTouchEvent(event);
44 assertFalse(mDetector.isSwiping());
45 assertFalse(mDetector.isPinching());
46
47 // Any distance greater than the touch-slop threshold should work.
48 p0.y += 100;
49 p1.y += 100;
50
51 event = MotionEvent.obtain(eventTime, eventTime, MotionEvent.ACTION_MOVE , 2, mPointers,
52 pointerCoords, 0, 0, 1, 1, 0, 0, InputDevice.SOURCE_TOUCHSCREEN , 0);
53 mDetector.onTouchEvent(event);
54 assertTrue(mDetector.isSwiping());
55 assertFalse(mDetector.isPinching());
56 }
57 }
OLDNEW
« 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