use of android.test.AndroidTestCase in project cucumber-jvm by cucumber.
the class AndroidObjectFactoryTest method injects_instrumentation_context_into_AndroidTestCase.
@Test
public void injects_instrumentation_context_into_AndroidTestCase() {
// given
final Class<?> androidTestCaseClass = AndroidTestCase.class;
final AndroidTestCase androidTestCase = mock(AndroidTestCase.class);
when(delegate.getInstance(androidTestCaseClass)).thenReturn(androidTestCase);
final Context context = mock(Context.class);
when(instrumentation.getTargetContext()).thenReturn(context);
// when
androidObjectFactory.getInstance(androidTestCaseClass);
// then
verify(androidTestCase).setContext(context);
}
use of android.test.AndroidTestCase 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