use of android.test.ActivityInstrumentationTestCase2 in project cucumber-jvm by cucumber.
the class AndroidObjectFactory method decorate.
private void decorate(final Object instance) {
if (instance instanceof ActivityInstrumentationTestCase2) {
final ActivityInstrumentationTestCase2 activityInstrumentationTestCase2 = (ActivityInstrumentationTestCase2) instance;
activityInstrumentationTestCase2.injectInstrumentation(instrumentation);
final Intent intent = new Intent();
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
activityInstrumentationTestCase2.setActivityIntent(intent);
} else if (instance instanceof InstrumentationTestCase) {
((InstrumentationTestCase) instance).injectInstrumentation(instrumentation);
} else if (instance instanceof AndroidTestCase) {
((AndroidTestCase) instance).setContext(instrumentation.getTargetContext());
}
}
use of android.test.ActivityInstrumentationTestCase2 in project cucumber-jvm by cucumber.
the class AndroidObjectFactoryTest method sets_activity_intent_with_FLAG_ACTIVITY_CLEAR_TOP_to_prevent_stalling_when_calling_getActivity_if_the_activity_is_already_running.
@Test
public void sets_activity_intent_with_FLAG_ACTIVITY_CLEAR_TOP_to_prevent_stalling_when_calling_getActivity_if_the_activity_is_already_running() {
// given
final Class<?> activityInstrumentationTestCase2Class = ActivityInstrumentationTestCase2.class;
final ActivityInstrumentationTestCase2 activityInstrumentationTestCase2 = mock(ActivityInstrumentationTestCase2.class);
when(delegate.getInstance(activityInstrumentationTestCase2Class)).thenReturn(activityInstrumentationTestCase2);
final Intent intent = new Intent().addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
// when
androidObjectFactory.getInstance(activityInstrumentationTestCase2Class);
// then
verify(activityInstrumentationTestCase2).setActivityIntent(intent);
}
use of android.test.ActivityInstrumentationTestCase2 in project cucumber-jvm by cucumber.
the class AndroidObjectFactoryTest method injects_instrumentation_into_ActivityInstrumentationTestCase2.
@Test
public void injects_instrumentation_into_ActivityInstrumentationTestCase2() {
// given
final Class<?> activityInstrumentationTestCase2Class = ActivityInstrumentationTestCase2.class;
final ActivityInstrumentationTestCase2 activityInstrumentationTestCase2 = mock(ActivityInstrumentationTestCase2.class);
when(delegate.getInstance(activityInstrumentationTestCase2Class)).thenReturn(activityInstrumentationTestCase2);
// when
androidObjectFactory.getInstance(activityInstrumentationTestCase2Class);
// then
verify(activityInstrumentationTestCase2).injectInstrumentation(instrumentation);
}
Aggregations