Search in sources :

Example 1 with MockOSTimeImpl

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

the class OneSignalInitializationIntegrationTestsRunner method beforeEachTest.

@Before
public void beforeEachTest() throws Exception {
    TestHelpers.beforeTestInitAndCleanup();
    setRemoteParamsGetHtmlResponse();
    blankActivityController = Robolectric.buildActivity(BlankActivity.class).create();
    time = new MockOSTimeImpl();
    OneSignal_setTime(time);
}
Also used : MockOSTimeImpl(com.onesignal.MockOSTimeImpl) Before(org.junit.Before)

Example 2 with MockOSTimeImpl

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

the class OutcomeEventIntegrationTests method beforeEachTest.

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

Example 3 with MockOSTimeImpl

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

the class OutcomeEventV2UnitTests method beforeEachTest.

// Before each test
@Before
public void beforeEachTest() throws Exception {
    outcomeEvents = null;
    dbHelper = new MockOneSignalDBHelper(ApplicationProvider.getApplicationContext());
    // Mock on a custom HashMap in order to not use custom context
    preferences = new MockOSSharedPreferences();
    // Save v2 flag
    String v2Name = preferences.getOutcomesV2KeyName();
    preferences.saveBool(preferences.getPreferencesName(), v2Name, true);
    MockOSTimeImpl time = new MockOSTimeImpl();
    trackerFactory = new OSTrackerFactory(preferences, logWrapper, time);
    sessionManager = new MockSessionManager(sessionListener, trackerFactory, logWrapper);
    service = new MockOneSignalAPIClient();
    OSOutcomeEventsFactory factory = new OSOutcomeEventsFactory(logWrapper, service, dbHelper, preferences);
    controller = new MockOutcomeEventsController(sessionManager, factory);
    TestHelpers.beforeTestInitAndCleanup();
    repository = factory.getRepository();
    trackerFactory.saveInfluenceParams(new OneSignalPackagePrivateHelper.RemoteOutcomeParams());
    OneSignal.setAppId(APP_ID);
}
Also used : OSTrackerFactory(com.onesignal.influence.data.OSTrackerFactory) MockOneSignalDBHelper(com.onesignal.MockOneSignalDBHelper) MockOSTimeImpl(com.onesignal.MockOSTimeImpl) MockSessionManager(com.onesignal.MockSessionManager) MockOSSharedPreferences(com.onesignal.MockOSSharedPreferences) MockOneSignalAPIClient(com.onesignal.MockOneSignalAPIClient) OSOutcomeEventsFactory(com.onesignal.outcomes.data.OSOutcomeEventsFactory) MockOutcomeEventsController(com.onesignal.MockOutcomeEventsController) OneSignalPackagePrivateHelper(com.onesignal.OneSignalPackagePrivateHelper) Before(org.junit.Before)

Example 4 with MockOSTimeImpl

use of com.onesignal.MockOSTimeImpl 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 5 with MockOSTimeImpl

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

the class InAppMessagingUnitTests method testBuiltMessageRedisplayDelay.

@Test
public void testBuiltMessageRedisplayDelay() throws JSONException {
    MockOSTimeImpl time = new MockOSTimeImpl();
    OneSignal_setTime(time);
    OSTestInAppMessageInternal message = InAppMessagingHelpers.buildTestMessageWitRedisplay(LIMIT, DELAY);
    assertTrue(message.getRedisplayStats().isDelayTimeSatisfied());
    message.getRedisplayStats().setLastDisplayTimeToCurrent(time);
    time.advanceSystemTimeBy(DELAY);
    assertTrue(message.getRedisplayStats().isDelayTimeSatisfied());
    message.getRedisplayStats().setLastDisplayTimeToCurrent(time);
    time.advanceSystemTimeBy(DELAY - 1);
    assertFalse(message.getRedisplayStats().isDelayTimeSatisfied());
}
Also used : OSTestInAppMessageInternal(com.onesignal.OneSignalPackagePrivateHelper.OSTestInAppMessageInternal) MockOSTimeImpl(com.onesignal.MockOSTimeImpl) Test(org.junit.Test)

Aggregations

MockOSTimeImpl (com.onesignal.MockOSTimeImpl)13 Before (org.junit.Before)12 OSTrackerFactory (com.onesignal.influence.data.OSTrackerFactory)9 MockOSSharedPreferences (com.onesignal.MockOSSharedPreferences)8 MockOneSignalDBHelper (com.onesignal.MockOneSignalDBHelper)8 MockSessionManager (com.onesignal.MockSessionManager)8 MockOSLog (com.onesignal.MockOSLog)6 OneSignalPackagePrivateHelper (com.onesignal.OneSignalPackagePrivateHelper)3 MockOneSignalAPIClient (com.onesignal.MockOneSignalAPIClient)2 MockOutcomeEventsController (com.onesignal.MockOutcomeEventsController)2 OSOutcomeEventsFactory (com.onesignal.outcomes.data.OSOutcomeEventsFactory)2 NotificationManager (android.app.NotificationManager)1 OSTestInAppMessageInternal (com.onesignal.OneSignalPackagePrivateHelper.OSTestInAppMessageInternal)1 ShadowRoboNotificationManager (com.onesignal.ShadowRoboNotificationManager)1 Test (org.junit.Test)1