Search in sources :

Example 1 with InstrumentationTestCase

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);
}
Also used : InstrumentationTestCase(android.test.InstrumentationTestCase) Test(org.junit.Test)

Example 2 with InstrumentationTestCase

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());
    }
}
Also used : ActivityInstrumentationTestCase2(android.test.ActivityInstrumentationTestCase2) InstrumentationTestCase(android.test.InstrumentationTestCase) AndroidTestCase(android.test.AndroidTestCase) Intent(android.content.Intent)

Aggregations

InstrumentationTestCase (android.test.InstrumentationTestCase)2 Intent (android.content.Intent)1 ActivityInstrumentationTestCase2 (android.test.ActivityInstrumentationTestCase2)1 AndroidTestCase (android.test.AndroidTestCase)1 Test (org.junit.Test)1