CTS - Add scale gesture detector tests for constructor and stylus APIs
Bug: 21661739
Change-Id: I0da5dbd313cacd10c91a298808710fb7ac2391fb
diff --git a/tests/tests/view/AndroidManifest.xml b/tests/tests/view/AndroidManifest.xml
index 9ccbeb4..e5e77bc 100644
--- a/tests/tests/view/AndroidManifest.xml
+++ b/tests/tests/view/AndroidManifest.xml
@@ -150,7 +150,11 @@
<activity android:name="android.view.cts.GestureDetectorCtsActivity"
android:label="GestureDetectorCtsActivity"
android:theme="@android:style/Theme.NoTitleBar.Fullscreen" />
-
+
+ <activity android:name="android.view.cts.ScaleGestureDetectorCtsActivity"
+ android:label="ScaleGestureDetectorCtsActivity"
+ android:theme="@android:style/Theme.NoTitleBar.Fullscreen" />
+
<activity android:name="android.view.cts.GLSurfaceViewCtsActivity"
android:label="GLSurfaceViewCts"/>
diff --git a/tests/tests/view/src/android/view/cts/ScaleGestureDetectorCtsActivity.java b/tests/tests/view/src/android/view/cts/ScaleGestureDetectorCtsActivity.java
new file mode 100644
index 0000000..606d536
--- /dev/null
+++ b/tests/tests/view/src/android/view/cts/ScaleGestureDetectorCtsActivity.java
@@ -0,0 +1,40 @@
+/*
+ * Copyright (C) 2015 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.view.cts;
+
+import android.app.Activity;
+import android.os.Bundle;
+import android.os.Handler;
+import android.view.ScaleGestureDetector;
+import android.view.ScaleGestureDetector.SimpleOnScaleGestureListener;
+
+public class ScaleGestureDetectorCtsActivity extends Activity {
+
+ private ScaleGestureDetector mScaleGestureDetector;
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+
+ mScaleGestureDetector = new ScaleGestureDetector(this, new SimpleOnScaleGestureListener(),
+ new Handler());
+ }
+
+ public ScaleGestureDetector getScaleGestureDetector() {
+ return mScaleGestureDetector;
+ }
+}
\ No newline at end of file
diff --git a/tests/tests/view/src/android/view/cts/ScaleGestureDetectorTest.java b/tests/tests/view/src/android/view/cts/ScaleGestureDetectorTest.java
new file mode 100644
index 0000000..b8ba200
--- /dev/null
+++ b/tests/tests/view/src/android/view/cts/ScaleGestureDetectorTest.java
@@ -0,0 +1,60 @@
+/*
+ * Copyright (C) 2015 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.view.cts;
+
+import android.content.Context;
+import android.os.Handler;
+import android.os.Looper;
+import android.test.ActivityInstrumentationTestCase2;
+import android.test.UiThreadTest;
+import android.view.ScaleGestureDetector;
+import android.view.ScaleGestureDetector.SimpleOnScaleGestureListener;
+
+public class ScaleGestureDetectorTest extends
+ ActivityInstrumentationTestCase2<ScaleGestureDetectorCtsActivity> {
+
+ private ScaleGestureDetector mScaleGestureDetector;
+ private ScaleGestureDetectorCtsActivity mActivity;
+ private Context mContext;
+
+ public ScaleGestureDetectorTest() {
+ super("com.android.cts.view", ScaleGestureDetectorCtsActivity.class);
+ }
+
+ @Override
+ protected void setUp() throws Exception {
+ super.setUp();
+ mActivity = getActivity();
+ mScaleGestureDetector = mActivity.getScaleGestureDetector();
+ mContext = getInstrumentation().getTargetContext();
+ }
+
+ @UiThreadTest
+ public void testConstructor() {
+ new ScaleGestureDetector(
+ mContext, new SimpleOnScaleGestureListener(), new Handler(Looper.getMainLooper()));
+ new ScaleGestureDetector(mContext, new SimpleOnScaleGestureListener());
+ }
+
+ public void testAccessStylusScaleEnabled() {
+ assertTrue(mScaleGestureDetector.isStylusScaleEnabled());
+ mScaleGestureDetector.setStylusScaleEnabled(true);
+
+ mScaleGestureDetector.setStylusScaleEnabled(false);
+ assertFalse(mScaleGestureDetector.isStylusScaleEnabled());
+ }
+}
\ No newline at end of file