Java Code Examples for android.support.test.espresso.intent.Intents#init()
The following examples show how to use
android.support.test.espresso.intent.Intents#init() .
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 File: TutorialActivityTest.java From incubator-taverna-mobile with Apache License 2.0 | 6 votes |
/** * 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 2
Source File: TestResultActivity.java From polling-station-app with GNU Lesser General Public License v3.0 | 6 votes |
@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 File: DashboardActivityTest.java From incubator-taverna-mobile with Apache License 2.0 | 6 votes |
/** * 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 4
Source File: DashboardActivityTest.java From incubator-taverna-mobile with Apache License 2.0 | 6 votes |
/** * 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 5
Source File: ElectionChoiceActivityTest.java From polling-station-app with GNU Lesser General Public License v3.0 | 6 votes |
@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 6
Source File: DashboardActivityTest.java From incubator-taverna-mobile with Apache License 2.0 | 6 votes |
/** * 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 7
Source File: DashboardActivityTest.java From incubator-taverna-mobile with Apache License 2.0 | 6 votes |
/** * 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 8
Source File: TutorialActivityTest.java From incubator-taverna-mobile with Apache License 2.0 | 5 votes |
/** * 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 9
Source File: ImmediateIntentsTestRule.java From Spork with Apache License 2.0 | 5 votes |
@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 10
Source File: LoginActivityTest.java From kaif-android with Apache License 2.0 | 5 votes |
@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 11
Source File: HomeActivityTest.java From kaif-android with Apache License 2.0 | 5 votes |
@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 12
Source File: MainActivityTest.java From otp-authenticator with MIT License | 4 votes |
public void test002NocodeScanned() throws InterruptedException { Intents.init(); // Build a result to return from the ZXING app Intent resultData = new Intent(); Instrumentation.ActivityResult result = new Instrumentation.ActivityResult(Activity.RESULT_CANCELED, 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); // Now that we have the stub in place, click on the button in our app that launches into the Camera onView(withId(R.id.action_scan)).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")); onView(withText("No account has been added yet")).check(matches(isDisplayed())); Intents.release(); }
Example 13
Source File: SnippetListActivityTests.java From android-java-snippets-sample with MIT License | 4 votes |
@Before public void initIntents(){ Intents.init(); }
Example 14
Source File: SnippetDetailActivityTests.java From android-java-snippets-sample with MIT License | 4 votes |
@Before public void initIntents(){ Intents.init(); }
Example 15
Source File: ApplicationTest.java From AndroidSchool with Apache License 2.0 | 4 votes |
@Before public void setUp() throws Exception { Intents.init(); }
Example 16
Source File: RepositoriesActivityTest.java From AndroidSchool with Apache License 2.0 | 4 votes |
@Before public void setUp() throws Exception { Intents.init(); idlingResource = TimeIdlingResource.timeout(4000); }
Example 17
Source File: IntentTestRuleWithActivityFactory.java From material-activity-chooser with Apache License 2.0 | 4 votes |
@Override protected void afterActivityLaunched() { Intents.init(); super.afterActivityLaunched(); }
Example 18
Source File: CameraHelperTest.java From android-sdk with Apache License 2.0 | 4 votes |
@Before public void initializeIntents() { Intents.init(); }
Example 19
Source File: GalleryHelperTest.java From android-sdk with Apache License 2.0 | 4 votes |
@Before public void initializeIntents() { Intents.init(); }
Example 20
Source File: MainActivityTest.java From otp-authenticator with MIT License | 3 votes |
public void test001InvalidQRCode() throws InterruptedException { Intents.init(); String qr ="invalid qr code"; // Build a result to return from the ZXING app Intent resultData = new Intent(); resultData.putExtra(com.google.zxing.client.android.Intents.Scan.RESULT, 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); // Now that we have the stub in place, click on the button in our app that launches into the Camera onView(withId(R.id.action_scan)).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")); onView(withText("Invalid QR Code")).check(matches(isDisplayed())); Thread.sleep(5000); onView(withText("No account has been added yet")).check(matches(isDisplayed())); Intents.release(); }