Search in sources :

Example 36 with OSInfluence

use of com.onesignal.influence.domain.OSInfluence in project OneSignal-Android-SDK by OneSignal.

the class SessionManagerUnitTests method testDirectWithEmptyNotification.

@Test
public void testDirectWithEmptyNotification() {
    trackerFactory.saveInfluenceParams(new OneSignalPackagePrivateHelper.RemoteOutcomeParams());
    sessionManager.onNotificationReceived("");
    sessionManager.onDirectInfluenceFromNotificationOpen("");
    OSInfluence influence = trackerFactory.getNotificationChannelTracker().getCurrentSessionInfluence();
    assertEquals(OSInfluenceType.UNATTRIBUTED, influence.getInfluenceType());
    assertNull(influence.getIds());
}
Also used : OSInfluence(com.onesignal.influence.domain.OSInfluence) OneSignalPackagePrivateHelper(com.onesignal.OneSignalPackagePrivateHelper) Test(org.junit.Test)

Example 37 with OSInfluence

use of com.onesignal.influence.domain.OSInfluence in project OneSignal-Android-SDK by OneSignal.

the class OutcomeEventIntegrationTests method assertIAMChannelIndirectInfluence.

private void assertIAMChannelIndirectInfluence(int indirectIdsLength) {
    OSInfluence influence = trackerFactory.getIAMChannelTracker().getCurrentSessionInfluence();
    assertTrue(influence.getInfluenceType().isIndirect());
    assertEquals(indirectIdsLength, influence.getIds().length());
}
Also used : OSInfluence(com.onesignal.influence.domain.OSInfluence)

Example 38 with OSInfluence

use of com.onesignal.influence.domain.OSInfluence in project OneSignal-Android-SDK by OneSignal.

the class OutcomeEventIntegrationTests method assertIAMChannelDirectInfluence.

private void assertIAMChannelDirectInfluence() {
    OSInfluence influence = trackerFactory.getIAMChannelTracker().getCurrentSessionInfluence();
    assertTrue(influence.getInfluenceType().isDirect());
    assertEquals(1, influence.getIds().length());
}
Also used : OSInfluence(com.onesignal.influence.domain.OSInfluence)

Example 39 with OSInfluence

use of com.onesignal.influence.domain.OSInfluence in project OneSignal-Android-SDK by OneSignal.

the class OutcomeEventIntegrationTests method testDirectSession_fromNotificationClick_OpenHandleByUser_whenAppIsInBackground.

@Test
@Config(shadows = { OneSignalShadowPackageManager.class })
public void testDirectSession_fromNotificationClick_OpenHandleByUser_whenAppIsInBackground() throws Exception {
    OneSignalInit();
    threadAndTaskWait();
    OneSignalShadowPackageManager.addManifestMetaData("com.onesignal.NotificationOpened.DEFAULT", "DISABLE");
    OneSignal.setNotificationOpenedHandler(result -> {
        OneSignal.onesignalLog(OneSignal.LOG_LEVEL.VERBOSE, "OSNotificationOpenedHandler called with result: " + result);
        notificationOpenedResult = result;
        // App opened after clicking notification, but Robolectric needs this to simulate onAppFocus() code after a click
        blankActivityController.resume();
    });
    // Background app
    pauseActivity(blankActivityController);
    String notificationID = ONESIGNAL_NOTIFICATION_ID + "1";
    sessionManager.onNotificationReceived(notificationID);
    // Click notification before new session
    OneSignal_handleNotificationOpen(blankActivity, new JSONArray("[{ \"alert\": \"Test Msg\", \"custom\": { \"i\": \"" + notificationID + "\" } }]"), false, notificationID);
    threadAndTaskWait();
    assertNotNull(notificationOpenedResult);
    // Check message String matches data sent in open handler
    assertEquals("Test Msg", notificationOpenedResult.getNotification().getBody());
    // Make sure notification influence is DIRECT
    assertNotificationChannelDirectInfluence(notificationID);
    // Make sure iam influence is UNATTRIBUTED
    assertIAMChannelUnattributedInfluence();
    for (OSInfluence influence : lastInfluencesEnding) {
        assertEquals(OSInfluenceType.UNATTRIBUTED, influence.getInfluenceType());
    }
}
Also used : JSONArray(org.json.JSONArray) OSInfluence(com.onesignal.influence.domain.OSInfluence) Test(org.junit.Test) Config(org.robolectric.annotation.Config)

Example 40 with OSInfluence

use of com.onesignal.influence.domain.OSInfluence in project OneSignal-Android-SDK by OneSignal.

the class TrackerUnitTests method testDisabledInitInfluence.

@Test
public void testDisabledInitInfluence() {
    trackerFactory.saveInfluenceParams(new OneSignalPackagePrivateHelper.RemoteOutcomeParams(false, false, false));
    trackerFactory.initFromCache();
    List<OSInfluence> influences = trackerFactory.getInfluences();
    for (OSInfluence influence : influences) {
        assertTrue(influence.getInfluenceType().isDisabled());
        assertNull(influence.getIds());
    }
}
Also used : OSInfluence(com.onesignal.influence.domain.OSInfluence) OneSignalPackagePrivateHelper(com.onesignal.OneSignalPackagePrivateHelper) Test(org.junit.Test)

Aggregations

OSInfluence (com.onesignal.influence.domain.OSInfluence)40 Test (org.junit.Test)25 OneSignalPackagePrivateHelper (com.onesignal.OneSignalPackagePrivateHelper)23 OSChannelTracker (com.onesignal.influence.data.OSChannelTracker)7 JSONArray (org.json.JSONArray)5 ArrayList (java.util.ArrayList)3 Config (org.robolectric.annotation.Config)2 Bundle (android.os.Bundle)1 FCMBroadcastReceiver_onReceived_withBundle (com.onesignal.OneSignalPackagePrivateHelper.FCMBroadcastReceiver_onReceived_withBundle)1 OSOutcomeEventParams (com.onesignal.outcomes.domain.OSOutcomeEventParams)1 OSOutcomeSource (com.onesignal.outcomes.domain.OSOutcomeSource)1 OSOutcomeSourceBody (com.onesignal.outcomes.domain.OSOutcomeSourceBody)1 GenerateNotificationRunner.getBaseNotifBundle (com.test.onesignal.GenerateNotificationRunner.getBaseNotifBundle)1