Search in sources :

Example 1 with GrpcClientModule

use of com.google.firebase.inappmessaging.internal.injection.modules.GrpcClientModule in project firebase-android-sdk by firebase.

the class FirebaseInAppMessagingFlowableTest method setUp.

@Before
public void setUp() {
    initMocks(this);
    callbacksHashMap = new HashMap<>();
    clearProtoDiskCache(InstrumentationRegistry.getTargetContext());
    application = spy((Application) InstrumentationRegistry.getTargetContext().getApplicationContext());
    when(firebaseInstallations.getId()).thenReturn(Tasks.forResult(INSTALLATION_ID));
    when(firebaseInstallations.getToken(false)).thenReturn(Tasks.forResult(INSTALLATION_TOKEN_RESULT));
    when(testDeviceHelper.isAppInstallFresh()).thenReturn(false);
    when(testDeviceHelper.isDeviceInTestMode()).thenReturn(false);
    if (Looper.myLooper() == null) {
        Looper.prepare();
    }
    foregroundNotifier = new TestForegroundNotifier();
    universalComponentBuilder = DaggerTestUniversalComponent.builder().testGrpcModule(new TestGrpcModule(grpcServerRule.getChannel())).testForegroundFlowableModule(new TestForegroundFlowableModule(foregroundNotifier)).applicationModule(new ApplicationModule(application)).appMeasurementModule(new AppMeasurementModule(p -> p.handle(() -> analyticsConnector), firebaseEventSubscriber)).testSystemClockModule(new TestSystemClockModule(NOW)).programmaticContextualTriggerFlowableModule(new ProgrammaticContextualTriggerFlowableModule(new ProgramaticContextualTriggers()));
    TestUniversalComponent universalComponent = universalComponentBuilder.build();
    appComponentBuilder = DaggerTestAppComponent.builder().universalComponent(universalComponent).testAbTestingModule(new TestAbTestingModule(abtIntegrationHelper)).testEngagementMetricsLoggerClientModule(new TestEngagementMetricsLoggerClientModule(app, engagementMetricsLoggerInterface)).grpcClientModule(new GrpcClientModule(app)).testApiClientModule(new TestApiClientModule(app, firebaseInstallations, testDeviceHelper, universalComponent.clock()));
    TestAppComponent appComponent = appComponentBuilder.build();
    instance = appComponent.providesFirebaseInAppMessaging();
    displayCallbacksFactory = appComponent.displayCallbacksFactory();
    programaticContextualTriggers = universalComponent.programmaticContextualTriggers();
    grpcServerRule.getServiceRegistry().addService(new GoodFiamService(eligibleCampaigns));
    subscriber = listenerToFlowable(instance);
}
Also used : ProgrammaticContextualTriggerFlowableModule(com.google.firebase.inappmessaging.internal.injection.modules.ProgrammaticContextualTriggerFlowableModule) ProgramaticContextualTriggers(com.google.firebase.inappmessaging.internal.ProgramaticContextualTriggers) AppMeasurementModule(com.google.firebase.inappmessaging.internal.injection.modules.AppMeasurementModule) GrpcClientModule(com.google.firebase.inappmessaging.internal.injection.modules.GrpcClientModule) ApplicationModule(com.google.firebase.inappmessaging.internal.injection.modules.ApplicationModule) Application(android.app.Application) Before(org.junit.Before)

Example 2 with GrpcClientModule

use of com.google.firebase.inappmessaging.internal.injection.modules.GrpcClientModule in project firebase-android-sdk by firebase.

the class FirebaseInAppMessagingRegistrar method providesFirebaseInAppMessaging.

