diff --git a/.travis.yml b/.travis.yml index 1ec588ac..7bcd3c50 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,24 +1,36 @@ +sudo: required +dist: precise language: android -jdk: oraclejdk8 -sudo: false + +jdk: + - oraclejdk8 + +env: + global: + - TARGET_SDK=26 + - BUILD_TOOLS_VERSION=26.0.0 + matrix: + - EMULATOR_SDK=android-19 ABI=armeabi-v7a android: components: + - tools - platform-tools - tools - - build-tools-26.0.0 - - android-22 - - android-26 - - sys-img-armeabi-v7a-android-22 + - android-${TARGET_SDK} + - build-tools-${BUILD_TOOLS_VERSION} - extra-android-m2repository - - extra-android-support - - extra-google-m2repository before_script: - # Create and start emulator - - echo no | android create avd --force -n test -t android-22 --abi armeabi-v7a - - emulator -avd test -no-skin -no-audio -no-window & + - android-update-sdk --components=sys-img-$ABI-$EMULATOR_SDK --accept-licenses='android-sdk-license-[0-9a-f]{8}' + - echo no | android create avd --force -n test -t $EMULATOR_SDK --abi $ABI + - emulator -avd test -no-audio -no-window & + - ./gradlew clean assembleDebug assembleDebugAndroidTest - android-wait-for-emulator - adb shell input keyevent 82 & -script: travis_wait 90 ./gradlew clean connectedAndroidTest -PdisablePreDex --stacktrace \ No newline at end of file +script: + - travis_wait 60 ./gradlew jacocoDebugTestReport + +after_success: + - bash <(curl -s https://codecov.io/bash) \ No newline at end of file diff --git a/README.md b/README.md index a985ac19..c98320c6 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ Wifi configuration and util library built for Android. > >
Supports Android SDK levels 16-26

