From 1d679147d508b4c5d0a2ae1cc85bd030eb2f8761 Mon Sep 17 00:00:00 2001 From: Brett Chabot Date: Thu, 8 Apr 2010 14:55:24 -0700 Subject: IME test fixes. Tweak OneEditTextActivitySelectedTests:testSoftKeyboardAutoPop so it always expects IME to be shown for devices with no hard keyboard. Bug 2267311 2318969 Change-Id: Ica31e8f1153cf3e7dbc838d263ea0ae805161610 --- .../imftest/samples/OneEditTextActivitySelected.java | 6 +++++- .../src/com/android/imftest/samples/ImfBaseTestCase.java | 15 +++++++++------ 2 files changed, 14 insertions(+), 7 deletions(-) (limited to 'tests') diff --git a/tests/ImfTest/src/com/android/imftest/samples/OneEditTextActivitySelected.java b/tests/ImfTest/src/com/android/imftest/samples/OneEditTextActivitySelected.java index f313a90..64882aa 100644 --- a/tests/ImfTest/src/com/android/imftest/samples/OneEditTextActivitySelected.java +++ b/tests/ImfTest/src/com/android/imftest/samples/OneEditTextActivitySelected.java @@ -55,7 +55,11 @@ public class OneEditTextActivitySelected extends Activity ((ScrollView) mRootView).addView(layout); setContentView(mRootView); - } + + // set to resize so IME is always shown (and also so + // ImfBaseTestCase#destructiveCheckImeInitialState thinks it should always be shown + this.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE); + } public View getRootView() { return mRootView; diff --git a/tests/ImfTest/tests/src/com/android/imftest/samples/ImfBaseTestCase.java b/tests/ImfTest/tests/src/com/android/imftest/samples/ImfBaseTestCase.java index 1957640..50e2009 100755 --- a/tests/ImfTest/tests/src/com/android/imftest/samples/ImfBaseTestCase.java +++ b/tests/ImfTest/tests/src/com/android/imftest/samples/ImfBaseTestCase.java @@ -19,6 +19,7 @@ package com.android.imftest.samples; import android.app.Activity; import android.app.KeyguardManager; import android.content.Context; +import android.content.res.Configuration; import android.os.SystemClock; import android.test.InstrumentationTestCase; import android.view.KeyEvent; @@ -43,7 +44,6 @@ public abstract class ImfBaseTestCase extends Instrumentatio public final int IME_MIN_HEIGHT = 150; public final int IME_MAX_HEIGHT = 300; - public final String TARGET_PACKAGE_NAME = "com.android.imftest"; protected InputMethodManager mImm; protected T mTargetActivity; protected boolean mExpectAutoPop; @@ -56,9 +56,12 @@ public abstract class ImfBaseTestCase extends Instrumentatio @Override public void setUp() throws Exception { super.setUp(); + final String packageName = getInstrumentation().getTargetContext().getPackageName(); + mTargetActivity = launchActivity(packageName, mTargetActivityClass, null); + // expect ime to auto pop up if device has no hard keyboard + mExpectAutoPop = mTargetActivity.getResources().getConfiguration().hardKeyboardHidden == + Configuration.HARDKEYBOARDHIDDEN_YES; - mTargetActivity = launchActivity(TARGET_PACKAGE_NAME, mTargetActivityClass, null); - mExpectAutoPop = mTargetActivity.getResources().getBoolean(R.bool.def_expect_ime_autopop); mImm = InputMethodManager.getInstance(mTargetActivity); KeyguardManager keyguardManager = @@ -104,9 +107,9 @@ public abstract class ImfBaseTestCase extends Instrumentatio } public void destructiveCheckImeInitialState(View rootView, View servedView) { - if (mExpectAutoPop && (mTargetActivity.getWindow().getAttributes(). - softInputMode&WindowManager.LayoutParams.SOFT_INPUT_MASK_ADJUST) - == WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE) { + int windowSoftInputMode = mTargetActivity.getWindow().getAttributes().softInputMode; + int adjustMode = windowSoftInputMode & WindowManager.LayoutParams.SOFT_INPUT_MASK_ADJUST; + if (mExpectAutoPop && adjustMode == WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE) { assertTrue(destructiveCheckImeUp(rootView, servedView)); } else { assertFalse(destructiveCheckImeUp(rootView, servedView)); -- cgit v1.1