summaryrefslogtreecommitdiff
path: root/app/src/test/java/se/leap
diff options
context:
space:
mode:
authorcyberta <cyberta@riseup.net>2020-01-29 12:23:48 -0600
committercyberta <cyberta@riseup.net>2020-01-29 12:23:48 -0600
commit7a42047640daef05f5771d8cb812a03ee14bbec6 (patch)
treec1976d6256e9ec9b19873d50bece585addaa4b53 /app/src/test/java/se/leap
parent7fbea5459e59de1327f2c76a23f5940d67e4ae8d (diff)
adapt tests
Diffstat (limited to 'app/src/test/java/se/leap')
-rw-r--r--app/src/test/java/se/leap/bitmaskclient/tethering/TetheringStateManagerTest.java19
1 files changed, 14 insertions, 5 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 295714c3..85352c53 100644
--- a/app/src/test/java/se/leap/bitmaskclient/tethering/TetheringStateManagerTest.java
+++ b/app/src/test/java/se/leap/bitmaskclient/tethering/TetheringStateManagerTest.java
@@ -39,6 +39,7 @@ import java.util.Enumeration;
import se.leap.bitmaskclient.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;
@@ -57,7 +58,7 @@ public class TetheringStateManagerTest {
@Mock(answer = Answers.RETURNS_DEEP_STUBS)
IntentFilter intentFilter;
- TetheringObservable observable;
+ private TetheringObservable observable;
@Before
public void setup() throws Exception {
@@ -233,7 +234,7 @@ public class TetheringStateManagerTest {
when(mockWrapper.isWifiAPEnabled()).thenThrow(new NoSuchMethodException());
PowerMockito.whenNew(WifiManagerWrapper.class).withAnyArguments().thenReturn(mockWrapper);
- TetheringObservable.setWifiTethering(true);
+ TetheringObservable.setWifiTethering(true, "192.168.43.0/24", "wlan0");
TetheringStateManager.getInstance().init(mockContext);
TetheringStateManager manager = TetheringStateManager.getInstance();
assertTrue(observable.isWifiTetheringEnabled());
@@ -245,7 +246,7 @@ public class TetheringStateManagerTest {
when(mockWrapper.isWifiAPEnabled()).thenThrow(new NoSuchMethodException());
PowerMockito.whenNew(WifiManagerWrapper.class).withAnyArguments().thenReturn(mockWrapper);
- TetheringObservable.setWifiTethering(false);
+ TetheringObservable.setWifiTethering(false, "", "");
TetheringStateManager.getInstance().init(mockContext);
TetheringStateManager manager = TetheringStateManager.getInstance();
assertFalse(observable.isWifiTetheringEnabled());
@@ -257,7 +258,7 @@ public class TetheringStateManagerTest {
when(mockWrapper.isWifiAPEnabled()).thenReturn(true);
PowerMockito.whenNew(WifiManagerWrapper.class).withAnyArguments().thenReturn(mockWrapper);
- TetheringObservable.setWifiTethering(false);
+ TetheringObservable.setWifiTethering(false, "", "");
TetheringStateManager.getInstance().init(mockContext);
TetheringStateManager manager = TetheringStateManager.getInstance();
assertTrue(observable.isWifiTetheringEnabled());
@@ -269,11 +270,19 @@ public class TetheringStateManagerTest {
when(mockWrapper.isWifiAPEnabled()).thenReturn(false);
PowerMockito.whenNew(WifiManagerWrapper.class).withAnyArguments().thenReturn(mockWrapper);
- TetheringObservable.setWifiTethering(true);
+ TetheringObservable.setWifiTethering(true, "", "");
TetheringStateManager.getInstance().init(mockContext);
TetheringStateManager manager = TetheringStateManager.getInstance();
assertFalse(observable.isWifiTetheringEnabled());
}
+ @Test
+ public void testGetWifiAddressRange() {
+ mockStatic(TetheringStateManager.class);
+ PowerMockito.when(TetheringStateManager.getWifiInterfaceAddress()).thenReturn("192.168.40.217/24");
+ PowerMockito.when(TetheringStateManager.getInstance()).thenCallRealMethod();
+ PowerMockito.when(TetheringStateManager.getWifiAddressRange()).thenCallRealMethod();
+ assertEquals("192.168.40.0/24", TetheringStateManager.getWifiAddressRange());
+ }
} \ No newline at end of file