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());
}
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());
}
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());
}
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());
}
}
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());
}
}
Aggregations