use of android.test.InstrumentationTestCase in project cucumber-jvm by cucumber.
the class AndroidObjectFactoryTest method injects_instrumentation_into_InstrumentationTestCase.
@Test
public void injects_instrumentation_into_InstrumentationTestCase() {
// given
final Class<?> instrumentationTestCaseClass = InstrumentationTestCase.class;
final InstrumentationTestCase instrumentationTestCase = mock(InstrumentationTestCase.class);
when(delegate.getInstance(instrumentationTestCaseClass)).thenReturn(instrumentationTestCase);
// when
androidObjectFactory.getInstance(instrumentationTestCaseClass);
// then
verify(instrumentationTestCase).injectInstrumentation(instrumentation);
}
use of android.test.InstrumentationTestCase 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());
}
}
Aggregations