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.LLEditTextThenButton;
     20 import static android.util.TouchModeFlexibleAsserts.assertNotInTouchModeAfterKey;
     21 
     22 import android.test.ActivityInstrumentationTestCase2;
     23 import android.test.suitebuilder.annotation.MediumTest;
     24 import android.view.KeyEvent;
     25 import android.widget.Button;
     26 import android.widget.EditText;
     27 
     28 public class StartInTouchWithViewInFocusTest extends
     29         ActivityInstrumentationTestCase2<LLEditTextThenButton> {
     30 
     31     private EditText mEditText;
     32 
     33     private Button mButton;
     34 
     35     public StartInTouchWithViewInFocusTest() {
     36         super("com.android.frameworks.coretests", LLEditTextThenButton.class);
     37     }
     38 
     39     @Override
     40     protected void setUp() throws Exception {
     41         super.setUp();
     42         this.setActivityInitialTouchMode(true);
     43         mEditText = getActivity().getEditText();
     44         mButton = getActivity().getButton();
     45     }
     46 
     47     @MediumTest
     48     public void testPreconditions() {
     49         assertTrue("should start in touch mode", mEditText.isInTouchMode());
     50         assertTrue("edit text is focusable in touch mode, should have focus", mEditText.isFocused());
     51     }
     52 
     53     // TODO: reenable when more reliable
     54     public void DISABLE_testKeyDownLeavesTouchModeAndGoesToNextView() {
     55         assertNotInTouchModeAfterKey(this, KeyEvent.KEYCODE_DPAD_DOWN, mEditText);
     56         assertFalse("should have left touch mode", mEditText.isInTouchMode());
     57         assertTrue("should have given focus to next view", mButton.isFocused());
     58     }
     59 
     60     // TODO: reenable when more reliable
     61     public void DISABLE_testNonDirectionalKeyExitsTouchMode() {
     62         assertNotInTouchModeAfterKey(this, KeyEvent.KEYCODE_A, mEditText);
     63         assertFalse("should have left touch mode", mEditText.isInTouchMode());
     64         assertTrue("edit text should still have focus", mEditText.isFocused());
     65     }
     66 
     67 }
     68