-[![Android Weekly](https://img.shields.io/badge/Android%20Weekly-%23230-blue.svg)](http://androidweekly.net/issues/issue-230) [![Build Status](https://travis-ci.org/isuPatches/WiseFy.svg?branch=master)](https://travis-ci.org/isuPatches/WiseFy) [ ![Download](https://api.bintray.com/packages/isupatches/Maven/wisefy/images/download.svg) ](https://bintray.com/isupatches/Maven/wisefy/_latestVersion) +[![Android Weekly](https://img.shields.io/badge/Android%20Weekly-%23230-blue.svg)](http://androidweekly.net/issues/issue-230) [![Build Status](https://travis-ci.org/isuPatches/WiseFy.svg?branch=master)](https://travis-ci.org/isuPatches/WiseFy) [ ![Download](https://api.bintray.com/packages/isupatches/Maven/wisefy/images/download.svg) ](https://bintray.com/isupatches/Maven/wisefy/_latestVersion) [![codecov.io](https://codecov.io/github/codecov/wisefy/branch/2.x/graph/badge.svg)](https://codecov.io/github/codecov/wisefy) ## What's New in 2.x diff --git a/build.gradle b/build.gradle index 9991176b..14f65f8b 100644 --- a/build.gradle +++ b/build.gradle @@ -45,6 +45,10 @@ subprojects { } ext { + travisBuild = System.getenv("TRAVIS") == "true" + // allows for -Dpre-dex=false to be set + preDexEnabled = "true".equals(System.getProperty("pre-dex", "true")) + GROUP = "com.isupatches" VERSION_NAME = "2.0.0" diff --git a/gradle.properties b/gradle.properties index 6cbe7a62..bae547d3 100644 --- a/gradle.properties +++ b/gradle.properties @@ -7,6 +7,10 @@ # For more details on how to configure your build environment visit # http://www.gradle.org/docs/current/userguide/build_environment.html +# The Gradle daemon aims to improve the startup and execution time of Gradle. +# When set to true the Gradle daemon is to run the build. +org.gradle.daemon=true + # Specifies the JVM arguments used for the daemon process. # The setting is particularly useful for tweaking memory settings. # Default value: -Xmx10248m -XX:MaxPermSize=256m @@ -15,4 +19,9 @@ org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryErro # When configured, Gradle will run in incubating parallel mode. # This option should only be used with decoupled projects. More details, visit # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects -# org.gradle.parallel=true \ No newline at end of file +org.gradle.parallel=true + +# Enables new incubating mode that makes Gradle selective when configuring projects. +# Only relevant projects are configured which results in faster builds for large multi-projects. +# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:configuration_on_demand +org.gradle.configureondemand=true \ No newline at end of file diff --git a/gradle/jacoco.gradle b/gradle/jacoco.gradle index 35661302..a35c74f5 100644 --- a/gradle/jacoco.gradle +++ b/gradle/jacoco.gradle @@ -17,13 +17,13 @@ def classDirs = fileTree( '**/*$Builder*']) task jacocoDebugTestReport(type: JacocoReport) { - dependsOn = ["connectedDebugAndroidTest"] + dependsOn = ["connectedDebugAndroidTest", "testDebugUnitTest"] group = "Reporting" description = "Run tests and generate Jacoco coverage report for debug" classDirectories = classDirs additionalSourceDirs = files(coverageSourceDirs) sourceDirectories = files(coverageSourceDirs) - executionData = files([fileTree(dir: 'build/outputs/code-coverage/connected', include: '**/*.ec')]) + executionData = files([fileTree(dir: 'build/outputs/code-coverage/connected', include: '**/*.ec'), fileTree(dir: 'build/jacoco', include: '**/*.exec')]) reports { xml.enabled = true @@ -37,7 +37,7 @@ task jacocoDebugReport(type: JacocoReport) { classDirectories = classDirs additionalSourceDirs = files(coverageSourceDirs) sourceDirectories = files(coverageSourceDirs) - executionData = files([fileTree(dir: 'build/outputs/code-coverage/connected', include: '**/*.ec')]) + executionData = files([fileTree(dir: 'build/outputs/code-coverage/connected', include: '**/*.ec'), fileTree(dir: 'build/jacoco', include: '**/*.exec')]) reports { xml.enabled = true diff --git a/wisefy/build.gradle b/wisefy/build.gradle index 30457742..f32957ed 100644 --- a/wisefy/build.gradle +++ b/wisefy/build.gradle @@ -15,6 +15,11 @@ dexcount { android { + dexOptions { + // Skip pre-dexing when running on Travis CI or when disabled via -Dpre-dex=false. + preDexLibraries = preDexEnabled && !travisBuild + } + adbOptions { timeOutInMs 15 * 60 * 1000 // 15 minutes installOptions "-d","-t" diff --git a/wisefy/src/androidTest/java/com/isupatches/wisefy/AddOpenNetworkTests.java b/wisefy/src/androidTest/java/com/isupatches/wisefy/AddOpenNetworkTests.java index 76073241..e020d4b3 100644 --- a/wisefy/src/androidTest/java/com/isupatches/wisefy/AddOpenNetworkTests.java +++ b/wisefy/src/androidTest/java/com/isupatches/wisefy/AddOpenNetworkTests.java @@ -4,11 +4,11 @@ import android.net.wifi.WifiConfiguration; import com.isupatches.wisefy.callbacks.AddOpenNetworkCallbacks; import com.isupatches.wisefy.constants.WiseFyCodes; -import com.isupatches.wisefy.base.TestActivity; +import org.junit.Assert; import org.junit.Test; import static com.isupatches.wisefy.base.TestUtils.OPEN_NETWORK_SSID; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotEquals; +import static junit.framework.Assert.assertEquals; +import static org.junit.Assert.*; import static org.junit.Assert.fail; import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.mock; @@ -18,11 +18,7 @@ import static org.mockito.Mockito.when; -public class AddOpenNetworkTests extends BaseTestClass { - - public AddOpenNetworkTests() { - super(TestActivity.class); - } +public class AddOpenNetworkTests extends BaseAndroidJUnit4TestClass { @Test public void noCallbacks_failure() { @@ -33,7 +29,7 @@ public void noCallbacks_failure() { @Test public void noCallbacks_failure_nullSSIDParam() { - assertEquals(WiseFyCodes.MISSING_PARAMETER, mWiseFy.addOpenNetwork(null)); + Assert.assertEquals(WiseFyCodes.MISSING_PARAMETER, mWiseFy.addOpenNetwork(null)); verify(mMockWiFiManager, never()).addNetwork(any(WifiConfiguration.class)); } diff --git a/wisefy/src/androidTest/java/com/isupatches/wisefy/AddWEPNetworkTests.java b/wisefy/src/androidTest/java/com/isupatches/wisefy/AddWEPNetworkTests.java index d637cf7d..9e672ec7 100644 --- a/wisefy/src/androidTest/java/com/isupatches/wisefy/AddWEPNetworkTests.java +++ b/wisefy/src/androidTest/java/com/isupatches/wisefy/AddWEPNetworkTests.java @@ -2,12 +2,10 @@ import android.net.wifi.WifiConfiguration; -import com.isupatches.wisefy.base.TestActivity; +import com.isupatches.wisefy.base.TestUtils; import com.isupatches.wisefy.callbacks.AddWEPNetworkCallbacks; import com.isupatches.wisefy.constants.WiseFyCodes; import org.junit.Test; -import static com.isupatches.wisefy.base.TestUtils.WEP_NETWORK_PASSWORD; -import static com.isupatches.wisefy.base.TestUtils.WEP_NETWORK_SSID; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotEquals; import static org.junit.Assert.fail; @@ -19,49 +17,45 @@ import static org.mockito.Mockito.when; -public class AddWEPNetworkTests extends BaseTestClass { - - public AddWEPNetworkTests() { - super(TestActivity.class); - } +public class AddWEPNetworkTests extends BaseAndroidJUnit4TestClass { @Test public void noCallbacks_failure() { when(mMockWiFiManager.addNetwork(any(WifiConfiguration.class))).thenReturn(WiseFy.WIFI_MANAGER_FAILURE); - assertEquals(WiseFy.WIFI_MANAGER_FAILURE, mWiseFy.addWEPNetwork(WEP_NETWORK_SSID, WEP_NETWORK_PASSWORD)); + assertEquals(WiseFy.WIFI_MANAGER_FAILURE, mWiseFy.addWEPNetwork(TestUtils.WEP_NETWORK_SSID, TestUtils.WEP_NETWORK_PASSWORD)); verify(mMockWiFiManager, timeout(VERIFICATION_TIMEOUT)).addNetwork(any(WifiConfiguration.class)); } @Test public void noCallbacks_failure_nullPasswordParam() { - assertEquals(WiseFyCodes.MISSING_PARAMETER, mWiseFy.addWEPNetwork(WEP_NETWORK_SSID, null)); + assertEquals(WiseFyCodes.MISSING_PARAMETER, mWiseFy.addWEPNetwork(TestUtils.WEP_NETWORK_SSID, null)); verify(mMockWiFiManager, never()).addNetwork(any(WifiConfiguration.class)); } @Test public void noCallbacks_failure_nullSSIDParam() { - assertEquals(WiseFyCodes.MISSING_PARAMETER, mWiseFy.addWEPNetwork(null, WEP_NETWORK_PASSWORD)); + assertEquals(WiseFyCodes.MISSING_PARAMETER, mWiseFy.addWEPNetwork(null, TestUtils.WEP_NETWORK_PASSWORD)); verify(mMockWiFiManager, never()).addNetwork(any(WifiConfiguration.class)); } @Test public void noCallbacks_failure_missingPrerequisite() { missingPrerequisite(); - assertEquals(WiseFyCodes.MISSING_PREREQUISITE, mWiseFy.addWEPNetwork(WEP_NETWORK_SSID, WEP_NETWORK_PASSWORD)); + assertEquals(WiseFyCodes.MISSING_PREREQUISITE, mWiseFy.addWEPNetwork(TestUtils.WEP_NETWORK_SSID, TestUtils.WEP_NETWORK_PASSWORD)); verify(mMockWiFiManager, never()).addNetwork(any(WifiConfiguration.class)); } @Test public void noCallbacks_success() { when(mMockWiFiManager.addNetwork(any(WifiConfiguration.class))).thenReturn(0); - assertNotEquals(WiseFy.WIFI_MANAGER_FAILURE, mWiseFy.addWEPNetwork(WEP_NETWORK_SSID, WEP_NETWORK_PASSWORD)); + assertNotEquals(WiseFy.WIFI_MANAGER_FAILURE, mWiseFy.addWEPNetwork(TestUtils.WEP_NETWORK_SSID, TestUtils.WEP_NETWORK_PASSWORD)); verify(mMockWiFiManager, timeout(VERIFICATION_TIMEOUT)).addNetwork(any(WifiConfiguration.class)); } @Test public void noCallbacks_success_alreadyConfigured() { networkAlreadyInConfigurationList(); - assertEquals(WiseFyCodes.NETWORK_ALREADY_CONFIGURED, mWiseFy.addWEPNetwork(WEP_NETWORK_SSID, WEP_NETWORK_PASSWORD)); + assertEquals(WiseFyCodes.NETWORK_ALREADY_CONFIGURED, mWiseFy.addWEPNetwork(TestUtils.WEP_NETWORK_SSID, TestUtils.WEP_NETWORK_PASSWORD)); verify(mMockWiFiManager, never()).addNetwork(any(WifiConfiguration.class)); } @@ -69,7 +63,7 @@ public void noCallbacks_success_alreadyConfigured() { public void callbacks_failure() { when(mMockWiFiManager.addNetwork(any(WifiConfiguration.class))).thenReturn(WiseFy.WIFI_MANAGER_FAILURE); AddWEPNetworkCallbacks mockCallbacks = mock(AddWEPNetworkCallbacks.class); - mWiseFy.addWEPNetwork(WEP_NETWORK_SSID, WEP_NETWORK_PASSWORD, mockCallbacks); + mWiseFy.addWEPNetwork(TestUtils.WEP_NETWORK_SSID, TestUtils.WEP_NETWORK_PASSWORD, mockCallbacks); verify(mockCallbacks, timeout(VERIFICATION_TIMEOUT)).failureAddingWEPNetwork(WiseFy.WIFI_MANAGER_FAILURE); verify(mMockWiFiManager, timeout(VERIFICATION_TIMEOUT)).addNetwork(any(WifiConfiguration.class)); } @@ -79,7 +73,7 @@ public void callbacks_failure_nullCallback() { when(mMockWiFiManager.addNetwork(any(WifiConfiguration.class))).thenReturn(WiseFy.WIFI_MANAGER_FAILURE); try { - mWiseFy.addWEPNetwork(WEP_NETWORK_SSID, WEP_NETWORK_PASSWORD, null); + mWiseFy.addWEPNetwork(TestUtils.WEP_NETWORK_SSID, TestUtils.WEP_NETWORK_PASSWORD, null); verify(mMockWiFiManager, never()).addNetwork(any(WifiConfiguration.class)); } catch (NullPointerException npe) { fail(); @@ -89,7 +83,7 @@ public void callbacks_failure_nullCallback() { @Test public void callbacks_failure_nullPasswordParam() { AddWEPNetworkCallbacks mockCallbacks = mock(AddWEPNetworkCallbacks.class); - mWiseFy.addWEPNetwork(WEP_NETWORK_SSID, null, mockCallbacks); + mWiseFy.addWEPNetwork(TestUtils.WEP_NETWORK_SSID, null, mockCallbacks); verify(mockCallbacks, timeout(VERIFICATION_TIMEOUT)).addWEPNetworkWiseFyFailure(WiseFyCodes.MISSING_PARAMETER); verify(mMockWiFiManager, never()).addNetwork(any(WifiConfiguration.class)); } @@ -97,7 +91,7 @@ public void callbacks_failure_nullPasswordParam() { @Test public void callbacks_failure_nullPasswordParam_nullCallback() { try { - mWiseFy.addWEPNetwork(WEP_NETWORK_SSID, null, null); + mWiseFy.addWEPNetwork(TestUtils.WEP_NETWORK_SSID, null, null); verify(mMockWiFiManager, never()).addNetwork(any(WifiConfiguration.class)); } catch (NullPointerException npe) { fail(); @@ -107,7 +101,7 @@ public void callbacks_failure_nullPasswordParam_nullCallback() { @Test public void callbacks_failure_nullSSIDParam() { AddWEPNetworkCallbacks mockCallbacks = mock(AddWEPNetworkCallbacks.class); - mWiseFy.addWEPNetwork(null, WEP_NETWORK_PASSWORD, mockCallbacks); + mWiseFy.addWEPNetwork(null, TestUtils.WEP_NETWORK_PASSWORD, mockCallbacks); verify(mockCallbacks, timeout(VERIFICATION_TIMEOUT)).addWEPNetworkWiseFyFailure(WiseFyCodes.MISSING_PARAMETER); verify(mMockWiFiManager, never()).addNetwork(any(WifiConfiguration.class)); } @@ -115,7 +109,7 @@ public void callbacks_failure_nullSSIDParam() { @Test public void callbacks_failure_nullSSIDParam_nullCallback() { try { - mWiseFy.addWEPNetwork(null, WEP_NETWORK_PASSWORD, null); + mWiseFy.addWEPNetwork(null, TestUtils.WEP_NETWORK_PASSWORD, null); verify(mMockWiFiManager, never()).addNetwork(any(WifiConfiguration.class)); } catch (NullPointerException npe) { fail(); @@ -126,7 +120,7 @@ public void callbacks_failure_nullSSIDParam_nullCallback() { public void callbacks_failure_missingPrerequisite() { missingPrerequisite(); AddWEPNetworkCallbacks mockCallbacks = mock(AddWEPNetworkCallbacks.class); - mWiseFy.addWEPNetwork(WEP_NETWORK_SSID, WEP_NETWORK_PASSWORD, mockCallbacks); + mWiseFy.addWEPNetwork(TestUtils.WEP_NETWORK_SSID, TestUtils.WEP_NETWORK_PASSWORD, mockCallbacks); verify(mockCallbacks, timeout(VERIFICATION_TIMEOUT)).addWEPNetworkWiseFyFailure(WiseFyCodes.MISSING_PREREQUISITE); verify(mMockWiFiManager, never()).addNetwork(any(WifiConfiguration.class)); } @@ -136,7 +130,7 @@ public void callbacks_failure_missingPrerequisite_nullCallback() { missingPrerequisite(); try { - mWiseFy.addWEPNetwork(WEP_NETWORK_SSID, WEP_NETWORK_PASSWORD, null); + mWiseFy.addWEPNetwork(TestUtils.WEP_NETWORK_SSID, TestUtils.WEP_NETWORK_PASSWORD, null); verify(mMockWiFiManager, never()).addNetwork(any(WifiConfiguration.class)); } catch (NullPointerException npe) { fail(); @@ -147,7 +141,7 @@ public void callbacks_failure_missingPrerequisite_nullCallback() { public void callbacks_success() { when(mMockWiFiManager.addNetwork(any(WifiConfiguration.class))).thenReturn(0); AddWEPNetworkCallbacks mockCallbacks = mock(AddWEPNetworkCallbacks.class); - mWiseFy.addWEPNetwork(WEP_NETWORK_SSID, WEP_NETWORK_PASSWORD, mockCallbacks); + mWiseFy.addWEPNetwork(TestUtils.WEP_NETWORK_SSID, TestUtils.WEP_NETWORK_PASSWORD, mockCallbacks); verify(mockCallbacks, timeout(VERIFICATION_TIMEOUT)).wepNetworkAdded(any(WifiConfiguration.class)); verify(mMockWiFiManager, timeout(VERIFICATION_TIMEOUT)).addNetwork(any(WifiConfiguration.class)); } @@ -157,7 +151,7 @@ public void callbacks_success_nullCallback() { when(mMockWiFiManager.addNetwork(any(WifiConfiguration.class))).thenReturn(0); try { - mWiseFy.addWEPNetwork(WEP_NETWORK_SSID, WEP_NETWORK_PASSWORD, null); + mWiseFy.addWEPNetwork(TestUtils.WEP_NETWORK_SSID, TestUtils.WEP_NETWORK_PASSWORD, null); verify(mMockWiFiManager, never()).addNetwork(any(WifiConfiguration.class)); } catch (NullPointerException npe) { fail(); @@ -169,7 +163,7 @@ public void callbacks_success_alreadyConfigured() { networkAlreadyInConfigurationList(); AddWEPNetworkCallbacks mockCallbacks = mock(AddWEPNetworkCallbacks.class); - mWiseFy.addWEPNetwork(WEP_NETWORK_SSID, WEP_NETWORK_PASSWORD, mockCallbacks); + mWiseFy.addWEPNetwork(TestUtils.WEP_NETWORK_SSID, TestUtils.WEP_NETWORK_PASSWORD, mockCallbacks); verify(mockCallbacks, timeout(VERIFICATION_TIMEOUT)).addWEPNetworkWiseFyFailure(WiseFyCodes.NETWORK_ALREADY_CONFIGURED); verify(mMockWiFiManager, never()).addNetwork(any(WifiConfiguration.class)); } @@ -179,7 +173,7 @@ public void callbacks_success_alreadyConfigured_nullCallback() { networkAlreadyInConfigurationList(); try { - mWiseFy.addWEPNetwork(WEP_NETWORK_SSID, WEP_NETWORK_PASSWORD, null); + mWiseFy.addWEPNetwork(TestUtils.WEP_NETWORK_SSID, TestUtils.WEP_NETWORK_PASSWORD, null); verify(mMockWiFiManager, never()).addNetwork(any(WifiConfiguration.class)); } catch (NullPointerException npe) { fail(); diff --git a/wisefy/src/androidTest/java/com/isupatches/wisefy/AddWPA2NetworkTests.java b/wisefy/src/androidTest/java/com/isupatches/wisefy/AddWPA2NetworkTests.java index 4e3d2480..684e00c7 100644 --- a/wisefy/src/androidTest/java/com/isupatches/wisefy/AddWPA2NetworkTests.java +++ b/wisefy/src/androidTest/java/com/isupatches/wisefy/AddWPA2NetworkTests.java @@ -2,13 +2,11 @@ import android.net.wifi.WifiConfiguration; -import com.isupatches.wisefy.base.TestActivity; +import com.isupatches.wisefy.base.TestUtils; import com.isupatches.wisefy.callbacks.AddWPA2NetworkCallbacks; import com.isupatches.wisefy.constants.WiseFyCodes; import org.junit.Test; -import static com.isupatches.wisefy.base.TestUtils.WPA2_NETWORK_PASSWORD; -import static com.isupatches.wisefy.base.TestUtils.WPA2_NETWORK_SSID; -import static org.junit.Assert.assertEquals; +import static junit.framework.Assert.assertEquals; import static org.junit.Assert.assertNotEquals; import static org.junit.Assert.fail; import static org.mockito.ArgumentMatchers.any; @@ -19,49 +17,45 @@ import static org.mockito.Mockito.when; -public class AddWPA2NetworkTests extends BaseTestClass { - - public AddWPA2NetworkTests() { - super(TestActivity.class); - } +public class AddWPA2NetworkTests extends BaseAndroidJUnit4TestClass { @Test public void noCallbacks_failure() { when(mMockWiFiManager.addNetwork(any(WifiConfiguration.class))).thenReturn(WiseFy.WIFI_MANAGER_FAILURE); - assertEquals(WiseFy.WIFI_MANAGER_FAILURE, mWiseFy.addWPA2Network(WPA2_NETWORK_SSID, WPA2_NETWORK_PASSWORD)); + assertEquals(WiseFy.WIFI_MANAGER_FAILURE, mWiseFy.addWPA2Network(TestUtils.WPA2_NETWORK_SSID, TestUtils.WPA2_NETWORK_PASSWORD)); verify(mMockWiFiManager, timeout(VERIFICATION_TIMEOUT)).addNetwork(any(WifiConfiguration.class)); } @Test public void noCallbacks_failure_nullPasswordParam() { - assertEquals(WiseFyCodes.MISSING_PARAMETER, mWiseFy.addWPA2Network(WPA2_NETWORK_SSID, null)); + assertEquals(WiseFyCodes.MISSING_PARAMETER, mWiseFy.addWPA2Network(TestUtils.WPA2_NETWORK_SSID, null)); verify(mMockWiFiManager, never()).addNetwork(any(WifiConfiguration.class)); } @Test public void anoCallbacks_failure_nullSSIDParam() { - assertEquals(WiseFyCodes.MISSING_PARAMETER, mWiseFy.addWPA2Network(null, WPA2_NETWORK_PASSWORD)); + assertEquals(WiseFyCodes.MISSING_PARAMETER, mWiseFy.addWPA2Network(null, TestUtils.WPA2_NETWORK_PASSWORD)); verify(mMockWiFiManager, never()).addNetwork(any(WifiConfiguration.class)); } @Test public void noCallbacks_failure_missingPrerequisite() { missingPrerequisite(); - assertEquals(WiseFyCodes.MISSING_PREREQUISITE, mWiseFy.addWPA2Network(WPA2_NETWORK_SSID, WPA2_NETWORK_PASSWORD)); + assertEquals(WiseFyCodes.MISSING_PREREQUISITE, mWiseFy.addWPA2Network(TestUtils.WPA2_NETWORK_SSID, TestUtils.WPA2_NETWORK_PASSWORD)); verify(mMockWiFiManager, never()).addNetwork(any(WifiConfiguration.class)); } @Test public void noCallbacks_success() { when(mMockWiFiManager.addNetwork(any(WifiConfiguration.class))).thenReturn(0); - assertNotEquals(WiseFy.WIFI_MANAGER_FAILURE, mWiseFy.addWPA2Network(WPA2_NETWORK_SSID, WPA2_NETWORK_PASSWORD)); + assertNotEquals(WiseFy.WIFI_MANAGER_FAILURE, mWiseFy.addWPA2Network(TestUtils.WPA2_NETWORK_SSID, TestUtils.WPA2_NETWORK_PASSWORD)); verify(mMockWiFiManager, timeout(VERIFICATION_TIMEOUT)).addNetwork(any(WifiConfiguration.class)); } @Test public void noCallbacks_success_alreadyConfigured() { networkAlreadyInConfigurationList(); - assertEquals(WiseFyCodes.NETWORK_ALREADY_CONFIGURED, mWiseFy.addWPA2Network(WPA2_NETWORK_SSID, WPA2_NETWORK_PASSWORD)); + assertEquals(WiseFyCodes.NETWORK_ALREADY_CONFIGURED, mWiseFy.addWPA2Network(TestUtils.WPA2_NETWORK_SSID, TestUtils.WPA2_NETWORK_PASSWORD)); verify(mMockWiFiManager, never()).addNetwork(any(WifiConfiguration.class)); } @@ -69,7 +63,7 @@ public void noCallbacks_success_alreadyConfigured() { public void callbacks_failure() { when(mMockWiFiManager.addNetwork(any(WifiConfiguration.class))).thenReturn(WiseFy.WIFI_MANAGER_FAILURE); AddWPA2NetworkCallbacks mockCallbacks = mock(AddWPA2NetworkCallbacks.class); - mWiseFy.addWPA2Network(WPA2_NETWORK_SSID, WPA2_NETWORK_PASSWORD, mockCallbacks); + mWiseFy.addWPA2Network(TestUtils.WPA2_NETWORK_SSID, TestUtils.WPA2_NETWORK_PASSWORD, mockCallbacks); verify(mockCallbacks, timeout(VERIFICATION_TIMEOUT)).failureAddingWPA2Network(WiseFy.WIFI_MANAGER_FAILURE); verify(mMockWiFiManager, timeout(VERIFICATION_TIMEOUT)).addNetwork(any(WifiConfiguration.class)); } @@ -78,7 +72,7 @@ public void callbacks_failure() { public void callbacks_failure_nullCallback() { when(mMockWiFiManager.addNetwork(any(WifiConfiguration.class))).thenReturn(WiseFy.WIFI_MANAGER_FAILURE); try { - mWiseFy.addWPA2Network(WPA2_NETWORK_SSID, WPA2_NETWORK_PASSWORD, null); + mWiseFy.addWPA2Network(TestUtils.WPA2_NETWORK_SSID, TestUtils.WPA2_NETWORK_PASSWORD, null); verify(mMockWiFiManager, never()).addNetwork(any(WifiConfiguration.class)); } catch (NullPointerException npe) { fail(); @@ -88,7 +82,7 @@ public void callbacks_failure_nullCallback() { @Test public void callbacks_failure_nullPasswordParam() { AddWPA2NetworkCallbacks mockCallbacks = mock(AddWPA2NetworkCallbacks.class); - mWiseFy.addWPA2Network(WPA2_NETWORK_SSID, null, mockCallbacks); + mWiseFy.addWPA2Network(TestUtils.WPA2_NETWORK_SSID, null, mockCallbacks); verify(mockCallbacks, timeout(VERIFICATION_TIMEOUT)).addWPA2NetworkWiseFyFailure(WiseFyCodes.MISSING_PARAMETER); verify(mMockWiFiManager, never()).addNetwork(any(WifiConfiguration.class)); } @@ -96,7 +90,7 @@ public void callbacks_failure_nullPasswordParam() { @Test public void callbacks_failure_nullPasswordParam_nullCallback() { try { - mWiseFy.addWPA2Network(WPA2_NETWORK_SSID, null, null); + mWiseFy.addWPA2Network(TestUtils.WPA2_NETWORK_SSID, null, null); verify(mMockWiFiManager, never()).addNetwork(any(WifiConfiguration.class)); } catch (NullPointerException npe) { fail(); @@ -106,14 +100,14 @@ public void callbacks_failure_nullPasswordParam_nullCallback() { @Test public void callbacks_failure_nullSSIDParam() { AddWPA2NetworkCallbacks mockCallbacks = mock(AddWPA2NetworkCallbacks.class); - mWiseFy.addWPA2Network(null, WPA2_NETWORK_PASSWORD, mockCallbacks); + mWiseFy.addWPA2Network(null, TestUtils.WPA2_NETWORK_PASSWORD, mockCallbacks); verify(mockCallbacks, never()).addWPA2NetworkWiseFyFailure(WiseFyCodes.MISSING_PARAMETER); } @Test public void callbacks_failure_nullSSIDParam_nullCallback() { try { - mWiseFy.addWPA2Network(null, WPA2_NETWORK_PASSWORD, null); + mWiseFy.addWPA2Network(null, TestUtils.WPA2_NETWORK_PASSWORD, null); verify(mMockWiFiManager, never()).addNetwork(any(WifiConfiguration.class)); } catch (NullPointerException npe) { fail(); @@ -125,7 +119,7 @@ public void callbacks_failure_missingPrerequisite() { missingPrerequisite(); AddWPA2NetworkCallbacks mockCallbacks = mock(AddWPA2NetworkCallbacks.class); - mWiseFy.addWPA2Network(WPA2_NETWORK_SSID, WPA2_NETWORK_PASSWORD, mockCallbacks); + mWiseFy.addWPA2Network(TestUtils.WPA2_NETWORK_SSID, TestUtils.WPA2_NETWORK_PASSWORD, mockCallbacks); verify(mockCallbacks, timeout(VERIFICATION_TIMEOUT)).addWPA2NetworkWiseFyFailure(WiseFyCodes.MISSING_PREREQUISITE); verify(mMockWiFiManager, never()).addNetwork(any(WifiConfiguration.class)); } @@ -135,7 +129,7 @@ public void callbacks_failure_missingPrerequisite_nullCallback() { missingPrerequisite(); try { - mWiseFy.addWPA2Network(WPA2_NETWORK_SSID, WPA2_NETWORK_PASSWORD, null); + mWiseFy.addWPA2Network(TestUtils.WPA2_NETWORK_SSID, TestUtils.WPA2_NETWORK_PASSWORD, null); verify(mMockWiFiManager, never()).addNetwork(any(WifiConfiguration.class)); } catch (NullPointerException npe) { fail(); @@ -146,7 +140,7 @@ public void callbacks_failure_missingPrerequisite_nullCallback() { public void callbacks_success() { when(mMockWiFiManager.addNetwork(any(WifiConfiguration.class))).thenReturn(0); AddWPA2NetworkCallbacks mockCallbacks = mock(AddWPA2NetworkCallbacks.class); - mWiseFy.addWPA2Network(WPA2_NETWORK_SSID, WPA2_NETWORK_PASSWORD, mockCallbacks); + mWiseFy.addWPA2Network(TestUtils.WPA2_NETWORK_SSID, TestUtils.WPA2_NETWORK_PASSWORD, mockCallbacks); verify(mockCallbacks, timeout(VERIFICATION_TIMEOUT)).wpa2NetworkAdded(any(WifiConfiguration.class)); verify(mMockWiFiManager, timeout(VERIFICATION_TIMEOUT)).addNetwork(any(WifiConfiguration.class)); } @@ -156,7 +150,7 @@ public void callbacks_success_nullCallback() { when(mMockWiFiManager.addNetwork(any(WifiConfiguration.class))).thenReturn(0); try { - mWiseFy.addWPA2Network(WPA2_NETWORK_SSID, WPA2_NETWORK_PASSWORD, null); + mWiseFy.addWPA2Network(TestUtils.WPA2_NETWORK_SSID, TestUtils.WPA2_NETWORK_PASSWORD, null); verify(mMockWiFiManager, never()).addNetwork(any(WifiConfiguration.class)); } catch (NullPointerException npe) { fail(); @@ -168,7 +162,7 @@ public void callbacks_success_alreadyConfigured() { networkAlreadyInConfigurationList(); AddWPA2NetworkCallbacks mockCallbacks = mock(AddWPA2NetworkCallbacks.class); - mWiseFy.addWPA2Network(WPA2_NETWORK_SSID, WPA2_NETWORK_PASSWORD, mockCallbacks); + mWiseFy.addWPA2Network(TestUtils.WPA2_NETWORK_SSID, TestUtils.WPA2_NETWORK_PASSWORD, mockCallbacks); verify(mockCallbacks, timeout(VERIFICATION_TIMEOUT)).addWPA2NetworkWiseFyFailure(WiseFyCodes.NETWORK_ALREADY_CONFIGURED); verify(mMockWiFiManager, never()).addNetwork(any(WifiConfiguration.class)); } @@ -178,7 +172,7 @@ public void callbacks_success_alreadyConfigured_nullCallback() { networkAlreadyInConfigurationList(); try { - mWiseFy.addWPA2Network(WPA2_NETWORK_SSID, WPA2_NETWORK_PASSWORD, null); + mWiseFy.addWPA2Network(TestUtils.WPA2_NETWORK_SSID, TestUtils.WPA2_NETWORK_PASSWORD, null); verify(mMockWiFiManager, never()).addNetwork(any(WifiConfiguration.class)); } catch (NullPointerException npe) { fail(); diff --git a/wisefy/src/androidTest/java/com/isupatches/wisefy/BaseTestClass.java b/wisefy/src/androidTest/java/com/isupatches/wisefy/BaseAndroidJUnit4TestClass.java similarity index 74% rename from wisefy/src/androidTest/java/com/isupatches/wisefy/BaseTestClass.java rename to wisefy/src/androidTest/java/com/isupatches/wisefy/BaseAndroidJUnit4TestClass.java index 070ec0d0..fbbc1f05 100644 --- a/wisefy/src/androidTest/java/com/isupatches/wisefy/BaseTestClass.java +++ b/wisefy/src/androidTest/java/com/isupatches/wisefy/BaseAndroidJUnit4TestClass.java @@ -1,24 +1,20 @@ package com.isupatches.wisefy; -import android.app.Activity; -import android.content.Intent; import android.net.ConnectivityManager; import android.net.wifi.WifiManager; -import android.support.test.rule.ActivityTestRule; -import com.isupatches.wisefy.base.TestActivity; +import android.support.test.InstrumentationRegistry; +import android.support.test.runner.AndroidJUnit4; import org.junit.After; import org.junit.Before; -import org.junit.Rule; +import org.junit.runner.RunWith; import static org.mockito.ArgumentMatchers.anyString; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; -public abstract class BaseTestClass extends ActivityTestRule { - - @Rule - public ActivityTestRule mActivityTestRule = new ActivityTestRule<>(TestActivity.class); +@RunWith(AndroidJUnit4.class) +public abstract class BaseAndroidJUnit4TestClass { ConnectivityManager mMockConnectivityManager; @@ -28,10 +24,6 @@ public abstract class BaseTestClass extends ActivityTestRule protected static final Integer VERIFICATION_TIMEOUT = 2000; - public BaseTestClass(Class activityClass) { - super(activityClass); - } - @Before public void setUp() { mMockWiFiManager = mock(WifiManager.class); @@ -40,9 +32,7 @@ public void setUp() { mMockWiFiManager = mock(WifiManager.class); mMockConnectivityManager = mock(ConnectivityManager.class); - mActivityTestRule.launchActivity(new Intent()); - - mWiseFy = new WiseFy.brains(mActivityTestRule.getActivity()).logging(true).getSmarts(); + mWiseFy = new WiseFy.brains(InstrumentationRegistry.getContext()).logging(true).getSmarts(); setManagers(); } @@ -75,4 +65,4 @@ private void setManagers() { when(mockPrereqs.getWifiManager()).thenReturn(mMockWiFiManager); when(mockPrereqs.getConnectivityManager()).thenReturn(mMockConnectivityManager); } -} \ No newline at end of file +} diff --git a/wisefy/src/androidTest/java/com/isupatches/wisefy/ConnectToNetworkTests.java b/wisefy/src/androidTest/java/com/isupatches/wisefy/ConnectToNetworkTests.java index e5893856..57bbcfe7 100644 --- a/wisefy/src/androidTest/java/com/isupatches/wisefy/ConnectToNetworkTests.java +++ b/wisefy/src/androidTest/java/com/isupatches/wisefy/ConnectToNetworkTests.java @@ -2,7 +2,6 @@ import android.net.wifi.WifiConfiguration; -import com.isupatches.wisefy.base.TestActivity; import com.isupatches.wisefy.callbacks.ConnectToNetworkCallbacks; import com.isupatches.wisefy.constants.WiseFyCodes; import org.junit.Test; @@ -19,11 +18,7 @@ import static org.mockito.Mockito.when; -public class ConnectToNetworkTests extends BaseTestClass { - - public ConnectToNetworkTests() { - super(TestActivity.class); - } +public class ConnectToNetworkTests extends BaseAndroidJUnit4TestClass { @Test public void noCallbacks_failure_nullSSIDParam() { diff --git a/wisefy/src/androidTest/java/com/isupatches/wisefy/DisableWifiTests.java b/wisefy/src/androidTest/java/com/isupatches/wisefy/DisableWifiTests.java index 9afbe40d..10552123 100644 --- a/wisefy/src/androidTest/java/com/isupatches/wisefy/DisableWifiTests.java +++ b/wisefy/src/androidTest/java/com/isupatches/wisefy/DisableWifiTests.java @@ -1,7 +1,6 @@ package com.isupatches.wisefy; -import com.isupatches.wisefy.base.TestActivity; import com.isupatches.wisefy.callbacks.DisableWifiCallbacks; import com.isupatches.wisefy.constants.WiseFyCodes; import org.junit.Test; @@ -15,11 +14,7 @@ import static org.mockito.Mockito.when; -public class DisableWifiTests extends BaseTestClass { - - public DisableWifiTests() { - super(TestActivity.class); - } +public class DisableWifiTests extends BaseAndroidJUnit4TestClass { @Test public void noCallbacks_failure() { diff --git a/wisefy/src/androidTest/java/com/isupatches/wisefy/DisconnectFromCurrentNetworkTests.java b/wisefy/src/androidTest/java/com/isupatches/wisefy/DisconnectFromCurrentNetworkTests.java index d26f12a4..979e6311 100644 --- a/wisefy/src/androidTest/java/com/isupatches/wisefy/DisconnectFromCurrentNetworkTests.java +++ b/wisefy/src/androidTest/java/com/isupatches/wisefy/DisconnectFromCurrentNetworkTests.java @@ -1,7 +1,6 @@ package com.isupatches.wisefy; -import com.isupatches.wisefy.base.TestActivity; import com.isupatches.wisefy.callbacks.DisconnectFromCurrentNetworkCallbacks; import com.isupatches.wisefy.constants.WiseFyCodes; import org.junit.Test; @@ -14,11 +13,7 @@ import static org.mockito.Mockito.when; -public class DisconnectFromCurrentNetworkTests extends BaseTestClass { - - public DisconnectFromCurrentNetworkTests() { - super(TestActivity.class); - } +public class DisconnectFromCurrentNetworkTests extends BaseAndroidJUnit4TestClass { @Test public void noCallbacks_failure() { diff --git a/wisefy/src/androidTest/java/com/isupatches/wisefy/EnableWifiTests.java b/wisefy/src/androidTest/java/com/isupatches/wisefy/EnableWifiTests.java index f962b3e7..30eb1b63 100644 --- a/wisefy/src/androidTest/java/com/isupatches/wisefy/EnableWifiTests.java +++ b/wisefy/src/androidTest/java/com/isupatches/wisefy/EnableWifiTests.java @@ -1,7 +1,6 @@ package com.isupatches.wisefy; -import com.isupatches.wisefy.base.TestActivity; import com.isupatches.wisefy.callbacks.EnableWifiCallbacks; import com.isupatches.wisefy.constants.WiseFyCodes; import org.junit.Test; @@ -15,11 +14,7 @@ import static org.mockito.Mockito.when; -public class EnableWifiTests extends BaseTestClass { - - public EnableWifiTests() { - super(TestActivity.class); - } +public class EnableWifiTests extends BaseAndroidJUnit4TestClass { @Test public void noCallbacks_failure() { diff --git a/wisefy/src/androidTest/java/com/isupatches/wisefy/GetCurrentNetworkTests.java b/wisefy/src/androidTest/java/com/isupatches/wisefy/GetCurrentNetworkTests.java index 6acdfd66..7f10e2c6 100644 --- a/wisefy/src/androidTest/java/com/isupatches/wisefy/GetCurrentNetworkTests.java +++ b/wisefy/src/androidTest/java/com/isupatches/wisefy/GetCurrentNetworkTests.java @@ -2,7 +2,6 @@ import android.net.wifi.WifiInfo; -import com.isupatches.wisefy.base.TestActivity; import com.isupatches.wisefy.callbacks.GetCurrentNetworkCallbacks; import com.isupatches.wisefy.constants.WiseFyCodes; import org.junit.Test; @@ -16,11 +15,7 @@ import static org.mockito.Mockito.when; -public class GetCurrentNetworkTests extends BaseTestClass { - - public GetCurrentNetworkTests() { - super(TestActivity.class); - } +public class GetCurrentNetworkTests extends BaseAndroidJUnit4TestClass { @Test public void noCallbacks_failure_missingPrerequisite() { diff --git a/wisefy/src/androidTest/java/com/isupatches/wisefy/GetFrequencyTests.java b/wisefy/src/androidTest/java/com/isupatches/wisefy/GetFrequencyTests.java index 3963809e..d5f7542d 100644 --- a/wisefy/src/androidTest/java/com/isupatches/wisefy/GetFrequencyTests.java +++ b/wisefy/src/androidTest/java/com/isupatches/wisefy/GetFrequencyTests.java @@ -3,7 +3,6 @@ import android.net.wifi.WifiInfo; import android.os.Build; -import com.isupatches.wisefy.base.TestActivity; import com.isupatches.wisefy.callbacks.GetFrequencyCallbacks; import com.isupatches.wisefy.constants.WiseFyCodes; import org.junit.Test; @@ -16,11 +15,7 @@ import static org.mockito.Mockito.when; -public class GetFrequencyTests extends BaseTestClass { - - public GetFrequencyTests() { - super(TestActivity.class); - } +public class GetFrequencyTests extends BaseAndroidJUnit4TestClass { @Test public void noCallbacks_getFrequency_currentNetwork_failure() { diff --git a/wisefy/src/androidTest/java/com/isupatches/wisefy/GetNearbyAccessPointsTests.java b/wisefy/src/androidTest/java/com/isupatches/wisefy/GetNearbyAccessPointsTests.java index df07acfc..e9144cac 100644 --- a/wisefy/src/androidTest/java/com/isupatches/wisefy/GetNearbyAccessPointsTests.java +++ b/wisefy/src/androidTest/java/com/isupatches/wisefy/GetNearbyAccessPointsTests.java @@ -2,7 +2,6 @@ import android.net.wifi.ScanResult; -import com.isupatches.wisefy.base.TestActivity; import com.isupatches.wisefy.callbacks.GetNearbyAccessPointsCallbacks; import com.isupatches.wisefy.constants.WiseFyCodes; import org.junit.Test; @@ -20,11 +19,7 @@ import static org.mockito.Mockito.when; -public class GetNearbyAccessPointsTests extends BaseTestClass { - - public GetNearbyAccessPointsTests() { - super(TestActivity.class); - } +public class GetNearbyAccessPointsTests extends BaseAndroidJUnit4TestClass { @Test public void noCallbacks_failure_missingPrerequisite_filterDuplicates_false() { diff --git a/wisefy/src/androidTest/java/com/isupatches/wisefy/GetRSSITests.java b/wisefy/src/androidTest/java/com/isupatches/wisefy/GetRSSITests.java index a1405794..1f622a6f 100644 --- a/wisefy/src/androidTest/java/com/isupatches/wisefy/GetRSSITests.java +++ b/wisefy/src/androidTest/java/com/isupatches/wisefy/GetRSSITests.java @@ -2,7 +2,6 @@ import android.net.wifi.ScanResult; -import com.isupatches.wisefy.base.TestActivity; import com.isupatches.wisefy.callbacks.GetRSSICallbacks; import com.isupatches.wisefy.constants.WiseFyCodes; import org.junit.Test; @@ -19,11 +18,7 @@ import static org.mockito.Mockito.when; -public class GetRSSITests extends BaseTestClass { - - public GetRSSITests() { - super(TestActivity.class); - } +public class GetRSSITests extends BaseAndroidJUnit4TestClass { @Test public void noCallbacks_failure_takeHighest_false_nullSSIDParam() { diff --git a/wisefy/src/androidTest/java/com/isupatches/wisefy/GetSavedNetworkTests.java b/wisefy/src/androidTest/java/com/isupatches/wisefy/GetSavedNetworkTests.java index 1bbe3a07..f1bb847a 100644 --- a/wisefy/src/androidTest/java/com/isupatches/wisefy/GetSavedNetworkTests.java +++ b/wisefy/src/androidTest/java/com/isupatches/wisefy/GetSavedNetworkTests.java @@ -2,7 +2,6 @@ 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; @@ -16,11 +15,7 @@ import static org.mockito.Mockito.when; -public class GetSavedNetworkTests extends BaseTestClass { - - public GetSavedNetworkTests() { - super(TestActivity.class); - } +public class GetSavedNetworkTests extends BaseAndroidJUnit4TestClass { @Test public void noCallbacks_failure_nullSSIDParam() { diff --git a/wisefy/src/androidTest/java/com/isupatches/wisefy/GetSavedNetworksTests.java b/wisefy/src/androidTest/java/com/isupatches/wisefy/GetSavedNetworksTests.java index 1926c5de..f96626d2 100644 --- a/wisefy/src/androidTest/java/com/isupatches/wisefy/GetSavedNetworksTests.java +++ b/wisefy/src/androidTest/java/com/isupatches/wisefy/GetSavedNetworksTests.java @@ -2,7 +2,6 @@ import android.net.wifi.WifiConfiguration; -import com.isupatches.wisefy.base.TestActivity; import com.isupatches.wisefy.callbacks.GetSavedNetworksCallbacks; import com.isupatches.wisefy.constants.WiseFyCodes; import org.junit.Test; @@ -18,11 +17,7 @@ import static org.mockito.Mockito.when; -public class GetSavedNetworksTests extends BaseTestClass { - - public GetSavedNetworksTests() { - super(TestActivity.class); - } +public class GetSavedNetworksTests extends BaseAndroidJUnit4TestClass { @Test public void noCallbacks_failure_missingPrerequisite() { diff --git a/wisefy/src/androidTest/java/com/isupatches/wisefy/IsDeviceConnectedToMobileNetworkTests.java b/wisefy/src/androidTest/java/com/isupatches/wisefy/IsDeviceConnectedToMobileNetworkTests.java index 73f3b9aa..9353adc7 100644 --- a/wisefy/src/androidTest/java/com/isupatches/wisefy/IsDeviceConnectedToMobileNetworkTests.java +++ b/wisefy/src/androidTest/java/com/isupatches/wisefy/IsDeviceConnectedToMobileNetworkTests.java @@ -2,7 +2,6 @@ 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; @@ -12,11 +11,7 @@ import static org.mockito.Mockito.when; -public class IsDeviceConnectedToMobileNetworkTests extends BaseTestClass { - - public IsDeviceConnectedToMobileNetworkTests() { - super(TestActivity.class); - } +public class IsDeviceConnectedToMobileNetworkTests extends BaseAndroidJUnit4TestClass { @Test public void failure_missingPrerequisite() { diff --git a/wisefy/src/androidTest/java/com/isupatches/wisefy/IsDeviceConnectedToMobileOrWifiNetworkTests.java b/wisefy/src/androidTest/java/com/isupatches/wisefy/IsDeviceConnectedToMobileOrWifiNetworkTests.java index 2d15222c..840bb8d4 100644 --- a/wisefy/src/androidTest/java/com/isupatches/wisefy/IsDeviceConnectedToMobileOrWifiNetworkTests.java +++ b/wisefy/src/androidTest/java/com/isupatches/wisefy/IsDeviceConnectedToMobileOrWifiNetworkTests.java @@ -11,11 +11,7 @@ import static org.mockito.Mockito.when; -public class IsDeviceConnectedToMobileOrWifiNetworkTests extends BaseTestClass { - - public IsDeviceConnectedToMobileOrWifiNetworkTests() { - super(TestActivity.class); - } +public class IsDeviceConnectedToMobileOrWifiNetworkTests extends BaseAndroidJUnit4TestClass { @Test public void failure_missingPrerequisite() { diff --git a/wisefy/src/androidTest/java/com/isupatches/wisefy/IsDeviceConnectedToSSIDTests.java b/wisefy/src/androidTest/java/com/isupatches/wisefy/IsDeviceConnectedToSSIDTests.java index 1f3d0a78..adceb5d9 100644 --- a/wisefy/src/androidTest/java/com/isupatches/wisefy/IsDeviceConnectedToSSIDTests.java +++ b/wisefy/src/androidTest/java/com/isupatches/wisefy/IsDeviceConnectedToSSIDTests.java @@ -1,7 +1,6 @@ package com.isupatches.wisefy; -import com.isupatches.wisefy.base.TestActivity; import org.junit.Test; import static com.isupatches.wisefy.base.TestUtils.TEST_SSID; import static junit.framework.Assert.assertFalse; @@ -11,11 +10,7 @@ import static org.mockito.Mockito.when; -public class IsDeviceConnectedToSSIDTests extends BaseTestClass { - - public IsDeviceConnectedToSSIDTests() { - super(TestActivity.class); - } +public class IsDeviceConnectedToSSIDTests extends BaseAndroidJUnit4TestClass { @Test public void noCallbacks_failure_nullSSIDParams() { diff --git a/wisefy/src/androidTest/java/com/isupatches/wisefy/IsDeviceConnectedToWifiNetworkTests.java b/wisefy/src/androidTest/java/com/isupatches/wisefy/IsDeviceConnectedToWifiNetworkTests.java index 534a195d..da3d209d 100644 --- a/wisefy/src/androidTest/java/com/isupatches/wisefy/IsDeviceConnectedToWifiNetworkTests.java +++ b/wisefy/src/androidTest/java/com/isupatches/wisefy/IsDeviceConnectedToWifiNetworkTests.java @@ -2,7 +2,6 @@ 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; @@ -12,11 +11,7 @@ import static org.mockito.Mockito.when; -public class IsDeviceConnectedToWifiNetworkTests extends BaseTestClass { - - public IsDeviceConnectedToWifiNetworkTests() { - super(TestActivity.class); - } +public class IsDeviceConnectedToWifiNetworkTests extends BaseAndroidJUnit4TestClass { @Test public void failure_missingPrerequisite() { diff --git a/wisefy/src/androidTest/java/com/isupatches/wisefy/IsDeviceRoamingTests.java b/wisefy/src/androidTest/java/com/isupatches/wisefy/IsDeviceRoamingTests.java index aa13ee8d..7e214cb1 100644 --- a/wisefy/src/androidTest/java/com/isupatches/wisefy/IsDeviceRoamingTests.java +++ b/wisefy/src/androidTest/java/com/isupatches/wisefy/IsDeviceRoamingTests.java @@ -2,7 +2,6 @@ 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; @@ -10,11 +9,7 @@ import static org.mockito.Mockito.when; -public class IsDeviceRoamingTests extends BaseTestClass { - - public IsDeviceRoamingTests() { - super(TestActivity.class); - } +public class IsDeviceRoamingTests extends BaseAndroidJUnit4TestClass { @Test public void failure_missingPrerequisite() { diff --git a/wisefy/src/androidTest/java/com/isupatches/wisefy/IsNetwork5gHzTests.java b/wisefy/src/androidTest/java/com/isupatches/wisefy/IsNetwork5gHzTests.java index 0e5622c8..0af93446 100644 --- a/wisefy/src/androidTest/java/com/isupatches/wisefy/IsNetwork5gHzTests.java +++ b/wisefy/src/androidTest/java/com/isupatches/wisefy/IsNetwork5gHzTests.java @@ -3,7 +3,6 @@ import android.net.wifi.WifiInfo; import android.os.Build; -import com.isupatches.wisefy.base.TestActivity; import org.junit.Test; import static com.isupatches.wisefy.base.TestUtils.TEST_NETWORK_FREQUENCY_5GHZ; import static com.isupatches.wisefy.base.TestUtils.TEST_NETWORK_FREQUENCY_ABOVE_5GHZ; @@ -13,11 +12,7 @@ import static org.mockito.Mockito.when; -public class IsNetwork5gHzTests extends BaseTestClass { - - public IsNetwork5gHzTests() { - super(TestActivity.class); - } +public class IsNetwork5gHzTests extends BaseAndroidJUnit4TestClass { @Test public void currentNetwork_failure_above5ghz() { diff --git a/wisefy/src/androidTest/java/com/isupatches/wisefy/IsNetworkEAPTests.java b/wisefy/src/androidTest/java/com/isupatches/wisefy/IsNetworkEAPTests.java index c67106a9..51a45406 100644 --- a/wisefy/src/androidTest/java/com/isupatches/wisefy/IsNetworkEAPTests.java +++ b/wisefy/src/androidTest/java/com/isupatches/wisefy/IsNetworkEAPTests.java @@ -2,18 +2,13 @@ import android.net.wifi.ScanResult; -import com.isupatches.wisefy.base.TestActivity; import com.isupatches.wisefy.constants.Capabilities; import org.junit.Test; import static org.junit.Assert.assertEquals; import static org.mockito.Mockito.mock; -public class IsNetworkEAPTests extends BaseTestClass { - - public IsNetworkEAPTests() { - super(TestActivity.class); - } +public class IsNetworkEAPTests extends BaseAndroidJUnit4TestClass { @Test public void failure_differentCapability() { diff --git a/wisefy/src/androidTest/java/com/isupatches/wisefy/IsNetworkInConfigurationListTests.java b/wisefy/src/androidTest/java/com/isupatches/wisefy/IsNetworkInConfigurationListTests.java index ee5bd639..b2981cd2 100644 --- a/wisefy/src/androidTest/java/com/isupatches/wisefy/IsNetworkInConfigurationListTests.java +++ b/wisefy/src/androidTest/java/com/isupatches/wisefy/IsNetworkInConfigurationListTests.java @@ -2,7 +2,6 @@ import android.net.wifi.WifiConfiguration; -import com.isupatches.wisefy.base.TestActivity; import org.junit.Test; import java.util.ArrayList; import java.util.List; @@ -13,11 +12,7 @@ import static org.mockito.Mockito.when; -public class IsNetworkInConfigurationListTests extends BaseTestClass { - - public IsNetworkInConfigurationListTests() { - super(TestActivity.class); - } +public class IsNetworkInConfigurationListTests extends BaseAndroidJUnit4TestClass { @Test public void failure() { diff --git a/wisefy/src/androidTest/java/com/isupatches/wisefy/IsNetworkPSKTest.java b/wisefy/src/androidTest/java/com/isupatches/wisefy/IsNetworkPSKTest.java index a2a75d78..5ac26f84 100644 --- a/wisefy/src/androidTest/java/com/isupatches/wisefy/IsNetworkPSKTest.java +++ b/wisefy/src/androidTest/java/com/isupatches/wisefy/IsNetworkPSKTest.java @@ -2,18 +2,13 @@ import android.net.wifi.ScanResult; -import com.isupatches.wisefy.base.TestActivity; import com.isupatches.wisefy.constants.Capabilities; import org.junit.Test; import static org.junit.Assert.assertEquals; import static org.mockito.Mockito.mock; -public class IsNetworkPSKTest extends BaseTestClass { - - public IsNetworkPSKTest() { - super(TestActivity.class); - } +public class IsNetworkPSKTest extends BaseAndroidJUnit4TestClass { @Test public void failure_differentCapability() { diff --git a/wisefy/src/androidTest/java/com/isupatches/wisefy/IsNetworkSecureTests.java b/wisefy/src/androidTest/java/com/isupatches/wisefy/IsNetworkSecureTests.java index a3b5abf7..cd3823ec 100644 --- a/wisefy/src/androidTest/java/com/isupatches/wisefy/IsNetworkSecureTests.java +++ b/wisefy/src/androidTest/java/com/isupatches/wisefy/IsNetworkSecureTests.java @@ -2,18 +2,13 @@ import android.net.wifi.ScanResult; -import com.isupatches.wisefy.base.TestActivity; import com.isupatches.wisefy.constants.Capabilities; import org.junit.Test; import static org.junit.Assert.assertEquals; import static org.mockito.Mockito.mock; -public class IsNetworkSecureTests extends BaseTestClass { - - public IsNetworkSecureTests() { - super(TestActivity.class); - } +public class IsNetworkSecureTests extends BaseAndroidJUnit4TestClass { @Test public void failure_emptyCapabilities() { diff --git a/wisefy/src/androidTest/java/com/isupatches/wisefy/IsNetworkWPA2Test.java b/wisefy/src/androidTest/java/com/isupatches/wisefy/IsNetworkWPA2Test.java index 02b9958c..48f98ada 100644 --- a/wisefy/src/androidTest/java/com/isupatches/wisefy/IsNetworkWPA2Test.java +++ b/wisefy/src/androidTest/java/com/isupatches/wisefy/IsNetworkWPA2Test.java @@ -2,18 +2,13 @@ import android.net.wifi.ScanResult; -import com.isupatches.wisefy.base.TestActivity; import com.isupatches.wisefy.constants.Capabilities; import org.junit.Test; import static org.junit.Assert.assertEquals; import static org.mockito.Mockito.mock; -public class IsNetworkWPA2Test extends BaseTestClass { - - public IsNetworkWPA2Test() { - super(TestActivity.class); - } +public class IsNetworkWPA2Test extends BaseAndroidJUnit4TestClass { @Test public void failure_differentCapability() { diff --git a/wisefy/src/androidTest/java/com/isupatches/wisefy/IsNetworkWPATests.java b/wisefy/src/androidTest/java/com/isupatches/wisefy/IsNetworkWPATests.java index 9ad82084..64793f87 100644 --- a/wisefy/src/androidTest/java/com/isupatches/wisefy/IsNetworkWPATests.java +++ b/wisefy/src/androidTest/java/com/isupatches/wisefy/IsNetworkWPATests.java @@ -2,18 +2,13 @@ import android.net.wifi.ScanResult; -import com.isupatches.wisefy.base.TestActivity; import com.isupatches.wisefy.constants.Capabilities; import org.junit.Test; import static junit.framework.Assert.assertEquals; import static org.mockito.Mockito.mock; -public class IsNetworkWPATests extends BaseTestClass { - - public IsNetworkWPATests() { - super(TestActivity.class); - } +public class IsNetworkWPATests extends BaseAndroidJUnit4TestClass { @Test public void failure_differentCapability() { diff --git a/wisefy/src/androidTest/java/com/isupatches/wisefy/IsNetworkWepTests.java b/wisefy/src/androidTest/java/com/isupatches/wisefy/IsNetworkWepTests.java index 5b46f961..e94e8d90 100644 --- a/wisefy/src/androidTest/java/com/isupatches/wisefy/IsNetworkWepTests.java +++ b/wisefy/src/androidTest/java/com/isupatches/wisefy/IsNetworkWepTests.java @@ -2,18 +2,13 @@ import android.net.wifi.ScanResult; -import com.isupatches.wisefy.base.TestActivity; import com.isupatches.wisefy.constants.Capabilities; import org.junit.Test; import static org.junit.Assert.assertEquals; import static org.mockito.Mockito.mock; -public class IsNetworkWepTests extends BaseTestClass { - - public IsNetworkWepTests() { - super(TestActivity.class); - } +public class IsNetworkWepTests extends BaseAndroidJUnit4TestClass { @Test public void failure_differentCapability() { diff --git a/wisefy/src/androidTest/java/com/isupatches/wisefy/IsWifiEnabledTests.java b/wisefy/src/androidTest/java/com/isupatches/wisefy/IsWifiEnabledTests.java index 97b0e028..25bb11cb 100644 --- a/wisefy/src/androidTest/java/com/isupatches/wisefy/IsWifiEnabledTests.java +++ b/wisefy/src/androidTest/java/com/isupatches/wisefy/IsWifiEnabledTests.java @@ -1,17 +1,12 @@ package com.isupatches.wisefy; -import com.isupatches.wisefy.base.TestActivity; import org.junit.Test; import static org.junit.Assert.assertEquals; import static org.mockito.Mockito.when; -public class IsWifiEnabledTests extends BaseTestClass { - - public IsWifiEnabledTests() { - super(TestActivity.class); - } +public class IsWifiEnabledTests extends BaseAndroidJUnit4TestClass { @Test public void failure() { diff --git a/wisefy/src/androidTest/java/com/isupatches/wisefy/ManagerUtilTest.java b/wisefy/src/androidTest/java/com/isupatches/wisefy/ManagerUtilTest.java index 64e125b5..43a8da60 100644 --- a/wisefy/src/androidTest/java/com/isupatches/wisefy/ManagerUtilTest.java +++ b/wisefy/src/androidTest/java/com/isupatches/wisefy/ManagerUtilTest.java @@ -3,26 +3,17 @@ import android.net.ConnectivityManager; import android.net.wifi.WifiManager; -import android.support.test.rule.ActivityTestRule; -import com.isupatches.wisefy.base.TestActivity; +import android.support.test.InstrumentationRegistry; import com.isupatches.wisefy.util.ManagerUtil; -import org.junit.Rule; import org.junit.Test; import static junit.framework.Assert.*; -public class ManagerUtilTest extends BaseTestClass { - - public ManagerUtilTest() { - super(TestActivity.class); - } - - @Rule - public ActivityTestRule mActivityTestRule = new ActivityTestRule<>(TestActivity.class); +public class ManagerUtilTest extends BaseAndroidJUnit4TestClass { @Test public void getConnectivityManager_returnsNotNull() { - ConnectivityManager connectivityManager = ManagerUtil.getInstance().getConnectivityManager(mActivityTestRule.getActivity()); + ConnectivityManager connectivityManager = ManagerUtil.getInstance().getConnectivityManager(InstrumentationRegistry.getContext()); assertNotNull(connectivityManager); } @@ -34,7 +25,7 @@ public void getConnectivityManager_returnsNull_noActivity() { @Test public void getWiFiManager_returnsNotNull() { - WifiManager wifiManager = ManagerUtil.getInstance().getWiFiManager(mActivityTestRule.getActivity()); + WifiManager wifiManager = ManagerUtil.getInstance().getWiFiManager(InstrumentationRegistry.getContext()); assertNotNull(wifiManager); } diff --git a/wisefy/src/androidTest/java/com/isupatches/wisefy/RemoveNetworkTests.java b/wisefy/src/androidTest/java/com/isupatches/wisefy/RemoveNetworkTests.java index 942aa1ca..ae3f5a42 100644 --- a/wisefy/src/androidTest/java/com/isupatches/wisefy/RemoveNetworkTests.java +++ b/wisefy/src/androidTest/java/com/isupatches/wisefy/RemoveNetworkTests.java @@ -2,7 +2,6 @@ import android.net.wifi.WifiConfiguration; -import com.isupatches.wisefy.base.TestActivity; import com.isupatches.wisefy.callbacks.RemoveNetworkCallbacks; import com.isupatches.wisefy.constants.WiseFyCodes; import org.junit.Test; @@ -18,11 +17,7 @@ import static org.mockito.Mockito.when; -public class RemoveNetworkTests extends BaseTestClass { - - public RemoveNetworkTests() { - super(TestActivity.class); - } +public class RemoveNetworkTests extends BaseAndroidJUnit4TestClass { @Test public void noCallbacks_failure_nullSSIDParam() { diff --git a/wisefy/src/androidTest/java/com/isupatches/wisefy/SearchForAccessPointTests.java b/wisefy/src/androidTest/java/com/isupatches/wisefy/SearchForAccessPointTests.java index 4381be0a..b83f885f 100644 --- a/wisefy/src/androidTest/java/com/isupatches/wisefy/SearchForAccessPointTests.java +++ b/wisefy/src/androidTest/java/com/isupatches/wisefy/SearchForAccessPointTests.java @@ -2,7 +2,6 @@ import android.net.wifi.ScanResult; -import com.isupatches.wisefy.base.TestActivity; import com.isupatches.wisefy.callbacks.SearchForAccessPointCallbacks; import com.isupatches.wisefy.constants.WiseFyCodes; import org.junit.Test; @@ -18,11 +17,7 @@ import static org.mockito.Mockito.when; -public class SearchForAccessPointTests extends BaseTestClass { - - public SearchForAccessPointTests() { - super(TestActivity.class); - } +public class SearchForAccessPointTests extends BaseAndroidJUnit4TestClass{ @Test public void noCallbacks_failure_filterDuplicates_false_nullSSIDParam() { diff --git a/wisefy/src/androidTest/java/com/isupatches/wisefy/SearchForAccessPointsTests.java b/wisefy/src/androidTest/java/com/isupatches/wisefy/SearchForAccessPointsTests.java index 6c60c5aa..7a073b3a 100644 --- a/wisefy/src/androidTest/java/com/isupatches/wisefy/SearchForAccessPointsTests.java +++ b/wisefy/src/androidTest/java/com/isupatches/wisefy/SearchForAccessPointsTests.java @@ -19,11 +19,7 @@ import static org.mockito.Mockito.when; -public class SearchForAccessPointsTests extends BaseTestClass { - - public SearchForAccessPointsTests() { - super(TestActivity.class); - } +public class SearchForAccessPointsTests extends BaseAndroidJUnit4TestClass { @Test public void noCallbacks_failure_filterDuplicates_false_nullSSIDParam() { diff --git a/wisefy/src/androidTest/java/com/isupatches/wisefy/SearchForSSIDTests.java b/wisefy/src/androidTest/java/com/isupatches/wisefy/SearchForSSIDTests.java index a69a2648..947b92df 100644 --- a/wisefy/src/androidTest/java/com/isupatches/wisefy/SearchForSSIDTests.java +++ b/wisefy/src/androidTest/java/com/isupatches/wisefy/SearchForSSIDTests.java @@ -2,7 +2,6 @@ import android.net.wifi.ScanResult; -import com.isupatches.wisefy.base.TestActivity; import com.isupatches.wisefy.callbacks.SearchForSSIDCallbacks; import com.isupatches.wisefy.constants.WiseFyCodes; import org.junit.Test; @@ -18,11 +17,7 @@ import static org.mockito.Mockito.when; -public class SearchForSSIDTests extends BaseTestClass { - - public SearchForSSIDTests() { - super(TestActivity.class); - } +public class SearchForSSIDTests extends BaseAndroidJUnit4TestClass { @Test public void noCallbacks_failure_nullSSIDParam() { diff --git a/wisefy/src/androidTest/java/com/isupatches/wisefy/SearchForSSIDsTests.java b/wisefy/src/androidTest/java/com/isupatches/wisefy/SearchForSSIDsTests.java index 13cad278..0e241871 100644 --- a/wisefy/src/androidTest/java/com/isupatches/wisefy/SearchForSSIDsTests.java +++ b/wisefy/src/androidTest/java/com/isupatches/wisefy/SearchForSSIDsTests.java @@ -1,7 +1,6 @@ package com.isupatches.wisefy; -import com.isupatches.wisefy.base.TestActivity; import com.isupatches.wisefy.callbacks.SearchForSSIDsCallbacks; import com.isupatches.wisefy.constants.WiseFyCodes; import org.junit.Test; @@ -17,11 +16,7 @@ import static org.mockito.Mockito.when; -public class SearchForSSIDsTests extends BaseTestClass { - - public SearchForSSIDsTests() { - super(TestActivity.class); - } +public class SearchForSSIDsTests extends BaseAndroidJUnit4TestClass { @Test public void noCallbacks_failure_nullSSIDParam() { diff --git a/wisefy/src/androidTest/java/com/isupatches/wisefy/WiseFyConnectionTests.java b/wisefy/src/androidTest/java/com/isupatches/wisefy/WiseFyConnectionTests.java index a5f96d2d..e721eb62 100644 --- a/wisefy/src/androidTest/java/com/isupatches/wisefy/WiseFyConnectionTests.java +++ b/wisefy/src/androidTest/java/com/isupatches/wisefy/WiseFyConnectionTests.java @@ -3,7 +3,6 @@ import android.net.NetworkInfo; import android.net.wifi.WifiInfo; -import com.isupatches.wisefy.base.TestActivity; import org.junit.Before; import org.junit.Test; import static com.isupatches.wisefy.base.TestUtils.TEST_SSID; @@ -16,11 +15,7 @@ import static org.mockito.Mockito.when; -public class WiseFyConnectionTests extends BaseTestClass { - - public WiseFyConnectionTests() { - super(TestActivity.class); - } +public class WiseFyConnectionTests extends BaseAndroidJUnit4TestClass { @Before public void setUp() { diff --git a/wisefy/src/androidTest/java/com/isupatches/wisefy/WiseFyPrerequisitesTests.java b/wisefy/src/androidTest/java/com/isupatches/wisefy/WiseFyPrerequisitesTests.java index aa94e8bc..f3f17a3d 100644 --- a/wisefy/src/androidTest/java/com/isupatches/wisefy/WiseFyPrerequisitesTests.java +++ b/wisefy/src/androidTest/java/com/isupatches/wisefy/WiseFyPrerequisitesTests.java @@ -1,16 +1,11 @@ package com.isupatches.wisefy; -import com.isupatches.wisefy.base.TestActivity; import org.junit.Test; import static junit.framework.Assert.*; -public class WiseFyPrerequisitesTests extends BaseTestClass { - - public WiseFyPrerequisitesTests() { - super(TestActivity.class); - } +public class WiseFyPrerequisitesTests extends BaseAndroidJUnit4TestClass { @Test public void hasPrerequisites_nullWifiManager() { diff --git a/wisefy/src/androidTest/java/com/isupatches/wisefy/WiseFySearchTests.java b/wisefy/src/androidTest/java/com/isupatches/wisefy/WiseFySearchTests.java index eb786da6..a69d045a 100644 --- a/wisefy/src/androidTest/java/com/isupatches/wisefy/WiseFySearchTests.java +++ b/wisefy/src/androidTest/java/com/isupatches/wisefy/WiseFySearchTests.java @@ -3,7 +3,6 @@ import android.net.wifi.ScanResult; import android.net.wifi.WifiConfiguration; -import com.isupatches.wisefy.base.TestActivity; import org.junit.Test; import java.util.ArrayList; import java.util.List; @@ -15,11 +14,8 @@ import static org.mockito.Mockito.when; -public class WiseFySearchTests extends BaseTestClass { +public class WiseFySearchTests extends BaseAndroidJUnit4TestClass { - public WiseFySearchTests() { - super(TestActivity.class); - } /* * findAccessPointByRegex tests diff --git a/wisefy/src/androidTest/java/com/isupatches/wisefy/WiseFyTests.java b/wisefy/src/androidTest/java/com/isupatches/wisefy/WiseFyTests.java index c435d876..a1acaabb 100644 --- a/wisefy/src/androidTest/java/com/isupatches/wisefy/WiseFyTests.java +++ b/wisefy/src/androidTest/java/com/isupatches/wisefy/WiseFyTests.java @@ -1,28 +1,25 @@ package com.isupatches.wisefy; +import android.support.test.InstrumentationRegistry; + import com.google.android.gms.iid.InstanceID; -import com.isupatches.wisefy.base.TestActivity; import org.junit.Test; import static org.junit.Assert.*; -public class WiseFyTests extends BaseTestClass { - - public WiseFyTests() { - super(TestActivity.class); - } +public class WiseFyTests extends BaseAndroidJUnit4TestClass { @Test public void builder_loggingFalse() { - WiseFy wiseFy = new WiseFy.brains(mActivityTestRule.getActivity()).logging(false).getSmarts(); + WiseFy wiseFy = new WiseFy.brains(InstrumentationRegistry.getContext()).logging(false).getSmarts(); assertEquals(false, wiseFy.mWiseFyConfiguration.isLoggingEnabled()); assertEquals(false, wiseFy.isLoggingEnabled()); } @Test public void builder_loggingTrue() { - WiseFy wiseFy = new WiseFy.brains(mActivityTestRule.getActivity()).logging(true).getSmarts(); + WiseFy wiseFy = new WiseFy.brains(InstrumentationRegistry.getContext()).logging(true).getSmarts(); assertEquals(true, wiseFy.mWiseFyConfiguration.isLoggingEnabled()); assertEquals(true, wiseFy.isLoggingEnabled()); } @@ -41,7 +38,7 @@ public void compareSignalLevel() { @Test public void olderGcm_IllegalAccessError_notThrown() { - InstanceID instanceID = InstanceID.getInstance(mActivityTestRule.getActivity()); + InstanceID instanceID = InstanceID.getInstance(InstrumentationRegistry.getContext()); assertNotNull(instanceID); } } \ No newline at end of file diff --git a/wisefy/src/androidTest/java/com/isupatches/wisefy/test/BuilderTests.java b/wisefy/src/androidTest/java/com/isupatches/wisefy/test/BuilderTests.java index d90be9cb..041e3edf 100644 --- a/wisefy/src/androidTest/java/com/isupatches/wisefy/test/BuilderTests.java +++ b/wisefy/src/androidTest/java/com/isupatches/wisefy/test/BuilderTests.java @@ -1,32 +1,23 @@ package com.isupatches.wisefy.test; -import android.support.test.rule.ActivityTestRule; +import android.support.test.InstrumentationRegistry; import com.isupatches.wisefy.WiseFy; -import com.isupatches.wisefy.base.TestActivity; -import org.junit.Rule; import org.junit.Test; import static org.junit.Assert.assertEquals; -public class BuilderTests extends ActivityTestRule { - - @Rule - public ActivityTestRule mActivityTestRule = new ActivityTestRule<>(TestActivity.class); - - public BuilderTests() { - super(TestActivity.class); - } +public class BuilderTests { @Test public void builder_loggingFalse() { - WiseFy wiseFy = new WiseFy.brains(mActivityTestRule.getActivity()).logging(false).getSmarts(); + WiseFy wiseFy = new WiseFy.brains(InstrumentationRegistry.getContext()).logging(false).getSmarts(); assertEquals(false, wiseFy.isLoggingEnabled()); } @Test public void builder_loggingTrue() { - WiseFy wiseFy = new WiseFy.brains(mActivityTestRule.getActivity()).logging(true).getSmarts(); + WiseFy wiseFy = new WiseFy.brains(InstrumentationRegistry.getContext()).logging(true).getSmarts(); assertEquals(true, wiseFy.isLoggingEnabled()); } } diff --git a/wisefy/src/androidTest/java/com/isupatches/wisefy/test/PublicApiVisibilityTests.java b/wisefy/src/test/java/com/isupatches/wisefy/test/PublicApiVisibilityTests.java similarity index 97% rename from wisefy/src/androidTest/java/com/isupatches/wisefy/test/PublicApiVisibilityTests.java rename to wisefy/src/test/java/com/isupatches/wisefy/test/PublicApiVisibilityTests.java index 19bccbeb..5ea07b6b 100644 --- a/wisefy/src/androidTest/java/com/isupatches/wisefy/test/PublicApiVisibilityTests.java +++ b/wisefy/src/test/java/com/isupatches/wisefy/test/PublicApiVisibilityTests.java @@ -1,13 +1,10 @@ package com.isupatches.wisefy.test; -import android.content.Intent; import android.net.wifi.ScanResult; import android.net.wifi.WifiConfiguration; import android.net.wifi.WifiInfo; -import android.support.test.rule.ActivityTestRule; import com.isupatches.wisefy.WiseFy; -import com.isupatches.wisefy.base.TestActivity; import com.isupatches.wisefy.callbacks.AddOpenNetworkCallbacks; import com.isupatches.wisefy.callbacks.AddWEPNetworkCallbacks; import com.isupatches.wisefy.callbacks.AddWPA2NetworkCallbacks; @@ -27,7 +24,6 @@ import com.isupatches.wisefy.callbacks.SearchForSSIDCallbacks; import com.isupatches.wisefy.callbacks.SearchForSSIDsCallbacks; import org.junit.Before; -import org.junit.Rule; import org.junit.Test; import java.util.List; import static junit.framework.Assert.assertEquals; @@ -39,21 +35,12 @@ import static org.mockito.Mockito.verify; -public class PublicApiVisibilityTests extends ActivityTestRule { - - @Rule - public ActivityTestRule mActivityTestRule = new ActivityTestRule<>(TestActivity.class); +public class PublicApiVisibilityTests { private WiseFy mWiseFy; - public PublicApiVisibilityTests() { - super(TestActivity.class); - } - @Before public void setUp() { - mActivityTestRule.launchActivity(new Intent()); - mWiseFy = mock(WiseFy.class); }