Home | History | Annotate | Download | only in cts
      1 /*
      2  * Copyright (C) 2015 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 static org.junit.Assert.assertFalse;
     20 import static org.junit.Assert.assertTrue;
     21 
     22 import android.os.Handler;
     23 import android.os.Looper;
     24 import android.support.test.annotation.UiThreadTest;
     25 import android.support.test.filters.MediumTest;
     26 import android.support.test.rule.ActivityTestRule;
     27 import android.support.test.runner.AndroidJUnit4;
     28 import android.view.ScaleGestureDetector;
     29 import android.view.ScaleGestureDetector.SimpleOnScaleGestureListener;
     30 
     31 import org.junit.Before;
     32 import org.junit.Rule;
     33 import org.junit.Test;
     34 import org.junit.runner.RunWith;
     35 
     36 @MediumTest
     37 @RunWith(AndroidJUnit4.class)
     38 public class ScaleGestureDetectorTest {
     39 
     40     private ScaleGestureDetector mScaleGestureDetector;
     41     private ScaleGestureDetectorCtsActivity mActivity;
     42 
     43     @Rule
     44     public ActivityTestRule<ScaleGestureDetectorCtsActivity> mActivityRule =
     45             new ActivityTestRule<>(ScaleGestureDetectorCtsActivity.class);
     46 
     47     @Before
     48     public void setup() {
     49         mActivity = mActivityRule.getActivity();
     50         mScaleGestureDetector = mActivity.getScaleGestureDetector();
     51     }
     52 
     53     @UiThreadTest
     54     @Test
     55     public void testConstructor() {
     56         new ScaleGestureDetector(
     57                 mActivity, new SimpleOnScaleGestureListener(), new Handler(Looper.getMainLooper()));
     58         new ScaleGestureDetector(mActivity, new SimpleOnScaleGestureListener());
     59     }
     60 
     61     @Test
     62     public void testAccessStylusScaleEnabled() {
     63         assertTrue(mScaleGestureDetector.isStylusScaleEnabled());
     64         mScaleGestureDetector.setStylusScaleEnabled(true);
     65 
     66         mScaleGestureDetector.setStylusScaleEnabled(false);
     67         assertFalse(mScaleGestureDetector.isStylusScaleEnabled());
     68     }
     69 }