當前位置: 首頁>>代碼示例>>Java>>正文


Java Instrumentation.ActivityResult方法代碼示例

本文整理匯總了Java中android.app.Instrumentation.ActivityResult方法的典型用法代碼示例。如果您正苦於以下問題:Java Instrumentation.ActivityResult方法的具體用法?Java Instrumentation.ActivityResult怎麽用?Java Instrumentation.ActivityResult使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在android.app.Instrumentation的用法示例。


在下文中一共展示了Instrumentation.ActivityResult方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: pickGalleryPhoto

import android.app.Instrumentation; //導入方法依賴的package包/類
private static void pickGalleryPhoto() throws IOException {

        Drawable drawable = getTargetContext().getResources().getDrawable(R.drawable.upc_library);
        Bitmap bmp = drawableToBitmap(drawable);

        File storageDir =
                new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DCIM),
                        "Camera");
        File image = File.createTempFile("testImage", ".jpg", storageDir);

        FileOutputStream out = new FileOutputStream(image);
        bmp.compress(CompressFormat.JPEG, 100, out);

        // Build a result to return from the Camera app
        Intent resultData = new Intent();
        resultData.setData(Uri.fromFile(image));
        Instrumentation.ActivityResult result =
                new Instrumentation.ActivityResult(Activity.RESULT_OK, resultData);

        // Stub out the Camera. When an intent is sent to the Camera, this tells Espresso to respond
        // with the ActivityResult we just created
        intending(not(isInternal())).respondWith(result);
        intended(not(isInternal()));
    }
 
開發者ID:ArnauBlanch,項目名稱:civify-app,代碼行數:25,代碼來源:CreateIssueActivityTest.java

示例2: addImage

import android.app.Instrumentation; //導入方法依賴的package包/類
@Test
public void addImage() {
    Intent resultData = new Intent();
    Bitmap icon = BitmapFactory.decodeResource(getInstrumentation().getContext().getResources(),
            R.drawable.mock_camera_image);
    resultData.putExtra("data", icon);
    Instrumentation.ActivityResult result =
            new Instrumentation.ActivityResult(Activity.RESULT_OK, resultData);

    intending(not(isInternal())).respondWith(result);

    Espresso.closeSoftKeyboard();

    onView(withId(R.id.imageOpacityOverlay)).perform(click());
    onView(withId(R.id.imageOpacityOverlay)).check(matches(not(isDisplayed())));

    onView(withId(R.id.imageDelete)).perform(click());
    onView(withId(R.id.imageOpacityOverlay)).check(matches(isDisplayed()));
}
 
開發者ID:CMPUT301F17T13,項目名稱:cat-is-a-dog,代碼行數:20,代碼來源:AddHabitEventActivityTest.java

示例3: createEnvironmentalSensorListScanActivityResultStub

import android.app.Instrumentation; //導入方法依賴的package包/類
private Instrumentation.ActivityResult createEnvironmentalSensorListScanActivityResultStub() {

        Intent resultData = new Intent();

        resultData.putExtra(EnvironmentalSensorsScanActivity.EXTRA_DEVICE_ADDRESS, TEST_ADDRESS);
        Instrumentation.ActivityResult result =
                new Instrumentation.ActivityResult(Activity.RESULT_OK, resultData);
        return result;
    }
 
開發者ID:igrow-systems,項目名稱:igrow-android,代碼行數:10,代碼來源:EnvironmentalSensorsActivityTest.java

示例4: createRequestEnableBluetoothResultStub

import android.app.Instrumentation; //導入方法依賴的package包/類
private Instrumentation.ActivityResult createRequestEnableBluetoothResultStub() {

        // create a stub that indicates the user did not enable Bluetooth
        Intent resultData = new Intent();

        Instrumentation.ActivityResult result =
                new Instrumentation.ActivityResult(Activity.RESULT_CANCELED, resultData);
        return result;
    }
 
開發者ID:igrow-systems,項目名稱:igrow-android,代碼行數:10,代碼來源:EnvironmentalSensorsActivityTest.java

示例5: getPhotoIdActivityResult

import android.app.Instrumentation; //導入方法依賴的package包/類
private Instrumentation.ActivityResult getPhotoIdActivityResult() {
    Intent resultData = new Intent();

    resultData.setData(
            Uri.parse(ContentResolver.SCHEME_ANDROID_RESOURCE + "://" +
                    activity.getResources().getResourcePackageName(R.raw.test) + '/' +
                    activity.getResources().getResourceTypeName(R.raw.test) + '/' +
                    activity.getResources().getResourceEntryName(R.raw.test)) );

    return new Instrumentation.ActivityResult(Activity.RESULT_OK, resultData);
}
 
開發者ID:UTN-FRBA-Mobile,項目名稱:Clases-2017c1,代碼行數:12,代碼來源:SelectPictureActivityTest.java

示例6: buildOkResult

import android.app.Instrumentation; //導入方法依賴的package包/類
private static Instrumentation.ActivityResult buildOkResult()
{
    Intent resultData = new Intent();
    return new Instrumentation.ActivityResult(Activity.RESULT_OK, resultData);
}
 
