diff --git a/.circleci/config.yml b/.circleci/config.yml index 22e7b11b..33e4fc47 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -7,7 +7,7 @@ jobs: ci_checks: working_directory: ~/code docker: - - image: circleci/android:api-28-alpha + - image: circleci/android:api-29 environment: JVM_OPTS: -Xmx3200m steps: diff --git a/.github/ISSUE_TEMPLATE/bug-report.md b/.github/ISSUE_TEMPLATE/bug-report.md index f7f69d36..f5687b64 100644 --- a/.github/ISSUE_TEMPLATE/bug-report.md +++ b/.github/ISSUE_TEMPLATE/bug-report.md @@ -30,8 +30,8 @@ A description of what you expected to happen. A description of what actually happened **Additional Information** - - Device (i.e. Nexus 5x): - - OS Version (i.e. Android 8.1): + - Device (f.e. Nexus 5x): + - OS Version (f.e. Android 8.1): - Rooted: - Using legacy connection logic?: - Using legacy search logic?: diff --git a/.github/ISSUE_TEMPLATE/feature-request.md b/.github/ISSUE_TEMPLATE/feature-request.md index 6e123b74..0fa5221e 100644 --- a/.github/ISSUE_TEMPLATE/feature-request.md +++ b/.github/ISSUE_TEMPLATE/feature-request.md @@ -7,13 +7,13 @@ about: Suggest an idea for this project Thank you for creating an issue to improve this library! Please check Please check [the current issues](https://github.com/isuPatches/WiseFy/issues) to make sure that the improvement isn't already being worked on. **Description** -A clear and concise high-level description of the request. (i.e. As a developer I want ___ so that ___) +A clear and concise high-level description of the request. (f.e. As a developer I want ___ so that ___) **Reason** A brief explanation as to why it matters to you and your project. **Acceptance Criteria** -Describe in more detail the request. (i.e. - a method is added to the library, - the method when called does ___, etc.) +Describe in more detail the request. (f.e. - a method is added to the library, - the method when called does ___, etc.) **Additional context** Add any other context about the request here. diff --git a/.gitignore b/.gitignore index 9e2f1274..b9341982 100644 --- a/.gitignore +++ b/.gitignore @@ -6,4 +6,5 @@ /.idea/*.xml /.idea/caches/* -/.idea/libraries/* \ No newline at end of file +/.idea/libraries/* +/.idea/codestyles/* diff --git a/.idea/dictionaries/patches.xml b/.idea/dictionaries/patches.xml index f7cb0dd3..7dd9b639 100644 --- a/.idea/dictionaries/patches.xml +++ b/.idea/dictionaries/patches.xml @@ -3,8 +3,10 @@ inet isupatches + klinefelter precheck prechecks + robo rssi runnables ssid diff --git a/.idea/inspectionProfiles/Project_Default.xml b/.idea/inspectionProfiles/Project_Default.xml new file mode 100644 index 00000000..d22ce367 --- /dev/null +++ b/.idea/inspectionProfiles/Project_Default.xml @@ -0,0 +1,176 @@ + + + + \ No newline at end of file diff --git a/README.md b/README.md index 38f37d08..c083e5c4 100644 --- a/README.md +++ b/README.md @@ -157,12 +157,12 @@ For the sake of transparency and because you're probably curious as to what perm - + ``` * NOTE * -If access points or SSIDs are not being returned on >= 6.x devices but there are visible networks, it's most likely because you haven't asked in your application for the `Manifest.permission.ACCESS_COARSE_LOCATION` permission which is what allows us to see the access points nearby. This permission request will not be added to the WiseFy library to reduce package bloat and so users can determine their own UI/UX. +If access points or SSIDs are not being returned on >= 6.x devices but there are visible networks, it's most likely because you haven't asked in your application for the `Manifest.permission.ACCESS_FINE_LOCATION` permission which is what allows us to see the access points nearby. This permission request will not be added to the WiseFy library to reduce package bloat and so users can determine their own UI/UX. Please check [the sample app](/wisefysample) for an example of how to request permissions for WiseFy. diff --git a/build.gradle b/build.gradle index fad7f9dd..1687729e 100644 --- a/build.gradle +++ b/build.gradle @@ -1,12 +1,13 @@ buildscript { + project.ext { - agp_version = '3.4.1' + agp_version = '3.5.3' bintray_version = '1.8.4' - cpd_version = '2.0' + cpd_version = '3.1' dokka_version = '0.9.18' - dexcount_version = '0.8.5' - jacoco_version = '0.8.3' - kotlin_version = "1.3.40" + dexcount_version = '1.0.0' + jacoco_version = '0.8.5' + kotlin_version = "1.3.61" maven_version = '2.1' } @@ -37,8 +38,8 @@ buildscript { } plugins { - id "io.gitlab.arturbosch.detekt" version "1.0.0-RC14" - id "org.jlleitschuh.gradle.ktlint" version "7.3.0" + id "io.gitlab.arturbosch.detekt" version "1.2.2" + id "org.jlleitschuh.gradle.ktlint" version "9.1.1" } apply from: rootProject.file("$rootProject.projectDir/gradle/versions.gradle") @@ -84,7 +85,7 @@ task clean(type: Delete) { project.ext.preDexLibs = !project.hasProperty('disablePreDex') subprojects { - project.plugins.whenPluginAdded { plugin -> + project.plugins.whenPluginAdded { final plugin -> if (rootProject.ext.has('preDexLibs')) { if ("com.android.build.gradle.AppPlugin" == plugin.class.name) { project.android.dexOptions.preDexLibraries = rootProject.ext.preDexLibs @@ -127,11 +128,11 @@ ext { POM_DEVELOPER_EMAIL = "isuPatches@yahoo.com" // Common build version details - BUILD_TOOLS_VERSION = '28.0.3' + BUILD_TOOLS_VERSION = '29.0.2' MAX_SDK_VERSION = 28 MIN_SDK_VERSION = 16 - VERSION_CODE = 14 - VERSION_NAME = "4.0.0" + VERSION_CODE = 15 + VERSION_NAME = "4.1.0" } task makeGoodChoices { @@ -147,4 +148,4 @@ task makeGoodChoices { "\n# You may now push the awesome to origin :) #" + "\n#############################################" } -} \ No newline at end of file +} diff --git a/gradle.properties b/gradle.properties index d11bb024..8c2e47de 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,7 +1,6 @@ -org.gradle.jvmargs=-Xmx1g -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 - # Android X: https://developer.android.com/topic/libraries/support-library/androidx-rn android.enableJetifier=true android.useAndroidX=true org.gradle.caching=false +org.gradle.jvmargs=-Xmx1g -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 diff --git a/gradle/gradle-bintray-upload.gradle b/gradle/gradle-bintray-upload.gradle index 92e6fe34..bfda33b0 100644 --- a/gradle/gradle-bintray-upload.gradle +++ b/gradle/gradle-bintray-upload.gradle @@ -34,19 +34,19 @@ artifacts { } // Bintray -Properties properties = new Properties() +final Properties properties = new Properties() if (project.rootProject.file('local.properties').exists()) { properties.load(project.rootProject.file('local.properties').newDataInputStream()) } bintray { - user = properties.getProperty("bintray.user") key = properties.getProperty("bintray.apikey") - def gpg_passphrase = properties.getProperty("bintray.gpg_passphrase") + user = properties.getProperty("bintray.user") + final def gpgPassphrase = properties.getProperty("bintray.gpg_passphrase") println("user: " + user) println("key: " + key) - println("gpg_passphrase: " + gpg_passphrase) + println("gpg_passphrase: " + gpgPassphrase) configurations = ['archives'] @@ -65,7 +65,7 @@ bintray { desc = LIBRARY_DESCRIPTION gpg { sign = true // Determines whether to GPG sign the files. The default is false - passphrase = gpg_passphrase + passphrase = gpgPassphrase // Optional. The passphrase for GPG signing' } } diff --git a/gradle/jacoco.gradle b/gradle/jacoco.gradle index ca9b4caf..89d2c679 100644 --- a/gradle/jacoco.gradle +++ b/gradle/jacoco.gradle @@ -4,9 +4,9 @@ jacoco { toolVersion = "$jacoco_version" } -def srcDirs = ["src/main/java"] +final def srcDirs = ["src/main/java"] -def excludes = [ +final def excludes = [ '**/R.class', '**/R$*.class', '**/*$ViewBinder*.*', @@ -20,9 +20,9 @@ def excludes = [ ] project.afterEvaluate { - def variants = getVariants() + final def variants = getVariants() if (variants != null) { - variants.all { variant -> + variants.all { final variant -> if (variant.name.toLowerCase().contains("release")) { return } @@ -140,12 +140,12 @@ project.afterEvaluate { } } -private def getClassDirs(String javaDirSuffix, String kotlinDirSuffix, excludes) { - def java = fileTree( +private def getClassDirs(final String javaDirSuffix, final String kotlinDirSuffix, final excludes) { + final def java = fileTree( dir: "${buildDir}/intermediates/classes/${javaDirSuffix}", excludes: excludes ) - def kotlin = fileTree( + final def kotlin = fileTree( dir: "${buildDir}/tmp/kotlin-classes/${kotlinDirSuffix}", excludes: excludes ) diff --git a/gradle/ktlint.gradle b/gradle/ktlint.gradle index 46765a18..3ca52e74 100644 --- a/gradle/ktlint.gradle +++ b/gradle/ktlint.gradle @@ -3,6 +3,10 @@ ktlint { debug = true verbose = true android = true - reporters = ["PLAIN", "CHECKSTYLE"] + reporters { + reporter "plain" + reporter "checkstyle" + + } ignoreFailures = false -} \ No newline at end of file +} diff --git a/gradle/versions.gradle b/gradle/versions.gradle index afd91bcc..715cfc82 100644 --- a/gradle/versions.gradle +++ b/gradle/versions.gradle @@ -1,25 +1,25 @@ ext { - androidx_appcompat_version = "1.1.0-beta01" - androidx_constraintlayout_version = "2.0.0-beta2" + androidx_appcompat_version = "1.1.0" + androidx_constraintlayout_version = "2.0.0-beta4" androidx_support_annotations_version = '1.0.0' - androidx_core_ktx_version = '1.0.2' + androidx_core_ktx_version = '1.1.0' androidx_core_test_version = '1.1.0' - google_android_material_version = "1.1.0-alpha07" + google_android_material_version = "1.2.0-alpha03" - dagger_version = "2.23.2" + dagger_version = "2.25.4" - detekt_version = "1.0.0-RC15" - ktlint_version = "0.33.0" + detekt_version = "1.3.1" + ktlint_version = "0.36.0" rxandroid_version = '2.1.1' - rxjava_version = '2.2.10' + rxjava_version = '2.2.15' // Test deps junit_version = '4.12' - mockito_version = '2.28.2' - mockito_kotlin_version = '2.1.0' + mockito_version = '3.2.4' + mockito_kotlin_version = '2.2.0' - androidx_espresso_core_version = '3.1.1' - androidx_test_runner_version = "1.1.1" + androidx_espresso_core_version = '3.2.0' + androidx_test_runner_version = '1.2.0' } \ No newline at end of file diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index 5c2d1cf0..cc4fdc29 100644 Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index ee69dd68..1ba7206f 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-6.0.1-all.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/gradlew b/gradlew index b0d6d0ab..2fe81a7d 100755 --- a/gradlew +++ b/gradlew @@ -7,7 +7,7 @@ # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # -# http://www.apache.org/licenses/LICENSE-2.0 +# https://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, @@ -125,8 +125,8 @@ if $darwin; then GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" fi -# For Cygwin, switch paths to Windows format before running java -if $cygwin ; then +# For Cygwin or MSYS, switch paths to Windows format before running java +if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then APP_HOME=`cygpath --path --mixed "$APP_HOME"` CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` JAVACMD=`cygpath --unix "$JAVACMD"` @@ -154,19 +154,19 @@ if $cygwin ; then else eval `echo args$i`="\"$arg\"" fi - i=$((i+1)) + i=`expr $i + 1` done case $i in - (0) set -- ;; - (1) set -- "$args0" ;; - (2) set -- "$args0" "$args1" ;; - (3) set -- "$args0" "$args1" "$args2" ;; - (4) set -- "$args0" "$args1" "$args2" "$args3" ;; - (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; - (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; - (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; - (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; - (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; + 0) set -- ;; + 1) set -- "$args0" ;; + 2) set -- "$args0" "$args1" ;; + 3) set -- "$args0" "$args1" "$args2" ;; + 4) set -- "$args0" "$args1" "$args2" "$args3" ;; + 5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; + 6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; + 7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; + 8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; + 9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; esac fi @@ -175,14 +175,9 @@ save () { for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done echo " " } -APP_ARGS=$(save "$@") +APP_ARGS=`save "$@"` # Collect all arguments for the java command, following the shell quoting and substitution rules eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" -# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong -if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then - cd "$(dirname "$0")" -fi - exec "$JAVACMD" "$@" diff --git a/gradlew.bat b/gradlew.bat index 15e1ee37..24467a14 100644 --- a/gradlew.bat +++ b/gradlew.bat @@ -5,7 +5,7 @@ @rem you may not use this file except in compliance with the License. @rem You may obtain a copy of the License at @rem -@rem http://www.apache.org/licenses/LICENSE-2.0 +@rem https://www.apache.org/licenses/LICENSE-2.0 @rem @rem Unless required by applicable law or agreed to in writing, software @rem distributed under the License is distributed on an "AS IS" BASIS, diff --git a/wisefy/build.gradle b/wisefy/build.gradle index 6780ed4c..5dac85a6 100644 --- a/wisefy/build.gradle +++ b/wisefy/build.gradle @@ -54,8 +54,7 @@ android { showAll true explainIssues true abortOnError true - // UnusedIds is disabled for Kotlin synthetics and MissingRegistered is disabled for androidx. - disable 'UnusedIds', 'MissingRegistered' + disable 'UnusedIds' // UnusedIds is disabled for Kotlin synthetics } testOptions { @@ -74,7 +73,7 @@ android { } sourceSets { - def commonTestDir = 'src/commonTest/java' + final def commonTestDir = 'src/commonTest/java' test { java.srcDir commonTestDir } @@ -85,7 +84,6 @@ android { } dependencies { - implementation fileTree(dir: 'libs', include: ['*.jar']) implementation "androidx.annotation:annotation:$androidx_support_annotations_version" // Kotlin diff --git a/wisefy/consumer-proguard-rules.pro b/wisefy/consumer-proguard-rules.pro index 2d69fd1f..e69de29b 100644 --- a/wisefy/consumer-proguard-rules.pro +++ b/wisefy/consumer-proguard-rules.pro @@ -1,2 +0,0 @@ --keep class com.isupatches.wisefy.** { *; } --keep public interface com.isupatches.wisefy.** { *; } \ No newline at end of file diff --git a/wisefy/proguard-rules.pro b/wisefy/proguard-rules.pro index 49c4e946..a252efb7 100644 --- a/wisefy/proguard-rules.pro +++ b/wisefy/proguard-rules.pro @@ -1,6 +1,3 @@ -verbose -dontobfuscate - --keep class com.isupatches.wisefy.** { *; } --keep public interface com.isupatches.wisefy.** { *; } diff --git a/wisefy/proguard-test-rules.pro b/wisefy/proguard-test-rules.pro index e69de29b..f22ec8b2 100644 --- a/wisefy/proguard-test-rules.pro +++ b/wisefy/proguard-test-rules.pro @@ -0,0 +1 @@ +-include proguard-rules.pro diff --git a/wisefy/src/androidTest/java/com/isupatches/wisefy/AddOpenNetworkTests.kt b/wisefy/src/androidTest/java/com/isupatches/wisefy/AddOpenNetworkTests.kt index 46b986cd..4d268987 100644 --- a/wisefy/src/androidTest/java/com/isupatches/wisefy/AddOpenNetworkTests.kt +++ b/wisefy/src/androidTest/java/com/isupatches/wisefy/AddOpenNetworkTests.kt @@ -4,11 +4,9 @@ import com.isupatches.wisefy.WiseFy.Companion.WIFI_MANAGER_FAILURE import com.isupatches.wisefy.callbacks.AddNetworkCallbacks import com.isupatches.wisefy.constants.MISSING_PARAMETER import com.isupatches.wisefy.internal.base.BaseInstrumentationTest - import org.junit.Assert.assertEquals import org.junit.Assert.assertNotEquals import org.junit.Test - import org.mockito.Mockito.mock import org.mockito.Mockito.timeout import org.mockito.Mockito.verify @@ -21,27 +19,31 @@ import org.mockito.Mockito.verify */ internal class AddOpenNetworkTests : BaseInstrumentationTest() { - @Test fun sync_failure_prechecks() { + @Test + fun sync_failure_prechecks() { mockWiseFyPrechecksUtil.addNetwork_failure() assertEquals(MISSING_PARAMETER, wisefy.addOpenNetwork(OPEN_NETWORK_SSID)) verificationUtil.didNoTryToAddNetwork() } - @Test fun sync_failure() { + @Test + fun sync_failure() { mockWiseFyPrechecksUtil.addNetwork_success() mockNetworkUtil.addNetwork_failure() assertEquals(WIFI_MANAGER_FAILURE, wisefy.addOpenNetwork(OPEN_NETWORK_SSID)) verificationUtil.triedToAddNetwork() } - @Test fun sync_success() { + @Test + fun sync_success() { mockWiseFyPrechecksUtil.addNetwork_success() mockNetworkUtil.addNetwork_success() assertNotEquals(WIFI_MANAGER_FAILURE, wisefy.addOpenNetwork(OPEN_NETWORK_SSID)) verificationUtil.triedToAddNetwork() } - @Test fun async_failure_prechecks() { + @Test + fun async_failure_prechecks() { mockWiseFyPrechecksUtil.addNetwork_failure() val mockCallbacks = mock(AddNetworkCallbacks::class.java) wisefy.addOpenNetwork(OPEN_NETWORK_SSID, mockCallbacks) @@ -49,13 +51,15 @@ internal class AddOpenNetworkTests : BaseInstrumentationTest() { verificationUtil.didNoTryToAddNetwork() } - @Test fun async_failure_prechecks_nullCallback() { + @Test + fun async_failure_prechecks_nullCallback() { mockWiseFyPrechecksUtil.addNetwork_failure() nullCallbackUtil.callAddOpenNetwork(OPEN_NETWORK_SSID) verificationUtil.didNoTryToAddNetwork() } - @Test fun async_failure() { + @Test + fun async_failure() { mockWiseFyPrechecksUtil.addNetwork_success() mockNetworkUtil.addNetwork_failure() val mockCallbacks = mock(AddNetworkCallbacks::class.java) @@ -64,14 +68,16 @@ internal class AddOpenNetworkTests : BaseInstrumentationTest() { verificationUtil.triedToAddNetwork() } - @Test fun async_failure_nullCallback() { + @Test + fun async_failure_nullCallback() { mockWiseFyPrechecksUtil.addNetwork_success() mockNetworkUtil.addNetwork_failure() nullCallbackUtil.callAddOpenNetwork(OPEN_NETWORK_SSID) verificationUtil.triedToAddNetwork() } - @Test fun async_success() { + @Test + fun async_success() { mockWiseFyPrechecksUtil.addNetwork_success() mockNetworkUtil.addNetwork_success() val mockCallbacks = mock(AddNetworkCallbacks::class.java) @@ -80,7 +86,8 @@ internal class AddOpenNetworkTests : BaseInstrumentationTest() { verificationUtil.triedToAddNetwork() } - @Test fun async_success_nullCallback() { + @Test + fun async_success_nullCallback() { mockWiseFyPrechecksUtil.addNetwork_success() mockNetworkUtil.addNetwork_success() nullCallbackUtil.callAddOpenNetwork(OPEN_NETWORK_SSID) diff --git a/wisefy/src/androidTest/java/com/isupatches/wisefy/AddWEPNetworkTests.kt b/wisefy/src/androidTest/java/com/isupatches/wisefy/AddWEPNetworkTests.kt index c7ec7014..7e36ae2d 100644 --- a/wisefy/src/androidTest/java/com/isupatches/wisefy/AddWEPNetworkTests.kt +++ b/wisefy/src/androidTest/java/com/isupatches/wisefy/AddWEPNetworkTests.kt @@ -4,11 +4,9 @@ import com.isupatches.wisefy.WiseFy.Companion.WIFI_MANAGER_FAILURE import com.isupatches.wisefy.callbacks.AddNetworkCallbacks import com.isupatches.wisefy.constants.MISSING_PARAMETER import com.isupatches.wisefy.internal.base.BaseInstrumentationTest - import org.junit.Assert.assertEquals import org.junit.Assert.assertNotEquals import org.junit.Test - import org.mockito.Mockito.mock import org.mockito.Mockito.timeout import org.mockito.Mockito.verify @@ -22,27 +20,31 @@ import org.mockito.Mockito.verify @Suppress("deprecation") internal class AddWEPNetworkTests : BaseInstrumentationTest() { - @Test fun sync_failure_prechecks() { + @Test + fun sync_failure_prechecks() { mockWiseFyPrechecksUtil.addNetwork_failure() assertEquals(MISSING_PARAMETER, wisefy.addWEPNetwork(WEP_NETWORK_SSID, WEP_NETWORK_PASSWORD)) verificationUtil.didNoTryToAddNetwork() } - @Test fun sync_failure() { + @Test + fun sync_failure() { mockWiseFyPrechecksUtil.addNetwork_success() mockNetworkUtil.addNetwork_failure() assertEquals(WIFI_MANAGER_FAILURE, wisefy.addWEPNetwork(WEP_NETWORK_SSID, WEP_NETWORK_PASSWORD)) verificationUtil.triedToAddNetwork() } - @Test fun sync_success() { + @Test + fun sync_success() { mockWiseFyPrechecksUtil.addNetwork_success() mockNetworkUtil.addNetwork_success() assertNotEquals(1, wisefy.addWEPNetwork(WEP_NETWORK_SSID, WEP_NETWORK_PASSWORD)) verificationUtil.triedToAddNetwork() } - @Test fun async_failure_prechecks() { + @Test + fun async_failure_prechecks() { mockWiseFyPrechecksUtil.addNetwork_failure() val mockCallbacks = mock(AddNetworkCallbacks::class.java) wisefy.addWEPNetwork(WEP_NETWORK_SSID, WEP_NETWORK_PASSWORD, mockCallbacks) @@ -50,13 +52,15 @@ internal class AddWEPNetworkTests : BaseInstrumentationTest() { verificationUtil.didNoTryToAddNetwork() } - @Test fun async_failure_prechecks_nullCallback() { + @Test + fun async_failure_prechecks_nullCallback() { mockWiseFyPrechecksUtil.addNetwork_failure() nullCallbackUtil.callAddWEPNetwork(WEP_NETWORK_SSID, WEP_NETWORK_PASSWORD) verificationUtil.didNoTryToAddNetwork() } - @Test fun async_failure() { + @Test + fun async_failure() { mockWiseFyPrechecksUtil.addNetwork_success() mockNetworkUtil.addNetwork_failure() val mockCallbacks = mock(AddNetworkCallbacks::class.java) @@ -65,14 +69,16 @@ internal class AddWEPNetworkTests : BaseInstrumentationTest() { verificationUtil.triedToAddNetwork() } - @Test fun async_failure_nullCallback() { + @Test + fun async_failure_nullCallback() { mockWiseFyPrechecksUtil.addNetwork_success() mockNetworkUtil.addNetwork_failure() nullCallbackUtil.callAddWEPNetwork(WEP_NETWORK_SSID, WEP_NETWORK_PASSWORD) verificationUtil.triedToAddNetwork() } - @Test fun async_success() { + @Test + fun async_success() { mockWiseFyPrechecksUtil.addNetwork_success() mockNetworkUtil.addNetwork_success() val mockCallbacks = mock(AddNetworkCallbacks::class.java) @@ -81,7 +87,8 @@ internal class AddWEPNetworkTests : BaseInstrumentationTest() { verificationUtil.triedToAddNetwork() } - @Test fun async_success_nullCallback() { + @Test + fun async_success_nullCallback() { mockWiseFyPrechecksUtil.addNetwork_success() mockNetworkUtil.addNetwork_success() nullCallbackUtil.callAddWEPNetwork(WEP_NETWORK_SSID, WEP_NETWORK_PASSWORD) diff --git a/wisefy/src/androidTest/java/com/isupatches/wisefy/AddWPA2NetworkTests.kt b/wisefy/src/androidTest/java/com/isupatches/wisefy/AddWPA2NetworkTests.kt index 61c4b0ab..a7d0dc43 100644 --- a/wisefy/src/androidTest/java/com/isupatches/wisefy/AddWPA2NetworkTests.kt +++ b/wisefy/src/androidTest/java/com/isupatches/wisefy/AddWPA2NetworkTests.kt @@ -4,11 +4,9 @@ import com.isupatches.wisefy.WiseFy.Companion.WIFI_MANAGER_FAILURE import com.isupatches.wisefy.callbacks.AddNetworkCallbacks import com.isupatches.wisefy.constants.MISSING_PARAMETER import com.isupatches.wisefy.internal.base.BaseInstrumentationTest - import org.junit.Assert.assertEquals import org.junit.Assert.assertNotEquals import org.junit.Test - import org.mockito.Mockito.mock import org.mockito.Mockito.timeout import org.mockito.Mockito.verify @@ -21,27 +19,31 @@ import org.mockito.Mockito.verify */ internal class AddWPA2NetworkTests : BaseInstrumentationTest() { - @Test fun sync_failure_prechecks() { + @Test + fun sync_failure_prechecks() { mockWiseFyPrechecksUtil.addNetwork_failure() assertEquals(MISSING_PARAMETER, wisefy.addWPA2Network(WPA2_NETWORK_SSID, WPA2_NETWORK_PASSWORD)) verificationUtil.didNoTryToAddNetwork() } - @Test fun sync_failure() { + @Test + fun sync_failure() { mockWiseFyPrechecksUtil.addNetwork_success() mockNetworkUtil.addNetwork_failure() assertEquals(WIFI_MANAGER_FAILURE, wisefy.addWPA2Network(WPA2_NETWORK_SSID, WPA2_NETWORK_PASSWORD)) verificationUtil.triedToAddNetwork() } - @Test fun sync_success() { + @Test + fun sync_success() { mockWiseFyPrechecksUtil.addNetwork_success() mockNetworkUtil.addNetwork_success() assertNotEquals(WIFI_MANAGER_FAILURE, wisefy.addWPA2Network(WPA2_NETWORK_SSID, WPA2_NETWORK_PASSWORD)) verificationUtil.triedToAddNetwork() } - @Test fun async_failure_prechecks() { + @Test + fun async_failure_prechecks() { mockWiseFyPrechecksUtil.addNetwork_failure() val mockCallbacks = mock(AddNetworkCallbacks::class.java) wisefy.addWPA2Network(WPA2_NETWORK_SSID, WPA2_NETWORK_PASSWORD, mockCallbacks) @@ -49,13 +51,15 @@ internal class AddWPA2NetworkTests : BaseInstrumentationTest() { verificationUtil.didNoTryToAddNetwork() } - @Test fun async_failure_prechecks_nullCallback() { + @Test + fun async_failure_prechecks_nullCallback() { mockWiseFyPrechecksUtil.addNetwork_failure() nullCallbackUtil.callAddWPA2Network(WPA2_NETWORK_SSID, WPA2_NETWORK_PASSWORD) verificationUtil.didNoTryToAddNetwork() } - @Test fun async_failure() { + @Test + fun async_failure() { mockWiseFyPrechecksUtil.addNetwork_success() mockNetworkUtil.addNetwork_failure() val mockCallbacks = mock(AddNetworkCallbacks::class.java) @@ -64,14 +68,16 @@ internal class AddWPA2NetworkTests : BaseInstrumentationTest() { verificationUtil.triedToAddNetwork() } - @Test fun async_failure_nullCallback() { + @Test + fun async_failure_nullCallback() { mockWiseFyPrechecksUtil.addNetwork_success() mockNetworkUtil.addNetwork_failure() nullCallbackUtil.callAddWPA2Network(WPA2_NETWORK_SSID, WPA2_NETWORK_PASSWORD) verificationUtil.triedToAddNetwork() } - @Test fun async_success() { + @Test + fun async_success() { mockWiseFyPrechecksUtil.addNetwork_success() mockNetworkUtil.addNetwork_success() val mockCallbacks = mock(AddNetworkCallbacks::class.java) @@ -80,7 +86,8 @@ internal class AddWPA2NetworkTests : BaseInstrumentationTest() { verificationUtil.triedToAddNetwork() } - @Test fun async_success_nullCallback() { + @Test + fun async_success_nullCallback() { mockWiseFyPrechecksUtil.addNetwork_success() mockNetworkUtil.addNetwork_success() nullCallbackUtil.callAddWPA2Network(WPA2_NETWORK_SSID, WPA2_NETWORK_PASSWORD) diff --git a/wisefy/src/androidTest/java/com/isupatches/wisefy/ConnectToNetworkTests.kt b/wisefy/src/androidTest/java/com/isupatches/wisefy/ConnectToNetworkTests.kt index 7d5eae7c..2a703a58 100644 --- a/wisefy/src/androidTest/java/com/isupatches/wisefy/ConnectToNetworkTests.kt +++ b/wisefy/src/androidTest/java/com/isupatches/wisefy/ConnectToNetworkTests.kt @@ -3,10 +3,8 @@ package com.isupatches.wisefy import com.isupatches.wisefy.callbacks.ConnectToNetworkCallbacks import com.isupatches.wisefy.constants.MISSING_PARAMETER import com.isupatches.wisefy.internal.base.BaseInstrumentationTest - import org.junit.Assert.assertEquals import org.junit.Test - import org.mockito.Mockito.mock import org.mockito.Mockito.timeout import org.mockito.Mockito.verify @@ -19,20 +17,23 @@ import org.mockito.Mockito.verify */ internal class ConnectToNetworkTests : BaseInstrumentationTest() { - @Test fun sync_failure_prechecks() { + @Test + fun sync_failure_prechecks() { mockWiseFyPrechecksUtil.connectToNetwork_failure() assertEquals(false, wisefy.connectToNetwork(TEST_SSID, TEST_TIMEOUT)) verificationUtil.didNotTryToConnectToNetwork() } - @Test fun sync_failure_noSavedNetwork() { + @Test + fun sync_failure_noSavedNetwork() { mockWiseFyPrechecksUtil.connectToNetwork_success() mockWiseFySearchUtil.findSavedNetworkByRegex_null() assertEquals(false, wisefy.connectToNetwork(TEST_SSID, TEST_TIMEOUT)) verificationUtil.didNotTryToConnectToNetwork() } - @Test fun sync_failure() { + @Test + fun sync_failure() { mockWiseFyPrechecksUtil.connectToNetwork_success() mockWiseFySearchUtil.findSavedNetworkByRegex_success() mockWiseFyConnectionUtil.waitToConnectToSSID(false) @@ -40,7 +41,8 @@ internal class ConnectToNetworkTests : BaseInstrumentationTest() { verificationUtil.triedToConnectToNetwork() } - @Test fun sync_success() { + @Test + fun sync_success() { mockWiseFyPrechecksUtil.connectToNetwork_success() mockWiseFySearchUtil.findSavedNetworkByRegex_success() mockWiseFyConnectionUtil.waitToConnectToSSID(true) @@ -48,7 +50,8 @@ internal class ConnectToNetworkTests : BaseInstrumentationTest() { verificationUtil.triedToConnectToNetwork() } - @Test fun async_failure_prechecks() { + @Test + fun async_failure_prechecks() { mockWiseFyPrechecksUtil.connectToNetwork_failure() val mockCallbacks = mock(ConnectToNetworkCallbacks::class.java) wisefy.connectToNetwork(TEST_SSID, TEST_TIMEOUT, mockCallbacks) @@ -56,14 +59,16 @@ internal class ConnectToNetworkTests : BaseInstrumentationTest() { verificationUtil.didNotTryToConnectToNetwork() } - @Test fun async_failure_prechecks_nullCallback() { + @Test + fun async_failure_prechecks_nullCallback() { mockWiseFyPrechecksUtil.connectToNetwork_success() mockWiseFyPrechecksUtil.connectToNetwork_failure() nullCallbackUtil.callConnectToNetwork(TEST_SSID) verificationUtil.didNotTryToConnectToNetwork() } - @Test fun async_failure_noSavedNetwork() { + @Test + fun async_failure_noSavedNetwork() { mockWiseFyPrechecksUtil.connectToNetwork_success() mockWiseFySearchUtil.findSavedNetworkByRegex_null() val mockCallbacks = mock(ConnectToNetworkCallbacks::class.java) @@ -72,14 +77,16 @@ internal class ConnectToNetworkTests : BaseInstrumentationTest() { verificationUtil.didNotTryToConnectToNetwork() } - @Test fun async_failure_noSavedNetwork_nullCallback() { + @Test + fun async_failure_noSavedNetwork_nullCallback() { mockWiseFyPrechecksUtil.connectToNetwork_success() mockWiseFySearchUtil.findSavedNetworkByRegex_null() nullCallbackUtil.callConnectToNetwork(TEST_SSID) verificationUtil.didNotTryToConnectToNetwork() } - @Test fun async_failure() { + @Test + fun async_failure() { mockWiseFyPrechecksUtil.connectToNetwork_success() mockWiseFySearchUtil.findSavedNetworkByRegex_success() mockWiseFyConnectionUtil.waitToConnectToSSID(false) @@ -89,7 +96,8 @@ internal class ConnectToNetworkTests : BaseInstrumentationTest() { verificationUtil.triedToConnectToNetwork() } - @Test fun async_failure_nullCallback() { + @Test + fun async_failure_nullCallback() { mockWiseFyPrechecksUtil.connectToNetwork_success() mockWiseFySearchUtil.findSavedNetworkByRegex_success() mockWiseFyConnectionUtil.waitToConnectToSSID(false) @@ -97,7 +105,8 @@ internal class ConnectToNetworkTests : BaseInstrumentationTest() { verificationUtil.triedToConnectToNetwork() } - @Test fun async_success() { + @Test + fun async_success() { mockWiseFyPrechecksUtil.connectToNetwork_success() mockWiseFySearchUtil.findSavedNetworkByRegex_success() mockWiseFyConnectionUtil.waitToConnectToSSID(true) @@ -107,7 +116,8 @@ internal class ConnectToNetworkTests : BaseInstrumentationTest() { verificationUtil.triedToConnectToNetwork() } - @Test fun async_success_nullCallback() { + @Test + fun async_success_nullCallback() { mockWiseFyPrechecksUtil.connectToNetwork_success() mockWiseFySearchUtil.findSavedNetworkByRegex_success() mockWiseFyConnectionUtil.waitToConnectToSSID(true) diff --git a/wisefy/src/androidTest/java/com/isupatches/wisefy/DisableWifiTests.kt b/wisefy/src/androidTest/java/com/isupatches/wisefy/DisableWifiTests.kt index 81fb8633..ece45cdf 100644 --- a/wisefy/src/androidTest/java/com/isupatches/wisefy/DisableWifiTests.kt +++ b/wisefy/src/androidTest/java/com/isupatches/wisefy/DisableWifiTests.kt @@ -3,10 +3,8 @@ package com.isupatches.wisefy import com.isupatches.wisefy.callbacks.DisableWifiCallbacks import com.isupatches.wisefy.constants.MISSING_PARAMETER import com.isupatches.wisefy.internal.base.BaseInstrumentationTest - import org.junit.Assert.assertEquals import org.junit.Test - import org.mockito.Mockito.mock import org.mockito.Mockito.timeout import org.mockito.Mockito.verify @@ -19,27 +17,31 @@ import org.mockito.Mockito.verify */ internal class DisableWifiTests : BaseInstrumentationTest() { - @Test fun sync_failure_prechecks() { + @Test + fun sync_failure_prechecks() { mockWiseFyPrechecksUtil.disableWifi_failure() assertEquals(false, wisefy.disableWifi()) verificationUtil.didNotTryToDisableWifi() } - @Test fun sync_failure() { + @Test + fun sync_failure() { mockWiseFyPrechecksUtil.disableWifi_success() mockNetworkUtil.disableWifi_failure() assertEquals(false, wisefy.disableWifi()) verificationUtil.triedToDisableWifi() } - @Test fun sync_success() { + @Test + fun sync_success() { mockWiseFyPrechecksUtil.disableWifi_success() mockNetworkUtil.disableWifi_success() assertEquals(true, wisefy.disableWifi()) verificationUtil.triedToDisableWifi() } - @Test fun async_failure_prechecks() { + @Test + fun async_failure_prechecks() { mockWiseFyPrechecksUtil.disableWifi_failure() val mockCallbacks = mock(DisableWifiCallbacks::class.java) wisefy.disableWifi(mockCallbacks) @@ -47,13 +49,15 @@ internal class DisableWifiTests : BaseInstrumentationTest() { verificationUtil.didNotTryToDisableWifi() } - @Test fun async_failure_prechecks_nullCallback() { + @Test + fun async_failure_prechecks_nullCallback() { mockWiseFyPrechecksUtil.disableWifi_failure() nullCallbackUtil.callDisableWifi() verificationUtil.didNotTryToDisableWifi() } - @Test fun async_failure() { + @Test + fun async_failure() { mockWiseFyPrechecksUtil.disableWifi_success() mockNetworkUtil.disableWifi_failure() val mockCallbacks = mock(DisableWifiCallbacks::class.java) @@ -62,14 +66,16 @@ internal class DisableWifiTests : BaseInstrumentationTest() { verificationUtil.triedToDisableWifi() } - @Test fun async_failure_nullCallback() { + @Test + fun async_failure_nullCallback() { mockWiseFyPrechecksUtil.disableWifi_success() mockNetworkUtil.disableWifi_failure() nullCallbackUtil.callDisableWifi() verificationUtil.triedToDisableWifi() } - @Test fun async_success() { + @Test + fun async_success() { mockWiseFyPrechecksUtil.disableWifi_success() mockNetworkUtil.disableWifi_success() val mockCallbacks = mock(DisableWifiCallbacks::class.java) @@ -78,7 +84,8 @@ internal class DisableWifiTests : BaseInstrumentationTest() { verificationUtil.triedToDisableWifi() } - @Test fun async_success_nullCallback() { + @Test + fun async_success_nullCallback() { mockWiseFyPrechecksUtil.disableWifi_success() mockNetworkUtil.disableWifi_success() nullCallbackUtil.callDisableWifi() diff --git a/wisefy/src/androidTest/java/com/isupatches/wisefy/DisconnectFromCurrentNetworkTests.kt b/wisefy/src/androidTest/java/com/isupatches/wisefy/DisconnectFromCurrentNetworkTests.kt index b63d7080..1636a848 100644 --- a/wisefy/src/androidTest/java/com/isupatches/wisefy/DisconnectFromCurrentNetworkTests.kt +++ b/wisefy/src/androidTest/java/com/isupatches/wisefy/DisconnectFromCurrentNetworkTests.kt @@ -3,10 +3,8 @@ package com.isupatches.wisefy import com.isupatches.wisefy.callbacks.DisconnectFromCurrentNetworkCallbacks import com.isupatches.wisefy.constants.MISSING_PARAMETER import com.isupatches.wisefy.internal.base.BaseInstrumentationTest - import org.junit.Assert.assertEquals import org.junit.Test - import org.mockito.Mockito.mock import org.mockito.Mockito.timeout import org.mockito.Mockito.verify @@ -19,27 +17,31 @@ import org.mockito.Mockito.verify */ internal class DisconnectFromCurrentNetworkTests : BaseInstrumentationTest() { - @Test fun sync_failure_prechecks() { + @Test + fun sync_failure_prechecks() { mockWiseFyPrechecksUtil.disconnectFromCurrentNetwork_failure() assertEquals(false, wisefy.disconnectFromCurrentNetwork()) verificationUtil.didNotTryToDisconnectFromCurrentNetwork() } - @Test fun sync_failure() { + @Test + fun sync_failure() { mockWiseFyPrechecksUtil.disconnectFromCurrentNetwork_success() mockNetworkUtil.disconnectFromCurrentNetwork_failure() assertEquals(false, wisefy.disconnectFromCurrentNetwork()) verificationUtil.triedToDisconnectFromCurrentNetwork() } - @Test fun sync_success() { + @Test + fun sync_success() { mockWiseFyPrechecksUtil.disconnectFromCurrentNetwork_success() mockNetworkUtil.disconnectFromCurrentNetwork_success() assertEquals(true, wisefy.disconnectFromCurrentNetwork()) verificationUtil.triedToDisconnectFromCurrentNetwork() } - @Test fun async_failure_prechecks() { + @Test + fun async_failure_prechecks() { mockWiseFyPrechecksUtil.disconnectFromCurrentNetwork_failure() val mockCallbacks = mock(DisconnectFromCurrentNetworkCallbacks::class.java) wisefy.disconnectFromCurrentNetwork(mockCallbacks) @@ -47,13 +49,15 @@ internal class DisconnectFromCurrentNetworkTests : BaseInstrumentationTest() { verificationUtil.didNotTryToDisconnectFromCurrentNetwork() } - @Test fun async_failure_prechecks_nullCallback() { + @Test + fun async_failure_prechecks_nullCallback() { mockWiseFyPrechecksUtil.disconnectFromCurrentNetwork_failure() nullCallbackUtil.callDisconnectFromCurrentNetwork() verificationUtil.didNotTryToDisconnectFromCurrentNetwork() } - @Test fun async_failure() { + @Test + fun async_failure() { mockWiseFyPrechecksUtil.disconnectFromCurrentNetwork_success() mockNetworkUtil.disconnectFromCurrentNetwork_failure() val mockCallbacks = mock(DisconnectFromCurrentNetworkCallbacks::class.java) @@ -62,14 +66,16 @@ internal class DisconnectFromCurrentNetworkTests : BaseInstrumentationTest() { verificationUtil.triedToDisconnectFromCurrentNetwork() } - @Test fun async_failure_nullCallback() { + @Test + fun async_failure_nullCallback() { mockWiseFyPrechecksUtil.disconnectFromCurrentNetwork_success() mockNetworkUtil.disconnectFromCurrentNetwork_failure() nullCallbackUtil.callDisconnectFromCurrentNetwork() verificationUtil.triedToDisconnectFromCurrentNetwork() } - @Test fun async_success() { + @Test + fun async_success() { mockWiseFyPrechecksUtil.disconnectFromCurrentNetwork_success() mockNetworkUtil.disconnectFromCurrentNetwork_success() val mockCallbacks = mock(DisconnectFromCurrentNetworkCallbacks::class.java) @@ -78,7 +84,8 @@ internal class DisconnectFromCurrentNetworkTests : BaseInstrumentationTest() { verificationUtil.triedToDisconnectFromCurrentNetwork() } - @Test fun async_success_nullCallback() { + @Test + fun async_success_nullCallback() { mockWiseFyPrechecksUtil.disconnectFromCurrentNetwork_success() mockNetworkUtil.disconnectFromCurrentNetwork_success() nullCallbackUtil.callDisconnectFromCurrentNetwork() diff --git a/wisefy/src/androidTest/java/com/isupatches/wisefy/EnableWifiTests.kt b/wisefy/src/androidTest/java/com/isupatches/wisefy/EnableWifiTests.kt index 17464c60..5ec8fc1b 100644 --- a/wisefy/src/androidTest/java/com/isupatches/wisefy/EnableWifiTests.kt +++ b/wisefy/src/androidTest/java/com/isupatches/wisefy/EnableWifiTests.kt @@ -3,10 +3,8 @@ package com.isupatches.wisefy import com.isupatches.wisefy.callbacks.EnableWifiCallbacks import com.isupatches.wisefy.constants.MISSING_PARAMETER import com.isupatches.wisefy.internal.base.BaseInstrumentationTest - import org.junit.Assert.assertEquals import org.junit.Test - import org.mockito.Mockito.mock import org.mockito.Mockito.timeout import org.mockito.Mockito.verify @@ -19,27 +17,31 @@ import org.mockito.Mockito.verify */ internal class EnableWifiTests : BaseInstrumentationTest() { - @Test fun sync_failure_prechecks() { + @Test + fun sync_failure_prechecks() { mockWiseFyPrechecksUtil.enableWifi_failure() assertEquals(false, wisefy.enableWifi()) verificationUtil.didNotTryToEnableWifi() } - @Test fun sync_failure() { + @Test + fun sync_failure() { mockWiseFyPrechecksUtil.enableWifi_success() mockNetworkUtil.enableWifi_failure() assertEquals(false, wisefy.enableWifi()) verificationUtil.triedToEnableWifi() } - @Test fun sync_success() { + @Test + fun sync_success() { mockWiseFyPrechecksUtil.enableWifi_success() mockNetworkUtil.enableWifi_success() assertEquals(true, wisefy.enableWifi()) verificationUtil.triedToEnableWifi() } - @Test fun async_failure_prechecks() { + @Test + fun async_failure_prechecks() { mockWiseFyPrechecksUtil.enableWifi_failure() val mockCallbacks = mock(EnableWifiCallbacks::class.java) wisefy.enableWifi(mockCallbacks) @@ -47,13 +49,15 @@ internal class EnableWifiTests : BaseInstrumentationTest() { verificationUtil.didNotTryToEnableWifi() } - @Test fun async_failure_prechecks_nullCallback() { + @Test + fun async_failure_prechecks_nullCallback() { mockWiseFyPrechecksUtil.enableWifi_failure() nullCallbackUtil.callEnableWifi() verificationUtil.didNotTryToEnableWifi() } - @Test fun async_failure() { + @Test + fun async_failure() { mockWiseFyPrechecksUtil.enableWifi_success() mockNetworkUtil.enableWifi_failure() val mockCallbacks = mock(EnableWifiCallbacks::class.java) @@ -62,14 +66,16 @@ internal class EnableWifiTests : BaseInstrumentationTest() { verificationUtil.triedToEnableWifi() } - @Test fun async_failure_nullCallback() { + @Test + fun async_failure_nullCallback() { mockWiseFyPrechecksUtil.enableWifi_success() mockNetworkUtil.enableWifi_failure() nullCallbackUtil.callEnableWifi() verificationUtil.triedToEnableWifi() } - @Test fun async_success() { + @Test + fun async_success() { mockWiseFyPrechecksUtil.enableWifi_success() mockNetworkUtil.enableWifi_success() val mockCallbacks = mock(EnableWifiCallbacks::class.java) @@ -78,7 +84,8 @@ internal class EnableWifiTests : BaseInstrumentationTest() { verificationUtil.triedToEnableWifi() } - @Test fun async_success_nullCallback() { + @Test + fun async_success_nullCallback() { mockWiseFyPrechecksUtil.enableWifi_success() mockNetworkUtil.enableWifi_success() nullCallbackUtil.callEnableWifi() diff --git a/wisefy/src/androidTest/java/com/isupatches/wisefy/GetCurrentNetworkInfoTest.kt b/wisefy/src/androidTest/java/com/isupatches/wisefy/GetCurrentNetworkInfoTest.kt index 824f6e47..5dafcb9b 100644 --- a/wisefy/src/androidTest/java/com/isupatches/wisefy/GetCurrentNetworkInfoTest.kt +++ b/wisefy/src/androidTest/java/com/isupatches/wisefy/GetCurrentNetworkInfoTest.kt @@ -1,16 +1,13 @@ package com.isupatches.wisefy import android.net.NetworkInfo - import com.isupatches.wisefy.callbacks.GetCurrentNetworkInfoCallbacks import com.isupatches.wisefy.constants.MISSING_PARAMETER import com.isupatches.wisefy.internal.base.BaseInstrumentationTest - import org.junit.Assert.assertEquals import org.junit.Assert.assertNotNull import org.junit.Assert.fail import org.junit.Test - import org.mockito.Mockito.mock import org.mockito.Mockito.timeout import org.mockito.Mockito.verify @@ -23,19 +20,22 @@ import org.mockito.Mockito.verify */ internal class GetCurrentNetworkInfoTest : BaseInstrumentationTest() { - @Test fun sync_failure_prechecks() { + @Test + fun sync_failure_prechecks() { mockWiseFyPrechecksUtil.getCurrentNetworkInfo_failure() assertEquals(null, wisefy.getCurrentNetworkInfo()) verificationUtil.didNotTryToGetCurrentNetworkInfo() } - @Test fun sync_failure_nullCurrentNetwork() { + @Test + fun sync_failure_nullCurrentNetwork() { mockWiseFyPrechecksUtil.getCurrentNetworkInfo_success() assertEquals(null, wisefy.getCurrentNetworkInfo()) verificationUtil.triedToGetCurrentNetworkInfo() } - @Test fun sync_success() { + @Test + fun sync_success() { mockWiseFyPrechecksUtil.getCurrentNetworkInfo_success() mockNetworkUtil.activeNetwork() val currentNetworkInfo = wisefy.getCurrentNetworkInfo() @@ -47,7 +47,8 @@ internal class GetCurrentNetworkInfoTest : BaseInstrumentationTest() { } } - @Test fun async_failure_prechecks() { + @Test + fun async_failure_prechecks() { mockWiseFyPrechecksUtil.getCurrentNetworkInfo_failure() val mockCallbacks = mock(GetCurrentNetworkInfoCallbacks::class.java) wisefy.getCurrentNetworkInfo(mockCallbacks) @@ -55,13 +56,15 @@ internal class GetCurrentNetworkInfoTest : BaseInstrumentationTest() { verificationUtil.didNotTryToGetCurrentNetworkInfo() } - @Test fun async_failure_prechecks_nullCallbacks() { + @Test + fun async_failure_prechecks_nullCallbacks() { mockWiseFyPrechecksUtil.getCurrentNetworkInfo_failure() nullCallbackUtil.callGetCurrentNetworkInfo() verificationUtil.didNotTryToGetCurrentNetworkInfo() } - @Test fun async_failure_nullCurrentNetwork() { + @Test + fun async_failure_nullCurrentNetwork() { mockWiseFyPrechecksUtil.getCurrentNetworkInfo_success() val mockCallbacks = mock(GetCurrentNetworkInfoCallbacks::class.java) wisefy.getCurrentNetworkInfo(mockCallbacks) @@ -69,22 +72,27 @@ internal class GetCurrentNetworkInfoTest : BaseInstrumentationTest() { verificationUtil.triedToGetCurrentNetworkInfo() } - @Test fun async_failure_nullCurrentNetwork_nullCallbacks() { + @Test + fun async_failure_nullCurrentNetwork_nullCallbacks() { mockWiseFyPrechecksUtil.getCurrentNetworkInfo_success() nullCallbackUtil.callGetCurrentNetworkInfo() verificationUtil.triedToGetCurrentNetworkInfo() } - @Test fun async_success() { + @Test + fun async_success() { mockWiseFyPrechecksUtil.getCurrentNetworkInfo_success() mockNetworkUtil.activeNetwork() val mockCallbacks = mock(GetCurrentNetworkInfoCallbacks::class.java) wisefy.getCurrentNetworkInfo(mockCallbacks) - verify(mockCallbacks, timeout(VERIFICATION_SUCCESS_TIMEOUT)).retrievedCurrentNetworkInfo(any(NetworkInfo::class.java)) + verify(mockCallbacks, timeout(VERIFICATION_SUCCESS_TIMEOUT)).retrievedCurrentNetworkInfo( + any(NetworkInfo::class.java) + ) verificationUtil.triedToGetCurrentNetworkInfo() } - @Test fun async_success_nullCallback() { + @Test + fun async_success_nullCallback() { mockWiseFyPrechecksUtil.getCurrentNetworkInfo_success() mockNetworkUtil.activeNetwork() nullCallbackUtil.callGetCurrentNetworkInfo() diff --git a/wisefy/src/androidTest/java/com/isupatches/wisefy/GetCurrentNetworkTests.kt b/wisefy/src/androidTest/java/com/isupatches/wisefy/GetCurrentNetworkTests.kt index 32569c7c..db581496 100644 --- a/wisefy/src/androidTest/java/com/isupatches/wisefy/GetCurrentNetworkTests.kt +++ b/wisefy/src/androidTest/java/com/isupatches/wisefy/GetCurrentNetworkTests.kt @@ -3,11 +3,9 @@ package com.isupatches.wisefy import com.isupatches.wisefy.callbacks.GetCurrentNetworkCallbacks import com.isupatches.wisefy.constants.MISSING_PARAMETER import com.isupatches.wisefy.internal.base.BaseInstrumentationTest - import org.junit.Assert.assertEquals import org.junit.Assert.fail import org.junit.Test - import org.mockito.Mockito.mock import org.mockito.Mockito.timeout import org.mockito.Mockito.verify @@ -20,19 +18,22 @@ import org.mockito.Mockito.verify */ internal class GetCurrentNetworkTests : BaseInstrumentationTest() { - @Test fun sync_failure_prechecks() { + @Test + fun sync_failure_prechecks() { mockWiseFyPrechecksUtil.getCurrentNetwork_failure() assertEquals(null, wisefy.getCurrentNetwork()) verificationUtil.didNotTryToGetCurrentNetwork() } - @Test fun sync_failure_nullCurrentNetwork() { + @Test + fun sync_failure_nullCurrentNetwork() { mockWiseFyPrechecksUtil.getCurrentNetwork_success() assertEquals(null, wisefy.getCurrentNetwork()) verificationUtil.triedToGetCurrentNetwork() } - @Test fun sync_success() { + @Test + fun sync_success() { mockWiseFyPrechecksUtil.getCurrentNetwork_success() mockNetworkUtil.currentNetwork(TEST_SSID) val currentNetwork = wisefy.getCurrentNetwork() @@ -44,7 +45,8 @@ internal class GetCurrentNetworkTests : BaseInstrumentationTest() { } } - @Test fun async_failure_prechecks() { + @Test + fun async_failure_prechecks() { mockWiseFyPrechecksUtil.getCurrentNetwork_failure() val mockCallbacks = mock(GetCurrentNetworkCallbacks::class.java) wisefy.getCurrentNetwork(mockCallbacks) @@ -52,13 +54,15 @@ internal class GetCurrentNetworkTests : BaseInstrumentationTest() { verificationUtil.didNotTryToGetCurrentNetwork() } - @Test fun async_failure_prechecks_nullCallbacks() { + @Test + fun async_failure_prechecks_nullCallbacks() { mockWiseFyPrechecksUtil.getCurrentNetwork_failure() nullCallbackUtil.callGetCurrentNetwork() verificationUtil.didNotTryToGetCurrentNetwork() } - @Test fun async_failure_nullCurrentNetwork() { + @Test + fun async_failure_nullCurrentNetwork() { mockWiseFyPrechecksUtil.getCurrentNetwork_success() val mockCallbacks = mock(GetCurrentNetworkCallbacks::class.java) wisefy.getCurrentNetwork(mockCallbacks) @@ -66,13 +70,15 @@ internal class GetCurrentNetworkTests : BaseInstrumentationTest() { verificationUtil.triedToGetCurrentNetwork() } - @Test fun async_failure_nullCurrentNetwork_nullCallbacks() { + @Test + fun async_failure_nullCurrentNetwork_nullCallbacks() { mockWiseFyPrechecksUtil.getCurrentNetwork_success() nullCallbackUtil.callGetCurrentNetwork() verificationUtil.triedToGetCurrentNetwork() } - @Test fun async_success() { + @Test + fun async_success() { mockWiseFyPrechecksUtil.getCurrentNetwork_success() val currentNetwork = mockNetworkUtil.currentNetwork(TEST_SSID) val mockCallbacks = mock(GetCurrentNetworkCallbacks::class.java) @@ -81,7 +87,8 @@ internal class GetCurrentNetworkTests : BaseInstrumentationTest() { verificationUtil.triedToGetCurrentNetwork() } - @Test fun async_success_nullCallback() { + @Test + fun async_success_nullCallback() { mockWiseFyPrechecksUtil.getCurrentNetwork_success() mockNetworkUtil.currentNetwork(TEST_SSID) nullCallbackUtil.callGetCurrentNetwork() diff --git a/wisefy/src/androidTest/java/com/isupatches/wisefy/GetFrequencyTests.kt b/wisefy/src/androidTest/java/com/isupatches/wisefy/GetFrequencyTests.kt index 2da052a8..d069b6f5 100644 --- a/wisefy/src/androidTest/java/com/isupatches/wisefy/GetFrequencyTests.kt +++ b/wisefy/src/androidTest/java/com/isupatches/wisefy/GetFrequencyTests.kt @@ -2,17 +2,14 @@ package com.isupatches.wisefy import android.net.wifi.WifiInfo import android.os.Build - import com.isupatches.wisefy.callbacks.GetFrequencyCallbacks import com.isupatches.wisefy.constants.MISSING_PARAMETER import com.isupatches.wisefy.internal.base.BaseInstrumentationTest - import org.junit.Assert.assertEquals import org.junit.Assert.fail import org.junit.Assume import org.junit.Before import org.junit.Test - import org.mockito.Mockito.after import org.mockito.Mockito.mock import org.mockito.Mockito.timeout @@ -26,21 +23,26 @@ import org.mockito.Mockito.verify */ internal class GetFrequencyTests : BaseInstrumentationTest() { - @Before fun setup() { + @Before + fun setup() { Assume.assumeTrue( - "Can only run on API Level 21 or newer", - Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP + "Can only run on API Level 21 or newer", + Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP ) } - @Test fun sync_getFrequency_currentNetwork_failure() { + @Test + fun sync_getFrequency_currentNetwork_failure() { + mockWiseFyPrechecksUtil.getFrequency_success() mockWiseFyPrechecksUtil.getCurrentNetwork_success() mockNetworkUtil.currentNetwork_null() assertEquals(null, wisefy.getFrequency()) verificationUtil.triedToGetCurrentNetwork() } - @Test fun sync_getFrequency_currentNetwork_success() { + @Test + fun sync_getFrequency_currentNetwork_success() { + mockWiseFyPrechecksUtil.getFrequency_success() mockWiseFyPrechecksUtil.getCurrentNetwork_success() val wifiInfo = mockNetworkUtil.networkWithFrequency(TEST_NETWORK_FREQUENCY_24GHZ) val frequency = wisefy.getFrequency() @@ -53,7 +55,16 @@ internal class GetFrequencyTests : BaseInstrumentationTest() { } } - @Test fun async_getFrequency_currentNetwork_failure() { + @Test + fun sync_getFrequency_failure_prechecks() { + mockWiseFyPrechecksUtil.getFrequency_failure() + assertEquals(null, wisefy.getFrequency()) + verificationUtil.didNotTryToGetCurrentNetwork() + } + + @Test + fun async_getFrequency_currentNetwork_failure() { + mockWiseFyPrechecksUtil.getFrequency_success() mockWiseFyPrechecksUtil.getCurrentNetwork_success() mockNetworkUtil.currentNetwork_null() val mockCallbacks = mock(GetFrequencyCallbacks::class.java) @@ -62,14 +73,18 @@ internal class GetFrequencyTests : BaseInstrumentationTest() { verificationUtil.triedToGetCurrentNetwork() } - @Test fun async_getFrequency_currentNetwork_failure_nullCallback() { + @Test + fun async_getFrequency_currentNetwork_failure_nullCallback() { + mockWiseFyPrechecksUtil.getFrequency_success() mockWiseFyPrechecksUtil.getCurrentNetwork_success() mockNetworkUtil.currentNetwork_null() nullCallbackUtil.callGetFrequency() verificationUtil.triedToGetCurrentNetwork() } - @Test fun async_getFrequency_currentNetwork_success() { + @Test + fun async_getFrequency_currentNetwork_success() { + mockWiseFyPrechecksUtil.getFrequency_success() mockWiseFyPrechecksUtil.getCurrentNetwork_success() val mockWifiInfo = mockNetworkUtil.networkWithFrequency(TEST_NETWORK_FREQUENCY_24GHZ) val mockCallbacks = mock(GetFrequencyCallbacks::class.java) @@ -79,19 +94,39 @@ internal class GetFrequencyTests : BaseInstrumentationTest() { verify(mockWifiInfo, timeout(VERIFICATION_SUCCESS_TIMEOUT)).frequency } - @Test fun async_getFrequency_currentNetwork_success_nullCallback() { + @Test + fun async_getFrequency_currentNetwork_success_nullCallback() { + mockWiseFyPrechecksUtil.getFrequency_success() mockWiseFyPrechecksUtil.getCurrentNetwork_success() mockNetworkUtil.networkWithFrequency(TEST_NETWORK_FREQUENCY_24GHZ) nullCallbackUtil.callGetFrequency() verificationUtil.triedToGetCurrentNetwork() } - @Test fun sync_getFrequency_networkProvided_failure() { + @Test + fun async_getFrequency_failure_prechecks() { + mockWiseFyPrechecksUtil.getFrequency_failure() + val mockCallbacks = mock(GetFrequencyCallbacks::class.java) + wisefy.getFrequency(mockCallbacks) + verify(mockCallbacks, timeout(VERIFICATION_SUCCESS_TIMEOUT)).wisefyFailure(MISSING_PARAMETER) + verificationUtil.didNotTryToGetCurrentNetwork() + } + + @Test + fun async_getFrequency_failure_prechecks_nullCallback() { + mockWiseFyPrechecksUtil.getFrequency_failure() + nullCallbackUtil.callGetFrequency() + verificationUtil.didNotTryToGetCurrentNetwork() + } + + @Test + fun sync_getFrequency_networkProvided_failure() { mockNetworkUtil.currentNetwork_null() assertEquals(null, wisefy.getFrequency(null as? WifiInfo?)) } - @Test fun sync_getFrequency_networkProvided_success() { + @Test + fun sync_getFrequency_networkProvided_success() { val mockWifiInfo = mockNetworkUtil.networkWithFrequency(TEST_NETWORK_FREQUENCY_24GHZ) val frequency = wisefy.getFrequency(mockWifiInfo) if (frequency != null) { @@ -101,19 +136,22 @@ internal class GetFrequencyTests : BaseInstrumentationTest() { } } - @Test fun async_getFrequency_networkProvided_failure() { + @Test + fun async_getFrequency_networkProvided_failure() { mockNetworkUtil.currentNetwork_null() val mockCallbacks = mock(GetFrequencyCallbacks::class.java) wisefy.getFrequency(null, mockCallbacks) verify(mockCallbacks, timeout(VERIFICATION_SUCCESS_TIMEOUT)).wisefyFailure(MISSING_PARAMETER) } - @Test fun async_getFrequency_networkProvided_failure_nullCallback() { + @Test + fun async_getFrequency_networkProvided_failure_nullCallback() { mockNetworkUtil.currentNetwork_null() nullCallbackUtil.callGetFrequency_networkProvided(null) } - @Test fun async_getFrequency_networkProvided_success() { + @Test + fun async_getFrequency_networkProvided_success() { val mockWifiInfo = mockNetworkUtil.networkWithFrequency(TEST_NETWORK_FREQUENCY_24GHZ) val mockCallbacks = mock(GetFrequencyCallbacks::class.java) wisefy.getFrequency(mockWifiInfo, mockCallbacks) @@ -121,7 +159,8 @@ internal class GetFrequencyTests : BaseInstrumentationTest() { verify(mockWifiInfo, timeout(VERIFICATION_SUCCESS_TIMEOUT)).frequency } - @Test fun async_getFrequency_networkProvided_success_nullCallback() { + @Test + fun async_getFrequency_networkProvided_success_nullCallback() { val mockWifiInfo = mockNetworkUtil.networkWithFrequency(TEST_NETWORK_FREQUENCY_24GHZ) nullCallbackUtil.callGetFrequency_networkProvided(mockWifiInfo) verify(mockWifiInfo, after(VERIFICATION_FAILURE_TIMEOUT).times(0)).frequency diff --git a/wisefy/src/androidTest/java/com/isupatches/wisefy/GetIPTests.kt b/wisefy/src/androidTest/java/com/isupatches/wisefy/GetIPTests.kt index a65815af..664cdb86 100644 --- a/wisefy/src/androidTest/java/com/isupatches/wisefy/GetIPTests.kt +++ b/wisefy/src/androidTest/java/com/isupatches/wisefy/GetIPTests.kt @@ -3,10 +3,8 @@ package com.isupatches.wisefy import com.isupatches.wisefy.callbacks.GetIPCallbacks import com.isupatches.wisefy.constants.MISSING_PARAMETER import com.isupatches.wisefy.internal.base.BaseInstrumentationTest - import org.junit.Assert.assertEquals import org.junit.Test - import org.mockito.Mockito.mock import org.mockito.Mockito.timeout import org.mockito.Mockito.verify @@ -19,18 +17,21 @@ import org.mockito.Mockito.verify */ internal class GetIPTests : BaseInstrumentationTest() { - @Test fun sync_getIP_failure_missingPrerequisites() { + @Test + fun sync_getIP_failure_missingPrerequisites() { mockWiseFyPrechecksUtil.getIP_failure() assertEquals(null, wisefy.getIP()) } - @Test fun sync_getIP_failure() { + @Test + fun sync_getIP_failure() { mockWiseFyPrechecksUtil.getIP_success() mockNetworkUtil.ip_failure() assertEquals(null, wisefy.getIP()) } - @Test fun sync_getIP_success() { + @Test + fun sync_getIP_success() { mockWiseFyPrechecksUtil.getIP_success() mockNetworkUtil.ip_success() assertEquals(TEST_IP_ADDRESS_STRING, wisefy.getIP()) diff --git a/wisefy/src/androidTest/java/com/isupatches/wisefy/GetNearbyAccessPointsTests.kt b/wisefy/src/androidTest/java/com/isupatches/wisefy/GetNearbyAccessPointsTests.kt index 965f4fcc..de14c5cb 100644 --- a/wisefy/src/androidTest/java/com/isupatches/wisefy/GetNearbyAccessPointsTests.kt +++ b/wisefy/src/androidTest/java/com/isupatches/wisefy/GetNearbyAccessPointsTests.kt @@ -3,10 +3,8 @@ package com.isupatches.wisefy import com.isupatches.wisefy.callbacks.GetNearbyAccessPointsCallbacks import com.isupatches.wisefy.constants.MISSING_PARAMETER import com.isupatches.wisefy.internal.base.BaseInstrumentationTest - import org.junit.Assert.assertEquals import org.junit.Test - import org.mockito.Mockito.mock import org.mockito.Mockito.timeout import org.mockito.Mockito.verify @@ -19,69 +17,80 @@ import org.mockito.Mockito.verify */ internal class GetNearbyAccessPointsTests : BaseInstrumentationTest() { - @Test fun sync_failure_prechecks_filterDuplicates_false() { + @Test + fun sync_failure_prechecks_filterDuplicates_false() { mockWiseFyPrechecksUtil.getNearbyAccessPoints_failure() assertEquals(null, wisefy.getNearbyAccessPoints(false)) } - @Test fun sync_failure_prechecks_filterDuplicates_true() { + @Test + fun sync_failure_prechecks_filterDuplicates_true() { mockWiseFyPrechecksUtil.getNearbyAccessPoints_failure() assertEquals(null, wisefy.getNearbyAccessPoints(true)) } - @Test fun sync_failure_filterDuplicates_false() { + @Test + fun sync_failure_filterDuplicates_false() { mockWiseFyPrechecksUtil.getNearbyAccessPoints_success() mockWiseFySearchUtil.nearbyAccessPoints_null(false) val nearbyAccessPoints = wisefy.getNearbyAccessPoints(false) assertEquals(null, nearbyAccessPoints) } - @Test fun sync_failure_filterDuplicates_true() { + @Test + fun sync_failure_filterDuplicates_true() { mockWiseFyPrechecksUtil.getNearbyAccessPoints_success() mockWiseFySearchUtil.nearbyAccessPoints_null(true) val nearbyAccessPoints = wisefy.getNearbyAccessPoints(true) assertEquals(null, nearbyAccessPoints) } - @Test fun sync_success_filterDuplicates_false() { + @Test + fun sync_success_filterDuplicates_false() { mockWiseFyPrechecksUtil.getNearbyAccessPoints_success() val accessPoints = mockWiseFySearchUtil.nearbyAccessPoints_success(false) val nearbyAccessPoints = wisefy.getNearbyAccessPoints(false) assertEquals(accessPoints, nearbyAccessPoints) } - @Test fun sync_success_filterDuplicates_true() { + @Test + fun sync_success_filterDuplicates_true() { mockWiseFyPrechecksUtil.getNearbyAccessPoints_success() val accessPoints = mockWiseFySearchUtil.nearbyAccessPoints_success(true) val nearbyAccessPoints = wisefy.getNearbyAccessPoints(true) assertEquals(accessPoints, nearbyAccessPoints) } - @Test fun async_failure_prechecks_filterDuplicates_false() { + @Test + fun async_failure_prechecks_filterDuplicates_false() { mockWiseFyPrechecksUtil.getNearbyAccessPoints_failure() val mockCallbacks = mock(GetNearbyAccessPointsCallbacks::class.java) wisefy.getNearbyAccessPoints(false, mockCallbacks) verify(mockCallbacks, timeout(VERIFICATION_SUCCESS_TIMEOUT)).wisefyFailure(MISSING_PARAMETER) } - @Test fun async_failure_prechecks_filterDuplicates_false_nullCallback() { + @Test + fun async_failure_prechecks_filterDuplicates_false_nullCallback() { mockWiseFyPrechecksUtil.getNearbyAccessPoints_failure() nullCallbackUtil.callGetNearbyAccessPoints(false) } - @Test fun async_failure_prechecks_filterDuplicates_true() { + @Test + fun async_failure_prechecks_filterDuplicates_true() { mockWiseFyPrechecksUtil.getNearbyAccessPoints_failure() val mockCallbacks = mock(GetNearbyAccessPointsCallbacks::class.java) wisefy.getNearbyAccessPoints(true, mockCallbacks) verify(mockCallbacks, timeout(VERIFICATION_SUCCESS_TIMEOUT)).wisefyFailure(MISSING_PARAMETER) } - @Test fun async_failure_prechecks_filterDuplicates_true_nullCallback() { + @Test + fun async_failure_prechecks_filterDuplicates_true_nullCallback() { mockWiseFyPrechecksUtil.getNearbyAccessPoints_failure() nullCallbackUtil.callGetNearbyAccessPoints(true) } - @Test fun async_failure_filterDuplicates_false() { + @Test + fun async_failure_filterDuplicates_false() { mockWiseFyPrechecksUtil.getNearbyAccessPoints_success() mockWiseFySearchUtil.nearbyAccessPoints_null(false) val mockCallbacks = mock(GetNearbyAccessPointsCallbacks::class.java) @@ -89,13 +98,15 @@ internal class GetNearbyAccessPointsTests : BaseInstrumentationTest() { verify(mockCallbacks, timeout(VERIFICATION_SUCCESS_TIMEOUT)).noAccessPointsFound() } - @Test fun async_failure_filterDuplicates_false_nullCallback() { + @Test + fun async_failure_filterDuplicates_false_nullCallback() { mockWiseFyPrechecksUtil.getNearbyAccessPoints_success() mockWiseFySearchUtil.nearbyAccessPoints_success(true) nullCallbackUtil.callGetNearbyAccessPoints(false) } - @Test fun async_failure_filterDuplicates_true() { + @Test + fun async_failure_filterDuplicates_true() { mockWiseFyPrechecksUtil.getNearbyAccessPoints_success() mockWiseFySearchUtil.nearbyAccessPoints_null(true) val mockCallbacks = mock(GetNearbyAccessPointsCallbacks::class.java) @@ -103,13 +114,15 @@ internal class GetNearbyAccessPointsTests : BaseInstrumentationTest() { verify(mockCallbacks, timeout(VERIFICATION_SUCCESS_TIMEOUT)).noAccessPointsFound() } - @Test fun async_failure_filterDuplicates_true_nullCallback() { + @Test + fun async_failure_filterDuplicates_true_nullCallback() { mockWiseFyPrechecksUtil.getNearbyAccessPoints_success() mockWiseFySearchUtil.nearbyAccessPoints_null(true) nullCallbackUtil.callGetNearbyAccessPoints(true) } - @Test fun async_success_filterDuplicates_false() { + @Test + fun async_success_filterDuplicates_false() { mockWiseFyPrechecksUtil.getNearbyAccessPoints_success() val accessPoints = mockWiseFySearchUtil.nearbyAccessPoints_success(false) val mockCallbacks = mock(GetNearbyAccessPointsCallbacks::class.java) @@ -117,13 +130,15 @@ internal class GetNearbyAccessPointsTests : BaseInstrumentationTest() { verify(mockCallbacks, timeout(VERIFICATION_SUCCESS_TIMEOUT)).retrievedNearbyAccessPoints(accessPoints) } - @Test fun async_success_filterDuplicates_false_nullCallback() { + @Test + fun async_success_filterDuplicates_false_nullCallback() { mockWiseFyPrechecksUtil.getNearbyAccessPoints_success() mockWiseFySearchUtil.nearbyAccessPoints_success(true) nullCallbackUtil.callGetNearbyAccessPoints(false) } - @Test fun async_success_filterDuplicates_true() { + @Test + fun async_success_filterDuplicates_true() { mockWiseFyPrechecksUtil.getNearbyAccessPoints_success() val accessPoints = mockWiseFySearchUtil.nearbyAccessPoints_success(true) val mockCallbacks = mock(GetNearbyAccessPointsCallbacks::class.java) @@ -131,7 +146,8 @@ internal class GetNearbyAccessPointsTests : BaseInstrumentationTest() { verify(mockCallbacks, timeout(VERIFICATION_SUCCESS_TIMEOUT)).retrievedNearbyAccessPoints(accessPoints) } - @Test fun async_success_filterDuplicates_true_nullCallback() { + @Test + fun async_success_filterDuplicates_true_nullCallback() { mockWiseFyPrechecksUtil.getNearbyAccessPoints_success() mockWiseFySearchUtil.nearbyAccessPoints_success(true) nullCallbackUtil.callGetNearbyAccessPoints(true) diff --git a/wisefy/src/androidTest/java/com/isupatches/wisefy/GetRSSITests.kt b/wisefy/src/androidTest/java/com/isupatches/wisefy/GetRSSITests.kt index 2df3dfe3..2977d411 100644 --- a/wisefy/src/androidTest/java/com/isupatches/wisefy/GetRSSITests.kt +++ b/wisefy/src/androidTest/java/com/isupatches/wisefy/GetRSSITests.kt @@ -3,11 +3,9 @@ package com.isupatches.wisefy import com.isupatches.wisefy.callbacks.GetRSSICallbacks import com.isupatches.wisefy.constants.MISSING_PARAMETER import com.isupatches.wisefy.internal.base.BaseInstrumentationTest - import org.junit.Assert.assertEquals import org.junit.Assert.fail import org.junit.Test - import org.mockito.Mockito.mock import org.mockito.Mockito.timeout import org.mockito.Mockito.verify @@ -20,29 +18,34 @@ import org.mockito.Mockito.verify */ internal class GetRSSITests : BaseInstrumentationTest() { - @Test fun sync_failure_prechecks_takeHighest_false() { + @Test + fun sync_failure_prechecks_takeHighest_false() { mockWiseFyPrechecksUtil.getRSSI_failure() assertEquals(null, wisefy.getRSSI(TEST_SSID, false, TEST_TIMEOUT)) } - @Test fun sync_failure_prechecks_takeHighest_true() { + @Test + fun sync_failure_prechecks_takeHighest_true() { mockWiseFyPrechecksUtil.getRSSI_failure() assertEquals(null, wisefy.getRSSI(TEST_SSID, true, TEST_TIMEOUT)) } - @Test fun sync_failure_noNetworkFound_takeHighest_false() { + @Test + fun sync_failure_noNetworkFound_takeHighest_false() { mockWiseFyPrechecksUtil.getRSSI_success() mockWiseFySearchUtil.findAccessPointByRegex_null() assertEquals(null, wisefy.getRSSI(TEST_SSID, false, TEST_TIMEOUT)) } - @Test fun sync_failure_noNetworkFound_takeHighest_true() { + @Test + fun sync_failure_noNetworkFound_takeHighest_true() { mockWiseFyPrechecksUtil.getRSSI_success() mockWiseFySearchUtil.findAccessPointByRegex_null() assertEquals(null, wisefy.getRSSI(TEST_SSID, true, TEST_TIMEOUT)) } - @Test fun sync_success_takeHighest_false() { + @Test + fun sync_success_takeHighest_false() { mockWiseFyPrechecksUtil.getRSSI_success() mockWiseFySearchUtil.findAccessPointByRegex_success() @@ -54,7 +57,8 @@ internal class GetRSSITests : BaseInstrumentationTest() { } } - @Test fun sync_success_takeHighest_true() { + @Test + fun sync_success_takeHighest_true() { mockWiseFyPrechecksUtil.getRSSI_success() mockWiseFySearchUtil.findAccessPointByRegex_success() @@ -66,31 +70,36 @@ internal class GetRSSITests : BaseInstrumentationTest() { } } - @Test fun async_failure_prechecks_takeHighest_false() { + @Test + fun async_failure_prechecks_takeHighest_false() { mockWiseFyPrechecksUtil.getRSSI_failure() val mockCallbacks = mock(GetRSSICallbacks::class.java) wisefy.getRSSI(TEST_SSID, false, TEST_TIMEOUT, mockCallbacks) verify(mockCallbacks, timeout(VERIFICATION_SUCCESS_TIMEOUT)).wisefyFailure(MISSING_PARAMETER) } - @Test fun async_failure_prechecks_takeHighest_false_nullCallback() { + @Test + fun async_failure_prechecks_takeHighest_false_nullCallback() { mockWiseFyPrechecksUtil.getRSSI_failure() nullCallbackUtil.callGetRSSI(false) } - @Test fun async_failure_prechecks_takeHighest_true() { + @Test + fun async_failure_prechecks_takeHighest_true() { mockWiseFyPrechecksUtil.getRSSI_failure() val mockCallbacks = mock(GetRSSICallbacks::class.java) wisefy.getRSSI(TEST_SSID, true, TEST_TIMEOUT, mockCallbacks) verify(mockCallbacks, timeout(VERIFICATION_SUCCESS_TIMEOUT)).wisefyFailure(MISSING_PARAMETER) } - @Test fun async_failure_prechecks_takeHighest_true_nullCallback() { + @Test + fun async_failure_prechecks_takeHighest_true_nullCallback() { mockWiseFyPrechecksUtil.getRSSI_failure() nullCallbackUtil.callGetRSSI(true) } - @Test fun async_failure_noNetworkFound_takeHighest_false() { + @Test + fun async_failure_noNetworkFound_takeHighest_false() { mockWiseFyPrechecksUtil.getRSSI_success() mockWiseFySearchUtil.findAccessPointByRegex_null() val mockCallbacks = mock(GetRSSICallbacks::class.java) @@ -98,13 +107,15 @@ internal class GetRSSITests : BaseInstrumentationTest() { verify(mockCallbacks, timeout(VERIFICATION_SUCCESS_TIMEOUT)).networkNotFoundToRetrieveRSSI() } - @Test fun async_failure_noNetworkFound_takeHighest_false_nullCallback() { + @Test + fun async_failure_noNetworkFound_takeHighest_false_nullCallback() { mockWiseFyPrechecksUtil.getRSSI_success() mockWiseFySearchUtil.findAccessPointByRegex_null() nullCallbackUtil.callGetRSSI(false) } - @Test fun async_failure_noNetworkFound_takeHighest_true() { + @Test + fun async_failure_noNetworkFound_takeHighest_true() { mockWiseFyPrechecksUtil.getRSSI_success() mockWiseFySearchUtil.findAccessPointByRegex_null() val mockCallbacks = mock(GetRSSICallbacks::class.java) @@ -112,13 +123,15 @@ internal class GetRSSITests : BaseInstrumentationTest() { verify(mockCallbacks, timeout(VERIFICATION_SUCCESS_TIMEOUT)).networkNotFoundToRetrieveRSSI() } - @Test fun async_failure_noNetworkFound_takeHighest_true_nullCallback() { + @Test + fun async_failure_noNetworkFound_takeHighest_true_nullCallback() { mockWiseFyPrechecksUtil.getRSSI_success() mockWiseFySearchUtil.findAccessPointByRegex_null() nullCallbackUtil.callGetRSSI(true) } - @Test fun async_success_takeHighest_false() { + @Test + fun async_success_takeHighest_false() { mockWiseFyPrechecksUtil.getRSSI_success() mockWiseFySearchUtil.findAccessPointByRegex_success() val mockCallbacks = mock(GetRSSICallbacks::class.java) @@ -126,13 +139,15 @@ internal class GetRSSITests : BaseInstrumentationTest() { verify(mockCallbacks, timeout(VERIFICATION_SUCCESS_TIMEOUT)).retrievedRSSI(TEST_RSSI_LEVEL) } - @Test fun async_success_takeHighest_false_nullCallback() { + @Test + fun async_success_takeHighest_false_nullCallback() { mockWiseFyPrechecksUtil.getRSSI_success() mockWiseFySearchUtil.findAccessPointByRegex_success() nullCallbackUtil.callGetRSSI(false) } - @Test fun async_success_takeHighest_true() { + @Test + fun async_success_takeHighest_true() { mockWiseFyPrechecksUtil.getRSSI_success() mockWiseFySearchUtil.findAccessPointByRegex_success() val mockCallbacks = mock(GetRSSICallbacks::class.java) @@ -140,7 +155,8 @@ internal class GetRSSITests : BaseInstrumentationTest() { verify(mockCallbacks, timeout(VERIFICATION_SUCCESS_TIMEOUT)).retrievedRSSI(TEST_RSSI_LEVEL) } - @Test fun async_success_takeHighest_true_nullCallback() { + @Test + fun async_success_takeHighest_true_nullCallback() { mockWiseFyPrechecksUtil.getRSSI_success() mockWiseFySearchUtil.findAccessPointByRegex_success() nullCallbackUtil.callGetRSSI(true) diff --git a/wisefy/src/androidTest/java/com/isupatches/wisefy/GetSavedNetworksTests.kt b/wisefy/src/androidTest/java/com/isupatches/wisefy/GetSavedNetworksTests.kt index 207843d7..c5a24db5 100644 --- a/wisefy/src/androidTest/java/com/isupatches/wisefy/GetSavedNetworksTests.kt +++ b/wisefy/src/androidTest/java/com/isupatches/wisefy/GetSavedNetworksTests.kt @@ -3,10 +3,8 @@ package com.isupatches.wisefy import com.isupatches.wisefy.callbacks.GetSavedNetworksCallbacks import com.isupatches.wisefy.constants.MISSING_PARAMETER import com.isupatches.wisefy.internal.base.BaseInstrumentationTest - import org.junit.Assert.assertEquals import org.junit.Test - import org.mockito.Mockito.mock import org.mockito.Mockito.timeout import org.mockito.Mockito.verify @@ -19,20 +17,23 @@ import org.mockito.Mockito.verify */ internal class GetSavedNetworksTests : BaseInstrumentationTest() { - @Test fun sync_failure_prechecks() { + @Test + fun sync_failure_prechecks() { mockWiseFyPrechecksUtil.getSavedNetworks_failure() assertEquals(null, wisefy.getSavedNetworks()) verificationUtil.didNotTryToGetSavedNetworks() } - @Test fun sync_success() { + @Test + fun sync_success() { mockWiseFyPrechecksUtil.getSavedNetworks_success() val savedNetworks = mockNetworkUtil.savedNetworks() assertEquals(savedNetworks, wisefy.getSavedNetworks()) verificationUtil.triedToGetSavedNetworks() } - @Test fun async_failure_prechecks() { + @Test + fun async_failure_prechecks() { mockWiseFyPrechecksUtil.getSavedNetworks_failure() val mockCallbacks = mock(GetSavedNetworksCallbacks::class.java) wisefy.getSavedNetworks(mockCallbacks) @@ -40,13 +41,15 @@ internal class GetSavedNetworksTests : BaseInstrumentationTest() { verificationUtil.didNotTryToGetSavedNetworks() } - @Test fun async_failure_prechecks_nullCallback() { + @Test + fun async_failure_prechecks_nullCallback() { mockWiseFyPrechecksUtil.getSavedNetworks_failure() nullCallbackUtil.callGetSavedNetworks() verificationUtil.didNotTryToGetSavedNetworks() } - @Test fun async_failure_nullSavedNetworks() { + @Test + fun async_failure_nullSavedNetworks() { mockWiseFyPrechecksUtil.getSavedNetworks_success() mockNetworkUtil.savedNetworks_nullList() val mockCallbacks = mock(GetSavedNetworksCallbacks::class.java) @@ -55,14 +58,16 @@ internal class GetSavedNetworksTests : BaseInstrumentationTest() { verificationUtil.triedToGetSavedNetworks() } - @Test fun async_failure_nullSavedNetworks_nullCallback() { + @Test + fun async_failure_nullSavedNetworks_nullCallback() { mockWiseFyPrechecksUtil.getSavedNetworks_success() mockNetworkUtil.savedNetworks_nullList() nullCallbackUtil.callGetSavedNetworks() verificationUtil.triedToGetSavedNetworks() } - @Test fun async_failure_emptyConfiguredNetworks() { + @Test + fun async_failure_emptyConfiguredNetworks() { mockWiseFyPrechecksUtil.getSavedNetworks_success() mockNetworkUtil.savedNetworks_emptyList() val mockCallbacks = mock(GetSavedNetworksCallbacks::class.java) @@ -71,14 +76,16 @@ internal class GetSavedNetworksTests : BaseInstrumentationTest() { verificationUtil.triedToGetSavedNetworks() } - @Test fun async_failure_emptyConfiguredNetworks_nullCallback() { + @Test + fun async_failure_emptyConfiguredNetworks_nullCallback() { mockWiseFyPrechecksUtil.getSavedNetworks_success() mockNetworkUtil.savedNetworks_emptyList() nullCallbackUtil.callGetSavedNetworks() verificationUtil.triedToGetSavedNetworks() } - @Test fun async_success() { + @Test + fun async_success() { mockWiseFyPrechecksUtil.getSavedNetworks_success() val savedNetworks = mockNetworkUtil.savedNetworks() val mockCallbacks = mock(GetSavedNetworksCallbacks::class.java) @@ -87,7 +94,8 @@ internal class GetSavedNetworksTests : BaseInstrumentationTest() { verificationUtil.triedToGetSavedNetworks() } - @Test fun async_success_nullCallback() { + @Test + fun async_success_nullCallback() { mockWiseFyPrechecksUtil.getSavedNetworks_success() mockNetworkUtil.savedNetworks() nullCallbackUtil.callGetSavedNetworks() diff --git a/wisefy/src/androidTest/java/com/isupatches/wisefy/IsDeviceConnectedToMobileNetworkTests.kt b/wisefy/src/androidTest/java/com/isupatches/wisefy/IsDeviceConnectedToMobileNetworkTests.kt index 99af9a0f..37f94488 100644 --- a/wisefy/src/androidTest/java/com/isupatches/wisefy/IsDeviceConnectedToMobileNetworkTests.kt +++ b/wisefy/src/androidTest/java/com/isupatches/wisefy/IsDeviceConnectedToMobileNetworkTests.kt @@ -1,7 +1,6 @@ package com.isupatches.wisefy import com.isupatches.wisefy.internal.base.BaseInstrumentationTest - import org.junit.Assert.assertFalse import org.junit.Assert.assertTrue import org.junit.Test @@ -14,18 +13,21 @@ import org.junit.Test */ internal class IsDeviceConnectedToMobileNetworkTests : BaseInstrumentationTest() { - @Test fun failure_prechecks() { + @Test + fun failure_prechecks() { mockWiseFyPrechecksUtil.isDeviceConnectedToMobileNetwork_failure() assertFalse(wisefy.isDeviceConnectedToMobileNetwork()) } - @Test fun failure() { + @Test + fun failure() { mockWiseFyPrechecksUtil.isDeviceConnectedToMobileNetwork_success() mockWiseFyConnectionUtil.isDeviceConnectedToMobileNetwork(false) assertFalse(wisefy.isDeviceConnectedToMobileNetwork()) } - @Test fun success() { + @Test + fun success() { mockWiseFyPrechecksUtil.isDeviceConnectedToMobileNetwork_success() mockNetworkUtil.activeNetwork() mockWiseFyConnectionUtil.isDeviceConnectedToMobileNetwork(true) diff --git a/wisefy/src/androidTest/java/com/isupatches/wisefy/IsDeviceConnectedToMobileOrWifiNetworkTests.kt b/wisefy/src/androidTest/java/com/isupatches/wisefy/IsDeviceConnectedToMobileOrWifiNetworkTests.kt index b6ddba84..0452130d 100644 --- a/wisefy/src/androidTest/java/com/isupatches/wisefy/IsDeviceConnectedToMobileOrWifiNetworkTests.kt +++ b/wisefy/src/androidTest/java/com/isupatches/wisefy/IsDeviceConnectedToMobileOrWifiNetworkTests.kt @@ -1,7 +1,6 @@ package com.isupatches.wisefy import com.isupatches.wisefy.internal.base.BaseInstrumentationTest - import org.junit.Assert.assertFalse import org.junit.Assert.assertTrue import org.junit.Test @@ -14,18 +13,21 @@ import org.junit.Test */ internal class IsDeviceConnectedToMobileOrWifiNetworkTests : BaseInstrumentationTest() { - @Test fun failure_missingPrerequisite() { + @Test + fun failure_missingPrerequisite() { mockWiseFyPrechecksUtil.isDeviceConnectedToMobileOrWifiNetwork_failure() assertFalse(wisefy.isDeviceConnectedToMobileOrWifiNetwork()) } - @Test fun failure() { + @Test + fun failure() { mockWiseFyPrechecksUtil.isDeviceConnectedToMobileOrWifiNetwork_success() mockWiseFyConnectionUtil.isNetworkConnected(false) assertFalse(wisefy.isDeviceConnectedToMobileOrWifiNetwork()) } - @Test fun success() { + @Test + fun success() { mockWiseFyPrechecksUtil.isDeviceConnectedToMobileOrWifiNetwork_success() mockNetworkUtil.activeNetwork() mockWiseFyConnectionUtil.isNetworkConnected(true) diff --git a/wisefy/src/androidTest/java/com/isupatches/wisefy/IsDeviceConnectedToSSIDTests.kt b/wisefy/src/androidTest/java/com/isupatches/wisefy/IsDeviceConnectedToSSIDTests.kt index 81418dc4..e2860fb8 100644 --- a/wisefy/src/androidTest/java/com/isupatches/wisefy/IsDeviceConnectedToSSIDTests.kt +++ b/wisefy/src/androidTest/java/com/isupatches/wisefy/IsDeviceConnectedToSSIDTests.kt @@ -1,7 +1,6 @@ package com.isupatches.wisefy import com.isupatches.wisefy.internal.base.BaseInstrumentationTest - import org.junit.Assert.assertFalse import org.junit.Assert.assertTrue import org.junit.Test @@ -14,18 +13,21 @@ import org.junit.Test */ internal class IsDeviceConnectedToSSIDTests : BaseInstrumentationTest() { - @Test fun failure_prechecks() { + @Test + fun failure_prechecks() { mockWiseFyPrechecksUtil.isDeviceConnectedToSSIDChecks_failure() assertFalse(wisefy.isDeviceConnectedToSSID(TEST_SSID)) } - @Test fun failure() { + @Test + fun failure() { mockWiseFyPrechecksUtil.isDeviceConnectedToSSIDChecks_success() mockWiseFyConnectionUtil.isCurrentNetworkConnectedToSSID(false) assertFalse(wisefy.isDeviceConnectedToSSID(TEST_SSID)) } - @Test fun success() { + @Test + fun success() { mockWiseFyPrechecksUtil.isDeviceConnectedToSSIDChecks_success() mockWiseFyConnectionUtil.isCurrentNetworkConnectedToSSID(true) assertTrue(wisefy.isDeviceConnectedToSSID(TEST_SSID)) diff --git a/wisefy/src/androidTest/java/com/isupatches/wisefy/IsDeviceConnectedToWifiNetworkTests.kt b/wisefy/src/androidTest/java/com/isupatches/wisefy/IsDeviceConnectedToWifiNetworkTests.kt index 129b2b1c..c93a2dcd 100644 --- a/wisefy/src/androidTest/java/com/isupatches/wisefy/IsDeviceConnectedToWifiNetworkTests.kt +++ b/wisefy/src/androidTest/java/com/isupatches/wisefy/IsDeviceConnectedToWifiNetworkTests.kt @@ -1,7 +1,6 @@ package com.isupatches.wisefy import com.isupatches.wisefy.internal.base.BaseInstrumentationTest - import org.junit.Assert.assertFalse import org.junit.Assert.assertTrue import org.junit.Test @@ -14,18 +13,21 @@ import org.junit.Test */ internal class IsDeviceConnectedToWifiNetworkTests : BaseInstrumentationTest() { - @Test fun failure_missingPrerequisite() { + @Test + fun failure_missingPrerequisite() { mockWiseFyPrechecksUtil.isDeviceConnectedToWifiNetwork_failure() assertFalse(wisefy.isDeviceConnectedToWifiNetwork()) } - @Test fun failure() { + @Test + fun failure() { mockWiseFyPrechecksUtil.isDeviceConnectedToWifiNetwork_success() mockWiseFyConnectionUtil.isDeviceConnectedToWifiNetwork(false) assertFalse(wisefy.isDeviceConnectedToWifiNetwork()) } - @Test fun success() { + @Test + fun success() { mockWiseFyPrechecksUtil.isDeviceConnectedToWifiNetwork_success() mockNetworkUtil.activeNetwork() mockWiseFyConnectionUtil.isDeviceConnectedToWifiNetwork(true) diff --git a/wisefy/src/androidTest/java/com/isupatches/wisefy/IsDeviceRoamingTests.kt b/wisefy/src/androidTest/java/com/isupatches/wisefy/IsDeviceRoamingTests.kt index afecd339..59dfaa3b 100644 --- a/wisefy/src/androidTest/java/com/isupatches/wisefy/IsDeviceRoamingTests.kt +++ b/wisefy/src/androidTest/java/com/isupatches/wisefy/IsDeviceRoamingTests.kt @@ -1,7 +1,6 @@ package com.isupatches.wisefy import com.isupatches.wisefy.internal.base.BaseInstrumentationTest - import org.junit.Assert.assertFalse import org.junit.Assert.assertTrue import org.junit.Test @@ -14,18 +13,21 @@ import org.junit.Test */ internal class IsDeviceRoamingTests : BaseInstrumentationTest() { - @Test fun failure_missingPrerequisite() { + @Test + fun failure_missingPrerequisite() { mockWiseFyPrechecksUtil.isDeviceRoaming_failure() assertFalse(wisefy.isDeviceRoaming()) } - @Test fun failure() { + @Test + fun failure() { mockWiseFyPrechecksUtil.isDeviceRoaming_success() mockWiseFyConnectionUtil.isDeviceRoaming(false) assertFalse(wisefy.isDeviceRoaming()) } - @Test fun success() { + @Test + fun success() { mockWiseFyPrechecksUtil.isDeviceRoaming_success() mockWiseFyConnectionUtil.isDeviceRoaming(true) assertTrue(wisefy.isDeviceRoaming()) diff --git a/wisefy/src/androidTest/java/com/isupatches/wisefy/IsNetwork5gHzTests.kt b/wisefy/src/androidTest/java/com/isupatches/wisefy/IsNetwork5gHzTests.kt index f96118fe..62b4a1ca 100644 --- a/wisefy/src/androidTest/java/com/isupatches/wisefy/IsNetwork5gHzTests.kt +++ b/wisefy/src/androidTest/java/com/isupatches/wisefy/IsNetwork5gHzTests.kt @@ -1,9 +1,7 @@ package com.isupatches.wisefy import android.os.Build - import com.isupatches.wisefy.internal.base.BaseInstrumentationTest - import org.junit.Assert.assertEquals import org.junit.Assume.assumeTrue import org.junit.Before @@ -17,52 +15,65 @@ import org.junit.Test */ internal class IsNetwork5gHzTests : BaseInstrumentationTest() { - @Before fun setUp() { + @Before + fun setUp() { assumeTrue( - "Can only run on API Level 21 or newer", - Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP + "Can only run on API Level 21 or newer", + Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP ) } - @Test fun currentNetwork_failure_above5ghz() { + @Test + fun currentNetwork_failure_above5ghz() { + mockWiseFyPrechecksUtil.getFrequency_success() mockWiseFyPrechecksUtil.getCurrentNetwork_success() mockNetworkUtil.networkWithFrequency(TEST_NETWORK_FREQUENCY_ABOVE_5GHZ) assertEquals(false, wisefy.isNetwork5gHz()) } - @Test fun currentNetwork_failure_below5ghz() { + @Test + fun currentNetwork_failure_below5ghz() { + mockWiseFyPrechecksUtil.getFrequency_success() mockWiseFyPrechecksUtil.getCurrentNetwork_success() mockNetworkUtil.networkWithFrequency(TEST_NETWORK_FREQUENCY_BELOW_5GHZ) assertEquals(false, wisefy.isNetwork5gHz()) } - @Test fun currentNetwork_failure_null() { + @Test + fun currentNetwork_failure_null() { + mockWiseFyPrechecksUtil.getFrequency_success() mockWiseFyPrechecksUtil.getCurrentNetwork_success() mockNetworkUtil.currentNetwork_null() assertEquals(false, wisefy.isNetwork5gHz()) } - @Test fun currentNetwork_success() { + @Test + fun currentNetwork_success() { + mockWiseFyPrechecksUtil.getFrequency_success() mockWiseFyPrechecksUtil.getCurrentNetwork_success() mockNetworkUtil.networkWithFrequency(TEST_NETWORK_FREQUENCY_5GHZ) assertEquals(true, wisefy.isNetwork5gHz()) } - @Test fun provideWifiInfo_failure_above5ghz() { + @Test + fun provideWifiInfo_failure_above5ghz() { val network = mockNetworkUtil.networkWithFrequency(TEST_NETWORK_FREQUENCY_ABOVE_5GHZ) assertEquals(false, wisefy.isNetwork5gHz(network)) } - @Test fun provideWifiInfo_failure_below5ghz() { + @Test + fun provideWifiInfo_failure_below5ghz() { val network = mockNetworkUtil.networkWithFrequency(TEST_NETWORK_FREQUENCY_BELOW_5GHZ) assertEquals(false, wisefy.isNetwork5gHz(network)) } - @Test fun provideWifiInfo_failure_null() { + @Test + fun provideWifiInfo_failure_null() { assertEquals(false, wisefy.isNetwork5gHz(null)) } - @Test fun provideWifiInfo_success() { + @Test + fun provideWifiInfo_success() { val mockWifiInfo = mockNetworkUtil.networkWithFrequency(TEST_NETWORK_FREQUENCY_5GHZ) assertEquals(true, wisefy.isNetwork5gHz(mockWifiInfo)) } diff --git a/wisefy/src/androidTest/java/com/isupatches/wisefy/IsNetworkEAPTests.kt b/wisefy/src/androidTest/java/com/isupatches/wisefy/IsNetworkEAPTests.kt index 4e8267ed..2be17305 100644 --- a/wisefy/src/androidTest/java/com/isupatches/wisefy/IsNetworkEAPTests.kt +++ b/wisefy/src/androidTest/java/com/isupatches/wisefy/IsNetworkEAPTests.kt @@ -3,7 +3,6 @@ package com.isupatches.wisefy import com.isupatches.wisefy.constants.EAP import com.isupatches.wisefy.internal.base.BaseInstrumentationTest import com.isupatches.wisefy.internal.createMockAccessPointWithCapabilities - import org.junit.Assert.assertEquals import org.junit.Test @@ -15,26 +14,31 @@ import org.junit.Test */ internal class IsNetworkEAPTests : BaseInstrumentationTest() { - @Test fun failure_differentCapability() { + @Test + fun failure_differentCapability() { val scanResult = createMockAccessPointWithCapabilities("Other") assertEquals(false, wisefy.isNetworkEAP(scanResult)) } - @Test fun failure_emptyCapabilities() { + @Test + fun failure_emptyCapabilities() { val scanResult = createMockAccessPointWithCapabilities("") assertEquals(false, wisefy.isNetworkEAP(scanResult)) } - @Test fun failure_nullCapabilities() { + @Test + fun failure_nullCapabilities() { val scanResult = createMockAccessPointWithCapabilities(null) assertEquals(false, wisefy.isNetworkEAP(scanResult)) } - @Test fun failure_nullScanResult() { + @Test + fun failure_nullScanResult() { assertEquals(false, wisefy.isNetworkEAP(null)) } - @Test fun success() { + @Test + fun success() { val scanResult = createMockAccessPointWithCapabilities(EAP) assertEquals(true, wisefy.isNetworkEAP(scanResult)) } diff --git a/wisefy/src/androidTest/java/com/isupatches/wisefy/IsNetworkPSKTest.kt b/wisefy/src/androidTest/java/com/isupatches/wisefy/IsNetworkPSKTest.kt index 8a978719..7c8cd0fa 100644 --- a/wisefy/src/androidTest/java/com/isupatches/wisefy/IsNetworkPSKTest.kt +++ b/wisefy/src/androidTest/java/com/isupatches/wisefy/IsNetworkPSKTest.kt @@ -3,7 +3,6 @@ package com.isupatches.wisefy import com.isupatches.wisefy.constants.PSK import com.isupatches.wisefy.internal.base.BaseInstrumentationTest import com.isupatches.wisefy.internal.createMockAccessPointWithCapabilities - import org.junit.Assert.assertEquals import org.junit.Test @@ -15,26 +14,31 @@ import org.junit.Test */ internal class IsNetworkPSKTest : BaseInstrumentationTest() { - @Test fun failure_differentCapability() { + @Test + fun failure_differentCapability() { val scanResult = createMockAccessPointWithCapabilities("Other") assertEquals(false, wisefy.isNetworkPSK(scanResult)) } - @Test fun failure_emptyCapabilities() { + @Test + fun failure_emptyCapabilities() { val scanResult = createMockAccessPointWithCapabilities("") assertEquals(false, wisefy.isNetworkPSK(scanResult)) } - @Test fun failure_nullCapabilities() { + @Test + fun failure_nullCapabilities() { val scanResult = createMockAccessPointWithCapabilities(null) assertEquals(false, wisefy.isNetworkPSK(scanResult)) } - @Test fun failure_nullScanResult() { + @Test + fun failure_nullScanResult() { assertEquals(false, wisefy.isNetworkPSK(null)) } - @Test fun success() { + @Test + fun success() { val scanResult = createMockAccessPointWithCapabilities(PSK) assertEquals(true, wisefy.isNetworkPSK(scanResult)) } diff --git a/wisefy/src/androidTest/java/com/isupatches/wisefy/IsNetworkSavedTests.kt b/wisefy/src/androidTest/java/com/isupatches/wisefy/IsNetworkSavedTests.kt index 950bee3e..d63607bc 100644 --- a/wisefy/src/androidTest/java/com/isupatches/wisefy/IsNetworkSavedTests.kt +++ b/wisefy/src/androidTest/java/com/isupatches/wisefy/IsNetworkSavedTests.kt @@ -1,7 +1,6 @@ package com.isupatches.wisefy import com.isupatches.wisefy.internal.base.BaseInstrumentationTest - import org.junit.Assert.assertEquals import org.junit.Test @@ -13,18 +12,21 @@ import org.junit.Test */ internal class IsNetworkSavedTests : BaseInstrumentationTest() { - @Test fun failure_missingPrerequisite() { + @Test + fun failure_missingPrerequisite() { mockWiseFyPrechecksUtil.isNetworkSaved_failure() assertEquals(false, wisefy.isNetworkSaved(TEST_SSID)) } - @Test fun failure() { + @Test + fun failure() { mockWiseFyPrechecksUtil.isNetworkSaved_success() mockWiseFySearchUtil.isNetworkASavedConfiguration(false) assertEquals(false, wisefy.isNetworkSaved(TEST_SSID)) } - @Test fun success() { + @Test + fun success() { mockWiseFyPrechecksUtil.isNetworkSaved_success() mockWiseFySearchUtil.isNetworkASavedConfiguration(true) assertEquals(true, wisefy.isNetworkSaved(TEST_SSID)) diff --git a/wisefy/src/androidTest/java/com/isupatches/wisefy/IsNetworkSecureTests.kt b/wisefy/src/androidTest/java/com/isupatches/wisefy/IsNetworkSecureTests.kt index 7cb2ba69..a0904d28 100644 --- a/wisefy/src/androidTest/java/com/isupatches/wisefy/IsNetworkSecureTests.kt +++ b/wisefy/src/androidTest/java/com/isupatches/wisefy/IsNetworkSecureTests.kt @@ -7,7 +7,6 @@ import com.isupatches.wisefy.constants.WPA import com.isupatches.wisefy.constants.WPA2 import com.isupatches.wisefy.internal.base.BaseInstrumentationTest import com.isupatches.wisefy.internal.createMockAccessPointWithCapabilities - import org.junit.Assert.assertEquals import org.junit.Test @@ -19,46 +18,55 @@ import org.junit.Test */ internal class IsNetworkSecureTests : BaseInstrumentationTest() { - @Test fun failure_emptyCapabilities() { + @Test + fun failure_emptyCapabilities() { val scanResult = createMockAccessPointWithCapabilities("") assertEquals(false, wisefy.isNetworkSecure(scanResult)) } - @Test fun failure_nullCapabilities() { + @Test + fun failure_nullCapabilities() { val scanResult = createMockAccessPointWithCapabilities(null) assertEquals(false, wisefy.isNetworkSecure(scanResult)) } - @Test fun failure_nullScanResult() { + @Test + fun failure_nullScanResult() { assertEquals(false, wisefy.isNetworkSecure(null)) } - @Test fun success_withEAP() { + @Test + fun success_withEAP() { val scanResult = createMockAccessPointWithCapabilities(EAP) assertEquals(true, wisefy.isNetworkSecure(scanResult)) } - @Test fun success_withPSK() { + @Test + fun success_withPSK() { val scanResult = createMockAccessPointWithCapabilities(PSK) assertEquals(true, wisefy.isNetworkSecure(scanResult)) } - @Test fun success_withWEP() { + @Test + fun success_withWEP() { val scanResult = createMockAccessPointWithCapabilities(WEP) assertEquals(true, wisefy.isNetworkSecure(scanResult)) } - @Test fun success_withWPA() { + @Test + fun success_withWPA() { val scanResult = createMockAccessPointWithCapabilities(WPA) assertEquals(true, wisefy.isNetworkSecure(scanResult)) } - @Test fun success_withWPA2() { + @Test + fun success_withWPA2() { val scanResult = createMockAccessPointWithCapabilities(WPA2) assertEquals(true, wisefy.isNetworkSecure(scanResult)) } - @Test fun failure_otherCapabilities() { + @Test + fun failure_otherCapabilities() { val scanResult = createMockAccessPointWithCapabilities("Other") assertEquals(false, wisefy.isNetworkSecure(scanResult)) } diff --git a/wisefy/src/androidTest/java/com/isupatches/wisefy/IsNetworkWPA2Test.kt b/wisefy/src/androidTest/java/com/isupatches/wisefy/IsNetworkWPA2Test.kt index 2daf3770..4a0b37c5 100644 --- a/wisefy/src/androidTest/java/com/isupatches/wisefy/IsNetworkWPA2Test.kt +++ b/wisefy/src/androidTest/java/com/isupatches/wisefy/IsNetworkWPA2Test.kt @@ -3,7 +3,6 @@ package com.isupatches.wisefy import com.isupatches.wisefy.constants.WPA2 import com.isupatches.wisefy.internal.base.BaseInstrumentationTest import com.isupatches.wisefy.internal.createMockAccessPointWithCapabilities - import org.junit.Assert.assertEquals import org.junit.Test @@ -15,26 +14,31 @@ import org.junit.Test */ internal class IsNetworkWPA2Test : BaseInstrumentationTest() { - @Test fun failure_differentCapability() { + @Test + fun failure_differentCapability() { val scanResult = createMockAccessPointWithCapabilities("Other") assertEquals(false, wisefy.isNetworkWPA2(scanResult)) } - @Test fun failure_emptyCapabilities() { + @Test + fun failure_emptyCapabilities() { val scanResult = createMockAccessPointWithCapabilities("") assertEquals(false, wisefy.isNetworkWPA2(scanResult)) } - @Test fun failure_nullCapabilities() { + @Test + fun failure_nullCapabilities() { val scanResult = createMockAccessPointWithCapabilities(null) assertEquals(false, wisefy.isNetworkWPA2(scanResult)) } - @Test fun failure_nullScanResult() { + @Test + fun failure_nullScanResult() { assertEquals(false, wisefy.isNetworkWPA2(null)) } - @Test fun success() { + @Test + fun success() { val scanResult = createMockAccessPointWithCapabilities(WPA2) assertEquals(true, wisefy.isNetworkWPA2(scanResult)) } diff --git a/wisefy/src/androidTest/java/com/isupatches/wisefy/IsNetworkWPATests.kt b/wisefy/src/androidTest/java/com/isupatches/wisefy/IsNetworkWPATests.kt index 12f13c1f..7516a916 100644 --- a/wisefy/src/androidTest/java/com/isupatches/wisefy/IsNetworkWPATests.kt +++ b/wisefy/src/androidTest/java/com/isupatches/wisefy/IsNetworkWPATests.kt @@ -3,7 +3,6 @@ package com.isupatches.wisefy import com.isupatches.wisefy.constants.WPA import com.isupatches.wisefy.internal.base.BaseInstrumentationTest import com.isupatches.wisefy.internal.createMockAccessPointWithCapabilities - import org.junit.Assert.assertEquals import org.junit.Test @@ -15,26 +14,31 @@ import org.junit.Test */ internal class IsNetworkWPATests : BaseInstrumentationTest() { - @Test fun failure_differentCapability() { + @Test + fun failure_differentCapability() { val scanResult = createMockAccessPointWithCapabilities("Other") assertEquals(false, wisefy.isNetworkWPA(scanResult)) } - @Test fun failure_emptyCapabilities() { + @Test + fun failure_emptyCapabilities() { val scanResult = createMockAccessPointWithCapabilities("") assertEquals(false, wisefy.isNetworkWPA(scanResult)) } - @Test fun failure_nullCapabilities() { + @Test + fun failure_nullCapabilities() { val scanResult = createMockAccessPointWithCapabilities(null) assertEquals(false, wisefy.isNetworkWPA(scanResult)) } - @Test fun failure_nullScanResult() { + @Test + fun failure_nullScanResult() { assertEquals(false, wisefy.isNetworkWPA(null)) } - @Test fun success() { + @Test + fun success() { val scanResult = createMockAccessPointWithCapabilities(WPA) assertEquals(true, wisefy.isNetworkWPA(scanResult)) } diff --git a/wisefy/src/androidTest/java/com/isupatches/wisefy/IsNetworkWepTests.kt b/wisefy/src/androidTest/java/com/isupatches/wisefy/IsNetworkWepTests.kt index bd0cc5ca..3837a723 100644 --- a/wisefy/src/androidTest/java/com/isupatches/wisefy/IsNetworkWepTests.kt +++ b/wisefy/src/androidTest/java/com/isupatches/wisefy/IsNetworkWepTests.kt @@ -3,7 +3,6 @@ package com.isupatches.wisefy import com.isupatches.wisefy.constants.WEP import com.isupatches.wisefy.internal.base.BaseInstrumentationTest import com.isupatches.wisefy.internal.createMockAccessPointWithCapabilities - import org.junit.Assert.assertEquals import org.junit.Test @@ -15,26 +14,31 @@ import org.junit.Test */ internal class IsNetworkWepTests : BaseInstrumentationTest() { - @Test fun failure_differentCapability() { + @Test + fun failure_differentCapability() { val scanResult = createMockAccessPointWithCapabilities("Other") assertEquals(false, wisefy.isNetworkWEP(scanResult)) } - @Test fun failure_emptyCapabilities() { + @Test + fun failure_emptyCapabilities() { val scanResult = createMockAccessPointWithCapabilities("") assertEquals(false, wisefy.isNetworkWEP(scanResult)) } - @Test fun failure_nullCapabilities() { + @Test + fun failure_nullCapabilities() { val scanResult = createMockAccessPointWithCapabilities(null) assertEquals(false, wisefy.isNetworkWEP(scanResult)) } - @Test fun failure_nullScanResult() { + @Test + fun failure_nullScanResult() { assertEquals(false, wisefy.isNetworkWEP(null)) } - @Test fun success() { + @Test + fun success() { val scanResult = createMockAccessPointWithCapabilities(WEP) assertEquals(true, wisefy.isNetworkWEP(scanResult)) } diff --git a/wisefy/src/androidTest/java/com/isupatches/wisefy/IsWifiEnabledTests.kt b/wisefy/src/androidTest/java/com/isupatches/wisefy/IsWifiEnabledTests.kt index 30ac8be6..c688701b 100644 --- a/wisefy/src/androidTest/java/com/isupatches/wisefy/IsWifiEnabledTests.kt +++ b/wisefy/src/androidTest/java/com/isupatches/wisefy/IsWifiEnabledTests.kt @@ -1,7 +1,6 @@ package com.isupatches.wisefy import com.isupatches.wisefy.internal.base.BaseInstrumentationTest - import org.junit.Assert.assertEquals import org.junit.Test @@ -13,18 +12,21 @@ import org.junit.Test */ internal class IsWifiEnabledTests : BaseInstrumentationTest() { - @Test fun failure_prechecks() { + @Test + fun failure_prechecks() { mockWiseFyPrechecksUtil.isWifiEnabled_failure() assertEquals(false, wisefy.isWifiEnabled()) } - @Test fun failure() { + @Test + fun failure() { mockWiseFyPrechecksUtil.isWifiEnabled_success() mockNetworkUtil.isWifiEnabled(false) assertEquals(false, wisefy.isWifiEnabled()) } - @Test fun success() { + @Test + fun success() { mockWiseFyPrechecksUtil.isWifiEnabled_success() mockNetworkUtil.isWifiEnabled(true) assertEquals(true, wisefy.isWifiEnabled()) diff --git a/wisefy/src/androidTest/java/com/isupatches/wisefy/RemoveNetworkTests.kt b/wisefy/src/androidTest/java/com/isupatches/wisefy/RemoveNetworkTests.kt index fd8d3b45..422c6681 100644 --- a/wisefy/src/androidTest/java/com/isupatches/wisefy/RemoveNetworkTests.kt +++ b/wisefy/src/androidTest/java/com/isupatches/wisefy/RemoveNetworkTests.kt @@ -3,10 +3,8 @@ package com.isupatches.wisefy import com.isupatches.wisefy.callbacks.RemoveNetworkCallbacks import com.isupatches.wisefy.constants.MISSING_PARAMETER import com.isupatches.wisefy.internal.base.BaseInstrumentationTest - import org.junit.Assert.assertEquals import org.junit.Test - import org.mockito.Mockito.mock import org.mockito.Mockito.timeout import org.mockito.Mockito.verify @@ -19,20 +17,23 @@ import org.mockito.Mockito.verify */ internal class RemoveNetworkTests : BaseInstrumentationTest() { - @Test fun sync_failure_prechecks() { + @Test + fun sync_failure_prechecks() { mockWiseFyPrechecksUtil.removeNetwork_failure() assertEquals(false, wisefy.removeNetwork(TEST_SSID)) verificationUtil.didNotTryToRemoveNetwork() } - @Test fun sync_failure_noSavedNetwork() { + @Test + fun sync_failure_noSavedNetwork() { mockWiseFyPrechecksUtil.removeNetwork_success() mockWiseFySearchUtil.findSavedNetworkByRegex_null() assertEquals(false, wisefy.removeNetwork(TEST_SSID)) verificationUtil.didNotTryToRemoveNetwork() } - @Test fun sync_failure() { + @Test + fun sync_failure() { mockWiseFyPrechecksUtil.removeNetwork_success() mockWiseFySearchUtil.findSavedNetworkByRegex_success() mockNetworkUtil.removeNetwork(false) @@ -40,7 +41,8 @@ internal class RemoveNetworkTests : BaseInstrumentationTest() { verificationUtil.triedToRemoveNetwork() } - @Test fun sync_success() { + @Test + fun sync_success() { mockWiseFyPrechecksUtil.removeNetwork_success() mockWiseFySearchUtil.findSavedNetworkByRegex_success() mockNetworkUtil.removeNetwork(true) @@ -48,7 +50,8 @@ internal class RemoveNetworkTests : BaseInstrumentationTest() { verificationUtil.triedToRemoveNetwork() } - @Test fun async_failure_prechecks() { + @Test + fun async_failure_prechecks() { mockWiseFyPrechecksUtil.removeNetwork_failure() val mockCallbacks = mock(RemoveNetworkCallbacks::class.java) wisefy.removeNetwork(TEST_SSID, mockCallbacks) @@ -56,13 +59,15 @@ internal class RemoveNetworkTests : BaseInstrumentationTest() { verificationUtil.didNotTryToRemoveNetwork() } - @Test fun async_failure_prechecks_nullCallback() { + @Test + fun async_failure_prechecks_nullCallback() { mockWiseFyPrechecksUtil.removeNetwork_failure() nullCallbackUtil.callRemoveNetwork(TEST_SSID) verificationUtil.didNotTryToRemoveNetwork() } - @Test fun async_failure_noSavedNetwork() { + @Test + fun async_failure_noSavedNetwork() { mockWiseFyPrechecksUtil.removeNetwork_success() mockWiseFySearchUtil.findSavedNetworkByRegex_null() val mockCallbacks = mock(RemoveNetworkCallbacks::class.java) @@ -71,14 +76,16 @@ internal class RemoveNetworkTests : BaseInstrumentationTest() { verificationUtil.didNotTryToRemoveNetwork() } - @Test fun async_failure_noSavedNetwork_nullCallback() { + @Test + fun async_failure_noSavedNetwork_nullCallback() { mockWiseFyPrechecksUtil.removeNetwork_success() mockWiseFySearchUtil.findSavedNetworkByRegex_null() nullCallbackUtil.callRemoveNetwork(TEST_SSID) verificationUtil.didNotTryToRemoveNetwork() } - @Test fun async_failure() { + @Test + fun async_failure() { mockWiseFyPrechecksUtil.removeNetwork_success() mockWiseFySearchUtil.findSavedNetworkByRegex_success() mockNetworkUtil.removeNetwork(false) @@ -88,7 +95,8 @@ internal class RemoveNetworkTests : BaseInstrumentationTest() { verificationUtil.triedToRemoveNetwork() } - @Test fun async_failure_nullCallback() { + @Test + fun async_failure_nullCallback() { mockWiseFyPrechecksUtil.removeNetwork_success() mockWiseFySearchUtil.findSavedNetworkByRegex_success() mockNetworkUtil.removeNetwork(false) @@ -96,7 +104,8 @@ internal class RemoveNetworkTests : BaseInstrumentationTest() { verificationUtil.triedToRemoveNetwork() } - @Test fun async_success() { + @Test + fun async_success() { mockWiseFyPrechecksUtil.removeNetwork_success() mockWiseFySearchUtil.findSavedNetworkByRegex_success() mockNetworkUtil.removeNetwork(true) @@ -106,7 +115,8 @@ internal class RemoveNetworkTests : BaseInstrumentationTest() { verificationUtil.triedToRemoveNetwork() } - @Test fun async_success_nullCallback() { + @Test + fun async_success_nullCallback() { mockWiseFyPrechecksUtil.removeNetwork_success() mockWiseFySearchUtil.findSavedNetworkByRegex_success() mockNetworkUtil.removeNetwork(true) diff --git a/wisefy/src/androidTest/java/com/isupatches/wisefy/SearchForAccessPointTests.kt b/wisefy/src/androidTest/java/com/isupatches/wisefy/SearchForAccessPointTests.kt index 4fdd2118..33c10b8b 100644 --- a/wisefy/src/androidTest/java/com/isupatches/wisefy/SearchForAccessPointTests.kt +++ b/wisefy/src/androidTest/java/com/isupatches/wisefy/SearchForAccessPointTests.kt @@ -3,10 +3,8 @@ package com.isupatches.wisefy import com.isupatches.wisefy.callbacks.SearchForAccessPointCallbacks import com.isupatches.wisefy.constants.MISSING_PARAMETER import com.isupatches.wisefy.internal.base.BaseInstrumentationTest - import org.junit.Assert.assertEquals import org.junit.Test - import org.mockito.Mockito.mock import org.mockito.Mockito.timeout import org.mockito.Mockito.verify @@ -19,65 +17,76 @@ import org.mockito.Mockito.verify */ internal class SearchForAccessPointTests : BaseInstrumentationTest() { - @Test fun sync_failure_prechecks_filterDuplicates_false() { + @Test + fun sync_failure_prechecks_filterDuplicates_false() { mockWiseFyPrechecksUtil.searchForAccessPoint_failure() assertEquals(null, wisefy.searchForAccessPoint(TEST_SSID, TEST_TIMEOUT, false)) } - @Test fun sync_failure_prechecks_filterDuplicates_true() { + @Test + fun sync_failure_prechecks_filterDuplicates_true() { mockWiseFyPrechecksUtil.searchForAccessPoint_failure() assertEquals(null, wisefy.searchForAccessPoint(TEST_SSID, TEST_TIMEOUT, true)) } - @Test fun sync_failure_filterDuplicates_false() { + @Test + fun sync_failure_filterDuplicates_false() { mockWiseFyPrechecksUtil.searchForAccessPoint_success() mockWiseFySearchUtil.findAccessPointByRegex_null() assertEquals(null, wisefy.searchForAccessPoint(TEST_SSID, TEST_TIMEOUT, false)) } - @Test fun sync_failure_filterDuplicates_true() { + @Test + fun sync_failure_filterDuplicates_true() { mockWiseFyPrechecksUtil.searchForAccessPoint_success() mockWiseFySearchUtil.findAccessPointByRegex_null() assertEquals(null, wisefy.searchForAccessPoint(TEST_SSID, TEST_TIMEOUT, true)) } - @Test fun sync_success_filterDuplicates_false() { + @Test + fun sync_success_filterDuplicates_false() { mockWiseFyPrechecksUtil.searchForAccessPoint_success() val accessPoint = mockWiseFySearchUtil.findAccessPointByRegex_success() assertEquals(accessPoint, wisefy.searchForAccessPoint(TEST_SSID, TEST_TIMEOUT, false)) } - @Test fun sync_success_filterDuplicates_true() { + @Test + fun sync_success_filterDuplicates_true() { mockWiseFyPrechecksUtil.searchForAccessPoint_success() val accessPoint = mockWiseFySearchUtil.findAccessPointByRegex_success() assertEquals(accessPoint, wisefy.searchForAccessPoint(TEST_SSID, TEST_TIMEOUT, true)) } - @Test fun async_failure_prechecks_filterDuplicates_false() { + @Test + fun async_failure_prechecks_filterDuplicates_false() { mockWiseFyPrechecksUtil.searchForAccessPoint_failure() val mockCallbacks = mock(SearchForAccessPointCallbacks::class.java) wisefy.searchForAccessPoint(TEST_SSID, TEST_TIMEOUT, false, mockCallbacks) verify(mockCallbacks, timeout(VERIFICATION_SUCCESS_TIMEOUT)).wisefyFailure(MISSING_PARAMETER) } - @Test fun async_failure_prechecks_filterDuplicates_false_nullCallback() { + @Test + fun async_failure_prechecks_filterDuplicates_false_nullCallback() { mockWiseFyPrechecksUtil.searchForAccessPoint_failure() nullCallbackUtil.callSearchForAccessPoint(TEST_SSID, false) } - @Test fun async_failure_prechecks_filterDuplicates_true() { + @Test + fun async_failure_prechecks_filterDuplicates_true() { mockWiseFyPrechecksUtil.searchForAccessPoint_failure() val mockCallbacks = mock(SearchForAccessPointCallbacks::class.java) wisefy.searchForAccessPoint(TEST_SSID, TEST_TIMEOUT, true, mockCallbacks) verify(mockCallbacks, timeout(VERIFICATION_SUCCESS_TIMEOUT)).wisefyFailure(MISSING_PARAMETER) } - @Test fun async_failure_prechecks_filterDuplicates_true_nullCallback() { + @Test + fun async_failure_prechecks_filterDuplicates_true_nullCallback() { mockWiseFyPrechecksUtil.searchForAccessPoint_failure() nullCallbackUtil.callSearchForAccessPoint(TEST_SSID, true) } - @Test fun async_failure_filterDuplicates_false() { + @Test + fun async_failure_filterDuplicates_false() { mockWiseFyPrechecksUtil.searchForAccessPoint_success() mockWiseFySearchUtil.findAccessPointByRegex_null() val mockCallbacks = mock(SearchForAccessPointCallbacks::class.java) @@ -85,13 +94,15 @@ internal class SearchForAccessPointTests : BaseInstrumentationTest() { verify(mockCallbacks, timeout(VERIFICATION_SUCCESS_TIMEOUT)).accessPointNotFound() } - @Test fun async_failure_filterDuplicates_false_nullCallback() { + @Test + fun async_failure_filterDuplicates_false_nullCallback() { mockWiseFyPrechecksUtil.searchForAccessPoint_success() mockWiseFySearchUtil.findAccessPointByRegex_null() nullCallbackUtil.callSearchForAccessPoint(TEST_SSID, false) } - @Test fun async_failure_filterDuplicates_true() { + @Test + fun async_failure_filterDuplicates_true() { mockWiseFyPrechecksUtil.searchForAccessPoint_success() mockWiseFySearchUtil.findAccessPointByRegex_null() val mockCallbacks = mock(SearchForAccessPointCallbacks::class.java) @@ -99,13 +110,15 @@ internal class SearchForAccessPointTests : BaseInstrumentationTest() { verify(mockCallbacks, timeout(VERIFICATION_SUCCESS_TIMEOUT)).accessPointNotFound() } - @Test fun async_failure_filterDuplicates_true_nullCallback() { + @Test + fun async_failure_filterDuplicates_true_nullCallback() { mockWiseFyPrechecksUtil.searchForAccessPoint_success() mockWiseFySearchUtil.findAccessPointByRegex_null() nullCallbackUtil.callSearchForAccessPoint(TEST_SSID, true) } - @Test fun async_success_filterDuplicates_false() { + @Test + fun async_success_filterDuplicates_false() { mockWiseFyPrechecksUtil.searchForAccessPoint_success() val accessPoint = mockWiseFySearchUtil.findAccessPointByRegex_success() val mockCallbacks = mock(SearchForAccessPointCallbacks::class.java) @@ -113,13 +126,15 @@ internal class SearchForAccessPointTests : BaseInstrumentationTest() { verify(mockCallbacks, timeout(VERIFICATION_SUCCESS_TIMEOUT)).accessPointFound(accessPoint) } - @Test fun async_success_filterDuplicates_false_nullCallback() { + @Test + fun async_success_filterDuplicates_false_nullCallback() { mockWiseFyPrechecksUtil.searchForAccessPoint_success() mockWiseFySearchUtil.findAccessPointByRegex_success() nullCallbackUtil.callSearchForAccessPoint(TEST_SSID, false) } - @Test fun async_success_filterDuplicates_true() { + @Test + fun async_success_filterDuplicates_true() { mockWiseFyPrechecksUtil.searchForAccessPoint_success() val accessPoint = mockWiseFySearchUtil.findAccessPointByRegex_success() val mockCallbacks = mock(SearchForAccessPointCallbacks::class.java) @@ -127,7 +142,8 @@ internal class SearchForAccessPointTests : BaseInstrumentationTest() { verify(mockCallbacks, timeout(VERIFICATION_SUCCESS_TIMEOUT)).accessPointFound(accessPoint) } - @Test fun async_success_filterDuplicates_true_nullCallback() { + @Test + fun async_success_filterDuplicates_true_nullCallback() { mockWiseFyPrechecksUtil.searchForAccessPoint_success() mockWiseFySearchUtil.findAccessPointByRegex_success() nullCallbackUtil.callSearchForAccessPoint(TEST_SSID, true) diff --git a/wisefy/src/androidTest/java/com/isupatches/wisefy/SearchForAccessPointsTests.kt b/wisefy/src/androidTest/java/com/isupatches/wisefy/SearchForAccessPointsTests.kt index 53f541fa..f4caab4e 100644 --- a/wisefy/src/androidTest/java/com/isupatches/wisefy/SearchForAccessPointsTests.kt +++ b/wisefy/src/androidTest/java/com/isupatches/wisefy/SearchForAccessPointsTests.kt @@ -3,10 +3,8 @@ package com.isupatches.wisefy import com.isupatches.wisefy.callbacks.SearchForAccessPointsCallbacks import com.isupatches.wisefy.constants.MISSING_PARAMETER import com.isupatches.wisefy.internal.base.BaseInstrumentationTest - import org.junit.Assert.assertEquals import org.junit.Test - import org.mockito.Mockito.mock import org.mockito.Mockito.timeout import org.mockito.Mockito.verify @@ -19,65 +17,76 @@ import org.mockito.Mockito.verify */ internal class SearchForAccessPointsTests : BaseInstrumentationTest() { - @Test fun sync_failure_prechecks_filterDuplicates_false() { + @Test + fun sync_failure_prechecks_filterDuplicates_false() { mockWiseFyPrechecksUtil.searchForAccessPoints_failure() assertEquals(null, wisefy.searchForAccessPoints(TEST_SSID, false)) } - @Test fun sync_failure_prechecks_filterDuplicates_true() { + @Test + fun sync_failure_prechecks_filterDuplicates_true() { mockWiseFyPrechecksUtil.searchForAccessPoints_failure() assertEquals(null, wisefy.searchForAccessPoints(TEST_SSID, true)) } - @Test fun sync_failure_filterDuplicates_false() { + @Test + fun sync_failure_filterDuplicates_false() { mockWiseFyPrechecksUtil.searchForAccessPoints_success() mockWiseFySearchUtil.findAccessPointsMatchingRegex_null() assertEquals(null, wisefy.searchForAccessPoints(TEST_SSID, false)) } - @Test fun sync_failure_filterDuplicates_true() { + @Test + fun sync_failure_filterDuplicates_true() { mockWiseFyPrechecksUtil.searchForAccessPoints_success() mockWiseFySearchUtil.findAccessPointsMatchingRegex_null() assertEquals(null, wisefy.searchForAccessPoints(TEST_SSID, true)) } - @Test fun sync_success_filterDuplicates_false() { + @Test + fun sync_success_filterDuplicates_false() { mockWiseFyPrechecksUtil.searchForAccessPoints_success() val accessPoints = mockWiseFySearchUtil.findAccessPointsMatchingRegex_success() assertEquals(accessPoints, wisefy.searchForAccessPoints(TEST_SSID, false)) } - @Test fun sync_success_filterDuplicates_true() { + @Test + fun sync_success_filterDuplicates_true() { mockWiseFyPrechecksUtil.searchForAccessPoints_success() val accessPoints = mockWiseFySearchUtil.findAccessPointsMatchingRegex_success() assertEquals(accessPoints, wisefy.searchForAccessPoints(TEST_SSID, true)) } - @Test fun async_failure_prechecks_filterDuplicates_false() { + @Test + fun async_failure_prechecks_filterDuplicates_false() { mockWiseFyPrechecksUtil.searchForAccessPoints_failure() val mockCallbacks = mock(SearchForAccessPointsCallbacks::class.java) wisefy.searchForAccessPoints(TEST_SSID, false, mockCallbacks) verify(mockCallbacks, timeout(VERIFICATION_SUCCESS_TIMEOUT)).wisefyFailure(MISSING_PARAMETER) } - @Test fun async_failure_prechecks_filterDuplicates_false_nullCallback() { + @Test + fun async_failure_prechecks_filterDuplicates_false_nullCallback() { mockWiseFyPrechecksUtil.searchForAccessPoints_failure() nullCallbackUtil.callSearchForAccessPoints(TEST_SSID, false) } - @Test fun async_failure_prechecks_filterDuplicates_true() { + @Test + fun async_failure_prechecks_filterDuplicates_true() { mockWiseFyPrechecksUtil.searchForAccessPoints_failure() val mockCallbacks = mock(SearchForAccessPointsCallbacks::class.java) wisefy.searchForAccessPoints(TEST_SSID, true, mockCallbacks) verify(mockCallbacks, timeout(VERIFICATION_SUCCESS_TIMEOUT)).wisefyFailure(MISSING_PARAMETER) } - @Test fun async_failure_prechecks_filterDuplicates_true_nullCallback() { + @Test + fun async_failure_prechecks_filterDuplicates_true_nullCallback() { mockWiseFyPrechecksUtil.searchForAccessPoints_failure() nullCallbackUtil.callSearchForAccessPoints(TEST_SSID, true) } - @Test fun async_failure_filterDuplicates_false() { + @Test + fun async_failure_filterDuplicates_false() { mockWiseFyPrechecksUtil.searchForAccessPoints_success() mockWiseFySearchUtil.findAccessPointsMatchingRegex_null() val mockCallbacks = mock(SearchForAccessPointsCallbacks::class.java) @@ -85,13 +94,15 @@ internal class SearchForAccessPointsTests : BaseInstrumentationTest() { verify(mockCallbacks, timeout(VERIFICATION_SUCCESS_TIMEOUT)).noAccessPointsFound() } - @Test fun async_failure_filterDuplicates_false_nullCallback() { + @Test + fun async_failure_filterDuplicates_false_nullCallback() { mockWiseFyPrechecksUtil.searchForAccessPoints_success() mockWiseFySearchUtil.findAccessPointsMatchingRegex_null() nullCallbackUtil.callSearchForAccessPoints(TEST_SSID, false) } - @Test fun async_failure_filterDuplicates_true() { + @Test + fun async_failure_filterDuplicates_true() { mockWiseFyPrechecksUtil.searchForAccessPoints_success() mockWiseFySearchUtil.findAccessPointsMatchingRegex_null() val mockCallbacks = mock(SearchForAccessPointsCallbacks::class.java) @@ -99,13 +110,15 @@ internal class SearchForAccessPointsTests : BaseInstrumentationTest() { verify(mockCallbacks, timeout(VERIFICATION_SUCCESS_TIMEOUT)).noAccessPointsFound() } - @Test fun async_failure_filterDuplicates_true_nullCallback() { + @Test + fun async_failure_filterDuplicates_true_nullCallback() { mockWiseFyPrechecksUtil.searchForAccessPoints_success() mockWiseFySearchUtil.findAccessPointsMatchingRegex_null() nullCallbackUtil.callSearchForAccessPoints(TEST_SSID, true) } - @Test fun async_success_filterDuplicates_false() { + @Test + fun async_success_filterDuplicates_false() { mockWiseFyPrechecksUtil.searchForAccessPoints_success() val accessPoints = mockWiseFySearchUtil.findAccessPointsMatchingRegex_success() val mockCallbacks = mock(SearchForAccessPointsCallbacks::class.java) @@ -113,13 +126,15 @@ internal class SearchForAccessPointsTests : BaseInstrumentationTest() { verify(mockCallbacks, timeout(VERIFICATION_SUCCESS_TIMEOUT)).foundAccessPoints(accessPoints) } - @Test fun async_success_filterDuplicates_false_nullCallback() { + @Test + fun async_success_filterDuplicates_false_nullCallback() { mockWiseFyPrechecksUtil.searchForAccessPoints_success() mockWiseFySearchUtil.findAccessPointsMatchingRegex_success() nullCallbackUtil.callSearchForAccessPoints(TEST_SSID, false) } - @Test fun async_success_filterDuplicates_true() { + @Test + fun async_success_filterDuplicates_true() { mockWiseFyPrechecksUtil.searchForAccessPoints_success() val accessPoints = mockWiseFySearchUtil.findAccessPointsMatchingRegex_success() val mockCallbacks = mock(SearchForAccessPointsCallbacks::class.java) @@ -127,7 +142,8 @@ internal class SearchForAccessPointsTests : BaseInstrumentationTest() { verify(mockCallbacks, timeout(VERIFICATION_SUCCESS_TIMEOUT)).foundAccessPoints(accessPoints) } - @Test fun async_success_filterDuplicates_true_nullCallback() { + @Test + fun async_success_filterDuplicates_true_nullCallback() { mockWiseFyPrechecksUtil.searchForAccessPoints_success() mockWiseFySearchUtil.findAccessPointsMatchingRegex_success() nullCallbackUtil.callSearchForAccessPoints(TEST_SSID, true) diff --git a/wisefy/src/androidTest/java/com/isupatches/wisefy/SearchForSSIDTests.kt b/wisefy/src/androidTest/java/com/isupatches/wisefy/SearchForSSIDTests.kt index cad23bbf..9c22c3ea 100644 --- a/wisefy/src/androidTest/java/com/isupatches/wisefy/SearchForSSIDTests.kt +++ b/wisefy/src/androidTest/java/com/isupatches/wisefy/SearchForSSIDTests.kt @@ -3,10 +3,8 @@ package com.isupatches.wisefy import com.isupatches.wisefy.callbacks.SearchForSSIDCallbacks import com.isupatches.wisefy.constants.MISSING_PARAMETER import com.isupatches.wisefy.internal.base.BaseInstrumentationTest - import org.junit.Assert.assertEquals import org.junit.Test - import org.mockito.Mockito.mock import org.mockito.Mockito.timeout import org.mockito.Mockito.verify @@ -19,36 +17,42 @@ import org.mockito.Mockito.verify */ internal class SearchForSSIDTests : BaseInstrumentationTest() { - @Test fun sync_failure_missingPrerequisite() { + @Test + fun sync_failure_missingPrerequisite() { mockWiseFyPrechecksUtil.searchForSSID_failure() assertEquals(null, wisefy.searchForSSID(TEST_SSID, TEST_TIMEOUT)) } - @Test fun sync_failure() { + @Test + fun sync_failure() { mockWiseFyPrechecksUtil.searchForSSID_success() mockWiseFySearchUtil.findAccessPointByRegex_null() assertEquals(null, wisefy.searchForSSID(TEST_SSID, TEST_TIMEOUT)) } - @Test fun sync_success() { + @Test + fun sync_success() { mockWiseFyPrechecksUtil.searchForSSID_success() mockWiseFySearchUtil.findAccessPointByRegex_success() assertEquals(TEST_SSID, wisefy.searchForSSID(TEST_SSID, TEST_TIMEOUT)) } - @Test fun async_failure_missingPrerequisite() { + @Test + fun async_failure_missingPrerequisite() { mockWiseFyPrechecksUtil.searchForSSID_failure() val mockCallbacks = mock(SearchForSSIDCallbacks::class.java) wisefy.searchForSSID(TEST_SSID, TEST_TIMEOUT, mockCallbacks) verify(mockCallbacks, timeout(VERIFICATION_SUCCESS_TIMEOUT)).wisefyFailure(MISSING_PARAMETER) } - @Test fun async_failure_missingPrerequisite_nullCallback() { + @Test + fun async_failure_missingPrerequisite_nullCallback() { mockWiseFyPrechecksUtil.searchForSSID_failure() nullCallbackUtil.callSearchForSSID(TEST_SSID) } - @Test fun async_failure() { + @Test + fun async_failure() { mockWiseFyPrechecksUtil.searchForSSID_success() mockWiseFySearchUtil.findAccessPointByRegex_null() val mockCallbacks = mock(SearchForSSIDCallbacks::class.java) @@ -56,13 +60,15 @@ internal class SearchForSSIDTests : BaseInstrumentationTest() { verify(mockCallbacks, timeout(VERIFICATION_SUCCESS_TIMEOUT)).ssidNotFound() } - @Test fun async_failure_nullCallback() { + @Test + fun async_failure_nullCallback() { mockWiseFyPrechecksUtil.searchForSSID_success() mockWiseFySearchUtil.findAccessPointByRegex_null() nullCallbackUtil.callSearchForSSID(TEST_SSID) } - @Test fun async_success() { + @Test + fun async_success() { mockWiseFyPrechecksUtil.searchForSSID_success() mockWiseFySearchUtil.findAccessPointByRegex_success() val mockCallbacks = mock(SearchForSSIDCallbacks::class.java) @@ -70,7 +76,8 @@ internal class SearchForSSIDTests : BaseInstrumentationTest() { verify(mockCallbacks, timeout(VERIFICATION_SUCCESS_TIMEOUT)).ssidFound(TEST_SSID) } - @Test fun async_success_nullCallback() { + @Test + fun async_success_nullCallback() { mockWiseFyPrechecksUtil.searchForSSID_success() mockWiseFySearchUtil.findAccessPointByRegex_success() nullCallbackUtil.callSearchForSSID(TEST_SSID) diff --git a/wisefy/src/androidTest/java/com/isupatches/wisefy/SearchForSSIDsTests.kt b/wisefy/src/androidTest/java/com/isupatches/wisefy/SearchForSSIDsTests.kt index e6ea0516..29ce3a72 100644 --- a/wisefy/src/androidTest/java/com/isupatches/wisefy/SearchForSSIDsTests.kt +++ b/wisefy/src/androidTest/java/com/isupatches/wisefy/SearchForSSIDsTests.kt @@ -3,10 +3,8 @@ package com.isupatches.wisefy import com.isupatches.wisefy.callbacks.SearchForSSIDsCallbacks import com.isupatches.wisefy.constants.MISSING_PARAMETER import com.isupatches.wisefy.internal.base.BaseInstrumentationTest - import org.junit.Assert.assertEquals import org.junit.Test - import org.mockito.Mockito.mock import org.mockito.Mockito.timeout import org.mockito.Mockito.verify @@ -19,36 +17,42 @@ import org.mockito.Mockito.verify */ internal class SearchForSSIDsTests : BaseInstrumentationTest() { - @Test fun sync_failure_precheck() { + @Test + fun sync_failure_precheck() { mockWiseFyPrechecksUtil.searchForSSIDs_failure() assertEquals(null, wisefy.searchForSSIDs(TEST_SSID)) } - @Test fun sync_failure() { + @Test + fun sync_failure() { mockWiseFyPrechecksUtil.searchForSSIDs_success() mockWiseFySearchUtil.findSSIDsMatchingRegex_null() assertEquals(null, wisefy.searchForSSIDs(TEST_SSID)) } - @Test fun sync_success() { + @Test + fun sync_success() { mockWiseFyPrechecksUtil.searchForSSIDs_success() val ssids = mockWiseFySearchUtil.findSSIDsMatchingRegex_success() assertEquals(ssids, wisefy.searchForSSIDs(TEST_SSID)) } - @Test fun async_failure_prechecks() { + @Test + fun async_failure_prechecks() { mockWiseFyPrechecksUtil.searchForSSIDs_failure() val mockCallbacks = mock(SearchForSSIDsCallbacks::class.java) wisefy.searchForSSIDs(TEST_SSID, mockCallbacks) verify(mockCallbacks, timeout(VERIFICATION_SUCCESS_TIMEOUT)).wisefyFailure(MISSING_PARAMETER) } - @Test fun async_failure_prechecks_nullCallback() { + @Test + fun async_failure_prechecks_nullCallback() { mockWiseFyPrechecksUtil.searchForSSIDs_failure() nullCallbackUtil.callSearchForSSIDs(TEST_SSID) } - @Test fun async_failure() { + @Test + fun async_failure() { mockWiseFyPrechecksUtil.searchForSSIDs_success() mockWiseFySearchUtil.findSSIDsMatchingRegex_null() val mockCallbacks = mock(SearchForSSIDsCallbacks::class.java) @@ -56,13 +60,15 @@ internal class SearchForSSIDsTests : BaseInstrumentationTest() { verify(mockCallbacks, timeout(VERIFICATION_SUCCESS_TIMEOUT)).noSSIDsFound() } - @Test fun async_failure_nullCallback() { + @Test + fun async_failure_nullCallback() { mockWiseFyPrechecksUtil.searchForSSIDs_success() mockWiseFySearchUtil.findSSIDsMatchingRegex_null() nullCallbackUtil.callSearchForSSIDs(TEST_SSID) } - @Test fun async_success() { + @Test + fun async_success() { mockWiseFyPrechecksUtil.searchForSSIDs_success() val ssids = mockWiseFySearchUtil.findSSIDsMatchingRegex_success() val mockCallbacks = mock(SearchForSSIDsCallbacks::class.java) @@ -70,7 +76,8 @@ internal class SearchForSSIDsTests : BaseInstrumentationTest() { verify(mockCallbacks, timeout(VERIFICATION_SUCCESS_TIMEOUT)).retrievedSSIDs(ssids) } - @Test fun async_success_nullCallback() { + @Test + fun async_success_nullCallback() { mockWiseFyPrechecksUtil.searchForSSIDs_success() mockWiseFySearchUtil.findSSIDsMatchingRegex_success() nullCallbackUtil.callSearchForSSIDs(TEST_SSID) diff --git a/wisefy/src/androidTest/java/com/isupatches/wisefy/SearchForSavedNetworkTests.kt b/wisefy/src/androidTest/java/com/isupatches/wisefy/SearchForSavedNetworkTests.kt index d7cf2d9f..c9006e17 100644 --- a/wisefy/src/androidTest/java/com/isupatches/wisefy/SearchForSavedNetworkTests.kt +++ b/wisefy/src/androidTest/java/com/isupatches/wisefy/SearchForSavedNetworkTests.kt @@ -2,12 +2,9 @@ package com.isupatches.wisefy import com.isupatches.wisefy.callbacks.SearchForSavedNetworkCallbacks import com.isupatches.wisefy.constants.MISSING_PARAMETER - import com.isupatches.wisefy.internal.base.BaseInstrumentationTest - import org.junit.Assert.assertEquals import org.junit.Test - import org.mockito.Mockito.mock import org.mockito.Mockito.timeout import org.mockito.Mockito.verify @@ -20,36 +17,42 @@ import org.mockito.Mockito.verify */ internal class SearchForSavedNetworkTests : BaseInstrumentationTest() { - @Test fun sync_failure_prechecks() { + @Test + fun sync_failure_prechecks() { mockWiseFyPrechecksUtil.searchForSavedNetwork_failure() assertEquals(null, wisefy.searchForSavedNetwork(TEST_SSID)) } - @Test fun sync_failure() { + @Test + fun sync_failure() { mockWiseFyPrechecksUtil.searchForSavedNetwork_success() mockWiseFySearchUtil.findSavedNetworkByRegex_null() assertEquals(null, wisefy.searchForSavedNetwork(TEST_SSID)) } - @Test fun sync_success() { + @Test + fun sync_success() { mockWiseFyPrechecksUtil.searchForSavedNetwork_success() val savedNetwork = mockWiseFySearchUtil.findSavedNetworkByRegex_success() assertEquals(savedNetwork, wisefy.searchForSavedNetwork(TEST_SSID)) } - @Test fun async_failure_prechecks() { + @Test + fun async_failure_prechecks() { mockWiseFyPrechecksUtil.searchForSavedNetwork_failure() val mockCallbacks = mock(SearchForSavedNetworkCallbacks::class.java) wisefy.searchForSavedNetwork(TEST_SSID, mockCallbacks) verify(mockCallbacks, timeout(VERIFICATION_SUCCESS_TIMEOUT)).wisefyFailure(MISSING_PARAMETER) } - @Test fun async_failure_prechecks_nullCallback() { + @Test + fun async_failure_prechecks_nullCallback() { mockWiseFyPrechecksUtil.searchForSavedNetwork_failure() nullCallbackUtil.callSearchForSavedNetwork(TEST_SSID) } - @Test fun async_failure() { + @Test + fun async_failure() { mockWiseFyPrechecksUtil.searchForSavedNetwork_success() mockWiseFySearchUtil.findSavedNetworkByRegex_null() val mockCallbacks = mock(SearchForSavedNetworkCallbacks::class.java) @@ -57,13 +60,15 @@ internal class SearchForSavedNetworkTests : BaseInstrumentationTest() { verify(mockCallbacks, timeout(VERIFICATION_SUCCESS_TIMEOUT)).savedNetworkNotFound() } - @Test fun async_failure_nullCallback() { + @Test + fun async_failure_nullCallback() { mockWiseFyPrechecksUtil.searchForSavedNetwork_success() mockWiseFySearchUtil.findSavedNetworkByRegex_null() nullCallbackUtil.callSearchForSavedNetwork(TEST_SSID) } - @Test fun async_success() { + @Test + fun async_success() { mockWiseFyPrechecksUtil.searchForSavedNetwork_success() val savedNetwork = mockWiseFySearchUtil.findSavedNetworkByRegex_success() val mockCallbacks = mock(SearchForSavedNetworkCallbacks::class.java) @@ -71,7 +76,8 @@ internal class SearchForSavedNetworkTests : BaseInstrumentationTest() { verify(mockCallbacks, timeout(VERIFICATION_SUCCESS_TIMEOUT)).retrievedSavedNetwork(savedNetwork) } - @Test fun async_success_nullCallback() { + @Test + fun async_success_nullCallback() { mockWiseFyPrechecksUtil.searchForSavedNetwork_success() mockWiseFySearchUtil.findSavedNetworkByRegex_success() nullCallbackUtil.callSearchForSavedNetwork(TEST_SSID) diff --git a/wisefy/src/androidTest/java/com/isupatches/wisefy/SearchForSavedNetworksTests.kt b/wisefy/src/androidTest/java/com/isupatches/wisefy/SearchForSavedNetworksTests.kt index 896c1ac7..f554bca4 100644 --- a/wisefy/src/androidTest/java/com/isupatches/wisefy/SearchForSavedNetworksTests.kt +++ b/wisefy/src/androidTest/java/com/isupatches/wisefy/SearchForSavedNetworksTests.kt @@ -3,10 +3,8 @@ package com.isupatches.wisefy import com.isupatches.wisefy.callbacks.SearchForSavedNetworksCallbacks import com.isupatches.wisefy.constants.MISSING_PARAMETER import com.isupatches.wisefy.internal.base.BaseInstrumentationTest - import org.junit.Assert.assertEquals import org.junit.Test - import org.mockito.Mockito.mock import org.mockito.Mockito.timeout import org.mockito.Mockito.verify @@ -19,32 +17,37 @@ import org.mockito.Mockito.verify */ internal class SearchForSavedNetworksTests : BaseInstrumentationTest() { - @Test fun sync_failure_prechecks() { + @Test + fun sync_failure_prechecks() { mockWiseFyPrechecksUtil.searchForSavedNetworks_failure() assertEquals(null, wisefy.searchForSavedNetworks(TEST_SSID)) verificationUtil.didNotTryToGetSavedNetworks() } - @Test fun sync_success() { + @Test + fun sync_success() { mockWiseFyPrechecksUtil.searchForSavedNetworks_success() val savedNetwork = mockWiseFySearchUtil.findSavedNetworksMatchingRegex_success() assertEquals(savedNetwork, wisefy.searchForSavedNetworks(TEST_SSID)) } - @Test fun async_failure_prechecks() { + @Test + fun async_failure_prechecks() { mockWiseFyPrechecksUtil.searchForSavedNetworks_failure() val mockCallbacks = mock(SearchForSavedNetworksCallbacks::class.java) wisefy.searchForSavedNetworks(TEST_SSID, mockCallbacks) verify(mockCallbacks, timeout(VERIFICATION_SUCCESS_TIMEOUT)).wisefyFailure(MISSING_PARAMETER) } - @Test fun async_failure_prechecks_nullCallback() { + @Test + fun async_failure_prechecks_nullCallback() { mockWiseFyPrechecksUtil.searchForSavedNetworks_failure() nullCallbackUtil.callSearchForSavedNetworks(TEST_SSID) wisefy.searchForSavedNetworks(TEST_SSID, null) } - @Test fun async_failure_nullSavedNetworks() { + @Test + fun async_failure_nullSavedNetworks() { mockWiseFyPrechecksUtil.searchForSavedNetworks_success() mockWiseFySearchUtil.findSavedNetworksByRegex_null() val mockCallbacks = mock(SearchForSavedNetworksCallbacks::class.java) @@ -52,13 +55,15 @@ internal class SearchForSavedNetworksTests : BaseInstrumentationTest() { verify(mockCallbacks, timeout(VERIFICATION_SUCCESS_TIMEOUT)).noSavedNetworksFound() } - @Test fun async_failure_nullSavedNetworks_nullCallback() { + @Test + fun async_failure_nullSavedNetworks_nullCallback() { mockWiseFyPrechecksUtil.searchForSavedNetworks_success() mockWiseFySearchUtil.findSavedNetworksByRegex_null() nullCallbackUtil.callSearchForSavedNetworks(TEST_SSID) } - @Test fun async_failure_emptyConfiguredNetworks() { + @Test + fun async_failure_emptyConfiguredNetworks() { mockWiseFyPrechecksUtil.searchForSavedNetworks_success() mockWiseFySearchUtil.findSavedNetworksByRegex_emptyList() val mockCallbacks = mock(SearchForSavedNetworksCallbacks::class.java) @@ -66,13 +71,15 @@ internal class SearchForSavedNetworksTests : BaseInstrumentationTest() { verify(mockCallbacks, timeout(VERIFICATION_SUCCESS_TIMEOUT)).noSavedNetworksFound() } - @Test fun async_failure_emptyConfiguredNetworks_nullCallback() { + @Test + fun async_failure_emptyConfiguredNetworks_nullCallback() { mockWiseFyPrechecksUtil.searchForSavedNetworks_success() mockWiseFySearchUtil.findSavedNetworksByRegex_emptyList() nullCallbackUtil.callSearchForSavedNetworks(TEST_SSID) } - @Test fun async_success() { + @Test + fun async_success() { mockWiseFyPrechecksUtil.searchForSavedNetworks_success() val savedNetworks = mockWiseFySearchUtil.findSavedNetworksMatchingRegex_success() val mockCallbacks = mock(SearchForSavedNetworksCallbacks::class.java) @@ -80,7 +87,8 @@ internal class SearchForSavedNetworksTests : BaseInstrumentationTest() { verify(mockCallbacks, timeout(VERIFICATION_SUCCESS_TIMEOUT)).retrievedSavedNetworks(savedNetworks) } - @Test fun async_success_nullCallbacks() { + @Test + fun async_success_nullCallbacks() { mockWiseFyPrechecksUtil.searchForSavedNetworks_success() mockWiseFySearchUtil.findSavedNetworksMatchingRegex_success() nullCallbackUtil.callSearchForSavedNetworks(TEST_SSID) diff --git a/wisefy/src/androidTest/java/com/isupatches/wisefy/WiseFyPrechecksTests.kt b/wisefy/src/androidTest/java/com/isupatches/wisefy/WiseFyPrechecksTests.kt index f344a8ea..4b3ec736 100644 --- a/wisefy/src/androidTest/java/com/isupatches/wisefy/WiseFyPrechecksTests.kt +++ b/wisefy/src/androidTest/java/com/isupatches/wisefy/WiseFyPrechecksTests.kt @@ -4,7 +4,6 @@ import com.isupatches.wisefy.constants.DEFAULT_PRECHECK_RETURN_CODE import com.isupatches.wisefy.constants.MISSING_PARAMETER import com.isupatches.wisefy.constants.NETWORK_ALREADY_CONFIGURED import com.isupatches.wisefy.internal.base.BaseInstrumentationTest - import org.junit.Assert.assertEquals import org.junit.Test @@ -19,181 +18,318 @@ internal class WiseFyPrechecksTests : BaseInstrumentationTest() { private val wisefyPrechecks: WiseFyPrechecks = WiseFyPrechecksImpl.create(mockWiseFySearch) - @Test fun addNetworkPrechecks_failure_nullSSIDParam() { + @Test + fun addNetworkPrechecks_failure_nullSSIDParam() { assertEquals(MISSING_PARAMETER, wisefyPrechecks.addNetworkPrechecks(null).code) } - @Test fun addNetworkPrechecks_failure_emptySSID() { + @Test + fun addNetworkPrechecks_failure_emptySSID() { assertEquals(MISSING_PARAMETER, wisefyPrechecks.addNetworkPrechecks("").code) } - @Test fun addNetworkPrechecks_failure_networkAlreadySaved() { + @Test + fun addNetworkPrechecks_failure_networkAlreadySaved() { mockWiseFySearchUtil.isNetworkASavedConfiguration(true) assertEquals(NETWORK_ALREADY_CONFIGURED, wisefyPrechecks.addNetworkPrechecks(TEST_SSID).code) } - @Test fun addNetworkPrechecks_success() { + @Test + fun addNetworkPrechecks_success() { mockWiseFySearchUtil.isNetworkASavedConfiguration(false) assertEquals(DEFAULT_PRECHECK_RETURN_CODE, wisefyPrechecks.addNetworkPrechecks(TEST_SSID).code) } - @Test fun addNetworkPrechecks_withPassword_failure_nullSSIDParam() { + @Test + fun addNetworkPrechecks_withPassword_failure_nullSSIDParam() { assertEquals(MISSING_PARAMETER, wisefyPrechecks.addNetworkPrechecks(null, WEP_NETWORK_PASSWORD).code) } - @Test fun addNetworkPrechecks_withPassword_failure_emptySSIDParam() { + @Test + fun addNetworkPrechecks_withPassword_failure_emptySSIDParam() { assertEquals(MISSING_PARAMETER, wisefyPrechecks.addNetworkPrechecks("", WEP_NETWORK_PASSWORD).code) } - @Test fun addNetworkPrechecks_withPassword_failure_nullPasswordParam() { + @Test + fun addNetworkPrechecks_withPassword_failure_nullPasswordParam() { assertEquals(MISSING_PARAMETER, wisefyPrechecks.addNetworkPrechecks(WEP_NETWORK_SSID, null).code) } - @Test fun addNetworkPrechecks_withPassword_failure_emptyPasswordParam() { + @Test + fun addNetworkPrechecks_withPassword_failure_emptyPasswordParam() { assertEquals(MISSING_PARAMETER, wisefyPrechecks.addNetworkPrechecks(WEP_NETWORK_SSID, "").code) } - @Test fun addNetworkPrechecks_withPassword_failure_networkAlreadySaved() { + @Test + fun addNetworkPrechecks_withPassword_failure_networkAlreadySaved() { mockWiseFySearchUtil.isNetworkASavedConfiguration(true) - assertEquals(NETWORK_ALREADY_CONFIGURED, wisefyPrechecks.addNetworkPrechecks(WEP_NETWORK_SSID, WEP_NETWORK_PASSWORD).code) + assertEquals( + NETWORK_ALREADY_CONFIGURED, + wisefyPrechecks.addNetworkPrechecks(WEP_NETWORK_SSID, WEP_NETWORK_PASSWORD).code + ) } - @Test fun addNetworkPrechecks_withPassword_success() { + @Test + fun addNetworkPrechecks_withPassword_success() { mockWiseFySearchUtil.isNetworkASavedConfiguration(false) - assertEquals(DEFAULT_PRECHECK_RETURN_CODE, wisefyPrechecks.addNetworkPrechecks(WEP_NETWORK_SSID, WEP_NETWORK_PASSWORD).code) + assertEquals( + DEFAULT_PRECHECK_RETURN_CODE, + wisefyPrechecks.addNetworkPrechecks(WEP_NETWORK_SSID, WEP_NETWORK_PASSWORD).code + ) } - @Test fun connectToNetworkPrechecks_failure_nullParam() { + @Test + fun connectToNetworkPrechecks_failure_nullParam() { assertEquals(MISSING_PARAMETER, wisefyPrechecks.connectToNetworkPrechecks(null).code) } - @Test fun connectToNetworkPrechecks_success() { + + @Test + fun connectToNetworkPrechecks_failure_emptyParam() { + assertEquals(MISSING_PARAMETER, wisefyPrechecks.connectToNetworkPrechecks("").code) + } + + @Test + fun connectToNetworkPrechecks_success() { assertEquals(DEFAULT_PRECHECK_RETURN_CODE, wisefyPrechecks.connectToNetworkPrechecks(TEST_SSID).code) } - @Test fun disableWifiChecks() { + @Test + fun disableWifiChecks() { assertEquals(DEFAULT_PRECHECK_RETURN_CODE, wisefyPrechecks.disableWifiChecks().code) } - @Test fun disconnectFromCurrentNetworkChecks() { + @Test + fun disconnectFromCurrentNetworkChecks() { assertEquals(DEFAULT_PRECHECK_RETURN_CODE, wisefyPrechecks.disconnectFromCurrentNetworkChecks().code) } - @Test fun enableWifiChecks() { + @Test + fun enableWifiChecks() { assertEquals(DEFAULT_PRECHECK_RETURN_CODE, wisefyPrechecks.enableWifiChecks().code) } - @Test fun getCurrentNetworkChecks() { + @Test + fun getCurrentNetworkChecks() { assertEquals(DEFAULT_PRECHECK_RETURN_CODE, wisefyPrechecks.getCurrentNetworkChecks().code) } - @Test fun getCurrentNetworkInfoChecks() { + @Test + fun getCurrentNetworkInfoChecks() { assertEquals(DEFAULT_PRECHECK_RETURN_CODE, wisefyPrechecks.getCurrentNetworkInfoChecks().code) } - @Test fun getIPChecks() { + @Test + fun getFrequencyChecks() { + assertEquals(DEFAULT_PRECHECK_RETURN_CODE, wisefyPrechecks.getFrequencyChecks().code) + } + + @Test + fun getIPChecks() { assertEquals(DEFAULT_PRECHECK_RETURN_CODE, wisefyPrechecks.getIPChecks().code) } - @Test fun getNearbyAccessPointsChecks_success() { + @Test + fun getNearbyAccessPointsChecks_success() { assertEquals(DEFAULT_PRECHECK_RETURN_CODE, wisefyPrechecks.getNearbyAccessPointsChecks().code) } - @Test fun getRSSIChecks_failure_nullRegexForSSIDParam() { + @Test + fun getRSSIChecks_failure_nullRegexForSSIDParam() { assertEquals(MISSING_PARAMETER, wisefyPrechecks.getRSSIChecks(null).code) } - @Test fun getRSSIChecks_success() { + @Test + fun getRSSIChecks_failure_emptyRegexForSSIDParam() { + assertEquals(MISSING_PARAMETER, wisefyPrechecks.getRSSIChecks("").code) + } + + @Test + fun getRSSIChecks_success() { assertEquals(DEFAULT_PRECHECK_RETURN_CODE, wisefyPrechecks.getRSSIChecks(TEST_SSID).code) } - @Test fun getSavedNetworkChecks_failure_nullRegexForSSIDParam() { + @Test + fun getSavedNetworkChecks_failure_nullRegexForSSIDParam() { assertEquals(MISSING_PARAMETER, wisefyPrechecks.getSavedNetworkChecks(null).code) } - @Test fun getSavedNetworkChecks_success() { - assertEquals(DEFAULT_PRECHECK_RETURN_CODE, wisefyPrechecks.getSavedNetworkChecks(TEST_SSID).code) + @Test + fun getSavedNetworkChecks_failure_emptyRegexForSSIDParam() { + assertEquals(MISSING_PARAMETER, wisefyPrechecks.getSavedNetworkChecks("").code) } - @Test fun getSavedNetworksChecks_success() { - assertEquals(DEFAULT_PRECHECK_RETURN_CODE, wisefyPrechecks.getSavedNetworksChecks().code) + @Test + fun getSavedNetworkChecks_success() { + assertEquals(DEFAULT_PRECHECK_RETURN_CODE, wisefyPrechecks.getSavedNetworkChecks(TEST_SSID).code) } - @Test fun getSavedNetworksChecks_withRegex_failure_nullRegexForSSIDParam() { + @Test + fun getSavedNetworksChecks_withRegex_failure_nullRegexForSSIDParam() { assertEquals(MISSING_PARAMETER, wisefyPrechecks.getSavedNetworksChecks(null).code) } - @Test fun getSavedNetworksChecks_with_regex_success() { + @Test + fun getSavedNetworksChecks_withRegex_failure_emptyRegexForSSIDParam() { + assertEquals(MISSING_PARAMETER, wisefyPrechecks.getSavedNetworksChecks("").code) + } + + @Test + fun getSavedNetworksChecks_success() { + assertEquals(DEFAULT_PRECHECK_RETURN_CODE, wisefyPrechecks.getSavedNetworksChecks().code) + } + + @Test + fun getSavedNetworksChecks_with_regex_success() { assertEquals(DEFAULT_PRECHECK_RETURN_CODE, wisefyPrechecks.getSavedNetworksChecks(TEST_SSID).code) } - @Test fun isDeviceConnectedToMobileNetworkChecks() { + @Test + fun isDeviceConnectedToMobileNetworkChecks() { assertEquals(DEFAULT_PRECHECK_RETURN_CODE, wisefyPrechecks.isDeviceConnectedToMobileNetworkChecks().code) } - @Test fun isDeviceConnectedToMobileOrWifiNetworkChecks_success() { + @Test + fun isDeviceConnectedToMobileOrWifiNetworkChecks_success() { assertEquals(DEFAULT_PRECHECK_RETURN_CODE, wisefyPrechecks.isDeviceConnectedToMobileOrWifiNetworkChecks().code) } - @Test fun isDeviceConnectedToSSIDChecks_failure_nullSSIDParam() { + @Test + fun isDeviceConnectedToSSIDChecks_failure_nullSSIDParam() { assertEquals(MISSING_PARAMETER, wisefyPrechecks.isDeviceConnectedToSSIDChecks(null).code) } - @Test fun isDeviceConnectedToSSIDChecks_success() { + @Test + fun isDeviceConnectedToSSIDChecks_failure_emptySSIDParam() { + assertEquals(MISSING_PARAMETER, wisefyPrechecks.isDeviceConnectedToSSIDChecks("").code) + } + + @Test + fun isDeviceConnectedToSSIDChecks_success() { assertEquals(DEFAULT_PRECHECK_RETURN_CODE, wisefyPrechecks.isDeviceConnectedToSSIDChecks(TEST_SSID).code) } - @Test fun isDeviceConnectedToWifiNetworkChecks() { + @Test + fun isDeviceConnectedToWifiNetworkChecks() { assertEquals(DEFAULT_PRECHECK_RETURN_CODE, wisefyPrechecks.isDeviceConnectedToWifiNetworkChecks().code) } - @Test fun isDeviceRoamingChecks() { + + @Test + fun isDeviceRoamingChecks() { assertEquals(DEFAULT_PRECHECK_RETURN_CODE, wisefyPrechecks.isDeviceRoamingChecks().code) } - @Test fun isNetworkSavedChecks() { + @Test + fun isNetworkSavedChecks() { assertEquals(DEFAULT_PRECHECK_RETURN_CODE, wisefyPrechecks.isNetworkSavedChecks().code) } - @Test fun isWifiEnabledChecks() { + @Test + fun isWifiEnabledChecks() { assertEquals(DEFAULT_PRECHECK_RETURN_CODE, wisefyPrechecks.isWifiEnabledChecks().code) } - @Test fun removeNetworkCheck_failure_nullSSIDToRemoveParam() { + @Test + fun removeNetworkCheck_failure_nullSSIDToRemoveParam() { assertEquals(MISSING_PARAMETER, wisefyPrechecks.removeNetworkCheck(null).code) } - @Test fun removeNetworkCheck_success() { + @Test + fun removeNetworkCheck_failure_emptySSIDToRemoveParam() { + assertEquals(MISSING_PARAMETER, wisefyPrechecks.removeNetworkCheck("").code) + } + + @Test + fun removeNetworkCheck_success() { assertEquals(DEFAULT_PRECHECK_RETURN_CODE, wisefyPrechecks.removeNetworkCheck(TEST_SSID).code) } - @Test fun searchForAccessPointChecks_failure_nullRegexForSSIDParam() { + @Test + fun searchForAccessPointChecks_failure_nullRegexForSSIDParam() { assertEquals(MISSING_PARAMETER, wisefyPrechecks.searchForAccessPointChecks(null).code) } - @Test fun searchForAccessPointChecks_success() { + @Test + fun searchForAccessPointChecks_failure_emptyRegexForSSIDParam() { + assertEquals(MISSING_PARAMETER, wisefyPrechecks.searchForAccessPointChecks("").code) + } + + @Test + fun searchForAccessPointChecks_success() { assertEquals(DEFAULT_PRECHECK_RETURN_CODE, wisefyPrechecks.searchForAccessPointChecks(TEST_SSID).code) } - @Test fun searchForAccessPointsChecks_failure_nullRegexForSSIDParam() { + @Test + fun searchForAccessPointsChecks_failure_nullRegexForSSIDParam() { assertEquals(MISSING_PARAMETER, wisefyPrechecks.searchForAccessPointsChecks(null).code) } - @Test fun searchForAccessPointsChecks_success() { + @Test + fun searchForAccessPointsChecks_failure_emptyRegexForSSIDParam() { + assertEquals(MISSING_PARAMETER, wisefyPrechecks.searchForAccessPointsChecks("").code) + } + + @Test + fun searchForAccessPointsChecks_success() { assertEquals(DEFAULT_PRECHECK_RETURN_CODE, wisefyPrechecks.searchForAccessPointsChecks(TEST_SSID).code) } - @Test fun searchForSSIDChecks_failure_nullRegexForSSIDParam() { + @Test + fun searchForSavedNetwork_failure_nullRegexForSSIDParam() { + assertEquals(MISSING_PARAMETER, wisefyPrechecks.searchForSavedNetworkChecks(null).code) + } + + @Test + fun searchForSavedNetwork_failure_emptyRegexForSSIDParam() { + assertEquals(MISSING_PARAMETER, wisefyPrechecks.searchForSavedNetworkChecks("").code) + } + + @Test + fun searchForSavedNetworkChecks_success() { + assertEquals(DEFAULT_PRECHECK_RETURN_CODE, wisefyPrechecks.searchForSavedNetworkChecks(TEST_SSID).code) + } + + @Test + fun searchForSavedNetworksChecks_failure_nullRegexForSSIDParam() { + assertEquals(MISSING_PARAMETER, wisefyPrechecks.searchForSavedNetworksChecks(null).code) + } + + @Test + fun searchForSavedNetworksChecks_failure_emptyRegexForSSIDParam() { + assertEquals(MISSING_PARAMETER, wisefyPrechecks.searchForSavedNetworksChecks("").code) + } + + @Test + fun searchForSavedNetworksChecks_success() { + assertEquals(DEFAULT_PRECHECK_RETURN_CODE, wisefyPrechecks.searchForSavedNetworksChecks(TEST_SSID).code) + } + + @Test + fun searchForSSIDChecks_failure_nullRegexForSSIDParam() { assertEquals(MISSING_PARAMETER, wisefyPrechecks.searchForSSIDChecks(null).code) } - @Test fun searchForSSIDChecks_success() { + @Test + fun searchForSSIDChecks_failure_emptyRegexForSSIDParam() { + assertEquals(MISSING_PARAMETER, wisefyPrechecks.searchForSSIDChecks("").code) + } + + @Test + fun searchForSSIDChecks_success() { assertEquals(DEFAULT_PRECHECK_RETURN_CODE, wisefyPrechecks.searchForSSIDChecks(TEST_SSID).code) } - @Test fun searchForSSIDsChecks_failure_nullRegexForSSIDParam() { + @Test + fun searchForSSIDsChecks_failure_nullRegexForSSIDParam() { assertEquals(MISSING_PARAMETER, wisefyPrechecks.searchForSSIDsChecks(null).code) } - @Test fun searchForSSIDsChecks_success() { + @Test + fun searchForSSIDsChecks_failure_emptyRegexForSSIDParam() { + assertEquals(MISSING_PARAMETER, wisefyPrechecks.searchForSSIDsChecks("").code) + } + + @Test + fun searchForSSIDsChecks_success() { assertEquals(DEFAULT_PRECHECK_RETURN_CODE, wisefyPrechecks.searchForSSIDsChecks(TEST_SSID).code) } } diff --git a/wisefy/src/androidTest/java/com/isupatches/wisefy/WiseFyTests.kt b/wisefy/src/androidTest/java/com/isupatches/wisefy/WiseFyTests.kt index 9c52dfb1..6401f1e9 100644 --- a/wisefy/src/androidTest/java/com/isupatches/wisefy/WiseFyTests.kt +++ b/wisefy/src/androidTest/java/com/isupatches/wisefy/WiseFyTests.kt @@ -1,9 +1,7 @@ package com.isupatches.wisefy import androidx.test.platform.app.InstrumentationRegistry - import com.isupatches.wisefy.internal.base.BaseInstrumentationTest - import org.junit.Assert.assertEquals import org.junit.Assert.assertNotNull import org.junit.Test @@ -21,27 +19,36 @@ internal class WiseFyTests : BaseInstrumentationTest() { private const val EXPECTED_SIGNAL_RESULT = 35 } - @Test fun brains_loggingFalse() { - val wisefy = WiseFy.Brains(InstrumentationRegistry.getInstrumentation().targetContext).logging(false).getSmarts() + @Test + fun brains_loggingFalse() { + val wisefy = WiseFy.Brains(InstrumentationRegistry.getInstrumentation().targetContext) + .logging(false) + .getSmarts() assertEquals(false, wisefy.isLoggingEnabled()) } - @Test fun brains_loggingTrue() { - val wisefy = WiseFy.Brains(InstrumentationRegistry.getInstrumentation().targetContext).logging(true).getSmarts() + @Test + fun brains_loggingTrue() { + val wisefy = WiseFy.Brains(InstrumentationRegistry.getInstrumentation().targetContext) + .logging(true) + .getSmarts() assertEquals(true, wisefy.isLoggingEnabled()) } - @Test fun calculateBars() { + @Test + fun calculateBars() { val result = wisefy.calculateBars(TEST_RSSI_LEVEL_HIGH, TEST_NUMBER_OF_BARS) assertEquals(EXPECTED_NUMBER_OF_BARS.toLong(), result.toLong()) } - @Test fun compareSignalLevel() { + @Test + fun compareSignalLevel() { val result = wisefy.compareSignalLevel(TEST_RSSI_LEVEL_HIGH, TEST_RSSI_LEVEL_LOW) assertEquals(EXPECTED_SIGNAL_RESULT.toLong(), result.toLong()) } - @Test fun getWiseFyLock() { + @Test + fun getWiseFyLock() { assertNotNull(wisefy.getWiseFyLock()) } } diff --git a/wisefy/src/androidTest/java/com/isupatches/wisefy/connection/WiseFyConnectionLegacyTests.kt b/wisefy/src/androidTest/java/com/isupatches/wisefy/connection/WiseFyConnectionLegacyTests.kt index 3417a2e1..cbc863ef 100644 --- a/wisefy/src/androidTest/java/com/isupatches/wisefy/connection/WiseFyConnectionLegacyTests.kt +++ b/wisefy/src/androidTest/java/com/isupatches/wisefy/connection/WiseFyConnectionLegacyTests.kt @@ -6,7 +6,6 @@ import com.isupatches.wisefy.TEST_TIMEOUT import com.isupatches.wisefy.constants.MOBILE import com.isupatches.wisefy.constants.WIFI import com.isupatches.wisefy.internal.base.BaseInstrumentationTest - import org.junit.After import org.junit.Assert.assertFalse import org.junit.Assert.assertTrue @@ -28,11 +27,13 @@ internal class WiseFyConnectionLegacyTests : BaseInstrumentationTest() { mockWifiManager ) - @Before fun setUp() { + @Before + fun setUp() { wisefyConnection.init() } - @After override fun tearDown() { + @After + override fun tearDown() { super.tearDown() wisefyConnection.destroy() } @@ -41,58 +42,68 @@ internal class WiseFyConnectionLegacyTests : BaseInstrumentationTest() { * isCurrentNetworkConnectedToSSID tests */ - @Test fun isCurrentNetworkConnectedToSSID_failure_nullSSIDParam() { + @Test + fun isCurrentNetworkConnectedToSSID_failure_nullSSIDParam() { assertFalse(wisefyConnection.isCurrentNetworkConnectedToSSID(null)) } - @Test fun isCurrentNetworkConnectedToSSID_failure_emptySSIDParam() { + @Test + fun isCurrentNetworkConnectedToSSID_failure_emptySSIDParam() { assertFalse(wisefyConnection.isCurrentNetworkConnectedToSSID("")) } - @Test fun isCurrentNetworkConnectedToSSID_failure_nullConnectionInfo() { + @Test + fun isCurrentNetworkConnectedToSSID_failure_nullConnectionInfo() { mockNetworkUtil.currentNetwork_null() assertFalse(wisefyConnection.isCurrentNetworkConnectedToSSID(TEST_SSID)) } - @Test fun isCurrentNetworkConnectedToSSID_failure_nullSSID() { + @Test + fun isCurrentNetworkConnectedToSSID_failure_nullSSID() { mockNetworkUtil.currentNetwork(null) - mockNetworkUtil.currentNetworkConnectionStatus(true, true, null) + mockNetworkUtil.currentNetworkConnectionStatus(isAvailable = true, isConnected = true, type = null) assertFalse(wisefyConnection.isCurrentNetworkConnectedToSSID(TEST_SSID)) } - @Test fun isCurrentNetworkConnectedToSSID_failure_emptySSID() { + @Test + fun isCurrentNetworkConnectedToSSID_failure_emptySSID() { mockNetworkUtil.currentNetwork("") - mockNetworkUtil.currentNetworkConnectionStatus(true, true, null) + mockNetworkUtil.currentNetworkConnectionStatus(isAvailable = true, isConnected = true, type = null) assertFalse(wisefyConnection.isCurrentNetworkConnectedToSSID(TEST_SSID)) } - @Test fun isCurrentNetworkConnectedToSSID_failure_differentSSID() { + @Test + fun isCurrentNetworkConnectedToSSID_failure_differentSSID() { mockNetworkUtil.currentNetwork(TEST_SSID2) - mockNetworkUtil.currentNetworkConnectionStatus(true, true, null) + mockNetworkUtil.currentNetworkConnectionStatus(isAvailable = true, isConnected = true, type = null) assertFalse(wisefyConnection.isCurrentNetworkConnectedToSSID(TEST_SSID)) } - @Test fun isCurrentNetworkConnectedToSSID_failure_notAvailable() { + @Test + fun isCurrentNetworkConnectedToSSID_failure_notAvailable() { mockNetworkUtil.currentNetwork(TEST_SSID) - mockNetworkUtil.currentNetworkConnectionStatus(false, true, null) + mockNetworkUtil.currentNetworkConnectionStatus(isAvailable = false, isConnected = true, type = null) assertFalse(wisefyConnection.isCurrentNetworkConnectedToSSID(TEST_SSID)) } - @Test fun isCurrentNetworkConnectedToSSID_failure_notAvailableOrConnected() { + @Test + fun isCurrentNetworkConnectedToSSID_failure_notAvailableOrConnected() { mockNetworkUtil.currentNetwork(TEST_SSID) - mockNetworkUtil.currentNetworkConnectionStatus(false, false, null) + mockNetworkUtil.currentNetworkConnectionStatus(isAvailable = false, isConnected = false, type = null) assertFalse(wisefyConnection.isCurrentNetworkConnectedToSSID(TEST_SSID)) } - @Test fun isCurrentNetworkConnectedToSSID_failure_notConnected() { + @Test + fun isCurrentNetworkConnectedToSSID_failure_notConnected() { mockNetworkUtil.currentNetwork(TEST_SSID) - mockNetworkUtil.currentNetworkConnectionStatus(true, false, null) + mockNetworkUtil.currentNetworkConnectionStatus(isAvailable = true, isConnected = false, type = null) assertFalse(wisefyConnection.isCurrentNetworkConnectedToSSID(TEST_SSID)) } - @Test fun isCurrentNetworkConnectedToSSID_success() { + @Test + fun isCurrentNetworkConnectedToSSID_success() { mockNetworkUtil.currentNetwork(TEST_SSID) - mockNetworkUtil.currentNetworkConnectionStatus(true, true, null) + mockNetworkUtil.currentNetworkConnectionStatus(isAvailable = true, isConnected = true, type = null) assertTrue(wisefyConnection.isCurrentNetworkConnectedToSSID(TEST_SSID)) } @@ -100,27 +111,32 @@ internal class WiseFyConnectionLegacyTests : BaseInstrumentationTest() { * isNetworkConnected tests */ - @Test fun isNetworkConnected_failure_nullNetworkInfoParam() { + @Test + fun isNetworkConnected_failure_nullNetworkInfoParam() { assertFalse(wisefyConnection.isNetworkConnected()) } - @Test fun isNetworkConnected_failure_notAvailable() { - mockNetworkUtil.currentNetworkConnectionStatus(false, true, null) + @Test + fun isNetworkConnected_failure_notAvailable() { + mockNetworkUtil.currentNetworkConnectionStatus(isAvailable = false, isConnected = true, type = null) assertFalse(wisefyConnection.isNetworkConnected()) } - @Test fun isNetworkConnected_failure_notAvailableOrConnected() { - mockNetworkUtil.currentNetworkConnectionStatus(false, false, null) + @Test + fun isNetworkConnected_failure_notAvailableOrConnected() { + mockNetworkUtil.currentNetworkConnectionStatus(isAvailable = false, isConnected = false, type = null) assertFalse(wisefyConnection.isNetworkConnected()) } - @Test fun isNetworkConnected_failure_notConnected() { - mockNetworkUtil.currentNetworkConnectionStatus(true, false, null) + @Test + fun isNetworkConnected_failure_notConnected() { + mockNetworkUtil.currentNetworkConnectionStatus(isAvailable = true, isConnected = false, type = null) assertFalse(wisefyConnection.isNetworkConnected()) } - @Test fun isNetworkConnected_success() { - mockNetworkUtil.currentNetworkConnectionStatus(true, true, null) + @Test + fun isNetworkConnected_success() { + mockNetworkUtil.currentNetworkConnectionStatus(isAvailable = true, isConnected = true, type = null) assertTrue(wisefyConnection.isNetworkConnected()) } @@ -128,55 +144,64 @@ internal class WiseFyConnectionLegacyTests : BaseInstrumentationTest() { * isDeviceConnectedToMobileNetwork tests */ - @Test fun isDeviceConnectedToMobileNetwork_failure_nullNetworkInfo() { + @Test + fun isDeviceConnectedToMobileNetwork_failure_nullNetworkInfo() { assertFalse(wisefyConnection.isDeviceConnectedToMobileNetwork()) } - @Test fun isDeviceConnectedToMobileNetwork_failure_notAvailableOrConnected() { + @Test + fun isDeviceConnectedToMobileNetwork_failure_notAvailableOrConnected() { mockNetworkUtil.currentNetwork(TEST_SSID) - mockNetworkUtil.currentNetworkConnectionStatus(false, false, MOBILE) + mockNetworkUtil.currentNetworkConnectionStatus(isAvailable = false, isConnected = false, type = MOBILE) assertFalse(wisefyConnection.isDeviceConnectedToMobileNetwork()) } - @Test fun isDeviceConnectedToMobileNetwork_failure_notAvailable() { + @Test + fun isDeviceConnectedToMobileNetwork_failure_notAvailable() { mockNetworkUtil.currentNetwork(TEST_SSID) - mockNetworkUtil.currentNetworkConnectionStatus(false, true, MOBILE) + mockNetworkUtil.currentNetworkConnectionStatus(isAvailable = false, isConnected = true, type = MOBILE) assertFalse(wisefyConnection.isDeviceConnectedToMobileNetwork()) } - @Test fun isDeviceConnectedToMobileNetwork_failure_notConnected() { + @Test + fun isDeviceConnectedToMobileNetwork_failure_notConnected() { mockNetworkUtil.currentNetwork(TEST_SSID) - mockNetworkUtil.currentNetworkConnectionStatus(true, false, MOBILE) + mockNetworkUtil.currentNetworkConnectionStatus(isAvailable = true, isConnected = false, type = MOBILE) assertFalse(wisefyConnection.isDeviceConnectedToMobileNetwork()) } - @Test fun isDeviceConnectedToMobileNetwork_failure_nullTypeName() { + @Test + fun isDeviceConnectedToMobileNetwork_failure_nullTypeName() { mockNetworkUtil.currentNetwork(TEST_SSID) - mockNetworkUtil.currentNetworkConnectionStatus(true, true, null) + mockNetworkUtil.currentNetworkConnectionStatus(isAvailable = true, isConnected = true, type = null) assertFalse(wisefyConnection.isDeviceConnectedToMobileNetwork()) } - @Test fun isDeviceConnectedToMobileNetwork_failure_differentTypeName() { + @Test + fun isDeviceConnectedToMobileNetwork_failure_differentTypeName() { mockNetworkUtil.currentNetwork(TEST_SSID) - mockNetworkUtil.currentNetworkConnectionStatus(true, true, WIFI) + mockNetworkUtil.currentNetworkConnectionStatus(isAvailable = true, isConnected = true, type = WIFI) assertFalse(wisefyConnection.isDeviceConnectedToMobileNetwork()) } - @Test fun isDeviceConnectedToMobileNetwork_failure_differentTypeName_differentCase() { + @Test + fun isDeviceConnectedToMobileNetwork_failure_differentTypeName_differentCase() { mockNetworkUtil.currentNetwork(TEST_SSID) - mockNetworkUtil.currentNetworkConnectionStatus(true, true, "wifi") + mockNetworkUtil.currentNetworkConnectionStatus(isAvailable = true, isConnected = true, type = "wifi") assertFalse(wisefyConnection.isDeviceConnectedToMobileNetwork()) } - @Test fun isDeviceConnectedToMobileNetwork_success() { + @Test + fun isDeviceConnectedToMobileNetwork_success() { mockNetworkUtil.currentNetwork(TEST_SSID) - mockNetworkUtil.currentNetworkConnectionStatus(true, true, MOBILE) + mockNetworkUtil.currentNetworkConnectionStatus(isAvailable = true, isConnected = true, type = MOBILE) assertTrue(wisefyConnection.isDeviceConnectedToMobileNetwork()) } - @Test fun isDeviceConnectedToMobileNetwork_success_differentCase() { + @Test + fun isDeviceConnectedToMobileNetwork_success_differentCase() { mockNetworkUtil.currentNetwork(TEST_SSID) - mockNetworkUtil.currentNetworkConnectionStatus(true, true, "mobile") + mockNetworkUtil.currentNetworkConnectionStatus(isAvailable = true, isConnected = true, type = "mobile") assertTrue(wisefyConnection.isDeviceConnectedToMobileNetwork()) } @@ -184,55 +209,64 @@ internal class WiseFyConnectionLegacyTests : BaseInstrumentationTest() { * isDeviceConnectedToWifiNetwork tests */ - @Test fun isDeviceConnectedToWifiNetwork_failure_nullNetworkInfo() { + @Test + fun isDeviceConnectedToWifiNetwork_failure_nullNetworkInfo() { assertFalse(wisefyConnection.isDeviceConnectedToWifiNetwork()) } - @Test fun isDeviceConnectedToWifiNetwork_failure_notAvailableOrConnected() { + @Test + fun isDeviceConnectedToWifiNetwork_failure_notAvailableOrConnected() { mockNetworkUtil.currentNetwork(TEST_SSID) - mockNetworkUtil.currentNetworkConnectionStatus(false, false, WIFI) + mockNetworkUtil.currentNetworkConnectionStatus(isAvailable = false, isConnected = false, type = WIFI) assertFalse(wisefyConnection.isDeviceConnectedToWifiNetwork()) } - @Test fun isDeviceConnectedToWifiNetwork_failure_notAvailable() { + @Test + fun isDeviceConnectedToWifiNetwork_failure_notAvailable() { mockNetworkUtil.currentNetwork(TEST_SSID) - mockNetworkUtil.currentNetworkConnectionStatus(false, true, WIFI) + mockNetworkUtil.currentNetworkConnectionStatus(isAvailable = false, isConnected = true, type = WIFI) assertFalse(wisefyConnection.isDeviceConnectedToWifiNetwork()) } - @Test fun isDeviceConnectedToWifiNetwork_failure_notConnected() { + @Test + fun isDeviceConnectedToWifiNetwork_failure_notConnected() { mockNetworkUtil.currentNetwork(TEST_SSID) - mockNetworkUtil.currentNetworkConnectionStatus(true, false, WIFI) + mockNetworkUtil.currentNetworkConnectionStatus(isAvailable = true, isConnected = false, type = WIFI) assertFalse(wisefyConnection.isDeviceConnectedToWifiNetwork()) } - @Test fun isDeviceConnectedToWifiNetwork_failure_nullTypeName() { + @Test + fun isDeviceConnectedToWifiNetwork_failure_nullTypeName() { mockNetworkUtil.currentNetwork(TEST_SSID) - mockNetworkUtil.currentNetworkConnectionStatus(true, true, null) + mockNetworkUtil.currentNetworkConnectionStatus(isAvailable = true, isConnected = true, type = null) assertFalse(wisefyConnection.isDeviceConnectedToWifiNetwork()) } - @Test fun isDeviceConnectedToWifiNetwork_failure_differentTypeName() { + @Test + fun isDeviceConnectedToWifiNetwork_failure_differentTypeName() { mockNetworkUtil.currentNetwork(TEST_SSID) - mockNetworkUtil.currentNetworkConnectionStatus(true, true, MOBILE) + mockNetworkUtil.currentNetworkConnectionStatus(isAvailable = true, isConnected = true, type = MOBILE) assertFalse(wisefyConnection.isDeviceConnectedToWifiNetwork()) } - @Test fun isDeviceConnectedToWifiNetwork_failure_differentTypeName_differentCase() { + @Test + fun isDeviceConnectedToWifiNetwork_failure_differentTypeName_differentCase() { mockNetworkUtil.currentNetwork(TEST_SSID) - mockNetworkUtil.currentNetworkConnectionStatus(true, true, "mobile") + mockNetworkUtil.currentNetworkConnectionStatus(isAvailable = true, isConnected = true, type = "mobile") assertFalse(wisefyConnection.isDeviceConnectedToWifiNetwork()) } - @Test fun isDeviceConnectedToWifiNetwork_success() { + @Test + fun isDeviceConnectedToWifiNetwork_success() { mockNetworkUtil.currentNetwork(TEST_SSID) - mockNetworkUtil.currentNetworkConnectionStatus(true, true, WIFI) + mockNetworkUtil.currentNetworkConnectionStatus(isAvailable = true, isConnected = true, type = WIFI) assertTrue(wisefyConnection.isDeviceConnectedToWifiNetwork()) } - @Test fun isDeviceConnectedToWifiNetwork_success_differentCase() { + @Test + fun isDeviceConnectedToWifiNetwork_success_differentCase() { mockNetworkUtil.currentNetwork(TEST_SSID) - mockNetworkUtil.currentNetworkConnectionStatus(true, true, "wifi") + mockNetworkUtil.currentNetworkConnectionStatus(isAvailable = true, isConnected = true, type = "wifi") assertTrue(wisefyConnection.isDeviceConnectedToWifiNetwork()) } @@ -240,17 +274,20 @@ internal class WiseFyConnectionLegacyTests : BaseInstrumentationTest() { * isDeviceRoaming tests */ - @Test fun isDeviceRoaming_failure_nullNetworkInfo() { + @Test + fun isDeviceRoaming_failure_nullNetworkInfo() { assertFalse(wisefyConnection.isDeviceRoaming()) } - @Test fun isDeviceRoaming_failure() { + @Test + fun isDeviceRoaming_failure() { mockNetworkUtil.currentNetwork(TEST_SSID) mockNetworkUtil.isDeviceRoaming(false) assertFalse(wisefyConnection.isDeviceRoaming()) } - @Test fun isDeviceRoaming_success() { + @Test + fun isDeviceRoaming_success() { mockNetworkUtil.currentNetwork(TEST_SSID) mockNetworkUtil.isDeviceRoaming(true) assertTrue(wisefyConnection.isDeviceRoaming()) @@ -260,46 +297,54 @@ internal class WiseFyConnectionLegacyTests : BaseInstrumentationTest() { * waitToConnectToSSID tests */ - @Test fun waitToConnectToSSID_failure_nullSSIDParam() { + @Test + fun waitToConnectToSSID_failure_nullSSIDParam() { assertFalse(wisefyConnection.waitToConnectToSSID(null, TEST_TIMEOUT)) } - @Test fun waitToConnectToSSID_failure_nullConnectionInfo() { + @Test + fun waitToConnectToSSID_failure_nullConnectionInfo() { mockNetworkUtil.currentNetwork_null() assertFalse(wisefyConnection.waitToConnectToSSID(TEST_SSID, TEST_TIMEOUT)) } - @Test fun waitToConnectToSSID_failure_nullSSID() { + @Test + fun waitToConnectToSSID_failure_nullSSID() { mockNetworkUtil.currentNetwork(null) assertFalse(wisefyConnection.waitToConnectToSSID(null, TEST_TIMEOUT)) } - @Test fun waitToConnectToSSID_failure_differentSSID() { - mockNetworkUtil.currentNetworkConnectionStatus(true, true, WIFI) + @Test + fun waitToConnectToSSID_failure_differentSSID() { + mockNetworkUtil.currentNetworkConnectionStatus(isAvailable = true, isConnected = true, type = WIFI) mockNetworkUtil.currentNetwork(TEST_SSID2) assertFalse(wisefyConnection.waitToConnectToSSID(TEST_SSID, TEST_TIMEOUT)) } - @Test fun waitToConnectToSSID_failure_notAvailable() { - mockNetworkUtil.currentNetworkConnectionStatus(false, true, WIFI) + @Test + fun waitToConnectToSSID_failure_notAvailable() { + mockNetworkUtil.currentNetworkConnectionStatus(isAvailable = false, isConnected = true, type = WIFI) mockNetworkUtil.currentNetwork(TEST_SSID) assertFalse(wisefyConnection.waitToConnectToSSID(TEST_SSID, TEST_TIMEOUT)) } - @Test fun waitToConnectToSSID_failure_notAvailableOrConnected() { - mockNetworkUtil.currentNetworkConnectionStatus(false, false, WIFI) + @Test + fun waitToConnectToSSID_failure_notAvailableOrConnected() { + mockNetworkUtil.currentNetworkConnectionStatus(isAvailable = false, isConnected = false, type = WIFI) mockNetworkUtil.currentNetwork(TEST_SSID) assertFalse(wisefyConnection.waitToConnectToSSID(TEST_SSID, TEST_TIMEOUT)) } - @Test fun waitToConnectToSSID_failure_notConnected() { - mockNetworkUtil.currentNetworkConnectionStatus(true, false, WIFI) + @Test + fun waitToConnectToSSID_failure_notConnected() { + mockNetworkUtil.currentNetworkConnectionStatus(isAvailable = true, isConnected = false, type = WIFI) mockNetworkUtil.currentNetwork(TEST_SSID) assertFalse(wisefyConnection.waitToConnectToSSID(TEST_SSID, TEST_TIMEOUT)) } - @Test fun waitToConnectToSSID_success() { - mockNetworkUtil.currentNetworkConnectionStatus(true, true, WIFI) + @Test + fun waitToConnectToSSID_success() { + mockNetworkUtil.currentNetworkConnectionStatus(isAvailable = true, isConnected = true, type = WIFI) mockNetworkUtil.currentNetwork(TEST_SSID) assertTrue(wisefyConnection.waitToConnectToSSID(TEST_SSID, TEST_TIMEOUT)) } diff --git a/wisefy/src/androidTest/java/com/isupatches/wisefy/connection/WisefyConnectionSDK23Tests.kt b/wisefy/src/androidTest/java/com/isupatches/wisefy/connection/WisefyConnectionSDK23Tests.kt index e069e640..b1175b09 100644 --- a/wisefy/src/androidTest/java/com/isupatches/wisefy/connection/WisefyConnectionSDK23Tests.kt +++ b/wisefy/src/androidTest/java/com/isupatches/wisefy/connection/WisefyConnectionSDK23Tests.kt @@ -2,21 +2,18 @@ package com.isupatches.wisefy.connection import android.net.Network import android.os.Build - import com.isupatches.wisefy.TEST_SSID import com.isupatches.wisefy.TEST_SSID2 import com.isupatches.wisefy.TEST_TIMEOUT import com.isupatches.wisefy.internal.base.BaseInstrumentationTest import com.isupatches.wisefy.internal.getNetworkCapabilities import com.isupatches.wisefy.internal.setUpNetworkCapabilities - import org.junit.After import org.junit.Assert.assertFalse import org.junit.Assert.assertTrue import org.junit.Assume.assumeTrue import org.junit.Before import org.junit.Test - import org.mockito.Mockito.mock /** @@ -33,17 +30,19 @@ internal class WisefyConnectionSDK23Tests : BaseInstrumentationTest() { WiseFyConnectionSDK23.create(mockConnectivityManager, mockWifiManager) } - @Before fun setUp() { + @Before + fun setUp() { assumeTrue( - "Can only run on API Level 23 or newer", - Build.VERSION.SDK_INT >= Build.VERSION_CODES.M + "Can only run on API Level 23 or newer", + Build.VERSION.SDK_INT >= Build.VERSION_CODES.M ) if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { wisefyConnection.init() } } - @After override fun tearDown() { + @After + override fun tearDown() { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { wisefyConnection.destroy() } @@ -54,48 +53,56 @@ internal class WisefyConnectionSDK23Tests : BaseInstrumentationTest() { * isCurrentNetworkConnectedToSSID tests */ - @Test fun isCurrentNetworkConnectedToSSID_failure_nullSSIDParam() { + @Test + fun isCurrentNetworkConnectedToSSID_failure_nullSSIDParam() { withAvailableNetwork() assertFalse(wisefyConnection.isCurrentNetworkConnectedToSSID(null)) } - @Test fun isCurrentNetworkConnectedToSSID_failure_nullConnectionInfo() { + @Test + fun isCurrentNetworkConnectedToSSID_failure_nullConnectionInfo() { withAvailableNetwork() mockNetworkUtil.currentNetwork_null() assertFalse(wisefyConnection.isCurrentNetworkConnectedToSSID(TEST_SSID)) } - @Test fun isCurrentNetworkConnectedToSSID_failure_nullSSID() { + @Test + fun isCurrentNetworkConnectedToSSID_failure_nullSSID() { withAvailableNetwork() mockNetworkUtil.currentNetwork(null) assertFalse(wisefyConnection.isCurrentNetworkConnectedToSSID(TEST_SSID)) } - @Test fun isCurrentNetworkConnectedToSSID_failure_differentSSID() { + @Test + fun isCurrentNetworkConnectedToSSID_failure_differentSSID() { withAvailableNetwork() mockNetworkUtil.currentNetwork(TEST_SSID2) assertFalse(wisefyConnection.isCurrentNetworkConnectedToSSID(TEST_SSID)) } - @Test fun isCurrentNetworkConnectedToSSID_failure_unavailable() { + @Test + fun isCurrentNetworkConnectedToSSID_failure_unavailable() { mockNetworkUtil.currentNetwork(TEST_SSID) withUnavailableNetwork() assertFalse(wisefyConnection.isCurrentNetworkConnectedToSSID(TEST_SSID)) } - @Test fun isCurrentNetworkConnectedToSSID_failure_lost() { + @Test + fun isCurrentNetworkConnectedToSSID_failure_lost() { mockNetworkUtil.currentNetwork(TEST_SSID) withLostNetwork() assertFalse(wisefyConnection.isCurrentNetworkConnectedToSSID(TEST_SSID)) } - @Test fun isCurrentNetworkConnectedToSSID_failure_losing() { + @Test + fun isCurrentNetworkConnectedToSSID_failure_losing() { mockNetworkUtil.currentNetwork(TEST_SSID) withLosingNetwork() assertFalse(wisefyConnection.isCurrentNetworkConnectedToSSID(TEST_SSID)) } - @Test fun isCurrentNetworkConnectedToSSID_success() { + @Test + fun isCurrentNetworkConnectedToSSID_success() { mockNetworkUtil.currentNetwork(TEST_SSID) withAvailableNetwork() assertTrue(wisefyConnection.isCurrentNetworkConnectedToSSID(TEST_SSID)) @@ -105,22 +112,26 @@ internal class WisefyConnectionSDK23Tests : BaseInstrumentationTest() { * isNetworkConnected tests */ - @Test fun isNetworkConnected_failure_unavailable() { + @Test + fun isNetworkConnected_failure_unavailable() { withUnavailableNetwork() assertFalse(wisefyConnection.isNetworkConnected()) } - @Test fun isNetworkConnected_failure_lost() { + @Test + fun isNetworkConnected_failure_lost() { withLostNetwork() assertFalse(wisefyConnection.isNetworkConnected()) } - @Test fun isNetworkConnected_failure_losing() { + @Test + fun isNetworkConnected_failure_losing() { withLosingNetwork() assertFalse(wisefyConnection.isNetworkConnected()) } - @Test fun isNetworkConnected_success() { + @Test + fun isNetworkConnected_success() { withAvailableNetwork() assertTrue(wisefyConnection.isNetworkConnected()) } @@ -129,16 +140,19 @@ internal class WisefyConnectionSDK23Tests : BaseInstrumentationTest() { * isDeviceConnectedToMobileNetwork tests */ - @Test fun isDeviceConnectedToMobileNetwork_failure_noActiveNetwork() { + @Test + fun isDeviceConnectedToMobileNetwork_failure_noActiveNetwork() { assertFalse(wisefyConnection.isDeviceConnectedToMobileNetwork()) } - @Test fun isDeviceConnectedToMobileNetwork_failure_noCapabilities() { + @Test + fun isDeviceConnectedToMobileNetwork_failure_noCapabilities() { withAvailableNetwork() assertFalse(wisefyConnection.isDeviceConnectedToMobileNetwork()) } - @Test fun isDeviceConnectedToMobileNetwork_failure_differentTransport() { + @Test + fun isDeviceConnectedToMobileNetwork_failure_differentTransport() { withAvailableNetwork() val networkCapabilities = getNetworkCapabilities( android.net.NetworkCapabilities.TRANSPORT_WIFI, @@ -152,7 +166,8 @@ internal class WisefyConnectionSDK23Tests : BaseInstrumentationTest() { assertFalse(wisefyConnection.isDeviceConnectedToMobileNetwork()) } - @Test fun isDeviceConnectedToMobileNetwork_failure_noInternetCapability() { + @Test + fun isDeviceConnectedToMobileNetwork_failure_noInternetCapability() { withAvailableNetwork() val networkCapabilities = getNetworkCapabilities( android.net.NetworkCapabilities.TRANSPORT_CELLULAR @@ -165,7 +180,8 @@ internal class WisefyConnectionSDK23Tests : BaseInstrumentationTest() { assertFalse(wisefyConnection.isDeviceConnectedToMobileNetwork()) } - @Test fun isDeviceConnectedToMobileNetwork_failure_unavailable() { + @Test + fun isDeviceConnectedToMobileNetwork_failure_unavailable() { withUnavailableNetwork() val networkCapabilities = getNetworkCapabilities( android.net.NetworkCapabilities.TRANSPORT_CELLULAR, @@ -179,7 +195,8 @@ internal class WisefyConnectionSDK23Tests : BaseInstrumentationTest() { assertFalse(wisefyConnection.isDeviceConnectedToMobileNetwork()) } - @Test fun isDeviceConnectedToMobileNetwork_failure_lost() { + @Test + fun isDeviceConnectedToMobileNetwork_failure_lost() { withLostNetwork() val networkCapabilities = getNetworkCapabilities( android.net.NetworkCapabilities.TRANSPORT_CELLULAR, @@ -193,7 +210,8 @@ internal class WisefyConnectionSDK23Tests : BaseInstrumentationTest() { assertFalse(wisefyConnection.isDeviceConnectedToMobileNetwork()) } - @Test fun isDeviceConnectedToMobileNetwork_failure_losing() { + @Test + fun isDeviceConnectedToMobileNetwork_failure_losing() { withLosingNetwork() val networkCapabilities = getNetworkCapabilities( android.net.NetworkCapabilities.TRANSPORT_CELLULAR, @@ -207,7 +225,8 @@ internal class WisefyConnectionSDK23Tests : BaseInstrumentationTest() { assertFalse(wisefyConnection.isDeviceConnectedToMobileNetwork()) } - @Test fun isDeviceConnectedToMobileNetwork_success() { + @Test + fun isDeviceConnectedToMobileNetwork_success() { withAvailableNetwork() val networkCapabilities = getNetworkCapabilities( android.net.NetworkCapabilities.TRANSPORT_CELLULAR, @@ -225,16 +244,19 @@ internal class WisefyConnectionSDK23Tests : BaseInstrumentationTest() { * isDeviceConnectedToWifiNetwork tests */ - @Test fun isDeviceConnectedToWifiNetwork_failure_noActiveNetwork() { + @Test + fun isDeviceConnectedToWifiNetwork_failure_noActiveNetwork() { assertFalse(wisefyConnection.isDeviceConnectedToWifiNetwork()) } - @Test fun isDeviceConnectedToWifiNetwork_failure_noCapabilities() { + @Test + fun isDeviceConnectedToWifiNetwork_failure_noCapabilities() { withAvailableNetwork() assertFalse(wisefyConnection.isDeviceConnectedToWifiNetwork()) } - @Test fun isDeviceConnectedToWifiNetwork_failure_differentTransport() { + @Test + fun isDeviceConnectedToWifiNetwork_failure_differentTransport() { withAvailableNetwork() val networkCapabilities = getNetworkCapabilities( android.net.NetworkCapabilities.TRANSPORT_CELLULAR, @@ -248,7 +270,8 @@ internal class WisefyConnectionSDK23Tests : BaseInstrumentationTest() { assertFalse(wisefyConnection.isDeviceConnectedToWifiNetwork()) } - @Test fun isDeviceConnectedToWifiNetwork_failure_noInternetCapability() { + @Test + fun isDeviceConnectedToWifiNetwork_failure_noInternetCapability() { withAvailableNetwork() val networkCapabilities = getNetworkCapabilities( android.net.NetworkCapabilities.TRANSPORT_WIFI @@ -261,7 +284,8 @@ internal class WisefyConnectionSDK23Tests : BaseInstrumentationTest() { assertFalse(wisefyConnection.isDeviceConnectedToWifiNetwork()) } - @Test fun isDeviceConnectedToWifiNetwork_failure_unavailable() { + @Test + fun isDeviceConnectedToWifiNetwork_failure_unavailable() { withUnavailableNetwork() val networkCapabilities = getNetworkCapabilities( android.net.NetworkCapabilities.TRANSPORT_WIFI, @@ -275,7 +299,8 @@ internal class WisefyConnectionSDK23Tests : BaseInstrumentationTest() { assertFalse(wisefyConnection.isDeviceConnectedToWifiNetwork()) } - @Test fun isDeviceConnectedToWifiNetwork_failure_lost() { + @Test + fun isDeviceConnectedToWifiNetwork_failure_lost() { withLostNetwork() val networkCapabilities = getNetworkCapabilities( android.net.NetworkCapabilities.TRANSPORT_WIFI, @@ -289,7 +314,8 @@ internal class WisefyConnectionSDK23Tests : BaseInstrumentationTest() { assertFalse(wisefyConnection.isDeviceConnectedToWifiNetwork()) } - @Test fun isDeviceConnectedToWifiNetwork_failure_losing() { + @Test + fun isDeviceConnectedToWifiNetwork_failure_losing() { withLosingNetwork() val networkCapabilities = getNetworkCapabilities( android.net.NetworkCapabilities.TRANSPORT_WIFI, @@ -303,7 +329,8 @@ internal class WisefyConnectionSDK23Tests : BaseInstrumentationTest() { assertFalse(wisefyConnection.isDeviceConnectedToWifiNetwork()) } - @Test fun isDeviceConnectedToWifiNetwork_success() { + @Test + fun isDeviceConnectedToWifiNetwork_success() { withAvailableNetwork() val networkCapabilities = getNetworkCapabilities( android.net.NetworkCapabilities.TRANSPORT_WIFI, @@ -321,15 +348,17 @@ internal class WisefyConnectionSDK23Tests : BaseInstrumentationTest() { * isDeviceRoaming tests */ - @Test fun isDeviceRoaming_failure_nullNetworkInfo() { + @Test + fun isDeviceRoaming_failure_nullNetworkInfo() { assumeTrue( - "Can only run on API's before Level 28", - Build.VERSION.SDK_INT < Build.VERSION_CODES.P + "Can only run on API's before Level 28", + Build.VERSION.SDK_INT < Build.VERSION_CODES.P ) assertFalse(wisefyConnection.isDeviceRoaming()) } - @Test fun isDeviceRoaming_failure() { + @Test + fun isDeviceRoaming_failure() { assumeTrue( "Can only run on API's before Level 28", Build.VERSION.SDK_INT < Build.VERSION_CODES.P @@ -339,29 +368,32 @@ internal class WisefyConnectionSDK23Tests : BaseInstrumentationTest() { assertFalse(wisefyConnection.isDeviceRoaming()) } - @Test fun isDeviceRoaming_success() { + @Test + fun isDeviceRoaming_success() { assumeTrue( - "Can only run on API's before Level 28", - Build.VERSION.SDK_INT < Build.VERSION_CODES.P + "Can only run on API's before Level 28", + Build.VERSION.SDK_INT < Build.VERSION_CODES.P ) mockNetworkUtil.currentNetwork(TEST_SSID) mockNetworkUtil.isDeviceRoaming(true) assertTrue(wisefyConnection.isDeviceRoaming()) } - @Test fun isDeviceRoaming_sdk28_failure_nullNetwork() { + @Test + fun isDeviceRoaming_sdk28_failure_nullNetwork() { assumeTrue( - "Can only run on API Level 28 or newer", - Build.VERSION.SDK_INT >= Build.VERSION_CODES.P + "Can only run on API Level 28 or newer", + Build.VERSION.SDK_INT >= Build.VERSION_CODES.P ) mockNetworkUtil.isDeviceRoaming(false) assertTrue(wisefyConnection.isDeviceRoaming()) } - @Test fun isDeviceRoaming_sdk28_failure_missingNotRoamingCapability() { + @Test + fun isDeviceRoaming_sdk28_failure_missingNotRoamingCapability() { assumeTrue( - "Can only run on API Level 28 or newer", - Build.VERSION.SDK_INT >= Build.VERSION_CODES.P + "Can only run on API Level 28 or newer", + Build.VERSION.SDK_INT >= Build.VERSION_CODES.P ) val networkCapabilities = android.net.NetworkCapabilities(null) setUpNetworkCapabilities( @@ -373,10 +405,11 @@ internal class WisefyConnectionSDK23Tests : BaseInstrumentationTest() { assertTrue(wisefyConnection.isDeviceRoaming()) } - @Test fun isDeviceRoaming_sdk28_success() { + @Test + fun isDeviceRoaming_sdk28_success() { assumeTrue( - "Can only run on API Level 28 or newer", - Build.VERSION.SDK_INT >= Build.VERSION_CODES.P + "Can only run on API Level 28 or newer", + Build.VERSION.SDK_INT >= Build.VERSION_CODES.P ) val networkCapabilities = getNetworkCapabilities( arrayOf(android.net.NetworkCapabilities.NET_CAPABILITY_NOT_ROAMING) @@ -394,48 +427,56 @@ internal class WisefyConnectionSDK23Tests : BaseInstrumentationTest() { * waitToConnectToSSID tests */ - @Test fun waitToConnectToSSID_failure_nullSSIDParam() { + @Test + fun waitToConnectToSSID_failure_nullSSIDParam() { withAvailableNetwork() assertFalse(wisefyConnection.waitToConnectToSSID(null, TEST_TIMEOUT)) } - @Test fun waitToConnectToSSID_failure_nullConnectionInfo() { + @Test + fun waitToConnectToSSID_failure_nullConnectionInfo() { withAvailableNetwork() mockNetworkUtil.currentNetwork_null() assertFalse(wisefyConnection.waitToConnectToSSID(TEST_SSID, TEST_TIMEOUT)) } - @Test fun waitToConnectToSSID_failure_nullSSID() { + @Test + fun waitToConnectToSSID_failure_nullSSID() { withAvailableNetwork() mockNetworkUtil.currentNetwork(null) assertFalse(wisefyConnection.waitToConnectToSSID(null, TEST_TIMEOUT)) } - @Test fun waitToConnectToSSID_failure_differentSSID() { + @Test + fun waitToConnectToSSID_failure_differentSSID() { withAvailableNetwork() mockNetworkUtil.currentNetwork(TEST_SSID2) assertFalse(wisefyConnection.waitToConnectToSSID(TEST_SSID, TEST_TIMEOUT)) } - @Test fun waitToConnectToSSID_failure_unavailable() { + @Test + fun waitToConnectToSSID_failure_unavailable() { withUnavailableNetwork() mockNetworkUtil.currentNetwork(TEST_SSID) assertFalse(wisefyConnection.waitToConnectToSSID(TEST_SSID, TEST_TIMEOUT)) } - @Test fun waitToConnectToSSID_failure_losing() { + @Test + fun waitToConnectToSSID_failure_losing() { withLosingNetwork() mockNetworkUtil.currentNetwork(TEST_SSID) assertFalse(wisefyConnection.waitToConnectToSSID(TEST_SSID, TEST_TIMEOUT)) } - @Test fun waitToConnectToSSID_failure_lost() { + @Test + fun waitToConnectToSSID_failure_lost() { withLostNetwork() mockNetworkUtil.currentNetwork(TEST_SSID) assertFalse(wisefyConnection.waitToConnectToSSID(TEST_SSID, TEST_TIMEOUT)) } - @Test fun waitToConnectToSSID_success() { + @Test + fun waitToConnectToSSID_success() { withAvailableNetwork() mockNetworkUtil.currentNetwork(TEST_SSID) assertTrue(wisefyConnection.waitToConnectToSSID(TEST_SSID, TEST_TIMEOUT)) diff --git a/wisefy/src/androidTest/java/com/isupatches/wisefy/internal/GeneratorUtil.kt b/wisefy/src/androidTest/java/com/isupatches/wisefy/internal/GeneratorUtil.kt index 3a89b12e..8b236b73 100644 --- a/wisefy/src/androidTest/java/com/isupatches/wisefy/internal/GeneratorUtil.kt +++ b/wisefy/src/androidTest/java/com/isupatches/wisefy/internal/GeneratorUtil.kt @@ -2,7 +2,6 @@ package com.isupatches.wisefy.internal import android.net.wifi.ScanResult import android.net.wifi.WifiConfiguration - import org.mockito.Mockito.mock /** diff --git a/wisefy/src/androidTest/java/com/isupatches/wisefy/internal/NetworkCapabilitiesUtil.kt b/wisefy/src/androidTest/java/com/isupatches/wisefy/internal/NetworkCapabilitiesUtil.kt index 0cadf0c1..a38147aa 100644 --- a/wisefy/src/androidTest/java/com/isupatches/wisefy/internal/NetworkCapabilitiesUtil.kt +++ b/wisefy/src/androidTest/java/com/isupatches/wisefy/internal/NetworkCapabilitiesUtil.kt @@ -3,9 +3,7 @@ package com.isupatches.wisefy.internal import android.net.ConnectivityManager import android.net.Network import android.net.NetworkCapabilities - import com.isupatches.wisefy.connection.WiseFyConnectionSDK23 - import org.mockito.Mockito.`when` import org.mockito.Mockito.mock @@ -24,9 +22,9 @@ import org.mockito.Mockito.mock internal fun getNetworkCapabilities(transportType: Int): NetworkCapabilities { val networkCapabilities = NetworkCapabilities(null) ReflectionHelpers.callInstanceMethod( - networkCapabilities, - "addTransportType", - ReflectionHelpers.ClassParameter.from(Int::class.java, transportType) + networkCapabilities, + "addTransportType", + ReflectionHelpers.ClassParameter.from(Int::class.java, transportType) ) return networkCapabilities } @@ -34,6 +32,8 @@ internal fun getNetworkCapabilities(transportType: Int): NetworkCapabilities { /** * To create a NetworkCapabilities instance with a specified set of capabilities. * + * @param capabilities The int array of capabilities for the NetworkCapabilities instance + * * @return NetworkCapabilities - The network capabilities instance with a given transport type * * @see NetworkCapabilities @@ -45,9 +45,9 @@ internal fun getNetworkCapabilities(capabilities: Array): NetworkCapabiliti val networkCapabilities = NetworkCapabilities(null) for (capability in capabilities) { ReflectionHelpers.callInstanceMethod( - networkCapabilities, - "addCapability", - ReflectionHelpers.ClassParameter.from(Int::class.java, capability) + networkCapabilities, + "addCapability", + ReflectionHelpers.ClassParameter.from(Int::class.java, capability) ) } return networkCapabilities @@ -70,15 +70,15 @@ internal fun getNetworkCapabilities(capabilities: Array): NetworkCapabiliti internal fun getNetworkCapabilities(transportType: Int, capabilities: Array): NetworkCapabilities { val networkCapabilities = NetworkCapabilities(null) ReflectionHelpers.callInstanceMethod( - networkCapabilities, - "addTransportType", - ReflectionHelpers.ClassParameter.from(Int::class.java, transportType) + networkCapabilities, + "addTransportType", + ReflectionHelpers.ClassParameter.from(Int::class.java, transportType) ) for (capability in capabilities) { ReflectionHelpers.callInstanceMethod( - networkCapabilities, - "addCapability", - ReflectionHelpers.ClassParameter.from(Int::class.java, capability) + networkCapabilities, + "addCapability", + ReflectionHelpers.ClassParameter.from(Int::class.java, capability) ) } return networkCapabilities diff --git a/wisefy/src/androidTest/java/com/isupatches/wisefy/internal/NullCallbackUtil.kt b/wisefy/src/androidTest/java/com/isupatches/wisefy/internal/NullCallbackUtil.kt index c6f8bd46..0431e51d 100644 --- a/wisefy/src/androidTest/java/com/isupatches/wisefy/internal/NullCallbackUtil.kt +++ b/wisefy/src/androidTest/java/com/isupatches/wisefy/internal/NullCallbackUtil.kt @@ -1,13 +1,11 @@ package com.isupatches.wisefy.internal import android.net.wifi.WifiInfo - import com.isupatches.wisefy.TEST_SSID import com.isupatches.wisefy.TEST_TIMEOUT import com.isupatches.wisefy.WiseFy import com.isupatches.wisefy.callbacks.GetFrequencyCallbacks import com.isupatches.wisefy.callbacks.GetSavedNetworksCallbacks - import org.junit.Assert.fail /** @@ -44,7 +42,7 @@ internal class NullCallbackUtil internal constructor(private val wisefy: WiseFy) * @author Patches * @since 3.0 */ - @Suppress("DEPRECATION") + @Suppress("deprecation") fun callAddWEPNetwork(ssid: String?, password: String?) { try { wisefy.addWEPNetwork(ssid, password, null) diff --git a/wisefy/src/androidTest/java/com/isupatches/wisefy/internal/ReflectionHelpers.java b/wisefy/src/androidTest/java/com/isupatches/wisefy/internal/ReflectionHelpers.java index f15e07e6..d2d50558 100644 --- a/wisefy/src/androidTest/java/com/isupatches/wisefy/internal/ReflectionHelpers.java +++ b/wisefy/src/androidTest/java/com/isupatches/wisefy/internal/ReflectionHelpers.java @@ -1,7 +1,7 @@ /* - * This logic/class was borrowed from Robolectric. + * This logic/class was borrowed from Robolectric's ReflectionHelpers.java. * - * https://github.com/robolectric/robolectric/blob/master/shadowapi/src/main/java/org/robolectric/util/ReflectionHelpers.java + * https://github.com/robolectric/robolectric/blob/master/shadowapi/src/main/java/org/robolectric/util/ */ package com.isupatches.wisefy.internal; @@ -21,7 +21,11 @@ public class ReflectionHelpers { * @param The return type. * @return The return value of the method. */ - public static R callInstanceMethod(final Object instance, final String methodName, ClassParameter... classParameters) { + public static R callInstanceMethod( + final Object instance, + final String methodName, + ClassParameter... classParameters + ) { try { final Class[] classes = ClassParameter.getClasses(classParameters); final Object[] values = ClassParameter.getValues(classParameters); @@ -44,7 +48,11 @@ public static R callInstanceMethod(final Object instance, final String metho } } - private static R traverseClassHierarchy(Class targetClass, Class exceptionClass, InsideTraversal insideTraversal) throws Exception { + private static R traverseClassHierarchy( + Class targetClass, + Class exceptionClass, + InsideTraversal insideTraversal + ) throws Exception { Class hierarchyTraversalClass = targetClass; while (true) { try { diff --git a/wisefy/src/androidTest/java/com/isupatches/wisefy/internal/VerificationUtil.kt b/wisefy/src/androidTest/java/com/isupatches/wisefy/internal/VerificationUtil.kt index 48c39d71..438484a4 100644 --- a/wisefy/src/androidTest/java/com/isupatches/wisefy/internal/VerificationUtil.kt +++ b/wisefy/src/androidTest/java/com/isupatches/wisefy/internal/VerificationUtil.kt @@ -5,7 +5,6 @@ import android.net.wifi.WifiConfiguration import android.net.wifi.WifiManager import com.isupatches.wisefy.VERIFICATION_FAILURE_TIMEOUT import com.isupatches.wisefy.VERIFICATION_SUCCESS_TIMEOUT - import org.mockito.ArgumentMatchers.any import org.mockito.ArgumentMatchers.anyBoolean import org.mockito.ArgumentMatchers.anyInt @@ -40,7 +39,9 @@ internal class VerificationUtil internal constructor( * @since 3.0 */ fun didNoTryToAddNetwork() { - verify(mockWifiManager, after(VERIFICATION_FAILURE_TIMEOUT).times(0)).addNetwork(any(WifiConfiguration::class.java)) + verify(mockWifiManager, after(VERIFICATION_FAILURE_TIMEOUT).times(0)).addNetwork( + any(WifiConfiguration::class.java) + ) } /** @@ -137,7 +138,7 @@ internal class VerificationUtil internal constructor( * @author Patches * @since 3.0 */ - @Suppress("DEPRECATION") + @Suppress("deprecation") fun didNotTryToScanForAccessPoints() { verify(mockWifiManager, after(VERIFICATION_FAILURE_TIMEOUT).times(0)).startScan() } @@ -288,7 +289,7 @@ internal class VerificationUtil internal constructor( * @author Patches * @since 3.0 */ - @Suppress("DEPRECATION") + @Suppress("deprecation") fun triedToScanForAccessPoints() { verify(mockWifiManager, atLeastOnce()).startScan() } diff --git a/wisefy/src/androidTest/java/com/isupatches/wisefy/internal/base/BaseInstrumentationTest.kt b/wisefy/src/androidTest/java/com/isupatches/wisefy/internal/base/BaseInstrumentationTest.kt index 172f60d0..e4447b65 100644 --- a/wisefy/src/androidTest/java/com/isupatches/wisefy/internal/base/BaseInstrumentationTest.kt +++ b/wisefy/src/androidTest/java/com/isupatches/wisefy/internal/base/BaseInstrumentationTest.kt @@ -4,7 +4,6 @@ import android.net.ConnectivityManager import android.net.wifi.WifiConfiguration import android.net.wifi.WifiManager import androidx.test.platform.app.InstrumentationRegistry - import com.isupatches.wisefy.VERIFICATION_SUCCESS_TIMEOUT import com.isupatches.wisefy.WiseFy import com.isupatches.wisefy.WiseFyPrechecks @@ -17,9 +16,7 @@ import com.isupatches.wisefy.internal.mock.MockWiseFyConnectionUtil import com.isupatches.wisefy.internal.mock.MockWiseFyPrechecksUtil import com.isupatches.wisefy.internal.mock.MockWiseFySearchUtil import com.isupatches.wisefy.search.WiseFySearch - import org.junit.After - import org.mockito.ArgumentMatchers.anyInt import org.mockito.Mockito import org.mockito.Mockito.mock @@ -55,13 +52,13 @@ internal abstract class BaseInstrumentationTest { mockConnectivityManager = mock(ConnectivityManager::class.java) wisefy = WiseFy.Brains(InstrumentationRegistry.getInstrumentation().targetContext) - .customConnectivityManager(mockConnectivityManager) - .customWifiManager(mockWifiManager) - .customWiseFyConnection(mockWiseFyConnection) - .customWiseFyPrechecks(mockWiseFyPrechecks) - .customWiseFySearch(mockWiseFySearch) - .logging(true) - .getSmarts() + .customConnectivityManager(mockConnectivityManager) + .customWifiManager(mockWifiManager) + .customWiseFyConnection(mockWiseFyConnection) + .customWiseFyPrechecks(mockWiseFyPrechecks) + .customWiseFySearch(mockWiseFySearch) + .logging(true) + .getSmarts() wisefy.setupWiseFyThread(true) @@ -83,6 +80,9 @@ internal abstract class BaseInstrumentationTest { protected fun any(type: Class): T = Mockito.any(type) protected fun verifyNetworkAdded(mockCallbacks: AddNetworkCallbacks) { - verify(mockCallbacks, timeout(VERIFICATION_SUCCESS_TIMEOUT)).networkAdded(anyInt(), any(WifiConfiguration::class.java)) + verify( + mockCallbacks, + timeout(VERIFICATION_SUCCESS_TIMEOUT) + ).networkAdded(anyInt(), any(WifiConfiguration::class.java)) } -} \ No newline at end of file +} diff --git a/wisefy/src/androidTest/java/com/isupatches/wisefy/internal/mock/MockNetworkUtil.kt b/wisefy/src/androidTest/java/com/isupatches/wisefy/internal/mock/MockNetworkUtil.kt index 742f3fd1..3413229b 100644 --- a/wisefy/src/androidTest/java/com/isupatches/wisefy/internal/mock/MockNetworkUtil.kt +++ b/wisefy/src/androidTest/java/com/isupatches/wisefy/internal/mock/MockNetworkUtil.kt @@ -6,7 +6,6 @@ import android.net.wifi.ScanResult import android.net.wifi.WifiConfiguration import android.net.wifi.WifiInfo import android.net.wifi.WifiManager - import com.isupatches.wisefy.TEST_IP_ADDRESS_INT import com.isupatches.wisefy.TEST_RSSI_LEVEL import com.isupatches.wisefy.TEST_RSSI_LEVEL_HIGH @@ -18,7 +17,6 @@ import com.isupatches.wisefy.WiseFy.Companion.WIFI_MANAGER_FAILURE import com.isupatches.wisefy.internal.createMockAccessPointWithSSID import com.isupatches.wisefy.internal.createMockAccessPointWithSSIDAndRSSI import com.isupatches.wisefy.internal.createSavedNetwork - import org.mockito.ArgumentMatchers.any import org.mockito.ArgumentMatchers.anyInt import org.mockito.Mockito.`when` @@ -118,7 +116,7 @@ internal class MockNetworkUtil internal constructor( * @author Patches * @since 3.0 */ - @Suppress("DEPRECATION") + @Suppress("deprecation") internal fun currentNetworkConnectionStatus(isAvailable: Boolean, isConnected: Boolean, type: String?) { val networkInfo = mock(NetworkInfo::class.java) `when`(networkInfo.isAvailable).thenReturn(isAvailable) @@ -282,7 +280,7 @@ internal class MockNetworkUtil internal constructor( * @author Patches * @since 3.0 */ - @Suppress("DEPRECATION") + @Suppress("deprecation") internal fun isDeviceRoaming(roaming: Boolean) { val networkInfo = mock(NetworkInfo::class.java) `when`(networkInfo.isRoaming).thenReturn(roaming) @@ -825,41 +823,48 @@ internal class MockNetworkUtil internal constructor( private fun addToExpectedNearbyAccessPoints(accessPoint: ScanResult) { expectedNearbyAccessPoint = accessPoint - expectedNearbyAccessPoints = ArrayList() - expectedNearbyAccessPoints!!.add(accessPoint) + val accessPoints = ArrayList() + accessPoints.add(accessPoint) + expectedNearbyAccessPoints = accessPoints } private fun addToExpectedNearbyAccessPoints(accessPoint1: ScanResult, accessPoint2: ScanResult) { expectedNearbyAccessPoint = accessPoint1 - expectedNearbyAccessPoints = ArrayList() - expectedNearbyAccessPoints!!.add(accessPoint1) - expectedNearbyAccessPoints!!.add(accessPoint2) + val accessPoints = ArrayList() + accessPoints.add(accessPoint1) + accessPoints.add(accessPoint2) + expectedNearbyAccessPoints = accessPoints } private fun addToExpectedSavedNetworks(savedNetwork: WifiConfiguration) { expectedSavedNetwork = savedNetwork - expectedSavedNetworks = ArrayList() - expectedSavedNetworks!!.add(savedNetwork) + val savedNetworks = ArrayList() + savedNetworks.add(savedNetwork) + expectedSavedNetworks = savedNetworks } private fun addToExpectedSavedNetworks(savedNetwork1: WifiConfiguration, savedNetwork2: WifiConfiguration) { expectedSavedNetwork = savedNetwork1 expectedSavedNetworks = ArrayList() - expectedSavedNetworks!!.add(savedNetwork1) - expectedSavedNetworks!!.add(savedNetwork2) + val savedNetworks = ArrayList() + savedNetworks.add(savedNetwork1) + savedNetworks.add(savedNetwork2) + expectedSavedNetworks = savedNetworks } private fun addToExpectedSSIDs(accessPoint: ScanResult) { - expectedSSIDs = ArrayList() - expectedSSIDs!!.add(accessPoint.SSID) + val ssids = ArrayList() + ssids.add(accessPoint.SSID) + expectedSSIDs = ssids } private fun addToExpectedSSIDs(accessPoint1: ScanResult, accessPoint2: ScanResult) { - expectedSSIDs = ArrayList() - expectedSSIDs!!.add(accessPoint1.SSID) - expectedSSIDs!!.add(accessPoint2.SSID) + val ssids = ArrayList() + ssids.add(accessPoint1.SSID) + ssids.add(accessPoint2.SSID) + expectedSSIDs = ssids } } diff --git a/wisefy/src/androidTest/java/com/isupatches/wisefy/internal/mock/MockWiseFyConnectionUtil.kt b/wisefy/src/androidTest/java/com/isupatches/wisefy/internal/mock/MockWiseFyConnectionUtil.kt index 78accbb2..8609cf2c 100644 --- a/wisefy/src/androidTest/java/com/isupatches/wisefy/internal/mock/MockWiseFyConnectionUtil.kt +++ b/wisefy/src/androidTest/java/com/isupatches/wisefy/internal/mock/MockWiseFyConnectionUtil.kt @@ -1,7 +1,6 @@ package com.isupatches.wisefy.internal.mock import com.isupatches.wisefy.connection.WiseFyConnection - import org.mockito.ArgumentMatchers.anyInt import org.mockito.ArgumentMatchers.anyString import org.mockito.Mockito.`when` diff --git a/wisefy/src/androidTest/java/com/isupatches/wisefy/internal/mock/MockWiseFyPrechecksUtil.kt b/wisefy/src/androidTest/java/com/isupatches/wisefy/internal/mock/MockWiseFyPrechecksUtil.kt index 45b2fc28..24a219b9 100644 --- a/wisefy/src/androidTest/java/com/isupatches/wisefy/internal/mock/MockWiseFyPrechecksUtil.kt +++ b/wisefy/src/androidTest/java/com/isupatches/wisefy/internal/mock/MockWiseFyPrechecksUtil.kt @@ -4,7 +4,6 @@ import com.isupatches.wisefy.DEFAULT_PRECHECK_RESULT import com.isupatches.wisefy.PrecheckResult import com.isupatches.wisefy.WiseFyPrechecks import com.isupatches.wisefy.constants.MISSING_PARAMETER - import org.mockito.ArgumentMatchers.anyString import org.mockito.Mockito.`when` @@ -197,6 +196,32 @@ internal class MockWiseFyPrechecksUtil internal constructor(private val mockWise `when`(mockWiseFyPrechecks.getCurrentNetworkInfoChecks()).thenReturn(DEFAULT_PRECHECK_RESULT) } + /** + * Mocks a precheck failure getting the current network's frequency. + * + * @see WiseFyPrechecks.getFrequencyChecks + * @see DEFAULT_PRECHECK_RESULT + * + * @author Patches + * @since 4.1 + */ + fun getFrequency_failure() { + `when`(mockWiseFyPrechecks.getFrequencyChecks()).thenReturn(PRECHECK_RESULT_FAILURE) + } + + /** + * Mocks a precheck success getting the current network's frequency. + * + * @see WiseFyPrechecks.getFrequencyChecks + * @see DEFAULT_PRECHECK_RESULT + * + * @author Patches + * @since 4.1 + */ + fun getFrequency_success() { + `when`(mockWiseFyPrechecks.getFrequencyChecks()).thenReturn(DEFAULT_PRECHECK_RESULT) + } + /** * Mocks a precheck failure getting the ip of the device. * diff --git a/wisefy/src/androidTest/java/com/isupatches/wisefy/internal/mock/MockWiseFySearchUtil.kt b/wisefy/src/androidTest/java/com/isupatches/wisefy/internal/mock/MockWiseFySearchUtil.kt index 169c524d..cddf7e1d 100644 --- a/wisefy/src/androidTest/java/com/isupatches/wisefy/internal/mock/MockWiseFySearchUtil.kt +++ b/wisefy/src/androidTest/java/com/isupatches/wisefy/internal/mock/MockWiseFySearchUtil.kt @@ -2,7 +2,6 @@ package com.isupatches.wisefy.internal.mock import android.net.wifi.ScanResult import android.net.wifi.WifiConfiguration - import com.isupatches.wisefy.TEST_RSSI_LEVEL import com.isupatches.wisefy.TEST_RSSI_LEVEL_HIGH import com.isupatches.wisefy.TEST_RSSI_LEVEL_LOW @@ -12,7 +11,6 @@ import com.isupatches.wisefy.internal.createMockAccessPointList import com.isupatches.wisefy.internal.createMockAccessPointWithSSIDAndRSSI import com.isupatches.wisefy.internal.createSavedNetwork import com.isupatches.wisefy.search.WiseFySearch - import org.mockito.ArgumentMatchers.anyBoolean import org.mockito.ArgumentMatchers.anyInt import org.mockito.ArgumentMatchers.anyString @@ -31,6 +29,8 @@ internal class MockWiseFySearchUtil internal constructor(private val mockWiseFyS /** * Mocks no nearby access points. * + * @param filterDuplicates The filter duplicate param to use when trying + * * @see WiseFySearch.getNearbyAccessPoints * * @author Patches @@ -43,6 +43,8 @@ internal class MockWiseFySearchUtil internal constructor(private val mockWiseFyS /** * Mocks a list of nearby access point. * + * @param filterDuplicates The filter duplicate param to use when trying + * * @return List of ScanResult - The mocked list of nearby access points * * @see WiseFySearch.getNearbyAccessPoints @@ -65,7 +67,11 @@ internal class MockWiseFySearchUtil internal constructor(private val mockWiseFyS * @since 3.0 */ fun findAccessPointByRegex_null() { - `when`(mockWiseFySearch.findAccessPointByRegex(anyString(), anyInt(), anyBoolean())).thenReturn(null) + `when`(mockWiseFySearch.findAccessPointByRegex( + anyString(), + anyInt(), + anyBoolean() + )).thenReturn(null) } /** @@ -80,7 +86,11 @@ internal class MockWiseFySearchUtil internal constructor(private val mockWiseFyS */ fun findAccessPointByRegex_success(): ScanResult { val accessPoint = createMockAccessPointWithSSIDAndRSSI(TEST_SSID, TEST_RSSI_LEVEL) - `when`(mockWiseFySearch.findAccessPointByRegex(anyString(), anyInt(), anyBoolean())).thenReturn(accessPoint) + `when`(mockWiseFySearch.findAccessPointByRegex( + anyString(), + anyInt(), + anyBoolean() + )).thenReturn(accessPoint) return accessPoint } @@ -93,7 +103,10 @@ internal class MockWiseFySearchUtil internal constructor(private val mockWiseFyS * @since 3.0 */ fun findAccessPointsMatchingRegex_null() { - `when`>(mockWiseFySearch.findAccessPointsMatchingRegex(anyString(), anyBoolean())).thenReturn(null) + `when`>(mockWiseFySearch.findAccessPointsMatchingRegex( + anyString(), + anyBoolean() + )).thenReturn(null) } /** @@ -110,7 +123,10 @@ internal class MockWiseFySearchUtil internal constructor(private val mockWiseFyS val accessPoints = ArrayList() val accessPoint = createMockAccessPointWithSSIDAndRSSI(TEST_SSID, TEST_RSSI_LEVEL) accessPoints.add(accessPoint) - `when`>(mockWiseFySearch.findAccessPointsMatchingRegex(anyString(), anyBoolean())).thenReturn(accessPoints) + `when`>(mockWiseFySearch.findAccessPointsMatchingRegex( + anyString(), + anyBoolean()) + ).thenReturn(accessPoints) return accessPoints } @@ -123,7 +139,9 @@ internal class MockWiseFySearchUtil internal constructor(private val mockWiseFyS * @since 3.0 */ fun findSavedNetworkByRegex_null() { - `when`(mockWiseFySearch.findSavedNetworkByRegex(anyString())).thenReturn(null) + `when`(mockWiseFySearch.findSavedNetworkByRegex( + anyString() + )).thenReturn(null) } /** @@ -151,7 +169,9 @@ internal class MockWiseFySearchUtil internal constructor(private val mockWiseFyS * @since 3.0 */ fun findSavedNetworksByRegex_emptyList() { - `when`>(mockWiseFySearch.findSavedNetworksMatchingRegex(anyString())).thenReturn(ArrayList()) + `when`>(mockWiseFySearch.findSavedNetworksMatchingRegex( + anyString() + )).thenReturn(ArrayList()) } /** @@ -163,7 +183,9 @@ internal class MockWiseFySearchUtil internal constructor(private val mockWiseFyS * @since 3.0 */ fun findSavedNetworksByRegex_null() { - `when`>(mockWiseFySearch.findSavedNetworksMatchingRegex(anyString())).thenReturn(null) + `when`>(mockWiseFySearch.findSavedNetworksMatchingRegex( + anyString() + )).thenReturn(null) } /** @@ -181,7 +203,9 @@ internal class MockWiseFySearchUtil internal constructor(private val mockWiseFyS val wiFiConfiguration = createSavedNetwork(TEST_SSID) savedNetworks.add(wiFiConfiguration) - `when`>(mockWiseFySearch.findSavedNetworksMatchingRegex(anyString())).thenReturn(savedNetworks) + `when`>(mockWiseFySearch.findSavedNetworksMatchingRegex( + anyString() + )).thenReturn(savedNetworks) return savedNetworks } diff --git a/wisefy/src/androidTest/java/com/isupatches/wisefy/search/AbstractWiseFySearchTests.kt b/wisefy/src/androidTest/java/com/isupatches/wisefy/search/AbstractWiseFySearchTests.kt index 3797c4b2..ab4d9626 100644 --- a/wisefy/src/androidTest/java/com/isupatches/wisefy/search/AbstractWiseFySearchTests.kt +++ b/wisefy/src/androidTest/java/com/isupatches/wisefy/search/AbstractWiseFySearchTests.kt @@ -2,9 +2,7 @@ package com.isupatches.wisefy.search import com.isupatches.wisefy.TEST_REGEX import com.isupatches.wisefy.TEST_SSID - import com.isupatches.wisefy.internal.base.BaseInstrumentationTest - import org.junit.Assert.assertEquals import org.junit.Test @@ -25,52 +23,62 @@ internal class AbstractWiseFySearchTests : BaseInstrumentationTest() { * findSavedNetworkByRegex tests */ - @Test fun findSavedNetworkByRegex_failure_nullSavedNetworkList() { + @Test + fun findSavedNetworkByRegex_failure_nullSavedNetworkList() { mockNetworkUtil.savedNetworks_nullList() assertEquals(null, wisefySearch.findSavedNetworkByRegex(TEST_SSID)) } - @Test fun findSavedNetworkByRegex_failure_emptySavedNetworkList() { + @Test + fun findSavedNetworkByRegex_failure_emptySavedNetworkList() { mockNetworkUtil.savedNetworks_emptyList() assertEquals(null, wisefySearch.findSavedNetworkByRegex(TEST_SSID)) } - @Test fun findSavedNetworkByRegex_failure_nullSavedNetworkInList() { + @Test + fun findSavedNetworkByRegex_failure_nullSavedNetworkInList() { mockNetworkUtil.savedNetworks_listWithNull() assertEquals(null, wisefySearch.findSavedNetworksMatchingRegex(TEST_SSID)) } - @Test fun findSavedNetworkByRegex_failure_nullSSID() { + @Test + fun findSavedNetworkByRegex_failure_nullSSID() { mockNetworkUtil.savedNetworks_nullSSID() assertEquals(null, wisefySearch.findSavedNetworkByRegex(TEST_SSID)) } - @Test fun findSavedNetworkByRegex_failure_nonMatchingSSID() { + @Test + fun findSavedNetworkByRegex_failure_nonMatchingSSID() { mockNetworkUtil.savedNetworks_nonMatchingSSID() assertEquals(null, wisefySearch.findSavedNetworkByRegex(TEST_SSID)) } - @Test fun findSavedNetworkByRegex_failure_multipleNonMatchingSSIDs() { + @Test + fun findSavedNetworkByRegex_failure_multipleNonMatchingSSIDs() { mockNetworkUtil.savedNetworks_multipleNonMatchingSSIDs() assertEquals(null, wisefySearch.findSavedNetworkByRegex(TEST_SSID)) } - @Test fun findSavedNetworkByRegex_success() { + @Test + fun findSavedNetworkByRegex_success() { mockNetworkUtil.savedNetworks_matchingSSID() assertEquals(mockNetworkUtil.getExpectedSavedNetwork(), wisefySearch.findSavedNetworkByRegex(TEST_SSID)) } - @Test fun findSavedNetworkByRegex_success_multipleMatchingSSIDs() { + @Test + fun findSavedNetworkByRegex_success_multipleMatchingSSIDs() { mockNetworkUtil.savedNetworks_multipleMatchingSSIDs() assertEquals(mockNetworkUtil.getExpectedSavedNetwork(), wisefySearch.findSavedNetworkByRegex(TEST_SSID)) } - @Test fun findSavedNetworkByRegex_success_multipleSSIDs_nonRegex() { + @Test + fun findSavedNetworkByRegex_success_multipleSSIDs_nonRegex() { mockNetworkUtil.savedNetworks_multipleSSIDs(false) assertEquals(mockNetworkUtil.getExpectedSavedNetwork(), wisefySearch.findSavedNetworkByRegex(TEST_SSID)) } - @Test fun findSavedNetworkByRegex_success_multipleSSIDs_regex() { + @Test + fun findSavedNetworkByRegex_success_multipleSSIDs_regex() { mockNetworkUtil.savedNetworks_multipleSSIDs(true) assertEquals(mockNetworkUtil.getExpectedSavedNetwork(), wisefySearch.findSavedNetworkByRegex(TEST_REGEX)) } @@ -79,112 +87,136 @@ internal class AbstractWiseFySearchTests : BaseInstrumentationTest() { * findSavedNetworksMatchingRegex tests */ - @Test fun findSavedNetworksMatchingRegex_failure_nullSavedNetworkList() { + @Test + fun findSavedNetworksMatchingRegex_failure_nullSavedNetworkList() { mockNetworkUtil.savedNetworks_nullList() assertEquals(null, wisefySearch.findSavedNetworksMatchingRegex(TEST_SSID)) } - @Test fun findSavedNetworksMatchingRegex_failure_emptySavedNetworkList() { + @Test + fun findSavedNetworksMatchingRegex_failure_emptySavedNetworkList() { mockNetworkUtil.savedNetworks_emptyList() assertEquals(null, wisefySearch.findSavedNetworksMatchingRegex(TEST_SSID)) } - @Test fun findSavedNetworksMatchingRegex_failure_nullSavedNetworkInList() { + @Test + fun findSavedNetworksMatchingRegex_failure_nullSavedNetworkInList() { mockNetworkUtil.savedNetworks_listWithNull() assertEquals(null, wisefySearch.findSavedNetworksMatchingRegex(TEST_SSID)) } - @Test fun findSavedNetworksMatchingRegex_failure_nullSSID() { + @Test + fun findSavedNetworksMatchingRegex_failure_nullSSID() { mockNetworkUtil.savedNetworks_nullSSID() assertEquals(null, wisefySearch.findSavedNetworksMatchingRegex(TEST_SSID)) } - @Test fun findSavedNetworksMatchingRegex_failure_nonMatchingSSID() { + @Test + fun findSavedNetworksMatchingRegex_failure_nonMatchingSSID() { mockNetworkUtil.savedNetworks_nonMatchingSSID() assertEquals(null, wisefySearch.findSavedNetworksMatchingRegex(TEST_SSID)) } - @Test fun findSavedNetworksMatchingRegex_failure_multipleNonMatchingSSIDs() { + @Test + fun findSavedNetworksMatchingRegex_failure_multipleNonMatchingSSIDs() { mockNetworkUtil.savedNetworks_multipleNonMatchingSSIDs() assertEquals(null, wisefySearch.findSavedNetworksMatchingRegex(TEST_SSID)) } - @Test fun findSavedNetworksMatchingRegex_success() { + @Test + fun findSavedNetworksMatchingRegex_success() { mockNetworkUtil.savedNetworks_matchingSSID() assertEquals(mockNetworkUtil.getExpectedSavedNetworks(), wisefySearch.findSavedNetworksMatchingRegex(TEST_SSID)) } - @Test fun findSavedNetworksMatchingRegex_success_multipleMatchingSSIDs() { + @Test + fun findSavedNetworksMatchingRegex_success_multipleMatchingSSIDs() { mockNetworkUtil.savedNetworks_multipleMatchingSSIDs() assertEquals(mockNetworkUtil.getExpectedSavedNetworks(), wisefySearch.findSavedNetworksMatchingRegex(TEST_SSID)) } - @Test fun findSavedNetworksMatchingRegex_success_multipleSSIDs_nonRegex() { + @Test + fun findSavedNetworksMatchingRegex_success_multipleSSIDs_nonRegex() { mockNetworkUtil.savedNetworks_multipleSSIDs(false) assertEquals(mockNetworkUtil.getExpectedSavedNetworks(), wisefySearch.findSavedNetworksMatchingRegex(TEST_SSID)) } - @Test fun findSavedNetworksMatchingRegex_success_multipleSSIDs_regex() { + @Test + fun findSavedNetworksMatchingRegex_success_multipleSSIDs_regex() { mockNetworkUtil.savedNetworks_multipleSSIDs(true) - assertEquals(mockNetworkUtil.getExpectedSavedNetworks(), wisefySearch.findSavedNetworksMatchingRegex(TEST_REGEX)) + assertEquals( + mockNetworkUtil.getExpectedSavedNetworks(), + wisefySearch.findSavedNetworksMatchingRegex(TEST_REGEX) + ) } /* * isNetworkASavedConfiguration tests */ - @Test fun isNetworkASavedConfiguration_failure_nullSSIDParam() { + @Test + fun isNetworkASavedConfiguration_failure_nullSSIDParam() { mockNetworkUtil.savedNetworks_nullList() assertEquals(false, wisefySearch.isNetworkASavedConfiguration(null)) } - @Test fun isNetworkASavedConfiguration_failure_emptySSIDParam() { + @Test + fun isNetworkASavedConfiguration_failure_emptySSIDParam() { mockNetworkUtil.savedNetworks_nullList() assertEquals(false, wisefySearch.isNetworkASavedConfiguration("")) } - @Test fun isNetworkASavedConfiguration_failure_nullSavedNetworkList() { + @Test + fun isNetworkASavedConfiguration_failure_nullSavedNetworkList() { mockNetworkUtil.savedNetworks_nullList() assertEquals(false, wisefySearch.isNetworkASavedConfiguration(TEST_SSID)) } - @Test fun isNetworkASavedConfiguration_failure_emptySavedNetworkList() { + @Test + fun isNetworkASavedConfiguration_failure_emptySavedNetworkList() { mockNetworkUtil.savedNetworks_emptyList() assertEquals(false, wisefySearch.isNetworkASavedConfiguration(TEST_SSID)) } - @Test fun isNetworkASavedConfiguration_failure_nullSSID() { + @Test + fun isNetworkASavedConfiguration_failure_nullSSID() { mockNetworkUtil.savedNetworks_nullSSID() assertEquals(false, wisefySearch.isNetworkASavedConfiguration(TEST_SSID)) } - @Test fun isNetworkASavedConfiguration_failure_nonMatchingSSID() { + @Test + fun isNetworkASavedConfiguration_failure_nonMatchingSSID() { mockNetworkUtil.savedNetworks_nonMatchingSSID() assertEquals(false, wisefySearch.isNetworkASavedConfiguration(TEST_SSID)) } - @Test fun isNetworkASavedConfiguration_failure_multipleNonMatchingSSIDs() { + @Test + fun isNetworkASavedConfiguration_failure_multipleNonMatchingSSIDs() { mockNetworkUtil.savedNetworks_multipleNonMatchingSSIDs() assertEquals(false, wisefySearch.isNetworkASavedConfiguration(TEST_SSID)) } - @Test fun isNetworkASavedConfiguration_success() { + @Test + fun isNetworkASavedConfiguration_success() { mockNetworkUtil.savedNetworks_matchingSSID() assertEquals(true, wisefySearch.isNetworkASavedConfiguration(TEST_SSID)) } - @Test fun isNetworkASavedConfiguration_success_multipleMatchingSSIDs() { + @Test + fun isNetworkASavedConfiguration_success_multipleMatchingSSIDs() { mockNetworkUtil.savedNetworks_multipleMatchingSSIDs() assertEquals(true, wisefySearch.isNetworkASavedConfiguration(TEST_SSID)) } - @Test fun isNetworkASavedConfiguration_success_multipleSSIDs_nonRegex() { + @Test + fun isNetworkASavedConfiguration_success_multipleSSIDs_nonRegex() { mockNetworkUtil.savedNetworks_multipleSSIDs(false) assertEquals(true, wisefySearch.isNetworkASavedConfiguration(TEST_SSID)) } - @Test fun isNetworkASavedConfiguration_success_multipleSSIDs_regex() { + @Test + fun isNetworkASavedConfiguration_success_multipleSSIDs_regex() { mockNetworkUtil.savedNetworks_multipleSSIDs(true) assertEquals(true, wisefySearch.isNetworkASavedConfiguration(TEST_REGEX)) } -} \ No newline at end of file +} diff --git a/wisefy/src/androidTest/java/com/isupatches/wisefy/search/WiseFySearchLegacyTests.kt b/wisefy/src/androidTest/java/com/isupatches/wisefy/search/WiseFySearchLegacyTests.kt index 77c5e989..40fa19a2 100644 --- a/wisefy/src/androidTest/java/com/isupatches/wisefy/search/WiseFySearchLegacyTests.kt +++ b/wisefy/src/androidTest/java/com/isupatches/wisefy/search/WiseFySearchLegacyTests.kt @@ -3,9 +3,7 @@ package com.isupatches.wisefy.search import com.isupatches.wisefy.TEST_REGEX import com.isupatches.wisefy.TEST_SSID import com.isupatches.wisefy.TEST_TIMEOUT - import com.isupatches.wisefy.internal.base.BaseInstrumentationTest - import org.junit.Assert.assertEquals import org.junit.Assert.assertNull import org.junit.Test @@ -27,149 +25,221 @@ internal class WiseFySearchLegacyTests : BaseInstrumentationTest() { * findAccessPointByRegex tests */ - @Test fun findAccessPointByRegex_failure_nullAccessPoints_takeHighest_false() { + @Test + fun findAccessPointByRegex_failure_nullAccessPoints_takeHighest_false() { mockNetworkUtil.nearbyAccessPoints_nullList() assertEquals(null, wisefySearch.findAccessPointByRegex(TEST_SSID, TEST_TIMEOUT, false)) verificationUtil.triedToScanForAccessPoints() } - @Test fun findAccessPointByRegex_failure_nullAccessPoints_takeHighest_true() { + @Test + fun findAccessPointByRegex_failure_nullAccessPoints_takeHighest_true() { mockNetworkUtil.nearbyAccessPoints_nullList() assertEquals(null, wisefySearch.findAccessPointByRegex(TEST_SSID, TEST_TIMEOUT, true)) verificationUtil.triedToScanForAccessPoints() } - @Test fun findAccessPointByRegex_failure_emptyAccessPointList_takeHighest_false() { + @Test + fun findAccessPointByRegex_failure_emptyAccessPointList_takeHighest_false() { mockNetworkUtil.nearbyAccessPoints_emptyList() assertEquals(null, wisefySearch.findAccessPointByRegex(TEST_SSID, TEST_TIMEOUT, false)) verificationUtil.triedToScanForAccessPoints() } - @Test fun findAccessPointByRegex_failure_emptyAccessPointList_takeHighest_true() { + @Test + fun findAccessPointByRegex_failure_emptyAccessPointList_takeHighest_true() { mockNetworkUtil.nearbyAccessPoints_emptyList() assertEquals(null, wisefySearch.findAccessPointByRegex(TEST_SSID, TEST_TIMEOUT, true)) verificationUtil.triedToScanForAccessPoints() } - @Test fun findAccessPointByRegex_failure_nullAccessPoint_takeHighest_false() { + @Test + fun findAccessPointByRegex_failure_nullAccessPoint_takeHighest_false() { mockNetworkUtil.nearbyAccessPoints_nullAccessPoint() assertEquals(null, wisefySearch.findAccessPointByRegex(TEST_SSID, TEST_TIMEOUT, false)) verificationUtil.triedToScanForAccessPoints() } - @Test fun findAccessPointByRegex_failure_nullAccessPoint_takeHighest_true() { + @Test + fun findAccessPointByRegex_failure_nullAccessPoint_takeHighest_true() { mockNetworkUtil.nearbyAccessPoints_nullAccessPoint() assertEquals(null, wisefySearch.findAccessPointByRegex(TEST_SSID, TEST_TIMEOUT, true)) verificationUtil.triedToScanForAccessPoints() } - @Test fun findAccessPointByRegex_failure_nullSSID_takeHighest_false() { + @Test + fun findAccessPointByRegex_failure_nullSSID_takeHighest_false() { mockNetworkUtil.nearbyAccessPoints_nullSSID() assertEquals(null, wisefySearch.findAccessPointByRegex(TEST_SSID, TEST_TIMEOUT, false)) verificationUtil.triedToScanForAccessPoints() } - @Test fun findAccessPointByRegex_failure_nullSSID_takeHighest_true() { + @Test + fun findAccessPointByRegex_failure_nullSSID_takeHighest_true() { mockNetworkUtil.nearbyAccessPoints_nullSSID() assertEquals(null, wisefySearch.findAccessPointByRegex(TEST_SSID, TEST_TIMEOUT, true)) verificationUtil.triedToScanForAccessPoints() } - @Test fun findAccessPointByRegex_failure_nonMatchingSSID_takeHighest_false() { + @Test + fun findAccessPointByRegex_failure_nonMatchingSSID_takeHighest_false() { mockNetworkUtil.nearbyAccessPoints_nonMatchingSSID() assertEquals(null, wisefySearch.findAccessPointByRegex(TEST_SSID, TEST_TIMEOUT, false)) verificationUtil.triedToScanForAccessPoints() } - @Test fun findAccessPointByRegex_failure_nonMatchingSSID_takeHighest_true() { + @Test + fun findAccessPointByRegex_failure_nonMatchingSSID_takeHighest_true() { mockNetworkUtil.nearbyAccessPoints_nonMatchingSSID() assertEquals(null, wisefySearch.findAccessPointByRegex(TEST_SSID, TEST_TIMEOUT, true)) verificationUtil.triedToScanForAccessPoints() } - @Test fun findAccessPointByRegex_failure_multipleNonMatchingSSIDs_takeHighest_false() { + @Test + fun findAccessPointByRegex_failure_multipleNonMatchingSSIDs_takeHighest_false() { mockNetworkUtil.nearbyAccessPoints_multipleNonMatchingSSIDs() assertEquals(null, wisefySearch.findAccessPointByRegex(TEST_SSID, TEST_TIMEOUT, false)) verificationUtil.triedToScanForAccessPoints() } - @Test fun findAccessPointByRegex_failure_multipleNonMatchingSSIDs_takeHighest_true() { + @Test + fun findAccessPointByRegex_failure_multipleNonMatchingSSIDs_takeHighest_true() { mockNetworkUtil.nearbyAccessPoints_multipleNonMatchingSSIDs() assertEquals(null, wisefySearch.findAccessPointByRegex(TEST_SSID, TEST_TIMEOUT, true)) verificationUtil.triedToScanForAccessPoints() } - @Test fun findAccessPointByRegex_success_takeHighest_false() { + @Test + fun findAccessPointByRegex_success_takeHighest_false() { mockNetworkUtil.nearbyAccessPoints_matchingSSID() - assertEquals(mockNetworkUtil.getExpectedNearbyAccessPoint(), wisefySearch.findAccessPointByRegex(TEST_SSID, TEST_TIMEOUT, false)) + assertEquals(mockNetworkUtil.getExpectedNearbyAccessPoint(), wisefySearch.findAccessPointByRegex( + TEST_SSID, + TEST_TIMEOUT, + false + )) verificationUtil.triedToScanForAccessPoints() } - @Test fun findAccessPointByRegex_success_takeHighest_true() { + @Test + fun findAccessPointByRegex_success_takeHighest_true() { mockNetworkUtil.nearbyAccessPoints_matchingSSID() - assertEquals(mockNetworkUtil.getExpectedNearbyAccessPoint(), wisefySearch.findAccessPointByRegex(TEST_SSID, TEST_TIMEOUT, true)) + assertEquals(mockNetworkUtil.getExpectedNearbyAccessPoint(), wisefySearch.findAccessPointByRegex( + TEST_SSID, + TEST_TIMEOUT, + true + )) verificationUtil.triedToScanForAccessPoints() } - @Test fun findAccessPointByRegex_success_multipleSSIDs_sameRSSI_nonRegex_takeHighest_false() { + @Test + fun findAccessPointByRegex_success_multipleSSIDs_sameRSSI_nonRegex_takeHighest_false() { mockNetworkUtil.nearbyAccessPoints_multipleSSIDs_sameRSSI(false) - assertEquals(mockNetworkUtil.getExpectedNearbyAccessPoint(), wisefySearch.findAccessPointByRegex(TEST_SSID, TEST_TIMEOUT, false)) + assertEquals(mockNetworkUtil.getExpectedNearbyAccessPoint(), wisefySearch.findAccessPointByRegex( + TEST_SSID, + TEST_TIMEOUT, + false + )) verificationUtil.triedToScanForAccessPoints() } - @Test fun findAccessPointByRegex_success_multipleSSIDs_sameRSSI_nonRegex_takeHighest_true() { + @Test + fun findAccessPointByRegex_success_multipleSSIDs_sameRSSI_nonRegex_takeHighest_true() { mockNetworkUtil.nearbyAccessPoints_multipleSSIDs_sameRSSI(false) - assertEquals(mockNetworkUtil.getExpectedNearbyAccessPoint(), wisefySearch.findAccessPointByRegex(TEST_SSID, TEST_TIMEOUT, true)) + assertEquals(mockNetworkUtil.getExpectedNearbyAccessPoint(), wisefySearch.findAccessPointByRegex( + TEST_SSID, + TEST_TIMEOUT, + true + )) verificationUtil.triedToScanForAccessPoints() } - @Test fun findAccessPointByRegex_success_multipleSSIDs_sameRSSI_regex_takeHighest_false() { + @Test + fun findAccessPointByRegex_success_multipleSSIDs_sameRSSI_regex_takeHighest_false() { mockNetworkUtil.nearbyAccessPoints_multipleSSIDs_sameRSSI(true) - assertEquals(mockNetworkUtil.getExpectedNearbyAccessPoint(), wisefySearch.findAccessPointByRegex(TEST_REGEX, TEST_TIMEOUT, false)) + assertEquals(mockNetworkUtil.getExpectedNearbyAccessPoint(), wisefySearch.findAccessPointByRegex( + TEST_REGEX, + TEST_TIMEOUT, + false + )) verificationUtil.triedToScanForAccessPoints() } - @Test fun findAccessPointByRegex_success_multipleSSIDs_sameRSSI_regex_takeHighest_true() { + @Test + fun findAccessPointByRegex_success_multipleSSIDs_sameRSSI_regex_takeHighest_true() { mockNetworkUtil.nearbyAccessPoints_multipleSSIDs_sameRSSI(true) - assertEquals(mockNetworkUtil.getExpectedNearbyAccessPoint(), wisefySearch.findAccessPointByRegex(TEST_REGEX, TEST_TIMEOUT, true)) + assertEquals(mockNetworkUtil.getExpectedNearbyAccessPoint(), wisefySearch.findAccessPointByRegex( + TEST_REGEX, + TEST_TIMEOUT, + true + )) verificationUtil.triedToScanForAccessPoints() } - @Test fun findAccessPointByRegex_success_multipleMatchingSSIDs_accessPoint1HasHigherRSSI_takeHighest_false() { + @Test + fun findAccessPointByRegex_success_multipleMatchingSSIDs_accessPoint1HasHigherRSSI_takeHighest_false() { mockNetworkUtil.nearbyAccessPoints_multipleMatchingSSIDs_accessPoint1HasHigherRSSI(false) - assertEquals(mockNetworkUtil.getExpectedNearbyAccessPoint(), wisefySearch.findAccessPointByRegex(TEST_SSID, TEST_TIMEOUT, false)) + assertEquals(mockNetworkUtil.getExpectedNearbyAccessPoint(), wisefySearch.findAccessPointByRegex( + TEST_SSID, + TEST_TIMEOUT, + false + )) verificationUtil.triedToScanForAccessPoints() } - @Test fun findAccessPointByRegex_success_multipleMatchesSSIDs_accessPoint1HasHigherRSSI_takeHighest_true() { + @Test + fun findAccessPointByRegex_success_multipleMatchesSSIDs_accessPoint1HasHigherRSSI_takeHighest_true() { mockNetworkUtil.nearbyAccessPoints_multipleMatchingSSIDs_accessPoint1HasHigherRSSI(true) - assertEquals(mockNetworkUtil.getExpectedNearbyAccessPoint(), wisefySearch.findAccessPointByRegex(TEST_SSID, TEST_TIMEOUT, true)) + assertEquals(mockNetworkUtil.getExpectedNearbyAccessPoint(), wisefySearch.findAccessPointByRegex( + TEST_SSID, + TEST_TIMEOUT, + true + )) verificationUtil.triedToScanForAccessPoints() } - @Test fun findAccessPointByRegex_success_multipleMatchingSSIDs_accessPoint2HasHigherRSSI_takeHighest_false() { + @Test + fun findAccessPointByRegex_success_multipleMatchingSSIDs_accessPoint2HasHigherRSSI_takeHighest_false() { val takeHighest = false mockNetworkUtil.nearbyAccessPoints_multipleMatchingSSIDs_accessPoint2HasHigherRSSI(takeHighest) - assertEquals(mockNetworkUtil.getExpectedNearbyAccessPoint(), wisefySearch.findAccessPointByRegex(TEST_SSID, TEST_TIMEOUT, takeHighest)) + assertEquals(mockNetworkUtil.getExpectedNearbyAccessPoint(), wisefySearch.findAccessPointByRegex( + TEST_SSID, + TEST_TIMEOUT, + takeHighest + )) verificationUtil.triedToScanForAccessPoints() } - @Test fun findAccessPointByRegex_success_multipleMatchesSSIDs_accessPoint2HasHigherRSSI_takeHighest_true() { + @Test + fun findAccessPointByRegex_success_multipleMatchesSSIDs_accessPoint2HasHigherRSSI_takeHighest_true() { val takeHighest = true mockNetworkUtil.nearbyAccessPoints_multipleMatchingSSIDs_accessPoint2HasHigherRSSI(takeHighest) - assertEquals(mockNetworkUtil.getExpectedNearbyAccessPoint(), wisefySearch.findAccessPointByRegex(TEST_SSID, TEST_TIMEOUT, takeHighest)) + assertEquals(mockNetworkUtil.getExpectedNearbyAccessPoint(), wisefySearch.findAccessPointByRegex( + TEST_SSID, + TEST_TIMEOUT, + takeHighest + )) verificationUtil.triedToScanForAccessPoints() } - @Test fun findAccessPointByRegex_success_multipleMatchingSSIDs_sameRSSI_takeHighest_false() { + @Test + fun findAccessPointByRegex_success_multipleMatchingSSIDs_sameRSSI_takeHighest_false() { mockNetworkUtil.nearbyAccessPoints_multipleMatchingSSIDs_sameRSSI(false) - assertEquals(mockNetworkUtil.getExpectedNearbyAccessPoint(), wisefySearch.findAccessPointByRegex(TEST_SSID, TEST_TIMEOUT, false)) + assertEquals(mockNetworkUtil.getExpectedNearbyAccessPoint(), wisefySearch.findAccessPointByRegex( + TEST_SSID, + TEST_TIMEOUT, + false + )) verificationUtil.triedToScanForAccessPoints() } - @Test fun findAccessPointByRegex_success_multipleMatchesSSIDs_sameRSSI_takeHighest_true() { + @Test + fun findAccessPointByRegex_success_multipleMatchesSSIDs_sameRSSI_takeHighest_true() { mockNetworkUtil.nearbyAccessPoints_multipleMatchingSSIDs_sameRSSI(false) - assertEquals(mockNetworkUtil.getExpectedNearbyAccessPoint(), wisefySearch.findAccessPointByRegex(TEST_SSID, TEST_TIMEOUT, true)) + assertEquals(mockNetworkUtil.getExpectedNearbyAccessPoint(), wisefySearch.findAccessPointByRegex( + TEST_SSID, + TEST_TIMEOUT, + true + )) verificationUtil.triedToScanForAccessPoints() } @@ -177,149 +247,209 @@ internal class WiseFySearchLegacyTests : BaseInstrumentationTest() { * findAccessPointsMatchingRegex tests */ - @Test fun findAccessPointsMatchingRegex_failure_nullAccessPoints_takeHighest_false() { + @Test + fun findAccessPointsMatchingRegex_failure_nullAccessPoints_takeHighest_false() { mockNetworkUtil.nearbyAccessPoints_nullList() assertEquals(null, wisefySearch.findAccessPointsMatchingRegex(TEST_SSID, false)) verificationUtil.triedToScanForAccessPoints() } - @Test fun findAccessPointsMatchingRegex_failure_nullAccessPoints_takeHighest_true() { + @Test + fun findAccessPointsMatchingRegex_failure_nullAccessPoints_takeHighest_true() { mockNetworkUtil.nearbyAccessPoints_nullList() assertEquals(null, wisefySearch.findAccessPointsMatchingRegex(TEST_SSID, true)) verificationUtil.triedToScanForAccessPoints() } - @Test fun findAccessPointsMatchingRegex_failure_emptyAccessPointList_takeHighest_false() { + @Test + fun findAccessPointsMatchingRegex_failure_emptyAccessPointList_takeHighest_false() { mockNetworkUtil.nearbyAccessPoints_emptyList() assertEquals(null, wisefySearch.findAccessPointsMatchingRegex(TEST_SSID, false)) verificationUtil.triedToScanForAccessPoints() } - @Test fun findAccessPointsMatchingRegex_failure_emptyAccessPointList_takeHighest_true() { + @Test + fun findAccessPointsMatchingRegex_failure_emptyAccessPointList_takeHighest_true() { mockNetworkUtil.nearbyAccessPoints_emptyList() assertEquals(null, wisefySearch.findAccessPointsMatchingRegex(TEST_SSID, true)) verificationUtil.triedToScanForAccessPoints() } - @Test fun findAccessPointsMatchingRegex_failure_nullAccessPoint_takeHighest_false() { + @Test + fun findAccessPointsMatchingRegex_failure_nullAccessPoint_takeHighest_false() { mockNetworkUtil.nearbyAccessPoints_nullAccessPoint() assertEquals(null, wisefySearch.findAccessPointsMatchingRegex(TEST_SSID, false)) verificationUtil.triedToScanForAccessPoints() } - @Test fun findAccessPointsMatchingRegex_failure_nullAccessPoint_takeHighest_true() { + @Test + fun findAccessPointsMatchingRegex_failure_nullAccessPoint_takeHighest_true() { mockNetworkUtil.nearbyAccessPoints_nullAccessPoint() assertEquals(null, wisefySearch.findAccessPointsMatchingRegex(TEST_SSID, true)) verificationUtil.triedToScanForAccessPoints() } - @Test fun findAccessPointsMatchingRegex_failure_nullSSID_takeHighest_false() { + @Test + fun findAccessPointsMatchingRegex_failure_nullSSID_takeHighest_false() { mockNetworkUtil.nearbyAccessPoints_nullSSID() assertEquals(null, wisefySearch.findAccessPointsMatchingRegex(TEST_SSID, false)) verificationUtil.triedToScanForAccessPoints() } - @Test fun findAccessPointsMatchingRegex_failure_nullSSID_takeHighest_true() { + @Test + fun findAccessPointsMatchingRegex_failure_nullSSID_takeHighest_true() { mockNetworkUtil.nearbyAccessPoints_nullSSID() assertEquals(null, wisefySearch.findAccessPointsMatchingRegex(TEST_SSID, true)) verificationUtil.triedToScanForAccessPoints() } - @Test fun findAccessPointsMatchingRegex_failure_nonMatchingSSID_takeHighest_false() { + @Test + fun findAccessPointsMatchingRegex_failure_nonMatchingSSID_takeHighest_false() { mockNetworkUtil.nearbyAccessPoints_nonMatchingSSID() assertEquals(null, wisefySearch.findAccessPointsMatchingRegex(TEST_SSID, false)) verificationUtil.triedToScanForAccessPoints() } - @Test fun findAccessPointsMatchingRegex_failure_nonMatchingSSID_takeHighest_true() { + @Test + fun findAccessPointsMatchingRegex_failure_nonMatchingSSID_takeHighest_true() { mockNetworkUtil.nearbyAccessPoints_nonMatchingSSID() assertEquals(null, wisefySearch.findAccessPointsMatchingRegex(TEST_SSID, true)) verificationUtil.triedToScanForAccessPoints() } - @Test fun findAccessPointsMatchingRegex_failure_multipleNonMatchingSSIDs_takeHighest_false() { + @Test + fun findAccessPointsMatchingRegex_failure_multipleNonMatchingSSIDs_takeHighest_false() { mockNetworkUtil.nearbyAccessPoints_multipleNonMatchingSSIDs() assertEquals(null, wisefySearch.findAccessPointsMatchingRegex(TEST_SSID, false)) verificationUtil.triedToScanForAccessPoints() } - @Test fun findAccessPointsMatchingRegex_failure_multipleNonMatchingSSIDs_takeHighest_true() { + @Test + fun findAccessPointsMatchingRegex_failure_multipleNonMatchingSSIDs_takeHighest_true() { mockNetworkUtil.nearbyAccessPoints_multipleNonMatchingSSIDs() assertEquals(null, wisefySearch.findAccessPointsMatchingRegex(TEST_SSID, true)) verificationUtil.triedToScanForAccessPoints() } - @Test fun findAccessPointsMatchingRegex_success_takeHighest_false() { + @Test + fun findAccessPointsMatchingRegex_success_takeHighest_false() { mockNetworkUtil.nearbyAccessPoints_matchingSSID() - assertEquals(mockNetworkUtil.getExpectedNearbyAccessPoints(), wisefySearch.findAccessPointsMatchingRegex(TEST_SSID, false)) + assertEquals(mockNetworkUtil.getExpectedNearbyAccessPoints(), wisefySearch.findAccessPointsMatchingRegex( + TEST_SSID, + false + )) verificationUtil.triedToScanForAccessPoints() } - @Test fun findAccessPointsMatchingRegex_success_takeHighest_true() { + @Test + fun findAccessPointsMatchingRegex_success_takeHighest_true() { mockNetworkUtil.nearbyAccessPoints_matchingSSID() - assertEquals(mockNetworkUtil.getExpectedNearbyAccessPoints(), wisefySearch.findAccessPointsMatchingRegex(TEST_SSID, true)) + assertEquals(mockNetworkUtil.getExpectedNearbyAccessPoints(), wisefySearch.findAccessPointsMatchingRegex( + TEST_SSID, + true + )) verificationUtil.triedToScanForAccessPoints() } - @Test fun findAccessPointsMatchingRegex_success_multipleSSIDs_nonRegex_takeHighest_false() { + @Test + fun findAccessPointsMatchingRegex_success_multipleSSIDs_nonRegex_takeHighest_false() { mockNetworkUtil.nearbyAccessPoints_multipleSSIDs_sameRSSI(false) - assertEquals(mockNetworkUtil.getExpectedNearbyAccessPoints(), wisefySearch.findAccessPointsMatchingRegex(TEST_SSID, false)) + assertEquals(mockNetworkUtil.getExpectedNearbyAccessPoints(), wisefySearch.findAccessPointsMatchingRegex( + TEST_SSID, + false + )) verificationUtil.triedToScanForAccessPoints() } - @Test fun findAccessPointsMatchingRegex_success_multipleSSIDs_nonRegex_takeHighest_true() { + @Test + fun findAccessPointsMatchingRegex_success_multipleSSIDs_nonRegex_takeHighest_true() { mockNetworkUtil.nearbyAccessPoints_multipleSSIDs_sameRSSI(false) - assertEquals(mockNetworkUtil.getExpectedNearbyAccessPoints(), wisefySearch.findAccessPointsMatchingRegex(TEST_SSID, true)) + assertEquals(mockNetworkUtil.getExpectedNearbyAccessPoints(), wisefySearch.findAccessPointsMatchingRegex( + TEST_SSID, + true + )) verificationUtil.triedToScanForAccessPoints() } - @Test fun findAccessPointsMatchingRegex_success_multipleSSIDs_regex_takeHighest_false() { + @Test + fun findAccessPointsMatchingRegex_success_multipleSSIDs_regex_takeHighest_false() { mockNetworkUtil.nearbyAccessPoints_multipleSSIDs_sameRSSI(true) - assertEquals(mockNetworkUtil.getExpectedNearbyAccessPoints(), wisefySearch.findAccessPointsMatchingRegex(TEST_REGEX, false)) + assertEquals(mockNetworkUtil.getExpectedNearbyAccessPoints(), wisefySearch.findAccessPointsMatchingRegex( + TEST_REGEX, + false + )) verificationUtil.triedToScanForAccessPoints() } - @Test fun findAccessPointsMatchingRegex_success_multipleSSIDs_regex_takeHighest_true() { + @Test + fun findAccessPointsMatchingRegex_success_multipleSSIDs_regex_takeHighest_true() { mockNetworkUtil.nearbyAccessPoints_multipleSSIDs_sameRSSI(true) - assertEquals(mockNetworkUtil.getExpectedNearbyAccessPoints(), wisefySearch.findAccessPointsMatchingRegex(TEST_REGEX, true)) + assertEquals(mockNetworkUtil.getExpectedNearbyAccessPoints(), wisefySearch.findAccessPointsMatchingRegex( + TEST_REGEX, + true + )) verificationUtil.triedToScanForAccessPoints() } - @Test fun findAccessPointsMatchingRegex_success_multipleMatchingSSIDs_accessPoint1HasHigherRSSI_takeHighest_false() { + @Test + fun findAccessPointsMatchingRegex_success_multipleMatchingSSIDs_accessPoint1HasHigherRSSI_takeHighest_false() { val takeHighest = false mockNetworkUtil.nearbyAccessPoints_multipleMatchingSSIDs_accessPoint1HasHigherRSSI(takeHighest) - assertEquals(mockNetworkUtil.getExpectedNearbyAccessPoints(), wisefySearch.findAccessPointsMatchingRegex(TEST_SSID, takeHighest)) + assertEquals(mockNetworkUtil.getExpectedNearbyAccessPoints(), wisefySearch.findAccessPointsMatchingRegex( + TEST_SSID, + takeHighest + )) verificationUtil.triedToScanForAccessPoints() } - @Test fun findAccessPointsMatchingRegex_success_multipleMatchingSSIDs_accessPoint1HasHigherRSSI_takeHighest_true() { + @Test + fun findAccessPointsMatchingRegex_success_multipleMatchingSSIDs_accessPoint1HasHigherRSSI_takeHighest_true() { val takeHighest = true mockNetworkUtil.nearbyAccessPoints_multipleMatchingSSIDs_accessPoint1HasHigherRSSI(takeHighest) - assertEquals(mockNetworkUtil.getExpectedNearbyAccessPoints(), wisefySearch.findAccessPointsMatchingRegex(TEST_SSID, takeHighest)) + assertEquals(mockNetworkUtil.getExpectedNearbyAccessPoints(), wisefySearch.findAccessPointsMatchingRegex( + TEST_SSID, + takeHighest + )) verificationUtil.triedToScanForAccessPoints() } - @Test fun findAccessPointsMatchingRegex_success_multipleMatchingSSIDs_accessPoint2HasHigherRSSI_takeHighest_false() { + @Test + fun findAccessPointsMatchingRegex_success_multipleMatchingSSIDs_accessPoint2HasHigherRSSI_takeHighest_false() { mockNetworkUtil.nearbyAccessPoints_multipleMatchingSSIDs_accessPoint2HasHigherRSSI(false) - assertEquals(mockNetworkUtil.getExpectedNearbyAccessPoints(), wisefySearch.findAccessPointsMatchingRegex(TEST_SSID, false)) + assertEquals(mockNetworkUtil.getExpectedNearbyAccessPoints(), wisefySearch.findAccessPointsMatchingRegex( + TEST_SSID, + false + )) verificationUtil.triedToScanForAccessPoints() } - @Test fun findAccessPointsMatchingRegex_success_multipleMatchingSSIDs_accessPoint2HasHigherRSSI_takeHighest_true() { + @Test + fun findAccessPointsMatchingRegex_success_multipleMatchingSSIDs_accessPoint2HasHigherRSSI_takeHighest_true() { mockNetworkUtil.nearbyAccessPoints_multipleMatchingSSIDs_accessPoint2HasHigherRSSI(true) - assertEquals(mockNetworkUtil.getExpectedNearbyAccessPoints(), wisefySearch.findAccessPointsMatchingRegex(TEST_SSID, true)) + assertEquals(mockNetworkUtil.getExpectedNearbyAccessPoints(), wisefySearch.findAccessPointsMatchingRegex( + TEST_SSID, + true + )) verificationUtil.triedToScanForAccessPoints() } - @Test fun findAccessPointsMatchingRegex_success_multipleMatchingSSIDs_sameRSSI_takeHighest_false() { + @Test + fun findAccessPointsMatchingRegex_success_multipleMatchingSSIDs_sameRSSI_takeHighest_false() { mockNetworkUtil.nearbyAccessPoints_multipleMatchingSSIDs_sameRSSI(true) - assertEquals(mockNetworkUtil.getExpectedNearbyAccessPoints(), wisefySearch.findAccessPointsMatchingRegex(TEST_SSID, false)) + assertEquals(mockNetworkUtil.getExpectedNearbyAccessPoints(), wisefySearch.findAccessPointsMatchingRegex( + TEST_SSID, + false + )) verificationUtil.triedToScanForAccessPoints() } - @Test fun findAccessPointsMatchingRegex_success_multipleMatchingSSIDs_sameRSSI_takeHighest_true() { + @Test + fun findAccessPointsMatchingRegex_success_multipleMatchingSSIDs_sameRSSI_takeHighest_true() { mockNetworkUtil.nearbyAccessPoints_multipleMatchingSSIDs_sameRSSI(true) - assertEquals(mockNetworkUtil.getExpectedNearbyAccessPoints(), wisefySearch.findAccessPointsMatchingRegex(TEST_SSID, true)) + assertEquals(mockNetworkUtil.getExpectedNearbyAccessPoints(), wisefySearch.findAccessPointsMatchingRegex( + TEST_SSID, + true + )) verificationUtil.triedToScanForAccessPoints() } @@ -327,73 +457,85 @@ internal class WiseFySearchLegacyTests : BaseInstrumentationTest() { * findSSIDsMatchingRegex tests */ - @Test fun findSSIDsMatchingRegex_failure_nullAccessPoints() { + @Test + fun findSSIDsMatchingRegex_failure_nullAccessPoints() { mockNetworkUtil.nearbyAccessPoints_nullList() assertEquals(null, wisefySearch.findSSIDsMatchingRegex(TEST_SSID)) verificationUtil.triedToScanForAccessPoints() } - @Test fun findSSIDsMatchingRegex_failure_emptySavedNetworkList() { + @Test + fun findSSIDsMatchingRegex_failure_emptySavedNetworkList() { mockNetworkUtil.nearbyAccessPoints_emptyList() assertEquals(null, wisefySearch.findSSIDsMatchingRegex(TEST_SSID)) verificationUtil.triedToScanForAccessPoints() } - @Test fun findSSIDsMatchingRegex_failure_nullAccessPoint() { + @Test + fun findSSIDsMatchingRegex_failure_nullAccessPoint() { mockNetworkUtil.nearbyAccessPoints_nullAccessPoint() assertEquals(null, wisefySearch.findSSIDsMatchingRegex(TEST_SSID)) verificationUtil.triedToScanForAccessPoints() } - @Test fun findSSIDsMatchingRegex_failure_nullSSID() { + @Test + fun findSSIDsMatchingRegex_failure_nullSSID() { mockNetworkUtil.nearbyAccessPoints_nullSSID() assertEquals(null, wisefySearch.findSSIDsMatchingRegex(TEST_SSID)) verificationUtil.triedToScanForAccessPoints() } - @Test fun findSSIDsMatchingRegex_failure_nonMatchingSSID() { + @Test + fun findSSIDsMatchingRegex_failure_nonMatchingSSID() { mockNetworkUtil.nearbyAccessPoints_nonMatchingSSID() assertEquals(null, wisefySearch.findSSIDsMatchingRegex(TEST_SSID)) verificationUtil.triedToScanForAccessPoints() } - @Test fun findSSIDsMatchingRegex_failure_multipleNonMatchingSSIDs() { + @Test + fun findSSIDsMatchingRegex_failure_multipleNonMatchingSSIDs() { mockNetworkUtil.nearbyAccessPoints_multipleNonMatchingSSIDs() assertEquals(null, wisefySearch.findSSIDsMatchingRegex(TEST_SSID)) verificationUtil.triedToScanForAccessPoints() } - @Test fun findSSIDsMatchingRegex_success() { + @Test + fun findSSIDsMatchingRegex_success() { mockNetworkUtil.nearbyAccessPoints_matchingSSID() assertEquals(mockNetworkUtil.getExpectedSSIDs(), wisefySearch.findSSIDsMatchingRegex(TEST_SSID)) verificationUtil.triedToScanForAccessPoints() } - @Test fun findSSIDsMatchingRegex_success_multipleMatchingSSIDs_sameRSSI() { + @Test + fun findSSIDsMatchingRegex_success_multipleMatchingSSIDs_sameRSSI() { mockNetworkUtil.nearbyAccessPoints_multipleMatchingSSIDs_sameRSSI(true) assertEquals(mockNetworkUtil.getExpectedSSIDs(), wisefySearch.findSSIDsMatchingRegex(TEST_SSID)) verificationUtil.triedToScanForAccessPoints() } - @Test fun findSSIDsMatchingRegex_success_multipleMatchingSSIDs_accessPoint1HasHigherRSSI() { + @Test + fun findSSIDsMatchingRegex_success_multipleMatchingSSIDs_accessPoint1HasHigherRSSI() { mockNetworkUtil.nearbyAccessPoints_multipleMatchingSSIDs_accessPoint1HasHigherRSSI(true) assertEquals(mockNetworkUtil.getExpectedSSIDs(), wisefySearch.findSSIDsMatchingRegex(TEST_SSID)) verificationUtil.triedToScanForAccessPoints() } - @Test fun findSSIDsMatchingRegex_success_multipleMatchingSSIDs_accessPoint2HasHigherRSSI() { + @Test + fun findSSIDsMatchingRegex_success_multipleMatchingSSIDs_accessPoint2HasHigherRSSI() { mockNetworkUtil.nearbyAccessPoints_multipleMatchingSSIDs_accessPoint2HasHigherRSSI(true) assertEquals(mockNetworkUtil.getExpectedSSIDs(), wisefySearch.findSSIDsMatchingRegex(TEST_SSID)) verificationUtil.triedToScanForAccessPoints() } - @Test fun findSSIDsMatchingRegex_success_multipleSSIDs_nonRegex() { + @Test + fun findSSIDsMatchingRegex_success_multipleSSIDs_nonRegex() { mockNetworkUtil.nearbyAccessPoints_multipleSSIDs_sameRSSI(false) assertEquals(mockNetworkUtil.getExpectedSSIDs(), wisefySearch.findSSIDsMatchingRegex(TEST_SSID)) verificationUtil.triedToScanForAccessPoints() } - @Test fun findSSIDsMatchingRegex_success_multipleSSIDs_regex() { + @Test + fun findSSIDsMatchingRegex_success_multipleSSIDs_regex() { mockNetworkUtil.nearbyAccessPoints_multipleSSIDs_sameRSSI(true) assertEquals(mockNetworkUtil.getExpectedSSIDs(), wisefySearch.findSSIDsMatchingRegex(TEST_REGEX)) verificationUtil.triedToScanForAccessPoints() @@ -403,7 +545,8 @@ internal class WiseFySearchLegacyTests : BaseInstrumentationTest() { * getNearbyAccessPoints tests */ - @Test fun getNearbyAccessPoints_nullAccessPointList_filterDuplicates_true() { + @Test + fun getNearbyAccessPoints_nullAccessPointList_filterDuplicates_true() { mockNetworkUtil.nearbyAccessPoints_nullList() val accessPoints = wisefySearch.getNearbyAccessPoints(true) assertNull(accessPoints) @@ -411,7 +554,8 @@ internal class WiseFySearchLegacyTests : BaseInstrumentationTest() { verificationUtil.triedToScanForAccessPoints() } - @Test fun getNearbyAccessPoints_emptyAccessPointList_filterDuplicates_true() { + @Test + fun getNearbyAccessPoints_emptyAccessPointList_filterDuplicates_true() { mockNetworkUtil.nearbyAccessPoints_emptyList() val accessPoints = wisefySearch.getNearbyAccessPoints(true) assertNull(accessPoints) @@ -419,7 +563,8 @@ internal class WiseFySearchLegacyTests : BaseInstrumentationTest() { verificationUtil.triedToScanForAccessPoints() } - @Test fun getNearbyAccessPoints_differentSSIDs_filterDuplicates_true() { + @Test + fun getNearbyAccessPoints_differentSSIDs_filterDuplicates_true() { mockNetworkUtil.nearbyAccessPoints_multipleSSIDs_sameRSSI(true) val accessPoints = wisefySearch.getNearbyAccessPoints(true) assertEquals(mockNetworkUtil.getExpectedNearbyAccessPoints(), accessPoints) @@ -427,7 +572,8 @@ internal class WiseFySearchLegacyTests : BaseInstrumentationTest() { verificationUtil.triedToScanForAccessPoints() } - @Test fun getNearbyAccessPoints_sameSignalLevels_filterDuplicates_true() { + @Test + fun getNearbyAccessPoints_sameSignalLevels_filterDuplicates_true() { mockNetworkUtil.nearbyAccessPoints_multipleMatchingSSIDs_sameRSSI(false) val accessPoints = wisefySearch.getNearbyAccessPoints(true) assertEquals(mockNetworkUtil.getExpectedNearbyAccessPoints(), accessPoints) @@ -435,7 +581,8 @@ internal class WiseFySearchLegacyTests : BaseInstrumentationTest() { verificationUtil.triedToScanForAccessPoints() } - @Test fun getNearbyAccessPoints_accessPoint1Higher_filterDuplicates_true() { + @Test + fun getNearbyAccessPoints_accessPoint1Higher_filterDuplicates_true() { mockNetworkUtil.nearbyAccessPoints_multipleMatchingSSIDs_accessPoint1HasHigherRSSI(true) val accessPoints = wisefySearch.getNearbyAccessPoints(true) assertEquals(mockNetworkUtil.getExpectedNearbyAccessPoints(), accessPoints) @@ -443,7 +590,8 @@ internal class WiseFySearchLegacyTests : BaseInstrumentationTest() { verificationUtil.triedToScanForAccessPoints() } - @Test fun getNearbyAccessPoints_accessPoint2Higher_filterDuplicates_true() { + @Test + fun getNearbyAccessPoints_accessPoint2Higher_filterDuplicates_true() { mockNetworkUtil.nearbyAccessPoints_multipleMatchingSSIDs_accessPoint2HasHigherRSSI(true) val accessPoints = wisefySearch.getNearbyAccessPoints(true) assertEquals(mockNetworkUtil.getExpectedNearbyAccessPoints(), accessPoints) @@ -451,7 +599,8 @@ internal class WiseFySearchLegacyTests : BaseInstrumentationTest() { verificationUtil.triedToScanForAccessPoints() } - @Test fun getNearbyAccessPoints_nullAccessPointList_filterDuplicates_false() { + @Test + fun getNearbyAccessPoints_nullAccessPointList_filterDuplicates_false() { mockNetworkUtil.nearbyAccessPoints_nullList() val accessPoints = wisefySearch.getNearbyAccessPoints(false) assertNull(accessPoints) @@ -459,7 +608,8 @@ internal class WiseFySearchLegacyTests : BaseInstrumentationTest() { verificationUtil.triedToScanForAccessPoints() } - @Test fun getNearbyAccessPoints_emptyAccessPointList_filterDuplicates_false() { + @Test + fun getNearbyAccessPoints_emptyAccessPointList_filterDuplicates_false() { mockNetworkUtil.nearbyAccessPoints_emptyList() val accessPoints = wisefySearch.getNearbyAccessPoints(false) assertNull(accessPoints) @@ -467,7 +617,8 @@ internal class WiseFySearchLegacyTests : BaseInstrumentationTest() { verificationUtil.triedToScanForAccessPoints() } - @Test fun getNearbyAccessPoints_differentSSIDs_filterDuplicates_false() { + @Test + fun getNearbyAccessPoints_differentSSIDs_filterDuplicates_false() { mockNetworkUtil.nearbyAccessPoints_multipleSSIDs_sameRSSI(true) val accessPoints = wisefySearch.getNearbyAccessPoints(false) assertEquals(mockNetworkUtil.getExpectedNearbyAccessPoints(), accessPoints) @@ -475,7 +626,8 @@ internal class WiseFySearchLegacyTests : BaseInstrumentationTest() { verificationUtil.triedToScanForAccessPoints() } - @Test fun getNearbyAccessPoints_sameSignalLevels_filterDuplicates_false() { + @Test + fun getNearbyAccessPoints_sameSignalLevels_filterDuplicates_false() { mockNetworkUtil.nearbyAccessPoints_multipleMatchingSSIDs_sameRSSI(true) val accessPoints = wisefySearch.getNearbyAccessPoints(false) assertEquals(mockNetworkUtil.getExpectedNearbyAccessPoints(), accessPoints) @@ -483,7 +635,8 @@ internal class WiseFySearchLegacyTests : BaseInstrumentationTest() { verificationUtil.triedToScanForAccessPoints() } - @Test fun getNearbyAccessPoints_accessPoint1Higher_filterDuplicates_false() { + @Test + fun getNearbyAccessPoints_accessPoint1Higher_filterDuplicates_false() { mockNetworkUtil.nearbyAccessPoints_multipleMatchingSSIDs_accessPoint1HasHigherRSSI(false) val accessPoints = wisefySearch.getNearbyAccessPoints(false) assertEquals(mockNetworkUtil.getExpectedNearbyAccessPoints(), accessPoints) @@ -491,7 +644,8 @@ internal class WiseFySearchLegacyTests : BaseInstrumentationTest() { verificationUtil.triedToScanForAccessPoints() } - @Test fun getNearbyAccessPoints_accessPoint2Higher_filterDuplicates_false() { + @Test + fun getNearbyAccessPoints_accessPoint2Higher_filterDuplicates_false() { mockNetworkUtil.nearbyAccessPoints_multipleMatchingSSIDs_accessPoint2HasHigherRSSI(false) val accessPoints = wisefySearch.getNearbyAccessPoints(false) assertEquals(mockNetworkUtil.getExpectedNearbyAccessPoints(), accessPoints) diff --git a/wisefy/src/androidTest/java/com/isupatches/wisefy/search/WiseFySearchSdk23Tests.kt b/wisefy/src/androidTest/java/com/isupatches/wisefy/search/WiseFySearchSdk23Tests.kt index 9399b1fc..67dfccaf 100644 --- a/wisefy/src/androidTest/java/com/isupatches/wisefy/search/WiseFySearchSdk23Tests.kt +++ b/wisefy/src/androidTest/java/com/isupatches/wisefy/search/WiseFySearchSdk23Tests.kt @@ -4,9 +4,7 @@ import android.os.Build import com.isupatches.wisefy.TEST_REGEX import com.isupatches.wisefy.TEST_SSID import com.isupatches.wisefy.TEST_TIMEOUT - import com.isupatches.wisefy.internal.base.BaseInstrumentationTest - import org.junit.Assert.assertEquals import org.junit.Assert.assertNull import org.junit.Assume.assumeTrue @@ -28,10 +26,11 @@ internal class WiseFySearchSdk23Tests : BaseInstrumentationTest() { WiseFySearchSDK23.create(mockWifiManager) } - @Before fun setUp() { + @Before + fun setUp() { assumeTrue( - "Can only run on API Level 23 or newer", - Build.VERSION.SDK_INT >= Build.VERSION_CODES.M + "Can only run on API Level 23 or newer", + Build.VERSION.SDK_INT >= Build.VERSION_CODES.M ) } @@ -39,149 +38,221 @@ internal class WiseFySearchSdk23Tests : BaseInstrumentationTest() { * findAccessPointByRegex tests */ - @Test fun findAccessPointByRegex_failure_nullAccessPoints_takeHighest_false() { + @Test + fun findAccessPointByRegex_failure_nullAccessPoints_takeHighest_false() { mockNetworkUtil.nearbyAccessPoints_nullList() assertEquals(null, wisefySearch.findAccessPointByRegex(TEST_SSID, TEST_TIMEOUT, false)) verificationUtil.didNotTryToScanForAccessPoints() } - @Test fun findAccessPointByRegex_failure_nullAccessPoints_takeHighest_true() { + @Test + fun findAccessPointByRegex_failure_nullAccessPoints_takeHighest_true() { mockNetworkUtil.nearbyAccessPoints_nullList() assertEquals(null, wisefySearch.findAccessPointByRegex(TEST_SSID, TEST_TIMEOUT, true)) verificationUtil.didNotTryToScanForAccessPoints() } - @Test fun findAccessPointByRegex_failure_emptyAccessPointList_takeHighest_false() { + @Test + fun findAccessPointByRegex_failure_emptyAccessPointList_takeHighest_false() { mockNetworkUtil.nearbyAccessPoints_emptyList() assertEquals(null, wisefySearch.findAccessPointByRegex(TEST_SSID, TEST_TIMEOUT, false)) verificationUtil.didNotTryToScanForAccessPoints() } - @Test fun findAccessPointByRegex_failure_emptyAccessPointList_takeHighest_true() { + @Test + fun findAccessPointByRegex_failure_emptyAccessPointList_takeHighest_true() { mockNetworkUtil.nearbyAccessPoints_emptyList() assertEquals(null, wisefySearch.findAccessPointByRegex(TEST_SSID, TEST_TIMEOUT, true)) verificationUtil.didNotTryToScanForAccessPoints() } - @Test fun findAccessPointByRegex_failure_nullAccessPoint_takeHighest_false() { + @Test + fun findAccessPointByRegex_failure_nullAccessPoint_takeHighest_false() { mockNetworkUtil.nearbyAccessPoints_nullAccessPoint() assertEquals(null, wisefySearch.findAccessPointByRegex(TEST_SSID, TEST_TIMEOUT, false)) verificationUtil.didNotTryToScanForAccessPoints() } - @Test fun findAccessPointByRegex_failure_nullAccessPoint_takeHighest_true() { + @Test + fun findAccessPointByRegex_failure_nullAccessPoint_takeHighest_true() { mockNetworkUtil.nearbyAccessPoints_nullAccessPoint() assertEquals(null, wisefySearch.findAccessPointByRegex(TEST_SSID, TEST_TIMEOUT, true)) verificationUtil.didNotTryToScanForAccessPoints() } - @Test fun findAccessPointByRegex_failure_nullSSID_takeHighest_false() { + @Test + fun findAccessPointByRegex_failure_nullSSID_takeHighest_false() { mockNetworkUtil.nearbyAccessPoints_nullSSID() assertEquals(null, wisefySearch.findAccessPointByRegex(TEST_SSID, TEST_TIMEOUT, false)) verificationUtil.didNotTryToScanForAccessPoints() } - @Test fun findAccessPointByRegex_failure_nullSSID_takeHighest_true() { + @Test + fun findAccessPointByRegex_failure_nullSSID_takeHighest_true() { mockNetworkUtil.nearbyAccessPoints_nullSSID() assertEquals(null, wisefySearch.findAccessPointByRegex(TEST_SSID, TEST_TIMEOUT, true)) verificationUtil.didNotTryToScanForAccessPoints() } - @Test fun findAccessPointByRegex_failure_nonMatchingSSID_takeHighest_false() { + @Test + fun findAccessPointByRegex_failure_nonMatchingSSID_takeHighest_false() { mockNetworkUtil.nearbyAccessPoints_nonMatchingSSID() assertEquals(null, wisefySearch.findAccessPointByRegex(TEST_SSID, TEST_TIMEOUT, false)) verificationUtil.didNotTryToScanForAccessPoints() } - @Test fun findAccessPointByRegex_failure_nonMatchingSSID_takeHighest_true() { + @Test + fun findAccessPointByRegex_failure_nonMatchingSSID_takeHighest_true() { mockNetworkUtil.nearbyAccessPoints_nonMatchingSSID() assertEquals(null, wisefySearch.findAccessPointByRegex(TEST_SSID, TEST_TIMEOUT, true)) verificationUtil.didNotTryToScanForAccessPoints() } - @Test fun findAccessPointByRegex_failure_multipleNonMatchingSSIDs_takeHighest_false() { + @Test + fun findAccessPointByRegex_failure_multipleNonMatchingSSIDs_takeHighest_false() { mockNetworkUtil.nearbyAccessPoints_multipleNonMatchingSSIDs() assertEquals(null, wisefySearch.findAccessPointByRegex(TEST_SSID, TEST_TIMEOUT, false)) verificationUtil.didNotTryToScanForAccessPoints() } - @Test fun findAccessPointByRegex_failure_multipleNonMatchingSSIDs_takeHighest_true() { + @Test + fun findAccessPointByRegex_failure_multipleNonMatchingSSIDs_takeHighest_true() { mockNetworkUtil.nearbyAccessPoints_multipleNonMatchingSSIDs() assertEquals(null, wisefySearch.findAccessPointByRegex(TEST_SSID, TEST_TIMEOUT, true)) verificationUtil.didNotTryToScanForAccessPoints() } - @Test fun findAccessPointByRegex_success_takeHighest_false() { + @Test + fun findAccessPointByRegex_success_takeHighest_false() { mockNetworkUtil.nearbyAccessPoints_matchingSSID() - assertEquals(mockNetworkUtil.getExpectedNearbyAccessPoint(), wisefySearch.findAccessPointByRegex(TEST_SSID, TEST_TIMEOUT, false)) + assertEquals(mockNetworkUtil.getExpectedNearbyAccessPoint(), wisefySearch.findAccessPointByRegex( + TEST_SSID, + TEST_TIMEOUT, + false + )) verificationUtil.didNotTryToScanForAccessPoints() } - @Test fun findAccessPointByRegex_success_takeHighest_true() { + @Test + fun findAccessPointByRegex_success_takeHighest_true() { mockNetworkUtil.nearbyAccessPoints_matchingSSID() - assertEquals(mockNetworkUtil.getExpectedNearbyAccessPoint(), wisefySearch.findAccessPointByRegex(TEST_SSID, TEST_TIMEOUT, true)) + assertEquals(mockNetworkUtil.getExpectedNearbyAccessPoint(), wisefySearch.findAccessPointByRegex( + TEST_SSID, + TEST_TIMEOUT, + true + )) verificationUtil.didNotTryToScanForAccessPoints() } - @Test fun findAccessPointByRegex_success_multipleSSIDs_sameRSSI_nonRegex_takeHighest_false() { + @Test + fun findAccessPointByRegex_success_multipleSSIDs_sameRSSI_nonRegex_takeHighest_false() { mockNetworkUtil.nearbyAccessPoints_multipleSSIDs_sameRSSI(false) - assertEquals(mockNetworkUtil.getExpectedNearbyAccessPoint(), wisefySearch.findAccessPointByRegex(TEST_SSID, TEST_TIMEOUT, false)) + assertEquals(mockNetworkUtil.getExpectedNearbyAccessPoint(), wisefySearch.findAccessPointByRegex( + TEST_SSID, + TEST_TIMEOUT, + false + )) verificationUtil.didNotTryToScanForAccessPoints() } - @Test fun findAccessPointByRegex_success_multipleSSIDs_sameRSSI_nonRegex_takeHighest_true() { + @Test + fun findAccessPointByRegex_success_multipleSSIDs_sameRSSI_nonRegex_takeHighest_true() { mockNetworkUtil.nearbyAccessPoints_multipleSSIDs_sameRSSI(false) - assertEquals(mockNetworkUtil.getExpectedNearbyAccessPoint(), wisefySearch.findAccessPointByRegex(TEST_SSID, TEST_TIMEOUT, true)) + assertEquals(mockNetworkUtil.getExpectedNearbyAccessPoint(), wisefySearch.findAccessPointByRegex( + TEST_SSID, + TEST_TIMEOUT, + true + )) verificationUtil.didNotTryToScanForAccessPoints() } - @Test fun findAccessPointByRegex_success_multipleSSIDs_sameRSSI_regex_takeHighest_false() { + @Test + fun findAccessPointByRegex_success_multipleSSIDs_sameRSSI_regex_takeHighest_false() { mockNetworkUtil.nearbyAccessPoints_multipleSSIDs_sameRSSI(true) - assertEquals(mockNetworkUtil.getExpectedNearbyAccessPoint(), wisefySearch.findAccessPointByRegex(TEST_REGEX, TEST_TIMEOUT, false)) + assertEquals(mockNetworkUtil.getExpectedNearbyAccessPoint(), wisefySearch.findAccessPointByRegex( + TEST_REGEX, + TEST_TIMEOUT, + false + )) verificationUtil.didNotTryToScanForAccessPoints() } - @Test fun findAccessPointByRegex_success_multipleSSIDs_sameRSSI_regex_takeHighest_true() { + @Test + fun findAccessPointByRegex_success_multipleSSIDs_sameRSSI_regex_takeHighest_true() { mockNetworkUtil.nearbyAccessPoints_multipleSSIDs_sameRSSI(true) - assertEquals(mockNetworkUtil.getExpectedNearbyAccessPoint(), wisefySearch.findAccessPointByRegex(TEST_REGEX, TEST_TIMEOUT, true)) + assertEquals(mockNetworkUtil.getExpectedNearbyAccessPoint(), wisefySearch.findAccessPointByRegex( + TEST_REGEX, + TEST_TIMEOUT, + true + )) verificationUtil.didNotTryToScanForAccessPoints() } - @Test fun findAccessPointByRegex_success_multipleMatchingSSIDs_accessPoint1HasHigherRSSI_takeHighest_false() { + @Test + fun findAccessPointByRegex_success_multipleMatchingSSIDs_accessPoint1HasHigherRSSI_takeHighest_false() { mockNetworkUtil.nearbyAccessPoints_multipleMatchingSSIDs_accessPoint1HasHigherRSSI(false) - assertEquals(mockNetworkUtil.getExpectedNearbyAccessPoint(), wisefySearch.findAccessPointByRegex(TEST_SSID, TEST_TIMEOUT, false)) + assertEquals(mockNetworkUtil.getExpectedNearbyAccessPoint(), wisefySearch.findAccessPointByRegex( + TEST_SSID, + TEST_TIMEOUT, + false + )) verificationUtil.didNotTryToScanForAccessPoints() } - @Test fun findAccessPointByRegex_success_multipleMatchesSSIDs_accessPoint1HasHigherRSSI_takeHighest_true() { + @Test + fun findAccessPointByRegex_success_multipleMatchesSSIDs_accessPoint1HasHigherRSSI_takeHighest_true() { mockNetworkUtil.nearbyAccessPoints_multipleMatchingSSIDs_accessPoint1HasHigherRSSI(true) - assertEquals(mockNetworkUtil.getExpectedNearbyAccessPoint(), wisefySearch.findAccessPointByRegex(TEST_SSID, TEST_TIMEOUT, true)) + assertEquals(mockNetworkUtil.getExpectedNearbyAccessPoint(), wisefySearch.findAccessPointByRegex( + TEST_SSID, + TEST_TIMEOUT, + true + )) verificationUtil.didNotTryToScanForAccessPoints() } - @Test fun findAccessPointByRegex_success_multipleMatchingSSIDs_accessPoint2HasHigherRSSI_takeHighest_false() { + @Test + fun findAccessPointByRegex_success_multipleMatchingSSIDs_accessPoint2HasHigherRSSI_takeHighest_false() { val takeHighest = false mockNetworkUtil.nearbyAccessPoints_multipleMatchingSSIDs_accessPoint2HasHigherRSSI(takeHighest) - assertEquals(mockNetworkUtil.getExpectedNearbyAccessPoint(), wisefySearch.findAccessPointByRegex(TEST_SSID, TEST_TIMEOUT, takeHighest)) + assertEquals(mockNetworkUtil.getExpectedNearbyAccessPoint(), wisefySearch.findAccessPointByRegex( + TEST_SSID, + TEST_TIMEOUT, + takeHighest + )) verificationUtil.didNotTryToScanForAccessPoints() } - @Test fun findAccessPointByRegex_success_multipleMatchesSSIDs_accessPoint2HasHigherRSSI_takeHighest_true() { + @Test + fun findAccessPointByRegex_success_multipleMatchesSSIDs_accessPoint2HasHigherRSSI_takeHighest_true() { val takeHighest = true mockNetworkUtil.nearbyAccessPoints_multipleMatchingSSIDs_accessPoint2HasHigherRSSI(takeHighest) - assertEquals(mockNetworkUtil.getExpectedNearbyAccessPoint(), wisefySearch.findAccessPointByRegex(TEST_SSID, TEST_TIMEOUT, takeHighest)) + assertEquals(mockNetworkUtil.getExpectedNearbyAccessPoint(), wisefySearch.findAccessPointByRegex( + TEST_SSID, + TEST_TIMEOUT, + takeHighest + )) verificationUtil.didNotTryToScanForAccessPoints() } - @Test fun findAccessPointByRegex_success_multipleMatchingSSIDs_sameRSSI_takeHighest_false() { + @Test + fun findAccessPointByRegex_success_multipleMatchingSSIDs_sameRSSI_takeHighest_false() { mockNetworkUtil.nearbyAccessPoints_multipleMatchingSSIDs_sameRSSI(false) - assertEquals(mockNetworkUtil.getExpectedNearbyAccessPoint(), wisefySearch.findAccessPointByRegex(TEST_SSID, TEST_TIMEOUT, false)) + assertEquals(mockNetworkUtil.getExpectedNearbyAccessPoint(), wisefySearch.findAccessPointByRegex( + TEST_SSID, + TEST_TIMEOUT, + false + )) verificationUtil.didNotTryToScanForAccessPoints() } - @Test fun findAccessPointByRegex_success_multipleMatchesSSIDs_sameRSSI_takeHighest_true() { + @Test + fun findAccessPointByRegex_success_multipleMatchesSSIDs_sameRSSI_takeHighest_true() { mockNetworkUtil.nearbyAccessPoints_multipleMatchingSSIDs_sameRSSI(false) - assertEquals(mockNetworkUtil.getExpectedNearbyAccessPoint(), wisefySearch.findAccessPointByRegex(TEST_SSID, TEST_TIMEOUT, true)) + assertEquals(mockNetworkUtil.getExpectedNearbyAccessPoint(), wisefySearch.findAccessPointByRegex( + TEST_SSID, + TEST_TIMEOUT, + true + )) verificationUtil.didNotTryToScanForAccessPoints() } @@ -189,149 +260,209 @@ internal class WiseFySearchSdk23Tests : BaseInstrumentationTest() { * findAccessPointsMatchingRegex tests */ - @Test fun findAccessPointsMatchingRegex_failure_nullAccessPoints_takeHighest_false() { + @Test + fun findAccessPointsMatchingRegex_failure_nullAccessPoints_takeHighest_false() { mockNetworkUtil.nearbyAccessPoints_nullList() assertEquals(null, wisefySearch.findAccessPointsMatchingRegex(TEST_SSID, false)) verificationUtil.didNotTryToScanForAccessPoints() } - @Test fun findAccessPointsMatchingRegex_failure_nullAccessPoints_takeHighest_true() { + @Test + fun findAccessPointsMatchingRegex_failure_nullAccessPoints_takeHighest_true() { mockNetworkUtil.nearbyAccessPoints_nullList() assertEquals(null, wisefySearch.findAccessPointsMatchingRegex(TEST_SSID, true)) verificationUtil.didNotTryToScanForAccessPoints() } - @Test fun findAccessPointsMatchingRegex_failure_emptyAccessPointList_takeHighest_false() { + @Test + fun findAccessPointsMatchingRegex_failure_emptyAccessPointList_takeHighest_false() { mockNetworkUtil.nearbyAccessPoints_emptyList() assertEquals(null, wisefySearch.findAccessPointsMatchingRegex(TEST_SSID, false)) verificationUtil.didNotTryToScanForAccessPoints() } - @Test fun findAccessPointsMatchingRegex_failure_emptyAccessPointList_takeHighest_true() { + @Test + fun findAccessPointsMatchingRegex_failure_emptyAccessPointList_takeHighest_true() { mockNetworkUtil.nearbyAccessPoints_emptyList() assertEquals(null, wisefySearch.findAccessPointsMatchingRegex(TEST_SSID, true)) verificationUtil.didNotTryToScanForAccessPoints() } - @Test fun findAccessPointsMatchingRegex_failure_nullAccessPoint_takeHighest_false() { + @Test + fun findAccessPointsMatchingRegex_failure_nullAccessPoint_takeHighest_false() { mockNetworkUtil.nearbyAccessPoints_nullAccessPoint() assertEquals(null, wisefySearch.findAccessPointsMatchingRegex(TEST_SSID, false)) verificationUtil.didNotTryToScanForAccessPoints() } - @Test fun findAccessPointsMatchingRegex_failure_nullAccessPoint_takeHighest_true() { + @Test + fun findAccessPointsMatchingRegex_failure_nullAccessPoint_takeHighest_true() { mockNetworkUtil.nearbyAccessPoints_nullAccessPoint() assertEquals(null, wisefySearch.findAccessPointsMatchingRegex(TEST_SSID, true)) verificationUtil.didNotTryToScanForAccessPoints() } - @Test fun findAccessPointsMatchingRegex_failure_nullSSID_takeHighest_false() { + @Test + fun findAccessPointsMatchingRegex_failure_nullSSID_takeHighest_false() { mockNetworkUtil.nearbyAccessPoints_nullSSID() assertEquals(null, wisefySearch.findAccessPointsMatchingRegex(TEST_SSID, false)) verificationUtil.didNotTryToScanForAccessPoints() } - @Test fun findAccessPointsMatchingRegex_failure_nullSSID_takeHighest_true() { + @Test + fun findAccessPointsMatchingRegex_failure_nullSSID_takeHighest_true() { mockNetworkUtil.nearbyAccessPoints_nullSSID() assertEquals(null, wisefySearch.findAccessPointsMatchingRegex(TEST_SSID, true)) verificationUtil.didNotTryToScanForAccessPoints() } - @Test fun findAccessPointsMatchingRegex_failure_nonMatchingSSID_takeHighest_false() { + @Test + fun findAccessPointsMatchingRegex_failure_nonMatchingSSID_takeHighest_false() { mockNetworkUtil.nearbyAccessPoints_nonMatchingSSID() assertEquals(null, wisefySearch.findAccessPointsMatchingRegex(TEST_SSID, false)) verificationUtil.didNotTryToScanForAccessPoints() } - @Test fun findAccessPointsMatchingRegex_failure_nonMatchingSSID_takeHighest_true() { + @Test + fun findAccessPointsMatchingRegex_failure_nonMatchingSSID_takeHighest_true() { mockNetworkUtil.nearbyAccessPoints_nonMatchingSSID() assertEquals(null, wisefySearch.findAccessPointsMatchingRegex(TEST_SSID, true)) verificationUtil.didNotTryToScanForAccessPoints() } - @Test fun findAccessPointsMatchingRegex_failure_multipleNonMatchingSSIDs_takeHighest_false() { + @Test + fun findAccessPointsMatchingRegex_failure_multipleNonMatchingSSIDs_takeHighest_false() { mockNetworkUtil.nearbyAccessPoints_multipleNonMatchingSSIDs() assertEquals(null, wisefySearch.findAccessPointsMatchingRegex(TEST_SSID, false)) verificationUtil.didNotTryToScanForAccessPoints() } - @Test fun findAccessPointsMatchingRegex_failure_multipleNonMatchingSSIDs_takeHighest_true() { + @Test + fun findAccessPointsMatchingRegex_failure_multipleNonMatchingSSIDs_takeHighest_true() { mockNetworkUtil.nearbyAccessPoints_multipleNonMatchingSSIDs() assertEquals(null, wisefySearch.findAccessPointsMatchingRegex(TEST_SSID, true)) verificationUtil.didNotTryToScanForAccessPoints() } - @Test fun findAccessPointsMatchingRegex_success_takeHighest_false() { + @Test + fun findAccessPointsMatchingRegex_success_takeHighest_false() { mockNetworkUtil.nearbyAccessPoints_matchingSSID() - assertEquals(mockNetworkUtil.getExpectedNearbyAccessPoints(), wisefySearch.findAccessPointsMatchingRegex(TEST_SSID, false)) + assertEquals(mockNetworkUtil.getExpectedNearbyAccessPoints(), wisefySearch.findAccessPointsMatchingRegex( + TEST_SSID, + false + )) verificationUtil.didNotTryToScanForAccessPoints() } - @Test fun findAccessPointsMatchingRegex_success_takeHighest_true() { + @Test + fun findAccessPointsMatchingRegex_success_takeHighest_true() { mockNetworkUtil.nearbyAccessPoints_matchingSSID() - assertEquals(mockNetworkUtil.getExpectedNearbyAccessPoints(), wisefySearch.findAccessPointsMatchingRegex(TEST_SSID, true)) + assertEquals(mockNetworkUtil.getExpectedNearbyAccessPoints(), wisefySearch.findAccessPointsMatchingRegex( + TEST_SSID, + true + )) verificationUtil.didNotTryToScanForAccessPoints() } - @Test fun findAccessPointsMatchingRegex_success_multipleSSIDs_nonRegex_takeHighest_false() { + @Test + fun findAccessPointsMatchingRegex_success_multipleSSIDs_nonRegex_takeHighest_false() { mockNetworkUtil.nearbyAccessPoints_multipleSSIDs_sameRSSI(false) - assertEquals(mockNetworkUtil.getExpectedNearbyAccessPoints(), wisefySearch.findAccessPointsMatchingRegex(TEST_SSID, false)) + assertEquals(mockNetworkUtil.getExpectedNearbyAccessPoints(), wisefySearch.findAccessPointsMatchingRegex( + TEST_SSID, + false + )) verificationUtil.didNotTryToScanForAccessPoints() } - @Test fun findAccessPointsMatchingRegex_success_multipleSSIDs_nonRegex_takeHighest_true() { + @Test + fun findAccessPointsMatchingRegex_success_multipleSSIDs_nonRegex_takeHighest_true() { mockNetworkUtil.nearbyAccessPoints_multipleSSIDs_sameRSSI(false) - assertEquals(mockNetworkUtil.getExpectedNearbyAccessPoints(), wisefySearch.findAccessPointsMatchingRegex(TEST_SSID, true)) + assertEquals(mockNetworkUtil.getExpectedNearbyAccessPoints(), wisefySearch.findAccessPointsMatchingRegex( + TEST_SSID, + true + )) verificationUtil.didNotTryToScanForAccessPoints() } - @Test fun findAccessPointsMatchingRegex_success_multipleSSIDs_regex_takeHighest_false() { + @Test + fun findAccessPointsMatchingRegex_success_multipleSSIDs_regex_takeHighest_false() { mockNetworkUtil.nearbyAccessPoints_multipleSSIDs_sameRSSI(true) - assertEquals(mockNetworkUtil.getExpectedNearbyAccessPoints(), wisefySearch.findAccessPointsMatchingRegex(TEST_REGEX, false)) + assertEquals(mockNetworkUtil.getExpectedNearbyAccessPoints(), wisefySearch.findAccessPointsMatchingRegex( + TEST_REGEX, + false + )) verificationUtil.didNotTryToScanForAccessPoints() } - @Test fun findAccessPointsMatchingRegex_success_multipleSSIDs_regex_takeHighest_true() { + @Test + fun findAccessPointsMatchingRegex_success_multipleSSIDs_regex_takeHighest_true() { mockNetworkUtil.nearbyAccessPoints_multipleSSIDs_sameRSSI(true) - assertEquals(mockNetworkUtil.getExpectedNearbyAccessPoints(), wisefySearch.findAccessPointsMatchingRegex(TEST_REGEX, true)) + assertEquals(mockNetworkUtil.getExpectedNearbyAccessPoints(), wisefySearch.findAccessPointsMatchingRegex( + TEST_REGEX, + true + )) verificationUtil.didNotTryToScanForAccessPoints() } - @Test fun findAccessPointsMatchingRegex_success_multipleMatchingSSIDs_accessPoint1HasHigherRSSI_takeHighest_false() { + @Test + fun findAccessPointsMatchingRegex_success_multipleMatchingSSIDs_accessPoint1HasHigherRSSI_takeHighest_false() { val takeHighest = false mockNetworkUtil.nearbyAccessPoints_multipleMatchingSSIDs_accessPoint1HasHigherRSSI(takeHighest) - assertEquals(mockNetworkUtil.getExpectedNearbyAccessPoints(), wisefySearch.findAccessPointsMatchingRegex(TEST_SSID, takeHighest)) + assertEquals(mockNetworkUtil.getExpectedNearbyAccessPoints(), wisefySearch.findAccessPointsMatchingRegex( + TEST_SSID, + takeHighest + )) verificationUtil.didNotTryToScanForAccessPoints() } - @Test fun findAccessPointsMatchingRegex_success_multipleMatchingSSIDs_accessPoint1HasHigherRSSI_takeHighest_true() { + @Test + fun findAccessPointsMatchingRegex_success_multipleMatchingSSIDs_accessPoint1HasHigherRSSI_takeHighest_true() { val takeHighest = true mockNetworkUtil.nearbyAccessPoints_multipleMatchingSSIDs_accessPoint1HasHigherRSSI(takeHighest) - assertEquals(mockNetworkUtil.getExpectedNearbyAccessPoints(), wisefySearch.findAccessPointsMatchingRegex(TEST_SSID, takeHighest)) + assertEquals(mockNetworkUtil.getExpectedNearbyAccessPoints(), wisefySearch.findAccessPointsMatchingRegex( + TEST_SSID, + takeHighest + )) verificationUtil.didNotTryToScanForAccessPoints() } - @Test fun findAccessPointsMatchingRegex_success_multipleMatchingSSIDs_accessPoint2HasHigherRSSI_takeHighest_false() { + @Test + fun findAccessPointsMatchingRegex_success_multipleMatchingSSIDs_accessPoint2HasHigherRSSI_takeHighest_false() { mockNetworkUtil.nearbyAccessPoints_multipleMatchingSSIDs_accessPoint2HasHigherRSSI(false) - assertEquals(mockNetworkUtil.getExpectedNearbyAccessPoints(), wisefySearch.findAccessPointsMatchingRegex(TEST_SSID, false)) + assertEquals(mockNetworkUtil.getExpectedNearbyAccessPoints(), wisefySearch.findAccessPointsMatchingRegex( + TEST_SSID, + false + )) verificationUtil.didNotTryToScanForAccessPoints() } - @Test fun findAccessPointsMatchingRegex_success_multipleMatchingSSIDs_accessPoint2HasHigherRSSI_takeHighest_true() { + @Test + fun findAccessPointsMatchingRegex_success_multipleMatchingSSIDs_accessPoint2HasHigherRSSI_takeHighest_true() { mockNetworkUtil.nearbyAccessPoints_multipleMatchingSSIDs_accessPoint2HasHigherRSSI(true) - assertEquals(mockNetworkUtil.getExpectedNearbyAccessPoints(), wisefySearch.findAccessPointsMatchingRegex(TEST_SSID, true)) + assertEquals(mockNetworkUtil.getExpectedNearbyAccessPoints(), wisefySearch.findAccessPointsMatchingRegex( + TEST_SSID, + true + )) verificationUtil.didNotTryToScanForAccessPoints() } - @Test fun findAccessPointsMatchingRegex_success_multipleMatchingSSIDs_sameRSSI_takeHighest_false() { + @Test + fun findAccessPointsMatchingRegex_success_multipleMatchingSSIDs_sameRSSI_takeHighest_false() { mockNetworkUtil.nearbyAccessPoints_multipleMatchingSSIDs_sameRSSI(true) - assertEquals(mockNetworkUtil.getExpectedNearbyAccessPoints(), wisefySearch.findAccessPointsMatchingRegex(TEST_SSID, false)) + assertEquals(mockNetworkUtil.getExpectedNearbyAccessPoints(), wisefySearch.findAccessPointsMatchingRegex( + TEST_SSID, + false + )) verificationUtil.didNotTryToScanForAccessPoints() } - @Test fun findAccessPointsMatchingRegex_success_multipleMatchingSSIDs_sameRSSI_takeHighest_true() { + @Test + fun findAccessPointsMatchingRegex_success_multipleMatchingSSIDs_sameRSSI_takeHighest_true() { mockNetworkUtil.nearbyAccessPoints_multipleMatchingSSIDs_sameRSSI(true) - assertEquals(mockNetworkUtil.getExpectedNearbyAccessPoints(), wisefySearch.findAccessPointsMatchingRegex(TEST_SSID, true)) + assertEquals(mockNetworkUtil.getExpectedNearbyAccessPoints(), wisefySearch.findAccessPointsMatchingRegex( + TEST_SSID, + true + )) verificationUtil.didNotTryToScanForAccessPoints() } @@ -339,73 +470,85 @@ internal class WiseFySearchSdk23Tests : BaseInstrumentationTest() { * findSSIDsMatchingRegex tests */ - @Test fun findSSIDsMatchingRegex_failure_nullAccessPoints() { + @Test + fun findSSIDsMatchingRegex_failure_nullAccessPoints() { mockNetworkUtil.nearbyAccessPoints_nullList() assertEquals(null, wisefySearch.findSSIDsMatchingRegex(TEST_SSID)) verificationUtil.didNotTryToScanForAccessPoints() } - @Test fun findSSIDsMatchingRegex_failure_emptySavedNetworkList() { + @Test + fun findSSIDsMatchingRegex_failure_emptySavedNetworkList() { mockNetworkUtil.nearbyAccessPoints_emptyList() assertEquals(null, wisefySearch.findSSIDsMatchingRegex(TEST_SSID)) verificationUtil.didNotTryToScanForAccessPoints() } - @Test fun findSSIDsMatchingRegex_failure_nullAccessPoint() { + @Test + fun findSSIDsMatchingRegex_failure_nullAccessPoint() { mockNetworkUtil.nearbyAccessPoints_nullAccessPoint() assertEquals(null, wisefySearch.findSSIDsMatchingRegex(TEST_SSID)) verificationUtil.didNotTryToScanForAccessPoints() } - @Test fun findSSIDsMatchingRegex_failure_nullSSID() { + @Test + fun findSSIDsMatchingRegex_failure_nullSSID() { mockNetworkUtil.nearbyAccessPoints_nullSSID() assertEquals(null, wisefySearch.findSSIDsMatchingRegex(TEST_SSID)) verificationUtil.didNotTryToScanForAccessPoints() } - @Test fun findSSIDsMatchingRegex_failure_nonMatchingSSID() { + @Test + fun findSSIDsMatchingRegex_failure_nonMatchingSSID() { mockNetworkUtil.nearbyAccessPoints_nonMatchingSSID() assertEquals(null, wisefySearch.findSSIDsMatchingRegex(TEST_SSID)) verificationUtil.didNotTryToScanForAccessPoints() } - @Test fun findSSIDsMatchingRegex_failure_multipleNonMatchingSSIDs() { + @Test + fun findSSIDsMatchingRegex_failure_multipleNonMatchingSSIDs() { mockNetworkUtil.nearbyAccessPoints_multipleNonMatchingSSIDs() assertEquals(null, wisefySearch.findSSIDsMatchingRegex(TEST_SSID)) verificationUtil.didNotTryToScanForAccessPoints() } - @Test fun findSSIDsMatchingRegex_success() { + @Test + fun findSSIDsMatchingRegex_success() { mockNetworkUtil.nearbyAccessPoints_matchingSSID() assertEquals(mockNetworkUtil.getExpectedSSIDs(), wisefySearch.findSSIDsMatchingRegex(TEST_SSID)) verificationUtil.didNotTryToScanForAccessPoints() } - @Test fun findSSIDsMatchingRegex_success_multipleMatchingSSIDs_sameRSSI() { + @Test + fun findSSIDsMatchingRegex_success_multipleMatchingSSIDs_sameRSSI() { mockNetworkUtil.nearbyAccessPoints_multipleMatchingSSIDs_sameRSSI(true) assertEquals(mockNetworkUtil.getExpectedSSIDs(), wisefySearch.findSSIDsMatchingRegex(TEST_SSID)) verificationUtil.didNotTryToScanForAccessPoints() } - @Test fun findSSIDsMatchingRegex_success_multipleMatchingSSIDs_accessPoint1HasHigherRSSI() { + @Test + fun findSSIDsMatchingRegex_success_multipleMatchingSSIDs_accessPoint1HasHigherRSSI() { mockNetworkUtil.nearbyAccessPoints_multipleMatchingSSIDs_accessPoint1HasHigherRSSI(true) assertEquals(mockNetworkUtil.getExpectedSSIDs(), wisefySearch.findSSIDsMatchingRegex(TEST_SSID)) verificationUtil.didNotTryToScanForAccessPoints() } - @Test fun findSSIDsMatchingRegex_success_multipleMatchingSSIDs_accessPoint2HasHigherRSSI() { + @Test + fun findSSIDsMatchingRegex_success_multipleMatchingSSIDs_accessPoint2HasHigherRSSI() { mockNetworkUtil.nearbyAccessPoints_multipleMatchingSSIDs_accessPoint2HasHigherRSSI(true) assertEquals(mockNetworkUtil.getExpectedSSIDs(), wisefySearch.findSSIDsMatchingRegex(TEST_SSID)) verificationUtil.didNotTryToScanForAccessPoints() } - @Test fun findSSIDsMatchingRegex_success_multipleSSIDs_nonRegex() { + @Test + fun findSSIDsMatchingRegex_success_multipleSSIDs_nonRegex() { mockNetworkUtil.nearbyAccessPoints_multipleSSIDs_sameRSSI(false) assertEquals(mockNetworkUtil.getExpectedSSIDs(), wisefySearch.findSSIDsMatchingRegex(TEST_SSID)) verificationUtil.didNotTryToScanForAccessPoints() } - @Test fun findSSIDsMatchingRegex_success_multipleSSIDs_regex() { + @Test + fun findSSIDsMatchingRegex_success_multipleSSIDs_regex() { mockNetworkUtil.nearbyAccessPoints_multipleSSIDs_sameRSSI(true) assertEquals(mockNetworkUtil.getExpectedSSIDs(), wisefySearch.findSSIDsMatchingRegex(TEST_REGEX)) verificationUtil.didNotTryToScanForAccessPoints() @@ -415,7 +558,8 @@ internal class WiseFySearchSdk23Tests : BaseInstrumentationTest() { * getNearbyAccessPoints tests */ - @Test fun getNearbyAccessPoints_differentSSIDs_filterDuplicates_true() { + @Test + fun getNearbyAccessPoints_differentSSIDs_filterDuplicates_true() { mockNetworkUtil.nearbyAccessPoints_multipleSSIDs_sameRSSI(true) val accessPoints = wisefySearch.getNearbyAccessPoints(true) assertEquals(mockNetworkUtil.getExpectedNearbyAccessPoints(), accessPoints) @@ -423,7 +567,8 @@ internal class WiseFySearchSdk23Tests : BaseInstrumentationTest() { verificationUtil.didNotTryToScanForAccessPoints() } - @Test fun getNearbyAccessPoints_sameSignalLevels_filterDuplicates_true() { + @Test + fun getNearbyAccessPoints_sameSignalLevels_filterDuplicates_true() { mockNetworkUtil.nearbyAccessPoints_multipleMatchingSSIDs_sameRSSI(false) val accessPoints = wisefySearch.getNearbyAccessPoints(true) assertEquals(mockNetworkUtil.getExpectedNearbyAccessPoints(), accessPoints) @@ -431,7 +576,8 @@ internal class WiseFySearchSdk23Tests : BaseInstrumentationTest() { verificationUtil.didNotTryToScanForAccessPoints() } - @Test fun getNearbyAccessPoints_accessPoint1Higher_filterDuplicates_true() { + @Test + fun getNearbyAccessPoints_accessPoint1Higher_filterDuplicates_true() { mockNetworkUtil.nearbyAccessPoints_multipleMatchingSSIDs_accessPoint1HasHigherRSSI(true) val accessPoints = wisefySearch.getNearbyAccessPoints(true) assertEquals(mockNetworkUtil.getExpectedNearbyAccessPoints(), accessPoints) @@ -439,7 +585,8 @@ internal class WiseFySearchSdk23Tests : BaseInstrumentationTest() { verificationUtil.didNotTryToScanForAccessPoints() } - @Test fun getNearbyAccessPoints_accessPoint2Higher_filterDuplicates_true() { + @Test + fun getNearbyAccessPoints_accessPoint2Higher_filterDuplicates_true() { mockNetworkUtil.nearbyAccessPoints_multipleMatchingSSIDs_accessPoint2HasHigherRSSI(true) val accessPoints = wisefySearch.getNearbyAccessPoints(true) assertEquals(mockNetworkUtil.getExpectedNearbyAccessPoints(), accessPoints) @@ -447,7 +594,8 @@ internal class WiseFySearchSdk23Tests : BaseInstrumentationTest() { verificationUtil.didNotTryToScanForAccessPoints() } - @Test fun getNearbyAccessPoints_nullAccessPointList_filterDuplicates_false() { + @Test + fun getNearbyAccessPoints_nullAccessPointList_filterDuplicates_false() { mockNetworkUtil.nearbyAccessPoints_nullList() val accessPoints = wisefySearch.getNearbyAccessPoints(false) assertNull(accessPoints) @@ -455,7 +603,8 @@ internal class WiseFySearchSdk23Tests : BaseInstrumentationTest() { verificationUtil.didNotTryToScanForAccessPoints() } - @Test fun getNearbyAccessPoints_emptyAccessPointList_filterDuplicates_false() { + @Test + fun getNearbyAccessPoints_emptyAccessPointList_filterDuplicates_false() { mockNetworkUtil.nearbyAccessPoints_emptyList() val accessPoints = wisefySearch.getNearbyAccessPoints(false) assertNull(accessPoints) @@ -463,7 +612,8 @@ internal class WiseFySearchSdk23Tests : BaseInstrumentationTest() { verificationUtil.didNotTryToScanForAccessPoints() } - @Test fun getNearbyAccessPoints_differentSSIDs_filterDuplicates_false() { + @Test + fun getNearbyAccessPoints_differentSSIDs_filterDuplicates_false() { mockNetworkUtil.nearbyAccessPoints_multipleSSIDs_sameRSSI(true) val accessPoints = wisefySearch.getNearbyAccessPoints(false) assertEquals(mockNetworkUtil.getExpectedNearbyAccessPoints(), accessPoints) @@ -471,7 +621,8 @@ internal class WiseFySearchSdk23Tests : BaseInstrumentationTest() { verificationUtil.didNotTryToScanForAccessPoints() } - @Test fun getNearbyAccessPoints_sameSignalLevels_filterDuplicates_false() { + @Test + fun getNearbyAccessPoints_sameSignalLevels_filterDuplicates_false() { mockNetworkUtil.nearbyAccessPoints_multipleMatchingSSIDs_sameRSSI(true) val accessPoints = wisefySearch.getNearbyAccessPoints(false) assertEquals(mockNetworkUtil.getExpectedNearbyAccessPoints(), accessPoints) @@ -479,7 +630,8 @@ internal class WiseFySearchSdk23Tests : BaseInstrumentationTest() { verificationUtil.didNotTryToScanForAccessPoints() } - @Test fun getNearbyAccessPoints_accessPoint1Higher_filterDuplicates_false() { + @Test + fun getNearbyAccessPoints_accessPoint1Higher_filterDuplicates_false() { mockNetworkUtil.nearbyAccessPoints_multipleMatchingSSIDs_accessPoint1HasHigherRSSI(false) val accessPoints = wisefySearch.getNearbyAccessPoints(false) assertEquals(mockNetworkUtil.getExpectedNearbyAccessPoints(), accessPoints) @@ -487,7 +639,8 @@ internal class WiseFySearchSdk23Tests : BaseInstrumentationTest() { verificationUtil.didNotTryToScanForAccessPoints() } - @Test fun getNearbyAccessPoints_accessPoint2Higher_filterDuplicates_false() { + @Test + fun getNearbyAccessPoints_accessPoint2Higher_filterDuplicates_false() { mockNetworkUtil.nearbyAccessPoints_multipleMatchingSSIDs_accessPoint2HasHigherRSSI(false) val accessPoints = wisefySearch.getNearbyAccessPoints(false) assertEquals(mockNetworkUtil.getExpectedNearbyAccessPoints(), accessPoints) diff --git a/wisefy/src/main/AndroidManifest.xml b/wisefy/src/main/AndroidManifest.xml index 7aebbfd8..c5c62cb3 100644 --- a/wisefy/src/main/AndroidManifest.xml +++ b/wisefy/src/main/AndroidManifest.xml @@ -1,13 +1,12 @@ - - - + - + - \ No newline at end of file diff --git a/wisefy/src/main/java/com/isupatches/wisefy/WiseFy.kt b/wisefy/src/main/java/com/isupatches/wisefy/WiseFy.kt index c4f9bfe1..4f8419ca 100644 --- a/wisefy/src/main/java/com/isupatches/wisefy/WiseFy.kt +++ b/wisefy/src/main/java/com/isupatches/wisefy/WiseFy.kt @@ -14,12 +14,10 @@ * limitations under the License. */ @file:JvmName("WiseFy") + package com.isupatches.wisefy -import android.Manifest.permission.ACCESS_COARSE_LOCATION -import android.Manifest.permission.ACCESS_NETWORK_STATE -import android.Manifest.permission.ACCESS_WIFI_STATE -import android.Manifest.permission.CHANGE_WIFI_STATE +import android.Manifest.permission.ACCESS_FINE_LOCATION import android.content.Context import android.net.ConnectivityManager import android.net.NetworkInfo @@ -33,7 +31,6 @@ import android.os.Looper import androidx.annotation.RequiresApi import androidx.annotation.RequiresPermission import androidx.annotation.VisibleForTesting - import com.isupatches.wisefy.annotations.Async import com.isupatches.wisefy.annotations.CallingThread import com.isupatches.wisefy.annotations.PublicAPI @@ -77,7 +74,6 @@ import com.isupatches.wisefy.threads.WiseFyHandlerThread import com.isupatches.wisefy.utils.generateOpenNetworkConfiguration import com.isupatches.wisefy.utils.generateWEPNetworkConfiguration import com.isupatches.wisefy.utils.generateWPA2NetworkConfiguration - import java.math.BigInteger import java.net.InetAddress import java.net.UnknownHostException @@ -163,7 +159,9 @@ class WiseFy private constructor( private var wisefySearch: WiseFySearch init { - connectivityManager = context.getSystemService(Context.CONNECTIVITY_SERVICE) as ConnectivityManager + connectivityManager = context.applicationContext.getSystemService( + Context.CONNECTIVITY_SERVICE + ) as ConnectivityManager wifiManager = context.applicationContext.getSystemService(Context.WIFI_SERVICE) as WifiManager // We'll use SDK 23 logic for WiseFyConnection if client is on at least an SDK 23 device @@ -308,7 +306,7 @@ class WiseFy private constructor( */ @Sync @CallingThread - @RequiresPermission(ACCESS_WIFI_STATE) + @RequiresPermission(ACCESS_FINE_LOCATION) override fun addOpenNetwork(ssid: String?): Int { val precheck = wisefyPrechecks.addNetworkPrechecks(ssid) return if (precheck.failed()) { @@ -334,7 +332,7 @@ class WiseFy private constructor( */ @Async @WiseFyThread - @RequiresPermission(ACCESS_WIFI_STATE) + @RequiresPermission(ACCESS_FINE_LOCATION) override fun addOpenNetwork(ssid: String?, callbacks: AddNetworkCallbacks?) { runOnWiseFyThread(Runnable { synchronized(wisefyLock) { @@ -372,11 +370,11 @@ class WiseFy private constructor( */ @Sync @CallingThread - @RequiresPermission(ACCESS_WIFI_STATE) + @RequiresPermission(ACCESS_FINE_LOCATION) @Deprecated("Due to security and performance limitations, WEP networks are discouraged") - @Suppress("deprecation") override fun addWEPNetwork(ssid: String?, password: String?): Int { val precheck = wisefyPrechecks.addNetworkPrechecks(ssid, password) + @Suppress("deprecation") return if (precheck.failed()) { precheck.code } else addNetworkConfiguration(generateWEPNetworkConfiguration(ssid!!, password!!)) @@ -403,16 +401,18 @@ class WiseFy private constructor( */ @Async @WiseFyThread - @RequiresPermission(ACCESS_WIFI_STATE) + @RequiresPermission(ACCESS_FINE_LOCATION) @Deprecated("Due to security and performance limitations, WEP networks are discouraged") - @Suppress("deprecation") override fun addWEPNetwork(ssid: String?, password: String?, callbacks: AddNetworkCallbacks?) { runOnWiseFyThread(Runnable { synchronized(wisefyLock) { addNetworkWithPasswordAsync( ssid = ssid, password = password, - wifiConfigurationProvider = { generateWEPNetworkConfiguration(ssid!!, password!!) }, + wifiConfigurationProvider = { + @Suppress("deprecation") + generateWEPNetworkConfiguration(ssid!!, password!!) + }, callbacks = callbacks ) } @@ -436,7 +436,7 @@ class WiseFy private constructor( */ @Sync @CallingThread - @RequiresPermission(ACCESS_WIFI_STATE) + @RequiresPermission(ACCESS_FINE_LOCATION) override fun addWPA2Network(ssid: String?, password: String?): Int { val precheck = wisefyPrechecks.addNetworkPrechecks(ssid, password) return if (precheck.failed()) { @@ -465,7 +465,7 @@ class WiseFy private constructor( */ @Async @WiseFyThread - @RequiresPermission(ACCESS_WIFI_STATE) + @RequiresPermission(ACCESS_FINE_LOCATION) override fun addWPA2Network(ssid: String?, password: String?, callbacks: AddNetworkCallbacks?) { runOnWiseFyThread(Runnable { synchronized(wisefyLock) { @@ -535,13 +535,16 @@ class WiseFy private constructor( * @see [WiseFyPrechecks.connectToNetworkPrechecks] * @see [WiseFySearch.findSavedNetworkByRegex] * + * Updates + * - 12/19/2019: Added ACCESS_FINE_LOCATION requirement + * * @author Patches * @since 3.0 */ @Sync @CallingThread @WaitsForTimeout - @RequiresPermission(ACCESS_WIFI_STATE) + @RequiresPermission(ACCESS_FINE_LOCATION) override fun connectToNetwork(ssidToConnectTo: String?, timeoutInMillis: Int): Boolean { if (wisefyPrechecks.connectToNetworkPrechecks(ssidToConnectTo).failed()) { return false @@ -573,13 +576,16 @@ class WiseFy private constructor( * @see [WiseFyPrechecks.connectToNetworkPrechecks] * @see [WiseFySearch.findSavedNetworkByRegex] * + * Updates + * - 12/19/2019: Added ACCESS_FINE_LOCATION requirement + * * @author Patches * @since 3.0 */ @Async @WiseFyThread @WaitsForTimeout - @RequiresPermission(ACCESS_WIFI_STATE) + @RequiresPermission(ACCESS_FINE_LOCATION) override fun connectToNetwork( ssidToConnectTo: String?, timeoutInMillis: Int, @@ -622,7 +628,6 @@ class WiseFy private constructor( */ @Sync @CallingThread - @RequiresPermission(CHANGE_WIFI_STATE) override fun disableWifi(): Boolean = wisefyPrechecks.disableWifiChecks().passed() && wifiManager.setWifiEnabled(false) @@ -642,7 +647,6 @@ class WiseFy private constructor( */ @Async @WiseFyThread - @RequiresPermission(CHANGE_WIFI_STATE) override fun disableWifi(callbacks: DisableWifiCallbacks?) { runOnWiseFyThread(Runnable { synchronized(wisefyLock) { @@ -766,7 +770,6 @@ class WiseFy private constructor( */ @Sync @CallingThread - @RequiresPermission(CHANGE_WIFI_STATE) override fun enableWifi(): Boolean = wisefyPrechecks.enableWifiChecks().passed() && wifiManager.setWifiEnabled(true) @@ -786,7 +789,6 @@ class WiseFy private constructor( */ @Async @WiseFyThread - @RequiresPermission(CHANGE_WIFI_STATE) override fun enableWifi(callbacks: EnableWifiCallbacks?) { runOnWiseFyThread(Runnable { synchronized(wisefyLock) { @@ -819,7 +821,6 @@ class WiseFy private constructor( */ @Sync @CallingThread - @RequiresPermission(allOf = [ACCESS_COARSE_LOCATION, ACCESS_WIFI_STATE]) override fun getCurrentNetwork(): WifiInfo? { return if (wisefyPrechecks.getCurrentNetworkChecks().passed()) { wifiManager.connectionInfo @@ -846,7 +847,6 @@ class WiseFy private constructor( */ @Async @WiseFyThread - @RequiresPermission(allOf = [ACCESS_COARSE_LOCATION, ACCESS_WIFI_STATE]) override fun getCurrentNetwork(callbacks: GetCurrentNetworkCallbacks?) { runOnWiseFyThread(Runnable { synchronized(wisefyLock) { @@ -880,7 +880,6 @@ class WiseFy private constructor( */ @Sync @CallingThread - @RequiresPermission(ACCESS_NETWORK_STATE) override fun getCurrentNetworkInfo(): NetworkInfo? { return if (wisefyPrechecks.getCurrentNetworkInfoChecks().passed()) { connectivityManager.activeNetworkInfo @@ -907,7 +906,6 @@ class WiseFy private constructor( */ @Async @WiseFyThread - @RequiresPermission(ACCESS_NETWORK_STATE) override fun getCurrentNetworkInfo(callbacks: GetCurrentNetworkInfoCallbacks?) { runOnWiseFyThread(Runnable { synchronized(wisefyLock) { @@ -934,6 +932,10 @@ class WiseFy private constructor( * * @see [getCurrentNetwork] * @see [WifiInfo.getFrequency] + * @see [WiseFyPrechecks.getFrequencyChecks] + * + * Updates + * - 01/04/2020: Added getFrequencyChecks call * * @author Patches * @since 3.0 @@ -941,10 +943,12 @@ class WiseFy private constructor( @Sync @CallingThread @RequiresApi(Build.VERSION_CODES.LOLLIPOP) - @RequiresPermission(allOf = [ACCESS_COARSE_LOCATION, ACCESS_WIFI_STATE]) + @RequiresPermission(ACCESS_FINE_LOCATION) override fun getFrequency(): Int? { - val currentNetwork = getCurrentNetwork() - return currentNetwork?.frequency + return if (wisefyPrechecks.getFrequencyChecks().passed()) { + val currentNetwork = getCurrentNetwork() + currentNetwork?.frequency + } else null } /** @@ -957,6 +961,10 @@ class WiseFy private constructor( * @see [runOnWiseFyThread] * @see [WifiInfo.getFrequency] * @see [WiseFyLock] + * @see [WiseFyPrechecks.getFrequencyChecks] + * + * Updates + * - 01/04/2020: Added getFrequencyChecks call * * @author Patches * @since 3.0 @@ -964,10 +972,16 @@ class WiseFy private constructor( @Async @WiseFyThread @RequiresApi(Build.VERSION_CODES.LOLLIPOP) - @RequiresPermission(allOf = [ACCESS_COARSE_LOCATION, ACCESS_WIFI_STATE]) + @RequiresPermission(ACCESS_FINE_LOCATION) override fun getFrequency(callbacks: GetFrequencyCallbacks?) { runOnWiseFyThread(Runnable { synchronized(wisefyLock) { + val precheck = wisefyPrechecks.getFrequencyChecks() + if (precheck.failed()) { + callbacks?.wisefyFailure(precheck.code) + return@Runnable + } + val currentNetwork = getCurrentNetwork() if (currentNetwork != null) { callbacks?.retrievedFrequency(currentNetwork.frequency) @@ -1039,7 +1053,6 @@ class WiseFy private constructor( */ @Sync @CallingThread - @RequiresPermission(ACCESS_WIFI_STATE) override fun getIP(): String? { if (wisefyPrechecks.getIPChecks().failed()) { return null @@ -1072,7 +1085,7 @@ class WiseFy private constructor( */ @Async @WiseFyThread - @RequiresPermission(allOf = [ACCESS_COARSE_LOCATION, ACCESS_WIFI_STATE]) + @RequiresPermission(ACCESS_FINE_LOCATION) override fun getIP(callbacks: GetIPCallbacks?) { runOnWiseFyThread(Runnable { synchronized(wisefyLock) { @@ -1115,7 +1128,7 @@ class WiseFy private constructor( */ @Sync @CallingThread - @RequiresPermission(allOf = [ACCESS_COARSE_LOCATION, ACCESS_WIFI_STATE]) + @RequiresPermission(ACCESS_FINE_LOCATION) override fun getNearbyAccessPoints(filterDuplicates: Boolean): List? { if (wisefyPrechecks.getNearbyAccessPointsChecks().failed()) { return null @@ -1149,7 +1162,7 @@ class WiseFy private constructor( */ @Async @WiseFyThread - @RequiresPermission(allOf = [ACCESS_COARSE_LOCATION, ACCESS_WIFI_STATE]) + @RequiresPermission(ACCESS_FINE_LOCATION) override fun getNearbyAccessPoints(filterDuplicates: Boolean, callbacks: GetNearbyAccessPointsCallbacks?) { runOnWiseFyThread(Runnable { synchronized(wisefyLock) { @@ -1190,12 +1203,11 @@ class WiseFy private constructor( @Sync @CallingThread @WaitsForTimeout - @RequiresPermission(ACCESS_WIFI_STATE) + @RequiresPermission(ACCESS_FINE_LOCATION) override fun getRSSI(regexForSSID: String?, takeHighest: Boolean, timeoutInMillis: Int): Int? { if (wisefyPrechecks.getRSSIChecks(regexForSSID).failed()) { return null } - return wisefySearch.findAccessPointByRegex(regexForSSID!!, timeoutInMillis, takeHighest)?.level } @@ -1222,7 +1234,7 @@ class WiseFy private constructor( @Async @WiseFyThread @WaitsForTimeout - @RequiresPermission(ACCESS_WIFI_STATE) + @RequiresPermission(ACCESS_FINE_LOCATION) override fun getRSSI( regexForSSID: String?, takeHighest: Boolean, @@ -1256,12 +1268,15 @@ class WiseFy private constructor( * @see [WiseFyPrechecks.getSavedNetworksChecks] * @see [WiseFySearch.findSavedNetworksMatchingRegex] * + * Updates + * - 12/19/2019: Added ACCESS_FINE_LOCATION requirement + * * @author Patches * @since 3.0 */ @Sync @CallingThread - @RequiresPermission(ACCESS_WIFI_STATE) + @RequiresPermission(ACCESS_FINE_LOCATION) override fun getSavedNetworks(): List? { return if (wisefyPrechecks.getSavedNetworksChecks().passed()) { wifiManager.configuredNetworks @@ -1280,12 +1295,15 @@ class WiseFy private constructor( * @see [WiseFyPrechecks.getSavedNetworksChecks] * @see [WiseFySearch.findSavedNetworksMatchingRegex] * + * Updates + * - 12/19/2019: Added ACCESS_FINE_LOCATION requirement + * * @author Patches * @since 3.0 */ @Async @WiseFyThread - @RequiresPermission(ACCESS_WIFI_STATE) + @RequiresPermission(ACCESS_FINE_LOCATION) override fun getSavedNetworks(callbacks: GetSavedNetworksCallbacks?) { runOnWiseFyThread(Runnable { synchronized(wisefyLock) { @@ -1333,7 +1351,6 @@ class WiseFy private constructor( */ @Sync @CallingThread - @RequiresPermission(ACCESS_NETWORK_STATE) override fun isDeviceConnectedToMobileNetwork(): Boolean = wisefyPrechecks.isDeviceConnectedToMobileNetworkChecks().passed() && wisefyConnection.isDeviceConnectedToMobileNetwork() @@ -1351,7 +1368,6 @@ class WiseFy private constructor( */ @Sync @CallingThread - @RequiresPermission(ACCESS_NETWORK_STATE) override fun isDeviceConnectedToMobileOrWifiNetwork(): Boolean = wisefyPrechecks.isDeviceConnectedToMobileOrWifiNetworkChecks().passed() && wisefyConnection.isNetworkConnected() @@ -1371,7 +1387,6 @@ class WiseFy private constructor( */ @Sync @CallingThread - @RequiresPermission(allOf = [ACCESS_NETWORK_STATE, ACCESS_WIFI_STATE]) override fun isDeviceConnectedToSSID(ssid: String?): Boolean = wisefyPrechecks.isDeviceConnectedToSSIDChecks(ssid).passed() && wisefyConnection.isCurrentNetworkConnectedToSSID(ssid) @@ -1393,7 +1408,6 @@ class WiseFy private constructor( */ @Sync @CallingThread - @RequiresPermission(ACCESS_NETWORK_STATE) override fun isDeviceConnectedToWifiNetwork(): Boolean = wisefyPrechecks.isDeviceConnectedToWifiNetworkChecks().passed() && wisefyConnection.isDeviceConnectedToWifiNetwork() @@ -1414,7 +1428,6 @@ class WiseFy private constructor( */ @Sync @CallingThread - @RequiresPermission(ACCESS_NETWORK_STATE) override fun isDeviceRoaming(): Boolean { if (wisefyPrechecks.isDeviceRoamingChecks().failed()) { return false @@ -1451,7 +1464,7 @@ class WiseFy private constructor( @Sync @CallingThread @RequiresApi(Build.VERSION_CODES.LOLLIPOP) - @RequiresPermission(allOf = [ACCESS_COARSE_LOCATION, ACCESS_WIFI_STATE]) + @RequiresPermission(ACCESS_FINE_LOCATION) override fun isNetwork5gHz(): Boolean { val frequency = getFrequency() return frequency != null && frequency > MIN_FREQUENCY_5GHZ && frequency < MAX_FREQUENCY_5GHZ @@ -1531,7 +1544,7 @@ class WiseFy private constructor( */ @Sync @CallingThread - @RequiresPermission(ACCESS_WIFI_STATE) + @RequiresPermission(ACCESS_FINE_LOCATION) override fun isNetworkSaved(ssid: String?): Boolean = wisefyPrechecks.isNetworkSavedChecks().passed() && wisefySearch.isNetworkASavedConfiguration(ssid) @@ -1650,12 +1663,15 @@ class WiseFy private constructor( * @see [WiseFyPrechecks.removeNetworkCheck] * @sse [WiseFySearch.findSavedNetworkByRegex] * + * Updates + * - 12/19/2019: Added ACCESS_FINE_LOCATION requirement + * * @author Patches * @since 3.0 */ @Sync @CallingThread - @RequiresPermission(ACCESS_WIFI_STATE) + @RequiresPermission(ACCESS_FINE_LOCATION) override fun removeNetwork(ssidToRemove: String?): Boolean { if (wisefyPrechecks.removeNetworkCheck(ssidToRemove).failed()) { return false @@ -1684,12 +1700,15 @@ class WiseFy private constructor( * @see [WiseFyPrechecks.removeNetworkCheck] * @sse [WiseFySearch.findSavedNetworkByRegex] * + * Updates + * - 12/19/2019: Added ACCESS_FINE_LOCATION requirement + * * @author Patches * @since 3.0 */ @Async @WiseFyThread - @RequiresPermission(ACCESS_WIFI_STATE) + @RequiresPermission(ACCESS_FINE_LOCATION) override fun removeNetwork(ssidToRemove: String?, callbacks: RemoveNetworkCallbacks?) { runOnWiseFyThread(Runnable { synchronized(wisefyLock) { @@ -1716,13 +1735,16 @@ class WiseFy private constructor( /** * To return the first access point that matches a given regex. * - * *NOTE* Setting filterDuplicates to true will not return an access point with a weaker signal strength (will always take the highest). + * *NOTE* Setting filterDuplicates to true will not return an access point with a weaker signal strength. + * It will always take the highest. * * @param regexForSSID The regex to use when iterating through nearby access points * @param timeoutInMillis The amount of time (in milliseconds) to wait for a matching access point - * @param filterDuplicates If you want to exclude access points with the same name that have a weaker signal strength + * @param filterDuplicates If you want to exclude access points with the same name that have a weaker signal + * strength * - * @return ScanResult|null - The first access point or access point with the highest signal strength matching the regex + * @return ScanResult|null - The first access point or access point with the highest signal strength matching the + * regex * * @see [ScanResult] * @see [WiseFyPrechecks.searchForAccessPointChecks] @@ -1733,7 +1755,7 @@ class WiseFy private constructor( */ @Sync @CallingThread - @RequiresPermission(allOf = [ACCESS_COARSE_LOCATION, ACCESS_WIFI_STATE]) + @RequiresPermission(ACCESS_FINE_LOCATION) override fun searchForAccessPoint( regexForSSID: String?, timeoutInMillis: Int, @@ -1747,11 +1769,13 @@ class WiseFy private constructor( /** * To return the first access point that matches a given regex. * - * *NOTE* Setting filterDuplicates to true will not return an access point with a weaker signal strength (will always take the highest). + * *NOTE* Setting filterDuplicates to true will not return an access point with a weaker signal strength. + * It will always take the highest. * * @param regexForSSID The regex to use when iterating through nearby access points * @param timeoutInMillis The amount of time (in milliseconds) to wait for a matching access point - * @param filterDuplicates If you want to exclude access points with the same name that have a weaker signal strength + * @param filterDuplicates If you want to exclude access points with the same name that have a weaker signal + * strength * @param callbacks The listener to return results to * * @see [runOnWiseFyThread] @@ -1766,7 +1790,7 @@ class WiseFy private constructor( */ @Async @WiseFyThread - @RequiresPermission(allOf = [ACCESS_COARSE_LOCATION, ACCESS_WIFI_STATE]) + @RequiresPermission(ACCESS_FINE_LOCATION) override fun searchForAccessPoint( regexForSSID: String?, timeoutInMillis: Int, @@ -1794,10 +1818,12 @@ class WiseFy private constructor( /** * To return nearby access points that match a given regex. * - * *NOTE* Setting filterDuplicates to true will not return access points with a weaker signal strength (will always take the highest). + * *NOTE* Setting filterDuplicates to true will not return access points with a weaker signal strength. + * It will always take the highest. * * @param regexForSSID The regex to use when iterating through nearby access points - * @param filterDuplicates If you want to exclude access points with the same name that have a weaker signal strength + * @param filterDuplicates If you want to exclude access points with the same name that have a weaker signal + * strength * * @return List of ScanResult|null - The list of matching access points or null if none match the given regex * @@ -1810,7 +1836,7 @@ class WiseFy private constructor( */ @Sync @CallingThread - @RequiresPermission(allOf = [ACCESS_COARSE_LOCATION, ACCESS_WIFI_STATE]) + @RequiresPermission(ACCESS_FINE_LOCATION) override fun searchForAccessPoints(regexForSSID: String?, filterDuplicates: Boolean): List? { return if (wisefyPrechecks.searchForAccessPointsChecks(regexForSSID).passed()) { wisefySearch.findAccessPointsMatchingRegex(regexForSSID!!, filterDuplicates) @@ -1820,10 +1846,12 @@ class WiseFy private constructor( /** * To return nearby access points that match a given regex. * - * *NOTE* Setting filterDuplicates to true will not return access points with a weaker signal strength (will always take the highest). + * *NOTE* Setting filterDuplicates to true will not return access points with a weaker signal strength. + * It will always take the highest. * * @param regexForSSID The regex to use when iterating through nearby access points - * @param filterDuplicates If you want to exclude access points with the same name that have a weaker signal strength + * @param filterDuplicates If you want to exclude access points with the same name that have a weaker signal + * strength * @param callbacks The listener to return results to * * @see [runOnWiseFyThread] @@ -1838,7 +1866,7 @@ class WiseFy private constructor( */ @Async @WiseFyThread - @RequiresPermission(allOf = [ACCESS_COARSE_LOCATION, ACCESS_WIFI_STATE]) + @RequiresPermission(ACCESS_FINE_LOCATION) override fun searchForAccessPoints( regexForSSID: String?, filterDuplicates: Boolean, @@ -1873,12 +1901,15 @@ class WiseFy private constructor( * @see [WiseFyPrechecks.searchForSavedNetworkChecks] * @see [WiseFySearch.findSavedNetworkByRegex] * + * Updates + * - 12/19/2019: Added ACCESS_FINE_LOCATION requirement + * * @author Patches * @since 3.0 */ @Sync @CallingThread - @RequiresPermission(ACCESS_WIFI_STATE) + @RequiresPermission(ACCESS_FINE_LOCATION) override fun searchForSavedNetwork(regexForSSID: String?): WifiConfiguration? { return if (wisefyPrechecks.searchForSavedNetworkChecks(regexForSSID).passed()) { wisefySearch.findSavedNetworkByRegex(regexForSSID!!) @@ -1898,12 +1929,15 @@ class WiseFy private constructor( * @see [WiseFyPrechecks.searchForSavedNetworkChecks] * @see [WiseFySearch.findSavedNetworkByRegex] * + * Updates + * - 12/19/2019: Added ACCESS_FINE_LOCATION requirement + * * @author Patches * @since 3.0 */ @Async @WiseFyThread - @RequiresPermission(ACCESS_WIFI_STATE) + @RequiresPermission(ACCESS_FINE_LOCATION) override fun searchForSavedNetwork(regexForSSID: String?, callbacks: SearchForSavedNetworkCallbacks?) { runOnWiseFyThread(Runnable { synchronized(wisefyLock) { @@ -1934,12 +1968,15 @@ class WiseFy private constructor( * @see [WiseFyPrechecks.searchForSavedNetworksChecks] * @see [WiseFySearch.findSavedNetworksMatchingRegex] * + * Updates + * - 12/19/2019: Added ACCESS_FINE_LOCATION requirement + * * @author Patches * @since 3.0 */ @Sync @CallingThread - @RequiresPermission(ACCESS_WIFI_STATE) + @RequiresPermission(ACCESS_FINE_LOCATION) override fun searchForSavedNetworks(regexForSSID: String?): List? { return if (wisefyPrechecks.searchForSavedNetworksChecks(regexForSSID).passed()) { wisefySearch.findSavedNetworksMatchingRegex(regexForSSID!!) @@ -1959,12 +1996,15 @@ class WiseFy private constructor( * @see [WiseFyPrechecks.searchForSavedNetworksChecks] * @see [WiseFySearch.findSavedNetworksMatchingRegex] * + * Updates + * - 12/19/2019: Added ACCESS_FINE_LOCATION requirement + * * @author Patches * @since 3.0 */ @Async @WiseFyThread - @RequiresPermission(ACCESS_WIFI_STATE) + @RequiresPermission(ACCESS_FINE_LOCATION) override fun searchForSavedNetworks(regexForSSID: String?, callbacks: SearchForSavedNetworksCallbacks?) { runOnWiseFyThread(Runnable { synchronized(wisefyLock) { @@ -2002,7 +2042,7 @@ class WiseFy private constructor( @Sync @CallingThread @WaitsForTimeout - @RequiresPermission(allOf = [ACCESS_COARSE_LOCATION, ACCESS_WIFI_STATE]) + @RequiresPermission(ACCESS_FINE_LOCATION) override fun searchForSSID(regexForSSID: String?, timeoutInMillis: Int): String? { if (wisefyPrechecks.searchForSSIDChecks(regexForSSID).failed()) { return null @@ -2032,7 +2072,7 @@ class WiseFy private constructor( @Async @WiseFyThread @WaitsForTimeout - @RequiresPermission(allOf = [ACCESS_COARSE_LOCATION, ACCESS_WIFI_STATE]) + @RequiresPermission(ACCESS_FINE_LOCATION) override fun searchForSSID(regexForSSID: String?, timeoutInMillis: Int, callbacks: SearchForSSIDCallbacks?) { runOnWiseFyThread(Runnable { synchronized(wisefyLock) { @@ -2067,7 +2107,7 @@ class WiseFy private constructor( */ @Sync @CallingThread - @RequiresPermission(allOf = [ACCESS_COARSE_LOCATION, ACCESS_WIFI_STATE]) + @RequiresPermission(ACCESS_FINE_LOCATION) override fun searchForSSIDs(regexForSSID: String?): List? { return if (wisefyPrechecks.searchForSSIDsChecks(regexForSSID).passed()) { wisefySearch.findSSIDsMatchingRegex(regexForSSID!!) @@ -2091,7 +2131,7 @@ class WiseFy private constructor( */ @Async @WiseFyThread - @RequiresPermission(allOf = [ACCESS_COARSE_LOCATION, ACCESS_WIFI_STATE]) + @RequiresPermission(ACCESS_FINE_LOCATION) override fun searchForSSIDs(regexForSSID: String?, callbacks: SearchForSSIDsCallbacks?) { runOnWiseFyThread(Runnable { synchronized(wisefyLock) { @@ -2133,6 +2173,7 @@ class WiseFy private constructor( * @author Patches * @since 4.0 */ + @RequiresPermission(ACCESS_FINE_LOCATION) private fun addNetworkWithPasswordAsync( ssid: String?, password: String?, diff --git a/wisefy/src/main/java/com/isupatches/wisefy/WiseFyPrechecks.kt b/wisefy/src/main/java/com/isupatches/wisefy/WiseFyPrechecks.kt index 4f5f75f8..df64a4d3 100644 --- a/wisefy/src/main/java/com/isupatches/wisefy/WiseFyPrechecks.kt +++ b/wisefy/src/main/java/com/isupatches/wisefy/WiseFyPrechecks.kt @@ -15,9 +15,8 @@ */ package com.isupatches.wisefy -import android.Manifest.permission.ACCESS_WIFI_STATE +import android.Manifest.permission.ACCESS_FINE_LOCATION import androidx.annotation.RequiresPermission - import com.isupatches.wisefy.constants.DEFAULT_PRECHECK_RETURN_CODE import com.isupatches.wisefy.constants.MISSING_PARAMETER import com.isupatches.wisefy.constants.NETWORK_ALREADY_CONFIGURED @@ -50,15 +49,17 @@ internal class WiseFyPrechecksImpl private constructor( * @author Patches * @since 3.0 */ - @RequiresPermission(ACCESS_WIFI_STATE) + @RequiresPermission(ACCESS_FINE_LOCATION) override fun addNetworkPrechecks(ssid: String?): PrecheckResult = checkAddNetworkPrerequisites(ssid) /** * Used internally to make sure perquisites for adding a network as a saved configuration are met. * - * @param ssid The ssid param from [com.isupatches.wisefy.WiseFy.addWEPNetwork] or [com.isupatches.wisefy.WiseFy.addWPA2Network] - * @param password The password from [com.isupatches.wisefy.WiseFy.addWEPNetwork] or [com.isupatches.wisefy.WiseFy.addWPA2Network] + * @param ssid The ssid param from [com.isupatches.wisefy.WiseFy.addWEPNetwork] or + * [com.isupatches.wisefy.WiseFy.addWPA2Network] + * @param password The password from [com.isupatches.wisefy.WiseFy.addWEPNetwork] or + * [com.isupatches.wisefy.WiseFy.addWPA2Network] * * @return PrecheckResult - [DEFAULT_PRECHECK_RESULT] or a [PrecheckResult] with an error code. * @@ -69,7 +70,7 @@ internal class WiseFyPrechecksImpl private constructor( * @author Patches * @since 3.0 */ - @RequiresPermission(ACCESS_WIFI_STATE) + @RequiresPermission(ACCESS_FINE_LOCATION) override fun addNetworkPrechecks(ssid: String?, password: String?): PrecheckResult = checkAddNetworkPrerequisites(ssid, password) @@ -154,6 +155,19 @@ internal class WiseFyPrechecksImpl private constructor( */ override fun getCurrentNetworkInfoChecks() = DEFAULT_PRECHECK_RESULT + /** + * Used internally to make sure perquisites for getting the frequency of the current network are met. + * + * @return PrecheckResult - [DEFAULT_PRECHECK_RESULT] + * + * @see [com.isupatches.wisefy.WiseFy.getFrequency] + * @see [DEFAULT_PRECHECK_RESULT] + * + * @author Patches + * @since 4.1 + */ + override fun getFrequencyChecks() = DEFAULT_PRECHECK_RESULT + /** * Used internally to make sure perquisites for getting the ip of the device are met. * @@ -404,7 +418,7 @@ internal class WiseFyPrechecksImpl private constructor( * @since 4.0 */ override fun searchForSavedNetworkChecks(regexForSSID: String?): PrecheckResult = - checkForParam(regexForSSID) + checkForParam(regexForSSID) /** * Used internally to make sure prerequisites for searching for saved networks are met. @@ -420,7 +434,7 @@ internal class WiseFyPrechecksImpl private constructor( * @since 4.0 */ override fun searchForSavedNetworksChecks(regexForSSID: String?): PrecheckResult = - checkForParam(regexForSSID) + checkForParam(regexForSSID) /** * Used internally to make sure prerequisites for searching for an individual SSID are met. @@ -481,7 +495,7 @@ internal class WiseFyPrechecksImpl private constructor( /** * Used internally as an abstracted layer that checks if all of the prerequisites for adding - * a network are met. i.e. ssid is not null or empty, network is not already saved, etc. + * a network are met. f.e. ssid is not null or empty, network is not already saved, etc. * * @param ssid The ssid of the network to add * @@ -495,6 +509,7 @@ internal class WiseFyPrechecksImpl private constructor( * @author Patches * @since 3.0 */ + @RequiresPermission(ACCESS_FINE_LOCATION) private fun checkAddNetworkPrerequisites(ssid: String?): PrecheckResult = when { ssid.isNullOrEmpty() -> PrecheckResult(code = MISSING_PARAMETER) @@ -506,7 +521,7 @@ internal class WiseFyPrechecksImpl private constructor( /** * Used internally as an abstracted layer that checks if all of the prerequisites for adding - * a network are met. i.e. ssid and password are not null or empty, network is not already saved, etc. + * a network are met. f.e. ssid and password are not null or empty, network is not already saved, etc. * * @param ssid The ssid of the network to add * @param password The password of the network to add @@ -521,6 +536,7 @@ internal class WiseFyPrechecksImpl private constructor( * @author Patches * @since 3.0 */ + @RequiresPermission(ACCESS_FINE_LOCATION) private fun checkAddNetworkPrerequisites(ssid: String?, password: String?): PrecheckResult = when { ssid.isNullOrEmpty() || password.isNullOrEmpty() -> { @@ -543,13 +559,18 @@ internal class WiseFyPrechecksImpl private constructor( * * @see [WiseFyPrechecksImpl] * + * Updates + * - 01/04/2020: Refined permissions + * * @author Patches * @since 3.0 */ internal interface WiseFyPrechecks { + @RequiresPermission(ACCESS_FINE_LOCATION) fun addNetworkPrechecks(ssid: String?): PrecheckResult + @RequiresPermission(ACCESS_FINE_LOCATION) fun addNetworkPrechecks(ssid: String?, password: String?): PrecheckResult fun connectToNetworkPrechecks(ssidToConnectTo: String?): PrecheckResult @@ -564,6 +585,8 @@ internal interface WiseFyPrechecks { fun getCurrentNetworkInfoChecks(): PrecheckResult + fun getFrequencyChecks(): PrecheckResult + fun getIPChecks(): PrecheckResult fun getNearbyAccessPointsChecks(): PrecheckResult @@ -608,7 +631,7 @@ internal interface WiseFyPrechecks { /** * A return from WiseFyPrechecks that includes a relevant detail code. * - * @param code The return code from prechecks (i.e. [DEFAULT_PRECHECK_RETURN_CODE] or + * @param code The return code from prechecks (f.e. [DEFAULT_PRECHECK_RETURN_CODE] or * an error code such as [MISSING_PARAMETER]. This code will also be used by the extension * functions [passed] and [failed]. * diff --git a/wisefy/src/main/java/com/isupatches/wisefy/WisePublicApi.kt b/wisefy/src/main/java/com/isupatches/wisefy/WisePublicApi.kt index 9efff79d..61ae6dbf 100644 --- a/wisefy/src/main/java/com/isupatches/wisefy/WisePublicApi.kt +++ b/wisefy/src/main/java/com/isupatches/wisefy/WisePublicApi.kt @@ -15,11 +15,14 @@ */ package com.isupatches.wisefy +import android.Manifest.permission.ACCESS_FINE_LOCATION import android.net.NetworkInfo import android.net.wifi.ScanResult import android.net.wifi.WifiConfiguration import android.net.wifi.WifiInfo - +import android.os.Build +import androidx.annotation.RequiresApi +import androidx.annotation.RequiresPermission import com.isupatches.wisefy.callbacks.AddNetworkCallbacks import com.isupatches.wisefy.callbacks.ConnectToNetworkCallbacks import com.isupatches.wisefy.callbacks.DisableWifiCallbacks @@ -109,8 +112,8 @@ interface AccessPointApi { /** * To retrieve a list of nearby access points. * - * *NOTE* Setting filterDuplicates to true will exclude access points for an SSID that have a weaker RSSI - * (will always take the highest signal strength). + * *NOTE* Setting filterDuplicates to true will exclude access points for an SSID that have a weaker RSSI. + * It will always take the highest signal strength. * * @param filterDuplicates If you want to exclude SSIDs with that same name that have a weaker signal strength * @@ -119,26 +122,34 @@ interface AccessPointApi { * @see [WiseFy.getNearbyAccessPoints] * @see [ScanResult] * + * Updates + * - 01/04/2020: Refined permissions + * * @author Patches * @since 3.0 */ + @RequiresPermission(ACCESS_FINE_LOCATION) fun getNearbyAccessPoints(filterDuplicates: Boolean): List? /** * To retrieve a list of nearby access points. * - * *NOTE* Setting filterDuplicates to true will not return SSIDs with a weaker signal strength - * (will always take the highest). + * *NOTE* Setting filterDuplicates to true will not return SSIDs with a weaker signal strength. + * It will always take the highest. * * @param filterDuplicates If you want to exclude SSIDs with that same name that have a weaker signal strength * @param callbacks The listener to return results to * * @see [WiseFy.getNearbyAccessPoints] * @see [GetNearbyAccessPointsCallbacks] - + * + * Updates + * - 01/04/2020: Refined permissions + * * @author Patches * @since 3.0 */ + @RequiresPermission(ACCESS_FINE_LOCATION) fun getNearbyAccessPoints(filterDuplicates: Boolean, callbacks: GetNearbyAccessPointsCallbacks?) /** @@ -154,9 +165,13 @@ interface AccessPointApi { * * @see [WiseFy.getRSSI] * + * Updates + * - 01/04/2020: Refined permissions + * * @author Patches * @since 3.0 */ + @RequiresPermission(ACCESS_FINE_LOCATION) fun getRSSI(regexForSSID: String?, takeHighest: Boolean, timeoutInMillis: Int): Int? /** @@ -172,9 +187,13 @@ interface AccessPointApi { * @see [WiseFy.getRSSI] * @see [GetRSSICallbacks] * + * Updates + * - 01/04/2020: Refined permissions + * * @author Patches * @since 3.0 */ + @RequiresPermission(ACCESS_FINE_LOCATION) fun getRSSI( regexForSSID: String?, takeHighest: Boolean, @@ -185,20 +204,27 @@ interface AccessPointApi { /** * To return the first access point that matches a given regex. * - * *NOTE* Setting filterDuplicates to true will not return an access point with a weaker signal strength (will always take the highest). + * *NOTE* Setting filterDuplicates to true will not return an access point with a weaker signal strength. + * It will always take the highest. * * @param regexForSSID The regex to use when iterating through nearby access points * @param timeoutInMillis The amount of time (in milliseconds) to wait for a matching access point - * @param filterDuplicates If you want to exclude access points with the same name that have a weaker signal strength + * @param filterDuplicates If you want to exclude access points with the same name that have a weaker signal + * strength * - * @return ScanResult|null - The first access point or access point with the highest signal strength matching the regex + * @return ScanResult|null - The first access point or access point with the highest signal strength matching the + * regex * * @see [WiseFy.searchForAccessPoint] * @see [ScanResult] * + * Updates + * - 01/04/2020: Refined permissions + * * @author Patches * @since 3.0 */ + @RequiresPermission(ACCESS_FINE_LOCATION) fun searchForAccessPoint( regexForSSID: String?, timeoutInMillis: Int, @@ -208,19 +234,25 @@ interface AccessPointApi { /** * To return the first access point that matches a given regex. * - * *NOTE* Setting filterDuplicates to true will not return an access point with a weaker signal strength (will always take the highest). + * *NOTE* Setting filterDuplicates to true will not return an access point with a weaker signal strength. + * It will always take the highest. * * @param regexForSSID The regex to use when iterating through nearby access points * @param timeoutInMillis The amount of time (in milliseconds) to wait for a matching access point - * @param filterDuplicates If you want to exclude access points with the same name that have a weaker signal strength + * @param filterDuplicates If you want to exclude access points with the same name that have a weaker signal + * strength * @param callbacks The listener to return results to * * @see [WiseFy.searchForAccessPoint] * @see [SearchForAccessPointCallbacks] * + * Updates + * - 01/04/2020: Refined permissions + * * @author Patches * @since 3.0 */ + @RequiresPermission(ACCESS_FINE_LOCATION) fun searchForAccessPoint( regexForSSID: String?, timeoutInMillis: Int, @@ -231,36 +263,48 @@ interface AccessPointApi { /** * To return nearby access points that match a given regex. * - * *NOTE* Setting filterDuplicates to true will not return access points with a weaker signal strength (will always take the highest). + * *NOTE* Setting filterDuplicates to true will not return access points with a weaker signal strength. + * It will always take the highest. * * @param regexForSSID The regex to use when iterating through nearby access points - * @param filterDuplicates If you want to exclude access points with the same name that have a weaker signal strength + * @param filterDuplicates If you want to exclude access points with the same name that have a weaker signal + * strength * * @return List of ScanResult|null - The list of matching access points or null if none match the given regex * * @see [WiseFy.searchForAccessPoints] * @see [ScanResult] * + * Updates + * - 01/04/2020: Refined permissions + * * @author Patches * @since 3.0 */ + @RequiresPermission(ACCESS_FINE_LOCATION) fun searchForAccessPoints(regexForSSID: String?, filterDuplicates: Boolean): List? /** * To return nearby access points that match a given regex. * - * *NOTE* Setting filterDuplicates to true will not return access points with a weaker signal strength (will always take the highest). + * *NOTE* Setting filterDuplicates to true will not return access points with a weaker signal strength. + * It will always take the highest. * * @param regexForSSID The regex to use when iterating through nearby access points - * @param filterDuplicates If you want to exclude access points with the same name that have a weaker signal strength + * @param filterDuplicates If you want to exclude access points with the same name that have a weaker signal + * strength * @param callbacks The listener to return results to * * @see [WiseFy.searchForAccessPoints] * @see [SearchForAccessPointsCallbacks] * + * Updates + * - 01/04/2020: Refined permissions + * * @author Patches * @since 3.0 */ + @RequiresPermission(ACCESS_FINE_LOCATION) fun searchForAccessPoints( regexForSSID: String?, filterDuplicates: Boolean, @@ -277,9 +321,13 @@ interface AccessPointApi { * * @see [WiseFy.searchForSSID] * + * Updates + * - 01/04/2020: Refined permissions + * * @author Patches * @since 3.0 */ + @RequiresPermission(ACCESS_FINE_LOCATION) fun searchForSSID(regexForSSID: String?, timeoutInMillis: Int): String? /** @@ -292,9 +340,13 @@ interface AccessPointApi { * @see [WiseFy.searchForSSID] * @see [SearchForSSIDCallbacks] * + * Updates + * - 01/04/2020: Refined permissions + * * @author Patches * @since 3.0 */ + @RequiresPermission(ACCESS_FINE_LOCATION) fun searchForSSID(regexForSSID: String?, timeoutInMillis: Int, callbacks: SearchForSSIDCallbacks?) /** @@ -306,9 +358,13 @@ interface AccessPointApi { * * @see [WiseFy.searchForSSIDs] * + * Updates + * - 01/04/2020: Refined permissions + * * @author Patches * @since 3.0 */ + @RequiresPermission(ACCESS_FINE_LOCATION) fun searchForSSIDs(regexForSSID: String?): List? /** @@ -320,9 +376,13 @@ interface AccessPointApi { * @see [WiseFy.searchForSSIDs] * @see [SearchForSSIDsCallbacks] * + * Updates + * - 01/04/2020: Refined permissions + * * @author Patches * @since 3.0 */ + @RequiresPermission(ACCESS_FINE_LOCATION) fun searchForSSIDs(regexForSSID: String?, callbacks: SearchForSSIDsCallbacks?) } @@ -343,9 +403,13 @@ interface AddNetworkApi { * * @see [WiseFy.addOpenNetwork] * + * Updates + * - 01/04/2020: Refined permissions + * * @author Patches * @since 3.0 */ + @RequiresPermission(ACCESS_FINE_LOCATION) fun addOpenNetwork(ssid: String?): Int /** @@ -357,9 +421,13 @@ interface AddNetworkApi { * @see [WiseFy.addOpenNetwork] * @see [AddNetworkCallbacks] * + * Updates + * - 01/04/2020: Refined permissions + * * @author Patches * @since 3.0 */ + @RequiresPermission(ACCESS_FINE_LOCATION) fun addOpenNetwork(ssid: String?, callbacks: AddNetworkCallbacks?) /** @@ -372,9 +440,14 @@ interface AddNetworkApi { * * @see [WiseFy.addWEPNetwork] * + * Updates + * - 01/04/2020: Refined permissions + * * @author Patches * @since 3.0 */ + @RequiresPermission(ACCESS_FINE_LOCATION) + @Deprecated("Due to security and performance limitations, WEP networks are discouraged") fun addWEPNetwork(ssid: String?, password: String?): Int /** @@ -386,10 +459,15 @@ interface AddNetworkApi { * * @see [WiseFy.addWEPNetwork] * @see [AddNetworkCallbacks] - + * + * Updates + * - 01/04/2020: Refined permissions + * * @author Patches * @since 3.0 */ + @RequiresPermission(ACCESS_FINE_LOCATION) + @Deprecated("Due to security and performance limitations, WEP networks are discouraged") fun addWEPNetwork(ssid: String?, password: String?, callbacks: AddNetworkCallbacks?) /** @@ -402,9 +480,13 @@ interface AddNetworkApi { * * @see [WiseFy.addWPA2Network] * + * Updates + * - 01/04/2020: Refined permissions + * * @author Patches * @since 3.0 */ + @RequiresPermission(ACCESS_FINE_LOCATION) fun addWPA2Network(ssid: String?, password: String?): Int /** @@ -417,9 +499,13 @@ interface AddNetworkApi { * @see [WiseFy.addWPA2Network] * @see [AddNetworkCallbacks] * + * Updates + * - 01/04/2020: Refined permissions + * * @author Patches * @since 3.0 */ + @RequiresPermission(ACCESS_FINE_LOCATION) fun addWPA2Network(ssid: String?, password: String?, callbacks: AddNetworkCallbacks?) } @@ -441,9 +527,13 @@ interface ConnectionApi { * * @see [WiseFy.connectToNetwork] * + * Updates + * - 01/04/2020: Refined permissions + * * @author Patches * @since 3.0 */ + @RequiresPermission(ACCESS_FINE_LOCATION) fun connectToNetwork(ssidToConnectTo: String?, timeoutInMillis: Int): Boolean /** @@ -456,9 +546,13 @@ interface ConnectionApi { * @see [WiseFy.connectToNetwork] * @see [ConnectToNetworkCallbacks] * + * Updates + * - 01/04/2020: Refined permissions + * * @author Patches * @since 3.0 */ + @RequiresPermission(ACCESS_FINE_LOCATION) fun connectToNetwork( ssidToConnectTo: String?, timeoutInMillis: Int, @@ -577,9 +671,13 @@ interface FrequencyApi { * * @see [WiseFy.getFrequency] * + * Updates + * - 01/04/2020: Added API requirement + * * @author Patches * @since 3.0 */ + @RequiresApi(Build.VERSION_CODES.LOLLIPOP) fun getFrequency(): Int? /** @@ -590,9 +688,14 @@ interface FrequencyApi { * @see [WiseFy.getFrequency] * @see [GetFrequencyCallbacks] * + * Updates + * - 01/04/2020: Refined permissions and added API requirement + * * @author Patches * @since 3.0 */ + @RequiresApi(Build.VERSION_CODES.LOLLIPOP) + @RequiresPermission(ACCESS_FINE_LOCATION) fun getFrequency(callbacks: GetFrequencyCallbacks?) /** @@ -605,9 +708,13 @@ interface FrequencyApi { * @see [WiseFy.getFrequency] * @see [WifiInfo] * + * Updates + * - 01/04/2020: Added API requirement + * * @author Patches * @since 3.0 */ + @RequiresApi(Build.VERSION_CODES.LOLLIPOP) fun getFrequency(network: WifiInfo?): Int? /** @@ -620,9 +727,13 @@ interface FrequencyApi { * @see [GetFrequencyCallbacks] * @see [WifiInfo] * + * Updates + * - 01/04/2020: Added API requirement + * * @author Patches * @since 3.0 */ + @RequiresApi(Build.VERSION_CODES.LOLLIPOP) fun getFrequency(network: WifiInfo?, callbacks: GetFrequencyCallbacks?) /** @@ -633,9 +744,14 @@ interface FrequencyApi { * @see [WiseFy.isNetwork5gHz] * @see [getFrequency] * + * Updates + * - 01/04/2020: Refined permissions and added API requirement + * * @author Patches * @since 3.0 */ + @RequiresApi(Build.VERSION_CODES.LOLLIPOP) + @RequiresPermission(ACCESS_FINE_LOCATION) fun isNetwork5gHz(): Boolean /** @@ -648,9 +764,13 @@ interface FrequencyApi { * @see [WiseFy.isNetwork5gHz] * @see [WifiInfo] * + * Updates + * - 01/04/2020: Added API requirement + * * @author Patches * @since 3.0 */ + @RequiresApi(Build.VERSION_CODES.LOLLIPOP) fun isNetwork5gHz(network: WifiInfo?): Boolean } @@ -734,9 +854,13 @@ interface NetworkInfoApi { * @see [WiseFy.getIP] * @see [GetIPCallbacks] * + * Updates + * - 01/04/2020: Refined permissions + * * @author Patches * @since 3.0 */ + @RequiresPermission(ACCESS_FINE_LOCATION) fun getIP(callbacks: GetIPCallbacks?) } @@ -757,9 +881,13 @@ interface RemoveNetworkApi { * * @see [WiseFy.removeNetwork] * + * Updates + * - 01/04/2020: Refined permissions + * * @author Patches * @since 3.0 */ + @RequiresPermission(ACCESS_FINE_LOCATION) fun removeNetwork(ssidToRemove: String?): Boolean /** @@ -771,9 +899,13 @@ interface RemoveNetworkApi { * @see [WiseFy.removeNetwork] * @see [RemoveNetworkCallbacks] * + * Updates + * - 01/04/2020: Refined permissions + * * @author Patches * @since 3.0 */ + @RequiresPermission(ACCESS_FINE_LOCATION) fun removeNetwork(ssidToRemove: String?, callbacks: RemoveNetworkCallbacks?) } @@ -793,9 +925,13 @@ interface SavedNetworkApi { * @see [WiseFy.getSavedNetworks] * @see [WifiConfiguration] * + * Updates + * - 01/04/2020: Refined permissions + * * @author Patches * @since 3.0 */ + @RequiresPermission(ACCESS_FINE_LOCATION) fun getSavedNetworks(): List? /** @@ -806,9 +942,13 @@ interface SavedNetworkApi { * @see [WiseFy.getSavedNetworks] * @see [GetSavedNetworksCallbacks] * + * Updates + * - 01/04/2020: Refined permissions + * * @author Patches * @since 3.0 */ + @RequiresPermission(ACCESS_FINE_LOCATION) fun getSavedNetworks(callbacks: GetSavedNetworksCallbacks?) /** @@ -820,9 +960,13 @@ interface SavedNetworkApi { * * @see [WiseFy.isNetworkSaved] * + * Updates + * - 01/04/2020: Refined permissions + * * @author Patches * @since 3.0 */ + @RequiresPermission(ACCESS_FINE_LOCATION) fun isNetworkSaved(ssid: String?): Boolean /** @@ -835,9 +979,13 @@ interface SavedNetworkApi { * @see [WiseFy.searchForSavedNetwork] * @see [WifiConfiguration] * + * Updates + * - 01/04/2020: Refined permissions + * * @author Patches * @since 3.0 */ + @RequiresPermission(ACCESS_FINE_LOCATION) fun searchForSavedNetwork(regexForSSID: String?): WifiConfiguration? /** @@ -849,9 +997,13 @@ interface SavedNetworkApi { * @see [WiseFy.searchForSavedNetwork] * @see [SearchForSavedNetworkCallbacks] * + * Updates + * - 01/04/2020: Refined permissions + * * @author Patches * @since 3.0 */ + @RequiresPermission(ACCESS_FINE_LOCATION) fun searchForSavedNetwork(regexForSSID: String?, callbacks: SearchForSavedNetworkCallbacks?) /** @@ -864,9 +1016,13 @@ interface SavedNetworkApi { * @see [WiseFy.searchForSavedNetworks] * @see [WifiConfiguration] * + * Updates + * - 01/04/2020: Refined permissions + * * @author Patches * @since 3.0 */ + @RequiresPermission(ACCESS_FINE_LOCATION) fun searchForSavedNetworks(regexForSSID: String?): List? /** @@ -878,9 +1034,13 @@ interface SavedNetworkApi { * @see [WiseFy.searchForSavedNetworks] * @see [SearchForSavedNetworksCallbacks] * + * Updates + * - 01/04/2020: Refined permissions + * * @author Patches * @since 3.0 */ + @RequiresPermission(ACCESS_FINE_LOCATION) fun searchForSavedNetworks(regexForSSID: String?, callbacks: SearchForSavedNetworksCallbacks?) } diff --git a/wisefy/src/main/java/com/isupatches/wisefy/callbacks/AddNetworkCallbacks.kt b/wisefy/src/main/java/com/isupatches/wisefy/callbacks/AddNetworkCallbacks.kt index c7a31d83..702594f5 100644 --- a/wisefy/src/main/java/com/isupatches/wisefy/callbacks/AddNetworkCallbacks.kt +++ b/wisefy/src/main/java/com/isupatches/wisefy/callbacks/AddNetworkCallbacks.kt @@ -33,6 +33,8 @@ interface AddNetworkCallbacks : BaseCallback { /** * Called when [android.net.wifi.WifiManager] encounters an error adding a network. * + * @param wifiManagerReturn The return code from WifiManager when failing to add a network + * * @see [android.net.wifi.WifiManager] * @see [com.isupatches.wisefy.WiseFy.WIFI_MANAGER_FAILURE] * @@ -44,6 +46,9 @@ interface AddNetworkCallbacks : BaseCallback { /** * Called upon successfully adding a network. * + * @param newNetworkId The id of the network that was added + * @param networkConfig The configuration of the network that was added + * * @see [android.net.wifi.WifiConfiguration] * * @author Patches diff --git a/wisefy/src/main/java/com/isupatches/wisefy/callbacks/BaseCallback.kt b/wisefy/src/main/java/com/isupatches/wisefy/callbacks/BaseCallback.kt index c516161e..ad2a896e 100644 --- a/wisefy/src/main/java/com/isupatches/wisefy/callbacks/BaseCallback.kt +++ b/wisefy/src/main/java/com/isupatches/wisefy/callbacks/BaseCallback.kt @@ -32,6 +32,8 @@ interface BaseCallback { * * Example: A null or empty ssid is passed in but is a required parameter. * + * @param wisefyFailureCode The failure code defined by the WiseFy library + * * @see [com.isupatches.wisefy.WiseFyPrechecks] * @see [com.isupatches.wisefy.constants.WiseFyCode] * diff --git a/wisefy/src/main/java/com/isupatches/wisefy/callbacks/ConnectToNetworkCallbacks.kt b/wisefy/src/main/java/com/isupatches/wisefy/callbacks/ConnectToNetworkCallbacks.kt index 24a231cf..962217b1 100644 --- a/wisefy/src/main/java/com/isupatches/wisefy/callbacks/ConnectToNetworkCallbacks.kt +++ b/wisefy/src/main/java/com/isupatches/wisefy/callbacks/ConnectToNetworkCallbacks.kt @@ -18,6 +18,7 @@ package com.isupatches.wisefy.callbacks /** * Callbacks for attempting to connect to a network. * + * @see [BaseCallback] * @see [com.isupatches.wisefy.WiseFy.connectToNetwork] * * @author Patches diff --git a/wisefy/src/main/java/com/isupatches/wisefy/callbacks/GetCurrentNetworkCallbacks.kt b/wisefy/src/main/java/com/isupatches/wisefy/callbacks/GetCurrentNetworkCallbacks.kt index e52dbe96..dd90e28d 100644 --- a/wisefy/src/main/java/com/isupatches/wisefy/callbacks/GetCurrentNetworkCallbacks.kt +++ b/wisefy/src/main/java/com/isupatches/wisefy/callbacks/GetCurrentNetworkCallbacks.kt @@ -42,6 +42,8 @@ interface GetCurrentNetworkCallbacks : BaseCallback { /** * Called when WiseFy has successfully retrieved the device's current network. * + * @param currentNetwork The device's current network + * * @see [WifiInfo] * * @author Patches diff --git a/wisefy/src/main/java/com/isupatches/wisefy/callbacks/GetCurrentNetworkInfoCallbacks.kt b/wisefy/src/main/java/com/isupatches/wisefy/callbacks/GetCurrentNetworkInfoCallbacks.kt index e95adc83..eae26fe0 100644 --- a/wisefy/src/main/java/com/isupatches/wisefy/callbacks/GetCurrentNetworkInfoCallbacks.kt +++ b/wisefy/src/main/java/com/isupatches/wisefy/callbacks/GetCurrentNetworkInfoCallbacks.kt @@ -42,6 +42,8 @@ interface GetCurrentNetworkInfoCallbacks : BaseCallback { /** * Called when WiseFy has successfully retrieved the device's current network info. * + * @param currentNetworkInfo The information about the device's current network + * * @see [NetworkInfo] * * @author Patches diff --git a/wisefy/src/main/java/com/isupatches/wisefy/callbacks/GetFrequencyCallbacks.kt b/wisefy/src/main/java/com/isupatches/wisefy/callbacks/GetFrequencyCallbacks.kt index 1b2ed742..6c3239b2 100644 --- a/wisefy/src/main/java/com/isupatches/wisefy/callbacks/GetFrequencyCallbacks.kt +++ b/wisefy/src/main/java/com/isupatches/wisefy/callbacks/GetFrequencyCallbacks.kt @@ -29,7 +29,7 @@ interface GetFrequencyCallbacks : BaseCallback { /** * Called when there is an issue retrieving the frequency of a network. * - * i.e. Unable to retrieve current network or no current network + * f.e. Unable to retrieve current network or no current network * * @author Patches * @since 3.0 @@ -39,6 +39,8 @@ interface GetFrequencyCallbacks : BaseCallback { /** * Called when WiseFy has successfully retrieved the frequency of a network. * + * @param frequency The frequency of the network (either the current one or one that is passed in) + * * @author Patches * @since 3.0 */ diff --git a/wisefy/src/main/java/com/isupatches/wisefy/callbacks/GetIPCallbacks.kt b/wisefy/src/main/java/com/isupatches/wisefy/callbacks/GetIPCallbacks.kt index cbfdde62..aa8c4ac7 100644 --- a/wisefy/src/main/java/com/isupatches/wisefy/callbacks/GetIPCallbacks.kt +++ b/wisefy/src/main/java/com/isupatches/wisefy/callbacks/GetIPCallbacks.kt @@ -29,7 +29,7 @@ interface GetIPCallbacks : BaseCallback { /** * Called when there is an issue retrieving the IP of a device. * - * i.e. No current IP for the device, bad formatting, etc. + * f.e. No current IP for the device, bad formatting, etc. * * @author Patches * @since 3.0 @@ -39,6 +39,8 @@ interface GetIPCallbacks : BaseCallback { /** * Called when WiseFy has successfully retrieved the IP of a device. * + * @param ip The ip of the device + * * @author Patches * @since 3.0 */ diff --git a/wisefy/src/main/java/com/isupatches/wisefy/callbacks/GetNearbyAccessPointsCallbacks.kt b/wisefy/src/main/java/com/isupatches/wisefy/callbacks/GetNearbyAccessPointsCallbacks.kt index 2d5fee76..f6b3e845 100644 --- a/wisefy/src/main/java/com/isupatches/wisefy/callbacks/GetNearbyAccessPointsCallbacks.kt +++ b/wisefy/src/main/java/com/isupatches/wisefy/callbacks/GetNearbyAccessPointsCallbacks.kt @@ -34,6 +34,8 @@ interface GetNearbyAccessPointsCallbacks : BaseCallback { /** * Called when WiseFy has successfully retrieved a list of nearby access points. * + * @param nearbyAccessPoints The list of nearby access points + * * @see [ScanResult] * * @author Patches diff --git a/wisefy/src/main/java/com/isupatches/wisefy/callbacks/GetRSSICallbacks.kt b/wisefy/src/main/java/com/isupatches/wisefy/callbacks/GetRSSICallbacks.kt index 3b395f5b..68360cb9 100644 --- a/wisefy/src/main/java/com/isupatches/wisefy/callbacks/GetRSSICallbacks.kt +++ b/wisefy/src/main/java/com/isupatches/wisefy/callbacks/GetRSSICallbacks.kt @@ -29,6 +29,8 @@ interface GetRSSICallbacks : BaseCallback { /** * Called when WiseFy has successfully retrieved the RSSI level of a network. * + * @param rssi The RSSI of the network (either the current one or one that is passed in) + * * @author Patches * @since 3.0 */ diff --git a/wisefy/src/main/java/com/isupatches/wisefy/callbacks/GetSavedNetworksCallbacks.kt b/wisefy/src/main/java/com/isupatches/wisefy/callbacks/GetSavedNetworksCallbacks.kt index 08fc133c..23bb61c2 100644 --- a/wisefy/src/main/java/com/isupatches/wisefy/callbacks/GetSavedNetworksCallbacks.kt +++ b/wisefy/src/main/java/com/isupatches/wisefy/callbacks/GetSavedNetworksCallbacks.kt @@ -39,6 +39,8 @@ interface GetSavedNetworksCallbacks : BaseCallback { /** * Called when WiseFy has successfully retrieved a list of saved networks. * + * @param savedNetworks The list of saved networks found + * * @see [WifiConfiguration] * * @author Patches diff --git a/wisefy/src/main/java/com/isupatches/wisefy/callbacks/SearchForAccessPointCallbacks.kt b/wisefy/src/main/java/com/isupatches/wisefy/callbacks/SearchForAccessPointCallbacks.kt index bc7dc590..0eef0513 100644 --- a/wisefy/src/main/java/com/isupatches/wisefy/callbacks/SearchForAccessPointCallbacks.kt +++ b/wisefy/src/main/java/com/isupatches/wisefy/callbacks/SearchForAccessPointCallbacks.kt @@ -31,6 +31,8 @@ interface SearchForAccessPointCallbacks : BaseCallback { /** * Called when WiseFy has successfully found a matching access point. * + * @param accessPoint The found access point + * * @see [ScanResult] * * @author Patches diff --git a/wisefy/src/main/java/com/isupatches/wisefy/callbacks/SearchForAccessPointsCallbacks.kt b/wisefy/src/main/java/com/isupatches/wisefy/callbacks/SearchForAccessPointsCallbacks.kt index c568643e..7f90f064 100644 --- a/wisefy/src/main/java/com/isupatches/wisefy/callbacks/SearchForAccessPointsCallbacks.kt +++ b/wisefy/src/main/java/com/isupatches/wisefy/callbacks/SearchForAccessPointsCallbacks.kt @@ -31,6 +31,8 @@ interface SearchForAccessPointsCallbacks : BaseCallback { /** * Called when WiseFy has successfully found matching access points. * + * @param accessPoints The list of found access points + * * @see ScanResult * * @author Patches diff --git a/wisefy/src/main/java/com/isupatches/wisefy/callbacks/SearchForSSIDCallbacks.kt b/wisefy/src/main/java/com/isupatches/wisefy/callbacks/SearchForSSIDCallbacks.kt index c12cfb1c..f56af22b 100644 --- a/wisefy/src/main/java/com/isupatches/wisefy/callbacks/SearchForSSIDCallbacks.kt +++ b/wisefy/src/main/java/com/isupatches/wisefy/callbacks/SearchForSSIDCallbacks.kt @@ -29,6 +29,8 @@ interface SearchForSSIDCallbacks : BaseCallback { /** * Called when WiseFy has successfully found an access point with a matching SSID. * + * @param ssid The found SSID + * * @author Patches * @since 3.0 */ diff --git a/wisefy/src/main/java/com/isupatches/wisefy/callbacks/SearchForSSIDsCallbacks.kt b/wisefy/src/main/java/com/isupatches/wisefy/callbacks/SearchForSSIDsCallbacks.kt index 5ebc8430..141d2bd6 100644 --- a/wisefy/src/main/java/com/isupatches/wisefy/callbacks/SearchForSSIDsCallbacks.kt +++ b/wisefy/src/main/java/com/isupatches/wisefy/callbacks/SearchForSSIDsCallbacks.kt @@ -29,6 +29,8 @@ interface SearchForSSIDsCallbacks : BaseCallback { /** * Called when WiseFy has successfully found access points with a matching SSID. * + * @param ssids The list of found SSIDs + * * @author Patches * @since 3.0 */ diff --git a/wisefy/src/main/java/com/isupatches/wisefy/callbacks/SearchForSavedNetworkCallbacks.kt b/wisefy/src/main/java/com/isupatches/wisefy/callbacks/SearchForSavedNetworkCallbacks.kt index 1336d6e9..933b2be9 100644 --- a/wisefy/src/main/java/com/isupatches/wisefy/callbacks/SearchForSavedNetworkCallbacks.kt +++ b/wisefy/src/main/java/com/isupatches/wisefy/callbacks/SearchForSavedNetworkCallbacks.kt @@ -39,6 +39,8 @@ interface SearchForSavedNetworkCallbacks : BaseCallback { /** * Called when WiseFy has successfully retrieved a matching saved network configuration. * + * @param savedNetwork The found saved network + * * @see [WifiConfiguration] * * @author Patches diff --git a/wisefy/src/main/java/com/isupatches/wisefy/callbacks/SearchForSavedNetworksCallbacks.kt b/wisefy/src/main/java/com/isupatches/wisefy/callbacks/SearchForSavedNetworksCallbacks.kt index 266e707d..76ad698c 100644 --- a/wisefy/src/main/java/com/isupatches/wisefy/callbacks/SearchForSavedNetworksCallbacks.kt +++ b/wisefy/src/main/java/com/isupatches/wisefy/callbacks/SearchForSavedNetworksCallbacks.kt @@ -41,6 +41,8 @@ interface SearchForSavedNetworksCallbacks : BaseCallback { * Called when WiseFy has successfully retrieved a list of saved networks matching * the given search criteria. * + * @param savedNetworks The list of found saved networks + * * @see [WifiConfiguration] * * @author Patches diff --git a/wisefy/src/main/java/com/isupatches/wisefy/connection/AbstractWiseFyConnection.kt b/wisefy/src/main/java/com/isupatches/wisefy/connection/AbstractWiseFyConnection.kt index a96346b6..fc92ee14 100644 --- a/wisefy/src/main/java/com/isupatches/wisefy/connection/AbstractWiseFyConnection.kt +++ b/wisefy/src/main/java/com/isupatches/wisefy/connection/AbstractWiseFyConnection.kt @@ -15,11 +15,7 @@ */ package com.isupatches.wisefy.connection -import android.Manifest.permission.ACCESS_NETWORK_STATE -import android.Manifest.permission.ACCESS_WIFI_STATE import android.net.wifi.WifiManager -import androidx.annotation.RequiresPermission - import com.isupatches.wisefy.annotations.WaitsForTimeout import com.isupatches.wisefy.constants.QUOTE import com.isupatches.wisefy.logging.WiseFyLogger @@ -60,7 +56,6 @@ internal abstract class AbstractWiseFyConnection( * @author Patches * @since 3.0 */ - @RequiresPermission(allOf = [ACCESS_NETWORK_STATE, ACCESS_WIFI_STATE]) override fun isCurrentNetworkConnectedToSSID(ssid: String?): Boolean { if (ssid.isNullOrEmpty()) { return false @@ -92,14 +87,19 @@ internal abstract class AbstractWiseFyConnection( * * Updates * - 05/12/2019: Moved here from previous WiseFyConnectionImpl class + * - 01/04/2020: Formatting update * * @author Patches * @since 3.0 */ @WaitsForTimeout - @RequiresPermission(allOf = [ACCESS_NETWORK_STATE, ACCESS_WIFI_STATE]) override fun waitToConnectToSSID(ssid: String?, timeoutInMillis: Int): Boolean { - WiseFyLogger.debug(TAG, "Waiting %d milliseconds to connect to network with ssid %s", timeoutInMillis, ssid ?: "") + WiseFyLogger.debug( + TAG, + "Waiting %d milliseconds to connect to network with ssid %s", + timeoutInMillis, + ssid ?: "" + ) var currentTime: Long val endTime = System.currentTimeMillis() + timeoutInMillis do { diff --git a/wisefy/src/main/java/com/isupatches/wisefy/connection/WiseFyConnectionLegacy.kt b/wisefy/src/main/java/com/isupatches/wisefy/connection/WiseFyConnectionLegacy.kt index 46cac95e..24567b3c 100644 --- a/wisefy/src/main/java/com/isupatches/wisefy/connection/WiseFyConnectionLegacy.kt +++ b/wisefy/src/main/java/com/isupatches/wisefy/connection/WiseFyConnectionLegacy.kt @@ -18,7 +18,6 @@ package com.isupatches.wisefy.connection import android.net.ConnectivityManager import android.net.NetworkInfo import android.net.wifi.WifiManager - import com.isupatches.wisefy.constants.MOBILE import com.isupatches.wisefy.constants.NetworkType import com.isupatches.wisefy.constants.WIFI @@ -44,8 +43,25 @@ internal class WiseFyConnectionLegacy private constructor( internal companion object { private val TAG = WiseFyConnectionLegacy::class.java.simpleName - fun create(connectivityManager: ConnectivityManager, wifiManager: WifiManager): WiseFyConnection = - WiseFyConnectionLegacy(connectivityManager, wifiManager) + /** + * Used internally to create an instance of a legacy WiseFyConnection. + * + * @param connectivityManager The instance of ConnectivityManager to use + * @param wifiManager The instance of WifiManager to use + * + * @return WiseFyConnectionLegacy + * + * @see [WiseFyConnection] + * + * Updates + * - 01/04/2020: Formatting update + * + * @author Patches + * @since 4.0 + */ + fun create(connectivityManager: ConnectivityManager, wifiManager: WifiManager): WiseFyConnection { + return WiseFyConnectionLegacy(connectivityManager, wifiManager) + } } /** @@ -69,7 +85,7 @@ internal class WiseFyConnectionLegacy private constructor( } /** - * Used internally to check if a network is connected to a mobile network (i.e. non-Wifi) + * Used internally to check if a network is connected to a mobile network (f.e. non-Wifi) * * @return boolean - True if the device is using a mobile network, false otherwise * @@ -80,11 +96,12 @@ internal class WiseFyConnectionLegacy private constructor( * @author Patches * @since 4.0 */ - override fun isDeviceConnectedToMobileNetwork(): Boolean = - isNetworkConnectedAndMatchesType(connectivityManager.activeNetworkInfo, MOBILE) + override fun isDeviceConnectedToMobileNetwork(): Boolean { + return isNetworkConnectedAndMatchesType(connectivityManager.activeNetworkInfo, MOBILE) + } /** - * Used internally to check if a network is connected to a wifi network (i.e. not using + * Used internally to check if a network is connected to a wifi network (f.e. not using * mobile data) * * @return boolean - True if the device is using a wifi network, false otherwise @@ -93,11 +110,15 @@ internal class WiseFyConnectionLegacy private constructor( * @see [isNetworkConnectedAndMatchesType] * @see [WIFI] * + * Updates + * - 01/04/2020: Formatting update + * * @author Patches * @since 4.0 */ - override fun isDeviceConnectedToWifiNetwork(): Boolean = - isNetworkConnectedAndMatchesType(connectivityManager.activeNetworkInfo, WIFI) + override fun isDeviceConnectedToWifiNetwork(): Boolean { + return isNetworkConnectedAndMatchesType(connectivityManager.activeNetworkInfo, WIFI) + } /** * Used internally to check if a network is in a roaming state. @@ -141,7 +162,7 @@ internal class WiseFyConnectionLegacy private constructor( * *NOTE* Case insensitive * * @param networkInfo The network to check - * @param type The type of network + * @param type The type of network (f.e. Mobile or Wifi) * * @return boolean - True if the network matches the given type * @@ -150,18 +171,20 @@ internal class WiseFyConnectionLegacy private constructor( * * Updates * - 05/12/2019: Made networkInfo expectation non-null + * - 01/04/2020: Formatting update * * @author Patches * @since 3.0 */ - private fun doesNetworkMatchType(networkInfo: NetworkInfo, @NetworkType type: String): Boolean = - type.equals(networkInfo.typeName, ignoreCase = true) + private fun doesNetworkMatchType(networkInfo: NetworkInfo, @NetworkType type: String): Boolean { + return type.equals(networkInfo.typeName, ignoreCase = true) + } /** * Used internally to check if a given network matches a given type and is connected. * * @param networkInfo The network to check - * @param type The type of network (i.error. Mobile or Wifi) + * @param type The type of network (f.e. Mobile or Wifi) * * @return boolean - True if the network is both connected and matches the given type of network * @@ -171,12 +194,14 @@ internal class WiseFyConnectionLegacy private constructor( * * Updates * - 05/12/2019: Switched to using [isConnectedAndAvailable] over [isNetworkConnected] + * - 01/04/2020: Formatting update * * @author Patches * @since 3.0 */ - private fun isNetworkConnectedAndMatchesType(networkInfo: NetworkInfo?, @NetworkType type: String): Boolean = - networkInfo?.let { doesNetworkMatchType(it, type) && it.isConnectedAndAvailable() } ?: false + private fun isNetworkConnectedAndMatchesType(networkInfo: NetworkInfo?, @NetworkType type: String): Boolean { + return networkInfo?.let { doesNetworkMatchType(it, type) && it.isConnectedAndAvailable() } ?: false + } /** * Used within legacy class to determine if a given network is in a connected state. diff --git a/wisefy/src/main/java/com/isupatches/wisefy/connection/WiseFyConnectionSDK23.kt b/wisefy/src/main/java/com/isupatches/wisefy/connection/WiseFyConnectionSDK23.kt index 439a7b7e..f52cf7e0 100644 --- a/wisefy/src/main/java/com/isupatches/wisefy/connection/WiseFyConnectionSDK23.kt +++ b/wisefy/src/main/java/com/isupatches/wisefy/connection/WiseFyConnectionSDK23.kt @@ -25,7 +25,6 @@ import android.net.wifi.WifiManager import android.os.Build import androidx.annotation.RequiresApi import androidx.annotation.VisibleForTesting - import com.isupatches.wisefy.logging.WiseFyLogger /** @@ -50,14 +49,32 @@ internal class WiseFyConnectionSDK23 private constructor( // Internal to avoid SyntheticAccessor error within networkChangeCallback internal val TAG = WiseFyConnectionSDK23::class.java.simpleName - fun create(connectivityManager: ConnectivityManager, wifiManager: WifiManager): WiseFyConnection = - WiseFyConnectionSDK23(connectivityManager, wifiManager) + /** + * Used internally to create an instance of a WiseFyConnection for SDK 23. + * + * @param connectivityManager The instance of ConnectivityManager to use + * @param wifiManager The instance of WifiManager to use + * + * @return WiseFyConnectionSDK23 + * + * @see [WiseFyConnection] + * + * Updates + * - 01/04/2020: Formatting update + * + * @author Patches + * @since 4.0 + */ + fun create(connectivityManager: ConnectivityManager, wifiManager: WifiManager): WiseFyConnection { + return WiseFyConnectionSDK23(connectivityManager, wifiManager) + } } // Internal to avoid SyntheticAccessor error within networkChangeCallback internal var connectionStatus: WiseFyConnectionStatus? = null - @VisibleForTesting internal val networkChangeCallbacks by lazy { + @VisibleForTesting + internal val networkChangeCallbacks by lazy { object : ConnectivityManager.NetworkCallback() { override fun onAvailable(network: Network?) { super.onAvailable(network) @@ -67,7 +84,10 @@ internal class WiseFyConnectionSDK23 private constructor( override fun onCapabilitiesChanged(network: Network?, networkCapabilities: NetworkCapabilities?) { super.onCapabilitiesChanged(network, networkCapabilities) - WiseFyLogger.debug(TAG, "onCapabilitiesChanged, network: $network, networkCapabilities: $networkCapabilities") + WiseFyLogger.debug( + TAG, + "onCapabilitiesChanged, network: $network, networkCapabilities: $networkCapabilities" + ) } override fun onLinkPropertiesChanged(network: Network?, linkProperties: LinkProperties?) { @@ -120,7 +140,7 @@ internal class WiseFyConnectionSDK23 private constructor( } /** - * Used internally to check if a network is connected to a mobile network (i.e. non-Wifi) + * Used internally to check if a network is connected to a mobile network (f.e. non-Wifi) * * @return boolean - True if the device is using a mobile network, false otherwise * @@ -128,16 +148,20 @@ internal class WiseFyConnectionSDK23 private constructor( * @see [isNetworkConnected] * @see [NetworkCapabilities.TRANSPORT_CELLULAR] * + * Updates + * - 01/05/2020: Formatting update + * * @author Patches * @since 4.0 */ - override fun isDeviceConnectedToMobileNetwork(): Boolean = - doesNetworkHaveTransportTypeAndInternetCapability( + override fun isDeviceConnectedToMobileNetwork(): Boolean { + return doesNetworkHaveTransportTypeAndInternetCapability( transportType = NetworkCapabilities.TRANSPORT_CELLULAR ) && isNetworkConnected() + } /** - * Used internally to check if a network is connected to a wifi network (i.e. not using + * Used internally to check if a network is connected to a wifi network (f.e. not using * mobile data) * * @return boolean - True if the device is using a wifi network, false otherwise @@ -146,13 +170,17 @@ internal class WiseFyConnectionSDK23 private constructor( * @see [isNetworkConnected] * @see [NetworkCapabilities.TRANSPORT_WIFI] * + * Updates + * - 01/05/2020: Formatting update + * * @author Patches * @since 4.0 */ - override fun isDeviceConnectedToWifiNetwork(): Boolean = - doesNetworkHaveTransportTypeAndInternetCapability( + override fun isDeviceConnectedToWifiNetwork(): Boolean { + return doesNetworkHaveTransportTypeAndInternetCapability( transportType = NetworkCapabilities.TRANSPORT_WIFI ) && isNetworkConnected() + } /** * Used internally to check if a network is in a roaming state. @@ -165,18 +193,22 @@ internal class WiseFyConnectionSDK23 private constructor( * @see [ConnectivityManager.getActiveNetworkInfo] * @see [NetworkInfo.isRoaming] * + * Updates + * - 01/05/2020: Formatting update + * * @author Patches * @since 4.0 */ - override fun isDeviceRoaming(): Boolean = - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) { + override fun isDeviceRoaming(): Boolean { + return if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) { // NET_CAPABILITY_NOT_ROAMING only available for P and above devices :'( !doesNetworkHaveCapability(capability = NetworkCapabilities.NET_CAPABILITY_NOT_ROAMING) } else { val networkInfo = connectivityManager.activeNetworkInfo - @Suppress("DEPRECATION") + @Suppress("deprecation") networkInfo != null && networkInfo.isRoaming } + } /** * Used internally to check if a network is connected. @@ -196,32 +228,44 @@ internal class WiseFyConnectionSDK23 private constructor( * Used internally to check if the active network has a certain transport type as well as * internet capability. * + * @param transportType The transport capability to check and see if the current network has + * * @see [getActiveNetworkCapabilities] * @see [NetworkCapabilities.hasTransport] * @see [NetworkCapabilities.hasCapability] * @see [NetworkCapabilities.NET_CAPABILITY_INTERNET] * + * Updates + * - 01/05/2020: Formatting update + * * @author Patches * @since 4.0 */ - private fun doesNetworkHaveTransportTypeAndInternetCapability(transportType: Int): Boolean = - getActiveNetworkCapabilities()?.let { - it.hasTransport(transportType) && - it.hasCapability(NetworkCapabilities.NET_CAPABILITY_INTERNET) + private fun doesNetworkHaveTransportTypeAndInternetCapability(transportType: Int): Boolean { + return getActiveNetworkCapabilities()?.let { + it.hasTransport(transportType) && it.hasCapability(NetworkCapabilities.NET_CAPABILITY_INTERNET) } ?: false + } /** - * Used internally to check if the active network has a certain capability (i.e. to check if the + * Used internally to check if the active network has a certain capability (f.e. to check if the * device has [NetworkCapabilities.NET_CAPABILITY_NOT_ROAMING] capability listed) * + * @param capability The capability to check and see if the current network has + * * @see [getActiveNetworkCapabilities] * @see [NetworkCapabilities.hasCapability] + * @see NetworkCapabilities + * + * Updates + * - 01/04/2020: Formatting update * * @author Patches * @since 4.0 */ - private fun doesNetworkHaveCapability(capability: Int): Boolean = - getActiveNetworkCapabilities()?.hasCapability(capability) ?: false + private fun doesNetworkHaveCapability(capability: Int): Boolean { + return getActiveNetworkCapabilities()?.hasCapability(capability) ?: false + } /** * Used internally to return the capabilities of the active network. @@ -230,15 +274,22 @@ internal class WiseFyConnectionSDK23 private constructor( * @see [ConnectivityManager.getNetworkCapabilities] * @see [ConnectivityManager.getActiveNetwork] * + * Updates + * - 01/04/2020: Formatting update + * * @author Patches * @since 4.0 */ - private fun getActiveNetworkCapabilities(): NetworkCapabilities? = - connectivityManager.getNetworkCapabilities(connectivityManager.activeNetwork) + private fun getActiveNetworkCapabilities(): NetworkCapabilities? { + return connectivityManager.getNetworkCapabilities(connectivityManager.activeNetwork) + } /** * Used internally to start listening for network changes * + * @param connectivityManager The connectivity manager instance to use to listen for network + * callbacks + * * @see [ConnectivityManager.registerNetworkCallback] * @see [NetworkRequest.Builder] * @see [networkChangeCallbacks] @@ -254,6 +305,9 @@ internal class WiseFyConnectionSDK23 private constructor( /** * Used internally to stop listening for network changes * + * @param connectivityManager The connectivity manager instance to use to stop + * listening for networ callbacks + * * @see [ConnectivityManager.unregisterNetworkCallback] * @see [networkChangeCallbacks] * diff --git a/wisefy/src/main/java/com/isupatches/wisefy/constants/Capabilities.kt b/wisefy/src/main/java/com/isupatches/wisefy/constants/Capabilities.kt index ea1aa69d..9b9785ac 100644 --- a/wisefy/src/main/java/com/isupatches/wisefy/constants/Capabilities.kt +++ b/wisefy/src/main/java/com/isupatches/wisefy/constants/Capabilities.kt @@ -14,6 +14,7 @@ * limitations under the License. */ @file:JvmName("Capabilities") + package com.isupatches.wisefy.constants import androidx.annotation.StringDef diff --git a/wisefy/src/main/java/com/isupatches/wisefy/constants/NetworkTypes.kt b/wisefy/src/main/java/com/isupatches/wisefy/constants/NetworkTypes.kt index 817687ce..37b8c99a 100644 --- a/wisefy/src/main/java/com/isupatches/wisefy/constants/NetworkTypes.kt +++ b/wisefy/src/main/java/com/isupatches/wisefy/constants/NetworkTypes.kt @@ -14,6 +14,7 @@ * limitations under the License. */ @file:JvmName("NetworkTypes") + package com.isupatches.wisefy.constants import androidx.annotation.StringDef diff --git a/wisefy/src/main/java/com/isupatches/wisefy/constants/WiseFyCodes.kt b/wisefy/src/main/java/com/isupatches/wisefy/constants/WiseFyCodes.kt index d31460e4..438829d6 100644 --- a/wisefy/src/main/java/com/isupatches/wisefy/constants/WiseFyCodes.kt +++ b/wisefy/src/main/java/com/isupatches/wisefy/constants/WiseFyCodes.kt @@ -14,6 +14,7 @@ * limitations under the License. */ @file:JvmName("WiseFyCodes") + package com.isupatches.wisefy.constants import androidx.annotation.IntDef diff --git a/wisefy/src/main/java/com/isupatches/wisefy/search/AbstractWiseFySearch.kt b/wisefy/src/main/java/com/isupatches/wisefy/search/AbstractWiseFySearch.kt index c790c9be..0bad8ae2 100644 --- a/wisefy/src/main/java/com/isupatches/wisefy/search/AbstractWiseFySearch.kt +++ b/wisefy/src/main/java/com/isupatches/wisefy/search/AbstractWiseFySearch.kt @@ -15,16 +15,14 @@ */ package com.isupatches.wisefy.search -import android.Manifest.permission.ACCESS_WIFI_STATE +import android.Manifest.permission.ACCESS_FINE_LOCATION import android.net.wifi.ScanResult import android.net.wifi.WifiConfiguration import android.net.wifi.WifiManager import androidx.annotation.RequiresPermission - import com.isupatches.wisefy.constants.QUOTE import com.isupatches.wisefy.logging.WiseFyLogger import com.isupatches.wisefy.utils.rest - import java.util.Locale /** @@ -64,11 +62,12 @@ internal abstract class AbstractWiseFySearch( * * Updates * - 05/12/2019: Moved here from previous WiseFySearchImpl class + * - 01/04/2020: Refined permissions * * @author Patches * @since 3.0 */ - @RequiresPermission(ACCESS_WIFI_STATE) + @RequiresPermission(ACCESS_FINE_LOCATION) override fun findSavedNetworkByRegex(regexForSSID: String): WifiConfiguration? { val savedNetworks = wifiManager.configuredNetworks if (savedNetworks == null || savedNetworks.isEmpty()) { @@ -97,11 +96,12 @@ internal abstract class AbstractWiseFySearch( * * Updates * - 05/12/2019: Moved here from previous WiseFySearchImpl class + * - 01/04/2020: Refined permissions * * @author Patches * @since 3.0 */ - @RequiresPermission(ACCESS_WIFI_STATE) + @RequiresPermission(ACCESS_FINE_LOCATION) override fun findSavedNetworksMatchingRegex(regexForSSID: String): List? { val savedNetworks = wifiManager.configuredNetworks val matchingSavedNetworks = ArrayList() @@ -130,13 +130,14 @@ internal abstract class AbstractWiseFySearch( * * Updates * - 05/12/2019: Moved here from previous WiseFySearchImpl class + * - 01/04/2020: Refined permissions * * @author Patches * @since 3.0 */ - @RequiresPermission(ACCESS_WIFI_STATE) + @RequiresPermission(ACCESS_FINE_LOCATION) override fun isNetworkASavedConfiguration(ssid: String?): Boolean = - !ssid.isNullOrEmpty() && findSavedNetworkByRegex(ssid) != null + !ssid.isNullOrEmpty() && findSavedNetworkByRegex(ssid) != null /** * Used internally to wait for a given time and return the first ScanResult whose SSID matches a given regex. @@ -162,11 +163,12 @@ internal abstract class AbstractWiseFySearch( * * Moved here from previous WiseFySearchImpl class * * Fixed bad behavior with empty access point list * * Started using scanResultsProvider for various SDK level support + * - 01/04/2020: Refined permissions * * @author Patches * @since 3.0 */ - @RequiresPermission(ACCESS_WIFI_STATE) + @RequiresPermission(ACCESS_FINE_LOCATION) override fun findAccessPointByRegex( regexForSSID: String, timeoutInMillis: Int, @@ -187,7 +189,7 @@ internal abstract class AbstractWiseFySearch( for (accessPoint in accessPointsTemp) { if (takeHighest) { if (accessPointMatchesRegex(accessPoint, regexForSSID) && - hasHighestSignalStrength(accessPointsTemp, accessPoint) + hasHighestSignalStrength(accessPointsTemp, accessPoint) ) { accessPointToReturn = accessPoint // Need to continue through rest of the list since @@ -233,11 +235,12 @@ internal abstract class AbstractWiseFySearch( * - 05/12/2019 * * Moved here from previous WiseFySearchImpl class * * Started using scanResultsProvider for various SDK level support + * - 01/04/2020: Refined permissions * * @author Patches * @since 3.0 */ - @RequiresPermission(ACCESS_WIFI_STATE) + @RequiresPermission(ACCESS_FINE_LOCATION) override fun findAccessPointsMatchingRegex( regexForSSID: String, takeHighest: Boolean @@ -280,11 +283,12 @@ internal abstract class AbstractWiseFySearch( * - 05/12/2019 * * Moved here from previous WiseFySearchImpl class * * Started using scanResultsProvider for various SDK level support + * - 01/04/2020: Refined permissions * * @author Patches * @since 3.0 */ - @RequiresPermission(ACCESS_WIFI_STATE) + @RequiresPermission(ACCESS_FINE_LOCATION) override fun findSSIDsMatchingRegex( regexForSSID: String ): List? { @@ -312,10 +316,13 @@ internal abstract class AbstractWiseFySearch( * @see [ScanResult] * @see [removeEntriesWithLowerSignalStrength] * + * Updates + * - 01/04/2020: Refined permissions + * * @author Patches * @since 4.0 */ - @RequiresPermission(ACCESS_WIFI_STATE) + @RequiresPermission(ACCESS_FINE_LOCATION) override fun getNearbyAccessPoints( filterDuplicates: Boolean ): List? { diff --git a/wisefy/src/main/java/com/isupatches/wisefy/search/WiseFySearch.kt b/wisefy/src/main/java/com/isupatches/wisefy/search/WiseFySearch.kt index d29bd5b5..796f6ecd 100644 --- a/wisefy/src/main/java/com/isupatches/wisefy/search/WiseFySearch.kt +++ b/wisefy/src/main/java/com/isupatches/wisefy/search/WiseFySearch.kt @@ -15,8 +15,10 @@ */ package com.isupatches.wisefy.search +import android.Manifest.permission.ACCESS_FINE_LOCATION import android.net.wifi.ScanResult import android.net.wifi.WifiConfiguration +import androidx.annotation.RequiresPermission /** * An interface that helps with searching. @@ -29,23 +31,31 @@ import android.net.wifi.WifiConfiguration * * Made more generic for pre and post SDK 23 classes * * Added getNearbyAccessPoints * * Removed removeEntriesWithLowerSignalStrength + * - 01/04/2020: Refined permissions * * @author Patches * @since 3.0 */ internal interface WiseFySearch { + @RequiresPermission(ACCESS_FINE_LOCATION) fun findAccessPointByRegex(regexForSSID: String, timeoutInMillis: Int, takeHighest: Boolean): ScanResult? + @RequiresPermission(ACCESS_FINE_LOCATION) fun findAccessPointsMatchingRegex(regexForSSID: String, takeHighest: Boolean): List? + @RequiresPermission(ACCESS_FINE_LOCATION) fun findSavedNetworkByRegex(regexForSSID: String): WifiConfiguration? + @RequiresPermission(ACCESS_FINE_LOCATION) fun findSavedNetworksMatchingRegex(regexForSSID: String): List? + @RequiresPermission(ACCESS_FINE_LOCATION) fun findSSIDsMatchingRegex(regexForSSID: String): List? + @RequiresPermission(ACCESS_FINE_LOCATION) fun getNearbyAccessPoints(filterDuplicates: Boolean): List? + @RequiresPermission(ACCESS_FINE_LOCATION) fun isNetworkASavedConfiguration(ssid: String?): Boolean } diff --git a/wisefy/src/main/java/com/isupatches/wisefy/search/WiseFySearchLegacy.kt b/wisefy/src/main/java/com/isupatches/wisefy/search/WiseFySearchLegacy.kt index 6d63894e..28b82e40 100644 --- a/wisefy/src/main/java/com/isupatches/wisefy/search/WiseFySearchLegacy.kt +++ b/wisefy/src/main/java/com/isupatches/wisefy/search/WiseFySearchLegacy.kt @@ -25,6 +25,9 @@ import android.net.wifi.WifiManager * @see [WifiManager] * @see [AbstractWiseFySearch] * + * Updates + * - 01/04/2020: Formatting update + * * @author Patches * @since 3.0 */ @@ -39,8 +42,10 @@ internal class WiseFySearchLegacy private constructor( // For SDK 23 and below, devices are still allowed to trigger a scan for nearby access points, // so we'll continue to do that to preserve previous behavior. - override val scanResultsProvider by lazy { { - wifiManager.startScan() - wifiManager.scanResults - } } + override val scanResultsProvider by lazy { + { + wifiManager.startScan() + wifiManager.scanResults + } + } } diff --git a/wisefy/src/main/java/com/isupatches/wisefy/utils/WifiConfigurationUtil.kt b/wisefy/src/main/java/com/isupatches/wisefy/utils/WifiConfigurationUtil.kt index 7339d3dd..740c61be 100644 --- a/wisefy/src/main/java/com/isupatches/wisefy/utils/WifiConfigurationUtil.kt +++ b/wisefy/src/main/java/com/isupatches/wisefy/utils/WifiConfigurationUtil.kt @@ -16,7 +16,6 @@ package com.isupatches.wisefy.utils import android.net.wifi.WifiConfiguration - import com.isupatches.wisefy.constants.QUOTE /** diff --git a/wisefy/src/test/java/com/isupatches/wisefy/main/PublicApiVisibilityTests.kt b/wisefy/src/test/java/com/isupatches/wisefy/main/PublicApiVisibilityTests.kt index 6becea91..aeacc17c 100644 --- a/wisefy/src/test/java/com/isupatches/wisefy/main/PublicApiVisibilityTests.kt +++ b/wisefy/src/test/java/com/isupatches/wisefy/main/PublicApiVisibilityTests.kt @@ -4,7 +4,6 @@ import android.net.NetworkInfo import android.net.wifi.ScanResult import android.net.wifi.WifiConfiguration import android.net.wifi.WifiInfo - import com.isupatches.wisefy.OPEN_NETWORK_SSID import com.isupatches.wisefy.TEST_DELAY import com.isupatches.wisefy.TEST_NUMBER_OF_BARS @@ -37,10 +36,8 @@ import com.isupatches.wisefy.callbacks.SearchForSSIDCallbacks import com.isupatches.wisefy.callbacks.SearchForSSIDsCallbacks import com.isupatches.wisefy.callbacks.SearchForSavedNetworkCallbacks import com.isupatches.wisefy.callbacks.SearchForSavedNetworksCallbacks - import org.junit.Assert.assertEquals import org.junit.Test - import org.mockito.ArgumentMatchers.any import org.mockito.ArgumentMatchers.anyBoolean import org.mockito.ArgumentMatchers.anyInt @@ -58,7 +55,8 @@ internal class PublicApiVisibilityTests { private val wisefy = mock(WiseFyPublicApi::class.java) - @Test fun addOpenNetwork_apis() { + @Test + fun addOpenNetwork_apis() { wisefy.addOpenNetwork(OPEN_NETWORK_SSID) verify(wisefy).addOpenNetwork(anyString()) wisefy.addOpenNetwork(OPEN_NETWORK_SSID, object : AddNetworkCallbacks { @@ -74,7 +72,9 @@ internal class PublicApiVisibilityTests { verify(wisefy).addOpenNetwork(anyString(), any(AddNetworkCallbacks::class.java)) } - @Test fun addWEPNetwork_apis() { + @Suppress("deprecation") + @Test + fun addWEPNetwork_apis() { wisefy.addWEPNetwork(WEP_NETWORK_SSID, WEP_NETWORK_PASSWORD) verify(wisefy).addWEPNetwork(anyString(), anyString()) wisefy.addWEPNetwork(WEP_NETWORK_SSID, WEP_NETWORK_PASSWORD, object : AddNetworkCallbacks { @@ -90,7 +90,8 @@ internal class PublicApiVisibilityTests { verify(wisefy).addWEPNetwork(anyString(), anyString(), any(AddNetworkCallbacks::class.java)) } - @Test fun addWPA2Network_apis() { + @Test + fun addWPA2Network_apis() { wisefy.addWPA2Network(WPA2_NETWORK_SSID, WPA2_NETWORK_PASSWORD) verify(wisefy).addWPA2Network(anyString(), anyString()) wisefy.addWPA2Network(WPA2_NETWORK_SSID, WPA2_NETWORK_PASSWORD, object : AddNetworkCallbacks { @@ -106,17 +107,20 @@ internal class PublicApiVisibilityTests { verify(wisefy).addWPA2Network(anyString(), anyString(), any(AddNetworkCallbacks::class.java)) } - @Test fun compareSignalLevel_api() { + @Test + fun compareSignalLevel_api() { wisefy.compareSignalLevel(TEST_RSSI_LEVEL_LOW, TEST_RSSI_LEVEL_HIGH) verify(wisefy).compareSignalLevel(anyInt(), anyInt()) } - @Test fun calculateBars_api() { + @Test + fun calculateBars_api() { wisefy.calculateBars(TEST_RSSI_LEVEL, TEST_NUMBER_OF_BARS) verify(wisefy).calculateBars(anyInt(), anyInt()) } - @Test fun connectToNetwork_apis() { + @Test + fun connectToNetwork_apis() { wisefy.connectToNetwork(TEST_SSID, TEST_DELAY) verify(wisefy).connectToNetwork(anyString(), anyInt()) wisefy.connectToNetwork(TEST_SSID, TEST_DELAY, object : ConnectToNetworkCallbacks { @@ -132,10 +136,15 @@ internal class PublicApiVisibilityTests { override fun networkNotFoundToConnectTo() { } }) - verify(wisefy).connectToNetwork(anyString(), anyInt(), any(ConnectToNetworkCallbacks::class.java)) + verify(wisefy).connectToNetwork( + anyString(), + anyInt(), + any(ConnectToNetworkCallbacks::class.java) + ) } - @Test fun disableWifi_apis() { + @Test + fun disableWifi_apis() { wisefy.disableWifi() verify(wisefy).disableWifi() wisefy.disableWifi(object : DisableWifiCallbacks { @@ -151,7 +160,8 @@ internal class PublicApiVisibilityTests { verify(wisefy).disableWifi(any(DisableWifiCallbacks::class.java)) } - @Test fun disconnectFromCurrentNetwork_apis() { + @Test + fun disconnectFromCurrentNetwork_apis() { wisefy.disconnectFromCurrentNetwork() verify(wisefy).disconnectFromCurrentNetwork() wisefy.disconnectFromCurrentNetwork(object : DisconnectFromCurrentNetworkCallbacks { @@ -164,10 +174,13 @@ internal class PublicApiVisibilityTests { override fun failureDisconnectingFromCurrentNetwork() { } }) - verify(wisefy).disconnectFromCurrentNetwork(any(DisconnectFromCurrentNetworkCallbacks::class.java)) + verify(wisefy).disconnectFromCurrentNetwork( + any(DisconnectFromCurrentNetworkCallbacks::class.java) + ) } - @Test fun enableWifi_apis() { + @Test + fun enableWifi_apis() { wisefy.enableWifi() verify(wisefy).enableWifi() wisefy.enableWifi(object : EnableWifiCallbacks { @@ -183,7 +196,8 @@ internal class PublicApiVisibilityTests { verify(wisefy).enableWifi(any(EnableWifiCallbacks::class.java)) } - @Test fun getCurrentNetwork_apis() { + @Test + fun getCurrentNetwork_apis() { wisefy.getCurrentNetwork() verify(wisefy).getCurrentNetwork() wisefy.getCurrentNetwork(object : GetCurrentNetworkCallbacks { @@ -199,14 +213,15 @@ internal class PublicApiVisibilityTests { verify(wisefy).getCurrentNetwork(any(GetCurrentNetworkCallbacks::class.java)) } - @Test fun getCurrentNetworkInfo_apis() { + @Test + fun getCurrentNetworkInfo_apis() { wisefy.getCurrentNetworkInfo() verify(wisefy).getCurrentNetworkInfo() wisefy.getCurrentNetworkInfo(object : GetCurrentNetworkInfoCallbacks { override fun noCurrentNetworkInfo() { } - override fun retrievedCurrentNetworkInfo(currentNetworkDetails: NetworkInfo) { + override fun retrievedCurrentNetworkInfo(currentNetworkInfo: NetworkInfo) { } override fun wisefyFailure(wisefyFailureCode: Int) { @@ -215,7 +230,8 @@ internal class PublicApiVisibilityTests { verify(wisefy).getCurrentNetworkInfo(any(GetCurrentNetworkInfoCallbacks::class.java)) } - @Test fun getFrequency_apis() { + @Test + fun getFrequency_apis() { wisefy.getFrequency() verify(wisefy).getFrequency() wisefy.getFrequency(object : GetFrequencyCallbacks { @@ -245,7 +261,8 @@ internal class PublicApiVisibilityTests { verify(wisefy).getFrequency(any(WifiInfo::class.java), any(GetFrequencyCallbacks::class.java)) } - @Test fun getIP_apis() { + @Test + fun getIP_apis() { wisefy.getIP() verify(wisefy).getIP() wisefy.getIP(object : GetIPCallbacks { @@ -261,7 +278,8 @@ internal class PublicApiVisibilityTests { verify(wisefy).getIP(any(GetIPCallbacks::class.java)) } - @Test fun getNearbyAccessPoints_apis() { + @Test + fun getNearbyAccessPoints_apis() { wisefy.getNearbyAccessPoints(true) verify(wisefy).getNearbyAccessPoints(anyBoolean()) wisefy.getNearbyAccessPoints(true, object : GetNearbyAccessPointsCallbacks { @@ -274,10 +292,14 @@ internal class PublicApiVisibilityTests { override fun wisefyFailure(wisefyFailureCode: Int) { } }) - verify(wisefy).getNearbyAccessPoints(anyBoolean(), any(GetNearbyAccessPointsCallbacks::class.java)) + verify(wisefy).getNearbyAccessPoints( + anyBoolean(), + any(GetNearbyAccessPointsCallbacks::class.java) + ) } - @Test fun getRSSI_apis() { + @Test + fun getRSSI_apis() { wisefy.getRSSI(TEST_SSID, true, TEST_DELAY) verify(wisefy).getRSSI(anyString(), anyBoolean(), anyInt()) wisefy.getRSSI(TEST_SSID, true, TEST_DELAY, object : GetRSSICallbacks { @@ -293,7 +315,8 @@ internal class PublicApiVisibilityTests { verify(wisefy).getRSSI(anyString(), anyBoolean(), anyInt(), any(GetRSSICallbacks::class.java)) } - @Test fun getSavedNetworks_apis() { + @Test + fun getSavedNetworks_apis() { wisefy.getSavedNetworks() verify(wisefy).getSavedNetworks() wisefy.getSavedNetworks(object : GetSavedNetworksCallbacks { @@ -309,42 +332,50 @@ internal class PublicApiVisibilityTests { verify(wisefy).getSavedNetworks(any(GetSavedNetworksCallbacks::class.java)) } - @Test fun getWiseFyLock_api() { + @Test + fun getWiseFyLock_api() { wisefy.getWiseFyLock() verify(wisefy).getWiseFyLock() } - @Test fun isDeviceConnectedToMobileNetwork_apis() { + @Test + fun isDeviceConnectedToMobileNetwork_apis() { wisefy.isDeviceConnectedToMobileNetwork() verify(wisefy).isDeviceConnectedToMobileNetwork() } - @Test fun isDeviceConnectedToMobileOrWifiNetwork_apis() { + @Test + fun isDeviceConnectedToMobileOrWifiNetwork_apis() { wisefy.isDeviceConnectedToMobileOrWifiNetwork() verify(wisefy).isDeviceConnectedToMobileOrWifiNetwork() } - @Test fun isDeviceConnectedToSSID_apis() { + @Test + fun isDeviceConnectedToSSID_apis() { wisefy.isDeviceConnectedToSSID(TEST_SSID) verify(wisefy).isDeviceConnectedToSSID(anyString()) } - @Test fun isDeviceConnectedToWifiNetwork_apis() { + @Test + fun isDeviceConnectedToWifiNetwork_apis() { wisefy.isDeviceConnectedToWifiNetwork() verify(wisefy).isDeviceConnectedToWifiNetwork() } - @Test fun isDeviceRoaming_apis() { + @Test + fun isDeviceRoaming_apis() { wisefy.isDeviceRoaming() verify(wisefy).isDeviceRoaming() } - @Test fun isLoggingEnabled_api() { + @Test + fun isLoggingEnabled_api() { wisefy.isLoggingEnabled() verify(wisefy).isLoggingEnabled() } - @Test fun isNetwork5gHz_apis() { + @Test + fun isNetwork5gHz_apis() { wisefy.isNetwork5gHz() verify(wisefy).isNetwork5gHz() @@ -352,27 +383,32 @@ internal class PublicApiVisibilityTests { verify(wisefy).isNetwork5gHz(any(WifiInfo::class.java)) } - @Test fun isNetworkEAP_api() { + @Test + fun isNetworkEAP_api() { wisefy.isNetworkEAP(mock(ScanResult::class.java)) verify(wisefy).isNetworkEAP(any(ScanResult::class.java)) } - @Test fun isNetworkPSK_api() { + @Test + fun isNetworkPSK_api() { wisefy.isNetworkPSK(mock(ScanResult::class.java)) verify(wisefy).isNetworkPSK(any(ScanResult::class.java)) } - @Test fun isNetworkSaved_api() { + @Test + fun isNetworkSaved_api() { wisefy.isNetworkSaved(TEST_SSID) verify(wisefy).isNetworkSaved(anyString()) } - @Test fun isNetworkSecure_api() { + @Test + fun isNetworkSecure_api() { wisefy.isNetworkSecure(mock(ScanResult::class.java)) verify(wisefy).isNetworkSecure(any(ScanResult::class.java)) } - @Test fun isNetworkWEP_api() { + @Test + fun isNetworkWEP_api() { wisefy.isNetworkWEP(mock(ScanResult::class.java)) verify(wisefy).isNetworkWEP(any(ScanResult::class.java)) } @@ -383,17 +419,20 @@ internal class PublicApiVisibilityTests { verify(wisefy).isNetworkWPA(any(ScanResult::class.java)) } - @Test fun isNetworkWPA2_api() { + @Test + fun isNetworkWPA2_api() { wisefy.isNetworkWPA2(mock(ScanResult::class.java)) verify(wisefy).isNetworkWPA2(any(ScanResult::class.java)) } - @Test fun isWifiEnabled_api() { + @Test + fun isWifiEnabled_api() { wisefy.isWifiEnabled() verify(wisefy).isWifiEnabled() } - @Test fun removeNetwork_api() { + @Test + fun removeNetwork_api() { wisefy.removeNetwork(TEST_SSID) verify(wisefy).removeNetwork(anyString()) @@ -413,7 +452,8 @@ internal class PublicApiVisibilityTests { verify(wisefy).removeNetwork(anyString(), any(RemoveNetworkCallbacks::class.java)) } - @Test fun searchForAccessPoint_api() { + @Test + fun searchForAccessPoint_api() { wisefy.searchForAccessPoint(TEST_SSID, TEST_DELAY, true) verify(wisefy).searchForAccessPoint(anyString(), anyInt(), anyBoolean()) @@ -427,10 +467,16 @@ internal class PublicApiVisibilityTests { override fun accessPointNotFound() { } }) - verify(wisefy).searchForAccessPoint(anyString(), anyInt(), anyBoolean(), any(SearchForAccessPointCallbacks::class.java)) + verify(wisefy).searchForAccessPoint( + anyString(), + anyInt(), + anyBoolean(), + any(SearchForAccessPointCallbacks::class.java) + ) } - @Test fun searchForAccessPoints_api() { + @Test + fun searchForAccessPoints_api() { wisefy.searchForAccessPoints(TEST_SSID, true) verify(wisefy).searchForAccessPoints(anyString(), anyBoolean()) @@ -444,10 +490,15 @@ internal class PublicApiVisibilityTests { override fun wisefyFailure(wisefyFailureCode: Int) { } }) - verify(wisefy).searchForAccessPoints(anyString(), anyBoolean(), any(SearchForAccessPointsCallbacks::class.java)) + verify(wisefy).searchForAccessPoints( + anyString(), + anyBoolean(), + any(SearchForAccessPointsCallbacks::class.java) + ) } - @Test fun searchForSavedNetwork_apis() { + @Test + fun searchForSavedNetwork_apis() { wisefy.searchForSavedNetwork(TEST_SSID) verify(wisefy).searchForSavedNetwork(anyString()) wisefy.searchForSavedNetwork(TEST_SSID, object : SearchForSavedNetworkCallbacks { @@ -460,10 +511,14 @@ internal class PublicApiVisibilityTests { override fun retrievedSavedNetwork(savedNetwork: WifiConfiguration) { } }) - verify(wisefy).searchForSavedNetwork(anyString(), any(SearchForSavedNetworkCallbacks::class.java)) + verify(wisefy).searchForSavedNetwork( + anyString(), + any(SearchForSavedNetworkCallbacks::class.java) + ) } - @Test fun searchForSavedNetworks_apis() { + @Test + fun searchForSavedNetworks_apis() { wisefy.searchForSavedNetworks(TEST_SSID) verify(wisefy).searchForSavedNetworks(anyString()) wisefy.searchForSavedNetworks(TEST_SSID, object : SearchForSavedNetworksCallbacks { @@ -476,10 +531,14 @@ internal class PublicApiVisibilityTests { override fun wisefyFailure(wisefyFailureCode: Int) { } }) - verify(wisefy).searchForSavedNetworks(anyString(), any(SearchForSavedNetworksCallbacks::class.java)) + verify(wisefy).searchForSavedNetworks( + anyString(), + any(SearchForSavedNetworksCallbacks::class.java) + ) } - @Test fun searchForSSID_api() { + @Test + fun searchForSSID_api() { wisefy.searchForSSID(TEST_SSID, TEST_DELAY) verify(wisefy).searchForSSID(anyString(), anyInt()) @@ -496,7 +555,8 @@ internal class PublicApiVisibilityTests { verify(wisefy).searchForSSID(anyString(), anyInt(), any(SearchForSSIDCallbacks::class.java)) } - @Test fun searchForSSIDs_api() { + @Test + fun searchForSSIDs_api() { wisefy.searchForSSIDs(TEST_SSID) verify(wisefy).searchForSSIDs(anyString()) @@ -513,7 +573,8 @@ internal class PublicApiVisibilityTests { verify(wisefy).searchForSSIDs(anyString(), any(SearchForSSIDsCallbacks::class.java)) } - @Test fun wifiManagerFailure_value() { + @Test + fun wifiManagerFailure_value() { assertEquals(WIFI_MANAGER_FAILURE.toLong(), -1) } } diff --git a/wisefysample/build.gradle b/wisefysample/build.gradle index 117cffc4..e21305fc 100644 --- a/wisefysample/build.gradle +++ b/wisefysample/build.gradle @@ -21,13 +21,13 @@ android { debug { testCoverageEnabled true minifyEnabled true - proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' + proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules-debug.pro' testProguardFile file("proguard-test-rules.pro.pro") } release { minifyEnabled true - proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' + proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules-release.pro' } } @@ -35,8 +35,13 @@ android { unitTests.returnDefaultValues = true } + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 + } + sourceSets { - def commonTestDir = 'src/commonTest/java' + final def commonTestDir = 'src/commonTest/java' test { java.srcDir commonTestDir } @@ -44,13 +49,20 @@ android { main { jni.srcDirs = [] } } + + lintOptions { + checkAllWarnings true + warningsAsErrors true + showAll true + explainIssues true + abortOnError true + disable 'UnusedIds' // UnusedIds is disabled for Kotlin synthetics + } } dependencies { implementation project(':wisefy') - implementation fileTree(dir: 'libs', include: ['*.jar']) - implementation"org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" // Android X diff --git a/wisefysample/proguard-rules-common.pro b/wisefysample/proguard-rules-common.pro new file mode 100644 index 00000000..0ff2fd3f --- /dev/null +++ b/wisefysample/proguard-rules-common.pro @@ -0,0 +1,23 @@ +-dontnote + +-dontskipnonpubliclibraryclasses +-dontskipnonpubliclibraryclassmembers + +-keepattributes *Annotation*, EnclosingMethod, InnerClasses, Signature + +# Kotlin +-keep class kotlin.collections.CollectionsKt { *; } +-keepclassmembers class **$WhenMappings { + ; +} +-keepclassmembers class kotlin.Metadata { + public ; +} +-assumenosideeffects class kotlin.jvm.internal.Intrinsics { + static void checkParameterIsNotNull(java.lang.Object, java.lang.String); +} + +# RxJava +-keep class io.reactivex.schedulers.Schedulers { + public static ; +} diff --git a/wisefysample/proguard-rules-debug.pro b/wisefysample/proguard-rules-debug.pro new file mode 100644 index 00000000..12ff5f85 --- /dev/null +++ b/wisefysample/proguard-rules-debug.pro @@ -0,0 +1,7 @@ +-include proguard-rules-common.pro + +-dontobfuscate + +-keepattributes SourceFile, LineNumberTable + +-keep class com.isupatches.wisefysample.DebugMainApplication { *; } diff --git a/wisefysample/proguard-rules-release.pro b/wisefysample/proguard-rules-release.pro new file mode 100644 index 00000000..77c5391a --- /dev/null +++ b/wisefysample/proguard-rules-release.pro @@ -0,0 +1 @@ +-include proguard-rules-common.pro diff --git a/wisefysample/proguard-rules.pro b/wisefysample/proguard-rules.pro deleted file mode 100644 index d3aaaa43..00000000 --- a/wisefysample/proguard-rules.pro +++ /dev/null @@ -1,21 +0,0 @@ --verbose - --dontobfuscate - --keep class com.isupatches.wisefysample.** { *; } --keep public interface com.isupatches.wisefysample.** { *; } - --keep class kotlin.** { *; } --keep class kotlin.Metadata { *; } --dontwarn kotlin.** --keepclassmembers class **$WhenMappings { - ; -} --keepclassmembers class kotlin.Metadata { - public ; -} --assumenosideeffects class kotlin.jvm.internal.Intrinsics { - static void checkParameterIsNotNull(java.lang.Object, java.lang.String); -} - --keep class io.reactivex.schedulers.Schedulers { *; } diff --git a/wisefysample/proguard-test-rules.pro b/wisefysample/proguard-test-rules.pro index e69de29b..f22ec8b2 100644 --- a/wisefysample/proguard-test-rules.pro +++ b/wisefysample/proguard-test-rules.pro @@ -0,0 +1 @@ +-include proguard-rules.pro diff --git a/wisefysample/src/androidTest/java/com/isupatches/wisefysample/internal/base/AbstractEspressoTestClass.kt b/wisefysample/src/androidTest/java/com/isupatches/wisefysample/internal/base/AbstractEspressoTestClass.kt index cc0bce4b..cea8085a 100644 --- a/wisefysample/src/androidTest/java/com/isupatches/wisefysample/internal/base/AbstractEspressoTestClass.kt +++ b/wisefysample/src/androidTest/java/com/isupatches/wisefysample/internal/base/AbstractEspressoTestClass.kt @@ -23,7 +23,6 @@ import com.isupatches.wisefysample.ui.remove.RemoveNetworkPresenter import com.isupatches.wisefysample.ui.search.SearchModel import com.isupatches.wisefysample.ui.search.SearchMvp import com.isupatches.wisefysample.ui.search.SearchPresenter - import com.nhaarman.mockitokotlin2.mock internal abstract class AbstractEspressoTestClass { diff --git a/wisefysample/src/androidTest/java/com/isupatches/wisefysample/internal/base/BaseRobot.kt b/wisefysample/src/androidTest/java/com/isupatches/wisefysample/internal/base/BaseRobot.kt index 68622a77..8a9ff462 100644 --- a/wisefysample/src/androidTest/java/com/isupatches/wisefysample/internal/base/BaseRobot.kt +++ b/wisefysample/src/androidTest/java/com/isupatches/wisefysample/internal/base/BaseRobot.kt @@ -4,7 +4,6 @@ import androidx.test.espresso.Espresso.onView import androidx.test.espresso.matcher.ViewMatchers.withId import androidx.test.espresso.matcher.ViewMatchers.withText import androidx.test.rule.ActivityTestRule - import com.isupatches.wisefy.constants.MISSING_PARAMETER import com.isupatches.wisefysample.R import com.isupatches.wisefysample.RANDO_PERMISSION_REQUEST_CODE @@ -14,13 +13,10 @@ import com.isupatches.wisefysample.internal.espresso.getString import com.isupatches.wisefysample.internal.espresso.performClick import com.isupatches.wisefysample.internal.espresso.performScrollToAndCheckIsDisplayed import com.isupatches.wisefysample.internal.util.PermissionUtil - import com.nhaarman.mockitokotlin2.any import com.nhaarman.mockitokotlin2.eq - import org.hamcrest.CoreMatchers.allOf import org.hamcrest.CoreMatchers.containsString - import org.mockito.Mockito.`when` internal abstract class BaseRobot( @@ -41,13 +37,6 @@ internal abstract class BaseRobot( .thenReturn(true) } - fun withPermissions(vararg permissions: String) { - for (permission in permissions) { - `when`(permissionUtil.isPermissionGranted(any(), eq(permission))) - .thenReturn(true) - } - } - fun withPermissionDeniedOnce(permission: String) { `when`(permissionUtil.isPermissionGranted(any(), eq(permission))) .thenReturn(false) @@ -64,15 +53,13 @@ internal abstract class BaseRobot( R.string.permission_error_unhandled_request_code_args, RANDO_PERMISSION_REQUEST_CODE ) - )) - .checkIsDisplayed() + )).checkIsDisplayed() } fun verifyWiseFyFailureIsDisplayed() { onView(withText(R.string.wisefy_error)).checkIsDisplayed() onView(withText( - activityTestRule.getString( - R.string.wisefy_error_descriptions_args, MISSING_PARAMETER) + activityTestRule.getString(R.string.wisefy_error_descriptions_args, MISSING_PARAMETER) )).checkIsDisplayed() } diff --git a/wisefysample/src/androidTest/java/com/isupatches/wisefysample/internal/di/TestMainApplicationComponent.kt b/wisefysample/src/androidTest/java/com/isupatches/wisefysample/internal/di/TestMainApplicationComponent.kt index 8638d7cb..802bfe5f 100644 --- a/wisefysample/src/androidTest/java/com/isupatches/wisefysample/internal/di/TestMainApplicationComponent.kt +++ b/wisefysample/src/androidTest/java/com/isupatches/wisefysample/internal/di/TestMainApplicationComponent.kt @@ -1,9 +1,7 @@ package com.isupatches.wisefysample.internal.di import com.isupatches.wisefysample.MainApplication - import dagger.Component - import javax.inject.Singleton @Suppress("unused") diff --git a/wisefysample/src/androidTest/java/com/isupatches/wisefysample/internal/di/TestMainApplicationComponentBuilder.kt b/wisefysample/src/androidTest/java/com/isupatches/wisefysample/internal/di/TestMainApplicationComponentBuilder.kt index 827907d5..472ffdcb 100644 --- a/wisefysample/src/androidTest/java/com/isupatches/wisefysample/internal/di/TestMainApplicationComponentBuilder.kt +++ b/wisefysample/src/androidTest/java/com/isupatches/wisefysample/internal/di/TestMainApplicationComponentBuilder.kt @@ -1,7 +1,6 @@ package com.isupatches.wisefysample.internal.di import android.content.Context - import com.isupatches.wisefy.WiseFyPublicApi import com.isupatches.wisefysample.DebugMainApplication import com.isupatches.wisefysample.MainApplication @@ -16,7 +15,6 @@ import com.isupatches.wisefysample.ui.add.AddNetworkMvp import com.isupatches.wisefysample.ui.misc.MiscMvp import com.isupatches.wisefysample.ui.remove.RemoveNetworkMvp import com.isupatches.wisefysample.ui.search.SearchMvp - import dagger.BindsInstance internal interface TestMainApplicationComponentBuilder> { diff --git a/wisefysample/src/androidTest/java/com/isupatches/wisefysample/internal/di/TestRxModule.kt b/wisefysample/src/androidTest/java/com/isupatches/wisefysample/internal/di/TestRxModule.kt index d037aaef..73444fab 100644 --- a/wisefysample/src/androidTest/java/com/isupatches/wisefysample/internal/di/TestRxModule.kt +++ b/wisefysample/src/androidTest/java/com/isupatches/wisefysample/internal/di/TestRxModule.kt @@ -1,10 +1,11 @@ package com.isupatches.wisefysample.internal.di import com.isupatches.wisefysample.TestRxSchedulersProvider +import com.isupatches.wisefysample.internal.util.RxSchedulersProvider import dagger.Module import dagger.Provides @Suppress("unused") @Module object TestRxModule { - @Provides @JvmStatic fun rxSchedulersProvider() = TestRxSchedulersProvider() + @Provides @JvmStatic fun rxSchedulersProvider(): RxSchedulersProvider = TestRxSchedulersProvider() } diff --git a/wisefysample/src/androidTest/java/com/isupatches/wisefysample/internal/di/TestScreenBindingsModule.kt b/wisefysample/src/androidTest/java/com/isupatches/wisefysample/internal/di/TestScreenBindingsModule.kt index 3dd17c64..0137fdd6 100644 --- a/wisefysample/src/androidTest/java/com/isupatches/wisefysample/internal/di/TestScreenBindingsModule.kt +++ b/wisefysample/src/androidTest/java/com/isupatches/wisefysample/internal/di/TestScreenBindingsModule.kt @@ -6,7 +6,6 @@ import com.isupatches.wisefysample.ui.main.MainFragment import com.isupatches.wisefysample.ui.misc.MiscFragment import com.isupatches.wisefysample.ui.remove.RemoveNetworkFragment import com.isupatches.wisefysample.ui.search.SearchFragment - import dagger.Module import dagger.android.ContributesAndroidInjector @@ -18,4 +17,4 @@ import dagger.android.ContributesAndroidInjector @ContributesAndroidInjector fun mainFragment(): MainFragment @ContributesAndroidInjector fun miscFragment(): MiscFragment @ContributesAndroidInjector fun searchFragment(): SearchFragment -} \ No newline at end of file +} diff --git a/wisefysample/src/androidTest/java/com/isupatches/wisefysample/internal/espresso/ActivityTestRule.kt b/wisefysample/src/androidTest/java/com/isupatches/wisefysample/internal/espresso/ActivityTestRule.kt index b5e3b3c4..33baf5f7 100644 --- a/wisefysample/src/androidTest/java/com/isupatches/wisefysample/internal/espresso/ActivityTestRule.kt +++ b/wisefysample/src/androidTest/java/com/isupatches/wisefysample/internal/espresso/ActivityTestRule.kt @@ -3,8 +3,9 @@ package com.isupatches.wisefysample.internal.espresso import androidx.annotation.StringRes import androidx.test.rule.ActivityTestRule -fun ActivityTestRule<*>.getString(@StringRes stringRes: Int): String = - activity.getString(stringRes) +fun ActivityTestRule<*>.getString(@StringRes stringRes: Int): String = activity.getString(stringRes) -fun ActivityTestRule<*>.getString(@StringRes stringRes: Int, varargs: Any): String = - activity.getString(stringRes, varargs) \ No newline at end of file +fun ActivityTestRule<*>.getString( + @StringRes stringRes: Int, + varargs: Any +): String = activity.getString(stringRes, varargs) diff --git a/wisefysample/src/androidTest/java/com/isupatches/wisefysample/internal/espresso/SetProgress.kt b/wisefysample/src/androidTest/java/com/isupatches/wisefysample/internal/espresso/SetProgress.kt index 61802c55..c16cbbfd 100644 --- a/wisefysample/src/androidTest/java/com/isupatches/wisefysample/internal/espresso/SetProgress.kt +++ b/wisefysample/src/androidTest/java/com/isupatches/wisefysample/internal/espresso/SetProgress.kt @@ -3,9 +3,8 @@ package com.isupatches.wisefysample.internal.espresso import android.view.View import android.widget.SeekBar import androidx.test.espresso.UiController -import androidx.test.espresso.matcher.ViewMatchers import androidx.test.espresso.ViewAction - +import androidx.test.espresso.matcher.ViewMatchers import org.hamcrest.Matcher fun setProgress(progress: Int): ViewAction { @@ -24,4 +23,4 @@ fun setProgress(progress: Int): ViewAction { return ViewMatchers.isAssignableFrom(SeekBar::class.java) } } -} \ No newline at end of file +} diff --git a/wisefysample/src/androidTest/java/com/isupatches/wisefysample/internal/espresso/ViewInteractions.kt b/wisefysample/src/androidTest/java/com/isupatches/wisefysample/internal/espresso/ViewInteractions.kt index 742fe15a..fa1b2112 100644 --- a/wisefysample/src/androidTest/java/com/isupatches/wisefysample/internal/espresso/ViewInteractions.kt +++ b/wisefysample/src/androidTest/java/com/isupatches/wisefysample/internal/espresso/ViewInteractions.kt @@ -12,34 +12,30 @@ import androidx.test.espresso.matcher.ViewMatchers.isNotChecked import androidx.test.espresso.matcher.ViewMatchers.withEffectiveVisibility fun ViewInteraction.checkIsDisplayed(): ViewInteraction = - check(matches(isDisplayed())) + check(matches(isDisplayed())) -fun ViewInteraction.performScrollToAndCheckIsDisplayed(): ViewInteraction = - perform(scrollTo()) - .check(matches(isDisplayed())) +fun ViewInteraction.performScrollToAndCheckIsDisplayed(): ViewInteraction = perform(scrollTo()) + .check(matches(isDisplayed())) fun ViewInteraction.checkIsVisible(): ViewInteraction = - check(matches(withEffectiveVisibility(ViewMatchers.Visibility.VISIBLE))) + check(matches(withEffectiveVisibility(ViewMatchers.Visibility.VISIBLE))) fun ViewInteraction.checkIsInvisible(): ViewInteraction = - check(matches(withEffectiveVisibility(ViewMatchers.Visibility.INVISIBLE))) + check(matches(withEffectiveVisibility(ViewMatchers.Visibility.INVISIBLE))) fun ViewInteraction.checkIsChecked(): ViewInteraction = - check(matches(isChecked())) + check(matches(isChecked())) fun ViewInteraction.checkIsNotChecked(): ViewInteraction = - check(matches(isNotChecked())) + check(matches(isNotChecked())) -fun ViewInteraction.performClick(): ViewInteraction = - checkIsDisplayed() - .perform(click()) +fun ViewInteraction.performClick(): ViewInteraction = checkIsDisplayed() + .perform(click()) -fun ViewInteraction.performScrollToAndClick(): ViewInteraction = - perform(scrollTo()) - .checkIsDisplayed() - .perform(click()) +fun ViewInteraction.performScrollToAndClick(): ViewInteraction = perform(scrollTo()) + .checkIsDisplayed() + .perform(click()) -fun ViewInteraction.performScrollToAndReplaceText(text: String): ViewInteraction = - perform(scrollTo()) - .checkIsDisplayed() - .perform(replaceText(text)) +fun ViewInteraction.performScrollToAndReplaceText(text: String): ViewInteraction = perform(scrollTo()) + .checkIsDisplayed() + .perform(replaceText(text)) diff --git a/wisefysample/src/androidTest/java/com/isupatches/wisefysample/internal/preferences/InMemorySearchStore.kt b/wisefysample/src/androidTest/java/com/isupatches/wisefysample/internal/preferences/InMemorySearchStore.kt index 283624de..87ec95ce 100644 --- a/wisefysample/src/androidTest/java/com/isupatches/wisefysample/internal/preferences/InMemorySearchStore.kt +++ b/wisefysample/src/androidTest/java/com/isupatches/wisefysample/internal/preferences/InMemorySearchStore.kt @@ -62,4 +62,4 @@ internal class InMemorySearchStore : SearchStore { override fun setTimeout(timeout: Int) { this.timeout = timeout } -} \ No newline at end of file +} diff --git a/wisefysample/src/androidTest/java/com/isupatches/wisefysample/ui/add/AddNetworkFragmentTest.kt b/wisefysample/src/androidTest/java/com/isupatches/wisefysample/ui/add/AddNetworkFragmentTest.kt index cf24c2d7..eb1ca20b 100644 --- a/wisefysample/src/androidTest/java/com/isupatches/wisefysample/ui/add/AddNetworkFragmentTest.kt +++ b/wisefysample/src/androidTest/java/com/isupatches/wisefysample/ui/add/AddNetworkFragmentTest.kt @@ -1,13 +1,12 @@ package com.isupatches.wisefysample.ui.add -import android.Manifest.permission.ACCESS_WIFI_STATE +import android.Manifest.permission.ACCESS_FINE_LOCATION import android.content.pm.PackageManager import androidx.test.espresso.intent.rule.IntentsTestRule - +import androidx.test.rule.GrantPermissionRule import com.isupatches.wisefysample.RANDO_PERMISSION_REQUEST_CODE import com.isupatches.wisefysample.internal.base.AbstractEspressoTestClass import com.isupatches.wisefysample.ui.main.MainActivity - import org.junit.Before import org.junit.Rule import org.junit.Test @@ -17,9 +16,13 @@ internal class AddNetworkFragmentTest : AbstractEspressoTestClass() { @get:Rule val activityTestRule = IntentsTestRule(MainActivity::class.java, false, false) + @get:Rule + val grantPermissionRule: GrantPermissionRule = GrantPermissionRule.grant(ACCESS_FINE_LOCATION) + private lateinit var addNetworkRobot: AddNetworkRobot - @Before override fun setUp() { + @Before + override fun setUp() { super.setUp() addNetworkRobot = AddNetworkRobot( activityTestRule, @@ -29,7 +32,8 @@ internal class AddNetworkFragmentTest : AbstractEspressoTestClass() { ) } - @Test fun networkTypeSelector() { + @Test + fun networkTypeSelector() { with(addNetworkRobot) { // Given launchAddNetworkScreen() @@ -56,7 +60,8 @@ internal class AddNetworkFragmentTest : AbstractEspressoTestClass() { } } - @Test fun loadsOpenNetworkFromStore() { + @Test + fun loadsOpenNetworkFromStore() { with(addNetworkRobot) { // Given withOpenNetworkInStore() @@ -70,7 +75,8 @@ internal class AddNetworkFragmentTest : AbstractEspressoTestClass() { } } - @Test fun loadsWEPNetworkFromStore() { + @Test + fun loadsWEPNetworkFromStore() { with(addNetworkRobot) { // Given withWEPNetworkInStore() @@ -84,7 +90,8 @@ internal class AddNetworkFragmentTest : AbstractEspressoTestClass() { } } - @Test fun loadsWPA2NetworkFromStore() { + @Test + fun loadsWPA2NetworkFromStore() { with(addNetworkRobot) { // Given withWPA2NetworkInStore() @@ -98,12 +105,11 @@ internal class AddNetworkFragmentTest : AbstractEspressoTestClass() { } } - @Test fun addOpenNetwork_permissionErrorDialog() { + @Test + fun addOpenNetwork_permissionErrorDialog() { with(addNetworkRobot) { // Given - withPermission(ACCESS_WIFI_STATE) launchAddNetworkScreen() - addOpenNetwork() // When permissionCallbackTriggered( @@ -116,11 +122,12 @@ internal class AddNetworkFragmentTest : AbstractEspressoTestClass() { } } - @Test fun addOpenNetwork_permissionError_once() { + @Test + fun addOpenNetwork_permissionError_once() { with(addNetworkRobot) { // Given withSuccessAddingOpenNetwork() - withPermissionDeniedOnce(ACCESS_WIFI_STATE) + withPermissionDeniedOnce(ACCESS_FINE_LOCATION) launchAddNetworkScreen() // When @@ -133,13 +140,11 @@ internal class AddNetworkFragmentTest : AbstractEspressoTestClass() { } } - @Test fun addOpenNetwork_permissionError_emptyList() { + @Test + fun addOpenNetwork_permissionError_emptyList() { with(addNetworkRobot) { // Given - withPermission(ACCESS_WIFI_STATE) - withSuccessAddingOpenNetwork() launchAddNetworkScreen() - addOpenNetwork() // When permissionCallbackTriggeredWithEmptyArray( @@ -148,17 +153,14 @@ internal class AddNetworkFragmentTest : AbstractEspressoTestClass() { // Then dismissErrorDialog() - verifyTriedToAddOpenNetwork() } } - @Test fun addOpenNetwork_permissionError_permissionDenied() { + @Test + fun addOpenNetwork_permissionError_permissionDenied() { with(addNetworkRobot) { // Given - withPermission(ACCESS_WIFI_STATE) - withSuccessAddingOpenNetwork() launchAddNetworkScreen() - addOpenNetwork() // When permissionCallbackTriggered( @@ -168,17 +170,17 @@ internal class AddNetworkFragmentTest : AbstractEspressoTestClass() { // Then dismissErrorDialog() - verifyTriedToAddOpenNetwork() } } - @Test fun addOpenNetwork_success_afterPermissionGranted() { + @Test + fun addOpenNetwork_success_afterPermissionGranted() { with(addNetworkRobot) { // Given - withPermission(ACCESS_WIFI_STATE) + withPermission(ACCESS_FINE_LOCATION) withSuccessAddingOpenNetwork() launchAddNetworkScreen() - addOpenNetwork() + enterOpenNetworkDetails() // When permissionCallbackTriggered( @@ -187,16 +189,17 @@ internal class AddNetworkFragmentTest : AbstractEspressoTestClass() { ) // Then - verifyTriedToAddOpenNetwork(times = 2) + verifyTriedToAddOpenNetwork() verifyNewNetworkIsDisplayed() dismissResultsDialog() } } - @Test fun addOpenNetwork_success() { + @Test + fun addOpenNetwork_success() { with(addNetworkRobot) { // Given - withPermission(ACCESS_WIFI_STATE) + withPermission(ACCESS_FINE_LOCATION) withSuccessAddingOpenNetwork() launchAddNetworkScreen() @@ -210,10 +213,11 @@ internal class AddNetworkFragmentTest : AbstractEspressoTestClass() { } } - @Test fun addOpenNetwork_wifiManagerFailure() { + @Test + fun addOpenNetwork_wifiManagerFailure() { with(addNetworkRobot) { // Given - withPermission(ACCESS_WIFI_STATE) + withPermission(ACCESS_FINE_LOCATION) withWifiManagerFailureAddingOpenNetwork() launchAddNetworkScreen() @@ -227,10 +231,11 @@ internal class AddNetworkFragmentTest : AbstractEspressoTestClass() { } } - @Test fun addOpenNetwork_wiseFyFailure() { + @Test + fun addOpenNetwork_wiseFyFailure() { with(addNetworkRobot) { // Given - withPermission(ACCESS_WIFI_STATE) + withPermission(ACCESS_FINE_LOCATION) withWiseFyFailureAddingOpenNetwork() launchAddNetworkScreen() @@ -246,12 +251,11 @@ internal class AddNetworkFragmentTest : AbstractEspressoTestClass() { } } - @Test fun addWEPNetwork_permissionErrorDialog() { + @Test + fun addWEPNetwork_permissionErrorDialog() { with(addNetworkRobot) { // Given - withPermission(ACCESS_WIFI_STATE) launchAddNetworkScreen() - addWEPNetwork() // When permissionCallbackTriggered( @@ -264,11 +268,12 @@ internal class AddNetworkFragmentTest : AbstractEspressoTestClass() { } } - @Test fun addWEPNetwork_permissionError_once() { + @Test + fun addWEPNetwork_permissionError_once() { with(addNetworkRobot) { // Given withSuccessAddingWEPNetwork() - withPermissionDeniedOnce(ACCESS_WIFI_STATE) + withPermissionDeniedOnce(ACCESS_FINE_LOCATION) launchAddNetworkScreen() // When @@ -281,13 +286,11 @@ internal class AddNetworkFragmentTest : AbstractEspressoTestClass() { } } - @Test fun addWEPNetwork_permissionError_emptyList() { + @Test + fun addWEPNetwork_permissionError_emptyList() { with(addNetworkRobot) { // Given - withPermission(ACCESS_WIFI_STATE) - withSuccessAddingWEPNetwork() launchAddNetworkScreen() - addWEPNetwork() // When permissionCallbackTriggeredWithEmptyArray( @@ -296,17 +299,14 @@ internal class AddNetworkFragmentTest : AbstractEspressoTestClass() { // Then dismissErrorDialog() - verifyTriedToAddWEPNetwork() } } - @Test fun addWEPNetwork_permissionError_permissionDenied() { + @Test + fun addWEPNetwork_permissionError_permissionDenied() { with(addNetworkRobot) { // Given - withPermission(ACCESS_WIFI_STATE) - withSuccessAddingWEPNetwork() launchAddNetworkScreen() - addWEPNetwork() // When permissionCallbackTriggered( @@ -316,17 +316,17 @@ internal class AddNetworkFragmentTest : AbstractEspressoTestClass() { // Then dismissErrorDialog() - verifyTriedToAddWEPNetwork() } } - @Test fun addWEPNetwork_success_afterPermissionGranted() { + @Test + fun addWEPNetwork_success_afterPermissionGranted() { with(addNetworkRobot) { // Given - withPermission(ACCESS_WIFI_STATE) + withPermission(ACCESS_FINE_LOCATION) withSuccessAddingWEPNetwork() launchAddNetworkScreen() - addWEPNetwork() + enterWEPNetworkDetails() // When permissionCallbackTriggered( @@ -335,16 +335,17 @@ internal class AddNetworkFragmentTest : AbstractEspressoTestClass() { ) // Then - verifyTriedToAddWEPNetwork(times = 2) + verifyTriedToAddWEPNetwork() verifyNewNetworkIsDisplayed() dismissResultsDialog() } } - @Test fun addWEPNetwork_success() { + @Test + fun addWEPNetwork_success() { with(addNetworkRobot) { // Given - withPermission(ACCESS_WIFI_STATE) + withPermission(ACCESS_FINE_LOCATION) withSuccessAddingWEPNetwork() launchAddNetworkScreen() @@ -358,10 +359,11 @@ internal class AddNetworkFragmentTest : AbstractEspressoTestClass() { } } - @Test fun addWEPNetwork_wifiManagerFailure() { + @Test + fun addWEPNetwork_wifiManagerFailure() { with(addNetworkRobot) { // Given - withPermission(ACCESS_WIFI_STATE) + withPermission(ACCESS_FINE_LOCATION) withWifiManagerFailureAddingWEPNetwork() launchAddNetworkScreen() @@ -375,10 +377,11 @@ internal class AddNetworkFragmentTest : AbstractEspressoTestClass() { } } - @Test fun addWEPNetwork_wiseFyFailure() { + @Test + fun addWEPNetwork_wiseFyFailure() { with(addNetworkRobot) { // Given - withPermission(ACCESS_WIFI_STATE) + withPermission(ACCESS_FINE_LOCATION) withWiseFyFailureAddingWEPNetwork() launchAddNetworkScreen() @@ -394,12 +397,11 @@ internal class AddNetworkFragmentTest : AbstractEspressoTestClass() { } } - @Test fun addWPA2Network_permissionErrorDialog() { + @Test + fun addWPA2Network_permissionErrorDialog() { with(addNetworkRobot) { // Given - withPermission(ACCESS_WIFI_STATE) launchAddNetworkScreen() - addWPA2Network() // When permissionCallbackTriggered( @@ -411,11 +413,13 @@ internal class AddNetworkFragmentTest : AbstractEspressoTestClass() { dismissErrorDialog() } } - @Test fun addWPA2Network_permissionError_once() { + + @Test + fun addWPA2Network_permissionError_once() { with(addNetworkRobot) { // Given withSuccessAddingWPA2Network() - withPermissionDeniedOnce(ACCESS_WIFI_STATE) + withPermissionDeniedOnce(ACCESS_FINE_LOCATION) launchAddNetworkScreen() // When @@ -428,13 +432,11 @@ internal class AddNetworkFragmentTest : AbstractEspressoTestClass() { } } - @Test fun addWPA2Network_permissionError_emptyList() { + @Test + fun addWPA2Network_permissionError_emptyList() { with(addNetworkRobot) { // Given - withPermission(ACCESS_WIFI_STATE) - withSuccessAddingWPA2Network() launchAddNetworkScreen() - addWPA2Network() // When permissionCallbackTriggeredWithEmptyArray( @@ -443,17 +445,14 @@ internal class AddNetworkFragmentTest : AbstractEspressoTestClass() { // Then dismissErrorDialog() - verifyTriedToAddWPA2Network() } } - @Test fun addWPA2Network_permissionError_permissionDenied() { + @Test + fun addWPA2Network_permissionError_permissionDenied() { with(addNetworkRobot) { // Given - withPermission(ACCESS_WIFI_STATE) - withSuccessAddingWEPNetwork() launchAddNetworkScreen() - addWPA2Network() // When permissionCallbackTriggered( @@ -463,17 +462,17 @@ internal class AddNetworkFragmentTest : AbstractEspressoTestClass() { // Then dismissErrorDialog() - verifyTriedToAddWPA2Network() } } - @Test fun addWPA2Network_success_afterPermissionGranted() { + @Test + fun addWPA2Network_success_afterPermissionGranted() { with(addNetworkRobot) { // Given - withPermission(ACCESS_WIFI_STATE) + withPermission(ACCESS_FINE_LOCATION) withSuccessAddingWPA2Network() launchAddNetworkScreen() - addWPA2Network() + enterWPA2NetworkDetails() // When permissionCallbackTriggered( @@ -482,16 +481,17 @@ internal class AddNetworkFragmentTest : AbstractEspressoTestClass() { ) // Then - verifyTriedToAddWPA2Network(times = 2) + verifyTriedToAddWPA2Network() verifyNewNetworkIsDisplayed() dismissResultsDialog() } } - @Test fun addWPA2Network_success() { + @Test + fun addWPA2Network_success() { with(addNetworkRobot) { // Given - withPermission(ACCESS_WIFI_STATE) + withPermission(ACCESS_FINE_LOCATION) withSuccessAddingWPA2Network() launchAddNetworkScreen() @@ -504,10 +504,11 @@ internal class AddNetworkFragmentTest : AbstractEspressoTestClass() { } } - @Test fun addWPA2Network_wifiManagerFailure() { + @Test + fun addWPA2Network_wifiManagerFailure() { with(addNetworkRobot) { // Given - withPermission(ACCESS_WIFI_STATE) + withPermission(ACCESS_FINE_LOCATION) withWifiManagerFailureAddingWPA2Network() launchAddNetworkScreen() @@ -521,10 +522,11 @@ internal class AddNetworkFragmentTest : AbstractEspressoTestClass() { } } - @Test fun addWPA2Network_wiseFyFailure() { + @Test + fun addWPA2Network_wiseFyFailure() { with(addNetworkRobot) { // Given - withPermission(ACCESS_WIFI_STATE) + withPermission(ACCESS_FINE_LOCATION) withWiseFyFailureAddingWPA2Network() launchAddNetworkScreen() @@ -540,7 +542,8 @@ internal class AddNetworkFragmentTest : AbstractEspressoTestClass() { } } - @Test fun ridiculousPermissionRequested() { + @Test + fun ridiculousPermissionRequested() { with(addNetworkRobot) { // Given launchAddNetworkScreen() diff --git a/wisefysample/src/androidTest/java/com/isupatches/wisefysample/ui/add/AddNetworkRobot.kt b/wisefysample/src/androidTest/java/com/isupatches/wisefysample/ui/add/AddNetworkRobot.kt index 7ab88458..16de8e0e 100644 --- a/wisefysample/src/androidTest/java/com/isupatches/wisefysample/ui/add/AddNetworkRobot.kt +++ b/wisefysample/src/androidTest/java/com/isupatches/wisefysample/ui/add/AddNetworkRobot.kt @@ -6,7 +6,6 @@ import androidx.test.espresso.Espresso.onView import androidx.test.espresso.matcher.ViewMatchers.withId import androidx.test.espresso.matcher.ViewMatchers.withText import androidx.test.rule.ActivityTestRule - import com.isupatches.wisefy.WiseFyPublicApi import com.isupatches.wisefy.callbacks.AddNetworkCallbacks import com.isupatches.wisefy.constants.MISSING_PARAMETER @@ -28,7 +27,6 @@ import com.isupatches.wisefysample.internal.models.NetworkType import com.isupatches.wisefysample.internal.preferences.AddNetworkStore import com.isupatches.wisefysample.internal.util.PermissionUtil import com.isupatches.wisefysample.ui.main.MainActivity - import com.nhaarman.mockitokotlin2.any import com.nhaarman.mockitokotlin2.doAnswer import com.nhaarman.mockitokotlin2.eq @@ -76,6 +74,7 @@ internal class AddNetworkRobot( }.whenever(wiseFyPublicApi).addOpenNetwork(eq(TEST_SSID_1), any()) } + @Suppress("deprecation") fun withSuccessAddingWEPNetwork() { doAnswer { invocationOnMock -> val callback = invocationOnMock.arguments[2] as AddNetworkCallbacks @@ -87,6 +86,7 @@ internal class AddNetworkRobot( ) } + @Suppress("deprecation") fun withWifiManagerFailureAddingWEPNetwork() { doAnswer { invocationOnMock -> val callback = invocationOnMock.arguments[2] as AddNetworkCallbacks @@ -98,6 +98,7 @@ internal class AddNetworkRobot( ) } + @Suppress("deprecation") fun withWiseFyFailureAddingWEPNetwork() { doAnswer { invocationOnMock -> val callback = invocationOnMock.arguments[2] as AddNetworkCallbacks @@ -169,6 +170,21 @@ internal class AddNetworkRobot( * Actions */ + fun enterOpenNetworkDetails() { + onView(withId(R.id.openNetworkRdb)).performScrollToAndClick() + onView(withId(R.id.networkNameEdt)).performScrollToAndReplaceText(TEST_SSID_1) + } + + fun enterWEPNetworkDetails() { + onView(withId(R.id.wepNetworkRdb)).performScrollToAndClick() + enterNetworkNameAndPassword() + } + + fun enterWPA2NetworkDetails() { + onView(withId(R.id.wpa2NetworkRdb)).performScrollToAndClick() + enterNetworkNameAndPassword() + } + fun launchAddNetworkScreen() { activityTestRule.launchActivity(Intent()) onView(withId(R.id.menu_add)).performClick() @@ -211,10 +227,10 @@ internal class AddNetworkRobot( fun permissionCallbackTriggered(requestCode: Int, permissionResult: Int) { val activity = activityTestRule.activity val fragment: AddNetworkFragment? = activity - .supportFragmentManager - .findFragmentByTag( - AddNetworkFragment.TAG - ) as? AddNetworkFragment + .supportFragmentManager + .findFragmentByTag( + AddNetworkFragment.TAG + ) as? AddNetworkFragment activity.runOnUiThread { fragment?.onRequestPermissionsResult( @@ -289,6 +305,7 @@ internal class AddNetworkRobot( verify(wiseFyPublicApi, timeout(3000).times(times)).addOpenNetwork(eq(TEST_SSID_1), any()) } + @Suppress("deprecation") fun verifyTriedToAddWEPNetwork(times: Int = 1) { verify(wiseFyPublicApi, timeout(3000).times(times)).addWEPNetwork( eq(TEST_SSID_1), diff --git a/wisefysample/src/androidTest/java/com/isupatches/wisefysample/ui/main/MainFragmentTest.kt b/wisefysample/src/androidTest/java/com/isupatches/wisefysample/ui/main/MainFragmentTest.kt index 2908604e..feb04e66 100644 --- a/wisefysample/src/androidTest/java/com/isupatches/wisefysample/ui/main/MainFragmentTest.kt +++ b/wisefysample/src/androidTest/java/com/isupatches/wisefysample/ui/main/MainFragmentTest.kt @@ -1,11 +1,9 @@ package com.isupatches.wisefysample.ui.main -import android.Manifest.permission.ACCESS_COARSE_LOCATION +import android.Manifest.permission.ACCESS_FINE_LOCATION import androidx.test.espresso.intent.rule.IntentsTestRule import androidx.test.rule.GrantPermissionRule - import com.isupatches.wisefysample.internal.base.AbstractEspressoTestClass - import org.junit.Before import org.junit.Rule import org.junit.Test @@ -16,16 +14,18 @@ internal class MainFragmentTest : AbstractEspressoTestClass() { val activityTestRule = IntentsTestRule(MainActivity::class.java, false, false) @get:Rule - val grantPermissionRule: GrantPermissionRule = GrantPermissionRule.grant(ACCESS_COARSE_LOCATION) + val grantPermissionRule: GrantPermissionRule = GrantPermissionRule.grant(ACCESS_FINE_LOCATION) private lateinit var mainRobot: MainRobot - @Before override fun setUp() { + @Before + override fun setUp() { super.setUp() mainRobot = MainRobot(activityTestRule, permissionUtil) } - @Test fun verifyOpensAddNetwork() { + @Test + fun verifyOpensAddNetwork() { with(mainRobot) { // Given launchActivity() @@ -44,7 +44,8 @@ internal class MainFragmentTest : AbstractEspressoTestClass() { } } - @Test fun verifyOpensRemoveNetwork() { + @Test + fun verifyOpensRemoveNetwork() { with(mainRobot) { // Given launchActivity() @@ -63,7 +64,8 @@ internal class MainFragmentTest : AbstractEspressoTestClass() { } } - @Test fun verifyOpensMisc() { + @Test + fun verifyOpensMisc() { with(mainRobot) { // Given launchActivity() @@ -82,7 +84,8 @@ internal class MainFragmentTest : AbstractEspressoTestClass() { } } - @Test fun verifyOpensSearch() { + @Test + fun verifyOpensSearch() { with(mainRobot) { // Given launchActivity() diff --git a/wisefysample/src/androidTest/java/com/isupatches/wisefysample/ui/main/MainRobot.kt b/wisefysample/src/androidTest/java/com/isupatches/wisefysample/ui/main/MainRobot.kt index eb52c044..9bcf00d3 100644 --- a/wisefysample/src/androidTest/java/com/isupatches/wisefysample/ui/main/MainRobot.kt +++ b/wisefysample/src/androidTest/java/com/isupatches/wisefysample/ui/main/MainRobot.kt @@ -4,7 +4,6 @@ import android.content.Intent import androidx.test.espresso.Espresso.onView import androidx.test.espresso.matcher.ViewMatchers.withId import androidx.test.rule.ActivityTestRule - import com.isupatches.wisefysample.R import com.isupatches.wisefysample.internal.base.BaseRobot import com.isupatches.wisefysample.internal.espresso.performClick @@ -67,4 +66,4 @@ internal class MainRobot( fun verifySearchWasOpened() { onView(withId(R.id.searchBtn)).performScrollToAndCheckIsDisplayed() } -} \ No newline at end of file +} diff --git a/wisefysample/src/androidTest/java/com/isupatches/wisefysample/ui/misc/MiscFragmentTest.kt b/wisefysample/src/androidTest/java/com/isupatches/wisefysample/ui/misc/MiscFragmentTest.kt index bac4f446..4abbd5b5 100644 --- a/wisefysample/src/androidTest/java/com/isupatches/wisefysample/ui/misc/MiscFragmentTest.kt +++ b/wisefysample/src/androidTest/java/com/isupatches/wisefysample/ui/misc/MiscFragmentTest.kt @@ -1,17 +1,12 @@ package com.isupatches.wisefysample.ui.misc -import android.Manifest.permission.ACCESS_COARSE_LOCATION -import android.Manifest.permission.ACCESS_NETWORK_STATE -import android.Manifest.permission.ACCESS_WIFI_STATE -import android.Manifest.permission.CHANGE_WIFI_STATE +import android.Manifest.permission.ACCESS_FINE_LOCATION import android.content.pm.PackageManager import androidx.test.espresso.intent.rule.IntentsTestRule import androidx.test.rule.GrantPermissionRule - import com.isupatches.wisefysample.RANDO_PERMISSION_REQUEST_CODE import com.isupatches.wisefysample.internal.base.AbstractEspressoTestClass import com.isupatches.wisefysample.ui.main.MainActivity - import org.junit.Before import org.junit.Rule import org.junit.Test @@ -22,114 +17,20 @@ internal class MiscFragmentTest : AbstractEspressoTestClass() { val activityTestRule = IntentsTestRule(MainActivity::class.java, false, false) @get:Rule - val grantPermissionRule: GrantPermissionRule = GrantPermissionRule.grant(ACCESS_COARSE_LOCATION) + val grantPermissionRule: GrantPermissionRule = GrantPermissionRule.grant(ACCESS_FINE_LOCATION) private lateinit var miscRobot: MiscRobot - @Before override fun setUp() { + @Before + override fun setUp() { super.setUp() miscRobot = MiscRobot(activityTestRule, wiseFy, sdkUtil, permissionUtil) } - @Test fun disableWifi_permissionErrorDialog() { - with(miscRobot) { - // Given - withPermission(CHANGE_WIFI_STATE) - launchMiscScreen() - disableWifi() - - // When - permissionCallbackTriggered( - MiscFragment.WISEFY_DISABLE_WIFI_REQUEST_CODE, - PackageManager.PERMISSION_DENIED - ) - - // Then - dismissErrorDialog() - } - } - - @Test fun disableWifi_permissionError_once() { - with(miscRobot) { - // Given - withSuccessDisablingWifi() - withPermissionDeniedOnce(CHANGE_WIFI_STATE) - launchMiscScreen() - - // When - disableWifi() - - // Then - verifyTriedToDisableWifi() - verifyWifiDisabledIsDisplayed() - dismissResultsDialog() - } - } - - @Test fun disableWifi_permissionError_emptyList() { - with(miscRobot) { - // Given - withPermission(CHANGE_WIFI_STATE) - withSuccessDisablingWifi() - launchMiscScreen() - disableWifi() - - // When - permissionCallbackTriggeredWithEmptyArray( - MiscFragment.WISEFY_DISABLE_WIFI_REQUEST_CODE - ) - - // Then - dismissErrorDialog() - verifyTriedToDisableWifi() - } - } - - @Test fun disableWifi_permissionError_permissionDenied() { - with(miscRobot) { - // Given - withPermission(CHANGE_WIFI_STATE) - withSuccessDisablingWifi() - launchMiscScreen() - disableWifi() - - // When - permissionCallbackTriggered( - MiscFragment.WISEFY_DISABLE_WIFI_REQUEST_CODE, - PackageManager.PERMISSION_DENIED - ) - - // Then - dismissErrorDialog() - verifyTriedToDisableWifi() - } - } - - @Test fun disableWifi_success_afterPermissionGranted() { + @Test + fun disableWifi_success() { with(miscRobot) { // Given - withPermission(CHANGE_WIFI_STATE) - withSuccessDisablingWifi() - launchMiscScreen() - disableWifi() - - // When - permissionCallbackTriggered( - MiscFragment.WISEFY_DISABLE_WIFI_REQUEST_CODE, - PackageManager.PERMISSION_GRANTED - ) - - // Then - verifyTriedToDisableWifi(times = 2) - verifyWifiDisabledIsDisplayed() - dismissResultsDialog() - } - } - - @Test fun disableWifi_success() { - with(miscRobot) { - // Given - withPermissionDeniedOnce(CHANGE_WIFI_STATE) withSuccessDisablingWifi() launchMiscScreen() @@ -143,10 +44,10 @@ internal class MiscFragmentTest : AbstractEspressoTestClass() { } } - @Test fun disableWifi_failureDisablingWifi() { + @Test + fun disableWifi_failureDisablingWifi() { with(miscRobot) { // Given - withPermission(CHANGE_WIFI_STATE) withFailureDisablingWifi() launchMiscScreen() @@ -160,10 +61,10 @@ internal class MiscFragmentTest : AbstractEspressoTestClass() { } } - @Test fun disableWifi_wiseFyFailure() { + @Test + fun disableWifi_wiseFyFailure() { with(miscRobot) { // Given - withPermission(CHANGE_WIFI_STATE) withWiseFyFailureDisablingWifi() launchMiscScreen() @@ -179,105 +80,10 @@ internal class MiscFragmentTest : AbstractEspressoTestClass() { } } - @Test fun enableWifi_permissionErrorDialog() { - with(miscRobot) { - // Given - withPermission(CHANGE_WIFI_STATE) - launchMiscScreen() - enableWifi() - - // When - permissionCallbackTriggered( - MiscFragment.WISEFY_ENABLE_WIFI_REQUEST_CODE, - PackageManager.PERMISSION_DENIED - ) - - // Then - dismissErrorDialog() - } - } - - @Test fun enableWifi_permissionError_once() { - with(miscRobot) { - // Given - withSuccessEnablingWifi() - withPermissionDeniedOnce(CHANGE_WIFI_STATE) - launchMiscScreen() - - // When - enableWifi() - - // Then - verifyTriedToEnableWifi() - verifyWifiEnabledIsDisplayed() - dismissResultsDialog() - } - } - - @Test fun enableWifi_permissionError_emptyList() { - with(miscRobot) { - // Given - withPermission(CHANGE_WIFI_STATE) - withSuccessEnablingWifi() - launchMiscScreen() - enableWifi() - - // When - permissionCallbackTriggeredWithEmptyArray( - MiscFragment.WISEFY_ENABLE_WIFI_REQUEST_CODE - ) - - // Then - dismissErrorDialog() - verifyTriedToEnableWifi() - } - } - - @Test fun enableWifi_permissionError_permissionDenied() { + @Test + fun enableWifi_success() { with(miscRobot) { // Given - withPermission(CHANGE_WIFI_STATE) - withSuccessEnablingWifi() - launchMiscScreen() - enableWifi() - - // When - permissionCallbackTriggered( - MiscFragment.WISEFY_ENABLE_WIFI_REQUEST_CODE, - PackageManager.PERMISSION_DENIED - ) - - // Then - dismissErrorDialog() - verifyTriedToEnableWifi() - } - } - - @Test fun enableWifi_success_afterPermissionGranted() { - with(miscRobot) { - // Given - withPermission(CHANGE_WIFI_STATE) - withSuccessEnablingWifi() - launchMiscScreen() - enableWifi() - - // When - permissionCallbackTriggered( - MiscFragment.WISEFY_ENABLE_WIFI_REQUEST_CODE, - PackageManager.PERMISSION_GRANTED - ) - - // Then - verifyTriedToEnableWifi(times = 2) - verifyWifiEnabledIsDisplayed() - dismissResultsDialog() - } - } - - @Test fun enableWifi_success() { - with(miscRobot) { - // Given - withPermission(CHANGE_WIFI_STATE) withSuccessEnablingWifi() launchMiscScreen() @@ -291,10 +97,10 @@ internal class MiscFragmentTest : AbstractEspressoTestClass() { } } - @Test fun enableWifi_failureEnablingWifi() { + @Test + fun enableWifi_failureEnablingWifi() { with(miscRobot) { // Given - withPermission(CHANGE_WIFI_STATE) withFailureEnablingWifi() launchMiscScreen() @@ -308,10 +114,10 @@ internal class MiscFragmentTest : AbstractEspressoTestClass() { } } - @Test fun enableWifi_wiseFyFailure() { + @Test + fun enableWifi_wiseFyFailure() { with(miscRobot) { // Given - withPermission(CHANGE_WIFI_STATE) withWiseFyFailureEnablingWifi() launchMiscScreen() @@ -327,48 +133,11 @@ internal class MiscFragmentTest : AbstractEspressoTestClass() { } } - @Test fun getCurrentNetwork_permissionErrorDialog() { - with(miscRobot) { - // Given - withPermissions(ACCESS_WIFI_STATE, ACCESS_COARSE_LOCATION) - launchMiscScreen() - getCurrentNetwork() - - // When - permissionCallbackTriggered( - MiscFragment.WISEFY_GET_NEARBY_ACCESS_POINTS_REQUEST_CODE, - PackageManager.PERMISSION_DENIED - ) - - // Then - dismissErrorDialog() - } - } - - @Test fun getCurrentNetwork_permissionError_once() { - with(miscRobot) { - // Given - withSuccessGettingCurrentNetwork() - withPermissionDeniedOnce(ACCESS_WIFI_STATE) - withPermissionDeniedOnce(ACCESS_COARSE_LOCATION) - launchMiscScreen() - - // When - getCurrentNetwork() - - // Then - verifyTriedToGetCurrentNetwork() - verifyCurrentNetworkIsDisplayed() - dismissResultsDialog() - } - } - - @Test fun getCurrentNetwork_permissionError_once_accessWifiState() { + @Test + fun getCurrentNetwork_success() { with(miscRobot) { // Given withSuccessGettingCurrentNetwork() - withPermissionDeniedOnce(ACCESS_WIFI_STATE) - withPermission(ACCESS_COARSE_LOCATION) launchMiscScreen() // When @@ -381,105 +150,10 @@ internal class MiscFragmentTest : AbstractEspressoTestClass() { } } - @Test fun getCurrentNetwork_permissionError_once_accessCoarseLocation() { + @Test + fun getCurrentNetwork_noCurrentNetwork() { with(miscRobot) { // Given - withSuccessGettingCurrentNetwork() - withPermission(ACCESS_WIFI_STATE) - withPermissionDeniedOnce(ACCESS_COARSE_LOCATION) - launchMiscScreen() - - // When - getCurrentNetwork() - - // Then - verifyTriedToGetCurrentNetwork() - verifyCurrentNetworkIsDisplayed() - dismissResultsDialog() - } - } - - @Test fun getCurrentNetwork_permissionError_emptyList() { - with(miscRobot) { - // Given - withPermissions(ACCESS_WIFI_STATE, ACCESS_COARSE_LOCATION) - withSuccessGettingCurrentNetwork() - launchMiscScreen() - getCurrentNetwork() - - // When - permissionCallbackTriggeredWithEmptyArray( - MiscFragment.WISEFY_GET_CURRENT_NETWORK_REQUEST_CODE - ) - - // Then - dismissErrorDialog() - verifyTriedToGetCurrentNetwork() - } - } - - @Test fun getCurrentNetwork_permissionError_permissionDenied() { - with(miscRobot) { - // Given - withPermissions(ACCESS_WIFI_STATE, ACCESS_COARSE_LOCATION) - withSuccessGettingCurrentNetwork() - launchMiscScreen() - getCurrentNetwork() - - // When - permissionCallbackTriggered( - MiscFragment.WISEFY_GET_CURRENT_NETWORK_REQUEST_CODE, - PackageManager.PERMISSION_DENIED - ) - - // Then - dismissErrorDialog() - verifyTriedToGetCurrentNetwork() - } - } - - @Test fun getCurrentNetwork_success_afterPermissionGranted() { - with(miscRobot) { - // Given - withPermissions(ACCESS_WIFI_STATE, ACCESS_COARSE_LOCATION) - withSuccessGettingCurrentNetwork() - launchMiscScreen() - getCurrentNetwork() - - // When - permissionCallbackTriggered( - MiscFragment.WISEFY_GET_CURRENT_NETWORK_REQUEST_CODE, - PackageManager.PERMISSION_GRANTED - ) - - // Then - verifyTriedToGetCurrentNetwork(times = 2) - verifyCurrentNetworkIsDisplayed() - dismissResultsDialog() - } - } - - @Test fun getCurrentNetwork_success() { - with(miscRobot) { - // Given - withPermissions(ACCESS_WIFI_STATE, ACCESS_COARSE_LOCATION) - withSuccessGettingCurrentNetwork() - launchMiscScreen() - - // When - getCurrentNetwork() - - // Then - verifyTriedToGetCurrentNetwork() - verifyCurrentNetworkIsDisplayed() - dismissResultsDialog() - } - } - - @Test fun getCurrentNetwork_noCurrentNetwork() { - with(miscRobot) { - // Given - withPermissions(ACCESS_WIFI_STATE, ACCESS_COARSE_LOCATION) withNoCurrentNetwork() launchMiscScreen() @@ -493,10 +167,10 @@ internal class MiscFragmentTest : AbstractEspressoTestClass() { } } - @Test fun getCurrentNetwork_wiseFyFailure() { + @Test + fun getCurrentNetwork_wiseFyFailure() { with(miscRobot) { // Given - withPermissions(ACCESS_WIFI_STATE, ACCESS_COARSE_LOCATION) withWiseFyFailureGettingCurrentNetwork() launchMiscScreen() @@ -512,105 +186,10 @@ internal class MiscFragmentTest : AbstractEspressoTestClass() { } } - @Test fun getCurrentNetworkInfo_permissionErrorDialog() { - with(miscRobot) { - // Given - withPermission(ACCESS_NETWORK_STATE) - launchMiscScreen() - getCurrentNetworkInfo() - - // When - permissionCallbackTriggered( - MiscFragment.WISEFY_GET_CURRENT_NETWORK_INFO_REQUEST_CODE, - PackageManager.PERMISSION_DENIED - ) - - // Then - dismissErrorDialog() - } - } - - @Test fun getCurrentNetworkInfo_permissionError_once() { - with(miscRobot) { - // Given - withSuccessGettingCurrentNetworkInfo() - withPermissionDeniedOnce(ACCESS_NETWORK_STATE) - launchMiscScreen() - - // When - getCurrentNetworkInfo() - - // Then - verifyTriedToGetCurrentNetworkInfo() - verifyCurrentNetworkInfoIsDisplayed() - dismissResultsDialog() - } - } - - @Test fun getCurrentNetworkInfo_permissionError_emptyList() { - with(miscRobot) { - // Given - withPermission(ACCESS_NETWORK_STATE) - withSuccessGettingCurrentNetworkInfo() - launchMiscScreen() - getCurrentNetworkInfo() - - // When - permissionCallbackTriggeredWithEmptyArray( - MiscFragment.WISEFY_GET_CURRENT_NETWORK_INFO_REQUEST_CODE - ) - - // Then - dismissErrorDialog() - verifyTriedToGetCurrentNetworkInfo() - } - } - - @Test fun getCurrentNetworkInfo_permissionError_permissionDenied() { + @Test + fun getCurrentNetworkInfo_success() { with(miscRobot) { // Given - withPermission(ACCESS_NETWORK_STATE) - withSuccessGettingCurrentNetworkInfo() - launchMiscScreen() - getCurrentNetworkInfo() - - // When - permissionCallbackTriggered( - MiscFragment.WISEFY_GET_CURRENT_NETWORK_INFO_REQUEST_CODE, - PackageManager.PERMISSION_DENIED - ) - - // Then - dismissErrorDialog() - verifyTriedToGetCurrentNetworkInfo() - } - } - - @Test fun getCurrentNetworkInfo_success_afterPermissionGranted() { - with(miscRobot) { - // Given - withPermission(ACCESS_NETWORK_STATE) - withSuccessGettingCurrentNetworkInfo() - launchMiscScreen() - getCurrentNetworkInfo() - - // When - permissionCallbackTriggered( - MiscFragment.WISEFY_GET_CURRENT_NETWORK_INFO_REQUEST_CODE, - PackageManager.PERMISSION_GRANTED - ) - - // Then - verifyTriedToGetCurrentNetworkInfo(times = 2) - verifyCurrentNetworkInfoIsDisplayed() - dismissResultsDialog() - } - } - - @Test fun getCurrentNetworkInfo_success() { - with(miscRobot) { - // Given - withPermission(ACCESS_NETWORK_STATE) withSuccessGettingCurrentNetworkInfo() launchMiscScreen() @@ -624,10 +203,10 @@ internal class MiscFragmentTest : AbstractEspressoTestClass() { } } - @Test fun getCurrentNetworkInfo_noCurrentNetworkInfo() { + @Test + fun getCurrentNetworkInfo_noCurrentNetworkInfo() { with(miscRobot) { // Given - withPermission(ACCESS_NETWORK_STATE) withNoCurrentNetworkInfo() launchMiscScreen() @@ -641,10 +220,10 @@ internal class MiscFragmentTest : AbstractEspressoTestClass() { } } - @Test fun getCurrentNetworkInfo_wiseFyFailure() { + @Test + fun getCurrentNetworkInfo_wiseFyFailure() { with(miscRobot) { // Given - withPermission(ACCESS_NETWORK_STATE) withWiseFyFailureGettingCurrentNetworkInfo() launchMiscScreen() @@ -660,11 +239,12 @@ internal class MiscFragmentTest : AbstractEspressoTestClass() { } } - @Test fun getFrequency_belowLollipop() { + @Test + fun getFrequency_belowLollipop() { with(miscRobot) { // Given withDeviceBelowLollipop() - withPermissions(ACCESS_WIFI_STATE, ACCESS_COARSE_LOCATION) + withPermission(ACCESS_FINE_LOCATION) launchMiscScreen() // When @@ -676,13 +256,11 @@ internal class MiscFragmentTest : AbstractEspressoTestClass() { } } - @Test fun getFrequency_permissionErrorDialog() { + @Test + fun getFrequency_permissionErrorDialog() { with(miscRobot) { // Given - withDeviceLollipopOrHigher() - withPermissions(ACCESS_WIFI_STATE, ACCESS_COARSE_LOCATION) launchMiscScreen() - getFrequency() // When permissionCallbackTriggered( @@ -695,31 +273,13 @@ internal class MiscFragmentTest : AbstractEspressoTestClass() { } } - @Test fun getFrequency_permissionError_once() { + @Test + fun getFrequency_permissionError_once_accessFineLocation() { with(miscRobot) { // Given withDeviceLollipopOrHigher() withSuccessGettingFrequency() - withPermissionDeniedOnce(ACCESS_WIFI_STATE) - withPermissionDeniedOnce(ACCESS_COARSE_LOCATION) - launchMiscScreen() - - // When - getFrequency() - - // Then - verifyTriedToGetFrequency() - dismissResultsDialog() - } - } - - @Test fun getFrequency_permissionError_once_accessWifiState() { - with(miscRobot) { - // Given - withDeviceLollipopOrHigher() - withSuccessGettingFrequency() - withPermissionDeniedOnce(ACCESS_WIFI_STATE) - withPermission(ACCESS_COARSE_LOCATION) + withPermissionDeniedOnce(ACCESS_FINE_LOCATION) launchMiscScreen() // When @@ -732,34 +292,12 @@ internal class MiscFragmentTest : AbstractEspressoTestClass() { } } - @Test fun getFrequency_permissionError_once_accessCoarseLocation() { + @Test + fun getFrequency_permissionError_emptyList() { with(miscRobot) { // Given - withDeviceLollipopOrHigher() - withSuccessGettingFrequency() - withPermission(ACCESS_WIFI_STATE) - withPermissionDeniedOnce(ACCESS_COARSE_LOCATION) launchMiscScreen() - // When - getFrequency() - - // Then - verifyTriedToGetFrequency() - verifyFrequencyIsDisplayed() - dismissResultsDialog() - } - } - - @Test fun getFrequency_permissionError_emptyList() { - with(miscRobot) { - // Given - withDeviceLollipopOrHigher() - withPermissions(ACCESS_WIFI_STATE, ACCESS_COARSE_LOCATION) - withSuccessGettingFrequency() - launchMiscScreen() - getFrequency() - // When permissionCallbackTriggeredWithEmptyArray( MiscFragment.WISEFY_GET_FREQUENCY_REQUEST_CODE @@ -767,18 +305,14 @@ internal class MiscFragmentTest : AbstractEspressoTestClass() { // Then dismissErrorDialog() - verifyTriedToGetFrequency() } } - @Test fun getFrequency_permissionError_permissionDenied() { + @Test + fun getFrequency_permissionError_permissionDenied() { with(miscRobot) { // Given - withDeviceLollipopOrHigher() - withPermissions(ACCESS_WIFI_STATE, ACCESS_COARSE_LOCATION) - withSuccessGettingFrequency() launchMiscScreen() - getFrequency() // When permissionCallbackTriggered( @@ -788,18 +322,17 @@ internal class MiscFragmentTest : AbstractEspressoTestClass() { // Then dismissErrorDialog() - verifyTriedToGetFrequency() } } - @Test fun getFrequency_success_afterPermissionGranted() { + @Test + fun getFrequency_success_afterPermissionGranted() { with(miscRobot) { // Given withDeviceLollipopOrHigher() - withPermissions(ACCESS_WIFI_STATE, ACCESS_COARSE_LOCATION) + withPermission(ACCESS_FINE_LOCATION) withSuccessGettingFrequency() launchMiscScreen() - getFrequency() // When permissionCallbackTriggered( @@ -808,16 +341,17 @@ internal class MiscFragmentTest : AbstractEspressoTestClass() { ) // Then - verifyTriedToGetFrequency(times = 2) + verifyTriedToGetFrequency() dismissResultsDialog() } } - @Test fun getFrequency_success() { + @Test + fun getFrequency_success() { with(miscRobot) { // Given withDeviceLollipopOrHigher() - withPermissions(ACCESS_WIFI_STATE, ACCESS_COARSE_LOCATION) + withPermission(ACCESS_FINE_LOCATION) withSuccessGettingFrequency() launchMiscScreen() @@ -831,11 +365,12 @@ internal class MiscFragmentTest : AbstractEspressoTestClass() { } } - @Test fun getFrequency_failureGettingFrequency() { + @Test + fun getFrequency_failureGettingFrequency() { with(miscRobot) { // Given withDeviceLollipopOrHigher() - withPermissions(ACCESS_WIFI_STATE, ACCESS_COARSE_LOCATION) + withPermission(ACCESS_FINE_LOCATION) withFailureGettingFrequency() launchMiscScreen() @@ -849,11 +384,12 @@ internal class MiscFragmentTest : AbstractEspressoTestClass() { } } - @Test fun getFrequency_wiseFyFailure() { + @Test + fun getFrequency_wiseFyFailure() { with(miscRobot) { // Given withDeviceLollipopOrHigher() - withPermissions(ACCESS_WIFI_STATE, ACCESS_COARSE_LOCATION) + withPermission(ACCESS_FINE_LOCATION) withWiseFyFailureGettingFrequency() launchMiscScreen() @@ -863,18 +399,15 @@ internal class MiscFragmentTest : AbstractEspressoTestClass() { // Then verifyWiseFyFailureIsDisplayed() verifyTriedToGetFrequency() - - // And - dismissErrorDialog() + dismissResultsDialog() } } - @Test fun getIP_permissionErrorDialog() { + @Test + fun getIP_permissionErrorDialog() { with(miscRobot) { // Given - withPermissions(ACCESS_WIFI_STATE, ACCESS_COARSE_LOCATION) launchMiscScreen() - getIP() // When permissionCallbackTriggered( @@ -887,30 +420,12 @@ internal class MiscFragmentTest : AbstractEspressoTestClass() { } } - @Test fun getIP_permissionError_once() { - with(miscRobot) { - // Given - withSuccessGettingIP() - withPermissionDeniedOnce(ACCESS_WIFI_STATE) - withPermissionDeniedOnce(ACCESS_COARSE_LOCATION) - launchMiscScreen() - - // When - getIP() - - // Then - verifyTriedToGetIP() - verifyIPIsDisplayed() - dismissResultsDialog() - } - } - - @Test fun getIP_permissionError_once_accessWifiState() { + @Test + fun getIP_permissionError_once_accessFineLocation() { with(miscRobot) { // Given withSuccessGettingIP() - withPermissionDeniedOnce(ACCESS_WIFI_STATE) - withPermission(ACCESS_COARSE_LOCATION) + withPermissionDeniedOnce(ACCESS_FINE_LOCATION) launchMiscScreen() // When @@ -923,32 +438,12 @@ internal class MiscFragmentTest : AbstractEspressoTestClass() { } } - @Test fun getIP_permissionError_once_accessCoarseLocation() { + @Test + fun getIP_permissionError_emptyList() { with(miscRobot) { // Given - withSuccessGettingIP() - withPermission(ACCESS_WIFI_STATE) - withPermissionDeniedOnce(ACCESS_COARSE_LOCATION) launchMiscScreen() - // When - getIP() - - // Then - verifyTriedToGetIP() - verifyIPIsDisplayed() - dismissResultsDialog() - } - } - - @Test fun getIP_permissionError_emptyList() { - with(miscRobot) { - // Given - withPermissions(ACCESS_WIFI_STATE, ACCESS_COARSE_LOCATION) - withSuccessGettingIP() - launchMiscScreen() - getIP() - // When permissionCallbackTriggeredWithEmptyArray( MiscFragment.WISEFY_GET_IP_REQUEST_CODE @@ -956,17 +451,14 @@ internal class MiscFragmentTest : AbstractEspressoTestClass() { // Then dismissErrorDialog() - verifyTriedToGetIP() } } - @Test fun getIP_permissionError_permissionDenied() { + @Test + fun getIP_permissionError_permissionDenied() { with(miscRobot) { // Given - withPermissions(ACCESS_WIFI_STATE, ACCESS_COARSE_LOCATION) - withSuccessGettingIP() launchMiscScreen() - getIP() // When permissionCallbackTriggered( @@ -976,17 +468,16 @@ internal class MiscFragmentTest : AbstractEspressoTestClass() { // Then dismissErrorDialog() - verifyTriedToGetIP() } } - @Test fun getIP_success_afterPermissionGranted() { + @Test + fun getIP_success_afterPermissionGranted() { with(miscRobot) { // Given - withPermissions(ACCESS_WIFI_STATE, ACCESS_COARSE_LOCATION) + withPermission(ACCESS_FINE_LOCATION) withSuccessGettingIP() launchMiscScreen() - getIP() // When permissionCallbackTriggered( @@ -995,16 +486,17 @@ internal class MiscFragmentTest : AbstractEspressoTestClass() { ) // Then - verifyTriedToGetIP(times = 2) + verifyTriedToGetIP() verifyIPIsDisplayed() dismissResultsDialog() } } - @Test fun getIP_success() { + @Test + fun getIP_success() { with(miscRobot) { // Given - withPermissions(ACCESS_WIFI_STATE, ACCESS_COARSE_LOCATION) + withPermission(ACCESS_FINE_LOCATION) withSuccessGettingIP() launchMiscScreen() @@ -1018,10 +510,11 @@ internal class MiscFragmentTest : AbstractEspressoTestClass() { } } - @Test fun getIP_failureGettingIp() { + @Test + fun getIP_failureGettingIp() { with(miscRobot) { // Given - withPermissions(ACCESS_WIFI_STATE, ACCESS_COARSE_LOCATION) + withPermission(ACCESS_FINE_LOCATION) withFailureGettingIP() launchMiscScreen() @@ -1035,10 +528,11 @@ internal class MiscFragmentTest : AbstractEspressoTestClass() { } } - @Test fun getIP_wiseFyFailure() { + @Test + fun getIP_wiseFyFailure() { with(miscRobot) { // Given - withPermissions(ACCESS_WIFI_STATE, ACCESS_COARSE_LOCATION) + withPermission(ACCESS_FINE_LOCATION) withWiseFyFailureGettingIP() launchMiscScreen() @@ -1054,12 +548,11 @@ internal class MiscFragmentTest : AbstractEspressoTestClass() { } } - @Test fun getNearbyAccessPoints_permissionErrorDialog() { + @Test + fun getNearbyAccessPoints_permissionErrorDialog() { with(miscRobot) { // Given - withPermissions(ACCESS_WIFI_STATE, ACCESS_COARSE_LOCATION) launchMiscScreen() - getNearbyAccessPoints() // When permissionCallbackTriggered( @@ -1072,48 +565,12 @@ internal class MiscFragmentTest : AbstractEspressoTestClass() { } } - @Test fun getNearbyAccessPoints_permissionError_once() { - with(miscRobot) { - // Given - withSuccessGettingNearbyAccessPoints() - withPermissionDeniedOnce(ACCESS_WIFI_STATE) - withPermissionDeniedOnce(ACCESS_COARSE_LOCATION) - launchMiscScreen() - - // When - getNearbyAccessPoints() - - // Then - verifyTriedToGetNearbyAccessPoints() - verifyAccessPointsAreDisplayed() - dismissResultsDialog() - } - } - - @Test fun getNearbyAccessPoints_permissionError_once_accessWifiState() { - with(miscRobot) { - // Given - withSuccessGettingNearbyAccessPoints() - withPermissionDeniedOnce(ACCESS_WIFI_STATE) - withPermission(ACCESS_COARSE_LOCATION) - launchMiscScreen() - - // When - getNearbyAccessPoints() - - // Then - verifyTriedToGetNearbyAccessPoints() - verifyAccessPointsAreDisplayed() - dismissResultsDialog() - } - } - - @Test fun getNearbyAccessPoints_permissionError_once_accessCoarseLocation() { + @Test + fun getNearbyAccessPoints_permissionError_once_accessFineLocation() { with(miscRobot) { // Given withSuccessGettingNearbyAccessPoints() - withPermission(ACCESS_WIFI_STATE) - withPermissionDeniedOnce(ACCESS_COARSE_LOCATION) + withPermissionDeniedOnce(ACCESS_FINE_LOCATION) launchMiscScreen() // When @@ -1126,13 +583,11 @@ internal class MiscFragmentTest : AbstractEspressoTestClass() { } } - @Test fun getNearbyAccessPoints_permissionError_emptyList() { + @Test + fun getNearbyAccessPoints_permissionError_emptyList() { with(miscRobot) { // Given - withPermissions(ACCESS_WIFI_STATE, ACCESS_COARSE_LOCATION) - withSuccessGettingNearbyAccessPoints() launchMiscScreen() - getNearbyAccessPoints() // When permissionCallbackTriggeredWithEmptyArray( @@ -1141,17 +596,14 @@ internal class MiscFragmentTest : AbstractEspressoTestClass() { // Then dismissErrorDialog() - verifyTriedToGetNearbyAccessPoints() } } - @Test fun getNearbyAccessPoints_permissionError_permissionDenied() { + @Test + fun getNearbyAccessPoints_permissionError_permissionDenied() { with(miscRobot) { // Given - withPermissions(ACCESS_WIFI_STATE, ACCESS_COARSE_LOCATION) - withSuccessGettingNearbyAccessPoints() launchMiscScreen() - getNearbyAccessPoints() // When permissionCallbackTriggered( @@ -1161,17 +613,16 @@ internal class MiscFragmentTest : AbstractEspressoTestClass() { // Then dismissErrorDialog() - verifyTriedToGetNearbyAccessPoints() } } - @Test fun getNearbyAccessPoints_success_afterPermissionGranted() { + @Test + fun getNearbyAccessPoints_success_afterPermissionGranted() { with(miscRobot) { // Given - withPermissions(ACCESS_WIFI_STATE, ACCESS_COARSE_LOCATION) + withPermission(ACCESS_FINE_LOCATION) withSuccessGettingNearbyAccessPoints() launchMiscScreen() - getNearbyAccessPoints() // When permissionCallbackTriggered( @@ -1180,16 +631,17 @@ internal class MiscFragmentTest : AbstractEspressoTestClass() { ) // Then - verifyTriedToGetNearbyAccessPoints(times = 2) + verifyTriedToGetNearbyAccessPoints() verifyAccessPointsAreDisplayed() dismissResultsDialog() } } - @Test fun getNearbyAccessPoints_success() { + @Test + fun getNearbyAccessPoints_success() { with(miscRobot) { // Given - withPermissions(ACCESS_WIFI_STATE, ACCESS_COARSE_LOCATION) + withPermission(ACCESS_FINE_LOCATION) withSuccessGettingNearbyAccessPoints() launchMiscScreen() @@ -1203,10 +655,11 @@ internal class MiscFragmentTest : AbstractEspressoTestClass() { } } - @Test fun getNearbyAccessPoints_noNearbyAccessPoints() { + @Test + fun getNearbyAccessPoints_noNearbyAccessPoints() { with(miscRobot) { // Given - withPermissions(ACCESS_WIFI_STATE, ACCESS_COARSE_LOCATION) + withPermission(ACCESS_FINE_LOCATION) withNoNearbyAccessPoints() launchMiscScreen() @@ -1220,10 +673,11 @@ internal class MiscFragmentTest : AbstractEspressoTestClass() { } } - @Test fun getNearbyAccessPoints_wiseFyFailure() { + @Test + fun getNearbyAccessPoints_wiseFyFailure() { with(miscRobot) { // Given - withPermissions(ACCESS_WIFI_STATE, ACCESS_COARSE_LOCATION) + withPermission(ACCESS_FINE_LOCATION) withWiseFyFailureGettingNearbyAccessPoints() launchMiscScreen() @@ -1239,12 +693,11 @@ internal class MiscFragmentTest : AbstractEspressoTestClass() { } } - @Test fun getSavedNetworks_permissionErrorDialog() { + @Test + fun getSavedNetworks_permissionErrorDialog() { with(miscRobot) { // Given - withPermission(ACCESS_WIFI_STATE) launchMiscScreen() - getSavedNetworks() // When permissionCallbackTriggered( @@ -1257,11 +710,12 @@ internal class MiscFragmentTest : AbstractEspressoTestClass() { } } - @Test fun getSavedNetworks_permissionError_once() { + @Test + fun getSavedNetworks_permissionError_once() { with(miscRobot) { // Given withSuccessGettingSavedNetworks() - withPermissionDeniedOnce(ACCESS_WIFI_STATE) + withPermissionDeniedOnce(ACCESS_FINE_LOCATION) launchMiscScreen() // When @@ -1274,13 +728,11 @@ internal class MiscFragmentTest : AbstractEspressoTestClass() { } } - @Test fun getSavedNetworks_permissionError_emptyList() { + @Test + fun getSavedNetworks_permissionError_emptyList() { with(miscRobot) { // Given - withPermission(ACCESS_WIFI_STATE) - withSuccessGettingCurrentNetworkInfo() launchMiscScreen() - getSavedNetworks() // When permissionCallbackTriggeredWithEmptyArray( @@ -1289,17 +741,14 @@ internal class MiscFragmentTest : AbstractEspressoTestClass() { // Then dismissErrorDialog() - verifyTriedToGetSavedNetworks() } } - @Test fun getSavedNetworks_permissionError_permissionDenied() { + @Test + fun getSavedNetworks_permissionError_permissionDenied() { with(miscRobot) { // Given - withPermission(ACCESS_WIFI_STATE) - withSuccessGettingCurrentNetworkInfo() launchMiscScreen() - getSavedNetworks() // When permissionCallbackTriggered( @@ -1309,17 +758,16 @@ internal class MiscFragmentTest : AbstractEspressoTestClass() { // Then dismissErrorDialog() - verifyTriedToGetSavedNetworks() } } - @Test fun getSavedNetworks_success_afterPermissionGranted() { + @Test + fun getSavedNetworks_success_afterPermissionGranted() { with(miscRobot) { // Given - withPermission(ACCESS_WIFI_STATE) + withPermission(ACCESS_FINE_LOCATION) withSuccessGettingSavedNetworks() launchMiscScreen() - getSavedNetworks() // When permissionCallbackTriggered( @@ -1328,16 +776,17 @@ internal class MiscFragmentTest : AbstractEspressoTestClass() { ) // Then - verifyTriedToGetSavedNetworks(times = 2) + verifyTriedToGetSavedNetworks() verifySavedNetworksAreDisplayed() dismissResultsDialog() } } - @Test fun getSavedNetworks_success() { + @Test + fun getSavedNetworks_success() { with(miscRobot) { // Given - withPermission(ACCESS_WIFI_STATE) + withPermission(ACCESS_FINE_LOCATION) withSuccessGettingSavedNetworks() launchMiscScreen() @@ -1351,10 +800,11 @@ internal class MiscFragmentTest : AbstractEspressoTestClass() { } } - @Test fun getSavedNetworks_noSavedNetworks() { + @Test + fun getSavedNetworks_noSavedNetworks() { with(miscRobot) { // Given - withPermission(ACCESS_WIFI_STATE) + withPermission(ACCESS_FINE_LOCATION) withNoSavedNetworks() launchMiscScreen() @@ -1368,10 +818,11 @@ internal class MiscFragmentTest : AbstractEspressoTestClass() { } } - @Test fun getSavedNetworks_wiseFyFailure() { + @Test + fun getSavedNetworks_wiseFyFailure() { with(miscRobot) { // Given - withPermission(ACCESS_WIFI_STATE) + withPermission(ACCESS_FINE_LOCATION) withWiseFyFailureGettingSavedNetworks() launchMiscScreen() @@ -1387,7 +838,8 @@ internal class MiscFragmentTest : AbstractEspressoTestClass() { } } - @Test fun ridiculousPermissionRequested() { + @Test + fun ridiculousPermissionRequested() { with(miscRobot) { // Given launchMiscScreen() diff --git a/wisefysample/src/androidTest/java/com/isupatches/wisefysample/ui/misc/MiscRobot.kt b/wisefysample/src/androidTest/java/com/isupatches/wisefysample/ui/misc/MiscRobot.kt index 211698e1..c7f5adb1 100644 --- a/wisefysample/src/androidTest/java/com/isupatches/wisefysample/ui/misc/MiscRobot.kt +++ b/wisefysample/src/androidTest/java/com/isupatches/wisefysample/ui/misc/MiscRobot.kt @@ -9,7 +9,6 @@ import androidx.test.espresso.Espresso.onView import androidx.test.espresso.matcher.ViewMatchers.withId import androidx.test.espresso.matcher.ViewMatchers.withText import androidx.test.rule.ActivityTestRule - import com.isupatches.wisefy.WiseFy.Companion.MIN_FREQUENCY_5GHZ import com.isupatches.wisefy.WiseFyPublicApi import com.isupatches.wisefy.callbacks.DisableWifiCallbacks @@ -31,18 +30,16 @@ import com.isupatches.wisefysample.internal.espresso.performScrollToAndClick import com.isupatches.wisefysample.internal.util.PermissionUtil import com.isupatches.wisefysample.internal.util.SdkUtil import com.isupatches.wisefysample.ui.main.MainActivity - import com.nhaarman.mockitokotlin2.any import com.nhaarman.mockitokotlin2.doAnswer import com.nhaarman.mockitokotlin2.eq +import com.nhaarman.mockitokotlin2.given import com.nhaarman.mockitokotlin2.mock import com.nhaarman.mockitokotlin2.timeout import com.nhaarman.mockitokotlin2.verify import com.nhaarman.mockitokotlin2.whenever import org.hamcrest.CoreMatchers.containsString -import org.mockito.Mockito.`when` - internal class MiscRobot( private val activityTestRule: ActivityTestRule, private val wiseFyPublicApi: WiseFyPublicApi, @@ -231,11 +228,11 @@ internal class MiscRobot( } fun withDeviceBelowLollipop() { - `when`(sdkUtil.isAtLeastLollipop()).thenReturn(false) + given(sdkUtil.isAtLeastLollipop()).willReturn(false) } fun withDeviceLollipopOrHigher() { - `when`(sdkUtil.isAtLeastLollipop()).thenReturn(true) + given(sdkUtil.isAtLeastLollipop()).willReturn(true) } /* @@ -303,16 +300,16 @@ internal class MiscRobot( fun permissionCallbackTriggeredWithEmptyArray(requestCode: Int) { val activity = activityTestRule.activity val fragment: MiscFragment? = activity - .supportFragmentManager - .findFragmentByTag( - MiscFragment.TAG - ) as? MiscFragment + .supportFragmentManager + .findFragmentByTag( + MiscFragment.TAG + ) as? MiscFragment activity.runOnUiThread { fragment?.onRequestPermissionsResult( - requestCode, - emptyArray(), - intArrayOf() + requestCode, + emptyArray(), + intArrayOf() ) } } @@ -404,7 +401,6 @@ internal class MiscRobot( fun verifyFrequencyLollipopNoticeIsDisplayed() { onView(withText( activityTestRule.getString(R.string.frequency_lollipop_notice) - )) - .checkIsDisplayed() + )).checkIsDisplayed() } } diff --git a/wisefysample/src/androidTest/java/com/isupatches/wisefysample/ui/remove/RemoveNetworkFragmentTest.kt b/wisefysample/src/androidTest/java/com/isupatches/wisefysample/ui/remove/RemoveNetworkFragmentTest.kt index 13009197..ce72de4c 100644 --- a/wisefysample/src/androidTest/java/com/isupatches/wisefysample/ui/remove/RemoveNetworkFragmentTest.kt +++ b/wisefysample/src/androidTest/java/com/isupatches/wisefysample/ui/remove/RemoveNetworkFragmentTest.kt @@ -1,13 +1,12 @@ package com.isupatches.wisefysample.ui.remove -import android.Manifest.permission.ACCESS_WIFI_STATE +import android.Manifest.permission.ACCESS_FINE_LOCATION import android.content.pm.PackageManager import androidx.test.espresso.intent.rule.IntentsTestRule - +import androidx.test.rule.GrantPermissionRule import com.isupatches.wisefysample.RANDO_PERMISSION_REQUEST_CODE import com.isupatches.wisefysample.internal.base.AbstractEspressoTestClass import com.isupatches.wisefysample.ui.main.MainActivity - import org.junit.Before import org.junit.Rule import org.junit.Test @@ -17,9 +16,13 @@ internal class RemoveNetworkFragmentTest : AbstractEspressoTestClass() { @get:Rule val activityTestRule = IntentsTestRule(MainActivity::class.java, false, false) + @get:Rule + val grantPermissionRule: GrantPermissionRule = GrantPermissionRule.grant(ACCESS_FINE_LOCATION) + private lateinit var removeNetworkRobot: RemoveNetworkRobot - @Before override fun setUp() { + @Before + override fun setUp() { super.setUp() removeNetworkRobot = RemoveNetworkRobot( activityTestRule, @@ -29,7 +32,8 @@ internal class RemoveNetworkFragmentTest : AbstractEspressoTestClass() { ) } - @Test fun loadsFromStore() { + @Test + fun loadsFromStore() { with(removeNetworkRobot) { // Given withDetailsInStore() @@ -42,12 +46,11 @@ internal class RemoveNetworkFragmentTest : AbstractEspressoTestClass() { } } - @Test fun removeNetwork_permissionErrorDialog() { + @Test + fun removeNetwork_permissionErrorDialog() { with(removeNetworkRobot) { // Given - withPermission(ACCESS_WIFI_STATE) launchRemoveNetworkScreen() - removeNetwork() // When permissionCallbackTriggered( @@ -60,11 +63,12 @@ internal class RemoveNetworkFragmentTest : AbstractEspressoTestClass() { } } - @Test fun removeNetwork_permissionError_once() { + @Test + fun removeNetwork_permissionError_once() { with(removeNetworkRobot) { // Given withSuccessRemovingNetwork() - withPermissionDeniedOnce(ACCESS_WIFI_STATE) + withPermissionDeniedOnce(ACCESS_FINE_LOCATION) launchRemoveNetworkScreen() // When @@ -77,13 +81,11 @@ internal class RemoveNetworkFragmentTest : AbstractEspressoTestClass() { } } - @Test fun removeNetwork_permissionError_emptyList() { + @Test + fun removeNetwork_permissionError_emptyList() { with(removeNetworkRobot) { // Given - withPermission(ACCESS_WIFI_STATE) - withSuccessRemovingNetwork() launchRemoveNetworkScreen() - removeNetwork() // When permissionCallbackTriggeredWithEmptyArray( @@ -92,17 +94,14 @@ internal class RemoveNetworkFragmentTest : AbstractEspressoTestClass() { // Then dismissErrorDialog() - verifyTriedToRemoveNetwork() } } - @Test fun removeNetwork_permissionError_permissionDenied() { + @Test + fun removeNetwork_permissionError_permissionDenied() { with(removeNetworkRobot) { // Given - withPermission(ACCESS_WIFI_STATE) - withSuccessRemovingNetwork() launchRemoveNetworkScreen() - removeNetwork() // When permissionCallbackTriggered( @@ -112,17 +111,17 @@ internal class RemoveNetworkFragmentTest : AbstractEspressoTestClass() { // Then dismissErrorDialog() - verifyTriedToRemoveNetwork() } } - @Test fun removeNetwork_success_afterPermissionGranted() { + @Test + fun removeNetwork_success_afterPermissionGranted() { with(removeNetworkRobot) { // Given - withPermission(ACCESS_WIFI_STATE) + withPermission(ACCESS_FINE_LOCATION) withSuccessRemovingNetwork() launchRemoveNetworkScreen() - removeNetwork() + enterNetworkDetails() // When permissionCallbackTriggered( @@ -131,16 +130,17 @@ internal class RemoveNetworkFragmentTest : AbstractEspressoTestClass() { ) // Then - verifyTriedToRemoveNetwork(times = 2) + verifyTriedToRemoveNetwork() verifyNetworkRemovedIsDisplayed() dismissResultsDialog() } } - @Test fun removeNetwork_success() { + @Test + fun removeNetwork_success() { with(removeNetworkRobot) { // Given - withPermission(ACCESS_WIFI_STATE) + withPermission(ACCESS_FINE_LOCATION) withSuccessRemovingNetwork() launchRemoveNetworkScreen() @@ -154,10 +154,11 @@ internal class RemoveNetworkFragmentTest : AbstractEspressoTestClass() { } } - @Test fun removeNetwork_failureToRemoveNetwork() { + @Test + fun removeNetwork_failureToRemoveNetwork() { with(removeNetworkRobot) { // Given - withPermission(ACCESS_WIFI_STATE) + withPermission(ACCESS_FINE_LOCATION) withFailureRemovingNetwork() launchRemoveNetworkScreen() @@ -171,10 +172,11 @@ internal class RemoveNetworkFragmentTest : AbstractEspressoTestClass() { } } - @Test fun removeNetwork_networkNotFoundToRemove() { + @Test + fun removeNetwork_networkNotFoundToRemove() { with(removeNetworkRobot) { // Given - withPermission(ACCESS_WIFI_STATE) + withPermission(ACCESS_FINE_LOCATION) withNetworkNotFoundToRemove() launchRemoveNetworkScreen() @@ -188,10 +190,11 @@ internal class RemoveNetworkFragmentTest : AbstractEspressoTestClass() { } } - @Test fun removeNetwork_wiseFyFailure() { + @Test + fun removeNetwork_wiseFyFailure() { with(removeNetworkRobot) { // Given - withPermission(ACCESS_WIFI_STATE) + withPermission(ACCESS_FINE_LOCATION) withWiseFyFailureRemovingNetwork() launchRemoveNetworkScreen() @@ -207,7 +210,8 @@ internal class RemoveNetworkFragmentTest : AbstractEspressoTestClass() { } } - @Test fun ridiculousPermissionRequested() { + @Test + fun ridiculousPermissionRequested() { with(removeNetworkRobot) { // Given launchRemoveNetworkScreen() diff --git a/wisefysample/src/androidTest/java/com/isupatches/wisefysample/ui/remove/RemoveNetworkRobot.kt b/wisefysample/src/androidTest/java/com/isupatches/wisefysample/ui/remove/RemoveNetworkRobot.kt index 94014d94..384cae46 100644 --- a/wisefysample/src/androidTest/java/com/isupatches/wisefysample/ui/remove/RemoveNetworkRobot.kt +++ b/wisefysample/src/androidTest/java/com/isupatches/wisefysample/ui/remove/RemoveNetworkRobot.kt @@ -5,7 +5,6 @@ import androidx.test.espresso.Espresso.onView import androidx.test.espresso.matcher.ViewMatchers.withId import androidx.test.espresso.matcher.ViewMatchers.withText import androidx.test.rule.ActivityTestRule - import com.isupatches.wisefy.WiseFyPublicApi import com.isupatches.wisefy.callbacks.RemoveNetworkCallbacks import com.isupatches.wisefy.constants.MISSING_PARAMETER @@ -19,7 +18,6 @@ import com.isupatches.wisefysample.internal.espresso.performScrollToAndReplaceTe import com.isupatches.wisefysample.internal.preferences.RemoveNetworkStore import com.isupatches.wisefysample.internal.util.PermissionUtil import com.isupatches.wisefysample.ui.main.MainActivity - import com.nhaarman.mockitokotlin2.any import com.nhaarman.mockitokotlin2.doAnswer import com.nhaarman.mockitokotlin2.eq @@ -88,6 +86,10 @@ internal class RemoveNetworkRobot( * Actions */ + fun enterNetworkDetails() { + onView(withId(R.id.networkNameEdt)).performScrollToAndReplaceText(TEST_SSID_1) + } + fun launchRemoveNetworkScreen() { activityTestRule.launchActivity(Intent()) onView(withId(R.id.menu_remove)).performClick() diff --git a/wisefysample/src/androidTest/java/com/isupatches/wisefysample/ui/search/SearchFragmentTest.kt b/wisefysample/src/androidTest/java/com/isupatches/wisefysample/ui/search/SearchFragmentTest.kt index e0e8e4f6..93d0af17 100644 --- a/wisefysample/src/androidTest/java/com/isupatches/wisefysample/ui/search/SearchFragmentTest.kt +++ b/wisefysample/src/androidTest/java/com/isupatches/wisefysample/ui/search/SearchFragmentTest.kt @@ -1,15 +1,13 @@ package com.isupatches.wisefysample.ui.search -import android.Manifest.permission.ACCESS_COARSE_LOCATION -import android.Manifest.permission.ACCESS_WIFI_STATE +import android.Manifest.permission.ACCESS_FINE_LOCATION import android.content.pm.PackageManager import androidx.test.espresso.intent.rule.IntentsTestRule import androidx.test.rule.GrantPermissionRule - import com.isupatches.wisefysample.RANDO_PERMISSION_REQUEST_CODE +import com.isupatches.wisefysample.TEST_SSID_1 import com.isupatches.wisefysample.internal.base.AbstractEspressoTestClass import com.isupatches.wisefysample.ui.main.MainActivity - import org.junit.Before import org.junit.Rule import org.junit.Test @@ -20,24 +18,25 @@ internal class SearchFragmentTest : AbstractEspressoTestClass() { var activityTestRule = IntentsTestRule(MainActivity::class.java, false, false) @get:Rule - val grantPermissionRule: GrantPermissionRule = GrantPermissionRule.grant(ACCESS_COARSE_LOCATION) + val grantPermissionRule: GrantPermissionRule = GrantPermissionRule.grant(ACCESS_FINE_LOCATION) private lateinit var searchRobot: SearchRobot - @Before override fun setUp() { + @Before + override fun setUp() { super.setUp() searchRobot = SearchRobot(activityTestRule, wiseFy, searchStore, permissionUtil) } - @Test fun adaptiveUI() { + @Test + fun adaptiveUI() { with(searchRobot) { // Given - withPermissions(ACCESS_WIFI_STATE, ACCESS_COARSE_LOCATION) withAccessPointInStore(false) launchSearchScreen() // When - selectAccessPoint() + fillOutForAccessPoint() // Then - Access Point verifyAccessPointIsChecked() @@ -52,7 +51,7 @@ internal class SearchFragmentTest : AbstractEspressoTestClass() { verifyTimeoutIsDisplayed() // And When - selectAccessPoints() + fillOutForAccessPoints() // Then - Access Points verifyAccessPointIsChecked() @@ -67,7 +66,7 @@ internal class SearchFragmentTest : AbstractEspressoTestClass() { verifyTimeoutIsNotDisplayed() // And When - selectSSID() + fillOutForSSID() // Then - SSID verifySSIDsChecked() @@ -76,7 +75,7 @@ internal class SearchFragmentTest : AbstractEspressoTestClass() { verifyTimeoutIsDisplayed() // And When - selectSSIDs() + fillOutForSSIDs() // Then - SSIDS verifySSIDsChecked() @@ -85,7 +84,7 @@ internal class SearchFragmentTest : AbstractEspressoTestClass() { verifyTimeoutIsNotDisplayed() // And When - selectSavedNetwork() + fillOutForSavedNetwork() // Then - Saved Network verifySavedNetworkIsChecked() @@ -94,7 +93,7 @@ internal class SearchFragmentTest : AbstractEspressoTestClass() { verifyTimeoutIsNotDisplayed() // And When - selectSavedNetworks() + fillOutForSavedNetworks() // Then - Saved Networks verifySavedNetworkIsChecked() @@ -103,7 +102,7 @@ internal class SearchFragmentTest : AbstractEspressoTestClass() { verifyTimeoutIsNotDisplayed() // And When - selectAccessPoint() + fillOutForAccessPoint() // Then Finally - Access Point verifyAccessPointIsChecked() @@ -113,10 +112,10 @@ internal class SearchFragmentTest : AbstractEspressoTestClass() { } } - @Test fun loadsAccessPointFromStore_filterDuplicates_false() { + @Test + fun loadsAccessPointFromStore_filterDuplicates_false() { with(searchRobot) { // Given - withPermissions(ACCESS_WIFI_STATE, ACCESS_COARSE_LOCATION) withAccessPointInStore(false) // When @@ -131,10 +130,10 @@ internal class SearchFragmentTest : AbstractEspressoTestClass() { } } - @Test fun loadsAccessPointFromStore_filterDuplicates_true() { + @Test + fun loadsAccessPointFromStore_filterDuplicates_true() { with(searchRobot) { // Given - withPermissions(ACCESS_WIFI_STATE, ACCESS_COARSE_LOCATION) withAccessPointInStore(true) // When @@ -149,10 +148,10 @@ internal class SearchFragmentTest : AbstractEspressoTestClass() { } } - @Test fun loadsAccessPointsFromStore_filterDuplicates_false() { + @Test + fun loadsAccessPointsFromStore_filterDuplicates_false() { with(searchRobot) { // Given - withPermissions(ACCESS_WIFI_STATE, ACCESS_COARSE_LOCATION) withAccessPointsInStore(false) // When @@ -167,10 +166,10 @@ internal class SearchFragmentTest : AbstractEspressoTestClass() { } } - @Test fun loadsAccessPointsFromStore_filterDuplicates_true() { + @Test + fun loadsAccessPointsFromStore_filterDuplicates_true() { with(searchRobot) { // Given - withPermissions(ACCESS_WIFI_STATE, ACCESS_COARSE_LOCATION) withAccessPointsInStore(true) // When @@ -185,10 +184,10 @@ internal class SearchFragmentTest : AbstractEspressoTestClass() { } } - @Test fun loadsSSIDFromStore() { + @Test + fun loadsSSIDFromStore() { with(searchRobot) { // Given - withPermissions(ACCESS_WIFI_STATE, ACCESS_COARSE_LOCATION) withSSIDInStore() // When @@ -203,10 +202,10 @@ internal class SearchFragmentTest : AbstractEspressoTestClass() { } } - @Test fun loadsSSIDSFromStore() { + @Test + fun loadsSSIDSFromStore() { with(searchRobot) { // Given - withPermissions(ACCESS_WIFI_STATE, ACCESS_COARSE_LOCATION) withSSIDsInStore() // When @@ -221,10 +220,10 @@ internal class SearchFragmentTest : AbstractEspressoTestClass() { } } - @Test fun loadsSavedNetworkFromStore() { + @Test + fun loadsSavedNetworkFromStore() { with(searchRobot) { // Given - withPermissions(ACCESS_WIFI_STATE, ACCESS_COARSE_LOCATION) withSavedNetworkInStore() // When @@ -239,10 +238,10 @@ internal class SearchFragmentTest : AbstractEspressoTestClass() { } } - @Test fun loadsSavedNetworksFromStore() { + @Test + fun loadsSavedNetworksFromStore() { with(searchRobot) { // Given - withPermissions(ACCESS_WIFI_STATE, ACCESS_COARSE_LOCATION) withSavedNetworksInStore() // When @@ -257,12 +256,11 @@ internal class SearchFragmentTest : AbstractEspressoTestClass() { } } - @Test fun searchForAccessPoint_permissionErrorDialog_filterDuplicates_true() { + @Test + fun searchForAccessPoint_permissionErrorDialog_filterDuplicates_true() { with(searchRobot) { // Given - withPermissions(ACCESS_WIFI_STATE, ACCESS_COARSE_LOCATION) launchSearchScreen() - searchForAccessPoint(true) // When permissionCallbackTriggered( @@ -275,16 +273,16 @@ internal class SearchFragmentTest : AbstractEspressoTestClass() { } } - @Test fun searchForAccessPoint_permissionError_once_filterDuplicates_true() { + @Test + fun searchForAccessPoint_permissionError_once_accessFineLocation_filterDuplicates_true() { with(searchRobot) { // Given withSuccessSearchingForAccessPoint(true) - withPermissionDeniedOnce(ACCESS_WIFI_STATE) - withPermissionDeniedOnce(ACCESS_COARSE_LOCATION) + withPermissionDeniedOnce(ACCESS_FINE_LOCATION) launchSearchScreen() // When - searchForAccessPoint(true) + searchForAccessPoint(TEST_SSID_1, true) // Then verifySearchedForAccessPoint(true) @@ -293,50 +291,12 @@ internal class SearchFragmentTest : AbstractEspressoTestClass() { } } - @Test fun searchForAccessPoint_permissionError_once_accessWifiState_filterDuplicates_true() { + @Test + fun searchForAccessPoint_permissionError_emptyList_filterDuplicates_true() { with(searchRobot) { // Given - withSuccessSearchingForAccessPoint(true) - withPermissionDeniedOnce(ACCESS_WIFI_STATE) - withPermission(ACCESS_COARSE_LOCATION) launchSearchScreen() - // When - searchForAccessPoint(true) - - // Then - verifySearchedForAccessPoint(true) - verifyAccessPointIsDisplayed() - dismissResultsDialog() - } - } - - @Test fun searchForAccessPoint_permissionError_once_accessCourseLocation_filterDuplicates_true() { - with(searchRobot) { - // Given - withSuccessSearchingForAccessPoint(true) - withPermission(ACCESS_WIFI_STATE) - withPermissionDeniedOnce(ACCESS_COARSE_LOCATION) - launchSearchScreen() - - // When - searchForAccessPoint(true) - - // Then - verifySearchedForAccessPoint(true) - verifyAccessPointIsDisplayed() - dismissResultsDialog() - } - } - - @Test fun searchForAccessPoint_permissionError_emptyList_filterDuplicates_true() { - with(searchRobot) { - // Given - withPermissions(ACCESS_WIFI_STATE, ACCESS_COARSE_LOCATION) - withSuccessSearchingForAccessPoint(true) - launchSearchScreen() - searchForAccessPoint(true) - // When permissionCallbackTriggeredWithEmptyArray( SearchFragment.WISEFY_SEARCH_FOR_ACCESS_POINT_REQUEST_CODE @@ -344,17 +304,14 @@ internal class SearchFragmentTest : AbstractEspressoTestClass() { // Then dismissErrorDialog() - verifySearchedForAccessPoint(true) } } - @Test fun searchForAccessPoint_permissionError_permissionDenied_filterDuplicates_true() { + @Test + fun searchForAccessPoint_permissionError_permissionDenied_filterDuplicates_true() { with(searchRobot) { // Given - withPermissions(ACCESS_WIFI_STATE, ACCESS_COARSE_LOCATION) - withSuccessSearchingForAccessPoint(true) launchSearchScreen() - searchForAccessPoint(true) // When permissionCallbackTriggered( @@ -364,17 +321,17 @@ internal class SearchFragmentTest : AbstractEspressoTestClass() { // Then dismissErrorDialog() - verifySearchedForAccessPoint(true) } } - @Test fun searchForAccessPoint_success_afterPermissionGranted_filterDuplicates_true() { + @Test + fun searchForAccessPoint_success_afterPermissionGranted_filterDuplicates_true() { with(searchRobot) { // Given - withPermissions(ACCESS_WIFI_STATE, ACCESS_COARSE_LOCATION) + withPermission(ACCESS_FINE_LOCATION) withSuccessSearchingForAccessPoint(true) launchSearchScreen() - searchForAccessPoint(true) + fillOutForAccessPoint(TEST_SSID_1, true) // When permissionCallbackTriggered( @@ -383,21 +340,22 @@ internal class SearchFragmentTest : AbstractEspressoTestClass() { ) // Then - verifySearchedForAccessPoint(true, times = 2) + verifySearchedForAccessPoint(true) verifyAccessPointIsDisplayed() dismissResultsDialog() } } - @Test fun searchForAccessPoint_success_filterDuplicates_true() { + @Test + fun searchForAccessPoint_success_filterDuplicates_true() { with(searchRobot) { // Given - withPermissions(ACCESS_WIFI_STATE, ACCESS_COARSE_LOCATION) + withPermission(ACCESS_FINE_LOCATION) withSuccessSearchingForAccessPoint(true) launchSearchScreen() // When - searchForAccessPoint(true) + searchForAccessPoint(TEST_SSID_1, true) // Then verifySearchedForAccessPoint(true) @@ -406,15 +364,16 @@ internal class SearchFragmentTest : AbstractEspressoTestClass() { } } - @Test fun searchForAccessPoint_accessPointNotFound_filterDuplicates_true() { + @Test + fun searchForAccessPoint_accessPointNotFound_filterDuplicates_true() { with(searchRobot) { // Given - withPermissions(ACCESS_WIFI_STATE, ACCESS_COARSE_LOCATION) + withPermission(ACCESS_FINE_LOCATION) withAccessPointNotFound(true) launchSearchScreen() // When - searchForAccessPoint(true) + searchForAccessPoint(TEST_SSID_1, true) // Then verifySearchedForAccessPoint(true) @@ -423,15 +382,16 @@ internal class SearchFragmentTest : AbstractEspressoTestClass() { } } - @Test fun searchForAccessPoint_wiseFyFailure_filterDuplicates_true() { + @Test + fun searchForAccessPoint_wiseFyFailure_filterDuplicates_true() { with(searchRobot) { // Given - withPermissions(ACCESS_WIFI_STATE, ACCESS_COARSE_LOCATION) + withPermission(ACCESS_FINE_LOCATION) withWiseFyFailureSearchingForAccessPoint(true) launchSearchScreen() // When - searchForAccessPoint(true) + searchForAccessPoint(TEST_SSID_1, true) // Then verifyWiseFyFailureIsDisplayed() @@ -442,12 +402,11 @@ internal class SearchFragmentTest : AbstractEspressoTestClass() { } } - @Test fun searchForAccessPoint_permissionErrorDialog_filterDuplicates_false() { + @Test + fun searchForAccessPoint_permissionErrorDialog_filterDuplicates_false() { with(searchRobot) { // Given - withPermissions(ACCESS_WIFI_STATE, ACCESS_COARSE_LOCATION) launchSearchScreen() - searchForAccessPoint(false) // When permissionCallbackTriggered( @@ -460,34 +419,16 @@ internal class SearchFragmentTest : AbstractEspressoTestClass() { } } - @Test fun searchForAccessPoint_permissionError_once_filterDuplicates_false() { - with(searchRobot) { - // Given - withSuccessSearchingForAccessPoint(false) - withPermissionDeniedOnce(ACCESS_WIFI_STATE) - withPermissionDeniedOnce(ACCESS_COARSE_LOCATION) - launchSearchScreen() - - // When - searchForAccessPoint(false) - - // Then - verifySearchedForAccessPoint(false) - verifyAccessPointIsDisplayed() - dismissResultsDialog() - } - } - - @Test fun searchForAccessPoint_permissionError_once_accessWifiState_filterDuplicates_false() { + @Test + fun searchForAccessPoint_permissionError_once_accessFineLocation_filterDuplicates_false() { with(searchRobot) { // Given withSuccessSearchingForAccessPoint(false) - withPermissionDeniedOnce(ACCESS_WIFI_STATE) - withPermission(ACCESS_COARSE_LOCATION) + withPermissionDeniedOnce(ACCESS_FINE_LOCATION) launchSearchScreen() // When - searchForAccessPoint(false) + searchForAccessPoint(TEST_SSID_1, false) // Then verifySearchedForAccessPoint(false) @@ -496,32 +437,12 @@ internal class SearchFragmentTest : AbstractEspressoTestClass() { } } - @Test fun searchForAccessPoint_permissionError_once_accessCourseLocation_filterDuplicates_false() { + @Test + fun searchForAccessPoint_permissionError_emptyList_filterDuplicates_false() { with(searchRobot) { // Given - withSuccessSearchingForAccessPoint(false) - withPermission(ACCESS_WIFI_STATE) - withPermissionDeniedOnce(ACCESS_COARSE_LOCATION) launchSearchScreen() - // When - searchForAccessPoint(false) - - // Then - verifySearchedForAccessPoint(false) - verifyAccessPointIsDisplayed() - dismissResultsDialog() - } - } - - @Test fun searchForAccessPoint_permissionError_emptyList_filterDuplicates_false() { - with(searchRobot) { - // Given - withPermissions(ACCESS_WIFI_STATE, ACCESS_COARSE_LOCATION) - withSuccessSearchingForAccessPoint(false) - launchSearchScreen() - searchForAccessPoint(false) - // When permissionCallbackTriggeredWithEmptyArray( SearchFragment.WISEFY_SEARCH_FOR_ACCESS_POINT_REQUEST_CODE @@ -529,17 +450,14 @@ internal class SearchFragmentTest : AbstractEspressoTestClass() { // Then dismissErrorDialog() - verifySearchedForAccessPoint(false) } } - @Test fun searchForAccessPoint_permissionError_permissionDenied_filterDuplicates_false() { + @Test + fun searchForAccessPoint_permissionError_permissionDenied_filterDuplicates_false() { with(searchRobot) { // Given - withPermissions(ACCESS_WIFI_STATE, ACCESS_COARSE_LOCATION) - withSuccessSearchingForAccessPoint(false) launchSearchScreen() - searchForAccessPoint(false) // When permissionCallbackTriggered( @@ -549,17 +467,17 @@ internal class SearchFragmentTest : AbstractEspressoTestClass() { // Then dismissErrorDialog() - verifySearchedForAccessPoint(false) } } - @Test fun searchForAccessPoint_success_afterPermissionGranted_filterDuplicates_false() { + @Test + fun searchForAccessPoint_success_afterPermissionGranted_filterDuplicates_false() { with(searchRobot) { // Given - withPermissions(ACCESS_WIFI_STATE, ACCESS_COARSE_LOCATION) + withPermission(ACCESS_FINE_LOCATION) withSuccessSearchingForAccessPoint(false) launchSearchScreen() - searchForAccessPoint(false) + fillOutForAccessPoint(TEST_SSID_1, false) // When permissionCallbackTriggered( @@ -568,21 +486,22 @@ internal class SearchFragmentTest : AbstractEspressoTestClass() { ) // Then - verifySearchedForAccessPoint(false, times = 2) + verifySearchedForAccessPoint(false) verifyAccessPointIsDisplayed() dismissResultsDialog() } } - @Test fun searchForAccessPoint_success_filterDuplicates_false() { + @Test + fun searchForAccessPoint_success_filterDuplicates_false() { with(searchRobot) { // Given - withPermissions(ACCESS_WIFI_STATE, ACCESS_COARSE_LOCATION) + withPermission(ACCESS_FINE_LOCATION) withSuccessSearchingForAccessPoint(false) launchSearchScreen() // When - searchForAccessPoint(false) + searchForAccessPoint(TEST_SSID_1, false) // Then verifySearchedForAccessPoint(false) @@ -591,15 +510,16 @@ internal class SearchFragmentTest : AbstractEspressoTestClass() { } } - @Test fun searchForAccessPoint_accessPointNotFound_filterDuplicates_false() { + @Test + fun searchForAccessPoint_accessPointNotFound_filterDuplicates_false() { with(searchRobot) { // Given - withPermissions(ACCESS_WIFI_STATE, ACCESS_COARSE_LOCATION) + withPermission(ACCESS_FINE_LOCATION) withAccessPointNotFound(false) launchSearchScreen() // When - searchForAccessPoint(false) + searchForAccessPoint(TEST_SSID_1, false) // Then verifySearchedForAccessPoint(false) @@ -608,15 +528,16 @@ internal class SearchFragmentTest : AbstractEspressoTestClass() { } } - @Test fun searchForAccessPoint_wiseFyFailure_filterDuplicates_false() { + @Test + fun searchForAccessPoint_wiseFyFailure_filterDuplicates_false() { with(searchRobot) { // Given - withPermissions(ACCESS_WIFI_STATE, ACCESS_COARSE_LOCATION) + withPermission(ACCESS_FINE_LOCATION) withWiseFyFailureSearchingForAccessPoint(false) launchSearchScreen() // When - searchForAccessPoint(false) + searchForAccessPoint(TEST_SSID_1, false) // Then verifyWiseFyFailureIsDisplayed() @@ -627,12 +548,11 @@ internal class SearchFragmentTest : AbstractEspressoTestClass() { } } - @Test fun searchForAccessPoints_permissionErrorDialog_filterDuplicates_true() { + @Test + fun searchForAccessPoints_permissionErrorDialog_filterDuplicates_true() { with(searchRobot) { // Given - withPermissions(ACCESS_WIFI_STATE, ACCESS_COARSE_LOCATION) launchSearchScreen() - searchForAccessPoints(true) // When permissionCallbackTriggered( @@ -645,52 +565,16 @@ internal class SearchFragmentTest : AbstractEspressoTestClass() { } } - @Test fun searchForAccessPoints_permissionError_once_filterDuplicates_true() { - with(searchRobot) { - // Given - withSuccessSearchingForAccessPoints(true) - withPermissionDeniedOnce(ACCESS_WIFI_STATE) - withPermissionDeniedOnce(ACCESS_COARSE_LOCATION) - launchSearchScreen() - - // When - searchForAccessPoints(true) - - // Then - verifySearchedForAccessPoints(true) - verifyAccessPointsAreDisplayed() - dismissResultsDialog() - } - } - - @Test fun searchForAccessPoints_permissionError_once_accessWifiState_filterDuplicates_true() { - with(searchRobot) { - // Given - withSuccessSearchingForAccessPoints(true) - withPermissionDeniedOnce(ACCESS_WIFI_STATE) - withPermission(ACCESS_COARSE_LOCATION) - launchSearchScreen() - - // When - searchForAccessPoints(true) - - // Then - verifySearchedForAccessPoints(true) - verifyAccessPointsAreDisplayed() - dismissResultsDialog() - } - } - - @Test fun searchForAccessPoints_permissionError_once_accessCourseLocation_filterDuplicates_true() { + @Test + fun searchForAccessPoints_permissionError_once_accessFineLocation_filterDuplicates_true() { with(searchRobot) { // Given withSuccessSearchingForAccessPoints(true) - withPermission(ACCESS_WIFI_STATE) - withPermissionDeniedOnce(ACCESS_COARSE_LOCATION) + withPermissionDeniedOnce(ACCESS_FINE_LOCATION) launchSearchScreen() // When - searchForAccessPoints(true) + searchForAccessPoints(TEST_SSID_1, true) // Then verifySearchedForAccessPoints(true) @@ -699,13 +583,11 @@ internal class SearchFragmentTest : AbstractEspressoTestClass() { } } - @Test fun searchForAccessPoints_permissionError_emptyList_filterDuplicates_true() { + @Test + fun searchForAccessPoints_permissionError_emptyList_filterDuplicates_true() { with(searchRobot) { // Given - withPermissions(ACCESS_WIFI_STATE, ACCESS_COARSE_LOCATION) - withSuccessSearchingForAccessPoints(true) launchSearchScreen() - searchForAccessPoints(true) // When permissionCallbackTriggeredWithEmptyArray( @@ -714,17 +596,14 @@ internal class SearchFragmentTest : AbstractEspressoTestClass() { // Then dismissErrorDialog() - verifySearchedForAccessPoints(true) } } - @Test fun searchForAccessPoints_permissionError_permissionDenied_filterDuplicates_true() { + @Test + fun searchForAccessPoints_permissionError_permissionDenied_filterDuplicates_true() { with(searchRobot) { // Given - withPermissions(ACCESS_WIFI_STATE, ACCESS_COARSE_LOCATION) - withSuccessSearchingForAccessPoints(true) launchSearchScreen() - searchForAccessPoints(true) // When permissionCallbackTriggered( @@ -734,17 +613,17 @@ internal class SearchFragmentTest : AbstractEspressoTestClass() { // Then dismissErrorDialog() - verifySearchedForAccessPoints(true) } } - @Test fun searchForAccessPoints_success_afterPermissionGranted_filterDuplicates_true() { + @Test + fun searchForAccessPoints_success_afterPermissionGranted_filterDuplicates_true() { with(searchRobot) { // Given - withPermissions(ACCESS_WIFI_STATE, ACCESS_COARSE_LOCATION) + withPermission(ACCESS_FINE_LOCATION) withSuccessSearchingForAccessPoints(true) launchSearchScreen() - searchForAccessPoints(true) + fillOutForAccessPoints(TEST_SSID_1, true) // When permissionCallbackTriggered( @@ -753,21 +632,22 @@ internal class SearchFragmentTest : AbstractEspressoTestClass() { ) // Then - verifySearchedForAccessPoints(true, times = 2) + verifySearchedForAccessPoints(true) verifyAccessPointsAreDisplayed() dismissResultsDialog() } } - @Test fun searchForAccessPoints_success_filterDuplicates_true() { + @Test + fun searchForAccessPoints_success_filterDuplicates_true() { with(searchRobot) { // Given - withPermissions(ACCESS_WIFI_STATE, ACCESS_COARSE_LOCATION) + withPermission(ACCESS_FINE_LOCATION) withSuccessSearchingForAccessPoints(true) launchSearchScreen() // When - searchForAccessPoints(true) + searchForAccessPoints(TEST_SSID_1, true) // Then verifySearchedForAccessPoints(true) @@ -776,15 +656,16 @@ internal class SearchFragmentTest : AbstractEspressoTestClass() { } } - @Test fun searchForAccessPoints_noAccessPointsFound_filterDuplicates_true() { + @Test + fun searchForAccessPoints_noAccessPointsFound_filterDuplicates_true() { with(searchRobot) { // Given - withPermissions(ACCESS_WIFI_STATE, ACCESS_COARSE_LOCATION) + withPermission(ACCESS_FINE_LOCATION) withNoAccessPointsFound(true) launchSearchScreen() // When - searchForAccessPoints(true) + searchForAccessPoints(TEST_SSID_1, true) // Then verifySearchedForAccessPoints(true) @@ -793,15 +674,16 @@ internal class SearchFragmentTest : AbstractEspressoTestClass() { } } - @Test fun searchForAccessPoints_wiseFyFailure_filterDuplicates_true() { + @Test + fun searchForAccessPoints_wiseFyFailure_filterDuplicates_true() { with(searchRobot) { // Given - withPermissions(ACCESS_WIFI_STATE, ACCESS_COARSE_LOCATION) + withPermission(ACCESS_FINE_LOCATION) withWiseFyFailureSearchingForAccessPoints(true) launchSearchScreen() // When - searchForAccessPoints(true) + searchForAccessPoints(TEST_SSID_1, true) // Then verifyWiseFyFailureIsDisplayed() @@ -812,12 +694,11 @@ internal class SearchFragmentTest : AbstractEspressoTestClass() { } } - @Test fun searchForAccessPoints_permissionErrorDialog_filterDuplicates_false() { + @Test + fun searchForAccessPoints_permissionErrorDialog_filterDuplicates_false() { with(searchRobot) { // Given - withPermissions(ACCESS_WIFI_STATE, ACCESS_COARSE_LOCATION) launchSearchScreen() - searchForAccessPoints(false) // When permissionCallbackTriggered( @@ -830,34 +711,16 @@ internal class SearchFragmentTest : AbstractEspressoTestClass() { } } - @Test fun searchForAccessPoints_permissionError_once_filterDuplicates_false() { - with(searchRobot) { - // Given - withSuccessSearchingForAccessPoints(false) - withPermission(ACCESS_WIFI_STATE) - withPermissionDeniedOnce(ACCESS_COARSE_LOCATION) - launchSearchScreen() - - // When - searchForAccessPoints(false) - - // Then - verifySearchedForAccessPoints(false) - verifyAccessPointsAreDisplayed() - dismissResultsDialog() - } - } - - @Test fun searchForAccessPoints_permissionError_once_accessWifiState_filterDuplicates_false() { + @Test + fun searchForAccessPoints_permissionError_once_accessFineLocation_filterDuplicates_false() { with(searchRobot) { // Given withSuccessSearchingForAccessPoints(false) - withPermissionDeniedOnce(ACCESS_WIFI_STATE) - withPermission(ACCESS_COARSE_LOCATION) + withPermissionDeniedOnce(ACCESS_FINE_LOCATION) launchSearchScreen() // When - searchForAccessPoints(false) + searchForAccessPoints(TEST_SSID_1, false) // Then verifySearchedForAccessPoints(false) @@ -866,32 +729,12 @@ internal class SearchFragmentTest : AbstractEspressoTestClass() { } } - @Test fun searchForAccessPoints_permissionError_once_accessCourseLocation_filterDuplicates_false() { + @Test + fun searchForAccessPoints_permissionError_emptyList_filterDuplicates_false() { with(searchRobot) { // Given - withSuccessSearchingForAccessPoints(false) - withPermission(ACCESS_WIFI_STATE) - withPermissionDeniedOnce(ACCESS_COARSE_LOCATION) launchSearchScreen() - // When - searchForAccessPoints(false) - - // Then - verifySearchedForAccessPoints(false) - verifyAccessPointsAreDisplayed() - dismissResultsDialog() - } - } - - @Test fun searchForAccessPoints_permissionError_emptyList_filterDuplicates_false() { - with(searchRobot) { - // Given - withPermissions(ACCESS_WIFI_STATE, ACCESS_COARSE_LOCATION) - withSuccessSearchingForAccessPoints(false) - launchSearchScreen() - searchForAccessPoints(false) - // When permissionCallbackTriggeredWithEmptyArray( SearchFragment.WISEFY_SEARCH_FOR_ACCESS_POINTS_REQUEST_CODE @@ -899,17 +742,14 @@ internal class SearchFragmentTest : AbstractEspressoTestClass() { // Then dismissErrorDialog() - verifySearchedForAccessPoints(false) } } - @Test fun searchForAccessPoints_permissionError_permissionDenied_filterDuplicates_false() { + @Test + fun searchForAccessPoints_permissionError_permissionDenied_filterDuplicates_false() { with(searchRobot) { // Given - withPermissions(ACCESS_WIFI_STATE, ACCESS_COARSE_LOCATION) - withSuccessSearchingForAccessPoints(false) launchSearchScreen() - searchForAccessPoints(false) // When permissionCallbackTriggered( @@ -919,17 +759,17 @@ internal class SearchFragmentTest : AbstractEspressoTestClass() { // Then dismissErrorDialog() - verifySearchedForAccessPoints(false) } } - @Test fun searchForAccessPoints_success_afterPermissionGranted_filterDuplicates_false() { + @Test + fun searchForAccessPoints_success_afterPermissionGranted_filterDuplicates_false() { with(searchRobot) { // Given - withPermissions(ACCESS_WIFI_STATE, ACCESS_COARSE_LOCATION) + withPermission(ACCESS_FINE_LOCATION) withSuccessSearchingForAccessPoints(false) launchSearchScreen() - searchForAccessPoints(false) + fillOutForAccessPoints(TEST_SSID_1, false) // When permissionCallbackTriggered( @@ -938,21 +778,22 @@ internal class SearchFragmentTest : AbstractEspressoTestClass() { ) // Then - verifySearchedForAccessPoints(false, times = 2) + verifySearchedForAccessPoints(false) verifyAccessPointsAreDisplayed() dismissResultsDialog() } } - @Test fun searchForAccessPoints_success_filterDuplicates_false() { + @Test + fun searchForAccessPoints_success_filterDuplicates_false() { with(searchRobot) { // Given - withPermissions(ACCESS_WIFI_STATE, ACCESS_COARSE_LOCATION) + withPermission(ACCESS_FINE_LOCATION) withSuccessSearchingForAccessPoints(false) launchSearchScreen() // When - searchForAccessPoints(false) + searchForAccessPoints(TEST_SSID_1, false) // Then verifySearchedForAccessPoints(false) @@ -961,15 +802,16 @@ internal class SearchFragmentTest : AbstractEspressoTestClass() { } } - @Test fun searchForAccessPoints_noAccessPointsFound_filterDuplicates_false() { + @Test + fun searchForAccessPoints_noAccessPointsFound_filterDuplicates_false() { with(searchRobot) { // Given - withPermissions(ACCESS_WIFI_STATE, ACCESS_COARSE_LOCATION) + withPermission(ACCESS_FINE_LOCATION) withNoAccessPointsFound(false) launchSearchScreen() // When - searchForAccessPoints(false) + searchForAccessPoints(TEST_SSID_1, false) // Then verifySearchedForAccessPoints(false) @@ -978,15 +820,16 @@ internal class SearchFragmentTest : AbstractEspressoTestClass() { } } - @Test fun searchForAccessPoints_wiseFyFailure_filterDuplicates_false() { + @Test + fun searchForAccessPoints_wiseFyFailure_filterDuplicates_false() { with(searchRobot) { // Given - withPermissions(ACCESS_WIFI_STATE, ACCESS_COARSE_LOCATION) + withPermission(ACCESS_FINE_LOCATION) withWiseFyFailureSearchingForAccessPoints(false) launchSearchScreen() // When - searchForAccessPoints(false) + searchForAccessPoints(TEST_SSID_1, false) // Then verifyWiseFyFailureIsDisplayed() @@ -997,12 +840,11 @@ internal class SearchFragmentTest : AbstractEspressoTestClass() { } } - @Test fun searchForSSID_permissionErrorDialog() { + @Test + fun searchForSSID_permissionErrorDialog() { with(searchRobot) { // Given - withPermissions(ACCESS_WIFI_STATE, ACCESS_COARSE_LOCATION) launchSearchScreen() - searchForSSID() // When permissionCallbackTriggered( @@ -1015,34 +857,16 @@ internal class SearchFragmentTest : AbstractEspressoTestClass() { } } - @Test fun searchForSSID_permissionError_once() { - with(searchRobot) { - // Given - withSuccessSearchingForSSID() - withPermissionDeniedOnce(ACCESS_WIFI_STATE) - withPermissionDeniedOnce(ACCESS_COARSE_LOCATION) - launchSearchScreen() - - // When - searchForSSID() - - // Then - verifySearchedForSSID() - verifySSIDIsDisplayed() - dismissResultsDialog() - } - } - - @Test fun searchForSSID_permissionError_once_accessWifiState() { + @Test + fun searchForSSID_permissionError_once_accessFineLocation() { with(searchRobot) { // Given withSuccessSearchingForSSID() - withPermissionDeniedOnce(ACCESS_WIFI_STATE) - withPermission(ACCESS_COARSE_LOCATION) + withPermissionDeniedOnce(ACCESS_FINE_LOCATION) launchSearchScreen() // When - searchForSSID() + searchForSSID(TEST_SSID_1) // Then verifySearchedForSSID() @@ -1051,32 +875,12 @@ internal class SearchFragmentTest : AbstractEspressoTestClass() { } } - @Test fun searchForSSID_permissionError_once_accessCoarseLocation() { + @Test + fun searchForSSID_permissionError_emptyList() { with(searchRobot) { // Given - withSuccessSearchingForSSID() - withPermission(ACCESS_WIFI_STATE) - withPermissionDeniedOnce(ACCESS_COARSE_LOCATION) launchSearchScreen() - // When - searchForSSID() - - // Then - verifySearchedForSSID() - verifySSIDIsDisplayed() - dismissResultsDialog() - } - } - - @Test fun searchForSSID_permissionError_emptyList() { - with(searchRobot) { - // Given - withPermissions(ACCESS_WIFI_STATE, ACCESS_COARSE_LOCATION) - withSuccessSearchingForSSID() - launchSearchScreen() - searchForSSID() - // When permissionCallbackTriggeredWithEmptyArray( SearchFragment.WISEFY_SEARCH_FOR_SSID_REQUEST_CODE @@ -1084,17 +888,14 @@ internal class SearchFragmentTest : AbstractEspressoTestClass() { // Then dismissErrorDialog() - verifySearchedForSSID() } } - @Test fun searchForSSID_permissionError_permissionDenied() { + @Test + fun searchForSSID_permissionError_permissionDenied() { with(searchRobot) { // Given - withPermissions(ACCESS_WIFI_STATE, ACCESS_COARSE_LOCATION) - withSuccessSearchingForSSID() launchSearchScreen() - searchForSSID() // When permissionCallbackTriggered( @@ -1104,17 +905,17 @@ internal class SearchFragmentTest : AbstractEspressoTestClass() { // Then dismissErrorDialog() - verifySearchedForSSID() } } - @Test fun searchForSSID_success_afterPermissionGranted() { + @Test + fun searchForSSID_success_afterPermissionGranted() { with(searchRobot) { // Given - withPermissions(ACCESS_WIFI_STATE, ACCESS_COARSE_LOCATION) + withPermission(ACCESS_FINE_LOCATION) withSuccessSearchingForSSID() launchSearchScreen() - searchForSSID() + fillOutForSSID(TEST_SSID_1) // When permissionCallbackTriggered( @@ -1123,21 +924,22 @@ internal class SearchFragmentTest : AbstractEspressoTestClass() { ) // Then - verifySearchedForSSID(times = 2) + verifySearchedForSSID() verifySSIDIsDisplayed() dismissResultsDialog() } } - @Test fun searchForSSID_success() { + @Test + fun searchForSSID_success() { with(searchRobot) { // Given - withPermissions(ACCESS_WIFI_STATE, ACCESS_COARSE_LOCATION) + withPermission(ACCESS_FINE_LOCATION) withSuccessSearchingForSSID() launchSearchScreen() // When - searchForSSID() + searchForSSID(TEST_SSID_1) // Then verifySearchedForSSID() @@ -1146,15 +948,16 @@ internal class SearchFragmentTest : AbstractEspressoTestClass() { } } - @Test fun searchForSSID_SSIDNotFound() { + @Test + fun searchForSSID_SSIDNotFound() { with(searchRobot) { // Given - withPermissions(ACCESS_WIFI_STATE, ACCESS_COARSE_LOCATION) + withPermission(ACCESS_FINE_LOCATION) withSSIDNotFound() launchSearchScreen() // When - searchForSSID() + searchForSSID(TEST_SSID_1) // Then verifySearchedForSSID() @@ -1163,15 +966,16 @@ internal class SearchFragmentTest : AbstractEspressoTestClass() { } } - @Test fun searchForSSID_wiseFyFailure() { + @Test + fun searchForSSID_wiseFyFailure() { with(searchRobot) { // Given - withPermissions(ACCESS_WIFI_STATE, ACCESS_COARSE_LOCATION) + withPermission(ACCESS_FINE_LOCATION) withWiseFyFailureSearchingForSSID() launchSearchScreen() // When - searchForSSID() + searchForSSID(TEST_SSID_1) // Then verifyWiseFyFailureIsDisplayed() @@ -1182,12 +986,11 @@ internal class SearchFragmentTest : AbstractEspressoTestClass() { } } - @Test fun searchForSSIDs_permissionErrorDialog() { + @Test + fun searchForSSIDs_permissionErrorDialog() { with(searchRobot) { // Given - withPermissions(ACCESS_WIFI_STATE, ACCESS_COARSE_LOCATION) launchSearchScreen() - searchForSSIDs() // When permissionCallbackTriggered( @@ -1200,52 +1003,16 @@ internal class SearchFragmentTest : AbstractEspressoTestClass() { } } - @Test fun searchForSSIDs_permissionError_once() { - with(searchRobot) { - // Given - withSuccessSearchingForSSIDs() - withPermissionDeniedOnce(ACCESS_WIFI_STATE) - withPermissionDeniedOnce(ACCESS_COARSE_LOCATION) - launchSearchScreen() - - // When - searchForSSIDs() - - // Then - verifySearchedForSSIDs() - verifySSIDsAreDisplayed() - dismissResultsDialog() - } - } - - @Test fun searchForSSIDs_permissionError_once_accessWifiState() { - with(searchRobot) { - // Given - withSuccessSearchingForSSIDs() - withPermissionDeniedOnce(ACCESS_WIFI_STATE) - withPermission(ACCESS_COARSE_LOCATION) - launchSearchScreen() - - // When - searchForSSIDs() - - // Then - verifySearchedForSSIDs() - verifySSIDsAreDisplayed() - dismissResultsDialog() - } - } - - @Test fun searchForSSIDs_permissionError_once_accessCoarseLocation() { + @Test + fun searchForSSIDs_permissionError_once_accessFineLocation() { with(searchRobot) { // Given withSuccessSearchingForSSIDs() - withPermission(ACCESS_WIFI_STATE) - withPermissionDeniedOnce(ACCESS_COARSE_LOCATION) + withPermissionDeniedOnce(ACCESS_FINE_LOCATION) launchSearchScreen() // When - searchForSSIDs() + searchForSSIDs(TEST_SSID_1) // Then verifySearchedForSSIDs() @@ -1254,13 +1021,11 @@ internal class SearchFragmentTest : AbstractEspressoTestClass() { } } - @Test fun searchForSSIDs_permissionError_emptyList() { + @Test + fun searchForSSIDs_permissionError_emptyList() { with(searchRobot) { // Given - withPermissions(ACCESS_WIFI_STATE, ACCESS_COARSE_LOCATION) - withSuccessSearchingForSSIDs() launchSearchScreen() - searchForSSIDs() // When permissionCallbackTriggeredWithEmptyArray( @@ -1269,17 +1034,14 @@ internal class SearchFragmentTest : AbstractEspressoTestClass() { // Then dismissErrorDialog() - verifySearchedForSSIDs() } } - @Test fun searchForSSIDs_permissionError_permissionDenied() { + @Test + fun searchForSSIDs_permissionError_permissionDenied() { with(searchRobot) { // Given - withPermissions(ACCESS_WIFI_STATE, ACCESS_COARSE_LOCATION) - withSuccessSearchingForSSIDs() launchSearchScreen() - searchForSSIDs() // When permissionCallbackTriggered( @@ -1289,17 +1051,17 @@ internal class SearchFragmentTest : AbstractEspressoTestClass() { // Then dismissErrorDialog() - verifySearchedForSSIDs() } } - @Test fun searchForSSIDs_success_afterPermissionGranted() { + @Test + fun searchForSSIDs_success_afterPermissionGranted() { with(searchRobot) { // Given - withPermissions(ACCESS_WIFI_STATE, ACCESS_COARSE_LOCATION) + withPermission(ACCESS_FINE_LOCATION) withSuccessSearchingForSSIDs() launchSearchScreen() - searchForSSIDs() + fillOutForSSIDs(TEST_SSID_1) // When permissionCallbackTriggered( @@ -1308,21 +1070,22 @@ internal class SearchFragmentTest : AbstractEspressoTestClass() { ) // Then - verifySearchedForSSIDs(times = 2) + verifySearchedForSSIDs() verifySSIDsAreDisplayed() dismissResultsDialog() } } - @Test fun searchForSSIDs_success() { + @Test + fun searchForSSIDs_success() { with(searchRobot) { // Given - withPermissions(ACCESS_WIFI_STATE, ACCESS_COARSE_LOCATION) + withPermission(ACCESS_FINE_LOCATION) withSuccessSearchingForSSIDs() launchSearchScreen() // When - searchForSSIDs() + searchForSSIDs(TEST_SSID_1) // Then verifySearchedForSSIDs() @@ -1331,15 +1094,16 @@ internal class SearchFragmentTest : AbstractEspressoTestClass() { } } - @Test fun searchForSSIDs_noSSIDsFound() { + @Test + fun searchForSSIDs_noSSIDsFound() { with(searchRobot) { // Given - withPermissions(ACCESS_WIFI_STATE, ACCESS_COARSE_LOCATION) + withPermission(ACCESS_FINE_LOCATION) withNoSSIDsFound() launchSearchScreen() // When - searchForSSIDs() + searchForSSIDs(TEST_SSID_1) // Then verifySearchedForSSIDs() @@ -1348,15 +1112,16 @@ internal class SearchFragmentTest : AbstractEspressoTestClass() { } } - @Test fun searchForSSIDs_wiseFyFailure() { + @Test + fun searchForSSIDs_wiseFyFailure() { with(searchRobot) { // Given - withPermissions(ACCESS_WIFI_STATE, ACCESS_COARSE_LOCATION) + withPermission(ACCESS_FINE_LOCATION) withWiseFyFailureSearchingForSSIDs() launchSearchScreen() // When - searchForSSIDs() + searchForSSIDs(TEST_SSID_1) // Then verifyWiseFyFailureIsDisplayed() @@ -1367,12 +1132,11 @@ internal class SearchFragmentTest : AbstractEspressoTestClass() { } } - @Test fun searchForSavedNetwork_permissionErrorDialog() { + @Test + fun searchForSavedNetwork_permissionErrorDialog() { with(searchRobot) { // Given - withPermission(ACCESS_WIFI_STATE) launchSearchScreen() - searchForSavedNetwork() // When permissionCallbackTriggered( @@ -1385,15 +1149,16 @@ internal class SearchFragmentTest : AbstractEspressoTestClass() { } } - @Test fun searchForSavedNetwork_permissionError_once() { + @Test + fun searchForSavedNetwork_permissionError_once() { with(searchRobot) { // Given withSuccessSearchingForSavedNetwork() - withPermissionDeniedOnce(ACCESS_WIFI_STATE) + withPermissionDeniedOnce(ACCESS_FINE_LOCATION) launchSearchScreen() // When - searchForSavedNetwork() + searchForSavedNetwork(TEST_SSID_1) // Then verifySearchedForSavedNetwork() @@ -1402,13 +1167,11 @@ internal class SearchFragmentTest : AbstractEspressoTestClass() { } } - @Test fun searchForSavedNetwork_permissionError_emptyList() { + @Test + fun searchForSavedNetwork_permissionError_emptyList() { with(searchRobot) { // Given - withPermission(ACCESS_WIFI_STATE) - withSuccessSearchingForSavedNetwork() launchSearchScreen() - searchForSavedNetwork() // When permissionCallbackTriggeredWithEmptyArray( @@ -1417,17 +1180,14 @@ internal class SearchFragmentTest : AbstractEspressoTestClass() { // Then dismissErrorDialog() - verifySearchedForSavedNetwork() } } - @Test fun searchForSavedNetwork_permissionError_permissionDenied() { + @Test + fun searchForSavedNetwork_permissionError_permissionDenied() { with(searchRobot) { // Given - withPermission(ACCESS_WIFI_STATE) - withSuccessSearchingForSavedNetwork() launchSearchScreen() - searchForSavedNetwork() // When permissionCallbackTriggered( @@ -1437,17 +1197,17 @@ internal class SearchFragmentTest : AbstractEspressoTestClass() { // Then dismissErrorDialog() - verifySearchedForSavedNetwork() } } - @Test fun searchForSavedNetwork_success_afterPermissionGranted() { + @Test + fun searchForSavedNetwork_success_afterPermissionGranted() { with(searchRobot) { // Given - withPermission(ACCESS_WIFI_STATE) + withPermission(ACCESS_FINE_LOCATION) withSuccessSearchingForSavedNetwork() launchSearchScreen() - searchForSavedNetwork() + fillOutForSavedNetwork(TEST_SSID_1) // When permissionCallbackTriggered( @@ -1456,21 +1216,22 @@ internal class SearchFragmentTest : AbstractEspressoTestClass() { ) // Then - verifySearchedForSavedNetwork(times = 2) + verifySearchedForSavedNetwork() verifySavedNetworkIsDisplayed() dismissResultsDialog() } } - @Test fun searchForSavedNetwork_success() { + @Test + fun searchForSavedNetwork_success() { with(searchRobot) { // Given - withPermissions(ACCESS_WIFI_STATE) + withPermission(ACCESS_FINE_LOCATION) withSuccessSearchingForSavedNetwork() launchSearchScreen() // When - searchForSavedNetwork() + searchForSavedNetwork(TEST_SSID_1) // Then verifySearchedForSavedNetwork() @@ -1479,15 +1240,16 @@ internal class SearchFragmentTest : AbstractEspressoTestClass() { } } - @Test fun searchForSavedNetwork_savedNetworkNotFound() { + @Test + fun searchForSavedNetwork_savedNetworkNotFound() { with(searchRobot) { // Given - withPermissions(ACCESS_WIFI_STATE) + withPermission(ACCESS_FINE_LOCATION) withSavedNetworkNotFound() launchSearchScreen() // When - searchForSavedNetwork() + searchForSavedNetwork(TEST_SSID_1) // Then verifySearchedForSavedNetwork() @@ -1496,15 +1258,16 @@ internal class SearchFragmentTest : AbstractEspressoTestClass() { } } - @Test fun searchForSavedNetwork_wiseFyFailure() { + @Test + fun searchForSavedNetwork_wiseFyFailure() { with(searchRobot) { // Given - withPermissions(ACCESS_WIFI_STATE) + withPermission(ACCESS_FINE_LOCATION) withWiseFyFailureSearchingForSavedNetwork() launchSearchScreen() // When - searchForSavedNetwork() + searchForSavedNetwork(TEST_SSID_1) // Then verifyWiseFyFailureIsDisplayed() @@ -1515,12 +1278,11 @@ internal class SearchFragmentTest : AbstractEspressoTestClass() { } } - @Test fun searchForSavedNetworks_permissionErrorDialog() { + @Test + fun searchForSavedNetworks_permissionErrorDialog() { with(searchRobot) { // Given - withPermission(ACCESS_WIFI_STATE) launchSearchScreen() - searchForSavedNetworks() // When permissionCallbackTriggered( @@ -1533,15 +1295,16 @@ internal class SearchFragmentTest : AbstractEspressoTestClass() { } } - @Test fun searchForSavedNetworks_permissionError_once() { + @Test + fun searchForSavedNetworks_permissionError_once() { with(searchRobot) { // Given withSuccessSearchingForSavedNetworks() - withPermissionDeniedOnce(ACCESS_WIFI_STATE) + withPermissionDeniedOnce(ACCESS_FINE_LOCATION) launchSearchScreen() // When - searchForSavedNetworks() + searchForSavedNetworks(TEST_SSID_1) // Then verifySearchedForSavedNetworks() @@ -1550,13 +1313,11 @@ internal class SearchFragmentTest : AbstractEspressoTestClass() { } } - @Test fun searchForSavedNetworks_permissionError_emptyList() { + @Test + fun searchForSavedNetworks_permissionError_emptyList() { with(searchRobot) { // Given - withPermission(ACCESS_WIFI_STATE) - withSuccessSearchingForSavedNetworks() launchSearchScreen() - searchForSavedNetworks() // When permissionCallbackTriggeredWithEmptyArray( @@ -1565,17 +1326,14 @@ internal class SearchFragmentTest : AbstractEspressoTestClass() { // Then dismissErrorDialog() - verifySearchedForSavedNetworks() } } - @Test fun searchForSavedNetworks_permissionError_permissionDenied() { + @Test + fun searchForSavedNetworks_permissionError_permissionDenied() { with(searchRobot) { // Given - withPermission(ACCESS_WIFI_STATE) - withSuccessSearchingForSavedNetworks() launchSearchScreen() - searchForSavedNetworks() // When permissionCallbackTriggered( @@ -1585,17 +1343,17 @@ internal class SearchFragmentTest : AbstractEspressoTestClass() { // Then dismissErrorDialog() - verifySearchedForSavedNetworks() } } - @Test fun searchForSavedNetworks_success_afterPermissionGranted() { + @Test + fun searchForSavedNetworks_success_afterPermissionGranted() { with(searchRobot) { // Given - withPermission(ACCESS_WIFI_STATE) + withPermission(ACCESS_FINE_LOCATION) withSuccessSearchingForSavedNetworks() launchSearchScreen() - searchForSavedNetworks() + fillOutForSavedNetworks(TEST_SSID_1) // When permissionCallbackTriggered( @@ -1604,21 +1362,22 @@ internal class SearchFragmentTest : AbstractEspressoTestClass() { ) // Then - verifySearchedForSavedNetworks(times = 2) + verifySearchedForSavedNetworks() verifySavedNetworksAreDisplayed() dismissResultsDialog() } } - @Test fun searchForSavedNetworks_success() { + @Test + fun searchForSavedNetworks_success() { with(searchRobot) { // Given - withPermissions(ACCESS_WIFI_STATE) + withPermission(ACCESS_FINE_LOCATION) withSuccessSearchingForSavedNetworks() launchSearchScreen() // When - searchForSavedNetworks() + searchForSavedNetworks(TEST_SSID_1) // Then verifySearchedForSavedNetworks() @@ -1627,15 +1386,16 @@ internal class SearchFragmentTest : AbstractEspressoTestClass() { } } - @Test fun searchForSavedNetworks_noSavedNetworksFound() { + @Test + fun searchForSavedNetworks_noSavedNetworksFound() { with(searchRobot) { // Given - withPermissions(ACCESS_WIFI_STATE) + withPermission(ACCESS_FINE_LOCATION) withNotSavedNetworksFound() launchSearchScreen() // When - searchForSavedNetworks() + searchForSavedNetworks(TEST_SSID_1) // Then verifySearchedForSavedNetworks() @@ -1644,15 +1404,16 @@ internal class SearchFragmentTest : AbstractEspressoTestClass() { } } - @Test fun searchForSavedNetworks_wiseFyFailure() { + @Test + fun searchForSavedNetworks_wiseFyFailure() { with(searchRobot) { // Given - withPermissions(ACCESS_WIFI_STATE) + withPermission(ACCESS_FINE_LOCATION) withWiseFyFailureSearchingForSavedNetworks() launchSearchScreen() // When - searchForSavedNetworks() + searchForSavedNetworks(TEST_SSID_1) // Then verifyWiseFyFailureIsDisplayed() @@ -1663,7 +1424,8 @@ internal class SearchFragmentTest : AbstractEspressoTestClass() { } } - @Test fun ridiculousPermissionRequested() { + @Test + fun ridiculousPermissionRequested() { with(searchRobot) { // Given launchSearchScreen() diff --git a/wisefysample/src/androidTest/java/com/isupatches/wisefysample/ui/search/SearchRobot.kt b/wisefysample/src/androidTest/java/com/isupatches/wisefysample/ui/search/SearchRobot.kt index dd6600c6..3e358c06 100644 --- a/wisefysample/src/androidTest/java/com/isupatches/wisefysample/ui/search/SearchRobot.kt +++ b/wisefysample/src/androidTest/java/com/isupatches/wisefysample/ui/search/SearchRobot.kt @@ -8,7 +8,6 @@ import androidx.test.espresso.action.ViewActions.scrollTo import androidx.test.espresso.matcher.ViewMatchers.withId import androidx.test.espresso.matcher.ViewMatchers.withText import androidx.test.rule.ActivityTestRule - import com.isupatches.wisefy.WiseFyPublicApi import com.isupatches.wisefy.callbacks.SearchForAccessPointCallbacks import com.isupatches.wisefy.callbacks.SearchForAccessPointsCallbacks @@ -34,7 +33,6 @@ import com.isupatches.wisefysample.internal.models.SearchType import com.isupatches.wisefysample.internal.preferences.SearchStore import com.isupatches.wisefysample.internal.util.PermissionUtil import com.isupatches.wisefysample.ui.main.MainActivity - import com.nhaarman.mockitokotlin2.any import com.nhaarman.mockitokotlin2.doAnswer import com.nhaarman.mockitokotlin2.eq @@ -266,95 +264,87 @@ internal class SearchRobot( * Actions */ - fun launchSearchScreen() { - activityTestRule.launchActivity(Intent()) - onView(withId(R.id.menu_search)).performClick() - } - - fun setFilterDupesToNo() { - onView(withId(R.id.noFilterDupesRdb)).performScrollToAndClick() - } - - fun setFilterDupesToYes() { - onView(withId(R.id.yesFilterDupesRdb)).performScrollToAndClick() - } - - fun searchForAccessPoint(filterDuplicates: Boolean) { - fillOutFormForAccessPoint() + fun fillOutForAccessPoint(ssid: String? = null, filterDuplicates: Boolean? = null) { + onView(withId(R.id.accessPointRdb)).performScrollToAndClick() + setSearchRegex(ssid) onView(withId(R.id.noFullListRdb)).performScrollToAndClick() - if (filterDuplicates) { - onView(withId(R.id.yesFilterDupesRdb)).performScrollToAndClick() - } else { - onView(withId(R.id.noFilterDupesRdb)).performScrollToAndClick() - } + setFilterDuplicates(filterDuplicates) setTimeoutSeek() - clickSearchButton() } - fun searchForAccessPoints(filterDuplicates: Boolean) { - fillOutFormForAccessPoint() + fun fillOutForAccessPoints(ssid: String? = null, filterDuplicates: Boolean? = null) { + onView(withId(R.id.accessPointRdb)).performScrollToAndClick() + setSearchRegex(ssid) onView(withId(R.id.yesFullListRdb)).performScrollToAndClick() - if (filterDuplicates) { - onView(withId(R.id.yesFilterDupesRdb)).performScrollToAndClick() - } else { - onView(withId(R.id.noFilterDupesRdb)).performScrollToAndClick() - } - clickSearchButton() + setFilterDuplicates(filterDuplicates) } - fun searchForSavedNetwork() { - fillOutFormForForSavedNetwork() + fun fillOutForSavedNetwork(ssid: String? = null) { + onView(withId(R.id.savedNetworkRdb)).performScrollToAndClick() + setSearchRegex(ssid) onView(withId(R.id.noFullListRdb)).performScrollToAndClick() - clickSearchButton() } - fun searchForSavedNetworks() { - fillOutFormForForSavedNetwork() + fun fillOutForSavedNetworks(ssid: String? = null) { + onView(withId(R.id.savedNetworkRdb)).performScrollToAndClick() + setSearchRegex(ssid) onView(withId(R.id.yesFullListRdb)).performScrollToAndClick() - clickSearchButton() } - fun searchForSSID() { - fillOutFormFormForSSID() + fun fillOutForSSID(ssid: String? = null) { + onView(withId(R.id.ssidRdb)).performScrollToAndClick() + setSearchRegex(ssid) onView(withId(R.id.noFullListRdb)).performScrollToAndClick() setTimeoutSeek() - clickSearchButton() } - fun searchForSSIDs() { - fillOutFormFormForSSID() + fun fillOutForSSIDs(ssid: String? = null) { + onView(withId(R.id.ssidRdb)).performScrollToAndClick() + setSearchRegex(ssid) onView(withId(R.id.yesFullListRdb)).performScrollToAndClick() - clickSearchButton() } - fun selectAccessPoint() { - fillOutFormForAccessPoint() - onView(withId(R.id.noFullListRdb)).performScrollToAndClick() + fun launchSearchScreen() { + activityTestRule.launchActivity(Intent()) + onView(withId(R.id.menu_search)).performClick() } - fun selectAccessPoints() { - fillOutFormForAccessPoint() - onView(withId(R.id.yesFullListRdb)).performScrollToAndClick() + fun setFilterDupesToNo() { + onView(withId(R.id.noFilterDupesRdb)).performScrollToAndClick() } - fun selectSSID() { - fillOutFormFormForSSID() - onView(withId(R.id.noFullListRdb)).performScrollToAndClick() + fun setFilterDupesToYes() { + onView(withId(R.id.yesFilterDupesRdb)).performScrollToAndClick() } - fun selectSSIDs() { - fillOutFormFormForSSID() - onView(withId(R.id.yesFullListRdb)).performScrollToAndClick() + fun searchForAccessPoint(ssid: String, filterDuplicates: Boolean) { + fillOutForAccessPoint(ssid, filterDuplicates) + clickSearchButton() } - fun selectSavedNetwork() { - fillOutFormForForSavedNetwork() - onView(withId(R.id.noFullListRdb)).performScrollToAndClick() + fun searchForAccessPoints(ssid: String, filterDuplicates: Boolean) { + fillOutForAccessPoints(ssid, filterDuplicates) + clickSearchButton() } - fun selectSavedNetworks() { - fillOutFormForForSavedNetwork() - onView(withId(R.id.yesFullListRdb)).performScrollToAndClick() + fun searchForSavedNetwork(ssid: String) { + fillOutForSavedNetwork(ssid) + clickSearchButton() + } + + fun searchForSavedNetworks(ssid: String) { + fillOutForSavedNetworks(ssid) + clickSearchButton() + } + + fun searchForSSID(ssid: String) { + fillOutForSSID(ssid) + clickSearchButton() + } + + fun searchForSSIDs(ssid: String) { + fillOutForSSIDs(ssid) + clickSearchButton() } /* @@ -365,23 +355,20 @@ internal class SearchRobot( onView(withId(R.id.searchBtn)).performScrollToAndClick() } - private fun fillOutFormForAccessPoint() { - onView(withId(R.id.accessPointRdb)).performScrollToAndClick() - setSearchRegex() - } - - private fun fillOutFormForForSavedNetwork() { - onView(withId(R.id.savedNetworkRdb)).performScrollToAndClick() - setSearchRegex() - } - - private fun fillOutFormFormForSSID() { - onView(withId(R.id.ssidRdb)).performScrollToAndClick() - setSearchRegex() + private fun setFilterDuplicates(filterDuplicates: Boolean?) { + filterDuplicates?.let { + if (it) { + setFilterDupesToYes() + } else { + setFilterDupesToNo() + } + } } - private fun setSearchRegex() { - onView(withId(R.id.searchRegexEdt)).performScrollToAndReplaceText(TEST_SSID_1) + private fun setSearchRegex(ssid: String?) { + ssid?.let { + onView(withId(R.id.searchRegexEdt)).performScrollToAndReplaceText(ssid) + } } private fun setTimeoutSeek() { diff --git a/wisefysample/src/main/AndroidManifest.xml b/wisefysample/src/main/AndroidManifest.xml index d8372b7b..25049a7c 100644 --- a/wisefysample/src/main/AndroidManifest.xml +++ b/wisefysample/src/main/AndroidManifest.xml @@ -4,12 +4,15 @@ xmlns:tools="http://schemas.android.com/tools" package="com.isupatches.wisefysample"> - - + + - + + + - + + - override fun activityInjector() = activityInjector - - @Inject lateinit var supportFragmentInject: DispatchingAndroidInjector - override fun supportFragmentInjector() = supportFragmentInject + @Inject lateinit var androidInjector: DispatchingAndroidInjector + override fun androidInjector() = androidInjector protected lateinit var mainApplicationComponent: MainApplicationComponent diff --git a/wisefysample/src/main/java/com/isupatches/wisefysample/internal/base/BaseActivity.kt b/wisefysample/src/main/java/com/isupatches/wisefysample/internal/base/BaseActivity.kt index 4c62731b..b3b73bca 100644 --- a/wisefysample/src/main/java/com/isupatches/wisefysample/internal/base/BaseActivity.kt +++ b/wisefysample/src/main/java/com/isupatches/wisefysample/internal/base/BaseActivity.kt @@ -17,7 +17,6 @@ package com.isupatches.wisefysample.internal.base import android.os.Bundle import androidx.appcompat.app.AppCompatActivity - import dagger.android.AndroidInjection internal abstract class BaseActivity : AppCompatActivity() { diff --git a/wisefysample/src/main/java/com/isupatches/wisefysample/internal/base/BaseFragment.kt b/wisefysample/src/main/java/com/isupatches/wisefysample/internal/base/BaseFragment.kt index 7cbad8c9..d11bdd2a 100644 --- a/wisefysample/src/main/java/com/isupatches/wisefysample/internal/base/BaseFragment.kt +++ b/wisefysample/src/main/java/com/isupatches/wisefysample/internal/base/BaseFragment.kt @@ -23,15 +23,12 @@ import android.view.ViewGroup import androidx.annotation.LayoutRes import androidx.annotation.StringRes import androidx.fragment.app.Fragment - import com.isupatches.wisefy.constants.WiseFyCode import com.isupatches.wisefysample.R import com.isupatches.wisefysample.internal.util.PermissionUtil import com.isupatches.wisefysample.ui.dialogs.FullScreenNoticeDialogFragment import com.isupatches.wisefysample.ui.dialogs.NoticeDialogFragment - import dagger.android.support.AndroidSupportInjection - import javax.inject.Inject internal abstract class BaseFragment : Fragment() { diff --git a/wisefysample/src/main/java/com/isupatches/wisefysample/internal/base/BasePresenter.kt b/wisefysample/src/main/java/com/isupatches/wisefysample/internal/base/BasePresenter.kt index cb07c263..76601c3d 100644 --- a/wisefysample/src/main/java/com/isupatches/wisefysample/internal/base/BasePresenter.kt +++ b/wisefysample/src/main/java/com/isupatches/wisefysample/internal/base/BasePresenter.kt @@ -16,7 +16,6 @@ package com.isupatches.wisefysample.internal.base import android.util.Log - import com.isupatches.wisefy.constants.WiseFyCode import com.isupatches.wisefysample.internal.util.RxSchedulersProvider @@ -47,7 +46,9 @@ internal abstract class BasePresenter constructor( if (isViewAttached) { rxSchedulersProvider.main.scheduleDirect { if (isViewAttached) { - viewCommand(view!!) + val view = view + requireNotNull(view) + viewCommand(view) } else { Log.w(TAG, "ViewCommand was scheduled., but view is now detached!") } diff --git a/wisefysample/src/main/java/com/isupatches/wisefysample/internal/di/PermissionsModule.kt b/wisefysample/src/main/java/com/isupatches/wisefysample/internal/di/PermissionsModule.kt index a7ab50ad..deb81936 100644 --- a/wisefysample/src/main/java/com/isupatches/wisefysample/internal/di/PermissionsModule.kt +++ b/wisefysample/src/main/java/com/isupatches/wisefysample/internal/di/PermissionsModule.kt @@ -17,7 +17,6 @@ package com.isupatches.wisefysample.internal.di import com.isupatches.wisefysample.internal.util.PermissionUtil import com.isupatches.wisefysample.internal.util.PermissionsUtilImpl - import dagger.Binds import dagger.Module diff --git a/wisefysample/src/main/java/com/isupatches/wisefysample/internal/di/PreferencesModule.kt b/wisefysample/src/main/java/com/isupatches/wisefysample/internal/di/PreferencesModule.kt index 544881fe..1e1f5d8e 100644 --- a/wisefysample/src/main/java/com/isupatches/wisefysample/internal/di/PreferencesModule.kt +++ b/wisefysample/src/main/java/com/isupatches/wisefysample/internal/di/PreferencesModule.kt @@ -17,7 +17,6 @@ package com.isupatches.wisefysample.internal.di import android.content.Context import androidx.annotation.StringRes - import com.isupatches.wisefysample.R import com.isupatches.wisefysample.internal.preferences.AddNetworkStore import com.isupatches.wisefysample.internal.preferences.RemoveNetworkStore @@ -25,10 +24,8 @@ import com.isupatches.wisefysample.internal.preferences.SearchStore import com.isupatches.wisefysample.internal.preferences.SharedPreferencesAddNetworkStore import com.isupatches.wisefysample.internal.preferences.SharedPreferencesRemoveNetworkStore import com.isupatches.wisefysample.internal.preferences.SharedPreferencesSearchStore - import dagger.Module import dagger.Provides - import javax.inject.Singleton @Suppress("unused", "UndocumentedPublicClass", "UndocumentedPublicFunction") diff --git a/wisefysample/src/main/java/com/isupatches/wisefysample/internal/di/ScreenBindingsModule.kt b/wisefysample/src/main/java/com/isupatches/wisefysample/internal/di/ScreenBindingsModule.kt index 181ef58e..1efa25b3 100644 --- a/wisefysample/src/main/java/com/isupatches/wisefysample/internal/di/ScreenBindingsModule.kt +++ b/wisefysample/src/main/java/com/isupatches/wisefysample/internal/di/ScreenBindingsModule.kt @@ -16,7 +16,6 @@ package com.isupatches.wisefysample.internal.di import com.isupatches.wisefysample.ui.main.MainActivity - import dagger.Module import dagger.android.ContributesAndroidInjector diff --git a/wisefysample/src/main/java/com/isupatches/wisefysample/internal/nav/MainRouter.kt b/wisefysample/src/main/java/com/isupatches/wisefysample/internal/nav/MainRouter.kt index cabf7abe..82d46637 100644 --- a/wisefysample/src/main/java/com/isupatches/wisefysample/internal/nav/MainRouter.kt +++ b/wisefysample/src/main/java/com/isupatches/wisefysample/internal/nav/MainRouter.kt @@ -18,7 +18,6 @@ package com.isupatches.wisefysample.internal.nav import androidx.fragment.app.Fragment import androidx.fragment.app.FragmentActivity import com.google.android.material.bottomnavigation.BottomNavigationView - import com.isupatches.wisefysample.R internal fun BottomNavigationView.selectItem(actionId: Int) { diff --git a/wisefysample/src/main/java/com/isupatches/wisefysample/internal/preferences/AddNetworkStore.kt b/wisefysample/src/main/java/com/isupatches/wisefysample/internal/preferences/AddNetworkStore.kt index d184f21f..1e42e575 100644 --- a/wisefysample/src/main/java/com/isupatches/wisefysample/internal/preferences/AddNetworkStore.kt +++ b/wisefysample/src/main/java/com/isupatches/wisefysample/internal/preferences/AddNetworkStore.kt @@ -18,7 +18,6 @@ package com.isupatches.wisefysample.internal.preferences import android.content.SharedPreferences import androidx.annotation.VisibleForTesting import androidx.core.content.edit - import com.isupatches.wisefysample.internal.models.NetworkType @VisibleForTesting internal const val PREF_NETWORK_TYPE = "network type" diff --git a/wisefysample/src/main/java/com/isupatches/wisefysample/internal/preferences/RemoveNetworkStore.kt b/wisefysample/src/main/java/com/isupatches/wisefysample/internal/preferences/RemoveNetworkStore.kt index 0e295f50..d33984f3 100644 --- a/wisefysample/src/main/java/com/isupatches/wisefysample/internal/preferences/RemoveNetworkStore.kt +++ b/wisefysample/src/main/java/com/isupatches/wisefysample/internal/preferences/RemoveNetworkStore.kt @@ -16,7 +16,6 @@ package com.isupatches.wisefysample.internal.preferences import android.content.SharedPreferences - import androidx.core.content.edit internal interface RemoveNetworkStore { diff --git a/wisefysample/src/main/java/com/isupatches/wisefysample/internal/preferences/SearchStore.kt b/wisefysample/src/main/java/com/isupatches/wisefysample/internal/preferences/SearchStore.kt index 25baa6ed..82dff2de 100644 --- a/wisefysample/src/main/java/com/isupatches/wisefysample/internal/preferences/SearchStore.kt +++ b/wisefysample/src/main/java/com/isupatches/wisefysample/internal/preferences/SearchStore.kt @@ -18,7 +18,6 @@ package com.isupatches.wisefysample.internal.preferences import android.content.SharedPreferences import androidx.annotation.VisibleForTesting import androidx.core.content.edit - import com.isupatches.wisefysample.internal.models.SearchType @VisibleForTesting internal const val PREF_SEARCH_TYPE = "search type" diff --git a/wisefysample/src/main/java/com/isupatches/wisefysample/internal/preferences/SharedPreferences.kt b/wisefysample/src/main/java/com/isupatches/wisefysample/internal/preferences/SharedPreferences.kt index 3f7e2483..329f767c 100644 --- a/wisefysample/src/main/java/com/isupatches/wisefysample/internal/preferences/SharedPreferences.kt +++ b/wisefysample/src/main/java/com/isupatches/wisefysample/internal/preferences/SharedPreferences.kt @@ -18,9 +18,7 @@ package com.isupatches.wisefysample.internal.preferences import android.content.SharedPreferences import androidx.core.content.edit -internal fun SharedPreferences.getLastUsedRegex() = getNonNullString( - PREF_LAST_USED_REGEX - ) +internal fun SharedPreferences.getLastUsedRegex() = getNonNullString(PREF_LAST_USED_REGEX) internal fun SharedPreferences.setLastUsedRegex(lastUsedRegex: String) { edit { @@ -28,5 +26,4 @@ internal fun SharedPreferences.setLastUsedRegex(lastUsedRegex: String) { } } -internal fun SharedPreferences.getNonNullString(key: String) = - getString(key, "") ?: "" +internal fun SharedPreferences.getNonNullString(key: String) = getString(key, "") ?: "" diff --git a/wisefysample/src/main/java/com/isupatches/wisefysample/internal/util/BundleUtil.kt b/wisefysample/src/main/java/com/isupatches/wisefysample/internal/util/BundleUtil.kt index 7333ef46..3609aeb8 100644 --- a/wisefysample/src/main/java/com/isupatches/wisefysample/internal/util/BundleUtil.kt +++ b/wisefysample/src/main/java/com/isupatches/wisefysample/internal/util/BundleUtil.kt @@ -19,7 +19,11 @@ import android.os.Bundle import androidx.fragment.app.Fragment /** + * A syntactic-sugar function used to apply arguments to a Fragment's bundle * + * @param block The arguments to add to the bundle + * + * @return The fragment whose bundle was altered */ fun T.applyArguments(block: Bundle.() -> Unit): T { arguments = Bundle().apply(block) diff --git a/wisefysample/src/main/java/com/isupatches/wisefysample/internal/util/HtmlUtil.kt b/wisefysample/src/main/java/com/isupatches/wisefysample/internal/util/HtmlUtil.kt index db3b5f5f..274417fc 100644 --- a/wisefysample/src/main/java/com/isupatches/wisefysample/internal/util/HtmlUtil.kt +++ b/wisefysample/src/main/java/com/isupatches/wisefysample/internal/util/HtmlUtil.kt @@ -19,7 +19,7 @@ import android.os.Build import android.text.Html import android.text.Spanned -@Suppress("DEPRECATION") +@Suppress("deprecation") internal fun String.asHtmlSpanned(): Spanned = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { Html.fromHtml(this, Html.FROM_HTML_MODE_COMPACT) diff --git a/wisefysample/src/main/java/com/isupatches/wisefysample/internal/util/KeyboardUtil.kt b/wisefysample/src/main/java/com/isupatches/wisefysample/internal/util/KeyboardUtil.kt index ff2e9eba..a5d26d03 100644 --- a/wisefysample/src/main/java/com/isupatches/wisefysample/internal/util/KeyboardUtil.kt +++ b/wisefysample/src/main/java/com/isupatches/wisefysample/internal/util/KeyboardUtil.kt @@ -18,7 +18,6 @@ package com.isupatches.wisefysample.internal.util import android.app.Activity import android.view.View import android.view.inputmethod.InputMethodManager - import com.isupatches.wisefysample.internal.base.BaseFragment internal fun BaseFragment.hideKeyboardFrom(view: View) { diff --git a/wisefysample/src/main/java/com/isupatches/wisefysample/internal/util/PermissionsUtil.kt b/wisefysample/src/main/java/com/isupatches/wisefysample/internal/util/PermissionsUtil.kt index 76d8ef2d..ddd38f97 100644 --- a/wisefysample/src/main/java/com/isupatches/wisefysample/internal/util/PermissionsUtil.kt +++ b/wisefysample/src/main/java/com/isupatches/wisefysample/internal/util/PermissionsUtil.kt @@ -18,7 +18,6 @@ package com.isupatches.wisefysample.internal.util import android.content.Context import android.content.pm.PackageManager import androidx.core.content.ContextCompat - import javax.inject.Inject internal interface PermissionUtil { diff --git a/wisefysample/src/main/java/com/isupatches/wisefysample/internal/util/RxSchedulersProvider.kt b/wisefysample/src/main/java/com/isupatches/wisefysample/internal/util/RxSchedulersProvider.kt index 491bc955..70c504a9 100644 --- a/wisefysample/src/main/java/com/isupatches/wisefysample/internal/util/RxSchedulersProvider.kt +++ b/wisefysample/src/main/java/com/isupatches/wisefysample/internal/util/RxSchedulersProvider.kt @@ -16,13 +16,22 @@ package com.isupatches.wisefysample.internal.util import io.reactivex.Scheduler -import io.reactivex.schedulers.Schedulers import io.reactivex.android.schedulers.AndroidSchedulers - +import io.reactivex.schedulers.Schedulers import javax.inject.Inject -@Suppress("UndocumentedPublicClass") +/** + * A classed used to provide appropriate Rx schedulers for both production and tests + */ open class RxSchedulersProvider @Inject constructor() { + + /** + * The UI/main thread for Rx subscriptions to use + */ open val main: Scheduler by lazy { AndroidSchedulers.mainThread() } + + /** + * The background thread for Rx subscriptions to use + */ open val io: Scheduler by lazy { Schedulers.io() } } diff --git a/wisefysample/src/main/java/com/isupatches/wisefysample/internal/util/SdkUtil.kt b/wisefysample/src/main/java/com/isupatches/wisefysample/internal/util/SdkUtil.kt index 0685da6b..6c29f36f 100644 --- a/wisefysample/src/main/java/com/isupatches/wisefysample/internal/util/SdkUtil.kt +++ b/wisefysample/src/main/java/com/isupatches/wisefysample/internal/util/SdkUtil.kt @@ -16,7 +16,6 @@ package com.isupatches.wisefysample.internal.util import android.os.Build - import javax.inject.Inject internal interface SdkUtil { diff --git a/wisefysample/src/main/java/com/isupatches/wisefysample/internal/util/WiseFyFactory.kt b/wisefysample/src/main/java/com/isupatches/wisefysample/internal/util/WiseFyFactory.kt index d612e5d1..869c19e1 100644 --- a/wisefysample/src/main/java/com/isupatches/wisefysample/internal/util/WiseFyFactory.kt +++ b/wisefysample/src/main/java/com/isupatches/wisefysample/internal/util/WiseFyFactory.kt @@ -16,11 +16,19 @@ package com.isupatches.wisefysample.internal.util import androidx.fragment.app.FragmentActivity - import com.isupatches.wisefy.WiseFy import com.isupatches.wisefy.WiseFyPublicApi -@Suppress("UndocumentedPublicFunction") -fun createWiseFy(activity: FragmentActivity): WiseFyPublicApi = WiseFy.Brains(activity) +/** + * @param activity The context to create a WiseFy implementation + * + * @return WiseFyPublicApi - The implementation of the public API for WiseFy + * + * @see [WiseFy] + * @see [WiseFyPublicApi] + */ +fun createWiseFy(activity: FragmentActivity): WiseFyPublicApi { + return WiseFy.Brains(activity) .logging(true) .getSmarts() +} diff --git a/wisefysample/src/main/java/com/isupatches/wisefysample/ui/add/AddNetworkFragment.kt b/wisefysample/src/main/java/com/isupatches/wisefysample/ui/add/AddNetworkFragment.kt index 64b5074d..c5343385 100644 --- a/wisefysample/src/main/java/com/isupatches/wisefysample/ui/add/AddNetworkFragment.kt +++ b/wisefysample/src/main/java/com/isupatches/wisefysample/ui/add/AddNetworkFragment.kt @@ -15,14 +15,13 @@ */ package com.isupatches.wisefysample.ui.add -import android.Manifest.permission.ACCESS_WIFI_STATE +import android.Manifest.permission.ACCESS_FINE_LOCATION import android.content.pm.PackageManager import android.net.wifi.WifiConfiguration import android.os.Bundle import android.util.Log import android.view.View import androidx.annotation.VisibleForTesting - import com.isupatches.wisefy.constants.WiseFyCode import com.isupatches.wisefysample.R import com.isupatches.wisefysample.internal.base.BaseFragment @@ -30,17 +29,14 @@ import com.isupatches.wisefysample.internal.models.NetworkType import com.isupatches.wisefysample.internal.preferences.AddNetworkStore import com.isupatches.wisefysample.internal.util.getTrimmedInput import com.isupatches.wisefysample.internal.util.hideKeyboardFrom - import dagger.Binds import dagger.Module - +import javax.inject.Inject import kotlinx.android.synthetic.main.fragment_add.addNetworkBtn import kotlinx.android.synthetic.main.fragment_add.addNetworkTypeRdg import kotlinx.android.synthetic.main.fragment_add.networkNameEdt -import kotlinx.android.synthetic.main.fragment_add.networkPasswordTil import kotlinx.android.synthetic.main.fragment_add.networkPasswordEdt - -import javax.inject.Inject +import kotlinx.android.synthetic.main.fragment_add.networkPasswordTil internal class AddNetworkFragment : BaseFragment(), AddNetworkMvp.View { @@ -155,12 +151,14 @@ internal class AddNetworkFragment : BaseFragment(), AddNetworkMvp.View { * WiseFy helpers */ + @Throws(SecurityException::class) private fun addOpenNetwork() { if (checkAddOpenNetworkPermissions()) { presenter.addOpenNetwork(networkNameEdt.getTrimmedInput()) } } + @Throws(SecurityException::class) private fun addWEPNetwork() { if (checkAddWEPNetworkPermissions()) { presenter.addWEPNetwork( @@ -170,6 +168,7 @@ internal class AddNetworkFragment : BaseFragment(), AddNetworkMvp.View { } } + @Throws(SecurityException::class) private fun addWPA2Network() { if (checkAddWPA2NetworkPermissions()) { presenter.addWPA2Network( @@ -184,15 +183,15 @@ internal class AddNetworkFragment : BaseFragment(), AddNetworkMvp.View { */ private fun checkAddOpenNetworkPermissions(): Boolean { - return isPermissionGranted(ACCESS_WIFI_STATE, WISEFY_ADD_OPEN_NETWORK_REQUEST_CODE) + return isPermissionGranted(ACCESS_FINE_LOCATION, WISEFY_ADD_OPEN_NETWORK_REQUEST_CODE) } private fun checkAddWEPNetworkPermissions(): Boolean { - return isPermissionGranted(ACCESS_WIFI_STATE, WISEFY_ADD_WEP_NETWORK_REQUEST_CODE) + return isPermissionGranted(ACCESS_FINE_LOCATION, WISEFY_ADD_WEP_NETWORK_REQUEST_CODE) } private fun checkAddWPA2NetworkPermissions(): Boolean { - return isPermissionGranted(ACCESS_WIFI_STATE, WISEFY_ADD_WPA2_NETWORK_REQUEST_CODE) + return isPermissionGranted(ACCESS_FINE_LOCATION, WISEFY_ADD_WPA2_NETWORK_REQUEST_CODE) } override fun onRequestPermissionsResult(requestCode: Int, permissions: Array, grantResults: IntArray) { diff --git a/wisefysample/src/main/java/com/isupatches/wisefysample/ui/add/AddNetworkModel.kt b/wisefysample/src/main/java/com/isupatches/wisefysample/ui/add/AddNetworkModel.kt index 7c353d71..7cd821d1 100644 --- a/wisefysample/src/main/java/com/isupatches/wisefysample/ui/add/AddNetworkModel.kt +++ b/wisefysample/src/main/java/com/isupatches/wisefysample/ui/add/AddNetworkModel.kt @@ -15,25 +15,23 @@ */ package com.isupatches.wisefysample.ui.add -import android.Manifest.permission.ACCESS_WIFI_STATE +import android.Manifest.permission.ACCESS_FINE_LOCATION import androidx.annotation.RequiresPermission - import com.isupatches.wisefy.WiseFyPublicApi import com.isupatches.wisefy.callbacks.AddNetworkCallbacks - import javax.inject.Inject internal class AddNetworkModel @Inject constructor( private val wiseFy: WiseFyPublicApi ) : AddNetworkMvp.Model { - @RequiresPermission(ACCESS_WIFI_STATE) + @RequiresPermission(ACCESS_FINE_LOCATION) override fun addOpenNetwork(ssid: String, callbacks: AddNetworkCallbacks) { wiseFy.addOpenNetwork(ssid, callbacks) } - @RequiresPermission(ACCESS_WIFI_STATE) - @Suppress("DEPRECATION") + @RequiresPermission(ACCESS_FINE_LOCATION) + @Suppress("deprecation") override fun addWEPNetwork( ssid: String, password: String, @@ -42,7 +40,7 @@ internal class AddNetworkModel @Inject constructor( wiseFy.addWEPNetwork(ssid, password, callbacks) } - @RequiresPermission(ACCESS_WIFI_STATE) + @RequiresPermission(ACCESS_FINE_LOCATION) override fun addWPA2Network( ssid: String, password: String, diff --git a/wisefysample/src/main/java/com/isupatches/wisefysample/ui/add/AddNetworkMvp.kt b/wisefysample/src/main/java/com/isupatches/wisefysample/ui/add/AddNetworkMvp.kt index 1f9f6b0e..29689a11 100644 --- a/wisefysample/src/main/java/com/isupatches/wisefysample/ui/add/AddNetworkMvp.kt +++ b/wisefysample/src/main/java/com/isupatches/wisefysample/ui/add/AddNetworkMvp.kt @@ -15,8 +15,9 @@ */ package com.isupatches.wisefysample.ui.add +import android.Manifest.permission.ACCESS_FINE_LOCATION import android.net.wifi.WifiConfiguration - +import androidx.annotation.RequiresPermission import com.isupatches.wisefy.callbacks.AddNetworkCallbacks import com.isupatches.wisefysample.internal.base.BaseMvp @@ -29,14 +30,26 @@ internal interface AddNetworkMvp { } interface Presenter : BaseMvp.Presenter { + + @RequiresPermission(ACCESS_FINE_LOCATION) fun addOpenNetwork(ssid: String) + + @RequiresPermission(ACCESS_FINE_LOCATION) fun addWEPNetwork(ssid: String, password: String) + + @RequiresPermission(ACCESS_FINE_LOCATION) fun addWPA2Network(ssid: String, password: String) } interface Model { + + @RequiresPermission(ACCESS_FINE_LOCATION) fun addOpenNetwork(ssid: String, callbacks: AddNetworkCallbacks) + + @RequiresPermission(ACCESS_FINE_LOCATION) fun addWEPNetwork(ssid: String, password: String, callbacks: AddNetworkCallbacks) + + @RequiresPermission(ACCESS_FINE_LOCATION) fun addWPA2Network(ssid: String, password: String, callbacks: AddNetworkCallbacks) } } diff --git a/wisefysample/src/main/java/com/isupatches/wisefysample/ui/add/AddNetworkPresenter.kt b/wisefysample/src/main/java/com/isupatches/wisefysample/ui/add/AddNetworkPresenter.kt index 45d71f1b..b06ac919 100644 --- a/wisefysample/src/main/java/com/isupatches/wisefysample/ui/add/AddNetworkPresenter.kt +++ b/wisefysample/src/main/java/com/isupatches/wisefysample/ui/add/AddNetworkPresenter.kt @@ -15,14 +15,12 @@ */ package com.isupatches.wisefysample.ui.add -import android.Manifest.permission.ACCESS_WIFI_STATE +import android.Manifest.permission.ACCESS_FINE_LOCATION import android.net.wifi.WifiConfiguration import androidx.annotation.RequiresPermission - import com.isupatches.wisefy.callbacks.AddNetworkCallbacks import com.isupatches.wisefysample.internal.base.BasePresenter import com.isupatches.wisefysample.internal.util.RxSchedulersProvider - import javax.inject.Inject internal class AddNetworkPresenter @Inject constructor( @@ -33,11 +31,11 @@ internal class AddNetworkPresenter @Inject constructor( private val addNetworkCallbacks by lazy { object : AddNetworkCallbacks { override fun networkAdded(newNetworkId: Int, networkConfig: WifiConfiguration) { - displayNetworkAdded(newNetworkId, networkConfig) + doSafelyWithView { view -> view.displayNetworkAdded(newNetworkId, networkConfig) } } override fun failureAddingNetwork(wifiManagerReturn: Int) { - displayFailureAddingNetwork(wifiManagerReturn) + doSafelyWithView { view -> view.displayFailureAddingNetwork(wifiManagerReturn) } } override fun wisefyFailure(wisefyFailureCode: Int) { @@ -50,30 +48,18 @@ internal class AddNetworkPresenter @Inject constructor( * Model call-throughs */ - @RequiresPermission(ACCESS_WIFI_STATE) + @RequiresPermission(ACCESS_FINE_LOCATION) override fun addOpenNetwork(ssid: String) { model.addOpenNetwork(ssid, addNetworkCallbacks) } - @RequiresPermission(ACCESS_WIFI_STATE) + @RequiresPermission(ACCESS_FINE_LOCATION) override fun addWEPNetwork(ssid: String, password: String) { model.addWEPNetwork(ssid, password, addNetworkCallbacks) } - @RequiresPermission(ACCESS_WIFI_STATE) + @RequiresPermission(ACCESS_FINE_LOCATION) override fun addWPA2Network(ssid: String, password: String) { model.addWPA2Network(ssid, password, addNetworkCallbacks) } - - /* - * View callbacks - */ - - private fun displayFailureAddingNetwork(wifiManagerReturn: Int) { - doSafelyWithView { view -> view.displayFailureAddingNetwork(wifiManagerReturn) } - } - - private fun displayNetworkAdded(newNetworkId: Int, networkConfig: WifiConfiguration) { - doSafelyWithView { view -> view.displayNetworkAdded(newNetworkId, networkConfig) } - } } diff --git a/wisefysample/src/main/java/com/isupatches/wisefysample/ui/dialogs/BaseNoticeDialogFragment.kt b/wisefysample/src/main/java/com/isupatches/wisefysample/ui/dialogs/BaseNoticeDialogFragment.kt index d192b2ca..541a9ea4 100644 --- a/wisefysample/src/main/java/com/isupatches/wisefysample/ui/dialogs/BaseNoticeDialogFragment.kt +++ b/wisefysample/src/main/java/com/isupatches/wisefysample/ui/dialogs/BaseNoticeDialogFragment.kt @@ -17,9 +17,7 @@ package com.isupatches.wisefysample.ui.dialogs import android.os.Bundle import android.view.View - import com.isupatches.wisefysample.internal.base.BaseDialogFragment - import kotlinx.android.synthetic.main.dialog_base.dialogMessageTxt import kotlinx.android.synthetic.main.dialog_base.dialogTitleTxt import kotlinx.android.synthetic.main.dialog_base.okBtn diff --git a/wisefysample/src/main/java/com/isupatches/wisefysample/ui/dialogs/FullScreenNoticeDialogFragment.kt b/wisefysample/src/main/java/com/isupatches/wisefysample/ui/dialogs/FullScreenNoticeDialogFragment.kt index 6766ebc8..41113da1 100644 --- a/wisefysample/src/main/java/com/isupatches/wisefysample/ui/dialogs/FullScreenNoticeDialogFragment.kt +++ b/wisefysample/src/main/java/com/isupatches/wisefysample/ui/dialogs/FullScreenNoticeDialogFragment.kt @@ -18,7 +18,6 @@ package com.isupatches.wisefysample.ui.dialogs import android.app.Dialog import android.os.Bundle import android.view.ViewGroup - import com.isupatches.wisefysample.R import com.isupatches.wisefysample.internal.util.applyArguments diff --git a/wisefysample/src/main/java/com/isupatches/wisefysample/ui/main/MainActivity.kt b/wisefysample/src/main/java/com/isupatches/wisefysample/ui/main/MainActivity.kt index bc3bab27..ca9225f3 100644 --- a/wisefysample/src/main/java/com/isupatches/wisefysample/ui/main/MainActivity.kt +++ b/wisefysample/src/main/java/com/isupatches/wisefysample/ui/main/MainActivity.kt @@ -17,12 +17,8 @@ package com.isupatches.wisefysample.ui.main import android.os.Bundle import android.view.MenuItem -import androidx.appcompat.app.AppCompatActivity -import androidx.fragment.app.Fragment - import com.google.android.material.bottomnavigation.BottomNavigationView import com.isupatches.wisefy.WiseFyPublicApi - import com.isupatches.wisefysample.R import com.isupatches.wisefysample.internal.nav.openFragment import com.isupatches.wisefysample.internal.nav.selectItem @@ -33,26 +29,17 @@ import com.isupatches.wisefysample.ui.add.AddNetworkFragment import com.isupatches.wisefysample.ui.misc.MiscFragment import com.isupatches.wisefysample.ui.remove.RemoveNetworkFragment import com.isupatches.wisefysample.ui.search.SearchFragment - import dagger.Binds import dagger.Module import dagger.Provides import dagger.android.AndroidInjection -import dagger.android.AndroidInjector import dagger.android.ContributesAndroidInjector -import dagger.android.DispatchingAndroidInjector -import dagger.android.support.HasSupportFragmentInjector - -import kotlinx.android.synthetic.main.activity_main.bottomNavigationView - +import dagger.android.support.DaggerAppCompatActivity import javax.inject.Inject +import kotlinx.android.synthetic.main.activity_main.bottomNavigationView -internal class MainActivity : AppCompatActivity(), - BottomNavigationView.OnNavigationItemSelectedListener, - HasSupportFragmentInjector { - - @Inject lateinit var fragmentInjector: DispatchingAndroidInjector - override fun supportFragmentInjector(): AndroidInjector = fragmentInjector +internal class MainActivity : DaggerAppCompatActivity(), + BottomNavigationView.OnNavigationItemSelectedListener { @Inject lateinit var wiseFy: WiseFyPublicApi @@ -106,13 +93,17 @@ internal class MainActivity : AppCompatActivity(), @ContributesAndroidInjector(modules = [ AddNetworkFragment.AddNetworkFragmentModule::class ]) fun addNetworkFragment(): AddNetworkFragment + @ContributesAndroidInjector(modules = [ RemoveNetworkFragment.RemoveNetworkFragmentModule::class ]) fun removeNetworkFragment(): RemoveNetworkFragment + @ContributesAndroidInjector fun mainFragment(): MainFragment + @ContributesAndroidInjector(modules = [ MiscFragment.MiscFragmentModule::class ]) fun miscFragment(): MiscFragment + @ContributesAndroidInjector(modules = [ SearchFragment.SearchFragmentModule::class ]) fun searchFragment(): SearchFragment diff --git a/wisefysample/src/main/java/com/isupatches/wisefysample/ui/misc/MiscFragment.kt b/wisefysample/src/main/java/com/isupatches/wisefysample/ui/misc/MiscFragment.kt index bc4c7404..af6ea401 100644 --- a/wisefysample/src/main/java/com/isupatches/wisefysample/ui/misc/MiscFragment.kt +++ b/wisefysample/src/main/java/com/isupatches/wisefysample/ui/misc/MiscFragment.kt @@ -15,10 +15,7 @@ */ package com.isupatches.wisefysample.ui.misc -import android.Manifest.permission.ACCESS_COARSE_LOCATION -import android.Manifest.permission.ACCESS_NETWORK_STATE -import android.Manifest.permission.ACCESS_WIFI_STATE -import android.Manifest.permission.CHANGE_WIFI_STATE +import android.Manifest.permission.ACCESS_FINE_LOCATION import android.content.pm.PackageManager import android.net.NetworkInfo import android.net.wifi.ScanResult @@ -28,17 +25,15 @@ import android.os.Bundle import android.util.Log import android.view.View import androidx.annotation.VisibleForTesting - import com.isupatches.wisefy.constants.WiseFyCode import com.isupatches.wisefysample.R import com.isupatches.wisefysample.internal.base.BaseFragment import com.isupatches.wisefysample.internal.util.SdkUtil - import dagger.Binds import dagger.Module - -import kotlinx.android.synthetic.main.fragment_misc.enableWifiBtn +import javax.inject.Inject import kotlinx.android.synthetic.main.fragment_misc.disableWifiBtn +import kotlinx.android.synthetic.main.fragment_misc.enableWifiBtn import kotlinx.android.synthetic.main.fragment_misc.getCurrentNetworkBtn import kotlinx.android.synthetic.main.fragment_misc.getCurrentNetworkInfoBtn import kotlinx.android.synthetic.main.fragment_misc.getFrequencyBtn @@ -46,8 +41,6 @@ import kotlinx.android.synthetic.main.fragment_misc.getIPBtn import kotlinx.android.synthetic.main.fragment_misc.getNearbyAccessPointsBtn import kotlinx.android.synthetic.main.fragment_misc.getSavedNetworksBtn -import javax.inject.Inject - @Suppress("LargeClass") internal class MiscFragment : BaseFragment(), MiscMvp.View { @@ -61,30 +54,26 @@ internal class MiscFragment : BaseFragment(), MiscMvp.View { fun newInstance() = MiscFragment() - @VisibleForTesting internal const val WISEFY_DISABLE_WIFI_REQUEST_CODE = 1 - @VisibleForTesting internal const val WISEFY_ENABLE_WIFI_REQUEST_CODE = 2 - @VisibleForTesting internal const val WISEFY_GET_CURRENT_NETWORK_REQUEST_CODE = 3 - @VisibleForTesting internal const val WISEFY_GET_CURRENT_NETWORK_INFO_REQUEST_CODE = 4 - @VisibleForTesting internal const val WISEFY_GET_FREQUENCY_REQUEST_CODE = 5 - @VisibleForTesting internal const val WISEFY_GET_IP_REQUEST_CODE = 6 - @VisibleForTesting internal const val WISEFY_GET_NEARBY_ACCESS_POINTS_REQUEST_CODE = 7 - @VisibleForTesting internal const val WISEFY_GET_SAVED_NETWORKS_REQUEST_CODE = 8 + @VisibleForTesting internal const val WISEFY_GET_FREQUENCY_REQUEST_CODE = 1 + @VisibleForTesting internal const val WISEFY_GET_IP_REQUEST_CODE = 2 + @VisibleForTesting internal const val WISEFY_GET_NEARBY_ACCESS_POINTS_REQUEST_CODE = 3 + @VisibleForTesting internal const val WISEFY_GET_SAVED_NETWORKS_REQUEST_CODE = 4 } override fun onViewCreated(view: View, savedInstanceState: Bundle?) { super.onViewCreated(view, savedInstanceState) disableWifiBtn.setOnClickListener { - disableWifi() + presenter.disableWifi() } enableWifiBtn.setOnClickListener { - enableWifi() + presenter.enableWifi() } getCurrentNetworkBtn.setOnClickListener { - getCurrentNetwork() + presenter.getCurrentNetwork() } getCurrentNetworkInfoBtn.setOnClickListener { - getCurrentNetworkInfo() + presenter.getCurrentNetworkInfo() } getFrequencyBtn.setOnClickListener { getFrequency() @@ -198,31 +187,6 @@ internal class MiscFragment : BaseFragment(), MiscMvp.View { * WiseFy helpers */ - private fun disableWifi() { - if (checkDisableWifiPermissions()) { - presenter.disableWifi() - } - } - - private fun enableWifi() { - if (checkEnableWifiPermissions()) { - presenter.enableWifi() - } - } - - @Throws(SecurityException::class) - private fun getCurrentNetwork() { - if (checkGetCurrentNetworkPermissions()) { - presenter.getCurrentNetwork() - } - } - - private fun getCurrentNetworkInfo() { - if (checkGetCurrentNetworkInfoPermissions()) { - presenter.getCurrentNetworkInfo() - } - } - @Throws(SecurityException::class) private fun getFrequency() { if (sdkUtil.isAtLeastLollipop()) { @@ -248,6 +212,7 @@ internal class MiscFragment : BaseFragment(), MiscMvp.View { } } + @Throws(SecurityException::class) private fun getSavedNetworks() { if (checkGetSavedNetworksPermissions()) { presenter.getSavedNetworks() @@ -258,77 +223,24 @@ internal class MiscFragment : BaseFragment(), MiscMvp.View { * Permission helpers */ - private fun checkDisableWifiPermissions(): Boolean { - return isPermissionGranted(CHANGE_WIFI_STATE, WISEFY_DISABLE_WIFI_REQUEST_CODE) - } - - private fun checkEnableWifiPermissions(): Boolean { - return isPermissionGranted(CHANGE_WIFI_STATE, WISEFY_ENABLE_WIFI_REQUEST_CODE) - } - - private fun checkGetCurrentNetworkPermissions(): Boolean { - return isPermissionGranted(ACCESS_WIFI_STATE, WISEFY_GET_CURRENT_NETWORK_REQUEST_CODE) && - isPermissionGranted(ACCESS_COARSE_LOCATION, WISEFY_GET_CURRENT_NETWORK_REQUEST_CODE) - } - - private fun checkGetCurrentNetworkInfoPermissions(): Boolean { - return isPermissionGranted(ACCESS_NETWORK_STATE, WISEFY_GET_CURRENT_NETWORK_INFO_REQUEST_CODE) - } - private fun checkGetFrequencyPermissions(): Boolean { - return isPermissionGranted(ACCESS_WIFI_STATE, WISEFY_GET_FREQUENCY_REQUEST_CODE) && - isPermissionGranted(ACCESS_COARSE_LOCATION, WISEFY_GET_FREQUENCY_REQUEST_CODE) + return isPermissionGranted(ACCESS_FINE_LOCATION, WISEFY_GET_FREQUENCY_REQUEST_CODE) } private fun checkGetIPPermissions(): Boolean { - return isPermissionGranted(ACCESS_WIFI_STATE, WISEFY_GET_IP_REQUEST_CODE) && - isPermissionGranted(ACCESS_COARSE_LOCATION, WISEFY_GET_IP_REQUEST_CODE) + return isPermissionGranted(ACCESS_FINE_LOCATION, WISEFY_GET_IP_REQUEST_CODE) } private fun checkGetNearbyAccessPointsPermissions(): Boolean { - return isPermissionGranted(ACCESS_WIFI_STATE, WISEFY_GET_NEARBY_ACCESS_POINTS_REQUEST_CODE) && - isPermissionGranted(ACCESS_COARSE_LOCATION, WISEFY_GET_NEARBY_ACCESS_POINTS_REQUEST_CODE) + return isPermissionGranted(ACCESS_FINE_LOCATION, WISEFY_GET_NEARBY_ACCESS_POINTS_REQUEST_CODE) } private fun checkGetSavedNetworksPermissions(): Boolean { - return isPermissionGranted(ACCESS_WIFI_STATE, WISEFY_GET_SAVED_NETWORKS_REQUEST_CODE) + return isPermissionGranted(ACCESS_FINE_LOCATION, WISEFY_GET_SAVED_NETWORKS_REQUEST_CODE) } - @Suppress("LongMethod", "ComplexMethod") override fun onRequestPermissionsResult(requestCode: Int, permissions: Array, grantResults: IntArray) { when (requestCode) { - WISEFY_DISABLE_WIFI_REQUEST_CODE -> { - if (grantResults.isNotEmpty() && grantResults[0] == PackageManager.PERMISSION_GRANTED) { - disableWifi() - } else { - Log.w(TAG, "Permissions for disabling wifi are denied") - displayPermissionErrorDialog(R.string.permission_error_disable_wifi) - } - } - WISEFY_ENABLE_WIFI_REQUEST_CODE -> { - if (grantResults.isNotEmpty() && grantResults[0] == PackageManager.PERMISSION_GRANTED) { - enableWifi() - } else { - Log.w(TAG, "Permissions for enabling wifi are denied") - displayPermissionErrorDialog(R.string.permission_error_enable_wifi) - } - } - WISEFY_GET_CURRENT_NETWORK_REQUEST_CODE -> { - if (grantResults.isNotEmpty() && grantResults[0] == PackageManager.PERMISSION_GRANTED) { - getCurrentNetwork() - } else { - Log.w(TAG, "Permissions for getting current network are denied") - displayPermissionErrorDialog(R.string.permission_error_get_current_network) - } - } - WISEFY_GET_CURRENT_NETWORK_INFO_REQUEST_CODE -> { - if (grantResults.isNotEmpty() && grantResults[0] == PackageManager.PERMISSION_GRANTED) { - getCurrentNetworkInfo() - } else { - Log.w(TAG, "Permissions for getting current network info are denied") - displayPermissionErrorDialog(R.string.permission_error_get_current_network_info) - } - } WISEFY_GET_FREQUENCY_REQUEST_CODE -> { if (grantResults.isNotEmpty() && grantResults[0] == PackageManager.PERMISSION_GRANTED) { getFrequency() diff --git a/wisefysample/src/main/java/com/isupatches/wisefysample/ui/misc/MiscModel.kt b/wisefysample/src/main/java/com/isupatches/wisefysample/ui/misc/MiscModel.kt index c6b47b87..c06fc6eb 100644 --- a/wisefysample/src/main/java/com/isupatches/wisefysample/ui/misc/MiscModel.kt +++ b/wisefysample/src/main/java/com/isupatches/wisefysample/ui/misc/MiscModel.kt @@ -15,14 +15,10 @@ */ package com.isupatches.wisefysample.ui.misc -import android.Manifest.permission.ACCESS_COARSE_LOCATION -import android.Manifest.permission.ACCESS_NETWORK_STATE -import android.Manifest.permission.ACCESS_WIFI_STATE -import android.Manifest.permission.CHANGE_WIFI_STATE +import android.Manifest.permission.ACCESS_FINE_LOCATION import android.os.Build import androidx.annotation.RequiresApi import androidx.annotation.RequiresPermission - import com.isupatches.wisefy.WiseFyPublicApi import com.isupatches.wisefy.callbacks.DisableWifiCallbacks import com.isupatches.wisefy.callbacks.EnableWifiCallbacks @@ -32,50 +28,45 @@ import com.isupatches.wisefy.callbacks.GetFrequencyCallbacks import com.isupatches.wisefy.callbacks.GetIPCallbacks import com.isupatches.wisefy.callbacks.GetNearbyAccessPointsCallbacks import com.isupatches.wisefy.callbacks.GetSavedNetworksCallbacks - import javax.inject.Inject internal class MiscModel @Inject constructor( private val wiseFy: WiseFyPublicApi ) : MiscMvp.Model { - @RequiresPermission(allOf = [CHANGE_WIFI_STATE]) override fun disableWifi(callbacks: DisableWifiCallbacks) { wiseFy.disableWifi(callbacks) } - @RequiresPermission(allOf = [CHANGE_WIFI_STATE]) override fun enableWifi(callbacks: EnableWifiCallbacks) { wiseFy.enableWifi(callbacks) } - @RequiresPermission(allOf = [ACCESS_COARSE_LOCATION, ACCESS_WIFI_STATE]) override fun getCurrentNetwork(callbacks: GetCurrentNetworkCallbacks) { wiseFy.getCurrentNetwork(callbacks) } - @RequiresPermission(allOf = [ACCESS_NETWORK_STATE]) override fun getCurrentNetworkInfo(callbacks: GetCurrentNetworkInfoCallbacks) { wiseFy.getCurrentNetworkInfo(callbacks) } - @RequiresPermission(allOf = [ACCESS_COARSE_LOCATION, ACCESS_WIFI_STATE]) + @RequiresPermission(ACCESS_FINE_LOCATION) @RequiresApi(Build.VERSION_CODES.LOLLIPOP) override fun getFrequency(callbacks: GetFrequencyCallbacks) { wiseFy.getFrequency(callbacks) } - @RequiresPermission(allOf = [ACCESS_COARSE_LOCATION, ACCESS_WIFI_STATE]) + @RequiresPermission(ACCESS_FINE_LOCATION) override fun getIP(callbacks: GetIPCallbacks) { wiseFy.getIP(callbacks) } - @RequiresPermission(allOf = [ACCESS_COARSE_LOCATION, ACCESS_WIFI_STATE]) + @RequiresPermission(ACCESS_FINE_LOCATION) override fun getNearbyAccessPoints(callbacks: GetNearbyAccessPointsCallbacks) { wiseFy.getNearbyAccessPoints(true, callbacks) } - @RequiresPermission(allOf = [ACCESS_WIFI_STATE]) + @RequiresPermission(ACCESS_FINE_LOCATION) override fun getSavedNetworks(callbacks: GetSavedNetworksCallbacks) { wiseFy.getSavedNetworks(callbacks) } diff --git a/wisefysample/src/main/java/com/isupatches/wisefysample/ui/misc/MiscMvp.kt b/wisefysample/src/main/java/com/isupatches/wisefysample/ui/misc/MiscMvp.kt index 5a88adba..36d8b8af 100644 --- a/wisefysample/src/main/java/com/isupatches/wisefysample/ui/misc/MiscMvp.kt +++ b/wisefysample/src/main/java/com/isupatches/wisefysample/ui/misc/MiscMvp.kt @@ -15,11 +15,12 @@ */ package com.isupatches.wisefysample.ui.misc +import android.Manifest.permission.ACCESS_FINE_LOCATION import android.net.NetworkInfo import android.net.wifi.ScanResult import android.net.wifi.WifiConfiguration import android.net.wifi.WifiInfo - +import androidx.annotation.RequiresPermission import com.isupatches.wisefy.callbacks.DisableWifiCallbacks import com.isupatches.wisefy.callbacks.EnableWifiCallbacks import com.isupatches.wisefy.callbacks.GetCurrentNetworkCallbacks @@ -53,24 +54,48 @@ internal interface MiscMvp { } interface Presenter : BaseMvp.Presenter { + fun disableWifi() + fun enableWifi() + fun getCurrentNetwork() + fun getCurrentNetworkInfo() + + @RequiresPermission(ACCESS_FINE_LOCATION) fun getFrequency() + + @RequiresPermission(ACCESS_FINE_LOCATION) fun getIP() + + @RequiresPermission(ACCESS_FINE_LOCATION) fun getNearbyAccessPoints() + + @RequiresPermission(ACCESS_FINE_LOCATION) fun getSavedNetworks() } interface Model { + fun disableWifi(callbacks: DisableWifiCallbacks) + fun enableWifi(callbacks: EnableWifiCallbacks) + fun getCurrentNetwork(callbacks: GetCurrentNetworkCallbacks) + fun getCurrentNetworkInfo(callbacks: GetCurrentNetworkInfoCallbacks) + + @RequiresPermission(ACCESS_FINE_LOCATION) fun getFrequency(callbacks: GetFrequencyCallbacks) + + @RequiresPermission(ACCESS_FINE_LOCATION) fun getIP(callbacks: GetIPCallbacks) + + @RequiresPermission(ACCESS_FINE_LOCATION) fun getNearbyAccessPoints(callbacks: GetNearbyAccessPointsCallbacks) + + @RequiresPermission(ACCESS_FINE_LOCATION) fun getSavedNetworks(callbacks: GetSavedNetworksCallbacks) } } diff --git a/wisefysample/src/main/java/com/isupatches/wisefysample/ui/misc/MiscPresenter.kt b/wisefysample/src/main/java/com/isupatches/wisefysample/ui/misc/MiscPresenter.kt index f9121fb7..d041c186 100644 --- a/wisefysample/src/main/java/com/isupatches/wisefysample/ui/misc/MiscPresenter.kt +++ b/wisefysample/src/main/java/com/isupatches/wisefysample/ui/misc/MiscPresenter.kt @@ -15,10 +15,7 @@ */ package com.isupatches.wisefysample.ui.misc -import android.Manifest.permission.ACCESS_COARSE_LOCATION -import android.Manifest.permission.ACCESS_NETWORK_STATE -import android.Manifest.permission.ACCESS_WIFI_STATE -import android.Manifest.permission.CHANGE_WIFI_STATE +import android.Manifest.permission.ACCESS_FINE_LOCATION import android.net.NetworkInfo import android.net.wifi.ScanResult import android.net.wifi.WifiConfiguration @@ -26,7 +23,6 @@ import android.net.wifi.WifiInfo import android.os.Build import androidx.annotation.RequiresApi import androidx.annotation.RequiresPermission - import com.isupatches.wisefy.callbacks.DisableWifiCallbacks import com.isupatches.wisefy.callbacks.EnableWifiCallbacks import com.isupatches.wisefy.callbacks.GetCurrentNetworkCallbacks @@ -37,7 +33,6 @@ import com.isupatches.wisefy.callbacks.GetNearbyAccessPointsCallbacks import com.isupatches.wisefy.callbacks.GetSavedNetworksCallbacks import com.isupatches.wisefysample.internal.base.BasePresenter import com.isupatches.wisefysample.internal.util.RxSchedulersProvider - import javax.inject.Inject internal class MiscPresenter @Inject constructor( @@ -49,15 +44,14 @@ internal class MiscPresenter @Inject constructor( * Model call-throughs */ - @RequiresPermission(allOf = [CHANGE_WIFI_STATE]) override fun disableWifi() { model.disableWifi(object : DisableWifiCallbacks { override fun wifiDisabled() { - displayWifiDisabled() + doSafelyWithView { view -> view.displayWifiDisabled() } } override fun failureDisablingWifi() { - displayFailureDisablingWifi() + doSafelyWithView { view -> view.displayFailureDisablingWifi() } } override fun wisefyFailure(wisefyFailureCode: Int) { @@ -66,15 +60,14 @@ internal class MiscPresenter @Inject constructor( }) } - @RequiresPermission(allOf = [CHANGE_WIFI_STATE]) override fun enableWifi() { model.enableWifi(object : EnableWifiCallbacks { override fun wifiEnabled() { - displayWifiEnabled() + doSafelyWithView { view -> view.displayWifiEnabled() } } override fun failureEnablingWifi() { - displayFailureEnablingWifi() + doSafelyWithView { view -> view.displayFailureEnablingWifi() } } override fun wisefyFailure(wisefyFailureCode: Int) { @@ -83,15 +76,14 @@ internal class MiscPresenter @Inject constructor( }) } - @RequiresPermission(allOf = [ACCESS_COARSE_LOCATION, ACCESS_WIFI_STATE]) override fun getCurrentNetwork() { model.getCurrentNetwork(object : GetCurrentNetworkCallbacks { override fun retrievedCurrentNetwork(currentNetwork: WifiInfo) { - displayCurrentNetwork(currentNetwork) + doSafelyWithView { view -> view.displayCurrentNetwork(currentNetwork) } } override fun noCurrentNetwork() { - displayNoCurrentNetwork() + doSafelyWithView { view -> view.displayNoCurrentNetwork() } } override fun wisefyFailure(wisefyFailureCode: Int) { @@ -100,15 +92,14 @@ internal class MiscPresenter @Inject constructor( }) } - @RequiresPermission(allOf = [ACCESS_NETWORK_STATE]) override fun getCurrentNetworkInfo() { model.getCurrentNetworkInfo(object : GetCurrentNetworkInfoCallbacks { override fun retrievedCurrentNetworkInfo(currentNetworkInfo: NetworkInfo) { - displayCurrentNetworkInfo(currentNetworkInfo) + doSafelyWithView { view -> view.displayCurrentNetworkInfo(currentNetworkInfo) } } override fun noCurrentNetworkInfo() { - displayNoCurrentNetworkInfo() + doSafelyWithView { view -> view.displayNoCurrentNetworkInfo() } } override fun wisefyFailure(wisefyFailureCode: Int) { @@ -117,16 +108,16 @@ internal class MiscPresenter @Inject constructor( }) } - @RequiresPermission(allOf = [ACCESS_COARSE_LOCATION, ACCESS_WIFI_STATE]) + @RequiresPermission(ACCESS_FINE_LOCATION) @RequiresApi(Build.VERSION_CODES.LOLLIPOP) override fun getFrequency() { model.getFrequency(object : GetFrequencyCallbacks { override fun retrievedFrequency(frequency: Int) { - displayFrequency(frequency) + doSafelyWithView { view -> view.displayFrequency(frequency) } } override fun failureGettingFrequency() { - displayFailureRetrievingFrequency() + doSafelyWithView { view -> view.displayFailureRetrievingFrequency() } } override fun wisefyFailure(wisefyFailureCode: Int) { @@ -135,15 +126,15 @@ internal class MiscPresenter @Inject constructor( }) } - @RequiresPermission(allOf = [ACCESS_COARSE_LOCATION, ACCESS_WIFI_STATE]) + @RequiresPermission(ACCESS_FINE_LOCATION) override fun getIP() { model.getIP(object : GetIPCallbacks { override fun retrievedIP(ip: String) { - displayIP(ip) + doSafelyWithView { view -> view.displayIP(ip) } } override fun failureRetrievingIP() { - displayFailureRetrievingIP() + doSafelyWithView { view -> view.displayFailureRetrievingIP() } } override fun wisefyFailure(wisefyFailureCode: Int) { @@ -152,15 +143,15 @@ internal class MiscPresenter @Inject constructor( }) } - @RequiresPermission(allOf = [ACCESS_COARSE_LOCATION, ACCESS_WIFI_STATE]) + @RequiresPermission(ACCESS_FINE_LOCATION) override fun getNearbyAccessPoints() { model.getNearbyAccessPoints(object : GetNearbyAccessPointsCallbacks { - override fun retrievedNearbyAccessPoints(nearbyAccessPoints: List) { - displayNearbyAccessPoints(nearbyAccessPoints) + override fun noAccessPointsFound() { + doSafelyWithView { view -> view.displayNoAccessPointsFound() } } - override fun noAccessPointsFound() { - displayNoAccessPointsFound() + override fun retrievedNearbyAccessPoints(nearbyAccessPoints: List) { + doSafelyWithView { view -> view.displayNearbyAccessPoints(nearbyAccessPoints) } } override fun wisefyFailure(wisefyFailureCode: Int) { @@ -169,15 +160,15 @@ internal class MiscPresenter @Inject constructor( }) } - @RequiresPermission(allOf = [ACCESS_WIFI_STATE]) + @RequiresPermission(ACCESS_FINE_LOCATION) override fun getSavedNetworks() { model.getSavedNetworks(object : GetSavedNetworksCallbacks { override fun noSavedNetworksFound() { - displayNoSavedNetworksFound() + doSafelyWithView { view -> view.displayNoSavedNetworksFound() } } override fun retrievedSavedNetworks(savedNetworks: List) { - displaySavedNetworks(savedNetworks) + doSafelyWithView { view -> view.displaySavedNetworks(savedNetworks) } } override fun wisefyFailure(wisefyFailureCode: Int) { @@ -185,72 +176,4 @@ internal class MiscPresenter @Inject constructor( } }) } - - /* - * View callbacks - */ - - private fun displayWifiDisabled() { - doSafelyWithView { view -> view.displayWifiDisabled() } - } - - private fun displayFailureDisablingWifi() { - doSafelyWithView { view -> view.displayFailureDisablingWifi() } - } - - private fun displayWifiEnabled() { - doSafelyWithView { view -> view.displayWifiEnabled() } - } - - private fun displayFailureEnablingWifi() { - doSafelyWithView { view -> view.displayFailureEnablingWifi() } - } - - private fun displayCurrentNetwork(currentNetwork: WifiInfo) { - doSafelyWithView { view -> view.displayCurrentNetwork(currentNetwork) } - } - - private fun displayNoCurrentNetwork() { - doSafelyWithView { view -> view.displayNoCurrentNetwork() } - } - - private fun displayCurrentNetworkInfo(currentNetworkDetails: NetworkInfo) { - doSafelyWithView { view -> view.displayCurrentNetworkInfo(currentNetworkDetails) } - } - - private fun displayNoCurrentNetworkInfo() { - doSafelyWithView { view -> view.displayNoCurrentNetworkInfo() } - } - - private fun displayFrequency(frequency: Int) { - doSafelyWithView { view -> view.displayFrequency(frequency) } - } - - private fun displayFailureRetrievingFrequency() { - doSafelyWithView { view -> view.displayFailureRetrievingFrequency() } - } - - private fun displayIP(ip: String) { - doSafelyWithView { view -> view.displayIP(ip) } - } - - private fun displayFailureRetrievingIP() { - doSafelyWithView { view -> view.displayFailureRetrievingIP() } - } - - private fun displayNearbyAccessPoints(accessPoints: List) { - doSafelyWithView { view -> view.displayNearbyAccessPoints(accessPoints) } - } - - private fun displayNoAccessPointsFound() { - doSafelyWithView { view -> view.displayNoAccessPointsFound() } - } - - private fun displayNoSavedNetworksFound() { - doSafelyWithView { view -> view.displayNoSavedNetworksFound() } - } - - private fun displaySavedNetworks(savedNetworks: List) { - doSafelyWithView { view -> view.displaySavedNetworks(savedNetworks) } - } } diff --git a/wisefysample/src/main/java/com/isupatches/wisefysample/ui/remove/RemoveNetworkFragment.kt b/wisefysample/src/main/java/com/isupatches/wisefysample/ui/remove/RemoveNetworkFragment.kt index 023a9840..260fe128 100644 --- a/wisefysample/src/main/java/com/isupatches/wisefysample/ui/remove/RemoveNetworkFragment.kt +++ b/wisefysample/src/main/java/com/isupatches/wisefysample/ui/remove/RemoveNetworkFragment.kt @@ -15,27 +15,23 @@ */ package com.isupatches.wisefysample.ui.remove -import android.Manifest.permission.ACCESS_WIFI_STATE +import android.Manifest.permission.ACCESS_FINE_LOCATION import android.content.pm.PackageManager import android.os.Bundle import android.util.Log import android.view.View import androidx.annotation.VisibleForTesting - import com.isupatches.wisefy.constants.WiseFyCode import com.isupatches.wisefysample.R import com.isupatches.wisefysample.internal.base.BaseFragment import com.isupatches.wisefysample.internal.preferences.RemoveNetworkStore import com.isupatches.wisefysample.internal.util.getTrimmedInput import com.isupatches.wisefysample.internal.util.hideKeyboardFrom - import dagger.Binds import dagger.Module - -import kotlinx.android.synthetic.main.fragment_remove.removeNetworkBtn -import kotlinx.android.synthetic.main.fragment_remove.networkNameEdt - import javax.inject.Inject +import kotlinx.android.synthetic.main.fragment_remove.networkNameEdt +import kotlinx.android.synthetic.main.fragment_remove.removeNetworkBtn internal class RemoveNetworkFragment : BaseFragment(), RemoveNetworkMvp.View { @@ -110,6 +106,7 @@ internal class RemoveNetworkFragment : BaseFragment(), RemoveNetworkMvp.View { * WiseFy helpers */ + @Throws(SecurityException::class) private fun removeNetwork() { if (checkRemoveNetworkPermissions()) { presenter.removeNetwork(networkNameEdt.getTrimmedInput()) @@ -121,7 +118,7 @@ internal class RemoveNetworkFragment : BaseFragment(), RemoveNetworkMvp.View { */ private fun checkRemoveNetworkPermissions(): Boolean { - return isPermissionGranted(ACCESS_WIFI_STATE, WISEFY_REMOVE_NETWORK_REQUEST_CODE) + return isPermissionGranted(ACCESS_FINE_LOCATION, WISEFY_REMOVE_NETWORK_REQUEST_CODE) } override fun onRequestPermissionsResult(requestCode: Int, permissions: Array, grantResults: IntArray) { diff --git a/wisefysample/src/main/java/com/isupatches/wisefysample/ui/remove/RemoveNetworkModel.kt b/wisefysample/src/main/java/com/isupatches/wisefysample/ui/remove/RemoveNetworkModel.kt index 34289061..e82b0c90 100644 --- a/wisefysample/src/main/java/com/isupatches/wisefysample/ui/remove/RemoveNetworkModel.kt +++ b/wisefysample/src/main/java/com/isupatches/wisefysample/ui/remove/RemoveNetworkModel.kt @@ -15,19 +15,17 @@ */ package com.isupatches.wisefysample.ui.remove -import android.Manifest.permission.ACCESS_WIFI_STATE +import android.Manifest.permission.ACCESS_FINE_LOCATION import androidx.annotation.RequiresPermission - import com.isupatches.wisefy.WiseFyPublicApi import com.isupatches.wisefy.callbacks.RemoveNetworkCallbacks - import javax.inject.Inject internal class RemoveNetworkModel @Inject constructor( private val wiseFy: WiseFyPublicApi ) : RemoveNetworkMvp.Model { - @RequiresPermission(ACCESS_WIFI_STATE) + @RequiresPermission(ACCESS_FINE_LOCATION) override fun removeNetwork(networkName: String, callbacks: RemoveNetworkCallbacks) { wiseFy.removeNetwork(networkName, callbacks) } diff --git a/wisefysample/src/main/java/com/isupatches/wisefysample/ui/remove/RemoveNetworkMvp.kt b/wisefysample/src/main/java/com/isupatches/wisefysample/ui/remove/RemoveNetworkMvp.kt index 6178c6df..afbf1797 100644 --- a/wisefysample/src/main/java/com/isupatches/wisefysample/ui/remove/RemoveNetworkMvp.kt +++ b/wisefysample/src/main/java/com/isupatches/wisefysample/ui/remove/RemoveNetworkMvp.kt @@ -15,6 +15,8 @@ */ package com.isupatches.wisefysample.ui.remove +import android.Manifest.permission.ACCESS_FINE_LOCATION +import androidx.annotation.RequiresPermission import com.isupatches.wisefy.callbacks.RemoveNetworkCallbacks import com.isupatches.wisefysample.internal.base.BaseMvp @@ -28,10 +30,14 @@ internal interface RemoveNetworkMvp { } interface Presenter : BaseMvp.Presenter { + + @RequiresPermission(ACCESS_FINE_LOCATION) fun removeNetwork(networkName: String) } interface Model { + + @RequiresPermission(ACCESS_FINE_LOCATION) fun removeNetwork(networkName: String, callbacks: RemoveNetworkCallbacks) } } diff --git a/wisefysample/src/main/java/com/isupatches/wisefysample/ui/remove/RemoveNetworkPresenter.kt b/wisefysample/src/main/java/com/isupatches/wisefysample/ui/remove/RemoveNetworkPresenter.kt index 35c2bafa..aa997c47 100644 --- a/wisefysample/src/main/java/com/isupatches/wisefysample/ui/remove/RemoveNetworkPresenter.kt +++ b/wisefysample/src/main/java/com/isupatches/wisefysample/ui/remove/RemoveNetworkPresenter.kt @@ -15,14 +15,12 @@ */ package com.isupatches.wisefysample.ui.remove -import android.Manifest.permission.ACCESS_WIFI_STATE +import android.Manifest.permission.ACCESS_FINE_LOCATION import androidx.annotation.RequiresPermission - import com.isupatches.wisefy.callbacks.RemoveNetworkCallbacks import com.isupatches.wisefy.constants.WiseFyCode import com.isupatches.wisefysample.internal.base.BasePresenter import com.isupatches.wisefysample.internal.util.RxSchedulersProvider - import javax.inject.Inject internal class RemoveNetworkPresenter @Inject constructor( @@ -34,19 +32,19 @@ internal class RemoveNetworkPresenter @Inject constructor( * Model call-throughs */ - @RequiresPermission(ACCESS_WIFI_STATE) + @RequiresPermission(ACCESS_FINE_LOCATION) override fun removeNetwork(networkName: String) { model.removeNetwork(networkName, object : RemoveNetworkCallbacks { override fun networkRemoved() { - displayNetworkRemoved() + doSafelyWithView { view -> view.displayNetworkRemoved() } } override fun networkNotFoundToRemove() { - displayNetworkNotFoundToRemove() + doSafelyWithView { view -> view.displayNetworkNotFoundToRemove() } } override fun failureRemovingNetwork() { - displayFailureRemovingNetwork() + doSafelyWithView { view -> view.displayFailureRemovingNetwork() } } override fun wisefyFailure(@WiseFyCode wisefyFailureCode: Int) { @@ -54,20 +52,4 @@ internal class RemoveNetworkPresenter @Inject constructor( } }) } - - /* - * View callbacks - */ - - private fun displayNetworkRemoved() { - doSafelyWithView { view -> view.displayNetworkRemoved() } - } - - private fun displayNetworkNotFoundToRemove() { - doSafelyWithView { view -> view.displayNetworkNotFoundToRemove() } - } - - private fun displayFailureRemovingNetwork() { - doSafelyWithView { view -> view.displayFailureRemovingNetwork() } - } } diff --git a/wisefysample/src/main/java/com/isupatches/wisefysample/ui/search/SearchFragment.kt b/wisefysample/src/main/java/com/isupatches/wisefysample/ui/search/SearchFragment.kt index ce63aa7b..68998d6a 100644 --- a/wisefysample/src/main/java/com/isupatches/wisefysample/ui/search/SearchFragment.kt +++ b/wisefysample/src/main/java/com/isupatches/wisefysample/ui/search/SearchFragment.kt @@ -15,8 +15,7 @@ */ package com.isupatches.wisefysample.ui.search -import android.Manifest.permission.ACCESS_COARSE_LOCATION -import android.Manifest.permission.ACCESS_WIFI_STATE +import android.Manifest.permission.ACCESS_FINE_LOCATION import android.content.pm.PackageManager import android.net.wifi.ScanResult import android.net.wifi.WifiConfiguration @@ -25,18 +24,17 @@ import android.util.Log import android.view.View import android.widget.SeekBar import androidx.annotation.VisibleForTesting - import com.isupatches.wisefysample.R +import com.isupatches.wisefysample.internal.base.BaseFragment import com.isupatches.wisefysample.internal.models.SearchType import com.isupatches.wisefysample.internal.preferences.SearchStore -import com.isupatches.wisefysample.internal.base.BaseFragment import com.isupatches.wisefysample.internal.util.asHtmlSpanned import com.isupatches.wisefysample.internal.util.getTrimmedInput import com.isupatches.wisefysample.internal.util.hideKeyboardFrom - import dagger.Binds import dagger.Module - +import javax.inject.Inject +import kotlin.math.max import kotlinx.android.synthetic.main.fragment_search.filterDupesRdg import kotlinx.android.synthetic.main.fragment_search.filterDupesTxt import kotlinx.android.synthetic.main.fragment_search.returnFullListRdg @@ -46,8 +44,6 @@ import kotlinx.android.synthetic.main.fragment_search.searchTypeRdg import kotlinx.android.synthetic.main.fragment_search.timeoutSeek import kotlinx.android.synthetic.main.fragment_search.timeoutTxt -import javax.inject.Inject - @Suppress("LargeClass") internal class SearchFragment : BaseFragment(), SearchMvp.View { @@ -108,7 +104,7 @@ internal class SearchFragment : BaseFragment(), SearchMvp.View { max = TIMEOUT_MAX setOnSeekBarChangeListener(object : SeekBar.OnSeekBarChangeListener { override fun onProgressChanged(seekBar: SeekBar?, progress: Int, fromUser: Boolean) { - val timeout = Math.max(TIMEOUT_MIN, progress) + val timeout = max(TIMEOUT_MIN, progress) searchStore.setTimeout(timeout) timeoutTxt.text = getString(R.string.timeout_after_x_seconds_args_html, timeout).asHtmlSpanned() } @@ -262,7 +258,11 @@ internal class SearchFragment : BaseFragment(), SearchMvp.View { @Throws(SecurityException::class) private fun searchForAccessPoint() { if (checkSearchForAccessPointPermissions()) { - presenter.searchForAccessPoint(searchRegexEdt.getTrimmedInput(), getSelectedTimeout(), getFilterDuplicates()) + presenter.searchForAccessPoint( + searchRegexEdt.getTrimmedInput(), + getSelectedTimeout(), + getFilterDuplicates() + ) } } @@ -273,12 +273,14 @@ internal class SearchFragment : BaseFragment(), SearchMvp.View { } } + @Throws(SecurityException::class) private fun searchForSavedNetwork() { if (checkSearchForSavedNetworkPermissions()) { presenter.searchForSavedNetwork(searchRegexEdt.getTrimmedInput()) } } + @Throws(SecurityException::class) private fun searchForSavedNetworks() { if (checkSearchForSavedNetworksPermissions()) { presenter.searchForSavedNetworks(searchRegexEdt.getTrimmedInput()) @@ -312,7 +314,7 @@ internal class SearchFragment : BaseFragment(), SearchMvp.View { } override fun displaySavedNetworks(savedNetworks: List) { - displayInfo(getString(R.string.saved_networks_args, savedNetworks), R.string.search_result) + displayInfoFullScreen(getString(R.string.saved_networks_args, savedNetworks), R.string.search_result) } override fun displayNoSavedNetworksFound() { @@ -360,31 +362,27 @@ internal class SearchFragment : BaseFragment(), SearchMvp.View { */ private fun checkSearchForSavedNetworkPermissions(): Boolean { - return isPermissionGranted(ACCESS_WIFI_STATE, WISEFY_SEARCH_FOR_SAVED_NETWORK_REQUEST_CODE) + return isPermissionGranted(ACCESS_FINE_LOCATION, WISEFY_SEARCH_FOR_SAVED_NETWORK_REQUEST_CODE) } private fun checkSearchForSavedNetworksPermissions(): Boolean { - return isPermissionGranted(ACCESS_WIFI_STATE, WISEFY_SEARCH_FOR_SAVED_NETWORKS_REQUEST_CODE) + return isPermissionGranted(ACCESS_FINE_LOCATION, WISEFY_SEARCH_FOR_SAVED_NETWORKS_REQUEST_CODE) } private fun checkSearchForAccessPointPermissions(): Boolean { - return isPermissionGranted(ACCESS_WIFI_STATE, WISEFY_SEARCH_FOR_ACCESS_POINT_REQUEST_CODE) && - isPermissionGranted(ACCESS_COARSE_LOCATION, WISEFY_SEARCH_FOR_ACCESS_POINT_REQUEST_CODE) + return isPermissionGranted(ACCESS_FINE_LOCATION, WISEFY_SEARCH_FOR_ACCESS_POINT_REQUEST_CODE) } private fun checkSearchForAccessPointsPermissions(): Boolean { - return isPermissionGranted(ACCESS_WIFI_STATE, WISEFY_SEARCH_FOR_ACCESS_POINTS_REQUEST_CODE) && - isPermissionGranted(ACCESS_COARSE_LOCATION, WISEFY_SEARCH_FOR_ACCESS_POINTS_REQUEST_CODE) + return isPermissionGranted(ACCESS_FINE_LOCATION, WISEFY_SEARCH_FOR_ACCESS_POINTS_REQUEST_CODE) } private fun checkSearchForSSIDPermissions(): Boolean { - return isPermissionGranted(ACCESS_WIFI_STATE, WISEFY_SEARCH_FOR_SSID_REQUEST_CODE) && - isPermissionGranted(ACCESS_COARSE_LOCATION, WISEFY_SEARCH_FOR_SSID_REQUEST_CODE) + return isPermissionGranted(ACCESS_FINE_LOCATION, WISEFY_SEARCH_FOR_SSID_REQUEST_CODE) } private fun checkSearchForSSIDsPermissions(): Boolean { - return isPermissionGranted(ACCESS_WIFI_STATE, WISEFY_SEARCH_FOR_SSIDS_REQUEST_CODE) && - isPermissionGranted(ACCESS_COARSE_LOCATION, WISEFY_SEARCH_FOR_SSIDS_REQUEST_CODE) + return isPermissionGranted(ACCESS_FINE_LOCATION, WISEFY_SEARCH_FOR_SSIDS_REQUEST_CODE) } @Suppress("LongMethod", "ComplexMethod") diff --git a/wisefysample/src/main/java/com/isupatches/wisefysample/ui/search/SearchModel.kt b/wisefysample/src/main/java/com/isupatches/wisefysample/ui/search/SearchModel.kt index 5bec96d1..352e1d1e 100644 --- a/wisefysample/src/main/java/com/isupatches/wisefysample/ui/search/SearchModel.kt +++ b/wisefysample/src/main/java/com/isupatches/wisefysample/ui/search/SearchModel.kt @@ -15,10 +15,8 @@ */ package com.isupatches.wisefysample.ui.search -import android.Manifest.permission.ACCESS_COARSE_LOCATION -import android.Manifest.permission.ACCESS_WIFI_STATE +import android.Manifest.permission.ACCESS_FINE_LOCATION import androidx.annotation.RequiresPermission - import com.isupatches.wisefy.WiseFyPublicApi import com.isupatches.wisefy.callbacks.SearchForAccessPointCallbacks import com.isupatches.wisefy.callbacks.SearchForAccessPointsCallbacks @@ -26,14 +24,13 @@ import com.isupatches.wisefy.callbacks.SearchForSSIDCallbacks import com.isupatches.wisefy.callbacks.SearchForSSIDsCallbacks import com.isupatches.wisefy.callbacks.SearchForSavedNetworkCallbacks import com.isupatches.wisefy.callbacks.SearchForSavedNetworksCallbacks - import javax.inject.Inject internal class SearchModel @Inject constructor( private val wiseFy: WiseFyPublicApi ) : SearchMvp.Model { - @RequiresPermission(allOf = [ACCESS_COARSE_LOCATION, ACCESS_WIFI_STATE]) + @RequiresPermission(ACCESS_FINE_LOCATION) override fun searchForAccessPoint( regexForSSID: String, timeout: Int, @@ -43,7 +40,7 @@ internal class SearchModel @Inject constructor( wiseFy.searchForAccessPoint(regexForSSID, timeout, filterDuplicates, callbacks) } - @RequiresPermission(allOf = [ACCESS_COARSE_LOCATION, ACCESS_WIFI_STATE]) + @RequiresPermission(ACCESS_FINE_LOCATION) override fun searchForAccessPoints( regexForSSID: String, filterDuplicates: Boolean, @@ -52,7 +49,7 @@ internal class SearchModel @Inject constructor( wiseFy.searchForAccessPoints(regexForSSID, filterDuplicates, callbacks) } - @RequiresPermission(ACCESS_WIFI_STATE) + @RequiresPermission(ACCESS_FINE_LOCATION) override fun searchForSavedNetwork( regexForSSID: String, callbacks: SearchForSavedNetworkCallbacks @@ -60,7 +57,7 @@ internal class SearchModel @Inject constructor( wiseFy.searchForSavedNetwork(regexForSSID, callbacks) } - @RequiresPermission(ACCESS_WIFI_STATE) + @RequiresPermission(ACCESS_FINE_LOCATION) override fun searchForSavedNetworks( regexForSSID: String, callbacks: SearchForSavedNetworksCallbacks @@ -68,7 +65,7 @@ internal class SearchModel @Inject constructor( wiseFy.searchForSavedNetworks(regexForSSID, callbacks) } - @RequiresPermission(allOf = [ACCESS_COARSE_LOCATION, ACCESS_WIFI_STATE]) + @RequiresPermission(ACCESS_FINE_LOCATION) override fun searchForSSID( regexForSSID: String, timeout: Int, @@ -77,7 +74,7 @@ internal class SearchModel @Inject constructor( wiseFy.searchForSSID(regexForSSID, timeout, callbacks) } - @RequiresPermission(allOf = [ACCESS_COARSE_LOCATION, ACCESS_WIFI_STATE]) + @RequiresPermission(ACCESS_FINE_LOCATION) override fun searchForSSIDs(regexForSSID: String, callbacks: SearchForSSIDsCallbacks) { wiseFy.searchForSSIDs(regexForSSID, callbacks) } diff --git a/wisefysample/src/main/java/com/isupatches/wisefysample/ui/search/SearchMvp.kt b/wisefysample/src/main/java/com/isupatches/wisefysample/ui/search/SearchMvp.kt index bfee598f..a6feeaba 100644 --- a/wisefysample/src/main/java/com/isupatches/wisefysample/ui/search/SearchMvp.kt +++ b/wisefysample/src/main/java/com/isupatches/wisefysample/ui/search/SearchMvp.kt @@ -15,9 +15,10 @@ */ package com.isupatches.wisefysample.ui.search +import android.Manifest.permission.ACCESS_FINE_LOCATION import android.net.wifi.ScanResult import android.net.wifi.WifiConfiguration - +import androidx.annotation.RequiresPermission import com.isupatches.wisefy.callbacks.SearchForAccessPointCallbacks import com.isupatches.wisefy.callbacks.SearchForAccessPointsCallbacks import com.isupatches.wisefy.callbacks.SearchForSSIDCallbacks @@ -45,29 +46,52 @@ internal interface SearchMvp { } interface Presenter : BaseMvp.Presenter { + @RequiresPermission(ACCESS_FINE_LOCATION) fun searchForAccessPoint(regexForSSID: String, timeout: Int, filterDuplicates: Boolean) + + @RequiresPermission(ACCESS_FINE_LOCATION) fun searchForAccessPoints(regexForSSID: String, filterDuplicates: Boolean) + + @RequiresPermission(ACCESS_FINE_LOCATION) fun searchForSavedNetwork(regexForSSID: String) + + @RequiresPermission(ACCESS_FINE_LOCATION) fun searchForSavedNetworks(regexForSSID: String) + + @RequiresPermission(ACCESS_FINE_LOCATION) fun searchForSSID(regexForSSID: String, timeout: Int) + + @RequiresPermission(ACCESS_FINE_LOCATION) fun searchForSSIDs(regexForSSID: String) } interface Model { + + @RequiresPermission(ACCESS_FINE_LOCATION) fun searchForAccessPoint( regexForSSID: String, timeout: Int, filterDuplicates: Boolean, callbacks: SearchForAccessPointCallbacks ) + + @RequiresPermission(ACCESS_FINE_LOCATION) fun searchForAccessPoints( regexForSSID: String, filterDuplicates: Boolean, callbacks: SearchForAccessPointsCallbacks ) + + @RequiresPermission(ACCESS_FINE_LOCATION) fun searchForSavedNetwork(regexForSSID: String, callbacks: SearchForSavedNetworkCallbacks) + + @RequiresPermission(ACCESS_FINE_LOCATION) fun searchForSavedNetworks(regexForSSID: String, callbacks: SearchForSavedNetworksCallbacks) + + @RequiresPermission(ACCESS_FINE_LOCATION) fun searchForSSID(regexForSSID: String, timeout: Int, callbacks: SearchForSSIDCallbacks) + + @RequiresPermission(ACCESS_FINE_LOCATION) fun searchForSSIDs(regexForSSID: String, callbacks: SearchForSSIDsCallbacks) } } diff --git a/wisefysample/src/main/java/com/isupatches/wisefysample/ui/search/SearchPresenter.kt b/wisefysample/src/main/java/com/isupatches/wisefysample/ui/search/SearchPresenter.kt index 023f9720..b4368be1 100644 --- a/wisefysample/src/main/java/com/isupatches/wisefysample/ui/search/SearchPresenter.kt +++ b/wisefysample/src/main/java/com/isupatches/wisefysample/ui/search/SearchPresenter.kt @@ -15,12 +15,10 @@ */ package com.isupatches.wisefysample.ui.search -import android.Manifest.permission.ACCESS_COARSE_LOCATION -import android.Manifest.permission.ACCESS_WIFI_STATE +import android.Manifest.permission.ACCESS_FINE_LOCATION import android.net.wifi.ScanResult import android.net.wifi.WifiConfiguration import androidx.annotation.RequiresPermission - import com.isupatches.wisefy.callbacks.SearchForAccessPointCallbacks import com.isupatches.wisefy.callbacks.SearchForAccessPointsCallbacks import com.isupatches.wisefy.callbacks.SearchForSSIDCallbacks @@ -30,7 +28,6 @@ import com.isupatches.wisefy.callbacks.SearchForSavedNetworksCallbacks import com.isupatches.wisefy.constants.WiseFyCode import com.isupatches.wisefysample.internal.base.BasePresenter import com.isupatches.wisefysample.internal.util.RxSchedulersProvider - import javax.inject.Inject internal class SearchPresenter @Inject constructor( @@ -42,7 +39,7 @@ internal class SearchPresenter @Inject constructor( * Model call-throughs */ - @RequiresPermission(allOf = [ACCESS_COARSE_LOCATION, ACCESS_WIFI_STATE]) + @RequiresPermission(ACCESS_FINE_LOCATION) override fun searchForAccessPoint( regexForSSID: String, timeout: Int, @@ -54,11 +51,11 @@ internal class SearchPresenter @Inject constructor( filterDuplicates, object : SearchForAccessPointCallbacks { override fun accessPointFound(accessPoint: ScanResult) { - displayAccessPoint(accessPoint) + doSafelyWithView { view -> view.displayAccessPoint(accessPoint) } } override fun accessPointNotFound() { - displayAccessPointNotFound() + doSafelyWithView { view -> view.displayAccessPointNotFound() } } override fun wisefyFailure(@WiseFyCode wisefyFailureCode: Int) { @@ -67,15 +64,15 @@ internal class SearchPresenter @Inject constructor( }) } - @RequiresPermission(allOf = [ACCESS_COARSE_LOCATION, ACCESS_WIFI_STATE]) + @RequiresPermission(ACCESS_FINE_LOCATION) override fun searchForAccessPoints(regexForSSID: String, filterDuplicates: Boolean) { model.searchForAccessPoints(regexForSSID, filterDuplicates, object : SearchForAccessPointsCallbacks { override fun foundAccessPoints(accessPoints: List) { - displayAccessPoints(accessPoints) + doSafelyWithView { view -> view.displayAccessPoints(accessPoints) } } override fun noAccessPointsFound() { - displayNoAccessPointsFound() + doSafelyWithView { view -> view.displayNoAccessPointsFound() } } override fun wisefyFailure(@WiseFyCode wisefyFailureCode: Int) { @@ -84,14 +81,15 @@ internal class SearchPresenter @Inject constructor( }) } + @RequiresPermission(ACCESS_FINE_LOCATION) override fun searchForSavedNetwork(regexForSSID: String) { model.searchForSavedNetwork(regexForSSID, object : SearchForSavedNetworkCallbacks { override fun retrievedSavedNetwork(savedNetwork: WifiConfiguration) { - displaySavedNetwork(savedNetwork) + doSafelyWithView { view -> view.displaySavedNetwork(savedNetwork) } } override fun savedNetworkNotFound() { - displaySavedNetworkNotFound() + doSafelyWithView { view -> view.displaySavedNetworkNotFound() } } override fun wisefyFailure(@WiseFyCode wisefyFailureCode: Int) { @@ -100,14 +98,15 @@ internal class SearchPresenter @Inject constructor( }) } + @RequiresPermission(ACCESS_FINE_LOCATION) override fun searchForSavedNetworks(regexForSSID: String) { model.searchForSavedNetworks(regexForSSID, object : SearchForSavedNetworksCallbacks { override fun retrievedSavedNetworks(savedNetworks: List) { - displaySavedNetworks(savedNetworks) + doSafelyWithView { view -> view.displaySavedNetworks(savedNetworks) } } override fun noSavedNetworksFound() { - displayNoSavedNetworksFound() + doSafelyWithView { view -> view.displayNoSavedNetworksFound() } } override fun wisefyFailure(@WiseFyCode wisefyFailureCode: Int) { @@ -116,15 +115,15 @@ internal class SearchPresenter @Inject constructor( }) } - @RequiresPermission(allOf = [ACCESS_COARSE_LOCATION, ACCESS_WIFI_STATE]) + @RequiresPermission(ACCESS_FINE_LOCATION) override fun searchForSSID(regexForSSID: String, timeout: Int) { model.searchForSSID(regexForSSID, timeout, object : SearchForSSIDCallbacks { override fun ssidFound(ssid: String) { - displaySSID(ssid) + doSafelyWithView { view -> view.displaySSID(ssid) } } override fun ssidNotFound() { - displaySSIDNotFound() + doSafelyWithView { view -> view.displaySSIDNotFound() } } override fun wisefyFailure(@WiseFyCode wisefyFailureCode: Int) { @@ -133,15 +132,15 @@ internal class SearchPresenter @Inject constructor( }) } - @RequiresPermission(allOf = [ACCESS_COARSE_LOCATION, ACCESS_WIFI_STATE]) + @RequiresPermission(ACCESS_FINE_LOCATION) override fun searchForSSIDs(regexForSSID: String) { model.searchForSSIDs(regexForSSID, object : SearchForSSIDsCallbacks { override fun retrievedSSIDs(ssids: List) { - displaySSIDs(ssids) + doSafelyWithView { view -> view.displaySSIDs(ssids) } } override fun noSSIDsFound() { - displayNoSSIDsFound() + doSafelyWithView { view -> view.displayNoSSIDsFound() } } override fun wisefyFailure(@WiseFyCode wisefyFailureCode: Int) { @@ -149,56 +148,4 @@ internal class SearchPresenter @Inject constructor( } }) } - - /* - * View callbacks - */ - - private fun displaySavedNetwork(savedNetwork: WifiConfiguration) { - doSafelyWithView { view -> view.displaySavedNetwork(savedNetwork) } - } - - private fun displaySavedNetworkNotFound() { - doSafelyWithView { view -> view.displaySavedNetworkNotFound() } - } - - private fun displaySavedNetworks(savedNetworks: List) { - doSafelyWithView { view -> view.displaySavedNetworks(savedNetworks) } - } - - private fun displayNoSavedNetworksFound() { - doSafelyWithView { view -> view.displayNoSavedNetworksFound() } - } - - private fun displayAccessPoint(accessPoint: ScanResult) { - doSafelyWithView { view -> view.displayAccessPoint(accessPoint) } - } - - private fun displayAccessPointNotFound() { - doSafelyWithView { view -> view.displayAccessPointNotFound() } - } - - private fun displayAccessPoints(accessPoints: List) { - doSafelyWithView { view -> view.displayAccessPoints(accessPoints) } - } - - private fun displayNoAccessPointsFound() { - doSafelyWithView { view -> view.displayNoAccessPointsFound() } - } - - private fun displaySSID(ssid: String) { - doSafelyWithView { view -> view.displaySSID(ssid) } - } - - private fun displaySSIDNotFound() { - doSafelyWithView { view -> view.displaySSIDNotFound() } - } - - private fun displaySSIDs(ssids: List) { - doSafelyWithView { view -> view.displaySSIDs(ssids) } - } - - private fun displayNoSSIDsFound() { - doSafelyWithView { view -> view.displayNoSSIDsFound() } - } } diff --git a/wisefysample/src/main/res/layout/dialog_base_fullscreen.xml b/wisefysample/src/main/res/layout/dialog_base_fullscreen.xml index 69e3880c..5f93587c 100644 --- a/wisefysample/src/main/res/layout/dialog_base_fullscreen.xml +++ b/wisefysample/src/main/res/layout/dialog_base_fullscreen.xml @@ -1,7 +1,6 @@ diff --git a/wisefysample/src/main/res/layout/fragment_search.xml b/wisefysample/src/main/res/layout/fragment_search.xml index 7245a58d..4f43854a 100644 --- a/wisefysample/src/main/res/layout/fragment_search.xml +++ b/wisefysample/src/main/res/layout/fragment_search.xml @@ -235,6 +235,7 @@ android:gravity="center" android:layout_width="0dp" android:layout_height="wrap_content" + android:textIsSelectable="false" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toBottomOf="@id/timeoutSeek" diff --git a/wisefysample/src/main/res/values/misc.xml b/wisefysample/src/main/res/values/misc.xml index b069f4fa..4f783f57 100644 --- a/wisefysample/src/main/res/values/misc.xml +++ b/wisefysample/src/main/res/values/misc.xml @@ -35,13 +35,13 @@ Failure retrieving IP - Permissions for disabling wifi are denied - Permissions for enabling wifi are denied - Permissions for getting current network are denied - Permissions for getting current network info are denied - Permissions for getting the frequency of the device\'s current network are denied + + Permissions for getting the frequency of the device\'s current network are denied + Permissions for getting the device\'s IP are denied - Permissions for getting nearby access points are denied + + Permissions for getting nearby access points are denied + Permissions for getting saved networks are denied \ No newline at end of file diff --git a/wisefysample/src/main/res/values/preferences.xml b/wisefysample/src/main/res/values/preferences.xml index 49652c2c..9f7cd992 100644 --- a/wisefysample/src/main/res/values/preferences.xml +++ b/wisefysample/src/main/res/values/preferences.xml @@ -1,6 +1,12 @@ - com.isupatches.wisefysample.app.add_network_data - com.isupatches.wisefysample.app.remove_network_data - com.isupatches.wisefysample.app.search_data + + com.isupatches.wisefysample.app.add_network_data + + + com.isupatches.wisefysample.app.remove_network_data + + + com.isupatches.wisefysample.app.search_data + \ No newline at end of file diff --git a/wisefysample/src/main/res/values/search.xml b/wisefysample/src/main/res/values/search.xml index fe0abf64..1441c224 100644 --- a/wisefysample/src/main/res/values/search.xml +++ b/wisefysample/src/main/res/values/search.xml @@ -10,7 +10,9 @@ Saved Network Return full list of results? - This option will return a list of results instead of an individual item when enabled. + + This option will return a list of results instead of an individual item when enabled. + Filter Duplicates @@ -32,11 +34,19 @@ Saved network not found - Permissions for searching for a saved network are denied - Permissions for searching for saved networks are denied - - Permissions for searching for an access point are denied - Permissions for searching for access points are denied + + Permissions for searching for a saved network are denied + + + Permissions for searching for saved networks are denied + + + + Permissions for searching for an access point are denied + + + Permissions for searching for access points are denied + Permissions for searching for an SSID are denied Permissions for searching for SSIDs are denied diff --git a/wisefysample/src/main/res/values/strings.xml b/wisefysample/src/main/res/values/strings.xml index 7c745492..b6cb320c 100644 --- a/wisefysample/src/main/res/values/strings.xml +++ b/wisefysample/src/main/res/values/strings.xml @@ -4,7 +4,9 @@ WiseFy - Explore the various uses for WiseFy by poking around this sample app based on MVP architecture. + + Explore the various uses for WiseFy by poking around this sample app based on MVP architecture. + Network Password @@ -26,6 +28,8 @@ Permission Error - Unhandled permission requested. Request code: %d + + Unhandled permission requested. Request code: %d + diff --git a/wisefysample/src/test/java/com/isupatches/wisefysample/internal/models/NetworkTypeTest.kt b/wisefysample/src/test/java/com/isupatches/wisefysample/internal/models/NetworkTypeTest.kt index e4c02f82..16b99414 100644 --- a/wisefysample/src/test/java/com/isupatches/wisefysample/internal/models/NetworkTypeTest.kt +++ b/wisefysample/src/test/java/com/isupatches/wisefysample/internal/models/NetworkTypeTest.kt @@ -6,19 +6,23 @@ import org.junit.Test internal class NetworkTypeTest { - @Test fun open() { + @Test + fun open() { assertEquals(NetworkType.OPEN, NetworkType.of(NetworkType.OPEN.intVal)) } - @Test fun wpa2() { + @Test + fun wpa2() { assertEquals(NetworkType.WPA2, NetworkType.of(NetworkType.WPA2.intVal)) } - @Test fun wep() { + @Test + fun wep() { assertEquals(NetworkType.WEP, NetworkType.of(NetworkType.WEP.intVal)) } - @Test fun unexpected() { + @Test + fun unexpected() { try { NetworkType.of(999) fail("Expected IllegalArgumentException from NetworkType.of") diff --git a/wisefysample/src/test/java/com/isupatches/wisefysample/internal/models/SearchTypeTest.kt b/wisefysample/src/test/java/com/isupatches/wisefysample/internal/models/SearchTypeTest.kt index 09e85515..94ac0c77 100644 --- a/wisefysample/src/test/java/com/isupatches/wisefysample/internal/models/SearchTypeTest.kt +++ b/wisefysample/src/test/java/com/isupatches/wisefysample/internal/models/SearchTypeTest.kt @@ -6,19 +6,23 @@ import org.junit.Test internal class SearchTypeTest { - @Test fun accessPoint() { + @Test + fun accessPoint() { assertEquals(SearchType.ACCESS_POINT, SearchType.of(SearchType.ACCESS_POINT.intVal)) } - @Test fun ssid() { + @Test + fun ssid() { assertEquals(SearchType.SSID, SearchType.of(SearchType.SSID.intVal)) } - @Test fun savedNetwork() { + @Test + fun savedNetwork() { assertEquals(SearchType.SAVED_NETWORK, SearchType.of(SearchType.SAVED_NETWORK.intVal)) } - @Test fun unexpected() { + @Test + fun unexpected() { try { SearchType.of(999) fail("Expected IllegalArgumentException from NetworkType.of") diff --git a/wisefysample/src/test/java/com/isupatches/wisefysample/internal/preferences/BaseSharedPreferencesStoreTest.kt b/wisefysample/src/test/java/com/isupatches/wisefysample/internal/preferences/BaseSharedPreferencesStoreTest.kt index fb88545e..87474967 100644 --- a/wisefysample/src/test/java/com/isupatches/wisefysample/internal/preferences/BaseSharedPreferencesStoreTest.kt +++ b/wisefysample/src/test/java/com/isupatches/wisefysample/internal/preferences/BaseSharedPreferencesStoreTest.kt @@ -1,18 +1,15 @@ package com.isupatches.wisefysample.internal.preferences import android.content.SharedPreferences - import com.isupatches.wisefysample.TEST_SSID_1 - import com.nhaarman.mockitokotlin2.mock import com.nhaarman.mockitokotlin2.verify - import org.mockito.Mockito abstract class BaseSharedPreferencesStoreTest { - protected val editor = mock() - protected val sharedPreferences = mock().also { + protected val editor: SharedPreferences.Editor = mock() + protected val sharedPreferences: SharedPreferences = mock().also { Mockito.`when`(it.edit()).thenReturn(editor) } diff --git a/wisefysample/src/test/java/com/isupatches/wisefysample/internal/preferences/SharedPreferencesAddNetworkStoreTest.kt b/wisefysample/src/test/java/com/isupatches/wisefysample/internal/preferences/SharedPreferencesAddNetworkStoreTest.kt index e3904e83..02e4666b 100644 --- a/wisefysample/src/test/java/com/isupatches/wisefysample/internal/preferences/SharedPreferencesAddNetworkStoreTest.kt +++ b/wisefysample/src/test/java/com/isupatches/wisefysample/internal/preferences/SharedPreferencesAddNetworkStoreTest.kt @@ -3,9 +3,7 @@ package com.isupatches.wisefysample.internal.preferences import com.isupatches.wisefysample.TEST_PASSWORD_1 import com.isupatches.wisefysample.TEST_SSID_1 import com.isupatches.wisefysample.internal.models.NetworkType - import com.nhaarman.mockitokotlin2.verify - import org.junit.Test internal class SharedPreferencesAddNetworkStoreTest : BaseSharedPreferencesStoreTest() { @@ -14,7 +12,8 @@ internal class SharedPreferencesAddNetworkStoreTest : BaseSharedPreferencesStore SharedPreferencesAddNetworkStore(sharedPreferences) } - @Test fun clearsAddNetworkStoreData() { + @Test + fun clearsAddNetworkStoreData() { store.clear() verify(editor).clear() } @@ -23,12 +22,14 @@ internal class SharedPreferencesAddNetworkStoreTest : BaseSharedPreferencesStore * Network Type */ - @Test fun setNetworkType() { + @Test + fun setNetworkType() { store.setNetworkType(NetworkType.WPA2) verify(editor).putInt(PREF_NETWORK_TYPE, NetworkType.WPA2.intVal) } - @Test fun getNetworkType() { + @Test + fun getNetworkType() { store.getNetworkType() verify(sharedPreferences).getInt(PREF_NETWORK_TYPE, NetworkType.WPA2.intVal) } @@ -37,12 +38,14 @@ internal class SharedPreferencesAddNetworkStoreTest : BaseSharedPreferencesStore * Last Used Network Name */ - @Test fun setLastUsedNetworkName() { + @Test + fun setLastUsedNetworkName() { store.setLastUsedNetworkName(TEST_SSID_1) verify(editor).putString(PREF_LAST_USED_NETWORK_NAME, TEST_SSID_1) } - @Test fun getLastUsedNetworkName() { + @Test + fun getLastUsedNetworkName() { store.getLastUsedNetworkName() verify(sharedPreferences).getString(PREF_LAST_USED_NETWORK_NAME, "") } @@ -51,13 +54,15 @@ internal class SharedPreferencesAddNetworkStoreTest : BaseSharedPreferencesStore * Last Used Network Password */ - @Test fun setLastUsedNetworkPassword() { + @Test + fun setLastUsedNetworkPassword() { store.setLastUsedNetworkPassword(TEST_PASSWORD_1) verify(editor).putString(PREF_LAST_USED_NETWORK_PASSWORD, TEST_PASSWORD_1) } - @Test fun getLastUsedNetworkPassword() { + @Test + fun getLastUsedNetworkPassword() { store.getLastUsedNetworkPassword() verify(sharedPreferences).getString(PREF_LAST_USED_NETWORK_PASSWORD, "") } -} \ No newline at end of file +} diff --git a/wisefysample/src/test/java/com/isupatches/wisefysample/internal/preferences/SharedPreferencesRemoveNetworkStoreTest.kt b/wisefysample/src/test/java/com/isupatches/wisefysample/internal/preferences/SharedPreferencesRemoveNetworkStoreTest.kt index 1f6d477b..2b914800 100644 --- a/wisefysample/src/test/java/com/isupatches/wisefysample/internal/preferences/SharedPreferencesRemoveNetworkStoreTest.kt +++ b/wisefysample/src/test/java/com/isupatches/wisefysample/internal/preferences/SharedPreferencesRemoveNetworkStoreTest.kt @@ -1,9 +1,7 @@ package com.isupatches.wisefysample.internal.preferences import com.isupatches.wisefysample.TEST_SSID_1 - import com.nhaarman.mockitokotlin2.verify - import org.junit.Test internal class SharedPreferencesRemoveNetworkStoreTest : BaseSharedPreferencesStoreTest() { @@ -12,7 +10,8 @@ internal class SharedPreferencesRemoveNetworkStoreTest : BaseSharedPreferencesSt SharedPreferencesRemoveNetworkStore(sharedPreferences) } - @Test fun clearsRemoveNetworkStoreData() { + @Test + fun clearsRemoveNetworkStoreData() { store.clear() verify(editor).clear() } @@ -21,12 +20,14 @@ internal class SharedPreferencesRemoveNetworkStoreTest : BaseSharedPreferencesSt * Last Used Regex */ - @Test fun setLastUsedRegex_remove() { + @Test + fun setLastUsedRegex_remove() { store.setLastUsedRegex(TEST_SSID_1) verifyUpdatedLastUsedRegex() } - @Test fun getLastUsedRegex_remove() { + @Test + fun getLastUsedRegex_remove() { store.getLastUsedRegex() verifyRetrievedLastUsedRegex() } diff --git a/wisefysample/src/test/java/com/isupatches/wisefysample/internal/preferences/SharedPreferencesSearchStoreTest.kt b/wisefysample/src/test/java/com/isupatches/wisefysample/internal/preferences/SharedPreferencesSearchStoreTest.kt index 8f85594d..3d7abd50 100644 --- a/wisefysample/src/test/java/com/isupatches/wisefysample/internal/preferences/SharedPreferencesSearchStoreTest.kt +++ b/wisefysample/src/test/java/com/isupatches/wisefysample/internal/preferences/SharedPreferencesSearchStoreTest.kt @@ -3,9 +3,7 @@ package com.isupatches.wisefysample.internal.preferences import com.isupatches.wisefysample.TEST_SSID_1 import com.isupatches.wisefysample.TEST_TIMEOUT import com.isupatches.wisefysample.internal.models.SearchType - import com.nhaarman.mockitokotlin2.verify - import org.junit.Test internal class SharedPreferencesSearchStoreTest : BaseSharedPreferencesStoreTest() { @@ -18,7 +16,8 @@ internal class SharedPreferencesSearchStoreTest : BaseSharedPreferencesStoreTest SharedPreferencesSearchStore(sharedPreferences) } - @Test fun clearsSearchStoreData() { + @Test + fun clearsSearchStoreData() { store.clear() verify(editor).clear() } @@ -27,12 +26,14 @@ internal class SharedPreferencesSearchStoreTest : BaseSharedPreferencesStoreTest * Last Used Regex */ - @Test fun setLastUsedRegex_search() { + @Test + fun setLastUsedRegex_search() { store.setLastUsedRegex(TEST_SSID_1) verifyUpdatedLastUsedRegex() } - @Test fun getLastUsedRegex_search() { + @Test + fun getLastUsedRegex_search() { store.getLastUsedRegex() verifyRetrievedLastUsedRegex() } @@ -41,12 +42,14 @@ internal class SharedPreferencesSearchStoreTest : BaseSharedPreferencesStoreTest * Search Type */ - @Test fun setSearchType() { + @Test + fun setSearchType() { store.setSearchType(SearchType.ACCESS_POINT) verify(editor).putInt(PREF_SEARCH_TYPE, SearchType.ACCESS_POINT.intVal) } - @Test fun getSearchType() { + @Test + fun getSearchType() { store.getSearchType() verify(sharedPreferences).getInt(PREF_SEARCH_TYPE, SearchType.ACCESS_POINT.intVal) } @@ -55,12 +58,14 @@ internal class SharedPreferencesSearchStoreTest : BaseSharedPreferencesStoreTest * Filter Duplicates */ - @Test fun setFilterDuplicates() { + @Test + fun setFilterDuplicates() { store.setFilterDuplicates(true) verify(editor).putBoolean(PREF_FILTER_DUPLICATES, true) } - @Test fun shouldFilterDuplicates() { + @Test + fun shouldFilterDuplicates() { store.shouldFilterDuplicates() verify(sharedPreferences).getBoolean(PREF_FILTER_DUPLICATES, true) } @@ -69,12 +74,14 @@ internal class SharedPreferencesSearchStoreTest : BaseSharedPreferencesStoreTest * Return Full List */ - @Test fun setReturnFullList() { + @Test + fun setReturnFullList() { store.setReturnFullList(true) verify(editor).putBoolean(PREF_RETURN_FULL_LIST, true) } - @Test fun shouldReturnFullList() { + @Test + fun shouldReturnFullList() { store.shouldReturnFullList() verify(sharedPreferences).getBoolean(PREF_RETURN_FULL_LIST, true) } @@ -83,12 +90,14 @@ internal class SharedPreferencesSearchStoreTest : BaseSharedPreferencesStoreTest * Timeout */ - @Test fun setTimeout() { + @Test + fun setTimeout() { store.setTimeout(TIMEOUT) verify(editor).putInt(PREF_TIMEOUT, TIMEOUT) } - @Test fun getTimeout() { + @Test + fun getTimeout() { store.getTimeout() verify(sharedPreferences).getInt(PREF_TIMEOUT, TEST_TIMEOUT) } diff --git a/wisefysample/src/test/java/com/isupatches/wisefysample/ui/add/AddNetworkModelTest.kt b/wisefysample/src/test/java/com/isupatches/wisefysample/ui/add/AddNetworkModelTest.kt index 3815236c..c88e61db 100644 --- a/wisefysample/src/test/java/com/isupatches/wisefysample/ui/add/AddNetworkModelTest.kt +++ b/wisefysample/src/test/java/com/isupatches/wisefysample/ui/add/AddNetworkModelTest.kt @@ -1,18 +1,15 @@ package com.isupatches.wisefysample.ui.add import android.net.wifi.WifiConfiguration - import com.isupatches.wisefy.WiseFyPublicApi import com.isupatches.wisefy.callbacks.AddNetworkCallbacks import com.isupatches.wisefysample.TEST_PASSWORD_1 import com.isupatches.wisefysample.TEST_SSID_1 - import com.nhaarman.mockitokotlin2.any import com.nhaarman.mockitokotlin2.eq import com.nhaarman.mockitokotlin2.mock import com.nhaarman.mockitokotlin2.times import com.nhaarman.mockitokotlin2.verify - import org.junit.Test internal class AddNetworkModelTest { @@ -32,7 +29,8 @@ internal class AddNetworkModelTest { } } - @Test fun addOpenNetwork() { + @Test + fun addOpenNetwork() { // When model.addOpenNetwork(TEST_SSID_1, addNetworkCallbacks) @@ -40,7 +38,8 @@ internal class AddNetworkModelTest { verify(wiseFy, times(1)).addOpenNetwork(eq(TEST_SSID_1), any()) } - @Test fun addWepNetwork() { + @Test + fun addWepNetwork() { // When model.addWEPNetwork(TEST_SSID_1, TEST_PASSWORD_1, addNetworkCallbacks) @@ -52,7 +51,8 @@ internal class AddNetworkModelTest { ) } - @Test fun addWPA2Network() { + @Test + fun addWPA2Network() { // When model.addWPA2Network(TEST_SSID_1, TEST_PASSWORD_1, addNetworkCallbacks) @@ -63,4 +63,4 @@ internal class AddNetworkModelTest { any() ) } -} \ No newline at end of file +} diff --git a/wisefysample/src/test/java/com/isupatches/wisefysample/ui/add/AddNetworkPresenterTest.kt b/wisefysample/src/test/java/com/isupatches/wisefysample/ui/add/AddNetworkPresenterTest.kt index afd82dcf..8b6b7a15 100644 --- a/wisefysample/src/test/java/com/isupatches/wisefysample/ui/add/AddNetworkPresenterTest.kt +++ b/wisefysample/src/test/java/com/isupatches/wisefysample/ui/add/AddNetworkPresenterTest.kt @@ -1,14 +1,12 @@ package com.isupatches.wisefysample.ui.add import android.net.wifi.WifiConfiguration - import com.isupatches.wisefy.callbacks.AddNetworkCallbacks import com.isupatches.wisefy.constants.MISSING_PARAMETER import com.isupatches.wisefysample.BAD_WIFI_MANAGER_RETURN import com.isupatches.wisefysample.TEST_PASSWORD_1 import com.isupatches.wisefysample.TEST_SSID_1 import com.isupatches.wisefysample.TestRxSchedulersProvider - import com.nhaarman.mockitokotlin2.any import com.nhaarman.mockitokotlin2.doAnswer import com.nhaarman.mockitokotlin2.eq @@ -16,7 +14,6 @@ import com.nhaarman.mockitokotlin2.mock import com.nhaarman.mockitokotlin2.times import com.nhaarman.mockitokotlin2.verify import com.nhaarman.mockitokotlin2.whenever - import org.junit.After import org.junit.Before import org.junit.Test @@ -33,15 +30,18 @@ internal class AddNetworkPresenterTest { private val SAVED_NETWORK = mock() } - @Before fun setUp() { + @Before + fun setUp() { presenter.attachView(view) } - @After fun tearDown() { + @After + fun tearDown() { presenter.detachView() } - @Test fun addOpenNetwork_networkAdded() { + @Test + fun addOpenNetwork_networkAdded() { // Given doAnswer { invocationOnMock -> val callback = invocationOnMock.arguments[1] as AddNetworkCallbacks @@ -56,7 +56,8 @@ internal class AddNetworkPresenterTest { verify(view, times(1)).displayNetworkAdded(NETWORK_ID, SAVED_NETWORK) } - @Test fun addOpenNetwork_failureAddingNetwork() { + @Test + fun addOpenNetwork_failureAddingNetwork() { // Given doAnswer { invocationOnMock -> val callback = invocationOnMock.arguments[1] as AddNetworkCallbacks @@ -71,7 +72,8 @@ internal class AddNetworkPresenterTest { verify(view, times(1)).displayFailureAddingNetwork(BAD_WIFI_MANAGER_RETURN) } - @Test fun addOpenNetwork_wisefyFailure() { + @Test + fun addOpenNetwork_wisefyFailure() { // Given doAnswer { invocationOnMock -> val callback = invocationOnMock.arguments[1] as AddNetworkCallbacks @@ -86,7 +88,8 @@ internal class AddNetworkPresenterTest { verify(view, times(1)).displayWiseFyFailure(MISSING_PARAMETER) } - @Test fun addWEPNetwork_networkAdded() { + @Test + fun addWEPNetwork_networkAdded() { // Given doAnswer { invocationOnMock -> val callback = invocationOnMock.arguments[2] as AddNetworkCallbacks @@ -101,7 +104,8 @@ internal class AddNetworkPresenterTest { verify(view, times(1)).displayNetworkAdded(NETWORK_ID, SAVED_NETWORK) } - @Test fun addWEPNetwork_failureAddingNetwork() { + @Test + fun addWEPNetwork_failureAddingNetwork() { // Given doAnswer { invocationOnMock -> val callback = invocationOnMock.arguments[2] as AddNetworkCallbacks @@ -116,7 +120,8 @@ internal class AddNetworkPresenterTest { verify(view, times(1)).displayFailureAddingNetwork(BAD_WIFI_MANAGER_RETURN) } - @Test fun addWEPNetwork_wisefyFailure() { + @Test + fun addWEPNetwork_wisefyFailure() { // Given doAnswer { invocationOnMock -> val callback = invocationOnMock.arguments[2] as AddNetworkCallbacks @@ -131,7 +136,8 @@ internal class AddNetworkPresenterTest { verify(view, times(1)).displayWiseFyFailure(MISSING_PARAMETER) } - @Test fun addWPA2Network_networkAdded() { + @Test + fun addWPA2Network_networkAdded() { // Given doAnswer { invocationOnMock -> val callback = invocationOnMock.arguments[2] as AddNetworkCallbacks @@ -146,7 +152,8 @@ internal class AddNetworkPresenterTest { verify(view, times(1)).displayNetworkAdded(NETWORK_ID, SAVED_NETWORK) } - @Test fun addWPA2Network_failureAddingNetwork() { + @Test + fun addWPA2Network_failureAddingNetwork() { // Given doAnswer { invocationOnMock -> val callback = invocationOnMock.arguments[2] as AddNetworkCallbacks @@ -161,7 +168,8 @@ internal class AddNetworkPresenterTest { verify(view, times(1)).displayFailureAddingNetwork(BAD_WIFI_MANAGER_RETURN) } - @Test fun addWPA2Network_wisefyFailure() { + @Test + fun addWPA2Network_wisefyFailure() { // Given doAnswer { invocationOnMock -> val callback = invocationOnMock.arguments[2] as AddNetworkCallbacks @@ -215,4 +223,4 @@ internal class AddNetworkPresenterTest { any() ) } -} \ No newline at end of file +} diff --git a/wisefysample/src/test/java/com/isupatches/wisefysample/ui/misc/MiscModelTest.kt b/wisefysample/src/test/java/com/isupatches/wisefysample/ui/misc/MiscModelTest.kt index b894c975..070f7c92 100644 --- a/wisefysample/src/test/java/com/isupatches/wisefysample/ui/misc/MiscModelTest.kt +++ b/wisefysample/src/test/java/com/isupatches/wisefysample/ui/misc/MiscModelTest.kt @@ -4,7 +4,6 @@ import android.net.NetworkInfo import android.net.wifi.ScanResult import android.net.wifi.WifiConfiguration import android.net.wifi.WifiInfo - import com.isupatches.wisefy.WiseFyPublicApi import com.isupatches.wisefy.callbacks.DisableWifiCallbacks import com.isupatches.wisefy.callbacks.EnableWifiCallbacks @@ -14,13 +13,11 @@ import com.isupatches.wisefy.callbacks.GetFrequencyCallbacks import com.isupatches.wisefy.callbacks.GetIPCallbacks import com.isupatches.wisefy.callbacks.GetNearbyAccessPointsCallbacks import com.isupatches.wisefy.callbacks.GetSavedNetworksCallbacks - import com.nhaarman.mockitokotlin2.any import com.nhaarman.mockitokotlin2.eq import com.nhaarman.mockitokotlin2.mock import com.nhaarman.mockitokotlin2.times import com.nhaarman.mockitokotlin2.verify - import org.junit.Test internal class MiscModelTest { @@ -29,7 +26,8 @@ internal class MiscModelTest { private val model = MiscModel(wiseFy) - @Test fun disableWifi() { + @Test + fun disableWifi() { // When model.disableWifi(object : DisableWifiCallbacks { override fun failureDisablingWifi() { @@ -46,7 +44,8 @@ internal class MiscModelTest { verify(wiseFy, times(1)).disableWifi(any()) } - @Test fun enableWifi() { + @Test + fun enableWifi() { // When model.enableWifi(object : EnableWifiCallbacks { override fun failureEnablingWifi() { @@ -63,7 +62,8 @@ internal class MiscModelTest { verify(wiseFy, times(1)).enableWifi(any()) } - @Test fun getCurrentNetwork() { + @Test + fun getCurrentNetwork() { // When model.getCurrentNetwork(object : GetCurrentNetworkCallbacks { override fun noCurrentNetwork() { @@ -80,13 +80,14 @@ internal class MiscModelTest { verify(wiseFy, times(1)).getCurrentNetwork(any()) } - @Test fun getCurrentNetworkInfo() { + @Test + fun getCurrentNetworkInfo() { // When model.getCurrentNetworkInfo(object : GetCurrentNetworkInfoCallbacks { override fun noCurrentNetworkInfo() { } - override fun retrievedCurrentNetworkInfo(currentNetworkDetails: NetworkInfo) { + override fun retrievedCurrentNetworkInfo(currentNetworkInfo: NetworkInfo) { } override fun wisefyFailure(wisefyFailureCode: Int) { @@ -97,7 +98,8 @@ internal class MiscModelTest { verify(wiseFy, times(1)).getCurrentNetworkInfo(any()) } - @Test fun getFrequency() { + @Test + fun getFrequency() { // When model.getFrequency(object : GetFrequencyCallbacks { override fun failureGettingFrequency() { @@ -114,7 +116,8 @@ internal class MiscModelTest { verify(wiseFy, times(1)).getFrequency(any()) } - @Test fun getIp() { + @Test + fun getIp() { // When model.getIP(object : GetIPCallbacks { override fun failureRetrievingIP() { @@ -131,7 +134,8 @@ internal class MiscModelTest { verify(wiseFy, times(1)).getIP(any()) } - @Test fun getNearbyAccessPoints() { + @Test + fun getNearbyAccessPoints() { // When model.getNearbyAccessPoints(object : GetNearbyAccessPointsCallbacks { override fun retrievedNearbyAccessPoints(nearbyAccessPoints: List) { @@ -148,7 +152,8 @@ internal class MiscModelTest { verify(wiseFy, times(1)).getNearbyAccessPoints(eq(true), any()) } - @Test fun getSavedNetworks() { + @Test + fun getSavedNetworks() { // When model.getSavedNetworks(object : GetSavedNetworksCallbacks { override fun noSavedNetworksFound() { @@ -164,4 +169,4 @@ internal class MiscModelTest { // Then verify(wiseFy, times(1)).getSavedNetworks(any()) } -} \ No newline at end of file +} diff --git a/wisefysample/src/test/java/com/isupatches/wisefysample/ui/misc/MiscPresenterTest.kt b/wisefysample/src/test/java/com/isupatches/wisefysample/ui/misc/MiscPresenterTest.kt index 39facb97..b8f6710b 100644 --- a/wisefysample/src/test/java/com/isupatches/wisefysample/ui/misc/MiscPresenterTest.kt +++ b/wisefysample/src/test/java/com/isupatches/wisefysample/ui/misc/MiscPresenterTest.kt @@ -4,7 +4,6 @@ import android.net.NetworkInfo import android.net.wifi.ScanResult import android.net.wifi.WifiConfiguration import android.net.wifi.WifiInfo - import com.isupatches.wisefy.WiseFy.Companion.MIN_FREQUENCY_5GHZ import com.isupatches.wisefy.callbacks.DisableWifiCallbacks import com.isupatches.wisefy.callbacks.EnableWifiCallbacks @@ -17,14 +16,12 @@ import com.isupatches.wisefy.callbacks.GetSavedNetworksCallbacks import com.isupatches.wisefy.constants.MISSING_PARAMETER import com.isupatches.wisefysample.TEST_IP import com.isupatches.wisefysample.TestRxSchedulersProvider - import com.nhaarman.mockitokotlin2.any import com.nhaarman.mockitokotlin2.doAnswer import com.nhaarman.mockitokotlin2.mock import com.nhaarman.mockitokotlin2.times import com.nhaarman.mockitokotlin2.verify import com.nhaarman.mockitokotlin2.whenever - import org.junit.After import org.junit.Before import org.junit.Test @@ -44,15 +41,18 @@ internal class MiscPresenterTest { private val SAVED_NETWORK = mock() } - @Before fun setUp() { + @Before + fun setUp() { presenter.attachView(view) } - @After fun tearDown() { + @After + fun tearDown() { presenter.detachView() } - @Test fun disableWifi_wifiDisabled() { + @Test + fun disableWifi_wifiDisabled() { // Given doAnswer { invocationOnMock -> val callback = invocationOnMock.arguments[0] as DisableWifiCallbacks @@ -67,7 +67,8 @@ internal class MiscPresenterTest { verify(view, times(1)).displayWifiDisabled() } - @Test fun disableWifi_failureDisablingWifi() { + @Test + fun disableWifi_failureDisablingWifi() { // Given doAnswer { invocationOnMock -> val callback = invocationOnMock.arguments[0] as DisableWifiCallbacks @@ -82,7 +83,8 @@ internal class MiscPresenterTest { verify(view, times(1)).displayFailureDisablingWifi() } - @Test fun disableWifi_wisefyFailure() { + @Test + fun disableWifi_wisefyFailure() { // Given doAnswer { invocationOnMock -> val callback = invocationOnMock.arguments[0] as DisableWifiCallbacks @@ -97,7 +99,8 @@ internal class MiscPresenterTest { verify(view, times(1)).displayWiseFyFailure(MISSING_PARAMETER) } - @Test fun enableWifi_wifiEnabled() { + @Test + fun enableWifi_wifiEnabled() { // Given doAnswer { invocationOnMock -> val callback = invocationOnMock.arguments[0] as EnableWifiCallbacks @@ -112,7 +115,8 @@ internal class MiscPresenterTest { verify(view, times(1)).displayWifiEnabled() } - @Test fun enableWifi_failureEnablingWifi() { + @Test + fun enableWifi_failureEnablingWifi() { // Given doAnswer { invocationOnMock -> val callback = invocationOnMock.arguments[0] as EnableWifiCallbacks @@ -127,7 +131,8 @@ internal class MiscPresenterTest { verify(view, times(1)).displayFailureEnablingWifi() } - @Test fun enableWifi_wisefyFailure() { + @Test + fun enableWifi_wisefyFailure() { // Given doAnswer { invocationOnMock -> val callback = invocationOnMock.arguments[0] as EnableWifiCallbacks @@ -142,7 +147,8 @@ internal class MiscPresenterTest { verify(view, times(1)).displayWiseFyFailure(MISSING_PARAMETER) } - @Test fun getCurrentNetwork_retrievedCurrentNetwork() { + @Test + fun getCurrentNetwork_retrievedCurrentNetwork() { // Given doAnswer { invocationOnMock -> val callback = invocationOnMock.arguments[0] as GetCurrentNetworkCallbacks @@ -157,7 +163,8 @@ internal class MiscPresenterTest { verify(view, times(1)).displayCurrentNetwork(CURRENT_NETWORK) } - @Test fun getCurrentNetwork_noCurrentNetwork() { + @Test + fun getCurrentNetwork_noCurrentNetwork() { // Given doAnswer { invocationOnMock -> val callback = invocationOnMock.arguments[0] as GetCurrentNetworkCallbacks @@ -172,7 +179,8 @@ internal class MiscPresenterTest { verify(view, times(1)).displayNoCurrentNetwork() } - @Test fun getCurrentNetwork_wisefyFailure() { + @Test + fun getCurrentNetwork_wisefyFailure() { // Given doAnswer { invocationOnMock -> val callback = invocationOnMock.arguments[0] as GetCurrentNetworkCallbacks @@ -187,7 +195,8 @@ internal class MiscPresenterTest { verify(view, times(1)).displayWiseFyFailure(MISSING_PARAMETER) } - @Test fun getCurrentNetworkInfo_retrievedCurrentNetworkInfo() { + @Test + fun getCurrentNetworkInfo_retrievedCurrentNetworkInfo() { // Given doAnswer { invocationOnMock -> val callback = invocationOnMock.arguments[0] as GetCurrentNetworkInfoCallbacks @@ -202,7 +211,8 @@ internal class MiscPresenterTest { verify(view, times(1)).displayCurrentNetworkInfo(CURRENT_NETWORK_INFO) } - @Test fun getCurrentNetworkInfo_noCurrentNetworkInfo() { + @Test + fun getCurrentNetworkInfo_noCurrentNetworkInfo() { // Given doAnswer { invocationOnMock -> val callback = invocationOnMock.arguments[0] as GetCurrentNetworkInfoCallbacks @@ -217,7 +227,8 @@ internal class MiscPresenterTest { verify(view, times(1)).displayNoCurrentNetworkInfo() } - @Test fun getCurrentNetworkInfo_wisefyFailure() { + @Test + fun getCurrentNetworkInfo_wisefyFailure() { // Given doAnswer { invocationOnMock -> val callback = invocationOnMock.arguments[0] as GetCurrentNetworkInfoCallbacks @@ -232,7 +243,8 @@ internal class MiscPresenterTest { verify(view, times(1)).displayWiseFyFailure(MISSING_PARAMETER) } - @Test fun getFrequency_retrievedFrequency() { + @Test + fun getFrequency_retrievedFrequency() { // Given doAnswer { invocationOnMock -> val callback = invocationOnMock.arguments[0] as GetFrequencyCallbacks @@ -247,7 +259,8 @@ internal class MiscPresenterTest { verify(view, times(1)).displayFrequency(MIN_FREQUENCY_5GHZ) } - @Test fun getFrequency_failureGettingFrequency() { + @Test + fun getFrequency_failureGettingFrequency() { // Given doAnswer { invocationOnMock -> val callback = invocationOnMock.arguments[0] as GetFrequencyCallbacks @@ -262,7 +275,8 @@ internal class MiscPresenterTest { verify(view, times(1)).displayFailureRetrievingFrequency() } - @Test fun getFrequency_wisefyFailure() { + @Test + fun getFrequency_wisefyFailure() { // Given doAnswer { invocationOnMock -> val callback = invocationOnMock.arguments[0] as GetFrequencyCallbacks @@ -277,7 +291,8 @@ internal class MiscPresenterTest { verify(view, times(1)).displayWiseFyFailure(MISSING_PARAMETER) } - @Test fun getIP_retrievedIP() { + @Test + fun getIP_retrievedIP() { // Given doAnswer { invocationOnMock -> val callback = invocationOnMock.arguments[0] as GetIPCallbacks @@ -292,7 +307,8 @@ internal class MiscPresenterTest { verify(view, times(1)).displayIP(TEST_IP) } - @Test fun getIP_failureRetrievingIP() { + @Test + fun getIP_failureRetrievingIP() { // Given doAnswer { invocationOnMock -> val callback = invocationOnMock.arguments[0] as GetIPCallbacks @@ -307,7 +323,8 @@ internal class MiscPresenterTest { verify(view, times(1)).displayFailureRetrievingIP() } - @Test fun getIP_wisefyFailure() { + @Test + fun getIP_wisefyFailure() { // Given doAnswer { invocationOnMock -> val callback = invocationOnMock.arguments[0] as GetIPCallbacks @@ -322,7 +339,8 @@ internal class MiscPresenterTest { verify(view, times(1)).displayWiseFyFailure(MISSING_PARAMETER) } - @Test fun getNearbyAccessPoints_retrievedNearbyAccessPoints() { + @Test + fun getNearbyAccessPoints_retrievedNearbyAccessPoints() { // Given doAnswer { invocationOnMock -> val callback = invocationOnMock.arguments[0] as GetNearbyAccessPointsCallbacks @@ -337,7 +355,8 @@ internal class MiscPresenterTest { verify(view, times(1)).displayNearbyAccessPoints(listOf(ACCESS_POINT)) } - @Test fun getNearbyAccessPoints_noAccessPointsFound() { + @Test + fun getNearbyAccessPoints_noAccessPointsFound() { // Given doAnswer { invocationOnMock -> val callback = invocationOnMock.arguments[0] as GetNearbyAccessPointsCallbacks @@ -352,7 +371,8 @@ internal class MiscPresenterTest { verify(view, times(1)).displayNoAccessPointsFound() } - @Test fun getNearbyAccessPoints_wisefyFailure() { + @Test + fun getNearbyAccessPoints_wisefyFailure() { // Given doAnswer { invocationOnMock -> val callback = invocationOnMock.arguments[0] as GetNearbyAccessPointsCallbacks @@ -367,7 +387,8 @@ internal class MiscPresenterTest { verify(view, times(1)).displayWiseFyFailure(MISSING_PARAMETER) } - @Test fun getSavedNetworks_retrievedSavedNetworks() { + @Test + fun getSavedNetworks_retrievedSavedNetworks() { // Given doAnswer { invocationOnMock -> val callback = invocationOnMock.arguments[0] as GetSavedNetworksCallbacks @@ -382,7 +403,8 @@ internal class MiscPresenterTest { verify(view, times(1)).displaySavedNetworks(listOf(SAVED_NETWORK)) } - @Test fun getSavedNetworks_noSavedNetworksFound() { + @Test + fun getSavedNetworks_noSavedNetworksFound() { // Given doAnswer { invocationOnMock -> val callback = invocationOnMock.arguments[0] as GetSavedNetworksCallbacks @@ -397,7 +419,8 @@ internal class MiscPresenterTest { verify(view, times(1)).displayNoSavedNetworksFound() } - @Test fun getSavedNetworks_wisefyFailure() { + @Test + fun getSavedNetworks_wisefyFailure() { // Given doAnswer { invocationOnMock -> val callback = invocationOnMock.arguments[0] as GetSavedNetworksCallbacks @@ -483,4 +506,4 @@ internal class MiscPresenterTest { private fun verifyTriedToGetSavedNetworks() { verify(model, times(1)).getSavedNetworks(any()) } -} \ No newline at end of file +} diff --git a/wisefysample/src/test/java/com/isupatches/wisefysample/ui/remove/RemoveModelTest.kt b/wisefysample/src/test/java/com/isupatches/wisefysample/ui/remove/RemoveModelTest.kt index 888ca9d3..b5345a3b 100644 --- a/wisefysample/src/test/java/com/isupatches/wisefysample/ui/remove/RemoveModelTest.kt +++ b/wisefysample/src/test/java/com/isupatches/wisefysample/ui/remove/RemoveModelTest.kt @@ -3,13 +3,11 @@ package com.isupatches.wisefysample.ui.remove import com.isupatches.wisefy.WiseFyPublicApi import com.isupatches.wisefy.callbacks.RemoveNetworkCallbacks import com.isupatches.wisefysample.TEST_SSID_1 - import com.nhaarman.mockitokotlin2.any import com.nhaarman.mockitokotlin2.eq import com.nhaarman.mockitokotlin2.mock import com.nhaarman.mockitokotlin2.times import com.nhaarman.mockitokotlin2.verify - import org.junit.Test internal class RemoveModelTest { @@ -18,7 +16,8 @@ internal class RemoveModelTest { private val model = RemoveNetworkModel(wiseFy) - @Test fun removeNetwork() { + @Test + fun removeNetwork() { // When model.removeNetwork(TEST_SSID_1, object : RemoveNetworkCallbacks { override fun failureRemovingNetwork() { diff --git a/wisefysample/src/test/java/com/isupatches/wisefysample/ui/remove/RemovePresenterTest.kt b/wisefysample/src/test/java/com/isupatches/wisefysample/ui/remove/RemovePresenterTest.kt index d1a5d92e..03447a12 100644 --- a/wisefysample/src/test/java/com/isupatches/wisefysample/ui/remove/RemovePresenterTest.kt +++ b/wisefysample/src/test/java/com/isupatches/wisefysample/ui/remove/RemovePresenterTest.kt @@ -4,18 +4,15 @@ import com.isupatches.wisefy.callbacks.RemoveNetworkCallbacks import com.isupatches.wisefy.constants.MISSING_PARAMETER import com.isupatches.wisefysample.TEST_SSID_1 import com.isupatches.wisefysample.TestRxSchedulersProvider - import com.nhaarman.mockitokotlin2.any import com.nhaarman.mockitokotlin2.eq import com.nhaarman.mockitokotlin2.mock import com.nhaarman.mockitokotlin2.times import com.nhaarman.mockitokotlin2.verify import com.nhaarman.mockitokotlin2.whenever - import org.junit.After import org.junit.Before import org.junit.Test - import org.mockito.Mockito.doAnswer internal class RemovePresenterTest { @@ -25,15 +22,18 @@ internal class RemovePresenterTest { private val presenter = RemoveNetworkPresenter(model, TestRxSchedulersProvider()) - @Before fun setUp() { + @Before + fun setUp() { presenter.attachView(view) } - @After fun tearDown() { + @After + fun tearDown() { presenter.detachView() } - @Test fun removeNetwork_networkRemoved() { + @Test + fun removeNetwork_networkRemoved() { // Given doAnswer { invocationOnMock -> val callback = invocationOnMock.arguments[1] as RemoveNetworkCallbacks @@ -48,7 +48,8 @@ internal class RemovePresenterTest { verify(view, times(1)).displayNetworkRemoved() } - @Test fun removeNetwork_failureRemovingNetwork() { + @Test + fun removeNetwork_failureRemovingNetwork() { // Then doAnswer { invocationOnMock -> val callback = invocationOnMock.arguments[1] as RemoveNetworkCallbacks @@ -63,7 +64,8 @@ internal class RemovePresenterTest { verify(view, times(1)).displayFailureRemovingNetwork() } - @Test fun removeNetwork_networkNotFoundToRemove() { + @Test + fun removeNetwork_networkNotFoundToRemove() { // Given doAnswer { invocationOnMock -> val callback = invocationOnMock.arguments[1] as RemoveNetworkCallbacks @@ -78,7 +80,8 @@ internal class RemovePresenterTest { verify(view, times(1)).displayNetworkNotFoundToRemove() } - @Test fun removeNetwork_wisefyFailure() { + @Test + fun removeNetwork_wisefyFailure() { // Given doAnswer { invocationOnMock -> val callback = invocationOnMock.arguments[1] as RemoveNetworkCallbacks @@ -108,4 +111,4 @@ internal class RemovePresenterTest { private fun verifyTriedToRemoveNetwork() { verify(model, times(1)).removeNetwork(eq(TEST_SSID_1), any()) } -} \ No newline at end of file +} diff --git a/wisefysample/src/test/java/com/isupatches/wisefysample/ui/search/SearchModelTest.kt b/wisefysample/src/test/java/com/isupatches/wisefysample/ui/search/SearchModelTest.kt index c8246242..fd7184d7 100644 --- a/wisefysample/src/test/java/com/isupatches/wisefysample/ui/search/SearchModelTest.kt +++ b/wisefysample/src/test/java/com/isupatches/wisefysample/ui/search/SearchModelTest.kt @@ -2,7 +2,6 @@ package com.isupatches.wisefysample.ui.search import android.net.wifi.ScanResult import android.net.wifi.WifiConfiguration - import com.isupatches.wisefy.WiseFyPublicApi import com.isupatches.wisefy.callbacks.SearchForAccessPointCallbacks import com.isupatches.wisefy.callbacks.SearchForAccessPointsCallbacks @@ -12,13 +11,11 @@ import com.isupatches.wisefy.callbacks.SearchForSavedNetworkCallbacks import com.isupatches.wisefy.callbacks.SearchForSavedNetworksCallbacks import com.isupatches.wisefysample.TEST_SSID_1 import com.isupatches.wisefysample.TEST_TIMEOUT - import com.nhaarman.mockitokotlin2.any import com.nhaarman.mockitokotlin2.eq import com.nhaarman.mockitokotlin2.mock import com.nhaarman.mockitokotlin2.times import com.nhaarman.mockitokotlin2.verify - import org.junit.Test internal class SearchModelTest { @@ -27,7 +24,8 @@ internal class SearchModelTest { private val model = SearchModel(wiseFy) - @Test fun searchForAccessPoint() { + @Test + fun searchForAccessPoint() { // When model.searchForAccessPoint(TEST_SSID_1, TEST_TIMEOUT, true, object : SearchForAccessPointCallbacks { override fun accessPointFound(accessPoint: ScanResult) { @@ -49,7 +47,8 @@ internal class SearchModelTest { ) } - @Test fun searchForAccessPoints() { + @Test + fun searchForAccessPoints() { // When model.searchForAccessPoints(TEST_SSID_1, true, object : SearchForAccessPointsCallbacks { override fun foundAccessPoints(accessPoints: List) { @@ -70,7 +69,8 @@ internal class SearchModelTest { ) } - @Test fun searchForSavedNetwork() { + @Test + fun searchForSavedNetwork() { // When model.searchForSavedNetwork(TEST_SSID_1, object : SearchForSavedNetworkCallbacks { override fun retrievedSavedNetwork(savedNetwork: WifiConfiguration) { @@ -87,7 +87,8 @@ internal class SearchModelTest { verify(wiseFy, times(1)).searchForSavedNetwork(eq(TEST_SSID_1), any()) } - @Test fun searchForSavedNetworks() { + @Test + fun searchForSavedNetworks() { // When model.searchForSavedNetworks(TEST_SSID_1, object : SearchForSavedNetworksCallbacks { override fun retrievedSavedNetworks(savedNetworks: List) { @@ -104,7 +105,8 @@ internal class SearchModelTest { verify(wiseFy, times(1)).searchForSavedNetworks(eq(TEST_SSID_1), any()) } - @Test fun searchForSSID() { + @Test + fun searchForSSID() { // When model.searchForSSID(TEST_SSID_1, TEST_TIMEOUT, object : SearchForSSIDCallbacks { override fun ssidFound(ssid: String) { @@ -125,7 +127,8 @@ internal class SearchModelTest { ) } - @Test fun searchForSSIDs() { + @Test + fun searchForSSIDs() { // When model.searchForSSIDs(TEST_SSID_1, object : SearchForSSIDsCallbacks { override fun retrievedSSIDs(ssids: List) { diff --git a/wisefysample/src/test/java/com/isupatches/wisefysample/ui/search/SearchPresenterTest.kt b/wisefysample/src/test/java/com/isupatches/wisefysample/ui/search/SearchPresenterTest.kt index 88fbf75c..53e919f7 100644 --- a/wisefysample/src/test/java/com/isupatches/wisefysample/ui/search/SearchPresenterTest.kt +++ b/wisefysample/src/test/java/com/isupatches/wisefysample/ui/search/SearchPresenterTest.kt @@ -2,7 +2,6 @@ package com.isupatches.wisefysample.ui.search import android.net.wifi.ScanResult import android.net.wifi.WifiConfiguration - import com.isupatches.wisefy.callbacks.SearchForAccessPointCallbacks import com.isupatches.wisefy.callbacks.SearchForAccessPointsCallbacks import com.isupatches.wisefy.callbacks.SearchForSSIDCallbacks @@ -13,7 +12,6 @@ import com.isupatches.wisefy.constants.MISSING_PARAMETER import com.isupatches.wisefysample.TEST_SSID_1 import com.isupatches.wisefysample.TEST_TIMEOUT import com.isupatches.wisefysample.TestRxSchedulersProvider - import com.nhaarman.mockitokotlin2.any import com.nhaarman.mockitokotlin2.doAnswer import com.nhaarman.mockitokotlin2.eq @@ -21,7 +19,6 @@ import com.nhaarman.mockitokotlin2.mock import com.nhaarman.mockitokotlin2.times import com.nhaarman.mockitokotlin2.verify import com.nhaarman.mockitokotlin2.whenever - import org.junit.After import org.junit.Before import org.junit.Test @@ -38,15 +35,18 @@ internal class SearchPresenterTest { private val ACCESS_POINT = mock() } - @Before fun setUp() { + @Before + fun setUp() { presenter.attachView(view) } - @After fun tearDown() { + @After + fun tearDown() { presenter.detachView() } - @Test fun searchForAccessPoint_accessPointFound() { + @Test + fun searchForAccessPoint_accessPointFound() { // Given doAnswer { invocationOnMock -> val callback = invocationOnMock.arguments[3] as SearchForAccessPointCallbacks @@ -61,7 +61,8 @@ internal class SearchPresenterTest { verify(view, times(1)).displayAccessPoint(ACCESS_POINT) } - @Test fun searchForAccessPoint_accessPointNotFound() { + @Test + fun searchForAccessPoint_accessPointNotFound() { // Given doAnswer { invocationOnMock -> val callback = invocationOnMock.arguments[3] as SearchForAccessPointCallbacks @@ -76,7 +77,8 @@ internal class SearchPresenterTest { verify(view, times(1)).displayAccessPointNotFound() } - @Test fun searchForAccessPoint_wisefyFailure() { + @Test + fun searchForAccessPoint_wisefyFailure() { // Given doAnswer { invocationOnMock -> val callback = invocationOnMock.arguments[3] as SearchForAccessPointCallbacks @@ -91,7 +93,8 @@ internal class SearchPresenterTest { verify(view, times(1)).displayWiseFyFailure(MISSING_PARAMETER) } - @Test fun searchForAccessPoints_foundAccessPoints() { + @Test + fun searchForAccessPoints_foundAccessPoints() { // Given doAnswer { invocationOnMock -> val callback = invocationOnMock.arguments[2] as SearchForAccessPointsCallbacks @@ -106,7 +109,8 @@ internal class SearchPresenterTest { verify(view, times(1)).displayAccessPoints(listOf(ACCESS_POINT)) } - @Test fun searchForAccessPoints_noAccessPointsFound() { + @Test + fun searchForAccessPoints_noAccessPointsFound() { // Given doAnswer { invocationOnMock -> val callback = invocationOnMock.arguments[2] as SearchForAccessPointsCallbacks @@ -121,7 +125,8 @@ internal class SearchPresenterTest { verify(view, times(1)).displayNoAccessPointsFound() } - @Test fun searchForAccessPoints_wisefyFailure() { + @Test + fun searchForAccessPoints_wisefyFailure() { // Given doAnswer { invocationOnMock -> val callback = invocationOnMock.arguments[2] as SearchForAccessPointsCallbacks @@ -136,7 +141,8 @@ internal class SearchPresenterTest { verify(view, times(1)).displayWiseFyFailure(MISSING_PARAMETER) } - @Test fun searchForSavedNetwork_retrievedSavedNetwork() { + @Test + fun searchForSavedNetwork_retrievedSavedNetwork() { // Given doAnswer { invocationOnMock -> val callback = invocationOnMock.arguments[1] as SearchForSavedNetworkCallbacks @@ -151,7 +157,8 @@ internal class SearchPresenterTest { verify(view, times(1)).displaySavedNetwork(SAVED_NETWORK) } - @Test fun searchForSavedNetwork_savedNetworkNotFound() { + @Test + fun searchForSavedNetwork_savedNetworkNotFound() { // Given doAnswer { invocationOnMock -> val callback = invocationOnMock.arguments[1] as SearchForSavedNetworkCallbacks @@ -166,7 +173,8 @@ internal class SearchPresenterTest { verify(view, times(1)).displaySavedNetworkNotFound() } - @Test fun searchForSavedNetwork_wisefyFailure() { + @Test + fun searchForSavedNetwork_wisefyFailure() { // Given doAnswer { invocationOnMock -> val callback = invocationOnMock.arguments[1] as SearchForSavedNetworkCallbacks @@ -181,7 +189,8 @@ internal class SearchPresenterTest { verify(view, times(1)).displayWiseFyFailure(MISSING_PARAMETER) } - @Test fun searchForSavedNetworks_retrievedSavedNetworks() { + @Test + fun searchForSavedNetworks_retrievedSavedNetworks() { // Given doAnswer { invocationOnMock -> val callback = invocationOnMock.arguments[1] as SearchForSavedNetworksCallbacks @@ -196,7 +205,8 @@ internal class SearchPresenterTest { verify(view, times(1)).displaySavedNetworks(listOf(SAVED_NETWORK)) } - @Test fun searchForSavedNetworks_noSavedNetworksFound() { + @Test + fun searchForSavedNetworks_noSavedNetworksFound() { // Given doAnswer { invocationOnMock -> val callback = invocationOnMock.arguments[1] as SearchForSavedNetworksCallbacks @@ -211,7 +221,8 @@ internal class SearchPresenterTest { verify(view, times(1)).displayNoSavedNetworksFound() } - @Test fun searchForSavedNetworks_wisefyFailure() { + @Test + fun searchForSavedNetworks_wisefyFailure() { // Given doAnswer { invocationOnMock -> val callback = invocationOnMock.arguments[1] as SearchForSavedNetworksCallbacks @@ -226,7 +237,8 @@ internal class SearchPresenterTest { verify(view, times(1)).displayWiseFyFailure(MISSING_PARAMETER) } - @Test fun searchForSSID_ssidFound() { + @Test + fun searchForSSID_ssidFound() { // Given doAnswer { invocationOnMock -> val callback = invocationOnMock.arguments[2] as SearchForSSIDCallbacks @@ -241,7 +253,8 @@ internal class SearchPresenterTest { verify(view, times(1)).displaySSID(TEST_SSID_1) } - @Test fun searchForSSID_ssidNotFound() { + @Test + fun searchForSSID_ssidNotFound() { // Then doAnswer { invocationOnMock -> val callback = invocationOnMock.arguments[2] as SearchForSSIDCallbacks @@ -256,7 +269,8 @@ internal class SearchPresenterTest { verify(view, times(1)).displaySSIDNotFound() } - @Test fun searchForSSID_wisefyFailure() { + @Test + fun searchForSSID_wisefyFailure() { // Given doAnswer { invocationOnMock -> val callback = invocationOnMock.arguments[2] as SearchForSSIDCallbacks @@ -271,7 +285,8 @@ internal class SearchPresenterTest { verify(view, times(1)).displayWiseFyFailure(MISSING_PARAMETER) } - @Test fun searchForSSIDs_retrievedSSIDs() { + @Test + fun searchForSSIDs_retrievedSSIDs() { // Given doAnswer { invocationOnMock -> val callback = invocationOnMock.arguments[1] as SearchForSSIDsCallbacks @@ -286,7 +301,8 @@ internal class SearchPresenterTest { verify(view, times(1)).displaySSIDs(listOf(TEST_SSID_1)) } - @Test fun searchForSSIDs_noSSIDsFound() { + @Test + fun searchForSSIDs_noSSIDsFound() { // Then doAnswer { invocationOnMock -> val callback = invocationOnMock.arguments[1] as SearchForSSIDsCallbacks @@ -301,7 +317,8 @@ internal class SearchPresenterTest { verify(view, times(1)).displayNoSSIDsFound() } - @Test fun searchForSSIDs_wisefyFailure() { + @Test + fun searchForSSIDs_wisefyFailure() { // Given doAnswer { invocationOnMock -> val callback = invocationOnMock.arguments[1] as SearchForSSIDsCallbacks