Java Code Examples for androidx.test.espresso.intent.Intents#init()

The following examples show how to use androidx.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: ActivityWithMockingNetworkUITest.java    From adamant-android with GNU General Public License v3.0 5 votes vote down vote up
@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 2
Source File: MainActivityTest.java    From quickstart-android with Apache License 2.0 5 votes vote down vote up
@Before
public void before() {
    // Initialize intents
    Intents.init();

    // Idling resource
    mUploadIdlingResource = new ServiceIdlingResource(mActivityTestRule.getActivity(),
            MyUploadService.class);
    Espresso.registerIdlingResources(mUploadIdlingResource);
}
 
Example 3
Source File: IntentTest.java    From android-test with Apache License 2.0 5 votes vote down vote up
@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 4
Source File: SettingsAboutActivityTest.java    From google-authenticator-android with Apache License 2.0 5 votes vote down vote up
@Before
public void setUp() throws Exception {
  DependencyInjector.resetForIntegrationTesting(
      InstrumentationRegistry.getInstrumentation().getTargetContext());
  TestUtilities.withLaunchPreventingStartActivityListenerInDependencyResolver();
  Intents.init();
}
 
Example 5
Source File: SettingsActivityTest.java    From google-authenticator-android with Apache License 2.0 5 votes vote down vote up
@Before
public void setUp() throws Exception {
  DependencyInjector.resetForIntegrationTesting(
      InstrumentationRegistry.getInstrumentation().getTargetContext());
  TestUtilities.withLaunchPreventingStartActivityListenerInDependencyResolver();
  Intents.init();
}
 
Example 6
Source File: LoginUITest.java    From adamant-android with GNU General Public License v3.0 4 votes vote down vote up
@Before
public void before() {
    Intents.init();
    startActivity(testNameRule.getMethodName());
}
 
Example 7
Source File: IntentsTestRule.java    From android-test with Apache License 2.0 4 votes vote down vote up
@Override
protected void afterActivityLaunched() {
  Intents.init();
  isInitialized = true;
  super.afterActivityLaunched();
}
 
Example 8
Source File: OpenLinkActionTest.java    From android-test with Apache License 2.0 4 votes vote down vote up
@Before
public void setUp() {
  Intents.init();
  // Stubbing to block all external intents
  intending(not(isInternal())).respondWith(new ActivityResult(Activity.RESULT_OK, null));
}
 
Example 9
Source File: ChangeTextBehaviorLocalTest.java    From testing-samples with Apache License 2.0 4 votes vote down vote up
@Before
public void intentsInit() {
  // initialize Espresso Intents capturing
  Intents.init();
}
 
Example 10
Source File: AuthenticatorActivityTest.java    From google-authenticator-android with Apache License 2.0 4 votes vote down vote up
@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 11
Source File: HowItWorksActivityTest.java    From google-authenticator-android with Apache License 2.0 4 votes vote down vote up
@Before
public void setUp() throws Exception {
  Intents.init();
  instr = InstrumentationRegistry.getInstrumentation();
  DependencyInjector.resetForIntegrationTesting(instr.getTargetContext());
}
 
Example 12
Source File: AddAccountActivityTest.java    From google-authenticator-android with Apache License 2.0 4 votes vote down vote up
@Before
public void setUp() throws Exception {
  Intents.init();
  DependencyInjector.resetForIntegrationTesting(
      InstrumentationRegistry.getInstrumentation().getTargetContext());
}