Search in sources :

Example 1 with ShadowActivity

use of org.robolectric.shadows.ShadowActivity in project collect by opendatakit.

the class MainActivityTest method sendDataButtonTest.

/**
 * {@link Test} to assert sendDataButton's functioning.
 */
@Test
public void sendDataButtonTest() throws Exception {
    Button sendDataButton = mainMenuActivity.findViewById(R.id.send_data);
    assertNotNull(sendDataButton);
    assertEquals(View.VISIBLE, sendDataButton.getVisibility());
    assertEquals(mainMenuActivity.getString(R.string.send_data_button), sendDataButton.getText());
    sendDataButton.performClick();
    ShadowActivity shadowActivity = shadowOf(mainMenuActivity);
    Intent startedIntent = shadowActivity.getNextStartedActivity();
    ShadowIntent shadowIntent = shadowOf(startedIntent);
    assertEquals(InstanceUploaderList.class.getName(), shadowIntent.getIntentClass().getName());
}
Also used : ShadowIntent(org.robolectric.shadows.ShadowIntent) Button(android.widget.Button) ShadowActivity(org.robolectric.shadows.ShadowActivity) ShadowIntent(org.robolectric.shadows.ShadowIntent) Intent(android.content.Intent) Test(org.junit.Test)

Example 2 with ShadowActivity

use of org.robolectric.shadows.ShadowActivity in project collect by opendatakit.

the class MainActivityTest method dataButtonTest.

/**
 * {@link Test} to assert dataButton's functioning.
 */
@Test
public void dataButtonTest() throws Exception {
    Button dataButton = mainMenuActivity.findViewById(R.id.enter_data);
    assertNotNull(dataButton);
    assertEquals(View.VISIBLE, dataButton.getVisibility());
    assertEquals(mainMenuActivity.getString(R.string.enter_data_button), dataButton.getText());
    dataButton.performClick();
    ShadowActivity shadowActivity = shadowOf(mainMenuActivity);
    Intent startedIntent = shadowActivity.getNextStartedActivity();
    ShadowIntent shadowIntent = shadowOf(startedIntent);
    assertEquals(FormChooserList.class.getName(), shadowIntent.getIntentClass().getName());
}
Also used : ShadowIntent(org.robolectric.shadows.ShadowIntent) Button(android.widget.Button) ShadowActivity(org.robolectric.shadows.ShadowActivity) ShadowIntent(org.robolectric.shadows.ShadowIntent) Intent(android.content.Intent) Test(org.junit.Test)

Example 3 with ShadowActivity

use of org.robolectric.shadows.ShadowActivity in project android_packages_apps_Settings by LineageOS.

the class HelpTrampolineTest method launchHelp_hasExtra_shouldLaunchHelp.

@Test
public void launchHelp_hasExtra_shouldLaunchHelp() {
    final Intent intent = new Intent().setClassName(RuntimeEnvironment.application.getPackageName(), HelpTrampoline.class.getName()).putExtra(Intent.EXTRA_TEXT, "help_url_upgrading");
    final ShadowActivity shadow = shadowOf(Robolectric.buildActivity(HelpTrampoline.class).withIntent(intent).create().get());
    final Intent launchedIntent = shadow.getNextStartedActivity();
    assertThat(ShadowHelpUtils.isGetHelpIntentCalled()).isTrue();
    assertThat(launchedIntent).isNotNull();
}
Also used : ShadowActivity(org.robolectric.shadows.ShadowActivity) Intent(android.content.Intent) Test(org.junit.Test)

Example 4 with ShadowActivity

use of org.robolectric.shadows.ShadowActivity in project android_packages_apps_Settings by LineageOS.

the class FingerprintEnrollFindSensorTest method clickSkip_shouldReturnResultSkip.

@Test
public void clickSkip_shouldReturnResultSkip() {
    Button skipButton = mActivity.findViewById(R.id.skip_button);
    skipButton.performClick();
    ShadowActivity shadowActivity = Shadows.shadowOf(mActivity);
    assertThat(shadowActivity.getResultCode()).named("result code").isEqualTo(FingerprintEnrollBase.RESULT_SKIP);
}
Also used : Button(android.widget.Button) ShadowActivity(org.robolectric.shadows.ShadowActivity) Test(org.junit.Test)

Example 5 with ShadowActivity

use of org.robolectric.shadows.ShadowActivity in project android_packages_apps_Settings by LineageOS.

the class SetupFingerprintEnrollIntroductionTest method testBackKeyPress_shouldNotSetIntentDataIfLockScreenPresentBeforeLaunch.

@Test
public void testBackKeyPress_shouldNotSetIntentDataIfLockScreenPresentBeforeLaunch() {
    getShadowKeyguardManager().setIsKeyguardSecure(true);
    mController.create().resume();
    SetupFingerprintEnrollIntroduction activity = mController.get();
    activity.onBackPressed();
    ShadowActivity shadowActivity = Shadows.shadowOf(activity);
    assertThat(shadowActivity.getResultIntent()).isNull();
}
Also used : ShadowActivity(org.robolectric.shadows.ShadowActivity) Test(org.junit.Test)

Aggregations

ShadowActivity (org.robolectric.shadows.ShadowActivity)201 Test (org.junit.Test)191 Intent (android.content.Intent)101 ComponentName (android.content.ComponentName)70 Button (android.widget.Button)51 IntentForResult (org.robolectric.shadows.ShadowActivity.IntentForResult)41 Bundle (android.os.Bundle)32 Activity (android.app.Activity)28 EnrollmentCallback (android.hardware.fingerprint.FingerprintManager.EnrollmentCallback)21 Config (org.robolectric.annotation.Config)15 IntentBuilder (com.android.settings.password.ChooseLockPassword.IntentBuilder)7 SetupChooseLockPasswordFragment (com.android.settings.password.SetupChooseLockPassword.SetupChooseLockPasswordFragment)7 Tile (com.android.settingslib.drawer.Tile)7 ShadowIntent (org.robolectric.shadows.ShadowIntent)7 Preference (android.support.v7.preference.Preference)6 SettingsActivity (com.android.settings.SettingsActivity)6 SubSettings (com.android.settings.SubSettings)6 TestConfig (com.android.settings.TestConfig)6 PartnerCustomizationLayout (com.google.android.setupcompat.PartnerCustomizationLayout)6 ShadowApplication (org.robolectric.shadows.ShadowApplication)6