Search in sources :

Example 6 with ActivityResult

use of android.app.Instrumentation.ActivityResult in project android_packages_apps_Settings by omnirom.

the class FingerprintEnrollFinishTest method clickAddAnother_shouldPropagateResults.

@Test
public void clickAddAnother_shouldPropagateResults() {
    final ComponentName enrollingComponent = new ComponentName(getTargetContext(), FingerprintEnrollEnrolling.class);
    intending(hasComponent(enrollingComponent)).respondWith(new ActivityResult(Activity.RESULT_OK, null));
    onView(withId(R.id.add_another_button)).perform(click());
    intended(hasComponent(enrollingComponent));
    assertTrue(mActivityRule.getActivity().isFinishing());
}
Also used : ComponentName(android.content.ComponentName) ActivityResult(android.app.Instrumentation.ActivityResult) Test(org.junit.Test) SmallTest(android.support.test.filters.SmallTest)

Example 7 with ActivityResult

use of android.app.Instrumentation.ActivityResult in project orgzly-android by orgzly.

the class BooksTest method testExportWithFakeResponse.

@Test
public void testExportWithFakeResponse() {
    // Only if DocumentsProvider is supported
    assumeTrue(android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.KITKAT);
    onBook(0).perform(longClick());
    openContextualToolbarOverflowMenu();
    Intents.init();
    // Response to get after app sends Intent.ACTION_CREATE_DOCUMENT
    Intent resultData = new Intent();
    File file = new File(context.getCacheDir(), "book-1.org");
    resultData.setData(DocumentFile.fromFile(file).getUri());
    ActivityResult result = new ActivityResult(Activity.RESULT_OK, resultData);
    intending(hasAction(Intent.ACTION_CREATE_DOCUMENT)).respondWith(result);
    // Perform export
    onView(withText(R.string.export)).perform(click());
    // Check that app has sent intent
    intended(allOf(hasAction(Intent.ACTION_CREATE_DOCUMENT), hasExtra(Intent.EXTRA_TITLE, "book-1.org")));
    // Check that file was exported.
    onSnackbar().check(matches(withText(startsWith(context.getString(R.string.book_exported, "")))));
    // Delete exported file
    file.delete();
    Intents.release();
}
Also used : Intent(android.content.Intent) ActivityResult(android.app.Instrumentation.ActivityResult) File(java.io.File) DocumentFile(androidx.documentfile.provider.DocumentFile) OrgzlyTest(com.orgzly.android.OrgzlyTest) Test(org.junit.Test)

Example 8 with ActivityResult

use of android.app.Instrumentation.ActivityResult in project android_packages_apps_Settings by SudaMod.

the class FingerprintEnrollFinishTest method clickAddAnother_shouldPropagateResults.

@Test
public void clickAddAnother_shouldPropagateResults() {
    final ComponentName enrollingComponent = new ComponentName(getTargetContext(), FingerprintEnrollEnrolling.class);
    intending(hasComponent(enrollingComponent)).respondWith(new ActivityResult(Activity.RESULT_OK, null));
    onView(withId(R.id.add_another_button)).perform(click());
    intended(hasComponent(enrollingComponent));
    assertTrue(mActivityRule.getActivity().isFinishing());
}
Also used : ComponentName(android.content.ComponentName) ActivityResult(android.app.Instrumentation.ActivityResult) Test(org.junit.Test) SmallTest(android.support.test.filters.SmallTest)

Example 9 with ActivityResult

use of android.app.Instrumentation.ActivityResult in project android_packages_apps_Settings by SudaMod.

the class FingerprintEnrollFinishTest method clickAddAnother_shouldLaunchEnrolling.

@Test
public void clickAddAnother_shouldLaunchEnrolling() {
    final ComponentName enrollingComponent = new ComponentName(getTargetContext(), FingerprintEnrollEnrolling.class);
    intending(hasComponent(enrollingComponent)).respondWith(new ActivityResult(Activity.RESULT_CANCELED, null));
    onView(withId(R.id.add_another_button)).perform(click());
    intended(hasComponent(enrollingComponent));
    assertFalse(mActivityRule.getActivity().isFinishing());
}
Also used : ComponentName(android.content.ComponentName) ActivityResult(android.app.Instrumentation.ActivityResult) Test(org.junit.Test) SmallTest(android.support.test.filters.SmallTest)

Example 10 with ActivityResult

use of android.app.Instrumentation.ActivityResult in project android_packages_apps_Settings by crdroidandroid.

the class FingerprintEnrollFinishTest method clickAddAnother_shouldPropagateResults.

@Test
public void clickAddAnother_shouldPropagateResults() {
    final ComponentName enrollingComponent = new ComponentName(getTargetContext(), FingerprintEnrollEnrolling.class);
    intending(hasComponent(enrollingComponent)).respondWith(new ActivityResult(Activity.RESULT_OK, null));
    onView(withId(R.id.add_another_button)).perform(click());
    intended(hasComponent(enrollingComponent));
    assertTrue(mActivityRule.getActivity().isFinishing());
}
Also used : ComponentName(android.content.ComponentName) ActivityResult(android.app.Instrumentation.ActivityResult) Test(org.junit.Test) SmallTest(android.support.test.filters.SmallTest)

Aggregations

ActivityResult (android.app.Instrumentation.ActivityResult)25 Test (org.junit.Test)18 ComponentName (android.content.ComponentName)14 SmallTest (android.support.test.filters.SmallTest)12 Intent (android.content.Intent)6 RandomString (net.bytebuddy.utility.RandomString)3 SmallTest (androidx.test.filters.SmallTest)2 PartnerCustomizationLayout (com.google.android.setupcompat.PartnerCustomizationLayout)2 Instrumentation (android.app.Instrumentation)1 Bundle (android.os.Bundle)1 LargeTest (android.support.test.filters.LargeTest)1 DocumentFile (androidx.documentfile.provider.DocumentFile)1 LargeTest (androidx.test.filters.LargeTest)1 HookAnnotation (com.kunpeng.pit.HookAnnotation)1 OrgzlyTest (com.orgzly.android.OrgzlyTest)1 File (java.io.File)1 Before (org.junit.Before)1 ShadowActivity (org.robolectric.shadows.ShadowActivity)1