Chromium Code Reviews| OLD | NEW |
|---|---|
| (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 public class SwipePinchDetectorTest extends InstrumentationTestCase { | |
| 16 private SwipePinchDetector mDetector; | |
| 17 private MotionEvent.PointerProperties[] mPointers; | |
| 18 | |
| 19 @Override | |
| 20 public void setUp() { | |
| 21 mDetector = new SwipePinchDetector(getInstrumentation().getTargetContext ()); | |
| 22 MotionEvent.PointerProperties pointer0 = new MotionEvent.PointerProperti es(); | |
| 23 pointer0.id = 0; | |
| 24 MotionEvent.PointerProperties pointer1 = new MotionEvent.PointerProperti es(); | |
| 25 pointer1.id = 1; | |
| 26 mPointers = new MotionEvent.PointerProperties[] {pointer0, pointer1}; | |
| 27 } | |
| 28 | |
| 29 /** Verify that a simple swipe gesture is recognized as a swipe. */ | |
| 30 @SmallTest | |
| 31 @Feature({"Chromoting"}) | |
| 32 public void testSwipeRecognition() throws Exception { | |
| 33 final long eventTime = SystemClock.uptimeMillis(); | |
| 34 MotionEvent.PointerCoords p0 = new MotionEvent.PointerCoords(); | |
| 35 MotionEvent.PointerCoords p1 = new MotionEvent.PointerCoords(); | |
| 36 p0.x = 0; | |
| 37 p0.y = 0; | |
| 38 p1.x = 50; | |
| 39 p1.y = 0; | |
| 40 MotionEvent.PointerCoords[] pointerCoords = {p0, p1}; | |
| 41 MotionEvent event = MotionEvent.obtain(eventTime, eventTime, | |
|
frankf
2013/12/18 00:10:03
There are utilities for MotionEvent to reduce boil
Lambros
2013/12/19 02:09:18
The main issue is that TouchCommon.java is under c
frankf
2013/12/19 02:21:38
Yea, org.chromium.base.test.util might be a good p
| |
| 42 MotionEvent.ACTION_POINTER_DOWN, 2, mPointers, pointerCoords, 0, 0, 1, 1, 0, 0, | |
| 43 InputDevice.SOURCE_TOUCHSCREEN , 0); | |
| 44 mDetector.onTouchEvent(event); | |
| 45 assertFalse(mDetector.isSwiping()); | |
| 46 assertFalse(mDetector.isPinching()); | |
| 47 | |
| 48 // Any distance greater than the touch-slop threshold should work. | |
| 49 p0.y += 100; | |
| 50 p1.y += 100; | |
| 51 | |
| 52 event = MotionEvent.obtain(eventTime, eventTime, MotionEvent.ACTION_MOVE , 2, mPointers, | |
| 53 pointerCoords, 0, 0, 1, 1, 0, 0, InputDevice.SOURCE_TOUCHSCREEN , 0); | |
| 54 mDetector.onTouchEvent(event); | |
| 55 assertTrue(mDetector.isSwiping()); | |
| 56 assertFalse(mDetector.isPinching()); | |
| 57 } | |
| 58 } | |
| OLD | NEW |