private void startNewLocalConnection(String name) { onView(withId(R.id.add_host_button)).perform(click()); onView(withId(R.id.protocol_text)).perform(click()); onView(withText("local")).perform(click()); onView(withId(R.id.quickconnect_field)).perform(typeText(name)); onView(withId(R.id.save)).perform(click()); Intents.init(); try { onView(withId(R.id.list)).perform(actionOnHolderItem( withHostNickname(name), click())); intended(hasComponent(ConsoleActivity.class.getName())); } finally { Intents.release(); } onView(withId(R.id.console_flip)).check(matches( hasDescendant(allOf(isDisplayed(), withId(R.id.terminal_view))))); }
@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)); }
@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); }
@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)); }
/** * Check if the activity is changed when any view is clicked. * * @param context instance of the caller. * @param viewId id of the view. * @param nextActivityName Name of the next activity. */ public static void checkActivityOnViewClicked(Context context, int viewId, String nextActivityName) { Intents.init(); //set intent package intending(toPackage(context.getString(R.string.package_name))); // Perform click operation on FAB onView(withId(viewId)).perform(click()); // Assert that if the opened activity is Quiz activity. intended(hasComponent(nextActivityName)); Intents.release(); }
@Test public void checkTextOnScreen() { //to check view on screen Intent resultData = new Intent(Intent.ACTION_PICK, android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI); resultData.setData(Uri.parse(("content://media/external/images/media/337663"))); Matcher<Intent> MediaPickIntent = allOf(hasAction(Intent.ACTION_PICK), hasData(android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI)); Intents.init(); intending(MediaPickIntent).respondWith(new Instrumentation.ActivityResult(Activity.RESULT_OK, resultData)); onView(withText("Gallery")).perform(click()); onView(withId(R.id.btnGalleryPick)).perform(click()); intended(MediaPickIntent); //To check the image pick works or not try{ Thread.sleep(4500); } catch (InterruptedException e) { e.printStackTrace(); } }
@Test public void shouldLoadUsersAndTriggerIntent() { serverRule .enqueueGET(200, "users.json") .assertPathIs("/2.2/users") .assertHasQuery("order", "desc") .assertHasQuery("sort", "reputation") .assertHasQuery("site", "stackoverflow"); Intents.init(); activityRule.launchActivity(new Intent(Intent.ACTION_MAIN)); onView(withId(R.id.recyclerView)) .perform(scrollToPosition(3)); TestUtils.rotateScreen(activityRule); onView(withId(R.id.recyclerView)) .perform(actionOnItemAtPosition(2, click())); intended(allOf( hasAction(Intent.ACTION_VIEW), hasData(Uri.parse("http://stackoverflow.com/users/157882/balusc")) )); Intents.release(); }
@Test public void shouldLoadUsersAndTriggerIntent() { when(mockApi.getUsers(anyInt())).thenReturn(successResult()); Intents.init(); activityRule.launchActivity(new Intent(Intent.ACTION_MAIN)); onView(withId(R.id.recyclerView)) .perform(scrollToPosition(3)); TestUtils.rotateScreen(activityRule); onView(withId(R.id.recyclerView)) .perform(actionOnItemAtPosition(2, click())); intended(allOf( hasAction(Intent.ACTION_VIEW), hasData(Uri.parse("http://stackoverflow.com/users/157882/balusc")) )); Intents.release(); }
public void testTapItem() { Intents.init(); addInitialData(); pause(); // DO UI INTERACTION onView(withId(R.id.recycler)).perform(RecyclerViewActions.actionOnItemAtPosition(1, click ())); pause(); // Confirm that the TodoListActivity was started! intended(hasComponent(TodoListActivity.class.getName())); Intents.release(); }
@Test public void speakerImage_WhenClicked_IntentFired() { Intent resultData = new Intent(); resultData.putExtras(new Bundle()); // Create the ActivityResult with the Intent. Intents.intending(CoreMatchers.not(IntentMatchers.isInternal())).respondWith( new Instrumentation.ActivityResult(Activity.RESULT_OK, resultData)); // When clicking on speaker image onView(withId(R.id.session_detail_frag)).perform(swipeUp()); onView(withId(R.id.speaker_image)).perform(click()); // Then the intent to display the speaker url is fired Uri expectedSpeakerUri = Uri.parse(SpeakersMockCursor.FAKE_SPEAKER_URL); intended(CoreMatchers.allOf( hasAction(IsEqual.equalTo(Intent.ACTION_VIEW)), hasData(expectedSpeakerUri))); }
@Test public void youTubeVideo_WhenClicked_IntentFired() { Intent resultData = new Intent(); resultData.putExtras(new Bundle()); // Create the ActivityResult with the Intent. Intents.intending(CoreMatchers.not(IntentMatchers.isInternal())).respondWith( new Instrumentation.ActivityResult(Activity.RESULT_OK, resultData)); // When clicking on video onView(withId(R.id.watch)).perform(click()); // Then the intent to play the video is fired IntentUtils.checkVideoIntentIsFired(SessionsMockCursor.FAKE_YOUTUBE_URL, mActivityRule.getActivity(), false); }
@After public void destroy() { Intents.release(); try { BlockChain.getInstance(null).disconnect(); } catch (Exception e) { e.printStackTrace(); } activity.finish(); }
@After public void destroy() { Intents.release(); try { BlockChain.getInstance(null).disconnect(); } catch (Exception e) { e.printStackTrace(); } resultActivity.finish(); }
@After public void destroy() { Intents.release(); try { BlockChain.getInstance(null).disconnect(); } catch (Exception e) { e.printStackTrace(); } electionActivity.finish(); }
@Before public void setUp() throws Exception { Intents.init(); mIdlingResource = mActivityRule.getActivity().getIdlingResource(); IdlingRegistry.getInstance().register(mIdlingResource); }
@After public void tearDown() { Intents.release(); if (mIdlingResource != null) { IdlingRegistry.getInstance().unregister(mIdlingResource); } }
@OnStartTest() public void onStartTest(String featureName, String scenarioName) { IdlingPolicies.setMasterPolicyTimeout(30, TimeUnit.SECONDS); Log.v(runnerConfig.LogTag, "Starting Test: " + featureName + " - " + scenarioName); Intents.init(); }
@OnFinishTest() public void onFinishTest(String featureName, String scenarioName) { getInstrumentation().waitForIdleSync(); if (LoginScreen.ActivityInstance != null) { if (Build.VERSION.SDK_INT > 20) { LoginScreen.ActivityInstance.finishAndRemoveTask(); } } Intents.release(); }
@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(); } } }; }
@Before public void setUp() throws Exception { mContext = InstrumentationRegistry.getContext(); ApiFactory.setProvider(new IntegrationProviderImpl(new TestServerImpl())); Intents.init(); clearRepositories(); }
@Test public void testStartsLogInActivity() throws Exception { onView(withId(R.id.pager)).perform(swipeLeft()); onView(withId(R.id.pager)).perform(swipeLeft()); onView(withId(R.id.btn_walkthrough)).perform(click()); Intents.intended(hasComponent(LogInActivity.class.getName())); }
@Test public void testErrorThenCorrect() throws Exception { errorInputAndClick(); onView(LOGIN_INPUT_LAYOUT).check(matches(withInputError(R.string.error))); clearInputs(); correctInputAndClick(); Intents.intended(hasComponent(RepositoriesActivity.class.getName())); }
@Before public void before() { // Initialize intents Intents.init(); // Idling resource mUploadIdlingResource = new ServiceIdlingResource(mActivityTestRule.getActivity(), MyUploadService.class); Espresso.registerIdlingResources(mUploadIdlingResource); }
@After public void after() { // Release intents Intents.release(); // Idling resource if (mUploadIdlingResource != null) { Espresso.unregisterIdlingResources(mUploadIdlingResource); } }
private void createCameraMockup(String qrCode){ //mockup camera result Intent resultData = new Intent(); resultData.putExtra(com.google.zxing.client.android.Intents.Scan.RESULT, qrCode); Instrumentation.ActivityResult result = new Instrumentation.ActivityResult(Activity.RESULT_OK, resultData); Matcher<Intent> matcher = hasAction(com.google.zxing.client.android.Intents.Scan.ACTION); OngoingStubbing ongoingStubbing = intending(matcher); ongoingStubbing.respondWith(result); //end mockup camera result }
@Test public void testRecipeAnalysis() { when(repository.getRecipeAnalysisData(ArgumentMatchers.<RecipeAnalysisParams>any())) .thenReturn(Single.just(AssetUtils.getRecipeAnalysisResult(context))); rule.launchActivity(new Intent()); selectTab(); inputFields(); onView(withId(R.id.btn_analyze)).perform(click()); Intents.intended(IntentMatchers.hasComponent(RecipeAnalysisDetailsActivity.class.getName())); }
@SuppressWarnings("UnusedParameters") @After public static void after(Scenario scenario) { ActivityUtils.finishOpenActivities(); Intents.release(); }
@Test public void testClickOnItem() throws Exception { onView(withId(R.id.recyclerView)) .perform(actionOnItemAtPosition(14, click())); Intents.intended(hasComponent(CommitsActivity.class.getName())); }
@After public void tearDown() throws Exception { Intents.release(); if (idlingResource != null) { Espresso.unregisterIdlingResources(idlingResource); } RepositoryProvider.provideKeyValueStorage().clear(); Realm.getDefaultInstance().executeTransaction(realm -> realm.deleteAll()); }
@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); }
@Test public void wipeDataOnLogout(){ //Given Intents.init(); onView(withId(org.hisp.dhis.android.sdk.R.id.server_url)).perform(replaceText(SDKTestUtils.HNQIS_DEV_CI)); onView(withId(org.hisp.dhis.android.sdk.R.id.username)).perform(replaceText(SDKTestUtils.TEST_USERNAME_WITH_PERMISSION)); onView(withId(org.hisp.dhis.android.sdk.R.id.password)).perform(replaceText(SDKTestUtils.TEST_PASSWORD_WITH_PERMISSION)); onView(withId(org.hisp.dhis.android.sdk.R.id.login_button)).perform(click()); intended(hasComponent(ProgressActivity.class.getName())); //Waiting for pull to finish in order to clear the state of the app waitForPull(DEFAULT_WAIT_FOR_PULL); //When SDKTestUtils.goToLogin(); //Then //Removed sdk data assertTrue(EventExtended.count() == 0); assertTrue(DataValueExtended.count() == 0); //removed app data assertTrue(Survey.count() == 0); assertTrue(Value.count() == 0); Intents.release(); }
@Test public void loginWithRightCredentials(){ Intents.init(); onView(withId(org.hisp.dhis.android.sdk.R.id.server_url)).perform(replaceText(SDKTestUtils.HNQIS_DEV_CI)); onView(withId(org.hisp.dhis.android.sdk.R.id.username)).perform(replaceText(SDKTestUtils.TEST_USERNAME_WITH_PERMISSION)); onView(withId(org.hisp.dhis.android.sdk.R.id.password)).perform(replaceText(SDKTestUtils.TEST_PASSWORD_WITH_PERMISSION)); onView(withId(org.hisp.dhis.android.sdk.R.id.login_button)).perform(click()); intended(hasComponent(ProgressActivity.class.getName())); //Waiting for pull to finish in order to clear the state of the app waitForPull(DEFAULT_WAIT_FOR_PULL); Intents.release(); }
@Before public void setUp() { final Intent testIntent = new Intent(activityTestRule.getActivity(), MainDialog.class).putExtra( NotificationTools.EXTRA_INTENT, Constants.testPin); Intents.init(); activityTestRule.launchActivity(testIntent); }
@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(); }
@Test public void scan() { Context context = InstrumentationRegistry.getTargetContext(); Assume.assumeTrue(MainActivity.isZXingSupported(context)); final String format = "EAN_13"; final String result = "9781449328214"; Intents.init(); activityRule.launchActivity(null); Intent data = new Intent(); data.putExtra(MainActivity.KEY_SCAN_RESULT_FORMAT, format); data.putExtra(MainActivity.KEY_SCAN_RESULT, result); Instrumentation.ActivityResult activityResult = new Instrumentation.ActivityResult( Activity.RESULT_OK, data); intending(hasAction(MainActivity.ACTION_ZXING_SCAN)) .respondWith(activityResult); onView(withId(R.id.scan_button)) .check(matches(isDisplayed())) .perform(click()); onView(withId(R.id.format)) .check(matches(withText(format))); onView(withId(R.id.result)) .check(matches(withText(result))); Intents.release(); }
@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(); }