Skip to content

Commit

Permalink
MM-1332 - Merged with master and updated tests + bug fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
stanislavin committed Mar 10, 2017
1 parent 3e7464d commit 621bd88
Show file tree
Hide file tree
Showing 33 changed files with 292 additions and 801 deletions.
Original file line number Diff line number Diff line change
@@ -1,19 +1,18 @@
package org.infobip.mobile.messaging;

import android.test.InstrumentationTestCase;

import org.infobip.mobile.messaging.mobile.BatchReporter;
import org.infobip.mobile.messaging.tools.InfobipAndroidTestCase;
import org.infobip.mobile.messaging.util.PreferenceHelper;
import org.mockito.Mockito;

/**
* @author sslavin
* @since 07/07/16.
*/
public class BatchReporterTest extends InstrumentationTestCase {
public class BatchReporterTest extends InfobipAndroidTestCase {

BatchReporter batchReporter;
Runnable runnable;
private BatchReporter batchReporter;
private Runnable runnable;

@Override
protected void setUp() throws Exception {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,8 @@
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.test.InstrumentationTestCase;

import org.infobip.mobile.messaging.tools.DebugServer;
import org.infobip.mobile.messaging.util.PreferenceHelper;
import org.infobip.mobile.messaging.tools.InfobipAndroidTestCase;
import org.mockito.ArgumentCaptor;
import org.mockito.Mockito;

Expand All @@ -20,13 +18,10 @@

import fi.iki.elonen.NanoHTTPD;

public class CustomUserDataTypeTest extends InstrumentationTestCase {
public class CustomUserDataTypeTest extends InfobipAndroidTestCase {

private Context context;
DebugServer debugServer;
BroadcastReceiver receiver;
ArgumentCaptor<Intent> captor;
MobileMessaging mobileMessaging;

private static final String KEY_FOR_STRING = "keyForString";
private static final String KEY_FOR_NUMBER = "keyForNumber";
Expand Down Expand Up @@ -58,15 +53,6 @@ public class CustomUserDataTypeTest extends InstrumentationTestCase {
@Override
protected void setUp() throws Exception {
super.setUp();
context = getInstrumentation().getContext();
mobileMessaging = MobileMessaging.getInstance(context);

debugServer = new DebugServer();
debugServer.start();

PreferenceHelper.saveString(getInstrumentation().getContext(), MobileMessagingProperty.API_URI, "http://127.0.0.1:" + debugServer.getListeningPort() + "/");
PreferenceHelper.saveString(getInstrumentation().getContext(), MobileMessagingProperty.APPLICATION_CODE, "TestApplicationCode");
PreferenceHelper.saveString(getInstrumentation().getContext(), MobileMessagingProperty.INFOBIP_REGISTRATION_ID, "TestDeviceInstanceId");

captor = ArgumentCaptor.forClass(Intent.class);
receiver = Mockito.mock(BroadcastReceiver.class);
Expand All @@ -77,15 +63,6 @@ protected void setUp() throws Exception {
protected void tearDown() throws Exception {
context.unregisterReceiver(receiver);

if (null != debugServer) {
try {
debugServer.stop();
} catch (Exception e) {
//ignore
}
}
PreferenceHelper.remove(context, MobileMessagingProperty.USER_DATA);

super.tearDown();
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
package org.infobip.mobile.messaging;

import android.content.Context;
import android.preference.PreferenceManager;
import android.test.InstrumentationTestCase;

import org.infobip.mobile.messaging.api.support.http.serialization.JsonSerializer;
import org.infobip.mobile.messaging.geo.Area;
import org.infobip.mobile.messaging.geo.Geo;
import org.infobip.mobile.messaging.geo.GeoEventSettings;
import org.infobip.mobile.messaging.tools.InfobipAndroidTestCase;
import org.infobip.mobile.messaging.util.PreferenceHelper;

import java.util.ArrayList;
Expand All @@ -17,9 +14,8 @@
/**
* Created by pandric on 20/09/16.
*/
public class GeoEventsTest extends InstrumentationTestCase {
public class GeoEventsTest extends InfobipAndroidTestCase {

private Context context;
private long timeDelta;

private class GeoTest extends Geo {
Expand All @@ -32,14 +28,6 @@ List<GeoEventSettings> getEventFilters() {
}
}

@Override
protected void setUp() throws Exception {
super.setUp();
context = getInstrumentation().getContext();

PreferenceManager.getDefaultSharedPreferences(context).edit().clear().commit();
}

@Override
protected void tearDown() throws Exception {
super.tearDown();
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,38 +1,15 @@
package org.infobip.mobile.messaging;

import android.annotation.SuppressLint;
import android.content.Context;
import android.preference.PreferenceManager;
import android.test.InstrumentationTestCase;

import org.infobip.mobile.messaging.geo.GeoSQLiteMessageStore;
import org.infobip.mobile.messaging.storage.TestMessageStore;
import org.infobip.mobile.messaging.util.PreferenceHelper;
import org.infobip.mobile.messaging.tools.InfobipAndroidTestCase;

/**
* @author sslavin
* @since 19/01/2017.
*/

public class MessageStoreTest extends InstrumentationTestCase {

Context context;

@SuppressLint("CommitPrefEdits")
@Override
protected void setUp() throws Exception {
super.setUp();

context = getInstrumentation().getContext();

PreferenceManager.getDefaultSharedPreferences(context)
.edit()
.clear()
.commit();

PreferenceHelper.saveString(getInstrumentation().getContext(), MobileMessagingProperty.APPLICATION_CODE, "TestApplicationCode");
PreferenceHelper.saveString(getInstrumentation().getContext(), MobileMessagingProperty.INFOBIP_REGISTRATION_ID, "TestDeviceInstanceId");
}
public class MessageStoreTest extends InfobipAndroidTestCase {

public void test_shouldUseGeoSqlStoreForGeo_whenConfiguredWithoutMessageStore() {
MobileMessagingCore.setMessageStoreClass(context, null);
Expand Down
Loading

0 comments on commit 621bd88

Please sign in to comment.