開發者ID:jbmlaird,項目名稱:DiscogsBrowser,代碼行數:6,代碼來源:TestUtils.java

示例7: test01ValidQR

import android.app.Instrumentation; //導入方法依賴的package包/類
@Test
public void test01ValidQR() {
    onView(withId(R.id.fab)).check(matches(isDisplayed()));
    ViewInteraction floatingActionButton = onView(
            allOf(withId(R.id.fab),
                    childAtPosition(
                            childAtPosition(
                                    withId(android.R.id.content),
                                    0),
                            2),
                    isDisplayed()));
    Intents.init();
    String valid_qr = "otpauth://hotp/testtoken?secret=TXHEXPREOXHFKDRE6BNZJOFKQ5OLDZWC&counter=1&digits=6&issuer=privacyIDEA";
    String invalid_qr = "lalalalala";

    // Build a result to return from the ZXING app
    Intent resultData = new Intent();
    resultData.putExtra(com.google.zxing.client.android.Intents.Scan.RESULT, valid_qr);
    Instrumentation.ActivityResult result = new Instrumentation.ActivityResult(Activity.RESULT_OK, resultData);

    // Stub out the Camera. When an intent is sent to the Camera, this tells Espresso to respond
    // with the ActivityResult we just created
    intending(hasAction("com.google.zxing.client.android.SCAN")).respondWith(result);

   /* onView(withId(R.id.fab)).check(matches(isDisplayed()));
    onView(withId(R.id.fab)).perform(click());*/
    floatingActionButton.perform(click());
    // We can also validate that an intent resolving to the "camera" activity has been sent out by our app
    intended(hasAction("com.google.zxing.client.android.SCAN"));
    sleep(2000);
    //onView(withText("Invalid QR Code")).check(matches(isDisplayed()));
    //onData(anything("privacyIDEA: testtoken")).check(matches(isDisplayed()));
    //onData(withRowString(1, "privacyIDEA: testtoken")).check(matches(isDisplayed()));

    onData(anything()).
            inAdapterView(withId(R.id.listview)).
            atPosition(0).
            onChildView(withId(R.id.textViewLabel))
            .check(matches(withText(startsWith("privacyIDEA: test"))));
    onData(anything()).
            inAdapterView(withId(R.id.listview)).
            atPosition(0).
            onChildView(withId(R.id.textViewToken))
            .check(matches(withText(startsWith("163584"))));

    //onData(withItem

    // delete the token

    onData(anything())
            .inAdapterView(allOf(withId(R.id.listview),
                    childAtPosition(
                            withClassName(is("android.support.constraint.ConstraintLayout")),
                            1)))
            .atPosition(0).perform(longClick());
    sleep();
    ViewInteraction actionMenuItemView = onView(
            allOf(withId(R.id.delete_token2), withContentDescription("Item"),
                    childAtPosition(
                            childAtPosition(
                                    withId(R.id.action_mode_bar),
                                    2),
                            1),
                    isDisplayed()));
    actionMenuItemView.perform(click());

    sleep();

    ViewInteraction appCompatButton4 = onView(
            allOf(withId(android.R.id.button1), withText("YES"),
                    childAtPosition(
                            allOf(withClassName(is("android.widget.LinearLayout")),
                                    childAtPosition(
                                            withClassName(is("android.widget.LinearLayout")),
                                            3)),
                            3),
                    isDisplayed()));
    appCompatButton4.perform(click());
    Intents.release();
}
 
開發者ID:privacyidea,項目名稱:privacyidea-authenticator,代碼行數:81,代碼來源:MainActivityTest.java

示例8: stubEnvironmentalSensorListScanActivityIntent

import android.app.Instrumentation; //導入方法依賴的package包/類
@Before
public void stubEnvironmentalSensorListScanActivityIntent() {

    Instrumentation.ActivityResult result = createEnvironmentalSensorListScanActivityResultStub();

    intending(allOf(hasComponent(new ComponentName(getTargetContext(),
                    EnvironmentalSensorsScanActivity.class)),
            hasAction(Intent.ACTION_PICK))).respondWith(result);

}
 
開發者ID:igrow-systems,項目名稱:igrow-android,代碼行數:11,代碼來源:EnvironmentalSensorsActivityTest.java

示例9: stubRequestEnableBluetoothIntent

import android.app.Instrumentation; //導入方法依賴的package包/類
@Before
public void stubRequestEnableBluetoothIntent() {

    Instrumentation.ActivityResult result = createRequestEnableBluetoothResultStub();

    intending(hasComponent(new ComponentName(getTargetContext(),
            BluetoothAdapter.ACTION_REQUEST_ENABLE))).respondWith(result);

}
 
開發者ID:igrow-systems,項目名稱:igrow-android,代碼行數:10,代碼來源:EnvironmentalSensorsActivityTest.java


注:本文中的android.app.Instrumentation.ActivityResult方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。