private FirebaseInAppMessaging providesFirebaseInAppMessaging(ComponentContainer container) {
    FirebaseApp firebaseApp = container.get(FirebaseApp.class);
    FirebaseInstallationsApi firebaseInstallations = container.get(FirebaseInstallationsApi.class);
    Deferred<AnalyticsConnector> analyticsConnector = container.getDeferred(AnalyticsConnector.class);
    Subscriber firebaseEventsSubscriber = container.get(Subscriber.class);
    Application application = (Application) firebaseApp.getApplicationContext();
    UniversalComponent universalComponent = DaggerUniversalComponent.builder().applicationModule(new ApplicationModule(application)).appMeasurementModule(new AppMeasurementModule(analyticsConnector, firebaseEventsSubscriber)).analyticsEventsModule(new AnalyticsEventsModule()).programmaticContextualTriggerFlowableModule(new ProgrammaticContextualTriggerFlowableModule(new ProgramaticContextualTriggers())).build();
    AppComponent instance = DaggerAppComponent.builder().abtIntegrationHelper(new AbtIntegrationHelper(container.get(AbtComponent.class).get(FirebaseABTesting.OriginService.INAPP_MESSAGING))).apiClientModule(new ApiClientModule(firebaseApp, firebaseInstallations, universalComponent.clock())).grpcClientModule(new GrpcClientModule(firebaseApp)).universalComponent(universalComponent).transportFactory(container.get(TransportFactory.class)).build();
    return instance.providesFirebaseInAppMessaging();
}
Also used : ProgrammaticContextualTriggerFlowableModule(com.google.firebase.inappmessaging.internal.injection.modules.ProgrammaticContextualTriggerFlowableModule) ProgramaticContextualTriggers(com.google.firebase.inappmessaging.internal.ProgramaticContextualTriggers) AnalyticsEventsModule(com.google.firebase.inappmessaging.internal.injection.modules.AnalyticsEventsModule) AppMeasurementModule(com.google.firebase.inappmessaging.internal.injection.modules.AppMeasurementModule) ApiClientModule(com.google.firebase.inappmessaging.internal.injection.modules.ApiClientModule) GrpcClientModule(com.google.firebase.inappmessaging.internal.injection.modules.GrpcClientModule) AnalyticsConnector(com.google.firebase.analytics.connector.AnalyticsConnector) ApplicationModule(com.google.firebase.inappmessaging.internal.injection.modules.ApplicationModule) Subscriber(com.google.firebase.events.Subscriber) AppComponent(com.google.firebase.inappmessaging.internal.injection.components.AppComponent) DaggerAppComponent(com.google.firebase.inappmessaging.internal.injection.components.DaggerAppComponent) AbtIntegrationHelper(com.google.firebase.inappmessaging.internal.AbtIntegrationHelper) FirebaseInstallationsApi(com.google.firebase.installations.FirebaseInstallationsApi) Application(android.app.Application) DaggerUniversalComponent(com.google.firebase.inappmessaging.internal.injection.components.DaggerUniversalComponent) UniversalComponent(com.google.firebase.inappmessaging.internal.injection.components.UniversalComponent) FirebaseApp(com.google.firebase.FirebaseApp)

Aggregations

Application (android.app.Application)2 ProgramaticContextualTriggers (com.google.firebase.inappmessaging.internal.ProgramaticContextualTriggers)2 AppMeasurementModule (com.google.firebase.inappmessaging.internal.injection.modules.AppMeasurementModule)2 ApplicationModule (com.google.firebase.inappmessaging.internal.injection.modules.ApplicationModule)2 GrpcClientModule (com.google.firebase.inappmessaging.internal.injection.modules.GrpcClientModule)2 ProgrammaticContextualTriggerFlowableModule (com.google.firebase.inappmessaging.internal.injection.modules.ProgrammaticContextualTriggerFlowableModule)2 FirebaseApp (com.google.firebase.FirebaseApp)1 AnalyticsConnector (com.google.firebase.analytics.connector.AnalyticsConnector)1 Subscriber (com.google.firebase.events.Subscriber)1 AbtIntegrationHelper (com.google.firebase.inappmessaging.internal.AbtIntegrationHelper)1 AppComponent (com.google.firebase.inappmessaging.internal.injection.components.AppComponent)1 DaggerAppComponent (com.google.firebase.inappmessaging.internal.injection.components.DaggerAppComponent)1 DaggerUniversalComponent (com.google.firebase.inappmessaging.internal.injection.components.DaggerUniversalComponent)1 UniversalComponent (com.google.firebase.inappmessaging.internal.injection.components.UniversalComponent)1 AnalyticsEventsModule (com.google.firebase.inappmessaging.internal.injection.modules.AnalyticsEventsModule)1 ApiClientModule (com.google.firebase.inappmessaging.internal.injection.modules.ApiClientModule)1 FirebaseInstallationsApi (com.google.firebase.installations.FirebaseInstallationsApi)1 Before (org.junit.Before)1