1 /* 2 * Copyright (C) 2010 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 package com.android.tradefed.uitestapp; 17 18 import android.test.ActivityInstrumentationTestCase2; 19 import android.test.TouchUtils; 20 import android.test.UiThreadTest; 21 import android.widget.EditText; 22 23 /** 24 * A test that does simple UI events. 25 * <p/> 26 * Its intended to verify that the UI on device is in a state where UI tests will be successful (ie 27 * screen is free from other dialogs, keyguard, etc) 28 */ 29 public class EditBoxActivityTest extends ActivityInstrumentationTestCase2<EditBoxActivity> { 30 31 public EditBoxActivityTest() { 32 super(EditBoxActivity.class); 33 } 34 35 /** 36 * Test that the edit box on {@link EditBoxActivity} can focused. 37 */ 38 @UiThreadTest 39 public void testEditTextFocus() { 40 EditText editText = (EditText)getActivity().findViewById(R.id.EditText); 41 assertNotNull(editText); 42 assertTrue(editText.requestFocus()); 43 assertTrue(editText.hasFocus()); 44 } 45 46 /** 47 * Test that the edit box on {@link EditBoxActivity} can modified. 48 */ 49 @UiThreadTest 50 public void testEditTextModified() { 51 EditText editText = (EditText)getActivity().findViewById(R.id.EditText); 52 assertNotNull(editText); 53 final String expectedText = "foo2"; 54 editText.setText(expectedText); 55 String actualText = editText.getText().toString(); 56 assertEquals(expectedText, actualText); 57 } 58 59 /** 60 * Test that a instrumentation string sync can be sent 61 */ 62 public void testInstrumentationStringSync() { 63 EditText editText = (EditText)getActivity().findViewById(R.id.EditText); 64 assertNotNull(editText); 65 assertTrue(editText.requestFocus()); 66 getInstrumentation().sendStringSync("foo"); 67 } 68 69 /** 70 * Test that a drag ui event can be sent 71 */ 72 public void testDragEvent() { 73 TouchUtils.dragQuarterScreenDown(this, getActivity()); 74 } 75 76 } 77