Search in sources :

Example 1 with MockOSLog

use of com.onesignal.MockOSLog in project OneSignal-Android-SDK by OneSignal.

the class SessionManagerUnitTests method beforeEachTest.

// Before each test
@Before
public void beforeEachTest() throws Exception {
    MockOSLog logger = new MockOSLog();
    MockOSTimeImpl time = new MockOSTimeImpl();
    preferences = new MockOSSharedPreferences();
    trackerFactory = new OSTrackerFactory(preferences, logger, time);
    sessionManager = new MockSessionManager(sessionListener, trackerFactory, logger);
    TestHelpers.beforeTestInitAndCleanup();
}
Also used : MockOSLog(com.onesignal.MockOSLog) OSTrackerFactory(com.onesignal.influence.data.OSTrackerFactory) MockOSTimeImpl(com.onesignal.MockOSTimeImpl) MockSessionManager(com.onesignal.MockSessionManager) MockOSSharedPreferences(com.onesignal.MockOSSharedPreferences) Before(org.junit.Before)

Example 2 with MockOSLog

use of com.onesignal.MockOSLog in project OneSignal-Android-SDK by OneSignal.

the class InAppMessageIntegrationTests method testInAppMessageClickActionOutcomeV2.

@Test
public void testInAppMessageClickActionOutcomeV2() throws Exception {
    // Enable IAM v2
    preferences = new MockOSSharedPreferences();
    preferences.saveBool(preferences.getPreferencesName(), preferences.getOutcomesV2KeyName(), true);
    trackerFactory = new OSTrackerFactory(preferences, new MockOSLog(), time);
    sessionManager = new MockSessionManager(OneSignal_getSessionListener(), trackerFactory, new MockOSLog());
    OneSignal_setSharedPreferences(preferences);
    OneSignal_setTrackerFactory(trackerFactory);
    OneSignal_setSessionManager(sessionManager);
    // 1. Init OneSignal
    OneSignalInit();
    threadAndTaskWait();
    // Enable influence outcomes
    trackerFactory.saveInfluenceParams(new OneSignalPackagePrivateHelper.RemoteOutcomeParams());
    // 2. Create an IAM
    final OSTestInAppMessageInternal message = InAppMessagingHelpers.buildTestMessageWithSingleTrigger(OSTriggerKind.SESSION_TIME, null, OSTestTrigger.OSTriggerOperator.NOT_EXISTS.toString(), null);
    final JSONArray outcomes = new JSONArray();
    outcomes.put(new JSONObject() {

        {
            put("name", IAM_OUTCOME_NAME);
        }
    });
    JSONObject action = new JSONObject() {

        {
            put("id", IAM_CLICK_ID);
            put("outcomes", outcomes);
        }
    };
    OneSignalPackagePrivateHelper.onMessageActionOccurredOnMessage(message, action);
    // 3. Ensure outcome is sent
    assertMeasureOnV2AtIndex(3, "outcome_name", new JSONArray().put(message.getMessageId()), new JSONArray(), null, null);
}
Also used : MockOSLog(com.onesignal.MockOSLog) OSTestInAppMessageInternal(com.onesignal.OneSignalPackagePrivateHelper.OSTestInAppMessageInternal) OSTrackerFactory(com.onesignal.influence.data.OSTrackerFactory) JSONObject(org.json.JSONObject) JSONArray(org.json.JSONArray) MockSessionManager(com.onesignal.MockSessionManager) MockOSSharedPreferences(com.onesignal.MockOSSharedPreferences) OneSignalPackagePrivateHelper(com.onesignal.OneSignalPackagePrivateHelper) Test(org.junit.Test)

Example 3 with MockOSLog

use of com.onesignal.MockOSLog in project OneSignal-Android-SDK by OneSignal.

the class LocationIntegrationTests method beforeEachTest.

