androidx.test.espresso.intent.Intents Java Examples
The following examples show how to use
androidx.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 File: ActivityWithMockingNetworkUITest.java From adamant-android with GNU General Public License v3.0 | 5 votes |
@After public void teardown() throws IOException { InstrumentationTestFacade instrumentationTestFacade = application.getInstrumentationTestFacade(); instrumentationTestFacade.logout(); super.teardown(); Intents.release(); mockWebServer.shutdown(); }
Example #2
Source File: AuthenticatorActivityTest.java From google-authenticator-android with Apache License 2.0 | 5 votes |
@After public void tearDown() throws Exception { // Stop the activity to avoid it using the DependencyInjector after it's been closed. TestUtilities.invokeFinishActivityOnUiThread(activityTestRule.getActivity()); DependencyInjector.close(); Intents.release(); }
Example #3
Source File: DialerActivityTest.java From testing-samples with Apache License 2.0 | 5 votes |
/** * Duplicate typeNumber_ValidInput_InitiatesCall, but using truth assertions */ @Test public void typeNumber_ValidInput_InitiatesCall_truth() { // Types a phone number into the dialer edit text field and presses the call button. onView(withId(R.id.edit_text_caller_number)) .perform(typeText(VALID_PHONE_NUMBER), closeSoftKeyboard()); onView(withId(R.id.button_call_number)).perform(click()); // Verify that an intent to the dialer was sent with the correct action, phone // number and package. Intent receivedIntent = Iterables.getOnlyElement(Intents.getIntents()); assertThat(receivedIntent).hasAction(Intent.ACTION_CALL); assertThat(receivedIntent).hasData(INTENT_DATA_PHONE_NUMBER); }
Example #4
Source File: ChangeTextBehaviorLocalTest.java From testing-samples with Apache License 2.0 | 5 votes |
@Test public void changeText_newActivity() { // Type text and then press the button. onView(withId(R.id.editTextUserInput)).perform(typeText(STRING_TO_BE_TYPED), closeSoftKeyboard()); onView(withId(R.id.activityChangeTextBtn)).perform(click()); // An intent is fired to launch a different Activity. Robolectric doesn't currently // support launching a new Activity, so use Espresso Intents to verify intent was sent assertThat(Iterables.getOnlyElement(Intents.getIntents())).hasComponentClass( ShowTextActivity.class); }
Example #5
Source File: SettingsAboutActivityTest.java From google-authenticator-android with Apache License 2.0 | 5 votes |
@Before public void setUp() throws Exception { DependencyInjector.resetForIntegrationTesting( InstrumentationRegistry.getInstrumentation().getTargetContext()); TestUtilities.withLaunchPreventingStartActivityListenerInDependencyResolver(); Intents.init(); }
Example #6
Source File: SettingsActivityTest.java From google-authenticator-android with Apache License 2.0 | 5 votes |
@Before public void setUp() throws Exception { DependencyInjector.resetForIntegrationTesting( InstrumentationRegistry.getInstrumentation().getTargetContext()); TestUtilities.withLaunchPreventingStartActivityListenerInDependencyResolver(); Intents.init(); }
Example #7
Source File: IntentsTestRule.java From android-test with Apache License 2.0 | 5 votes |
@Override protected void afterActivityFinished() { super.afterActivityFinished(); if (isInitialized) { // Otherwise will throw a NPE if Intents.init() wasn't called. Intents.release(); isInitialized = false; } }
Example #8
Source File: IntentTest.java From android-test with Apache License 2.0 | 5 votes |
@Before public void setUp() throws Exception { // Espresso will not launch our activity for us, we must launch it via ActivityScenario.launch. ActivityScenario.launch(SendActivity.class); // Once initialized, Intento will begin recording and providing stubbing for intents. Intents.init(); // Stubbing to block all external intents intending(not(isInternal())).respondWith(new ActivityResult(Activity.RESULT_OK, null)); }
Example #9
Source File: MainActivityTest.java From quickstart-android with Apache License 2.0 | 5 votes |
@After public void after() { // Release intents Intents.release(); // Idling resource if (mUploadIdlingResource != null) { Espresso.unregisterIdlingResources(mUploadIdlingResource); } }
Example #10
Source File: MainActivityTest.java From quickstart-android with Apache License 2.0 | 5 votes |
@Before public void before() { // Initialize intents Intents.init(); // Idling resource mUploadIdlingResource = new ServiceIdlingResource(mActivityTestRule.getActivity(), MyUploadService.class); Espresso.registerIdlingResources(mUploadIdlingResource); }
Example #11
Source File: ActivityWithMockingNetworkUITest.java From adamant-android with GNU General Public License v3.0 | 5 votes |
@Before public void setup() throws IOException { super.setup(); Dispatcher dispatcher = provideDispatcher(testNameRule.getMethodName()); if (dispatcher != null) { mockWebServer.setDispatcher(dispatcher); } mockWebServer.start(8080); startActivity(testNameRule.getMethodName()); Intents.init(); }
Example #12
Source File: HowItWorksActivityTest.java From google-authenticator-android with Apache License 2.0 | 4 votes |
@After public void tearDown() throws Exception { DependencyInjector.close(); Intents.release(); }
Example #13
Source File: HowItWorksActivityTest.java From google-authenticator-android with Apache License 2.0 | 4 votes |
@Before public void setUp() throws Exception { Intents.init(); instr = InstrumentationRegistry.getInstrumentation(); DependencyInjector.resetForIntegrationTesting(instr.getTargetContext()); }
Example #14
Source File: SettingsActivityTest.java From google-authenticator-android with Apache License 2.0 | 4 votes |
@After public void tearDown() throws Exception { DependencyInjector.close(); Intents.release(); }
Example #15
Source File: SettingsAboutActivityTest.java From google-authenticator-android with Apache License 2.0 | 4 votes |
@After public void tearDown() throws Exception { DependencyInjector.close(); Intents.release(); }
Example #16
Source File: AddAccountActivityTest.java From google-authenticator-android with Apache License 2.0 | 4 votes |
@Before public void setUp() throws Exception { Intents.init(); DependencyInjector.resetForIntegrationTesting( InstrumentationRegistry.getInstrumentation().getTargetContext()); }
Example #17
Source File: AddAccountActivityTest.java From google-authenticator-android with Apache License 2.0 | 4 votes |
@After public void tearDown() throws Exception { DependencyInjector.close(); Intents.release(); }
Example #18
Source File: AuthenticatorActivityTest.java From google-authenticator-android with Apache License 2.0 | 4 votes |
@Before public void setUp() throws Exception { Intents.init(); DependencyInjector.resetForIntegrationTesting( InstrumentationRegistry.getInstrumentation().getTargetContext()); accountDb = DependencyInjector.getAccountDb(); initMocks(this); otpSource = new OtpProvider(accountDb, mockTotpClock); // To launch the SettingsActivity, setting the mock module here. // (SettingsActivity is used in the testOptionsMenuSettings test) DaggerInjector.init(new MockModule()); when(mockTotpClock.nowMillis()).thenReturn(NOW_MILLIS); // Make sure the notice for first account added is not showing. PreferenceManager .getDefaultSharedPreferences( InstrumentationRegistry.getInstrumentation().getTargetContext()) .edit() .putInt(AuthenticatorActivity.PREF_KEY_LAST_LAUNCH_ACCOUNT_COUNT, 1) .commit(); when(mockBarcodeConditionChecker.isCameraAvailableOnDevice(any(Activity.class))) .thenReturn(true); when(mockBarcodeConditionChecker.isGooglePlayServicesAvailable(any(Activity.class))) .thenReturn(true); when(mockBarcodeConditionChecker.getIsBarcodeDetectorOperational(any(Activity.class))) .thenReturn(true); when(mockBarcodeConditionChecker.isLowStorage(any(Activity.class))).thenReturn(false); when(mockPermissionRequestor.shouldShowRequestPermissionRationale( any(Activity.class), eq(Manifest.permission.CAMERA))) .thenReturn(false); when(mockPermissionRequestor.checkSelfPermission( any(Context.class), eq(Manifest.permission.CAMERA))) .thenReturn(PackageManager.PERMISSION_GRANTED); setDarkModeEnabled(InstrumentationRegistry.getInstrumentation().getTargetContext(), false); }
Example #19
Source File: ChangeTextBehaviorLocalTest.java From testing-samples with Apache License 2.0 | 4 votes |
@After public void intentsTeardown() { // release Espresso Intents capturing Intents.release(); }
Example #20
Source File: ChangeTextBehaviorLocalTest.java From testing-samples with Apache License 2.0 | 4 votes |
@Before public void intentsInit() { // initialize Espresso Intents capturing Intents.init(); }
Example #21
Source File: OpenLinkActionTest.java From android-test with Apache License 2.0 | 4 votes |
@After public void tearDown() throws Exception { Intents.release(); }
Example #22
Source File: OpenLinkActionTest.java From android-test with Apache License 2.0 | 4 votes |
@Before public void setUp() { Intents.init(); // Stubbing to block all external intents intending(not(isInternal())).respondWith(new ActivityResult(Activity.RESULT_OK, null)); }
Example #23
Source File: IntentsTestRule.java From android-test with Apache License 2.0 | 4 votes |
@Override protected void afterActivityLaunched() { Intents.init(); isInitialized = true; super.afterActivityLaunched(); }
Example #24
Source File: IntentTest.java From android-test with Apache License 2.0 | 4 votes |
@After public void tearDown() throws Exception { // Releasing clears recorded intents and stubbing, ensuring a clean state for each test. Intents.release(); }
Example #25
Source File: LoginUITest.java From adamant-android with GNU General Public License v3.0 | 4 votes |
@After public void after() { Intents.release(); activityRule.finishActivity(); }
Example #26
Source File: LoginUITest.java From adamant-android with GNU General Public License v3.0 | 4 votes |
@Before public void before() { Intents.init(); startActivity(testNameRule.getMethodName()); }