Search in sources :

Example 1 with MainApplication

use of com.karumi.rosie.sample.main.MainApplication in project Rosie by Karumi.

the class InjectedInstrumentationTest method getApplication.

private MainApplication getApplication() {
    Instrumentation instrumentation = InstrumentationRegistry.getInstrumentation();
    MainApplication app = (MainApplication) instrumentation.getTargetContext().getApplicationContext();
    return app;
}
Also used : Instrumentation(android.app.Instrumentation) MainApplication(com.karumi.rosie.sample.main.MainApplication)

Example 2 with MainApplication

use of com.karumi.rosie.sample.main.MainApplication in project Rosie by Karumi.

the class InjectedInstrumentationTest method tearDown.

@After
public void tearDown() throws Exception {
    List<IdlingResource> idlingResources = getIdlingResources();
    for (IdlingResource resource : idlingResources) {
        unregisterIdlingResources(resource);
    }
    MainApplication application = getApplication();
    application.resetFakeGraph();
}
Also used : IdlingResource(android.support.test.espresso.IdlingResource) MainApplication(com.karumi.rosie.sample.main.MainApplication) After(org.junit.After)

Example 3 with MainApplication

use of com.karumi.rosie.sample.main.MainApplication in project Rosie by Karumi.

the class InjectedInstrumentationTest method setUp.

@Before
public void setUp() {
    MainApplication application = getApplication();
    List<Object> childTestModules = getTestModules();
    Context context = InstrumentationRegistry.getInstrumentation().getTargetContext();
    List<Object> testModules = new LinkedList<>(childTestModules);
    testModules.add(new BaseTestModule(context));
    ObjectGraph objectGraph = application.plusGraph(testModules);
    application.replaceGraph(objectGraph);
    objectGraph.inject(this);
}
Also used : Context(android.content.Context) ObjectGraph(dagger.ObjectGraph) LinkedList(java.util.LinkedList) MainApplication(com.karumi.rosie.sample.main.MainApplication) Before(org.junit.Before)

Aggregations

MainApplication (com.karumi.rosie.sample.main.MainApplication)3 Instrumentation (android.app.Instrumentation)1 Context (android.content.Context)1 IdlingResource (android.support.test.espresso.IdlingResource)1 ObjectGraph (dagger.ObjectGraph)1 LinkedList (java.util.LinkedList)1 After (org.junit.After)1 Before (org.junit.Before)1