• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2008 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 package android.view.cts;
18 
19 import android.test.InstrumentationTestCase;
20 import android.test.TouchUtils;
21 import android.view.View;
22 
23 class GestureDetectorTestUtil {
24 
25     /**
26      * Test GestureDetector.SimpleOnGestureListener
27      * @param testcase InstrumentationTestCase
28      * @param activity GestureDetectorStubActivity
29      */
testGestureDetector(InstrumentationTestCase testcase, GestureDetectorStubActivity activity)30     public static void testGestureDetector(InstrumentationTestCase testcase,
31             GestureDetectorStubActivity activity) {
32         View view = activity.getView();
33         TouchUtils.clickView(testcase, view);
34         TouchUtils.longClickView(testcase, view);
35         TouchUtils.scrollToBottom(testcase, activity, activity.getViewGroup());
36         TouchUtils.touchAndCancelView(testcase, view);
37         int fromX = 1;
38         int toX = 10;
39         // Y has to be outside the status bar bounding box
40         int fromY = 50;
41         int toY = 100;
42         int stepCount = 20;
43         TouchUtils.drag(testcase, fromX, toX, fromY, toY, stepCount);
44         InstrumentationTestCase.assertTrue(activity.isDown);
45         InstrumentationTestCase.assertTrue(activity.isScroll);
46         InstrumentationTestCase.assertTrue(activity.isFling);
47         InstrumentationTestCase.assertTrue(activity.isSingleTapUp);
48         InstrumentationTestCase.assertTrue(activity.onLongPress);
49         InstrumentationTestCase.assertTrue(activity.onShowPress);
50         InstrumentationTestCase.assertTrue(activity.onSingleTapConfirmed);
51 
52         // Test onDoubleTap
53         InstrumentationTestCase.assertFalse(activity.onDoubleTap);
54         InstrumentationTestCase.assertFalse(activity.onDoubleTapEvent);
55         TouchUtils.tapView(testcase, view);
56         TouchUtils.tapView(testcase, view);
57         InstrumentationTestCase.assertTrue(activity.onDoubleTap);
58         InstrumentationTestCase.assertTrue(activity.onDoubleTapEvent);
59     }
60 }
61