Search in sources :

Example 1 with AppDependencyComponent

use of org.odk.collect.android.injection.config.AppDependencyComponent in project collect by opendatakit.

the class FormMapActivityTest method setUpActivity.

@Before
public void setUpActivity() {
    CollectHelpers.setupDemoProject();
    AppDependencyComponent component = CollectHelpers.overrideAppDependencyModule(new AppDependencyModule() {

        @Override
        public MapProvider providesMapProvider() {
            MapProvider mapProvider = mock(MapProvider.class);
            when(mapProvider.createMapFragment(ArgumentMatchers.any())).thenReturn(map);
            return mapProvider;
        }
    });
    FormsRepository formsRepository = component.formsRepositoryProvider().get();
    instancesRepository = component.instancesRepositoryProvider().get();
    form = formsRepository.save(testForm);
    Arrays.stream(testInstances).forEach(instancesRepository::save);
    Intent intent = new Intent();
    intent.putExtra(FormMapActivity.EXTRA_FORM_ID, form.getDbId());
    activityController = CollectHelpers.buildThemedActivity(FormMapActivity.class, intent);
    activity = (FormMapActivity) activityController.get();
    activityController.setup();
}
Also used : MapProvider(org.odk.collect.android.geo.MapProvider) FormsRepository(org.odk.collect.forms.FormsRepository) AppDependencyComponent(org.odk.collect.android.injection.config.AppDependencyComponent) Intent(android.content.Intent) AppDependencyModule(org.odk.collect.android.injection.config.AppDependencyModule) Before(org.junit.Before)

Example 2 with AppDependencyComponent

use of org.odk.collect.android.injection.config.AppDependencyComponent in project collect by opendatakit.

the class CollectHelpers method overrideAppDependencyModule.

public static AppDependencyComponent overrideAppDependencyModule(AppDependencyModule appDependencyModule) {
    AppDependencyComponent testComponent = DaggerAppDependencyComponent.builder().application(ApplicationProvider.getApplicationContext()).appDependencyModule(appDependencyModule).build();
    ((Collect) ApplicationProvider.getApplicationContext()).setComponent(testComponent);
    return testComponent;
}
Also used : DaggerAppDependencyComponent(org.odk.collect.android.injection.config.DaggerAppDependencyComponent) AppDependencyComponent(org.odk.collect.android.injection.config.AppDependencyComponent) Collect(org.odk.collect.android.application.Collect)

Aggregations

AppDependencyComponent (org.odk.collect.android.injection.config.AppDependencyComponent)2 Intent (android.content.Intent)1 Before (org.junit.Before)1 Collect (org.odk.collect.android.application.Collect)1 MapProvider (org.odk.collect.android.geo.MapProvider)1 AppDependencyModule (org.odk.collect.android.injection.config.AppDependencyModule)1 DaggerAppDependencyComponent (org.odk.collect.android.injection.config.DaggerAppDependencyComponent)1 FormsRepository (org.odk.collect.forms.FormsRepository)1