Home | History | Annotate | Download | only in touchmode
      1 /*
      2  * Copyright (C) 2007 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.widget.touchmode;
     18 
     19 import android.widget.layout.linear.LLOfTwoFocusableInTouchMode;
     20 
     21 import android.test.ActivityInstrumentationTestCase2;
     22 import android.test.TouchUtils;
     23 import android.test.suitebuilder.annotation.LargeTest;
     24 import android.test.suitebuilder.annotation.MediumTest;
     25 
     26 public class FocusableInTouchModeClickTest extends ActivityInstrumentationTestCase2<LLOfTwoFocusableInTouchMode> {
     27 
     28     public FocusableInTouchModeClickTest() {
     29         super("com.android.frameworks.coretests", LLOfTwoFocusableInTouchMode.class);
     30     }
     31 
     32     protected void setUp() throws Exception {
     33         super.setUp();
     34         setActivityInitialTouchMode(true);
     35     }
     36 
     37     @MediumTest
     38     public void testPreconditions() {
     39         assertTrue("should start in touch mode", getActivity().getButton1().isInTouchMode());
     40         assertTrue(getActivity().getButton1().isFocused());
     41     }
     42 
     43     @LargeTest
     44     public void testClickGivesFocusNoClickFired() {
     45         TouchUtils.clickView(this, getActivity().getButton2());
     46         assertTrue("click should give focusable in touch mode focus",
     47                 getActivity().getButton2().isFocused());
     48         assertFalse("getting focus should result in no on click",
     49                 getActivity().isB2Fired());
     50 
     51         TouchUtils.clickView(this, getActivity().getButton2());
     52         assertTrue("subsequent click while focused should fire on click",
     53                 getActivity().isB2Fired());
     54     }
     55 
     56     @MediumTest
     57     public void testTapGivesFocusNoClickFired() {
     58         TouchUtils.touchAndCancelView(this, getActivity().getButton2());
     59         assertFalse("button shouldn't have fired click", getActivity().isB2Fired());
     60         assertFalse("button shouldn't have focus", getActivity().getButton2().isFocused());
     61     }
     62 
     63 
     64 }
     65