Search in sources :

Example 56 with Instrumentation

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);
}
Also used : Instrumentation(android.app.Instrumentation) FlakyTest(android.test.FlakyTest)

Example 57 with Instrumentation

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);
}
Also used : Instrumentation(android.app.Instrumentation)

Example 58 with Instrumentation

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");
    }
}
Also used : Field(java.lang.reflect.Field) Instrumentation(android.app.Instrumentation) PluginInstrumentation(com.morgoo.droidplugin.hook.handle.PluginInstrumentation) PluginInstrumentation(com.morgoo.droidplugin.hook.handle.PluginInstrumentation)

Example 59 with Instrumentation

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);
}
Also used : Context(android.content.Context) Instrumentation(android.app.Instrumentation) Resources(android.content.res.Resources)

Example 60 with Instrumentation

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();
}
Also used : Instrumentation(android.app.Instrumentation)

Aggregations

Instrumentation (android.app.Instrumentation)225 LargeTest (android.test.suitebuilder.annotation.LargeTest)59 FlakyTest (android.test.FlakyTest)49 Intent (android.content.Intent)37 KeyEvent (android.view.KeyEvent)30 MotionEvent (android.view.MotionEvent)27 Point (android.graphics.Point)25 MediumTest (android.test.suitebuilder.annotation.MediumTest)18 Activity (android.app.Activity)14 Field (java.lang.reflect.Field)10 CameraActivity (com.android.camera.CameraActivity)8 Uri (android.net.Uri)7 File (java.io.File)7 Handler (android.os.Handler)6 KeyCharacterMap (android.view.KeyCharacterMap)6 Button (android.widget.Button)6 ListView (android.widget.ListView)6 Message (android.os.Message)5 MessageQueue (android.os.MessageQueue)4 EditText (android.widget.EditText)4