use of com.onesignal.influence.domain.OSInfluence in project OneSignal-Android-SDK by OneSignal.
the class TrackerUnitTests method testUnattributedInitInfluence.
@Test
public void testUnattributedInitInfluence() {
trackerFactory.saveInfluenceParams(new OneSignalPackagePrivateHelper.RemoteOutcomeParams());
trackerFactory.initFromCache();
List<OSInfluence> influences = trackerFactory.getInfluences();
for (OSInfluence influence : influences) {
assertTrue(influence.getInfluenceType().isUnattributed());
assertNull(influence.getIds());
}
}
use of com.onesignal.influence.domain.OSInfluence in project OneSignal-Android-SDK by OneSignal.
the class SessionManagerUnitTests method testIndirectIAMQuantityInfluence.
@Test
public void testIndirectIAMQuantityInfluence() throws Exception {
trackerFactory.saveInfluenceParams(new OneSignalPackagePrivateHelper.RemoteOutcomeParams());
for (int i = 0; i < INFLUENCE_ID_LIMIT + 5; i++) {
sessionManager.onInAppMessageReceived(GENERIC_ID + i);
}
sessionManager.restartSessionIfNeeded(OneSignal.AppEntryAction.APP_OPEN);
OSInfluence influence = trackerFactory.getIAMChannelTracker().getCurrentSessionInfluence();
assertTrue(influence.getInfluenceType().isIndirect());
assertEquals(INFLUENCE_ID_LIMIT, influence.getIds().length());
assertEquals(GENERIC_ID + "5", influence.getIds().get(0));
}
use of com.onesignal.influence.domain.OSInfluence in project OneSignal-Android-SDK by OneSignal.
the class SessionManagerUnitTests method testDirectWithNullNotification.
@Test
public void testDirectWithNullNotification() {
trackerFactory.saveInfluenceParams(new OneSignalPackagePrivateHelper.RemoteOutcomeParams());
sessionManager.onNotificationReceived(null);
sessionManager.onDirectInfluenceFromNotificationOpen(null);
OSInfluence influence = trackerFactory.getNotificationChannelTracker().getCurrentSessionInfluence();
assertEquals(OSInfluenceType.UNATTRIBUTED, influence.getInfluenceType());
assertNull(influence.getIds());
}
use of com.onesignal.influence.domain.OSInfluence in project OneSignal-Android-SDK by OneSignal.
the class SessionManagerUnitTests method testDirectIAMResetInfluence.
@Test
public void testDirectIAMResetInfluence() throws JSONException {
trackerFactory.saveInfluenceParams(new OneSignalPackagePrivateHelper.RemoteOutcomeParams());
sessionManager.initSessionFromCache();
OSChannelTracker iamTracker = trackerFactory.getIAMChannelTracker();
assertEquals(0, iamTracker.getLastReceivedIds().length());
sessionManager.onInAppMessageReceived(IAM_ID);
sessionManager.onDirectInfluenceFromIAMClick(IAM_ID);
sessionManager.onDirectInfluenceFromIAMClickFinished();
iamTracker = trackerFactory.getIAMChannelTracker();
OSInfluence influence = iamTracker.getCurrentSessionInfluence();
assertEquals(OSInfluenceType.INDIRECT, iamTracker.getInfluenceType());
assertEquals(IAM_ID, iamTracker.getLastReceivedIds().get(0));
assertEquals(OSInfluenceChannel.IAM, influence.getInfluenceChannel());
assertEquals(OSInfluenceType.INDIRECT, influence.getInfluenceType());
assertEquals(1, influence.getIds().length());
assertEquals(IAM_ID, influence.getIds().get(0));
}
use of com.onesignal.influence.domain.OSInfluence in project OneSignal-Android-SDK by OneSignal.
the class SessionManagerUnitTests method testSessionUpgradeFromUnattributedToIndirect.
@Test
public void testSessionUpgradeFromUnattributedToIndirect() throws Exception {
trackerFactory.saveInfluenceParams(new OneSignalPackagePrivateHelper.RemoteOutcomeParams());
sessionManager.initSessionFromCache();
List<OSInfluence> influences = sessionManager.getInfluences();
for (OSInfluence influence : influences) {
assertEquals(OSInfluenceType.UNATTRIBUTED, influence.getInfluenceType());
assertNull(influence.getIds());
}
sessionManager.onNotificationReceived(GENERIC_ID);
sessionManager.onInAppMessageReceived(GENERIC_ID);
influences = sessionManager.getInfluences();
for (OSInfluence influence : influences) {
switch(influence.getInfluenceChannel()) {
case NOTIFICATION:
assertEquals(OSInfluenceType.UNATTRIBUTED, influence.getInfluenceType());
assertNull(influence.getIds());
break;
case IAM:
assertEquals(OSInfluenceType.INDIRECT, influence.getInfluenceType());
assertEquals(1, influence.getIds().length());
break;
}
}
sessionManager.attemptSessionUpgrade(OneSignal.AppEntryAction.APP_OPEN);
threadAndTaskWait();
influences = sessionManager.getInfluences();
for (OSInfluence influence : influences) {
assertEquals(OSInfluenceType.INDIRECT, influence.getInfluenceType());
assertEquals(1, influence.getIds().length());
assertEquals(GENERIC_ID, influence.getIds().get(0));
}
// We test that channel ending is working for both IAM and Notification
assertEquals(1, lastInfluencesBySessionEnding.size());
OSInfluence endingNotificationInfluence = lastInfluencesBySessionEnding.get(0);
assertEquals(OSInfluenceChannel.NOTIFICATION, endingNotificationInfluence.getInfluenceChannel());
assertEquals(OSInfluenceType.UNATTRIBUTED, endingNotificationInfluence.getInfluenceType());
assertNull(endingNotificationInfluence.getIds());
}
Aggregations