am b4c9a8f6: Merge "Fix imf tests." into froyo
Merge commit 'b4c9a8f664f1dd57644e6d6cf2723eff9a505072' into froyo-plus-aosp * commit 'b4c9a8f664f1dd57644e6d6cf2723eff9a505072': Fix imf tests.
This commit is contained in:
@@ -19,6 +19,7 @@ package com.android.imftest.samples;
|
|||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.app.KeyguardManager;
|
import android.app.KeyguardManager;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.content.Intent;
|
||||||
import android.content.res.Configuration;
|
import android.content.res.Configuration;
|
||||||
import android.os.SystemClock;
|
import android.os.SystemClock;
|
||||||
import android.test.InstrumentationTestCase;
|
import android.test.InstrumentationTestCase;
|
||||||
@@ -38,7 +39,7 @@ public abstract class ImfBaseTestCase<T extends Activity> extends Instrumentatio
|
|||||||
public final long WAIT_FOR_IME = 5000;
|
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.
|
* so we have to hard code a minimum and maximum value.
|
||||||
*/
|
*/
|
||||||
public final int IME_MIN_HEIGHT = 150;
|
public final int IME_MIN_HEIGHT = 150;
|
||||||
@@ -48,20 +49,23 @@ public abstract class ImfBaseTestCase<T extends Activity> extends Instrumentatio
|
|||||||
protected T mTargetActivity;
|
protected T mTargetActivity;
|
||||||
protected boolean mExpectAutoPop;
|
protected boolean mExpectAutoPop;
|
||||||
private Class<T> mTargetActivityClass;
|
private Class<T> mTargetActivityClass;
|
||||||
|
|
||||||
public ImfBaseTestCase(Class<T> activityClass) {
|
public ImfBaseTestCase(Class<T> activityClass) {
|
||||||
mTargetActivityClass = activityClass;
|
mTargetActivityClass = activityClass;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setUp() throws Exception {
|
public void setUp() throws Exception {
|
||||||
super.setUp();
|
super.setUp();
|
||||||
final String packageName = getInstrumentation().getTargetContext().getPackageName();
|
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
|
// expect ime to auto pop up if device has no hard keyboard
|
||||||
mExpectAutoPop = mTargetActivity.getResources().getConfiguration().hardKeyboardHidden ==
|
int keyboardType = mTargetActivity.getResources().getConfiguration().keyboard;
|
||||||
Configuration.HARDKEYBOARDHIDDEN_YES;
|
mExpectAutoPop = (keyboardType == Configuration.KEYBOARD_NOKEYS ||
|
||||||
|
keyboardType == Configuration.KEYBOARD_UNDEFINED);
|
||||||
|
|
||||||
mImm = InputMethodManager.getInstance(mTargetActivity);
|
mImm = InputMethodManager.getInstance(mTargetActivity);
|
||||||
|
|
||||||
KeyguardManager keyguardManager =
|
KeyguardManager keyguardManager =
|
||||||
@@ -115,26 +119,26 @@ public abstract class ImfBaseTestCase<T extends Activity> extends Instrumentatio
|
|||||||
assertFalse(destructiveCheckImeUp(rootView, servedView));
|
assertFalse(destructiveCheckImeUp(rootView, servedView));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean destructiveCheckImeUp(View rootView, View servedView) {
|
public boolean destructiveCheckImeUp(View rootView, View servedView) {
|
||||||
int origHeight;
|
int origHeight;
|
||||||
int newHeight;
|
int newHeight;
|
||||||
|
|
||||||
origHeight = rootView.getHeight();
|
origHeight = rootView.getHeight();
|
||||||
|
|
||||||
// Tell the keyboard to go away.
|
// Tell the keyboard to go away.
|
||||||
mImm.hideSoftInputFromWindow(servedView.getWindowToken(), 0);
|
mImm.hideSoftInputFromWindow(servedView.getWindowToken(), 0);
|
||||||
|
|
||||||
// Give it five seconds to adjust
|
// Give it five seconds to adjust
|
||||||
newHeight = rootView.getHeight();
|
newHeight = rootView.getHeight();
|
||||||
long timeoutTime = SystemClock.uptimeMillis() + WAIT_FOR_IME;
|
long timeoutTime = SystemClock.uptimeMillis() + WAIT_FOR_IME;
|
||||||
while (Math.abs(newHeight - origHeight) < IME_MIN_HEIGHT && SystemClock.uptimeMillis() < timeoutTime) {
|
while (Math.abs(newHeight - origHeight) < IME_MIN_HEIGHT && SystemClock.uptimeMillis() < timeoutTime) {
|
||||||
newHeight = rootView.getHeight();
|
newHeight = rootView.getHeight();
|
||||||
}
|
}
|
||||||
|
|
||||||
return (Math.abs(origHeight - newHeight) >= IME_MIN_HEIGHT);
|
return (Math.abs(origHeight - newHeight) >= IME_MIN_HEIGHT);
|
||||||
}
|
}
|
||||||
|
|
||||||
void pause(int millis) {
|
void pause(int millis) {
|
||||||
try {
|
try {
|
||||||
Thread.sleep(millis);
|
Thread.sleep(millis);
|
||||||
|
|||||||
Reference in New Issue
Block a user