use of android.app.Instrumentation in project android_frameworks_base by ResurrectionRemix.
the class AutoCompleteTextViewPopup method testPopupGetListSelection.
/** Test that we can look at the selection as we move around */
@FlakyTest(tolerance = 3)
public void testPopupGetListSelection() throws Throwable {
AutoCompleteTextViewSimple theActivity = getActivity();
final AutoCompleteTextView textView = theActivity.getTextView();
final Instrumentation instrumentation = getInstrumentation();
// focus and type
textView.requestFocus();
instrumentation.waitForIdleSync();
sendKeys("A");
// No initial selection
waitAssertListSelection(textView, ListView.INVALID_POSITION);
// check for selection position as expected
sendKeys("DPAD_DOWN");
waitAssertListSelection("move selection to (0)", textView, 0);
// Repeat for one more movement
sendKeys("DPAD_DOWN");
waitAssertListSelection("move selection to (1)", textView, 1);
// TODO: FlakyTest repeat runs will not currently call setUp, clear state
clearText(textView);
}
use of android.app.Instrumentation in project android_frameworks_base by ResurrectionRemix.
the class BugreportReceiverTest method setUp.
@Override
protected void setUp() throws Exception {
Log.i(TAG, "#### setup() on " + getName());
Instrumentation instrumentation = getInstrumentation();
mContext = instrumentation.getTargetContext();
mUiBot = new UiBot(UiDevice.getInstance(instrumentation), TIMEOUT);
mListener = ActionSendMultipleConsumerActivity.getListener(mContext);
cancelExistingNotifications();
mPlainTextPath = getPath(BUGREPORT_FILE);
mZipPath = getPath(ZIP_FILE);
mZipPath2 = getPath(ZIP_FILE2);
mScreenshotPath = getPath(SCREENSHOT_FILE);
createTextFile(mPlainTextPath, BUGREPORT_CONTENT);
createTextFile(mScreenshotPath, SCREENSHOT_CONTENT);
createZipFile(mZipPath, BUGREPORT_FILE, BUGREPORT_CONTENT);
createZipFile(mZipPath2, BUGREPORT_FILE, BUGREPORT_CONTENT);
// Creates a multi-line description.
StringBuilder sb = new StringBuilder();
for (int i = 1; i <= 20; i++) {
sb.append("All work and no play makes Shell a dull app!\n");
}
mDescription = sb.toString();
setWarningState(mContext, STATE_HIDE);
}
use of android.app.Instrumentation in project DroidPlugin by DroidPluginTeam.
the class InstrumentationHook method onInstall.
@Override
protected void onInstall(ClassLoader classLoader) throws Throwable {
Object target = ActivityThreadCompat.currentActivityThread();
Class ActivityThreadClass = ActivityThreadCompat.activityThreadClass();
/*替换ActivityThread.mInstrumentation,拦截组件调度消息*/
Field mInstrumentationField = FieldUtils.getField(ActivityThreadClass, "mInstrumentation");
Instrumentation mInstrumentation = (Instrumentation) FieldUtils.readField(mInstrumentationField, target);
if (!PluginInstrumentation.class.isInstance(mInstrumentation)) {
PluginInstrumentation pit = new PluginInstrumentation(mHostContext, mInstrumentation);
pit.setEnable(isEnable());
mPluginInstrumentations.add(pit);
FieldUtils.writeField(mInstrumentationField, target, pit);
Log.i(TAG, "Install Instrumentation Hook old=%s,new=%s", mInstrumentationField, pit);
} else {
Log.i(TAG, "Instrumentation has installed,skip");
}
}
use of android.app.Instrumentation in project android_packages_inputmethods_LatinIME by CyanogenMod.
the class MoreKeySpecStringReferenceTests method setUp.
@Override
protected void setUp() throws Exception {
super.setUp();
final Instrumentation instrumentation = getInstrumentation();
final Context testContext = instrumentation.getContext();
final Resources testRes = testContext.getResources();
final String testPackageName = testRes.getResourcePackageName(R.string.empty_string);
mTextsSet.setLocale(TEST_LOCALE, testRes, testPackageName);
}
use of android.app.Instrumentation in project android_frameworks_base by DirtyUnicorns.
the class InstrumentationTestCase method sendRepeatedKeys.
/**
* Sends a series of key events through instrumentation and waits for idle. Each key code
* must be preceded by the number of times the key code must be sent. For instance:
* sendRepeatedKeys(1, KEYCODE_DPAD_CENTER, 2, KEYCODE_DPAD_LEFT).
*
* @param keys The series of key repeats and codes to send through instrumentation.
*/
public void sendRepeatedKeys(int... keys) {
final int count = keys.length;
if ((count & 0x1) == 0x1) {
throw new IllegalArgumentException("The size of the keys array must " + "be a multiple of 2");
}
final Instrumentation instrumentation = getInstrumentation();
for (int i = 0; i < count; i += 2) {
final int keyCount = keys[i];
final int keyCode = keys[i + 1];
for (int j = 0; j < keyCount; j++) {
try {
instrumentation.sendKeyDownUpSync(keyCode);
} catch (SecurityException e) {
// Ignore security exceptions that are now thrown
// when trying to send to another app, to retain
// compatibility with existing tests.
}
}
}
instrumentation.waitForIdleSync();
}
Aggregations