summaryrefslogtreecommitdiffstats
path: root/tests/ImfTest
diff options
context:
space:
mode:
authorBrett Chabot <brettchabot@android.com>2010-05-11 18:51:16 -0700
committerBrett Chabot <brettchabot@android.com>2010-05-11 18:51:16 -0700
commite9d0b2962d21eada2e51479cc8f46b900cd7a553 (patch)
tree29f9f45263d46e2d6edd6e19b2516672bd1ad939 /tests/ImfTest
parentbe65399baf23855094596e27c25763ff92e9e027 (diff)
downloadframeworks_base-e9d0b2962d21eada2e51479cc8f46b900cd7a553.zip
frameworks_base-e9d0b2962d21eada2e51479cc8f46b900cd7a553.tar.gz
frameworks_base-e9d0b2962d21eada2e51479cc8f46b900cd7a553.tar.bz2
Fix imf tests.
- fix hard keyboard detection logic - use FLAG_ACTIVITY_MULTIPLE_TASK to force test activities to start with IME Bugs 2677320, 2677355 Change-Id: I1b943ee17fddcae5087faefa9fa5603dd3f18ec1
Diffstat (limited to 'tests/ImfTest')
-rwxr-xr-xtests/ImfTest/tests/src/com/android/imftest/samples/ImfBaseTestCase.java30
1 files changed, 17 insertions, 13 deletions
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 50e2009..bc77e04 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.Intent;
import android.content.res.Configuration;
import android.os.SystemClock;
import android.test.InstrumentationTestCase;
@@ -38,7 +39,7 @@ public abstract class ImfBaseTestCase<T extends Activity> extends Instrumentatio
public final long WAIT_FOR_IME = 5000;
/*
- * Unfortunately there is now way for us to know how tall the IME is,
+ * Unfortunately there is now way for us to know how tall the IME is,
* so we have to hard code a minimum and maximum value.
*/
public final int IME_MIN_HEIGHT = 150;
@@ -48,20 +49,23 @@ public abstract class ImfBaseTestCase<T extends Activity> extends Instrumentatio
protected T mTargetActivity;
protected boolean mExpectAutoPop;
private Class<T> mTargetActivityClass;
-
+
public ImfBaseTestCase(Class<T> activityClass) {
mTargetActivityClass = activityClass;
}
-
+
@Override
public void setUp() throws Exception {
super.setUp();
final String packageName = getInstrumentation().getTargetContext().getPackageName();
- mTargetActivity = launchActivity(packageName, mTargetActivityClass, null);
+ Intent intent = new Intent(Intent.ACTION_MAIN);
+ intent.addFlags(Intent.FLAG_ACTIVITY_MULTIPLE_TASK);
+ mTargetActivity = launchActivityWithIntent(packageName, mTargetActivityClass, intent);
// expect ime to auto pop up if device has no hard keyboard
- mExpectAutoPop = mTargetActivity.getResources().getConfiguration().hardKeyboardHidden ==
- Configuration.HARDKEYBOARDHIDDEN_YES;
-
+ int keyboardType = mTargetActivity.getResources().getConfiguration().keyboard;
+ mExpectAutoPop = (keyboardType == Configuration.KEYBOARD_NOKEYS ||
+ keyboardType == Configuration.KEYBOARD_UNDEFINED);
+
mImm = InputMethodManager.getInstance(mTargetActivity);
KeyguardManager keyguardManager =
@@ -115,26 +119,26 @@ public abstract class ImfBaseTestCase<T extends Activity> extends Instrumentatio
assertFalse(destructiveCheckImeUp(rootView, servedView));
}
}
-
+
public boolean destructiveCheckImeUp(View rootView, View servedView) {
int origHeight;
int newHeight;
-
+
origHeight = rootView.getHeight();
-
+
// Tell the keyboard to go away.
mImm.hideSoftInputFromWindow(servedView.getWindowToken(), 0);
-
+
// Give it five seconds to adjust
newHeight = rootView.getHeight();
long timeoutTime = SystemClock.uptimeMillis() + WAIT_FOR_IME;
while (Math.abs(newHeight - origHeight) < IME_MIN_HEIGHT && SystemClock.uptimeMillis() < timeoutTime) {
newHeight = rootView.getHeight();
}
-
+
return (Math.abs(origHeight - newHeight) >= IME_MIN_HEIGHT);
}
-
+
void pause(int millis) {
try {
Thread.sleep(millis);