ButtonActivityTest.java revision 9066cfe9886ac131c34d59ed0e2d287b0e3c0087
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
17package com.android.imftest.samples;
18
19import android.test.suitebuilder.annotation.LargeTest;
20import android.view.KeyEvent;
21import android.widget.Button;
22
23
24public class ButtonActivityTest extends ImfBaseTestCase<ButtonActivity> {
25
26	final public String TAG = "ButtonActivityTest";
27
28    public ButtonActivityTest() {
29        super(ButtonActivity.class);
30    }
31
32    @LargeTest
33    public void testButtonActivatesIme() {
34
35        final Button button = (Button) mTargetActivity.findViewById(ButtonActivity.BUTTON_ID);
36
37        // Push button
38        // Bring the target EditText into focus.
39        mTargetActivity.runOnUiThread(new Runnable() {
40            public void run() {
41                button.requestFocus();
42            }
43        });
44
45        sendKeys(KeyEvent.KEYCODE_DPAD_CENTER);
46
47        // Give it a couple seconds
48        pause(2000);
49
50        // We should have initialized imm.mServedView and imm.mCurrentTextBoxAttribute
51        assertTrue(mImm.isActive());
52        // imm.mServedInputConnection should be null since Button doesn't override onCreateInputConnection().
53        assertFalse(mImm.isAcceptingText());
54
55        destructiveCheckImeInitialState(mTargetActivity.getRootView(), button);
56
57    }
58}
59