-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
eb4de15
commit 6238f7f
Showing
25 changed files
with
3,361 additions
and
3,361 deletions.
There are no files selected for viewing
288 changes: 144 additions & 144 deletions
288
wisefy/src/androidTest/java/com/isupatches/wisefy/GetSavedNetworkTests.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,144 +1,144 @@ | ||
package com.isupatches.wisefy; | ||
|
||
|
||
import android.net.wifi.WifiConfiguration; | ||
import com.isupatches.wisefy.base.TestActivity; | ||
import com.isupatches.wisefy.callbacks.GetSavedNetworkCallbacks; | ||
import com.isupatches.wisefy.constants.WiseFyCodes; | ||
import org.junit.Test; | ||
import static com.isupatches.wisefy.base.TestUtils.TEST_SSID; | ||
import static junit.framework.Assert.assertEquals; | ||
import static junit.framework.Assert.fail; | ||
import static org.mockito.ArgumentMatchers.anyString; | ||
import static org.mockito.Mockito.mock; | ||
import static org.mockito.Mockito.timeout; | ||
import static org.mockito.Mockito.verify; | ||
import static org.mockito.Mockito.when; | ||
|
||
|
||
public class GetSavedNetworkTests extends BaseTestClass<TestActivity> { | ||
|
||
public GetSavedNetworkTests() { | ||
super(TestActivity.class); | ||
} | ||
|
||
@Test | ||
public void noCallbacks_failure_nullSSIDParam() { | ||
assertEquals(null, mWiseFy.getSavedNetwork(null)); | ||
} | ||
|
||
@Test | ||
public void noCallbacks_failure_missingPrerequisite() { | ||
missingPrerequisite(); | ||
assertEquals(null, mWiseFy.getSavedNetwork(TEST_SSID)); | ||
} | ||
|
||
@Test | ||
public void noCallbacks_failure() { | ||
WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); | ||
mWiseFy.mWiseFySearch = mockWiseFySearch; | ||
when(mockWiseFySearch.findSavedNetworkByRegex(anyString())).thenReturn(null); | ||
|
||
assertEquals(null, mWiseFy.getSavedNetwork(TEST_SSID)); | ||
} | ||
|
||
@Test | ||
public void noCallbacks_success() { | ||
WifiConfiguration wiFiConfiguration = new WifiConfiguration(); | ||
wiFiConfiguration.SSID = TEST_SSID; | ||
|
||
WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); | ||
mWiseFy.mWiseFySearch = mockWiseFySearch; | ||
when(mockWiseFySearch.findSavedNetworkByRegex(anyString())).thenReturn(wiFiConfiguration); | ||
|
||
assertEquals(wiFiConfiguration, mWiseFy.getSavedNetwork(TEST_SSID)); | ||
} | ||
|
||
@Test | ||
public void callbacks_failure_nullSSIDParam() { | ||
GetSavedNetworkCallbacks mockCallbacks = mock(GetSavedNetworkCallbacks.class); | ||
mWiseFy.getSavedNetwork(null, mockCallbacks); | ||
verify(mockCallbacks, timeout(2000)).getSavedNetworkWiseFyFailure(WiseFyCodes.MISSING_PARAMETER); | ||
} | ||
|
||
@Test | ||
public void callbacks_failure_nullSSIDParam_nullCallback() { | ||
try { | ||
mWiseFy.getSavedNetwork(null, null); | ||
} catch (NullPointerException npe) { | ||
fail(); | ||
} | ||
} | ||
|
||
@Test | ||
public void callbacks_failure_missingPrerequisite() { | ||
missingPrerequisite(); | ||
GetSavedNetworkCallbacks mockCallbacks = mock(GetSavedNetworkCallbacks.class); | ||
mWiseFy.getSavedNetwork(TEST_SSID, mockCallbacks); | ||
verify(mockCallbacks, timeout(2000)).getSavedNetworkWiseFyFailure(WiseFyCodes.MISSING_PREREQUISITE); | ||
} | ||
|
||
@Test | ||
public void callbacks_failure_missingPrerequisite_nullCallback() { | ||
missingPrerequisite(); | ||
try { | ||
mWiseFy.getSavedNetwork(TEST_SSID, null); | ||
} catch (NullPointerException npe) { | ||
fail(); | ||
} | ||
} | ||
|
||
@Test | ||
public void callbacks_failure() { | ||
WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); | ||
mWiseFy.mWiseFySearch = mockWiseFySearch; | ||
when(mockWiseFySearch.findSavedNetworkByRegex(anyString())).thenReturn(null); | ||
|
||
GetSavedNetworkCallbacks mockCallbacks = mock(GetSavedNetworkCallbacks.class); | ||
mWiseFy.getSavedNetwork(TEST_SSID, mockCallbacks); | ||
verify(mockCallbacks, timeout(2000)).savedNetworkNotFound(); | ||
} | ||
|
||
@Test | ||
public void callbacks_failure_nullCallback() { | ||
WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); | ||
mWiseFy.mWiseFySearch = mockWiseFySearch; | ||
when(mockWiseFySearch.findSavedNetworkByRegex(anyString())).thenReturn(null); | ||
|
||
try { | ||
mWiseFy.getSavedNetwork(TEST_SSID, null); | ||
} catch (NullPointerException npe) { | ||
fail(); | ||
} | ||
} | ||
|
||
@Test | ||
public void callbacks_success() { | ||
WifiConfiguration wiFiConfiguration = new WifiConfiguration(); | ||
wiFiConfiguration.SSID = TEST_SSID; | ||
|
||
WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); | ||
mWiseFy.mWiseFySearch = mockWiseFySearch; | ||
when(mockWiseFySearch.findSavedNetworkByRegex(anyString())).thenReturn(wiFiConfiguration); | ||
|
||
GetSavedNetworkCallbacks mockCallbacks = mock(GetSavedNetworkCallbacks.class); | ||
mWiseFy.getSavedNetwork(TEST_SSID, mockCallbacks); | ||
verify(mockCallbacks, timeout(2000)).retrievedSavedNetwork(wiFiConfiguration); | ||
} | ||
|
||
@Test | ||
public void callbacks_success_nullCallback() { | ||
WifiConfiguration wiFiConfiguration = new WifiConfiguration(); | ||
wiFiConfiguration.SSID = TEST_SSID; | ||
|
||
WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); | ||
mWiseFy.mWiseFySearch = mockWiseFySearch; | ||
when(mockWiseFySearch.findSavedNetworkByRegex(anyString())).thenReturn(wiFiConfiguration); | ||
|
||
try { | ||
mWiseFy.getSavedNetwork(TEST_SSID, null); | ||
} catch (NullPointerException npe) { | ||
fail(); | ||
} | ||
} | ||
} | ||
//package com.isupatches.wisefy; | ||
// | ||
// | ||
//import android.net.wifi.WifiConfiguration; | ||
//import com.isupatches.wisefy.base.TestActivity; | ||
//import com.isupatches.wisefy.callbacks.GetSavedNetworkCallbacks; | ||
//import com.isupatches.wisefy.constants.WiseFyCodes; | ||
//import org.junit.Test; | ||
//import static com.isupatches.wisefy.base.TestUtils.TEST_SSID; | ||
//import static junit.framework.Assert.assertEquals; | ||
//import static junit.framework.Assert.fail; | ||
//import static org.mockito.ArgumentMatchers.anyString; | ||
//import static org.mockito.Mockito.mock; | ||
//import static org.mockito.Mockito.timeout; | ||
//import static org.mockito.Mockito.verify; | ||
//import static org.mockito.Mockito.when; | ||
// | ||
// | ||
//public class GetSavedNetworkTests extends BaseTestClass<TestActivity> { | ||
// | ||
// public GetSavedNetworkTests() { | ||
// super(TestActivity.class); | ||
// } | ||
// | ||
// @Test | ||
// public void noCallbacks_failure_nullSSIDParam() { | ||
// assertEquals(null, mWiseFy.getSavedNetwork(null)); | ||
// } | ||
// | ||
// @Test | ||
// public void noCallbacks_failure_missingPrerequisite() { | ||
// missingPrerequisite(); | ||
// assertEquals(null, mWiseFy.getSavedNetwork(TEST_SSID)); | ||
// } | ||
// | ||
// @Test | ||
// public void noCallbacks_failure() { | ||
// WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); | ||
// mWiseFy.mWiseFySearch = mockWiseFySearch; | ||
// when(mockWiseFySearch.findSavedNetworkByRegex(anyString())).thenReturn(null); | ||
// | ||
// assertEquals(null, mWiseFy.getSavedNetwork(TEST_SSID)); | ||
// } | ||
// | ||
// @Test | ||
// public void noCallbacks_success() { | ||
// WifiConfiguration wiFiConfiguration = new WifiConfiguration(); | ||
// wiFiConfiguration.SSID = TEST_SSID; | ||
// | ||
// WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); | ||
// mWiseFy.mWiseFySearch = mockWiseFySearch; | ||
// when(mockWiseFySearch.findSavedNetworkByRegex(anyString())).thenReturn(wiFiConfiguration); | ||
// | ||
// assertEquals(wiFiConfiguration, mWiseFy.getSavedNetwork(TEST_SSID)); | ||
// } | ||
// | ||
// @Test | ||
// public void callbacks_failure_nullSSIDParam() { | ||
// GetSavedNetworkCallbacks mockCallbacks = mock(GetSavedNetworkCallbacks.class); | ||
// mWiseFy.getSavedNetwork(null, mockCallbacks); | ||
// verify(mockCallbacks, timeout(2000)).getSavedNetworkWiseFyFailure(WiseFyCodes.MISSING_PARAMETER); | ||
// } | ||
// | ||
// @Test | ||
// public void callbacks_failure_nullSSIDParam_nullCallback() { | ||
// try { | ||
// mWiseFy.getSavedNetwork(null, null); | ||
// } catch (NullPointerException npe) { | ||
// fail(); | ||
// } | ||
// } | ||
// | ||
// @Test | ||
// public void callbacks_failure_missingPrerequisite() { | ||
// missingPrerequisite(); | ||
// GetSavedNetworkCallbacks mockCallbacks = mock(GetSavedNetworkCallbacks.class); | ||
// mWiseFy.getSavedNetwork(TEST_SSID, mockCallbacks); | ||
// verify(mockCallbacks, timeout(2000)).getSavedNetworkWiseFyFailure(WiseFyCodes.MISSING_PREREQUISITE); | ||
// } | ||
// | ||
// @Test | ||
// public void callbacks_failure_missingPrerequisite_nullCallback() { | ||
// missingPrerequisite(); | ||
// try { | ||
// mWiseFy.getSavedNetwork(TEST_SSID, null); | ||
// } catch (NullPointerException npe) { | ||
// fail(); | ||
// } | ||
// } | ||
// | ||
// @Test | ||
// public void callbacks_failure() { | ||
// WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); | ||
// mWiseFy.mWiseFySearch = mockWiseFySearch; | ||
// when(mockWiseFySearch.findSavedNetworkByRegex(anyString())).thenReturn(null); | ||
// | ||
// GetSavedNetworkCallbacks mockCallbacks = mock(GetSavedNetworkCallbacks.class); | ||
// mWiseFy.getSavedNetwork(TEST_SSID, mockCallbacks); | ||
// verify(mockCallbacks, timeout(2000)).savedNetworkNotFound(); | ||
// } | ||
// | ||
// @Test | ||
// public void callbacks_failure_nullCallback() { | ||
// WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); | ||
// mWiseFy.mWiseFySearch = mockWiseFySearch; | ||
// when(mockWiseFySearch.findSavedNetworkByRegex(anyString())).thenReturn(null); | ||
// | ||
// try { | ||
// mWiseFy.getSavedNetwork(TEST_SSID, null); | ||
// } catch (NullPointerException npe) { | ||
// fail(); | ||
// } | ||
// } | ||
// | ||
// @Test | ||
// public void callbacks_success() { | ||
// WifiConfiguration wiFiConfiguration = new WifiConfiguration(); | ||
// wiFiConfiguration.SSID = TEST_SSID; | ||
// | ||
// WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); | ||
// mWiseFy.mWiseFySearch = mockWiseFySearch; | ||
// when(mockWiseFySearch.findSavedNetworkByRegex(anyString())).thenReturn(wiFiConfiguration); | ||
// | ||
// GetSavedNetworkCallbacks mockCallbacks = mock(GetSavedNetworkCallbacks.class); | ||
// mWiseFy.getSavedNetwork(TEST_SSID, mockCallbacks); | ||
// verify(mockCallbacks, timeout(2000)).retrievedSavedNetwork(wiFiConfiguration); | ||
// } | ||
// | ||
// @Test | ||
// public void callbacks_success_nullCallback() { | ||
// WifiConfiguration wiFiConfiguration = new WifiConfiguration(); | ||
// wiFiConfiguration.SSID = TEST_SSID; | ||
// | ||
// WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); | ||
// mWiseFy.mWiseFySearch = mockWiseFySearch; | ||
// when(mockWiseFySearch.findSavedNetworkByRegex(anyString())).thenReturn(wiFiConfiguration); | ||
// | ||
// try { | ||
// mWiseFy.getSavedNetwork(TEST_SSID, null); | ||
// } catch (NullPointerException npe) { | ||
// fail(); | ||
// } | ||
// } | ||
//} |
92 changes: 46 additions & 46 deletions
92
wisefy/src/androidTest/java/com/isupatches/wisefy/IsDeviceConnectedToMobileNetworkTests.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,46 +1,46 @@ | ||
package com.isupatches.wisefy; | ||
|
||
|
||
import android.net.NetworkInfo; | ||
import com.isupatches.wisefy.base.TestActivity; | ||
import org.junit.Test; | ||
import static junit.framework.Assert.assertFalse; | ||
import static junit.framework.Assert.assertTrue; | ||
import static org.mockito.ArgumentMatchers.any; | ||
import static org.mockito.ArgumentMatchers.anyString; | ||
import static org.mockito.Mockito.mock; | ||
import static org.mockito.Mockito.when; | ||
|
||
|
||
public class IsDeviceConnectedToMobileNetworkTests extends BaseTestClass<TestActivity> { | ||
|
||
public IsDeviceConnectedToMobileNetworkTests() { | ||
super(TestActivity.class); | ||
} | ||
|
||
@Test | ||
public void failure_missingPrerequisite() { | ||
missingPrerequisite(); | ||
assertFalse(mWiseFy.isDeviceConnectedToMobileNetwork()); | ||
} | ||
|
||
@Test | ||
public void failure() { | ||
when(mMockConnectivityManager.getActiveNetworkInfo()).thenReturn(mock(NetworkInfo.class)); | ||
|
||
WiseFyConnection mockWiseFyConnection = mock(WiseFyConnection.class); | ||
mWiseFy.mWiseFyConnection = mockWiseFyConnection; | ||
when(mockWiseFyConnection.isNetworkConnectedAndMatchesType(any(NetworkInfo.class), anyString())).thenReturn(false); | ||
assertFalse(mWiseFy.isDeviceConnectedToMobileNetwork()); | ||
} | ||
|
||
@Test | ||
public void success() { | ||
when(mMockConnectivityManager.getActiveNetworkInfo()).thenReturn(mock(NetworkInfo.class)); | ||
|
||
WiseFyConnection mockWiseFyConnection = mock(WiseFyConnection.class); | ||
mWiseFy.mWiseFyConnection = mockWiseFyConnection; | ||
when(mockWiseFyConnection.isNetworkConnectedAndMatchesType(any(NetworkInfo.class), anyString())).thenReturn(true); | ||
assertTrue(mWiseFy.isDeviceConnectedToMobileNetwork()); | ||
} | ||
} | ||
//package com.isupatches.wisefy; | ||
// | ||
// | ||
//import android.net.NetworkInfo; | ||
//import com.isupatches.wisefy.base.TestActivity; | ||
//import org.junit.Test; | ||
//import static junit.framework.Assert.assertFalse; | ||
//import static junit.framework.Assert.assertTrue; | ||
//import static org.mockito.ArgumentMatchers.any; | ||
//import static org.mockito.ArgumentMatchers.anyString; | ||
//import static org.mockito.Mockito.mock; | ||
//import static org.mockito.Mockito.when; | ||
// | ||
// | ||
//public class IsDeviceConnectedToMobileNetworkTests extends BaseTestClass<TestActivity> { | ||
// | ||
// public IsDeviceConnectedToMobileNetworkTests() { | ||
// super(TestActivity.class); | ||
// } | ||
// | ||
// @Test | ||
// public void failure_missingPrerequisite() { | ||
// missingPrerequisite(); | ||
// assertFalse(mWiseFy.isDeviceConnectedToMobileNetwork()); | ||
// } | ||
// | ||
// @Test | ||
// public void failure() { | ||
// when(mMockConnectivityManager.getActiveNetworkInfo()).thenReturn(mock(NetworkInfo.class)); | ||
// | ||
// WiseFyConnection mockWiseFyConnection = mock(WiseFyConnection.class); | ||
// mWiseFy.mWiseFyConnection = mockWiseFyConnection; | ||
// when(mockWiseFyConnection.isNetworkConnectedAndMatchesType(any(NetworkInfo.class), anyString())).thenReturn(false); | ||
// assertFalse(mWiseFy.isDeviceConnectedToMobileNetwork()); | ||
// } | ||
// | ||
// @Test | ||
// public void success() { | ||
// when(mMockConnectivityManager.getActiveNetworkInfo()).thenReturn(mock(NetworkInfo.class)); | ||
// | ||
// WiseFyConnection mockWiseFyConnection = mock(WiseFyConnection.class); | ||
// mWiseFy.mWiseFyConnection = mockWiseFyConnection; | ||
// when(mockWiseFyConnection.isNetworkConnectedAndMatchesType(any(NetworkInfo.class), anyString())).thenReturn(true); | ||
// assertTrue(mWiseFy.isDeviceConnectedToMobileNetwork()); | ||
// } | ||
//} |
Oops, something went wrong.