summaryrefslogtreecommitdiff
path: root/app/src
diff options
context:
space:
mode:
Diffstat (limited to 'app/src')
-rw-r--r--app/src/test/java/se/leap/bitmaskclient/eip/GatewaysManagerTest.java2
-rw-r--r--app/src/test/java/se/leap/bitmaskclient/tethering/TetheringStateManagerTest.java27
2 files changed, 19 insertions, 10 deletions
diff --git a/app/src/test/java/se/leap/bitmaskclient/eip/GatewaysManagerTest.java b/app/src/test/java/se/leap/bitmaskclient/eip/GatewaysManagerTest.java
index ee6ccce5..1f5aa74b 100644
--- a/app/src/test/java/se/leap/bitmaskclient/eip/GatewaysManagerTest.java
+++ b/app/src/test/java/se/leap/bitmaskclient/eip/GatewaysManagerTest.java
@@ -83,6 +83,8 @@ public class GatewaysManagerTest {
putString(CA_CERT, secrets.getString(CA_CERT)).
putString(PROVIDER_VPN_CERTIFICATE, secrets.getString(PROVIDER_VPN_CERTIFICATE))
.commit();
+ mockStatic(PreferenceHelper.class);
+ when(PreferenceHelper.getSharedPreferences(any())).thenReturn(sharedPreferences);
}
diff --git a/app/src/test/java/se/leap/bitmaskclient/tethering/TetheringStateManagerTest.java b/app/src/test/java/se/leap/bitmaskclient/tethering/TetheringStateManagerTest.java
index 509805d4..d972923c 100644
--- a/app/src/test/java/se/leap/bitmaskclient/tethering/TetheringStateManagerTest.java
+++ b/app/src/test/java/se/leap/bitmaskclient/tethering/TetheringStateManagerTest.java
@@ -16,8 +16,18 @@
*/
package se.leap.bitmaskclient.tethering;
+import static junit.framework.TestCase.assertTrue;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.anyString;
+import static org.mockito.Mockito.mock;
+import static org.powermock.api.mockito.PowerMockito.mockStatic;
+import static org.powermock.api.mockito.PowerMockito.when;
+
import android.content.Context;
import android.content.IntentFilter;
+import android.content.SharedPreferences;
import org.junit.Before;
import org.junit.Test;
@@ -37,19 +47,12 @@ import java.util.Collections;
import java.util.Enumeration;
import se.leap.bitmaskclient.base.utils.Cmd;
-
-import static junit.framework.TestCase.assertTrue;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.mockito.ArgumentMatchers.any;
-import static org.mockito.ArgumentMatchers.anyString;
-import static org.mockito.Mockito.mock;
-import static org.powermock.api.mockito.PowerMockito.mockStatic;
-import static org.powermock.api.mockito.PowerMockito.when;
+import se.leap.bitmaskclient.base.utils.PreferenceHelper;
+import se.leap.bitmaskclient.testutils.MockSharedPreferences;
@RunWith(PowerMockRunner.class)
-@PrepareForTest({WifiManagerWrapper.class, TetheringStateManager.class, Cmd.class, NetworkInterface.class})
+@PrepareForTest({WifiManagerWrapper.class, TetheringStateManager.class, Cmd.class, NetworkInterface.class, PreferenceHelper.class})
public class TetheringStateManagerTest {
@Mock(answer = Answers.RETURNS_DEEP_STUBS)
@@ -64,6 +67,10 @@ public class TetheringStateManagerTest {
public void setup() throws Exception {
PowerMockito.whenNew(IntentFilter.class).withArguments(anyString()).thenReturn(intentFilter);
PowerMockito.whenNew(IntentFilter.class).withNoArguments().thenReturn(intentFilter);
+ mockStatic(PreferenceHelper.class);
+ SharedPreferences sharedPreferences = new MockSharedPreferences();
+ when(PreferenceHelper.getSharedPreferences(any())).thenReturn(sharedPreferences);
+
observable = TetheringObservable.getInstance();
}