diff options
author | cyBerta <cyberta@riseup.net> | 2023-05-24 21:48:11 +0200 |
---|---|---|
committer | cyBerta <cyberta@riseup.net> | 2023-07-13 10:53:49 +0200 |
commit | 2caa267277e3d515f84b3d86192c538e17509e44 (patch) | |
tree | 2f6cd7023c61fb0ad6f86daf8722bc7ebb6df787 /app/src/test/java/se/leap/bitmaskclient/tethering | |
parent | af123f7a34eaa7839a238b32f2cb4ef473c9ed22 (diff) |
fix tests after encrypted shared preference usage
Diffstat (limited to 'app/src/test/java/se/leap/bitmaskclient/tethering')
-rw-r--r-- | app/src/test/java/se/leap/bitmaskclient/tethering/TetheringStateManagerTest.java | 27 |
1 files changed, 17 insertions, 10 deletions
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(); } |