Search in sources :

Example 1 with AnalyticsConnectorListener

use of com.google.firebase.analytics.connector.AnalyticsConnector.AnalyticsConnectorListener in project firebase-android-sdk by firebase.

the class ProxyAnalyticsConnectorTest method registerListener_whenConnectorLoadsAfterRegistration_shouldPropagateRegistrationAndEventNames.

@Test
public void registerListener_whenConnectorLoadsAfterRegistration_shouldPropagateRegistrationAndEventNames() {
    TestDeferred<AnalyticsConnector> testDeferred = new TestDeferred<>();
    ProxyAnalyticsConnector proxy = new ProxyAnalyticsConnector(testDeferred);
    AnalyticsConnectorListener listener = (i, bundle) -> {
    };
    AnalyticsConnectorHandle handle = proxy.registerAnalyticsConnectorListener("fiam", listener);
    handle.registerEventNames(Collections.singleton("hello"));
    testDeferred.provide(mockConnector);
    verify(mockConnector).registerAnalyticsConnectorListener("fiam", listener);
    verify(mockHandle, times(1)).registerEventNames(Collections.singleton("hello"));
}
Also used : AnalyticsConnectorListener(com.google.firebase.analytics.connector.AnalyticsConnector.AnalyticsConnectorListener) Bundle(android.os.Bundle) AnalyticsConnectorHandle(com.google.firebase.analytics.connector.AnalyticsConnector.AnalyticsConnectorHandle) NonNull(androidx.annotation.NonNull) RunWith(org.junit.runner.RunWith) Set(java.util.Set) Mockito.times(org.mockito.Mockito.times) Test(org.junit.Test) Mockito.when(org.mockito.Mockito.when) AndroidJUnit4(androidx.test.ext.junit.runners.AndroidJUnit4) Matchers.anyString(org.mockito.Matchers.anyString) AnalyticsConnectorListener(com.google.firebase.analytics.connector.AnalyticsConnector.AnalyticsConnectorListener) Mockito.verify(org.mockito.Mockito.verify) Matchers.any(org.mockito.Matchers.any) Mockito.never(org.mockito.Mockito.never) AnalyticsConnector(com.google.firebase.analytics.connector.AnalyticsConnector) Deferred(com.google.firebase.inject.Deferred) Collections(java.util.Collections) LinkedHashSet(java.util.LinkedHashSet) Mockito.mock(org.mockito.Mockito.mock) Before(org.junit.Before) AnalyticsConnectorHandle(com.google.firebase.analytics.connector.AnalyticsConnector.AnalyticsConnectorHandle) AnalyticsConnector(com.google.firebase.analytics.connector.AnalyticsConnector) Test(org.junit.Test)

Example 2 with AnalyticsConnectorListener

use of com.google.firebase.analytics.connector.AnalyticsConnector.AnalyticsConnectorListener in project firebase-android-sdk by firebase.

the class ProxyAnalyticsConnectorTest method registerListener_whenConnectorLoadsAfterUnRegistration_shouldNotPropagateRegistrationAndEventNames.

@Test
public void registerListener_whenConnectorLoadsAfterUnRegistration_shouldNotPropagateRegistrationAndEventNames() {
    TestDeferred<AnalyticsConnector> testDeferred = new TestDeferred<>();
    ProxyAnalyticsConnector proxy = new ProxyAnalyticsConnector(testDeferred);
    AnalyticsConnectorListener listener = (i, bundle) -> {
    };
    AnalyticsConnectorHandle handle = proxy.registerAnalyticsConnectorListener("fiam", listener);
    handle.unregister();
    handle.registerEventNames(Collections.singleton("hello"));
    testDeferred.provide(mockConnector);
    verify(mockConnector, never()).registerAnalyticsConnectorListener("fiam", listener);
    verify(mockHandle, never()).registerEventNames(Collections.singleton("hello"));
}
Also used : AnalyticsConnectorListener(com.google.firebase.analytics.connector.AnalyticsConnector.AnalyticsConnectorListener) Bundle(android.os.Bundle) AnalyticsConnectorHandle(com.google.firebase.analytics.connector.AnalyticsConnector.AnalyticsConnectorHandle) NonNull(androidx.annotation.NonNull) RunWith(org.junit.runner.RunWith) Set(java.util.Set) Mockito.times(org.mockito.Mockito.times) Test(org.junit.Test) Mockito.when(org.mockito.Mockito.when) AndroidJUnit4(androidx.test.ext.junit.runners.AndroidJUnit4) Matchers.anyString(org.mockito.Matchers.anyString) AnalyticsConnectorListener(com.google.firebase.analytics.connector.AnalyticsConnector.AnalyticsConnectorListener) Mockito.verify(org.mockito.Mockito.verify) Matchers.any(org.mockito.Matchers.any) Mockito.never(org.mockito.Mockito.never) AnalyticsConnector(com.google.firebase.analytics.connector.AnalyticsConnector) Deferred(com.google.firebase.inject.Deferred) Collections(java.util.Collections) LinkedHashSet(java.util.LinkedHashSet) Mockito.mock(org.mockito.Mockito.mock) Before(org.junit.Before) AnalyticsConnectorHandle(com.google.firebase.analytics.connector.AnalyticsConnector.AnalyticsConnectorHandle) AnalyticsConnector(com.google.firebase.analytics.connector.AnalyticsConnector) Test(org.junit.Test)

Aggregations

Bundle (android.os.Bundle)2 NonNull (androidx.annotation.NonNull)2 AndroidJUnit4 (androidx.test.ext.junit.runners.AndroidJUnit4)2 AnalyticsConnector (com.google.firebase.analytics.connector.AnalyticsConnector)2 AnalyticsConnectorHandle (com.google.firebase.analytics.connector.AnalyticsConnector.AnalyticsConnectorHandle)2 AnalyticsConnectorListener (com.google.firebase.analytics.connector.AnalyticsConnector.AnalyticsConnectorListener)2 Deferred (com.google.firebase.inject.Deferred)2 Collections (java.util.Collections)2 LinkedHashSet (java.util.LinkedHashSet)2 Set (java.util.Set)2 Before (org.junit.Before)2 Test (org.junit.Test)2 RunWith (org.junit.runner.RunWith)2 Matchers.any (org.mockito.Matchers.any)2 Matchers.anyString (org.mockito.Matchers.anyString)2 Mockito.mock (org.mockito.Mockito.mock)2 Mockito.never (org.mockito.Mockito.never)2 Mockito.times (org.mockito.Mockito.times)2 Mockito.verify (org.mockito.Mockito.verify)2 Mockito.when (org.mockito.Mockito.when)2