@Before
public void beforeEachTest() throws Exception {
    blankActivityController = Robolectric.buildActivity(BlankActivity.class).create();
    blankActivity = blankActivityController.get();
    time = new MockOSTimeImpl();
    trackerFactory = new OSTrackerFactory(new MockOSSharedPreferences(), new MockOSLog(), time);
    sessionManager = new MockSessionManager(OneSignal_getSessionListener(), trackerFactory, new MockOSLog());
    dbHelper = new MockOneSignalDBHelper(ApplicationProvider.getApplicationContext());
    TestHelpers.setupTestWorkManager(blankActivity);
    cleanUp();
    OneSignal_setTime(time);
}
Also used : MockOSLog(com.onesignal.MockOSLog) OSTrackerFactory(com.onesignal.influence.data.OSTrackerFactory) MockOneSignalDBHelper(com.onesignal.MockOneSignalDBHelper) MockOSTimeImpl(com.onesignal.MockOSTimeImpl) MockSessionManager(com.onesignal.MockSessionManager) MockOSSharedPreferences(com.onesignal.MockOSSharedPreferences) Before(org.junit.Before)

Example 4 with MockOSLog

use of com.onesignal.MockOSLog in project OneSignal-Android-SDK by OneSignal.

the class MainOneSignalClassRunner method beforeEachTest.

@Before
public void beforeEachTest() throws Exception {
    blankActivityController = Robolectric.buildActivity(BlankActivity.class).create();
    blankActivity = blankActivityController.get();
    time = new MockOSTimeImpl();
    trackerFactory = new OSTrackerFactory(new MockOSSharedPreferences(), new MockOSLog(), time);
    sessionManager = new MockSessionManager(OneSignal_getSessionListener(), trackerFactory, new MockOSLog());
    dbHelper = new MockOneSignalDBHelper(ApplicationProvider.getApplicationContext());
    TestHelpers.setupTestWorkManager(blankActivity);
    cleanUp();
    OneSignal_setTime(time);
}
Also used : MockOSLog(com.onesignal.MockOSLog) OSTrackerFactory(com.onesignal.influence.data.OSTrackerFactory) MockOneSignalDBHelper(com.onesignal.MockOneSignalDBHelper) MockOSTimeImpl(com.onesignal.MockOSTimeImpl) MockSessionManager(com.onesignal.MockSessionManager) MockOSSharedPreferences(com.onesignal.MockOSSharedPreferences) Before(org.junit.Before)

Example 5 with MockOSLog

use of com.onesignal.MockOSLog in project OneSignal-Android-SDK by OneSignal.

the class InAppMessageIntegrationTests method beforeEachTest.

@Before
public void beforeEachTest() throws Exception {
    ShadowDynamicTimer.shouldScheduleTimers = true;
    time = new MockOSTimeImpl();
    preferences = new MockOSSharedPreferences();
    trackerFactory = new OSTrackerFactory(preferences, new MockOSLog(), time);
    sessionManager = new MockSessionManager(OneSignal_getSessionListener(), trackerFactory, new MockOSLog());
    blankActivityController = Robolectric.buildActivity(BlankActivity.class).create();
    blankActivity = blankActivityController.get();
    dbHelper = new MockOneSignalDBHelper(ApplicationProvider.getApplicationContext());
    TestHelpers.beforeTestInitAndCleanup();
    // Set remote_params GET response
    setRemoteParamsGetHtmlResponse();
}
Also used : MockOSLog(com.onesignal.MockOSLog) OSTrackerFactory(com.onesignal.influence.data.OSTrackerFactory) MockOneSignalDBHelper(com.onesignal.MockOneSignalDBHelper) MockOSTimeImpl(com.onesignal.MockOSTimeImpl) MockSessionManager(com.onesignal.MockSessionManager) MockOSSharedPreferences(com.onesignal.MockOSSharedPreferences) Before(org.junit.Before)

Aggregations

MockOSLog (com.onesignal.MockOSLog)9 MockOSSharedPreferences (com.onesignal.MockOSSharedPreferences)9 OSTrackerFactory (com.onesignal.influence.data.OSTrackerFactory)9 MockSessionManager (com.onesignal.MockSessionManager)8 MockOSTimeImpl (com.onesignal.MockOSTimeImpl)6 Before (org.junit.Before)6 MockOneSignalDBHelper (com.onesignal.MockOneSignalDBHelper)4 OneSignalPackagePrivateHelper (com.onesignal.OneSignalPackagePrivateHelper)3 OSTestInAppMessageInternal (com.onesignal.OneSignalPackagePrivateHelper.OSTestInAppMessageInternal)3 JSONArray (org.json.JSONArray)3 JSONObject (org.json.JSONObject)3 Test (org.junit.Test)3 OSInAppMessageAction (com.onesignal.OSInAppMessageAction)2 OneSignal (com.onesignal.OneSignal)2 JSONException (org.json.JSONException)2