android.support.test.espresso.intent.Intents Java Examples

The following examples show how to use android.support.test.espresso.intent.Intents. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source Project: polling-station-app   Author: digital-voting-pass   File: ElectionChoiceActivityTest.java    License: GNU Lesser General Public License v3.0 6 votes vote down vote up
@Before
public void setUp() {
    Intents.init();

    // Wait till the splashactivity is closed, indicating blockchain was instantiated has started
    Context targetContext = InstrumentationRegistry.getInstrumentation().getTargetContext();
    mActivityRule.launchActivity(new Intent(targetContext, ElectionChoiceActivity.class));
    while (!mActivityRule.getActivity().isFinishing()) {
        try {
            Thread.sleep(1000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }
    activity = (ElectionChoiceActivity) mElectionActivityRule.launchActivity(new Intent(targetContext, ElectionChoiceActivity.class));
}
 
Example #2
Source Project: polling-station-app   Author: digital-voting-pass   File: TestResultActivity.java    License: GNU Lesser General Public License v3.0 6 votes vote down vote up
@Before
public void setUp() {
    Intents.init();

    // Wait till the splashactivity is closed, indicating blockchain was instantiated has started
    Context targetContext = InstrumentationRegistry.getInstrumentation().getTargetContext();
    splashActivityRule.launchActivity(new Intent(targetContext, SplashActivity.class));
    while (!splashActivityRule.getActivity().isFinishing()) {
        try {
            Thread.sleep(1000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }

    Context targetContext2 = InstrumentationRegistry.getInstrumentation()
            .getTargetContext();
    Intent intent = new Intent(targetContext2, ResultActivity.class);
    intent.putExtra("pubKey", pubKey);
    intent.putExtra("voter", voter);
    resultActivity = (ResultActivity) activityRule.launchActivity(intent);
}
 
Example #3
Source Project: polling-station-app   Author: digital-voting-pass   File: TestElectionChoice.java    License: GNU Lesser General Public License v3.0 6 votes vote down vote up
@Before
public void setUp() {
    Intents.init();

    // Wait till the splashactivity is closed, indicating blockchain was instantiated has started
    Context targetContext = InstrumentationRegistry.getInstrumentation().getTargetContext();
    mActivityRule.launchActivity(new Intent(targetContext, SplashActivity.class));
    while (!mActivityRule.getActivity().isFinishing()) {
        try {
            Thread.sleep(1000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }
    electionActivity = (ElectionChoiceActivity) mElectionActivityRule.launchActivity(new Intent(targetContext, ElectionChoiceActivity.class));
}
 
Example #4
Source Project: incubator-taverna-mobile   Author: apache   File: DashboardActivityTest.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Check if the username, password and userAvatar are visible and verify when click on
 * userAvatar UserProfileActivity will open
 */
@Test
public void checkAllViewsVisible_and_OnClickAvatar_openUserProfileActivity() throws Exception {

    Intents.init();
    onView(withId(R.id.drawer_layout))
            .check(matches(isClosed(Gravity.LEFT)))
            .perform(DrawerActions.open());

    //Please Login first otherwise it will not find username and email
    onView(withId(R.id.nav_user_avatar)).check(matches((isDisplayed())));
    onView(withId(R.id.nav_user_name)).check(matches((isDisplayed())));
    onView(withId(R.id.nav_user_email)).check(matches((isDisplayed())));

    onView(withId(R.id.nav_user_avatar)).perform(click());

    intended(hasComponent(UserProfileActivity.class.getName()));
    Intents.release();
}
 
Example #5
Source Project: incubator-taverna-mobile   Author: apache   File: DashboardActivityTest.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Checks if the usage activity is launched when we click on usage in nav drawer
 */
@Test
public void onClickNavUsage_openUsageActivity() throws Exception {

    Intents.init();

    onView(withId(R.id.drawer_layout))
            .check(matches(isClosed(Gravity.LEFT)))
            .perform(DrawerActions.open());

    onView(withId(R.id.nav_view))
            .perform(NavigationViewActions.navigateTo(R.id.nav_usage));

    intended(hasComponent(UsageActivity.class.getName()));

    Intents.release();
}
 
Example #6
Source Project: incubator-taverna-mobile   Author: apache   File: DashboardActivityTest.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Checks if the login is launched when click on logout in nav drawer and click on
 * sign out in alert dialouge box
 */
@Test
public void onClickLogout_ClickSignOut_OpenLoginScreen() throws Exception {

    Intents.init();
    onView(withId(R.id.drawer_layout))
            .check(matches(isClosed(Gravity.LEFT)))
            .perform(DrawerActions.open());

    onView(withId(R.id.nav_view))
            .perform(NavigationViewActions.navigateTo(R.id.nav_logout));

    onView(withId(android.R.id.button1)).perform(click());

    intended(hasComponent(LoginActivity.class.getName()));

    Intents.release();
}
 
Example #7
Source Project: incubator-taverna-mobile   Author: apache   File: DashboardActivityTest.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Checks if alert dialogue box is dismiss when click on cancel in logout alert sign in box
 */
@Test
public void onClickLogout_clickCancel_dismissDialogueBoz() throws Exception {

    Intents.init();
    onView(withId(R.id.drawer_layout))
            .check(matches(isClosed(Gravity.LEFT)))
            .perform(DrawerActions.open());

    onView(withId(R.id.nav_view))
            .perform(NavigationViewActions.navigateTo(R.id.nav_logout));

    onView(withId(android.R.id.button2)).perform(click());

    onView(withId(R.id.drawer_layout))
            .check(matches(isOpen(Gravity.LEFT)));

    Intents.release();
}
 
Example #8
Source Project: incubator-taverna-mobile   Author: apache   File: TutorialActivityTest.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Check swipes are working on tutorial screens and on last tutorial screen while clicking on
 * GOT IT it should go to login activity
 */
@Test
public void clickingNext_shouldGotoNextTutorial_onClickGotIt_ShouldGoToLoginActivity()
        throws Exception {

    Intents.init();
    onView(withText(R.string.next)).check(matches(isDisplayed()));
    onView(withId(R.id.slide_pager)).perform(swipeLeft());
    onView(withId(R.id.slide_pager)).perform(swipeLeft());
    onView(withId(R.id.slide_pager)).perform(swipeLeft());
    onView(withId(R.id.slide_pager)).perform(swipeLeft());
    onView(withText("SKIP")).check(matches(not(isDisplayed())));
    onView(withText("GOT IT")).check(matches(isDisplayed()));
    onView(withText("GOT IT")).perform(click());
    intended(hasComponent(LoginActivity.class.getName()));
    Intents.release();

}
 
Example #9
Source Project: polling-station-app   Author: digital-voting-pass   File: ElectionChoiceActivityTest.java    License: GNU Lesser General Public License v3.0 5 votes vote down vote up
@After
public void destroy() {
    Intents.release();
    try {
        BlockChain.getInstance(null).disconnect();
    } catch (Exception e) {
        e.printStackTrace();
    }
    activity.finish();
}
 
Example #10
Source Project: polling-station-app   Author: digital-voting-pass   File: TestResultActivity.java    License: GNU Lesser General Public License v3.0 5 votes vote down vote up
@After
public void destroy() {
    Intents.release();
    try {
        BlockChain.getInstance(null).disconnect();
    } catch (Exception e) {
        e.printStackTrace();
    }
    resultActivity.finish();
}
 
Example #11
Source Project: polling-station-app   Author: digital-voting-pass   File: TestElectionChoice.java    License: GNU Lesser General Public License v3.0 5 votes vote down vote up
@After
public void destroy() {
    Intents.release();
    try {
        BlockChain.getInstance(null).disconnect();
    } catch (Exception e) {
        e.printStackTrace();
    }
    electionActivity.finish();
}
 
Example #12
Source Project: Spork   Author: ByteWelder   File: ImmediateIntentsTestRule.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public Statement apply(final Statement base, Description description) {
	return new Statement() {
		@Override
		public void evaluate() throws Throwable {
			try {
				Intents.init();
				base.evaluate();
			} catch (Exception e) {
				Intents.release();
			}
		}
	};
}
 
Example #13
Source Project: AndroidSchool   Author: ArturVasilov   File: RepositoriesActivityTest.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void testClickOnItem() throws Exception {
    onView(withId(R.id.recyclerView))
            .perform(actionOnItemAtPosition(14, click()));

    Intents.intended(hasComponent(CommitsActivity.class.getName()));
}
 
Example #14
Source Project: AndroidSchool   Author: ArturVasilov   File: RepositoriesActivityTest.java    License: Apache License 2.0 5 votes vote down vote up
@After
public void tearDown() throws Exception {
    Intents.release();
    if (idlingResource != null) {
        Espresso.unregisterIdlingResources(idlingResource);
    }
    RepositoryProvider.provideKeyValueStorage().clear();
    Realm.getDefaultInstance().executeTransaction(realm -> realm.deleteAll());
}
 
Example #15
Source Project: AndroidSchool   Author: ArturVasilov   File: AuthActivityTest.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void testSuccessAuth() throws Exception {
    onView(withId(R.id.loginEdit)).perform(typeText("login"));
    closeSoftKeyboard();
    onView(withId(R.id.passwordEdit)).perform(typeText("pass"));
    closeSoftKeyboard();
    onView(withId(R.id.logInButton)).perform(click());

    IdlingResource idlingResource = TimeIdlingResource.timeout(4000);
    Intents.intended(hasComponent(RepositoriesActivity.class.getName()));
    Espresso.unregisterIdlingResources(idlingResource);

}
 
Example #16
Source Project: kaif-android   Author: kaif-open   File: HomeActivityTest.java    License: Apache License 2.0 5 votes vote down vote up
@Before
public void setUp() {
  Instrumentation instrumentation = InstrumentationRegistry.getInstrumentation();
  KaifApplication app = (KaifApplication) instrumentation.getTargetContext()
      .getApplicationContext();
  TestBeans beans = DaggerTestBeans.builder().build();
  app.setBeans(beans);
  beans.inject(this);
  Intents.init();
}
 
Example #17
Source Project: kaif-android   Author: kaif-open   File: LoginActivityTest.java    License: Apache License 2.0 5 votes vote down vote up
@Before
public void setUp() {
  Instrumentation instrumentation = InstrumentationRegistry.getInstrumentation();
  KaifApplication app = (KaifApplication) instrumentation.getTargetContext()
      .getApplicationContext();
  TestBeans beans = DaggerTestBeans.builder().build();
  app.setBeans(beans);
  beans.inject(this);
  Intents.init();
}
 
Example #18
Source Project: incubator-taverna-mobile   Author: apache   File: TutorialActivityTest.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Checks while clicking on skip button should start login activity
 */
@Test
public void clickingSkip_shouldStartLoginActivity() throws Exception {

    Intents.init();
    onView(withId(R.id.btn_skip)).perform(click());
    intended(hasComponent(LoginActivity.class.getName()));
    Intents.release();
}
 
Example #19
Source Project: incubator-taverna-mobile   Author: apache   File: TutorialActivityTest.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * First it swipes two times and then swipe back. Then this test will check while clicking
 * on the skip button should go the login activity
 */
@Test
public void swipeRightLeft_clickOnSkip_shouldGoToLoginActivity() throws Exception {

    Intents.init();
    onView(withText(R.string.next)).check(matches(isDisplayed()));
    onView(withId(R.id.slide_pager)).perform(swipeLeft());
    onView(withId(R.id.slide_pager)).perform(swipeLeft());
    onView(withId(R.id.slide_pager)).perform(swipeRight());
    onView(withText("SKIP")).check(matches(isDisplayed()));
    onView(withId(R.id.btn_skip)).perform(click());
    intended(hasComponent(LoginActivity.class.getName()));
    Intents.release();
}
 
Example #20
Source Project: vb-android-app-quality   Author: vincentbrison   File: TestMainActivityWithEspresso.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void testThatDefaultBehaviorIsWorking() throws Exception {
    Instrumentation.ActivityResult dummyResult = new Instrumentation.ActivityResult(0, null);
    Intents.intending(allOf(
            hasAction(Intent.ACTION_SEND),
            IntentMatchers.hasExtra(Intent.EXTRA_SUBJECT, mActivityRule.getActivity().getString(R.string.share_title))))
            .respondWith(dummyResult);
    super.testThatDefaultBehaviorIsWorking();
}
 
Example #21
Source Project: polling-station-app   Author: digital-voting-pass   File: TestManualInputActivity.java    License: GNU Lesser General Public License v3.0 4 votes vote down vote up
@Before
public void setUp() {
    Intents.init();
}
 
Example #22
Source Project: polling-station-app   Author: digital-voting-pass   File: TestManualInputActivity.java    License: GNU Lesser General Public License v3.0 4 votes vote down vote up
@After
public void destroy() {
    Intents.release();
}
 
Example #23
Source Project: polling-station-app   Author: digital-voting-pass   File: TestMainActivity.java    License: GNU Lesser General Public License v3.0 4 votes vote down vote up
@Before
public void setUp() {
    Intents.init();
}
 
Example #24
Source Project: polling-station-app   Author: digital-voting-pass   File: TestMainActivity.java    License: GNU Lesser General Public License v3.0 4 votes vote down vote up
@After
public void destroy() {
    Intents.release();
}
 
Example #25
Source Project: android-sdk   Author: watson-developer-cloud   File: GalleryHelperTest.java    License: Apache License 2.0 4 votes vote down vote up
@Before
public void initializeIntents() {
  Intents.init();
}
 
Example #26
Source Project: android-sdk   Author: watson-developer-cloud   File: GalleryHelperTest.java    License: Apache License 2.0 4 votes vote down vote up
@After
public void releaseIntents() {
  Intents.release();
}
 
Example #27
Source Project: android-sdk   Author: watson-developer-cloud   File: CameraHelperTest.java    License: Apache License 2.0 4 votes vote down vote up
@Before
public void initializeIntents() {
  Intents.init();
}
 
Example #28
Source Project: android-sdk   Author: watson-developer-cloud   File: CameraHelperTest.java    License: Apache License 2.0 4 votes vote down vote up
@After
public void releaseIntents() {
  Intents.release();
}
 
Example #29
Source Project: material-activity-chooser   Author: zawadz88   File: SampleListStepDefinitions.java    License: Apache License 2.0 4 votes vote down vote up
@SuppressWarnings("UnusedParameters")
@After
public static void after(Scenario scenario) {
    ActivityUtils.finishOpenActivities();
    Intents.release();
}
 
Example #30
Source Project: material-activity-chooser   Author: zawadz88   File: IntentTestRuleWithActivityFactory.java    License: Apache License 2.0 4 votes vote down vote up
@Override
protected void afterActivityLaunched() {
    Intents.init();
    super.afterActivityLaunched();
}