From 3fce18184d8523d59da27ffd32527da3a40324d1 Mon Sep 17 00:00:00 2001 From: isuPatches Date: Sun, 23 Jul 2017 08:05:47 -0500 Subject: [PATCH 01/74] Working on tavis.ci --- .travis.yml | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index 1ec588ac..b534dff6 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,18 +7,17 @@ android: - platform-tools - tools - build-tools-26.0.0 - - android-22 - android-26 - - sys-img-armeabi-v7a-android-22 + - sys-img-armeabi-v7a-android-26 - extra-android-m2repository - extra-android-support - extra-google-m2repository before_script: # Create and start emulator - - echo no | android create avd --force -n test -t android-22 --abi armeabi-v7a + - echo no | android create avd --force -n test -t android-26 --abi armeabi-v7a - emulator -avd test -no-skin -no-audio -no-window & - android-wait-for-emulator - adb shell input keyevent 82 & -script: travis_wait 90 ./gradlew clean connectedAndroidTest -PdisablePreDex --stacktrace \ No newline at end of file +script: travis_wait 60 ./gradlew clean connectedAndroidTest -PdisablePreDex --stacktrace \ No newline at end of file From 7757c030c35a13589d6ca3a049ccbebd7b64844b Mon Sep 17 00:00:00 2001 From: isuPatches Date: Sun, 23 Jul 2017 08:23:48 -0500 Subject: [PATCH 02/74] Another stab at travis --- .travis.yml | 27 +++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/.travis.yml b/.travis.yml index b534dff6..ad69a486 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,22 +2,37 @@ language: android jdk: oraclejdk8 sudo: false +cache: + directories: + - ${TRAVIS_BUILD_DIR}/gradle/caches/ + - ${TRAVIS_BUILD_DIR}/gradle/wrapper/dists/ + +env: + global: + - ANDROID_API_LEVEL=26 + - EMULATOR_API_LEVEL=26 + - ANDROID_BUILD_TOOLS_VERSION=26.0.0 + - ANDROID_ABI=armeabi-v7a + - ANDROID_TAG=google_apis + - ADB_INSTALL_TIMEOUT=20 # minutes (2 minutes by default) + android: components: + - tools - platform-tools - tools - - build-tools-26.0.0 - - android-26 - - sys-img-armeabi-v7a-android-26 + - build-tools-$ANDROID_BUILD_TOOLS_VERSION + - android-$ANDROID_API_LEVEL + - android-$EMULATOR_API_LEVEL + - sys-img-armeabi-v7a-google_apis-$ANDROID_API_LEVEL + - sys-img-armeabi-v7a-google_apis-$EMULATOR_API_LEVEL - extra-android-m2repository - extra-android-support - extra-google-m2repository before_script: - # Create and start emulator - - echo no | android create avd --force -n test -t android-26 --abi armeabi-v7a + - echo no | android create avd --force -n test -t "android-"$EMULATOR_API_LEVEL --abi $ANDROID_ABI - emulator -avd test -no-skin -no-audio -no-window & - android-wait-for-emulator - - adb shell input keyevent 82 & script: travis_wait 60 ./gradlew clean connectedAndroidTest -PdisablePreDex --stacktrace \ No newline at end of file From 9b08985be4189e0cb5b7268fbdbc0d2b7229342b Mon Sep 17 00:00:00 2001 From: isuPatches Date: Sun, 23 Jul 2017 08:29:49 -0500 Subject: [PATCH 03/74] Trying to adjust the ABI --- .travis.yml | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index ad69a486..3e264428 100644 --- a/.travis.yml +++ b/.travis.yml @@ -12,8 +12,7 @@ env: - ANDROID_API_LEVEL=26 - EMULATOR_API_LEVEL=26 - ANDROID_BUILD_TOOLS_VERSION=26.0.0 - - ANDROID_ABI=armeabi-v7a - - ANDROID_TAG=google_apis + - ANDROID_ABI=google_apis/armeabi-v7a - ADB_INSTALL_TIMEOUT=20 # minutes (2 minutes by default) android: @@ -24,8 +23,8 @@ android: - build-tools-$ANDROID_BUILD_TOOLS_VERSION - android-$ANDROID_API_LEVEL - android-$EMULATOR_API_LEVEL - - sys-img-armeabi-v7a-google_apis-$ANDROID_API_LEVEL - - sys-img-armeabi-v7a-google_apis-$EMULATOR_API_LEVEL + - sys-img-armeabi-v7a-addon-google_apis-google-$ANDROID_API_LEVEL + - sys-img-armeabi-v7a-addon-google_apis-google-$EMULATOR_API_LEVEL - extra-android-m2repository - extra-android-support - extra-google-m2repository From aa64cecd7987324855d166d2d4388e8124ef3186 Mon Sep 17 00:00:00 2001 From: isuPatches Date: Sun, 23 Jul 2017 08:35:16 -0500 Subject: [PATCH 04/74] Trying SDK 25 for travis --- .travis.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index 3e264428..0fab89ae 100644 --- a/.travis.yml +++ b/.travis.yml @@ -10,7 +10,7 @@ cache: env: global: - ANDROID_API_LEVEL=26 - - EMULATOR_API_LEVEL=26 + - EMULATOR_API_LEVEL=25 - ANDROID_BUILD_TOOLS_VERSION=26.0.0 - ANDROID_ABI=google_apis/armeabi-v7a - ADB_INSTALL_TIMEOUT=20 # minutes (2 minutes by default) @@ -23,8 +23,8 @@ android: - build-tools-$ANDROID_BUILD_TOOLS_VERSION - android-$ANDROID_API_LEVEL - android-$EMULATOR_API_LEVEL - - sys-img-armeabi-v7a-addon-google_apis-google-$ANDROID_API_LEVEL - - sys-img-armeabi-v7a-addon-google_apis-google-$EMULATOR_API_LEVEL + - sys-img-armeabi-v7a-android-$ANDROID_API_LEVEL + - sys-img-armeabi-v7a-android-$EMULATOR_API_LEVEL - extra-android-m2repository - extra-android-support - extra-google-m2repository From c268d5b956b020e2898ee0955c470010cf7994f7 Mon Sep 17 00:00:00 2001 From: isuPatches Date: Sun, 23 Jul 2017 08:38:38 -0500 Subject: [PATCH 05/74] Move to matrix --- .travis.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 0fab89ae..27e782fd 100644 --- a/.travis.yml +++ b/.travis.yml @@ -10,10 +10,12 @@ cache: env: global: - ANDROID_API_LEVEL=26 - - EMULATOR_API_LEVEL=25 - ANDROID_BUILD_TOOLS_VERSION=26.0.0 - - ANDROID_ABI=google_apis/armeabi-v7a - ADB_INSTALL_TIMEOUT=20 # minutes (2 minutes by default) + env: + matrix: + - EMULATOR_API_LEVEL=android-16 ANDROID_ABI=armeabi-v7a + - EMULATOR_API_LEVEL=android-25 ANDROID_ABI=armeabi-v7a android: components: From 7f58e07be945db7b249be6fba775bf25f29a2f5f Mon Sep 17 00:00:00 2001 From: isuPatches Date: Sun, 23 Jul 2017 08:49:17 -0500 Subject: [PATCH 06/74] Another travis adjustment --- .travis.yml | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/.travis.yml b/.travis.yml index 27e782fd..ccaaf1b5 100644 --- a/.travis.yml +++ b/.travis.yml @@ -9,31 +9,31 @@ cache: env: global: - - ANDROID_API_LEVEL=26 +# - ANDROID_MIN_API_LEVEL=16 +# - ANDROID_MAX_API_LEVEL=26 - ANDROID_BUILD_TOOLS_VERSION=26.0.0 - ADB_INSTALL_TIMEOUT=20 # minutes (2 minutes by default) - env: - matrix: - - EMULATOR_API_LEVEL=android-16 ANDROID_ABI=armeabi-v7a - - EMULATOR_API_LEVEL=android-25 ANDROID_ABI=armeabi-v7a + matrix: + - API=android-16 ABI=armeabi-v7a + - API=android-26 ABI=armeabi-v7a android: components: - tools - platform-tools - - tools - build-tools-$ANDROID_BUILD_TOOLS_VERSION - - android-$ANDROID_API_LEVEL - - android-$EMULATOR_API_LEVEL - - sys-img-armeabi-v7a-android-$ANDROID_API_LEVEL - - sys-img-armeabi-v7a-android-$EMULATOR_API_LEVEL + - android-16 + - android-26 - extra-android-m2repository - extra-android-support - extra-google-m2repository before_script: - - echo no | android create avd --force -n test -t "android-"$EMULATOR_API_LEVEL --abi $ANDROID_ABI - - emulator -avd test -no-skin -no-audio -no-window & + - android-update-sdk --components=sys-img-$ABI-$API --accept-licenses='android-sdk-license-[0-9a-f]{8}' + - echo no | android create avd --force -n test -t $API --abi $ABI + - emulator -avd test -no-audio -no-window - android-wait-for-emulator + - adb shell input keyevent 82 & -script: travis_wait 60 ./gradlew clean connectedAndroidTest -PdisablePreDex --stacktrace \ No newline at end of file +script: + - travis_wait 60 ./gradlew clean connectedAndroidTest -PdisablePreDex --stacktrace \ No newline at end of file From f116e88dcf28bbeef502ddb8cd43d0c4cc626b65 Mon Sep 17 00:00:00 2001 From: isuPatches Date: Sun, 23 Jul 2017 09:01:41 -0500 Subject: [PATCH 07/74] Trying another thing --- .travis.yml | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/.travis.yml b/.travis.yml index ccaaf1b5..b4d52bb3 100644 --- a/.travis.yml +++ b/.travis.yml @@ -9,21 +9,23 @@ cache: env: global: -# - ANDROID_MIN_API_LEVEL=16 -# - ANDROID_MAX_API_LEVEL=26 - - ANDROID_BUILD_TOOLS_VERSION=26.0.0 - - ADB_INSTALL_TIMEOUT=20 # minutes (2 minutes by default) + - ADB_INSTALL_TIMEOUT=20 + - BUILD_TOOLS_VERSION=26.0.0 + - SDK_LEVEL_MAX=26 + - SDK_LEVEL_MIN=16 matrix: - API=android-16 ABI=armeabi-v7a - - API=android-26 ABI=armeabi-v7a + - API=android-25 ABI=armeabi-v7a android: components: - tools - platform-tools - - build-tools-$ANDROID_BUILD_TOOLS_VERSION - - android-16 - - android-26 + - tools + - build-tools-$BUILD_TOOLS_VERSION + - android-SDK_LEVEL_MIN + - android-25 + - android-SDK_LEVEL_MAX - extra-android-m2repository - extra-android-support - extra-google-m2repository From 29486b0582815fc43e6356b38511556eb0313690 Mon Sep 17 00:00:00 2001 From: isuPatches Date: Sun, 23 Jul 2017 09:09:41 -0500 Subject: [PATCH 08/74] Trying another set of abis --- .travis.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index b4d52bb3..edadc5ee 100644 --- a/.travis.yml +++ b/.travis.yml @@ -14,8 +14,8 @@ env: - SDK_LEVEL_MAX=26 - SDK_LEVEL_MIN=16 matrix: - - API=android-16 ABI=armeabi-v7a - - API=android-25 ABI=armeabi-v7a + - API=android-16 ABI=x86 + - API=android-25 ABI=x86 android: components: @@ -31,7 +31,7 @@ android: - extra-google-m2repository before_script: - - android-update-sdk --components=sys-img-$ABI-$API --accept-licenses='android-sdk-license-[0-9a-f]{8}' + - android-update-sdk --components=sys-img-$ABI-google_apis-$API --accept-licenses='android-sdk-license-[0-9a-f]{8}' - echo no | android create avd --force -n test -t $API --abi $ABI - emulator -avd test -no-audio -no-window - android-wait-for-emulator From c99c985bed891aa56d672bc20e74e9a156e12998 Mon Sep 17 00:00:00 2001 From: isuPatches Date: Sun, 23 Jul 2017 09:18:17 -0500 Subject: [PATCH 09/74] Removing matrix --- .travis.yml | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/.travis.yml b/.travis.yml index edadc5ee..291aa341 100644 --- a/.travis.yml +++ b/.travis.yml @@ -9,31 +9,26 @@ cache: env: global: + - ABI=armeabi-v7a - ADB_INSTALL_TIMEOUT=20 - BUILD_TOOLS_VERSION=26.0.0 - - SDK_LEVEL_MAX=26 - - SDK_LEVEL_MIN=16 - matrix: - - API=android-16 ABI=x86 - - API=android-25 ABI=x86 + - EMULATOR_SDK_LEVEL=25 + - TARGET_SDK_LEVEL=26 android: components: - tools - platform-tools - - tools - build-tools-$BUILD_TOOLS_VERSION - - android-SDK_LEVEL_MIN - - android-25 - - android-SDK_LEVEL_MAX + - android-EMULATOR_SDK_LEVEL + - android-TARGET_SDK_LEVEL - extra-android-m2repository - extra-android-support - extra-google-m2repository before_script: - - android-update-sdk --components=sys-img-$ABI-google_apis-$API --accept-licenses='android-sdk-license-[0-9a-f]{8}' - - echo no | android create avd --force -n test -t $API --abi $ABI - - emulator -avd test -no-audio -no-window + - echo no | android create avd --force -n test -t android-$EMULATOR_SDK_LEVEL --abi $ABI + - emulator -avd test -no-audio -no-window & - android-wait-for-emulator - adb shell input keyevent 82 & From a3c5eef5d5b3a9623930575ff5e2c4707da98f1d Mon Sep 17 00:00:00 2001 From: isuPatches Date: Sun, 23 Jul 2017 09:23:13 -0500 Subject: [PATCH 10/74] Yet another travis adjustment --- .travis.yml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 291aa341..2aed7979 100644 --- a/.travis.yml +++ b/.travis.yml @@ -13,21 +13,25 @@ env: - ADB_INSTALL_TIMEOUT=20 - BUILD_TOOLS_VERSION=26.0.0 - EMULATOR_SDK_LEVEL=25 + - TAG=google_apis - TARGET_SDK_LEVEL=26 android: components: - tools - platform-tools + - tools - build-tools-$BUILD_TOOLS_VERSION - android-EMULATOR_SDK_LEVEL - android-TARGET_SDK_LEVEL + - sys-img-armeabi-v7a-addon-google_apis-google-EMULATOR_SDK_LEVEL + - sys-img-armeabi-v7a-addon-google_apis-google-TARGET_SDK_LEVEL - extra-android-m2repository - extra-android-support - extra-google-m2repository before_script: - - echo no | android create avd --force -n test -t android-$EMULATOR_SDK_LEVEL --abi $ABI + - echo no | android create avd --force -n test -t android-$EMULATOR_SDK_LEVEL --abi $ABI -tag $TAG - emulator -avd test -no-audio -no-window & - android-wait-for-emulator - adb shell input keyevent 82 & From 857c105bb82597f9264b65e47238e4ccf13d3183 Mon Sep 17 00:00:00 2001 From: isuPatches Date: Sun, 23 Jul 2017 09:24:38 -0500 Subject: [PATCH 11/74] Another tweak --- .travis.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 2aed7979..64fd5495 100644 --- a/.travis.yml +++ b/.travis.yml @@ -24,8 +24,8 @@ android: - build-tools-$BUILD_TOOLS_VERSION - android-EMULATOR_SDK_LEVEL - android-TARGET_SDK_LEVEL - - sys-img-armeabi-v7a-addon-google_apis-google-EMULATOR_SDK_LEVEL - - sys-img-armeabi-v7a-addon-google_apis-google-TARGET_SDK_LEVEL + - sys-img-$ABI-addon-google_apis-google-$EMULATOR_SDK_LEVEL + - sys-img-$ABI-addon-google_apis-google-$TARGET_SDK_LEVEL - extra-android-m2repository - extra-android-support - extra-google-m2repository From 96c0571451b6d7d13911376a6480431b50b1d4dc Mon Sep 17 00:00:00 2001 From: isuPatches Date: Sun, 23 Jul 2017 09:29:24 -0500 Subject: [PATCH 12/74] Missed a - --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 64fd5495..8a93cb4c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -31,7 +31,7 @@ android: - extra-google-m2repository before_script: - - echo no | android create avd --force -n test -t android-$EMULATOR_SDK_LEVEL --abi $ABI -tag $TAG + - echo no | android create avd --force -n test -t android-$EMULATOR_SDK_LEVEL --abi $ABI --tag $TAG - emulator -avd test -no-audio -no-window & - android-wait-for-emulator - adb shell input keyevent 82 & From 6cb6c3ffda6a0c27764e7b966a16f7b66e21ca23 Mon Sep 17 00:00:00 2001 From: isuPatches Date: Sun, 23 Jul 2017 09:33:19 -0500 Subject: [PATCH 13/74] I don't think travis has 26 yet --- .travis.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 8a93cb4c..620a2f29 100644 --- a/.travis.yml +++ b/.travis.yml @@ -25,7 +25,6 @@ android: - android-EMULATOR_SDK_LEVEL - android-TARGET_SDK_LEVEL - sys-img-$ABI-addon-google_apis-google-$EMULATOR_SDK_LEVEL - - sys-img-$ABI-addon-google_apis-google-$TARGET_SDK_LEVEL - extra-android-m2repository - extra-android-support - extra-google-m2repository From fd8e167efe81d3c54b37db50b10409fcdd64e4f2 Mon Sep 17 00:00:00 2001 From: isuPatches Date: Sun, 23 Jul 2017 09:37:23 -0500 Subject: [PATCH 14/74] More adjustments --- .travis.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index 620a2f29..86351740 100644 --- a/.travis.yml +++ b/.travis.yml @@ -22,9 +22,9 @@ android: - platform-tools - tools - build-tools-$BUILD_TOOLS_VERSION - - android-EMULATOR_SDK_LEVEL - - android-TARGET_SDK_LEVEL - - sys-img-$ABI-addon-google_apis-google-$EMULATOR_SDK_LEVEL + - android-$EMULATOR_SDK_LEVEL + - android-$TARGET_SDK_LEVEL + - sys-img-$ABI-google_apis-$EMULATOR_SDK_LEVEL - extra-android-m2repository - extra-android-support - extra-google-m2repository From 5a2ac608a9d11e7f48641b4086b0548984d1cee2 Mon Sep 17 00:00:00 2001 From: isuPatches Date: Sun, 23 Jul 2017 09:49:36 -0500 Subject: [PATCH 15/74] More travis fun --- .travis.yml | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/.travis.yml b/.travis.yml index 86351740..75be95bf 100644 --- a/.travis.yml +++ b/.travis.yml @@ -8,11 +8,12 @@ cache: - ${TRAVIS_BUILD_DIR}/gradle/wrapper/dists/ env: + matrix: + - EMULATOR_SDK_LEVEL=16 ABI=armeabi-v7a + - EMULATOR_SDK_LEVEL=25 ABI=armeabi-v7a global: - - ABI=armeabi-v7a - ADB_INSTALL_TIMEOUT=20 - BUILD_TOOLS_VERSION=26.0.0 - - EMULATOR_SDK_LEVEL=25 - TAG=google_apis - TARGET_SDK_LEVEL=26 @@ -20,7 +21,6 @@ android: components: - tools - platform-tools - - tools - build-tools-$BUILD_TOOLS_VERSION - android-$EMULATOR_SDK_LEVEL - android-$TARGET_SDK_LEVEL @@ -31,9 +31,12 @@ android: before_script: - echo no | android create avd --force -n test -t android-$EMULATOR_SDK_LEVEL --abi $ABI --tag $TAG - - emulator -avd test -no-audio -no-window & + - emulator -avd test -no-skin -no-audio -no-window & - android-wait-for-emulator - adb shell input keyevent 82 & script: - - travis_wait 60 ./gradlew clean connectedAndroidTest -PdisablePreDex --stacktrace \ No newline at end of file + - travis_wait 60 ./gradlew clean jacocoDebugTestReport -PdisablePreDex --stacktrace + +after_success: + - bash <(curl -s https://codecov.io/bash) \ No newline at end of file From 4eb22cc544f73064cc8fd71c861b21e2591e63f1 Mon Sep 17 00:00:00 2001 From: isuPatches Date: Sun, 23 Jul 2017 10:04:53 -0500 Subject: [PATCH 16/74] Trying to speed up travis --- .travis.yml | 6 +++--- build.gradle | 4 ++++ wisefy/build.gradle | 5 +++++ 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index 75be95bf..62e376a2 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,6 +1,6 @@ language: android jdk: oraclejdk8 -sudo: false +sudo: required cache: directories: @@ -31,12 +31,12 @@ android: before_script: - echo no | android create avd --force -n test -t android-$EMULATOR_SDK_LEVEL --abi $ABI --tag $TAG - - emulator -avd test -no-skin -no-audio -no-window & + - emulator -avd test -no-audio -no-window & - android-wait-for-emulator - adb shell input keyevent 82 & script: - - travis_wait 60 ./gradlew clean jacocoDebugTestReport -PdisablePreDex --stacktrace + - travis_wait 60 ./gradlew clean jacocoDebugTestReport --stacktrace after_success: - bash <(curl -s https://codecov.io/bash) \ No newline at end of file diff --git a/build.gradle b/build.gradle index 9991176b..14f65f8b 100644 --- a/build.gradle +++ b/build.gradle @@ -45,6 +45,10 @@ subprojects { } ext { + travisBuild = System.getenv("TRAVIS") == "true" + // allows for -Dpre-dex=false to be set + preDexEnabled = "true".equals(System.getProperty("pre-dex", "true")) + GROUP = "com.isupatches" VERSION_NAME = "2.0.0" diff --git a/wisefy/build.gradle b/wisefy/build.gradle index 30457742..f32957ed 100644 --- a/wisefy/build.gradle +++ b/wisefy/build.gradle @@ -15,6 +15,11 @@ dexcount { android { + dexOptions { + // Skip pre-dexing when running on Travis CI or when disabled via -Dpre-dex=false. + preDexLibraries = preDexEnabled && !travisBuild + } + adbOptions { timeOutInMs 15 * 60 * 1000 // 15 minutes installOptions "-d","-t" From c9db56bfbaca1f39878adde072983de83aa6fe28 Mon Sep 17 00:00:00 2001 From: isuPatches Date: Sun, 23 Jul 2017 10:14:00 -0500 Subject: [PATCH 17/74] More playing around with travis --- .travis.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 62e376a2..71f0222b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -19,7 +19,8 @@ env: android: components: - - tools + - tools # to get the new `repository-11.xml` + - tools # to install Android SDK tools 25.1.x (x = 6 right now) - platform-tools - build-tools-$BUILD_TOOLS_VERSION - android-$EMULATOR_SDK_LEVEL @@ -31,7 +32,7 @@ android: before_script: - echo no | android create avd --force -n test -t android-$EMULATOR_SDK_LEVEL --abi $ABI --tag $TAG - - emulator -avd test -no-audio -no-window & + - emulator -avd test -no-skin -no-audio -no-window -gpu off -no-boot-anim & - android-wait-for-emulator - adb shell input keyevent 82 & From 8caea6143d1d68a79f80bf6b18909aa8dbeaa15a Mon Sep 17 00:00:00 2001 From: isuPatches Date: Sun, 23 Jul 2017 10:23:20 -0500 Subject: [PATCH 18/74] More speed adjustments --- .travis.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index 71f0222b..578b5591 100644 --- a/.travis.yml +++ b/.travis.yml @@ -25,14 +25,14 @@ android: - build-tools-$BUILD_TOOLS_VERSION - android-$EMULATOR_SDK_LEVEL - android-$TARGET_SDK_LEVEL - - sys-img-$ABI-google_apis-$EMULATOR_SDK_LEVEL - extra-android-m2repository - extra-android-support - extra-google-m2repository before_script: - - echo no | android create avd --force -n test -t android-$EMULATOR_SDK_LEVEL --abi $ABI --tag $TAG - - emulator -avd test -no-skin -no-audio -no-window -gpu off -no-boot-anim & + - android-update-sdk --components=sys-img-$ABI-google_apis-$EMULATOR_SDK_LEVEL --accept-licenses='android-sdk-license-[0-9a-f]{8}' + - echo no | android create avd --force -n test -t $EMULATOR_SDK_LEVEL --abi $ABI + - emulator -avd test -no-audio -no-window - android-wait-for-emulator - adb shell input keyevent 82 & From ba806d167613301aa7248a8d70ce46fdb899e331 Mon Sep 17 00:00:00 2001 From: isuPatches Date: Sun, 23 Jul 2017 10:29:40 -0500 Subject: [PATCH 19/74] Please work --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 578b5591..6aeb2eb3 100644 --- a/.travis.yml +++ b/.travis.yml @@ -25,12 +25,12 @@ android: - build-tools-$BUILD_TOOLS_VERSION - android-$EMULATOR_SDK_LEVEL - android-$TARGET_SDK_LEVEL + - sys-img-$ABI-google_apis-$EMULATOR_SDK_LEVEL - extra-android-m2repository - extra-android-support - extra-google-m2repository before_script: - - android-update-sdk --components=sys-img-$ABI-google_apis-$EMULATOR_SDK_LEVEL --accept-licenses='android-sdk-license-[0-9a-f]{8}' - echo no | android create avd --force -n test -t $EMULATOR_SDK_LEVEL --abi $ABI - emulator -avd test -no-audio -no-window - android-wait-for-emulator From c1f6d6aac1c605362e57a4bb3e0966b771298ff2 Mon Sep 17 00:00:00 2001 From: isuPatches Date: Sun, 23 Jul 2017 10:37:20 -0500 Subject: [PATCH 20/74] Please please please work... --- .travis.yml | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/.travis.yml b/.travis.yml index 6aeb2eb3..408bfb3e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -14,14 +14,13 @@ env: global: - ADB_INSTALL_TIMEOUT=20 - BUILD_TOOLS_VERSION=26.0.0 - - TAG=google_apis - TARGET_SDK_LEVEL=26 android: components: - - tools # to get the new `repository-11.xml` - - tools # to install Android SDK tools 25.1.x (x = 6 right now) + - tools - platform-tools + - tools # (Not a typo. See https://docs.travis-ci.com/user/languages/android/, this is supposed to appear twice) - build-tools-$BUILD_TOOLS_VERSION - android-$EMULATOR_SDK_LEVEL - android-$TARGET_SDK_LEVEL @@ -31,8 +30,8 @@ android: - extra-google-m2repository before_script: - - echo no | android create avd --force -n test -t $EMULATOR_SDK_LEVEL --abi $ABI - - emulator -avd test -no-audio -no-window + - echo no | android create avd --force -n test -t android-$EMULATOR_SDK_LEVEL --abi $ABI + - emulator -avd test -no-audio -no-window & - android-wait-for-emulator - adb shell input keyevent 82 & From 263e5eebe0d06fb7fcb25628866c7b83f7e9fab1 Mon Sep 17 00:00:00 2001 From: isuPatches Date: Sun, 23 Jul 2017 10:44:44 -0500 Subject: [PATCH 21/74] More poking at Travis --- .travis.yml | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/.travis.yml b/.travis.yml index 408bfb3e..994c9444 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,11 +1,16 @@ language: android jdk: oraclejdk8 -sudo: required +sudo: false cache: directories: - ${TRAVIS_BUILD_DIR}/gradle/caches/ - ${TRAVIS_BUILD_DIR}/gradle/wrapper/dists/ + - $HOME/.gradle/caches/3.5 + - $HOME/.gradle/caches/jars-1 + - $HOME/.gradle/daemon + - $HOME/.gradle/native + - $HOME/.gradle/wrapper env: matrix: @@ -30,13 +35,15 @@ android: - extra-google-m2repository before_script: - - echo no | android create avd --force -n test -t android-$EMULATOR_SDK_LEVEL --abi $ABI - - emulator -avd test -no-audio -no-window & + - echo no | android create avd --force --name test --target $EMULATOR_SDK_LEVEL --abi $ABI + - emulator -avd test -no-audio -no-window & + - ./gradlew check -PdisablePreDex --continue --stacktrace - android-wait-for-emulator - - adb shell input keyevent 82 & + - adb devices + - adb shell input keyevent 82 & script: - - travis_wait 60 ./gradlew clean jacocoDebugTestReport --stacktrace + - travis_wait 60 ./gradlew clean jacocoDebugTestReport -PdisablePreDex --stacktrace after_success: - bash <(curl -s https://codecov.io/bash) \ No newline at end of file From 57526ec35d24e4ccdb0c1d69c7b3689e63441ffa Mon Sep 17 00:00:00 2001 From: isuPatches Date: Sun, 23 Jul 2017 10:47:26 -0500 Subject: [PATCH 22/74] More speed things --- .travis.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 994c9444..2f7cb77b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -43,7 +43,9 @@ before_script: - adb shell input keyevent 82 & script: - - travis_wait 60 ./gradlew clean jacocoDebugTestReport -PdisablePreDex --stacktrace + - travis_wait 60 ./gradlew connectedAndroidTest -PdisablePreDex --stacktrace after_success: - - bash <(curl -s https://codecov.io/bash) \ No newline at end of file + - ./gradlew jacocoDebugReport + - pip install --user codecov + - codecov \ No newline at end of file From 2118037604dc864df4ff52c8333e5fbf32729a70 Mon Sep 17 00:00:00 2001 From: isuPatches Date: Sun, 23 Jul 2017 10:50:36 -0500 Subject: [PATCH 23/74] Needed android- here --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 2f7cb77b..87d23b9f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -35,7 +35,7 @@ android: - extra-google-m2repository before_script: - - echo no | android create avd --force --name test --target $EMULATOR_SDK_LEVEL --abi $ABI + - echo no | android create avd --force --name test --target android-$EMULATOR_SDK_LEVEL --abi $ABI - emulator -avd test -no-audio -no-window & - ./gradlew check -PdisablePreDex --continue --stacktrace - android-wait-for-emulator From c629f5238c8014a64a7cee0b9811ecb31d28689f Mon Sep 17 00:00:00 2001 From: isuPatches Date: Sun, 23 Jul 2017 10:56:24 -0500 Subject: [PATCH 24/74] Add back tag --- .travis.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 87d23b9f..7e285a45 100644 --- a/.travis.yml +++ b/.travis.yml @@ -19,6 +19,7 @@ env: global: - ADB_INSTALL_TIMEOUT=20 - BUILD_TOOLS_VERSION=26.0.0 + - TAG=google_apis - TARGET_SDK_LEVEL=26 android: @@ -35,7 +36,7 @@ android: - extra-google-m2repository before_script: - - echo no | android create avd --force --name test --target android-$EMULATOR_SDK_LEVEL --abi $ABI + - echo no | android create avd --force --name test --target android-$EMULATOR_SDK_LEVEL --abi $ABI --tag $TAG - emulator -avd test -no-audio -no-window & - ./gradlew check -PdisablePreDex --continue --stacktrace - android-wait-for-emulator From 4ebb68715b58872c405da6689c416e21ad0e6e9a Mon Sep 17 00:00:00 2001 From: isuPatches Date: Sun, 23 Jul 2017 11:03:07 -0500 Subject: [PATCH 25/74] Change back & --- .travis.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 7e285a45..66505809 100644 --- a/.travis.yml +++ b/.travis.yml @@ -37,11 +37,11 @@ android: before_script: - echo no | android create avd --force --name test --target android-$EMULATOR_SDK_LEVEL --abi $ABI --tag $TAG - - emulator -avd test -no-audio -no-window & + - emulator -avd test -no-audio -no-window & - ./gradlew check -PdisablePreDex --continue --stacktrace - android-wait-for-emulator - adb devices - - adb shell input keyevent 82 & + - adb shell input keyevent 82 & script: - travis_wait 60 ./gradlew connectedAndroidTest -PdisablePreDex --stacktrace From 9886f7218a7729b4b9b29e943f0db6c2ca9c77d2 Mon Sep 17 00:00:00 2001 From: isuPatches Date: Sun, 23 Jul 2017 11:15:00 -0500 Subject: [PATCH 26/74] Needed -android in another spot I think --- .travis.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 66505809..2760380f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -30,13 +30,13 @@ android: - build-tools-$BUILD_TOOLS_VERSION - android-$EMULATOR_SDK_LEVEL - android-$TARGET_SDK_LEVEL - - sys-img-$ABI-google_apis-$EMULATOR_SDK_LEVEL + - sys-img-$ABI-google_apis-android-$EMULATOR_SDK_LEVEL - extra-android-m2repository - extra-android-support - extra-google-m2repository before_script: - - echo no | android create avd --force --name test --target android-$EMULATOR_SDK_LEVEL --abi $ABI --tag $TAG + - echo no | android create avd --force --name test --target android-$EMULATOR_SDK_LEVEL --abi $ABI - emulator -avd test -no-audio -no-window & - ./gradlew check -PdisablePreDex --continue --stacktrace - android-wait-for-emulator From 441c1967bcdefdac66c37272cab2675c7bd98e52 Mon Sep 17 00:00:00 2001 From: isuPatches Date: Sun, 23 Jul 2017 11:23:49 -0500 Subject: [PATCH 27/74] Trying another thing --- .travis.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 2760380f..4d7dabad 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,6 +1,9 @@ language: android jdk: oraclejdk8 -sudo: false +sudo: required +dist: trusty + +group: edge cache: directories: From 7c9bc279dd89d1cb1f3bf4d8153059240ac109a2 Mon Sep 17 00:00:00 2001 From: isuPatches Date: Sun, 23 Jul 2017 11:29:31 -0500 Subject: [PATCH 28/74] Trying sans Google APIs --- .travis.yml | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index 4d7dabad..60c70232 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,7 +3,7 @@ jdk: oraclejdk8 sudo: required dist: trusty -group: edge +group: edge cache: directories: @@ -18,11 +18,10 @@ cache: env: matrix: - EMULATOR_SDK_LEVEL=16 ABI=armeabi-v7a - - EMULATOR_SDK_LEVEL=25 ABI=armeabi-v7a + - EMULATOR_SDK_LEVEL=24 ABI=armeabi-v7a global: - ADB_INSTALL_TIMEOUT=20 - BUILD_TOOLS_VERSION=26.0.0 - - TAG=google_apis - TARGET_SDK_LEVEL=26 android: @@ -33,7 +32,7 @@ android: - build-tools-$BUILD_TOOLS_VERSION - android-$EMULATOR_SDK_LEVEL - android-$TARGET_SDK_LEVEL - - sys-img-$ABI-google_apis-android-$EMULATOR_SDK_LEVEL + - sys-img-$ABI-android-$EMULATOR_SDK_LEVEL - extra-android-m2repository - extra-android-support - extra-google-m2repository From 5d79110788fb959d6cf4565bc845f9464be8438b Mon Sep 17 00:00:00 2001 From: isuPatches Date: Sun, 23 Jul 2017 11:45:31 -0500 Subject: [PATCH 29/74] Trial for SDK 24 --- .travis.yml | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/.travis.yml b/.travis.yml index 60c70232..ad419238 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,8 +3,6 @@ jdk: oraclejdk8 sudo: required dist: trusty -group: edge - cache: directories: - ${TRAVIS_BUILD_DIR}/gradle/caches/ @@ -26,9 +24,6 @@ env: android: components: - - tools - - platform-tools - - tools # (Not a typo. See https://docs.travis-ci.com/user/languages/android/, this is supposed to appear twice) - build-tools-$BUILD_TOOLS_VERSION - android-$EMULATOR_SDK_LEVEL - android-$TARGET_SDK_LEVEL @@ -40,13 +35,13 @@ android: before_script: - echo no | android create avd --force --name test --target android-$EMULATOR_SDK_LEVEL --abi $ABI - emulator -avd test -no-audio -no-window & - - ./gradlew check -PdisablePreDex --continue --stacktrace + - ./gradlew check --continue --stacktrace - android-wait-for-emulator - adb devices - adb shell input keyevent 82 & script: - - travis_wait 60 ./gradlew connectedAndroidTest -PdisablePreDex --stacktrace + - travis_wait 60 ./gradlew connectedAndroidTest --stacktrace after_success: - ./gradlew jacocoDebugReport From 300ad43ff6b4d10933b9308e049c6bcb08be3bfc Mon Sep 17 00:00:00 2001 From: isuPatches Date: Sun, 23 Jul 2017 11:56:07 -0500 Subject: [PATCH 30/74] Trying more things --- .travis.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index ad419238..4f15c045 100644 --- a/.travis.yml +++ b/.travis.yml @@ -14,9 +14,10 @@ cache: - $HOME/.gradle/wrapper env: + - ANDROID_NDK_HOME= matrix: - EMULATOR_SDK_LEVEL=16 ABI=armeabi-v7a - - EMULATOR_SDK_LEVEL=24 ABI=armeabi-v7a + - EMULATOR_SDK_LEVEL=22 ABI=armeabi-v7a global: - ADB_INSTALL_TIMEOUT=20 - BUILD_TOOLS_VERSION=26.0.0 From ba8ee1fd3bf6374834a61cb3a1409e3dda83b807 Mon Sep 17 00:00:00 2001 From: isuPatches Date: Sun, 23 Jul 2017 11:58:12 -0500 Subject: [PATCH 31/74] Going back to what works --- .travis.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 4f15c045..246bf366 100644 --- a/.travis.yml +++ b/.travis.yml @@ -14,9 +14,7 @@ cache: - $HOME/.gradle/wrapper env: - - ANDROID_NDK_HOME= matrix: - - EMULATOR_SDK_LEVEL=16 ABI=armeabi-v7a - EMULATOR_SDK_LEVEL=22 ABI=armeabi-v7a global: - ADB_INSTALL_TIMEOUT=20 From a2abe7b0f6d259172751aa556eb4ec894a704f3f Mon Sep 17 00:00:00 2001 From: isuPatches Date: Sun, 23 Jul 2017 12:11:55 -0500 Subject: [PATCH 32/74] Trying sudo false --- .travis.yml | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/.travis.yml b/.travis.yml index 246bf366..4cd50477 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,21 +1,17 @@ language: android jdk: oraclejdk8 -sudo: required +sudo: false dist: trusty cache: directories: - ${TRAVIS_BUILD_DIR}/gradle/caches/ - ${TRAVIS_BUILD_DIR}/gradle/wrapper/dists/ - - $HOME/.gradle/caches/3.5 - - $HOME/.gradle/caches/jars-1 - - $HOME/.gradle/daemon - - $HOME/.gradle/native - - $HOME/.gradle/wrapper env: matrix: - - EMULATOR_SDK_LEVEL=22 ABI=armeabi-v7a + - EMULATOR_SDK_LEVEL=16 ABI=armeabi-v7a + - EMULATOR_SDK_LEVEL=24 ABI=armeabi-v7a global: - ADB_INSTALL_TIMEOUT=20 - BUILD_TOOLS_VERSION=26.0.0 From 4b6d695008e4475b1c6c6d6a71afa1c5fbb8b1cf Mon Sep 17 00:00:00 2001 From: isuPatches Date: Sun, 23 Jul 2017 12:20:18 -0500 Subject: [PATCH 33/74] More adjustments --- .travis.yml | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/.travis.yml b/.travis.yml index 4cd50477..7e628540 100644 --- a/.travis.yml +++ b/.travis.yml @@ -19,18 +19,19 @@ env: android: components: - - build-tools-$BUILD_TOOLS_VERSION - - android-$EMULATOR_SDK_LEVEL - - android-$TARGET_SDK_LEVEL - - sys-img-$ABI-android-$EMULATOR_SDK_LEVEL + - tools + - platform-tools + - build-tools-${BUILD_TOOLS_VERSION} + - android-${EMULATOR_SDK_LEVEL} + - android-${TARGET_SDK_LEVEL} - extra-android-m2repository - extra-android-support - extra-google-m2repository + - sys-img-${ABI}-${EMULATOR_SDK_LEVEL} before_script: - echo no | android create avd --force --name test --target android-$EMULATOR_SDK_LEVEL --abi $ABI - emulator -avd test -no-audio -no-window & - - ./gradlew check --continue --stacktrace - android-wait-for-emulator - adb devices - adb shell input keyevent 82 & @@ -39,6 +40,4 @@ script: - travis_wait 60 ./gradlew connectedAndroidTest --stacktrace after_success: - - ./gradlew jacocoDebugReport - - pip install --user codecov - - codecov \ No newline at end of file + - bash <(curl -s https://codecov.io/bash) \ No newline at end of file From c7684bddb53a333a82f6a8cefb0dd8eafdef6040 Mon Sep 17 00:00:00 2001 From: isuPatches Date: Sun, 23 Jul 2017 12:24:29 -0500 Subject: [PATCH 34/74] Sanity check --- .travis.yml | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index 7e628540..2bea71e1 100644 --- a/.travis.yml +++ b/.travis.yml @@ -21,13 +21,13 @@ android: components: - tools - platform-tools - - build-tools-${BUILD_TOOLS_VERSION} - - android-${EMULATOR_SDK_LEVEL} - - android-${TARGET_SDK_LEVEL} + - build-tools-$BUILD_TOOLS_VERSION + - android-$EMULATOR_SDK_LEVEL + - android-$TARGET_SDK_LEVEL - extra-android-m2repository - extra-android-support - extra-google-m2repository - - sys-img-${ABI}-${EMULATOR_SDK_LEVEL} + - sys-img-$ABI-$EMULATOR_SDK_LEVEL before_script: - echo no | android create avd --force --name test --target android-$EMULATOR_SDK_LEVEL --abi $ABI @@ -38,6 +38,7 @@ before_script: script: - travis_wait 60 ./gradlew connectedAndroidTest --stacktrace + - ./gradlew jacocoDebugReport after_success: - bash <(curl -s https://codecov.io/bash) \ No newline at end of file From 7ba6a77db23401927565687018864f04c48fe49e Mon Sep 17 00:00:00 2001 From: isuPatches Date: Sun, 23 Jul 2017 12:33:06 -0500 Subject: [PATCH 35/74] Fighting with travis still --- .travis.yml | 38 ++++++++++++-------------------------- 1 file changed, 12 insertions(+), 26 deletions(-) diff --git a/.travis.yml b/.travis.yml index 2bea71e1..5b40aa1e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,19 +1,10 @@ language: android jdk: oraclejdk8 -sudo: false -dist: trusty - -cache: - directories: - - ${TRAVIS_BUILD_DIR}/gradle/caches/ - - ${TRAVIS_BUILD_DIR}/gradle/wrapper/dists/ env: - matrix: - - EMULATOR_SDK_LEVEL=16 ABI=armeabi-v7a - - EMULATOR_SDK_LEVEL=24 ABI=armeabi-v7a global: - - ADB_INSTALL_TIMEOUT=20 + - ANDROID_TARGET=android-23 + - ANDROID_ABI=armeabi-v7a - BUILD_TOOLS_VERSION=26.0.0 - TARGET_SDK_LEVEL=26 @@ -21,24 +12,19 @@ android: components: - tools - platform-tools - - build-tools-$BUILD_TOOLS_VERSION - - android-$EMULATOR_SDK_LEVEL - - android-$TARGET_SDK_LEVEL + - build-tools-${BUILD_TOOLS_VERSION} + - android-23 + - android-${TARGET_SDK_LEVEL} - extra-android-m2repository - - extra-android-support - - extra-google-m2repository - - sys-img-$ABI-$EMULATOR_SDK_LEVEL - -before_script: - - echo no | android create avd --force --name test --target android-$EMULATOR_SDK_LEVEL --abi $ABI - - emulator -avd test -no-audio -no-window & - - android-wait-for-emulator - - adb devices - - adb shell input keyevent 82 & + - sys-img-${ANDROID_ABI}-${ANDROID_TARGET} script: - - travis_wait 60 ./gradlew connectedAndroidTest --stacktrace - - ./gradlew jacocoDebugReport + - ./gradlew build jacocoDebugTestReport assembleAndroidTest + - echo no | android create avd --force -n test -t $ANDROID_TARGET --abi $ANDROID_ABI + - emulator -avd test -no-skin -no-audio -no-window & + - android-wait-for-emulator + - adb shell setprop dalvik.vm.dexopt-flags v=n,o=v + - ./gradlew connectedCheck after_success: - bash <(curl -s https://codecov.io/bash) \ No newline at end of file From f54bfd625162fda9ccf79b3c1431381f08256f57 Mon Sep 17 00:00:00 2001 From: isuPatches Date: Sun, 23 Jul 2017 12:38:14 -0500 Subject: [PATCH 36/74] Ugh... --- .travis.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 5b40aa1e..da007a57 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,5 +1,6 @@ language: android jdk: oraclejdk8 +sudo: false env: global: @@ -19,12 +20,12 @@ android: - sys-img-${ANDROID_ABI}-${ANDROID_TARGET} script: - - ./gradlew build jacocoDebugTestReport assembleAndroidTest + - ./gradlew clean connectedDebugAndroidTest - echo no | android create avd --force -n test -t $ANDROID_TARGET --abi $ANDROID_ABI - emulator -avd test -no-skin -no-audio -no-window & - android-wait-for-emulator - adb shell setprop dalvik.vm.dexopt-flags v=n,o=v - - ./gradlew connectedCheck + - ./gradlew jacocoDebugReport after_success: - bash <(curl -s https://codecov.io/bash) \ No newline at end of file From 064443a3c2fdc513bf71effbe58e2d70e912025b Mon Sep 17 00:00:00 2001 From: isuPatches Date: Sun, 23 Jul 2017 12:41:44 -0500 Subject: [PATCH 37/74] Order of operations thing --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index da007a57..93d04c68 100644 --- a/.travis.yml +++ b/.travis.yml @@ -20,11 +20,11 @@ android: - sys-img-${ANDROID_ABI}-${ANDROID_TARGET} script: - - ./gradlew clean connectedDebugAndroidTest - echo no | android create avd --force -n test -t $ANDROID_TARGET --abi $ANDROID_ABI - emulator -avd test -no-skin -no-audio -no-window & - android-wait-for-emulator - adb shell setprop dalvik.vm.dexopt-flags v=n,o=v + - ./gradlew clean connectedDebugAndroidTest - ./gradlew jacocoDebugReport after_success: From e1fc49a2e573212ccae4d0969399ae66ecf5cf55 Mon Sep 17 00:00:00 2001 From: isuPatches Date: Sun, 23 Jul 2017 12:59:43 -0500 Subject: [PATCH 38/74] Reverting with a few minor changes --- .travis.yml | 30 ++++++++++++++---------------- 1 file changed, 14 insertions(+), 16 deletions(-) diff --git a/.travis.yml b/.travis.yml index 93d04c68..9a8daf87 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,29 +2,27 @@ language: android jdk: oraclejdk8 sudo: false -env: - global: - - ANDROID_TARGET=android-23 - - ANDROID_ABI=armeabi-v7a - - BUILD_TOOLS_VERSION=26.0.0 - - TARGET_SDK_LEVEL=26 - android: components: - - tools - platform-tools - - build-tools-${BUILD_TOOLS_VERSION} - - android-23 - - android-${TARGET_SDK_LEVEL} + - tools + - build-tools-26.0.0 + - android-22 + - android-26 + - sys-img-armeabi-v7a-android-22 - extra-android-m2repository - - sys-img-${ANDROID_ABI}-${ANDROID_TARGET} + - extra-android-support + - extra-google-m2repository -script: - - echo no | android create avd --force -n test -t $ANDROID_TARGET --abi $ANDROID_ABI +before_script: + # Create and start emulator + - echo no | android create avd --force -n test -t android-22 --abi armeabi-v7a - emulator -avd test -no-skin -no-audio -no-window & - android-wait-for-emulator - - adb shell setprop dalvik.vm.dexopt-flags v=n,o=v - - ./gradlew clean connectedDebugAndroidTest + - adb shell input keyevent 82 & + +script: + - travis_wait 90 ./gradlew clean connectedDebugAndroidTest --stacktrace - ./gradlew jacocoDebugReport after_success: From 1573fb618ba44e53a35e2000169e7b01015fd56b Mon Sep 17 00:00:00 2001 From: isuPatches Date: Sun, 23 Jul 2017 13:17:17 -0500 Subject: [PATCH 39/74] Still trying some more things --- .travis.yml | 29 ++++++++++++++++++++++------- 1 file changed, 22 insertions(+), 7 deletions(-) diff --git a/.travis.yml b/.travis.yml index 9a8daf87..93e8df0c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,28 +1,43 @@ language: android jdk: oraclejdk8 -sudo: false + +sudo: required +dist: precise android: components: - platform-tools - tools - build-tools-26.0.0 - - android-22 - android-26 - - sys-img-armeabi-v7a-android-22 +# - sys-img-armeabi-v7a-android-22 - extra-android-m2repository - extra-android-support - extra-google-m2repository +env: + matrix: + - API=android-16 ABI=armeabi-v7a +# - API=android-17 ABI=armeabi-v7a +# - API=android-18 ABI=armeabi-v7a +# - API=android-19 ABI=armeabi-v7a +# - API=android-20 ABI=armeabi-v7a +# - API=android-21 ABI=armeabi-v7a +# - API=android-22 ABI=armeabi-v7a +# - API=android-24 ABI=armeabi-v7a +# - API=android-25 ABI=armeabi-v7a + - API=android-26 ABI=armeabi-v7a + before_script: - # Create and start emulator - - echo no | android create avd --force -n test -t android-22 --abi armeabi-v7a - - emulator -avd test -no-skin -no-audio -no-window & + - android-update-sdk --components=sys-img-$ABI-$API --accept-licenses='android-sdk-license-[0-9a-f]{8}' + - echo no | android create avd --force -n test -t $API --abi $ABI + - emulator -avd test -no-audio -no-window + - ./gradlew clean assembleDebug assembleDebugAndroidTest - android-wait-for-emulator - adb shell input keyevent 82 & script: - - travis_wait 90 ./gradlew clean connectedDebugAndroidTest --stacktrace + - travis_wait 60 ./gradlew clean connectedDebugAndroidTest --stacktrace - ./gradlew jacocoDebugReport after_success: From 0007f46d010cb975c7ab6b5830d7a36a403795db Mon Sep 17 00:00:00 2001 From: isuPatches Date: Sun, 23 Jul 2017 13:28:55 -0500 Subject: [PATCH 40/74] Not giving up hope --- .travis.yml | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index 93e8df0c..28510c81 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,20 +4,25 @@ jdk: oraclejdk8 sudo: required dist: precise +cache: + directories: + - $HOME/.gradle/caches/ + - $HOME/.gradle/wrapper/ + - $HOME/.android/build-cache + android: components: - platform-tools - tools - build-tools-26.0.0 - android-26 -# - sys-img-armeabi-v7a-android-22 - extra-android-m2repository - extra-android-support - extra-google-m2repository env: matrix: - - API=android-16 ABI=armeabi-v7a + - API=android-16 ABI=x86_x64 # - API=android-17 ABI=armeabi-v7a # - API=android-18 ABI=armeabi-v7a # - API=android-19 ABI=armeabi-v7a @@ -26,10 +31,10 @@ env: # - API=android-22 ABI=armeabi-v7a # - API=android-24 ABI=armeabi-v7a # - API=android-25 ABI=armeabi-v7a - - API=android-26 ABI=armeabi-v7a +# - API=android-26 ABI=armeabi-v7a before_script: - - android-update-sdk --components=sys-img-$ABI-$API --accept-licenses='android-sdk-license-[0-9a-f]{8}' + - android-update-sdk --components=sys-img-$ABI-google_apis-$API --accept-licenses='android-sdk-license-[0-9a-f]{8}' - echo no | android create avd --force -n test -t $API --abi $ABI - emulator -avd test -no-audio -no-window - ./gradlew clean assembleDebug assembleDebugAndroidTest From 1b4ed37d396f19158c84b476b6aa3cecc61cff44 Mon Sep 17 00:00:00 2001 From: isuPatches Date: Sun, 23 Jul 2017 13:36:30 -0500 Subject: [PATCH 41/74] update ABI --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 28510c81..186a9522 100644 --- a/.travis.yml +++ b/.travis.yml @@ -22,7 +22,7 @@ android: env: matrix: - - API=android-16 ABI=x86_x64 + - API=android-16 ABI=armeabi-v7a # - API=android-17 ABI=armeabi-v7a # - API=android-18 ABI=armeabi-v7a # - API=android-19 ABI=armeabi-v7a From aa270634bf76c8e9ce327df3b401d6eb3cc14dee Mon Sep 17 00:00:00 2001 From: isuPatches Date: Sun, 23 Jul 2017 13:47:11 -0500 Subject: [PATCH 42/74] Moving some things --- .travis.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index 186a9522..9aadc534 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,9 +1,9 @@ -language: android -jdk: oraclejdk8 - sudo: required dist: precise +language: android +jdk: oraclejdk8 + cache: directories: - $HOME/.gradle/caches/ @@ -37,11 +37,11 @@ before_script: - android-update-sdk --components=sys-img-$ABI-google_apis-$API --accept-licenses='android-sdk-license-[0-9a-f]{8}' - echo no | android create avd --force -n test -t $API --abi $ABI - emulator -avd test -no-audio -no-window - - ./gradlew clean assembleDebug assembleDebugAndroidTest - android-wait-for-emulator - adb shell input keyevent 82 & script: + - ./gradlew clean assembleDebug assembleDebugAndroidTest - travis_wait 60 ./gradlew clean connectedDebugAndroidTest --stacktrace - ./gradlew jacocoDebugReport From 3d228bdd4d8bb80005174df23b3c09b8d8c912f3 Mon Sep 17 00:00:00 2001 From: isuPatches Date: Sun, 23 Jul 2017 15:39:24 -0500 Subject: [PATCH 43/74] Another check --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 9aadc534..0c574a4b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -19,6 +19,7 @@ android: - extra-android-m2repository - extra-android-support - extra-google-m2repository + - sys-img-armeabi-v7a-google_apis-android-16 env: matrix: @@ -34,7 +35,6 @@ env: # - API=android-26 ABI=armeabi-v7a before_script: - - android-update-sdk --components=sys-img-$ABI-google_apis-$API --accept-licenses='android-sdk-license-[0-9a-f]{8}' - echo no | android create avd --force -n test -t $API --abi $ABI - emulator -avd test -no-audio -no-window - android-wait-for-emulator From cb1d2ca3bdf532f5fb6e43f65345c5d5c5407c1d Mon Sep 17 00:00:00 2001 From: isuPatches Date: Sun, 23 Jul 2017 15:46:02 -0500 Subject: [PATCH 44/74] Another test --- .travis.yml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index 0c574a4b..bd236cfb 100644 --- a/.travis.yml +++ b/.travis.yml @@ -23,7 +23,7 @@ android: env: matrix: - - API=android-16 ABI=armeabi-v7a + - $SDK_LEVEL=android-16 ABI=armeabi-v7a # - API=android-17 ABI=armeabi-v7a # - API=android-18 ABI=armeabi-v7a # - API=android-19 ABI=armeabi-v7a @@ -35,9 +35,10 @@ env: # - API=android-26 ABI=armeabi-v7a before_script: - - echo no | android create avd --force -n test -t $API --abi $ABI - - emulator -avd test -no-audio -no-window + - echo no | android create avd --force -n test -t $SDK_LEVEL --abi $ABI + - emulator -avd test -no-skin -no-audio -no-window & - android-wait-for-emulator + - adb shell setprop dalvik.vm.dexopt-flags v=n,o=v - adb shell input keyevent 82 & script: From f8f3198d3823611d1bfb8521202e46e54ab7a1f1 Mon Sep 17 00:00:00 2001 From: isuPatches Date: Sun, 23 Jul 2017 15:53:49 -0500 Subject: [PATCH 45/74] Testing again --- .travis.yml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index bd236cfb..42e4d64a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -12,6 +12,7 @@ cache: android: components: + - tools - platform-tools - tools - build-tools-26.0.0 @@ -19,11 +20,11 @@ android: - extra-android-m2repository - extra-android-support - extra-google-m2repository - - sys-img-armeabi-v7a-google_apis-android-16 + - sys-img-x86_64-google_apis-25 env: matrix: - - $SDK_LEVEL=android-16 ABI=armeabi-v7a + - $SDK_LEVEL=android-25 ABI=x86_64 # - API=android-17 ABI=armeabi-v7a # - API=android-18 ABI=armeabi-v7a # - API=android-19 ABI=armeabi-v7a @@ -43,7 +44,7 @@ before_script: script: - ./gradlew clean assembleDebug assembleDebugAndroidTest - - travis_wait 60 ./gradlew clean connectedDebugAndroidTest --stacktrace + - travis_wait 60 ./gradlew connectedDebugAndroidTest --stacktrace - ./gradlew jacocoDebugReport after_success: From 9ce328025b9de7091c6a816701d77597c5e30715 Mon Sep 17 00:00:00 2001 From: isuPatches Date: Sun, 23 Jul 2017 15:58:14 -0500 Subject: [PATCH 46/74] Defaults? --- .travis.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index 42e4d64a..da37d3bc 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,6 +1,3 @@ -sudo: required -dist: precise - language: android jdk: oraclejdk8 From cdd199c363727a5a20239a55e43c05aa849cf59c Mon Sep 17 00:00:00 2001 From: isuPatches Date: Sun, 23 Jul 2017 16:07:21 -0500 Subject: [PATCH 47/74] Potential tag fix --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index da37d3bc..0ca96c8c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -21,7 +21,7 @@ android: env: matrix: - - $SDK_LEVEL=android-25 ABI=x86_64 + - $SDK_LEVEL=android-25 ABI=google_apis/x86_64 # - API=android-17 ABI=armeabi-v7a # - API=android-18 ABI=armeabi-v7a # - API=android-19 ABI=armeabi-v7a From 50419a67e5fa55f6e93c9111fa92f9d27c449f79 Mon Sep 17 00:00:00 2001 From: isuPatches Date: Sun, 23 Jul 2017 16:20:56 -0500 Subject: [PATCH 48/74] Try arm64 --- .travis.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index 0ca96c8c..0d2049bb 100644 --- a/.travis.yml +++ b/.travis.yml @@ -17,11 +17,11 @@ android: - extra-android-m2repository - extra-android-support - extra-google-m2repository - - sys-img-x86_64-google_apis-25 + - sys-img-arm64-v8a-google_apis-25 env: matrix: - - $SDK_LEVEL=android-25 ABI=google_apis/x86_64 + - $TARGET=android-25 ABI=google_apis/arm64-v8a # - API=android-17 ABI=armeabi-v7a # - API=android-18 ABI=armeabi-v7a # - API=android-19 ABI=armeabi-v7a @@ -33,7 +33,7 @@ env: # - API=android-26 ABI=armeabi-v7a before_script: - - echo no | android create avd --force -n test -t $SDK_LEVEL --abi $ABI + - echo no | android create avd --force -name test -target $TARGET --abi $ABI - emulator -avd test -no-skin -no-audio -no-window & - android-wait-for-emulator - adb shell setprop dalvik.vm.dexopt-flags v=n,o=v From f22623bb575d90b3248f62aeeff572ab2d24c1f8 Mon Sep 17 00:00:00 2001 From: Patches Date: Sun, 23 Jul 2017 16:27:31 -0500 Subject: [PATCH 49/74] Update .travis.yml --- .travis.yml | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/.travis.yml b/.travis.yml index 0d2049bb..5a2f4436 100644 --- a/.travis.yml +++ b/.travis.yml @@ -22,18 +22,9 @@ android: env: matrix: - $TARGET=android-25 ABI=google_apis/arm64-v8a -# - API=android-17 ABI=armeabi-v7a -# - API=android-18 ABI=armeabi-v7a -# - API=android-19 ABI=armeabi-v7a -# - API=android-20 ABI=armeabi-v7a -# - API=android-21 ABI=armeabi-v7a -# - API=android-22 ABI=armeabi-v7a -# - API=android-24 ABI=armeabi-v7a -# - API=android-25 ABI=armeabi-v7a -# - API=android-26 ABI=armeabi-v7a before_script: - - echo no | android create avd --force -name test -target $TARGET --abi $ABI + - echo no | android create avd --force -n test -t $TARGET --abi $ABI - emulator -avd test -no-skin -no-audio -no-window & - android-wait-for-emulator - adb shell setprop dalvik.vm.dexopt-flags v=n,o=v @@ -45,4 +36,4 @@ script: - ./gradlew jacocoDebugReport after_success: - - bash <(curl -s https://codecov.io/bash) \ No newline at end of file + - bash <(curl -s https://codecov.io/bash) From b9c271e9db179de8c7e8b28512d9d0c561cd3295 Mon Sep 17 00:00:00 2001 From: isuPatches Date: Sun, 23 Jul 2017 17:14:51 -0500 Subject: [PATCH 50/74] Trying to increase memory --- .travis.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 0d2049bb..a8769227 100644 --- a/.travis.yml +++ b/.travis.yml @@ -17,11 +17,11 @@ android: - extra-android-m2repository - extra-android-support - extra-google-m2repository - - sys-img-arm64-v8a-google_apis-25 + - sys-img-arm64-v8a-google_apis-24 env: matrix: - - $TARGET=android-25 ABI=google_apis/arm64-v8a + - $TARGET=android-24 ABI=google_apis/arm64-v8a # - API=android-17 ABI=armeabi-v7a # - API=android-18 ABI=armeabi-v7a # - API=android-19 ABI=armeabi-v7a @@ -33,6 +33,8 @@ env: # - API=android-26 ABI=armeabi-v7a before_script: + - echo $JAVA_OPTS + - export JAVA_OPTS=-Xmx2048m - echo no | android create avd --force -name test -target $TARGET --abi $ABI - emulator -avd test -no-skin -no-audio -no-window & - android-wait-for-emulator From e8892a8c085d71bcb0c3c3ad1693990a0a819eec Mon Sep 17 00:00:00 2001 From: isuPatches Date: Sun, 23 Jul 2017 17:20:40 -0500 Subject: [PATCH 51/74] Want to see targets --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index a59a675d..fdedebb1 100644 --- a/.travis.yml +++ b/.travis.yml @@ -28,6 +28,7 @@ env: before_script: - echo $JAVA_OPTS - export JAVA_OPTS=-Xmx2048m + - android list targets - echo no | android create avd --force -n test -t $TARGET --abi $ABI - emulator -avd test -no-skin -no-audio -no-window & - android-wait-for-emulator From e8a2d711d43a1add1c9c330863a7de2e44d39619 Mon Sep 17 00:00:00 2001 From: isuPatches Date: Sun, 23 Jul 2017 17:24:16 -0500 Subject: [PATCH 52/74] Remove sudo true --- .travis.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index fdedebb1..d7e1d629 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,8 +1,6 @@ language: android jdk: oraclejdk8 -sudo: true - cache: directories: - $HOME/.gradle/caches/ From 2aae0accb7a0135b0fec6ac5aae29e133a7737e3 Mon Sep 17 00:00:00 2001 From: isuPatches Date: Sun, 23 Jul 2017 17:31:05 -0500 Subject: [PATCH 53/74] Messing around with the gradle.properties --- .travis.yml | 2 ++ gradle.properties | 11 ++++++++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index d7e1d629..6751c12b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,6 +1,8 @@ language: android jdk: oraclejdk8 +sudo: required + cache: directories: - $HOME/.gradle/caches/ diff --git a/gradle.properties b/gradle.properties index 6cbe7a62..bae547d3 100644 --- a/gradle.properties +++ b/gradle.properties @@ -7,6 +7,10 @@ # For more details on how to configure your build environment visit # http://www.gradle.org/docs/current/userguide/build_environment.html +# The Gradle daemon aims to improve the startup and execution time of Gradle. +# When set to true the Gradle daemon is to run the build. +org.gradle.daemon=true + # Specifies the JVM arguments used for the daemon process. # The setting is particularly useful for tweaking memory settings. # Default value: -Xmx10248m -XX:MaxPermSize=256m @@ -15,4 +19,9 @@ org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryErro # When configured, Gradle will run in incubating parallel mode. # This option should only be used with decoupled projects. More details, visit # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects -# org.gradle.parallel=true \ No newline at end of file +org.gradle.parallel=true + +# Enables new incubating mode that makes Gradle selective when configuring projects. +# Only relevant projects are configured which results in faster builds for large multi-projects. +# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:configuration_on_demand +org.gradle.configureondemand=true \ No newline at end of file From 9ef873c1a1b043908fecc20dc927697d01f0ae63 Mon Sep 17 00:00:00 2001 From: isuPatches Date: Sun, 23 Jul 2017 17:35:34 -0500 Subject: [PATCH 54/74] Another stab at this --- .travis.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 6751c12b..d043335c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -19,11 +19,11 @@ android: - extra-android-m2repository - extra-android-support - extra-google-m2repository - - sys-img-arm64-v8a-google_apis-24 + - sys-img-armeabi-v7a-android-24 env: matrix: - - $TARGET=android-24 ABI=google_apis/arm64-v8a + - $TARGET=android-24 ABI=armeabi-v7a before_script: - echo $JAVA_OPTS From c426dd1e75b78163ca66c1f81cbb8e93d3b40a91 Mon Sep 17 00:00:00 2001 From: isuPatches Date: Sun, 23 Jul 2017 17:40:03 -0500 Subject: [PATCH 55/74] Add emulator level --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index d043335c..e4a5c9b5 100644 --- a/.travis.yml +++ b/.travis.yml @@ -15,6 +15,7 @@ android: - platform-tools - tools - build-tools-26.0.0 + - android-24 - android-26 - extra-android-m2repository - extra-android-support From ec412c859afea304542edb9eddccc73d60d421b8 Mon Sep 17 00:00:00 2001 From: isuPatches Date: Sun, 23 Jul 2017 18:25:07 -0500 Subject: [PATCH 56/74] Remove no-skin --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index e4a5c9b5..bb9d46fa 100644 --- a/.travis.yml +++ b/.travis.yml @@ -31,7 +31,7 @@ before_script: - export JAVA_OPTS=-Xmx2048m - android list targets - echo no | android create avd --force -n test -t $TARGET --abi $ABI - - emulator -avd test -no-skin -no-audio -no-window & + - emulator -avd test -no-audio -no-window & - android-wait-for-emulator - adb shell setprop dalvik.vm.dexopt-flags v=n,o=v - adb shell input keyevent 82 & From 1453e38fd3091a02296732a5b0d3bce0e9e5e3f3 Mon Sep 17 00:00:00 2001 From: isuPatches Date: Sun, 23 Jul 2017 18:26:07 -0500 Subject: [PATCH 57/74] Another stab at this --- .travis.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index bb9d46fa..45f40456 100644 --- a/.travis.yml +++ b/.travis.yml @@ -20,18 +20,18 @@ android: - extra-android-m2repository - extra-android-support - extra-google-m2repository - - sys-img-armeabi-v7a-android-24 + - sys-img-arm64-v8a-google_apis-24 env: matrix: - - $TARGET=android-24 ABI=armeabi-v7a + - $TARGET=android-24 ABI=google_apis/arm64-v8a before_script: - echo $JAVA_OPTS - export JAVA_OPTS=-Xmx2048m - android list targets - echo no | android create avd --force -n test -t $TARGET --abi $ABI - - emulator -avd test -no-audio -no-window & + - emulator -avd test -no-skin -no-audio -no-window & - android-wait-for-emulator - adb shell setprop dalvik.vm.dexopt-flags v=n,o=v - adb shell input keyevent 82 & From 02c5e0ba32d6ad6eebf36d3a67155760c8f29f99 Mon Sep 17 00:00:00 2001 From: isuPatches Date: Sun, 23 Jul 2017 18:47:45 -0500 Subject: [PATCH 58/74] Switching OS? --- .travis.yml | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index 45f40456..40d88477 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,6 +3,9 @@ jdk: oraclejdk8 sudo: required +os: + - osx + cache: directories: - $HOME/.gradle/caches/ @@ -20,18 +23,18 @@ android: - extra-android-m2repository - extra-android-support - extra-google-m2repository - - sys-img-arm64-v8a-google_apis-24 + - sys-img-x86-google_apis-24 env: matrix: - - $TARGET=android-24 ABI=google_apis/arm64-v8a + - $TARGET=android-24 ABI=google_apis/x86 before_script: - echo $JAVA_OPTS - export JAVA_OPTS=-Xmx2048m - android list targets - echo no | android create avd --force -n test -t $TARGET --abi $ABI - - emulator -avd test -no-skin -no-audio -no-window & + - emulator -avd test -no-audio -no-window & - android-wait-for-emulator - adb shell setprop dalvik.vm.dexopt-flags v=n,o=v - adb shell input keyevent 82 & From 8707f73e4fa969e21a6a07807430156cc61b873b Mon Sep 17 00:00:00 2001 From: isuPatches Date: Sun, 23 Jul 2017 18:50:32 -0500 Subject: [PATCH 59/74] Reverting --- .travis.yml | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/.travis.yml b/.travis.yml index 40d88477..caf8f4b0 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,9 +3,6 @@ jdk: oraclejdk8 sudo: required -os: - - osx - cache: directories: - $HOME/.gradle/caches/ @@ -23,11 +20,11 @@ android: - extra-android-m2repository - extra-android-support - extra-google-m2repository - - sys-img-x86-google_apis-24 + - sys-img-arm64-v8a-google_apis-24 env: matrix: - - $TARGET=android-24 ABI=google_apis/x86 + - $TARGET=android-24 ABI=google_apis/arm64-v8a before_script: - echo $JAVA_OPTS From 7471c83ee63a56520d329219ec9abfba37a2b807 Mon Sep 17 00:00:00 2001 From: isuPatches Date: Sun, 23 Jul 2017 19:08:14 -0500 Subject: [PATCH 60/74] Go back to SDK-22 --- .travis.yml | 13 ++++--------- wisefy/build.gradle | 7 +++++++ 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/.travis.yml b/.travis.yml index caf8f4b0..fd014400 100644 --- a/.travis.yml +++ b/.travis.yml @@ -11,29 +11,24 @@ cache: android: components: - - tools - platform-tools - tools - build-tools-26.0.0 - - android-24 + - android-22 - android-26 + - sys-img-armeabi-v7a-android-22 - extra-android-m2repository - extra-android-support - extra-google-m2repository - - sys-img-arm64-v8a-google_apis-24 env: matrix: - - $TARGET=android-24 ABI=google_apis/arm64-v8a + - $TARGET=android-22 ABI=armeabi-v7a before_script: - - echo $JAVA_OPTS - - export JAVA_OPTS=-Xmx2048m - - android list targets - echo no | android create avd --force -n test -t $TARGET --abi $ABI - - emulator -avd test -no-audio -no-window & + - emulator -avd test -no-skin -no-audio -no-window & - android-wait-for-emulator - - adb shell setprop dalvik.vm.dexopt-flags v=n,o=v - adb shell input keyevent 82 & script: diff --git a/wisefy/build.gradle b/wisefy/build.gradle index f32957ed..54c8e86d 100644 --- a/wisefy/build.gradle +++ b/wisefy/build.gradle @@ -16,6 +16,13 @@ dexcount { android { dexOptions { + // Sets the maximum number of DEX processes + // that can be started concurrently. + maxProcessCount 8 + // Sets the maximum memory allocation pool size + // for the dex operation. + javaMaxHeapSize "2g" + // Skip pre-dexing when running on Travis CI or when disabled via -Dpre-dex=false. preDexLibraries = preDexEnabled && !travisBuild } From 2101890b847bbf64776db14df5a6240cdb6f5e8d Mon Sep 17 00:00:00 2001 From: isuPatches Date: Sun, 23 Jul 2017 19:33:49 -0500 Subject: [PATCH 61/74] Another gradle properties adjustment --- gradle.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle.properties b/gradle.properties index bae547d3..e4c9d06b 100644 --- a/gradle.properties +++ b/gradle.properties @@ -14,7 +14,7 @@ org.gradle.daemon=true # Specifies the JVM arguments used for the daemon process. # The setting is particularly useful for tweaking memory settings. # Default value: -Xmx10248m -XX:MaxPermSize=256m -org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 +org.gradle.jvmargs=-Xmx2560Mm -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 # When configured, Gradle will run in incubating parallel mode. # This option should only be used with decoupled projects. More details, visit From 376a5022d845aba3966451ec2ef1942b1e34d3ec Mon Sep 17 00:00:00 2001 From: isuPatches Date: Sun, 23 Jul 2017 19:44:25 -0500 Subject: [PATCH 62/74] Trying API 16 emulator --- .travis.yml | 4 ++-- gradle.properties | 2 +- wisefy/build.gradle | 7 ------- 3 files changed, 3 insertions(+), 10 deletions(-) diff --git a/.travis.yml b/.travis.yml index fd014400..c727689e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -14,9 +14,9 @@ android: - platform-tools - tools - build-tools-26.0.0 - - android-22 + - android-16 - android-26 - - sys-img-armeabi-v7a-android-22 + - sys-img-armeabi-v7a-android-16 - extra-android-m2repository - extra-android-support - extra-google-m2repository diff --git a/gradle.properties b/gradle.properties index e4c9d06b..bae547d3 100644 --- a/gradle.properties +++ b/gradle.properties @@ -14,7 +14,7 @@ org.gradle.daemon=true # Specifies the JVM arguments used for the daemon process. # The setting is particularly useful for tweaking memory settings. # Default value: -Xmx10248m -XX:MaxPermSize=256m -org.gradle.jvmargs=-Xmx2560Mm -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 +org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 # When configured, Gradle will run in incubating parallel mode. # This option should only be used with decoupled projects. More details, visit diff --git a/wisefy/build.gradle b/wisefy/build.gradle index 54c8e86d..f32957ed 100644 --- a/wisefy/build.gradle +++ b/wisefy/build.gradle @@ -16,13 +16,6 @@ dexcount { android { dexOptions { - // Sets the maximum number of DEX processes - // that can be started concurrently. - maxProcessCount 8 - // Sets the maximum memory allocation pool size - // for the dex operation. - javaMaxHeapSize "2g" - // Skip pre-dexing when running on Travis CI or when disabled via -Dpre-dex=false. preDexLibraries = preDexEnabled && !travisBuild } From 45dfcc4e0d70ae1bd876ec3baa7ebc08cc09206e Mon Sep 17 00:00:00 2001 From: isuPatches Date: Sun, 23 Jul 2017 19:49:42 -0500 Subject: [PATCH 63/74] Need to adjust that too --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index c727689e..8328a594 100644 --- a/.travis.yml +++ b/.travis.yml @@ -23,7 +23,7 @@ android: env: matrix: - - $TARGET=android-22 ABI=armeabi-v7a + - $TARGET=android-16 ABI=armeabi-v7a before_script: - echo no | android create avd --force -n test -t $TARGET --abi $ABI From fee686d677053dca3d895a8ed5c995ec732509a5 Mon Sep 17 00:00:00 2001 From: isuPatches Date: Sun, 23 Jul 2017 20:01:52 -0500 Subject: [PATCH 64/74] Some more emulator testing --- .travis.yml | 47 +++++++++++++++++++++++------------------------ 1 file changed, 23 insertions(+), 24 deletions(-) diff --git a/.travis.yml b/.travis.yml index 8328a594..5ceea85c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,40 +1,39 @@ -language: android -jdk: oraclejdk8 - sudo: required +dist: precise +language: android -cache: - directories: - - $HOME/.gradle/caches/ - - $HOME/.gradle/wrapper/ - - $HOME/.android/build-cache +jdk: + - oraclejdk8 android: components: - - platform-tools - tools - - build-tools-26.0.0 - - android-16 - - android-26 - - sys-img-armeabi-v7a-android-16 + - platform-tools + - android-22 + - android-24 + - android-25 + - build-tools-25.0.2 - extra-android-m2repository - - extra-android-support - - extra-google-m2repository env: matrix: - - $TARGET=android-16 ABI=armeabi-v7a + - API=android-15 ABI=armeabi-v7a + - API=android-16 ABI=armeabi-v7a + - API=android-17 ABI=armeabi-v7a + - API=android-18 ABI=armeabi-v7a + - API=android-19 ABI=armeabi-v7a + - API=android-21 ABI=armeabi-v7a + - API=android-22 ABI=armeabi-v7a + - API=android-24 ABI=armeabi-v7a + - API=android-24 ABI=arm64-v8a +# Emulator Management: Create, Start and Wait before_script: - - echo no | android create avd --force -n test -t $TARGET --abi $ABI - - emulator -avd test -no-skin -no-audio -no-window & + - android-update-sdk --components=sys-img-$ABI-$API --accept-licenses='android-sdk-license-[0-9a-f]{8}' + - echo no | android create avd --force -n test -t $API --abi $ABI + - emulator -avd test -no-audio -no-window - android-wait-for-emulator - adb shell input keyevent 82 & script: - - ./gradlew clean assembleDebug assembleDebugAndroidTest - - travis_wait 60 ./gradlew connectedDebugAndroidTest --stacktrace - - ./gradlew jacocoDebugReport - -after_success: - - bash <(curl -s https://codecov.io/bash) \ No newline at end of file + - ./gradlew clean assemble \ No newline at end of file From bb65180a35e5bb35077954eb730b79b474cad334 Mon Sep 17 00:00:00 2001 From: isuPatches Date: Sun, 23 Jul 2017 20:11:23 -0500 Subject: [PATCH 65/74] Add & --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 5ceea85c..171ab2d3 100644 --- a/.travis.yml +++ b/.travis.yml @@ -31,7 +31,7 @@ env: before_script: - android-update-sdk --components=sys-img-$ABI-$API --accept-licenses='android-sdk-license-[0-9a-f]{8}' - echo no | android create avd --force -n test -t $API --abi $ABI - - emulator -avd test -no-audio -no-window + - emulator -avd test -no-audio -no-window & - android-wait-for-emulator - adb shell input keyevent 82 & From d092dcd4c5b6912d5bf7e04cf51f935099c062b0 Mon Sep 17 00:00:00 2001 From: isuPatches Date: Sun, 23 Jul 2017 20:18:51 -0500 Subject: [PATCH 66/74] Update to SDK 26 --- .travis.yml | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index 171ab2d3..0d423b1d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -9,10 +9,9 @@ android: components: - tools - platform-tools - - android-22 - - android-24 - - android-25 - - build-tools-25.0.2 + - tools + - android-26 + - build-tools-26.0.0 - extra-android-m2repository env: From 7bd0befc236a3950e2ea50712f88e17ec8801b8a Mon Sep 17 00:00:00 2001 From: isuPatches Date: Sun, 23 Jul 2017 20:31:46 -0500 Subject: [PATCH 67/74] Getting a baseline with SDK 16 --- .travis.yml | 35 +++++++++++++++++++---------------- 1 file changed, 19 insertions(+), 16 deletions(-) diff --git a/.travis.yml b/.travis.yml index 0d423b1d..ad609b71 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,28 +5,30 @@ language: android jdk: - oraclejdk8 +env: + global: + - TARGET_SDK_VERSION=26 + - BUILD_TOOLS_VERSION=26.0.0 + matrix: +# - API=android-15 ABI=armeabi-v7a + - API=android-16 ABI=armeabi-v7a +# - API=android-17 ABI=armeabi-v7a +# - API=android-18 ABI=armeabi-v7a +# - API=android-19 ABI=armeabi-v7a +# - API=android-21 ABI=armeabi-v7a +# - API=android-22 ABI=armeabi-v7a +# - API=android-24 ABI=armeabi-v7a +# - API=android-24 ABI=arm64-v8a + android: components: - tools - platform-tools - tools - - android-26 - - build-tools-26.0.0 + - android-${TARGET_SDK_VERSION} + - build-tools-${BUILD_TOOLS_VERSION} - extra-android-m2repository -env: - matrix: - - API=android-15 ABI=armeabi-v7a - - API=android-16 ABI=armeabi-v7a - - API=android-17 ABI=armeabi-v7a - - API=android-18 ABI=armeabi-v7a - - API=android-19 ABI=armeabi-v7a - - API=android-21 ABI=armeabi-v7a - - API=android-22 ABI=armeabi-v7a - - API=android-24 ABI=armeabi-v7a - - API=android-24 ABI=arm64-v8a - -# Emulator Management: Create, Start and Wait before_script: - android-update-sdk --components=sys-img-$ABI-$API --accept-licenses='android-sdk-license-[0-9a-f]{8}' - echo no | android create avd --force -n test -t $API --abi $ABI @@ -35,4 +37,5 @@ before_script: - adb shell input keyevent 82 & script: - - ./gradlew clean assemble \ No newline at end of file + - ./gradlew clean assembleDebug assembleDebugAndroidTest +# - ./gradlew \ No newline at end of file From 56bf3b13e1b0c360ea1708e09f162f3f352cb2c8 Mon Sep 17 00:00:00 2001 From: isuPatches Date: Sun, 23 Jul 2017 20:33:54 -0500 Subject: [PATCH 68/74] Fix yml --- .travis.yml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index ad609b71..bd172d0f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,7 +6,7 @@ jdk: - oraclejdk8 env: - global: + global: - TARGET_SDK_VERSION=26 - BUILD_TOOLS_VERSION=26.0.0 matrix: @@ -37,5 +37,4 @@ before_script: - adb shell input keyevent 82 & script: - - ./gradlew clean assembleDebug assembleDebugAndroidTest -# - ./gradlew \ No newline at end of file + - ./gradlew clean assembleDebug assembleDebugAndroidTest \ No newline at end of file From eb4de15479faf0f535edc219fe2057c064bf09f0 Mon Sep 17 00:00:00 2001 From: isuPatches Date: Sun, 23 Jul 2017 20:44:05 -0500 Subject: [PATCH 69/74] Temp test --- .travis.yml | 3 +- .../wisefy/AddOpenNetworkTests.java | 320 +++++------ .../isupatches/wisefy/AddWEPNetworkTests.java | 376 ++++++------- .../wisefy/AddWPA2NetworkTests.java | 374 ++++++------- .../wisefy/ConnectToNetworkTests.java | 444 +++++++-------- .../isupatches/wisefy/DisableWifiTests.java | 208 +++---- .../DisconnectFromCurrentNetworkTests.java | 206 +++---- .../isupatches/wisefy/EnableWifiTests.java | 208 +++---- .../wisefy/GetCurrentNetworkTests.java | 174 +++--- .../isupatches/wisefy/GetFrequencyTests.java | 316 +++++------ .../wisefy/GetNearbyAccessPointsTests.java | 420 +++++++------- .../com/isupatches/wisefy/GetRSSITests.java | 528 +++++++++--------- .../wisefy/GetSavedNetworksTests.java | 486 ++++++++-------- .../isupatches/wisefy/test/BuilderTests.java | 64 +-- 14 files changed, 2064 insertions(+), 2063 deletions(-) diff --git a/.travis.yml b/.travis.yml index bd172d0f..41bd1bdf 100644 --- a/.travis.yml +++ b/.travis.yml @@ -33,8 +33,9 @@ before_script: - android-update-sdk --components=sys-img-$ABI-$API --accept-licenses='android-sdk-license-[0-9a-f]{8}' - echo no | android create avd --force -n test -t $API --abi $ABI - emulator -avd test -no-audio -no-window & + - ./gradlew clean assembleDebug assembleDebugAndroidTest - android-wait-for-emulator - adb shell input keyevent 82 & script: - - ./gradlew clean assembleDebug assembleDebugAndroidTest \ No newline at end of file + - travis_wait 60 ./gradlew jacocoDebugTestReport \ No newline at end of file diff --git a/wisefy/src/androidTest/java/com/isupatches/wisefy/AddOpenNetworkTests.java b/wisefy/src/androidTest/java/com/isupatches/wisefy/AddOpenNetworkTests.java index 76073241..8443d1d3 100644 --- a/wisefy/src/androidTest/java/com/isupatches/wisefy/AddOpenNetworkTests.java +++ b/wisefy/src/androidTest/java/com/isupatches/wisefy/AddOpenNetworkTests.java @@ -1,160 +1,160 @@ -package com.isupatches.wisefy; - - -import android.net.wifi.WifiConfiguration; -import com.isupatches.wisefy.callbacks.AddOpenNetworkCallbacks; -import com.isupatches.wisefy.constants.WiseFyCodes; -import com.isupatches.wisefy.base.TestActivity; -import org.junit.Test; -import static com.isupatches.wisefy.base.TestUtils.OPEN_NETWORK_SSID; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotEquals; -import static org.junit.Assert.fail; -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.never; -import static org.mockito.Mockito.timeout; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; - - -public class AddOpenNetworkTests extends BaseTestClass { - - public AddOpenNetworkTests() { - super(TestActivity.class); - } - - @Test - public void noCallbacks_failure() { - when(mMockWiFiManager.addNetwork(any(WifiConfiguration.class))).thenReturn(WiseFy.WIFI_MANAGER_FAILURE); - assertEquals(WiseFy.WIFI_MANAGER_FAILURE, mWiseFy.addOpenNetwork(OPEN_NETWORK_SSID)); - verify(mMockWiFiManager, timeout(VERIFICATION_TIMEOUT)).addNetwork(any(WifiConfiguration.class)); - } - - @Test - public void noCallbacks_failure_nullSSIDParam() { - assertEquals(WiseFyCodes.MISSING_PARAMETER, mWiseFy.addOpenNetwork(null)); - verify(mMockWiFiManager, never()).addNetwork(any(WifiConfiguration.class)); - } - - @Test - public void noCallbacks_failure_missingPrerequisite() { - missingPrerequisite(); - assertEquals(WiseFyCodes.MISSING_PREREQUISITE, mWiseFy.addOpenNetwork(OPEN_NETWORK_SSID)); - verify(mMockWiFiManager, never()).addNetwork(any(WifiConfiguration.class)); - } - - @Test - public void noCallbacks_success() { - when(mMockWiFiManager.addNetwork(any(WifiConfiguration.class))).thenReturn(0); - assertNotEquals(WiseFy.WIFI_MANAGER_FAILURE, mWiseFy.addOpenNetwork(OPEN_NETWORK_SSID)); - verify(mMockWiFiManager, timeout(VERIFICATION_TIMEOUT)).addNetwork(any(WifiConfiguration.class)); - } - - @Test - public void noCallbacks_success_alreadyConfigured() { - networkAlreadyInConfigurationList(); - assertEquals(WiseFyCodes.NETWORK_ALREADY_CONFIGURED, mWiseFy.addOpenNetwork(OPEN_NETWORK_SSID)); - verify(mMockWiFiManager, never()).addNetwork(any(WifiConfiguration.class)); - } - - @Test - public void callbacks_failure() { - when(mMockWiFiManager.addNetwork(any(WifiConfiguration.class))).thenReturn(WiseFy.WIFI_MANAGER_FAILURE); - AddOpenNetworkCallbacks mockCallbacks = mock(AddOpenNetworkCallbacks.class); - mWiseFy.addOpenNetwork(OPEN_NETWORK_SSID, mockCallbacks); - verify(mockCallbacks, timeout(VERIFICATION_TIMEOUT)).failureAddingOpenNetwork(WiseFy.WIFI_MANAGER_FAILURE); - verify(mMockWiFiManager, timeout(VERIFICATION_TIMEOUT)).addNetwork(any(WifiConfiguration.class)); - } - - @Test - public void callbacks_failure_nullCallback() { - when(mMockWiFiManager.addNetwork(any(WifiConfiguration.class))).thenReturn(WiseFy.WIFI_MANAGER_FAILURE); - try { - mWiseFy.addOpenNetwork(OPEN_NETWORK_SSID, null); - verify(mMockWiFiManager, never()).addNetwork(any(WifiConfiguration.class)); - } catch (NullPointerException npe) { - fail(); - } - } - - @Test - public void callbacks_failure_nullSSIDParam() { - AddOpenNetworkCallbacks mockCallbacks = mock(AddOpenNetworkCallbacks.class); - mWiseFy.addOpenNetwork(null, mockCallbacks); - verify(mockCallbacks, timeout(VERIFICATION_TIMEOUT)).addOpenNetworkWiseFyFailure(WiseFyCodes.MISSING_PARAMETER); - verify(mMockWiFiManager, never()).addNetwork(any(WifiConfiguration.class)); - } - - @Test - public void callbacks_failure_nullSSIDParam_nullCallback() { - try { - mWiseFy.addOpenNetwork(null, null); - verify(mMockWiFiManager, never()).addNetwork(any(WifiConfiguration.class)); - } catch (NullPointerException npe) { - fail(); - } - } - - @Test - public void callbacks_failure_missingPrerequisite() { - missingPrerequisite(); - AddOpenNetworkCallbacks mockCallbacks = mock(AddOpenNetworkCallbacks.class); - mWiseFy.addOpenNetwork(OPEN_NETWORK_SSID, mockCallbacks); - verify(mockCallbacks, timeout(VERIFICATION_TIMEOUT)).addOpenNetworkWiseFyFailure(WiseFyCodes.MISSING_PREREQUISITE); - verify(mMockWiFiManager, never()).addNetwork(any(WifiConfiguration.class)); - } - - @Test - public void callbacks_failure_missingPrerequisite_nullCallback() { - missingPrerequisite(); - try { - mWiseFy.addOpenNetwork(OPEN_NETWORK_SSID, null); - verify(mMockWiFiManager, never()).addNetwork(any(WifiConfiguration.class)); - } catch (NullPointerException npe) { - fail(); - } - } - - @Test - public void callbacks_success() { - when(mMockWiFiManager.addNetwork(any(WifiConfiguration.class))).thenReturn(0); - AddOpenNetworkCallbacks mockCallbacks = mock(AddOpenNetworkCallbacks.class); - mWiseFy.addOpenNetwork(OPEN_NETWORK_SSID, mockCallbacks); - verify(mockCallbacks, timeout(VERIFICATION_TIMEOUT)).openNetworkAdded(any(WifiConfiguration.class)); - verify(mMockWiFiManager, timeout(VERIFICATION_TIMEOUT)).addNetwork(any(WifiConfiguration.class)); - } - - @Test - public void callbacks_success_nullCallback() { - when(mMockWiFiManager.addNetwork(any(WifiConfiguration.class))).thenReturn(0); - try { - mWiseFy.addOpenNetwork(OPEN_NETWORK_SSID, null); - verify(mMockWiFiManager, never()).addNetwork(any(WifiConfiguration.class)); - } catch (NullPointerException npe) { - fail(); - } - } - - @Test - public void callbacks_success_alreadyConfigured() { - networkAlreadyInConfigurationList(); - - AddOpenNetworkCallbacks mockCallbacks = mock(AddOpenNetworkCallbacks.class); - mWiseFy.addOpenNetwork(OPEN_NETWORK_SSID, mockCallbacks); - verify(mockCallbacks, timeout(VERIFICATION_TIMEOUT)).addOpenNetworkWiseFyFailure(WiseFyCodes.NETWORK_ALREADY_CONFIGURED); - verify(mMockWiFiManager, never()).addNetwork(any(WifiConfiguration.class)); - } - - @Test - public void callbacks_success_alreadyConfigured_nullCallback() { - networkAlreadyInConfigurationList(); - - try { - mWiseFy.addOpenNetwork(OPEN_NETWORK_SSID, null); - verify(mMockWiFiManager, never()).addNetwork(any(WifiConfiguration.class)); - } catch (NullPointerException npe) { - fail(); - } - } -} \ No newline at end of file +//package com.isupatches.wisefy; +// +// +//import android.net.wifi.WifiConfiguration; +//import com.isupatches.wisefy.callbacks.AddOpenNetworkCallbacks; +//import com.isupatches.wisefy.constants.WiseFyCodes; +//import com.isupatches.wisefy.base.TestActivity; +//import org.junit.Test; +//import static com.isupatches.wisefy.base.TestUtils.OPEN_NETWORK_SSID; +//import static org.junit.Assert.assertEquals; +//import static org.junit.Assert.assertNotEquals; +//import static org.junit.Assert.fail; +//import static org.mockito.ArgumentMatchers.any; +//import static org.mockito.Mockito.mock; +//import static org.mockito.Mockito.never; +//import static org.mockito.Mockito.timeout; +//import static org.mockito.Mockito.verify; +//import static org.mockito.Mockito.when; +// +// +//public class AddOpenNetworkTests extends BaseTestClass { +// +// public AddOpenNetworkTests() { +// super(TestActivity.class); +// } +// +// @Test +// public void noCallbacks_failure() { +// when(mMockWiFiManager.addNetwork(any(WifiConfiguration.class))).thenReturn(WiseFy.WIFI_MANAGER_FAILURE); +// assertEquals(WiseFy.WIFI_MANAGER_FAILURE, mWiseFy.addOpenNetwork(OPEN_NETWORK_SSID)); +// verify(mMockWiFiManager, timeout(VERIFICATION_TIMEOUT)).addNetwork(any(WifiConfiguration.class)); +// } +// +// @Test +// public void noCallbacks_failure_nullSSIDParam() { +// assertEquals(WiseFyCodes.MISSING_PARAMETER, mWiseFy.addOpenNetwork(null)); +// verify(mMockWiFiManager, never()).addNetwork(any(WifiConfiguration.class)); +// } +// +// @Test +// public void noCallbacks_failure_missingPrerequisite() { +// missingPrerequisite(); +// assertEquals(WiseFyCodes.MISSING_PREREQUISITE, mWiseFy.addOpenNetwork(OPEN_NETWORK_SSID)); +// verify(mMockWiFiManager, never()).addNetwork(any(WifiConfiguration.class)); +// } +// +// @Test +// public void noCallbacks_success() { +// when(mMockWiFiManager.addNetwork(any(WifiConfiguration.class))).thenReturn(0); +// assertNotEquals(WiseFy.WIFI_MANAGER_FAILURE, mWiseFy.addOpenNetwork(OPEN_NETWORK_SSID)); +// verify(mMockWiFiManager, timeout(VERIFICATION_TIMEOUT)).addNetwork(any(WifiConfiguration.class)); +// } +// +// @Test +// public void noCallbacks_success_alreadyConfigured() { +// networkAlreadyInConfigurationList(); +// assertEquals(WiseFyCodes.NETWORK_ALREADY_CONFIGURED, mWiseFy.addOpenNetwork(OPEN_NETWORK_SSID)); +// verify(mMockWiFiManager, never()).addNetwork(any(WifiConfiguration.class)); +// } +// +// @Test +// public void callbacks_failure() { +// when(mMockWiFiManager.addNetwork(any(WifiConfiguration.class))).thenReturn(WiseFy.WIFI_MANAGER_FAILURE); +// AddOpenNetworkCallbacks mockCallbacks = mock(AddOpenNetworkCallbacks.class); +// mWiseFy.addOpenNetwork(OPEN_NETWORK_SSID, mockCallbacks); +// verify(mockCallbacks, timeout(VERIFICATION_TIMEOUT)).failureAddingOpenNetwork(WiseFy.WIFI_MANAGER_FAILURE); +// verify(mMockWiFiManager, timeout(VERIFICATION_TIMEOUT)).addNetwork(any(WifiConfiguration.class)); +// } +// +// @Test +// public void callbacks_failure_nullCallback() { +// when(mMockWiFiManager.addNetwork(any(WifiConfiguration.class))).thenReturn(WiseFy.WIFI_MANAGER_FAILURE); +// try { +// mWiseFy.addOpenNetwork(OPEN_NETWORK_SSID, null); +// verify(mMockWiFiManager, never()).addNetwork(any(WifiConfiguration.class)); +// } catch (NullPointerException npe) { +// fail(); +// } +// } +// +// @Test +// public void callbacks_failure_nullSSIDParam() { +// AddOpenNetworkCallbacks mockCallbacks = mock(AddOpenNetworkCallbacks.class); +// mWiseFy.addOpenNetwork(null, mockCallbacks); +// verify(mockCallbacks, timeout(VERIFICATION_TIMEOUT)).addOpenNetworkWiseFyFailure(WiseFyCodes.MISSING_PARAMETER); +// verify(mMockWiFiManager, never()).addNetwork(any(WifiConfiguration.class)); +// } +// +// @Test +// public void callbacks_failure_nullSSIDParam_nullCallback() { +// try { +// mWiseFy.addOpenNetwork(null, null); +// verify(mMockWiFiManager, never()).addNetwork(any(WifiConfiguration.class)); +// } catch (NullPointerException npe) { +// fail(); +// } +// } +// +// @Test +// public void callbacks_failure_missingPrerequisite() { +// missingPrerequisite(); +// AddOpenNetworkCallbacks mockCallbacks = mock(AddOpenNetworkCallbacks.class); +// mWiseFy.addOpenNetwork(OPEN_NETWORK_SSID, mockCallbacks); +// verify(mockCallbacks, timeout(VERIFICATION_TIMEOUT)).addOpenNetworkWiseFyFailure(WiseFyCodes.MISSING_PREREQUISITE); +// verify(mMockWiFiManager, never()).addNetwork(any(WifiConfiguration.class)); +// } +// +// @Test +// public void callbacks_failure_missingPrerequisite_nullCallback() { +// missingPrerequisite(); +// try { +// mWiseFy.addOpenNetwork(OPEN_NETWORK_SSID, null); +// verify(mMockWiFiManager, never()).addNetwork(any(WifiConfiguration.class)); +// } catch (NullPointerException npe) { +// fail(); +// } +// } +// +// @Test +// public void callbacks_success() { +// when(mMockWiFiManager.addNetwork(any(WifiConfiguration.class))).thenReturn(0); +// AddOpenNetworkCallbacks mockCallbacks = mock(AddOpenNetworkCallbacks.class); +// mWiseFy.addOpenNetwork(OPEN_NETWORK_SSID, mockCallbacks); +// verify(mockCallbacks, timeout(VERIFICATION_TIMEOUT)).openNetworkAdded(any(WifiConfiguration.class)); +// verify(mMockWiFiManager, timeout(VERIFICATION_TIMEOUT)).addNetwork(any(WifiConfiguration.class)); +// } +// +// @Test +// public void callbacks_success_nullCallback() { +// when(mMockWiFiManager.addNetwork(any(WifiConfiguration.class))).thenReturn(0); +// try { +// mWiseFy.addOpenNetwork(OPEN_NETWORK_SSID, null); +// verify(mMockWiFiManager, never()).addNetwork(any(WifiConfiguration.class)); +// } catch (NullPointerException npe) { +// fail(); +// } +// } +// +// @Test +// public void callbacks_success_alreadyConfigured() { +// networkAlreadyInConfigurationList(); +// +// AddOpenNetworkCallbacks mockCallbacks = mock(AddOpenNetworkCallbacks.class); +// mWiseFy.addOpenNetwork(OPEN_NETWORK_SSID, mockCallbacks); +// verify(mockCallbacks, timeout(VERIFICATION_TIMEOUT)).addOpenNetworkWiseFyFailure(WiseFyCodes.NETWORK_ALREADY_CONFIGURED); +// verify(mMockWiFiManager, never()).addNetwork(any(WifiConfiguration.class)); +// } +// +// @Test +// public void callbacks_success_alreadyConfigured_nullCallback() { +// networkAlreadyInConfigurationList(); +// +// try { +// mWiseFy.addOpenNetwork(OPEN_NETWORK_SSID, null); +// verify(mMockWiFiManager, never()).addNetwork(any(WifiConfiguration.class)); +// } catch (NullPointerException npe) { +// fail(); +// } +// } +//} \ No newline at end of file diff --git a/wisefy/src/androidTest/java/com/isupatches/wisefy/AddWEPNetworkTests.java b/wisefy/src/androidTest/java/com/isupatches/wisefy/AddWEPNetworkTests.java index d637cf7d..d8da7f89 100644 --- a/wisefy/src/androidTest/java/com/isupatches/wisefy/AddWEPNetworkTests.java +++ b/wisefy/src/androidTest/java/com/isupatches/wisefy/AddWEPNetworkTests.java @@ -1,188 +1,188 @@ -package com.isupatches.wisefy; - - -import android.net.wifi.WifiConfiguration; -import com.isupatches.wisefy.base.TestActivity; -import com.isupatches.wisefy.callbacks.AddWEPNetworkCallbacks; -import com.isupatches.wisefy.constants.WiseFyCodes; -import org.junit.Test; -import static com.isupatches.wisefy.base.TestUtils.WEP_NETWORK_PASSWORD; -import static com.isupatches.wisefy.base.TestUtils.WEP_NETWORK_SSID; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotEquals; -import static org.junit.Assert.fail; -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.never; -import static org.mockito.Mockito.timeout; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; - - -public class AddWEPNetworkTests extends BaseTestClass { - - public AddWEPNetworkTests() { - super(TestActivity.class); - } - - @Test - public void noCallbacks_failure() { - when(mMockWiFiManager.addNetwork(any(WifiConfiguration.class))).thenReturn(WiseFy.WIFI_MANAGER_FAILURE); - assertEquals(WiseFy.WIFI_MANAGER_FAILURE, mWiseFy.addWEPNetwork(WEP_NETWORK_SSID, WEP_NETWORK_PASSWORD)); - verify(mMockWiFiManager, timeout(VERIFICATION_TIMEOUT)).addNetwork(any(WifiConfiguration.class)); - } - - @Test - public void noCallbacks_failure_nullPasswordParam() { - assertEquals(WiseFyCodes.MISSING_PARAMETER, mWiseFy.addWEPNetwork(WEP_NETWORK_SSID, null)); - verify(mMockWiFiManager, never()).addNetwork(any(WifiConfiguration.class)); - } - - @Test - public void noCallbacks_failure_nullSSIDParam() { - assertEquals(WiseFyCodes.MISSING_PARAMETER, mWiseFy.addWEPNetwork(null, WEP_NETWORK_PASSWORD)); - verify(mMockWiFiManager, never()).addNetwork(any(WifiConfiguration.class)); - } - - @Test - public void noCallbacks_failure_missingPrerequisite() { - missingPrerequisite(); - assertEquals(WiseFyCodes.MISSING_PREREQUISITE, mWiseFy.addWEPNetwork(WEP_NETWORK_SSID, WEP_NETWORK_PASSWORD)); - verify(mMockWiFiManager, never()).addNetwork(any(WifiConfiguration.class)); - } - - @Test - public void noCallbacks_success() { - when(mMockWiFiManager.addNetwork(any(WifiConfiguration.class))).thenReturn(0); - assertNotEquals(WiseFy.WIFI_MANAGER_FAILURE, mWiseFy.addWEPNetwork(WEP_NETWORK_SSID, WEP_NETWORK_PASSWORD)); - verify(mMockWiFiManager, timeout(VERIFICATION_TIMEOUT)).addNetwork(any(WifiConfiguration.class)); - } - - @Test - public void noCallbacks_success_alreadyConfigured() { - networkAlreadyInConfigurationList(); - assertEquals(WiseFyCodes.NETWORK_ALREADY_CONFIGURED, mWiseFy.addWEPNetwork(WEP_NETWORK_SSID, WEP_NETWORK_PASSWORD)); - verify(mMockWiFiManager, never()).addNetwork(any(WifiConfiguration.class)); - } - - @Test - public void callbacks_failure() { - when(mMockWiFiManager.addNetwork(any(WifiConfiguration.class))).thenReturn(WiseFy.WIFI_MANAGER_FAILURE); - AddWEPNetworkCallbacks mockCallbacks = mock(AddWEPNetworkCallbacks.class); - mWiseFy.addWEPNetwork(WEP_NETWORK_SSID, WEP_NETWORK_PASSWORD, mockCallbacks); - verify(mockCallbacks, timeout(VERIFICATION_TIMEOUT)).failureAddingWEPNetwork(WiseFy.WIFI_MANAGER_FAILURE); - verify(mMockWiFiManager, timeout(VERIFICATION_TIMEOUT)).addNetwork(any(WifiConfiguration.class)); - } - - @Test - public void callbacks_failure_nullCallback() { - when(mMockWiFiManager.addNetwork(any(WifiConfiguration.class))).thenReturn(WiseFy.WIFI_MANAGER_FAILURE); - - try { - mWiseFy.addWEPNetwork(WEP_NETWORK_SSID, WEP_NETWORK_PASSWORD, null); - verify(mMockWiFiManager, never()).addNetwork(any(WifiConfiguration.class)); - } catch (NullPointerException npe) { - fail(); - } - } - - @Test - public void callbacks_failure_nullPasswordParam() { - AddWEPNetworkCallbacks mockCallbacks = mock(AddWEPNetworkCallbacks.class); - mWiseFy.addWEPNetwork(WEP_NETWORK_SSID, null, mockCallbacks); - verify(mockCallbacks, timeout(VERIFICATION_TIMEOUT)).addWEPNetworkWiseFyFailure(WiseFyCodes.MISSING_PARAMETER); - verify(mMockWiFiManager, never()).addNetwork(any(WifiConfiguration.class)); - } - - @Test - public void callbacks_failure_nullPasswordParam_nullCallback() { - try { - mWiseFy.addWEPNetwork(WEP_NETWORK_SSID, null, null); - verify(mMockWiFiManager, never()).addNetwork(any(WifiConfiguration.class)); - } catch (NullPointerException npe) { - fail(); - } - } - - @Test - public void callbacks_failure_nullSSIDParam() { - AddWEPNetworkCallbacks mockCallbacks = mock(AddWEPNetworkCallbacks.class); - mWiseFy.addWEPNetwork(null, WEP_NETWORK_PASSWORD, mockCallbacks); - verify(mockCallbacks, timeout(VERIFICATION_TIMEOUT)).addWEPNetworkWiseFyFailure(WiseFyCodes.MISSING_PARAMETER); - verify(mMockWiFiManager, never()).addNetwork(any(WifiConfiguration.class)); - } - - @Test - public void callbacks_failure_nullSSIDParam_nullCallback() { - try { - mWiseFy.addWEPNetwork(null, WEP_NETWORK_PASSWORD, null); - verify(mMockWiFiManager, never()).addNetwork(any(WifiConfiguration.class)); - } catch (NullPointerException npe) { - fail(); - } - } - - @Test - public void callbacks_failure_missingPrerequisite() { - missingPrerequisite(); - AddWEPNetworkCallbacks mockCallbacks = mock(AddWEPNetworkCallbacks.class); - mWiseFy.addWEPNetwork(WEP_NETWORK_SSID, WEP_NETWORK_PASSWORD, mockCallbacks); - verify(mockCallbacks, timeout(VERIFICATION_TIMEOUT)).addWEPNetworkWiseFyFailure(WiseFyCodes.MISSING_PREREQUISITE); - verify(mMockWiFiManager, never()).addNetwork(any(WifiConfiguration.class)); - } - - @Test - public void callbacks_failure_missingPrerequisite_nullCallback() { - missingPrerequisite(); - - try { - mWiseFy.addWEPNetwork(WEP_NETWORK_SSID, WEP_NETWORK_PASSWORD, null); - verify(mMockWiFiManager, never()).addNetwork(any(WifiConfiguration.class)); - } catch (NullPointerException npe) { - fail(); - } - } - - @Test - public void callbacks_success() { - when(mMockWiFiManager.addNetwork(any(WifiConfiguration.class))).thenReturn(0); - AddWEPNetworkCallbacks mockCallbacks = mock(AddWEPNetworkCallbacks.class); - mWiseFy.addWEPNetwork(WEP_NETWORK_SSID, WEP_NETWORK_PASSWORD, mockCallbacks); - verify(mockCallbacks, timeout(VERIFICATION_TIMEOUT)).wepNetworkAdded(any(WifiConfiguration.class)); - verify(mMockWiFiManager, timeout(VERIFICATION_TIMEOUT)).addNetwork(any(WifiConfiguration.class)); - } - - @Test - public void callbacks_success_nullCallback() { - when(mMockWiFiManager.addNetwork(any(WifiConfiguration.class))).thenReturn(0); - - try { - mWiseFy.addWEPNetwork(WEP_NETWORK_SSID, WEP_NETWORK_PASSWORD, null); - verify(mMockWiFiManager, never()).addNetwork(any(WifiConfiguration.class)); - } catch (NullPointerException npe) { - fail(); - } - } - - @Test - public void callbacks_success_alreadyConfigured() { - networkAlreadyInConfigurationList(); - - AddWEPNetworkCallbacks mockCallbacks = mock(AddWEPNetworkCallbacks.class); - mWiseFy.addWEPNetwork(WEP_NETWORK_SSID, WEP_NETWORK_PASSWORD, mockCallbacks); - verify(mockCallbacks, timeout(VERIFICATION_TIMEOUT)).addWEPNetworkWiseFyFailure(WiseFyCodes.NETWORK_ALREADY_CONFIGURED); - verify(mMockWiFiManager, never()).addNetwork(any(WifiConfiguration.class)); - } - - @Test - public void callbacks_success_alreadyConfigured_nullCallback() { - networkAlreadyInConfigurationList(); - - try { - mWiseFy.addWEPNetwork(WEP_NETWORK_SSID, WEP_NETWORK_PASSWORD, null); - verify(mMockWiFiManager, never()).addNetwork(any(WifiConfiguration.class)); - } catch (NullPointerException npe) { - fail(); - } - } -} +//package com.isupatches.wisefy; +// +// +//import android.net.wifi.WifiConfiguration; +//import com.isupatches.wisefy.base.TestActivity; +//import com.isupatches.wisefy.callbacks.AddWEPNetworkCallbacks; +//import com.isupatches.wisefy.constants.WiseFyCodes; +//import org.junit.Test; +//import static com.isupatches.wisefy.base.TestUtils.WEP_NETWORK_PASSWORD; +//import static com.isupatches.wisefy.base.TestUtils.WEP_NETWORK_SSID; +//import static org.junit.Assert.assertEquals; +//import static org.junit.Assert.assertNotEquals; +//import static org.junit.Assert.fail; +//import static org.mockito.ArgumentMatchers.any; +//import static org.mockito.Mockito.mock; +//import static org.mockito.Mockito.never; +//import static org.mockito.Mockito.timeout; +//import static org.mockito.Mockito.verify; +//import static org.mockito.Mockito.when; +// +// +//public class AddWEPNetworkTests extends BaseTestClass { +// +// public AddWEPNetworkTests() { +// super(TestActivity.class); +// } +// +// @Test +// public void noCallbacks_failure() { +// when(mMockWiFiManager.addNetwork(any(WifiConfiguration.class))).thenReturn(WiseFy.WIFI_MANAGER_FAILURE); +// assertEquals(WiseFy.WIFI_MANAGER_FAILURE, mWiseFy.addWEPNetwork(WEP_NETWORK_SSID, WEP_NETWORK_PASSWORD)); +// verify(mMockWiFiManager, timeout(VERIFICATION_TIMEOUT)).addNetwork(any(WifiConfiguration.class)); +// } +// +// @Test +// public void noCallbacks_failure_nullPasswordParam() { +// assertEquals(WiseFyCodes.MISSING_PARAMETER, mWiseFy.addWEPNetwork(WEP_NETWORK_SSID, null)); +// verify(mMockWiFiManager, never()).addNetwork(any(WifiConfiguration.class)); +// } +// +// @Test +// public void noCallbacks_failure_nullSSIDParam() { +// assertEquals(WiseFyCodes.MISSING_PARAMETER, mWiseFy.addWEPNetwork(null, WEP_NETWORK_PASSWORD)); +// verify(mMockWiFiManager, never()).addNetwork(any(WifiConfiguration.class)); +// } +// +// @Test +// public void noCallbacks_failure_missingPrerequisite() { +// missingPrerequisite(); +// assertEquals(WiseFyCodes.MISSING_PREREQUISITE, mWiseFy.addWEPNetwork(WEP_NETWORK_SSID, WEP_NETWORK_PASSWORD)); +// verify(mMockWiFiManager, never()).addNetwork(any(WifiConfiguration.class)); +// } +// +// @Test +// public void noCallbacks_success() { +// when(mMockWiFiManager.addNetwork(any(WifiConfiguration.class))).thenReturn(0); +// assertNotEquals(WiseFy.WIFI_MANAGER_FAILURE, mWiseFy.addWEPNetwork(WEP_NETWORK_SSID, WEP_NETWORK_PASSWORD)); +// verify(mMockWiFiManager, timeout(VERIFICATION_TIMEOUT)).addNetwork(any(WifiConfiguration.class)); +// } +// +// @Test +// public void noCallbacks_success_alreadyConfigured() { +// networkAlreadyInConfigurationList(); +// assertEquals(WiseFyCodes.NETWORK_ALREADY_CONFIGURED, mWiseFy.addWEPNetwork(WEP_NETWORK_SSID, WEP_NETWORK_PASSWORD)); +// verify(mMockWiFiManager, never()).addNetwork(any(WifiConfiguration.class)); +// } +// +// @Test +// public void callbacks_failure() { +// when(mMockWiFiManager.addNetwork(any(WifiConfiguration.class))).thenReturn(WiseFy.WIFI_MANAGER_FAILURE); +// AddWEPNetworkCallbacks mockCallbacks = mock(AddWEPNetworkCallbacks.class); +// mWiseFy.addWEPNetwork(WEP_NETWORK_SSID, WEP_NETWORK_PASSWORD, mockCallbacks); +// verify(mockCallbacks, timeout(VERIFICATION_TIMEOUT)).failureAddingWEPNetwork(WiseFy.WIFI_MANAGER_FAILURE); +// verify(mMockWiFiManager, timeout(VERIFICATION_TIMEOUT)).addNetwork(any(WifiConfiguration.class)); +// } +// +// @Test +// public void callbacks_failure_nullCallback() { +// when(mMockWiFiManager.addNetwork(any(WifiConfiguration.class))).thenReturn(WiseFy.WIFI_MANAGER_FAILURE); +// +// try { +// mWiseFy.addWEPNetwork(WEP_NETWORK_SSID, WEP_NETWORK_PASSWORD, null); +// verify(mMockWiFiManager, never()).addNetwork(any(WifiConfiguration.class)); +// } catch (NullPointerException npe) { +// fail(); +// } +// } +// +// @Test +// public void callbacks_failure_nullPasswordParam() { +// AddWEPNetworkCallbacks mockCallbacks = mock(AddWEPNetworkCallbacks.class); +// mWiseFy.addWEPNetwork(WEP_NETWORK_SSID, null, mockCallbacks); +// verify(mockCallbacks, timeout(VERIFICATION_TIMEOUT)).addWEPNetworkWiseFyFailure(WiseFyCodes.MISSING_PARAMETER); +// verify(mMockWiFiManager, never()).addNetwork(any(WifiConfiguration.class)); +// } +// +// @Test +// public void callbacks_failure_nullPasswordParam_nullCallback() { +// try { +// mWiseFy.addWEPNetwork(WEP_NETWORK_SSID, null, null); +// verify(mMockWiFiManager, never()).addNetwork(any(WifiConfiguration.class)); +// } catch (NullPointerException npe) { +// fail(); +// } +// } +// +// @Test +// public void callbacks_failure_nullSSIDParam() { +// AddWEPNetworkCallbacks mockCallbacks = mock(AddWEPNetworkCallbacks.class); +// mWiseFy.addWEPNetwork(null, WEP_NETWORK_PASSWORD, mockCallbacks); +// verify(mockCallbacks, timeout(VERIFICATION_TIMEOUT)).addWEPNetworkWiseFyFailure(WiseFyCodes.MISSING_PARAMETER); +// verify(mMockWiFiManager, never()).addNetwork(any(WifiConfiguration.class)); +// } +// +// @Test +// public void callbacks_failure_nullSSIDParam_nullCallback() { +// try { +// mWiseFy.addWEPNetwork(null, WEP_NETWORK_PASSWORD, null); +// verify(mMockWiFiManager, never()).addNetwork(any(WifiConfiguration.class)); +// } catch (NullPointerException npe) { +// fail(); +// } +// } +// +// @Test +// public void callbacks_failure_missingPrerequisite() { +// missingPrerequisite(); +// AddWEPNetworkCallbacks mockCallbacks = mock(AddWEPNetworkCallbacks.class); +// mWiseFy.addWEPNetwork(WEP_NETWORK_SSID, WEP_NETWORK_PASSWORD, mockCallbacks); +// verify(mockCallbacks, timeout(VERIFICATION_TIMEOUT)).addWEPNetworkWiseFyFailure(WiseFyCodes.MISSING_PREREQUISITE); +// verify(mMockWiFiManager, never()).addNetwork(any(WifiConfiguration.class)); +// } +// +// @Test +// public void callbacks_failure_missingPrerequisite_nullCallback() { +// missingPrerequisite(); +// +// try { +// mWiseFy.addWEPNetwork(WEP_NETWORK_SSID, WEP_NETWORK_PASSWORD, null); +// verify(mMockWiFiManager, never()).addNetwork(any(WifiConfiguration.class)); +// } catch (NullPointerException npe) { +// fail(); +// } +// } +// +// @Test +// public void callbacks_success() { +// when(mMockWiFiManager.addNetwork(any(WifiConfiguration.class))).thenReturn(0); +// AddWEPNetworkCallbacks mockCallbacks = mock(AddWEPNetworkCallbacks.class); +// mWiseFy.addWEPNetwork(WEP_NETWORK_SSID, WEP_NETWORK_PASSWORD, mockCallbacks); +// verify(mockCallbacks, timeout(VERIFICATION_TIMEOUT)).wepNetworkAdded(any(WifiConfiguration.class)); +// verify(mMockWiFiManager, timeout(VERIFICATION_TIMEOUT)).addNetwork(any(WifiConfiguration.class)); +// } +// +// @Test +// public void callbacks_success_nullCallback() { +// when(mMockWiFiManager.addNetwork(any(WifiConfiguration.class))).thenReturn(0); +// +// try { +// mWiseFy.addWEPNetwork(WEP_NETWORK_SSID, WEP_NETWORK_PASSWORD, null); +// verify(mMockWiFiManager, never()).addNetwork(any(WifiConfiguration.class)); +// } catch (NullPointerException npe) { +// fail(); +// } +// } +// +// @Test +// public void callbacks_success_alreadyConfigured() { +// networkAlreadyInConfigurationList(); +// +// AddWEPNetworkCallbacks mockCallbacks = mock(AddWEPNetworkCallbacks.class); +// mWiseFy.addWEPNetwork(WEP_NETWORK_SSID, WEP_NETWORK_PASSWORD, mockCallbacks); +// verify(mockCallbacks, timeout(VERIFICATION_TIMEOUT)).addWEPNetworkWiseFyFailure(WiseFyCodes.NETWORK_ALREADY_CONFIGURED); +// verify(mMockWiFiManager, never()).addNetwork(any(WifiConfiguration.class)); +// } +// +// @Test +// public void callbacks_success_alreadyConfigured_nullCallback() { +// networkAlreadyInConfigurationList(); +// +// try { +// mWiseFy.addWEPNetwork(WEP_NETWORK_SSID, WEP_NETWORK_PASSWORD, null); +// verify(mMockWiFiManager, never()).addNetwork(any(WifiConfiguration.class)); +// } catch (NullPointerException npe) { +// fail(); +// } +// } +//} diff --git a/wisefy/src/androidTest/java/com/isupatches/wisefy/AddWPA2NetworkTests.java b/wisefy/src/androidTest/java/com/isupatches/wisefy/AddWPA2NetworkTests.java index 4e3d2480..fab3629a 100644 --- a/wisefy/src/androidTest/java/com/isupatches/wisefy/AddWPA2NetworkTests.java +++ b/wisefy/src/androidTest/java/com/isupatches/wisefy/AddWPA2NetworkTests.java @@ -1,187 +1,187 @@ -package com.isupatches.wisefy; - - -import android.net.wifi.WifiConfiguration; -import com.isupatches.wisefy.base.TestActivity; -import com.isupatches.wisefy.callbacks.AddWPA2NetworkCallbacks; -import com.isupatches.wisefy.constants.WiseFyCodes; -import org.junit.Test; -import static com.isupatches.wisefy.base.TestUtils.WPA2_NETWORK_PASSWORD; -import static com.isupatches.wisefy.base.TestUtils.WPA2_NETWORK_SSID; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotEquals; -import static org.junit.Assert.fail; -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.never; -import static org.mockito.Mockito.timeout; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; - - -public class AddWPA2NetworkTests extends BaseTestClass { - - public AddWPA2NetworkTests() { - super(TestActivity.class); - } - - @Test - public void noCallbacks_failure() { - when(mMockWiFiManager.addNetwork(any(WifiConfiguration.class))).thenReturn(WiseFy.WIFI_MANAGER_FAILURE); - assertEquals(WiseFy.WIFI_MANAGER_FAILURE, mWiseFy.addWPA2Network(WPA2_NETWORK_SSID, WPA2_NETWORK_PASSWORD)); - verify(mMockWiFiManager, timeout(VERIFICATION_TIMEOUT)).addNetwork(any(WifiConfiguration.class)); - } - - @Test - public void noCallbacks_failure_nullPasswordParam() { - assertEquals(WiseFyCodes.MISSING_PARAMETER, mWiseFy.addWPA2Network(WPA2_NETWORK_SSID, null)); - verify(mMockWiFiManager, never()).addNetwork(any(WifiConfiguration.class)); - } - - @Test - public void anoCallbacks_failure_nullSSIDParam() { - assertEquals(WiseFyCodes.MISSING_PARAMETER, mWiseFy.addWPA2Network(null, WPA2_NETWORK_PASSWORD)); - verify(mMockWiFiManager, never()).addNetwork(any(WifiConfiguration.class)); - } - - @Test - public void noCallbacks_failure_missingPrerequisite() { - missingPrerequisite(); - assertEquals(WiseFyCodes.MISSING_PREREQUISITE, mWiseFy.addWPA2Network(WPA2_NETWORK_SSID, WPA2_NETWORK_PASSWORD)); - verify(mMockWiFiManager, never()).addNetwork(any(WifiConfiguration.class)); - } - - @Test - public void noCallbacks_success() { - when(mMockWiFiManager.addNetwork(any(WifiConfiguration.class))).thenReturn(0); - assertNotEquals(WiseFy.WIFI_MANAGER_FAILURE, mWiseFy.addWPA2Network(WPA2_NETWORK_SSID, WPA2_NETWORK_PASSWORD)); - verify(mMockWiFiManager, timeout(VERIFICATION_TIMEOUT)).addNetwork(any(WifiConfiguration.class)); - } - - @Test - public void noCallbacks_success_alreadyConfigured() { - networkAlreadyInConfigurationList(); - assertEquals(WiseFyCodes.NETWORK_ALREADY_CONFIGURED, mWiseFy.addWPA2Network(WPA2_NETWORK_SSID, WPA2_NETWORK_PASSWORD)); - verify(mMockWiFiManager, never()).addNetwork(any(WifiConfiguration.class)); - } - - @Test - public void callbacks_failure() { - when(mMockWiFiManager.addNetwork(any(WifiConfiguration.class))).thenReturn(WiseFy.WIFI_MANAGER_FAILURE); - AddWPA2NetworkCallbacks mockCallbacks = mock(AddWPA2NetworkCallbacks.class); - mWiseFy.addWPA2Network(WPA2_NETWORK_SSID, WPA2_NETWORK_PASSWORD, mockCallbacks); - verify(mockCallbacks, timeout(VERIFICATION_TIMEOUT)).failureAddingWPA2Network(WiseFy.WIFI_MANAGER_FAILURE); - verify(mMockWiFiManager, timeout(VERIFICATION_TIMEOUT)).addNetwork(any(WifiConfiguration.class)); - } - - @Test - public void callbacks_failure_nullCallback() { - when(mMockWiFiManager.addNetwork(any(WifiConfiguration.class))).thenReturn(WiseFy.WIFI_MANAGER_FAILURE); - try { - mWiseFy.addWPA2Network(WPA2_NETWORK_SSID, WPA2_NETWORK_PASSWORD, null); - verify(mMockWiFiManager, never()).addNetwork(any(WifiConfiguration.class)); - } catch (NullPointerException npe) { - fail(); - } - } - - @Test - public void callbacks_failure_nullPasswordParam() { - AddWPA2NetworkCallbacks mockCallbacks = mock(AddWPA2NetworkCallbacks.class); - mWiseFy.addWPA2Network(WPA2_NETWORK_SSID, null, mockCallbacks); - verify(mockCallbacks, timeout(VERIFICATION_TIMEOUT)).addWPA2NetworkWiseFyFailure(WiseFyCodes.MISSING_PARAMETER); - verify(mMockWiFiManager, never()).addNetwork(any(WifiConfiguration.class)); - } - - @Test - public void callbacks_failure_nullPasswordParam_nullCallback() { - try { - mWiseFy.addWPA2Network(WPA2_NETWORK_SSID, null, null); - verify(mMockWiFiManager, never()).addNetwork(any(WifiConfiguration.class)); - } catch (NullPointerException npe) { - fail(); - } - } - - @Test - public void callbacks_failure_nullSSIDParam() { - AddWPA2NetworkCallbacks mockCallbacks = mock(AddWPA2NetworkCallbacks.class); - mWiseFy.addWPA2Network(null, WPA2_NETWORK_PASSWORD, mockCallbacks); - verify(mockCallbacks, never()).addWPA2NetworkWiseFyFailure(WiseFyCodes.MISSING_PARAMETER); - } - - @Test - public void callbacks_failure_nullSSIDParam_nullCallback() { - try { - mWiseFy.addWPA2Network(null, WPA2_NETWORK_PASSWORD, null); - verify(mMockWiFiManager, never()).addNetwork(any(WifiConfiguration.class)); - } catch (NullPointerException npe) { - fail(); - } - } - - @Test - public void callbacks_failure_missingPrerequisite() { - missingPrerequisite(); - - AddWPA2NetworkCallbacks mockCallbacks = mock(AddWPA2NetworkCallbacks.class); - mWiseFy.addWPA2Network(WPA2_NETWORK_SSID, WPA2_NETWORK_PASSWORD, mockCallbacks); - verify(mockCallbacks, timeout(VERIFICATION_TIMEOUT)).addWPA2NetworkWiseFyFailure(WiseFyCodes.MISSING_PREREQUISITE); - verify(mMockWiFiManager, never()).addNetwork(any(WifiConfiguration.class)); - } - - @Test - public void callbacks_failure_missingPrerequisite_nullCallback() { - missingPrerequisite(); - - try { - mWiseFy.addWPA2Network(WPA2_NETWORK_SSID, WPA2_NETWORK_PASSWORD, null); - verify(mMockWiFiManager, never()).addNetwork(any(WifiConfiguration.class)); - } catch (NullPointerException npe) { - fail(); - } - } - - @Test - public void callbacks_success() { - when(mMockWiFiManager.addNetwork(any(WifiConfiguration.class))).thenReturn(0); - AddWPA2NetworkCallbacks mockCallbacks = mock(AddWPA2NetworkCallbacks.class); - mWiseFy.addWPA2Network(WPA2_NETWORK_SSID, WPA2_NETWORK_PASSWORD, mockCallbacks); - verify(mockCallbacks, timeout(VERIFICATION_TIMEOUT)).wpa2NetworkAdded(any(WifiConfiguration.class)); - verify(mMockWiFiManager, timeout(VERIFICATION_TIMEOUT)).addNetwork(any(WifiConfiguration.class)); - } - - @Test - public void callbacks_success_nullCallback() { - when(mMockWiFiManager.addNetwork(any(WifiConfiguration.class))).thenReturn(0); - - try { - mWiseFy.addWPA2Network(WPA2_NETWORK_SSID, WPA2_NETWORK_PASSWORD, null); - verify(mMockWiFiManager, never()).addNetwork(any(WifiConfiguration.class)); - } catch (NullPointerException npe) { - fail(); - } - } - - @Test - public void callbacks_success_alreadyConfigured() { - networkAlreadyInConfigurationList(); - - AddWPA2NetworkCallbacks mockCallbacks = mock(AddWPA2NetworkCallbacks.class); - mWiseFy.addWPA2Network(WPA2_NETWORK_SSID, WPA2_NETWORK_PASSWORD, mockCallbacks); - verify(mockCallbacks, timeout(VERIFICATION_TIMEOUT)).addWPA2NetworkWiseFyFailure(WiseFyCodes.NETWORK_ALREADY_CONFIGURED); - verify(mMockWiFiManager, never()).addNetwork(any(WifiConfiguration.class)); - } - - @Test - public void callbacks_success_alreadyConfigured_nullCallback() { - networkAlreadyInConfigurationList(); - - try { - mWiseFy.addWPA2Network(WPA2_NETWORK_SSID, WPA2_NETWORK_PASSWORD, null); - verify(mMockWiFiManager, never()).addNetwork(any(WifiConfiguration.class)); - } catch (NullPointerException npe) { - fail(); - } - } -} +//package com.isupatches.wisefy; +// +// +//import android.net.wifi.WifiConfiguration; +//import com.isupatches.wisefy.base.TestActivity; +//import com.isupatches.wisefy.callbacks.AddWPA2NetworkCallbacks; +//import com.isupatches.wisefy.constants.WiseFyCodes; +//import org.junit.Test; +//import static com.isupatches.wisefy.base.TestUtils.WPA2_NETWORK_PASSWORD; +//import static com.isupatches.wisefy.base.TestUtils.WPA2_NETWORK_SSID; +//import static org.junit.Assert.assertEquals; +//import static org.junit.Assert.assertNotEquals; +//import static org.junit.Assert.fail; +//import static org.mockito.ArgumentMatchers.any; +//import static org.mockito.Mockito.mock; +//import static org.mockito.Mockito.never; +//import static org.mockito.Mockito.timeout; +//import static org.mockito.Mockito.verify; +//import static org.mockito.Mockito.when; +// +// +//public class AddWPA2NetworkTests extends BaseTestClass { +// +// public AddWPA2NetworkTests() { +// super(TestActivity.class); +// } +// +// @Test +// public void noCallbacks_failure() { +// when(mMockWiFiManager.addNetwork(any(WifiConfiguration.class))).thenReturn(WiseFy.WIFI_MANAGER_FAILURE); +// assertEquals(WiseFy.WIFI_MANAGER_FAILURE, mWiseFy.addWPA2Network(WPA2_NETWORK_SSID, WPA2_NETWORK_PASSWORD)); +// verify(mMockWiFiManager, timeout(VERIFICATION_TIMEOUT)).addNetwork(any(WifiConfiguration.class)); +// } +// +// @Test +// public void noCallbacks_failure_nullPasswordParam() { +// assertEquals(WiseFyCodes.MISSING_PARAMETER, mWiseFy.addWPA2Network(WPA2_NETWORK_SSID, null)); +// verify(mMockWiFiManager, never()).addNetwork(any(WifiConfiguration.class)); +// } +// +// @Test +// public void anoCallbacks_failure_nullSSIDParam() { +// assertEquals(WiseFyCodes.MISSING_PARAMETER, mWiseFy.addWPA2Network(null, WPA2_NETWORK_PASSWORD)); +// verify(mMockWiFiManager, never()).addNetwork(any(WifiConfiguration.class)); +// } +// +// @Test +// public void noCallbacks_failure_missingPrerequisite() { +// missingPrerequisite(); +// assertEquals(WiseFyCodes.MISSING_PREREQUISITE, mWiseFy.addWPA2Network(WPA2_NETWORK_SSID, WPA2_NETWORK_PASSWORD)); +// verify(mMockWiFiManager, never()).addNetwork(any(WifiConfiguration.class)); +// } +// +// @Test +// public void noCallbacks_success() { +// when(mMockWiFiManager.addNetwork(any(WifiConfiguration.class))).thenReturn(0); +// assertNotEquals(WiseFy.WIFI_MANAGER_FAILURE, mWiseFy.addWPA2Network(WPA2_NETWORK_SSID, WPA2_NETWORK_PASSWORD)); +// verify(mMockWiFiManager, timeout(VERIFICATION_TIMEOUT)).addNetwork(any(WifiConfiguration.class)); +// } +// +// @Test +// public void noCallbacks_success_alreadyConfigured() { +// networkAlreadyInConfigurationList(); +// assertEquals(WiseFyCodes.NETWORK_ALREADY_CONFIGURED, mWiseFy.addWPA2Network(WPA2_NETWORK_SSID, WPA2_NETWORK_PASSWORD)); +// verify(mMockWiFiManager, never()).addNetwork(any(WifiConfiguration.class)); +// } +// +// @Test +// public void callbacks_failure() { +// when(mMockWiFiManager.addNetwork(any(WifiConfiguration.class))).thenReturn(WiseFy.WIFI_MANAGER_FAILURE); +// AddWPA2NetworkCallbacks mockCallbacks = mock(AddWPA2NetworkCallbacks.class); +// mWiseFy.addWPA2Network(WPA2_NETWORK_SSID, WPA2_NETWORK_PASSWORD, mockCallbacks); +// verify(mockCallbacks, timeout(VERIFICATION_TIMEOUT)).failureAddingWPA2Network(WiseFy.WIFI_MANAGER_FAILURE); +// verify(mMockWiFiManager, timeout(VERIFICATION_TIMEOUT)).addNetwork(any(WifiConfiguration.class)); +// } +// +// @Test +// public void callbacks_failure_nullCallback() { +// when(mMockWiFiManager.addNetwork(any(WifiConfiguration.class))).thenReturn(WiseFy.WIFI_MANAGER_FAILURE); +// try { +// mWiseFy.addWPA2Network(WPA2_NETWORK_SSID, WPA2_NETWORK_PASSWORD, null); +// verify(mMockWiFiManager, never()).addNetwork(any(WifiConfiguration.class)); +// } catch (NullPointerException npe) { +// fail(); +// } +// } +// +// @Test +// public void callbacks_failure_nullPasswordParam() { +// AddWPA2NetworkCallbacks mockCallbacks = mock(AddWPA2NetworkCallbacks.class); +// mWiseFy.addWPA2Network(WPA2_NETWORK_SSID, null, mockCallbacks); +// verify(mockCallbacks, timeout(VERIFICATION_TIMEOUT)).addWPA2NetworkWiseFyFailure(WiseFyCodes.MISSING_PARAMETER); +// verify(mMockWiFiManager, never()).addNetwork(any(WifiConfiguration.class)); +// } +// +// @Test +// public void callbacks_failure_nullPasswordParam_nullCallback() { +// try { +// mWiseFy.addWPA2Network(WPA2_NETWORK_SSID, null, null); +// verify(mMockWiFiManager, never()).addNetwork(any(WifiConfiguration.class)); +// } catch (NullPointerException npe) { +// fail(); +// } +// } +// +// @Test +// public void callbacks_failure_nullSSIDParam() { +// AddWPA2NetworkCallbacks mockCallbacks = mock(AddWPA2NetworkCallbacks.class); +// mWiseFy.addWPA2Network(null, WPA2_NETWORK_PASSWORD, mockCallbacks); +// verify(mockCallbacks, never()).addWPA2NetworkWiseFyFailure(WiseFyCodes.MISSING_PARAMETER); +// } +// +// @Test +// public void callbacks_failure_nullSSIDParam_nullCallback() { +// try { +// mWiseFy.addWPA2Network(null, WPA2_NETWORK_PASSWORD, null); +// verify(mMockWiFiManager, never()).addNetwork(any(WifiConfiguration.class)); +// } catch (NullPointerException npe) { +// fail(); +// } +// } +// +// @Test +// public void callbacks_failure_missingPrerequisite() { +// missingPrerequisite(); +// +// AddWPA2NetworkCallbacks mockCallbacks = mock(AddWPA2NetworkCallbacks.class); +// mWiseFy.addWPA2Network(WPA2_NETWORK_SSID, WPA2_NETWORK_PASSWORD, mockCallbacks); +// verify(mockCallbacks, timeout(VERIFICATION_TIMEOUT)).addWPA2NetworkWiseFyFailure(WiseFyCodes.MISSING_PREREQUISITE); +// verify(mMockWiFiManager, never()).addNetwork(any(WifiConfiguration.class)); +// } +// +// @Test +// public void callbacks_failure_missingPrerequisite_nullCallback() { +// missingPrerequisite(); +// +// try { +// mWiseFy.addWPA2Network(WPA2_NETWORK_SSID, WPA2_NETWORK_PASSWORD, null); +// verify(mMockWiFiManager, never()).addNetwork(any(WifiConfiguration.class)); +// } catch (NullPointerException npe) { +// fail(); +// } +// } +// +// @Test +// public void callbacks_success() { +// when(mMockWiFiManager.addNetwork(any(WifiConfiguration.class))).thenReturn(0); +// AddWPA2NetworkCallbacks mockCallbacks = mock(AddWPA2NetworkCallbacks.class); +// mWiseFy.addWPA2Network(WPA2_NETWORK_SSID, WPA2_NETWORK_PASSWORD, mockCallbacks); +// verify(mockCallbacks, timeout(VERIFICATION_TIMEOUT)).wpa2NetworkAdded(any(WifiConfiguration.class)); +// verify(mMockWiFiManager, timeout(VERIFICATION_TIMEOUT)).addNetwork(any(WifiConfiguration.class)); +// } +// +// @Test +// public void callbacks_success_nullCallback() { +// when(mMockWiFiManager.addNetwork(any(WifiConfiguration.class))).thenReturn(0); +// +// try { +// mWiseFy.addWPA2Network(WPA2_NETWORK_SSID, WPA2_NETWORK_PASSWORD, null); +// verify(mMockWiFiManager, never()).addNetwork(any(WifiConfiguration.class)); +// } catch (NullPointerException npe) { +// fail(); +// } +// } +// +// @Test +// public void callbacks_success_alreadyConfigured() { +// networkAlreadyInConfigurationList(); +// +// AddWPA2NetworkCallbacks mockCallbacks = mock(AddWPA2NetworkCallbacks.class); +// mWiseFy.addWPA2Network(WPA2_NETWORK_SSID, WPA2_NETWORK_PASSWORD, mockCallbacks); +// verify(mockCallbacks, timeout(VERIFICATION_TIMEOUT)).addWPA2NetworkWiseFyFailure(WiseFyCodes.NETWORK_ALREADY_CONFIGURED); +// verify(mMockWiFiManager, never()).addNetwork(any(WifiConfiguration.class)); +// } +// +// @Test +// public void callbacks_success_alreadyConfigured_nullCallback() { +// networkAlreadyInConfigurationList(); +// +// try { +// mWiseFy.addWPA2Network(WPA2_NETWORK_SSID, WPA2_NETWORK_PASSWORD, null); +// verify(mMockWiFiManager, never()).addNetwork(any(WifiConfiguration.class)); +// } catch (NullPointerException npe) { +// fail(); +// } +// } +//} diff --git a/wisefy/src/androidTest/java/com/isupatches/wisefy/ConnectToNetworkTests.java b/wisefy/src/androidTest/java/com/isupatches/wisefy/ConnectToNetworkTests.java index e5893856..55e6e960 100644 --- a/wisefy/src/androidTest/java/com/isupatches/wisefy/ConnectToNetworkTests.java +++ b/wisefy/src/androidTest/java/com/isupatches/wisefy/ConnectToNetworkTests.java @@ -1,222 +1,222 @@ -package com.isupatches.wisefy; - - -import android.net.wifi.WifiConfiguration; -import com.isupatches.wisefy.base.TestActivity; -import com.isupatches.wisefy.callbacks.ConnectToNetworkCallbacks; -import com.isupatches.wisefy.constants.WiseFyCodes; -import org.junit.Test; -import static com.isupatches.wisefy.base.TestUtils.TEST_SSID; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.fail; -import static org.mockito.ArgumentMatchers.anyBoolean; -import static org.mockito.ArgumentMatchers.anyInt; -import static org.mockito.ArgumentMatchers.anyString; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.never; -import static org.mockito.Mockito.timeout; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; - - -public class ConnectToNetworkTests extends BaseTestClass { - - public ConnectToNetworkTests() { - super(TestActivity.class); - } - - @Test - public void noCallbacks_failure_nullSSIDParam() { - assertEquals(false, mWiseFy.connectToNetwork(null, 1)); - verify(mMockWiFiManager, never()).enableNetwork(anyInt(), anyBoolean()); - } - - @Test - public void noCallbacks_failure_missingPrerequisites() { - missingPrerequisite(); - assertEquals(false, mWiseFy.connectToNetwork(TEST_SSID, 1)); - verify(mMockWiFiManager, never()).enableNetwork(anyInt(), anyBoolean()); - } - - @Test - public void noCallbacks_failure_noSavedNetwork() { - WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); - mWiseFy.mWiseFySearch = mockWiseFySearch; - when(mockWiseFySearch.findSavedNetworkByRegex(anyString())).thenReturn(null); - - assertEquals(false, mWiseFy.connectToNetwork(TEST_SSID, 1)); - verify(mMockWiFiManager, never()).enableNetwork(anyInt(), anyBoolean()); - } - - @Test - public void noCallbacks_failure() { - WifiConfiguration wiFiConfiguration = new WifiConfiguration(); - wiFiConfiguration.SSID = TEST_SSID; - WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); - mWiseFy.mWiseFySearch = mockWiseFySearch; - when(mockWiseFySearch.findSavedNetworkByRegex(anyString())).thenReturn(wiFiConfiguration); - - WiseFyConnection mockWiseFyConnection = mock(WiseFyConnection.class); - mWiseFy.mWiseFyConnection = mockWiseFyConnection; - when(mockWiseFyConnection.waitToConnectToSSID(anyString(), anyInt())).thenReturn(false); - - assertEquals(false, mWiseFy.connectToNetwork(TEST_SSID, 1)); - verify(mMockWiFiManager, timeout(VERIFICATION_TIMEOUT)).enableNetwork(anyInt(), anyBoolean()); - } - - @Test - public void noCallbacks_success() { - WifiConfiguration wiFiConfiguration = new WifiConfiguration(); - wiFiConfiguration.SSID = TEST_SSID; - WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); - mWiseFy.mWiseFySearch = mockWiseFySearch; - when(mockWiseFySearch.findSavedNetworkByRegex(anyString())).thenReturn(wiFiConfiguration); - - WiseFyConnection mockWiseFyConnection = mock(WiseFyConnection.class); - mWiseFy.mWiseFyConnection = mockWiseFyConnection; - when(mockWiseFyConnection.waitToConnectToSSID(anyString(), anyInt())).thenReturn(true); - - assertEquals(true, mWiseFy.connectToNetwork(TEST_SSID, 1)); - verify(mMockWiFiManager, timeout(VERIFICATION_TIMEOUT)).enableNetwork(anyInt(), anyBoolean()); - } - - @Test - public void callbacks_failure_nullSSIDParam() { - ConnectToNetworkCallbacks mockCallbacks = mock(ConnectToNetworkCallbacks.class); - mWiseFy.connectToNetwork(null, 1, mockCallbacks); - verify(mockCallbacks, timeout(3000)).connectToNetworkWiseFyFailure(WiseFyCodes.MISSING_PARAMETER); - verify(mMockWiFiManager, never()).enableNetwork(anyInt(), anyBoolean()); - } - - @Test - public void callbacks_failure_nullSSIDParam_nullCallback() { - try { - mWiseFy.connectToNetwork(null, 1, null); - verify(mMockWiFiManager, never()).enableNetwork(anyInt(), anyBoolean()); - } catch (NullPointerException npe) { - fail(); - } - } - - @Test - public void callbacks_failure_missingPrerequisites() { - missingPrerequisite(); - ConnectToNetworkCallbacks mockCallbacks = mock(ConnectToNetworkCallbacks.class); - mWiseFy.connectToNetwork(TEST_SSID, 1, mockCallbacks); - verify(mockCallbacks, timeout(3000)).connectToNetworkWiseFyFailure(WiseFyCodes.MISSING_PREREQUISITE); - verify(mMockWiFiManager, never()).enableNetwork(anyInt(), anyBoolean()); - } - - @Test - public void callbacks_failure_missingPrerequisites_nullCallback() { - missingPrerequisite(); - try { - mWiseFy.connectToNetwork(TEST_SSID, 1, null); - verify(mMockWiFiManager, never()).enableNetwork(anyInt(), anyBoolean()); - } catch (NullPointerException npe) { - fail(); - } - } - - @Test - public void callbacks_failure_noSavedNetwork() { - WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); - mWiseFy.mWiseFySearch = mockWiseFySearch; - when(mockWiseFySearch.findSavedNetworkByRegex(anyString())).thenReturn(null); - - ConnectToNetworkCallbacks mockCallbacks = mock(ConnectToNetworkCallbacks.class); - mWiseFy.connectToNetwork(TEST_SSID, 1, mockCallbacks); - verify(mockCallbacks, timeout(VERIFICATION_TIMEOUT)).networkNotFoundToConnectTo(); - verify(mMockWiFiManager, never()).enableNetwork(anyInt(), anyBoolean()); - } - - @Test - public void callbacks_failure_noSavedNetwork_nullCallback() { - WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); - mWiseFy.mWiseFySearch = mockWiseFySearch; - when(mockWiseFySearch.findSavedNetworkByRegex(anyString())).thenReturn(null); - - try { - mWiseFy.connectToNetwork(TEST_SSID, 1, null); - verify(mMockWiFiManager, never()).enableNetwork(anyInt(), anyBoolean()); - } catch (NullPointerException npe) { - fail(); - } - } - - @Test - public void callbacks_failure() { - WifiConfiguration wiFiConfiguration = new WifiConfiguration(); - wiFiConfiguration.SSID = TEST_SSID; - WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); - mWiseFy.mWiseFySearch = mockWiseFySearch; - when(mockWiseFySearch.findSavedNetworkByRegex(anyString())).thenReturn(wiFiConfiguration); - - WiseFyConnection mockWiseFyConnection = mock(WiseFyConnection.class); - mWiseFy.mWiseFyConnection = mockWiseFyConnection; - when(mockWiseFyConnection.waitToConnectToSSID(anyString(), anyInt())).thenReturn(false); - - ConnectToNetworkCallbacks mockCallbacks = mock(ConnectToNetworkCallbacks.class); - mWiseFy.connectToNetwork(TEST_SSID, 1, mockCallbacks); - verify(mockCallbacks, timeout(VERIFICATION_TIMEOUT)).failureConnectingToNetwork(); - verify(mMockWiFiManager, timeout(VERIFICATION_TIMEOUT)).enableNetwork(anyInt(), anyBoolean()); - } - - @Test - public void callbacks_failure_nullCallback() { - WifiConfiguration wiFiConfiguration = new WifiConfiguration(); - wiFiConfiguration.SSID = TEST_SSID; - WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); - mWiseFy.mWiseFySearch = mockWiseFySearch; - when(mockWiseFySearch.findSavedNetworkByRegex(anyString())).thenReturn(wiFiConfiguration); - - WiseFyConnection mockWiseFyConnection = mock(WiseFyConnection.class); - mWiseFy.mWiseFyConnection = mockWiseFyConnection; - when(mockWiseFyConnection.waitToConnectToSSID(anyString(), anyInt())).thenReturn(false); - - try { - mWiseFy.connectToNetwork(TEST_SSID, 1, null); - verify(mMockWiFiManager, never()).enableNetwork(anyInt(), anyBoolean()); - } catch (NullPointerException npe) { - fail(); - } - } - - @Test - public void callbacks_success() { - WifiConfiguration wiFiConfiguration = new WifiConfiguration(); - wiFiConfiguration.SSID = TEST_SSID; - WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); - mWiseFy.mWiseFySearch = mockWiseFySearch; - when(mockWiseFySearch.findSavedNetworkByRegex(anyString())).thenReturn(wiFiConfiguration); - - WiseFyConnection mockWiseFyConnection = mock(WiseFyConnection.class); - mWiseFy.mWiseFyConnection = mockWiseFyConnection; - when(mockWiseFyConnection.waitToConnectToSSID(anyString(), anyInt())).thenReturn(true); - - ConnectToNetworkCallbacks mockCallbacks = mock(ConnectToNetworkCallbacks.class); - mWiseFy.connectToNetwork(TEST_SSID, 1, mockCallbacks); - verify(mockCallbacks, timeout(VERIFICATION_TIMEOUT)).connectedToNetwork(); - verify(mMockWiFiManager, timeout(VERIFICATION_TIMEOUT)).enableNetwork(anyInt(), anyBoolean()); - } - - @Test - public void callbacks_success_nullCallback() { - WifiConfiguration wiFiConfiguration = new WifiConfiguration(); - wiFiConfiguration.SSID = TEST_SSID; - WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); - mWiseFy.mWiseFySearch = mockWiseFySearch; - when(mockWiseFySearch.findSavedNetworkByRegex(anyString())).thenReturn(wiFiConfiguration); - - WiseFyConnection mockWiseFyConnection = mock(WiseFyConnection.class); - mWiseFy.mWiseFyConnection = mockWiseFyConnection; - when(mockWiseFyConnection.waitToConnectToSSID(anyString(), anyInt())).thenReturn(true); - - try { - mWiseFy.connectToNetwork(TEST_SSID, 1, null); - verify(mMockWiFiManager, never()).enableNetwork(anyInt(), anyBoolean()); - } catch (NullPointerException npe) { - fail(); - } - } -} \ No newline at end of file +//package com.isupatches.wisefy; +// +// +//import android.net.wifi.WifiConfiguration; +//import com.isupatches.wisefy.base.TestActivity; +//import com.isupatches.wisefy.callbacks.ConnectToNetworkCallbacks; +//import com.isupatches.wisefy.constants.WiseFyCodes; +//import org.junit.Test; +//import static com.isupatches.wisefy.base.TestUtils.TEST_SSID; +//import static org.junit.Assert.assertEquals; +//import static org.junit.Assert.fail; +//import static org.mockito.ArgumentMatchers.anyBoolean; +//import static org.mockito.ArgumentMatchers.anyInt; +//import static org.mockito.ArgumentMatchers.anyString; +//import static org.mockito.Mockito.mock; +//import static org.mockito.Mockito.never; +//import static org.mockito.Mockito.timeout; +//import static org.mockito.Mockito.verify; +//import static org.mockito.Mockito.when; +// +// +//public class ConnectToNetworkTests extends BaseTestClass { +// +// public ConnectToNetworkTests() { +// super(TestActivity.class); +// } +// +// @Test +// public void noCallbacks_failure_nullSSIDParam() { +// assertEquals(false, mWiseFy.connectToNetwork(null, 1)); +// verify(mMockWiFiManager, never()).enableNetwork(anyInt(), anyBoolean()); +// } +// +// @Test +// public void noCallbacks_failure_missingPrerequisites() { +// missingPrerequisite(); +// assertEquals(false, mWiseFy.connectToNetwork(TEST_SSID, 1)); +// verify(mMockWiFiManager, never()).enableNetwork(anyInt(), anyBoolean()); +// } +// +// @Test +// public void noCallbacks_failure_noSavedNetwork() { +// WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); +// mWiseFy.mWiseFySearch = mockWiseFySearch; +// when(mockWiseFySearch.findSavedNetworkByRegex(anyString())).thenReturn(null); +// +// assertEquals(false, mWiseFy.connectToNetwork(TEST_SSID, 1)); +// verify(mMockWiFiManager, never()).enableNetwork(anyInt(), anyBoolean()); +// } +// +// @Test +// public void noCallbacks_failure() { +// WifiConfiguration wiFiConfiguration = new WifiConfiguration(); +// wiFiConfiguration.SSID = TEST_SSID; +// WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); +// mWiseFy.mWiseFySearch = mockWiseFySearch; +// when(mockWiseFySearch.findSavedNetworkByRegex(anyString())).thenReturn(wiFiConfiguration); +// +// WiseFyConnection mockWiseFyConnection = mock(WiseFyConnection.class); +// mWiseFy.mWiseFyConnection = mockWiseFyConnection; +// when(mockWiseFyConnection.waitToConnectToSSID(anyString(), anyInt())).thenReturn(false); +// +// assertEquals(false, mWiseFy.connectToNetwork(TEST_SSID, 1)); +// verify(mMockWiFiManager, timeout(VERIFICATION_TIMEOUT)).enableNetwork(anyInt(), anyBoolean()); +// } +// +// @Test +// public void noCallbacks_success() { +// WifiConfiguration wiFiConfiguration = new WifiConfiguration(); +// wiFiConfiguration.SSID = TEST_SSID; +// WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); +// mWiseFy.mWiseFySearch = mockWiseFySearch; +// when(mockWiseFySearch.findSavedNetworkByRegex(anyString())).thenReturn(wiFiConfiguration); +// +// WiseFyConnection mockWiseFyConnection = mock(WiseFyConnection.class); +// mWiseFy.mWiseFyConnection = mockWiseFyConnection; +// when(mockWiseFyConnection.waitToConnectToSSID(anyString(), anyInt())).thenReturn(true); +// +// assertEquals(true, mWiseFy.connectToNetwork(TEST_SSID, 1)); +// verify(mMockWiFiManager, timeout(VERIFICATION_TIMEOUT)).enableNetwork(anyInt(), anyBoolean()); +// } +// +// @Test +// public void callbacks_failure_nullSSIDParam() { +// ConnectToNetworkCallbacks mockCallbacks = mock(ConnectToNetworkCallbacks.class); +// mWiseFy.connectToNetwork(null, 1, mockCallbacks); +// verify(mockCallbacks, timeout(3000)).connectToNetworkWiseFyFailure(WiseFyCodes.MISSING_PARAMETER); +// verify(mMockWiFiManager, never()).enableNetwork(anyInt(), anyBoolean()); +// } +// +// @Test +// public void callbacks_failure_nullSSIDParam_nullCallback() { +// try { +// mWiseFy.connectToNetwork(null, 1, null); +// verify(mMockWiFiManager, never()).enableNetwork(anyInt(), anyBoolean()); +// } catch (NullPointerException npe) { +// fail(); +// } +// } +// +// @Test +// public void callbacks_failure_missingPrerequisites() { +// missingPrerequisite(); +// ConnectToNetworkCallbacks mockCallbacks = mock(ConnectToNetworkCallbacks.class); +// mWiseFy.connectToNetwork(TEST_SSID, 1, mockCallbacks); +// verify(mockCallbacks, timeout(3000)).connectToNetworkWiseFyFailure(WiseFyCodes.MISSING_PREREQUISITE); +// verify(mMockWiFiManager, never()).enableNetwork(anyInt(), anyBoolean()); +// } +// +// @Test +// public void callbacks_failure_missingPrerequisites_nullCallback() { +// missingPrerequisite(); +// try { +// mWiseFy.connectToNetwork(TEST_SSID, 1, null); +// verify(mMockWiFiManager, never()).enableNetwork(anyInt(), anyBoolean()); +// } catch (NullPointerException npe) { +// fail(); +// } +// } +// +// @Test +// public void callbacks_failure_noSavedNetwork() { +// WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); +// mWiseFy.mWiseFySearch = mockWiseFySearch; +// when(mockWiseFySearch.findSavedNetworkByRegex(anyString())).thenReturn(null); +// +// ConnectToNetworkCallbacks mockCallbacks = mock(ConnectToNetworkCallbacks.class); +// mWiseFy.connectToNetwork(TEST_SSID, 1, mockCallbacks); +// verify(mockCallbacks, timeout(VERIFICATION_TIMEOUT)).networkNotFoundToConnectTo(); +// verify(mMockWiFiManager, never()).enableNetwork(anyInt(), anyBoolean()); +// } +// +// @Test +// public void callbacks_failure_noSavedNetwork_nullCallback() { +// WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); +// mWiseFy.mWiseFySearch = mockWiseFySearch; +// when(mockWiseFySearch.findSavedNetworkByRegex(anyString())).thenReturn(null); +// +// try { +// mWiseFy.connectToNetwork(TEST_SSID, 1, null); +// verify(mMockWiFiManager, never()).enableNetwork(anyInt(), anyBoolean()); +// } catch (NullPointerException npe) { +// fail(); +// } +// } +// +// @Test +// public void callbacks_failure() { +// WifiConfiguration wiFiConfiguration = new WifiConfiguration(); +// wiFiConfiguration.SSID = TEST_SSID; +// WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); +// mWiseFy.mWiseFySearch = mockWiseFySearch; +// when(mockWiseFySearch.findSavedNetworkByRegex(anyString())).thenReturn(wiFiConfiguration); +// +// WiseFyConnection mockWiseFyConnection = mock(WiseFyConnection.class); +// mWiseFy.mWiseFyConnection = mockWiseFyConnection; +// when(mockWiseFyConnection.waitToConnectToSSID(anyString(), anyInt())).thenReturn(false); +// +// ConnectToNetworkCallbacks mockCallbacks = mock(ConnectToNetworkCallbacks.class); +// mWiseFy.connectToNetwork(TEST_SSID, 1, mockCallbacks); +// verify(mockCallbacks, timeout(VERIFICATION_TIMEOUT)).failureConnectingToNetwork(); +// verify(mMockWiFiManager, timeout(VERIFICATION_TIMEOUT)).enableNetwork(anyInt(), anyBoolean()); +// } +// +// @Test +// public void callbacks_failure_nullCallback() { +// WifiConfiguration wiFiConfiguration = new WifiConfiguration(); +// wiFiConfiguration.SSID = TEST_SSID; +// WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); +// mWiseFy.mWiseFySearch = mockWiseFySearch; +// when(mockWiseFySearch.findSavedNetworkByRegex(anyString())).thenReturn(wiFiConfiguration); +// +// WiseFyConnection mockWiseFyConnection = mock(WiseFyConnection.class); +// mWiseFy.mWiseFyConnection = mockWiseFyConnection; +// when(mockWiseFyConnection.waitToConnectToSSID(anyString(), anyInt())).thenReturn(false); +// +// try { +// mWiseFy.connectToNetwork(TEST_SSID, 1, null); +// verify(mMockWiFiManager, never()).enableNetwork(anyInt(), anyBoolean()); +// } catch (NullPointerException npe) { +// fail(); +// } +// } +// +// @Test +// public void callbacks_success() { +// WifiConfiguration wiFiConfiguration = new WifiConfiguration(); +// wiFiConfiguration.SSID = TEST_SSID; +// WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); +// mWiseFy.mWiseFySearch = mockWiseFySearch; +// when(mockWiseFySearch.findSavedNetworkByRegex(anyString())).thenReturn(wiFiConfiguration); +// +// WiseFyConnection mockWiseFyConnection = mock(WiseFyConnection.class); +// mWiseFy.mWiseFyConnection = mockWiseFyConnection; +// when(mockWiseFyConnection.waitToConnectToSSID(anyString(), anyInt())).thenReturn(true); +// +// ConnectToNetworkCallbacks mockCallbacks = mock(ConnectToNetworkCallbacks.class); +// mWiseFy.connectToNetwork(TEST_SSID, 1, mockCallbacks); +// verify(mockCallbacks, timeout(VERIFICATION_TIMEOUT)).connectedToNetwork(); +// verify(mMockWiFiManager, timeout(VERIFICATION_TIMEOUT)).enableNetwork(anyInt(), anyBoolean()); +// } +// +// @Test +// public void callbacks_success_nullCallback() { +// WifiConfiguration wiFiConfiguration = new WifiConfiguration(); +// wiFiConfiguration.SSID = TEST_SSID; +// WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); +// mWiseFy.mWiseFySearch = mockWiseFySearch; +// when(mockWiseFySearch.findSavedNetworkByRegex(anyString())).thenReturn(wiFiConfiguration); +// +// WiseFyConnection mockWiseFyConnection = mock(WiseFyConnection.class); +// mWiseFy.mWiseFyConnection = mockWiseFyConnection; +// when(mockWiseFyConnection.waitToConnectToSSID(anyString(), anyInt())).thenReturn(true); +// +// try { +// mWiseFy.connectToNetwork(TEST_SSID, 1, null); +// verify(mMockWiFiManager, never()).enableNetwork(anyInt(), anyBoolean()); +// } catch (NullPointerException npe) { +// fail(); +// } +// } +//} \ No newline at end of file diff --git a/wisefy/src/androidTest/java/com/isupatches/wisefy/DisableWifiTests.java b/wisefy/src/androidTest/java/com/isupatches/wisefy/DisableWifiTests.java index 9afbe40d..f77d387a 100644 --- a/wisefy/src/androidTest/java/com/isupatches/wisefy/DisableWifiTests.java +++ b/wisefy/src/androidTest/java/com/isupatches/wisefy/DisableWifiTests.java @@ -1,104 +1,104 @@ -package com.isupatches.wisefy; - - -import com.isupatches.wisefy.base.TestActivity; -import com.isupatches.wisefy.callbacks.DisableWifiCallbacks; -import com.isupatches.wisefy.constants.WiseFyCodes; -import org.junit.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.fail; -import static org.mockito.ArgumentMatchers.anyBoolean; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.never; -import static org.mockito.Mockito.timeout; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; - - -public class DisableWifiTests extends BaseTestClass { - - public DisableWifiTests() { - super(TestActivity.class); - } - - @Test - public void noCallbacks_failure() { - when(mMockWiFiManager.setWifiEnabled(anyBoolean())).thenReturn(false); - assertEquals(false, mWiseFy.disableWifi()); - verify(mMockWiFiManager, timeout(VERIFICATION_TIMEOUT)).setWifiEnabled(false); - } - - @Test - public void noCallbacks_failure_missingPrerequisite() { - missingPrerequisite(); - assertEquals(false, mWiseFy.disableWifi()); - verify(mMockWiFiManager, never()).setWifiEnabled(false); - } - - @Test - public void noCallbacks_success() { - when(mMockWiFiManager.setWifiEnabled(anyBoolean())).thenReturn(true); - assertEquals(true, mWiseFy.disableWifi()); - verify(mMockWiFiManager, timeout(VERIFICATION_TIMEOUT)).setWifiEnabled(false); - } - - @Test - public void callbacks_failure() { - when(mMockWiFiManager.setWifiEnabled(anyBoolean())).thenReturn(false); - DisableWifiCallbacks mockCallbacks = mock(DisableWifiCallbacks.class); - mWiseFy.disableWifi(mockCallbacks); - verify(mMockWiFiManager, timeout(VERIFICATION_TIMEOUT)).setWifiEnabled(false); - verify(mockCallbacks, timeout(VERIFICATION_TIMEOUT)).failureDisablingWifi(); - } - - @Test - public void callbacks_failure_nullCallback() { - when(mMockWiFiManager.setWifiEnabled(anyBoolean())).thenReturn(false); - try { - mWiseFy.disableWifi(null); - verify(mMockWiFiManager, never()).setWifiEnabled(false); - } catch (NullPointerException npe) { - fail(); - } - } - - @Test - public void callbacks_failure_missingPrerequisite() { - missingPrerequisite(); - DisableWifiCallbacks mockCallbacks = mock(DisableWifiCallbacks.class); - mWiseFy.disableWifi(mockCallbacks); - verify(mMockWiFiManager, never()).setWifiEnabled(false); - verify(mockCallbacks, timeout(VERIFICATION_TIMEOUT)).disableWifiWiseFyFailure(WiseFyCodes.MISSING_PREREQUISITE); - } - - @Test - public void callbacks_failure_missingPrerequisite_nullCallback() { - missingPrerequisite(); - try { - mWiseFy.disableWifi(null); - verify(mMockWiFiManager, never()).setWifiEnabled(false); - } catch (NullPointerException npe) { - fail(); - } - } - - @Test - public void callbacks_success() { - when(mMockWiFiManager.setWifiEnabled(anyBoolean())).thenReturn(true); - DisableWifiCallbacks mockCallbacks = mock(DisableWifiCallbacks.class); - mWiseFy.disableWifi(mockCallbacks); - verify(mMockWiFiManager, timeout(VERIFICATION_TIMEOUT)).setWifiEnabled(false); - verify(mockCallbacks, timeout(VERIFICATION_TIMEOUT)).wifiDisabled(); - } - - @Test - public void callbacks_success_nullCallback() { - when(mMockWiFiManager.setWifiEnabled(anyBoolean())).thenReturn(true); - try { - mWiseFy.disableWifi(null); - verify(mMockWiFiManager, never()).setWifiEnabled(false); - } catch (NullPointerException npe) { - fail(); - } - } -} +//package com.isupatches.wisefy; +// +// +//import com.isupatches.wisefy.base.TestActivity; +//import com.isupatches.wisefy.callbacks.DisableWifiCallbacks; +//import com.isupatches.wisefy.constants.WiseFyCodes; +//import org.junit.Test; +//import static org.junit.Assert.assertEquals; +//import static org.junit.Assert.fail; +//import static org.mockito.ArgumentMatchers.anyBoolean; +//import static org.mockito.Mockito.mock; +//import static org.mockito.Mockito.never; +//import static org.mockito.Mockito.timeout; +//import static org.mockito.Mockito.verify; +//import static org.mockito.Mockito.when; +// +// +//public class DisableWifiTests extends BaseTestClass { +// +// public DisableWifiTests() { +// super(TestActivity.class); +// } +// +// @Test +// public void noCallbacks_failure() { +// when(mMockWiFiManager.setWifiEnabled(anyBoolean())).thenReturn(false); +// assertEquals(false, mWiseFy.disableWifi()); +// verify(mMockWiFiManager, timeout(VERIFICATION_TIMEOUT)).setWifiEnabled(false); +// } +// +// @Test +// public void noCallbacks_failure_missingPrerequisite() { +// missingPrerequisite(); +// assertEquals(false, mWiseFy.disableWifi()); +// verify(mMockWiFiManager, never()).setWifiEnabled(false); +// } +// +// @Test +// public void noCallbacks_success() { +// when(mMockWiFiManager.setWifiEnabled(anyBoolean())).thenReturn(true); +// assertEquals(true, mWiseFy.disableWifi()); +// verify(mMockWiFiManager, timeout(VERIFICATION_TIMEOUT)).setWifiEnabled(false); +// } +// +// @Test +// public void callbacks_failure() { +// when(mMockWiFiManager.setWifiEnabled(anyBoolean())).thenReturn(false); +// DisableWifiCallbacks mockCallbacks = mock(DisableWifiCallbacks.class); +// mWiseFy.disableWifi(mockCallbacks); +// verify(mMockWiFiManager, timeout(VERIFICATION_TIMEOUT)).setWifiEnabled(false); +// verify(mockCallbacks, timeout(VERIFICATION_TIMEOUT)).failureDisablingWifi(); +// } +// +// @Test +// public void callbacks_failure_nullCallback() { +// when(mMockWiFiManager.setWifiEnabled(anyBoolean())).thenReturn(false); +// try { +// mWiseFy.disableWifi(null); +// verify(mMockWiFiManager, never()).setWifiEnabled(false); +// } catch (NullPointerException npe) { +// fail(); +// } +// } +// +// @Test +// public void callbacks_failure_missingPrerequisite() { +// missingPrerequisite(); +// DisableWifiCallbacks mockCallbacks = mock(DisableWifiCallbacks.class); +// mWiseFy.disableWifi(mockCallbacks); +// verify(mMockWiFiManager, never()).setWifiEnabled(false); +// verify(mockCallbacks, timeout(VERIFICATION_TIMEOUT)).disableWifiWiseFyFailure(WiseFyCodes.MISSING_PREREQUISITE); +// } +// +// @Test +// public void callbacks_failure_missingPrerequisite_nullCallback() { +// missingPrerequisite(); +// try { +// mWiseFy.disableWifi(null); +// verify(mMockWiFiManager, never()).setWifiEnabled(false); +// } catch (NullPointerException npe) { +// fail(); +// } +// } +// +// @Test +// public void callbacks_success() { +// when(mMockWiFiManager.setWifiEnabled(anyBoolean())).thenReturn(true); +// DisableWifiCallbacks mockCallbacks = mock(DisableWifiCallbacks.class); +// mWiseFy.disableWifi(mockCallbacks); +// verify(mMockWiFiManager, timeout(VERIFICATION_TIMEOUT)).setWifiEnabled(false); +// verify(mockCallbacks, timeout(VERIFICATION_TIMEOUT)).wifiDisabled(); +// } +// +// @Test +// public void callbacks_success_nullCallback() { +// when(mMockWiFiManager.setWifiEnabled(anyBoolean())).thenReturn(true); +// try { +// mWiseFy.disableWifi(null); +// verify(mMockWiFiManager, never()).setWifiEnabled(false); +// } catch (NullPointerException npe) { +// fail(); +// } +// } +//} diff --git a/wisefy/src/androidTest/java/com/isupatches/wisefy/DisconnectFromCurrentNetworkTests.java b/wisefy/src/androidTest/java/com/isupatches/wisefy/DisconnectFromCurrentNetworkTests.java index d26f12a4..9b10a2eb 100644 --- a/wisefy/src/androidTest/java/com/isupatches/wisefy/DisconnectFromCurrentNetworkTests.java +++ b/wisefy/src/androidTest/java/com/isupatches/wisefy/DisconnectFromCurrentNetworkTests.java @@ -1,103 +1,103 @@ -package com.isupatches.wisefy; - - -import com.isupatches.wisefy.base.TestActivity; -import com.isupatches.wisefy.callbacks.DisconnectFromCurrentNetworkCallbacks; -import com.isupatches.wisefy.constants.WiseFyCodes; -import org.junit.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.fail; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.never; -import static org.mockito.Mockito.timeout; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; - - -public class DisconnectFromCurrentNetworkTests extends BaseTestClass { - - public DisconnectFromCurrentNetworkTests() { - super(TestActivity.class); - } - - @Test - public void noCallbacks_failure() { - when(mMockWiFiManager.disconnect()).thenReturn(false); - assertEquals(false, mWiseFy.disconnectFromCurrentNetwork()); - verify(mMockWiFiManager, timeout(VERIFICATION_TIMEOUT)).disconnect(); - } - - @Test - public void noCallbacks_failure_missingPrerequisite() { - missingPrerequisite(); - assertEquals(false, mWiseFy.disconnectFromCurrentNetwork()); - verify(mMockWiFiManager, never()).disconnect(); - } - - @Test - public void noCallbacks_success() { - when(mMockWiFiManager.disconnect()).thenReturn(true); - assertEquals(true, mWiseFy.disconnectFromCurrentNetwork()); - verify(mMockWiFiManager, timeout(VERIFICATION_TIMEOUT)).disconnect(); - } - - @Test - public void callbacks_failure() { - when(mMockWiFiManager.disconnect()).thenReturn(false); - DisconnectFromCurrentNetworkCallbacks mockCallbacks = mock(DisconnectFromCurrentNetworkCallbacks.class); - mWiseFy.disconnectFromCurrentNetwork(mockCallbacks); - verify(mMockWiFiManager, timeout(VERIFICATION_TIMEOUT)).disconnect(); - verify(mockCallbacks, timeout(VERIFICATION_TIMEOUT)).failureDisconnectingFromCurrentNetwork(); - } - - @Test - public void callbacks_failure_nullCallback() { - when(mMockWiFiManager.disconnect()).thenReturn(false); - try { - mWiseFy.disconnectFromCurrentNetwork(null); - verify(mMockWiFiManager, never()).disconnect(); - } catch (NullPointerException npe) { - fail(); - } - } - - @Test - public void callbacks_failure_missingPrerequisite() { - missingPrerequisite(); - DisconnectFromCurrentNetworkCallbacks mockCallbacks = mock(DisconnectFromCurrentNetworkCallbacks.class); - mWiseFy.disconnectFromCurrentNetwork(mockCallbacks); - verify(mMockWiFiManager, never()).disconnect(); - verify(mockCallbacks, timeout(VERIFICATION_TIMEOUT)).disconnectFromCurrentNetworkWiseFyFailure(WiseFyCodes.MISSING_PREREQUISITE); - } - - @Test - public void callbacks_failure_missingPrerequisite_nullCallback() { - missingPrerequisite(); - try { - mWiseFy.disconnectFromCurrentNetwork(null); - verify(mMockWiFiManager, never()).disconnect(); - } catch (NullPointerException npe) { - fail(); - } - } - - @Test - public void callbacks_success() { - when(mMockWiFiManager.disconnect()).thenReturn(true); - DisconnectFromCurrentNetworkCallbacks mockCallbacks = mock(DisconnectFromCurrentNetworkCallbacks.class); - mWiseFy.disconnectFromCurrentNetwork(mockCallbacks); - verify(mMockWiFiManager, timeout(VERIFICATION_TIMEOUT)).disconnect(); - verify(mockCallbacks, timeout(VERIFICATION_TIMEOUT)).disconnectedFromCurrentNetwork(); - } - - @Test - public void callbacks_success_nullCallback() { - when(mMockWiFiManager.disconnect()).thenReturn(true); - try { - mWiseFy.disconnectFromCurrentNetwork(null); - verify(mMockWiFiManager, never()).disconnect(); - } catch (NullPointerException npe) { - fail(); - } - } -} +//package com.isupatches.wisefy; +// +// +//import com.isupatches.wisefy.base.TestActivity; +//import com.isupatches.wisefy.callbacks.DisconnectFromCurrentNetworkCallbacks; +//import com.isupatches.wisefy.constants.WiseFyCodes; +//import org.junit.Test; +//import static org.junit.Assert.assertEquals; +//import static org.junit.Assert.fail; +//import static org.mockito.Mockito.mock; +//import static org.mockito.Mockito.never; +//import static org.mockito.Mockito.timeout; +//import static org.mockito.Mockito.verify; +//import static org.mockito.Mockito.when; +// +// +//public class DisconnectFromCurrentNetworkTests extends BaseTestClass { +// +// public DisconnectFromCurrentNetworkTests() { +// super(TestActivity.class); +// } +// +// @Test +// public void noCallbacks_failure() { +// when(mMockWiFiManager.disconnect()).thenReturn(false); +// assertEquals(false, mWiseFy.disconnectFromCurrentNetwork()); +// verify(mMockWiFiManager, timeout(VERIFICATION_TIMEOUT)).disconnect(); +// } +// +// @Test +// public void noCallbacks_failure_missingPrerequisite() { +// missingPrerequisite(); +// assertEquals(false, mWiseFy.disconnectFromCurrentNetwork()); +// verify(mMockWiFiManager, never()).disconnect(); +// } +// +// @Test +// public void noCallbacks_success() { +// when(mMockWiFiManager.disconnect()).thenReturn(true); +// assertEquals(true, mWiseFy.disconnectFromCurrentNetwork()); +// verify(mMockWiFiManager, timeout(VERIFICATION_TIMEOUT)).disconnect(); +// } +// +// @Test +// public void callbacks_failure() { +// when(mMockWiFiManager.disconnect()).thenReturn(false); +// DisconnectFromCurrentNetworkCallbacks mockCallbacks = mock(DisconnectFromCurrentNetworkCallbacks.class); +// mWiseFy.disconnectFromCurrentNetwork(mockCallbacks); +// verify(mMockWiFiManager, timeout(VERIFICATION_TIMEOUT)).disconnect(); +// verify(mockCallbacks, timeout(VERIFICATION_TIMEOUT)).failureDisconnectingFromCurrentNetwork(); +// } +// +// @Test +// public void callbacks_failure_nullCallback() { +// when(mMockWiFiManager.disconnect()).thenReturn(false); +// try { +// mWiseFy.disconnectFromCurrentNetwork(null); +// verify(mMockWiFiManager, never()).disconnect(); +// } catch (NullPointerException npe) { +// fail(); +// } +// } +// +// @Test +// public void callbacks_failure_missingPrerequisite() { +// missingPrerequisite(); +// DisconnectFromCurrentNetworkCallbacks mockCallbacks = mock(DisconnectFromCurrentNetworkCallbacks.class); +// mWiseFy.disconnectFromCurrentNetwork(mockCallbacks); +// verify(mMockWiFiManager, never()).disconnect(); +// verify(mockCallbacks, timeout(VERIFICATION_TIMEOUT)).disconnectFromCurrentNetworkWiseFyFailure(WiseFyCodes.MISSING_PREREQUISITE); +// } +// +// @Test +// public void callbacks_failure_missingPrerequisite_nullCallback() { +// missingPrerequisite(); +// try { +// mWiseFy.disconnectFromCurrentNetwork(null); +// verify(mMockWiFiManager, never()).disconnect(); +// } catch (NullPointerException npe) { +// fail(); +// } +// } +// +// @Test +// public void callbacks_success() { +// when(mMockWiFiManager.disconnect()).thenReturn(true); +// DisconnectFromCurrentNetworkCallbacks mockCallbacks = mock(DisconnectFromCurrentNetworkCallbacks.class); +// mWiseFy.disconnectFromCurrentNetwork(mockCallbacks); +// verify(mMockWiFiManager, timeout(VERIFICATION_TIMEOUT)).disconnect(); +// verify(mockCallbacks, timeout(VERIFICATION_TIMEOUT)).disconnectedFromCurrentNetwork(); +// } +// +// @Test +// public void callbacks_success_nullCallback() { +// when(mMockWiFiManager.disconnect()).thenReturn(true); +// try { +// mWiseFy.disconnectFromCurrentNetwork(null); +// verify(mMockWiFiManager, never()).disconnect(); +// } catch (NullPointerException npe) { +// fail(); +// } +// } +//} diff --git a/wisefy/src/androidTest/java/com/isupatches/wisefy/EnableWifiTests.java b/wisefy/src/androidTest/java/com/isupatches/wisefy/EnableWifiTests.java index f962b3e7..e68d4e38 100644 --- a/wisefy/src/androidTest/java/com/isupatches/wisefy/EnableWifiTests.java +++ b/wisefy/src/androidTest/java/com/isupatches/wisefy/EnableWifiTests.java @@ -1,104 +1,104 @@ -package com.isupatches.wisefy; - - -import com.isupatches.wisefy.base.TestActivity; -import com.isupatches.wisefy.callbacks.EnableWifiCallbacks; -import com.isupatches.wisefy.constants.WiseFyCodes; -import org.junit.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.fail; -import static org.mockito.ArgumentMatchers.anyBoolean; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.never; -import static org.mockito.Mockito.timeout; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; - - -public class EnableWifiTests extends BaseTestClass { - - public EnableWifiTests() { - super(TestActivity.class); - } - - @Test - public void noCallbacks_failure() { - when(mMockWiFiManager.setWifiEnabled(anyBoolean())).thenReturn(false); - assertEquals(false, mWiseFy.enableWifi()); - verify(mMockWiFiManager, timeout(VERIFICATION_TIMEOUT)).setWifiEnabled(true); - } - - @Test - public void noCallbacks_failure_missingPrerequisite() { - missingPrerequisite(); - assertEquals(false, mWiseFy.enableWifi()); - verify(mMockWiFiManager, never()).setWifiEnabled(true); - } - - @Test - public void noCallbacks_success() { - when(mMockWiFiManager.setWifiEnabled(anyBoolean())).thenReturn(true); - assertEquals(true, mWiseFy.enableWifi()); - verify(mMockWiFiManager, timeout(VERIFICATION_TIMEOUT)).setWifiEnabled(true); - } - - @Test - public void callbacks_failure() { - when(mMockWiFiManager.setWifiEnabled(anyBoolean())).thenReturn(false); - EnableWifiCallbacks mockCallbacks = mock(EnableWifiCallbacks.class); - mWiseFy.enableWifi(mockCallbacks); - verify(mMockWiFiManager, timeout(VERIFICATION_TIMEOUT)).setWifiEnabled(true); - verify(mockCallbacks, timeout(VERIFICATION_TIMEOUT)).failureEnablingWifi(); - } - - @Test - public void callbacks_failure_nullCallback() { - when(mMockWiFiManager.setWifiEnabled(anyBoolean())).thenReturn(false); - try { - mWiseFy.enableWifi(null); - verify(mMockWiFiManager, never()).setWifiEnabled(true); - } catch (NullPointerException npe) { - fail(); - } - } - - @Test - public void callbacks_failure_missingPrerequisite() { - missingPrerequisite(); - EnableWifiCallbacks mockCallbacks = mock(EnableWifiCallbacks.class); - mWiseFy.enableWifi(mockCallbacks); - verify(mMockWiFiManager, never()).setWifiEnabled(true); - verify(mockCallbacks, timeout(VERIFICATION_TIMEOUT)).enableWifiWiseFyFailure(WiseFyCodes.MISSING_PREREQUISITE); - } - - @Test - public void callbacks_failure_missingPrerequisite_nullCallback() { - missingPrerequisite(); - try { - mWiseFy.enableWifi(null); - verify(mMockWiFiManager, never()).setWifiEnabled(true); - } catch (NullPointerException npe) { - fail(); - } - } - - @Test - public void callbacks_success() { - when(mMockWiFiManager.setWifiEnabled(anyBoolean())).thenReturn(true); - EnableWifiCallbacks mockCallbacks = mock(EnableWifiCallbacks.class); - mWiseFy.enableWifi(mockCallbacks); - verify(mMockWiFiManager, timeout(VERIFICATION_TIMEOUT)).setWifiEnabled(true); - verify(mockCallbacks, timeout(VERIFICATION_TIMEOUT)).wifiEnabled(); - } - - @Test - public void callbacks_success_nullCallback() { - when(mMockWiFiManager.setWifiEnabled(anyBoolean())).thenReturn(true); - try { - mWiseFy.enableWifi(null); - verify(mMockWiFiManager, never()).setWifiEnabled(true); - } catch (NullPointerException npe) { - fail(); - } - } -} +//package com.isupatches.wisefy; +// +// +//import com.isupatches.wisefy.base.TestActivity; +//import com.isupatches.wisefy.callbacks.EnableWifiCallbacks; +//import com.isupatches.wisefy.constants.WiseFyCodes; +//import org.junit.Test; +//import static org.junit.Assert.assertEquals; +//import static org.junit.Assert.fail; +//import static org.mockito.ArgumentMatchers.anyBoolean; +//import static org.mockito.Mockito.mock; +//import static org.mockito.Mockito.never; +//import static org.mockito.Mockito.timeout; +//import static org.mockito.Mockito.verify; +//import static org.mockito.Mockito.when; +// +// +//public class EnableWifiTests extends BaseTestClass { +// +// public EnableWifiTests() { +// super(TestActivity.class); +// } +// +// @Test +// public void noCallbacks_failure() { +// when(mMockWiFiManager.setWifiEnabled(anyBoolean())).thenReturn(false); +// assertEquals(false, mWiseFy.enableWifi()); +// verify(mMockWiFiManager, timeout(VERIFICATION_TIMEOUT)).setWifiEnabled(true); +// } +// +// @Test +// public void noCallbacks_failure_missingPrerequisite() { +// missingPrerequisite(); +// assertEquals(false, mWiseFy.enableWifi()); +// verify(mMockWiFiManager, never()).setWifiEnabled(true); +// } +// +// @Test +// public void noCallbacks_success() { +// when(mMockWiFiManager.setWifiEnabled(anyBoolean())).thenReturn(true); +// assertEquals(true, mWiseFy.enableWifi()); +// verify(mMockWiFiManager, timeout(VERIFICATION_TIMEOUT)).setWifiEnabled(true); +// } +// +// @Test +// public void callbacks_failure() { +// when(mMockWiFiManager.setWifiEnabled(anyBoolean())).thenReturn(false); +// EnableWifiCallbacks mockCallbacks = mock(EnableWifiCallbacks.class); +// mWiseFy.enableWifi(mockCallbacks); +// verify(mMockWiFiManager, timeout(VERIFICATION_TIMEOUT)).setWifiEnabled(true); +// verify(mockCallbacks, timeout(VERIFICATION_TIMEOUT)).failureEnablingWifi(); +// } +// +// @Test +// public void callbacks_failure_nullCallback() { +// when(mMockWiFiManager.setWifiEnabled(anyBoolean())).thenReturn(false); +// try { +// mWiseFy.enableWifi(null); +// verify(mMockWiFiManager, never()).setWifiEnabled(true); +// } catch (NullPointerException npe) { +// fail(); +// } +// } +// +// @Test +// public void callbacks_failure_missingPrerequisite() { +// missingPrerequisite(); +// EnableWifiCallbacks mockCallbacks = mock(EnableWifiCallbacks.class); +// mWiseFy.enableWifi(mockCallbacks); +// verify(mMockWiFiManager, never()).setWifiEnabled(true); +// verify(mockCallbacks, timeout(VERIFICATION_TIMEOUT)).enableWifiWiseFyFailure(WiseFyCodes.MISSING_PREREQUISITE); +// } +// +// @Test +// public void callbacks_failure_missingPrerequisite_nullCallback() { +// missingPrerequisite(); +// try { +// mWiseFy.enableWifi(null); +// verify(mMockWiFiManager, never()).setWifiEnabled(true); +// } catch (NullPointerException npe) { +// fail(); +// } +// } +// +// @Test +// public void callbacks_success() { +// when(mMockWiFiManager.setWifiEnabled(anyBoolean())).thenReturn(true); +// EnableWifiCallbacks mockCallbacks = mock(EnableWifiCallbacks.class); +// mWiseFy.enableWifi(mockCallbacks); +// verify(mMockWiFiManager, timeout(VERIFICATION_TIMEOUT)).setWifiEnabled(true); +// verify(mockCallbacks, timeout(VERIFICATION_TIMEOUT)).wifiEnabled(); +// } +// +// @Test +// public void callbacks_success_nullCallback() { +// when(mMockWiFiManager.setWifiEnabled(anyBoolean())).thenReturn(true); +// try { +// mWiseFy.enableWifi(null); +// verify(mMockWiFiManager, never()).setWifiEnabled(true); +// } catch (NullPointerException npe) { +// fail(); +// } +// } +//} diff --git a/wisefy/src/androidTest/java/com/isupatches/wisefy/GetCurrentNetworkTests.java b/wisefy/src/androidTest/java/com/isupatches/wisefy/GetCurrentNetworkTests.java index 6acdfd66..960f7bbc 100644 --- a/wisefy/src/androidTest/java/com/isupatches/wisefy/GetCurrentNetworkTests.java +++ b/wisefy/src/androidTest/java/com/isupatches/wisefy/GetCurrentNetworkTests.java @@ -1,87 +1,87 @@ -package com.isupatches.wisefy; - - -import android.net.wifi.WifiInfo; -import com.isupatches.wisefy.base.TestActivity; -import com.isupatches.wisefy.callbacks.GetCurrentNetworkCallbacks; -import com.isupatches.wisefy.constants.WiseFyCodes; -import org.junit.Test; -import static com.isupatches.wisefy.base.TestUtils.TEST_SSID; -import static junit.framework.Assert.assertEquals; -import static junit.framework.Assert.fail; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.never; -import static org.mockito.Mockito.timeout; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; - - -public class GetCurrentNetworkTests extends BaseTestClass { - - public GetCurrentNetworkTests() { - super(TestActivity.class); - } - - @Test - public void noCallbacks_failure_missingPrerequisite() { - missingPrerequisite(); - assertEquals(null, mWiseFy.getCurrentNetwork()); - verify(mMockWiFiManager, never()).getConnectionInfo(); - } - - @Test - public void noCallbacks_success() { - WifiInfo mockWifiInfo = mock(WifiInfo.class); - when(mockWifiInfo.getSSID()).thenReturn(TEST_SSID); - when(mMockWiFiManager.getConnectionInfo()).thenReturn(mockWifiInfo); - - assertEquals(TEST_SSID, mWiseFy.getCurrentNetwork().getSSID()); - verify(mMockWiFiManager, timeout(VERIFICATION_TIMEOUT)).getConnectionInfo(); - } - - @Test - public void callbacks_failure_missingPrerequisite() { - missingPrerequisite(); - GetCurrentNetworkCallbacks mockCallbacks = mock(GetCurrentNetworkCallbacks.class); - mWiseFy.getCurrentNetwork(mockCallbacks); - verify(mockCallbacks, timeout(VERIFICATION_TIMEOUT)).getCurrentNetworkWiseFyFailure(WiseFyCodes.MISSING_PREREQUISITE); - verify(mMockWiFiManager, never()).getConnectionInfo(); - } - - @Test - public void callbacks_failure_missingPrerequisite_nullCallbacks() { - missingPrerequisite(); - try { - mWiseFy.getCurrentNetwork(null); - verify(mMockWiFiManager, never()).getConnectionInfo(); - } catch (NullPointerException npe) { - fail(); - } - } - - @Test - public void callbacks_success() { - WifiInfo mockWifiInfo = mock(WifiInfo.class); - when(mockWifiInfo.getSSID()).thenReturn(TEST_SSID); - when(mMockWiFiManager.getConnectionInfo()).thenReturn(mockWifiInfo); - - GetCurrentNetworkCallbacks mockCallbacks = mock(GetCurrentNetworkCallbacks.class); - mWiseFy.getCurrentNetwork(mockCallbacks); - verify(mockCallbacks, timeout(2000)).retrievedCurrentNetwork(mockWifiInfo); - verify(mMockWiFiManager, timeout(VERIFICATION_TIMEOUT)).getConnectionInfo(); - } - - @Test - public void callbacks_success_nullCallback() { - WifiInfo mockWifiInfo = mock(WifiInfo.class); - when(mockWifiInfo.getSSID()).thenReturn(TEST_SSID); - when(mMockWiFiManager.getConnectionInfo()).thenReturn(mockWifiInfo); - - try { - mWiseFy.getCurrentNetwork(null); - verify(mMockWiFiManager, never()).getConnectionInfo(); - } catch (NullPointerException npe) { - fail(); - } - } -} +//package com.isupatches.wisefy; +// +// +//import android.net.wifi.WifiInfo; +//import com.isupatches.wisefy.base.TestActivity; +//import com.isupatches.wisefy.callbacks.GetCurrentNetworkCallbacks; +//import com.isupatches.wisefy.constants.WiseFyCodes; +//import org.junit.Test; +//import static com.isupatches.wisefy.base.TestUtils.TEST_SSID; +//import static junit.framework.Assert.assertEquals; +//import static junit.framework.Assert.fail; +//import static org.mockito.Mockito.mock; +//import static org.mockito.Mockito.never; +//import static org.mockito.Mockito.timeout; +//import static org.mockito.Mockito.verify; +//import static org.mockito.Mockito.when; +// +// +//public class GetCurrentNetworkTests extends BaseTestClass { +// +// public GetCurrentNetworkTests() { +// super(TestActivity.class); +// } +// +// @Test +// public void noCallbacks_failure_missingPrerequisite() { +// missingPrerequisite(); +// assertEquals(null, mWiseFy.getCurrentNetwork()); +// verify(mMockWiFiManager, never()).getConnectionInfo(); +// } +// +// @Test +// public void noCallbacks_success() { +// WifiInfo mockWifiInfo = mock(WifiInfo.class); +// when(mockWifiInfo.getSSID()).thenReturn(TEST_SSID); +// when(mMockWiFiManager.getConnectionInfo()).thenReturn(mockWifiInfo); +// +// assertEquals(TEST_SSID, mWiseFy.getCurrentNetwork().getSSID()); +// verify(mMockWiFiManager, timeout(VERIFICATION_TIMEOUT)).getConnectionInfo(); +// } +// +// @Test +// public void callbacks_failure_missingPrerequisite() { +// missingPrerequisite(); +// GetCurrentNetworkCallbacks mockCallbacks = mock(GetCurrentNetworkCallbacks.class); +// mWiseFy.getCurrentNetwork(mockCallbacks); +// verify(mockCallbacks, timeout(VERIFICATION_TIMEOUT)).getCurrentNetworkWiseFyFailure(WiseFyCodes.MISSING_PREREQUISITE); +// verify(mMockWiFiManager, never()).getConnectionInfo(); +// } +// +// @Test +// public void callbacks_failure_missingPrerequisite_nullCallbacks() { +// missingPrerequisite(); +// try { +// mWiseFy.getCurrentNetwork(null); +// verify(mMockWiFiManager, never()).getConnectionInfo(); +// } catch (NullPointerException npe) { +// fail(); +// } +// } +// +// @Test +// public void callbacks_success() { +// WifiInfo mockWifiInfo = mock(WifiInfo.class); +// when(mockWifiInfo.getSSID()).thenReturn(TEST_SSID); +// when(mMockWiFiManager.getConnectionInfo()).thenReturn(mockWifiInfo); +// +// GetCurrentNetworkCallbacks mockCallbacks = mock(GetCurrentNetworkCallbacks.class); +// mWiseFy.getCurrentNetwork(mockCallbacks); +// verify(mockCallbacks, timeout(2000)).retrievedCurrentNetwork(mockWifiInfo); +// verify(mMockWiFiManager, timeout(VERIFICATION_TIMEOUT)).getConnectionInfo(); +// } +// +// @Test +// public void callbacks_success_nullCallback() { +// WifiInfo mockWifiInfo = mock(WifiInfo.class); +// when(mockWifiInfo.getSSID()).thenReturn(TEST_SSID); +// when(mMockWiFiManager.getConnectionInfo()).thenReturn(mockWifiInfo); +// +// try { +// mWiseFy.getCurrentNetwork(null); +// verify(mMockWiFiManager, never()).getConnectionInfo(); +// } catch (NullPointerException npe) { +// fail(); +// } +// } +//} diff --git a/wisefy/src/androidTest/java/com/isupatches/wisefy/GetFrequencyTests.java b/wisefy/src/androidTest/java/com/isupatches/wisefy/GetFrequencyTests.java index 3963809e..181af04e 100644 --- a/wisefy/src/androidTest/java/com/isupatches/wisefy/GetFrequencyTests.java +++ b/wisefy/src/androidTest/java/com/isupatches/wisefy/GetFrequencyTests.java @@ -1,158 +1,158 @@ -package com.isupatches.wisefy; - - -import android.net.wifi.WifiInfo; -import android.os.Build; -import com.isupatches.wisefy.base.TestActivity; -import com.isupatches.wisefy.callbacks.GetFrequencyCallbacks; -import com.isupatches.wisefy.constants.WiseFyCodes; -import org.junit.Test; -import static com.isupatches.wisefy.base.TestUtils.TEST_NETWORK_FREQUENCY_24GHZ; -import static junit.framework.Assert.assertEquals; -import static junit.framework.Assert.fail; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.timeout; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; - - -public class GetFrequencyTests extends BaseTestClass { - - public GetFrequencyTests() { - super(TestActivity.class); - } - - @Test - public void noCallbacks_getFrequency_currentNetwork_failure() { - if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { - when(mMockWiFiManager.getConnectionInfo()).thenReturn(null); - assertEquals(null, mWiseFy.getFrequency()); - } - } - - @Test - public void noCallbacks_getFrequency_currentNetwork_success() { - if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { - WifiInfo mockWifiInfo = mock(WifiInfo.class); - when(mockWifiInfo.getFrequency()).thenReturn(TEST_NETWORK_FREQUENCY_24GHZ); - when(mMockWiFiManager.getConnectionInfo()).thenReturn(mockWifiInfo); - assertEquals(TEST_NETWORK_FREQUENCY_24GHZ, (int) mWiseFy.getFrequency()); - verify(mockWifiInfo, timeout(VERIFICATION_TIMEOUT)).getFrequency(); - } - } - - @Test - public void callbacks_getFrequency_currentNetwork_failure() { - if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { - when(mMockWiFiManager.getConnectionInfo()).thenReturn(null); - GetFrequencyCallbacks mockCallbacks = mock(GetFrequencyCallbacks.class); - mWiseFy.getFrequency(mockCallbacks); - verify(mockCallbacks, timeout(2000)).failureGettingFrequency(); - } - } - - @Test - public void callbacks_getFrequency_currentNetwork_failure_nullCallback() { - if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { - when(mMockWiFiManager.getConnectionInfo()).thenReturn(null); - try { - mWiseFy.getFrequency((GetFrequencyCallbacks) null); - } catch (NullPointerException npe) { - fail(); - } - } - } - - @Test - public void callbacks_getFrequency_currentNetwork_success() { - if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { - WifiInfo mockWifiInfo = mock(WifiInfo.class); - when(mockWifiInfo.getFrequency()).thenReturn(TEST_NETWORK_FREQUENCY_24GHZ); - when(mMockWiFiManager.getConnectionInfo()).thenReturn(mockWifiInfo); - GetFrequencyCallbacks mockCallbacks = mock(GetFrequencyCallbacks.class); - mWiseFy.getFrequency(mockCallbacks); - verify(mockCallbacks, timeout(VERIFICATION_TIMEOUT)).retrievedFrequency(TEST_NETWORK_FREQUENCY_24GHZ); - verify(mockWifiInfo, timeout(VERIFICATION_TIMEOUT)).getFrequency(); - } - } - - @Test - public void callbacks_getFrequency_currentNetwork_success_nullCallback() { - if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { - WifiInfo mockWifiInfo = mock(WifiInfo.class); - when(mockWifiInfo.getFrequency()).thenReturn(TEST_NETWORK_FREQUENCY_24GHZ); - when(mMockWiFiManager.getConnectionInfo()).thenReturn(mockWifiInfo); - try { - mWiseFy.getFrequency((GetFrequencyCallbacks) null); - } catch (NullPointerException npe) { - fail(); - } - } - } - - @Test - public void noCallbacks_getFrequency_provideWifiInfo_failure() { - if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { - when(mMockWiFiManager.getConnectionInfo()).thenReturn(null); - assertEquals(null, mWiseFy.getFrequency((WifiInfo) null)); - } - } - - @Test - public void noCallbacks_getFrequency_provideWifiInfo_success() { - if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { - WifiInfo mockWifiInfo = mock(WifiInfo.class); - when(mockWifiInfo.getFrequency()).thenReturn(TEST_NETWORK_FREQUENCY_24GHZ); - when(mMockWiFiManager.getConnectionInfo()).thenReturn(mockWifiInfo); - assertEquals(TEST_NETWORK_FREQUENCY_24GHZ, (int) mWiseFy.getFrequency(mockWifiInfo)); - } - } - - @Test - public void callbacks_getFrequency_provideWifiInfo_failure() { - if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { - when(mMockWiFiManager.getConnectionInfo()).thenReturn(null); - GetFrequencyCallbacks mockCallbacks = mock(GetFrequencyCallbacks.class); - mWiseFy.getFrequency(null, mockCallbacks); - verify(mockCallbacks, timeout(2000)).getFrequencyWiseFyFailure(WiseFyCodes.MISSING_PARAMETER); - } - } - - @Test - public void callbacks_getFrequency_provideWifiInfo_failure_nullCallback() { - if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { - when(mMockWiFiManager.getConnectionInfo()).thenReturn(null); - try { - mWiseFy.getFrequency(null, null); - } catch (NullPointerException npe) { - fail(); - } - } - } - - @Test - public void callbacks_getFrequency_provideWifiInfo_success() { - if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { - WifiInfo mockWifiInfo = mock(WifiInfo.class); - when(mockWifiInfo.getFrequency()).thenReturn(TEST_NETWORK_FREQUENCY_24GHZ); - when(mMockWiFiManager.getConnectionInfo()).thenReturn(mockWifiInfo); - GetFrequencyCallbacks mockCallbacks = mock(GetFrequencyCallbacks.class); - mWiseFy.getFrequency(mockWifiInfo, mockCallbacks); - verify(mockCallbacks, timeout(2000)).retrievedFrequency(TEST_NETWORK_FREQUENCY_24GHZ); - } - } - - @Test - public void callbacks_getFrequency_provideWifiInfo_success_nullCallback() { - if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { - WifiInfo mockWifiInfo = mock(WifiInfo.class); - when(mockWifiInfo.getFrequency()).thenReturn(TEST_NETWORK_FREQUENCY_24GHZ); - when(mMockWiFiManager.getConnectionInfo()).thenReturn(mockWifiInfo); - try { - mWiseFy.getFrequency(mockWifiInfo, null); - } catch (NullPointerException npe) { - fail(); - } - } - } -} +//package com.isupatches.wisefy; +// +// +//import android.net.wifi.WifiInfo; +//import android.os.Build; +//import com.isupatches.wisefy.base.TestActivity; +//import com.isupatches.wisefy.callbacks.GetFrequencyCallbacks; +//import com.isupatches.wisefy.constants.WiseFyCodes; +//import org.junit.Test; +//import static com.isupatches.wisefy.base.TestUtils.TEST_NETWORK_FREQUENCY_24GHZ; +//import static junit.framework.Assert.assertEquals; +//import static junit.framework.Assert.fail; +//import static org.mockito.Mockito.mock; +//import static org.mockito.Mockito.timeout; +//import static org.mockito.Mockito.verify; +//import static org.mockito.Mockito.when; +// +// +//public class GetFrequencyTests extends BaseTestClass { +// +// public GetFrequencyTests() { +// super(TestActivity.class); +// } +// +// @Test +// public void noCallbacks_getFrequency_currentNetwork_failure() { +// if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { +// when(mMockWiFiManager.getConnectionInfo()).thenReturn(null); +// assertEquals(null, mWiseFy.getFrequency()); +// } +// } +// +// @Test +// public void noCallbacks_getFrequency_currentNetwork_success() { +// if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { +// WifiInfo mockWifiInfo = mock(WifiInfo.class); +// when(mockWifiInfo.getFrequency()).thenReturn(TEST_NETWORK_FREQUENCY_24GHZ); +// when(mMockWiFiManager.getConnectionInfo()).thenReturn(mockWifiInfo); +// assertEquals(TEST_NETWORK_FREQUENCY_24GHZ, (int) mWiseFy.getFrequency()); +// verify(mockWifiInfo, timeout(VERIFICATION_TIMEOUT)).getFrequency(); +// } +// } +// +// @Test +// public void callbacks_getFrequency_currentNetwork_failure() { +// if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { +// when(mMockWiFiManager.getConnectionInfo()).thenReturn(null); +// GetFrequencyCallbacks mockCallbacks = mock(GetFrequencyCallbacks.class); +// mWiseFy.getFrequency(mockCallbacks); +// verify(mockCallbacks, timeout(2000)).failureGettingFrequency(); +// } +// } +// +// @Test +// public void callbacks_getFrequency_currentNetwork_failure_nullCallback() { +// if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { +// when(mMockWiFiManager.getConnectionInfo()).thenReturn(null); +// try { +// mWiseFy.getFrequency((GetFrequencyCallbacks) null); +// } catch (NullPointerException npe) { +// fail(); +// } +// } +// } +// +// @Test +// public void callbacks_getFrequency_currentNetwork_success() { +// if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { +// WifiInfo mockWifiInfo = mock(WifiInfo.class); +// when(mockWifiInfo.getFrequency()).thenReturn(TEST_NETWORK_FREQUENCY_24GHZ); +// when(mMockWiFiManager.getConnectionInfo()).thenReturn(mockWifiInfo); +// GetFrequencyCallbacks mockCallbacks = mock(GetFrequencyCallbacks.class); +// mWiseFy.getFrequency(mockCallbacks); +// verify(mockCallbacks, timeout(VERIFICATION_TIMEOUT)).retrievedFrequency(TEST_NETWORK_FREQUENCY_24GHZ); +// verify(mockWifiInfo, timeout(VERIFICATION_TIMEOUT)).getFrequency(); +// } +// } +// +// @Test +// public void callbacks_getFrequency_currentNetwork_success_nullCallback() { +// if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { +// WifiInfo mockWifiInfo = mock(WifiInfo.class); +// when(mockWifiInfo.getFrequency()).thenReturn(TEST_NETWORK_FREQUENCY_24GHZ); +// when(mMockWiFiManager.getConnectionInfo()).thenReturn(mockWifiInfo); +// try { +// mWiseFy.getFrequency((GetFrequencyCallbacks) null); +// } catch (NullPointerException npe) { +// fail(); +// } +// } +// } +// +// @Test +// public void noCallbacks_getFrequency_provideWifiInfo_failure() { +// if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { +// when(mMockWiFiManager.getConnectionInfo()).thenReturn(null); +// assertEquals(null, mWiseFy.getFrequency((WifiInfo) null)); +// } +// } +// +// @Test +// public void noCallbacks_getFrequency_provideWifiInfo_success() { +// if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { +// WifiInfo mockWifiInfo = mock(WifiInfo.class); +// when(mockWifiInfo.getFrequency()).thenReturn(TEST_NETWORK_FREQUENCY_24GHZ); +// when(mMockWiFiManager.getConnectionInfo()).thenReturn(mockWifiInfo); +// assertEquals(TEST_NETWORK_FREQUENCY_24GHZ, (int) mWiseFy.getFrequency(mockWifiInfo)); +// } +// } +// +// @Test +// public void callbacks_getFrequency_provideWifiInfo_failure() { +// if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { +// when(mMockWiFiManager.getConnectionInfo()).thenReturn(null); +// GetFrequencyCallbacks mockCallbacks = mock(GetFrequencyCallbacks.class); +// mWiseFy.getFrequency(null, mockCallbacks); +// verify(mockCallbacks, timeout(2000)).getFrequencyWiseFyFailure(WiseFyCodes.MISSING_PARAMETER); +// } +// } +// +// @Test +// public void callbacks_getFrequency_provideWifiInfo_failure_nullCallback() { +// if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { +// when(mMockWiFiManager.getConnectionInfo()).thenReturn(null); +// try { +// mWiseFy.getFrequency(null, null); +// } catch (NullPointerException npe) { +// fail(); +// } +// } +// } +// +// @Test +// public void callbacks_getFrequency_provideWifiInfo_success() { +// if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { +// WifiInfo mockWifiInfo = mock(WifiInfo.class); +// when(mockWifiInfo.getFrequency()).thenReturn(TEST_NETWORK_FREQUENCY_24GHZ); +// when(mMockWiFiManager.getConnectionInfo()).thenReturn(mockWifiInfo); +// GetFrequencyCallbacks mockCallbacks = mock(GetFrequencyCallbacks.class); +// mWiseFy.getFrequency(mockWifiInfo, mockCallbacks); +// verify(mockCallbacks, timeout(2000)).retrievedFrequency(TEST_NETWORK_FREQUENCY_24GHZ); +// } +// } +// +// @Test +// public void callbacks_getFrequency_provideWifiInfo_success_nullCallback() { +// if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { +// WifiInfo mockWifiInfo = mock(WifiInfo.class); +// when(mockWifiInfo.getFrequency()).thenReturn(TEST_NETWORK_FREQUENCY_24GHZ); +// when(mMockWiFiManager.getConnectionInfo()).thenReturn(mockWifiInfo); +// try { +// mWiseFy.getFrequency(mockWifiInfo, null); +// } catch (NullPointerException npe) { +// fail(); +// } +// } +// } +//} diff --git a/wisefy/src/androidTest/java/com/isupatches/wisefy/GetNearbyAccessPointsTests.java b/wisefy/src/androidTest/java/com/isupatches/wisefy/GetNearbyAccessPointsTests.java index df07acfc..c8c64b5e 100644 --- a/wisefy/src/androidTest/java/com/isupatches/wisefy/GetNearbyAccessPointsTests.java +++ b/wisefy/src/androidTest/java/com/isupatches/wisefy/GetNearbyAccessPointsTests.java @@ -1,210 +1,210 @@ -package com.isupatches.wisefy; - - -import android.net.wifi.ScanResult; -import com.isupatches.wisefy.base.TestActivity; -import com.isupatches.wisefy.callbacks.GetNearbyAccessPointsCallbacks; -import com.isupatches.wisefy.constants.WiseFyCodes; -import org.junit.Test; -import org.mockito.ArgumentMatchers; -import java.util.ArrayList; -import java.util.List; -import static com.isupatches.wisefy.base.TestUtils.TEST_SSID; -import static com.isupatches.wisefy.base.TestUtils.TEST_SSID2; -import static junit.framework.Assert.assertEquals; -import static junit.framework.Assert.fail; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.never; -import static org.mockito.Mockito.timeout; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; - - -public class GetNearbyAccessPointsTests extends BaseTestClass { - - public GetNearbyAccessPointsTests() { - super(TestActivity.class); - } - - @Test - public void noCallbacks_failure_missingPrerequisite_filterDuplicates_false() { - missingPrerequisite(); - assertEquals(null, mWiseFy.getNearbyAccessPoints(false)); - verify(mMockWiFiManager, never()).getScanResults(); - } - - @Test - public void noCallbacks_failure_missingPrerequisite_filterDuplicates_true() { - missingPrerequisite(); - assertEquals(null, mWiseFy.getNearbyAccessPoints(true)); - verify(mMockWiFiManager, never()).getScanResults(); - } - - @Test - public void noCallbacks_success_filterDuplicates_false() { - List scanResults = new ArrayList<>(); - ScanResult scanResult1 = mock(ScanResult.class); - scanResult1.SSID = TEST_SSID; - scanResult1.level = -35; - scanResults.add(scanResult1); - ScanResult scanResult2 = mock(ScanResult.class); - scanResult2.SSID = TEST_SSID2; - scanResult2.level = -70; - scanResults.add(scanResult2); - - when(mMockWiFiManager.getScanResults()).thenReturn(scanResults); - - List accessPoints = mWiseFy.getNearbyAccessPoints(false); - assertEquals(accessPoints, scanResults); - verify(mMockWiFiManager, timeout(VERIFICATION_TIMEOUT)).getScanResults(); - } - - @Test - public void noCallbacks_success_filterDuplicates_true() { - List scanResults = new ArrayList<>(); - ScanResult scanResult1 = mock(ScanResult.class); - scanResult1.SSID = TEST_SSID; - scanResult1.level = -35; - scanResults.add(scanResult1); - ScanResult scanResult2 = mock(ScanResult.class); - scanResult2.SSID = TEST_SSID2; - scanResult2.level = -70; - scanResults.add(scanResult2); - - WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); - mWiseFy.mWiseFySearch = mockWiseFySearch; - when(mockWiseFySearch.removeEntriesWithLowerSignalStrength(ArgumentMatchers.anyList())).thenReturn(scanResults); - - List accessPoints = mWiseFy.getNearbyAccessPoints(true); - assertEquals(accessPoints, scanResults); - verify(mMockWiFiManager, timeout(VERIFICATION_TIMEOUT)).getScanResults(); - } - - @Test - public void callbacks_failure_missingPrerequisite_filterDuplicates_false() { - missingPrerequisite(); - GetNearbyAccessPointsCallbacks mockCallbacks = mock(GetNearbyAccessPointsCallbacks.class); - mWiseFy.getNearbyAccessPoints(false, mockCallbacks); - verify(mockCallbacks, timeout(VERIFICATION_TIMEOUT)).getNearbyAccessPointsWiseFyFailure(WiseFyCodes.MISSING_PREREQUISITE); - verify(mMockWiFiManager, never()).getScanResults(); - } - - @Test - public void callbacks_failure_missingPrerequisite_filterDuplicates_false_nullCallback() { - missingPrerequisite(); - try { - mWiseFy.getNearbyAccessPoints(false, null); - verify(mMockWiFiManager, never()).getScanResults(); - } catch (NullPointerException npe) { - fail(); - } - } - - @Test - public void callbacks_failure_missingPrerequisite_filterDuplicates_true() { - missingPrerequisite(); - GetNearbyAccessPointsCallbacks mockCallbacks = mock(GetNearbyAccessPointsCallbacks.class); - mWiseFy.getNearbyAccessPoints(true, mockCallbacks); - verify(mockCallbacks, timeout(3000)).getNearbyAccessPointsWiseFyFailure(WiseFyCodes.MISSING_PREREQUISITE); - verify(mMockWiFiManager, never()).getScanResults(); - } - - @Test - public void callbacks_failure_missingPrerequisite_filterDuplicates_true_nullCallback() { - missingPrerequisite(); - try { - mWiseFy.getNearbyAccessPoints(true, null); - verify(mMockWiFiManager, never()).getScanResults(); - } catch (NullPointerException npe) { - fail(); - } - } - - @Test - public void callbacks_success_filterDuplicates_false() { - List scanResults = new ArrayList<>(); - ScanResult scanResult1 = mock(ScanResult.class); - scanResult1.SSID = TEST_SSID; - scanResult1.level = -35; - scanResults.add(scanResult1); - ScanResult scanResult2 = mock(ScanResult.class); - scanResult2.SSID = TEST_SSID2; - scanResult2.level = -70; - scanResults.add(scanResult2); - - when(mMockWiFiManager.getScanResults()).thenReturn(scanResults); - - GetNearbyAccessPointsCallbacks mockCallbacks = mock(GetNearbyAccessPointsCallbacks.class); - mWiseFy.getNearbyAccessPoints(false, mockCallbacks); - verify(mockCallbacks, timeout(VERIFICATION_TIMEOUT)).retrievedNearbyAccessPoints(scanResults); - verify(mMockWiFiManager, timeout(VERIFICATION_TIMEOUT)).getScanResults(); - } - - @Test - public void callbacks_success_filterDuplicates_false_nullCallback() { - List scanResults = new ArrayList<>(); - ScanResult scanResult1 = mock(ScanResult.class); - scanResult1.SSID = TEST_SSID; - scanResult1.level = -35; - scanResults.add(scanResult1); - ScanResult scanResult2 = mock(ScanResult.class); - scanResult2.SSID = TEST_SSID2; - scanResult2.level = -70; - scanResults.add(scanResult2); - - when(mMockWiFiManager.getScanResults()).thenReturn(scanResults); - - try { - mWiseFy.getNearbyAccessPoints(false, null); - verify(mMockWiFiManager, never()).getScanResults(); - } catch (NullPointerException npe) { - fail(); - } - } - - @Test - public void callbacks_success_filterDuplicates_true() { - List scanResults = new ArrayList<>(); - ScanResult scanResult1 = mock(ScanResult.class); - scanResult1.SSID = TEST_SSID; - scanResult1.level = -35; - scanResults.add(scanResult1); - ScanResult scanResult2 = mock(ScanResult.class); - scanResult2.SSID = TEST_SSID2; - scanResult2.level = -70; - scanResults.add(scanResult2); - - WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); - mWiseFy.mWiseFySearch = mockWiseFySearch; - when(mockWiseFySearch.removeEntriesWithLowerSignalStrength(ArgumentMatchers.anyList())).thenReturn(scanResults); - - GetNearbyAccessPointsCallbacks mockCallbacks = mock(GetNearbyAccessPointsCallbacks.class); - mWiseFy.getNearbyAccessPoints(true, mockCallbacks); - verify(mockCallbacks, timeout(VERIFICATION_TIMEOUT)).retrievedNearbyAccessPoints(scanResults); - verify(mMockWiFiManager, timeout(VERIFICATION_TIMEOUT)).getScanResults(); - } - - @Test - public void callbacks_success_filterDuplicates_true_nullCallback() { - List scanResults = new ArrayList<>(); - ScanResult scanResult1 = mock(ScanResult.class); - scanResult1.SSID = TEST_SSID; - scanResult1.level = -35; - scanResults.add(scanResult1); - ScanResult scanResult2 = mock(ScanResult.class); - scanResult2.SSID = TEST_SSID2; - scanResult2.level = -70; - scanResults.add(scanResult2); - - WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); - mWiseFy.mWiseFySearch = mockWiseFySearch; - when(mockWiseFySearch.removeEntriesWithLowerSignalStrength(ArgumentMatchers.anyList())).thenReturn(scanResults); - - try { - mWiseFy.getNearbyAccessPoints(true, null); - verify(mMockWiFiManager, never()).getScanResults(); - } catch (NullPointerException npe) { - fail(); - } - } -} \ No newline at end of file +//package com.isupatches.wisefy; +// +// +//import android.net.wifi.ScanResult; +//import com.isupatches.wisefy.base.TestActivity; +//import com.isupatches.wisefy.callbacks.GetNearbyAccessPointsCallbacks; +//import com.isupatches.wisefy.constants.WiseFyCodes; +//import org.junit.Test; +//import org.mockito.ArgumentMatchers; +//import java.util.ArrayList; +//import java.util.List; +//import static com.isupatches.wisefy.base.TestUtils.TEST_SSID; +//import static com.isupatches.wisefy.base.TestUtils.TEST_SSID2; +//import static junit.framework.Assert.assertEquals; +//import static junit.framework.Assert.fail; +//import static org.mockito.Mockito.mock; +//import static org.mockito.Mockito.never; +//import static org.mockito.Mockito.timeout; +//import static org.mockito.Mockito.verify; +//import static org.mockito.Mockito.when; +// +// +//public class GetNearbyAccessPointsTests extends BaseTestClass { +// +// public GetNearbyAccessPointsTests() { +// super(TestActivity.class); +// } +// +// @Test +// public void noCallbacks_failure_missingPrerequisite_filterDuplicates_false() { +// missingPrerequisite(); +// assertEquals(null, mWiseFy.getNearbyAccessPoints(false)); +// verify(mMockWiFiManager, never()).getScanResults(); +// } +// +// @Test +// public void noCallbacks_failure_missingPrerequisite_filterDuplicates_true() { +// missingPrerequisite(); +// assertEquals(null, mWiseFy.getNearbyAccessPoints(true)); +// verify(mMockWiFiManager, never()).getScanResults(); +// } +// +// @Test +// public void noCallbacks_success_filterDuplicates_false() { +// List scanResults = new ArrayList<>(); +// ScanResult scanResult1 = mock(ScanResult.class); +// scanResult1.SSID = TEST_SSID; +// scanResult1.level = -35; +// scanResults.add(scanResult1); +// ScanResult scanResult2 = mock(ScanResult.class); +// scanResult2.SSID = TEST_SSID2; +// scanResult2.level = -70; +// scanResults.add(scanResult2); +// +// when(mMockWiFiManager.getScanResults()).thenReturn(scanResults); +// +// List accessPoints = mWiseFy.getNearbyAccessPoints(false); +// assertEquals(accessPoints, scanResults); +// verify(mMockWiFiManager, timeout(VERIFICATION_TIMEOUT)).getScanResults(); +// } +// +// @Test +// public void noCallbacks_success_filterDuplicates_true() { +// List scanResults = new ArrayList<>(); +// ScanResult scanResult1 = mock(ScanResult.class); +// scanResult1.SSID = TEST_SSID; +// scanResult1.level = -35; +// scanResults.add(scanResult1); +// ScanResult scanResult2 = mock(ScanResult.class); +// scanResult2.SSID = TEST_SSID2; +// scanResult2.level = -70; +// scanResults.add(scanResult2); +// +// WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); +// mWiseFy.mWiseFySearch = mockWiseFySearch; +// when(mockWiseFySearch.removeEntriesWithLowerSignalStrength(ArgumentMatchers.anyList())).thenReturn(scanResults); +// +// List accessPoints = mWiseFy.getNearbyAccessPoints(true); +// assertEquals(accessPoints, scanResults); +// verify(mMockWiFiManager, timeout(VERIFICATION_TIMEOUT)).getScanResults(); +// } +// +// @Test +// public void callbacks_failure_missingPrerequisite_filterDuplicates_false() { +// missingPrerequisite(); +// GetNearbyAccessPointsCallbacks mockCallbacks = mock(GetNearbyAccessPointsCallbacks.class); +// mWiseFy.getNearbyAccessPoints(false, mockCallbacks); +// verify(mockCallbacks, timeout(VERIFICATION_TIMEOUT)).getNearbyAccessPointsWiseFyFailure(WiseFyCodes.MISSING_PREREQUISITE); +// verify(mMockWiFiManager, never()).getScanResults(); +// } +// +// @Test +// public void callbacks_failure_missingPrerequisite_filterDuplicates_false_nullCallback() { +// missingPrerequisite(); +// try { +// mWiseFy.getNearbyAccessPoints(false, null); +// verify(mMockWiFiManager, never()).getScanResults(); +// } catch (NullPointerException npe) { +// fail(); +// } +// } +// +// @Test +// public void callbacks_failure_missingPrerequisite_filterDuplicates_true() { +// missingPrerequisite(); +// GetNearbyAccessPointsCallbacks mockCallbacks = mock(GetNearbyAccessPointsCallbacks.class); +// mWiseFy.getNearbyAccessPoints(true, mockCallbacks); +// verify(mockCallbacks, timeout(3000)).getNearbyAccessPointsWiseFyFailure(WiseFyCodes.MISSING_PREREQUISITE); +// verify(mMockWiFiManager, never()).getScanResults(); +// } +// +// @Test +// public void callbacks_failure_missingPrerequisite_filterDuplicates_true_nullCallback() { +// missingPrerequisite(); +// try { +// mWiseFy.getNearbyAccessPoints(true, null); +// verify(mMockWiFiManager, never()).getScanResults(); +// } catch (NullPointerException npe) { +// fail(); +// } +// } +// +// @Test +// public void callbacks_success_filterDuplicates_false() { +// List scanResults = new ArrayList<>(); +// ScanResult scanResult1 = mock(ScanResult.class); +// scanResult1.SSID = TEST_SSID; +// scanResult1.level = -35; +// scanResults.add(scanResult1); +// ScanResult scanResult2 = mock(ScanResult.class); +// scanResult2.SSID = TEST_SSID2; +// scanResult2.level = -70; +// scanResults.add(scanResult2); +// +// when(mMockWiFiManager.getScanResults()).thenReturn(scanResults); +// +// GetNearbyAccessPointsCallbacks mockCallbacks = mock(GetNearbyAccessPointsCallbacks.class); +// mWiseFy.getNearbyAccessPoints(false, mockCallbacks); +// verify(mockCallbacks, timeout(VERIFICATION_TIMEOUT)).retrievedNearbyAccessPoints(scanResults); +// verify(mMockWiFiManager, timeout(VERIFICATION_TIMEOUT)).getScanResults(); +// } +// +// @Test +// public void callbacks_success_filterDuplicates_false_nullCallback() { +// List scanResults = new ArrayList<>(); +// ScanResult scanResult1 = mock(ScanResult.class); +// scanResult1.SSID = TEST_SSID; +// scanResult1.level = -35; +// scanResults.add(scanResult1); +// ScanResult scanResult2 = mock(ScanResult.class); +// scanResult2.SSID = TEST_SSID2; +// scanResult2.level = -70; +// scanResults.add(scanResult2); +// +// when(mMockWiFiManager.getScanResults()).thenReturn(scanResults); +// +// try { +// mWiseFy.getNearbyAccessPoints(false, null); +// verify(mMockWiFiManager, never()).getScanResults(); +// } catch (NullPointerException npe) { +// fail(); +// } +// } +// +// @Test +// public void callbacks_success_filterDuplicates_true() { +// List scanResults = new ArrayList<>(); +// ScanResult scanResult1 = mock(ScanResult.class); +// scanResult1.SSID = TEST_SSID; +// scanResult1.level = -35; +// scanResults.add(scanResult1); +// ScanResult scanResult2 = mock(ScanResult.class); +// scanResult2.SSID = TEST_SSID2; +// scanResult2.level = -70; +// scanResults.add(scanResult2); +// +// WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); +// mWiseFy.mWiseFySearch = mockWiseFySearch; +// when(mockWiseFySearch.removeEntriesWithLowerSignalStrength(ArgumentMatchers.anyList())).thenReturn(scanResults); +// +// GetNearbyAccessPointsCallbacks mockCallbacks = mock(GetNearbyAccessPointsCallbacks.class); +// mWiseFy.getNearbyAccessPoints(true, mockCallbacks); +// verify(mockCallbacks, timeout(VERIFICATION_TIMEOUT)).retrievedNearbyAccessPoints(scanResults); +// verify(mMockWiFiManager, timeout(VERIFICATION_TIMEOUT)).getScanResults(); +// } +// +// @Test +// public void callbacks_success_filterDuplicates_true_nullCallback() { +// List scanResults = new ArrayList<>(); +// ScanResult scanResult1 = mock(ScanResult.class); +// scanResult1.SSID = TEST_SSID; +// scanResult1.level = -35; +// scanResults.add(scanResult1); +// ScanResult scanResult2 = mock(ScanResult.class); +// scanResult2.SSID = TEST_SSID2; +// scanResult2.level = -70; +// scanResults.add(scanResult2); +// +// WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); +// mWiseFy.mWiseFySearch = mockWiseFySearch; +// when(mockWiseFySearch.removeEntriesWithLowerSignalStrength(ArgumentMatchers.anyList())).thenReturn(scanResults); +// +// try { +// mWiseFy.getNearbyAccessPoints(true, null); +// verify(mMockWiFiManager, never()).getScanResults(); +// } catch (NullPointerException npe) { +// fail(); +// } +// } +//} \ No newline at end of file diff --git a/wisefy/src/androidTest/java/com/isupatches/wisefy/GetRSSITests.java b/wisefy/src/androidTest/java/com/isupatches/wisefy/GetRSSITests.java index a1405794..f6b6300c 100644 --- a/wisefy/src/androidTest/java/com/isupatches/wisefy/GetRSSITests.java +++ b/wisefy/src/androidTest/java/com/isupatches/wisefy/GetRSSITests.java @@ -1,264 +1,264 @@ -package com.isupatches.wisefy; - - -import android.net.wifi.ScanResult; -import com.isupatches.wisefy.base.TestActivity; -import com.isupatches.wisefy.callbacks.GetRSSICallbacks; -import com.isupatches.wisefy.constants.WiseFyCodes; -import org.junit.Test; -import static com.isupatches.wisefy.base.TestUtils.TEST_RSSI_LEVEL; -import static com.isupatches.wisefy.base.TestUtils.TEST_SSID; -import static junit.framework.Assert.assertEquals; -import static junit.framework.Assert.fail; -import static org.mockito.ArgumentMatchers.anyBoolean; -import static org.mockito.ArgumentMatchers.anyInt; -import static org.mockito.ArgumentMatchers.anyString; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.timeout; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; - - -public class GetRSSITests extends BaseTestClass { - - public GetRSSITests() { - super(TestActivity.class); - } - - @Test - public void noCallbacks_failure_takeHighest_false_nullSSIDParam() { - assertEquals(null, mWiseFy.getRSSI(null, false, 1000)); - } - - @Test - public void noCallbacks_failure_takeHighest_true_nullSSIDParam() { - assertEquals(null, mWiseFy.getRSSI(null, true, 1000)); - } - - @Test - public void noCallbacks_failure_takeHighest_false_missingPrerequisite() { - missingPrerequisite(); - assertEquals(null, mWiseFy.getRSSI(TEST_SSID, false, 1000)); - } - - @Test - public void noCallbacks_failure_takeHighest_true_missingPrerequisite() { - missingPrerequisite(); - assertEquals(null, mWiseFy.getRSSI(TEST_SSID, true, 1000)); - } - - @Test - public void noCallbacks_failure_takeHighest_false_noNetworkFound() { - WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); - mWiseFy.mWiseFySearch = mockWiseFySearch; - when(mockWiseFySearch.findAccessPointByRegex(anyString(), anyInt(), anyBoolean())).thenReturn(null); - - assertEquals(null, mWiseFy.getRSSI(TEST_SSID, false, 1000)); - } - - @Test - public void noCallbacks_failure_takeHighest_true_noNetworkFound() { - WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); - mWiseFy.mWiseFySearch = mockWiseFySearch; - when(mockWiseFySearch.findAccessPointByRegex(anyString(), anyInt(), anyBoolean())).thenReturn(null); - - assertEquals(null, mWiseFy.getRSSI(TEST_SSID, true, 1000)); - } - - @Test - public void noCallbacks_success_takeHighest_false () { - ScanResult accessPoint = mock(ScanResult.class); - accessPoint.level = TEST_RSSI_LEVEL; - WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); - mWiseFy.mWiseFySearch = mockWiseFySearch; - when(mockWiseFySearch.findAccessPointByRegex(anyString(), anyInt(), anyBoolean())).thenReturn(accessPoint); - - assertEquals(TEST_RSSI_LEVEL, (int) mWiseFy.getRSSI(TEST_SSID, false, 1000)); - - } - - @Test - public void noCallbacks_success_takeHighest_true () { - ScanResult accessPoint = mock(ScanResult.class); - accessPoint.level = TEST_RSSI_LEVEL; - WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); - mWiseFy.mWiseFySearch = mockWiseFySearch; - when(mockWiseFySearch.findAccessPointByRegex(anyString(), anyInt(), anyBoolean())).thenReturn(accessPoint); - - assertEquals(TEST_RSSI_LEVEL, (int) mWiseFy.getRSSI(TEST_SSID, true, 1000)); - } - - @Test - public void callbacks_failure_takeHighest_false_nullSSIDParam() { - GetRSSICallbacks mockCallbacks = mock(GetRSSICallbacks.class); - mWiseFy.getRSSI(null, false, 1000, mockCallbacks); - verify(mockCallbacks, timeout(2000)).getRSSIWiseFyFailure(WiseFyCodes.MISSING_PARAMETER); - } - - @Test - public void callbacks_failure_takeHighest_false_nullSSIDParam_nullCallback() { - try { - mWiseFy.getRSSI(null, false, 1000, null); - } catch (NullPointerException npe) { - fail(); - } - } - - @Test - public void callbacks_failure_takeHighest_true_nullSSIDParam() { - GetRSSICallbacks mockCallbacks = mock(GetRSSICallbacks.class); - mWiseFy.getRSSI(null, true, 1000, mockCallbacks); - verify(mockCallbacks, timeout(2000)).getRSSIWiseFyFailure(WiseFyCodes.MISSING_PARAMETER); - } - - @Test - public void callbacks_failure_takeHighest_true_nullSSIDParam_nullCallback() { - try { - mWiseFy.getRSSI(null, true, 1000, null); - } catch (NullPointerException npe) { - fail(); - } - } - - @Test - public void callbacks_failure_takeHighest_false_missingPrerequisite() { - missingPrerequisite(); - GetRSSICallbacks mockCallbacks = mock(GetRSSICallbacks.class); - mWiseFy.getRSSI(TEST_SSID, false, 1000, mockCallbacks); - verify(mockCallbacks, timeout(2000)).getRSSIWiseFyFailure(WiseFyCodes.MISSING_PREREQUISITE); - } - - @Test - public void callbacks_failure_takeHighest_false_nullSSIDParam_missingPrerequisite() { - missingPrerequisite(); - try { - mWiseFy.getRSSI(TEST_SSID, false, 1000, null); - } catch (NullPointerException npe) { - fail(); - } - } - - @Test - public void callbacks_failure_takeHighest_true_missingPrerequisite() { - missingPrerequisite(); - GetRSSICallbacks mockCallbacks = mock(GetRSSICallbacks.class); - mWiseFy.getRSSI(TEST_SSID, true, 1000, mockCallbacks); - verify(mockCallbacks, timeout(2000)).getRSSIWiseFyFailure(WiseFyCodes.MISSING_PREREQUISITE); - } - - @Test - public void callbacks_failure_takeHighest_true_nullSSIDParam_missingPrerequisite() { - missingPrerequisite(); - try { - mWiseFy.getRSSI(TEST_SSID, true, 1000, null); - } catch (NullPointerException npe) { - fail(); - } - } - - @Test - public void callbacks_failure_takeHighest_false_noNetworkFound() { - WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); - mWiseFy.mWiseFySearch = mockWiseFySearch; - when(mockWiseFySearch.findAccessPointByRegex(anyString(), anyInt(), anyBoolean())).thenReturn(null); - - GetRSSICallbacks mockCallbacks = mock(GetRSSICallbacks.class); - mWiseFy.getRSSI(TEST_SSID, false, 1000, mockCallbacks); - verify(mockCallbacks, timeout(2000)).networkNotFoundToRetrieveRSSI(); - } - - @Test - public void callbacks_failure_takeHighest_false_noNetworkFound_nullCallback() { - WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); - mWiseFy.mWiseFySearch = mockWiseFySearch; - when(mockWiseFySearch.findAccessPointByRegex(anyString(), anyInt(), anyBoolean())).thenReturn(null); - - try { - mWiseFy.getRSSI(TEST_SSID, false, 1000, null); - } catch (NullPointerException npe) { - fail(); - } - } - - @Test - public void callbacks_failure_takeHighest_true_noNetworkFound() { - WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); - mWiseFy.mWiseFySearch = mockWiseFySearch; - when(mockWiseFySearch.findAccessPointByRegex(anyString(), anyInt(), anyBoolean())).thenReturn(null); - - GetRSSICallbacks mockCallbacks = mock(GetRSSICallbacks.class); - mWiseFy.getRSSI(TEST_SSID, true, 1000, mockCallbacks); - verify(mockCallbacks, timeout(2000)).networkNotFoundToRetrieveRSSI(); - } - - @Test - public void callbacks_failure_takeHighest_true_noNetworkFound_nullCallback() { - WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); - mWiseFy.mWiseFySearch = mockWiseFySearch; - when(mockWiseFySearch.findAccessPointByRegex(anyString(), anyInt(), anyBoolean())).thenReturn(null); - - try { - mWiseFy.getRSSI(TEST_SSID, true, 1000, null); - } catch (NullPointerException npe) { - fail(); - } - } - - @Test - public void callbacks_success_takeHighest_false() { - WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); - mWiseFy.mWiseFySearch = mockWiseFySearch; - ScanResult accessPoint = mock(ScanResult.class); - accessPoint.level = TEST_RSSI_LEVEL; - when(mockWiseFySearch.findAccessPointByRegex(anyString(), anyInt(), anyBoolean())).thenReturn(accessPoint); - - - GetRSSICallbacks mockCallbacks = mock(GetRSSICallbacks.class); - mWiseFy.getRSSI(TEST_SSID, false, 1000, mockCallbacks); - verify(mockCallbacks, timeout(2000)).retrievedRSSI(TEST_RSSI_LEVEL); - } - - @Test - public void callbacks_success_takeHighest_false_nullCallback() { - WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); - mWiseFy.mWiseFySearch = mockWiseFySearch; - ScanResult accessPoint = mock(ScanResult.class); - accessPoint.level = TEST_RSSI_LEVEL; - when(mockWiseFySearch.findAccessPointByRegex(anyString(), anyInt(), anyBoolean())).thenReturn(accessPoint); - - try { - mWiseFy.getRSSI(TEST_SSID, false, 1000, null); - } catch (NullPointerException npe) { - fail(); - } - } - - @Test - public void callbacks_success_takeHighest_true() { - WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); - mWiseFy.mWiseFySearch = mockWiseFySearch; - ScanResult accessPoint = mock(ScanResult.class); - accessPoint.level = TEST_RSSI_LEVEL; - when(mockWiseFySearch.findAccessPointByRegex(anyString(), anyInt(), anyBoolean())).thenReturn(accessPoint); - - - GetRSSICallbacks mockCallbacks = mock(GetRSSICallbacks.class); - mWiseFy.getRSSI(TEST_SSID, true, 1000, mockCallbacks); - verify(mockCallbacks, timeout(2000)).retrievedRSSI(TEST_RSSI_LEVEL); - } - - @Test - public void callbacks_success_takeHighest_true_nullCallback() { - WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); - mWiseFy.mWiseFySearch = mockWiseFySearch; - ScanResult accessPoint = mock(ScanResult.class); - accessPoint.level = TEST_RSSI_LEVEL; - when(mockWiseFySearch.findAccessPointByRegex(anyString(), anyInt(), anyBoolean())).thenReturn(accessPoint); - - try { - mWiseFy.getRSSI(TEST_SSID, true, 1000, null); - } catch (NullPointerException npe) { - fail(); - } - } -} \ No newline at end of file +//package com.isupatches.wisefy; +// +// +//import android.net.wifi.ScanResult; +//import com.isupatches.wisefy.base.TestActivity; +//import com.isupatches.wisefy.callbacks.GetRSSICallbacks; +//import com.isupatches.wisefy.constants.WiseFyCodes; +//import org.junit.Test; +//import static com.isupatches.wisefy.base.TestUtils.TEST_RSSI_LEVEL; +//import static com.isupatches.wisefy.base.TestUtils.TEST_SSID; +//import static junit.framework.Assert.assertEquals; +//import static junit.framework.Assert.fail; +//import static org.mockito.ArgumentMatchers.anyBoolean; +//import static org.mockito.ArgumentMatchers.anyInt; +//import static org.mockito.ArgumentMatchers.anyString; +//import static org.mockito.Mockito.mock; +//import static org.mockito.Mockito.timeout; +//import static org.mockito.Mockito.verify; +//import static org.mockito.Mockito.when; +// +// +//public class GetRSSITests extends BaseTestClass { +// +// public GetRSSITests() { +// super(TestActivity.class); +// } +// +// @Test +// public void noCallbacks_failure_takeHighest_false_nullSSIDParam() { +// assertEquals(null, mWiseFy.getRSSI(null, false, 1000)); +// } +// +// @Test +// public void noCallbacks_failure_takeHighest_true_nullSSIDParam() { +// assertEquals(null, mWiseFy.getRSSI(null, true, 1000)); +// } +// +// @Test +// public void noCallbacks_failure_takeHighest_false_missingPrerequisite() { +// missingPrerequisite(); +// assertEquals(null, mWiseFy.getRSSI(TEST_SSID, false, 1000)); +// } +// +// @Test +// public void noCallbacks_failure_takeHighest_true_missingPrerequisite() { +// missingPrerequisite(); +// assertEquals(null, mWiseFy.getRSSI(TEST_SSID, true, 1000)); +// } +// +// @Test +// public void noCallbacks_failure_takeHighest_false_noNetworkFound() { +// WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); +// mWiseFy.mWiseFySearch = mockWiseFySearch; +// when(mockWiseFySearch.findAccessPointByRegex(anyString(), anyInt(), anyBoolean())).thenReturn(null); +// +// assertEquals(null, mWiseFy.getRSSI(TEST_SSID, false, 1000)); +// } +// +// @Test +// public void noCallbacks_failure_takeHighest_true_noNetworkFound() { +// WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); +// mWiseFy.mWiseFySearch = mockWiseFySearch; +// when(mockWiseFySearch.findAccessPointByRegex(anyString(), anyInt(), anyBoolean())).thenReturn(null); +// +// assertEquals(null, mWiseFy.getRSSI(TEST_SSID, true, 1000)); +// } +// +// @Test +// public void noCallbacks_success_takeHighest_false () { +// ScanResult accessPoint = mock(ScanResult.class); +// accessPoint.level = TEST_RSSI_LEVEL; +// WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); +// mWiseFy.mWiseFySearch = mockWiseFySearch; +// when(mockWiseFySearch.findAccessPointByRegex(anyString(), anyInt(), anyBoolean())).thenReturn(accessPoint); +// +// assertEquals(TEST_RSSI_LEVEL, (int) mWiseFy.getRSSI(TEST_SSID, false, 1000)); +// +// } +// +// @Test +// public void noCallbacks_success_takeHighest_true () { +// ScanResult accessPoint = mock(ScanResult.class); +// accessPoint.level = TEST_RSSI_LEVEL; +// WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); +// mWiseFy.mWiseFySearch = mockWiseFySearch; +// when(mockWiseFySearch.findAccessPointByRegex(anyString(), anyInt(), anyBoolean())).thenReturn(accessPoint); +// +// assertEquals(TEST_RSSI_LEVEL, (int) mWiseFy.getRSSI(TEST_SSID, true, 1000)); +// } +// +// @Test +// public void callbacks_failure_takeHighest_false_nullSSIDParam() { +// GetRSSICallbacks mockCallbacks = mock(GetRSSICallbacks.class); +// mWiseFy.getRSSI(null, false, 1000, mockCallbacks); +// verify(mockCallbacks, timeout(2000)).getRSSIWiseFyFailure(WiseFyCodes.MISSING_PARAMETER); +// } +// +// @Test +// public void callbacks_failure_takeHighest_false_nullSSIDParam_nullCallback() { +// try { +// mWiseFy.getRSSI(null, false, 1000, null); +// } catch (NullPointerException npe) { +// fail(); +// } +// } +// +// @Test +// public void callbacks_failure_takeHighest_true_nullSSIDParam() { +// GetRSSICallbacks mockCallbacks = mock(GetRSSICallbacks.class); +// mWiseFy.getRSSI(null, true, 1000, mockCallbacks); +// verify(mockCallbacks, timeout(2000)).getRSSIWiseFyFailure(WiseFyCodes.MISSING_PARAMETER); +// } +// +// @Test +// public void callbacks_failure_takeHighest_true_nullSSIDParam_nullCallback() { +// try { +// mWiseFy.getRSSI(null, true, 1000, null); +// } catch (NullPointerException npe) { +// fail(); +// } +// } +// +// @Test +// public void callbacks_failure_takeHighest_false_missingPrerequisite() { +// missingPrerequisite(); +// GetRSSICallbacks mockCallbacks = mock(GetRSSICallbacks.class); +// mWiseFy.getRSSI(TEST_SSID, false, 1000, mockCallbacks); +// verify(mockCallbacks, timeout(2000)).getRSSIWiseFyFailure(WiseFyCodes.MISSING_PREREQUISITE); +// } +// +// @Test +// public void callbacks_failure_takeHighest_false_nullSSIDParam_missingPrerequisite() { +// missingPrerequisite(); +// try { +// mWiseFy.getRSSI(TEST_SSID, false, 1000, null); +// } catch (NullPointerException npe) { +// fail(); +// } +// } +// +// @Test +// public void callbacks_failure_takeHighest_true_missingPrerequisite() { +// missingPrerequisite(); +// GetRSSICallbacks mockCallbacks = mock(GetRSSICallbacks.class); +// mWiseFy.getRSSI(TEST_SSID, true, 1000, mockCallbacks); +// verify(mockCallbacks, timeout(2000)).getRSSIWiseFyFailure(WiseFyCodes.MISSING_PREREQUISITE); +// } +// +// @Test +// public void callbacks_failure_takeHighest_true_nullSSIDParam_missingPrerequisite() { +// missingPrerequisite(); +// try { +// mWiseFy.getRSSI(TEST_SSID, true, 1000, null); +// } catch (NullPointerException npe) { +// fail(); +// } +// } +// +// @Test +// public void callbacks_failure_takeHighest_false_noNetworkFound() { +// WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); +// mWiseFy.mWiseFySearch = mockWiseFySearch; +// when(mockWiseFySearch.findAccessPointByRegex(anyString(), anyInt(), anyBoolean())).thenReturn(null); +// +// GetRSSICallbacks mockCallbacks = mock(GetRSSICallbacks.class); +// mWiseFy.getRSSI(TEST_SSID, false, 1000, mockCallbacks); +// verify(mockCallbacks, timeout(2000)).networkNotFoundToRetrieveRSSI(); +// } +// +// @Test +// public void callbacks_failure_takeHighest_false_noNetworkFound_nullCallback() { +// WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); +// mWiseFy.mWiseFySearch = mockWiseFySearch; +// when(mockWiseFySearch.findAccessPointByRegex(anyString(), anyInt(), anyBoolean())).thenReturn(null); +// +// try { +// mWiseFy.getRSSI(TEST_SSID, false, 1000, null); +// } catch (NullPointerException npe) { +// fail(); +// } +// } +// +// @Test +// public void callbacks_failure_takeHighest_true_noNetworkFound() { +// WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); +// mWiseFy.mWiseFySearch = mockWiseFySearch; +// when(mockWiseFySearch.findAccessPointByRegex(anyString(), anyInt(), anyBoolean())).thenReturn(null); +// +// GetRSSICallbacks mockCallbacks = mock(GetRSSICallbacks.class); +// mWiseFy.getRSSI(TEST_SSID, true, 1000, mockCallbacks); +// verify(mockCallbacks, timeout(2000)).networkNotFoundToRetrieveRSSI(); +// } +// +// @Test +// public void callbacks_failure_takeHighest_true_noNetworkFound_nullCallback() { +// WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); +// mWiseFy.mWiseFySearch = mockWiseFySearch; +// when(mockWiseFySearch.findAccessPointByRegex(anyString(), anyInt(), anyBoolean())).thenReturn(null); +// +// try { +// mWiseFy.getRSSI(TEST_SSID, true, 1000, null); +// } catch (NullPointerException npe) { +// fail(); +// } +// } +// +// @Test +// public void callbacks_success_takeHighest_false() { +// WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); +// mWiseFy.mWiseFySearch = mockWiseFySearch; +// ScanResult accessPoint = mock(ScanResult.class); +// accessPoint.level = TEST_RSSI_LEVEL; +// when(mockWiseFySearch.findAccessPointByRegex(anyString(), anyInt(), anyBoolean())).thenReturn(accessPoint); +// +// +// GetRSSICallbacks mockCallbacks = mock(GetRSSICallbacks.class); +// mWiseFy.getRSSI(TEST_SSID, false, 1000, mockCallbacks); +// verify(mockCallbacks, timeout(2000)).retrievedRSSI(TEST_RSSI_LEVEL); +// } +// +// @Test +// public void callbacks_success_takeHighest_false_nullCallback() { +// WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); +// mWiseFy.mWiseFySearch = mockWiseFySearch; +// ScanResult accessPoint = mock(ScanResult.class); +// accessPoint.level = TEST_RSSI_LEVEL; +// when(mockWiseFySearch.findAccessPointByRegex(anyString(), anyInt(), anyBoolean())).thenReturn(accessPoint); +// +// try { +// mWiseFy.getRSSI(TEST_SSID, false, 1000, null); +// } catch (NullPointerException npe) { +// fail(); +// } +// } +// +// @Test +// public void callbacks_success_takeHighest_true() { +// WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); +// mWiseFy.mWiseFySearch = mockWiseFySearch; +// ScanResult accessPoint = mock(ScanResult.class); +// accessPoint.level = TEST_RSSI_LEVEL; +// when(mockWiseFySearch.findAccessPointByRegex(anyString(), anyInt(), anyBoolean())).thenReturn(accessPoint); +// +// +// GetRSSICallbacks mockCallbacks = mock(GetRSSICallbacks.class); +// mWiseFy.getRSSI(TEST_SSID, true, 1000, mockCallbacks); +// verify(mockCallbacks, timeout(2000)).retrievedRSSI(TEST_RSSI_LEVEL); +// } +// +// @Test +// public void callbacks_success_takeHighest_true_nullCallback() { +// WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); +// mWiseFy.mWiseFySearch = mockWiseFySearch; +// ScanResult accessPoint = mock(ScanResult.class); +// accessPoint.level = TEST_RSSI_LEVEL; +// when(mockWiseFySearch.findAccessPointByRegex(anyString(), anyInt(), anyBoolean())).thenReturn(accessPoint); +// +// try { +// mWiseFy.getRSSI(TEST_SSID, true, 1000, null); +// } catch (NullPointerException npe) { +// fail(); +// } +// } +//} \ No newline at end of file diff --git a/wisefy/src/androidTest/java/com/isupatches/wisefy/GetSavedNetworksTests.java b/wisefy/src/androidTest/java/com/isupatches/wisefy/GetSavedNetworksTests.java index 1926c5de..550e8749 100644 --- a/wisefy/src/androidTest/java/com/isupatches/wisefy/GetSavedNetworksTests.java +++ b/wisefy/src/androidTest/java/com/isupatches/wisefy/GetSavedNetworksTests.java @@ -1,243 +1,243 @@ -package com.isupatches.wisefy; - - -import android.net.wifi.WifiConfiguration; -import com.isupatches.wisefy.base.TestActivity; -import com.isupatches.wisefy.callbacks.GetSavedNetworksCallbacks; -import com.isupatches.wisefy.constants.WiseFyCodes; -import org.junit.Test; -import java.util.ArrayList; -import java.util.List; -import static com.isupatches.wisefy.base.TestUtils.TEST_SSID; -import static junit.framework.Assert.assertEquals; -import static junit.framework.Assert.fail; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.never; -import static org.mockito.Mockito.timeout; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; - - -public class GetSavedNetworksTests extends BaseTestClass { - - public GetSavedNetworksTests() { - super(TestActivity.class); - } - - @Test - public void noCallbacks_failure_missingPrerequisite() { - missingPrerequisite(); - assertEquals(null, mWiseFy.getSavedNetworks()); - verify(mMockWiFiManager, never()).getConfiguredNetworks(); - } - - @Test - public void noCallbacks_success() { - List wifiList = new ArrayList<>(); - WifiConfiguration mWiFiConfiguration = new WifiConfiguration(); - mWiFiConfiguration.SSID = TEST_SSID; - wifiList.add(mWiFiConfiguration); - when(mMockWiFiManager.getConfiguredNetworks()).thenReturn(wifiList); - - assertEquals(wifiList, mWiseFy.getSavedNetworks()); - verify(mMockWiFiManager, timeout(VERIFICATION_TIMEOUT)).getConfiguredNetworks(); - } - - @Test - public void callbacks_failure_missingPrerequisite() { - missingPrerequisite(); - GetSavedNetworksCallbacks mockCallbacks = mock(GetSavedNetworksCallbacks.class); - mWiseFy.getSavedNetworks(mockCallbacks); - verify(mockCallbacks, timeout(VERIFICATION_TIMEOUT)).getSavedNetworksWiseFyFailure(WiseFyCodes.MISSING_PREREQUISITE); - verify(mMockWiFiManager, never()).getConfiguredNetworks(); - } - - @Test - public void callbacks_failure_missingPrerequisite_nullCallback() { - missingPrerequisite(); - try { - mWiseFy.getSavedNetworks((GetSavedNetworksCallbacks) null); - verify(mMockWiFiManager, never()).getConfiguredNetworks(); - } catch (NullPointerException npe) { - fail(); - } - } - - @Test - public void callbacks_failure_nullSavedNetworks() { - when(mMockWiFiManager.getConfiguredNetworks()).thenReturn(null); - GetSavedNetworksCallbacks mockCallbacks = mock(GetSavedNetworksCallbacks.class); - mWiseFy.getSavedNetworks(mockCallbacks); - verify(mockCallbacks, timeout(VERIFICATION_TIMEOUT)).noSavedNetworksFound(); - } - - @Test - public void callbacks_failure_nullSavedNetworks_nullCallback() { - when(mMockWiFiManager.getConfiguredNetworks()).thenReturn(null); - try { - mWiseFy.getSavedNetworks((GetSavedNetworksCallbacks) null); - verify(mMockWiFiManager, never()).getConfiguredNetworks(); - } catch (NullPointerException npe) { - fail(); - } - } - - @Test - public void callbacks_failure_emptyConfiguredNetworks() { - when(mMockWiFiManager.getConfiguredNetworks()).thenReturn(new ArrayList()); - GetSavedNetworksCallbacks mockCallbacks = mock(GetSavedNetworksCallbacks.class); - mWiseFy.getSavedNetworks(mockCallbacks); - verify(mockCallbacks, timeout(VERIFICATION_TIMEOUT)).noSavedNetworksFound(); - } - - @Test - public void callbacks_failure_emptyConfiguredNetworks_nullCallback() { - when(mMockWiFiManager.getConfiguredNetworks()).thenReturn(new ArrayList()); - try { - mWiseFy.getSavedNetworks((GetSavedNetworksCallbacks) null); - verify(mMockWiFiManager, never()).getConfiguredNetworks(); - } catch (NullPointerException npe) { - fail(); - } - } - - @Test - public void callbacks_success() { - List wifiList = new ArrayList<>(); - WifiConfiguration mWiFiConfiguration = new WifiConfiguration(); - mWiFiConfiguration.SSID = TEST_SSID; - wifiList.add(mWiFiConfiguration); - when(mMockWiFiManager.getConfiguredNetworks()).thenReturn(wifiList); - - GetSavedNetworksCallbacks mockCallbacks = mock(GetSavedNetworksCallbacks.class); - mWiseFy.getSavedNetworks(mockCallbacks); - verify(mockCallbacks, timeout(VERIFICATION_TIMEOUT)).retrievedSavedNetworks(wifiList); - verify(mMockWiFiManager, timeout(VERIFICATION_TIMEOUT)).getConfiguredNetworks(); - } - - @Test - public void callbacks_success_nullCallback() { - List wifiList = new ArrayList<>(); - WifiConfiguration mWiFiConfiguration = new WifiConfiguration(); - mWiFiConfiguration.SSID = TEST_SSID; - wifiList.add(mWiFiConfiguration); - when(mMockWiFiManager.getConfiguredNetworks()).thenReturn(wifiList); - - try { - mWiseFy.getSavedNetworks((GetSavedNetworksCallbacks) null); - verify(mMockWiFiManager, never()).getConfiguredNetworks(); - } catch (NullPointerException npe) { - fail(); - } - } - - @Test - public void callbacks_failure_withRegex_missingPrerequisite() { - missingPrerequisite(); - - GetSavedNetworksCallbacks mockCallbacks = mock(GetSavedNetworksCallbacks.class); - mWiseFy.getSavedNetworks(TEST_SSID, mockCallbacks); - verify(mockCallbacks, timeout(VERIFICATION_TIMEOUT)).getSavedNetworksWiseFyFailure(WiseFyCodes.MISSING_PREREQUISITE); - verify(mMockWiFiManager, never()).getConfiguredNetworks(); - } - - @Test - public void noCallbacks_failure_withRegex_missingPrerequisite() { - missingPrerequisite(); - assertEquals(null, mWiseFy.getSavedNetworks(TEST_SSID)); - verify(mMockWiFiManager, never()).getConfiguredNetworks(); - } - - @Test - public void noCallbacks_success_withRegex() { - List wifiList = new ArrayList<>(); - WifiConfiguration mWiFiConfiguration = new WifiConfiguration(); - mWiFiConfiguration.SSID = TEST_SSID; - wifiList.add(mWiFiConfiguration); - when(mMockWiFiManager.getConfiguredNetworks()).thenReturn(wifiList); - - assertEquals(wifiList, mWiseFy.getSavedNetworks(TEST_SSID)); - verify(mMockWiFiManager, timeout(VERIFICATION_TIMEOUT)).getConfiguredNetworks(); - } - - @Test - public void callbacks_failure_withRegex_missingPrerequisite_nullCallback() { - missingPrerequisite(); - - try{ - mWiseFy.getSavedNetworks(TEST_SSID, null); - verify(mMockWiFiManager, never()).getConfiguredNetworks(); - } catch (NullPointerException npe) { - fail(); - } - } - - @Test - public void callbacks_failure_withRegex_nullSavedNetworks() { - when(mMockWiFiManager.getConfiguredNetworks()).thenReturn(null); - GetSavedNetworksCallbacks mockCallbacks = mock(GetSavedNetworksCallbacks.class); - mWiseFy.getSavedNetworks(TEST_SSID, mockCallbacks); - verify(mockCallbacks, timeout(VERIFICATION_TIMEOUT)).noSavedNetworksFound(); - } - - @Test - public void callbacks_failure_withRegex_nullSavedNetworks_nullCallback() { - when(mMockWiFiManager.getConfiguredNetworks()).thenReturn(null); - try { - mWiseFy.getSavedNetworks(TEST_SSID, null); - verify(mMockWiFiManager, never()).getConfiguredNetworks(); - } catch (NullPointerException npe) { - fail(); - } - } - - @Test - public void callbacks_failure_withRegex_emptyConfiguredNetworks() { - when(mMockWiFiManager.getConfiguredNetworks()).thenReturn(new ArrayList()); - GetSavedNetworksCallbacks mockCallbacks = mock(GetSavedNetworksCallbacks.class); - mWiseFy.getSavedNetworks(TEST_SSID, mockCallbacks); - verify(mockCallbacks, timeout(VERIFICATION_TIMEOUT)).noSavedNetworksFound(); - verify(mMockWiFiManager, timeout(VERIFICATION_TIMEOUT)).getConfiguredNetworks(); - } - - @Test - public void callbacks_failure_withRegex_emptyConfiguredNetworks_nullCallback() { - when(mMockWiFiManager.getConfiguredNetworks()).thenReturn(new ArrayList()); - try { - mWiseFy.getSavedNetworks(TEST_SSID, null); - verify(mMockWiFiManager, never()).getConfiguredNetworks(); - } catch (NullPointerException npe) { - fail(); - } - } - - @Test - public void callbacks_success_withRegex() { - List wifiList = new ArrayList<>(); - WifiConfiguration mWiFiConfiguration = new WifiConfiguration(); - mWiFiConfiguration.SSID = TEST_SSID; - wifiList.add(mWiFiConfiguration); - when(mMockWiFiManager.getConfiguredNetworks()).thenReturn(wifiList); - - GetSavedNetworksCallbacks mockCallbacks = mock(GetSavedNetworksCallbacks.class); - mWiseFy.getSavedNetworks(TEST_SSID, mockCallbacks); - verify(mockCallbacks, timeout(VERIFICATION_TIMEOUT)).retrievedSavedNetworks(wifiList); - verify(mMockWiFiManager, timeout(VERIFICATION_TIMEOUT)).getConfiguredNetworks(); - } - - @Test - public void callbacks_success_withRegex_nullCallbacks() { - List wifiList = new ArrayList<>(); - WifiConfiguration mWiFiConfiguration = new WifiConfiguration(); - mWiFiConfiguration.SSID = TEST_SSID; - wifiList.add(mWiFiConfiguration); - when(mMockWiFiManager.getConfiguredNetworks()).thenReturn(wifiList); - - try { - mWiseFy.getSavedNetworks(TEST_SSID, null); - verify(mMockWiFiManager, never()).getConfiguredNetworks(); - } catch (NullPointerException npe) { - fail(); - } - } -} +//package com.isupatches.wisefy; +// +// +//import android.net.wifi.WifiConfiguration; +//import com.isupatches.wisefy.base.TestActivity; +//import com.isupatches.wisefy.callbacks.GetSavedNetworksCallbacks; +//import com.isupatches.wisefy.constants.WiseFyCodes; +//import org.junit.Test; +//import java.util.ArrayList; +//import java.util.List; +//import static com.isupatches.wisefy.base.TestUtils.TEST_SSID; +//import static junit.framework.Assert.assertEquals; +//import static junit.framework.Assert.fail; +//import static org.mockito.Mockito.mock; +//import static org.mockito.Mockito.never; +//import static org.mockito.Mockito.timeout; +//import static org.mockito.Mockito.verify; +//import static org.mockito.Mockito.when; +// +// +//public class GetSavedNetworksTests extends BaseTestClass { +// +// public GetSavedNetworksTests() { +// super(TestActivity.class); +// } +// +// @Test +// public void noCallbacks_failure_missingPrerequisite() { +// missingPrerequisite(); +// assertEquals(null, mWiseFy.getSavedNetworks()); +// verify(mMockWiFiManager, never()).getConfiguredNetworks(); +// } +// +// @Test +// public void noCallbacks_success() { +// List wifiList = new ArrayList<>(); +// WifiConfiguration mWiFiConfiguration = new WifiConfiguration(); +// mWiFiConfiguration.SSID = TEST_SSID; +// wifiList.add(mWiFiConfiguration); +// when(mMockWiFiManager.getConfiguredNetworks()).thenReturn(wifiList); +// +// assertEquals(wifiList, mWiseFy.getSavedNetworks()); +// verify(mMockWiFiManager, timeout(VERIFICATION_TIMEOUT)).getConfiguredNetworks(); +// } +// +// @Test +// public void callbacks_failure_missingPrerequisite() { +// missingPrerequisite(); +// GetSavedNetworksCallbacks mockCallbacks = mock(GetSavedNetworksCallbacks.class); +// mWiseFy.getSavedNetworks(mockCallbacks); +// verify(mockCallbacks, timeout(VERIFICATION_TIMEOUT)).getSavedNetworksWiseFyFailure(WiseFyCodes.MISSING_PREREQUISITE); +// verify(mMockWiFiManager, never()).getConfiguredNetworks(); +// } +// +// @Test +// public void callbacks_failure_missingPrerequisite_nullCallback() { +// missingPrerequisite(); +// try { +// mWiseFy.getSavedNetworks((GetSavedNetworksCallbacks) null); +// verify(mMockWiFiManager, never()).getConfiguredNetworks(); +// } catch (NullPointerException npe) { +// fail(); +// } +// } +// +// @Test +// public void callbacks_failure_nullSavedNetworks() { +// when(mMockWiFiManager.getConfiguredNetworks()).thenReturn(null); +// GetSavedNetworksCallbacks mockCallbacks = mock(GetSavedNetworksCallbacks.class); +// mWiseFy.getSavedNetworks(mockCallbacks); +// verify(mockCallbacks, timeout(VERIFICATION_TIMEOUT)).noSavedNetworksFound(); +// } +// +// @Test +// public void callbacks_failure_nullSavedNetworks_nullCallback() { +// when(mMockWiFiManager.getConfiguredNetworks()).thenReturn(null); +// try { +// mWiseFy.getSavedNetworks((GetSavedNetworksCallbacks) null); +// verify(mMockWiFiManager, never()).getConfiguredNetworks(); +// } catch (NullPointerException npe) { +// fail(); +// } +// } +// +// @Test +// public void callbacks_failure_emptyConfiguredNetworks() { +// when(mMockWiFiManager.getConfiguredNetworks()).thenReturn(new ArrayList()); +// GetSavedNetworksCallbacks mockCallbacks = mock(GetSavedNetworksCallbacks.class); +// mWiseFy.getSavedNetworks(mockCallbacks); +// verify(mockCallbacks, timeout(VERIFICATION_TIMEOUT)).noSavedNetworksFound(); +// } +// +// @Test +// public void callbacks_failure_emptyConfiguredNetworks_nullCallback() { +// when(mMockWiFiManager.getConfiguredNetworks()).thenReturn(new ArrayList()); +// try { +// mWiseFy.getSavedNetworks((GetSavedNetworksCallbacks) null); +// verify(mMockWiFiManager, never()).getConfiguredNetworks(); +// } catch (NullPointerException npe) { +// fail(); +// } +// } +// +// @Test +// public void callbacks_success() { +// List wifiList = new ArrayList<>(); +// WifiConfiguration mWiFiConfiguration = new WifiConfiguration(); +// mWiFiConfiguration.SSID = TEST_SSID; +// wifiList.add(mWiFiConfiguration); +// when(mMockWiFiManager.getConfiguredNetworks()).thenReturn(wifiList); +// +// GetSavedNetworksCallbacks mockCallbacks = mock(GetSavedNetworksCallbacks.class); +// mWiseFy.getSavedNetworks(mockCallbacks); +// verify(mockCallbacks, timeout(VERIFICATION_TIMEOUT)).retrievedSavedNetworks(wifiList); +// verify(mMockWiFiManager, timeout(VERIFICATION_TIMEOUT)).getConfiguredNetworks(); +// } +// +// @Test +// public void callbacks_success_nullCallback() { +// List wifiList = new ArrayList<>(); +// WifiConfiguration mWiFiConfiguration = new WifiConfiguration(); +// mWiFiConfiguration.SSID = TEST_SSID; +// wifiList.add(mWiFiConfiguration); +// when(mMockWiFiManager.getConfiguredNetworks()).thenReturn(wifiList); +// +// try { +// mWiseFy.getSavedNetworks((GetSavedNetworksCallbacks) null); +// verify(mMockWiFiManager, never()).getConfiguredNetworks(); +// } catch (NullPointerException npe) { +// fail(); +// } +// } +// +// @Test +// public void callbacks_failure_withRegex_missingPrerequisite() { +// missingPrerequisite(); +// +// GetSavedNetworksCallbacks mockCallbacks = mock(GetSavedNetworksCallbacks.class); +// mWiseFy.getSavedNetworks(TEST_SSID, mockCallbacks); +// verify(mockCallbacks, timeout(VERIFICATION_TIMEOUT)).getSavedNetworksWiseFyFailure(WiseFyCodes.MISSING_PREREQUISITE); +// verify(mMockWiFiManager, never()).getConfiguredNetworks(); +// } +// +// @Test +// public void noCallbacks_failure_withRegex_missingPrerequisite() { +// missingPrerequisite(); +// assertEquals(null, mWiseFy.getSavedNetworks(TEST_SSID)); +// verify(mMockWiFiManager, never()).getConfiguredNetworks(); +// } +// +// @Test +// public void noCallbacks_success_withRegex() { +// List wifiList = new ArrayList<>(); +// WifiConfiguration mWiFiConfiguration = new WifiConfiguration(); +// mWiFiConfiguration.SSID = TEST_SSID; +// wifiList.add(mWiFiConfiguration); +// when(mMockWiFiManager.getConfiguredNetworks()).thenReturn(wifiList); +// +// assertEquals(wifiList, mWiseFy.getSavedNetworks(TEST_SSID)); +// verify(mMockWiFiManager, timeout(VERIFICATION_TIMEOUT)).getConfiguredNetworks(); +// } +// +// @Test +// public void callbacks_failure_withRegex_missingPrerequisite_nullCallback() { +// missingPrerequisite(); +// +// try{ +// mWiseFy.getSavedNetworks(TEST_SSID, null); +// verify(mMockWiFiManager, never()).getConfiguredNetworks(); +// } catch (NullPointerException npe) { +// fail(); +// } +// } +// +// @Test +// public void callbacks_failure_withRegex_nullSavedNetworks() { +// when(mMockWiFiManager.getConfiguredNetworks()).thenReturn(null); +// GetSavedNetworksCallbacks mockCallbacks = mock(GetSavedNetworksCallbacks.class); +// mWiseFy.getSavedNetworks(TEST_SSID, mockCallbacks); +// verify(mockCallbacks, timeout(VERIFICATION_TIMEOUT)).noSavedNetworksFound(); +// } +// +// @Test +// public void callbacks_failure_withRegex_nullSavedNetworks_nullCallback() { +// when(mMockWiFiManager.getConfiguredNetworks()).thenReturn(null); +// try { +// mWiseFy.getSavedNetworks(TEST_SSID, null); +// verify(mMockWiFiManager, never()).getConfiguredNetworks(); +// } catch (NullPointerException npe) { +// fail(); +// } +// } +// +// @Test +// public void callbacks_failure_withRegex_emptyConfiguredNetworks() { +// when(mMockWiFiManager.getConfiguredNetworks()).thenReturn(new ArrayList()); +// GetSavedNetworksCallbacks mockCallbacks = mock(GetSavedNetworksCallbacks.class); +// mWiseFy.getSavedNetworks(TEST_SSID, mockCallbacks); +// verify(mockCallbacks, timeout(VERIFICATION_TIMEOUT)).noSavedNetworksFound(); +// verify(mMockWiFiManager, timeout(VERIFICATION_TIMEOUT)).getConfiguredNetworks(); +// } +// +// @Test +// public void callbacks_failure_withRegex_emptyConfiguredNetworks_nullCallback() { +// when(mMockWiFiManager.getConfiguredNetworks()).thenReturn(new ArrayList()); +// try { +// mWiseFy.getSavedNetworks(TEST_SSID, null); +// verify(mMockWiFiManager, never()).getConfiguredNetworks(); +// } catch (NullPointerException npe) { +// fail(); +// } +// } +// +// @Test +// public void callbacks_success_withRegex() { +// List wifiList = new ArrayList<>(); +// WifiConfiguration mWiFiConfiguration = new WifiConfiguration(); +// mWiFiConfiguration.SSID = TEST_SSID; +// wifiList.add(mWiFiConfiguration); +// when(mMockWiFiManager.getConfiguredNetworks()).thenReturn(wifiList); +// +// GetSavedNetworksCallbacks mockCallbacks = mock(GetSavedNetworksCallbacks.class); +// mWiseFy.getSavedNetworks(TEST_SSID, mockCallbacks); +// verify(mockCallbacks, timeout(VERIFICATION_TIMEOUT)).retrievedSavedNetworks(wifiList); +// verify(mMockWiFiManager, timeout(VERIFICATION_TIMEOUT)).getConfiguredNetworks(); +// } +// +// @Test +// public void callbacks_success_withRegex_nullCallbacks() { +// List wifiList = new ArrayList<>(); +// WifiConfiguration mWiFiConfiguration = new WifiConfiguration(); +// mWiFiConfiguration.SSID = TEST_SSID; +// wifiList.add(mWiFiConfiguration); +// when(mMockWiFiManager.getConfiguredNetworks()).thenReturn(wifiList); +// +// try { +// mWiseFy.getSavedNetworks(TEST_SSID, null); +// verify(mMockWiFiManager, never()).getConfiguredNetworks(); +// } catch (NullPointerException npe) { +// fail(); +// } +// } +//} diff --git a/wisefy/src/androidTest/java/com/isupatches/wisefy/test/BuilderTests.java b/wisefy/src/androidTest/java/com/isupatches/wisefy/test/BuilderTests.java index d90be9cb..e829d4e8 100644 --- a/wisefy/src/androidTest/java/com/isupatches/wisefy/test/BuilderTests.java +++ b/wisefy/src/androidTest/java/com/isupatches/wisefy/test/BuilderTests.java @@ -1,32 +1,32 @@ -package com.isupatches.wisefy.test; - - -import android.support.test.rule.ActivityTestRule; -import com.isupatches.wisefy.WiseFy; -import com.isupatches.wisefy.base.TestActivity; -import org.junit.Rule; -import org.junit.Test; -import static org.junit.Assert.assertEquals; - - -public class BuilderTests extends ActivityTestRule { - - @Rule - public ActivityTestRule mActivityTestRule = new ActivityTestRule<>(TestActivity.class); - - public BuilderTests() { - super(TestActivity.class); - } - - @Test - public void builder_loggingFalse() { - WiseFy wiseFy = new WiseFy.brains(mActivityTestRule.getActivity()).logging(false).getSmarts(); - assertEquals(false, wiseFy.isLoggingEnabled()); - } - - @Test - public void builder_loggingTrue() { - WiseFy wiseFy = new WiseFy.brains(mActivityTestRule.getActivity()).logging(true).getSmarts(); - assertEquals(true, wiseFy.isLoggingEnabled()); - } -} +//package com.isupatches.wisefy.test; +// +// +//import android.support.test.rule.ActivityTestRule; +//import com.isupatches.wisefy.WiseFy; +//import com.isupatches.wisefy.base.TestActivity; +//import org.junit.Rule; +//import org.junit.Test; +//import static org.junit.Assert.assertEquals; +// +// +//public class BuilderTests extends ActivityTestRule { +// +// @Rule +// public ActivityTestRule mActivityTestRule = new ActivityTestRule<>(TestActivity.class); +// +// public BuilderTests() { +// super(TestActivity.class); +// } +// +// @Test +// public void builder_loggingFalse() { +// WiseFy wiseFy = new WiseFy.brains(mActivityTestRule.getActivity()).logging(false).getSmarts(); +// assertEquals(false, wiseFy.isLoggingEnabled()); +// } +// +// @Test +// public void builder_loggingTrue() { +// WiseFy wiseFy = new WiseFy.brains(mActivityTestRule.getActivity()).logging(true).getSmarts(); +// assertEquals(true, wiseFy.isLoggingEnabled()); +// } +//} From 6238f7f5973fcbacb2f96a379671a603061b6765 Mon Sep 17 00:00:00 2001 From: isuPatches Date: Sun, 23 Jul 2017 20:44:13 -0500 Subject: [PATCH 70/74] Temp test --- .../wisefy/GetSavedNetworkTests.java | 288 +-- ...IsDeviceConnectedToMobileNetworkTests.java | 92 +- ...ceConnectedToMobileOrWifiNetworkTests.java | 90 +- .../wisefy/IsDeviceConnectedToSSIDTests.java | 96 +- .../IsDeviceConnectedToWifiNetworkTests.java | 92 +- .../wisefy/IsDeviceRoamingTests.java | 84 +- .../isupatches/wisefy/IsNetwork5gHzTests.java | 204 +- .../isupatches/wisefy/IsNetworkEAPTests.java | 98 +- .../IsNetworkInConfigurationListTests.java | 198 +- .../isupatches/wisefy/IsNetworkPSKTest.java | 98 +- .../wisefy/IsNetworkSecureTests.java | 154 +- .../isupatches/wisefy/IsNetworkWPA2Test.java | 98 +- .../isupatches/wisefy/IsNetworkWPATests.java | 98 +- .../isupatches/wisefy/IsNetworkWepTests.java | 98 +- .../isupatches/wisefy/IsWifiEnabledTests.java | 66 +- .../isupatches/wisefy/ManagerUtilTest.java | 92 +- .../isupatches/wisefy/RemoveNetworkTests.java | 420 ++-- .../wisefy/SearchForAccessPointTests.java | 544 +++--- .../wisefy/SearchForAccessPointsTests.java | 572 +++--- .../isupatches/wisefy/SearchForSSIDTests.java | 298 +-- .../wisefy/SearchForSSIDsTests.java | 292 +-- .../wisefy/WiseFyConnectionTests.java | 728 +++---- .../wisefy/WiseFyPrerequisitesTests.java | 108 +- .../isupatches/wisefy/WiseFySearchTests.java | 1720 ++++++++--------- .../com/isupatches/wisefy/WiseFyTests.java | 94 +- 25 files changed, 3361 insertions(+), 3361 deletions(-) diff --git a/wisefy/src/androidTest/java/com/isupatches/wisefy/GetSavedNetworkTests.java b/wisefy/src/androidTest/java/com/isupatches/wisefy/GetSavedNetworkTests.java index 1bbe3a07..519018b5 100644 --- a/wisefy/src/androidTest/java/com/isupatches/wisefy/GetSavedNetworkTests.java +++ b/wisefy/src/androidTest/java/com/isupatches/wisefy/GetSavedNetworkTests.java @@ -1,144 +1,144 @@ -package com.isupatches.wisefy; - - -import android.net.wifi.WifiConfiguration; -import com.isupatches.wisefy.base.TestActivity; -import com.isupatches.wisefy.callbacks.GetSavedNetworkCallbacks; -import com.isupatches.wisefy.constants.WiseFyCodes; -import org.junit.Test; -import static com.isupatches.wisefy.base.TestUtils.TEST_SSID; -import static junit.framework.Assert.assertEquals; -import static junit.framework.Assert.fail; -import static org.mockito.ArgumentMatchers.anyString; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.timeout; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; - - -public class GetSavedNetworkTests extends BaseTestClass { - - public GetSavedNetworkTests() { - super(TestActivity.class); - } - - @Test - public void noCallbacks_failure_nullSSIDParam() { - assertEquals(null, mWiseFy.getSavedNetwork(null)); - } - - @Test - public void noCallbacks_failure_missingPrerequisite() { - missingPrerequisite(); - assertEquals(null, mWiseFy.getSavedNetwork(TEST_SSID)); - } - - @Test - public void noCallbacks_failure() { - WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); - mWiseFy.mWiseFySearch = mockWiseFySearch; - when(mockWiseFySearch.findSavedNetworkByRegex(anyString())).thenReturn(null); - - assertEquals(null, mWiseFy.getSavedNetwork(TEST_SSID)); - } - - @Test - public void noCallbacks_success() { - WifiConfiguration wiFiConfiguration = new WifiConfiguration(); - wiFiConfiguration.SSID = TEST_SSID; - - WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); - mWiseFy.mWiseFySearch = mockWiseFySearch; - when(mockWiseFySearch.findSavedNetworkByRegex(anyString())).thenReturn(wiFiConfiguration); - - assertEquals(wiFiConfiguration, mWiseFy.getSavedNetwork(TEST_SSID)); - } - - @Test - public void callbacks_failure_nullSSIDParam() { - GetSavedNetworkCallbacks mockCallbacks = mock(GetSavedNetworkCallbacks.class); - mWiseFy.getSavedNetwork(null, mockCallbacks); - verify(mockCallbacks, timeout(2000)).getSavedNetworkWiseFyFailure(WiseFyCodes.MISSING_PARAMETER); - } - - @Test - public void callbacks_failure_nullSSIDParam_nullCallback() { - try { - mWiseFy.getSavedNetwork(null, null); - } catch (NullPointerException npe) { - fail(); - } - } - - @Test - public void callbacks_failure_missingPrerequisite() { - missingPrerequisite(); - GetSavedNetworkCallbacks mockCallbacks = mock(GetSavedNetworkCallbacks.class); - mWiseFy.getSavedNetwork(TEST_SSID, mockCallbacks); - verify(mockCallbacks, timeout(2000)).getSavedNetworkWiseFyFailure(WiseFyCodes.MISSING_PREREQUISITE); - } - - @Test - public void callbacks_failure_missingPrerequisite_nullCallback() { - missingPrerequisite(); - try { - mWiseFy.getSavedNetwork(TEST_SSID, null); - } catch (NullPointerException npe) { - fail(); - } - } - - @Test - public void callbacks_failure() { - WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); - mWiseFy.mWiseFySearch = mockWiseFySearch; - when(mockWiseFySearch.findSavedNetworkByRegex(anyString())).thenReturn(null); - - GetSavedNetworkCallbacks mockCallbacks = mock(GetSavedNetworkCallbacks.class); - mWiseFy.getSavedNetwork(TEST_SSID, mockCallbacks); - verify(mockCallbacks, timeout(2000)).savedNetworkNotFound(); - } - - @Test - public void callbacks_failure_nullCallback() { - WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); - mWiseFy.mWiseFySearch = mockWiseFySearch; - when(mockWiseFySearch.findSavedNetworkByRegex(anyString())).thenReturn(null); - - try { - mWiseFy.getSavedNetwork(TEST_SSID, null); - } catch (NullPointerException npe) { - fail(); - } - } - - @Test - public void callbacks_success() { - WifiConfiguration wiFiConfiguration = new WifiConfiguration(); - wiFiConfiguration.SSID = TEST_SSID; - - WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); - mWiseFy.mWiseFySearch = mockWiseFySearch; - when(mockWiseFySearch.findSavedNetworkByRegex(anyString())).thenReturn(wiFiConfiguration); - - GetSavedNetworkCallbacks mockCallbacks = mock(GetSavedNetworkCallbacks.class); - mWiseFy.getSavedNetwork(TEST_SSID, mockCallbacks); - verify(mockCallbacks, timeout(2000)).retrievedSavedNetwork(wiFiConfiguration); - } - - @Test - public void callbacks_success_nullCallback() { - WifiConfiguration wiFiConfiguration = new WifiConfiguration(); - wiFiConfiguration.SSID = TEST_SSID; - - WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); - mWiseFy.mWiseFySearch = mockWiseFySearch; - when(mockWiseFySearch.findSavedNetworkByRegex(anyString())).thenReturn(wiFiConfiguration); - - try { - mWiseFy.getSavedNetwork(TEST_SSID, null); - } catch (NullPointerException npe) { - fail(); - } - } -} +//package com.isupatches.wisefy; +// +// +//import android.net.wifi.WifiConfiguration; +//import com.isupatches.wisefy.base.TestActivity; +//import com.isupatches.wisefy.callbacks.GetSavedNetworkCallbacks; +//import com.isupatches.wisefy.constants.WiseFyCodes; +//import org.junit.Test; +//import static com.isupatches.wisefy.base.TestUtils.TEST_SSID; +//import static junit.framework.Assert.assertEquals; +//import static junit.framework.Assert.fail; +//import static org.mockito.ArgumentMatchers.anyString; +//import static org.mockito.Mockito.mock; +//import static org.mockito.Mockito.timeout; +//import static org.mockito.Mockito.verify; +//import static org.mockito.Mockito.when; +// +// +//public class GetSavedNetworkTests extends BaseTestClass { +// +// public GetSavedNetworkTests() { +// super(TestActivity.class); +// } +// +// @Test +// public void noCallbacks_failure_nullSSIDParam() { +// assertEquals(null, mWiseFy.getSavedNetwork(null)); +// } +// +// @Test +// public void noCallbacks_failure_missingPrerequisite() { +// missingPrerequisite(); +// assertEquals(null, mWiseFy.getSavedNetwork(TEST_SSID)); +// } +// +// @Test +// public void noCallbacks_failure() { +// WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); +// mWiseFy.mWiseFySearch = mockWiseFySearch; +// when(mockWiseFySearch.findSavedNetworkByRegex(anyString())).thenReturn(null); +// +// assertEquals(null, mWiseFy.getSavedNetwork(TEST_SSID)); +// } +// +// @Test +// public void noCallbacks_success() { +// WifiConfiguration wiFiConfiguration = new WifiConfiguration(); +// wiFiConfiguration.SSID = TEST_SSID; +// +// WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); +// mWiseFy.mWiseFySearch = mockWiseFySearch; +// when(mockWiseFySearch.findSavedNetworkByRegex(anyString())).thenReturn(wiFiConfiguration); +// +// assertEquals(wiFiConfiguration, mWiseFy.getSavedNetwork(TEST_SSID)); +// } +// +// @Test +// public void callbacks_failure_nullSSIDParam() { +// GetSavedNetworkCallbacks mockCallbacks = mock(GetSavedNetworkCallbacks.class); +// mWiseFy.getSavedNetwork(null, mockCallbacks); +// verify(mockCallbacks, timeout(2000)).getSavedNetworkWiseFyFailure(WiseFyCodes.MISSING_PARAMETER); +// } +// +// @Test +// public void callbacks_failure_nullSSIDParam_nullCallback() { +// try { +// mWiseFy.getSavedNetwork(null, null); +// } catch (NullPointerException npe) { +// fail(); +// } +// } +// +// @Test +// public void callbacks_failure_missingPrerequisite() { +// missingPrerequisite(); +// GetSavedNetworkCallbacks mockCallbacks = mock(GetSavedNetworkCallbacks.class); +// mWiseFy.getSavedNetwork(TEST_SSID, mockCallbacks); +// verify(mockCallbacks, timeout(2000)).getSavedNetworkWiseFyFailure(WiseFyCodes.MISSING_PREREQUISITE); +// } +// +// @Test +// public void callbacks_failure_missingPrerequisite_nullCallback() { +// missingPrerequisite(); +// try { +// mWiseFy.getSavedNetwork(TEST_SSID, null); +// } catch (NullPointerException npe) { +// fail(); +// } +// } +// +// @Test +// public void callbacks_failure() { +// WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); +// mWiseFy.mWiseFySearch = mockWiseFySearch; +// when(mockWiseFySearch.findSavedNetworkByRegex(anyString())).thenReturn(null); +// +// GetSavedNetworkCallbacks mockCallbacks = mock(GetSavedNetworkCallbacks.class); +// mWiseFy.getSavedNetwork(TEST_SSID, mockCallbacks); +// verify(mockCallbacks, timeout(2000)).savedNetworkNotFound(); +// } +// +// @Test +// public void callbacks_failure_nullCallback() { +// WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); +// mWiseFy.mWiseFySearch = mockWiseFySearch; +// when(mockWiseFySearch.findSavedNetworkByRegex(anyString())).thenReturn(null); +// +// try { +// mWiseFy.getSavedNetwork(TEST_SSID, null); +// } catch (NullPointerException npe) { +// fail(); +// } +// } +// +// @Test +// public void callbacks_success() { +// WifiConfiguration wiFiConfiguration = new WifiConfiguration(); +// wiFiConfiguration.SSID = TEST_SSID; +// +// WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); +// mWiseFy.mWiseFySearch = mockWiseFySearch; +// when(mockWiseFySearch.findSavedNetworkByRegex(anyString())).thenReturn(wiFiConfiguration); +// +// GetSavedNetworkCallbacks mockCallbacks = mock(GetSavedNetworkCallbacks.class); +// mWiseFy.getSavedNetwork(TEST_SSID, mockCallbacks); +// verify(mockCallbacks, timeout(2000)).retrievedSavedNetwork(wiFiConfiguration); +// } +// +// @Test +// public void callbacks_success_nullCallback() { +// WifiConfiguration wiFiConfiguration = new WifiConfiguration(); +// wiFiConfiguration.SSID = TEST_SSID; +// +// WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); +// mWiseFy.mWiseFySearch = mockWiseFySearch; +// when(mockWiseFySearch.findSavedNetworkByRegex(anyString())).thenReturn(wiFiConfiguration); +// +// try { +// mWiseFy.getSavedNetwork(TEST_SSID, null); +// } catch (NullPointerException npe) { +// fail(); +// } +// } +//} diff --git a/wisefy/src/androidTest/java/com/isupatches/wisefy/IsDeviceConnectedToMobileNetworkTests.java b/wisefy/src/androidTest/java/com/isupatches/wisefy/IsDeviceConnectedToMobileNetworkTests.java index 73f3b9aa..5a9a49cd 100644 --- a/wisefy/src/androidTest/java/com/isupatches/wisefy/IsDeviceConnectedToMobileNetworkTests.java +++ b/wisefy/src/androidTest/java/com/isupatches/wisefy/IsDeviceConnectedToMobileNetworkTests.java @@ -1,46 +1,46 @@ -package com.isupatches.wisefy; - - -import android.net.NetworkInfo; -import com.isupatches.wisefy.base.TestActivity; -import org.junit.Test; -import static junit.framework.Assert.assertFalse; -import static junit.framework.Assert.assertTrue; -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.ArgumentMatchers.anyString; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; - - -public class IsDeviceConnectedToMobileNetworkTests extends BaseTestClass { - - public IsDeviceConnectedToMobileNetworkTests() { - super(TestActivity.class); - } - - @Test - public void failure_missingPrerequisite() { - missingPrerequisite(); - assertFalse(mWiseFy.isDeviceConnectedToMobileNetwork()); - } - - @Test - public void failure() { - when(mMockConnectivityManager.getActiveNetworkInfo()).thenReturn(mock(NetworkInfo.class)); - - WiseFyConnection mockWiseFyConnection = mock(WiseFyConnection.class); - mWiseFy.mWiseFyConnection = mockWiseFyConnection; - when(mockWiseFyConnection.isNetworkConnectedAndMatchesType(any(NetworkInfo.class), anyString())).thenReturn(false); - assertFalse(mWiseFy.isDeviceConnectedToMobileNetwork()); - } - - @Test - public void success() { - when(mMockConnectivityManager.getActiveNetworkInfo()).thenReturn(mock(NetworkInfo.class)); - - WiseFyConnection mockWiseFyConnection = mock(WiseFyConnection.class); - mWiseFy.mWiseFyConnection = mockWiseFyConnection; - when(mockWiseFyConnection.isNetworkConnectedAndMatchesType(any(NetworkInfo.class), anyString())).thenReturn(true); - assertTrue(mWiseFy.isDeviceConnectedToMobileNetwork()); - } -} +//package com.isupatches.wisefy; +// +// +//import android.net.NetworkInfo; +//import com.isupatches.wisefy.base.TestActivity; +//import org.junit.Test; +//import static junit.framework.Assert.assertFalse; +//import static junit.framework.Assert.assertTrue; +//import static org.mockito.ArgumentMatchers.any; +//import static org.mockito.ArgumentMatchers.anyString; +//import static org.mockito.Mockito.mock; +//import static org.mockito.Mockito.when; +// +// +//public class IsDeviceConnectedToMobileNetworkTests extends BaseTestClass { +// +// public IsDeviceConnectedToMobileNetworkTests() { +// super(TestActivity.class); +// } +// +// @Test +// public void failure_missingPrerequisite() { +// missingPrerequisite(); +// assertFalse(mWiseFy.isDeviceConnectedToMobileNetwork()); +// } +// +// @Test +// public void failure() { +// when(mMockConnectivityManager.getActiveNetworkInfo()).thenReturn(mock(NetworkInfo.class)); +// +// WiseFyConnection mockWiseFyConnection = mock(WiseFyConnection.class); +// mWiseFy.mWiseFyConnection = mockWiseFyConnection; +// when(mockWiseFyConnection.isNetworkConnectedAndMatchesType(any(NetworkInfo.class), anyString())).thenReturn(false); +// assertFalse(mWiseFy.isDeviceConnectedToMobileNetwork()); +// } +// +// @Test +// public void success() { +// when(mMockConnectivityManager.getActiveNetworkInfo()).thenReturn(mock(NetworkInfo.class)); +// +// WiseFyConnection mockWiseFyConnection = mock(WiseFyConnection.class); +// mWiseFy.mWiseFyConnection = mockWiseFyConnection; +// when(mockWiseFyConnection.isNetworkConnectedAndMatchesType(any(NetworkInfo.class), anyString())).thenReturn(true); +// assertTrue(mWiseFy.isDeviceConnectedToMobileNetwork()); +// } +//} diff --git a/wisefy/src/androidTest/java/com/isupatches/wisefy/IsDeviceConnectedToMobileOrWifiNetworkTests.java b/wisefy/src/androidTest/java/com/isupatches/wisefy/IsDeviceConnectedToMobileOrWifiNetworkTests.java index 2d15222c..7fe984c9 100644 --- a/wisefy/src/androidTest/java/com/isupatches/wisefy/IsDeviceConnectedToMobileOrWifiNetworkTests.java +++ b/wisefy/src/androidTest/java/com/isupatches/wisefy/IsDeviceConnectedToMobileOrWifiNetworkTests.java @@ -1,45 +1,45 @@ -package com.isupatches.wisefy; - - -import android.net.NetworkInfo; -import com.isupatches.wisefy.base.TestActivity; -import org.junit.Test; -import static junit.framework.Assert.assertFalse; -import static junit.framework.Assert.assertTrue; -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; - - -public class IsDeviceConnectedToMobileOrWifiNetworkTests extends BaseTestClass { - - public IsDeviceConnectedToMobileOrWifiNetworkTests() { - super(TestActivity.class); - } - - @Test - public void failure_missingPrerequisite() { - missingPrerequisite(); - assertFalse(mWiseFy.isDeviceConnectedToMobileOrWifiNetwork()); - } - - @Test - public void failure() { - when(mMockConnectivityManager.getActiveNetworkInfo()).thenReturn(mock(NetworkInfo.class)); - - WiseFyConnection mockWiseFyConnection = mock(WiseFyConnection.class); - mWiseFy.mWiseFyConnection = mockWiseFyConnection; - when(mockWiseFyConnection.isNetworkConnected(any(NetworkInfo.class))).thenReturn(false); - assertFalse(mWiseFy.isDeviceConnectedToMobileOrWifiNetwork()); - } - - @Test - public void success() { - when(mMockConnectivityManager.getActiveNetworkInfo()).thenReturn(mock(NetworkInfo.class)); - - WiseFyConnection mockWiseFyConnection = mock(WiseFyConnection.class); - mWiseFy.mWiseFyConnection = mockWiseFyConnection; - when(mockWiseFyConnection.isNetworkConnected(any(NetworkInfo.class))).thenReturn(true); - assertTrue(mWiseFy.isDeviceConnectedToMobileOrWifiNetwork()); - } -} +//package com.isupatches.wisefy; +// +// +//import android.net.NetworkInfo; +//import com.isupatches.wisefy.base.TestActivity; +//import org.junit.Test; +//import static junit.framework.Assert.assertFalse; +//import static junit.framework.Assert.assertTrue; +//import static org.mockito.ArgumentMatchers.any; +//import static org.mockito.Mockito.mock; +//import static org.mockito.Mockito.when; +// +// +//public class IsDeviceConnectedToMobileOrWifiNetworkTests extends BaseTestClass { +// +// public IsDeviceConnectedToMobileOrWifiNetworkTests() { +// super(TestActivity.class); +// } +// +// @Test +// public void failure_missingPrerequisite() { +// missingPrerequisite(); +// assertFalse(mWiseFy.isDeviceConnectedToMobileOrWifiNetwork()); +// } +// +// @Test +// public void failure() { +// when(mMockConnectivityManager.getActiveNetworkInfo()).thenReturn(mock(NetworkInfo.class)); +// +// WiseFyConnection mockWiseFyConnection = mock(WiseFyConnection.class); +// mWiseFy.mWiseFyConnection = mockWiseFyConnection; +// when(mockWiseFyConnection.isNetworkConnected(any(NetworkInfo.class))).thenReturn(false); +// assertFalse(mWiseFy.isDeviceConnectedToMobileOrWifiNetwork()); +// } +// +// @Test +// public void success() { +// when(mMockConnectivityManager.getActiveNetworkInfo()).thenReturn(mock(NetworkInfo.class)); +// +// WiseFyConnection mockWiseFyConnection = mock(WiseFyConnection.class); +// mWiseFy.mWiseFyConnection = mockWiseFyConnection; +// when(mockWiseFyConnection.isNetworkConnected(any(NetworkInfo.class))).thenReturn(true); +// assertTrue(mWiseFy.isDeviceConnectedToMobileOrWifiNetwork()); +// } +//} diff --git a/wisefy/src/androidTest/java/com/isupatches/wisefy/IsDeviceConnectedToSSIDTests.java b/wisefy/src/androidTest/java/com/isupatches/wisefy/IsDeviceConnectedToSSIDTests.java index 1f3d0a78..faadaec3 100644 --- a/wisefy/src/androidTest/java/com/isupatches/wisefy/IsDeviceConnectedToSSIDTests.java +++ b/wisefy/src/androidTest/java/com/isupatches/wisefy/IsDeviceConnectedToSSIDTests.java @@ -1,48 +1,48 @@ -package com.isupatches.wisefy; - - -import com.isupatches.wisefy.base.TestActivity; -import org.junit.Test; -import static com.isupatches.wisefy.base.TestUtils.TEST_SSID; -import static junit.framework.Assert.assertFalse; -import static junit.framework.Assert.assertTrue; -import static org.mockito.ArgumentMatchers.anyString; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; - - -public class IsDeviceConnectedToSSIDTests extends BaseTestClass { - - public IsDeviceConnectedToSSIDTests() { - super(TestActivity.class); - } - - @Test - public void noCallbacks_failure_nullSSIDParams() { - assertFalse(mWiseFy.isDeviceConnectedToSSID(null)); - } - - @Test - public void noCallbacks_failure_missingPrerequisite() { - missingPrerequisite(); - assertFalse(mWiseFy.isDeviceConnectedToSSID(TEST_SSID)); - } - - @Test - public void noCallbacks_failure() { - WiseFyConnection mockWiseFyConnection = mock(WiseFyConnection.class); - mWiseFy.mWiseFyConnection = mockWiseFyConnection; - when(mockWiseFyConnection.isCurrentNetworkConnectedToSSID(anyString())).thenReturn(false); - - assertFalse(mWiseFy.isDeviceConnectedToSSID(TEST_SSID)); - } - - @Test - public void noCallbacks_success() { - WiseFyConnection mockWiseFyConnection = mock(WiseFyConnection.class); - mWiseFy.mWiseFyConnection = mockWiseFyConnection; - when(mockWiseFyConnection.isCurrentNetworkConnectedToSSID(anyString())).thenReturn(true); - - assertTrue(mWiseFy.isDeviceConnectedToSSID(TEST_SSID)); - } -} +//package com.isupatches.wisefy; +// +// +//import com.isupatches.wisefy.base.TestActivity; +//import org.junit.Test; +//import static com.isupatches.wisefy.base.TestUtils.TEST_SSID; +//import static junit.framework.Assert.assertFalse; +//import static junit.framework.Assert.assertTrue; +//import static org.mockito.ArgumentMatchers.anyString; +//import static org.mockito.Mockito.mock; +//import static org.mockito.Mockito.when; +// +// +//public class IsDeviceConnectedToSSIDTests extends BaseTestClass { +// +// public IsDeviceConnectedToSSIDTests() { +// super(TestActivity.class); +// } +// +// @Test +// public void noCallbacks_failure_nullSSIDParams() { +// assertFalse(mWiseFy.isDeviceConnectedToSSID(null)); +// } +// +// @Test +// public void noCallbacks_failure_missingPrerequisite() { +// missingPrerequisite(); +// assertFalse(mWiseFy.isDeviceConnectedToSSID(TEST_SSID)); +// } +// +// @Test +// public void noCallbacks_failure() { +// WiseFyConnection mockWiseFyConnection = mock(WiseFyConnection.class); +// mWiseFy.mWiseFyConnection = mockWiseFyConnection; +// when(mockWiseFyConnection.isCurrentNetworkConnectedToSSID(anyString())).thenReturn(false); +// +// assertFalse(mWiseFy.isDeviceConnectedToSSID(TEST_SSID)); +// } +// +// @Test +// public void noCallbacks_success() { +// WiseFyConnection mockWiseFyConnection = mock(WiseFyConnection.class); +// mWiseFy.mWiseFyConnection = mockWiseFyConnection; +// when(mockWiseFyConnection.isCurrentNetworkConnectedToSSID(anyString())).thenReturn(true); +// +// assertTrue(mWiseFy.isDeviceConnectedToSSID(TEST_SSID)); +// } +//} diff --git a/wisefy/src/androidTest/java/com/isupatches/wisefy/IsDeviceConnectedToWifiNetworkTests.java b/wisefy/src/androidTest/java/com/isupatches/wisefy/IsDeviceConnectedToWifiNetworkTests.java index 534a195d..0c4495f6 100644 --- a/wisefy/src/androidTest/java/com/isupatches/wisefy/IsDeviceConnectedToWifiNetworkTests.java +++ b/wisefy/src/androidTest/java/com/isupatches/wisefy/IsDeviceConnectedToWifiNetworkTests.java @@ -1,46 +1,46 @@ -package com.isupatches.wisefy; - - -import android.net.NetworkInfo; -import com.isupatches.wisefy.base.TestActivity; -import org.junit.Test; -import static junit.framework.Assert.assertFalse; -import static junit.framework.Assert.assertTrue; -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.ArgumentMatchers.anyString; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; - - -public class IsDeviceConnectedToWifiNetworkTests extends BaseTestClass { - - public IsDeviceConnectedToWifiNetworkTests() { - super(TestActivity.class); - } - - @Test - public void failure_missingPrerequisite() { - missingPrerequisite(); - assertFalse(mWiseFy.isDeviceConnectedToWifiNetwork()); - } - - @Test - public void failure() { - when(mMockConnectivityManager.getActiveNetworkInfo()).thenReturn(mock(NetworkInfo.class)); - - WiseFyConnection mockWiseFyConnection = mock(WiseFyConnection.class); - mWiseFy.mWiseFyConnection = mockWiseFyConnection; - when(mockWiseFyConnection.isNetworkConnectedAndMatchesType(any(NetworkInfo.class), anyString())).thenReturn(false); - assertFalse(mWiseFy.isDeviceConnectedToWifiNetwork()); - } - - @Test - public void success() { - when(mMockConnectivityManager.getActiveNetworkInfo()).thenReturn(mock(NetworkInfo.class)); - - WiseFyConnection mockWiseFyConnection = mock(WiseFyConnection.class); - mWiseFy.mWiseFyConnection = mockWiseFyConnection; - when(mockWiseFyConnection.isNetworkConnectedAndMatchesType(any(NetworkInfo.class), anyString())).thenReturn(true); - assertTrue(mWiseFy.isDeviceConnectedToWifiNetwork()); - } -} +//package com.isupatches.wisefy; +// +// +//import android.net.NetworkInfo; +//import com.isupatches.wisefy.base.TestActivity; +//import org.junit.Test; +//import static junit.framework.Assert.assertFalse; +//import static junit.framework.Assert.assertTrue; +//import static org.mockito.ArgumentMatchers.any; +//import static org.mockito.ArgumentMatchers.anyString; +//import static org.mockito.Mockito.mock; +//import static org.mockito.Mockito.when; +// +// +//public class IsDeviceConnectedToWifiNetworkTests extends BaseTestClass { +// +// public IsDeviceConnectedToWifiNetworkTests() { +// super(TestActivity.class); +// } +// +// @Test +// public void failure_missingPrerequisite() { +// missingPrerequisite(); +// assertFalse(mWiseFy.isDeviceConnectedToWifiNetwork()); +// } +// +// @Test +// public void failure() { +// when(mMockConnectivityManager.getActiveNetworkInfo()).thenReturn(mock(NetworkInfo.class)); +// +// WiseFyConnection mockWiseFyConnection = mock(WiseFyConnection.class); +// mWiseFy.mWiseFyConnection = mockWiseFyConnection; +// when(mockWiseFyConnection.isNetworkConnectedAndMatchesType(any(NetworkInfo.class), anyString())).thenReturn(false); +// assertFalse(mWiseFy.isDeviceConnectedToWifiNetwork()); +// } +// +// @Test +// public void success() { +// when(mMockConnectivityManager.getActiveNetworkInfo()).thenReturn(mock(NetworkInfo.class)); +// +// WiseFyConnection mockWiseFyConnection = mock(WiseFyConnection.class); +// mWiseFy.mWiseFyConnection = mockWiseFyConnection; +// when(mockWiseFyConnection.isNetworkConnectedAndMatchesType(any(NetworkInfo.class), anyString())).thenReturn(true); +// assertTrue(mWiseFy.isDeviceConnectedToWifiNetwork()); +// } +//} diff --git a/wisefy/src/androidTest/java/com/isupatches/wisefy/IsDeviceRoamingTests.java b/wisefy/src/androidTest/java/com/isupatches/wisefy/IsDeviceRoamingTests.java index aa13ee8d..a02cbc6f 100644 --- a/wisefy/src/androidTest/java/com/isupatches/wisefy/IsDeviceRoamingTests.java +++ b/wisefy/src/androidTest/java/com/isupatches/wisefy/IsDeviceRoamingTests.java @@ -1,42 +1,42 @@ -package com.isupatches.wisefy; - - -import android.net.NetworkInfo; -import com.isupatches.wisefy.base.TestActivity; -import org.junit.Test; -import static junit.framework.Assert.assertFalse; -import static junit.framework.Assert.assertTrue; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; - - -public class IsDeviceRoamingTests extends BaseTestClass { - - public IsDeviceRoamingTests() { - super(TestActivity.class); - } - - @Test - public void failure_missingPrerequisite() { - missingPrerequisite(); - assertFalse(mWiseFy.isDeviceRoaming()); - } - - @Test - public void failure() { - NetworkInfo networkInfo = mock(NetworkInfo.class); - when(networkInfo.isRoaming()).thenReturn(false); - when(mMockConnectivityManager.getActiveNetworkInfo()).thenReturn(networkInfo); - - assertFalse(mWiseFy.isDeviceRoaming()); - } - - @Test - public void success() { - NetworkInfo networkInfo = mock(NetworkInfo.class); - when(networkInfo.isRoaming()).thenReturn(true); - when(mMockConnectivityManager.getActiveNetworkInfo()).thenReturn(networkInfo); - - assertTrue(mWiseFy.isDeviceRoaming()); - } -} +//package com.isupatches.wisefy; +// +// +//import android.net.NetworkInfo; +//import com.isupatches.wisefy.base.TestActivity; +//import org.junit.Test; +//import static junit.framework.Assert.assertFalse; +//import static junit.framework.Assert.assertTrue; +//import static org.mockito.Mockito.mock; +//import static org.mockito.Mockito.when; +// +// +//public class IsDeviceRoamingTests extends BaseTestClass { +// +// public IsDeviceRoamingTests() { +// super(TestActivity.class); +// } +// +// @Test +// public void failure_missingPrerequisite() { +// missingPrerequisite(); +// assertFalse(mWiseFy.isDeviceRoaming()); +// } +// +// @Test +// public void failure() { +// NetworkInfo networkInfo = mock(NetworkInfo.class); +// when(networkInfo.isRoaming()).thenReturn(false); +// when(mMockConnectivityManager.getActiveNetworkInfo()).thenReturn(networkInfo); +// +// assertFalse(mWiseFy.isDeviceRoaming()); +// } +// +// @Test +// public void success() { +// NetworkInfo networkInfo = mock(NetworkInfo.class); +// when(networkInfo.isRoaming()).thenReturn(true); +// when(mMockConnectivityManager.getActiveNetworkInfo()).thenReturn(networkInfo); +// +// assertTrue(mWiseFy.isDeviceRoaming()); +// } +//} diff --git a/wisefy/src/androidTest/java/com/isupatches/wisefy/IsNetwork5gHzTests.java b/wisefy/src/androidTest/java/com/isupatches/wisefy/IsNetwork5gHzTests.java index 0e5622c8..f9de44d0 100644 --- a/wisefy/src/androidTest/java/com/isupatches/wisefy/IsNetwork5gHzTests.java +++ b/wisefy/src/androidTest/java/com/isupatches/wisefy/IsNetwork5gHzTests.java @@ -1,102 +1,102 @@ -package com.isupatches.wisefy; - - -import android.net.wifi.WifiInfo; -import android.os.Build; -import com.isupatches.wisefy.base.TestActivity; -import org.junit.Test; -import static com.isupatches.wisefy.base.TestUtils.TEST_NETWORK_FREQUENCY_5GHZ; -import static com.isupatches.wisefy.base.TestUtils.TEST_NETWORK_FREQUENCY_ABOVE_5GHZ; -import static com.isupatches.wisefy.base.TestUtils.TEST_NETWORK_FREQUENCY_BELOW_5GHZ; -import static org.junit.Assert.assertEquals; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; - - -public class IsNetwork5gHzTests extends BaseTestClass { - - public IsNetwork5gHzTests() { - super(TestActivity.class); - } - - @Test - public void currentNetwork_failure_above5ghz() { - if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { - WifiInfo mockWifiInfo = mock(WifiInfo.class); - when(mockWifiInfo.getFrequency()).thenReturn(TEST_NETWORK_FREQUENCY_ABOVE_5GHZ); - when(mMockWiFiManager.getConnectionInfo()).thenReturn(mockWifiInfo); - - assertEquals(false, mWiseFy.isNetwork5gHz()); - } - } - - @Test - public void currentNetwork_failure_below5ghz() { - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { - WifiInfo mockWifiInfo = mock(WifiInfo.class); - when(mockWifiInfo.getFrequency()).thenReturn(TEST_NETWORK_FREQUENCY_BELOW_5GHZ); - when(mMockWiFiManager.getConnectionInfo()).thenReturn(mockWifiInfo); - - assertEquals(false, mWiseFy.isNetwork5gHz()); - } - } - - @Test - public void currentNetwork_failure_null() { - if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { - when(mMockWiFiManager.getConnectionInfo()).thenReturn(null); - assertEquals(false, mWiseFy.isNetwork5gHz()); - } - } - - @Test - public void currentNetwork_success() { - if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { - WifiInfo mockWifiInfo = mock(WifiInfo.class); - when(mockWifiInfo.getFrequency()).thenReturn(TEST_NETWORK_FREQUENCY_5GHZ); - when(mMockWiFiManager.getConnectionInfo()).thenReturn(mockWifiInfo); - - assertEquals(true, mWiseFy.isNetwork5gHz()); - } - } - - @Test - public void provideWifiInfo_failure_above5ghz() { - if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { - WifiInfo mockWifiInfo = mock(WifiInfo.class); - when(mockWifiInfo.getFrequency()).thenReturn(TEST_NETWORK_FREQUENCY_ABOVE_5GHZ); - when(mMockWiFiManager.getConnectionInfo()).thenReturn(mockWifiInfo); - - assertEquals(false, mWiseFy.isNetwork5gHz(mockWifiInfo)); - } - } - - @Test - public void provideWifiInfo_failure_below5ghz() { - if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { - WifiInfo mockWifiInfo = mock(WifiInfo.class); - when(mockWifiInfo.getFrequency()).thenReturn(TEST_NETWORK_FREQUENCY_BELOW_5GHZ); - when(mMockWiFiManager.getConnectionInfo()).thenReturn(mockWifiInfo); - - assertEquals(false, mWiseFy.isNetwork5gHz(mockWifiInfo)); - } - } - - @Test - public void provideWifiInfo_failure_null() { - if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { - assertEquals(false, mWiseFy.isNetwork5gHz(null)); - } - } - - @Test - public void provideWifiInfo_success() { - if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { - WifiInfo mockWifiInfo = mock(WifiInfo.class); - when(mockWifiInfo.getFrequency()).thenReturn(TEST_NETWORK_FREQUENCY_5GHZ); - when(mMockWiFiManager.getConnectionInfo()).thenReturn(mockWifiInfo); - - assertEquals(true, mWiseFy.isNetwork5gHz(mockWifiInfo)); - } - } -} +//package com.isupatches.wisefy; +// +// +//import android.net.wifi.WifiInfo; +//import android.os.Build; +//import com.isupatches.wisefy.base.TestActivity; +//import org.junit.Test; +//import static com.isupatches.wisefy.base.TestUtils.TEST_NETWORK_FREQUENCY_5GHZ; +//import static com.isupatches.wisefy.base.TestUtils.TEST_NETWORK_FREQUENCY_ABOVE_5GHZ; +//import static com.isupatches.wisefy.base.TestUtils.TEST_NETWORK_FREQUENCY_BELOW_5GHZ; +//import static org.junit.Assert.assertEquals; +//import static org.mockito.Mockito.mock; +//import static org.mockito.Mockito.when; +// +// +//public class IsNetwork5gHzTests extends BaseTestClass { +// +// public IsNetwork5gHzTests() { +// super(TestActivity.class); +// } +// +// @Test +// public void currentNetwork_failure_above5ghz() { +// if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { +// WifiInfo mockWifiInfo = mock(WifiInfo.class); +// when(mockWifiInfo.getFrequency()).thenReturn(TEST_NETWORK_FREQUENCY_ABOVE_5GHZ); +// when(mMockWiFiManager.getConnectionInfo()).thenReturn(mockWifiInfo); +// +// assertEquals(false, mWiseFy.isNetwork5gHz()); +// } +// } +// +// @Test +// public void currentNetwork_failure_below5ghz() { +// if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { +// WifiInfo mockWifiInfo = mock(WifiInfo.class); +// when(mockWifiInfo.getFrequency()).thenReturn(TEST_NETWORK_FREQUENCY_BELOW_5GHZ); +// when(mMockWiFiManager.getConnectionInfo()).thenReturn(mockWifiInfo); +// +// assertEquals(false, mWiseFy.isNetwork5gHz()); +// } +// } +// +// @Test +// public void currentNetwork_failure_null() { +// if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { +// when(mMockWiFiManager.getConnectionInfo()).thenReturn(null); +// assertEquals(false, mWiseFy.isNetwork5gHz()); +// } +// } +// +// @Test +// public void currentNetwork_success() { +// if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { +// WifiInfo mockWifiInfo = mock(WifiInfo.class); +// when(mockWifiInfo.getFrequency()).thenReturn(TEST_NETWORK_FREQUENCY_5GHZ); +// when(mMockWiFiManager.getConnectionInfo()).thenReturn(mockWifiInfo); +// +// assertEquals(true, mWiseFy.isNetwork5gHz()); +// } +// } +// +// @Test +// public void provideWifiInfo_failure_above5ghz() { +// if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { +// WifiInfo mockWifiInfo = mock(WifiInfo.class); +// when(mockWifiInfo.getFrequency()).thenReturn(TEST_NETWORK_FREQUENCY_ABOVE_5GHZ); +// when(mMockWiFiManager.getConnectionInfo()).thenReturn(mockWifiInfo); +// +// assertEquals(false, mWiseFy.isNetwork5gHz(mockWifiInfo)); +// } +// } +// +// @Test +// public void provideWifiInfo_failure_below5ghz() { +// if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { +// WifiInfo mockWifiInfo = mock(WifiInfo.class); +// when(mockWifiInfo.getFrequency()).thenReturn(TEST_NETWORK_FREQUENCY_BELOW_5GHZ); +// when(mMockWiFiManager.getConnectionInfo()).thenReturn(mockWifiInfo); +// +// assertEquals(false, mWiseFy.isNetwork5gHz(mockWifiInfo)); +// } +// } +// +// @Test +// public void provideWifiInfo_failure_null() { +// if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { +// assertEquals(false, mWiseFy.isNetwork5gHz(null)); +// } +// } +// +// @Test +// public void provideWifiInfo_success() { +// if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { +// WifiInfo mockWifiInfo = mock(WifiInfo.class); +// when(mockWifiInfo.getFrequency()).thenReturn(TEST_NETWORK_FREQUENCY_5GHZ); +// when(mMockWiFiManager.getConnectionInfo()).thenReturn(mockWifiInfo); +// +// assertEquals(true, mWiseFy.isNetwork5gHz(mockWifiInfo)); +// } +// } +//} diff --git a/wisefy/src/androidTest/java/com/isupatches/wisefy/IsNetworkEAPTests.java b/wisefy/src/androidTest/java/com/isupatches/wisefy/IsNetworkEAPTests.java index c67106a9..608760ca 100644 --- a/wisefy/src/androidTest/java/com/isupatches/wisefy/IsNetworkEAPTests.java +++ b/wisefy/src/androidTest/java/com/isupatches/wisefy/IsNetworkEAPTests.java @@ -1,49 +1,49 @@ -package com.isupatches.wisefy; - - -import android.net.wifi.ScanResult; -import com.isupatches.wisefy.base.TestActivity; -import com.isupatches.wisefy.constants.Capabilities; -import org.junit.Test; -import static org.junit.Assert.assertEquals; -import static org.mockito.Mockito.mock; - - -public class IsNetworkEAPTests extends BaseTestClass { - - public IsNetworkEAPTests() { - super(TestActivity.class); - } - - @Test - public void failure_differentCapability() { - ScanResult scanResult = mock(ScanResult.class); - scanResult.capabilities = "Other"; - assertEquals(false, mWiseFy.isNetworkEAP(scanResult)); - } - - @Test - public void failure_emptyCapabilities() { - ScanResult scanResult = mock(ScanResult.class); - scanResult.capabilities = ""; - assertEquals(false, mWiseFy.isNetworkEAP(scanResult)); - } - - @Test - public void failure_nullCapabilities() { - ScanResult scanResult = mock(ScanResult.class); - assertEquals(false, mWiseFy.isNetworkEAP(scanResult)); - } - - @Test - public void failure_nullScanResult() { - assertEquals(false, mWiseFy.isNetworkEAP(null)); - } - - @Test - public void success() { - ScanResult scanResult = mock(ScanResult.class); - scanResult.capabilities = Capabilities.EAP; - assertEquals(true, mWiseFy.isNetworkEAP(scanResult)); - } -} +//package com.isupatches.wisefy; +// +// +//import android.net.wifi.ScanResult; +//import com.isupatches.wisefy.base.TestActivity; +//import com.isupatches.wisefy.constants.Capabilities; +//import org.junit.Test; +//import static org.junit.Assert.assertEquals; +//import static org.mockito.Mockito.mock; +// +// +//public class IsNetworkEAPTests extends BaseTestClass { +// +// public IsNetworkEAPTests() { +// super(TestActivity.class); +// } +// +// @Test +// public void failure_differentCapability() { +// ScanResult scanResult = mock(ScanResult.class); +// scanResult.capabilities = "Other"; +// assertEquals(false, mWiseFy.isNetworkEAP(scanResult)); +// } +// +// @Test +// public void failure_emptyCapabilities() { +// ScanResult scanResult = mock(ScanResult.class); +// scanResult.capabilities = ""; +// assertEquals(false, mWiseFy.isNetworkEAP(scanResult)); +// } +// +// @Test +// public void failure_nullCapabilities() { +// ScanResult scanResult = mock(ScanResult.class); +// assertEquals(false, mWiseFy.isNetworkEAP(scanResult)); +// } +// +// @Test +// public void failure_nullScanResult() { +// assertEquals(false, mWiseFy.isNetworkEAP(null)); +// } +// +// @Test +// public void success() { +// ScanResult scanResult = mock(ScanResult.class); +// scanResult.capabilities = Capabilities.EAP; +// assertEquals(true, mWiseFy.isNetworkEAP(scanResult)); +// } +//} diff --git a/wisefy/src/androidTest/java/com/isupatches/wisefy/IsNetworkInConfigurationListTests.java b/wisefy/src/androidTest/java/com/isupatches/wisefy/IsNetworkInConfigurationListTests.java index ee5bd639..b17936f8 100644 --- a/wisefy/src/androidTest/java/com/isupatches/wisefy/IsNetworkInConfigurationListTests.java +++ b/wisefy/src/androidTest/java/com/isupatches/wisefy/IsNetworkInConfigurationListTests.java @@ -1,99 +1,99 @@ -package com.isupatches.wisefy; - - -import android.net.wifi.WifiConfiguration; -import com.isupatches.wisefy.base.TestActivity; -import org.junit.Test; -import java.util.ArrayList; -import java.util.List; -import static com.isupatches.wisefy.base.TestUtils.TEST_SSID; -import static com.isupatches.wisefy.base.TestUtils.TEST_SSID2; -import static com.isupatches.wisefy.base.TestUtils.TEST_SSID3; -import static org.junit.Assert.assertEquals; -import static org.mockito.Mockito.when; - - -public class IsNetworkInConfigurationListTests extends BaseTestClass { - - public IsNetworkInConfigurationListTests() { - super(TestActivity.class); - } - - @Test - public void failure() { - assertEquals(false, mWiseFy.isNetworkInConfigurationList(TEST_SSID)); - } - - @Test - public void failure_multipleNetworks() { - List wifiList = new ArrayList<>(); - - WifiConfiguration wifiConfiguration1 = new WifiConfiguration(); - wifiConfiguration1.SSID = TEST_SSID2; - wifiList.add(wifiConfiguration1); - - WifiConfiguration wiFiConfiguration2 = new WifiConfiguration(); - wiFiConfiguration2.SSID = TEST_SSID3; - wifiList.add(wiFiConfiguration2); - - when(mMockWiFiManager.getConfiguredNetworks()).thenReturn(wifiList); - assertEquals(false, mWiseFy.isNetworkInConfigurationList(TEST_SSID)); - } - - @Test - public void failure_noNetworks() { - List wifiList = new ArrayList<>(); - when(mMockWiFiManager.getConfiguredNetworks()).thenReturn(wifiList); - assertEquals(false, mWiseFy.isNetworkInConfigurationList(TEST_SSID)); - } - - @Test - public void failure_nullSSID() { - List wifiList = new ArrayList<>(); - WifiConfiguration wifiConfiguration = new WifiConfiguration(); - wifiConfiguration.SSID = null; - wifiList.add(wifiConfiguration); - when(mMockWiFiManager.getConfiguredNetworks()).thenReturn(wifiList); - assertEquals(false, mWiseFy.isNetworkInConfigurationList(TEST_SSID)); - } - - @Test - public void failure_nullWifiConfiguration() { - List wifiList = new ArrayList<>(); - wifiList.add(0, null); - when(mMockWiFiManager.getConfiguredNetworks()).thenReturn(wifiList); - assertEquals(false, mWiseFy.isNetworkInConfigurationList(TEST_SSID)); - } - - @Test - public void failure_nmissingPrerequisite() { - missingPrerequisite(); - assertEquals(false, mWiseFy.isNetworkInConfigurationList(TEST_SSID)); - } - - @Test - public void success() { - List wifiList = new ArrayList<>(); - WifiConfiguration mWiFiConfiguration = new WifiConfiguration(); - mWiFiConfiguration.SSID = TEST_SSID; - wifiList.add(mWiFiConfiguration); - when(mMockWiFiManager.getConfiguredNetworks()).thenReturn(wifiList); - assertEquals(true, mWiseFy.isNetworkInConfigurationList(TEST_SSID)); - } - - @Test - public void success_multipleNetworks() { - List wifiList = new ArrayList<>(); - - WifiConfiguration wifiConfiguration1 = new WifiConfiguration(); - wifiConfiguration1.SSID = TEST_SSID; - wifiList.add(wifiConfiguration1); - - WifiConfiguration wiFiConfiguration2 = new WifiConfiguration(); - wiFiConfiguration2.SSID = TEST_SSID2; - wifiList.add(wiFiConfiguration2); - - when(mMockWiFiManager.getConfiguredNetworks()).thenReturn(wifiList); - assertEquals(true, mWiseFy.isNetworkInConfigurationList(TEST_SSID)); - } -} +//package com.isupatches.wisefy; +// +// +//import android.net.wifi.WifiConfiguration; +//import com.isupatches.wisefy.base.TestActivity; +//import org.junit.Test; +//import java.util.ArrayList; +//import java.util.List; +//import static com.isupatches.wisefy.base.TestUtils.TEST_SSID; +//import static com.isupatches.wisefy.base.TestUtils.TEST_SSID2; +//import static com.isupatches.wisefy.base.TestUtils.TEST_SSID3; +//import static org.junit.Assert.assertEquals; +//import static org.mockito.Mockito.when; +// +// +//public class IsNetworkInConfigurationListTests extends BaseTestClass { +// +// public IsNetworkInConfigurationListTests() { +// super(TestActivity.class); +// } +// +// @Test +// public void failure() { +// assertEquals(false, mWiseFy.isNetworkInConfigurationList(TEST_SSID)); +// } +// +// @Test +// public void failure_multipleNetworks() { +// List wifiList = new ArrayList<>(); +// +// WifiConfiguration wifiConfiguration1 = new WifiConfiguration(); +// wifiConfiguration1.SSID = TEST_SSID2; +// wifiList.add(wifiConfiguration1); +// +// WifiConfiguration wiFiConfiguration2 = new WifiConfiguration(); +// wiFiConfiguration2.SSID = TEST_SSID3; +// wifiList.add(wiFiConfiguration2); +// +// when(mMockWiFiManager.getConfiguredNetworks()).thenReturn(wifiList); +// assertEquals(false, mWiseFy.isNetworkInConfigurationList(TEST_SSID)); +// } +// +// @Test +// public void failure_noNetworks() { +// List wifiList = new ArrayList<>(); +// when(mMockWiFiManager.getConfiguredNetworks()).thenReturn(wifiList); +// assertEquals(false, mWiseFy.isNetworkInConfigurationList(TEST_SSID)); +// } +// +// @Test +// public void failure_nullSSID() { +// List wifiList = new ArrayList<>(); +// WifiConfiguration wifiConfiguration = new WifiConfiguration(); +// wifiConfiguration.SSID = null; +// wifiList.add(wifiConfiguration); +// when(mMockWiFiManager.getConfiguredNetworks()).thenReturn(wifiList); +// assertEquals(false, mWiseFy.isNetworkInConfigurationList(TEST_SSID)); +// } +// +// @Test +// public void failure_nullWifiConfiguration() { +// List wifiList = new ArrayList<>(); +// wifiList.add(0, null); +// when(mMockWiFiManager.getConfiguredNetworks()).thenReturn(wifiList); +// assertEquals(false, mWiseFy.isNetworkInConfigurationList(TEST_SSID)); +// } +// +// @Test +// public void failure_nmissingPrerequisite() { +// missingPrerequisite(); +// assertEquals(false, mWiseFy.isNetworkInConfigurationList(TEST_SSID)); +// } +// +// @Test +// public void success() { +// List wifiList = new ArrayList<>(); +// WifiConfiguration mWiFiConfiguration = new WifiConfiguration(); +// mWiFiConfiguration.SSID = TEST_SSID; +// wifiList.add(mWiFiConfiguration); +// when(mMockWiFiManager.getConfiguredNetworks()).thenReturn(wifiList); +// assertEquals(true, mWiseFy.isNetworkInConfigurationList(TEST_SSID)); +// } +// +// @Test +// public void success_multipleNetworks() { +// List wifiList = new ArrayList<>(); +// +// WifiConfiguration wifiConfiguration1 = new WifiConfiguration(); +// wifiConfiguration1.SSID = TEST_SSID; +// wifiList.add(wifiConfiguration1); +// +// WifiConfiguration wiFiConfiguration2 = new WifiConfiguration(); +// wiFiConfiguration2.SSID = TEST_SSID2; +// wifiList.add(wiFiConfiguration2); +// +// when(mMockWiFiManager.getConfiguredNetworks()).thenReturn(wifiList); +// assertEquals(true, mWiseFy.isNetworkInConfigurationList(TEST_SSID)); +// } +//} diff --git a/wisefy/src/androidTest/java/com/isupatches/wisefy/IsNetworkPSKTest.java b/wisefy/src/androidTest/java/com/isupatches/wisefy/IsNetworkPSKTest.java index a2a75d78..7a307f68 100644 --- a/wisefy/src/androidTest/java/com/isupatches/wisefy/IsNetworkPSKTest.java +++ b/wisefy/src/androidTest/java/com/isupatches/wisefy/IsNetworkPSKTest.java @@ -1,49 +1,49 @@ -package com.isupatches.wisefy; - - -import android.net.wifi.ScanResult; -import com.isupatches.wisefy.base.TestActivity; -import com.isupatches.wisefy.constants.Capabilities; -import org.junit.Test; -import static org.junit.Assert.assertEquals; -import static org.mockito.Mockito.mock; - - -public class IsNetworkPSKTest extends BaseTestClass { - - public IsNetworkPSKTest() { - super(TestActivity.class); - } - - @Test - public void failure_differentCapability() { - ScanResult scanResult = mock(ScanResult.class); - scanResult.capabilities = "Other"; - assertEquals(false, mWiseFy.isNetworkPSK(scanResult)); - } - - @Test - public void failure_emptyCapabilities() { - ScanResult scanResult = mock(ScanResult.class); - scanResult.capabilities = ""; - assertEquals(false, mWiseFy.isNetworkPSK(scanResult)); - } - - @Test - public void failure_nullCapabilities() { - ScanResult scanResult = mock(ScanResult.class); - assertEquals(false, mWiseFy.isNetworkPSK(scanResult)); - } - - @Test - public void failure_nullScanResult() { - assertEquals(false, mWiseFy.isNetworkPSK(null)); - } - - @Test - public void success() { - ScanResult scanResult = mock(ScanResult.class); - scanResult.capabilities = Capabilities.PSK; - assertEquals(true, mWiseFy.isNetworkPSK(scanResult)); - } -} +//package com.isupatches.wisefy; +// +// +//import android.net.wifi.ScanResult; +//import com.isupatches.wisefy.base.TestActivity; +//import com.isupatches.wisefy.constants.Capabilities; +//import org.junit.Test; +//import static org.junit.Assert.assertEquals; +//import static org.mockito.Mockito.mock; +// +// +//public class IsNetworkPSKTest extends BaseTestClass { +// +// public IsNetworkPSKTest() { +// super(TestActivity.class); +// } +// +// @Test +// public void failure_differentCapability() { +// ScanResult scanResult = mock(ScanResult.class); +// scanResult.capabilities = "Other"; +// assertEquals(false, mWiseFy.isNetworkPSK(scanResult)); +// } +// +// @Test +// public void failure_emptyCapabilities() { +// ScanResult scanResult = mock(ScanResult.class); +// scanResult.capabilities = ""; +// assertEquals(false, mWiseFy.isNetworkPSK(scanResult)); +// } +// +// @Test +// public void failure_nullCapabilities() { +// ScanResult scanResult = mock(ScanResult.class); +// assertEquals(false, mWiseFy.isNetworkPSK(scanResult)); +// } +// +// @Test +// public void failure_nullScanResult() { +// assertEquals(false, mWiseFy.isNetworkPSK(null)); +// } +// +// @Test +// public void success() { +// ScanResult scanResult = mock(ScanResult.class); +// scanResult.capabilities = Capabilities.PSK; +// assertEquals(true, mWiseFy.isNetworkPSK(scanResult)); +// } +//} diff --git a/wisefy/src/androidTest/java/com/isupatches/wisefy/IsNetworkSecureTests.java b/wisefy/src/androidTest/java/com/isupatches/wisefy/IsNetworkSecureTests.java index a3b5abf7..89a450b1 100644 --- a/wisefy/src/androidTest/java/com/isupatches/wisefy/IsNetworkSecureTests.java +++ b/wisefy/src/androidTest/java/com/isupatches/wisefy/IsNetworkSecureTests.java @@ -1,77 +1,77 @@ -package com.isupatches.wisefy; - - -import android.net.wifi.ScanResult; -import com.isupatches.wisefy.base.TestActivity; -import com.isupatches.wisefy.constants.Capabilities; -import org.junit.Test; -import static org.junit.Assert.assertEquals; -import static org.mockito.Mockito.mock; - - -public class IsNetworkSecureTests extends BaseTestClass { - - public IsNetworkSecureTests() { - super(TestActivity.class); - } - - @Test - public void failure_emptyCapabilities() { - ScanResult scanResult = mock(ScanResult.class); - scanResult.capabilities = ""; - assertEquals(false, mWiseFy.isNetworkSecure(scanResult)); - } - - @Test - public void failure_nullCapabilities() { - ScanResult scanResult = mock(ScanResult.class); - assertEquals(false, mWiseFy.isNetworkSecure(scanResult)); - } - - @Test - public void failure_nullScanResult() { - assertEquals(false, mWiseFy.isNetworkSecure(null)); - } - - @Test - public void success_withEAP() { - ScanResult scanResult = mock(ScanResult.class); - scanResult.capabilities = Capabilities.EAP; - assertEquals(true, mWiseFy.isNetworkSecure(scanResult)); - } - - @Test - public void success_withPSK() { - ScanResult scanResult = mock(ScanResult.class); - scanResult.capabilities = Capabilities.PSK; - assertEquals(true, mWiseFy.isNetworkSecure(scanResult)); - } - - @Test - public void success_withWEP() { - ScanResult scanResult = mock(ScanResult.class); - scanResult.capabilities = Capabilities.WEP; - assertEquals(true, mWiseFy.isNetworkSecure(scanResult)); - } - - @Test - public void success_withWPA() { - ScanResult scanResult = mock(ScanResult.class); - scanResult.capabilities = Capabilities.WPA; - assertEquals(true, mWiseFy.isNetworkSecure(scanResult)); - } - - @Test - public void success_withWPA2() { - ScanResult scanResult = mock(ScanResult.class); - scanResult.capabilities = Capabilities.WPA2; - assertEquals(true, mWiseFy.isNetworkSecure(scanResult)); - } - - @Test - public void failure_otherCapabilities() { - ScanResult scanResult = mock(ScanResult.class); - scanResult.capabilities = "Other"; - assertEquals(false, mWiseFy.isNetworkSecure(scanResult)); - } -} +//package com.isupatches.wisefy; +// +// +//import android.net.wifi.ScanResult; +//import com.isupatches.wisefy.base.TestActivity; +//import com.isupatches.wisefy.constants.Capabilities; +//import org.junit.Test; +//import static org.junit.Assert.assertEquals; +//import static org.mockito.Mockito.mock; +// +// +//public class IsNetworkSecureTests extends BaseTestClass { +// +// public IsNetworkSecureTests() { +// super(TestActivity.class); +// } +// +// @Test +// public void failure_emptyCapabilities() { +// ScanResult scanResult = mock(ScanResult.class); +// scanResult.capabilities = ""; +// assertEquals(false, mWiseFy.isNetworkSecure(scanResult)); +// } +// +// @Test +// public void failure_nullCapabilities() { +// ScanResult scanResult = mock(ScanResult.class); +// assertEquals(false, mWiseFy.isNetworkSecure(scanResult)); +// } +// +// @Test +// public void failure_nullScanResult() { +// assertEquals(false, mWiseFy.isNetworkSecure(null)); +// } +// +// @Test +// public void success_withEAP() { +// ScanResult scanResult = mock(ScanResult.class); +// scanResult.capabilities = Capabilities.EAP; +// assertEquals(true, mWiseFy.isNetworkSecure(scanResult)); +// } +// +// @Test +// public void success_withPSK() { +// ScanResult scanResult = mock(ScanResult.class); +// scanResult.capabilities = Capabilities.PSK; +// assertEquals(true, mWiseFy.isNetworkSecure(scanResult)); +// } +// +// @Test +// public void success_withWEP() { +// ScanResult scanResult = mock(ScanResult.class); +// scanResult.capabilities = Capabilities.WEP; +// assertEquals(true, mWiseFy.isNetworkSecure(scanResult)); +// } +// +// @Test +// public void success_withWPA() { +// ScanResult scanResult = mock(ScanResult.class); +// scanResult.capabilities = Capabilities.WPA; +// assertEquals(true, mWiseFy.isNetworkSecure(scanResult)); +// } +// +// @Test +// public void success_withWPA2() { +// ScanResult scanResult = mock(ScanResult.class); +// scanResult.capabilities = Capabilities.WPA2; +// assertEquals(true, mWiseFy.isNetworkSecure(scanResult)); +// } +// +// @Test +// public void failure_otherCapabilities() { +// ScanResult scanResult = mock(ScanResult.class); +// scanResult.capabilities = "Other"; +// assertEquals(false, mWiseFy.isNetworkSecure(scanResult)); +// } +//} diff --git a/wisefy/src/androidTest/java/com/isupatches/wisefy/IsNetworkWPA2Test.java b/wisefy/src/androidTest/java/com/isupatches/wisefy/IsNetworkWPA2Test.java index 02b9958c..e148472f 100644 --- a/wisefy/src/androidTest/java/com/isupatches/wisefy/IsNetworkWPA2Test.java +++ b/wisefy/src/androidTest/java/com/isupatches/wisefy/IsNetworkWPA2Test.java @@ -1,49 +1,49 @@ -package com.isupatches.wisefy; - - -import android.net.wifi.ScanResult; -import com.isupatches.wisefy.base.TestActivity; -import com.isupatches.wisefy.constants.Capabilities; -import org.junit.Test; -import static org.junit.Assert.assertEquals; -import static org.mockito.Mockito.mock; - - -public class IsNetworkWPA2Test extends BaseTestClass { - - public IsNetworkWPA2Test() { - super(TestActivity.class); - } - - @Test - public void failure_differentCapability() { - ScanResult scanResult = mock(ScanResult.class); - scanResult.capabilities = "Other"; - assertEquals(false, mWiseFy.isNetworkWPA2(scanResult)); - } - - @Test - public void failure_emptyCapabilities() { - ScanResult scanResult = mock(ScanResult.class); - scanResult.capabilities = ""; - assertEquals(false, mWiseFy.isNetworkWPA2(scanResult)); - } - - @Test - public void failure_nullCapabilities() { - ScanResult scanResult = mock(ScanResult.class); - assertEquals(false, mWiseFy.isNetworkWPA2(scanResult)); - } - - @Test - public void failure_nullScanResult() { - assertEquals(false, mWiseFy.isNetworkWPA2(null)); - } - - @Test - public void success() { - ScanResult scanResult = mock(ScanResult.class); - scanResult.capabilities = Capabilities.WPA2; - assertEquals(true, mWiseFy.isNetworkWPA2(scanResult)); - } -} +//package com.isupatches.wisefy; +// +// +//import android.net.wifi.ScanResult; +//import com.isupatches.wisefy.base.TestActivity; +//import com.isupatches.wisefy.constants.Capabilities; +//import org.junit.Test; +//import static org.junit.Assert.assertEquals; +//import static org.mockito.Mockito.mock; +// +// +//public class IsNetworkWPA2Test extends BaseTestClass { +// +// public IsNetworkWPA2Test() { +// super(TestActivity.class); +// } +// +// @Test +// public void failure_differentCapability() { +// ScanResult scanResult = mock(ScanResult.class); +// scanResult.capabilities = "Other"; +// assertEquals(false, mWiseFy.isNetworkWPA2(scanResult)); +// } +// +// @Test +// public void failure_emptyCapabilities() { +// ScanResult scanResult = mock(ScanResult.class); +// scanResult.capabilities = ""; +// assertEquals(false, mWiseFy.isNetworkWPA2(scanResult)); +// } +// +// @Test +// public void failure_nullCapabilities() { +// ScanResult scanResult = mock(ScanResult.class); +// assertEquals(false, mWiseFy.isNetworkWPA2(scanResult)); +// } +// +// @Test +// public void failure_nullScanResult() { +// assertEquals(false, mWiseFy.isNetworkWPA2(null)); +// } +// +// @Test +// public void success() { +// ScanResult scanResult = mock(ScanResult.class); +// scanResult.capabilities = Capabilities.WPA2; +// assertEquals(true, mWiseFy.isNetworkWPA2(scanResult)); +// } +//} diff --git a/wisefy/src/androidTest/java/com/isupatches/wisefy/IsNetworkWPATests.java b/wisefy/src/androidTest/java/com/isupatches/wisefy/IsNetworkWPATests.java index 9ad82084..b87bebe6 100644 --- a/wisefy/src/androidTest/java/com/isupatches/wisefy/IsNetworkWPATests.java +++ b/wisefy/src/androidTest/java/com/isupatches/wisefy/IsNetworkWPATests.java @@ -1,49 +1,49 @@ -package com.isupatches.wisefy; - - -import android.net.wifi.ScanResult; -import com.isupatches.wisefy.base.TestActivity; -import com.isupatches.wisefy.constants.Capabilities; -import org.junit.Test; -import static junit.framework.Assert.assertEquals; -import static org.mockito.Mockito.mock; - - -public class IsNetworkWPATests extends BaseTestClass { - - public IsNetworkWPATests() { - super(TestActivity.class); - } - - @Test - public void failure_differentCapability() { - ScanResult scanResult = mock(ScanResult.class); - scanResult.capabilities = "Other"; - assertEquals(false, mWiseFy.isNetworkWPA(scanResult)); - } - - @Test - public void failure_emptyCapabilities() { - ScanResult scanResult = mock(ScanResult.class); - scanResult.capabilities = ""; - assertEquals(false, mWiseFy.isNetworkWPA(scanResult)); - } - - @Test - public void failure_nullCapabilities() { - ScanResult scanResult = mock(ScanResult.class); - assertEquals(false, mWiseFy.isNetworkWPA(scanResult)); - } - - @Test - public void failure_nullScanResult() { - assertEquals(false, mWiseFy.isNetworkWPA(null)); - } - - @Test - public void success() { - ScanResult scanResult = mock(ScanResult.class); - scanResult.capabilities = Capabilities.WPA; - assertEquals(true, mWiseFy.isNetworkWPA(scanResult)); - } -} +//package com.isupatches.wisefy; +// +// +//import android.net.wifi.ScanResult; +//import com.isupatches.wisefy.base.TestActivity; +//import com.isupatches.wisefy.constants.Capabilities; +//import org.junit.Test; +//import static junit.framework.Assert.assertEquals; +//import static org.mockito.Mockito.mock; +// +// +//public class IsNetworkWPATests extends BaseTestClass { +// +// public IsNetworkWPATests() { +// super(TestActivity.class); +// } +// +// @Test +// public void failure_differentCapability() { +// ScanResult scanResult = mock(ScanResult.class); +// scanResult.capabilities = "Other"; +// assertEquals(false, mWiseFy.isNetworkWPA(scanResult)); +// } +// +// @Test +// public void failure_emptyCapabilities() { +// ScanResult scanResult = mock(ScanResult.class); +// scanResult.capabilities = ""; +// assertEquals(false, mWiseFy.isNetworkWPA(scanResult)); +// } +// +// @Test +// public void failure_nullCapabilities() { +// ScanResult scanResult = mock(ScanResult.class); +// assertEquals(false, mWiseFy.isNetworkWPA(scanResult)); +// } +// +// @Test +// public void failure_nullScanResult() { +// assertEquals(false, mWiseFy.isNetworkWPA(null)); +// } +// +// @Test +// public void success() { +// ScanResult scanResult = mock(ScanResult.class); +// scanResult.capabilities = Capabilities.WPA; +// assertEquals(true, mWiseFy.isNetworkWPA(scanResult)); +// } +//} diff --git a/wisefy/src/androidTest/java/com/isupatches/wisefy/IsNetworkWepTests.java b/wisefy/src/androidTest/java/com/isupatches/wisefy/IsNetworkWepTests.java index 5b46f961..b6bd3176 100644 --- a/wisefy/src/androidTest/java/com/isupatches/wisefy/IsNetworkWepTests.java +++ b/wisefy/src/androidTest/java/com/isupatches/wisefy/IsNetworkWepTests.java @@ -1,49 +1,49 @@ -package com.isupatches.wisefy; - - -import android.net.wifi.ScanResult; -import com.isupatches.wisefy.base.TestActivity; -import com.isupatches.wisefy.constants.Capabilities; -import org.junit.Test; -import static org.junit.Assert.assertEquals; -import static org.mockito.Mockito.mock; - - -public class IsNetworkWepTests extends BaseTestClass { - - public IsNetworkWepTests() { - super(TestActivity.class); - } - - @Test - public void failure_differentCapability() { - ScanResult scanResult = mock(ScanResult.class); - scanResult.capabilities = "Other"; - assertEquals(false, mWiseFy.isNetworkWEP(scanResult)); - } - - @Test - public void failure_emptyCapabilities() { - ScanResult scanResult = mock(ScanResult.class); - scanResult.capabilities = ""; - assertEquals(false, mWiseFy.isNetworkWEP(scanResult)); - } - - @Test - public void failure_nullCapabilities() { - ScanResult scanResult = mock(ScanResult.class); - assertEquals(false, mWiseFy.isNetworkWEP(scanResult)); - } - - @Test - public void failure_nullScanResult() { - assertEquals(false, mWiseFy.isNetworkWEP(null)); - } - - @Test - public void success() { - ScanResult scanResult = mock(ScanResult.class); - scanResult.capabilities = Capabilities.WEP; - assertEquals(true, mWiseFy.isNetworkWEP(scanResult)); - } -} +//package com.isupatches.wisefy; +// +// +//import android.net.wifi.ScanResult; +//import com.isupatches.wisefy.base.TestActivity; +//import com.isupatches.wisefy.constants.Capabilities; +//import org.junit.Test; +//import static org.junit.Assert.assertEquals; +//import static org.mockito.Mockito.mock; +// +// +//public class IsNetworkWepTests extends BaseTestClass { +// +// public IsNetworkWepTests() { +// super(TestActivity.class); +// } +// +// @Test +// public void failure_differentCapability() { +// ScanResult scanResult = mock(ScanResult.class); +// scanResult.capabilities = "Other"; +// assertEquals(false, mWiseFy.isNetworkWEP(scanResult)); +// } +// +// @Test +// public void failure_emptyCapabilities() { +// ScanResult scanResult = mock(ScanResult.class); +// scanResult.capabilities = ""; +// assertEquals(false, mWiseFy.isNetworkWEP(scanResult)); +// } +// +// @Test +// public void failure_nullCapabilities() { +// ScanResult scanResult = mock(ScanResult.class); +// assertEquals(false, mWiseFy.isNetworkWEP(scanResult)); +// } +// +// @Test +// public void failure_nullScanResult() { +// assertEquals(false, mWiseFy.isNetworkWEP(null)); +// } +// +// @Test +// public void success() { +// ScanResult scanResult = mock(ScanResult.class); +// scanResult.capabilities = Capabilities.WEP; +// assertEquals(true, mWiseFy.isNetworkWEP(scanResult)); +// } +//} diff --git a/wisefy/src/androidTest/java/com/isupatches/wisefy/IsWifiEnabledTests.java b/wisefy/src/androidTest/java/com/isupatches/wisefy/IsWifiEnabledTests.java index 97b0e028..cfd47f86 100644 --- a/wisefy/src/androidTest/java/com/isupatches/wisefy/IsWifiEnabledTests.java +++ b/wisefy/src/androidTest/java/com/isupatches/wisefy/IsWifiEnabledTests.java @@ -1,33 +1,33 @@ -package com.isupatches.wisefy; - - -import com.isupatches.wisefy.base.TestActivity; -import org.junit.Test; -import static org.junit.Assert.assertEquals; -import static org.mockito.Mockito.when; - - -public class IsWifiEnabledTests extends BaseTestClass { - - public IsWifiEnabledTests() { - super(TestActivity.class); - } - - @Test - public void failure() { - when(mMockWiFiManager.isWifiEnabled()).thenReturn(false); - assertEquals(false, mWiseFy.isWifiEnabled()); - } - - @Test - public void failure_missingPrerequisite() { - missingPrerequisite(); - assertEquals(false, mWiseFy.isWifiEnabled()); - } - - @Test - public void success() { - when(mMockWiFiManager.isWifiEnabled()).thenReturn(true); - assertEquals(true, mWiseFy.isWifiEnabled()); - } -} \ No newline at end of file +//package com.isupatches.wisefy; +// +// +//import com.isupatches.wisefy.base.TestActivity; +//import org.junit.Test; +//import static org.junit.Assert.assertEquals; +//import static org.mockito.Mockito.when; +// +// +//public class IsWifiEnabledTests extends BaseTestClass { +// +// public IsWifiEnabledTests() { +// super(TestActivity.class); +// } +// +// @Test +// public void failure() { +// when(mMockWiFiManager.isWifiEnabled()).thenReturn(false); +// assertEquals(false, mWiseFy.isWifiEnabled()); +// } +// +// @Test +// public void failure_missingPrerequisite() { +// missingPrerequisite(); +// assertEquals(false, mWiseFy.isWifiEnabled()); +// } +// +// @Test +// public void success() { +// when(mMockWiFiManager.isWifiEnabled()).thenReturn(true); +// assertEquals(true, mWiseFy.isWifiEnabled()); +// } +//} \ No newline at end of file diff --git a/wisefy/src/androidTest/java/com/isupatches/wisefy/ManagerUtilTest.java b/wisefy/src/androidTest/java/com/isupatches/wisefy/ManagerUtilTest.java index 64e125b5..3ae49076 100644 --- a/wisefy/src/androidTest/java/com/isupatches/wisefy/ManagerUtilTest.java +++ b/wisefy/src/androidTest/java/com/isupatches/wisefy/ManagerUtilTest.java @@ -1,46 +1,46 @@ -package com.isupatches.wisefy; - - -import android.net.ConnectivityManager; -import android.net.wifi.WifiManager; -import android.support.test.rule.ActivityTestRule; -import com.isupatches.wisefy.base.TestActivity; -import com.isupatches.wisefy.util.ManagerUtil; -import org.junit.Rule; -import org.junit.Test; -import static junit.framework.Assert.*; - - -public class ManagerUtilTest extends BaseTestClass { - - public ManagerUtilTest() { - super(TestActivity.class); - } - - @Rule - public ActivityTestRule mActivityTestRule = new ActivityTestRule<>(TestActivity.class); - - @Test - public void getConnectivityManager_returnsNotNull() { - ConnectivityManager connectivityManager = ManagerUtil.getInstance().getConnectivityManager(mActivityTestRule.getActivity()); - assertNotNull(connectivityManager); - } - - @Test - public void getConnectivityManager_returnsNull_noActivity() { - ConnectivityManager connectivityManager = ManagerUtil.getInstance().getConnectivityManager(null); - assertNull(connectivityManager); - } - - @Test - public void getWiFiManager_returnsNotNull() { - WifiManager wifiManager = ManagerUtil.getInstance().getWiFiManager(mActivityTestRule.getActivity()); - assertNotNull(wifiManager); - } - - @Test - public void getWiFiManager_returnsNull_noActivity() { - WifiManager wifiManager = ManagerUtil.getInstance().getWiFiManager(null); - assertNull(wifiManager); - } -} \ No newline at end of file +//package com.isupatches.wisefy; +// +// +//import android.net.ConnectivityManager; +//import android.net.wifi.WifiManager; +//import android.support.test.rule.ActivityTestRule; +//import com.isupatches.wisefy.base.TestActivity; +//import com.isupatches.wisefy.util.ManagerUtil; +//import org.junit.Rule; +//import org.junit.Test; +//import static junit.framework.Assert.*; +// +// +//public class ManagerUtilTest extends BaseTestClass { +// +// public ManagerUtilTest() { +// super(TestActivity.class); +// } +// +// @Rule +// public ActivityTestRule mActivityTestRule = new ActivityTestRule<>(TestActivity.class); +// +// @Test +// public void getConnectivityManager_returnsNotNull() { +// ConnectivityManager connectivityManager = ManagerUtil.getInstance().getConnectivityManager(mActivityTestRule.getActivity()); +// assertNotNull(connectivityManager); +// } +// +// @Test +// public void getConnectivityManager_returnsNull_noActivity() { +// ConnectivityManager connectivityManager = ManagerUtil.getInstance().getConnectivityManager(null); +// assertNull(connectivityManager); +// } +// +// @Test +// public void getWiFiManager_returnsNotNull() { +// WifiManager wifiManager = ManagerUtil.getInstance().getWiFiManager(mActivityTestRule.getActivity()); +// assertNotNull(wifiManager); +// } +// +// @Test +// public void getWiFiManager_returnsNull_noActivity() { +// WifiManager wifiManager = ManagerUtil.getInstance().getWiFiManager(null); +// assertNull(wifiManager); +// } +//} \ No newline at end of file diff --git a/wisefy/src/androidTest/java/com/isupatches/wisefy/RemoveNetworkTests.java b/wisefy/src/androidTest/java/com/isupatches/wisefy/RemoveNetworkTests.java index 942aa1ca..1de0d46a 100644 --- a/wisefy/src/androidTest/java/com/isupatches/wisefy/RemoveNetworkTests.java +++ b/wisefy/src/androidTest/java/com/isupatches/wisefy/RemoveNetworkTests.java @@ -1,210 +1,210 @@ -package com.isupatches.wisefy; - - -import android.net.wifi.WifiConfiguration; -import com.isupatches.wisefy.base.TestActivity; -import com.isupatches.wisefy.callbacks.RemoveNetworkCallbacks; -import com.isupatches.wisefy.constants.WiseFyCodes; -import org.junit.Test; -import static com.isupatches.wisefy.base.TestUtils.TEST_SSID; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.fail; -import static org.mockito.ArgumentMatchers.anyInt; -import static org.mockito.ArgumentMatchers.anyString; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.never; -import static org.mockito.Mockito.timeout; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; - - -public class RemoveNetworkTests extends BaseTestClass { - - public RemoveNetworkTests() { - super(TestActivity.class); - } - - @Test - public void noCallbacks_failure_nullSSIDParam() { - assertEquals(false, mWiseFy.removeNetwork(null)); - verify(mMockWiFiManager, never()).removeNetwork(anyInt()); - } - - @Test - public void noCallbacks_failure_missingPrerequisites() { - missingPrerequisite(); - assertEquals(false, mWiseFy.removeNetwork(TEST_SSID)); - verify(mMockWiFiManager, never()).removeNetwork(anyInt()); - } - - @Test - public void noCallbacks_failure_noSavedNetwork() { - WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); - mWiseFy.mWiseFySearch = mockWiseFySearch; - when(mockWiseFySearch.findSavedNetworkByRegex(anyString())).thenReturn(null); - - assertEquals(false, mWiseFy.removeNetwork(TEST_SSID)); - verify(mMockWiFiManager, never()).removeNetwork(anyInt()); - } - - @Test - public void noCallbacks_failure() { - WifiConfiguration wiFiConfiguration = new WifiConfiguration(); - wiFiConfiguration.SSID = TEST_SSID; - WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); - mWiseFy.mWiseFySearch = mockWiseFySearch; - when(mockWiseFySearch.findSavedNetworkByRegex(anyString())).thenReturn(wiFiConfiguration); - - when(mMockWiFiManager.removeNetwork(anyInt())).thenReturn(false); - - assertEquals(false, mWiseFy.removeNetwork(TEST_SSID)); - verify(mMockWiFiManager, timeout(VERIFICATION_TIMEOUT)).removeNetwork(anyInt()); - - } - - @Test - public void noCallbacks_success() { - WifiConfiguration wiFiConfiguration = new WifiConfiguration(); - wiFiConfiguration.SSID = TEST_SSID; - WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); - mWiseFy.mWiseFySearch = mockWiseFySearch; - when(mockWiseFySearch.findSavedNetworkByRegex(anyString())).thenReturn(wiFiConfiguration); - - when(mMockWiFiManager.removeNetwork(anyInt())).thenReturn(true); - - assertEquals(true, mWiseFy.removeNetwork(TEST_SSID)); - verify(mMockWiFiManager, timeout(VERIFICATION_TIMEOUT)).removeNetwork(anyInt()); - } - - @Test - public void callbacks_failure_nullSSIDParam() { - RemoveNetworkCallbacks mockCallbacks = mock(RemoveNetworkCallbacks.class); - mWiseFy.removeNetwork(null, mockCallbacks); - verify(mockCallbacks, timeout(3000)).removeNetworkWiseFyFailure(WiseFyCodes.MISSING_PARAMETER); - verify(mMockWiFiManager, never()).removeNetwork(anyInt()); - } - - @Test - public void callbacks_failure_nullSSIDParam_nullCallback() { - try { - mWiseFy.removeNetwork(null, null); - verify(mMockWiFiManager, never()).removeNetwork(anyInt()); - } catch (NullPointerException npe) { - fail(); - } - } - - @Test - public void callbacks_failure_missingPrerequisites() { - missingPrerequisite(); - RemoveNetworkCallbacks mockCallbacks = mock(RemoveNetworkCallbacks.class); - mWiseFy.removeNetwork(TEST_SSID, mockCallbacks); - verify(mockCallbacks, timeout(VERIFICATION_TIMEOUT)).removeNetworkWiseFyFailure(WiseFyCodes.MISSING_PREREQUISITE); - verify(mMockWiFiManager, never()).removeNetwork(anyInt()); - } - - @Test - public void callbacks_failure_missingPrerequisites_nullCallback() { - missingPrerequisite(); - try { - mWiseFy.removeNetwork(TEST_SSID, null); - verify(mMockWiFiManager, never()).removeNetwork(anyInt()); - } catch (NullPointerException npe) { - fail(); - } - } - - @Test - public void callbacks_failure_noSavedNetwork() { - WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); - mWiseFy.mWiseFySearch = mockWiseFySearch; - when(mockWiseFySearch.findSavedNetworkByRegex(anyString())).thenReturn(null); - - RemoveNetworkCallbacks mockCallbacks = mock(RemoveNetworkCallbacks.class); - mWiseFy.removeNetwork(TEST_SSID, mockCallbacks); - verify(mockCallbacks, timeout(VERIFICATION_TIMEOUT)).networkNotFoundToRemove(); - verify(mMockWiFiManager, never()).removeNetwork(anyInt()); - } - - @Test - public void callbacks_failure_noSavedNetwork_nullCallback() { - WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); - mWiseFy.mWiseFySearch = mockWiseFySearch; - when(mockWiseFySearch.findSavedNetworkByRegex(anyString())).thenReturn(null); - - try { - mWiseFy.removeNetwork(TEST_SSID, null); - verify(mMockWiFiManager, never()).removeNetwork(anyInt()); - } catch (NullPointerException npe) { - fail(); - } - } - - @Test - public void callbacks_failure() { - WifiConfiguration wiFiConfiguration = new WifiConfiguration(); - wiFiConfiguration.SSID = TEST_SSID; - WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); - mWiseFy.mWiseFySearch = mockWiseFySearch; - when(mockWiseFySearch.findSavedNetworkByRegex(anyString())).thenReturn(wiFiConfiguration); - - when(mMockWiFiManager.removeNetwork(anyInt())).thenReturn(false); - - RemoveNetworkCallbacks mockCallbacks = mock(RemoveNetworkCallbacks.class); - mWiseFy.removeNetwork(TEST_SSID, mockCallbacks); - verify(mockCallbacks, timeout(VERIFICATION_TIMEOUT)).failureRemovingNetwork(); - verify(mMockWiFiManager, timeout(VERIFICATION_TIMEOUT)).removeNetwork(anyInt()); - } - - @Test - public void callbacks_failure_nullCallback() { - WifiConfiguration wiFiConfiguration = new WifiConfiguration(); - wiFiConfiguration.SSID = TEST_SSID; - WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); - mWiseFy.mWiseFySearch = mockWiseFySearch; - when(mockWiseFySearch.findSavedNetworkByRegex(anyString())).thenReturn(wiFiConfiguration); - - when(mMockWiFiManager.removeNetwork(anyInt())).thenReturn(false); - - try { - mWiseFy.removeNetwork(TEST_SSID, null); - verify(mMockWiFiManager, never()).removeNetwork(anyInt()); - } catch (NullPointerException npe) { - fail(); - } - } - - @Test - public void callbacks_success() { - WifiConfiguration wiFiConfiguration = new WifiConfiguration(); - wiFiConfiguration.SSID = TEST_SSID; - WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); - mWiseFy.mWiseFySearch = mockWiseFySearch; - when(mockWiseFySearch.findSavedNetworkByRegex(anyString())).thenReturn(wiFiConfiguration); - - when(mMockWiFiManager.removeNetwork(anyInt())).thenReturn(true); - - RemoveNetworkCallbacks mockCallbacks = mock(RemoveNetworkCallbacks.class); - mWiseFy.removeNetwork(TEST_SSID, mockCallbacks); - verify(mockCallbacks, timeout(VERIFICATION_TIMEOUT)).networkRemoved(); - verify(mMockWiFiManager, timeout(VERIFICATION_TIMEOUT)).removeNetwork(anyInt()); - } - - @Test - public void callbacks_success_nullCallback() { - WifiConfiguration wiFiConfiguration = new WifiConfiguration(); - wiFiConfiguration.SSID = TEST_SSID; - WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); - mWiseFy.mWiseFySearch = mockWiseFySearch; - when(mockWiseFySearch.findSavedNetworkByRegex(anyString())).thenReturn(wiFiConfiguration); - - when(mMockWiFiManager.removeNetwork(anyInt())).thenReturn(true); - - try { - mWiseFy.removeNetwork(TEST_SSID, null); - verify(mMockWiFiManager, never()).removeNetwork(anyInt()); - } catch (NullPointerException npe) { - fail(); - } - } -} +//package com.isupatches.wisefy; +// +// +//import android.net.wifi.WifiConfiguration; +//import com.isupatches.wisefy.base.TestActivity; +//import com.isupatches.wisefy.callbacks.RemoveNetworkCallbacks; +//import com.isupatches.wisefy.constants.WiseFyCodes; +//import org.junit.Test; +//import static com.isupatches.wisefy.base.TestUtils.TEST_SSID; +//import static org.junit.Assert.assertEquals; +//import static org.junit.Assert.fail; +//import static org.mockito.ArgumentMatchers.anyInt; +//import static org.mockito.ArgumentMatchers.anyString; +//import static org.mockito.Mockito.mock; +//import static org.mockito.Mockito.never; +//import static org.mockito.Mockito.timeout; +//import static org.mockito.Mockito.verify; +//import static org.mockito.Mockito.when; +// +// +//public class RemoveNetworkTests extends BaseTestClass { +// +// public RemoveNetworkTests() { +// super(TestActivity.class); +// } +// +// @Test +// public void noCallbacks_failure_nullSSIDParam() { +// assertEquals(false, mWiseFy.removeNetwork(null)); +// verify(mMockWiFiManager, never()).removeNetwork(anyInt()); +// } +// +// @Test +// public void noCallbacks_failure_missingPrerequisites() { +// missingPrerequisite(); +// assertEquals(false, mWiseFy.removeNetwork(TEST_SSID)); +// verify(mMockWiFiManager, never()).removeNetwork(anyInt()); +// } +// +// @Test +// public void noCallbacks_failure_noSavedNetwork() { +// WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); +// mWiseFy.mWiseFySearch = mockWiseFySearch; +// when(mockWiseFySearch.findSavedNetworkByRegex(anyString())).thenReturn(null); +// +// assertEquals(false, mWiseFy.removeNetwork(TEST_SSID)); +// verify(mMockWiFiManager, never()).removeNetwork(anyInt()); +// } +// +// @Test +// public void noCallbacks_failure() { +// WifiConfiguration wiFiConfiguration = new WifiConfiguration(); +// wiFiConfiguration.SSID = TEST_SSID; +// WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); +// mWiseFy.mWiseFySearch = mockWiseFySearch; +// when(mockWiseFySearch.findSavedNetworkByRegex(anyString())).thenReturn(wiFiConfiguration); +// +// when(mMockWiFiManager.removeNetwork(anyInt())).thenReturn(false); +// +// assertEquals(false, mWiseFy.removeNetwork(TEST_SSID)); +// verify(mMockWiFiManager, timeout(VERIFICATION_TIMEOUT)).removeNetwork(anyInt()); +// +// } +// +// @Test +// public void noCallbacks_success() { +// WifiConfiguration wiFiConfiguration = new WifiConfiguration(); +// wiFiConfiguration.SSID = TEST_SSID; +// WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); +// mWiseFy.mWiseFySearch = mockWiseFySearch; +// when(mockWiseFySearch.findSavedNetworkByRegex(anyString())).thenReturn(wiFiConfiguration); +// +// when(mMockWiFiManager.removeNetwork(anyInt())).thenReturn(true); +// +// assertEquals(true, mWiseFy.removeNetwork(TEST_SSID)); +// verify(mMockWiFiManager, timeout(VERIFICATION_TIMEOUT)).removeNetwork(anyInt()); +// } +// +// @Test +// public void callbacks_failure_nullSSIDParam() { +// RemoveNetworkCallbacks mockCallbacks = mock(RemoveNetworkCallbacks.class); +// mWiseFy.removeNetwork(null, mockCallbacks); +// verify(mockCallbacks, timeout(3000)).removeNetworkWiseFyFailure(WiseFyCodes.MISSING_PARAMETER); +// verify(mMockWiFiManager, never()).removeNetwork(anyInt()); +// } +// +// @Test +// public void callbacks_failure_nullSSIDParam_nullCallback() { +// try { +// mWiseFy.removeNetwork(null, null); +// verify(mMockWiFiManager, never()).removeNetwork(anyInt()); +// } catch (NullPointerException npe) { +// fail(); +// } +// } +// +// @Test +// public void callbacks_failure_missingPrerequisites() { +// missingPrerequisite(); +// RemoveNetworkCallbacks mockCallbacks = mock(RemoveNetworkCallbacks.class); +// mWiseFy.removeNetwork(TEST_SSID, mockCallbacks); +// verify(mockCallbacks, timeout(VERIFICATION_TIMEOUT)).removeNetworkWiseFyFailure(WiseFyCodes.MISSING_PREREQUISITE); +// verify(mMockWiFiManager, never()).removeNetwork(anyInt()); +// } +// +// @Test +// public void callbacks_failure_missingPrerequisites_nullCallback() { +// missingPrerequisite(); +// try { +// mWiseFy.removeNetwork(TEST_SSID, null); +// verify(mMockWiFiManager, never()).removeNetwork(anyInt()); +// } catch (NullPointerException npe) { +// fail(); +// } +// } +// +// @Test +// public void callbacks_failure_noSavedNetwork() { +// WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); +// mWiseFy.mWiseFySearch = mockWiseFySearch; +// when(mockWiseFySearch.findSavedNetworkByRegex(anyString())).thenReturn(null); +// +// RemoveNetworkCallbacks mockCallbacks = mock(RemoveNetworkCallbacks.class); +// mWiseFy.removeNetwork(TEST_SSID, mockCallbacks); +// verify(mockCallbacks, timeout(VERIFICATION_TIMEOUT)).networkNotFoundToRemove(); +// verify(mMockWiFiManager, never()).removeNetwork(anyInt()); +// } +// +// @Test +// public void callbacks_failure_noSavedNetwork_nullCallback() { +// WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); +// mWiseFy.mWiseFySearch = mockWiseFySearch; +// when(mockWiseFySearch.findSavedNetworkByRegex(anyString())).thenReturn(null); +// +// try { +// mWiseFy.removeNetwork(TEST_SSID, null); +// verify(mMockWiFiManager, never()).removeNetwork(anyInt()); +// } catch (NullPointerException npe) { +// fail(); +// } +// } +// +// @Test +// public void callbacks_failure() { +// WifiConfiguration wiFiConfiguration = new WifiConfiguration(); +// wiFiConfiguration.SSID = TEST_SSID; +// WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); +// mWiseFy.mWiseFySearch = mockWiseFySearch; +// when(mockWiseFySearch.findSavedNetworkByRegex(anyString())).thenReturn(wiFiConfiguration); +// +// when(mMockWiFiManager.removeNetwork(anyInt())).thenReturn(false); +// +// RemoveNetworkCallbacks mockCallbacks = mock(RemoveNetworkCallbacks.class); +// mWiseFy.removeNetwork(TEST_SSID, mockCallbacks); +// verify(mockCallbacks, timeout(VERIFICATION_TIMEOUT)).failureRemovingNetwork(); +// verify(mMockWiFiManager, timeout(VERIFICATION_TIMEOUT)).removeNetwork(anyInt()); +// } +// +// @Test +// public void callbacks_failure_nullCallback() { +// WifiConfiguration wiFiConfiguration = new WifiConfiguration(); +// wiFiConfiguration.SSID = TEST_SSID; +// WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); +// mWiseFy.mWiseFySearch = mockWiseFySearch; +// when(mockWiseFySearch.findSavedNetworkByRegex(anyString())).thenReturn(wiFiConfiguration); +// +// when(mMockWiFiManager.removeNetwork(anyInt())).thenReturn(false); +// +// try { +// mWiseFy.removeNetwork(TEST_SSID, null); +// verify(mMockWiFiManager, never()).removeNetwork(anyInt()); +// } catch (NullPointerException npe) { +// fail(); +// } +// } +// +// @Test +// public void callbacks_success() { +// WifiConfiguration wiFiConfiguration = new WifiConfiguration(); +// wiFiConfiguration.SSID = TEST_SSID; +// WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); +// mWiseFy.mWiseFySearch = mockWiseFySearch; +// when(mockWiseFySearch.findSavedNetworkByRegex(anyString())).thenReturn(wiFiConfiguration); +// +// when(mMockWiFiManager.removeNetwork(anyInt())).thenReturn(true); +// +// RemoveNetworkCallbacks mockCallbacks = mock(RemoveNetworkCallbacks.class); +// mWiseFy.removeNetwork(TEST_SSID, mockCallbacks); +// verify(mockCallbacks, timeout(VERIFICATION_TIMEOUT)).networkRemoved(); +// verify(mMockWiFiManager, timeout(VERIFICATION_TIMEOUT)).removeNetwork(anyInt()); +// } +// +// @Test +// public void callbacks_success_nullCallback() { +// WifiConfiguration wiFiConfiguration = new WifiConfiguration(); +// wiFiConfiguration.SSID = TEST_SSID; +// WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); +// mWiseFy.mWiseFySearch = mockWiseFySearch; +// when(mockWiseFySearch.findSavedNetworkByRegex(anyString())).thenReturn(wiFiConfiguration); +// +// when(mMockWiFiManager.removeNetwork(anyInt())).thenReturn(true); +// +// try { +// mWiseFy.removeNetwork(TEST_SSID, null); +// verify(mMockWiFiManager, never()).removeNetwork(anyInt()); +// } catch (NullPointerException npe) { +// fail(); +// } +// } +//} diff --git a/wisefy/src/androidTest/java/com/isupatches/wisefy/SearchForAccessPointTests.java b/wisefy/src/androidTest/java/com/isupatches/wisefy/SearchForAccessPointTests.java index 4381be0a..5f80d28a 100644 --- a/wisefy/src/androidTest/java/com/isupatches/wisefy/SearchForAccessPointTests.java +++ b/wisefy/src/androidTest/java/com/isupatches/wisefy/SearchForAccessPointTests.java @@ -1,272 +1,272 @@ -package com.isupatches.wisefy; - - -import android.net.wifi.ScanResult; -import com.isupatches.wisefy.base.TestActivity; -import com.isupatches.wisefy.callbacks.SearchForAccessPointCallbacks; -import com.isupatches.wisefy.constants.WiseFyCodes; -import org.junit.Test; -import static com.isupatches.wisefy.base.TestUtils.TEST_SSID; -import static junit.framework.Assert.assertEquals; -import static junit.framework.Assert.fail; -import static org.mockito.ArgumentMatchers.anyBoolean; -import static org.mockito.ArgumentMatchers.anyInt; -import static org.mockito.ArgumentMatchers.anyString; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.timeout; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; - - -public class SearchForAccessPointTests extends BaseTestClass { - - public SearchForAccessPointTests() { - super(TestActivity.class); - } - - @Test - public void noCallbacks_failure_filterDuplicates_false_nullSSIDParam() { - assertEquals(null, mWiseFy.searchForAccessPoint(null, 1000, false)); - } - - @Test - public void noCallbacks_failure_filterDuplicates_true_nullSSIDParam() { - assertEquals(null, mWiseFy.searchForAccessPoint(null, 1000, true)); - } - - @Test - public void noCallbacks_failure_filterDuplicates_false_missingPrerequisite() { - missingPrerequisite(); - assertEquals(null, mWiseFy.searchForAccessPoint(TEST_SSID, 1000, false)); - } - - @Test - public void noCallbacks_failure_filterDuplicates_true_missingPrerequisite() { - missingPrerequisite(); - assertEquals(null, mWiseFy.searchForAccessPoint(TEST_SSID, 1000, true)); - } - - @Test - public void noCallbacks_failure_filterDuplicates_false() { - WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); - mWiseFy.mWiseFySearch = mockWiseFySearch; - when(mockWiseFySearch.findAccessPointByRegex(anyString(), anyInt(), anyBoolean())).thenReturn(null); - - assertEquals(null, mWiseFy.searchForAccessPoint(TEST_SSID, 1000, false)); - } - - @Test - public void noCallbacks_failure_filterDuplicates_true() { - WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); - mWiseFy.mWiseFySearch = mockWiseFySearch; - when(mockWiseFySearch.findAccessPointByRegex(anyString(), anyInt(), anyBoolean())).thenReturn(null); - - assertEquals(null, mWiseFy.searchForAccessPoint(TEST_SSID, 1000, true)); - } - - @Test - public void noCallbacks_success_filterDuplicates_false() { - ScanResult accessPoint = mock(ScanResult.class); - accessPoint.SSID = TEST_SSID; - - WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); - mWiseFy.mWiseFySearch = mockWiseFySearch; - when(mockWiseFySearch.findAccessPointByRegex(anyString(), anyInt(), anyBoolean())).thenReturn(accessPoint); - - assertEquals(accessPoint, mWiseFy.searchForAccessPoint(TEST_SSID, 1000, false)); - } - - @Test - public void noCallbacks_success_filterDuplicates_true() { - ScanResult accessPoint = mock(ScanResult.class); - accessPoint.SSID = TEST_SSID; - accessPoint.level = -35; - - WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); - mWiseFy.mWiseFySearch = mockWiseFySearch; - when(mockWiseFySearch.findAccessPointByRegex(anyString(), anyInt(), anyBoolean())).thenReturn(accessPoint); - - assertEquals(accessPoint, mWiseFy.searchForAccessPoint(TEST_SSID, 1000, true)); - } - - @Test - public void callbacks_failure_filterDuplicates_false_nullSSIDParam() { - SearchForAccessPointCallbacks mockCallbacks = mock(SearchForAccessPointCallbacks.class); - mWiseFy.searchForAccessPoint(null, 1000, false, mockCallbacks); - verify(mockCallbacks, timeout(VERIFICATION_TIMEOUT)).searchForAccessPointWiseFyFailure(WiseFyCodes.MISSING_PARAMETER); - } - - @Test - public void callbacks_failure_filterDuplicates_false_nullSSIDParam_nullCallback() { - try { - mWiseFy.searchForAccessPoint(null, 1000, false, null); - } catch (NullPointerException npe) { - fail(); - } - } - - @Test - public void callbacks_failure_filterDuplicates_true_nullSSIDParam() { - SearchForAccessPointCallbacks mockCallbacks = mock(SearchForAccessPointCallbacks.class); - mWiseFy.searchForAccessPoint(null, 1000, true, mockCallbacks); - verify(mockCallbacks, timeout(VERIFICATION_TIMEOUT)).searchForAccessPointWiseFyFailure(WiseFyCodes.MISSING_PARAMETER); - } - - @Test - public void callbacks_failure_filterDuplicates_true_nullSSIDParam_nullCallback() { - try { - mWiseFy.searchForAccessPoint(null, 1000, true, null); - } catch (NullPointerException npe) { - fail(); - } - } - - @Test - public void callbacks_failure_filterDuplicates_false_missingPrerequisite() { - missingPrerequisite(); - SearchForAccessPointCallbacks mockCallbacks = mock(SearchForAccessPointCallbacks.class); - mWiseFy.searchForAccessPoint(TEST_SSID, 1000, false, mockCallbacks); - verify(mockCallbacks, timeout(VERIFICATION_TIMEOUT)).searchForAccessPointWiseFyFailure(WiseFyCodes.MISSING_PREREQUISITE); - } - - @Test - public void callbacks_failure_filterDuplicates_false_missingPrerequisite_nullCallback() { - missingPrerequisite(); - try { - mWiseFy.searchForAccessPoint(TEST_SSID, 1000, false, null); - } catch (NullPointerException npe) { - fail(); - } - } - - @Test - public void callbacks_failure_filterDuplicates_true_missingPrerequisite() { - missingPrerequisite(); - SearchForAccessPointCallbacks mockCallbacks = mock(SearchForAccessPointCallbacks.class); - mWiseFy.searchForAccessPoint(TEST_SSID, 1000, true, mockCallbacks); - verify(mockCallbacks, timeout(VERIFICATION_TIMEOUT)).searchForAccessPointWiseFyFailure(WiseFyCodes.MISSING_PREREQUISITE); - } - - @Test - public void callbacks_failure_filterDuplicates_true_missingPrerequisite_nullCallback() { - missingPrerequisite(); - try { - mWiseFy.searchForAccessPoint(TEST_SSID, 1000, true, null); - } catch (NullPointerException npe) { - fail(); - } - } - - @Test - public void callbacks_failure_filterDuplicates_false() { - WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); - mWiseFy.mWiseFySearch = mockWiseFySearch; - when(mockWiseFySearch.findAccessPointByRegex(anyString(), anyInt(), anyBoolean())).thenReturn(null); - - SearchForAccessPointCallbacks mockCallbacks = mock(SearchForAccessPointCallbacks.class); - mWiseFy.searchForAccessPoint(TEST_SSID, 1000, false, mockCallbacks); - verify(mockCallbacks, timeout(VERIFICATION_TIMEOUT)).accessPointNotFound(); - } - - @Test - public void callbacks_failure_filterDuplicates_false_nullCallback() { - WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); - mWiseFy.mWiseFySearch = mockWiseFySearch; - when(mockWiseFySearch.findAccessPointByRegex(anyString(), anyInt(), anyBoolean())).thenReturn(null); - - try { - mWiseFy.searchForAccessPoint(TEST_SSID, 1000, false, null); - } catch (NullPointerException npe) { - fail(); - } - } - - @Test - public void callbacks_failure_filterDuplicates_true() { - WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); - mWiseFy.mWiseFySearch = mockWiseFySearch; - when(mockWiseFySearch.findAccessPointByRegex(anyString(), anyInt(), anyBoolean())).thenReturn(null); - - SearchForAccessPointCallbacks mockCallbacks = mock(SearchForAccessPointCallbacks.class); - mWiseFy.searchForAccessPoint(TEST_SSID, 1000, true, mockCallbacks); - verify(mockCallbacks, timeout(VERIFICATION_TIMEOUT)).accessPointNotFound(); - } - - - @Test - public void callbacks_failure_filterDuplicates_true_nullCallback() { - WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); - mWiseFy.mWiseFySearch = mockWiseFySearch; - when(mockWiseFySearch.findAccessPointByRegex(anyString(), anyInt(), anyBoolean())).thenReturn(null); - - try { - mWiseFy.searchForAccessPoint(TEST_SSID, 1000, true, null); - } catch (NullPointerException npe) { - fail(); - } - } - - @Test - public void callbacks_success_filterDuplicates_false() { - ScanResult accessPoint = mock(ScanResult.class); - accessPoint.SSID = TEST_SSID; - accessPoint.level = -35; - - WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); - mWiseFy.mWiseFySearch = mockWiseFySearch; - when(mockWiseFySearch.findAccessPointByRegex(anyString(), anyInt(), anyBoolean())).thenReturn(accessPoint); - - SearchForAccessPointCallbacks mockCallbacks = mock(SearchForAccessPointCallbacks.class); - mWiseFy.searchForAccessPoint(TEST_SSID, 1000, false, mockCallbacks); - verify(mockCallbacks, timeout(VERIFICATION_TIMEOUT)).accessPointFound(accessPoint); - } - - @Test - public void callbacks_success_filterDuplicates_false_nullCallback() { - ScanResult accessPoint = mock(ScanResult.class); - accessPoint.SSID = TEST_SSID; - accessPoint.level = -35; - - WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); - mWiseFy.mWiseFySearch = mockWiseFySearch; - when(mockWiseFySearch.findAccessPointByRegex(anyString(), anyInt(), anyBoolean())).thenReturn(accessPoint); - - try { - mWiseFy.searchForAccessPoint(TEST_SSID, 1000, false, null); - } catch (NullPointerException npe) { - fail(); - } - } - - @Test - public void callbacks_success_filterDuplicates_true() { - ScanResult accessPoint = mock(ScanResult.class); - accessPoint.SSID = TEST_SSID; - accessPoint.level = -35; - - WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); - mWiseFy.mWiseFySearch = mockWiseFySearch; - when(mockWiseFySearch.findAccessPointByRegex(anyString(), anyInt(), anyBoolean())).thenReturn(accessPoint); - - SearchForAccessPointCallbacks mockCallbacks = mock(SearchForAccessPointCallbacks.class); - mWiseFy.searchForAccessPoint(TEST_SSID, 1000, true, mockCallbacks); - verify(mockCallbacks, timeout(VERIFICATION_TIMEOUT)).accessPointFound(accessPoint); - } - - @Test - public void callbacks_success_filterDuplicates_true_nullCallback() { - ScanResult accessPoint = mock(ScanResult.class); - accessPoint.SSID = TEST_SSID; - accessPoint.level = -35; - - WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); - mWiseFy.mWiseFySearch = mockWiseFySearch; - when(mockWiseFySearch.findAccessPointByRegex(anyString(), anyInt(), anyBoolean())).thenReturn(accessPoint); - - try { - mWiseFy.searchForAccessPoint(TEST_SSID, 1000, true, null); - } catch (NullPointerException npe) { - fail(); - } - } -} +//package com.isupatches.wisefy; +// +// +//import android.net.wifi.ScanResult; +//import com.isupatches.wisefy.base.TestActivity; +//import com.isupatches.wisefy.callbacks.SearchForAccessPointCallbacks; +//import com.isupatches.wisefy.constants.WiseFyCodes; +//import org.junit.Test; +//import static com.isupatches.wisefy.base.TestUtils.TEST_SSID; +//import static junit.framework.Assert.assertEquals; +//import static junit.framework.Assert.fail; +//import static org.mockito.ArgumentMatchers.anyBoolean; +//import static org.mockito.ArgumentMatchers.anyInt; +//import static org.mockito.ArgumentMatchers.anyString; +//import static org.mockito.Mockito.mock; +//import static org.mockito.Mockito.timeout; +//import static org.mockito.Mockito.verify; +//import static org.mockito.Mockito.when; +// +// +//public class SearchForAccessPointTests extends BaseTestClass { +// +// public SearchForAccessPointTests() { +// super(TestActivity.class); +// } +// +// @Test +// public void noCallbacks_failure_filterDuplicates_false_nullSSIDParam() { +// assertEquals(null, mWiseFy.searchForAccessPoint(null, 1000, false)); +// } +// +// @Test +// public void noCallbacks_failure_filterDuplicates_true_nullSSIDParam() { +// assertEquals(null, mWiseFy.searchForAccessPoint(null, 1000, true)); +// } +// +// @Test +// public void noCallbacks_failure_filterDuplicates_false_missingPrerequisite() { +// missingPrerequisite(); +// assertEquals(null, mWiseFy.searchForAccessPoint(TEST_SSID, 1000, false)); +// } +// +// @Test +// public void noCallbacks_failure_filterDuplicates_true_missingPrerequisite() { +// missingPrerequisite(); +// assertEquals(null, mWiseFy.searchForAccessPoint(TEST_SSID, 1000, true)); +// } +// +// @Test +// public void noCallbacks_failure_filterDuplicates_false() { +// WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); +// mWiseFy.mWiseFySearch = mockWiseFySearch; +// when(mockWiseFySearch.findAccessPointByRegex(anyString(), anyInt(), anyBoolean())).thenReturn(null); +// +// assertEquals(null, mWiseFy.searchForAccessPoint(TEST_SSID, 1000, false)); +// } +// +// @Test +// public void noCallbacks_failure_filterDuplicates_true() { +// WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); +// mWiseFy.mWiseFySearch = mockWiseFySearch; +// when(mockWiseFySearch.findAccessPointByRegex(anyString(), anyInt(), anyBoolean())).thenReturn(null); +// +// assertEquals(null, mWiseFy.searchForAccessPoint(TEST_SSID, 1000, true)); +// } +// +// @Test +// public void noCallbacks_success_filterDuplicates_false() { +// ScanResult accessPoint = mock(ScanResult.class); +// accessPoint.SSID = TEST_SSID; +// +// WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); +// mWiseFy.mWiseFySearch = mockWiseFySearch; +// when(mockWiseFySearch.findAccessPointByRegex(anyString(), anyInt(), anyBoolean())).thenReturn(accessPoint); +// +// assertEquals(accessPoint, mWiseFy.searchForAccessPoint(TEST_SSID, 1000, false)); +// } +// +// @Test +// public void noCallbacks_success_filterDuplicates_true() { +// ScanResult accessPoint = mock(ScanResult.class); +// accessPoint.SSID = TEST_SSID; +// accessPoint.level = -35; +// +// WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); +// mWiseFy.mWiseFySearch = mockWiseFySearch; +// when(mockWiseFySearch.findAccessPointByRegex(anyString(), anyInt(), anyBoolean())).thenReturn(accessPoint); +// +// assertEquals(accessPoint, mWiseFy.searchForAccessPoint(TEST_SSID, 1000, true)); +// } +// +// @Test +// public void callbacks_failure_filterDuplicates_false_nullSSIDParam() { +// SearchForAccessPointCallbacks mockCallbacks = mock(SearchForAccessPointCallbacks.class); +// mWiseFy.searchForAccessPoint(null, 1000, false, mockCallbacks); +// verify(mockCallbacks, timeout(VERIFICATION_TIMEOUT)).searchForAccessPointWiseFyFailure(WiseFyCodes.MISSING_PARAMETER); +// } +// +// @Test +// public void callbacks_failure_filterDuplicates_false_nullSSIDParam_nullCallback() { +// try { +// mWiseFy.searchForAccessPoint(null, 1000, false, null); +// } catch (NullPointerException npe) { +// fail(); +// } +// } +// +// @Test +// public void callbacks_failure_filterDuplicates_true_nullSSIDParam() { +// SearchForAccessPointCallbacks mockCallbacks = mock(SearchForAccessPointCallbacks.class); +// mWiseFy.searchForAccessPoint(null, 1000, true, mockCallbacks); +// verify(mockCallbacks, timeout(VERIFICATION_TIMEOUT)).searchForAccessPointWiseFyFailure(WiseFyCodes.MISSING_PARAMETER); +// } +// +// @Test +// public void callbacks_failure_filterDuplicates_true_nullSSIDParam_nullCallback() { +// try { +// mWiseFy.searchForAccessPoint(null, 1000, true, null); +// } catch (NullPointerException npe) { +// fail(); +// } +// } +// +// @Test +// public void callbacks_failure_filterDuplicates_false_missingPrerequisite() { +// missingPrerequisite(); +// SearchForAccessPointCallbacks mockCallbacks = mock(SearchForAccessPointCallbacks.class); +// mWiseFy.searchForAccessPoint(TEST_SSID, 1000, false, mockCallbacks); +// verify(mockCallbacks, timeout(VERIFICATION_TIMEOUT)).searchForAccessPointWiseFyFailure(WiseFyCodes.MISSING_PREREQUISITE); +// } +// +// @Test +// public void callbacks_failure_filterDuplicates_false_missingPrerequisite_nullCallback() { +// missingPrerequisite(); +// try { +// mWiseFy.searchForAccessPoint(TEST_SSID, 1000, false, null); +// } catch (NullPointerException npe) { +// fail(); +// } +// } +// +// @Test +// public void callbacks_failure_filterDuplicates_true_missingPrerequisite() { +// missingPrerequisite(); +// SearchForAccessPointCallbacks mockCallbacks = mock(SearchForAccessPointCallbacks.class); +// mWiseFy.searchForAccessPoint(TEST_SSID, 1000, true, mockCallbacks); +// verify(mockCallbacks, timeout(VERIFICATION_TIMEOUT)).searchForAccessPointWiseFyFailure(WiseFyCodes.MISSING_PREREQUISITE); +// } +// +// @Test +// public void callbacks_failure_filterDuplicates_true_missingPrerequisite_nullCallback() { +// missingPrerequisite(); +// try { +// mWiseFy.searchForAccessPoint(TEST_SSID, 1000, true, null); +// } catch (NullPointerException npe) { +// fail(); +// } +// } +// +// @Test +// public void callbacks_failure_filterDuplicates_false() { +// WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); +// mWiseFy.mWiseFySearch = mockWiseFySearch; +// when(mockWiseFySearch.findAccessPointByRegex(anyString(), anyInt(), anyBoolean())).thenReturn(null); +// +// SearchForAccessPointCallbacks mockCallbacks = mock(SearchForAccessPointCallbacks.class); +// mWiseFy.searchForAccessPoint(TEST_SSID, 1000, false, mockCallbacks); +// verify(mockCallbacks, timeout(VERIFICATION_TIMEOUT)).accessPointNotFound(); +// } +// +// @Test +// public void callbacks_failure_filterDuplicates_false_nullCallback() { +// WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); +// mWiseFy.mWiseFySearch = mockWiseFySearch; +// when(mockWiseFySearch.findAccessPointByRegex(anyString(), anyInt(), anyBoolean())).thenReturn(null); +// +// try { +// mWiseFy.searchForAccessPoint(TEST_SSID, 1000, false, null); +// } catch (NullPointerException npe) { +// fail(); +// } +// } +// +// @Test +// public void callbacks_failure_filterDuplicates_true() { +// WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); +// mWiseFy.mWiseFySearch = mockWiseFySearch; +// when(mockWiseFySearch.findAccessPointByRegex(anyString(), anyInt(), anyBoolean())).thenReturn(null); +// +// SearchForAccessPointCallbacks mockCallbacks = mock(SearchForAccessPointCallbacks.class); +// mWiseFy.searchForAccessPoint(TEST_SSID, 1000, true, mockCallbacks); +// verify(mockCallbacks, timeout(VERIFICATION_TIMEOUT)).accessPointNotFound(); +// } +// +// +// @Test +// public void callbacks_failure_filterDuplicates_true_nullCallback() { +// WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); +// mWiseFy.mWiseFySearch = mockWiseFySearch; +// when(mockWiseFySearch.findAccessPointByRegex(anyString(), anyInt(), anyBoolean())).thenReturn(null); +// +// try { +// mWiseFy.searchForAccessPoint(TEST_SSID, 1000, true, null); +// } catch (NullPointerException npe) { +// fail(); +// } +// } +// +// @Test +// public void callbacks_success_filterDuplicates_false() { +// ScanResult accessPoint = mock(ScanResult.class); +// accessPoint.SSID = TEST_SSID; +// accessPoint.level = -35; +// +// WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); +// mWiseFy.mWiseFySearch = mockWiseFySearch; +// when(mockWiseFySearch.findAccessPointByRegex(anyString(), anyInt(), anyBoolean())).thenReturn(accessPoint); +// +// SearchForAccessPointCallbacks mockCallbacks = mock(SearchForAccessPointCallbacks.class); +// mWiseFy.searchForAccessPoint(TEST_SSID, 1000, false, mockCallbacks); +// verify(mockCallbacks, timeout(VERIFICATION_TIMEOUT)).accessPointFound(accessPoint); +// } +// +// @Test +// public void callbacks_success_filterDuplicates_false_nullCallback() { +// ScanResult accessPoint = mock(ScanResult.class); +// accessPoint.SSID = TEST_SSID; +// accessPoint.level = -35; +// +// WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); +// mWiseFy.mWiseFySearch = mockWiseFySearch; +// when(mockWiseFySearch.findAccessPointByRegex(anyString(), anyInt(), anyBoolean())).thenReturn(accessPoint); +// +// try { +// mWiseFy.searchForAccessPoint(TEST_SSID, 1000, false, null); +// } catch (NullPointerException npe) { +// fail(); +// } +// } +// +// @Test +// public void callbacks_success_filterDuplicates_true() { +// ScanResult accessPoint = mock(ScanResult.class); +// accessPoint.SSID = TEST_SSID; +// accessPoint.level = -35; +// +// WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); +// mWiseFy.mWiseFySearch = mockWiseFySearch; +// when(mockWiseFySearch.findAccessPointByRegex(anyString(), anyInt(), anyBoolean())).thenReturn(accessPoint); +// +// SearchForAccessPointCallbacks mockCallbacks = mock(SearchForAccessPointCallbacks.class); +// mWiseFy.searchForAccessPoint(TEST_SSID, 1000, true, mockCallbacks); +// verify(mockCallbacks, timeout(VERIFICATION_TIMEOUT)).accessPointFound(accessPoint); +// } +// +// @Test +// public void callbacks_success_filterDuplicates_true_nullCallback() { +// ScanResult accessPoint = mock(ScanResult.class); +// accessPoint.SSID = TEST_SSID; +// accessPoint.level = -35; +// +// WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); +// mWiseFy.mWiseFySearch = mockWiseFySearch; +// when(mockWiseFySearch.findAccessPointByRegex(anyString(), anyInt(), anyBoolean())).thenReturn(accessPoint); +// +// try { +// mWiseFy.searchForAccessPoint(TEST_SSID, 1000, true, null); +// } catch (NullPointerException npe) { +// fail(); +// } +// } +//} diff --git a/wisefy/src/androidTest/java/com/isupatches/wisefy/SearchForAccessPointsTests.java b/wisefy/src/androidTest/java/com/isupatches/wisefy/SearchForAccessPointsTests.java index 6c60c5aa..9b4eecd6 100644 --- a/wisefy/src/androidTest/java/com/isupatches/wisefy/SearchForAccessPointsTests.java +++ b/wisefy/src/androidTest/java/com/isupatches/wisefy/SearchForAccessPointsTests.java @@ -1,286 +1,286 @@ -package com.isupatches.wisefy; - - -import android.net.wifi.ScanResult; -import com.isupatches.wisefy.base.TestActivity; -import com.isupatches.wisefy.callbacks.SearchForAccessPointsCallbacks; -import com.isupatches.wisefy.constants.WiseFyCodes; -import org.junit.Test; -import java.util.ArrayList; -import java.util.List; -import static com.isupatches.wisefy.base.TestUtils.TEST_SSID; -import static junit.framework.Assert.assertEquals; -import static junit.framework.Assert.fail; -import static org.mockito.ArgumentMatchers.anyBoolean; -import static org.mockito.ArgumentMatchers.anyString; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.timeout; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; - - -public class SearchForAccessPointsTests extends BaseTestClass { - - public SearchForAccessPointsTests() { - super(TestActivity.class); - } - - @Test - public void noCallbacks_failure_filterDuplicates_false_nullSSIDParam() { - assertEquals(null, mWiseFy.searchForAccessPoints(null, false)); - } - - @Test - public void noCallbacks_failure_filterDuplicates_true_nullSSIDParam() { - assertEquals(null, mWiseFy.searchForAccessPoints(null, true)); - } - - @Test - public void noCallbacks_failure_filterDuplicates_false_missingPrerequisite() { - missingPrerequisite(); - assertEquals(null, mWiseFy.searchForAccessPoints(TEST_SSID, false)); - } - - @Test - public void noCallbacks_failure_filterDuplicates_true_missingPrerequisite() { - missingPrerequisite(); - assertEquals(null, mWiseFy.searchForAccessPoints(TEST_SSID, true)); - } - - @Test - public void noCallbacks_failure_filterDuplicates_false() { - WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); - mWiseFy.mWiseFySearch = mockWiseFySearch; - when(mockWiseFySearch.findAccessPointsMatchingRegex(anyString(), anyBoolean())).thenReturn(null); - - assertEquals(null, mWiseFy.searchForAccessPoints(TEST_SSID, false)); - } - - @Test - public void noCallbacks_failure_filterDuplicates_true() { - WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); - mWiseFy.mWiseFySearch = mockWiseFySearch; - when(mockWiseFySearch.findAccessPointsMatchingRegex(anyString(), anyBoolean())).thenReturn(null); - - assertEquals(null, mWiseFy.searchForAccessPoints(TEST_SSID, true)); - } - - @Test - public void noCallbacks_success_filterDuplicates_false() { - List accessPoints = new ArrayList<>(); - ScanResult accessPoint = mock(ScanResult.class); - accessPoint.SSID = TEST_SSID; - accessPoint.level = -35; - accessPoints.add(accessPoint); - - WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); - mWiseFy.mWiseFySearch = mockWiseFySearch; - when(mockWiseFySearch.findAccessPointsMatchingRegex(anyString(), anyBoolean())).thenReturn(accessPoints); - - assertEquals(accessPoints, mWiseFy.searchForAccessPoints(TEST_SSID, false)); - } - - @Test - public void noCallbacks_success_filterDuplicates_true() { - List accessPoints = new ArrayList<>(); - ScanResult accessPoint = mock(ScanResult.class); - accessPoint.SSID = TEST_SSID; - accessPoint.level = -35; - accessPoints.add(accessPoint); - - WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); - mWiseFy.mWiseFySearch = mockWiseFySearch; - when(mockWiseFySearch.findAccessPointsMatchingRegex(anyString(), anyBoolean())).thenReturn(accessPoints); - - assertEquals(accessPoints, mWiseFy.searchForAccessPoints(TEST_SSID, true)); - } - - @Test - public void callbacks_failure_filterDuplicates_false_nullSSIDParam() { - SearchForAccessPointsCallbacks mockCallbacks = mock(SearchForAccessPointsCallbacks.class); - mWiseFy.searchForAccessPoints(null, false, mockCallbacks); - verify(mockCallbacks, timeout(VERIFICATION_TIMEOUT)).searchForAccessPointsWiseFyFailure(WiseFyCodes.MISSING_PARAMETER); - } - - @Test - public void callbacks_failure_filterDuplicates_false_nullSSIDParam_nullCallback() { - try { - mWiseFy.searchForAccessPoints(null, false, null); - } catch (NullPointerException npe) { - fail(); - } - } - - @Test - public void callbacks_failure_filterDuplicates_true_nullSSIDParam() { - SearchForAccessPointsCallbacks mockCallbacks = mock(SearchForAccessPointsCallbacks.class); - mWiseFy.searchForAccessPoints(null, true, mockCallbacks); - verify(mockCallbacks, timeout(VERIFICATION_TIMEOUT)).searchForAccessPointsWiseFyFailure(WiseFyCodes.MISSING_PARAMETER); - } - - @Test - public void callbacks_failure_filterDuplicates_true_nullSSIDParam_nullCallback() { - try { - mWiseFy.searchForAccessPoints(null, true, null); - } catch (NullPointerException npe) { - fail(); - } - } - - @Test - public void callbacks_failure_filterDuplicates_false_missingPrerequisite() { - missingPrerequisite(); - SearchForAccessPointsCallbacks mockCallbacks = mock(SearchForAccessPointsCallbacks.class); - mWiseFy.searchForAccessPoints(TEST_SSID, false, mockCallbacks); - verify(mockCallbacks, timeout(VERIFICATION_TIMEOUT)).searchForAccessPointsWiseFyFailure(WiseFyCodes.MISSING_PREREQUISITE); - } - - @Test - public void callbacks_failure_filterDuplicates_false_missingPrerequisite_nullCallback() { - missingPrerequisite(); - try { - mWiseFy.searchForAccessPoints(TEST_SSID, false, null); - } catch (NullPointerException npe) { - fail(); - } - } - - @Test - public void callbacks_failure_filterDuplicates_true_missingPrerequisite() { - missingPrerequisite(); - SearchForAccessPointsCallbacks mockCallbacks = mock(SearchForAccessPointsCallbacks.class); - mWiseFy.searchForAccessPoints(TEST_SSID, true, mockCallbacks); - verify(mockCallbacks, timeout(VERIFICATION_TIMEOUT)).searchForAccessPointsWiseFyFailure(WiseFyCodes.MISSING_PREREQUISITE); - } - - @Test - public void callbacks_failure_filterDuplicates_true_missingPrerequisite_nullCallback() { - missingPrerequisite(); - try { - mWiseFy.searchForAccessPoints(TEST_SSID, true, null); - } catch (NullPointerException npe) { - fail(); - } - } - - @Test - public void callbacks_failure_filterDuplicates_false() { - WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); - mWiseFy.mWiseFySearch = mockWiseFySearch; - when(mockWiseFySearch.findAccessPointsMatchingRegex(anyString(), anyBoolean())).thenReturn(null); - - SearchForAccessPointsCallbacks mockCallbacks = mock(SearchForAccessPointsCallbacks.class); - mWiseFy.searchForAccessPoints(TEST_SSID, false, mockCallbacks); - verify(mockCallbacks, timeout(VERIFICATION_TIMEOUT)).noAccessPointsFound(); - } - - @Test - public void callbacks_failure_filterDuplicates_false_nullCallback() { - WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); - mWiseFy.mWiseFySearch = mockWiseFySearch; - when(mockWiseFySearch.findAccessPointsMatchingRegex(anyString(), anyBoolean())).thenReturn(null); - - try { - mWiseFy.searchForAccessPoints(TEST_SSID, false, null); - } catch (NullPointerException npe) { - fail(); - } - } - - @Test - public void callbacks_failure_filterDuplicates_true() { - WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); - mWiseFy.mWiseFySearch = mockWiseFySearch; - when(mockWiseFySearch.findAccessPointsMatchingRegex(anyString(), anyBoolean())).thenReturn(null); - - SearchForAccessPointsCallbacks mockCallbacks = mock(SearchForAccessPointsCallbacks.class); - mWiseFy.searchForAccessPoints(TEST_SSID, true, mockCallbacks); - verify(mockCallbacks, timeout(VERIFICATION_TIMEOUT)).noAccessPointsFound(); - } - - - @Test - public void callbacks_failure_filterDuplicates_true_nullCallback() { - WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); - mWiseFy.mWiseFySearch = mockWiseFySearch; - when(mockWiseFySearch.findAccessPointsMatchingRegex(anyString(), anyBoolean())).thenReturn(null); - - try { - mWiseFy.searchForAccessPoints(TEST_SSID, true, null); - } catch (NullPointerException npe) { - fail(); - } - } - - @Test - public void callbacks_success_filterDuplicates_false() { - List accessPoints = new ArrayList<>(); - ScanResult accessPoint = mock(ScanResult.class); - accessPoint.SSID = TEST_SSID; - accessPoint.level = -35; - accessPoints.add(accessPoint); - - WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); - mWiseFy.mWiseFySearch = mockWiseFySearch; - when(mockWiseFySearch.findAccessPointsMatchingRegex(anyString(), anyBoolean())).thenReturn(accessPoints); - - SearchForAccessPointsCallbacks mockCallbacks = mock(SearchForAccessPointsCallbacks.class); - mWiseFy.searchForAccessPoints(TEST_SSID, true, mockCallbacks); - verify(mockCallbacks, timeout(VERIFICATION_TIMEOUT)).foundAccessPoints(accessPoints); - } - - @Test - public void callbacks_success_filterDuplicates_false_nullCallback() { - List accessPoints = new ArrayList<>(); - ScanResult accessPoint = mock(ScanResult.class); - accessPoint.SSID = TEST_SSID; - accessPoint.level = -35; - accessPoints.add(accessPoint); - - WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); - mWiseFy.mWiseFySearch = mockWiseFySearch; - when(mockWiseFySearch.findAccessPointsMatchingRegex(anyString(), anyBoolean())).thenReturn(accessPoints); - - try { - mWiseFy.searchForAccessPoints(TEST_SSID, true, null); - } catch (NullPointerException npe) { - fail(); - } - } - - @Test - public void callbacks_success_filterDuplicates_true() { - List accessPoints = new ArrayList<>(); - ScanResult accessPoint = mock(ScanResult.class); - accessPoint.SSID = TEST_SSID; - accessPoint.level = -35; - accessPoints.add(accessPoint); - - WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); - mWiseFy.mWiseFySearch = mockWiseFySearch; - when(mockWiseFySearch.findAccessPointsMatchingRegex(anyString(), anyBoolean())).thenReturn(accessPoints); - - SearchForAccessPointsCallbacks mockCallbacks = mock(SearchForAccessPointsCallbacks.class); - mWiseFy.searchForAccessPoints(TEST_SSID, true, mockCallbacks); - verify(mockCallbacks, timeout(VERIFICATION_TIMEOUT)).foundAccessPoints(accessPoints); - } - - @Test - public void callbacks_success_filterDuplicates_true_nullCallback() { - List accessPoints = new ArrayList<>(); - ScanResult accessPoint = mock(ScanResult.class); - accessPoint.SSID = TEST_SSID; - accessPoint.level = -35; - accessPoints.add(accessPoint); - - WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); - mWiseFy.mWiseFySearch = mockWiseFySearch; - when(mockWiseFySearch.findAccessPointsMatchingRegex(anyString(), anyBoolean())).thenReturn(accessPoints); - - try { - mWiseFy.searchForAccessPoints(TEST_SSID, true, null); - } catch (NullPointerException npe) { - fail(); - } - } -} +//package com.isupatches.wisefy; +// +// +//import android.net.wifi.ScanResult; +//import com.isupatches.wisefy.base.TestActivity; +//import com.isupatches.wisefy.callbacks.SearchForAccessPointsCallbacks; +//import com.isupatches.wisefy.constants.WiseFyCodes; +//import org.junit.Test; +//import java.util.ArrayList; +//import java.util.List; +//import static com.isupatches.wisefy.base.TestUtils.TEST_SSID; +//import static junit.framework.Assert.assertEquals; +//import static junit.framework.Assert.fail; +//import static org.mockito.ArgumentMatchers.anyBoolean; +//import static org.mockito.ArgumentMatchers.anyString; +//import static org.mockito.Mockito.mock; +//import static org.mockito.Mockito.timeout; +//import static org.mockito.Mockito.verify; +//import static org.mockito.Mockito.when; +// +// +//public class SearchForAccessPointsTests extends BaseTestClass { +// +// public SearchForAccessPointsTests() { +// super(TestActivity.class); +// } +// +// @Test +// public void noCallbacks_failure_filterDuplicates_false_nullSSIDParam() { +// assertEquals(null, mWiseFy.searchForAccessPoints(null, false)); +// } +// +// @Test +// public void noCallbacks_failure_filterDuplicates_true_nullSSIDParam() { +// assertEquals(null, mWiseFy.searchForAccessPoints(null, true)); +// } +// +// @Test +// public void noCallbacks_failure_filterDuplicates_false_missingPrerequisite() { +// missingPrerequisite(); +// assertEquals(null, mWiseFy.searchForAccessPoints(TEST_SSID, false)); +// } +// +// @Test +// public void noCallbacks_failure_filterDuplicates_true_missingPrerequisite() { +// missingPrerequisite(); +// assertEquals(null, mWiseFy.searchForAccessPoints(TEST_SSID, true)); +// } +// +// @Test +// public void noCallbacks_failure_filterDuplicates_false() { +// WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); +// mWiseFy.mWiseFySearch = mockWiseFySearch; +// when(mockWiseFySearch.findAccessPointsMatchingRegex(anyString(), anyBoolean())).thenReturn(null); +// +// assertEquals(null, mWiseFy.searchForAccessPoints(TEST_SSID, false)); +// } +// +// @Test +// public void noCallbacks_failure_filterDuplicates_true() { +// WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); +// mWiseFy.mWiseFySearch = mockWiseFySearch; +// when(mockWiseFySearch.findAccessPointsMatchingRegex(anyString(), anyBoolean())).thenReturn(null); +// +// assertEquals(null, mWiseFy.searchForAccessPoints(TEST_SSID, true)); +// } +// +// @Test +// public void noCallbacks_success_filterDuplicates_false() { +// List accessPoints = new ArrayList<>(); +// ScanResult accessPoint = mock(ScanResult.class); +// accessPoint.SSID = TEST_SSID; +// accessPoint.level = -35; +// accessPoints.add(accessPoint); +// +// WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); +// mWiseFy.mWiseFySearch = mockWiseFySearch; +// when(mockWiseFySearch.findAccessPointsMatchingRegex(anyString(), anyBoolean())).thenReturn(accessPoints); +// +// assertEquals(accessPoints, mWiseFy.searchForAccessPoints(TEST_SSID, false)); +// } +// +// @Test +// public void noCallbacks_success_filterDuplicates_true() { +// List accessPoints = new ArrayList<>(); +// ScanResult accessPoint = mock(ScanResult.class); +// accessPoint.SSID = TEST_SSID; +// accessPoint.level = -35; +// accessPoints.add(accessPoint); +// +// WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); +// mWiseFy.mWiseFySearch = mockWiseFySearch; +// when(mockWiseFySearch.findAccessPointsMatchingRegex(anyString(), anyBoolean())).thenReturn(accessPoints); +// +// assertEquals(accessPoints, mWiseFy.searchForAccessPoints(TEST_SSID, true)); +// } +// +// @Test +// public void callbacks_failure_filterDuplicates_false_nullSSIDParam() { +// SearchForAccessPointsCallbacks mockCallbacks = mock(SearchForAccessPointsCallbacks.class); +// mWiseFy.searchForAccessPoints(null, false, mockCallbacks); +// verify(mockCallbacks, timeout(VERIFICATION_TIMEOUT)).searchForAccessPointsWiseFyFailure(WiseFyCodes.MISSING_PARAMETER); +// } +// +// @Test +// public void callbacks_failure_filterDuplicates_false_nullSSIDParam_nullCallback() { +// try { +// mWiseFy.searchForAccessPoints(null, false, null); +// } catch (NullPointerException npe) { +// fail(); +// } +// } +// +// @Test +// public void callbacks_failure_filterDuplicates_true_nullSSIDParam() { +// SearchForAccessPointsCallbacks mockCallbacks = mock(SearchForAccessPointsCallbacks.class); +// mWiseFy.searchForAccessPoints(null, true, mockCallbacks); +// verify(mockCallbacks, timeout(VERIFICATION_TIMEOUT)).searchForAccessPointsWiseFyFailure(WiseFyCodes.MISSING_PARAMETER); +// } +// +// @Test +// public void callbacks_failure_filterDuplicates_true_nullSSIDParam_nullCallback() { +// try { +// mWiseFy.searchForAccessPoints(null, true, null); +// } catch (NullPointerException npe) { +// fail(); +// } +// } +// +// @Test +// public void callbacks_failure_filterDuplicates_false_missingPrerequisite() { +// missingPrerequisite(); +// SearchForAccessPointsCallbacks mockCallbacks = mock(SearchForAccessPointsCallbacks.class); +// mWiseFy.searchForAccessPoints(TEST_SSID, false, mockCallbacks); +// verify(mockCallbacks, timeout(VERIFICATION_TIMEOUT)).searchForAccessPointsWiseFyFailure(WiseFyCodes.MISSING_PREREQUISITE); +// } +// +// @Test +// public void callbacks_failure_filterDuplicates_false_missingPrerequisite_nullCallback() { +// missingPrerequisite(); +// try { +// mWiseFy.searchForAccessPoints(TEST_SSID, false, null); +// } catch (NullPointerException npe) { +// fail(); +// } +// } +// +// @Test +// public void callbacks_failure_filterDuplicates_true_missingPrerequisite() { +// missingPrerequisite(); +// SearchForAccessPointsCallbacks mockCallbacks = mock(SearchForAccessPointsCallbacks.class); +// mWiseFy.searchForAccessPoints(TEST_SSID, true, mockCallbacks); +// verify(mockCallbacks, timeout(VERIFICATION_TIMEOUT)).searchForAccessPointsWiseFyFailure(WiseFyCodes.MISSING_PREREQUISITE); +// } +// +// @Test +// public void callbacks_failure_filterDuplicates_true_missingPrerequisite_nullCallback() { +// missingPrerequisite(); +// try { +// mWiseFy.searchForAccessPoints(TEST_SSID, true, null); +// } catch (NullPointerException npe) { +// fail(); +// } +// } +// +// @Test +// public void callbacks_failure_filterDuplicates_false() { +// WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); +// mWiseFy.mWiseFySearch = mockWiseFySearch; +// when(mockWiseFySearch.findAccessPointsMatchingRegex(anyString(), anyBoolean())).thenReturn(null); +// +// SearchForAccessPointsCallbacks mockCallbacks = mock(SearchForAccessPointsCallbacks.class); +// mWiseFy.searchForAccessPoints(TEST_SSID, false, mockCallbacks); +// verify(mockCallbacks, timeout(VERIFICATION_TIMEOUT)).noAccessPointsFound(); +// } +// +// @Test +// public void callbacks_failure_filterDuplicates_false_nullCallback() { +// WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); +// mWiseFy.mWiseFySearch = mockWiseFySearch; +// when(mockWiseFySearch.findAccessPointsMatchingRegex(anyString(), anyBoolean())).thenReturn(null); +// +// try { +// mWiseFy.searchForAccessPoints(TEST_SSID, false, null); +// } catch (NullPointerException npe) { +// fail(); +// } +// } +// +// @Test +// public void callbacks_failure_filterDuplicates_true() { +// WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); +// mWiseFy.mWiseFySearch = mockWiseFySearch; +// when(mockWiseFySearch.findAccessPointsMatchingRegex(anyString(), anyBoolean())).thenReturn(null); +// +// SearchForAccessPointsCallbacks mockCallbacks = mock(SearchForAccessPointsCallbacks.class); +// mWiseFy.searchForAccessPoints(TEST_SSID, true, mockCallbacks); +// verify(mockCallbacks, timeout(VERIFICATION_TIMEOUT)).noAccessPointsFound(); +// } +// +// +// @Test +// public void callbacks_failure_filterDuplicates_true_nullCallback() { +// WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); +// mWiseFy.mWiseFySearch = mockWiseFySearch; +// when(mockWiseFySearch.findAccessPointsMatchingRegex(anyString(), anyBoolean())).thenReturn(null); +// +// try { +// mWiseFy.searchForAccessPoints(TEST_SSID, true, null); +// } catch (NullPointerException npe) { +// fail(); +// } +// } +// +// @Test +// public void callbacks_success_filterDuplicates_false() { +// List accessPoints = new ArrayList<>(); +// ScanResult accessPoint = mock(ScanResult.class); +// accessPoint.SSID = TEST_SSID; +// accessPoint.level = -35; +// accessPoints.add(accessPoint); +// +// WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); +// mWiseFy.mWiseFySearch = mockWiseFySearch; +// when(mockWiseFySearch.findAccessPointsMatchingRegex(anyString(), anyBoolean())).thenReturn(accessPoints); +// +// SearchForAccessPointsCallbacks mockCallbacks = mock(SearchForAccessPointsCallbacks.class); +// mWiseFy.searchForAccessPoints(TEST_SSID, true, mockCallbacks); +// verify(mockCallbacks, timeout(VERIFICATION_TIMEOUT)).foundAccessPoints(accessPoints); +// } +// +// @Test +// public void callbacks_success_filterDuplicates_false_nullCallback() { +// List accessPoints = new ArrayList<>(); +// ScanResult accessPoint = mock(ScanResult.class); +// accessPoint.SSID = TEST_SSID; +// accessPoint.level = -35; +// accessPoints.add(accessPoint); +// +// WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); +// mWiseFy.mWiseFySearch = mockWiseFySearch; +// when(mockWiseFySearch.findAccessPointsMatchingRegex(anyString(), anyBoolean())).thenReturn(accessPoints); +// +// try { +// mWiseFy.searchForAccessPoints(TEST_SSID, true, null); +// } catch (NullPointerException npe) { +// fail(); +// } +// } +// +// @Test +// public void callbacks_success_filterDuplicates_true() { +// List accessPoints = new ArrayList<>(); +// ScanResult accessPoint = mock(ScanResult.class); +// accessPoint.SSID = TEST_SSID; +// accessPoint.level = -35; +// accessPoints.add(accessPoint); +// +// WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); +// mWiseFy.mWiseFySearch = mockWiseFySearch; +// when(mockWiseFySearch.findAccessPointsMatchingRegex(anyString(), anyBoolean())).thenReturn(accessPoints); +// +// SearchForAccessPointsCallbacks mockCallbacks = mock(SearchForAccessPointsCallbacks.class); +// mWiseFy.searchForAccessPoints(TEST_SSID, true, mockCallbacks); +// verify(mockCallbacks, timeout(VERIFICATION_TIMEOUT)).foundAccessPoints(accessPoints); +// } +// +// @Test +// public void callbacks_success_filterDuplicates_true_nullCallback() { +// List accessPoints = new ArrayList<>(); +// ScanResult accessPoint = mock(ScanResult.class); +// accessPoint.SSID = TEST_SSID; +// accessPoint.level = -35; +// accessPoints.add(accessPoint); +// +// WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); +// mWiseFy.mWiseFySearch = mockWiseFySearch; +// when(mockWiseFySearch.findAccessPointsMatchingRegex(anyString(), anyBoolean())).thenReturn(accessPoints); +// +// try { +// mWiseFy.searchForAccessPoints(TEST_SSID, true, null); +// } catch (NullPointerException npe) { +// fail(); +// } +// } +//} diff --git a/wisefy/src/androidTest/java/com/isupatches/wisefy/SearchForSSIDTests.java b/wisefy/src/androidTest/java/com/isupatches/wisefy/SearchForSSIDTests.java index a69a2648..b1202443 100644 --- a/wisefy/src/androidTest/java/com/isupatches/wisefy/SearchForSSIDTests.java +++ b/wisefy/src/androidTest/java/com/isupatches/wisefy/SearchForSSIDTests.java @@ -1,149 +1,149 @@ -package com.isupatches.wisefy; - - -import android.net.wifi.ScanResult; -import com.isupatches.wisefy.base.TestActivity; -import com.isupatches.wisefy.callbacks.SearchForSSIDCallbacks; -import com.isupatches.wisefy.constants.WiseFyCodes; -import org.junit.Test; -import static com.isupatches.wisefy.base.TestUtils.TEST_SSID; -import static junit.framework.Assert.fail; -import static org.junit.Assert.assertEquals; -import static org.mockito.ArgumentMatchers.anyBoolean; -import static org.mockito.ArgumentMatchers.anyInt; -import static org.mockito.ArgumentMatchers.anyString; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.timeout; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; - - -public class SearchForSSIDTests extends BaseTestClass { - - public SearchForSSIDTests() { - super(TestActivity.class); - } - - @Test - public void noCallbacks_failure_nullSSIDParam() { - assertEquals(null, mWiseFy.searchForSSID(null, 1000)); - } - - @Test - public void noCallbacks_failure_missingPrerequisite() { - missingPrerequisite(); - assertEquals(null, mWiseFy.searchForSSID(TEST_SSID, 1000)); - } - - @Test - public void noCallbacks_failure() { - WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); - mWiseFy.mWiseFySearch = mockWiseFySearch; - when(mockWiseFySearch.findAccessPointByRegex(anyString(), anyInt(), anyBoolean())).thenReturn(null); - - assertEquals(null, mWiseFy.searchForSSID(TEST_SSID, 1000)); - } - - @Test - public void noCallbacks_success() { - ScanResult accessPoint = mock(ScanResult.class); - accessPoint.SSID = TEST_SSID; - accessPoint.level = -35; - - WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); - mWiseFy.mWiseFySearch = mockWiseFySearch; - when(mockWiseFySearch.findAccessPointByRegex(anyString(), anyInt(), anyBoolean())).thenReturn(accessPoint); - - assertEquals(TEST_SSID, mWiseFy.searchForSSID(TEST_SSID, 1000)); - } - - @Test - public void callbacks_failure_nullSSIDParam() { - SearchForSSIDCallbacks mockCallbacks = mock(SearchForSSIDCallbacks.class); - mWiseFy.searchForSSID(null, 1000, mockCallbacks); - verify(mockCallbacks, timeout(VERIFICATION_TIMEOUT)).searchForSSIDWiseFyFailure(WiseFyCodes.MISSING_PARAMETER); - } - - @Test - public void callbacks_failure_nullSSIDParam_nullCallback() { - try { - mWiseFy.searchForSSID(null, 1000, null); - } catch (NullPointerException npe) { - fail(); - } - } - - @Test - public void callbacks_failure_missingPrerequisite() { - missingPrerequisite(); - SearchForSSIDCallbacks mockCallbacks = mock(SearchForSSIDCallbacks.class); - mWiseFy.searchForSSID(TEST_SSID, 1000, mockCallbacks); - verify(mockCallbacks, timeout(VERIFICATION_TIMEOUT)).searchForSSIDWiseFyFailure(WiseFyCodes.MISSING_PREREQUISITE); - } - - @Test - public void callbacks_failure_missingPrerequisite_nullCallback() { - missingPrerequisite(); - try { - mWiseFy.searchForSSID(TEST_SSID, 1000, null); - } catch (NullPointerException npe) { - fail(); - } - } - - @Test - public void callbacks_failure() { - WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); - mWiseFy.mWiseFySearch = mockWiseFySearch; - when(mockWiseFySearch.findAccessPointByRegex(anyString(), anyInt(), anyBoolean())).thenReturn(null); - - SearchForSSIDCallbacks mockCallbacks = mock(SearchForSSIDCallbacks.class); - mWiseFy.searchForSSID(TEST_SSID, 1000, mockCallbacks); - verify(mockCallbacks, timeout(VERIFICATION_TIMEOUT)).ssidNotFound(); - } - - - @Test - public void callbacks_failure_nullCallback() { - WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); - mWiseFy.mWiseFySearch = mockWiseFySearch; - when(mockWiseFySearch.findAccessPointByRegex(anyString(), anyInt(), anyBoolean())).thenReturn(null); - - try { - mWiseFy.searchForSSID(TEST_SSID, 1000, null); - } catch (NullPointerException npe) { - fail(); - } - } - - @Test - public void callbacks_success() { - ScanResult accessPoint = mock(ScanResult.class); - accessPoint.SSID = TEST_SSID; - accessPoint.level = -35; - - WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); - mWiseFy.mWiseFySearch = mockWiseFySearch; - when(mockWiseFySearch.findAccessPointByRegex(anyString(), anyInt(), anyBoolean())).thenReturn(accessPoint); - - SearchForSSIDCallbacks mockCallbacks = mock(SearchForSSIDCallbacks.class); - mWiseFy.searchForSSID(TEST_SSID, 1000, mockCallbacks); - verify(mockCallbacks, timeout(VERIFICATION_TIMEOUT)).ssidFound(TEST_SSID); - } - - @Test - public void callbacks_success_nullCallback() { - ScanResult accessPoint = mock(ScanResult.class); - accessPoint.SSID = TEST_SSID; - - WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); - mWiseFy.mWiseFySearch = mockWiseFySearch; - when(mockWiseFySearch.findAccessPointByRegex(anyString(), anyInt(), anyBoolean())).thenReturn(accessPoint); - - try { - mWiseFy.searchForSSID(TEST_SSID, 1000, null); - } catch (NullPointerException npe) { - fail(); - } - } -} +//package com.isupatches.wisefy; +// +// +//import android.net.wifi.ScanResult; +//import com.isupatches.wisefy.base.TestActivity; +//import com.isupatches.wisefy.callbacks.SearchForSSIDCallbacks; +//import com.isupatches.wisefy.constants.WiseFyCodes; +//import org.junit.Test; +//import static com.isupatches.wisefy.base.TestUtils.TEST_SSID; +//import static junit.framework.Assert.fail; +//import static org.junit.Assert.assertEquals; +//import static org.mockito.ArgumentMatchers.anyBoolean; +//import static org.mockito.ArgumentMatchers.anyInt; +//import static org.mockito.ArgumentMatchers.anyString; +//import static org.mockito.Mockito.mock; +//import static org.mockito.Mockito.timeout; +//import static org.mockito.Mockito.verify; +//import static org.mockito.Mockito.when; +// +// +//public class SearchForSSIDTests extends BaseTestClass { +// +// public SearchForSSIDTests() { +// super(TestActivity.class); +// } +// +// @Test +// public void noCallbacks_failure_nullSSIDParam() { +// assertEquals(null, mWiseFy.searchForSSID(null, 1000)); +// } +// +// @Test +// public void noCallbacks_failure_missingPrerequisite() { +// missingPrerequisite(); +// assertEquals(null, mWiseFy.searchForSSID(TEST_SSID, 1000)); +// } +// +// @Test +// public void noCallbacks_failure() { +// WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); +// mWiseFy.mWiseFySearch = mockWiseFySearch; +// when(mockWiseFySearch.findAccessPointByRegex(anyString(), anyInt(), anyBoolean())).thenReturn(null); +// +// assertEquals(null, mWiseFy.searchForSSID(TEST_SSID, 1000)); +// } +// +// @Test +// public void noCallbacks_success() { +// ScanResult accessPoint = mock(ScanResult.class); +// accessPoint.SSID = TEST_SSID; +// accessPoint.level = -35; +// +// WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); +// mWiseFy.mWiseFySearch = mockWiseFySearch; +// when(mockWiseFySearch.findAccessPointByRegex(anyString(), anyInt(), anyBoolean())).thenReturn(accessPoint); +// +// assertEquals(TEST_SSID, mWiseFy.searchForSSID(TEST_SSID, 1000)); +// } +// +// @Test +// public void callbacks_failure_nullSSIDParam() { +// SearchForSSIDCallbacks mockCallbacks = mock(SearchForSSIDCallbacks.class); +// mWiseFy.searchForSSID(null, 1000, mockCallbacks); +// verify(mockCallbacks, timeout(VERIFICATION_TIMEOUT)).searchForSSIDWiseFyFailure(WiseFyCodes.MISSING_PARAMETER); +// } +// +// @Test +// public void callbacks_failure_nullSSIDParam_nullCallback() { +// try { +// mWiseFy.searchForSSID(null, 1000, null); +// } catch (NullPointerException npe) { +// fail(); +// } +// } +// +// @Test +// public void callbacks_failure_missingPrerequisite() { +// missingPrerequisite(); +// SearchForSSIDCallbacks mockCallbacks = mock(SearchForSSIDCallbacks.class); +// mWiseFy.searchForSSID(TEST_SSID, 1000, mockCallbacks); +// verify(mockCallbacks, timeout(VERIFICATION_TIMEOUT)).searchForSSIDWiseFyFailure(WiseFyCodes.MISSING_PREREQUISITE); +// } +// +// @Test +// public void callbacks_failure_missingPrerequisite_nullCallback() { +// missingPrerequisite(); +// try { +// mWiseFy.searchForSSID(TEST_SSID, 1000, null); +// } catch (NullPointerException npe) { +// fail(); +// } +// } +// +// @Test +// public void callbacks_failure() { +// WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); +// mWiseFy.mWiseFySearch = mockWiseFySearch; +// when(mockWiseFySearch.findAccessPointByRegex(anyString(), anyInt(), anyBoolean())).thenReturn(null); +// +// SearchForSSIDCallbacks mockCallbacks = mock(SearchForSSIDCallbacks.class); +// mWiseFy.searchForSSID(TEST_SSID, 1000, mockCallbacks); +// verify(mockCallbacks, timeout(VERIFICATION_TIMEOUT)).ssidNotFound(); +// } +// +// +// @Test +// public void callbacks_failure_nullCallback() { +// WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); +// mWiseFy.mWiseFySearch = mockWiseFySearch; +// when(mockWiseFySearch.findAccessPointByRegex(anyString(), anyInt(), anyBoolean())).thenReturn(null); +// +// try { +// mWiseFy.searchForSSID(TEST_SSID, 1000, null); +// } catch (NullPointerException npe) { +// fail(); +// } +// } +// +// @Test +// public void callbacks_success() { +// ScanResult accessPoint = mock(ScanResult.class); +// accessPoint.SSID = TEST_SSID; +// accessPoint.level = -35; +// +// WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); +// mWiseFy.mWiseFySearch = mockWiseFySearch; +// when(mockWiseFySearch.findAccessPointByRegex(anyString(), anyInt(), anyBoolean())).thenReturn(accessPoint); +// +// SearchForSSIDCallbacks mockCallbacks = mock(SearchForSSIDCallbacks.class); +// mWiseFy.searchForSSID(TEST_SSID, 1000, mockCallbacks); +// verify(mockCallbacks, timeout(VERIFICATION_TIMEOUT)).ssidFound(TEST_SSID); +// } +// +// @Test +// public void callbacks_success_nullCallback() { +// ScanResult accessPoint = mock(ScanResult.class); +// accessPoint.SSID = TEST_SSID; +// +// WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); +// mWiseFy.mWiseFySearch = mockWiseFySearch; +// when(mockWiseFySearch.findAccessPointByRegex(anyString(), anyInt(), anyBoolean())).thenReturn(accessPoint); +// +// try { +// mWiseFy.searchForSSID(TEST_SSID, 1000, null); +// } catch (NullPointerException npe) { +// fail(); +// } +// } +//} diff --git a/wisefy/src/androidTest/java/com/isupatches/wisefy/SearchForSSIDsTests.java b/wisefy/src/androidTest/java/com/isupatches/wisefy/SearchForSSIDsTests.java index 13cad278..07edf930 100644 --- a/wisefy/src/androidTest/java/com/isupatches/wisefy/SearchForSSIDsTests.java +++ b/wisefy/src/androidTest/java/com/isupatches/wisefy/SearchForSSIDsTests.java @@ -1,146 +1,146 @@ -package com.isupatches.wisefy; - - -import com.isupatches.wisefy.base.TestActivity; -import com.isupatches.wisefy.callbacks.SearchForSSIDsCallbacks; -import com.isupatches.wisefy.constants.WiseFyCodes; -import org.junit.Test; -import java.util.ArrayList; -import java.util.List; -import static com.isupatches.wisefy.base.TestUtils.TEST_SSID; -import static junit.framework.Assert.fail; -import static org.junit.Assert.assertEquals; -import static org.mockito.ArgumentMatchers.anyString; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.timeout; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; - - -public class SearchForSSIDsTests extends BaseTestClass { - - public SearchForSSIDsTests() { - super(TestActivity.class); - } - - @Test - public void noCallbacks_failure_nullSSIDParam() { - assertEquals(null, mWiseFy.searchForSSIDs(null)); - } - - @Test - public void noCallbacks_failure_missingPrerequisite() { - missingPrerequisite(); - assertEquals(null, mWiseFy.searchForSSIDs(TEST_SSID)); - } - - @Test - public void noCallbacks_failure() { - WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); - mWiseFy.mWiseFySearch = mockWiseFySearch; - when(mockWiseFySearch.findSSIDsMatchingRegex(anyString())).thenReturn(null); - - assertEquals(null, mWiseFy.searchForSSIDs(TEST_SSID)); - } - - @Test - public void noCallbacks_success() { - List ssids = new ArrayList<>(); - ssids.add(TEST_SSID); - - WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); - mWiseFy.mWiseFySearch = mockWiseFySearch; - when(mockWiseFySearch.findSSIDsMatchingRegex(anyString())).thenReturn(ssids); - - assertEquals(ssids, mWiseFy.searchForSSIDs(TEST_SSID)); - } - - @Test - public void callbacks_failure_nullSSIDParam() { - SearchForSSIDsCallbacks mockCallbacks = mock(SearchForSSIDsCallbacks.class); - mWiseFy.searchForSSIDs(null, mockCallbacks); - verify(mockCallbacks, timeout(VERIFICATION_TIMEOUT)).searchForSSIDsWiseFyFailure(WiseFyCodes.MISSING_PARAMETER); - } - - @Test - public void callbacks_failure_nullSSIDParam_nullCallback() { - try { - mWiseFy.searchForSSIDs(null, null); - } catch (NullPointerException npe) { - fail(); - } - } - - @Test - public void callbacks_failure_missingPrerequisite() { - missingPrerequisite(); - SearchForSSIDsCallbacks mockCallbacks = mock(SearchForSSIDsCallbacks.class); - mWiseFy.searchForSSIDs(TEST_SSID, mockCallbacks); - verify(mockCallbacks, timeout(VERIFICATION_TIMEOUT)).searchForSSIDsWiseFyFailure(WiseFyCodes.MISSING_PREREQUISITE); - } - - @Test - public void callbacks_failure_missingPrerequisite_nullCallback() { - missingPrerequisite(); - try { - mWiseFy.searchForSSIDs(TEST_SSID, null); - } catch (NullPointerException npe) { - fail(); - } - } - - @Test - public void callbacks_failure() { - WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); - mWiseFy.mWiseFySearch = mockWiseFySearch; - when(mockWiseFySearch.findSSIDsMatchingRegex(anyString())).thenReturn(null); - - SearchForSSIDsCallbacks mockCallbacks = mock(SearchForSSIDsCallbacks.class); - mWiseFy.searchForSSIDs(TEST_SSID, mockCallbacks); - verify(mockCallbacks, timeout(VERIFICATION_TIMEOUT)).noSSIDsFound(); - } - - - @Test - public void callbacks_failure_nullCallback() { - WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); - mWiseFy.mWiseFySearch = mockWiseFySearch; - when(mockWiseFySearch.findSSIDsMatchingRegex(anyString())).thenReturn(null); - - try { - mWiseFy.searchForSSIDs(TEST_SSID, null); - } catch (NullPointerException npe) { - fail(); - } - } - - @Test - public void callbacks_success() { - List ssids = new ArrayList<>(); - ssids.add(TEST_SSID); - - WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); - mWiseFy.mWiseFySearch = mockWiseFySearch; - when(mockWiseFySearch.findSSIDsMatchingRegex(anyString())).thenReturn(ssids); - - SearchForSSIDsCallbacks mockCallbacks = mock(SearchForSSIDsCallbacks.class); - mWiseFy.searchForSSIDs(TEST_SSID, mockCallbacks); - verify(mockCallbacks, timeout(VERIFICATION_TIMEOUT)).retrievedSSIDs(ssids); - } - - @Test - public void callbacks_success_nullCallback() { - List ssids = new ArrayList<>(); - ssids.add(TEST_SSID); - - WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); - mWiseFy.mWiseFySearch = mockWiseFySearch; - when(mockWiseFySearch.findSSIDsMatchingRegex(anyString())).thenReturn(ssids); - - try { - mWiseFy.searchForSSIDs(TEST_SSID, null); - } catch (NullPointerException npe) { - fail(); - } - } -} +//package com.isupatches.wisefy; +// +// +//import com.isupatches.wisefy.base.TestActivity; +//import com.isupatches.wisefy.callbacks.SearchForSSIDsCallbacks; +//import com.isupatches.wisefy.constants.WiseFyCodes; +//import org.junit.Test; +//import java.util.ArrayList; +//import java.util.List; +//import static com.isupatches.wisefy.base.TestUtils.TEST_SSID; +//import static junit.framework.Assert.fail; +//import static org.junit.Assert.assertEquals; +//import static org.mockito.ArgumentMatchers.anyString; +//import static org.mockito.Mockito.mock; +//import static org.mockito.Mockito.timeout; +//import static org.mockito.Mockito.verify; +//import static org.mockito.Mockito.when; +// +// +//public class SearchForSSIDsTests extends BaseTestClass { +// +// public SearchForSSIDsTests() { +// super(TestActivity.class); +// } +// +// @Test +// public void noCallbacks_failure_nullSSIDParam() { +// assertEquals(null, mWiseFy.searchForSSIDs(null)); +// } +// +// @Test +// public void noCallbacks_failure_missingPrerequisite() { +// missingPrerequisite(); +// assertEquals(null, mWiseFy.searchForSSIDs(TEST_SSID)); +// } +// +// @Test +// public void noCallbacks_failure() { +// WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); +// mWiseFy.mWiseFySearch = mockWiseFySearch; +// when(mockWiseFySearch.findSSIDsMatchingRegex(anyString())).thenReturn(null); +// +// assertEquals(null, mWiseFy.searchForSSIDs(TEST_SSID)); +// } +// +// @Test +// public void noCallbacks_success() { +// List ssids = new ArrayList<>(); +// ssids.add(TEST_SSID); +// +// WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); +// mWiseFy.mWiseFySearch = mockWiseFySearch; +// when(mockWiseFySearch.findSSIDsMatchingRegex(anyString())).thenReturn(ssids); +// +// assertEquals(ssids, mWiseFy.searchForSSIDs(TEST_SSID)); +// } +// +// @Test +// public void callbacks_failure_nullSSIDParam() { +// SearchForSSIDsCallbacks mockCallbacks = mock(SearchForSSIDsCallbacks.class); +// mWiseFy.searchForSSIDs(null, mockCallbacks); +// verify(mockCallbacks, timeout(VERIFICATION_TIMEOUT)).searchForSSIDsWiseFyFailure(WiseFyCodes.MISSING_PARAMETER); +// } +// +// @Test +// public void callbacks_failure_nullSSIDParam_nullCallback() { +// try { +// mWiseFy.searchForSSIDs(null, null); +// } catch (NullPointerException npe) { +// fail(); +// } +// } +// +// @Test +// public void callbacks_failure_missingPrerequisite() { +// missingPrerequisite(); +// SearchForSSIDsCallbacks mockCallbacks = mock(SearchForSSIDsCallbacks.class); +// mWiseFy.searchForSSIDs(TEST_SSID, mockCallbacks); +// verify(mockCallbacks, timeout(VERIFICATION_TIMEOUT)).searchForSSIDsWiseFyFailure(WiseFyCodes.MISSING_PREREQUISITE); +// } +// +// @Test +// public void callbacks_failure_missingPrerequisite_nullCallback() { +// missingPrerequisite(); +// try { +// mWiseFy.searchForSSIDs(TEST_SSID, null); +// } catch (NullPointerException npe) { +// fail(); +// } +// } +// +// @Test +// public void callbacks_failure() { +// WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); +// mWiseFy.mWiseFySearch = mockWiseFySearch; +// when(mockWiseFySearch.findSSIDsMatchingRegex(anyString())).thenReturn(null); +// +// SearchForSSIDsCallbacks mockCallbacks = mock(SearchForSSIDsCallbacks.class); +// mWiseFy.searchForSSIDs(TEST_SSID, mockCallbacks); +// verify(mockCallbacks, timeout(VERIFICATION_TIMEOUT)).noSSIDsFound(); +// } +// +// +// @Test +// public void callbacks_failure_nullCallback() { +// WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); +// mWiseFy.mWiseFySearch = mockWiseFySearch; +// when(mockWiseFySearch.findSSIDsMatchingRegex(anyString())).thenReturn(null); +// +// try { +// mWiseFy.searchForSSIDs(TEST_SSID, null); +// } catch (NullPointerException npe) { +// fail(); +// } +// } +// +// @Test +// public void callbacks_success() { +// List ssids = new ArrayList<>(); +// ssids.add(TEST_SSID); +// +// WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); +// mWiseFy.mWiseFySearch = mockWiseFySearch; +// when(mockWiseFySearch.findSSIDsMatchingRegex(anyString())).thenReturn(ssids); +// +// SearchForSSIDsCallbacks mockCallbacks = mock(SearchForSSIDsCallbacks.class); +// mWiseFy.searchForSSIDs(TEST_SSID, mockCallbacks); +// verify(mockCallbacks, timeout(VERIFICATION_TIMEOUT)).retrievedSSIDs(ssids); +// } +// +// @Test +// public void callbacks_success_nullCallback() { +// List ssids = new ArrayList<>(); +// ssids.add(TEST_SSID); +// +// WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); +// mWiseFy.mWiseFySearch = mockWiseFySearch; +// when(mockWiseFySearch.findSSIDsMatchingRegex(anyString())).thenReturn(ssids); +// +// try { +// mWiseFy.searchForSSIDs(TEST_SSID, null); +// } catch (NullPointerException npe) { +// fail(); +// } +// } +//} diff --git a/wisefy/src/androidTest/java/com/isupatches/wisefy/WiseFyConnectionTests.java b/wisefy/src/androidTest/java/com/isupatches/wisefy/WiseFyConnectionTests.java index a5f96d2d..9d0d5889 100644 --- a/wisefy/src/androidTest/java/com/isupatches/wisefy/WiseFyConnectionTests.java +++ b/wisefy/src/androidTest/java/com/isupatches/wisefy/WiseFyConnectionTests.java @@ -1,364 +1,364 @@ -package com.isupatches.wisefy; - - -import android.net.NetworkInfo; -import android.net.wifi.WifiInfo; -import com.isupatches.wisefy.base.TestActivity; -import org.junit.Before; -import org.junit.Test; -import static com.isupatches.wisefy.base.TestUtils.TEST_SSID; -import static com.isupatches.wisefy.base.TestUtils.TEST_SSID2; -import static com.isupatches.wisefy.base.TestUtils.TEST_TYPE1; -import static com.isupatches.wisefy.base.TestUtils.TEST_TYPE2; -import static junit.framework.Assert.assertFalse; -import static junit.framework.Assert.assertTrue; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; - - -public class WiseFyConnectionTests extends BaseTestClass { - - public WiseFyConnectionTests() { - super(TestActivity.class); - } - - @Before - public void setUp() { - super.setUp(); - WiseFyConnection.getInstance().mWiseFyPrerequisites.setWifiManager(mMockWiFiManager); - WiseFyConnection.getInstance().mWiseFyPrerequisites.setConnectivityManager(mMockConnectivityManager); - } - - /* - * isCurrentNetworkConnectedToSSID tests - */ - - @Test - public void isCurrentNetworkConnectedToSSID_failure_nullSSIDParam() { - assertFalse(WiseFyConnection.getInstance().isCurrentNetworkConnectedToSSID(null)); - } - - @Test - public void isCurrentNetworkConnectedToSSID_failure_nullConnectionInfo() { - when(mMockWiFiManager.getConnectionInfo()).thenReturn(null); - assertFalse(WiseFyConnection.getInstance().isCurrentNetworkConnectedToSSID(TEST_SSID)); - } - - @Test - public void isCurrentNetworkConnectedToSSID_failure_nullSSID() { - WifiInfo currentNetwork = mock(WifiInfo.class); - when(currentNetwork.getSSID()).thenReturn(null); - when(mMockWiFiManager.getConnectionInfo()).thenReturn(currentNetwork); - assertFalse(WiseFyConnection.getInstance().isCurrentNetworkConnectedToSSID(null)); - } - - @Test - public void isCurrentNetworkConnectedToSSID_failure_differentSSID() { - WifiInfo currentNetwork = mock(WifiInfo.class); - when(currentNetwork.getSSID()).thenReturn(TEST_SSID2); - when(mMockWiFiManager.getConnectionInfo()).thenReturn(currentNetwork); - assertFalse(WiseFyConnection.getInstance().isCurrentNetworkConnectedToSSID(TEST_SSID)); - } - - @Test - public void isCurrentNetworkConnectedToSSID_failure_notAvailable() { - WifiInfo currentNetwork = mock(WifiInfo.class); - when(currentNetwork.getSSID()).thenReturn(TEST_SSID); - when(mMockWiFiManager.getConnectionInfo()).thenReturn(currentNetwork); - - NetworkInfo networkInfo = mock(NetworkInfo.class); - when(networkInfo.isAvailable()).thenReturn(false); - when(networkInfo.isConnected()).thenReturn(true); - when(mMockConnectivityManager.getActiveNetworkInfo()).thenReturn(networkInfo); - - assertFalse(WiseFyConnection.getInstance().isCurrentNetworkConnectedToSSID(TEST_SSID)); - } - - @Test - public void isCurrentNetworkConnectedToSSID_failure_notAvailableOrConnected() { - WifiInfo currentNetwork = mock(WifiInfo.class); - when(currentNetwork.getSSID()).thenReturn(TEST_SSID); - when(mMockWiFiManager.getConnectionInfo()).thenReturn(currentNetwork); - - NetworkInfo networkInfo = mock(NetworkInfo.class); - when(networkInfo.isAvailable()).thenReturn(false); - when(networkInfo.isConnected()).thenReturn(false); - when(mMockConnectivityManager.getActiveNetworkInfo()).thenReturn(networkInfo); - - assertFalse(WiseFyConnection.getInstance().isCurrentNetworkConnectedToSSID(TEST_SSID)); - } - - @Test - public void isCurrentNetworkConnectedToSSID_failure_notConnected() { - WifiInfo currentNetwork = mock(WifiInfo.class); - when(currentNetwork.getSSID()).thenReturn(TEST_SSID); - when(mMockWiFiManager.getConnectionInfo()).thenReturn(currentNetwork); - - NetworkInfo networkInfo = mock(NetworkInfo.class); - when(networkInfo.isAvailable()).thenReturn(true); - when(networkInfo.isConnected()).thenReturn(false); - when(mMockConnectivityManager.getActiveNetworkInfo()).thenReturn(networkInfo); - - assertFalse(WiseFyConnection.getInstance().isCurrentNetworkConnectedToSSID(TEST_SSID)); - } - - @Test - public void isCurrentNetworkConnectedToSSID_success() { - WifiInfo currentNetwork = mock(WifiInfo.class); - when(currentNetwork.getSSID()).thenReturn(TEST_SSID); - when(mMockWiFiManager.getConnectionInfo()).thenReturn(currentNetwork); - - NetworkInfo networkInfo = mock(NetworkInfo.class); - when(networkInfo.isAvailable()).thenReturn(true); - when(networkInfo.isConnected()).thenReturn(true); - when(mMockConnectivityManager.getActiveNetworkInfo()).thenReturn(networkInfo); - - assertTrue(WiseFyConnection.getInstance().isCurrentNetworkConnectedToSSID(TEST_SSID)); - } - - /* - * isNetworkConnected tests - */ - - @Test - public void isNetworkConnected_failure_nullNetworkInfoParam() { - NetworkInfo networkInfo = mock(NetworkInfo.class); - when(networkInfo.isAvailable()).thenReturn(false); - when(networkInfo.isConnected()).thenReturn(true); - when(mMockConnectivityManager.getActiveNetworkInfo()).thenReturn(networkInfo); - - assertFalse(WiseFyConnection.getInstance().isNetworkConnected(null)); - } - - @Test - public void isNetworkConnected_failure_notAvailable() { - NetworkInfo networkInfo = mock(NetworkInfo.class); - when(networkInfo.isAvailable()).thenReturn(false); - when(networkInfo.isConnected()).thenReturn(true); - when(mMockConnectivityManager.getActiveNetworkInfo()).thenReturn(networkInfo); - - assertFalse(WiseFyConnection.getInstance().isNetworkConnected(networkInfo)); - } - - @Test - public void isNetworkConnected_failure_notAvailableOrConnected() { - NetworkInfo networkInfo = mock(NetworkInfo.class); - when(networkInfo.isAvailable()).thenReturn(false); - when(networkInfo.isConnected()).thenReturn(false); - when(mMockConnectivityManager.getActiveNetworkInfo()).thenReturn(networkInfo); - - assertFalse(WiseFyConnection.getInstance().isNetworkConnected(networkInfo)); - } - - @Test - public void isNetworkConnected_failure_notConnected() { - NetworkInfo networkInfo = mock(NetworkInfo.class); - when(networkInfo.isAvailable()).thenReturn(true); - when(networkInfo.isConnected()).thenReturn(false); - when(mMockConnectivityManager.getActiveNetworkInfo()).thenReturn(networkInfo); - - assertFalse(WiseFyConnection.getInstance().isNetworkConnected(networkInfo)); - } - - @Test - public void isNetworkConnected_success() { - NetworkInfo networkInfo = mock(NetworkInfo.class); - when(networkInfo.isAvailable()).thenReturn(true); - when(networkInfo.isConnected()).thenReturn(true); - when(mMockConnectivityManager.getActiveNetworkInfo()).thenReturn(networkInfo); - - assertTrue(WiseFyConnection.getInstance().isNetworkConnected(networkInfo)); - } - - /* - * isNetworkConnectedAndMatchesType tests - */ - - @Test - public void isNetworkConnectedAndMatchesType_failure_nullNetworkInfoParam() { - WifiInfo currentNetwork = mock(WifiInfo.class); - when(currentNetwork.getSSID()).thenReturn(TEST_SSID); - when(mMockWiFiManager.getConnectionInfo()).thenReturn(currentNetwork); - - NetworkInfo networkInfo = mock(NetworkInfo.class); - when(networkInfo.isAvailable()).thenReturn(false); - when(networkInfo.isConnected()).thenReturn(true); - when(mMockConnectivityManager.getActiveNetworkInfo()).thenReturn(networkInfo); - - assertFalse(WiseFyConnection.getInstance().isNetworkConnectedAndMatchesType(null, TEST_TYPE1)); - } - - @Test - public void isNetworkConnectedAndMatchesType_failure_notAvailable() { - WifiInfo currentNetwork = mock(WifiInfo.class); - when(currentNetwork.getSSID()).thenReturn(TEST_SSID); - when(mMockWiFiManager.getConnectionInfo()).thenReturn(currentNetwork); - - NetworkInfo networkInfo = mock(NetworkInfo.class); - when(networkInfo.isAvailable()).thenReturn(false); - when(networkInfo.isConnected()).thenReturn(true); - when(mMockConnectivityManager.getActiveNetworkInfo()).thenReturn(networkInfo); - - assertFalse(WiseFyConnection.getInstance().isNetworkConnectedAndMatchesType(networkInfo, TEST_TYPE1)); - } - - @Test - public void isNetworkConnectedAndMatchesType_failure_notAvailableOrConnected() { - WifiInfo currentNetwork = mock(WifiInfo.class); - when(currentNetwork.getSSID()).thenReturn(TEST_SSID); - when(mMockWiFiManager.getConnectionInfo()).thenReturn(currentNetwork); - - NetworkInfo networkInfo = mock(NetworkInfo.class); - when(networkInfo.isAvailable()).thenReturn(false); - when(networkInfo.isConnected()).thenReturn(false); - when(mMockConnectivityManager.getActiveNetworkInfo()).thenReturn(networkInfo); - - assertFalse(WiseFyConnection.getInstance().isNetworkConnectedAndMatchesType(networkInfo, TEST_TYPE1)); - } - - @Test - public void isNetworkConnectedAndMatchesType_failure_notConnected() { - WifiInfo currentNetwork = mock(WifiInfo.class); - when(currentNetwork.getSSID()).thenReturn(TEST_SSID); - when(mMockWiFiManager.getConnectionInfo()).thenReturn(currentNetwork); - - NetworkInfo networkInfo = mock(NetworkInfo.class); - when(networkInfo.isAvailable()).thenReturn(true); - when(networkInfo.isConnected()).thenReturn(false); - when(mMockConnectivityManager.getActiveNetworkInfo()).thenReturn(networkInfo); - - assertFalse(WiseFyConnection.getInstance().isNetworkConnectedAndMatchesType(networkInfo, TEST_TYPE1)); - } - - @Test - public void isNetworkConnectedAndMatchesType_failure_nullTypeName() { - WifiInfo currentNetwork = mock(WifiInfo.class); - when(currentNetwork.getSSID()).thenReturn(TEST_SSID); - when(mMockWiFiManager.getConnectionInfo()).thenReturn(currentNetwork); - - NetworkInfo networkInfo = mock(NetworkInfo.class); - when(networkInfo.isAvailable()).thenReturn(true); - when(networkInfo.isConnected()).thenReturn(true); - when(networkInfo.getTypeName()).thenReturn(null); - when(mMockConnectivityManager.getActiveNetworkInfo()).thenReturn(networkInfo); - - assertFalse(WiseFyConnection.getInstance().isNetworkConnectedAndMatchesType(networkInfo, TEST_TYPE1)); - } - - @Test - public void isNetworkConnectedAndMatchesType_failure_differentTypeName() { - WifiInfo currentNetwork = mock(WifiInfo.class); - when(currentNetwork.getSSID()).thenReturn(TEST_SSID); - when(mMockWiFiManager.getConnectionInfo()).thenReturn(currentNetwork); - - NetworkInfo networkInfo = mock(NetworkInfo.class); - when(networkInfo.isAvailable()).thenReturn(true); - when(networkInfo.isConnected()).thenReturn(true); - when(networkInfo.getTypeName()).thenReturn(TEST_TYPE2); - when(mMockConnectivityManager.getActiveNetworkInfo()).thenReturn(networkInfo); - - assertFalse(WiseFyConnection.getInstance().isNetworkConnectedAndMatchesType(networkInfo, TEST_TYPE1)); - } - - @Test - public void isNetworkConnectedAndMatchesType_success() { - WifiInfo currentNetwork = mock(WifiInfo.class); - when(currentNetwork.getSSID()).thenReturn(TEST_SSID); - when(mMockWiFiManager.getConnectionInfo()).thenReturn(currentNetwork); - - NetworkInfo networkInfo = mock(NetworkInfo.class); - when(networkInfo.isAvailable()).thenReturn(true); - when(networkInfo.isConnected()).thenReturn(true); - when(networkInfo.getTypeName()).thenReturn(TEST_TYPE1); - when(mMockConnectivityManager.getActiveNetworkInfo()).thenReturn(networkInfo); - - assertTrue(WiseFyConnection.getInstance().isNetworkConnectedAndMatchesType(networkInfo, TEST_TYPE1)); - } - - /* - * waitToConnectToSSID tests - */ - - @Test - public void waitToConnectToSSID_failure_nullSSIDParam() { - assertFalse(WiseFyConnection.getInstance().waitToConnectToSSID(null, 1000)); - } - - @Test - public void waitToConnectToSSID_failure_nullConnectionInfo() { - when(mMockWiFiManager.getConnectionInfo()).thenReturn(null); - assertFalse(WiseFyConnection.getInstance().waitToConnectToSSID(TEST_SSID, 1000)); - } - - @Test - public void waitToConnectToSSID_failure_nullSSID() { - WifiInfo currentNetwork = mock(WifiInfo.class); - when(currentNetwork.getSSID()).thenReturn(null); - when(mMockWiFiManager.getConnectionInfo()).thenReturn(currentNetwork); - assertFalse(WiseFyConnection.getInstance().waitToConnectToSSID(null, 1000)); - } - - @Test - public void waitToConnectToSSID_failure_differentSSID() { - WifiInfo currentNetwork = mock(WifiInfo.class); - when(currentNetwork.getSSID()).thenReturn(TEST_SSID2); - when(mMockWiFiManager.getConnectionInfo()).thenReturn(currentNetwork); - assertFalse(WiseFyConnection.getInstance().waitToConnectToSSID(TEST_SSID, 1000)); - } - - @Test - public void waitToConnectToSSID_failure_notAvailable() { - WifiInfo currentNetwork = mock(WifiInfo.class); - when(currentNetwork.getSSID()).thenReturn(TEST_SSID); - when(mMockWiFiManager.getConnectionInfo()).thenReturn(currentNetwork); - - NetworkInfo networkInfo = mock(NetworkInfo.class); - when(networkInfo.isAvailable()).thenReturn(false); - when(networkInfo.isConnected()).thenReturn(true); - when(mMockConnectivityManager.getActiveNetworkInfo()).thenReturn(networkInfo); - - assertFalse(WiseFyConnection.getInstance().waitToConnectToSSID(TEST_SSID, 1000)); - } - - @Test - public void waitToConnectToSSID_failure_notAvailableOrConnected() { - WifiInfo currentNetwork = mock(WifiInfo.class); - when(currentNetwork.getSSID()).thenReturn(TEST_SSID); - when(mMockWiFiManager.getConnectionInfo()).thenReturn(currentNetwork); - - NetworkInfo networkInfo = mock(NetworkInfo.class); - when(networkInfo.isAvailable()).thenReturn(false); - when(networkInfo.isConnected()).thenReturn(false); - when(mMockConnectivityManager.getActiveNetworkInfo()).thenReturn(networkInfo); - - assertFalse(WiseFyConnection.getInstance().waitToConnectToSSID(TEST_SSID, 1000)); - } - - @Test - public void waitToConnectToSSID_failure_notConnected() { - WifiInfo currentNetwork = mock(WifiInfo.class); - when(currentNetwork.getSSID()).thenReturn(TEST_SSID); - when(mMockWiFiManager.getConnectionInfo()).thenReturn(currentNetwork); - - NetworkInfo networkInfo = mock(NetworkInfo.class); - when(networkInfo.isAvailable()).thenReturn(true); - when(networkInfo.isConnected()).thenReturn(false); - when(mMockConnectivityManager.getActiveNetworkInfo()).thenReturn(networkInfo); - - assertFalse(WiseFyConnection.getInstance().waitToConnectToSSID(TEST_SSID, 1000)); - } - - @Test - public void waitToConnectToSSID_success() { - WifiInfo currentNetwork = mock(WifiInfo.class); - when(currentNetwork.getSSID()).thenReturn(TEST_SSID); - when(mMockWiFiManager.getConnectionInfo()).thenReturn(currentNetwork); - - NetworkInfo networkInfo = mock(NetworkInfo.class); - when(networkInfo.isAvailable()).thenReturn(true); - when(networkInfo.isConnected()).thenReturn(true); - when(mMockConnectivityManager.getActiveNetworkInfo()).thenReturn(networkInfo); - - assertTrue(WiseFyConnection.getInstance().waitToConnectToSSID(TEST_SSID, 1000)); - } -} +//package com.isupatches.wisefy; +// +// +//import android.net.NetworkInfo; +//import android.net.wifi.WifiInfo; +//import com.isupatches.wisefy.base.TestActivity; +//import org.junit.Before; +//import org.junit.Test; +//import static com.isupatches.wisefy.base.TestUtils.TEST_SSID; +//import static com.isupatches.wisefy.base.TestUtils.TEST_SSID2; +//import static com.isupatches.wisefy.base.TestUtils.TEST_TYPE1; +//import static com.isupatches.wisefy.base.TestUtils.TEST_TYPE2; +//import static junit.framework.Assert.assertFalse; +//import static junit.framework.Assert.assertTrue; +//import static org.mockito.Mockito.mock; +//import static org.mockito.Mockito.when; +// +// +//public class WiseFyConnectionTests extends BaseTestClass { +// +// public WiseFyConnectionTests() { +// super(TestActivity.class); +// } +// +// @Before +// public void setUp() { +// super.setUp(); +// WiseFyConnection.getInstance().mWiseFyPrerequisites.setWifiManager(mMockWiFiManager); +// WiseFyConnection.getInstance().mWiseFyPrerequisites.setConnectivityManager(mMockConnectivityManager); +// } +// +// /* +// * isCurrentNetworkConnectedToSSID tests +// */ +// +// @Test +// public void isCurrentNetworkConnectedToSSID_failure_nullSSIDParam() { +// assertFalse(WiseFyConnection.getInstance().isCurrentNetworkConnectedToSSID(null)); +// } +// +// @Test +// public void isCurrentNetworkConnectedToSSID_failure_nullConnectionInfo() { +// when(mMockWiFiManager.getConnectionInfo()).thenReturn(null); +// assertFalse(WiseFyConnection.getInstance().isCurrentNetworkConnectedToSSID(TEST_SSID)); +// } +// +// @Test +// public void isCurrentNetworkConnectedToSSID_failure_nullSSID() { +// WifiInfo currentNetwork = mock(WifiInfo.class); +// when(currentNetwork.getSSID()).thenReturn(null); +// when(mMockWiFiManager.getConnectionInfo()).thenReturn(currentNetwork); +// assertFalse(WiseFyConnection.getInstance().isCurrentNetworkConnectedToSSID(null)); +// } +// +// @Test +// public void isCurrentNetworkConnectedToSSID_failure_differentSSID() { +// WifiInfo currentNetwork = mock(WifiInfo.class); +// when(currentNetwork.getSSID()).thenReturn(TEST_SSID2); +// when(mMockWiFiManager.getConnectionInfo()).thenReturn(currentNetwork); +// assertFalse(WiseFyConnection.getInstance().isCurrentNetworkConnectedToSSID(TEST_SSID)); +// } +// +// @Test +// public void isCurrentNetworkConnectedToSSID_failure_notAvailable() { +// WifiInfo currentNetwork = mock(WifiInfo.class); +// when(currentNetwork.getSSID()).thenReturn(TEST_SSID); +// when(mMockWiFiManager.getConnectionInfo()).thenReturn(currentNetwork); +// +// NetworkInfo networkInfo = mock(NetworkInfo.class); +// when(networkInfo.isAvailable()).thenReturn(false); +// when(networkInfo.isConnected()).thenReturn(true); +// when(mMockConnectivityManager.getActiveNetworkInfo()).thenReturn(networkInfo); +// +// assertFalse(WiseFyConnection.getInstance().isCurrentNetworkConnectedToSSID(TEST_SSID)); +// } +// +// @Test +// public void isCurrentNetworkConnectedToSSID_failure_notAvailableOrConnected() { +// WifiInfo currentNetwork = mock(WifiInfo.class); +// when(currentNetwork.getSSID()).thenReturn(TEST_SSID); +// when(mMockWiFiManager.getConnectionInfo()).thenReturn(currentNetwork); +// +// NetworkInfo networkInfo = mock(NetworkInfo.class); +// when(networkInfo.isAvailable()).thenReturn(false); +// when(networkInfo.isConnected()).thenReturn(false); +// when(mMockConnectivityManager.getActiveNetworkInfo()).thenReturn(networkInfo); +// +// assertFalse(WiseFyConnection.getInstance().isCurrentNetworkConnectedToSSID(TEST_SSID)); +// } +// +// @Test +// public void isCurrentNetworkConnectedToSSID_failure_notConnected() { +// WifiInfo currentNetwork = mock(WifiInfo.class); +// when(currentNetwork.getSSID()).thenReturn(TEST_SSID); +// when(mMockWiFiManager.getConnectionInfo()).thenReturn(currentNetwork); +// +// NetworkInfo networkInfo = mock(NetworkInfo.class); +// when(networkInfo.isAvailable()).thenReturn(true); +// when(networkInfo.isConnected()).thenReturn(false); +// when(mMockConnectivityManager.getActiveNetworkInfo()).thenReturn(networkInfo); +// +// assertFalse(WiseFyConnection.getInstance().isCurrentNetworkConnectedToSSID(TEST_SSID)); +// } +// +// @Test +// public void isCurrentNetworkConnectedToSSID_success() { +// WifiInfo currentNetwork = mock(WifiInfo.class); +// when(currentNetwork.getSSID()).thenReturn(TEST_SSID); +// when(mMockWiFiManager.getConnectionInfo()).thenReturn(currentNetwork); +// +// NetworkInfo networkInfo = mock(NetworkInfo.class); +// when(networkInfo.isAvailable()).thenReturn(true); +// when(networkInfo.isConnected()).thenReturn(true); +// when(mMockConnectivityManager.getActiveNetworkInfo()).thenReturn(networkInfo); +// +// assertTrue(WiseFyConnection.getInstance().isCurrentNetworkConnectedToSSID(TEST_SSID)); +// } +// +// /* +// * isNetworkConnected tests +// */ +// +// @Test +// public void isNetworkConnected_failure_nullNetworkInfoParam() { +// NetworkInfo networkInfo = mock(NetworkInfo.class); +// when(networkInfo.isAvailable()).thenReturn(false); +// when(networkInfo.isConnected()).thenReturn(true); +// when(mMockConnectivityManager.getActiveNetworkInfo()).thenReturn(networkInfo); +// +// assertFalse(WiseFyConnection.getInstance().isNetworkConnected(null)); +// } +// +// @Test +// public void isNetworkConnected_failure_notAvailable() { +// NetworkInfo networkInfo = mock(NetworkInfo.class); +// when(networkInfo.isAvailable()).thenReturn(false); +// when(networkInfo.isConnected()).thenReturn(true); +// when(mMockConnectivityManager.getActiveNetworkInfo()).thenReturn(networkInfo); +// +// assertFalse(WiseFyConnection.getInstance().isNetworkConnected(networkInfo)); +// } +// +// @Test +// public void isNetworkConnected_failure_notAvailableOrConnected() { +// NetworkInfo networkInfo = mock(NetworkInfo.class); +// when(networkInfo.isAvailable()).thenReturn(false); +// when(networkInfo.isConnected()).thenReturn(false); +// when(mMockConnectivityManager.getActiveNetworkInfo()).thenReturn(networkInfo); +// +// assertFalse(WiseFyConnection.getInstance().isNetworkConnected(networkInfo)); +// } +// +// @Test +// public void isNetworkConnected_failure_notConnected() { +// NetworkInfo networkInfo = mock(NetworkInfo.class); +// when(networkInfo.isAvailable()).thenReturn(true); +// when(networkInfo.isConnected()).thenReturn(false); +// when(mMockConnectivityManager.getActiveNetworkInfo()).thenReturn(networkInfo); +// +// assertFalse(WiseFyConnection.getInstance().isNetworkConnected(networkInfo)); +// } +// +// @Test +// public void isNetworkConnected_success() { +// NetworkInfo networkInfo = mock(NetworkInfo.class); +// when(networkInfo.isAvailable()).thenReturn(true); +// when(networkInfo.isConnected()).thenReturn(true); +// when(mMockConnectivityManager.getActiveNetworkInfo()).thenReturn(networkInfo); +// +// assertTrue(WiseFyConnection.getInstance().isNetworkConnected(networkInfo)); +// } +// +// /* +// * isNetworkConnectedAndMatchesType tests +// */ +// +// @Test +// public void isNetworkConnectedAndMatchesType_failure_nullNetworkInfoParam() { +// WifiInfo currentNetwork = mock(WifiInfo.class); +// when(currentNetwork.getSSID()).thenReturn(TEST_SSID); +// when(mMockWiFiManager.getConnectionInfo()).thenReturn(currentNetwork); +// +// NetworkInfo networkInfo = mock(NetworkInfo.class); +// when(networkInfo.isAvailable()).thenReturn(false); +// when(networkInfo.isConnected()).thenReturn(true); +// when(mMockConnectivityManager.getActiveNetworkInfo()).thenReturn(networkInfo); +// +// assertFalse(WiseFyConnection.getInstance().isNetworkConnectedAndMatchesType(null, TEST_TYPE1)); +// } +// +// @Test +// public void isNetworkConnectedAndMatchesType_failure_notAvailable() { +// WifiInfo currentNetwork = mock(WifiInfo.class); +// when(currentNetwork.getSSID()).thenReturn(TEST_SSID); +// when(mMockWiFiManager.getConnectionInfo()).thenReturn(currentNetwork); +// +// NetworkInfo networkInfo = mock(NetworkInfo.class); +// when(networkInfo.isAvailable()).thenReturn(false); +// when(networkInfo.isConnected()).thenReturn(true); +// when(mMockConnectivityManager.getActiveNetworkInfo()).thenReturn(networkInfo); +// +// assertFalse(WiseFyConnection.getInstance().isNetworkConnectedAndMatchesType(networkInfo, TEST_TYPE1)); +// } +// +// @Test +// public void isNetworkConnectedAndMatchesType_failure_notAvailableOrConnected() { +// WifiInfo currentNetwork = mock(WifiInfo.class); +// when(currentNetwork.getSSID()).thenReturn(TEST_SSID); +// when(mMockWiFiManager.getConnectionInfo()).thenReturn(currentNetwork); +// +// NetworkInfo networkInfo = mock(NetworkInfo.class); +// when(networkInfo.isAvailable()).thenReturn(false); +// when(networkInfo.isConnected()).thenReturn(false); +// when(mMockConnectivityManager.getActiveNetworkInfo()).thenReturn(networkInfo); +// +// assertFalse(WiseFyConnection.getInstance().isNetworkConnectedAndMatchesType(networkInfo, TEST_TYPE1)); +// } +// +// @Test +// public void isNetworkConnectedAndMatchesType_failure_notConnected() { +// WifiInfo currentNetwork = mock(WifiInfo.class); +// when(currentNetwork.getSSID()).thenReturn(TEST_SSID); +// when(mMockWiFiManager.getConnectionInfo()).thenReturn(currentNetwork); +// +// NetworkInfo networkInfo = mock(NetworkInfo.class); +// when(networkInfo.isAvailable()).thenReturn(true); +// when(networkInfo.isConnected()).thenReturn(false); +// when(mMockConnectivityManager.getActiveNetworkInfo()).thenReturn(networkInfo); +// +// assertFalse(WiseFyConnection.getInstance().isNetworkConnectedAndMatchesType(networkInfo, TEST_TYPE1)); +// } +// +// @Test +// public void isNetworkConnectedAndMatchesType_failure_nullTypeName() { +// WifiInfo currentNetwork = mock(WifiInfo.class); +// when(currentNetwork.getSSID()).thenReturn(TEST_SSID); +// when(mMockWiFiManager.getConnectionInfo()).thenReturn(currentNetwork); +// +// NetworkInfo networkInfo = mock(NetworkInfo.class); +// when(networkInfo.isAvailable()).thenReturn(true); +// when(networkInfo.isConnected()).thenReturn(true); +// when(networkInfo.getTypeName()).thenReturn(null); +// when(mMockConnectivityManager.getActiveNetworkInfo()).thenReturn(networkInfo); +// +// assertFalse(WiseFyConnection.getInstance().isNetworkConnectedAndMatchesType(networkInfo, TEST_TYPE1)); +// } +// +// @Test +// public void isNetworkConnectedAndMatchesType_failure_differentTypeName() { +// WifiInfo currentNetwork = mock(WifiInfo.class); +// when(currentNetwork.getSSID()).thenReturn(TEST_SSID); +// when(mMockWiFiManager.getConnectionInfo()).thenReturn(currentNetwork); +// +// NetworkInfo networkInfo = mock(NetworkInfo.class); +// when(networkInfo.isAvailable()).thenReturn(true); +// when(networkInfo.isConnected()).thenReturn(true); +// when(networkInfo.getTypeName()).thenReturn(TEST_TYPE2); +// when(mMockConnectivityManager.getActiveNetworkInfo()).thenReturn(networkInfo); +// +// assertFalse(WiseFyConnection.getInstance().isNetworkConnectedAndMatchesType(networkInfo, TEST_TYPE1)); +// } +// +// @Test +// public void isNetworkConnectedAndMatchesType_success() { +// WifiInfo currentNetwork = mock(WifiInfo.class); +// when(currentNetwork.getSSID()).thenReturn(TEST_SSID); +// when(mMockWiFiManager.getConnectionInfo()).thenReturn(currentNetwork); +// +// NetworkInfo networkInfo = mock(NetworkInfo.class); +// when(networkInfo.isAvailable()).thenReturn(true); +// when(networkInfo.isConnected()).thenReturn(true); +// when(networkInfo.getTypeName()).thenReturn(TEST_TYPE1); +// when(mMockConnectivityManager.getActiveNetworkInfo()).thenReturn(networkInfo); +// +// assertTrue(WiseFyConnection.getInstance().isNetworkConnectedAndMatchesType(networkInfo, TEST_TYPE1)); +// } +// +// /* +// * waitToConnectToSSID tests +// */ +// +// @Test +// public void waitToConnectToSSID_failure_nullSSIDParam() { +// assertFalse(WiseFyConnection.getInstance().waitToConnectToSSID(null, 1000)); +// } +// +// @Test +// public void waitToConnectToSSID_failure_nullConnectionInfo() { +// when(mMockWiFiManager.getConnectionInfo()).thenReturn(null); +// assertFalse(WiseFyConnection.getInstance().waitToConnectToSSID(TEST_SSID, 1000)); +// } +// +// @Test +// public void waitToConnectToSSID_failure_nullSSID() { +// WifiInfo currentNetwork = mock(WifiInfo.class); +// when(currentNetwork.getSSID()).thenReturn(null); +// when(mMockWiFiManager.getConnectionInfo()).thenReturn(currentNetwork); +// assertFalse(WiseFyConnection.getInstance().waitToConnectToSSID(null, 1000)); +// } +// +// @Test +// public void waitToConnectToSSID_failure_differentSSID() { +// WifiInfo currentNetwork = mock(WifiInfo.class); +// when(currentNetwork.getSSID()).thenReturn(TEST_SSID2); +// when(mMockWiFiManager.getConnectionInfo()).thenReturn(currentNetwork); +// assertFalse(WiseFyConnection.getInstance().waitToConnectToSSID(TEST_SSID, 1000)); +// } +// +// @Test +// public void waitToConnectToSSID_failure_notAvailable() { +// WifiInfo currentNetwork = mock(WifiInfo.class); +// when(currentNetwork.getSSID()).thenReturn(TEST_SSID); +// when(mMockWiFiManager.getConnectionInfo()).thenReturn(currentNetwork); +// +// NetworkInfo networkInfo = mock(NetworkInfo.class); +// when(networkInfo.isAvailable()).thenReturn(false); +// when(networkInfo.isConnected()).thenReturn(true); +// when(mMockConnectivityManager.getActiveNetworkInfo()).thenReturn(networkInfo); +// +// assertFalse(WiseFyConnection.getInstance().waitToConnectToSSID(TEST_SSID, 1000)); +// } +// +// @Test +// public void waitToConnectToSSID_failure_notAvailableOrConnected() { +// WifiInfo currentNetwork = mock(WifiInfo.class); +// when(currentNetwork.getSSID()).thenReturn(TEST_SSID); +// when(mMockWiFiManager.getConnectionInfo()).thenReturn(currentNetwork); +// +// NetworkInfo networkInfo = mock(NetworkInfo.class); +// when(networkInfo.isAvailable()).thenReturn(false); +// when(networkInfo.isConnected()).thenReturn(false); +// when(mMockConnectivityManager.getActiveNetworkInfo()).thenReturn(networkInfo); +// +// assertFalse(WiseFyConnection.getInstance().waitToConnectToSSID(TEST_SSID, 1000)); +// } +// +// @Test +// public void waitToConnectToSSID_failure_notConnected() { +// WifiInfo currentNetwork = mock(WifiInfo.class); +// when(currentNetwork.getSSID()).thenReturn(TEST_SSID); +// when(mMockWiFiManager.getConnectionInfo()).thenReturn(currentNetwork); +// +// NetworkInfo networkInfo = mock(NetworkInfo.class); +// when(networkInfo.isAvailable()).thenReturn(true); +// when(networkInfo.isConnected()).thenReturn(false); +// when(mMockConnectivityManager.getActiveNetworkInfo()).thenReturn(networkInfo); +// +// assertFalse(WiseFyConnection.getInstance().waitToConnectToSSID(TEST_SSID, 1000)); +// } +// +// @Test +// public void waitToConnectToSSID_success() { +// WifiInfo currentNetwork = mock(WifiInfo.class); +// when(currentNetwork.getSSID()).thenReturn(TEST_SSID); +// when(mMockWiFiManager.getConnectionInfo()).thenReturn(currentNetwork); +// +// NetworkInfo networkInfo = mock(NetworkInfo.class); +// when(networkInfo.isAvailable()).thenReturn(true); +// when(networkInfo.isConnected()).thenReturn(true); +// when(mMockConnectivityManager.getActiveNetworkInfo()).thenReturn(networkInfo); +// +// assertTrue(WiseFyConnection.getInstance().waitToConnectToSSID(TEST_SSID, 1000)); +// } +//} diff --git a/wisefy/src/androidTest/java/com/isupatches/wisefy/WiseFyPrerequisitesTests.java b/wisefy/src/androidTest/java/com/isupatches/wisefy/WiseFyPrerequisitesTests.java index aa94e8bc..4aebf88f 100644 --- a/wisefy/src/androidTest/java/com/isupatches/wisefy/WiseFyPrerequisitesTests.java +++ b/wisefy/src/androidTest/java/com/isupatches/wisefy/WiseFyPrerequisitesTests.java @@ -1,54 +1,54 @@ -package com.isupatches.wisefy; - - -import com.isupatches.wisefy.base.TestActivity; -import org.junit.Test; -import static junit.framework.Assert.*; - - -public class WiseFyPrerequisitesTests extends BaseTestClass { - - public WiseFyPrerequisitesTests() { - super(TestActivity.class); - } - - @Test - public void hasPrerequisites_nullWifiManager() { - WiseFyPrerequisites.getInstance().setConnectivityManager(mMockConnectivityManager); - WiseFyPrerequisites.getInstance().setWifiManager(null); - assertFalse(WiseFyPrerequisites.getInstance().hasPrerequisites()); - } - - @Test - public void hasPrerequisites_nullConnectivityManager() { - WiseFyPrerequisites.getInstance().setConnectivityManager(null); - WiseFyPrerequisites.getInstance().setWifiManager(mMockWiFiManager); - assertFalse(WiseFyPrerequisites.getInstance().hasPrerequisites()); - } - - @Test - public void hasPrerequisites_noManagers() { - WiseFyPrerequisites.getInstance().setConnectivityManager(null); - WiseFyPrerequisites.getInstance().setWifiManager(null); - assertFalse(WiseFyPrerequisites.getInstance().hasPrerequisites()); - } - - @Test - public void hasPrerequisites_bothManagers() { - WiseFyPrerequisites.getInstance().setConnectivityManager(mMockConnectivityManager); - WiseFyPrerequisites.getInstance().setWifiManager(mMockWiFiManager); - assertTrue(WiseFyPrerequisites.getInstance().hasPrerequisites()); - } - - @Test - public void connectivityManager_getterAndSetter() { - WiseFyPrerequisites.getInstance().setConnectivityManager(mMockConnectivityManager); - assertEquals(mMockConnectivityManager, WiseFyPrerequisites.getInstance().getConnectivityManager()); - } - - @Test - public void wifiManager_getterAndSetter() { - WiseFyPrerequisites.getInstance().setWifiManager(mMockWiFiManager); - assertEquals(mMockWiFiManager, WiseFyPrerequisites.getInstance().getWifiManager()); - } -} +//package com.isupatches.wisefy; +// +// +//import com.isupatches.wisefy.base.TestActivity; +//import org.junit.Test; +//import static junit.framework.Assert.*; +// +// +//public class WiseFyPrerequisitesTests extends BaseTestClass { +// +// public WiseFyPrerequisitesTests() { +// super(TestActivity.class); +// } +// +// @Test +// public void hasPrerequisites_nullWifiManager() { +// WiseFyPrerequisites.getInstance().setConnectivityManager(mMockConnectivityManager); +// WiseFyPrerequisites.getInstance().setWifiManager(null); +// assertFalse(WiseFyPrerequisites.getInstance().hasPrerequisites()); +// } +// +// @Test +// public void hasPrerequisites_nullConnectivityManager() { +// WiseFyPrerequisites.getInstance().setConnectivityManager(null); +// WiseFyPrerequisites.getInstance().setWifiManager(mMockWiFiManager); +// assertFalse(WiseFyPrerequisites.getInstance().hasPrerequisites()); +// } +// +// @Test +// public void hasPrerequisites_noManagers() { +// WiseFyPrerequisites.getInstance().setConnectivityManager(null); +// WiseFyPrerequisites.getInstance().setWifiManager(null); +// assertFalse(WiseFyPrerequisites.getInstance().hasPrerequisites()); +// } +// +// @Test +// public void hasPrerequisites_bothManagers() { +// WiseFyPrerequisites.getInstance().setConnectivityManager(mMockConnectivityManager); +// WiseFyPrerequisites.getInstance().setWifiManager(mMockWiFiManager); +// assertTrue(WiseFyPrerequisites.getInstance().hasPrerequisites()); +// } +// +// @Test +// public void connectivityManager_getterAndSetter() { +// WiseFyPrerequisites.getInstance().setConnectivityManager(mMockConnectivityManager); +// assertEquals(mMockConnectivityManager, WiseFyPrerequisites.getInstance().getConnectivityManager()); +// } +// +// @Test +// public void wifiManager_getterAndSetter() { +// WiseFyPrerequisites.getInstance().setWifiManager(mMockWiFiManager); +// assertEquals(mMockWiFiManager, WiseFyPrerequisites.getInstance().getWifiManager()); +// } +//} diff --git a/wisefy/src/androidTest/java/com/isupatches/wisefy/WiseFySearchTests.java b/wisefy/src/androidTest/java/com/isupatches/wisefy/WiseFySearchTests.java index eb786da6..a452837c 100644 --- a/wisefy/src/androidTest/java/com/isupatches/wisefy/WiseFySearchTests.java +++ b/wisefy/src/androidTest/java/com/isupatches/wisefy/WiseFySearchTests.java @@ -1,860 +1,860 @@ -package com.isupatches.wisefy; - - -import android.net.wifi.ScanResult; -import android.net.wifi.WifiConfiguration; -import com.isupatches.wisefy.base.TestActivity; -import org.junit.Test; -import java.util.ArrayList; -import java.util.List; -import static com.isupatches.wisefy.base.TestUtils.TEST_SSID; -import static com.isupatches.wisefy.base.TestUtils.TEST_SSID2; -import static com.isupatches.wisefy.base.TestUtils.TEST_SSID3; -import static junit.framework.Assert.assertEquals; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; - - -public class WiseFySearchTests extends BaseTestClass { - - public WiseFySearchTests() { - super(TestActivity.class); - } - - /* - * findAccessPointByRegex tests - */ - - @Test - public void findAccessPointByRegex_failure_nullAccessPoints_takeHighest_false() { - when(mMockWiFiManager.getScanResults()).thenReturn(null); - assertEquals(null, mWiseFy.mWiseFySearch.findAccessPointByRegex(TEST_SSID, 1000, false)); - } - - @Test - public void findAccessPointByRegex_failure_nullAccessPoints_takeHighest_true() { - when(mMockWiFiManager.getScanResults()).thenReturn(null); - assertEquals(null, mWiseFy.mWiseFySearch.findAccessPointByRegex(TEST_SSID, 1000, true)); - } - - @Test - public void findAccessPointByRegex_failure_emptyAccessPointList_takeHighest_false() { - when(mMockWiFiManager.getScanResults()).thenReturn(new ArrayList()); - assertEquals(null, mWiseFy.mWiseFySearch.findAccessPointByRegex(TEST_SSID, 1000, false)); - } - - @Test - public void findAccessPointByRegex_failure_emptyAccessPointList_takeHighest_true() { - when(mMockWiFiManager.getScanResults()).thenReturn(new ArrayList()); - assertEquals(null, mWiseFy.mWiseFySearch.findAccessPointByRegex(TEST_SSID, 1000, true)); - } - - @Test - public void findAccessPointByRegex_failure_nullAccessPoint_takeHighest_false() { - List accessPoints = new ArrayList<>(); - accessPoints.add(null); - - when(mMockWiFiManager.getScanResults()).thenReturn(accessPoints); - assertEquals(null, mWiseFy.mWiseFySearch.findAccessPointByRegex(TEST_SSID, 1000, false)); - } - - @Test - public void findAccessPointByRegex_failure_nullAccessPoint_takeHighest_true() { - List accessPoints = new ArrayList<>(); - accessPoints.add(null); - - when(mMockWiFiManager.getScanResults()).thenReturn(accessPoints); - assertEquals(null, mWiseFy.mWiseFySearch.findAccessPointByRegex(TEST_SSID, 1000, true)); - } - - @Test - public void findAccessPointByRegex_failure_nullSSID_takeHighest_false() { - List accessPoints = new ArrayList<>(); - - ScanResult accessPoint= mock(ScanResult.class); - accessPoint.SSID = null; - accessPoints.add(accessPoint); - - when(mMockWiFiManager.getScanResults()).thenReturn(accessPoints); - assertEquals(null, mWiseFy.mWiseFySearch.findAccessPointByRegex(TEST_SSID, 1000, false)); - } - - @Test - public void findAccessPointByRegex_failure_nullSSID_takeHighest_true() { - List accessPoints = new ArrayList<>(); - - ScanResult accessPoint= mock(ScanResult.class); - accessPoint.SSID = null; - accessPoints.add(accessPoint); - - when(mMockWiFiManager.getScanResults()).thenReturn(accessPoints); - assertEquals(null, mWiseFy.mWiseFySearch.findAccessPointByRegex(TEST_SSID, 1000, true)); - } - - @Test - public void findAccessPointByRegex_failure_nonMatchingSSID_takeHighest_false() { - List accessPoints = new ArrayList<>(); - - ScanResult accessPoint= mock(ScanResult.class); - accessPoint.SSID = TEST_SSID2; - accessPoints.add(accessPoint); - - when(mMockWiFiManager.getScanResults()).thenReturn(accessPoints); - assertEquals(null, mWiseFy.mWiseFySearch.findAccessPointByRegex(TEST_SSID, 1000, false)); - } - - @Test - public void findAccessPointByRegex_failure_nonMatchingSSID_takeHighest_true() { - List accessPoints = new ArrayList<>(); - - ScanResult accessPoint= mock(ScanResult.class); - accessPoint.SSID = TEST_SSID2; - accessPoints.add(accessPoint); - - when(mMockWiFiManager.getScanResults()).thenReturn(accessPoints); - assertEquals(null, mWiseFy.mWiseFySearch.findAccessPointByRegex(TEST_SSID, 1000, true)); - } - - @Test - public void findAccessPointByRegex_failure_multipleNonMatchingSSIDs_takeHighest_false() { - List accessPoints = new ArrayList<>(); - - ScanResult accessPoint1 = mock(ScanResult.class); - accessPoint1.SSID = TEST_SSID2; - accessPoints.add(accessPoint1); - - ScanResult accessPoint2 = mock(ScanResult.class); - accessPoint2.SSID = TEST_SSID3; - accessPoints.add(accessPoint2); - - when(mMockWiFiManager.getScanResults()).thenReturn(accessPoints); - assertEquals(null, mWiseFy.mWiseFySearch.findAccessPointByRegex(TEST_SSID, 1000, false)); - } - - @Test - public void findAccessPointByRegex_failure_multipleNnonMatchingSSIDs_takeHighest_true() { - List accessPoints = new ArrayList<>(); - - ScanResult accessPoint1= mock(ScanResult.class); - accessPoint1.SSID = TEST_SSID2; - accessPoints.add(accessPoint1); - - ScanResult accessPoint2 = mock(ScanResult.class); - accessPoint2.SSID = TEST_SSID3; - accessPoints.add(accessPoint2); - - when(mMockWiFiManager.getScanResults()).thenReturn(accessPoints); - assertEquals(null, mWiseFy.mWiseFySearch.findAccessPointByRegex(TEST_SSID, 1000, true)); - } - - @Test - public void findAccessPointByRegex_success_takeHighest_false() { - List accessPoints = new ArrayList<>(); - - ScanResult accessPoint = mock(ScanResult.class); - accessPoint.SSID = TEST_SSID; - accessPoints.add(accessPoint); - - when(mMockWiFiManager.getScanResults()).thenReturn(accessPoints); - assertEquals(accessPoint, mWiseFy.mWiseFySearch.findAccessPointByRegex(TEST_SSID, 1000, false)); - } - - @Test - public void findAccessPointByRegex_success_takeHighest_true() { - List accessPoints = new ArrayList<>(); - - ScanResult accessPoint = mock(ScanResult.class); - accessPoint.SSID = TEST_SSID; - accessPoints.add(accessPoint); - - when(mMockWiFiManager.getScanResults()).thenReturn(accessPoints); - assertEquals(accessPoint, mWiseFy.mWiseFySearch.findAccessPointByRegex(TEST_SSID, 1000, true)); - } - - @Test - public void findAccessPointByRegex_success_multipleSSIDs_takeHighest_false() { - List accessPoints = new ArrayList<>(); - - ScanResult accessPoint1 = mock(ScanResult.class); - accessPoint1.SSID = TEST_SSID; - accessPoint1.level = -70; - accessPoints.add(accessPoint1); - - ScanResult accessPoint2 = mock(ScanResult.class); - accessPoint2.SSID = TEST_SSID2; - accessPoint2.level = -50; - accessPoints.add(accessPoint2); - - when(mMockWiFiManager.getScanResults()).thenReturn(accessPoints); - assertEquals(accessPoint1, mWiseFy.mWiseFySearch.findAccessPointByRegex(TEST_SSID, 1000, false)); - } - - @Test - public void findAccessPointByRegex_success_multipleSSIDs_takeHighest_true() { - List accessPoints = new ArrayList<>(); - - ScanResult accessPoint1 = mock(ScanResult.class); - accessPoint1.SSID = TEST_SSID; - accessPoint1.level = -70; - accessPoints.add(accessPoint1); - - ScanResult accessPoint2 = mock(ScanResult.class); - accessPoint2.SSID = TEST_SSID2; - accessPoint2.level = -50; - accessPoints.add(accessPoint2); - - when(mMockWiFiManager.getScanResults()).thenReturn(accessPoints); - assertEquals(accessPoint1, mWiseFy.mWiseFySearch.findAccessPointByRegex(TEST_SSID, 1000, true)); - } - - @Test - public void findAccessPointByRegex_success_multipleSameSSIDs_takeHighest_false() { - List accessPoints = new ArrayList<>(); - - ScanResult accessPoint1 = mock(ScanResult.class); - accessPoint1.SSID = TEST_SSID; - accessPoint1.level = -70; - accessPoints.add(accessPoint1); - - ScanResult accessPoint2 = mock(ScanResult.class); - accessPoint2.SSID = TEST_SSID; - accessPoint2.level = -50; - accessPoints.add(accessPoint2); - - when(mMockWiFiManager.getScanResults()).thenReturn(accessPoints); - assertEquals(accessPoint1, mWiseFy.mWiseFySearch.findAccessPointByRegex(TEST_SSID, 1000, false)); - } - - @Test - public void findAccessPointByRegex_success_multipleSameSSIDs_takeHighest_true() { - List accessPoints = new ArrayList<>(); - - ScanResult accessPoint1 = mock(ScanResult.class); - accessPoint1.SSID = TEST_SSID; - accessPoint1.level = -70; - accessPoints.add(accessPoint1); - - ScanResult accessPoint2 = mock(ScanResult.class); - accessPoint2.SSID = TEST_SSID; - accessPoint2.level = -50; - accessPoints.add(accessPoint2); - - when(mMockWiFiManager.getScanResults()).thenReturn(accessPoints); - assertEquals(accessPoint2, mWiseFy.mWiseFySearch.findAccessPointByRegex(TEST_SSID, 1000, true)); - } - - /* - * findAccessPointsMatchingRegex tests - */ - - @Test - public void findAccessPointsMatchingRegex_failure_nullAccessPoints_takeHighest_false() { - when(mMockWiFiManager.getScanResults()).thenReturn(null); - assertEquals(null, mWiseFy.mWiseFySearch.findAccessPointsMatchingRegex(TEST_SSID, false)); - } - - @Test - public void findAccessPointsMatchingRegex_failure_nullAccessPoints_takeHighest_true() { - when(mMockWiFiManager.getScanResults()).thenReturn(null); - assertEquals(null, mWiseFy.mWiseFySearch.findAccessPointsMatchingRegex(TEST_SSID, true)); - } - - @Test - public void findAccessPointsMatchingRegex_failure_emptyAccessPointList_takeHighest_false() { - when(mMockWiFiManager.getScanResults()).thenReturn(new ArrayList()); - assertEquals(null, mWiseFy.mWiseFySearch.findAccessPointsMatchingRegex(TEST_SSID, false)); - } - - @Test - public void findAccessPointsMatchingRegex_failure_emptyAccessPointList_takeHighest_true() { - when(mMockWiFiManager.getScanResults()).thenReturn(new ArrayList()); - assertEquals(null, mWiseFy.mWiseFySearch.findAccessPointsMatchingRegex(TEST_SSID, true)); - } - - @Test - public void findAccessPointsMatchingRegex_failure_nullAccessPoint_takeHighest_false() { - List accessPoints = new ArrayList<>(); - accessPoints.add(null); - - when(mMockWiFiManager.getScanResults()).thenReturn(accessPoints); - assertEquals(null, mWiseFy.mWiseFySearch.findAccessPointsMatchingRegex(TEST_SSID, false)); - } - - @Test - public void findAccessPointsMatchingRegex_failure_nullAccessPoint_takeHighest_true() { - List accessPoints = new ArrayList<>(); - accessPoints.add(null); - - when(mMockWiFiManager.getScanResults()).thenReturn(accessPoints); - assertEquals(null, mWiseFy.mWiseFySearch.findAccessPointsMatchingRegex(TEST_SSID, true)); - } - - @Test - public void findAccessPointsMatchingRegex_failure_nullSSID_takeHighest_false() { - List accessPoints = new ArrayList<>(); - - ScanResult accessPoint= mock(ScanResult.class); - accessPoint.SSID = null; - accessPoints.add(accessPoint); - - when(mMockWiFiManager.getScanResults()).thenReturn(accessPoints); - assertEquals(null, mWiseFy.mWiseFySearch.findAccessPointsMatchingRegex(TEST_SSID, false)); - } - - @Test - public void findAccessPointsMatchingRegex_failure_nullSSID_takeHighest_true() { - List accessPoints = new ArrayList<>(); - - ScanResult accessPoint= mock(ScanResult.class); - accessPoint.SSID = null; - accessPoints.add(accessPoint); - - when(mMockWiFiManager.getScanResults()).thenReturn(accessPoints); - assertEquals(null, mWiseFy.mWiseFySearch.findAccessPointsMatchingRegex(TEST_SSID, true)); - } - - @Test - public void findAccessPointsMatchingRegex_failure_nonMatchingSSID_takeHighest_false() { - List accessPoints = new ArrayList<>(); - - ScanResult accessPoint= mock(ScanResult.class); - accessPoint.SSID = TEST_SSID2; - accessPoints.add(accessPoint); - - when(mMockWiFiManager.getScanResults()).thenReturn(accessPoints); - assertEquals(null, mWiseFy.mWiseFySearch.findAccessPointsMatchingRegex(TEST_SSID, false)); - } - - @Test - public void findAccessPointsMatchingRegex_failure_nonMatchingSSID_takeHighest_true() { - List accessPoints = new ArrayList<>(); - - ScanResult accessPoint= mock(ScanResult.class); - accessPoint.SSID = TEST_SSID2; - accessPoints.add(accessPoint); - - when(mMockWiFiManager.getScanResults()).thenReturn(accessPoints); - assertEquals(null, mWiseFy.mWiseFySearch.findAccessPointsMatchingRegex(TEST_SSID, true)); - } - - @Test - public void findAccessPointsMatchingRegex_failure_multipleNonMatchingSSIDs_takeHighest_false() { - List accessPoints = new ArrayList<>(); - - ScanResult accessPoint1 = mock(ScanResult.class); - accessPoint1.SSID = TEST_SSID2; - accessPoints.add(accessPoint1); - - ScanResult accessPoint2 = mock(ScanResult.class); - accessPoint2.SSID = TEST_SSID3; - accessPoints.add(accessPoint2); - - when(mMockWiFiManager.getScanResults()).thenReturn(accessPoints); - assertEquals(null, mWiseFy.mWiseFySearch.findAccessPointsMatchingRegex(TEST_SSID, false)); - } - - @Test - public void findAccessPointsMatchingRegex_failure_multipleNnonMatchingSSIDs_takeHighest_true() { - List accessPoints = new ArrayList<>(); - - ScanResult accessPoint1= mock(ScanResult.class); - accessPoint1.SSID = TEST_SSID2; - accessPoints.add(accessPoint1); - - ScanResult accessPoint2 = mock(ScanResult.class); - accessPoint2.SSID = TEST_SSID3; - accessPoints.add(accessPoint2); - - when(mMockWiFiManager.getScanResults()).thenReturn(accessPoints); - assertEquals(null, mWiseFy.mWiseFySearch.findAccessPointsMatchingRegex(TEST_SSID, true)); - } - - @Test - public void findAccessPointsMatchingRegex_success_takeHighest_false() { - List accessPoints = new ArrayList<>(); - - ScanResult accessPoint = mock(ScanResult.class); - accessPoint.SSID = TEST_SSID; - accessPoints.add(accessPoint); - - when(mMockWiFiManager.getScanResults()).thenReturn(accessPoints); - assertEquals(accessPoints, mWiseFy.mWiseFySearch.findAccessPointsMatchingRegex(TEST_SSID, false)); - } - - @Test - public void findAccessPointsMatchingRegex_success_takeHighest_true() { - List accessPoints = new ArrayList<>(); - - ScanResult accessPoint = mock(ScanResult.class); - accessPoint.SSID = TEST_SSID; - accessPoints.add(accessPoint); - - when(mMockWiFiManager.getScanResults()).thenReturn(accessPoints); - assertEquals(accessPoints, mWiseFy.mWiseFySearch.findAccessPointsMatchingRegex(TEST_SSID, true)); - } - - @Test - public void findAccessPointsMatchingRegex_success_multipleSSIDs_takeHighest_false() { - List accessPoints = new ArrayList<>(); - List expectedResults = new ArrayList<>(); - - ScanResult accessPoint1 = mock(ScanResult.class); - accessPoint1.SSID = TEST_SSID; - accessPoint1.level = -70; - accessPoints.add(accessPoint1); - expectedResults.add(accessPoint1); - - ScanResult accessPoint2 = mock(ScanResult.class); - accessPoint2.SSID = TEST_SSID2; - accessPoint2.level = -50; - accessPoints.add(accessPoint2); - - when(mMockWiFiManager.getScanResults()).thenReturn(accessPoints); - assertEquals(expectedResults, mWiseFy.mWiseFySearch.findAccessPointsMatchingRegex(TEST_SSID, false)); - } - - @Test - public void findAccessPointsMatchingRegex_success_multipleSSIDs_takeHighest_true() { - List accessPoints = new ArrayList<>(); - List expectedResults = new ArrayList<>(); - - ScanResult accessPoint1 = mock(ScanResult.class); - accessPoint1.SSID = TEST_SSID; - accessPoint1.level = -70; - accessPoints.add(accessPoint1); - expectedResults.add(accessPoint1); - - ScanResult accessPoint2 = mock(ScanResult.class); - accessPoint2.SSID = TEST_SSID2; - accessPoint2.level = -50; - accessPoints.add(accessPoint2); - - when(mMockWiFiManager.getScanResults()).thenReturn(accessPoints); - assertEquals(expectedResults, mWiseFy.mWiseFySearch.findAccessPointsMatchingRegex(TEST_SSID, true)); - } - - @Test - public void findAccessPointsMatchingRegex_success_multipleSameSSIDs_takeHighest_false() { - List accessPoints = new ArrayList<>(); - List expectedResults = new ArrayList<>(); - - ScanResult accessPoint1 = mock(ScanResult.class); - accessPoint1.SSID = TEST_SSID; - accessPoint1.level = -70; - accessPoints.add(accessPoint1); - expectedResults.add(accessPoint1); - - ScanResult accessPoint2 = mock(ScanResult.class); - accessPoint2.SSID = TEST_SSID; - accessPoint2.level = -50; - accessPoints.add(accessPoint2); - expectedResults.add(accessPoint2); - - when(mMockWiFiManager.getScanResults()).thenReturn(accessPoints); - assertEquals(expectedResults, mWiseFy.mWiseFySearch.findAccessPointsMatchingRegex(TEST_SSID, false)); - } - - @Test - public void findAccessPointsMatchingRegex_success_multipleSameSSIDs_takeHighest_true() { - List accessPoints = new ArrayList<>(); - List expectedResults = new ArrayList<>(); - - ScanResult accessPoint1 = mock(ScanResult.class); - accessPoint1.SSID = TEST_SSID; - accessPoint1.level = -70; - accessPoints.add(accessPoint1); - - ScanResult accessPoint2 = mock(ScanResult.class); - accessPoint2.SSID = TEST_SSID; - accessPoint2.level = -50; - accessPoints.add(accessPoint2); - expectedResults.add(accessPoint2); - - when(mMockWiFiManager.getScanResults()).thenReturn(accessPoints); - assertEquals(expectedResults, mWiseFy.mWiseFySearch.findAccessPointsMatchingRegex(TEST_SSID, true)); - } - - /* - * findSavedNetworkByRegex tests - */ - - @Test - public void findSavedNetworkByRegex_failure_nullSavedNetworkList() { - when(mMockWiFiManager.getConfiguredNetworks()).thenReturn(null); - assertEquals(null, mWiseFy.mWiseFySearch.findSavedNetworkByRegex(TEST_SSID)); - } - - @Test - public void findSavedNetworkByRegex_failure_emptySavedNetworkList() { - when(mMockWiFiManager.getConfiguredNetworks()).thenReturn(new ArrayList()); - assertEquals(null, mWiseFy.mWiseFySearch.findSavedNetworkByRegex(TEST_SSID)); - } - - @Test - public void findSavedNetworkByRegex_failure_nullWifiConfiguration() { - List wifiList = new ArrayList<>(); - wifiList.add(null); - - when(mMockWiFiManager.getConfiguredNetworks()).thenReturn(wifiList); - assertEquals(null, mWiseFy.mWiseFySearch.findSavedNetworkByRegex(TEST_SSID)); - } - - @Test - public void findSavedNetworkByRegex_failure_nullSSID() { - List wifiList = new ArrayList<>(); - WifiConfiguration mWiFiConfiguration = new WifiConfiguration(); - mWiFiConfiguration.SSID = null; - wifiList.add(mWiFiConfiguration); - - when(mMockWiFiManager.getConfiguredNetworks()).thenReturn(wifiList); - assertEquals(null, mWiseFy.mWiseFySearch.findSavedNetworkByRegex(TEST_SSID)); - } - - @Test - public void findSavedNetworkByRegex_failure_nonMatchingSSID() { - List wifiList = new ArrayList<>(); - - WifiConfiguration mWiFiConfiguration = new WifiConfiguration(); - mWiFiConfiguration.SSID = TEST_SSID2; - wifiList.add(mWiFiConfiguration); - - when(mMockWiFiManager.getConfiguredNetworks()).thenReturn(wifiList); - assertEquals(null, mWiseFy.mWiseFySearch.findSavedNetworkByRegex(TEST_SSID)); - } - - @Test - public void findSavedNetworkByRegex_failure_multipleNonMatchingSSIDs() { - List wifiList = new ArrayList<>(); - - WifiConfiguration mWiFiConfiguration1 = new WifiConfiguration(); - mWiFiConfiguration1.SSID = TEST_SSID2; - wifiList.add(mWiFiConfiguration1); - - WifiConfiguration mWiFiConfiguration2 = new WifiConfiguration(); - mWiFiConfiguration2.SSID = TEST_SSID3; - wifiList.add(mWiFiConfiguration2); - - when(mMockWiFiManager.getConfiguredNetworks()).thenReturn(wifiList); - assertEquals(null, mWiseFy.mWiseFySearch.findSavedNetworkByRegex(TEST_SSID)); - } - - @Test - public void findSavedNetworkByRegex_success() { - List wifiList = new ArrayList<>(); - - WifiConfiguration mWiFiConfiguration = new WifiConfiguration(); - mWiFiConfiguration.SSID = TEST_SSID; - wifiList.add(mWiFiConfiguration); - - when(mMockWiFiManager.getConfiguredNetworks()).thenReturn(wifiList); - assertEquals(mWiFiConfiguration, mWiseFy.mWiseFySearch.findSavedNetworkByRegex(TEST_SSID)); - } - - @Test - public void findSavedNetworkByRegex_success_multipleSSIDs() { - List wifiList = new ArrayList<>(); - - WifiConfiguration mWiFiConfiguration1 = new WifiConfiguration(); - mWiFiConfiguration1.SSID = TEST_SSID; - wifiList.add(mWiFiConfiguration1); - - WifiConfiguration mWiFiConfiguration2 = new WifiConfiguration(); - mWiFiConfiguration2.SSID = TEST_SSID2; - wifiList.add(mWiFiConfiguration2); - - when(mMockWiFiManager.getConfiguredNetworks()).thenReturn(wifiList); - assertEquals(mWiFiConfiguration1, mWiseFy.mWiseFySearch.findSavedNetworkByRegex(TEST_SSID)); - } - - /* - * findSavedNetworksMatchingRegex tests - */ - - @Test - public void findSavedNetworksMatchingRegex_failure_nullSavedNetworkList() { - when(mMockWiFiManager.getConfiguredNetworks()).thenReturn(null); - assertEquals(null, mWiseFy.mWiseFySearch.findSavedNetworksMatchingRegex(TEST_SSID)); - } - - @Test - public void findSavedNetworksMatchingRegex_failure_emptySavedNetworkList() { - when(mMockWiFiManager.getConfiguredNetworks()).thenReturn(new ArrayList()); - assertEquals(null, mWiseFy.mWiseFySearch.findSavedNetworksMatchingRegex(TEST_SSID)); - } - - @Test - public void findSavedNetworksMatchingRegex_failure_nullWifiConfiguration() { - List wifiList = new ArrayList<>(); - wifiList.add(null); - - when(mMockWiFiManager.getConfiguredNetworks()).thenReturn(wifiList); - assertEquals(null, mWiseFy.mWiseFySearch.findSavedNetworksMatchingRegex(TEST_SSID)); - } - - @Test - public void findSavedNetworksMatchingRegex_failure_nullSSID() { - List wifiList = new ArrayList<>(); - WifiConfiguration mWiFiConfiguration = new WifiConfiguration(); - mWiFiConfiguration.SSID = null; - wifiList.add(mWiFiConfiguration); - - when(mMockWiFiManager.getConfiguredNetworks()).thenReturn(wifiList); - assertEquals(null, mWiseFy.mWiseFySearch.findSavedNetworksMatchingRegex(TEST_SSID)); - } - - @Test - public void findSavedNetworksMatchingRegex_failure_nonMatchingSSID() { - List wifiList = new ArrayList<>(); - WifiConfiguration mWiFiConfiguration = new WifiConfiguration(); - mWiFiConfiguration.SSID = TEST_SSID2; - wifiList.add(mWiFiConfiguration); - - when(mMockWiFiManager.getConfiguredNetworks()).thenReturn(wifiList); - assertEquals(null, mWiseFy.mWiseFySearch.findSavedNetworksMatchingRegex(TEST_SSID)); - } - - @Test - public void findSavedNetworksMatchingRegex_failure_multipleNonMatchingSSIDs() { - List wifiList = new ArrayList<>(); - - WifiConfiguration mWiFiConfiguration1 = new WifiConfiguration(); - mWiFiConfiguration1.SSID = TEST_SSID2; - wifiList.add(mWiFiConfiguration1); - - WifiConfiguration mWiFiConfiguration2 = new WifiConfiguration(); - mWiFiConfiguration2.SSID = TEST_SSID3; - wifiList.add(mWiFiConfiguration2); - - when(mMockWiFiManager.getConfiguredNetworks()).thenReturn(wifiList); - assertEquals(null, mWiseFy.mWiseFySearch.findSavedNetworksMatchingRegex(TEST_SSID)); - } - - @Test - public void findSavedNetworksMatchingRegex_success() { - List wifiList = new ArrayList<>(); - - WifiConfiguration mWiFiConfiguration = new WifiConfiguration(); - mWiFiConfiguration.SSID = TEST_SSID; - wifiList.add(mWiFiConfiguration); - - when(mMockWiFiManager.getConfiguredNetworks()).thenReturn(wifiList); - assertEquals(wifiList, mWiseFy.mWiseFySearch.findSavedNetworksMatchingRegex(TEST_SSID)); - } - - @Test - public void findSavedNetworksMatchingRegex_success_multipleSSIDs() { - List wifiList = new ArrayList<>(); - - WifiConfiguration mWiFiConfiguration1 = new WifiConfiguration(); - mWiFiConfiguration1.SSID = TEST_SSID; - wifiList.add(mWiFiConfiguration1); - - WifiConfiguration mWiFiConfiguration2 = new WifiConfiguration(); - mWiFiConfiguration2.SSID = TEST_SSID2; - wifiList.add(mWiFiConfiguration2); - - when(mMockWiFiManager.getConfiguredNetworks()).thenReturn(wifiList); - assertEquals(wifiList, mWiseFy.mWiseFySearch.findSavedNetworksMatchingRegex(".*Test.*")); - } - - /* - * findSSIDsMatchingRegex tests - */ - - @Test - public void findSSIDsMatchingRegex_failure_nullAccessPoints() { - when(mMockWiFiManager.getScanResults()).thenReturn(null); - assertEquals(null, mWiseFy.mWiseFySearch.findSSIDsMatchingRegex(TEST_SSID)); - } - - @Test - public void findSSIDsMatchingRegex_failure_emptySavedNetworkList() { - when(mMockWiFiManager.getScanResults()).thenReturn(new ArrayList()); - assertEquals(null, mWiseFy.mWiseFySearch.findSSIDsMatchingRegex(TEST_SSID)); - } - - @Test - public void findSSIDsMatchingRegex_failure_nullWifiConfiguration() { - List accessPoints = new ArrayList<>(); - accessPoints.add(null); - - when(mMockWiFiManager.getScanResults()).thenReturn(accessPoints); - assertEquals(null, mWiseFy.mWiseFySearch.findSSIDsMatchingRegex(TEST_SSID)); - } - - @Test - public void findSSIDsMatchingRegex_failure_nullSSID() { - List accessPoints = new ArrayList<>(); - - ScanResult accessPoint = mock(ScanResult.class); - accessPoint.SSID = null; - accessPoints.add(accessPoint); - - when(mMockWiFiManager.getScanResults()).thenReturn(accessPoints); - assertEquals(null, mWiseFy.mWiseFySearch.findSSIDsMatchingRegex(TEST_SSID)); - } - - @Test - public void findSSIDsMatchingRegex_failure_nonMatchingSSID() { - List accessPoints = new ArrayList<>(); - - ScanResult accessPoint = mock(ScanResult.class); - accessPoint.SSID = TEST_SSID2; - accessPoints.add(accessPoint); - - when(mMockWiFiManager.getScanResults()).thenReturn(accessPoints); - assertEquals(null, mWiseFy.mWiseFySearch.findSSIDsMatchingRegex(TEST_SSID)); - } - - @Test - public void findSSIDsMatchingRegex_failure_multipleNonMatchingSSIDs() { - List accessPoints = new ArrayList<>(); - - ScanResult accessPoint1 = mock(ScanResult.class); - accessPoint1.SSID = TEST_SSID2; - accessPoints.add(accessPoint1); - - ScanResult accessPoint2 = mock(ScanResult.class); - accessPoint2.SSID = TEST_SSID3; - accessPoints.add(accessPoint2); - - when(mMockWiFiManager.getScanResults()).thenReturn(accessPoints); - assertEquals(null, mWiseFy.mWiseFySearch.findSSIDsMatchingRegex(TEST_SSID)); - } - - @Test - public void findSSIDsMatchingRegex_success() { - List accessPoints = new ArrayList<>(); - List expectedResults = new ArrayList<>(); - - ScanResult accessPoint = mock(ScanResult.class); - accessPoint.SSID = TEST_SSID; - accessPoints.add(accessPoint); - expectedResults.add(TEST_SSID); - - when(mMockWiFiManager.getScanResults()).thenReturn(accessPoints); - assertEquals(expectedResults, mWiseFy.mWiseFySearch.findSSIDsMatchingRegex(TEST_SSID)); - } - - @Test - public void findSSIDsMatchingRegex_success_multipleSSIDs() { - List accessPoints = new ArrayList<>(); - List expectedResults = new ArrayList<>(); - - ScanResult accessPoint1 = mock(ScanResult.class); - accessPoint1.SSID = TEST_SSID; - accessPoints.add(accessPoint1); - expectedResults.add(TEST_SSID); - - ScanResult accessPoint2 = mock(ScanResult.class); - accessPoint2.SSID = TEST_SSID; - accessPoints.add(accessPoint2); - expectedResults.add(TEST_SSID); - - when(mMockWiFiManager.getScanResults()).thenReturn(accessPoints); - assertEquals(expectedResults, mWiseFy.mWiseFySearch.findSSIDsMatchingRegex(".*Test.*")); - } - - /* - * isNetworkASavedConfiguration tests - */ - - @Test - public void isNetworkASavedConfiguration_failure() { - when(mMockWiFiManager.getConfiguredNetworks()).thenReturn(new ArrayList()); - assertEquals(false, mWiseFy.mWiseFySearch.isNetworkASavedConfiguration(TEST_SSID)); - } - - @Test - public void isNetworkASavedConfiguration_success() { - List wifiList = new ArrayList<>(); - - WifiConfiguration mWiFiConfiguration = new WifiConfiguration(); - mWiFiConfiguration.SSID = TEST_SSID; - wifiList.add(mWiFiConfiguration); - - when(mMockWiFiManager.getConfiguredNetworks()).thenReturn(wifiList); - assertEquals(true, mWiseFy.mWiseFySearch.isNetworkASavedConfiguration(TEST_SSID)); - } - - /* - * removeEntriesWithLowerSignalStrength tests - */ - - @Test - public void removeEntriesWithLowerSignalStrength_differentSSIDs() { - List accessPoints = new ArrayList<>(); - List expectedResults = new ArrayList<>(); - - ScanResult accessPoint1 = mock(ScanResult.class); - accessPoint1.SSID = TEST_SSID; - accessPoint1.level = -70; - accessPoints.add(accessPoint1); - expectedResults.add(accessPoint1); - - ScanResult accessPoint2 = mock(ScanResult.class); - accessPoint2.SSID = TEST_SSID2; - accessPoint2.level = -50; - accessPoints.add(accessPoint2); - expectedResults.add(accessPoint2); - - assertEquals(expectedResults, mWiseFy.mWiseFySearch.removeEntriesWithLowerSignalStrength(accessPoints)); - } - - @Test - public void removeEntriesWithLowerSignalStrength_sameSignalLevels() { - List accessPoints = new ArrayList<>(); - List expectedResults = new ArrayList<>(); - - ScanResult accessPoint1 = mock(ScanResult.class); - accessPoint1.SSID = TEST_SSID; - accessPoint1.level = -70; - accessPoints.add(accessPoint1); - expectedResults.add(accessPoint1); - - ScanResult accessPoint2 = mock(ScanResult.class); - accessPoint2.SSID = TEST_SSID; - accessPoint2.level = -70; - accessPoints.add(accessPoint2); - - assertEquals(expectedResults, mWiseFy.mWiseFySearch.removeEntriesWithLowerSignalStrength(accessPoints)); - } - - @Test - public void removeEntriesWithLowerSignalStrength_accessPoint1Higher() { - List accessPoints = new ArrayList<>(); - List expectedResults = new ArrayList<>(); - - ScanResult accessPoint1 = mock(ScanResult.class); - accessPoint1.SSID = TEST_SSID; - accessPoint1.level = -50; - accessPoints.add(accessPoint1); - expectedResults.add(accessPoint1); - - ScanResult accessPoint2 = mock(ScanResult.class); - accessPoint2.SSID = TEST_SSID; - accessPoint2.level = -70; - accessPoints.add(accessPoint2); - - assertEquals(expectedResults , mWiseFy.mWiseFySearch.removeEntriesWithLowerSignalStrength(accessPoints)); - } - - @Test - public void removeEntriesWithLowerSignalStrength_accessPoint2Higher() { - List accessPoints = new ArrayList<>(); - List expectedResults = new ArrayList<>(); - - ScanResult accessPoint1 = mock(ScanResult.class); - accessPoint1.SSID = TEST_SSID; - accessPoints.add(accessPoint1); - accessPoint1.level = -70; - - ScanResult accessPoint2 = mock(ScanResult.class); - accessPoint2.SSID = TEST_SSID; - accessPoint2.level = -50; - accessPoints.add(accessPoint2); - expectedResults.add(accessPoint2); - - assertEquals(expectedResults , mWiseFy.mWiseFySearch.removeEntriesWithLowerSignalStrength(accessPoints)); - } -} +//package com.isupatches.wisefy; +// +// +//import android.net.wifi.ScanResult; +//import android.net.wifi.WifiConfiguration; +//import com.isupatches.wisefy.base.TestActivity; +//import org.junit.Test; +//import java.util.ArrayList; +//import java.util.List; +//import static com.isupatches.wisefy.base.TestUtils.TEST_SSID; +//import static com.isupatches.wisefy.base.TestUtils.TEST_SSID2; +//import static com.isupatches.wisefy.base.TestUtils.TEST_SSID3; +//import static junit.framework.Assert.assertEquals; +//import static org.mockito.Mockito.mock; +//import static org.mockito.Mockito.when; +// +// +//public class WiseFySearchTests extends BaseTestClass { +// +// public WiseFySearchTests() { +// super(TestActivity.class); +// } +// +// /* +// * findAccessPointByRegex tests +// */ +// +// @Test +// public void findAccessPointByRegex_failure_nullAccessPoints_takeHighest_false() { +// when(mMockWiFiManager.getScanResults()).thenReturn(null); +// assertEquals(null, mWiseFy.mWiseFySearch.findAccessPointByRegex(TEST_SSID, 1000, false)); +// } +// +// @Test +// public void findAccessPointByRegex_failure_nullAccessPoints_takeHighest_true() { +// when(mMockWiFiManager.getScanResults()).thenReturn(null); +// assertEquals(null, mWiseFy.mWiseFySearch.findAccessPointByRegex(TEST_SSID, 1000, true)); +// } +// +// @Test +// public void findAccessPointByRegex_failure_emptyAccessPointList_takeHighest_false() { +// when(mMockWiFiManager.getScanResults()).thenReturn(new ArrayList()); +// assertEquals(null, mWiseFy.mWiseFySearch.findAccessPointByRegex(TEST_SSID, 1000, false)); +// } +// +// @Test +// public void findAccessPointByRegex_failure_emptyAccessPointList_takeHighest_true() { +// when(mMockWiFiManager.getScanResults()).thenReturn(new ArrayList()); +// assertEquals(null, mWiseFy.mWiseFySearch.findAccessPointByRegex(TEST_SSID, 1000, true)); +// } +// +// @Test +// public void findAccessPointByRegex_failure_nullAccessPoint_takeHighest_false() { +// List accessPoints = new ArrayList<>(); +// accessPoints.add(null); +// +// when(mMockWiFiManager.getScanResults()).thenReturn(accessPoints); +// assertEquals(null, mWiseFy.mWiseFySearch.findAccessPointByRegex(TEST_SSID, 1000, false)); +// } +// +// @Test +// public void findAccessPointByRegex_failure_nullAccessPoint_takeHighest_true() { +// List accessPoints = new ArrayList<>(); +// accessPoints.add(null); +// +// when(mMockWiFiManager.getScanResults()).thenReturn(accessPoints); +// assertEquals(null, mWiseFy.mWiseFySearch.findAccessPointByRegex(TEST_SSID, 1000, true)); +// } +// +// @Test +// public void findAccessPointByRegex_failure_nullSSID_takeHighest_false() { +// List accessPoints = new ArrayList<>(); +// +// ScanResult accessPoint= mock(ScanResult.class); +// accessPoint.SSID = null; +// accessPoints.add(accessPoint); +// +// when(mMockWiFiManager.getScanResults()).thenReturn(accessPoints); +// assertEquals(null, mWiseFy.mWiseFySearch.findAccessPointByRegex(TEST_SSID, 1000, false)); +// } +// +// @Test +// public void findAccessPointByRegex_failure_nullSSID_takeHighest_true() { +// List accessPoints = new ArrayList<>(); +// +// ScanResult accessPoint= mock(ScanResult.class); +// accessPoint.SSID = null; +// accessPoints.add(accessPoint); +// +// when(mMockWiFiManager.getScanResults()).thenReturn(accessPoints); +// assertEquals(null, mWiseFy.mWiseFySearch.findAccessPointByRegex(TEST_SSID, 1000, true)); +// } +// +// @Test +// public void findAccessPointByRegex_failure_nonMatchingSSID_takeHighest_false() { +// List accessPoints = new ArrayList<>(); +// +// ScanResult accessPoint= mock(ScanResult.class); +// accessPoint.SSID = TEST_SSID2; +// accessPoints.add(accessPoint); +// +// when(mMockWiFiManager.getScanResults()).thenReturn(accessPoints); +// assertEquals(null, mWiseFy.mWiseFySearch.findAccessPointByRegex(TEST_SSID, 1000, false)); +// } +// +// @Test +// public void findAccessPointByRegex_failure_nonMatchingSSID_takeHighest_true() { +// List accessPoints = new ArrayList<>(); +// +// ScanResult accessPoint= mock(ScanResult.class); +// accessPoint.SSID = TEST_SSID2; +// accessPoints.add(accessPoint); +// +// when(mMockWiFiManager.getScanResults()).thenReturn(accessPoints); +// assertEquals(null, mWiseFy.mWiseFySearch.findAccessPointByRegex(TEST_SSID, 1000, true)); +// } +// +// @Test +// public void findAccessPointByRegex_failure_multipleNonMatchingSSIDs_takeHighest_false() { +// List accessPoints = new ArrayList<>(); +// +// ScanResult accessPoint1 = mock(ScanResult.class); +// accessPoint1.SSID = TEST_SSID2; +// accessPoints.add(accessPoint1); +// +// ScanResult accessPoint2 = mock(ScanResult.class); +// accessPoint2.SSID = TEST_SSID3; +// accessPoints.add(accessPoint2); +// +// when(mMockWiFiManager.getScanResults()).thenReturn(accessPoints); +// assertEquals(null, mWiseFy.mWiseFySearch.findAccessPointByRegex(TEST_SSID, 1000, false)); +// } +// +// @Test +// public void findAccessPointByRegex_failure_multipleNnonMatchingSSIDs_takeHighest_true() { +// List accessPoints = new ArrayList<>(); +// +// ScanResult accessPoint1= mock(ScanResult.class); +// accessPoint1.SSID = TEST_SSID2; +// accessPoints.add(accessPoint1); +// +// ScanResult accessPoint2 = mock(ScanResult.class); +// accessPoint2.SSID = TEST_SSID3; +// accessPoints.add(accessPoint2); +// +// when(mMockWiFiManager.getScanResults()).thenReturn(accessPoints); +// assertEquals(null, mWiseFy.mWiseFySearch.findAccessPointByRegex(TEST_SSID, 1000, true)); +// } +// +// @Test +// public void findAccessPointByRegex_success_takeHighest_false() { +// List accessPoints = new ArrayList<>(); +// +// ScanResult accessPoint = mock(ScanResult.class); +// accessPoint.SSID = TEST_SSID; +// accessPoints.add(accessPoint); +// +// when(mMockWiFiManager.getScanResults()).thenReturn(accessPoints); +// assertEquals(accessPoint, mWiseFy.mWiseFySearch.findAccessPointByRegex(TEST_SSID, 1000, false)); +// } +// +// @Test +// public void findAccessPointByRegex_success_takeHighest_true() { +// List accessPoints = new ArrayList<>(); +// +// ScanResult accessPoint = mock(ScanResult.class); +// accessPoint.SSID = TEST_SSID; +// accessPoints.add(accessPoint); +// +// when(mMockWiFiManager.getScanResults()).thenReturn(accessPoints); +// assertEquals(accessPoint, mWiseFy.mWiseFySearch.findAccessPointByRegex(TEST_SSID, 1000, true)); +// } +// +// @Test +// public void findAccessPointByRegex_success_multipleSSIDs_takeHighest_false() { +// List accessPoints = new ArrayList<>(); +// +// ScanResult accessPoint1 = mock(ScanResult.class); +// accessPoint1.SSID = TEST_SSID; +// accessPoint1.level = -70; +// accessPoints.add(accessPoint1); +// +// ScanResult accessPoint2 = mock(ScanResult.class); +// accessPoint2.SSID = TEST_SSID2; +// accessPoint2.level = -50; +// accessPoints.add(accessPoint2); +// +// when(mMockWiFiManager.getScanResults()).thenReturn(accessPoints); +// assertEquals(accessPoint1, mWiseFy.mWiseFySearch.findAccessPointByRegex(TEST_SSID, 1000, false)); +// } +// +// @Test +// public void findAccessPointByRegex_success_multipleSSIDs_takeHighest_true() { +// List accessPoints = new ArrayList<>(); +// +// ScanResult accessPoint1 = mock(ScanResult.class); +// accessPoint1.SSID = TEST_SSID; +// accessPoint1.level = -70; +// accessPoints.add(accessPoint1); +// +// ScanResult accessPoint2 = mock(ScanResult.class); +// accessPoint2.SSID = TEST_SSID2; +// accessPoint2.level = -50; +// accessPoints.add(accessPoint2); +// +// when(mMockWiFiManager.getScanResults()).thenReturn(accessPoints); +// assertEquals(accessPoint1, mWiseFy.mWiseFySearch.findAccessPointByRegex(TEST_SSID, 1000, true)); +// } +// +// @Test +// public void findAccessPointByRegex_success_multipleSameSSIDs_takeHighest_false() { +// List accessPoints = new ArrayList<>(); +// +// ScanResult accessPoint1 = mock(ScanResult.class); +// accessPoint1.SSID = TEST_SSID; +// accessPoint1.level = -70; +// accessPoints.add(accessPoint1); +// +// ScanResult accessPoint2 = mock(ScanResult.class); +// accessPoint2.SSID = TEST_SSID; +// accessPoint2.level = -50; +// accessPoints.add(accessPoint2); +// +// when(mMockWiFiManager.getScanResults()).thenReturn(accessPoints); +// assertEquals(accessPoint1, mWiseFy.mWiseFySearch.findAccessPointByRegex(TEST_SSID, 1000, false)); +// } +// +// @Test +// public void findAccessPointByRegex_success_multipleSameSSIDs_takeHighest_true() { +// List accessPoints = new ArrayList<>(); +// +// ScanResult accessPoint1 = mock(ScanResult.class); +// accessPoint1.SSID = TEST_SSID; +// accessPoint1.level = -70; +// accessPoints.add(accessPoint1); +// +// ScanResult accessPoint2 = mock(ScanResult.class); +// accessPoint2.SSID = TEST_SSID; +// accessPoint2.level = -50; +// accessPoints.add(accessPoint2); +// +// when(mMockWiFiManager.getScanResults()).thenReturn(accessPoints); +// assertEquals(accessPoint2, mWiseFy.mWiseFySearch.findAccessPointByRegex(TEST_SSID, 1000, true)); +// } +// +// /* +// * findAccessPointsMatchingRegex tests +// */ +// +// @Test +// public void findAccessPointsMatchingRegex_failure_nullAccessPoints_takeHighest_false() { +// when(mMockWiFiManager.getScanResults()).thenReturn(null); +// assertEquals(null, mWiseFy.mWiseFySearch.findAccessPointsMatchingRegex(TEST_SSID, false)); +// } +// +// @Test +// public void findAccessPointsMatchingRegex_failure_nullAccessPoints_takeHighest_true() { +// when(mMockWiFiManager.getScanResults()).thenReturn(null); +// assertEquals(null, mWiseFy.mWiseFySearch.findAccessPointsMatchingRegex(TEST_SSID, true)); +// } +// +// @Test +// public void findAccessPointsMatchingRegex_failure_emptyAccessPointList_takeHighest_false() { +// when(mMockWiFiManager.getScanResults()).thenReturn(new ArrayList()); +// assertEquals(null, mWiseFy.mWiseFySearch.findAccessPointsMatchingRegex(TEST_SSID, false)); +// } +// +// @Test +// public void findAccessPointsMatchingRegex_failure_emptyAccessPointList_takeHighest_true() { +// when(mMockWiFiManager.getScanResults()).thenReturn(new ArrayList()); +// assertEquals(null, mWiseFy.mWiseFySearch.findAccessPointsMatchingRegex(TEST_SSID, true)); +// } +// +// @Test +// public void findAccessPointsMatchingRegex_failure_nullAccessPoint_takeHighest_false() { +// List accessPoints = new ArrayList<>(); +// accessPoints.add(null); +// +// when(mMockWiFiManager.getScanResults()).thenReturn(accessPoints); +// assertEquals(null, mWiseFy.mWiseFySearch.findAccessPointsMatchingRegex(TEST_SSID, false)); +// } +// +// @Test +// public void findAccessPointsMatchingRegex_failure_nullAccessPoint_takeHighest_true() { +// List accessPoints = new ArrayList<>(); +// accessPoints.add(null); +// +// when(mMockWiFiManager.getScanResults()).thenReturn(accessPoints); +// assertEquals(null, mWiseFy.mWiseFySearch.findAccessPointsMatchingRegex(TEST_SSID, true)); +// } +// +// @Test +// public void findAccessPointsMatchingRegex_failure_nullSSID_takeHighest_false() { +// List accessPoints = new ArrayList<>(); +// +// ScanResult accessPoint= mock(ScanResult.class); +// accessPoint.SSID = null; +// accessPoints.add(accessPoint); +// +// when(mMockWiFiManager.getScanResults()).thenReturn(accessPoints); +// assertEquals(null, mWiseFy.mWiseFySearch.findAccessPointsMatchingRegex(TEST_SSID, false)); +// } +// +// @Test +// public void findAccessPointsMatchingRegex_failure_nullSSID_takeHighest_true() { +// List accessPoints = new ArrayList<>(); +// +// ScanResult accessPoint= mock(ScanResult.class); +// accessPoint.SSID = null; +// accessPoints.add(accessPoint); +// +// when(mMockWiFiManager.getScanResults()).thenReturn(accessPoints); +// assertEquals(null, mWiseFy.mWiseFySearch.findAccessPointsMatchingRegex(TEST_SSID, true)); +// } +// +// @Test +// public void findAccessPointsMatchingRegex_failure_nonMatchingSSID_takeHighest_false() { +// List accessPoints = new ArrayList<>(); +// +// ScanResult accessPoint= mock(ScanResult.class); +// accessPoint.SSID = TEST_SSID2; +// accessPoints.add(accessPoint); +// +// when(mMockWiFiManager.getScanResults()).thenReturn(accessPoints); +// assertEquals(null, mWiseFy.mWiseFySearch.findAccessPointsMatchingRegex(TEST_SSID, false)); +// } +// +// @Test +// public void findAccessPointsMatchingRegex_failure_nonMatchingSSID_takeHighest_true() { +// List accessPoints = new ArrayList<>(); +// +// ScanResult accessPoint= mock(ScanResult.class); +// accessPoint.SSID = TEST_SSID2; +// accessPoints.add(accessPoint); +// +// when(mMockWiFiManager.getScanResults()).thenReturn(accessPoints); +// assertEquals(null, mWiseFy.mWiseFySearch.findAccessPointsMatchingRegex(TEST_SSID, true)); +// } +// +// @Test +// public void findAccessPointsMatchingRegex_failure_multipleNonMatchingSSIDs_takeHighest_false() { +// List accessPoints = new ArrayList<>(); +// +// ScanResult accessPoint1 = mock(ScanResult.class); +// accessPoint1.SSID = TEST_SSID2; +// accessPoints.add(accessPoint1); +// +// ScanResult accessPoint2 = mock(ScanResult.class); +// accessPoint2.SSID = TEST_SSID3; +// accessPoints.add(accessPoint2); +// +// when(mMockWiFiManager.getScanResults()).thenReturn(accessPoints); +// assertEquals(null, mWiseFy.mWiseFySearch.findAccessPointsMatchingRegex(TEST_SSID, false)); +// } +// +// @Test +// public void findAccessPointsMatchingRegex_failure_multipleNnonMatchingSSIDs_takeHighest_true() { +// List accessPoints = new ArrayList<>(); +// +// ScanResult accessPoint1= mock(ScanResult.class); +// accessPoint1.SSID = TEST_SSID2; +// accessPoints.add(accessPoint1); +// +// ScanResult accessPoint2 = mock(ScanResult.class); +// accessPoint2.SSID = TEST_SSID3; +// accessPoints.add(accessPoint2); +// +// when(mMockWiFiManager.getScanResults()).thenReturn(accessPoints); +// assertEquals(null, mWiseFy.mWiseFySearch.findAccessPointsMatchingRegex(TEST_SSID, true)); +// } +// +// @Test +// public void findAccessPointsMatchingRegex_success_takeHighest_false() { +// List accessPoints = new ArrayList<>(); +// +// ScanResult accessPoint = mock(ScanResult.class); +// accessPoint.SSID = TEST_SSID; +// accessPoints.add(accessPoint); +// +// when(mMockWiFiManager.getScanResults()).thenReturn(accessPoints); +// assertEquals(accessPoints, mWiseFy.mWiseFySearch.findAccessPointsMatchingRegex(TEST_SSID, false)); +// } +// +// @Test +// public void findAccessPointsMatchingRegex_success_takeHighest_true() { +// List accessPoints = new ArrayList<>(); +// +// ScanResult accessPoint = mock(ScanResult.class); +// accessPoint.SSID = TEST_SSID; +// accessPoints.add(accessPoint); +// +// when(mMockWiFiManager.getScanResults()).thenReturn(accessPoints); +// assertEquals(accessPoints, mWiseFy.mWiseFySearch.findAccessPointsMatchingRegex(TEST_SSID, true)); +// } +// +// @Test +// public void findAccessPointsMatchingRegex_success_multipleSSIDs_takeHighest_false() { +// List accessPoints = new ArrayList<>(); +// List expectedResults = new ArrayList<>(); +// +// ScanResult accessPoint1 = mock(ScanResult.class); +// accessPoint1.SSID = TEST_SSID; +// accessPoint1.level = -70; +// accessPoints.add(accessPoint1); +// expectedResults.add(accessPoint1); +// +// ScanResult accessPoint2 = mock(ScanResult.class); +// accessPoint2.SSID = TEST_SSID2; +// accessPoint2.level = -50; +// accessPoints.add(accessPoint2); +// +// when(mMockWiFiManager.getScanResults()).thenReturn(accessPoints); +// assertEquals(expectedResults, mWiseFy.mWiseFySearch.findAccessPointsMatchingRegex(TEST_SSID, false)); +// } +// +// @Test +// public void findAccessPointsMatchingRegex_success_multipleSSIDs_takeHighest_true() { +// List accessPoints = new ArrayList<>(); +// List expectedResults = new ArrayList<>(); +// +// ScanResult accessPoint1 = mock(ScanResult.class); +// accessPoint1.SSID = TEST_SSID; +// accessPoint1.level = -70; +// accessPoints.add(accessPoint1); +// expectedResults.add(accessPoint1); +// +// ScanResult accessPoint2 = mock(ScanResult.class); +// accessPoint2.SSID = TEST_SSID2; +// accessPoint2.level = -50; +// accessPoints.add(accessPoint2); +// +// when(mMockWiFiManager.getScanResults()).thenReturn(accessPoints); +// assertEquals(expectedResults, mWiseFy.mWiseFySearch.findAccessPointsMatchingRegex(TEST_SSID, true)); +// } +// +// @Test +// public void findAccessPointsMatchingRegex_success_multipleSameSSIDs_takeHighest_false() { +// List accessPoints = new ArrayList<>(); +// List expectedResults = new ArrayList<>(); +// +// ScanResult accessPoint1 = mock(ScanResult.class); +// accessPoint1.SSID = TEST_SSID; +// accessPoint1.level = -70; +// accessPoints.add(accessPoint1); +// expectedResults.add(accessPoint1); +// +// ScanResult accessPoint2 = mock(ScanResult.class); +// accessPoint2.SSID = TEST_SSID; +// accessPoint2.level = -50; +// accessPoints.add(accessPoint2); +// expectedResults.add(accessPoint2); +// +// when(mMockWiFiManager.getScanResults()).thenReturn(accessPoints); +// assertEquals(expectedResults, mWiseFy.mWiseFySearch.findAccessPointsMatchingRegex(TEST_SSID, false)); +// } +// +// @Test +// public void findAccessPointsMatchingRegex_success_multipleSameSSIDs_takeHighest_true() { +// List accessPoints = new ArrayList<>(); +// List expectedResults = new ArrayList<>(); +// +// ScanResult accessPoint1 = mock(ScanResult.class); +// accessPoint1.SSID = TEST_SSID; +// accessPoint1.level = -70; +// accessPoints.add(accessPoint1); +// +// ScanResult accessPoint2 = mock(ScanResult.class); +// accessPoint2.SSID = TEST_SSID; +// accessPoint2.level = -50; +// accessPoints.add(accessPoint2); +// expectedResults.add(accessPoint2); +// +// when(mMockWiFiManager.getScanResults()).thenReturn(accessPoints); +// assertEquals(expectedResults, mWiseFy.mWiseFySearch.findAccessPointsMatchingRegex(TEST_SSID, true)); +// } +// +// /* +// * findSavedNetworkByRegex tests +// */ +// +// @Test +// public void findSavedNetworkByRegex_failure_nullSavedNetworkList() { +// when(mMockWiFiManager.getConfiguredNetworks()).thenReturn(null); +// assertEquals(null, mWiseFy.mWiseFySearch.findSavedNetworkByRegex(TEST_SSID)); +// } +// +// @Test +// public void findSavedNetworkByRegex_failure_emptySavedNetworkList() { +// when(mMockWiFiManager.getConfiguredNetworks()).thenReturn(new ArrayList()); +// assertEquals(null, mWiseFy.mWiseFySearch.findSavedNetworkByRegex(TEST_SSID)); +// } +// +// @Test +// public void findSavedNetworkByRegex_failure_nullWifiConfiguration() { +// List wifiList = new ArrayList<>(); +// wifiList.add(null); +// +// when(mMockWiFiManager.getConfiguredNetworks()).thenReturn(wifiList); +// assertEquals(null, mWiseFy.mWiseFySearch.findSavedNetworkByRegex(TEST_SSID)); +// } +// +// @Test +// public void findSavedNetworkByRegex_failure_nullSSID() { +// List wifiList = new ArrayList<>(); +// WifiConfiguration mWiFiConfiguration = new WifiConfiguration(); +// mWiFiConfiguration.SSID = null; +// wifiList.add(mWiFiConfiguration); +// +// when(mMockWiFiManager.getConfiguredNetworks()).thenReturn(wifiList); +// assertEquals(null, mWiseFy.mWiseFySearch.findSavedNetworkByRegex(TEST_SSID)); +// } +// +// @Test +// public void findSavedNetworkByRegex_failure_nonMatchingSSID() { +// List wifiList = new ArrayList<>(); +// +// WifiConfiguration mWiFiConfiguration = new WifiConfiguration(); +// mWiFiConfiguration.SSID = TEST_SSID2; +// wifiList.add(mWiFiConfiguration); +// +// when(mMockWiFiManager.getConfiguredNetworks()).thenReturn(wifiList); +// assertEquals(null, mWiseFy.mWiseFySearch.findSavedNetworkByRegex(TEST_SSID)); +// } +// +// @Test +// public void findSavedNetworkByRegex_failure_multipleNonMatchingSSIDs() { +// List wifiList = new ArrayList<>(); +// +// WifiConfiguration mWiFiConfiguration1 = new WifiConfiguration(); +// mWiFiConfiguration1.SSID = TEST_SSID2; +// wifiList.add(mWiFiConfiguration1); +// +// WifiConfiguration mWiFiConfiguration2 = new WifiConfiguration(); +// mWiFiConfiguration2.SSID = TEST_SSID3; +// wifiList.add(mWiFiConfiguration2); +// +// when(mMockWiFiManager.getConfiguredNetworks()).thenReturn(wifiList); +// assertEquals(null, mWiseFy.mWiseFySearch.findSavedNetworkByRegex(TEST_SSID)); +// } +// +// @Test +// public void findSavedNetworkByRegex_success() { +// List wifiList = new ArrayList<>(); +// +// WifiConfiguration mWiFiConfiguration = new WifiConfiguration(); +// mWiFiConfiguration.SSID = TEST_SSID; +// wifiList.add(mWiFiConfiguration); +// +// when(mMockWiFiManager.getConfiguredNetworks()).thenReturn(wifiList); +// assertEquals(mWiFiConfiguration, mWiseFy.mWiseFySearch.findSavedNetworkByRegex(TEST_SSID)); +// } +// +// @Test +// public void findSavedNetworkByRegex_success_multipleSSIDs() { +// List wifiList = new ArrayList<>(); +// +// WifiConfiguration mWiFiConfiguration1 = new WifiConfiguration(); +// mWiFiConfiguration1.SSID = TEST_SSID; +// wifiList.add(mWiFiConfiguration1); +// +// WifiConfiguration mWiFiConfiguration2 = new WifiConfiguration(); +// mWiFiConfiguration2.SSID = TEST_SSID2; +// wifiList.add(mWiFiConfiguration2); +// +// when(mMockWiFiManager.getConfiguredNetworks()).thenReturn(wifiList); +// assertEquals(mWiFiConfiguration1, mWiseFy.mWiseFySearch.findSavedNetworkByRegex(TEST_SSID)); +// } +// +// /* +// * findSavedNetworksMatchingRegex tests +// */ +// +// @Test +// public void findSavedNetworksMatchingRegex_failure_nullSavedNetworkList() { +// when(mMockWiFiManager.getConfiguredNetworks()).thenReturn(null); +// assertEquals(null, mWiseFy.mWiseFySearch.findSavedNetworksMatchingRegex(TEST_SSID)); +// } +// +// @Test +// public void findSavedNetworksMatchingRegex_failure_emptySavedNetworkList() { +// when(mMockWiFiManager.getConfiguredNetworks()).thenReturn(new ArrayList()); +// assertEquals(null, mWiseFy.mWiseFySearch.findSavedNetworksMatchingRegex(TEST_SSID)); +// } +// +// @Test +// public void findSavedNetworksMatchingRegex_failure_nullWifiConfiguration() { +// List wifiList = new ArrayList<>(); +// wifiList.add(null); +// +// when(mMockWiFiManager.getConfiguredNetworks()).thenReturn(wifiList); +// assertEquals(null, mWiseFy.mWiseFySearch.findSavedNetworksMatchingRegex(TEST_SSID)); +// } +// +// @Test +// public void findSavedNetworksMatchingRegex_failure_nullSSID() { +// List wifiList = new ArrayList<>(); +// WifiConfiguration mWiFiConfiguration = new WifiConfiguration(); +// mWiFiConfiguration.SSID = null; +// wifiList.add(mWiFiConfiguration); +// +// when(mMockWiFiManager.getConfiguredNetworks()).thenReturn(wifiList); +// assertEquals(null, mWiseFy.mWiseFySearch.findSavedNetworksMatchingRegex(TEST_SSID)); +// } +// +// @Test +// public void findSavedNetworksMatchingRegex_failure_nonMatchingSSID() { +// List wifiList = new ArrayList<>(); +// WifiConfiguration mWiFiConfiguration = new WifiConfiguration(); +// mWiFiConfiguration.SSID = TEST_SSID2; +// wifiList.add(mWiFiConfiguration); +// +// when(mMockWiFiManager.getConfiguredNetworks()).thenReturn(wifiList); +// assertEquals(null, mWiseFy.mWiseFySearch.findSavedNetworksMatchingRegex(TEST_SSID)); +// } +// +// @Test +// public void findSavedNetworksMatchingRegex_failure_multipleNonMatchingSSIDs() { +// List wifiList = new ArrayList<>(); +// +// WifiConfiguration mWiFiConfiguration1 = new WifiConfiguration(); +// mWiFiConfiguration1.SSID = TEST_SSID2; +// wifiList.add(mWiFiConfiguration1); +// +// WifiConfiguration mWiFiConfiguration2 = new WifiConfiguration(); +// mWiFiConfiguration2.SSID = TEST_SSID3; +// wifiList.add(mWiFiConfiguration2); +// +// when(mMockWiFiManager.getConfiguredNetworks()).thenReturn(wifiList); +// assertEquals(null, mWiseFy.mWiseFySearch.findSavedNetworksMatchingRegex(TEST_SSID)); +// } +// +// @Test +// public void findSavedNetworksMatchingRegex_success() { +// List wifiList = new ArrayList<>(); +// +// WifiConfiguration mWiFiConfiguration = new WifiConfiguration(); +// mWiFiConfiguration.SSID = TEST_SSID; +// wifiList.add(mWiFiConfiguration); +// +// when(mMockWiFiManager.getConfiguredNetworks()).thenReturn(wifiList); +// assertEquals(wifiList, mWiseFy.mWiseFySearch.findSavedNetworksMatchingRegex(TEST_SSID)); +// } +// +// @Test +// public void findSavedNetworksMatchingRegex_success_multipleSSIDs() { +// List wifiList = new ArrayList<>(); +// +// WifiConfiguration mWiFiConfiguration1 = new WifiConfiguration(); +// mWiFiConfiguration1.SSID = TEST_SSID; +// wifiList.add(mWiFiConfiguration1); +// +// WifiConfiguration mWiFiConfiguration2 = new WifiConfiguration(); +// mWiFiConfiguration2.SSID = TEST_SSID2; +// wifiList.add(mWiFiConfiguration2); +// +// when(mMockWiFiManager.getConfiguredNetworks()).thenReturn(wifiList); +// assertEquals(wifiList, mWiseFy.mWiseFySearch.findSavedNetworksMatchingRegex(".*Test.*")); +// } +// +// /* +// * findSSIDsMatchingRegex tests +// */ +// +// @Test +// public void findSSIDsMatchingRegex_failure_nullAccessPoints() { +// when(mMockWiFiManager.getScanResults()).thenReturn(null); +// assertEquals(null, mWiseFy.mWiseFySearch.findSSIDsMatchingRegex(TEST_SSID)); +// } +// +// @Test +// public void findSSIDsMatchingRegex_failure_emptySavedNetworkList() { +// when(mMockWiFiManager.getScanResults()).thenReturn(new ArrayList()); +// assertEquals(null, mWiseFy.mWiseFySearch.findSSIDsMatchingRegex(TEST_SSID)); +// } +// +// @Test +// public void findSSIDsMatchingRegex_failure_nullWifiConfiguration() { +// List accessPoints = new ArrayList<>(); +// accessPoints.add(null); +// +// when(mMockWiFiManager.getScanResults()).thenReturn(accessPoints); +// assertEquals(null, mWiseFy.mWiseFySearch.findSSIDsMatchingRegex(TEST_SSID)); +// } +// +// @Test +// public void findSSIDsMatchingRegex_failure_nullSSID() { +// List accessPoints = new ArrayList<>(); +// +// ScanResult accessPoint = mock(ScanResult.class); +// accessPoint.SSID = null; +// accessPoints.add(accessPoint); +// +// when(mMockWiFiManager.getScanResults()).thenReturn(accessPoints); +// assertEquals(null, mWiseFy.mWiseFySearch.findSSIDsMatchingRegex(TEST_SSID)); +// } +// +// @Test +// public void findSSIDsMatchingRegex_failure_nonMatchingSSID() { +// List accessPoints = new ArrayList<>(); +// +// ScanResult accessPoint = mock(ScanResult.class); +// accessPoint.SSID = TEST_SSID2; +// accessPoints.add(accessPoint); +// +// when(mMockWiFiManager.getScanResults()).thenReturn(accessPoints); +// assertEquals(null, mWiseFy.mWiseFySearch.findSSIDsMatchingRegex(TEST_SSID)); +// } +// +// @Test +// public void findSSIDsMatchingRegex_failure_multipleNonMatchingSSIDs() { +// List accessPoints = new ArrayList<>(); +// +// ScanResult accessPoint1 = mock(ScanResult.class); +// accessPoint1.SSID = TEST_SSID2; +// accessPoints.add(accessPoint1); +// +// ScanResult accessPoint2 = mock(ScanResult.class); +// accessPoint2.SSID = TEST_SSID3; +// accessPoints.add(accessPoint2); +// +// when(mMockWiFiManager.getScanResults()).thenReturn(accessPoints); +// assertEquals(null, mWiseFy.mWiseFySearch.findSSIDsMatchingRegex(TEST_SSID)); +// } +// +// @Test +// public void findSSIDsMatchingRegex_success() { +// List accessPoints = new ArrayList<>(); +// List expectedResults = new ArrayList<>(); +// +// ScanResult accessPoint = mock(ScanResult.class); +// accessPoint.SSID = TEST_SSID; +// accessPoints.add(accessPoint); +// expectedResults.add(TEST_SSID); +// +// when(mMockWiFiManager.getScanResults()).thenReturn(accessPoints); +// assertEquals(expectedResults, mWiseFy.mWiseFySearch.findSSIDsMatchingRegex(TEST_SSID)); +// } +// +// @Test +// public void findSSIDsMatchingRegex_success_multipleSSIDs() { +// List accessPoints = new ArrayList<>(); +// List expectedResults = new ArrayList<>(); +// +// ScanResult accessPoint1 = mock(ScanResult.class); +// accessPoint1.SSID = TEST_SSID; +// accessPoints.add(accessPoint1); +// expectedResults.add(TEST_SSID); +// +// ScanResult accessPoint2 = mock(ScanResult.class); +// accessPoint2.SSID = TEST_SSID; +// accessPoints.add(accessPoint2); +// expectedResults.add(TEST_SSID); +// +// when(mMockWiFiManager.getScanResults()).thenReturn(accessPoints); +// assertEquals(expectedResults, mWiseFy.mWiseFySearch.findSSIDsMatchingRegex(".*Test.*")); +// } +// +// /* +// * isNetworkASavedConfiguration tests +// */ +// +// @Test +// public void isNetworkASavedConfiguration_failure() { +// when(mMockWiFiManager.getConfiguredNetworks()).thenReturn(new ArrayList()); +// assertEquals(false, mWiseFy.mWiseFySearch.isNetworkASavedConfiguration(TEST_SSID)); +// } +// +// @Test +// public void isNetworkASavedConfiguration_success() { +// List wifiList = new ArrayList<>(); +// +// WifiConfiguration mWiFiConfiguration = new WifiConfiguration(); +// mWiFiConfiguration.SSID = TEST_SSID; +// wifiList.add(mWiFiConfiguration); +// +// when(mMockWiFiManager.getConfiguredNetworks()).thenReturn(wifiList); +// assertEquals(true, mWiseFy.mWiseFySearch.isNetworkASavedConfiguration(TEST_SSID)); +// } +// +// /* +// * removeEntriesWithLowerSignalStrength tests +// */ +// +// @Test +// public void removeEntriesWithLowerSignalStrength_differentSSIDs() { +// List accessPoints = new ArrayList<>(); +// List expectedResults = new ArrayList<>(); +// +// ScanResult accessPoint1 = mock(ScanResult.class); +// accessPoint1.SSID = TEST_SSID; +// accessPoint1.level = -70; +// accessPoints.add(accessPoint1); +// expectedResults.add(accessPoint1); +// +// ScanResult accessPoint2 = mock(ScanResult.class); +// accessPoint2.SSID = TEST_SSID2; +// accessPoint2.level = -50; +// accessPoints.add(accessPoint2); +// expectedResults.add(accessPoint2); +// +// assertEquals(expectedResults, mWiseFy.mWiseFySearch.removeEntriesWithLowerSignalStrength(accessPoints)); +// } +// +// @Test +// public void removeEntriesWithLowerSignalStrength_sameSignalLevels() { +// List accessPoints = new ArrayList<>(); +// List expectedResults = new ArrayList<>(); +// +// ScanResult accessPoint1 = mock(ScanResult.class); +// accessPoint1.SSID = TEST_SSID; +// accessPoint1.level = -70; +// accessPoints.add(accessPoint1); +// expectedResults.add(accessPoint1); +// +// ScanResult accessPoint2 = mock(ScanResult.class); +// accessPoint2.SSID = TEST_SSID; +// accessPoint2.level = -70; +// accessPoints.add(accessPoint2); +// +// assertEquals(expectedResults, mWiseFy.mWiseFySearch.removeEntriesWithLowerSignalStrength(accessPoints)); +// } +// +// @Test +// public void removeEntriesWithLowerSignalStrength_accessPoint1Higher() { +// List accessPoints = new ArrayList<>(); +// List expectedResults = new ArrayList<>(); +// +// ScanResult accessPoint1 = mock(ScanResult.class); +// accessPoint1.SSID = TEST_SSID; +// accessPoint1.level = -50; +// accessPoints.add(accessPoint1); +// expectedResults.add(accessPoint1); +// +// ScanResult accessPoint2 = mock(ScanResult.class); +// accessPoint2.SSID = TEST_SSID; +// accessPoint2.level = -70; +// accessPoints.add(accessPoint2); +// +// assertEquals(expectedResults , mWiseFy.mWiseFySearch.removeEntriesWithLowerSignalStrength(accessPoints)); +// } +// +// @Test +// public void removeEntriesWithLowerSignalStrength_accessPoint2Higher() { +// List accessPoints = new ArrayList<>(); +// List expectedResults = new ArrayList<>(); +// +// ScanResult accessPoint1 = mock(ScanResult.class); +// accessPoint1.SSID = TEST_SSID; +// accessPoints.add(accessPoint1); +// accessPoint1.level = -70; +// +// ScanResult accessPoint2 = mock(ScanResult.class); +// accessPoint2.SSID = TEST_SSID; +// accessPoint2.level = -50; +// accessPoints.add(accessPoint2); +// expectedResults.add(accessPoint2); +// +// assertEquals(expectedResults , mWiseFy.mWiseFySearch.removeEntriesWithLowerSignalStrength(accessPoints)); +// } +//} diff --git a/wisefy/src/androidTest/java/com/isupatches/wisefy/WiseFyTests.java b/wisefy/src/androidTest/java/com/isupatches/wisefy/WiseFyTests.java index c435d876..e7892ecb 100644 --- a/wisefy/src/androidTest/java/com/isupatches/wisefy/WiseFyTests.java +++ b/wisefy/src/androidTest/java/com/isupatches/wisefy/WiseFyTests.java @@ -1,47 +1,47 @@ -package com.isupatches.wisefy; - - -import com.google.android.gms.iid.InstanceID; -import com.isupatches.wisefy.base.TestActivity; -import org.junit.Test; -import static org.junit.Assert.*; - - -public class WiseFyTests extends BaseTestClass { - - public WiseFyTests() { - super(TestActivity.class); - } - - @Test - public void builder_loggingFalse() { - WiseFy wiseFy = new WiseFy.brains(mActivityTestRule.getActivity()).logging(false).getSmarts(); - assertEquals(false, wiseFy.mWiseFyConfiguration.isLoggingEnabled()); - assertEquals(false, wiseFy.isLoggingEnabled()); - } - - @Test - public void builder_loggingTrue() { - WiseFy wiseFy = new WiseFy.brains(mActivityTestRule.getActivity()).logging(true).getSmarts(); - assertEquals(true, wiseFy.mWiseFyConfiguration.isLoggingEnabled()); - assertEquals(true, wiseFy.isLoggingEnabled()); - } - - @Test - public void calculateBars() { - int result = mWiseFy.calculateBars(-35, 5); - assertEquals(4, result); - } - - @Test - public void compareSignalLevel() { - int result = mWiseFy.compareSignalLevel(-35, -70); - assertEquals(35, result); - } - - @Test - public void olderGcm_IllegalAccessError_notThrown() { - InstanceID instanceID = InstanceID.getInstance(mActivityTestRule.getActivity()); - assertNotNull(instanceID); - } -} \ No newline at end of file +//package com.isupatches.wisefy; +// +// +//import com.google.android.gms.iid.InstanceID; +//import com.isupatches.wisefy.base.TestActivity; +//import org.junit.Test; +//import static org.junit.Assert.*; +// +// +//public class WiseFyTests extends BaseTestClass { +// +// public WiseFyTests() { +// super(TestActivity.class); +// } +// +// @Test +// public void builder_loggingFalse() { +// WiseFy wiseFy = new WiseFy.brains(mActivityTestRule.getActivity()).logging(false).getSmarts(); +// assertEquals(false, wiseFy.mWiseFyConfiguration.isLoggingEnabled()); +// assertEquals(false, wiseFy.isLoggingEnabled()); +// } +// +// @Test +// public void builder_loggingTrue() { +// WiseFy wiseFy = new WiseFy.brains(mActivityTestRule.getActivity()).logging(true).getSmarts(); +// assertEquals(true, wiseFy.mWiseFyConfiguration.isLoggingEnabled()); +// assertEquals(true, wiseFy.isLoggingEnabled()); +// } +// +// @Test +// public void calculateBars() { +// int result = mWiseFy.calculateBars(-35, 5); +// assertEquals(4, result); +// } +// +// @Test +// public void compareSignalLevel() { +// int result = mWiseFy.compareSignalLevel(-35, -70); +// assertEquals(35, result); +// } +// +// @Test +// public void olderGcm_IllegalAccessError_notThrown() { +// InstanceID instanceID = InstanceID.getInstance(mActivityTestRule.getActivity()); +// assertNotNull(instanceID); +// } +//} \ No newline at end of file From c3a1587fc8210d85c7a2523b768e061c8e6fca9d Mon Sep 17 00:00:00 2001 From: isuPatches Date: Sun, 23 Jul 2017 21:05:53 -0500 Subject: [PATCH 71/74] Run on SDK 19 --- .travis.yml | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) diff --git a/.travis.yml b/.travis.yml index 41bd1bdf..040b59d1 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,31 +7,23 @@ jdk: env: global: - - TARGET_SDK_VERSION=26 + - TARGET_SDK=26 - BUILD_TOOLS_VERSION=26.0.0 matrix: -# - API=android-15 ABI=armeabi-v7a - - API=android-16 ABI=armeabi-v7a -# - API=android-17 ABI=armeabi-v7a -# - API=android-18 ABI=armeabi-v7a -# - API=android-19 ABI=armeabi-v7a -# - API=android-21 ABI=armeabi-v7a -# - API=android-22 ABI=armeabi-v7a -# - API=android-24 ABI=armeabi-v7a -# - API=android-24 ABI=arm64-v8a + - EMULATOR_SDK=android-19 ABI=armeabi-v7a android: components: - tools - platform-tools - tools - - android-${TARGET_SDK_VERSION} + - android-${TARGET_SDK} - build-tools-${BUILD_TOOLS_VERSION} - extra-android-m2repository before_script: - - android-update-sdk --components=sys-img-$ABI-$API --accept-licenses='android-sdk-license-[0-9a-f]{8}' - - echo no | android create avd --force -n test -t $API --abi $ABI + - android-update-sdk --components=sys-img-$ABI-$EMULATOR_SDK --accept-licenses='android-sdk-license-[0-9a-f]{8}' + - echo no | android create avd --force -n test -t $EMULATOR_SDK --abi $ABI - emulator -avd test -no-audio -no-window & - ./gradlew clean assembleDebug assembleDebugAndroidTest - android-wait-for-emulator From 82a22ef8a3b9df91f12ab3a735edb15b18a04c20 Mon Sep 17 00:00:00 2001 From: isuPatches Date: Sun, 23 Jul 2017 21:23:17 -0500 Subject: [PATCH 72/74] Add code coverage thing --- .travis.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 040b59d1..7bcd3c50 100644 --- a/.travis.yml +++ b/.travis.yml @@ -30,4 +30,7 @@ before_script: - adb shell input keyevent 82 & script: - - travis_wait 60 ./gradlew jacocoDebugTestReport \ No newline at end of file + - travis_wait 60 ./gradlew jacocoDebugTestReport + +after_success: + - bash <(curl -s https://codecov.io/bash) \ No newline at end of file From 5c7f29e8e37970c16ce5142b6deb9ef5f52af44a Mon Sep 17 00:00:00 2001 From: isuPatches Date: Sun, 23 Jul 2017 22:10:26 -0500 Subject: [PATCH 73/74] Move all tests to AndroidJUnit4 tests --- gradle/jacoco.gradle | 6 +- .../wisefy/AddOpenNetworkTests.java | 316 ++- .../isupatches/wisefy/AddWEPNetworkTests.java | 370 ++-- .../wisefy/AddWPA2NetworkTests.java | 368 ++-- ...s.java => BaseAndroidJUnit4TestClass.java} | 24 +- .../wisefy/ConnectToNetworkTests.java | 439 +++-- .../isupatches/wisefy/DisableWifiTests.java | 203 +- .../DisconnectFromCurrentNetworkTests.java | 201 +- .../isupatches/wisefy/EnableWifiTests.java | 203 +- .../wisefy/GetCurrentNetworkTests.java | 169 +- .../isupatches/wisefy/GetFrequencyTests.java | 311 ++- .../wisefy/GetNearbyAccessPointsTests.java | 415 ++-- .../com/isupatches/wisefy/GetRSSITests.java | 523 +++-- .../wisefy/GetSavedNetworkTests.java | 283 ++- .../wisefy/GetSavedNetworksTests.java | 481 +++-- ...IsDeviceConnectedToMobileNetworkTests.java | 87 +- ...ceConnectedToMobileOrWifiNetworkTests.java | 86 +- .../wisefy/IsDeviceConnectedToSSIDTests.java | 91 +- .../IsDeviceConnectedToWifiNetworkTests.java | 87 +- .../wisefy/IsDeviceRoamingTests.java | 79 +- .../isupatches/wisefy/IsNetwork5gHzTests.java | 199 +- .../isupatches/wisefy/IsNetworkEAPTests.java | 93 +- .../IsNetworkInConfigurationListTests.java | 193 +- .../isupatches/wisefy/IsNetworkPSKTest.java | 93 +- .../wisefy/IsNetworkSecureTests.java | 149 +- .../isupatches/wisefy/IsNetworkWPA2Test.java | 93 +- .../isupatches/wisefy/IsNetworkWPATests.java | 93 +- .../isupatches/wisefy/IsNetworkWepTests.java | 93 +- .../isupatches/wisefy/IsWifiEnabledTests.java | 61 +- .../isupatches/wisefy/ManagerUtilTest.java | 83 +- .../isupatches/wisefy/RemoveNetworkTests.java | 415 ++-- .../wisefy/SearchForAccessPointTests.java | 539 +++--- .../wisefy/SearchForAccessPointsTests.java | 568 +++--- .../isupatches/wisefy/SearchForSSIDTests.java | 293 ++- .../wisefy/SearchForSSIDsTests.java | 287 ++- .../wisefy/WiseFyConnectionTests.java | 723 ++++--- .../wisefy/WiseFyPrerequisitesTests.java | 103 +- .../isupatches/wisefy/WiseFySearchTests.java | 1716 ++++++++--------- .../com/isupatches/wisefy/WiseFyTests.java | 91 +- .../isupatches/wisefy/test/BuilderTests.java | 55 +- .../wisefy/test/PublicApiVisibilityTests.java | 15 +- 41 files changed, 5240 insertions(+), 5457 deletions(-) rename wisefy/src/androidTest/java/com/isupatches/wisefy/{BaseTestClass.java => BaseAndroidJUnit4TestClass.java} (74%) rename wisefy/src/{androidTest => test}/java/com/isupatches/wisefy/test/PublicApiVisibilityTests.java (97%) diff --git a/gradle/jacoco.gradle b/gradle/jacoco.gradle index 35661302..a35c74f5 100644 --- a/gradle/jacoco.gradle +++ b/gradle/jacoco.gradle @@ -17,13 +17,13 @@ def classDirs = fileTree( '**/*$Builder*']) task jacocoDebugTestReport(type: JacocoReport) { - dependsOn = ["connectedDebugAndroidTest"] + dependsOn = ["connectedDebugAndroidTest", "testDebugUnitTest"] group = "Reporting" description = "Run tests and generate Jacoco coverage report for debug" classDirectories = classDirs additionalSourceDirs = files(coverageSourceDirs) sourceDirectories = files(coverageSourceDirs) - executionData = files([fileTree(dir: 'build/outputs/code-coverage/connected', include: '**/*.ec')]) + executionData = files([fileTree(dir: 'build/outputs/code-coverage/connected', include: '**/*.ec'), fileTree(dir: 'build/jacoco', include: '**/*.exec')]) reports { xml.enabled = true @@ -37,7 +37,7 @@ task jacocoDebugReport(type: JacocoReport) { classDirectories = classDirs additionalSourceDirs = files(coverageSourceDirs) sourceDirectories = files(coverageSourceDirs) - executionData = files([fileTree(dir: 'build/outputs/code-coverage/connected', include: '**/*.ec')]) + executionData = files([fileTree(dir: 'build/outputs/code-coverage/connected', include: '**/*.ec'), fileTree(dir: 'build/jacoco', include: '**/*.exec')]) reports { xml.enabled = true diff --git a/wisefy/src/androidTest/java/com/isupatches/wisefy/AddOpenNetworkTests.java b/wisefy/src/androidTest/java/com/isupatches/wisefy/AddOpenNetworkTests.java index 8443d1d3..e020d4b3 100644 --- a/wisefy/src/androidTest/java/com/isupatches/wisefy/AddOpenNetworkTests.java +++ b/wisefy/src/androidTest/java/com/isupatches/wisefy/AddOpenNetworkTests.java @@ -1,160 +1,156 @@ -//package com.isupatches.wisefy; -// -// -//import android.net.wifi.WifiConfiguration; -//import com.isupatches.wisefy.callbacks.AddOpenNetworkCallbacks; -//import com.isupatches.wisefy.constants.WiseFyCodes; -//import com.isupatches.wisefy.base.TestActivity; -//import org.junit.Test; -//import static com.isupatches.wisefy.base.TestUtils.OPEN_NETWORK_SSID; -//import static org.junit.Assert.assertEquals; -//import static org.junit.Assert.assertNotEquals; -//import static org.junit.Assert.fail; -//import static org.mockito.ArgumentMatchers.any; -//import static org.mockito.Mockito.mock; -//import static org.mockito.Mockito.never; -//import static org.mockito.Mockito.timeout; -//import static org.mockito.Mockito.verify; -//import static org.mockito.Mockito.when; -// -// -//public class AddOpenNetworkTests extends BaseTestClass { -// -// public AddOpenNetworkTests() { -// super(TestActivity.class); -// } -// -// @Test -// public void noCallbacks_failure() { -// when(mMockWiFiManager.addNetwork(any(WifiConfiguration.class))).thenReturn(WiseFy.WIFI_MANAGER_FAILURE); -// assertEquals(WiseFy.WIFI_MANAGER_FAILURE, mWiseFy.addOpenNetwork(OPEN_NETWORK_SSID)); -// verify(mMockWiFiManager, timeout(VERIFICATION_TIMEOUT)).addNetwork(any(WifiConfiguration.class)); -// } -// -// @Test -// public void noCallbacks_failure_nullSSIDParam() { -// assertEquals(WiseFyCodes.MISSING_PARAMETER, mWiseFy.addOpenNetwork(null)); -// verify(mMockWiFiManager, never()).addNetwork(any(WifiConfiguration.class)); -// } -// -// @Test -// public void noCallbacks_failure_missingPrerequisite() { -// missingPrerequisite(); -// assertEquals(WiseFyCodes.MISSING_PREREQUISITE, mWiseFy.addOpenNetwork(OPEN_NETWORK_SSID)); -// verify(mMockWiFiManager, never()).addNetwork(any(WifiConfiguration.class)); -// } -// -// @Test -// public void noCallbacks_success() { -// when(mMockWiFiManager.addNetwork(any(WifiConfiguration.class))).thenReturn(0); -// assertNotEquals(WiseFy.WIFI_MANAGER_FAILURE, mWiseFy.addOpenNetwork(OPEN_NETWORK_SSID)); -// verify(mMockWiFiManager, timeout(VERIFICATION_TIMEOUT)).addNetwork(any(WifiConfiguration.class)); -// } -// -// @Test -// public void noCallbacks_success_alreadyConfigured() { -// networkAlreadyInConfigurationList(); -// assertEquals(WiseFyCodes.NETWORK_ALREADY_CONFIGURED, mWiseFy.addOpenNetwork(OPEN_NETWORK_SSID)); -// verify(mMockWiFiManager, never()).addNetwork(any(WifiConfiguration.class)); -// } -// -// @Test -// public void callbacks_failure() { -// when(mMockWiFiManager.addNetwork(any(WifiConfiguration.class))).thenReturn(WiseFy.WIFI_MANAGER_FAILURE); -// AddOpenNetworkCallbacks mockCallbacks = mock(AddOpenNetworkCallbacks.class); -// mWiseFy.addOpenNetwork(OPEN_NETWORK_SSID, mockCallbacks); -// verify(mockCallbacks, timeout(VERIFICATION_TIMEOUT)).failureAddingOpenNetwork(WiseFy.WIFI_MANAGER_FAILURE); -// verify(mMockWiFiManager, timeout(VERIFICATION_TIMEOUT)).addNetwork(any(WifiConfiguration.class)); -// } -// -// @Test -// public void callbacks_failure_nullCallback() { -// when(mMockWiFiManager.addNetwork(any(WifiConfiguration.class))).thenReturn(WiseFy.WIFI_MANAGER_FAILURE); -// try { -// mWiseFy.addOpenNetwork(OPEN_NETWORK_SSID, null); -// verify(mMockWiFiManager, never()).addNetwork(any(WifiConfiguration.class)); -// } catch (NullPointerException npe) { -// fail(); -// } -// } -// -// @Test -// public void callbacks_failure_nullSSIDParam() { -// AddOpenNetworkCallbacks mockCallbacks = mock(AddOpenNetworkCallbacks.class); -// mWiseFy.addOpenNetwork(null, mockCallbacks); -// verify(mockCallbacks, timeout(VERIFICATION_TIMEOUT)).addOpenNetworkWiseFyFailure(WiseFyCodes.MISSING_PARAMETER); -// verify(mMockWiFiManager, never()).addNetwork(any(WifiConfiguration.class)); -// } -// -// @Test -// public void callbacks_failure_nullSSIDParam_nullCallback() { -// try { -// mWiseFy.addOpenNetwork(null, null); -// verify(mMockWiFiManager, never()).addNetwork(any(WifiConfiguration.class)); -// } catch (NullPointerException npe) { -// fail(); -// } -// } -// -// @Test -// public void callbacks_failure_missingPrerequisite() { -// missingPrerequisite(); -// AddOpenNetworkCallbacks mockCallbacks = mock(AddOpenNetworkCallbacks.class); -// mWiseFy.addOpenNetwork(OPEN_NETWORK_SSID, mockCallbacks); -// verify(mockCallbacks, timeout(VERIFICATION_TIMEOUT)).addOpenNetworkWiseFyFailure(WiseFyCodes.MISSING_PREREQUISITE); -// verify(mMockWiFiManager, never()).addNetwork(any(WifiConfiguration.class)); -// } -// -// @Test -// public void callbacks_failure_missingPrerequisite_nullCallback() { -// missingPrerequisite(); -// try { -// mWiseFy.addOpenNetwork(OPEN_NETWORK_SSID, null); -// verify(mMockWiFiManager, never()).addNetwork(any(WifiConfiguration.class)); -// } catch (NullPointerException npe) { -// fail(); -// } -// } -// -// @Test -// public void callbacks_success() { -// when(mMockWiFiManager.addNetwork(any(WifiConfiguration.class))).thenReturn(0); -// AddOpenNetworkCallbacks mockCallbacks = mock(AddOpenNetworkCallbacks.class); -// mWiseFy.addOpenNetwork(OPEN_NETWORK_SSID, mockCallbacks); -// verify(mockCallbacks, timeout(VERIFICATION_TIMEOUT)).openNetworkAdded(any(WifiConfiguration.class)); -// verify(mMockWiFiManager, timeout(VERIFICATION_TIMEOUT)).addNetwork(any(WifiConfiguration.class)); -// } -// -// @Test -// public void callbacks_success_nullCallback() { -// when(mMockWiFiManager.addNetwork(any(WifiConfiguration.class))).thenReturn(0); -// try { -// mWiseFy.addOpenNetwork(OPEN_NETWORK_SSID, null); -// verify(mMockWiFiManager, never()).addNetwork(any(WifiConfiguration.class)); -// } catch (NullPointerException npe) { -// fail(); -// } -// } -// -// @Test -// public void callbacks_success_alreadyConfigured() { -// networkAlreadyInConfigurationList(); -// -// AddOpenNetworkCallbacks mockCallbacks = mock(AddOpenNetworkCallbacks.class); -// mWiseFy.addOpenNetwork(OPEN_NETWORK_SSID, mockCallbacks); -// verify(mockCallbacks, timeout(VERIFICATION_TIMEOUT)).addOpenNetworkWiseFyFailure(WiseFyCodes.NETWORK_ALREADY_CONFIGURED); -// verify(mMockWiFiManager, never()).addNetwork(any(WifiConfiguration.class)); -// } -// -// @Test -// public void callbacks_success_alreadyConfigured_nullCallback() { -// networkAlreadyInConfigurationList(); -// -// try { -// mWiseFy.addOpenNetwork(OPEN_NETWORK_SSID, null); -// verify(mMockWiFiManager, never()).addNetwork(any(WifiConfiguration.class)); -// } catch (NullPointerException npe) { -// fail(); -// } -// } -//} \ No newline at end of file +package com.isupatches.wisefy; + + +import android.net.wifi.WifiConfiguration; +import com.isupatches.wisefy.callbacks.AddOpenNetworkCallbacks; +import com.isupatches.wisefy.constants.WiseFyCodes; +import org.junit.Assert; +import org.junit.Test; +import static com.isupatches.wisefy.base.TestUtils.OPEN_NETWORK_SSID; +import static junit.framework.Assert.assertEquals; +import static org.junit.Assert.*; +import static org.junit.Assert.fail; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.never; +import static org.mockito.Mockito.timeout; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; + + +public class AddOpenNetworkTests extends BaseAndroidJUnit4TestClass { + + @Test + public void noCallbacks_failure() { + when(mMockWiFiManager.addNetwork(any(WifiConfiguration.class))).thenReturn(WiseFy.WIFI_MANAGER_FAILURE); + assertEquals(WiseFy.WIFI_MANAGER_FAILURE, mWiseFy.addOpenNetwork(OPEN_NETWORK_SSID)); + verify(mMockWiFiManager, timeout(VERIFICATION_TIMEOUT)).addNetwork(any(WifiConfiguration.class)); + } + + @Test + public void noCallbacks_failure_nullSSIDParam() { + Assert.assertEquals(WiseFyCodes.MISSING_PARAMETER, mWiseFy.addOpenNetwork(null)); + verify(mMockWiFiManager, never()).addNetwork(any(WifiConfiguration.class)); + } + + @Test + public void noCallbacks_failure_missingPrerequisite() { + missingPrerequisite(); + assertEquals(WiseFyCodes.MISSING_PREREQUISITE, mWiseFy.addOpenNetwork(OPEN_NETWORK_SSID)); + verify(mMockWiFiManager, never()).addNetwork(any(WifiConfiguration.class)); + } + + @Test + public void noCallbacks_success() { + when(mMockWiFiManager.addNetwork(any(WifiConfiguration.class))).thenReturn(0); + assertNotEquals(WiseFy.WIFI_MANAGER_FAILURE, mWiseFy.addOpenNetwork(OPEN_NETWORK_SSID)); + verify(mMockWiFiManager, timeout(VERIFICATION_TIMEOUT)).addNetwork(any(WifiConfiguration.class)); + } + + @Test + public void noCallbacks_success_alreadyConfigured() { + networkAlreadyInConfigurationList(); + assertEquals(WiseFyCodes.NETWORK_ALREADY_CONFIGURED, mWiseFy.addOpenNetwork(OPEN_NETWORK_SSID)); + verify(mMockWiFiManager, never()).addNetwork(any(WifiConfiguration.class)); + } + + @Test + public void callbacks_failure() { + when(mMockWiFiManager.addNetwork(any(WifiConfiguration.class))).thenReturn(WiseFy.WIFI_MANAGER_FAILURE); + AddOpenNetworkCallbacks mockCallbacks = mock(AddOpenNetworkCallbacks.class); + mWiseFy.addOpenNetwork(OPEN_NETWORK_SSID, mockCallbacks); + verify(mockCallbacks, timeout(VERIFICATION_TIMEOUT)).failureAddingOpenNetwork(WiseFy.WIFI_MANAGER_FAILURE); + verify(mMockWiFiManager, timeout(VERIFICATION_TIMEOUT)).addNetwork(any(WifiConfiguration.class)); + } + + @Test + public void callbacks_failure_nullCallback() { + when(mMockWiFiManager.addNetwork(any(WifiConfiguration.class))).thenReturn(WiseFy.WIFI_MANAGER_FAILURE); + try { + mWiseFy.addOpenNetwork(OPEN_NETWORK_SSID, null); + verify(mMockWiFiManager, never()).addNetwork(any(WifiConfiguration.class)); + } catch (NullPointerException npe) { + fail(); + } + } + + @Test + public void callbacks_failure_nullSSIDParam() { + AddOpenNetworkCallbacks mockCallbacks = mock(AddOpenNetworkCallbacks.class); + mWiseFy.addOpenNetwork(null, mockCallbacks); + verify(mockCallbacks, timeout(VERIFICATION_TIMEOUT)).addOpenNetworkWiseFyFailure(WiseFyCodes.MISSING_PARAMETER); + verify(mMockWiFiManager, never()).addNetwork(any(WifiConfiguration.class)); + } + + @Test + public void callbacks_failure_nullSSIDParam_nullCallback() { + try { + mWiseFy.addOpenNetwork(null, null); + verify(mMockWiFiManager, never()).addNetwork(any(WifiConfiguration.class)); + } catch (NullPointerException npe) { + fail(); + } + } + + @Test + public void callbacks_failure_missingPrerequisite() { + missingPrerequisite(); + AddOpenNetworkCallbacks mockCallbacks = mock(AddOpenNetworkCallbacks.class); + mWiseFy.addOpenNetwork(OPEN_NETWORK_SSID, mockCallbacks); + verify(mockCallbacks, timeout(VERIFICATION_TIMEOUT)).addOpenNetworkWiseFyFailure(WiseFyCodes.MISSING_PREREQUISITE); + verify(mMockWiFiManager, never()).addNetwork(any(WifiConfiguration.class)); + } + + @Test + public void callbacks_failure_missingPrerequisite_nullCallback() { + missingPrerequisite(); + try { + mWiseFy.addOpenNetwork(OPEN_NETWORK_SSID, null); + verify(mMockWiFiManager, never()).addNetwork(any(WifiConfiguration.class)); + } catch (NullPointerException npe) { + fail(); + } + } + + @Test + public void callbacks_success() { + when(mMockWiFiManager.addNetwork(any(WifiConfiguration.class))).thenReturn(0); + AddOpenNetworkCallbacks mockCallbacks = mock(AddOpenNetworkCallbacks.class); + mWiseFy.addOpenNetwork(OPEN_NETWORK_SSID, mockCallbacks); + verify(mockCallbacks, timeout(VERIFICATION_TIMEOUT)).openNetworkAdded(any(WifiConfiguration.class)); + verify(mMockWiFiManager, timeout(VERIFICATION_TIMEOUT)).addNetwork(any(WifiConfiguration.class)); + } + + @Test + public void callbacks_success_nullCallback() { + when(mMockWiFiManager.addNetwork(any(WifiConfiguration.class))).thenReturn(0); + try { + mWiseFy.addOpenNetwork(OPEN_NETWORK_SSID, null); + verify(mMockWiFiManager, never()).addNetwork(any(WifiConfiguration.class)); + } catch (NullPointerException npe) { + fail(); + } + } + + @Test + public void callbacks_success_alreadyConfigured() { + networkAlreadyInConfigurationList(); + + AddOpenNetworkCallbacks mockCallbacks = mock(AddOpenNetworkCallbacks.class); + mWiseFy.addOpenNetwork(OPEN_NETWORK_SSID, mockCallbacks); + verify(mockCallbacks, timeout(VERIFICATION_TIMEOUT)).addOpenNetworkWiseFyFailure(WiseFyCodes.NETWORK_ALREADY_CONFIGURED); + verify(mMockWiFiManager, never()).addNetwork(any(WifiConfiguration.class)); + } + + @Test + public void callbacks_success_alreadyConfigured_nullCallback() { + networkAlreadyInConfigurationList(); + + try { + mWiseFy.addOpenNetwork(OPEN_NETWORK_SSID, null); + verify(mMockWiFiManager, never()).addNetwork(any(WifiConfiguration.class)); + } catch (NullPointerException npe) { + fail(); + } + } +} \ No newline at end of file diff --git a/wisefy/src/androidTest/java/com/isupatches/wisefy/AddWEPNetworkTests.java b/wisefy/src/androidTest/java/com/isupatches/wisefy/AddWEPNetworkTests.java index d8da7f89..9e672ec7 100644 --- a/wisefy/src/androidTest/java/com/isupatches/wisefy/AddWEPNetworkTests.java +++ b/wisefy/src/androidTest/java/com/isupatches/wisefy/AddWEPNetworkTests.java @@ -1,188 +1,182 @@ -//package com.isupatches.wisefy; -// -// -//import android.net.wifi.WifiConfiguration; -//import com.isupatches.wisefy.base.TestActivity; -//import com.isupatches.wisefy.callbacks.AddWEPNetworkCallbacks; -//import com.isupatches.wisefy.constants.WiseFyCodes; -//import org.junit.Test; -//import static com.isupatches.wisefy.base.TestUtils.WEP_NETWORK_PASSWORD; -//import static com.isupatches.wisefy.base.TestUtils.WEP_NETWORK_SSID; -//import static org.junit.Assert.assertEquals; -//import static org.junit.Assert.assertNotEquals; -//import static org.junit.Assert.fail; -//import static org.mockito.ArgumentMatchers.any; -//import static org.mockito.Mockito.mock; -//import static org.mockito.Mockito.never; -//import static org.mockito.Mockito.timeout; -//import static org.mockito.Mockito.verify; -//import static org.mockito.Mockito.when; -// -// -//public class AddWEPNetworkTests extends BaseTestClass { -// -// public AddWEPNetworkTests() { -// super(TestActivity.class); -// } -// -// @Test -// public void noCallbacks_failure() { -// when(mMockWiFiManager.addNetwork(any(WifiConfiguration.class))).thenReturn(WiseFy.WIFI_MANAGER_FAILURE); -// assertEquals(WiseFy.WIFI_MANAGER_FAILURE, mWiseFy.addWEPNetwork(WEP_NETWORK_SSID, WEP_NETWORK_PASSWORD)); -// verify(mMockWiFiManager, timeout(VERIFICATION_TIMEOUT)).addNetwork(any(WifiConfiguration.class)); -// } -// -// @Test -// public void noCallbacks_failure_nullPasswordParam() { -// assertEquals(WiseFyCodes.MISSING_PARAMETER, mWiseFy.addWEPNetwork(WEP_NETWORK_SSID, null)); -// verify(mMockWiFiManager, never()).addNetwork(any(WifiConfiguration.class)); -// } -// -// @Test -// public void noCallbacks_failure_nullSSIDParam() { -// assertEquals(WiseFyCodes.MISSING_PARAMETER, mWiseFy.addWEPNetwork(null, WEP_NETWORK_PASSWORD)); -// verify(mMockWiFiManager, never()).addNetwork(any(WifiConfiguration.class)); -// } -// -// @Test -// public void noCallbacks_failure_missingPrerequisite() { -// missingPrerequisite(); -// assertEquals(WiseFyCodes.MISSING_PREREQUISITE, mWiseFy.addWEPNetwork(WEP_NETWORK_SSID, WEP_NETWORK_PASSWORD)); -// verify(mMockWiFiManager, never()).addNetwork(any(WifiConfiguration.class)); -// } -// -// @Test -// public void noCallbacks_success() { -// when(mMockWiFiManager.addNetwork(any(WifiConfiguration.class))).thenReturn(0); -// assertNotEquals(WiseFy.WIFI_MANAGER_FAILURE, mWiseFy.addWEPNetwork(WEP_NETWORK_SSID, WEP_NETWORK_PASSWORD)); -// verify(mMockWiFiManager, timeout(VERIFICATION_TIMEOUT)).addNetwork(any(WifiConfiguration.class)); -// } -// -// @Test -// public void noCallbacks_success_alreadyConfigured() { -// networkAlreadyInConfigurationList(); -// assertEquals(WiseFyCodes.NETWORK_ALREADY_CONFIGURED, mWiseFy.addWEPNetwork(WEP_NETWORK_SSID, WEP_NETWORK_PASSWORD)); -// verify(mMockWiFiManager, never()).addNetwork(any(WifiConfiguration.class)); -// } -// -// @Test -// public void callbacks_failure() { -// when(mMockWiFiManager.addNetwork(any(WifiConfiguration.class))).thenReturn(WiseFy.WIFI_MANAGER_FAILURE); -// AddWEPNetworkCallbacks mockCallbacks = mock(AddWEPNetworkCallbacks.class); -// mWiseFy.addWEPNetwork(WEP_NETWORK_SSID, WEP_NETWORK_PASSWORD, mockCallbacks); -// verify(mockCallbacks, timeout(VERIFICATION_TIMEOUT)).failureAddingWEPNetwork(WiseFy.WIFI_MANAGER_FAILURE); -// verify(mMockWiFiManager, timeout(VERIFICATION_TIMEOUT)).addNetwork(any(WifiConfiguration.class)); -// } -// -// @Test -// public void callbacks_failure_nullCallback() { -// when(mMockWiFiManager.addNetwork(any(WifiConfiguration.class))).thenReturn(WiseFy.WIFI_MANAGER_FAILURE); -// -// try { -// mWiseFy.addWEPNetwork(WEP_NETWORK_SSID, WEP_NETWORK_PASSWORD, null); -// verify(mMockWiFiManager, never()).addNetwork(any(WifiConfiguration.class)); -// } catch (NullPointerException npe) { -// fail(); -// } -// } -// -// @Test -// public void callbacks_failure_nullPasswordParam() { -// AddWEPNetworkCallbacks mockCallbacks = mock(AddWEPNetworkCallbacks.class); -// mWiseFy.addWEPNetwork(WEP_NETWORK_SSID, null, mockCallbacks); -// verify(mockCallbacks, timeout(VERIFICATION_TIMEOUT)).addWEPNetworkWiseFyFailure(WiseFyCodes.MISSING_PARAMETER); -// verify(mMockWiFiManager, never()).addNetwork(any(WifiConfiguration.class)); -// } -// -// @Test -// public void callbacks_failure_nullPasswordParam_nullCallback() { -// try { -// mWiseFy.addWEPNetwork(WEP_NETWORK_SSID, null, null); -// verify(mMockWiFiManager, never()).addNetwork(any(WifiConfiguration.class)); -// } catch (NullPointerException npe) { -// fail(); -// } -// } -// -// @Test -// public void callbacks_failure_nullSSIDParam() { -// AddWEPNetworkCallbacks mockCallbacks = mock(AddWEPNetworkCallbacks.class); -// mWiseFy.addWEPNetwork(null, WEP_NETWORK_PASSWORD, mockCallbacks); -// verify(mockCallbacks, timeout(VERIFICATION_TIMEOUT)).addWEPNetworkWiseFyFailure(WiseFyCodes.MISSING_PARAMETER); -// verify(mMockWiFiManager, never()).addNetwork(any(WifiConfiguration.class)); -// } -// -// @Test -// public void callbacks_failure_nullSSIDParam_nullCallback() { -// try { -// mWiseFy.addWEPNetwork(null, WEP_NETWORK_PASSWORD, null); -// verify(mMockWiFiManager, never()).addNetwork(any(WifiConfiguration.class)); -// } catch (NullPointerException npe) { -// fail(); -// } -// } -// -// @Test -// public void callbacks_failure_missingPrerequisite() { -// missingPrerequisite(); -// AddWEPNetworkCallbacks mockCallbacks = mock(AddWEPNetworkCallbacks.class); -// mWiseFy.addWEPNetwork(WEP_NETWORK_SSID, WEP_NETWORK_PASSWORD, mockCallbacks); -// verify(mockCallbacks, timeout(VERIFICATION_TIMEOUT)).addWEPNetworkWiseFyFailure(WiseFyCodes.MISSING_PREREQUISITE); -// verify(mMockWiFiManager, never()).addNetwork(any(WifiConfiguration.class)); -// } -// -// @Test -// public void callbacks_failure_missingPrerequisite_nullCallback() { -// missingPrerequisite(); -// -// try { -// mWiseFy.addWEPNetwork(WEP_NETWORK_SSID, WEP_NETWORK_PASSWORD, null); -// verify(mMockWiFiManager, never()).addNetwork(any(WifiConfiguration.class)); -// } catch (NullPointerException npe) { -// fail(); -// } -// } -// -// @Test -// public void callbacks_success() { -// when(mMockWiFiManager.addNetwork(any(WifiConfiguration.class))).thenReturn(0); -// AddWEPNetworkCallbacks mockCallbacks = mock(AddWEPNetworkCallbacks.class); -// mWiseFy.addWEPNetwork(WEP_NETWORK_SSID, WEP_NETWORK_PASSWORD, mockCallbacks); -// verify(mockCallbacks, timeout(VERIFICATION_TIMEOUT)).wepNetworkAdded(any(WifiConfiguration.class)); -// verify(mMockWiFiManager, timeout(VERIFICATION_TIMEOUT)).addNetwork(any(WifiConfiguration.class)); -// } -// -// @Test -// public void callbacks_success_nullCallback() { -// when(mMockWiFiManager.addNetwork(any(WifiConfiguration.class))).thenReturn(0); -// -// try { -// mWiseFy.addWEPNetwork(WEP_NETWORK_SSID, WEP_NETWORK_PASSWORD, null); -// verify(mMockWiFiManager, never()).addNetwork(any(WifiConfiguration.class)); -// } catch (NullPointerException npe) { -// fail(); -// } -// } -// -// @Test -// public void callbacks_success_alreadyConfigured() { -// networkAlreadyInConfigurationList(); -// -// AddWEPNetworkCallbacks mockCallbacks = mock(AddWEPNetworkCallbacks.class); -// mWiseFy.addWEPNetwork(WEP_NETWORK_SSID, WEP_NETWORK_PASSWORD, mockCallbacks); -// verify(mockCallbacks, timeout(VERIFICATION_TIMEOUT)).addWEPNetworkWiseFyFailure(WiseFyCodes.NETWORK_ALREADY_CONFIGURED); -// verify(mMockWiFiManager, never()).addNetwork(any(WifiConfiguration.class)); -// } -// -// @Test -// public void callbacks_success_alreadyConfigured_nullCallback() { -// networkAlreadyInConfigurationList(); -// -// try { -// mWiseFy.addWEPNetwork(WEP_NETWORK_SSID, WEP_NETWORK_PASSWORD, null); -// verify(mMockWiFiManager, never()).addNetwork(any(WifiConfiguration.class)); -// } catch (NullPointerException npe) { -// fail(); -// } -// } -//} +package com.isupatches.wisefy; + + +import android.net.wifi.WifiConfiguration; +import com.isupatches.wisefy.base.TestUtils; +import com.isupatches.wisefy.callbacks.AddWEPNetworkCallbacks; +import com.isupatches.wisefy.constants.WiseFyCodes; +import org.junit.Test; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotEquals; +import static org.junit.Assert.fail; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.never; +import static org.mockito.Mockito.timeout; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; + + +public class AddWEPNetworkTests extends BaseAndroidJUnit4TestClass { + + @Test + public void noCallbacks_failure() { + when(mMockWiFiManager.addNetwork(any(WifiConfiguration.class))).thenReturn(WiseFy.WIFI_MANAGER_FAILURE); + assertEquals(WiseFy.WIFI_MANAGER_FAILURE, mWiseFy.addWEPNetwork(TestUtils.WEP_NETWORK_SSID, TestUtils.WEP_NETWORK_PASSWORD)); + verify(mMockWiFiManager, timeout(VERIFICATION_TIMEOUT)).addNetwork(any(WifiConfiguration.class)); + } + + @Test + public void noCallbacks_failure_nullPasswordParam() { + assertEquals(WiseFyCodes.MISSING_PARAMETER, mWiseFy.addWEPNetwork(TestUtils.WEP_NETWORK_SSID, null)); + verify(mMockWiFiManager, never()).addNetwork(any(WifiConfiguration.class)); + } + + @Test + public void noCallbacks_failure_nullSSIDParam() { + assertEquals(WiseFyCodes.MISSING_PARAMETER, mWiseFy.addWEPNetwork(null, TestUtils.WEP_NETWORK_PASSWORD)); + verify(mMockWiFiManager, never()).addNetwork(any(WifiConfiguration.class)); + } + + @Test + public void noCallbacks_failure_missingPrerequisite() { + missingPrerequisite(); + assertEquals(WiseFyCodes.MISSING_PREREQUISITE, mWiseFy.addWEPNetwork(TestUtils.WEP_NETWORK_SSID, TestUtils.WEP_NETWORK_PASSWORD)); + verify(mMockWiFiManager, never()).addNetwork(any(WifiConfiguration.class)); + } + + @Test + public void noCallbacks_success() { + when(mMockWiFiManager.addNetwork(any(WifiConfiguration.class))).thenReturn(0); + assertNotEquals(WiseFy.WIFI_MANAGER_FAILURE, mWiseFy.addWEPNetwork(TestUtils.WEP_NETWORK_SSID, TestUtils.WEP_NETWORK_PASSWORD)); + verify(mMockWiFiManager, timeout(VERIFICATION_TIMEOUT)).addNetwork(any(WifiConfiguration.class)); + } + + @Test + public void noCallbacks_success_alreadyConfigured() { + networkAlreadyInConfigurationList(); + assertEquals(WiseFyCodes.NETWORK_ALREADY_CONFIGURED, mWiseFy.addWEPNetwork(TestUtils.WEP_NETWORK_SSID, TestUtils.WEP_NETWORK_PASSWORD)); + verify(mMockWiFiManager, never()).addNetwork(any(WifiConfiguration.class)); + } + + @Test + public void callbacks_failure() { + when(mMockWiFiManager.addNetwork(any(WifiConfiguration.class))).thenReturn(WiseFy.WIFI_MANAGER_FAILURE); + AddWEPNetworkCallbacks mockCallbacks = mock(AddWEPNetworkCallbacks.class); + mWiseFy.addWEPNetwork(TestUtils.WEP_NETWORK_SSID, TestUtils.WEP_NETWORK_PASSWORD, mockCallbacks); + verify(mockCallbacks, timeout(VERIFICATION_TIMEOUT)).failureAddingWEPNetwork(WiseFy.WIFI_MANAGER_FAILURE); + verify(mMockWiFiManager, timeout(VERIFICATION_TIMEOUT)).addNetwork(any(WifiConfiguration.class)); + } + + @Test + public void callbacks_failure_nullCallback() { + when(mMockWiFiManager.addNetwork(any(WifiConfiguration.class))).thenReturn(WiseFy.WIFI_MANAGER_FAILURE); + + try { + mWiseFy.addWEPNetwork(TestUtils.WEP_NETWORK_SSID, TestUtils.WEP_NETWORK_PASSWORD, null); + verify(mMockWiFiManager, never()).addNetwork(any(WifiConfiguration.class)); + } catch (NullPointerException npe) { + fail(); + } + } + + @Test + public void callbacks_failure_nullPasswordParam() { + AddWEPNetworkCallbacks mockCallbacks = mock(AddWEPNetworkCallbacks.class); + mWiseFy.addWEPNetwork(TestUtils.WEP_NETWORK_SSID, null, mockCallbacks); + verify(mockCallbacks, timeout(VERIFICATION_TIMEOUT)).addWEPNetworkWiseFyFailure(WiseFyCodes.MISSING_PARAMETER); + verify(mMockWiFiManager, never()).addNetwork(any(WifiConfiguration.class)); + } + + @Test + public void callbacks_failure_nullPasswordParam_nullCallback() { + try { + mWiseFy.addWEPNetwork(TestUtils.WEP_NETWORK_SSID, null, null); + verify(mMockWiFiManager, never()).addNetwork(any(WifiConfiguration.class)); + } catch (NullPointerException npe) { + fail(); + } + } + + @Test + public void callbacks_failure_nullSSIDParam() { + AddWEPNetworkCallbacks mockCallbacks = mock(AddWEPNetworkCallbacks.class); + mWiseFy.addWEPNetwork(null, TestUtils.WEP_NETWORK_PASSWORD, mockCallbacks); + verify(mockCallbacks, timeout(VERIFICATION_TIMEOUT)).addWEPNetworkWiseFyFailure(WiseFyCodes.MISSING_PARAMETER); + verify(mMockWiFiManager, never()).addNetwork(any(WifiConfiguration.class)); + } + + @Test + public void callbacks_failure_nullSSIDParam_nullCallback() { + try { + mWiseFy.addWEPNetwork(null, TestUtils.WEP_NETWORK_PASSWORD, null); + verify(mMockWiFiManager, never()).addNetwork(any(WifiConfiguration.class)); + } catch (NullPointerException npe) { + fail(); + } + } + + @Test + public void callbacks_failure_missingPrerequisite() { + missingPrerequisite(); + AddWEPNetworkCallbacks mockCallbacks = mock(AddWEPNetworkCallbacks.class); + mWiseFy.addWEPNetwork(TestUtils.WEP_NETWORK_SSID, TestUtils.WEP_NETWORK_PASSWORD, mockCallbacks); + verify(mockCallbacks, timeout(VERIFICATION_TIMEOUT)).addWEPNetworkWiseFyFailure(WiseFyCodes.MISSING_PREREQUISITE); + verify(mMockWiFiManager, never()).addNetwork(any(WifiConfiguration.class)); + } + + @Test + public void callbacks_failure_missingPrerequisite_nullCallback() { + missingPrerequisite(); + + try { + mWiseFy.addWEPNetwork(TestUtils.WEP_NETWORK_SSID, TestUtils.WEP_NETWORK_PASSWORD, null); + verify(mMockWiFiManager, never()).addNetwork(any(WifiConfiguration.class)); + } catch (NullPointerException npe) { + fail(); + } + } + + @Test + public void callbacks_success() { + when(mMockWiFiManager.addNetwork(any(WifiConfiguration.class))).thenReturn(0); + AddWEPNetworkCallbacks mockCallbacks = mock(AddWEPNetworkCallbacks.class); + mWiseFy.addWEPNetwork(TestUtils.WEP_NETWORK_SSID, TestUtils.WEP_NETWORK_PASSWORD, mockCallbacks); + verify(mockCallbacks, timeout(VERIFICATION_TIMEOUT)).wepNetworkAdded(any(WifiConfiguration.class)); + verify(mMockWiFiManager, timeout(VERIFICATION_TIMEOUT)).addNetwork(any(WifiConfiguration.class)); + } + + @Test + public void callbacks_success_nullCallback() { + when(mMockWiFiManager.addNetwork(any(WifiConfiguration.class))).thenReturn(0); + + try { + mWiseFy.addWEPNetwork(TestUtils.WEP_NETWORK_SSID, TestUtils.WEP_NETWORK_PASSWORD, null); + verify(mMockWiFiManager, never()).addNetwork(any(WifiConfiguration.class)); + } catch (NullPointerException npe) { + fail(); + } + } + + @Test + public void callbacks_success_alreadyConfigured() { + networkAlreadyInConfigurationList(); + + AddWEPNetworkCallbacks mockCallbacks = mock(AddWEPNetworkCallbacks.class); + mWiseFy.addWEPNetwork(TestUtils.WEP_NETWORK_SSID, TestUtils.WEP_NETWORK_PASSWORD, mockCallbacks); + verify(mockCallbacks, timeout(VERIFICATION_TIMEOUT)).addWEPNetworkWiseFyFailure(WiseFyCodes.NETWORK_ALREADY_CONFIGURED); + verify(mMockWiFiManager, never()).addNetwork(any(WifiConfiguration.class)); + } + + @Test + public void callbacks_success_alreadyConfigured_nullCallback() { + networkAlreadyInConfigurationList(); + + try { + mWiseFy.addWEPNetwork(TestUtils.WEP_NETWORK_SSID, TestUtils.WEP_NETWORK_PASSWORD, null); + verify(mMockWiFiManager, never()).addNetwork(any(WifiConfiguration.class)); + } catch (NullPointerException npe) { + fail(); + } + } +} diff --git a/wisefy/src/androidTest/java/com/isupatches/wisefy/AddWPA2NetworkTests.java b/wisefy/src/androidTest/java/com/isupatches/wisefy/AddWPA2NetworkTests.java index fab3629a..684e00c7 100644 --- a/wisefy/src/androidTest/java/com/isupatches/wisefy/AddWPA2NetworkTests.java +++ b/wisefy/src/androidTest/java/com/isupatches/wisefy/AddWPA2NetworkTests.java @@ -1,187 +1,181 @@ -//package com.isupatches.wisefy; -// -// -//import android.net.wifi.WifiConfiguration; -//import com.isupatches.wisefy.base.TestActivity; -//import com.isupatches.wisefy.callbacks.AddWPA2NetworkCallbacks; -//import com.isupatches.wisefy.constants.WiseFyCodes; -//import org.junit.Test; -//import static com.isupatches.wisefy.base.TestUtils.WPA2_NETWORK_PASSWORD; -//import static com.isupatches.wisefy.base.TestUtils.WPA2_NETWORK_SSID; -//import static org.junit.Assert.assertEquals; -//import static org.junit.Assert.assertNotEquals; -//import static org.junit.Assert.fail; -//import static org.mockito.ArgumentMatchers.any; -//import static org.mockito.Mockito.mock; -//import static org.mockito.Mockito.never; -//import static org.mockito.Mockito.timeout; -//import static org.mockito.Mockito.verify; -//import static org.mockito.Mockito.when; -// -// -//public class AddWPA2NetworkTests extends BaseTestClass { -// -// public AddWPA2NetworkTests() { -// super(TestActivity.class); -// } -// -// @Test -// public void noCallbacks_failure() { -// when(mMockWiFiManager.addNetwork(any(WifiConfiguration.class))).thenReturn(WiseFy.WIFI_MANAGER_FAILURE); -// assertEquals(WiseFy.WIFI_MANAGER_FAILURE, mWiseFy.addWPA2Network(WPA2_NETWORK_SSID, WPA2_NETWORK_PASSWORD)); -// verify(mMockWiFiManager, timeout(VERIFICATION_TIMEOUT)).addNetwork(any(WifiConfiguration.class)); -// } -// -// @Test -// public void noCallbacks_failure_nullPasswordParam() { -// assertEquals(WiseFyCodes.MISSING_PARAMETER, mWiseFy.addWPA2Network(WPA2_NETWORK_SSID, null)); -// verify(mMockWiFiManager, never()).addNetwork(any(WifiConfiguration.class)); -// } -// -// @Test -// public void anoCallbacks_failure_nullSSIDParam() { -// assertEquals(WiseFyCodes.MISSING_PARAMETER, mWiseFy.addWPA2Network(null, WPA2_NETWORK_PASSWORD)); -// verify(mMockWiFiManager, never()).addNetwork(any(WifiConfiguration.class)); -// } -// -// @Test -// public void noCallbacks_failure_missingPrerequisite() { -// missingPrerequisite(); -// assertEquals(WiseFyCodes.MISSING_PREREQUISITE, mWiseFy.addWPA2Network(WPA2_NETWORK_SSID, WPA2_NETWORK_PASSWORD)); -// verify(mMockWiFiManager, never()).addNetwork(any(WifiConfiguration.class)); -// } -// -// @Test -// public void noCallbacks_success() { -// when(mMockWiFiManager.addNetwork(any(WifiConfiguration.class))).thenReturn(0); -// assertNotEquals(WiseFy.WIFI_MANAGER_FAILURE, mWiseFy.addWPA2Network(WPA2_NETWORK_SSID, WPA2_NETWORK_PASSWORD)); -// verify(mMockWiFiManager, timeout(VERIFICATION_TIMEOUT)).addNetwork(any(WifiConfiguration.class)); -// } -// -// @Test -// public void noCallbacks_success_alreadyConfigured() { -// networkAlreadyInConfigurationList(); -// assertEquals(WiseFyCodes.NETWORK_ALREADY_CONFIGURED, mWiseFy.addWPA2Network(WPA2_NETWORK_SSID, WPA2_NETWORK_PASSWORD)); -// verify(mMockWiFiManager, never()).addNetwork(any(WifiConfiguration.class)); -// } -// -// @Test -// public void callbacks_failure() { -// when(mMockWiFiManager.addNetwork(any(WifiConfiguration.class))).thenReturn(WiseFy.WIFI_MANAGER_FAILURE); -// AddWPA2NetworkCallbacks mockCallbacks = mock(AddWPA2NetworkCallbacks.class); -// mWiseFy.addWPA2Network(WPA2_NETWORK_SSID, WPA2_NETWORK_PASSWORD, mockCallbacks); -// verify(mockCallbacks, timeout(VERIFICATION_TIMEOUT)).failureAddingWPA2Network(WiseFy.WIFI_MANAGER_FAILURE); -// verify(mMockWiFiManager, timeout(VERIFICATION_TIMEOUT)).addNetwork(any(WifiConfiguration.class)); -// } -// -// @Test -// public void callbacks_failure_nullCallback() { -// when(mMockWiFiManager.addNetwork(any(WifiConfiguration.class))).thenReturn(WiseFy.WIFI_MANAGER_FAILURE); -// try { -// mWiseFy.addWPA2Network(WPA2_NETWORK_SSID, WPA2_NETWORK_PASSWORD, null); -// verify(mMockWiFiManager, never()).addNetwork(any(WifiConfiguration.class)); -// } catch (NullPointerException npe) { -// fail(); -// } -// } -// -// @Test -// public void callbacks_failure_nullPasswordParam() { -// AddWPA2NetworkCallbacks mockCallbacks = mock(AddWPA2NetworkCallbacks.class); -// mWiseFy.addWPA2Network(WPA2_NETWORK_SSID, null, mockCallbacks); -// verify(mockCallbacks, timeout(VERIFICATION_TIMEOUT)).addWPA2NetworkWiseFyFailure(WiseFyCodes.MISSING_PARAMETER); -// verify(mMockWiFiManager, never()).addNetwork(any(WifiConfiguration.class)); -// } -// -// @Test -// public void callbacks_failure_nullPasswordParam_nullCallback() { -// try { -// mWiseFy.addWPA2Network(WPA2_NETWORK_SSID, null, null); -// verify(mMockWiFiManager, never()).addNetwork(any(WifiConfiguration.class)); -// } catch (NullPointerException npe) { -// fail(); -// } -// } -// -// @Test -// public void callbacks_failure_nullSSIDParam() { -// AddWPA2NetworkCallbacks mockCallbacks = mock(AddWPA2NetworkCallbacks.class); -// mWiseFy.addWPA2Network(null, WPA2_NETWORK_PASSWORD, mockCallbacks); -// verify(mockCallbacks, never()).addWPA2NetworkWiseFyFailure(WiseFyCodes.MISSING_PARAMETER); -// } -// -// @Test -// public void callbacks_failure_nullSSIDParam_nullCallback() { -// try { -// mWiseFy.addWPA2Network(null, WPA2_NETWORK_PASSWORD, null); -// verify(mMockWiFiManager, never()).addNetwork(any(WifiConfiguration.class)); -// } catch (NullPointerException npe) { -// fail(); -// } -// } -// -// @Test -// public void callbacks_failure_missingPrerequisite() { -// missingPrerequisite(); -// -// AddWPA2NetworkCallbacks mockCallbacks = mock(AddWPA2NetworkCallbacks.class); -// mWiseFy.addWPA2Network(WPA2_NETWORK_SSID, WPA2_NETWORK_PASSWORD, mockCallbacks); -// verify(mockCallbacks, timeout(VERIFICATION_TIMEOUT)).addWPA2NetworkWiseFyFailure(WiseFyCodes.MISSING_PREREQUISITE); -// verify(mMockWiFiManager, never()).addNetwork(any(WifiConfiguration.class)); -// } -// -// @Test -// public void callbacks_failure_missingPrerequisite_nullCallback() { -// missingPrerequisite(); -// -// try { -// mWiseFy.addWPA2Network(WPA2_NETWORK_SSID, WPA2_NETWORK_PASSWORD, null); -// verify(mMockWiFiManager, never()).addNetwork(any(WifiConfiguration.class)); -// } catch (NullPointerException npe) { -// fail(); -// } -// } -// -// @Test -// public void callbacks_success() { -// when(mMockWiFiManager.addNetwork(any(WifiConfiguration.class))).thenReturn(0); -// AddWPA2NetworkCallbacks mockCallbacks = mock(AddWPA2NetworkCallbacks.class); -// mWiseFy.addWPA2Network(WPA2_NETWORK_SSID, WPA2_NETWORK_PASSWORD, mockCallbacks); -// verify(mockCallbacks, timeout(VERIFICATION_TIMEOUT)).wpa2NetworkAdded(any(WifiConfiguration.class)); -// verify(mMockWiFiManager, timeout(VERIFICATION_TIMEOUT)).addNetwork(any(WifiConfiguration.class)); -// } -// -// @Test -// public void callbacks_success_nullCallback() { -// when(mMockWiFiManager.addNetwork(any(WifiConfiguration.class))).thenReturn(0); -// -// try { -// mWiseFy.addWPA2Network(WPA2_NETWORK_SSID, WPA2_NETWORK_PASSWORD, null); -// verify(mMockWiFiManager, never()).addNetwork(any(WifiConfiguration.class)); -// } catch (NullPointerException npe) { -// fail(); -// } -// } -// -// @Test -// public void callbacks_success_alreadyConfigured() { -// networkAlreadyInConfigurationList(); -// -// AddWPA2NetworkCallbacks mockCallbacks = mock(AddWPA2NetworkCallbacks.class); -// mWiseFy.addWPA2Network(WPA2_NETWORK_SSID, WPA2_NETWORK_PASSWORD, mockCallbacks); -// verify(mockCallbacks, timeout(VERIFICATION_TIMEOUT)).addWPA2NetworkWiseFyFailure(WiseFyCodes.NETWORK_ALREADY_CONFIGURED); -// verify(mMockWiFiManager, never()).addNetwork(any(WifiConfiguration.class)); -// } -// -// @Test -// public void callbacks_success_alreadyConfigured_nullCallback() { -// networkAlreadyInConfigurationList(); -// -// try { -// mWiseFy.addWPA2Network(WPA2_NETWORK_SSID, WPA2_NETWORK_PASSWORD, null); -// verify(mMockWiFiManager, never()).addNetwork(any(WifiConfiguration.class)); -// } catch (NullPointerException npe) { -// fail(); -// } -// } -//} +package com.isupatches.wisefy; + + +import android.net.wifi.WifiConfiguration; +import com.isupatches.wisefy.base.TestUtils; +import com.isupatches.wisefy.callbacks.AddWPA2NetworkCallbacks; +import com.isupatches.wisefy.constants.WiseFyCodes; +import org.junit.Test; +import static junit.framework.Assert.assertEquals; +import static org.junit.Assert.assertNotEquals; +import static org.junit.Assert.fail; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.never; +import static org.mockito.Mockito.timeout; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; + + +public class AddWPA2NetworkTests extends BaseAndroidJUnit4TestClass { + + @Test + public void noCallbacks_failure() { + when(mMockWiFiManager.addNetwork(any(WifiConfiguration.class))).thenReturn(WiseFy.WIFI_MANAGER_FAILURE); + assertEquals(WiseFy.WIFI_MANAGER_FAILURE, mWiseFy.addWPA2Network(TestUtils.WPA2_NETWORK_SSID, TestUtils.WPA2_NETWORK_PASSWORD)); + verify(mMockWiFiManager, timeout(VERIFICATION_TIMEOUT)).addNetwork(any(WifiConfiguration.class)); + } + + @Test + public void noCallbacks_failure_nullPasswordParam() { + assertEquals(WiseFyCodes.MISSING_PARAMETER, mWiseFy.addWPA2Network(TestUtils.WPA2_NETWORK_SSID, null)); + verify(mMockWiFiManager, never()).addNetwork(any(WifiConfiguration.class)); + } + + @Test + public void anoCallbacks_failure_nullSSIDParam() { + assertEquals(WiseFyCodes.MISSING_PARAMETER, mWiseFy.addWPA2Network(null, TestUtils.WPA2_NETWORK_PASSWORD)); + verify(mMockWiFiManager, never()).addNetwork(any(WifiConfiguration.class)); + } + + @Test + public void noCallbacks_failure_missingPrerequisite() { + missingPrerequisite(); + assertEquals(WiseFyCodes.MISSING_PREREQUISITE, mWiseFy.addWPA2Network(TestUtils.WPA2_NETWORK_SSID, TestUtils.WPA2_NETWORK_PASSWORD)); + verify(mMockWiFiManager, never()).addNetwork(any(WifiConfiguration.class)); + } + + @Test + public void noCallbacks_success() { + when(mMockWiFiManager.addNetwork(any(WifiConfiguration.class))).thenReturn(0); + assertNotEquals(WiseFy.WIFI_MANAGER_FAILURE, mWiseFy.addWPA2Network(TestUtils.WPA2_NETWORK_SSID, TestUtils.WPA2_NETWORK_PASSWORD)); + verify(mMockWiFiManager, timeout(VERIFICATION_TIMEOUT)).addNetwork(any(WifiConfiguration.class)); + } + + @Test + public void noCallbacks_success_alreadyConfigured() { + networkAlreadyInConfigurationList(); + assertEquals(WiseFyCodes.NETWORK_ALREADY_CONFIGURED, mWiseFy.addWPA2Network(TestUtils.WPA2_NETWORK_SSID, TestUtils.WPA2_NETWORK_PASSWORD)); + verify(mMockWiFiManager, never()).addNetwork(any(WifiConfiguration.class)); + } + + @Test + public void callbacks_failure() { + when(mMockWiFiManager.addNetwork(any(WifiConfiguration.class))).thenReturn(WiseFy.WIFI_MANAGER_FAILURE); + AddWPA2NetworkCallbacks mockCallbacks = mock(AddWPA2NetworkCallbacks.class); + mWiseFy.addWPA2Network(TestUtils.WPA2_NETWORK_SSID, TestUtils.WPA2_NETWORK_PASSWORD, mockCallbacks); + verify(mockCallbacks, timeout(VERIFICATION_TIMEOUT)).failureAddingWPA2Network(WiseFy.WIFI_MANAGER_FAILURE); + verify(mMockWiFiManager, timeout(VERIFICATION_TIMEOUT)).addNetwork(any(WifiConfiguration.class)); + } + + @Test + public void callbacks_failure_nullCallback() { + when(mMockWiFiManager.addNetwork(any(WifiConfiguration.class))).thenReturn(WiseFy.WIFI_MANAGER_FAILURE); + try { + mWiseFy.addWPA2Network(TestUtils.WPA2_NETWORK_SSID, TestUtils.WPA2_NETWORK_PASSWORD, null); + verify(mMockWiFiManager, never()).addNetwork(any(WifiConfiguration.class)); + } catch (NullPointerException npe) { + fail(); + } + } + + @Test + public void callbacks_failure_nullPasswordParam() { + AddWPA2NetworkCallbacks mockCallbacks = mock(AddWPA2NetworkCallbacks.class); + mWiseFy.addWPA2Network(TestUtils.WPA2_NETWORK_SSID, null, mockCallbacks); + verify(mockCallbacks, timeout(VERIFICATION_TIMEOUT)).addWPA2NetworkWiseFyFailure(WiseFyCodes.MISSING_PARAMETER); + verify(mMockWiFiManager, never()).addNetwork(any(WifiConfiguration.class)); + } + + @Test + public void callbacks_failure_nullPasswordParam_nullCallback() { + try { + mWiseFy.addWPA2Network(TestUtils.WPA2_NETWORK_SSID, null, null); + verify(mMockWiFiManager, never()).addNetwork(any(WifiConfiguration.class)); + } catch (NullPointerException npe) { + fail(); + } + } + + @Test + public void callbacks_failure_nullSSIDParam() { + AddWPA2NetworkCallbacks mockCallbacks = mock(AddWPA2NetworkCallbacks.class); + mWiseFy.addWPA2Network(null, TestUtils.WPA2_NETWORK_PASSWORD, mockCallbacks); + verify(mockCallbacks, never()).addWPA2NetworkWiseFyFailure(WiseFyCodes.MISSING_PARAMETER); + } + + @Test + public void callbacks_failure_nullSSIDParam_nullCallback() { + try { + mWiseFy.addWPA2Network(null, TestUtils.WPA2_NETWORK_PASSWORD, null); + verify(mMockWiFiManager, never()).addNetwork(any(WifiConfiguration.class)); + } catch (NullPointerException npe) { + fail(); + } + } + + @Test + public void callbacks_failure_missingPrerequisite() { + missingPrerequisite(); + + AddWPA2NetworkCallbacks mockCallbacks = mock(AddWPA2NetworkCallbacks.class); + mWiseFy.addWPA2Network(TestUtils.WPA2_NETWORK_SSID, TestUtils.WPA2_NETWORK_PASSWORD, mockCallbacks); + verify(mockCallbacks, timeout(VERIFICATION_TIMEOUT)).addWPA2NetworkWiseFyFailure(WiseFyCodes.MISSING_PREREQUISITE); + verify(mMockWiFiManager, never()).addNetwork(any(WifiConfiguration.class)); + } + + @Test + public void callbacks_failure_missingPrerequisite_nullCallback() { + missingPrerequisite(); + + try { + mWiseFy.addWPA2Network(TestUtils.WPA2_NETWORK_SSID, TestUtils.WPA2_NETWORK_PASSWORD, null); + verify(mMockWiFiManager, never()).addNetwork(any(WifiConfiguration.class)); + } catch (NullPointerException npe) { + fail(); + } + } + + @Test + public void callbacks_success() { + when(mMockWiFiManager.addNetwork(any(WifiConfiguration.class))).thenReturn(0); + AddWPA2NetworkCallbacks mockCallbacks = mock(AddWPA2NetworkCallbacks.class); + mWiseFy.addWPA2Network(TestUtils.WPA2_NETWORK_SSID, TestUtils.WPA2_NETWORK_PASSWORD, mockCallbacks); + verify(mockCallbacks, timeout(VERIFICATION_TIMEOUT)).wpa2NetworkAdded(any(WifiConfiguration.class)); + verify(mMockWiFiManager, timeout(VERIFICATION_TIMEOUT)).addNetwork(any(WifiConfiguration.class)); + } + + @Test + public void callbacks_success_nullCallback() { + when(mMockWiFiManager.addNetwork(any(WifiConfiguration.class))).thenReturn(0); + + try { + mWiseFy.addWPA2Network(TestUtils.WPA2_NETWORK_SSID, TestUtils.WPA2_NETWORK_PASSWORD, null); + verify(mMockWiFiManager, never()).addNetwork(any(WifiConfiguration.class)); + } catch (NullPointerException npe) { + fail(); + } + } + + @Test + public void callbacks_success_alreadyConfigured() { + networkAlreadyInConfigurationList(); + + AddWPA2NetworkCallbacks mockCallbacks = mock(AddWPA2NetworkCallbacks.class); + mWiseFy.addWPA2Network(TestUtils.WPA2_NETWORK_SSID, TestUtils.WPA2_NETWORK_PASSWORD, mockCallbacks); + verify(mockCallbacks, timeout(VERIFICATION_TIMEOUT)).addWPA2NetworkWiseFyFailure(WiseFyCodes.NETWORK_ALREADY_CONFIGURED); + verify(mMockWiFiManager, never()).addNetwork(any(WifiConfiguration.class)); + } + + @Test + public void callbacks_success_alreadyConfigured_nullCallback() { + networkAlreadyInConfigurationList(); + + try { + mWiseFy.addWPA2Network(TestUtils.WPA2_NETWORK_SSID, TestUtils.WPA2_NETWORK_PASSWORD, null); + verify(mMockWiFiManager, never()).addNetwork(any(WifiConfiguration.class)); + } catch (NullPointerException npe) { + fail(); + } + } +} diff --git a/wisefy/src/androidTest/java/com/isupatches/wisefy/BaseTestClass.java b/wisefy/src/androidTest/java/com/isupatches/wisefy/BaseAndroidJUnit4TestClass.java similarity index 74% rename from wisefy/src/androidTest/java/com/isupatches/wisefy/BaseTestClass.java rename to wisefy/src/androidTest/java/com/isupatches/wisefy/BaseAndroidJUnit4TestClass.java index 070ec0d0..fbbc1f05 100644 --- a/wisefy/src/androidTest/java/com/isupatches/wisefy/BaseTestClass.java +++ b/wisefy/src/androidTest/java/com/isupatches/wisefy/BaseAndroidJUnit4TestClass.java @@ -1,24 +1,20 @@ package com.isupatches.wisefy; -import android.app.Activity; -import android.content.Intent; import android.net.ConnectivityManager; import android.net.wifi.WifiManager; -import android.support.test.rule.ActivityTestRule; -import com.isupatches.wisefy.base.TestActivity; +import android.support.test.InstrumentationRegistry; +import android.support.test.runner.AndroidJUnit4; import org.junit.After; import org.junit.Before; -import org.junit.Rule; +import org.junit.runner.RunWith; import static org.mockito.ArgumentMatchers.anyString; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; -public abstract class BaseTestClass extends ActivityTestRule { - - @Rule - public ActivityTestRule mActivityTestRule = new ActivityTestRule<>(TestActivity.class); +@RunWith(AndroidJUnit4.class) +public abstract class BaseAndroidJUnit4TestClass { ConnectivityManager mMockConnectivityManager; @@ -28,10 +24,6 @@ public abstract class BaseTestClass extends ActivityTestRule protected static final Integer VERIFICATION_TIMEOUT = 2000; - public BaseTestClass(Class activityClass) { - super(activityClass); - } - @Before public void setUp() { mMockWiFiManager = mock(WifiManager.class); @@ -40,9 +32,7 @@ public void setUp() { mMockWiFiManager = mock(WifiManager.class); mMockConnectivityManager = mock(ConnectivityManager.class); - mActivityTestRule.launchActivity(new Intent()); - - mWiseFy = new WiseFy.brains(mActivityTestRule.getActivity()).logging(true).getSmarts(); + mWiseFy = new WiseFy.brains(InstrumentationRegistry.getContext()).logging(true).getSmarts(); setManagers(); } @@ -75,4 +65,4 @@ private void setManagers() { when(mockPrereqs.getWifiManager()).thenReturn(mMockWiFiManager); when(mockPrereqs.getConnectivityManager()).thenReturn(mMockConnectivityManager); } -} \ No newline at end of file +} diff --git a/wisefy/src/androidTest/java/com/isupatches/wisefy/ConnectToNetworkTests.java b/wisefy/src/androidTest/java/com/isupatches/wisefy/ConnectToNetworkTests.java index 55e6e960..57bbcfe7 100644 --- a/wisefy/src/androidTest/java/com/isupatches/wisefy/ConnectToNetworkTests.java +++ b/wisefy/src/androidTest/java/com/isupatches/wisefy/ConnectToNetworkTests.java @@ -1,222 +1,217 @@ -//package com.isupatches.wisefy; -// -// -//import android.net.wifi.WifiConfiguration; -//import com.isupatches.wisefy.base.TestActivity; -//import com.isupatches.wisefy.callbacks.ConnectToNetworkCallbacks; -//import com.isupatches.wisefy.constants.WiseFyCodes; -//import org.junit.Test; -//import static com.isupatches.wisefy.base.TestUtils.TEST_SSID; -//import static org.junit.Assert.assertEquals; -//import static org.junit.Assert.fail; -//import static org.mockito.ArgumentMatchers.anyBoolean; -//import static org.mockito.ArgumentMatchers.anyInt; -//import static org.mockito.ArgumentMatchers.anyString; -//import static org.mockito.Mockito.mock; -//import static org.mockito.Mockito.never; -//import static org.mockito.Mockito.timeout; -//import static org.mockito.Mockito.verify; -//import static org.mockito.Mockito.when; -// -// -//public class ConnectToNetworkTests extends BaseTestClass { -// -// public ConnectToNetworkTests() { -// super(TestActivity.class); -// } -// -// @Test -// public void noCallbacks_failure_nullSSIDParam() { -// assertEquals(false, mWiseFy.connectToNetwork(null, 1)); -// verify(mMockWiFiManager, never()).enableNetwork(anyInt(), anyBoolean()); -// } -// -// @Test -// public void noCallbacks_failure_missingPrerequisites() { -// missingPrerequisite(); -// assertEquals(false, mWiseFy.connectToNetwork(TEST_SSID, 1)); -// verify(mMockWiFiManager, never()).enableNetwork(anyInt(), anyBoolean()); -// } -// -// @Test -// public void noCallbacks_failure_noSavedNetwork() { -// WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); -// mWiseFy.mWiseFySearch = mockWiseFySearch; -// when(mockWiseFySearch.findSavedNetworkByRegex(anyString())).thenReturn(null); -// -// assertEquals(false, mWiseFy.connectToNetwork(TEST_SSID, 1)); -// verify(mMockWiFiManager, never()).enableNetwork(anyInt(), anyBoolean()); -// } -// -// @Test -// public void noCallbacks_failure() { -// WifiConfiguration wiFiConfiguration = new WifiConfiguration(); -// wiFiConfiguration.SSID = TEST_SSID; -// WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); -// mWiseFy.mWiseFySearch = mockWiseFySearch; -// when(mockWiseFySearch.findSavedNetworkByRegex(anyString())).thenReturn(wiFiConfiguration); -// -// WiseFyConnection mockWiseFyConnection = mock(WiseFyConnection.class); -// mWiseFy.mWiseFyConnection = mockWiseFyConnection; -// when(mockWiseFyConnection.waitToConnectToSSID(anyString(), anyInt())).thenReturn(false); -// -// assertEquals(false, mWiseFy.connectToNetwork(TEST_SSID, 1)); -// verify(mMockWiFiManager, timeout(VERIFICATION_TIMEOUT)).enableNetwork(anyInt(), anyBoolean()); -// } -// -// @Test -// public void noCallbacks_success() { -// WifiConfiguration wiFiConfiguration = new WifiConfiguration(); -// wiFiConfiguration.SSID = TEST_SSID; -// WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); -// mWiseFy.mWiseFySearch = mockWiseFySearch; -// when(mockWiseFySearch.findSavedNetworkByRegex(anyString())).thenReturn(wiFiConfiguration); -// -// WiseFyConnection mockWiseFyConnection = mock(WiseFyConnection.class); -// mWiseFy.mWiseFyConnection = mockWiseFyConnection; -// when(mockWiseFyConnection.waitToConnectToSSID(anyString(), anyInt())).thenReturn(true); -// -// assertEquals(true, mWiseFy.connectToNetwork(TEST_SSID, 1)); -// verify(mMockWiFiManager, timeout(VERIFICATION_TIMEOUT)).enableNetwork(anyInt(), anyBoolean()); -// } -// -// @Test -// public void callbacks_failure_nullSSIDParam() { -// ConnectToNetworkCallbacks mockCallbacks = mock(ConnectToNetworkCallbacks.class); -// mWiseFy.connectToNetwork(null, 1, mockCallbacks); -// verify(mockCallbacks, timeout(3000)).connectToNetworkWiseFyFailure(WiseFyCodes.MISSING_PARAMETER); -// verify(mMockWiFiManager, never()).enableNetwork(anyInt(), anyBoolean()); -// } -// -// @Test -// public void callbacks_failure_nullSSIDParam_nullCallback() { -// try { -// mWiseFy.connectToNetwork(null, 1, null); -// verify(mMockWiFiManager, never()).enableNetwork(anyInt(), anyBoolean()); -// } catch (NullPointerException npe) { -// fail(); -// } -// } -// -// @Test -// public void callbacks_failure_missingPrerequisites() { -// missingPrerequisite(); -// ConnectToNetworkCallbacks mockCallbacks = mock(ConnectToNetworkCallbacks.class); -// mWiseFy.connectToNetwork(TEST_SSID, 1, mockCallbacks); -// verify(mockCallbacks, timeout(3000)).connectToNetworkWiseFyFailure(WiseFyCodes.MISSING_PREREQUISITE); -// verify(mMockWiFiManager, never()).enableNetwork(anyInt(), anyBoolean()); -// } -// -// @Test -// public void callbacks_failure_missingPrerequisites_nullCallback() { -// missingPrerequisite(); -// try { -// mWiseFy.connectToNetwork(TEST_SSID, 1, null); -// verify(mMockWiFiManager, never()).enableNetwork(anyInt(), anyBoolean()); -// } catch (NullPointerException npe) { -// fail(); -// } -// } -// -// @Test -// public void callbacks_failure_noSavedNetwork() { -// WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); -// mWiseFy.mWiseFySearch = mockWiseFySearch; -// when(mockWiseFySearch.findSavedNetworkByRegex(anyString())).thenReturn(null); -// -// ConnectToNetworkCallbacks mockCallbacks = mock(ConnectToNetworkCallbacks.class); -// mWiseFy.connectToNetwork(TEST_SSID, 1, mockCallbacks); -// verify(mockCallbacks, timeout(VERIFICATION_TIMEOUT)).networkNotFoundToConnectTo(); -// verify(mMockWiFiManager, never()).enableNetwork(anyInt(), anyBoolean()); -// } -// -// @Test -// public void callbacks_failure_noSavedNetwork_nullCallback() { -// WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); -// mWiseFy.mWiseFySearch = mockWiseFySearch; -// when(mockWiseFySearch.findSavedNetworkByRegex(anyString())).thenReturn(null); -// -// try { -// mWiseFy.connectToNetwork(TEST_SSID, 1, null); -// verify(mMockWiFiManager, never()).enableNetwork(anyInt(), anyBoolean()); -// } catch (NullPointerException npe) { -// fail(); -// } -// } -// -// @Test -// public void callbacks_failure() { -// WifiConfiguration wiFiConfiguration = new WifiConfiguration(); -// wiFiConfiguration.SSID = TEST_SSID; -// WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); -// mWiseFy.mWiseFySearch = mockWiseFySearch; -// when(mockWiseFySearch.findSavedNetworkByRegex(anyString())).thenReturn(wiFiConfiguration); -// -// WiseFyConnection mockWiseFyConnection = mock(WiseFyConnection.class); -// mWiseFy.mWiseFyConnection = mockWiseFyConnection; -// when(mockWiseFyConnection.waitToConnectToSSID(anyString(), anyInt())).thenReturn(false); -// -// ConnectToNetworkCallbacks mockCallbacks = mock(ConnectToNetworkCallbacks.class); -// mWiseFy.connectToNetwork(TEST_SSID, 1, mockCallbacks); -// verify(mockCallbacks, timeout(VERIFICATION_TIMEOUT)).failureConnectingToNetwork(); -// verify(mMockWiFiManager, timeout(VERIFICATION_TIMEOUT)).enableNetwork(anyInt(), anyBoolean()); -// } -// -// @Test -// public void callbacks_failure_nullCallback() { -// WifiConfiguration wiFiConfiguration = new WifiConfiguration(); -// wiFiConfiguration.SSID = TEST_SSID; -// WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); -// mWiseFy.mWiseFySearch = mockWiseFySearch; -// when(mockWiseFySearch.findSavedNetworkByRegex(anyString())).thenReturn(wiFiConfiguration); -// -// WiseFyConnection mockWiseFyConnection = mock(WiseFyConnection.class); -// mWiseFy.mWiseFyConnection = mockWiseFyConnection; -// when(mockWiseFyConnection.waitToConnectToSSID(anyString(), anyInt())).thenReturn(false); -// -// try { -// mWiseFy.connectToNetwork(TEST_SSID, 1, null); -// verify(mMockWiFiManager, never()).enableNetwork(anyInt(), anyBoolean()); -// } catch (NullPointerException npe) { -// fail(); -// } -// } -// -// @Test -// public void callbacks_success() { -// WifiConfiguration wiFiConfiguration = new WifiConfiguration(); -// wiFiConfiguration.SSID = TEST_SSID; -// WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); -// mWiseFy.mWiseFySearch = mockWiseFySearch; -// when(mockWiseFySearch.findSavedNetworkByRegex(anyString())).thenReturn(wiFiConfiguration); -// -// WiseFyConnection mockWiseFyConnection = mock(WiseFyConnection.class); -// mWiseFy.mWiseFyConnection = mockWiseFyConnection; -// when(mockWiseFyConnection.waitToConnectToSSID(anyString(), anyInt())).thenReturn(true); -// -// ConnectToNetworkCallbacks mockCallbacks = mock(ConnectToNetworkCallbacks.class); -// mWiseFy.connectToNetwork(TEST_SSID, 1, mockCallbacks); -// verify(mockCallbacks, timeout(VERIFICATION_TIMEOUT)).connectedToNetwork(); -// verify(mMockWiFiManager, timeout(VERIFICATION_TIMEOUT)).enableNetwork(anyInt(), anyBoolean()); -// } -// -// @Test -// public void callbacks_success_nullCallback() { -// WifiConfiguration wiFiConfiguration = new WifiConfiguration(); -// wiFiConfiguration.SSID = TEST_SSID; -// WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); -// mWiseFy.mWiseFySearch = mockWiseFySearch; -// when(mockWiseFySearch.findSavedNetworkByRegex(anyString())).thenReturn(wiFiConfiguration); -// -// WiseFyConnection mockWiseFyConnection = mock(WiseFyConnection.class); -// mWiseFy.mWiseFyConnection = mockWiseFyConnection; -// when(mockWiseFyConnection.waitToConnectToSSID(anyString(), anyInt())).thenReturn(true); -// -// try { -// mWiseFy.connectToNetwork(TEST_SSID, 1, null); -// verify(mMockWiFiManager, never()).enableNetwork(anyInt(), anyBoolean()); -// } catch (NullPointerException npe) { -// fail(); -// } -// } -//} \ No newline at end of file +package com.isupatches.wisefy; + + +import android.net.wifi.WifiConfiguration; +import com.isupatches.wisefy.callbacks.ConnectToNetworkCallbacks; +import com.isupatches.wisefy.constants.WiseFyCodes; +import org.junit.Test; +import static com.isupatches.wisefy.base.TestUtils.TEST_SSID; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.fail; +import static org.mockito.ArgumentMatchers.anyBoolean; +import static org.mockito.ArgumentMatchers.anyInt; +import static org.mockito.ArgumentMatchers.anyString; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.never; +import static org.mockito.Mockito.timeout; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; + + +public class ConnectToNetworkTests extends BaseAndroidJUnit4TestClass { + + @Test + public void noCallbacks_failure_nullSSIDParam() { + assertEquals(false, mWiseFy.connectToNetwork(null, 1)); + verify(mMockWiFiManager, never()).enableNetwork(anyInt(), anyBoolean()); + } + + @Test + public void noCallbacks_failure_missingPrerequisites() { + missingPrerequisite(); + assertEquals(false, mWiseFy.connectToNetwork(TEST_SSID, 1)); + verify(mMockWiFiManager, never()).enableNetwork(anyInt(), anyBoolean()); + } + + @Test + public void noCallbacks_failure_noSavedNetwork() { + WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); + mWiseFy.mWiseFySearch = mockWiseFySearch; + when(mockWiseFySearch.findSavedNetworkByRegex(anyString())).thenReturn(null); + + assertEquals(false, mWiseFy.connectToNetwork(TEST_SSID, 1)); + verify(mMockWiFiManager, never()).enableNetwork(anyInt(), anyBoolean()); + } + + @Test + public void noCallbacks_failure() { + WifiConfiguration wiFiConfiguration = new WifiConfiguration(); + wiFiConfiguration.SSID = TEST_SSID; + WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); + mWiseFy.mWiseFySearch = mockWiseFySearch; + when(mockWiseFySearch.findSavedNetworkByRegex(anyString())).thenReturn(wiFiConfiguration); + + WiseFyConnection mockWiseFyConnection = mock(WiseFyConnection.class); + mWiseFy.mWiseFyConnection = mockWiseFyConnection; + when(mockWiseFyConnection.waitToConnectToSSID(anyString(), anyInt())).thenReturn(false); + + assertEquals(false, mWiseFy.connectToNetwork(TEST_SSID, 1)); + verify(mMockWiFiManager, timeout(VERIFICATION_TIMEOUT)).enableNetwork(anyInt(), anyBoolean()); + } + + @Test + public void noCallbacks_success() { + WifiConfiguration wiFiConfiguration = new WifiConfiguration(); + wiFiConfiguration.SSID = TEST_SSID; + WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); + mWiseFy.mWiseFySearch = mockWiseFySearch; + when(mockWiseFySearch.findSavedNetworkByRegex(anyString())).thenReturn(wiFiConfiguration); + + WiseFyConnection mockWiseFyConnection = mock(WiseFyConnection.class); + mWiseFy.mWiseFyConnection = mockWiseFyConnection; + when(mockWiseFyConnection.waitToConnectToSSID(anyString(), anyInt())).thenReturn(true); + + assertEquals(true, mWiseFy.connectToNetwork(TEST_SSID, 1)); + verify(mMockWiFiManager, timeout(VERIFICATION_TIMEOUT)).enableNetwork(anyInt(), anyBoolean()); + } + + @Test + public void callbacks_failure_nullSSIDParam() { + ConnectToNetworkCallbacks mockCallbacks = mock(ConnectToNetworkCallbacks.class); + mWiseFy.connectToNetwork(null, 1, mockCallbacks); + verify(mockCallbacks, timeout(3000)).connectToNetworkWiseFyFailure(WiseFyCodes.MISSING_PARAMETER); + verify(mMockWiFiManager, never()).enableNetwork(anyInt(), anyBoolean()); + } + + @Test + public void callbacks_failure_nullSSIDParam_nullCallback() { + try { + mWiseFy.connectToNetwork(null, 1, null); + verify(mMockWiFiManager, never()).enableNetwork(anyInt(), anyBoolean()); + } catch (NullPointerException npe) { + fail(); + } + } + + @Test + public void callbacks_failure_missingPrerequisites() { + missingPrerequisite(); + ConnectToNetworkCallbacks mockCallbacks = mock(ConnectToNetworkCallbacks.class); + mWiseFy.connectToNetwork(TEST_SSID, 1, mockCallbacks); + verify(mockCallbacks, timeout(3000)).connectToNetworkWiseFyFailure(WiseFyCodes.MISSING_PREREQUISITE); + verify(mMockWiFiManager, never()).enableNetwork(anyInt(), anyBoolean()); + } + + @Test + public void callbacks_failure_missingPrerequisites_nullCallback() { + missingPrerequisite(); + try { + mWiseFy.connectToNetwork(TEST_SSID, 1, null); + verify(mMockWiFiManager, never()).enableNetwork(anyInt(), anyBoolean()); + } catch (NullPointerException npe) { + fail(); + } + } + + @Test + public void callbacks_failure_noSavedNetwork() { + WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); + mWiseFy.mWiseFySearch = mockWiseFySearch; + when(mockWiseFySearch.findSavedNetworkByRegex(anyString())).thenReturn(null); + + ConnectToNetworkCallbacks mockCallbacks = mock(ConnectToNetworkCallbacks.class); + mWiseFy.connectToNetwork(TEST_SSID, 1, mockCallbacks); + verify(mockCallbacks, timeout(VERIFICATION_TIMEOUT)).networkNotFoundToConnectTo(); + verify(mMockWiFiManager, never()).enableNetwork(anyInt(), anyBoolean()); + } + + @Test + public void callbacks_failure_noSavedNetwork_nullCallback() { + WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); + mWiseFy.mWiseFySearch = mockWiseFySearch; + when(mockWiseFySearch.findSavedNetworkByRegex(anyString())).thenReturn(null); + + try { + mWiseFy.connectToNetwork(TEST_SSID, 1, null); + verify(mMockWiFiManager, never()).enableNetwork(anyInt(), anyBoolean()); + } catch (NullPointerException npe) { + fail(); + } + } + + @Test + public void callbacks_failure() { + WifiConfiguration wiFiConfiguration = new WifiConfiguration(); + wiFiConfiguration.SSID = TEST_SSID; + WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); + mWiseFy.mWiseFySearch = mockWiseFySearch; + when(mockWiseFySearch.findSavedNetworkByRegex(anyString())).thenReturn(wiFiConfiguration); + + WiseFyConnection mockWiseFyConnection = mock(WiseFyConnection.class); + mWiseFy.mWiseFyConnection = mockWiseFyConnection; + when(mockWiseFyConnection.waitToConnectToSSID(anyString(), anyInt())).thenReturn(false); + + ConnectToNetworkCallbacks mockCallbacks = mock(ConnectToNetworkCallbacks.class); + mWiseFy.connectToNetwork(TEST_SSID, 1, mockCallbacks); + verify(mockCallbacks, timeout(VERIFICATION_TIMEOUT)).failureConnectingToNetwork(); + verify(mMockWiFiManager, timeout(VERIFICATION_TIMEOUT)).enableNetwork(anyInt(), anyBoolean()); + } + + @Test + public void callbacks_failure_nullCallback() { + WifiConfiguration wiFiConfiguration = new WifiConfiguration(); + wiFiConfiguration.SSID = TEST_SSID; + WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); + mWiseFy.mWiseFySearch = mockWiseFySearch; + when(mockWiseFySearch.findSavedNetworkByRegex(anyString())).thenReturn(wiFiConfiguration); + + WiseFyConnection mockWiseFyConnection = mock(WiseFyConnection.class); + mWiseFy.mWiseFyConnection = mockWiseFyConnection; + when(mockWiseFyConnection.waitToConnectToSSID(anyString(), anyInt())).thenReturn(false); + + try { + mWiseFy.connectToNetwork(TEST_SSID, 1, null); + verify(mMockWiFiManager, never()).enableNetwork(anyInt(), anyBoolean()); + } catch (NullPointerException npe) { + fail(); + } + } + + @Test + public void callbacks_success() { + WifiConfiguration wiFiConfiguration = new WifiConfiguration(); + wiFiConfiguration.SSID = TEST_SSID; + WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); + mWiseFy.mWiseFySearch = mockWiseFySearch; + when(mockWiseFySearch.findSavedNetworkByRegex(anyString())).thenReturn(wiFiConfiguration); + + WiseFyConnection mockWiseFyConnection = mock(WiseFyConnection.class); + mWiseFy.mWiseFyConnection = mockWiseFyConnection; + when(mockWiseFyConnection.waitToConnectToSSID(anyString(), anyInt())).thenReturn(true); + + ConnectToNetworkCallbacks mockCallbacks = mock(ConnectToNetworkCallbacks.class); + mWiseFy.connectToNetwork(TEST_SSID, 1, mockCallbacks); + verify(mockCallbacks, timeout(VERIFICATION_TIMEOUT)).connectedToNetwork(); + verify(mMockWiFiManager, timeout(VERIFICATION_TIMEOUT)).enableNetwork(anyInt(), anyBoolean()); + } + + @Test + public void callbacks_success_nullCallback() { + WifiConfiguration wiFiConfiguration = new WifiConfiguration(); + wiFiConfiguration.SSID = TEST_SSID; + WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); + mWiseFy.mWiseFySearch = mockWiseFySearch; + when(mockWiseFySearch.findSavedNetworkByRegex(anyString())).thenReturn(wiFiConfiguration); + + WiseFyConnection mockWiseFyConnection = mock(WiseFyConnection.class); + mWiseFy.mWiseFyConnection = mockWiseFyConnection; + when(mockWiseFyConnection.waitToConnectToSSID(anyString(), anyInt())).thenReturn(true); + + try { + mWiseFy.connectToNetwork(TEST_SSID, 1, null); + verify(mMockWiFiManager, never()).enableNetwork(anyInt(), anyBoolean()); + } catch (NullPointerException npe) { + fail(); + } + } +} \ No newline at end of file diff --git a/wisefy/src/androidTest/java/com/isupatches/wisefy/DisableWifiTests.java b/wisefy/src/androidTest/java/com/isupatches/wisefy/DisableWifiTests.java index f77d387a..10552123 100644 --- a/wisefy/src/androidTest/java/com/isupatches/wisefy/DisableWifiTests.java +++ b/wisefy/src/androidTest/java/com/isupatches/wisefy/DisableWifiTests.java @@ -1,104 +1,99 @@ -//package com.isupatches.wisefy; -// -// -//import com.isupatches.wisefy.base.TestActivity; -//import com.isupatches.wisefy.callbacks.DisableWifiCallbacks; -//import com.isupatches.wisefy.constants.WiseFyCodes; -//import org.junit.Test; -//import static org.junit.Assert.assertEquals; -//import static org.junit.Assert.fail; -//import static org.mockito.ArgumentMatchers.anyBoolean; -//import static org.mockito.Mockito.mock; -//import static org.mockito.Mockito.never; -//import static org.mockito.Mockito.timeout; -//import static org.mockito.Mockito.verify; -//import static org.mockito.Mockito.when; -// -// -//public class DisableWifiTests extends BaseTestClass { -// -// public DisableWifiTests() { -// super(TestActivity.class); -// } -// -// @Test -// public void noCallbacks_failure() { -// when(mMockWiFiManager.setWifiEnabled(anyBoolean())).thenReturn(false); -// assertEquals(false, mWiseFy.disableWifi()); -// verify(mMockWiFiManager, timeout(VERIFICATION_TIMEOUT)).setWifiEnabled(false); -// } -// -// @Test -// public void noCallbacks_failure_missingPrerequisite() { -// missingPrerequisite(); -// assertEquals(false, mWiseFy.disableWifi()); -// verify(mMockWiFiManager, never()).setWifiEnabled(false); -// } -// -// @Test -// public void noCallbacks_success() { -// when(mMockWiFiManager.setWifiEnabled(anyBoolean())).thenReturn(true); -// assertEquals(true, mWiseFy.disableWifi()); -// verify(mMockWiFiManager, timeout(VERIFICATION_TIMEOUT)).setWifiEnabled(false); -// } -// -// @Test -// public void callbacks_failure() { -// when(mMockWiFiManager.setWifiEnabled(anyBoolean())).thenReturn(false); -// DisableWifiCallbacks mockCallbacks = mock(DisableWifiCallbacks.class); -// mWiseFy.disableWifi(mockCallbacks); -// verify(mMockWiFiManager, timeout(VERIFICATION_TIMEOUT)).setWifiEnabled(false); -// verify(mockCallbacks, timeout(VERIFICATION_TIMEOUT)).failureDisablingWifi(); -// } -// -// @Test -// public void callbacks_failure_nullCallback() { -// when(mMockWiFiManager.setWifiEnabled(anyBoolean())).thenReturn(false); -// try { -// mWiseFy.disableWifi(null); -// verify(mMockWiFiManager, never()).setWifiEnabled(false); -// } catch (NullPointerException npe) { -// fail(); -// } -// } -// -// @Test -// public void callbacks_failure_missingPrerequisite() { -// missingPrerequisite(); -// DisableWifiCallbacks mockCallbacks = mock(DisableWifiCallbacks.class); -// mWiseFy.disableWifi(mockCallbacks); -// verify(mMockWiFiManager, never()).setWifiEnabled(false); -// verify(mockCallbacks, timeout(VERIFICATION_TIMEOUT)).disableWifiWiseFyFailure(WiseFyCodes.MISSING_PREREQUISITE); -// } -// -// @Test -// public void callbacks_failure_missingPrerequisite_nullCallback() { -// missingPrerequisite(); -// try { -// mWiseFy.disableWifi(null); -// verify(mMockWiFiManager, never()).setWifiEnabled(false); -// } catch (NullPointerException npe) { -// fail(); -// } -// } -// -// @Test -// public void callbacks_success() { -// when(mMockWiFiManager.setWifiEnabled(anyBoolean())).thenReturn(true); -// DisableWifiCallbacks mockCallbacks = mock(DisableWifiCallbacks.class); -// mWiseFy.disableWifi(mockCallbacks); -// verify(mMockWiFiManager, timeout(VERIFICATION_TIMEOUT)).setWifiEnabled(false); -// verify(mockCallbacks, timeout(VERIFICATION_TIMEOUT)).wifiDisabled(); -// } -// -// @Test -// public void callbacks_success_nullCallback() { -// when(mMockWiFiManager.setWifiEnabled(anyBoolean())).thenReturn(true); -// try { -// mWiseFy.disableWifi(null); -// verify(mMockWiFiManager, never()).setWifiEnabled(false); -// } catch (NullPointerException npe) { -// fail(); -// } -// } -//} +package com.isupatches.wisefy; + + +import com.isupatches.wisefy.callbacks.DisableWifiCallbacks; +import com.isupatches.wisefy.constants.WiseFyCodes; +import org.junit.Test; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.fail; +import static org.mockito.ArgumentMatchers.anyBoolean; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.never; +import static org.mockito.Mockito.timeout; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; + + +public class DisableWifiTests extends BaseAndroidJUnit4TestClass { + + @Test + public void noCallbacks_failure() { + when(mMockWiFiManager.setWifiEnabled(anyBoolean())).thenReturn(false); + assertEquals(false, mWiseFy.disableWifi()); + verify(mMockWiFiManager, timeout(VERIFICATION_TIMEOUT)).setWifiEnabled(false); + } + + @Test + public void noCallbacks_failure_missingPrerequisite() { + missingPrerequisite(); + assertEquals(false, mWiseFy.disableWifi()); + verify(mMockWiFiManager, never()).setWifiEnabled(false); + } + + @Test + public void noCallbacks_success() { + when(mMockWiFiManager.setWifiEnabled(anyBoolean())).thenReturn(true); + assertEquals(true, mWiseFy.disableWifi()); + verify(mMockWiFiManager, timeout(VERIFICATION_TIMEOUT)).setWifiEnabled(false); + } + + @Test + public void callbacks_failure() { + when(mMockWiFiManager.setWifiEnabled(anyBoolean())).thenReturn(false); + DisableWifiCallbacks mockCallbacks = mock(DisableWifiCallbacks.class); + mWiseFy.disableWifi(mockCallbacks); + verify(mMockWiFiManager, timeout(VERIFICATION_TIMEOUT)).setWifiEnabled(false); + verify(mockCallbacks, timeout(VERIFICATION_TIMEOUT)).failureDisablingWifi(); + } + + @Test + public void callbacks_failure_nullCallback() { + when(mMockWiFiManager.setWifiEnabled(anyBoolean())).thenReturn(false); + try { + mWiseFy.disableWifi(null); + verify(mMockWiFiManager, never()).setWifiEnabled(false); + } catch (NullPointerException npe) { + fail(); + } + } + + @Test + public void callbacks_failure_missingPrerequisite() { + missingPrerequisite(); + DisableWifiCallbacks mockCallbacks = mock(DisableWifiCallbacks.class); + mWiseFy.disableWifi(mockCallbacks); + verify(mMockWiFiManager, never()).setWifiEnabled(false); + verify(mockCallbacks, timeout(VERIFICATION_TIMEOUT)).disableWifiWiseFyFailure(WiseFyCodes.MISSING_PREREQUISITE); + } + + @Test + public void callbacks_failure_missingPrerequisite_nullCallback() { + missingPrerequisite(); + try { + mWiseFy.disableWifi(null); + verify(mMockWiFiManager, never()).setWifiEnabled(false); + } catch (NullPointerException npe) { + fail(); + } + } + + @Test + public void callbacks_success() { + when(mMockWiFiManager.setWifiEnabled(anyBoolean())).thenReturn(true); + DisableWifiCallbacks mockCallbacks = mock(DisableWifiCallbacks.class); + mWiseFy.disableWifi(mockCallbacks); + verify(mMockWiFiManager, timeout(VERIFICATION_TIMEOUT)).setWifiEnabled(false); + verify(mockCallbacks, timeout(VERIFICATION_TIMEOUT)).wifiDisabled(); + } + + @Test + public void callbacks_success_nullCallback() { + when(mMockWiFiManager.setWifiEnabled(anyBoolean())).thenReturn(true); + try { + mWiseFy.disableWifi(null); + verify(mMockWiFiManager, never()).setWifiEnabled(false); + } catch (NullPointerException npe) { + fail(); + } + } +} diff --git a/wisefy/src/androidTest/java/com/isupatches/wisefy/DisconnectFromCurrentNetworkTests.java b/wisefy/src/androidTest/java/com/isupatches/wisefy/DisconnectFromCurrentNetworkTests.java index 9b10a2eb..979e6311 100644 --- a/wisefy/src/androidTest/java/com/isupatches/wisefy/DisconnectFromCurrentNetworkTests.java +++ b/wisefy/src/androidTest/java/com/isupatches/wisefy/DisconnectFromCurrentNetworkTests.java @@ -1,103 +1,98 @@ -//package com.isupatches.wisefy; -// -// -//import com.isupatches.wisefy.base.TestActivity; -//import com.isupatches.wisefy.callbacks.DisconnectFromCurrentNetworkCallbacks; -//import com.isupatches.wisefy.constants.WiseFyCodes; -//import org.junit.Test; -//import static org.junit.Assert.assertEquals; -//import static org.junit.Assert.fail; -//import static org.mockito.Mockito.mock; -//import static org.mockito.Mockito.never; -//import static org.mockito.Mockito.timeout; -//import static org.mockito.Mockito.verify; -//import static org.mockito.Mockito.when; -// -// -//public class DisconnectFromCurrentNetworkTests extends BaseTestClass { -// -// public DisconnectFromCurrentNetworkTests() { -// super(TestActivity.class); -// } -// -// @Test -// public void noCallbacks_failure() { -// when(mMockWiFiManager.disconnect()).thenReturn(false); -// assertEquals(false, mWiseFy.disconnectFromCurrentNetwork()); -// verify(mMockWiFiManager, timeout(VERIFICATION_TIMEOUT)).disconnect(); -// } -// -// @Test -// public void noCallbacks_failure_missingPrerequisite() { -// missingPrerequisite(); -// assertEquals(false, mWiseFy.disconnectFromCurrentNetwork()); -// verify(mMockWiFiManager, never()).disconnect(); -// } -// -// @Test -// public void noCallbacks_success() { -// when(mMockWiFiManager.disconnect()).thenReturn(true); -// assertEquals(true, mWiseFy.disconnectFromCurrentNetwork()); -// verify(mMockWiFiManager, timeout(VERIFICATION_TIMEOUT)).disconnect(); -// } -// -// @Test -// public void callbacks_failure() { -// when(mMockWiFiManager.disconnect()).thenReturn(false); -// DisconnectFromCurrentNetworkCallbacks mockCallbacks = mock(DisconnectFromCurrentNetworkCallbacks.class); -// mWiseFy.disconnectFromCurrentNetwork(mockCallbacks); -// verify(mMockWiFiManager, timeout(VERIFICATION_TIMEOUT)).disconnect(); -// verify(mockCallbacks, timeout(VERIFICATION_TIMEOUT)).failureDisconnectingFromCurrentNetwork(); -// } -// -// @Test -// public void callbacks_failure_nullCallback() { -// when(mMockWiFiManager.disconnect()).thenReturn(false); -// try { -// mWiseFy.disconnectFromCurrentNetwork(null); -// verify(mMockWiFiManager, never()).disconnect(); -// } catch (NullPointerException npe) { -// fail(); -// } -// } -// -// @Test -// public void callbacks_failure_missingPrerequisite() { -// missingPrerequisite(); -// DisconnectFromCurrentNetworkCallbacks mockCallbacks = mock(DisconnectFromCurrentNetworkCallbacks.class); -// mWiseFy.disconnectFromCurrentNetwork(mockCallbacks); -// verify(mMockWiFiManager, never()).disconnect(); -// verify(mockCallbacks, timeout(VERIFICATION_TIMEOUT)).disconnectFromCurrentNetworkWiseFyFailure(WiseFyCodes.MISSING_PREREQUISITE); -// } -// -// @Test -// public void callbacks_failure_missingPrerequisite_nullCallback() { -// missingPrerequisite(); -// try { -// mWiseFy.disconnectFromCurrentNetwork(null); -// verify(mMockWiFiManager, never()).disconnect(); -// } catch (NullPointerException npe) { -// fail(); -// } -// } -// -// @Test -// public void callbacks_success() { -// when(mMockWiFiManager.disconnect()).thenReturn(true); -// DisconnectFromCurrentNetworkCallbacks mockCallbacks = mock(DisconnectFromCurrentNetworkCallbacks.class); -// mWiseFy.disconnectFromCurrentNetwork(mockCallbacks); -// verify(mMockWiFiManager, timeout(VERIFICATION_TIMEOUT)).disconnect(); -// verify(mockCallbacks, timeout(VERIFICATION_TIMEOUT)).disconnectedFromCurrentNetwork(); -// } -// -// @Test -// public void callbacks_success_nullCallback() { -// when(mMockWiFiManager.disconnect()).thenReturn(true); -// try { -// mWiseFy.disconnectFromCurrentNetwork(null); -// verify(mMockWiFiManager, never()).disconnect(); -// } catch (NullPointerException npe) { -// fail(); -// } -// } -//} +package com.isupatches.wisefy; + + +import com.isupatches.wisefy.callbacks.DisconnectFromCurrentNetworkCallbacks; +import com.isupatches.wisefy.constants.WiseFyCodes; +import org.junit.Test; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.fail; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.never; +import static org.mockito.Mockito.timeout; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; + + +public class DisconnectFromCurrentNetworkTests extends BaseAndroidJUnit4TestClass { + + @Test + public void noCallbacks_failure() { + when(mMockWiFiManager.disconnect()).thenReturn(false); + assertEquals(false, mWiseFy.disconnectFromCurrentNetwork()); + verify(mMockWiFiManager, timeout(VERIFICATION_TIMEOUT)).disconnect(); + } + + @Test + public void noCallbacks_failure_missingPrerequisite() { + missingPrerequisite(); + assertEquals(false, mWiseFy.disconnectFromCurrentNetwork()); + verify(mMockWiFiManager, never()).disconnect(); + } + + @Test + public void noCallbacks_success() { + when(mMockWiFiManager.disconnect()).thenReturn(true); + assertEquals(true, mWiseFy.disconnectFromCurrentNetwork()); + verify(mMockWiFiManager, timeout(VERIFICATION_TIMEOUT)).disconnect(); + } + + @Test + public void callbacks_failure() { + when(mMockWiFiManager.disconnect()).thenReturn(false); + DisconnectFromCurrentNetworkCallbacks mockCallbacks = mock(DisconnectFromCurrentNetworkCallbacks.class); + mWiseFy.disconnectFromCurrentNetwork(mockCallbacks); + verify(mMockWiFiManager, timeout(VERIFICATION_TIMEOUT)).disconnect(); + verify(mockCallbacks, timeout(VERIFICATION_TIMEOUT)).failureDisconnectingFromCurrentNetwork(); + } + + @Test + public void callbacks_failure_nullCallback() { + when(mMockWiFiManager.disconnect()).thenReturn(false); + try { + mWiseFy.disconnectFromCurrentNetwork(null); + verify(mMockWiFiManager, never()).disconnect(); + } catch (NullPointerException npe) { + fail(); + } + } + + @Test + public void callbacks_failure_missingPrerequisite() { + missingPrerequisite(); + DisconnectFromCurrentNetworkCallbacks mockCallbacks = mock(DisconnectFromCurrentNetworkCallbacks.class); + mWiseFy.disconnectFromCurrentNetwork(mockCallbacks); + verify(mMockWiFiManager, never()).disconnect(); + verify(mockCallbacks, timeout(VERIFICATION_TIMEOUT)).disconnectFromCurrentNetworkWiseFyFailure(WiseFyCodes.MISSING_PREREQUISITE); + } + + @Test + public void callbacks_failure_missingPrerequisite_nullCallback() { + missingPrerequisite(); + try { + mWiseFy.disconnectFromCurrentNetwork(null); + verify(mMockWiFiManager, never()).disconnect(); + } catch (NullPointerException npe) { + fail(); + } + } + + @Test + public void callbacks_success() { + when(mMockWiFiManager.disconnect()).thenReturn(true); + DisconnectFromCurrentNetworkCallbacks mockCallbacks = mock(DisconnectFromCurrentNetworkCallbacks.class); + mWiseFy.disconnectFromCurrentNetwork(mockCallbacks); + verify(mMockWiFiManager, timeout(VERIFICATION_TIMEOUT)).disconnect(); + verify(mockCallbacks, timeout(VERIFICATION_TIMEOUT)).disconnectedFromCurrentNetwork(); + } + + @Test + public void callbacks_success_nullCallback() { + when(mMockWiFiManager.disconnect()).thenReturn(true); + try { + mWiseFy.disconnectFromCurrentNetwork(null); + verify(mMockWiFiManager, never()).disconnect(); + } catch (NullPointerException npe) { + fail(); + } + } +} diff --git a/wisefy/src/androidTest/java/com/isupatches/wisefy/EnableWifiTests.java b/wisefy/src/androidTest/java/com/isupatches/wisefy/EnableWifiTests.java index e68d4e38..30eb1b63 100644 --- a/wisefy/src/androidTest/java/com/isupatches/wisefy/EnableWifiTests.java +++ b/wisefy/src/androidTest/java/com/isupatches/wisefy/EnableWifiTests.java @@ -1,104 +1,99 @@ -//package com.isupatches.wisefy; -// -// -//import com.isupatches.wisefy.base.TestActivity; -//import com.isupatches.wisefy.callbacks.EnableWifiCallbacks; -//import com.isupatches.wisefy.constants.WiseFyCodes; -//import org.junit.Test; -//import static org.junit.Assert.assertEquals; -//import static org.junit.Assert.fail; -//import static org.mockito.ArgumentMatchers.anyBoolean; -//import static org.mockito.Mockito.mock; -//import static org.mockito.Mockito.never; -//import static org.mockito.Mockito.timeout; -//import static org.mockito.Mockito.verify; -//import static org.mockito.Mockito.when; -// -// -//public class EnableWifiTests extends BaseTestClass { -// -// public EnableWifiTests() { -// super(TestActivity.class); -// } -// -// @Test -// public void noCallbacks_failure() { -// when(mMockWiFiManager.setWifiEnabled(anyBoolean())).thenReturn(false); -// assertEquals(false, mWiseFy.enableWifi()); -// verify(mMockWiFiManager, timeout(VERIFICATION_TIMEOUT)).setWifiEnabled(true); -// } -// -// @Test -// public void noCallbacks_failure_missingPrerequisite() { -// missingPrerequisite(); -// assertEquals(false, mWiseFy.enableWifi()); -// verify(mMockWiFiManager, never()).setWifiEnabled(true); -// } -// -// @Test -// public void noCallbacks_success() { -// when(mMockWiFiManager.setWifiEnabled(anyBoolean())).thenReturn(true); -// assertEquals(true, mWiseFy.enableWifi()); -// verify(mMockWiFiManager, timeout(VERIFICATION_TIMEOUT)).setWifiEnabled(true); -// } -// -// @Test -// public void callbacks_failure() { -// when(mMockWiFiManager.setWifiEnabled(anyBoolean())).thenReturn(false); -// EnableWifiCallbacks mockCallbacks = mock(EnableWifiCallbacks.class); -// mWiseFy.enableWifi(mockCallbacks); -// verify(mMockWiFiManager, timeout(VERIFICATION_TIMEOUT)).setWifiEnabled(true); -// verify(mockCallbacks, timeout(VERIFICATION_TIMEOUT)).failureEnablingWifi(); -// } -// -// @Test -// public void callbacks_failure_nullCallback() { -// when(mMockWiFiManager.setWifiEnabled(anyBoolean())).thenReturn(false); -// try { -// mWiseFy.enableWifi(null); -// verify(mMockWiFiManager, never()).setWifiEnabled(true); -// } catch (NullPointerException npe) { -// fail(); -// } -// } -// -// @Test -// public void callbacks_failure_missingPrerequisite() { -// missingPrerequisite(); -// EnableWifiCallbacks mockCallbacks = mock(EnableWifiCallbacks.class); -// mWiseFy.enableWifi(mockCallbacks); -// verify(mMockWiFiManager, never()).setWifiEnabled(true); -// verify(mockCallbacks, timeout(VERIFICATION_TIMEOUT)).enableWifiWiseFyFailure(WiseFyCodes.MISSING_PREREQUISITE); -// } -// -// @Test -// public void callbacks_failure_missingPrerequisite_nullCallback() { -// missingPrerequisite(); -// try { -// mWiseFy.enableWifi(null); -// verify(mMockWiFiManager, never()).setWifiEnabled(true); -// } catch (NullPointerException npe) { -// fail(); -// } -// } -// -// @Test -// public void callbacks_success() { -// when(mMockWiFiManager.setWifiEnabled(anyBoolean())).thenReturn(true); -// EnableWifiCallbacks mockCallbacks = mock(EnableWifiCallbacks.class); -// mWiseFy.enableWifi(mockCallbacks); -// verify(mMockWiFiManager, timeout(VERIFICATION_TIMEOUT)).setWifiEnabled(true); -// verify(mockCallbacks, timeout(VERIFICATION_TIMEOUT)).wifiEnabled(); -// } -// -// @Test -// public void callbacks_success_nullCallback() { -// when(mMockWiFiManager.setWifiEnabled(anyBoolean())).thenReturn(true); -// try { -// mWiseFy.enableWifi(null); -// verify(mMockWiFiManager, never()).setWifiEnabled(true); -// } catch (NullPointerException npe) { -// fail(); -// } -// } -//} +package com.isupatches.wisefy; + + +import com.isupatches.wisefy.callbacks.EnableWifiCallbacks; +import com.isupatches.wisefy.constants.WiseFyCodes; +import org.junit.Test; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.fail; +import static org.mockito.ArgumentMatchers.anyBoolean; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.never; +import static org.mockito.Mockito.timeout; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; + + +public class EnableWifiTests extends BaseAndroidJUnit4TestClass { + + @Test + public void noCallbacks_failure() { + when(mMockWiFiManager.setWifiEnabled(anyBoolean())).thenReturn(false); + assertEquals(false, mWiseFy.enableWifi()); + verify(mMockWiFiManager, timeout(VERIFICATION_TIMEOUT)).setWifiEnabled(true); + } + + @Test + public void noCallbacks_failure_missingPrerequisite() { + missingPrerequisite(); + assertEquals(false, mWiseFy.enableWifi()); + verify(mMockWiFiManager, never()).setWifiEnabled(true); + } + + @Test + public void noCallbacks_success() { + when(mMockWiFiManager.setWifiEnabled(anyBoolean())).thenReturn(true); + assertEquals(true, mWiseFy.enableWifi()); + verify(mMockWiFiManager, timeout(VERIFICATION_TIMEOUT)).setWifiEnabled(true); + } + + @Test + public void callbacks_failure() { + when(mMockWiFiManager.setWifiEnabled(anyBoolean())).thenReturn(false); + EnableWifiCallbacks mockCallbacks = mock(EnableWifiCallbacks.class); + mWiseFy.enableWifi(mockCallbacks); + verify(mMockWiFiManager, timeout(VERIFICATION_TIMEOUT)).setWifiEnabled(true); + verify(mockCallbacks, timeout(VERIFICATION_TIMEOUT)).failureEnablingWifi(); + } + + @Test + public void callbacks_failure_nullCallback() { + when(mMockWiFiManager.setWifiEnabled(anyBoolean())).thenReturn(false); + try { + mWiseFy.enableWifi(null); + verify(mMockWiFiManager, never()).setWifiEnabled(true); + } catch (NullPointerException npe) { + fail(); + } + } + + @Test + public void callbacks_failure_missingPrerequisite() { + missingPrerequisite(); + EnableWifiCallbacks mockCallbacks = mock(EnableWifiCallbacks.class); + mWiseFy.enableWifi(mockCallbacks); + verify(mMockWiFiManager, never()).setWifiEnabled(true); + verify(mockCallbacks, timeout(VERIFICATION_TIMEOUT)).enableWifiWiseFyFailure(WiseFyCodes.MISSING_PREREQUISITE); + } + + @Test + public void callbacks_failure_missingPrerequisite_nullCallback() { + missingPrerequisite(); + try { + mWiseFy.enableWifi(null); + verify(mMockWiFiManager, never()).setWifiEnabled(true); + } catch (NullPointerException npe) { + fail(); + } + } + + @Test + public void callbacks_success() { + when(mMockWiFiManager.setWifiEnabled(anyBoolean())).thenReturn(true); + EnableWifiCallbacks mockCallbacks = mock(EnableWifiCallbacks.class); + mWiseFy.enableWifi(mockCallbacks); + verify(mMockWiFiManager, timeout(VERIFICATION_TIMEOUT)).setWifiEnabled(true); + verify(mockCallbacks, timeout(VERIFICATION_TIMEOUT)).wifiEnabled(); + } + + @Test + public void callbacks_success_nullCallback() { + when(mMockWiFiManager.setWifiEnabled(anyBoolean())).thenReturn(true); + try { + mWiseFy.enableWifi(null); + verify(mMockWiFiManager, never()).setWifiEnabled(true); + } catch (NullPointerException npe) { + fail(); + } + } +} diff --git a/wisefy/src/androidTest/java/com/isupatches/wisefy/GetCurrentNetworkTests.java b/wisefy/src/androidTest/java/com/isupatches/wisefy/GetCurrentNetworkTests.java index 960f7bbc..7f10e2c6 100644 --- a/wisefy/src/androidTest/java/com/isupatches/wisefy/GetCurrentNetworkTests.java +++ b/wisefy/src/androidTest/java/com/isupatches/wisefy/GetCurrentNetworkTests.java @@ -1,87 +1,82 @@ -//package com.isupatches.wisefy; -// -// -//import android.net.wifi.WifiInfo; -//import com.isupatches.wisefy.base.TestActivity; -//import com.isupatches.wisefy.callbacks.GetCurrentNetworkCallbacks; -//import com.isupatches.wisefy.constants.WiseFyCodes; -//import org.junit.Test; -//import static com.isupatches.wisefy.base.TestUtils.TEST_SSID; -//import static junit.framework.Assert.assertEquals; -//import static junit.framework.Assert.fail; -//import static org.mockito.Mockito.mock; -//import static org.mockito.Mockito.never; -//import static org.mockito.Mockito.timeout; -//import static org.mockito.Mockito.verify; -//import static org.mockito.Mockito.when; -// -// -//public class GetCurrentNetworkTests extends BaseTestClass { -// -// public GetCurrentNetworkTests() { -// super(TestActivity.class); -// } -// -// @Test -// public void noCallbacks_failure_missingPrerequisite() { -// missingPrerequisite(); -// assertEquals(null, mWiseFy.getCurrentNetwork()); -// verify(mMockWiFiManager, never()).getConnectionInfo(); -// } -// -// @Test -// public void noCallbacks_success() { -// WifiInfo mockWifiInfo = mock(WifiInfo.class); -// when(mockWifiInfo.getSSID()).thenReturn(TEST_SSID); -// when(mMockWiFiManager.getConnectionInfo()).thenReturn(mockWifiInfo); -// -// assertEquals(TEST_SSID, mWiseFy.getCurrentNetwork().getSSID()); -// verify(mMockWiFiManager, timeout(VERIFICATION_TIMEOUT)).getConnectionInfo(); -// } -// -// @Test -// public void callbacks_failure_missingPrerequisite() { -// missingPrerequisite(); -// GetCurrentNetworkCallbacks mockCallbacks = mock(GetCurrentNetworkCallbacks.class); -// mWiseFy.getCurrentNetwork(mockCallbacks); -// verify(mockCallbacks, timeout(VERIFICATION_TIMEOUT)).getCurrentNetworkWiseFyFailure(WiseFyCodes.MISSING_PREREQUISITE); -// verify(mMockWiFiManager, never()).getConnectionInfo(); -// } -// -// @Test -// public void callbacks_failure_missingPrerequisite_nullCallbacks() { -// missingPrerequisite(); -// try { -// mWiseFy.getCurrentNetwork(null); -// verify(mMockWiFiManager, never()).getConnectionInfo(); -// } catch (NullPointerException npe) { -// fail(); -// } -// } -// -// @Test -// public void callbacks_success() { -// WifiInfo mockWifiInfo = mock(WifiInfo.class); -// when(mockWifiInfo.getSSID()).thenReturn(TEST_SSID); -// when(mMockWiFiManager.getConnectionInfo()).thenReturn(mockWifiInfo); -// -// GetCurrentNetworkCallbacks mockCallbacks = mock(GetCurrentNetworkCallbacks.class); -// mWiseFy.getCurrentNetwork(mockCallbacks); -// verify(mockCallbacks, timeout(2000)).retrievedCurrentNetwork(mockWifiInfo); -// verify(mMockWiFiManager, timeout(VERIFICATION_TIMEOUT)).getConnectionInfo(); -// } -// -// @Test -// public void callbacks_success_nullCallback() { -// WifiInfo mockWifiInfo = mock(WifiInfo.class); -// when(mockWifiInfo.getSSID()).thenReturn(TEST_SSID); -// when(mMockWiFiManager.getConnectionInfo()).thenReturn(mockWifiInfo); -// -// try { -// mWiseFy.getCurrentNetwork(null); -// verify(mMockWiFiManager, never()).getConnectionInfo(); -// } catch (NullPointerException npe) { -// fail(); -// } -// } -//} +package com.isupatches.wisefy; + + +import android.net.wifi.WifiInfo; +import com.isupatches.wisefy.callbacks.GetCurrentNetworkCallbacks; +import com.isupatches.wisefy.constants.WiseFyCodes; +import org.junit.Test; +import static com.isupatches.wisefy.base.TestUtils.TEST_SSID; +import static junit.framework.Assert.assertEquals; +import static junit.framework.Assert.fail; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.never; +import static org.mockito.Mockito.timeout; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; + + +public class GetCurrentNetworkTests extends BaseAndroidJUnit4TestClass { + + @Test + public void noCallbacks_failure_missingPrerequisite() { + missingPrerequisite(); + assertEquals(null, mWiseFy.getCurrentNetwork()); + verify(mMockWiFiManager, never()).getConnectionInfo(); + } + + @Test + public void noCallbacks_success() { + WifiInfo mockWifiInfo = mock(WifiInfo.class); + when(mockWifiInfo.getSSID()).thenReturn(TEST_SSID); + when(mMockWiFiManager.getConnectionInfo()).thenReturn(mockWifiInfo); + + assertEquals(TEST_SSID, mWiseFy.getCurrentNetwork().getSSID()); + verify(mMockWiFiManager, timeout(VERIFICATION_TIMEOUT)).getConnectionInfo(); + } + + @Test + public void callbacks_failure_missingPrerequisite() { + missingPrerequisite(); + GetCurrentNetworkCallbacks mockCallbacks = mock(GetCurrentNetworkCallbacks.class); + mWiseFy.getCurrentNetwork(mockCallbacks); + verify(mockCallbacks, timeout(VERIFICATION_TIMEOUT)).getCurrentNetworkWiseFyFailure(WiseFyCodes.MISSING_PREREQUISITE); + verify(mMockWiFiManager, never()).getConnectionInfo(); + } + + @Test + public void callbacks_failure_missingPrerequisite_nullCallbacks() { + missingPrerequisite(); + try { + mWiseFy.getCurrentNetwork(null); + verify(mMockWiFiManager, never()).getConnectionInfo(); + } catch (NullPointerException npe) { + fail(); + } + } + + @Test + public void callbacks_success() { + WifiInfo mockWifiInfo = mock(WifiInfo.class); + when(mockWifiInfo.getSSID()).thenReturn(TEST_SSID); + when(mMockWiFiManager.getConnectionInfo()).thenReturn(mockWifiInfo); + + GetCurrentNetworkCallbacks mockCallbacks = mock(GetCurrentNetworkCallbacks.class); + mWiseFy.getCurrentNetwork(mockCallbacks); + verify(mockCallbacks, timeout(2000)).retrievedCurrentNetwork(mockWifiInfo); + verify(mMockWiFiManager, timeout(VERIFICATION_TIMEOUT)).getConnectionInfo(); + } + + @Test + public void callbacks_success_nullCallback() { + WifiInfo mockWifiInfo = mock(WifiInfo.class); + when(mockWifiInfo.getSSID()).thenReturn(TEST_SSID); + when(mMockWiFiManager.getConnectionInfo()).thenReturn(mockWifiInfo); + + try { + mWiseFy.getCurrentNetwork(null); + verify(mMockWiFiManager, never()).getConnectionInfo(); + } catch (NullPointerException npe) { + fail(); + } + } +} diff --git a/wisefy/src/androidTest/java/com/isupatches/wisefy/GetFrequencyTests.java b/wisefy/src/androidTest/java/com/isupatches/wisefy/GetFrequencyTests.java index 181af04e..d5f7542d 100644 --- a/wisefy/src/androidTest/java/com/isupatches/wisefy/GetFrequencyTests.java +++ b/wisefy/src/androidTest/java/com/isupatches/wisefy/GetFrequencyTests.java @@ -1,158 +1,153 @@ -//package com.isupatches.wisefy; -// -// -//import android.net.wifi.WifiInfo; -//import android.os.Build; -//import com.isupatches.wisefy.base.TestActivity; -//import com.isupatches.wisefy.callbacks.GetFrequencyCallbacks; -//import com.isupatches.wisefy.constants.WiseFyCodes; -//import org.junit.Test; -//import static com.isupatches.wisefy.base.TestUtils.TEST_NETWORK_FREQUENCY_24GHZ; -//import static junit.framework.Assert.assertEquals; -//import static junit.framework.Assert.fail; -//import static org.mockito.Mockito.mock; -//import static org.mockito.Mockito.timeout; -//import static org.mockito.Mockito.verify; -//import static org.mockito.Mockito.when; -// -// -//public class GetFrequencyTests extends BaseTestClass { -// -// public GetFrequencyTests() { -// super(TestActivity.class); -// } -// -// @Test -// public void noCallbacks_getFrequency_currentNetwork_failure() { -// if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { -// when(mMockWiFiManager.getConnectionInfo()).thenReturn(null); -// assertEquals(null, mWiseFy.getFrequency()); -// } -// } -// -// @Test -// public void noCallbacks_getFrequency_currentNetwork_success() { -// if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { -// WifiInfo mockWifiInfo = mock(WifiInfo.class); -// when(mockWifiInfo.getFrequency()).thenReturn(TEST_NETWORK_FREQUENCY_24GHZ); -// when(mMockWiFiManager.getConnectionInfo()).thenReturn(mockWifiInfo); -// assertEquals(TEST_NETWORK_FREQUENCY_24GHZ, (int) mWiseFy.getFrequency()); -// verify(mockWifiInfo, timeout(VERIFICATION_TIMEOUT)).getFrequency(); -// } -// } -// -// @Test -// public void callbacks_getFrequency_currentNetwork_failure() { -// if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { -// when(mMockWiFiManager.getConnectionInfo()).thenReturn(null); -// GetFrequencyCallbacks mockCallbacks = mock(GetFrequencyCallbacks.class); -// mWiseFy.getFrequency(mockCallbacks); -// verify(mockCallbacks, timeout(2000)).failureGettingFrequency(); -// } -// } -// -// @Test -// public void callbacks_getFrequency_currentNetwork_failure_nullCallback() { -// if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { -// when(mMockWiFiManager.getConnectionInfo()).thenReturn(null); -// try { -// mWiseFy.getFrequency((GetFrequencyCallbacks) null); -// } catch (NullPointerException npe) { -// fail(); -// } -// } -// } -// -// @Test -// public void callbacks_getFrequency_currentNetwork_success() { -// if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { -// WifiInfo mockWifiInfo = mock(WifiInfo.class); -// when(mockWifiInfo.getFrequency()).thenReturn(TEST_NETWORK_FREQUENCY_24GHZ); -// when(mMockWiFiManager.getConnectionInfo()).thenReturn(mockWifiInfo); -// GetFrequencyCallbacks mockCallbacks = mock(GetFrequencyCallbacks.class); -// mWiseFy.getFrequency(mockCallbacks); -// verify(mockCallbacks, timeout(VERIFICATION_TIMEOUT)).retrievedFrequency(TEST_NETWORK_FREQUENCY_24GHZ); -// verify(mockWifiInfo, timeout(VERIFICATION_TIMEOUT)).getFrequency(); -// } -// } -// -// @Test -// public void callbacks_getFrequency_currentNetwork_success_nullCallback() { -// if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { -// WifiInfo mockWifiInfo = mock(WifiInfo.class); -// when(mockWifiInfo.getFrequency()).thenReturn(TEST_NETWORK_FREQUENCY_24GHZ); -// when(mMockWiFiManager.getConnectionInfo()).thenReturn(mockWifiInfo); -// try { -// mWiseFy.getFrequency((GetFrequencyCallbacks) null); -// } catch (NullPointerException npe) { -// fail(); -// } -// } -// } -// -// @Test -// public void noCallbacks_getFrequency_provideWifiInfo_failure() { -// if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { -// when(mMockWiFiManager.getConnectionInfo()).thenReturn(null); -// assertEquals(null, mWiseFy.getFrequency((WifiInfo) null)); -// } -// } -// -// @Test -// public void noCallbacks_getFrequency_provideWifiInfo_success() { -// if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { -// WifiInfo mockWifiInfo = mock(WifiInfo.class); -// when(mockWifiInfo.getFrequency()).thenReturn(TEST_NETWORK_FREQUENCY_24GHZ); -// when(mMockWiFiManager.getConnectionInfo()).thenReturn(mockWifiInfo); -// assertEquals(TEST_NETWORK_FREQUENCY_24GHZ, (int) mWiseFy.getFrequency(mockWifiInfo)); -// } -// } -// -// @Test -// public void callbacks_getFrequency_provideWifiInfo_failure() { -// if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { -// when(mMockWiFiManager.getConnectionInfo()).thenReturn(null); -// GetFrequencyCallbacks mockCallbacks = mock(GetFrequencyCallbacks.class); -// mWiseFy.getFrequency(null, mockCallbacks); -// verify(mockCallbacks, timeout(2000)).getFrequencyWiseFyFailure(WiseFyCodes.MISSING_PARAMETER); -// } -// } -// -// @Test -// public void callbacks_getFrequency_provideWifiInfo_failure_nullCallback() { -// if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { -// when(mMockWiFiManager.getConnectionInfo()).thenReturn(null); -// try { -// mWiseFy.getFrequency(null, null); -// } catch (NullPointerException npe) { -// fail(); -// } -// } -// } -// -// @Test -// public void callbacks_getFrequency_provideWifiInfo_success() { -// if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { -// WifiInfo mockWifiInfo = mock(WifiInfo.class); -// when(mockWifiInfo.getFrequency()).thenReturn(TEST_NETWORK_FREQUENCY_24GHZ); -// when(mMockWiFiManager.getConnectionInfo()).thenReturn(mockWifiInfo); -// GetFrequencyCallbacks mockCallbacks = mock(GetFrequencyCallbacks.class); -// mWiseFy.getFrequency(mockWifiInfo, mockCallbacks); -// verify(mockCallbacks, timeout(2000)).retrievedFrequency(TEST_NETWORK_FREQUENCY_24GHZ); -// } -// } -// -// @Test -// public void callbacks_getFrequency_provideWifiInfo_success_nullCallback() { -// if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { -// WifiInfo mockWifiInfo = mock(WifiInfo.class); -// when(mockWifiInfo.getFrequency()).thenReturn(TEST_NETWORK_FREQUENCY_24GHZ); -// when(mMockWiFiManager.getConnectionInfo()).thenReturn(mockWifiInfo); -// try { -// mWiseFy.getFrequency(mockWifiInfo, null); -// } catch (NullPointerException npe) { -// fail(); -// } -// } -// } -//} +package com.isupatches.wisefy; + + +import android.net.wifi.WifiInfo; +import android.os.Build; +import com.isupatches.wisefy.callbacks.GetFrequencyCallbacks; +import com.isupatches.wisefy.constants.WiseFyCodes; +import org.junit.Test; +import static com.isupatches.wisefy.base.TestUtils.TEST_NETWORK_FREQUENCY_24GHZ; +import static junit.framework.Assert.assertEquals; +import static junit.framework.Assert.fail; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.timeout; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; + + +public class GetFrequencyTests extends BaseAndroidJUnit4TestClass { + + @Test + public void noCallbacks_getFrequency_currentNetwork_failure() { + if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { + when(mMockWiFiManager.getConnectionInfo()).thenReturn(null); + assertEquals(null, mWiseFy.getFrequency()); + } + } + + @Test + public void noCallbacks_getFrequency_currentNetwork_success() { + if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { + WifiInfo mockWifiInfo = mock(WifiInfo.class); + when(mockWifiInfo.getFrequency()).thenReturn(TEST_NETWORK_FREQUENCY_24GHZ); + when(mMockWiFiManager.getConnectionInfo()).thenReturn(mockWifiInfo); + assertEquals(TEST_NETWORK_FREQUENCY_24GHZ, (int) mWiseFy.getFrequency()); + verify(mockWifiInfo, timeout(VERIFICATION_TIMEOUT)).getFrequency(); + } + } + + @Test + public void callbacks_getFrequency_currentNetwork_failure() { + if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { + when(mMockWiFiManager.getConnectionInfo()).thenReturn(null); + GetFrequencyCallbacks mockCallbacks = mock(GetFrequencyCallbacks.class); + mWiseFy.getFrequency(mockCallbacks); + verify(mockCallbacks, timeout(2000)).failureGettingFrequency(); + } + } + + @Test + public void callbacks_getFrequency_currentNetwork_failure_nullCallback() { + if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { + when(mMockWiFiManager.getConnectionInfo()).thenReturn(null); + try { + mWiseFy.getFrequency((GetFrequencyCallbacks) null); + } catch (NullPointerException npe) { + fail(); + } + } + } + + @Test + public void callbacks_getFrequency_currentNetwork_success() { + if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { + WifiInfo mockWifiInfo = mock(WifiInfo.class); + when(mockWifiInfo.getFrequency()).thenReturn(TEST_NETWORK_FREQUENCY_24GHZ); + when(mMockWiFiManager.getConnectionInfo()).thenReturn(mockWifiInfo); + GetFrequencyCallbacks mockCallbacks = mock(GetFrequencyCallbacks.class); + mWiseFy.getFrequency(mockCallbacks); + verify(mockCallbacks, timeout(VERIFICATION_TIMEOUT)).retrievedFrequency(TEST_NETWORK_FREQUENCY_24GHZ); + verify(mockWifiInfo, timeout(VERIFICATION_TIMEOUT)).getFrequency(); + } + } + + @Test + public void callbacks_getFrequency_currentNetwork_success_nullCallback() { + if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { + WifiInfo mockWifiInfo = mock(WifiInfo.class); + when(mockWifiInfo.getFrequency()).thenReturn(TEST_NETWORK_FREQUENCY_24GHZ); + when(mMockWiFiManager.getConnectionInfo()).thenReturn(mockWifiInfo); + try { + mWiseFy.getFrequency((GetFrequencyCallbacks) null); + } catch (NullPointerException npe) { + fail(); + } + } + } + + @Test + public void noCallbacks_getFrequency_provideWifiInfo_failure() { + if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { + when(mMockWiFiManager.getConnectionInfo()).thenReturn(null); + assertEquals(null, mWiseFy.getFrequency((WifiInfo) null)); + } + } + + @Test + public void noCallbacks_getFrequency_provideWifiInfo_success() { + if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { + WifiInfo mockWifiInfo = mock(WifiInfo.class); + when(mockWifiInfo.getFrequency()).thenReturn(TEST_NETWORK_FREQUENCY_24GHZ); + when(mMockWiFiManager.getConnectionInfo()).thenReturn(mockWifiInfo); + assertEquals(TEST_NETWORK_FREQUENCY_24GHZ, (int) mWiseFy.getFrequency(mockWifiInfo)); + } + } + + @Test + public void callbacks_getFrequency_provideWifiInfo_failure() { + if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { + when(mMockWiFiManager.getConnectionInfo()).thenReturn(null); + GetFrequencyCallbacks mockCallbacks = mock(GetFrequencyCallbacks.class); + mWiseFy.getFrequency(null, mockCallbacks); + verify(mockCallbacks, timeout(2000)).getFrequencyWiseFyFailure(WiseFyCodes.MISSING_PARAMETER); + } + } + + @Test + public void callbacks_getFrequency_provideWifiInfo_failure_nullCallback() { + if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { + when(mMockWiFiManager.getConnectionInfo()).thenReturn(null); + try { + mWiseFy.getFrequency(null, null); + } catch (NullPointerException npe) { + fail(); + } + } + } + + @Test + public void callbacks_getFrequency_provideWifiInfo_success() { + if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { + WifiInfo mockWifiInfo = mock(WifiInfo.class); + when(mockWifiInfo.getFrequency()).thenReturn(TEST_NETWORK_FREQUENCY_24GHZ); + when(mMockWiFiManager.getConnectionInfo()).thenReturn(mockWifiInfo); + GetFrequencyCallbacks mockCallbacks = mock(GetFrequencyCallbacks.class); + mWiseFy.getFrequency(mockWifiInfo, mockCallbacks); + verify(mockCallbacks, timeout(2000)).retrievedFrequency(TEST_NETWORK_FREQUENCY_24GHZ); + } + } + + @Test + public void callbacks_getFrequency_provideWifiInfo_success_nullCallback() { + if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { + WifiInfo mockWifiInfo = mock(WifiInfo.class); + when(mockWifiInfo.getFrequency()).thenReturn(TEST_NETWORK_FREQUENCY_24GHZ); + when(mMockWiFiManager.getConnectionInfo()).thenReturn(mockWifiInfo); + try { + mWiseFy.getFrequency(mockWifiInfo, null); + } catch (NullPointerException npe) { + fail(); + } + } + } +} diff --git a/wisefy/src/androidTest/java/com/isupatches/wisefy/GetNearbyAccessPointsTests.java b/wisefy/src/androidTest/java/com/isupatches/wisefy/GetNearbyAccessPointsTests.java index c8c64b5e..e9144cac 100644 --- a/wisefy/src/androidTest/java/com/isupatches/wisefy/GetNearbyAccessPointsTests.java +++ b/wisefy/src/androidTest/java/com/isupatches/wisefy/GetNearbyAccessPointsTests.java @@ -1,210 +1,205 @@ -//package com.isupatches.wisefy; -// -// -//import android.net.wifi.ScanResult; -//import com.isupatches.wisefy.base.TestActivity; -//import com.isupatches.wisefy.callbacks.GetNearbyAccessPointsCallbacks; -//import com.isupatches.wisefy.constants.WiseFyCodes; -//import org.junit.Test; -//import org.mockito.ArgumentMatchers; -//import java.util.ArrayList; -//import java.util.List; -//import static com.isupatches.wisefy.base.TestUtils.TEST_SSID; -//import static com.isupatches.wisefy.base.TestUtils.TEST_SSID2; -//import static junit.framework.Assert.assertEquals; -//import static junit.framework.Assert.fail; -//import static org.mockito.Mockito.mock; -//import static org.mockito.Mockito.never; -//import static org.mockito.Mockito.timeout; -//import static org.mockito.Mockito.verify; -//import static org.mockito.Mockito.when; -// -// -//public class GetNearbyAccessPointsTests extends BaseTestClass { -// -// public GetNearbyAccessPointsTests() { -// super(TestActivity.class); -// } -// -// @Test -// public void noCallbacks_failure_missingPrerequisite_filterDuplicates_false() { -// missingPrerequisite(); -// assertEquals(null, mWiseFy.getNearbyAccessPoints(false)); -// verify(mMockWiFiManager, never()).getScanResults(); -// } -// -// @Test -// public void noCallbacks_failure_missingPrerequisite_filterDuplicates_true() { -// missingPrerequisite(); -// assertEquals(null, mWiseFy.getNearbyAccessPoints(true)); -// verify(mMockWiFiManager, never()).getScanResults(); -// } -// -// @Test -// public void noCallbacks_success_filterDuplicates_false() { -// List scanResults = new ArrayList<>(); -// ScanResult scanResult1 = mock(ScanResult.class); -// scanResult1.SSID = TEST_SSID; -// scanResult1.level = -35; -// scanResults.add(scanResult1); -// ScanResult scanResult2 = mock(ScanResult.class); -// scanResult2.SSID = TEST_SSID2; -// scanResult2.level = -70; -// scanResults.add(scanResult2); -// -// when(mMockWiFiManager.getScanResults()).thenReturn(scanResults); -// -// List accessPoints = mWiseFy.getNearbyAccessPoints(false); -// assertEquals(accessPoints, scanResults); -// verify(mMockWiFiManager, timeout(VERIFICATION_TIMEOUT)).getScanResults(); -// } -// -// @Test -// public void noCallbacks_success_filterDuplicates_true() { -// List scanResults = new ArrayList<>(); -// ScanResult scanResult1 = mock(ScanResult.class); -// scanResult1.SSID = TEST_SSID; -// scanResult1.level = -35; -// scanResults.add(scanResult1); -// ScanResult scanResult2 = mock(ScanResult.class); -// scanResult2.SSID = TEST_SSID2; -// scanResult2.level = -70; -// scanResults.add(scanResult2); -// -// WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); -// mWiseFy.mWiseFySearch = mockWiseFySearch; -// when(mockWiseFySearch.removeEntriesWithLowerSignalStrength(ArgumentMatchers.anyList())).thenReturn(scanResults); -// -// List accessPoints = mWiseFy.getNearbyAccessPoints(true); -// assertEquals(accessPoints, scanResults); -// verify(mMockWiFiManager, timeout(VERIFICATION_TIMEOUT)).getScanResults(); -// } -// -// @Test -// public void callbacks_failure_missingPrerequisite_filterDuplicates_false() { -// missingPrerequisite(); -// GetNearbyAccessPointsCallbacks mockCallbacks = mock(GetNearbyAccessPointsCallbacks.class); -// mWiseFy.getNearbyAccessPoints(false, mockCallbacks); -// verify(mockCallbacks, timeout(VERIFICATION_TIMEOUT)).getNearbyAccessPointsWiseFyFailure(WiseFyCodes.MISSING_PREREQUISITE); -// verify(mMockWiFiManager, never()).getScanResults(); -// } -// -// @Test -// public void callbacks_failure_missingPrerequisite_filterDuplicates_false_nullCallback() { -// missingPrerequisite(); -// try { -// mWiseFy.getNearbyAccessPoints(false, null); -// verify(mMockWiFiManager, never()).getScanResults(); -// } catch (NullPointerException npe) { -// fail(); -// } -// } -// -// @Test -// public void callbacks_failure_missingPrerequisite_filterDuplicates_true() { -// missingPrerequisite(); -// GetNearbyAccessPointsCallbacks mockCallbacks = mock(GetNearbyAccessPointsCallbacks.class); -// mWiseFy.getNearbyAccessPoints(true, mockCallbacks); -// verify(mockCallbacks, timeout(3000)).getNearbyAccessPointsWiseFyFailure(WiseFyCodes.MISSING_PREREQUISITE); -// verify(mMockWiFiManager, never()).getScanResults(); -// } -// -// @Test -// public void callbacks_failure_missingPrerequisite_filterDuplicates_true_nullCallback() { -// missingPrerequisite(); -// try { -// mWiseFy.getNearbyAccessPoints(true, null); -// verify(mMockWiFiManager, never()).getScanResults(); -// } catch (NullPointerException npe) { -// fail(); -// } -// } -// -// @Test -// public void callbacks_success_filterDuplicates_false() { -// List scanResults = new ArrayList<>(); -// ScanResult scanResult1 = mock(ScanResult.class); -// scanResult1.SSID = TEST_SSID; -// scanResult1.level = -35; -// scanResults.add(scanResult1); -// ScanResult scanResult2 = mock(ScanResult.class); -// scanResult2.SSID = TEST_SSID2; -// scanResult2.level = -70; -// scanResults.add(scanResult2); -// -// when(mMockWiFiManager.getScanResults()).thenReturn(scanResults); -// -// GetNearbyAccessPointsCallbacks mockCallbacks = mock(GetNearbyAccessPointsCallbacks.class); -// mWiseFy.getNearbyAccessPoints(false, mockCallbacks); -// verify(mockCallbacks, timeout(VERIFICATION_TIMEOUT)).retrievedNearbyAccessPoints(scanResults); -// verify(mMockWiFiManager, timeout(VERIFICATION_TIMEOUT)).getScanResults(); -// } -// -// @Test -// public void callbacks_success_filterDuplicates_false_nullCallback() { -// List scanResults = new ArrayList<>(); -// ScanResult scanResult1 = mock(ScanResult.class); -// scanResult1.SSID = TEST_SSID; -// scanResult1.level = -35; -// scanResults.add(scanResult1); -// ScanResult scanResult2 = mock(ScanResult.class); -// scanResult2.SSID = TEST_SSID2; -// scanResult2.level = -70; -// scanResults.add(scanResult2); -// -// when(mMockWiFiManager.getScanResults()).thenReturn(scanResults); -// -// try { -// mWiseFy.getNearbyAccessPoints(false, null); -// verify(mMockWiFiManager, never()).getScanResults(); -// } catch (NullPointerException npe) { -// fail(); -// } -// } -// -// @Test -// public void callbacks_success_filterDuplicates_true() { -// List scanResults = new ArrayList<>(); -// ScanResult scanResult1 = mock(ScanResult.class); -// scanResult1.SSID = TEST_SSID; -// scanResult1.level = -35; -// scanResults.add(scanResult1); -// ScanResult scanResult2 = mock(ScanResult.class); -// scanResult2.SSID = TEST_SSID2; -// scanResult2.level = -70; -// scanResults.add(scanResult2); -// -// WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); -// mWiseFy.mWiseFySearch = mockWiseFySearch; -// when(mockWiseFySearch.removeEntriesWithLowerSignalStrength(ArgumentMatchers.anyList())).thenReturn(scanResults); -// -// GetNearbyAccessPointsCallbacks mockCallbacks = mock(GetNearbyAccessPointsCallbacks.class); -// mWiseFy.getNearbyAccessPoints(true, mockCallbacks); -// verify(mockCallbacks, timeout(VERIFICATION_TIMEOUT)).retrievedNearbyAccessPoints(scanResults); -// verify(mMockWiFiManager, timeout(VERIFICATION_TIMEOUT)).getScanResults(); -// } -// -// @Test -// public void callbacks_success_filterDuplicates_true_nullCallback() { -// List scanResults = new ArrayList<>(); -// ScanResult scanResult1 = mock(ScanResult.class); -// scanResult1.SSID = TEST_SSID; -// scanResult1.level = -35; -// scanResults.add(scanResult1); -// ScanResult scanResult2 = mock(ScanResult.class); -// scanResult2.SSID = TEST_SSID2; -// scanResult2.level = -70; -// scanResults.add(scanResult2); -// -// WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); -// mWiseFy.mWiseFySearch = mockWiseFySearch; -// when(mockWiseFySearch.removeEntriesWithLowerSignalStrength(ArgumentMatchers.anyList())).thenReturn(scanResults); -// -// try { -// mWiseFy.getNearbyAccessPoints(true, null); -// verify(mMockWiFiManager, never()).getScanResults(); -// } catch (NullPointerException npe) { -// fail(); -// } -// } -//} \ No newline at end of file +package com.isupatches.wisefy; + + +import android.net.wifi.ScanResult; +import com.isupatches.wisefy.callbacks.GetNearbyAccessPointsCallbacks; +import com.isupatches.wisefy.constants.WiseFyCodes; +import org.junit.Test; +import org.mockito.ArgumentMatchers; +import java.util.ArrayList; +import java.util.List; +import static com.isupatches.wisefy.base.TestUtils.TEST_SSID; +import static com.isupatches.wisefy.base.TestUtils.TEST_SSID2; +import static junit.framework.Assert.assertEquals; +import static junit.framework.Assert.fail; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.never; +import static org.mockito.Mockito.timeout; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; + + +public class GetNearbyAccessPointsTests extends BaseAndroidJUnit4TestClass { + + @Test + public void noCallbacks_failure_missingPrerequisite_filterDuplicates_false() { + missingPrerequisite(); + assertEquals(null, mWiseFy.getNearbyAccessPoints(false)); + verify(mMockWiFiManager, never()).getScanResults(); + } + + @Test + public void noCallbacks_failure_missingPrerequisite_filterDuplicates_true() { + missingPrerequisite(); + assertEquals(null, mWiseFy.getNearbyAccessPoints(true)); + verify(mMockWiFiManager, never()).getScanResults(); + } + + @Test + public void noCallbacks_success_filterDuplicates_false() { + List scanResults = new ArrayList<>(); + ScanResult scanResult1 = mock(ScanResult.class); + scanResult1.SSID = TEST_SSID; + scanResult1.level = -35; + scanResults.add(scanResult1); + ScanResult scanResult2 = mock(ScanResult.class); + scanResult2.SSID = TEST_SSID2; + scanResult2.level = -70; + scanResults.add(scanResult2); + + when(mMockWiFiManager.getScanResults()).thenReturn(scanResults); + + List accessPoints = mWiseFy.getNearbyAccessPoints(false); + assertEquals(accessPoints, scanResults); + verify(mMockWiFiManager, timeout(VERIFICATION_TIMEOUT)).getScanResults(); + } + + @Test + public void noCallbacks_success_filterDuplicates_true() { + List scanResults = new ArrayList<>(); + ScanResult scanResult1 = mock(ScanResult.class); + scanResult1.SSID = TEST_SSID; + scanResult1.level = -35; + scanResults.add(scanResult1); + ScanResult scanResult2 = mock(ScanResult.class); + scanResult2.SSID = TEST_SSID2; + scanResult2.level = -70; + scanResults.add(scanResult2); + + WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); + mWiseFy.mWiseFySearch = mockWiseFySearch; + when(mockWiseFySearch.removeEntriesWithLowerSignalStrength(ArgumentMatchers.anyList())).thenReturn(scanResults); + + List accessPoints = mWiseFy.getNearbyAccessPoints(true); + assertEquals(accessPoints, scanResults); + verify(mMockWiFiManager, timeout(VERIFICATION_TIMEOUT)).getScanResults(); + } + + @Test + public void callbacks_failure_missingPrerequisite_filterDuplicates_false() { + missingPrerequisite(); + GetNearbyAccessPointsCallbacks mockCallbacks = mock(GetNearbyAccessPointsCallbacks.class); + mWiseFy.getNearbyAccessPoints(false, mockCallbacks); + verify(mockCallbacks, timeout(VERIFICATION_TIMEOUT)).getNearbyAccessPointsWiseFyFailure(WiseFyCodes.MISSING_PREREQUISITE); + verify(mMockWiFiManager, never()).getScanResults(); + } + + @Test + public void callbacks_failure_missingPrerequisite_filterDuplicates_false_nullCallback() { + missingPrerequisite(); + try { + mWiseFy.getNearbyAccessPoints(false, null); + verify(mMockWiFiManager, never()).getScanResults(); + } catch (NullPointerException npe) { + fail(); + } + } + + @Test + public void callbacks_failure_missingPrerequisite_filterDuplicates_true() { + missingPrerequisite(); + GetNearbyAccessPointsCallbacks mockCallbacks = mock(GetNearbyAccessPointsCallbacks.class); + mWiseFy.getNearbyAccessPoints(true, mockCallbacks); + verify(mockCallbacks, timeout(3000)).getNearbyAccessPointsWiseFyFailure(WiseFyCodes.MISSING_PREREQUISITE); + verify(mMockWiFiManager, never()).getScanResults(); + } + + @Test + public void callbacks_failure_missingPrerequisite_filterDuplicates_true_nullCallback() { + missingPrerequisite(); + try { + mWiseFy.getNearbyAccessPoints(true, null); + verify(mMockWiFiManager, never()).getScanResults(); + } catch (NullPointerException npe) { + fail(); + } + } + + @Test + public void callbacks_success_filterDuplicates_false() { + List scanResults = new ArrayList<>(); + ScanResult scanResult1 = mock(ScanResult.class); + scanResult1.SSID = TEST_SSID; + scanResult1.level = -35; + scanResults.add(scanResult1); + ScanResult scanResult2 = mock(ScanResult.class); + scanResult2.SSID = TEST_SSID2; + scanResult2.level = -70; + scanResults.add(scanResult2); + + when(mMockWiFiManager.getScanResults()).thenReturn(scanResults); + + GetNearbyAccessPointsCallbacks mockCallbacks = mock(GetNearbyAccessPointsCallbacks.class); + mWiseFy.getNearbyAccessPoints(false, mockCallbacks); + verify(mockCallbacks, timeout(VERIFICATION_TIMEOUT)).retrievedNearbyAccessPoints(scanResults); + verify(mMockWiFiManager, timeout(VERIFICATION_TIMEOUT)).getScanResults(); + } + + @Test + public void callbacks_success_filterDuplicates_false_nullCallback() { + List scanResults = new ArrayList<>(); + ScanResult scanResult1 = mock(ScanResult.class); + scanResult1.SSID = TEST_SSID; + scanResult1.level = -35; + scanResults.add(scanResult1); + ScanResult scanResult2 = mock(ScanResult.class); + scanResult2.SSID = TEST_SSID2; + scanResult2.level = -70; + scanResults.add(scanResult2); + + when(mMockWiFiManager.getScanResults()).thenReturn(scanResults); + + try { + mWiseFy.getNearbyAccessPoints(false, null); + verify(mMockWiFiManager, never()).getScanResults(); + } catch (NullPointerException npe) { + fail(); + } + } + + @Test + public void callbacks_success_filterDuplicates_true() { + List scanResults = new ArrayList<>(); + ScanResult scanResult1 = mock(ScanResult.class); + scanResult1.SSID = TEST_SSID; + scanResult1.level = -35; + scanResults.add(scanResult1); + ScanResult scanResult2 = mock(ScanResult.class); + scanResult2.SSID = TEST_SSID2; + scanResult2.level = -70; + scanResults.add(scanResult2); + + WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); + mWiseFy.mWiseFySearch = mockWiseFySearch; + when(mockWiseFySearch.removeEntriesWithLowerSignalStrength(ArgumentMatchers.anyList())).thenReturn(scanResults); + + GetNearbyAccessPointsCallbacks mockCallbacks = mock(GetNearbyAccessPointsCallbacks.class); + mWiseFy.getNearbyAccessPoints(true, mockCallbacks); + verify(mockCallbacks, timeout(VERIFICATION_TIMEOUT)).retrievedNearbyAccessPoints(scanResults); + verify(mMockWiFiManager, timeout(VERIFICATION_TIMEOUT)).getScanResults(); + } + + @Test + public void callbacks_success_filterDuplicates_true_nullCallback() { + List scanResults = new ArrayList<>(); + ScanResult scanResult1 = mock(ScanResult.class); + scanResult1.SSID = TEST_SSID; + scanResult1.level = -35; + scanResults.add(scanResult1); + ScanResult scanResult2 = mock(ScanResult.class); + scanResult2.SSID = TEST_SSID2; + scanResult2.level = -70; + scanResults.add(scanResult2); + + WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); + mWiseFy.mWiseFySearch = mockWiseFySearch; + when(mockWiseFySearch.removeEntriesWithLowerSignalStrength(ArgumentMatchers.anyList())).thenReturn(scanResults); + + try { + mWiseFy.getNearbyAccessPoints(true, null); + verify(mMockWiFiManager, never()).getScanResults(); + } catch (NullPointerException npe) { + fail(); + } + } +} \ No newline at end of file diff --git a/wisefy/src/androidTest/java/com/isupatches/wisefy/GetRSSITests.java b/wisefy/src/androidTest/java/com/isupatches/wisefy/GetRSSITests.java index f6b6300c..1f622a6f 100644 --- a/wisefy/src/androidTest/java/com/isupatches/wisefy/GetRSSITests.java +++ b/wisefy/src/androidTest/java/com/isupatches/wisefy/GetRSSITests.java @@ -1,264 +1,259 @@ -//package com.isupatches.wisefy; -// -// -//import android.net.wifi.ScanResult; -//import com.isupatches.wisefy.base.TestActivity; -//import com.isupatches.wisefy.callbacks.GetRSSICallbacks; -//import com.isupatches.wisefy.constants.WiseFyCodes; -//import org.junit.Test; -//import static com.isupatches.wisefy.base.TestUtils.TEST_RSSI_LEVEL; -//import static com.isupatches.wisefy.base.TestUtils.TEST_SSID; -//import static junit.framework.Assert.assertEquals; -//import static junit.framework.Assert.fail; -//import static org.mockito.ArgumentMatchers.anyBoolean; -//import static org.mockito.ArgumentMatchers.anyInt; -//import static org.mockito.ArgumentMatchers.anyString; -//import static org.mockito.Mockito.mock; -//import static org.mockito.Mockito.timeout; -//import static org.mockito.Mockito.verify; -//import static org.mockito.Mockito.when; -// -// -//public class GetRSSITests extends BaseTestClass { -// -// public GetRSSITests() { -// super(TestActivity.class); -// } -// -// @Test -// public void noCallbacks_failure_takeHighest_false_nullSSIDParam() { -// assertEquals(null, mWiseFy.getRSSI(null, false, 1000)); -// } -// -// @Test -// public void noCallbacks_failure_takeHighest_true_nullSSIDParam() { -// assertEquals(null, mWiseFy.getRSSI(null, true, 1000)); -// } -// -// @Test -// public void noCallbacks_failure_takeHighest_false_missingPrerequisite() { -// missingPrerequisite(); -// assertEquals(null, mWiseFy.getRSSI(TEST_SSID, false, 1000)); -// } -// -// @Test -// public void noCallbacks_failure_takeHighest_true_missingPrerequisite() { -// missingPrerequisite(); -// assertEquals(null, mWiseFy.getRSSI(TEST_SSID, true, 1000)); -// } -// -// @Test -// public void noCallbacks_failure_takeHighest_false_noNetworkFound() { -// WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); -// mWiseFy.mWiseFySearch = mockWiseFySearch; -// when(mockWiseFySearch.findAccessPointByRegex(anyString(), anyInt(), anyBoolean())).thenReturn(null); -// -// assertEquals(null, mWiseFy.getRSSI(TEST_SSID, false, 1000)); -// } -// -// @Test -// public void noCallbacks_failure_takeHighest_true_noNetworkFound() { -// WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); -// mWiseFy.mWiseFySearch = mockWiseFySearch; -// when(mockWiseFySearch.findAccessPointByRegex(anyString(), anyInt(), anyBoolean())).thenReturn(null); -// -// assertEquals(null, mWiseFy.getRSSI(TEST_SSID, true, 1000)); -// } -// -// @Test -// public void noCallbacks_success_takeHighest_false () { -// ScanResult accessPoint = mock(ScanResult.class); -// accessPoint.level = TEST_RSSI_LEVEL; -// WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); -// mWiseFy.mWiseFySearch = mockWiseFySearch; -// when(mockWiseFySearch.findAccessPointByRegex(anyString(), anyInt(), anyBoolean())).thenReturn(accessPoint); -// -// assertEquals(TEST_RSSI_LEVEL, (int) mWiseFy.getRSSI(TEST_SSID, false, 1000)); -// -// } -// -// @Test -// public void noCallbacks_success_takeHighest_true () { -// ScanResult accessPoint = mock(ScanResult.class); -// accessPoint.level = TEST_RSSI_LEVEL; -// WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); -// mWiseFy.mWiseFySearch = mockWiseFySearch; -// when(mockWiseFySearch.findAccessPointByRegex(anyString(), anyInt(), anyBoolean())).thenReturn(accessPoint); -// -// assertEquals(TEST_RSSI_LEVEL, (int) mWiseFy.getRSSI(TEST_SSID, true, 1000)); -// } -// -// @Test -// public void callbacks_failure_takeHighest_false_nullSSIDParam() { -// GetRSSICallbacks mockCallbacks = mock(GetRSSICallbacks.class); -// mWiseFy.getRSSI(null, false, 1000, mockCallbacks); -// verify(mockCallbacks, timeout(2000)).getRSSIWiseFyFailure(WiseFyCodes.MISSING_PARAMETER); -// } -// -// @Test -// public void callbacks_failure_takeHighest_false_nullSSIDParam_nullCallback() { -// try { -// mWiseFy.getRSSI(null, false, 1000, null); -// } catch (NullPointerException npe) { -// fail(); -// } -// } -// -// @Test -// public void callbacks_failure_takeHighest_true_nullSSIDParam() { -// GetRSSICallbacks mockCallbacks = mock(GetRSSICallbacks.class); -// mWiseFy.getRSSI(null, true, 1000, mockCallbacks); -// verify(mockCallbacks, timeout(2000)).getRSSIWiseFyFailure(WiseFyCodes.MISSING_PARAMETER); -// } -// -// @Test -// public void callbacks_failure_takeHighest_true_nullSSIDParam_nullCallback() { -// try { -// mWiseFy.getRSSI(null, true, 1000, null); -// } catch (NullPointerException npe) { -// fail(); -// } -// } -// -// @Test -// public void callbacks_failure_takeHighest_false_missingPrerequisite() { -// missingPrerequisite(); -// GetRSSICallbacks mockCallbacks = mock(GetRSSICallbacks.class); -// mWiseFy.getRSSI(TEST_SSID, false, 1000, mockCallbacks); -// verify(mockCallbacks, timeout(2000)).getRSSIWiseFyFailure(WiseFyCodes.MISSING_PREREQUISITE); -// } -// -// @Test -// public void callbacks_failure_takeHighest_false_nullSSIDParam_missingPrerequisite() { -// missingPrerequisite(); -// try { -// mWiseFy.getRSSI(TEST_SSID, false, 1000, null); -// } catch (NullPointerException npe) { -// fail(); -// } -// } -// -// @Test -// public void callbacks_failure_takeHighest_true_missingPrerequisite() { -// missingPrerequisite(); -// GetRSSICallbacks mockCallbacks = mock(GetRSSICallbacks.class); -// mWiseFy.getRSSI(TEST_SSID, true, 1000, mockCallbacks); -// verify(mockCallbacks, timeout(2000)).getRSSIWiseFyFailure(WiseFyCodes.MISSING_PREREQUISITE); -// } -// -// @Test -// public void callbacks_failure_takeHighest_true_nullSSIDParam_missingPrerequisite() { -// missingPrerequisite(); -// try { -// mWiseFy.getRSSI(TEST_SSID, true, 1000, null); -// } catch (NullPointerException npe) { -// fail(); -// } -// } -// -// @Test -// public void callbacks_failure_takeHighest_false_noNetworkFound() { -// WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); -// mWiseFy.mWiseFySearch = mockWiseFySearch; -// when(mockWiseFySearch.findAccessPointByRegex(anyString(), anyInt(), anyBoolean())).thenReturn(null); -// -// GetRSSICallbacks mockCallbacks = mock(GetRSSICallbacks.class); -// mWiseFy.getRSSI(TEST_SSID, false, 1000, mockCallbacks); -// verify(mockCallbacks, timeout(2000)).networkNotFoundToRetrieveRSSI(); -// } -// -// @Test -// public void callbacks_failure_takeHighest_false_noNetworkFound_nullCallback() { -// WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); -// mWiseFy.mWiseFySearch = mockWiseFySearch; -// when(mockWiseFySearch.findAccessPointByRegex(anyString(), anyInt(), anyBoolean())).thenReturn(null); -// -// try { -// mWiseFy.getRSSI(TEST_SSID, false, 1000, null); -// } catch (NullPointerException npe) { -// fail(); -// } -// } -// -// @Test -// public void callbacks_failure_takeHighest_true_noNetworkFound() { -// WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); -// mWiseFy.mWiseFySearch = mockWiseFySearch; -// when(mockWiseFySearch.findAccessPointByRegex(anyString(), anyInt(), anyBoolean())).thenReturn(null); -// -// GetRSSICallbacks mockCallbacks = mock(GetRSSICallbacks.class); -// mWiseFy.getRSSI(TEST_SSID, true, 1000, mockCallbacks); -// verify(mockCallbacks, timeout(2000)).networkNotFoundToRetrieveRSSI(); -// } -// -// @Test -// public void callbacks_failure_takeHighest_true_noNetworkFound_nullCallback() { -// WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); -// mWiseFy.mWiseFySearch = mockWiseFySearch; -// when(mockWiseFySearch.findAccessPointByRegex(anyString(), anyInt(), anyBoolean())).thenReturn(null); -// -// try { -// mWiseFy.getRSSI(TEST_SSID, true, 1000, null); -// } catch (NullPointerException npe) { -// fail(); -// } -// } -// -// @Test -// public void callbacks_success_takeHighest_false() { -// WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); -// mWiseFy.mWiseFySearch = mockWiseFySearch; -// ScanResult accessPoint = mock(ScanResult.class); -// accessPoint.level = TEST_RSSI_LEVEL; -// when(mockWiseFySearch.findAccessPointByRegex(anyString(), anyInt(), anyBoolean())).thenReturn(accessPoint); -// -// -// GetRSSICallbacks mockCallbacks = mock(GetRSSICallbacks.class); -// mWiseFy.getRSSI(TEST_SSID, false, 1000, mockCallbacks); -// verify(mockCallbacks, timeout(2000)).retrievedRSSI(TEST_RSSI_LEVEL); -// } -// -// @Test -// public void callbacks_success_takeHighest_false_nullCallback() { -// WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); -// mWiseFy.mWiseFySearch = mockWiseFySearch; -// ScanResult accessPoint = mock(ScanResult.class); -// accessPoint.level = TEST_RSSI_LEVEL; -// when(mockWiseFySearch.findAccessPointByRegex(anyString(), anyInt(), anyBoolean())).thenReturn(accessPoint); -// -// try { -// mWiseFy.getRSSI(TEST_SSID, false, 1000, null); -// } catch (NullPointerException npe) { -// fail(); -// } -// } -// -// @Test -// public void callbacks_success_takeHighest_true() { -// WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); -// mWiseFy.mWiseFySearch = mockWiseFySearch; -// ScanResult accessPoint = mock(ScanResult.class); -// accessPoint.level = TEST_RSSI_LEVEL; -// when(mockWiseFySearch.findAccessPointByRegex(anyString(), anyInt(), anyBoolean())).thenReturn(accessPoint); -// -// -// GetRSSICallbacks mockCallbacks = mock(GetRSSICallbacks.class); -// mWiseFy.getRSSI(TEST_SSID, true, 1000, mockCallbacks); -// verify(mockCallbacks, timeout(2000)).retrievedRSSI(TEST_RSSI_LEVEL); -// } -// -// @Test -// public void callbacks_success_takeHighest_true_nullCallback() { -// WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); -// mWiseFy.mWiseFySearch = mockWiseFySearch; -// ScanResult accessPoint = mock(ScanResult.class); -// accessPoint.level = TEST_RSSI_LEVEL; -// when(mockWiseFySearch.findAccessPointByRegex(anyString(), anyInt(), anyBoolean())).thenReturn(accessPoint); -// -// try { -// mWiseFy.getRSSI(TEST_SSID, true, 1000, null); -// } catch (NullPointerException npe) { -// fail(); -// } -// } -//} \ No newline at end of file +package com.isupatches.wisefy; + + +import android.net.wifi.ScanResult; +import com.isupatches.wisefy.callbacks.GetRSSICallbacks; +import com.isupatches.wisefy.constants.WiseFyCodes; +import org.junit.Test; +import static com.isupatches.wisefy.base.TestUtils.TEST_RSSI_LEVEL; +import static com.isupatches.wisefy.base.TestUtils.TEST_SSID; +import static junit.framework.Assert.assertEquals; +import static junit.framework.Assert.fail; +import static org.mockito.ArgumentMatchers.anyBoolean; +import static org.mockito.ArgumentMatchers.anyInt; +import static org.mockito.ArgumentMatchers.anyString; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.timeout; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; + + +public class GetRSSITests extends BaseAndroidJUnit4TestClass { + + @Test + public void noCallbacks_failure_takeHighest_false_nullSSIDParam() { + assertEquals(null, mWiseFy.getRSSI(null, false, 1000)); + } + + @Test + public void noCallbacks_failure_takeHighest_true_nullSSIDParam() { + assertEquals(null, mWiseFy.getRSSI(null, true, 1000)); + } + + @Test + public void noCallbacks_failure_takeHighest_false_missingPrerequisite() { + missingPrerequisite(); + assertEquals(null, mWiseFy.getRSSI(TEST_SSID, false, 1000)); + } + + @Test + public void noCallbacks_failure_takeHighest_true_missingPrerequisite() { + missingPrerequisite(); + assertEquals(null, mWiseFy.getRSSI(TEST_SSID, true, 1000)); + } + + @Test + public void noCallbacks_failure_takeHighest_false_noNetworkFound() { + WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); + mWiseFy.mWiseFySearch = mockWiseFySearch; + when(mockWiseFySearch.findAccessPointByRegex(anyString(), anyInt(), anyBoolean())).thenReturn(null); + + assertEquals(null, mWiseFy.getRSSI(TEST_SSID, false, 1000)); + } + + @Test + public void noCallbacks_failure_takeHighest_true_noNetworkFound() { + WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); + mWiseFy.mWiseFySearch = mockWiseFySearch; + when(mockWiseFySearch.findAccessPointByRegex(anyString(), anyInt(), anyBoolean())).thenReturn(null); + + assertEquals(null, mWiseFy.getRSSI(TEST_SSID, true, 1000)); + } + + @Test + public void noCallbacks_success_takeHighest_false () { + ScanResult accessPoint = mock(ScanResult.class); + accessPoint.level = TEST_RSSI_LEVEL; + WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); + mWiseFy.mWiseFySearch = mockWiseFySearch; + when(mockWiseFySearch.findAccessPointByRegex(anyString(), anyInt(), anyBoolean())).thenReturn(accessPoint); + + assertEquals(TEST_RSSI_LEVEL, (int) mWiseFy.getRSSI(TEST_SSID, false, 1000)); + + } + + @Test + public void noCallbacks_success_takeHighest_true () { + ScanResult accessPoint = mock(ScanResult.class); + accessPoint.level = TEST_RSSI_LEVEL; + WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); + mWiseFy.mWiseFySearch = mockWiseFySearch; + when(mockWiseFySearch.findAccessPointByRegex(anyString(), anyInt(), anyBoolean())).thenReturn(accessPoint); + + assertEquals(TEST_RSSI_LEVEL, (int) mWiseFy.getRSSI(TEST_SSID, true, 1000)); + } + + @Test + public void callbacks_failure_takeHighest_false_nullSSIDParam() { + GetRSSICallbacks mockCallbacks = mock(GetRSSICallbacks.class); + mWiseFy.getRSSI(null, false, 1000, mockCallbacks); + verify(mockCallbacks, timeout(2000)).getRSSIWiseFyFailure(WiseFyCodes.MISSING_PARAMETER); + } + + @Test + public void callbacks_failure_takeHighest_false_nullSSIDParam_nullCallback() { + try { + mWiseFy.getRSSI(null, false, 1000, null); + } catch (NullPointerException npe) { + fail(); + } + } + + @Test + public void callbacks_failure_takeHighest_true_nullSSIDParam() { + GetRSSICallbacks mockCallbacks = mock(GetRSSICallbacks.class); + mWiseFy.getRSSI(null, true, 1000, mockCallbacks); + verify(mockCallbacks, timeout(2000)).getRSSIWiseFyFailure(WiseFyCodes.MISSING_PARAMETER); + } + + @Test + public void callbacks_failure_takeHighest_true_nullSSIDParam_nullCallback() { + try { + mWiseFy.getRSSI(null, true, 1000, null); + } catch (NullPointerException npe) { + fail(); + } + } + + @Test + public void callbacks_failure_takeHighest_false_missingPrerequisite() { + missingPrerequisite(); + GetRSSICallbacks mockCallbacks = mock(GetRSSICallbacks.class); + mWiseFy.getRSSI(TEST_SSID, false, 1000, mockCallbacks); + verify(mockCallbacks, timeout(2000)).getRSSIWiseFyFailure(WiseFyCodes.MISSING_PREREQUISITE); + } + + @Test + public void callbacks_failure_takeHighest_false_nullSSIDParam_missingPrerequisite() { + missingPrerequisite(); + try { + mWiseFy.getRSSI(TEST_SSID, false, 1000, null); + } catch (NullPointerException npe) { + fail(); + } + } + + @Test + public void callbacks_failure_takeHighest_true_missingPrerequisite() { + missingPrerequisite(); + GetRSSICallbacks mockCallbacks = mock(GetRSSICallbacks.class); + mWiseFy.getRSSI(TEST_SSID, true, 1000, mockCallbacks); + verify(mockCallbacks, timeout(2000)).getRSSIWiseFyFailure(WiseFyCodes.MISSING_PREREQUISITE); + } + + @Test + public void callbacks_failure_takeHighest_true_nullSSIDParam_missingPrerequisite() { + missingPrerequisite(); + try { + mWiseFy.getRSSI(TEST_SSID, true, 1000, null); + } catch (NullPointerException npe) { + fail(); + } + } + + @Test + public void callbacks_failure_takeHighest_false_noNetworkFound() { + WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); + mWiseFy.mWiseFySearch = mockWiseFySearch; + when(mockWiseFySearch.findAccessPointByRegex(anyString(), anyInt(), anyBoolean())).thenReturn(null); + + GetRSSICallbacks mockCallbacks = mock(GetRSSICallbacks.class); + mWiseFy.getRSSI(TEST_SSID, false, 1000, mockCallbacks); + verify(mockCallbacks, timeout(2000)).networkNotFoundToRetrieveRSSI(); + } + + @Test + public void callbacks_failure_takeHighest_false_noNetworkFound_nullCallback() { + WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); + mWiseFy.mWiseFySearch = mockWiseFySearch; + when(mockWiseFySearch.findAccessPointByRegex(anyString(), anyInt(), anyBoolean())).thenReturn(null); + + try { + mWiseFy.getRSSI(TEST_SSID, false, 1000, null); + } catch (NullPointerException npe) { + fail(); + } + } + + @Test + public void callbacks_failure_takeHighest_true_noNetworkFound() { + WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); + mWiseFy.mWiseFySearch = mockWiseFySearch; + when(mockWiseFySearch.findAccessPointByRegex(anyString(), anyInt(), anyBoolean())).thenReturn(null); + + GetRSSICallbacks mockCallbacks = mock(GetRSSICallbacks.class); + mWiseFy.getRSSI(TEST_SSID, true, 1000, mockCallbacks); + verify(mockCallbacks, timeout(2000)).networkNotFoundToRetrieveRSSI(); + } + + @Test + public void callbacks_failure_takeHighest_true_noNetworkFound_nullCallback() { + WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); + mWiseFy.mWiseFySearch = mockWiseFySearch; + when(mockWiseFySearch.findAccessPointByRegex(anyString(), anyInt(), anyBoolean())).thenReturn(null); + + try { + mWiseFy.getRSSI(TEST_SSID, true, 1000, null); + } catch (NullPointerException npe) { + fail(); + } + } + + @Test + public void callbacks_success_takeHighest_false() { + WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); + mWiseFy.mWiseFySearch = mockWiseFySearch; + ScanResult accessPoint = mock(ScanResult.class); + accessPoint.level = TEST_RSSI_LEVEL; + when(mockWiseFySearch.findAccessPointByRegex(anyString(), anyInt(), anyBoolean())).thenReturn(accessPoint); + + + GetRSSICallbacks mockCallbacks = mock(GetRSSICallbacks.class); + mWiseFy.getRSSI(TEST_SSID, false, 1000, mockCallbacks); + verify(mockCallbacks, timeout(2000)).retrievedRSSI(TEST_RSSI_LEVEL); + } + + @Test + public void callbacks_success_takeHighest_false_nullCallback() { + WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); + mWiseFy.mWiseFySearch = mockWiseFySearch; + ScanResult accessPoint = mock(ScanResult.class); + accessPoint.level = TEST_RSSI_LEVEL; + when(mockWiseFySearch.findAccessPointByRegex(anyString(), anyInt(), anyBoolean())).thenReturn(accessPoint); + + try { + mWiseFy.getRSSI(TEST_SSID, false, 1000, null); + } catch (NullPointerException npe) { + fail(); + } + } + + @Test + public void callbacks_success_takeHighest_true() { + WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); + mWiseFy.mWiseFySearch = mockWiseFySearch; + ScanResult accessPoint = mock(ScanResult.class); + accessPoint.level = TEST_RSSI_LEVEL; + when(mockWiseFySearch.findAccessPointByRegex(anyString(), anyInt(), anyBoolean())).thenReturn(accessPoint); + + + GetRSSICallbacks mockCallbacks = mock(GetRSSICallbacks.class); + mWiseFy.getRSSI(TEST_SSID, true, 1000, mockCallbacks); + verify(mockCallbacks, timeout(2000)).retrievedRSSI(TEST_RSSI_LEVEL); + } + + @Test + public void callbacks_success_takeHighest_true_nullCallback() { + WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); + mWiseFy.mWiseFySearch = mockWiseFySearch; + ScanResult accessPoint = mock(ScanResult.class); + accessPoint.level = TEST_RSSI_LEVEL; + when(mockWiseFySearch.findAccessPointByRegex(anyString(), anyInt(), anyBoolean())).thenReturn(accessPoint); + + try { + mWiseFy.getRSSI(TEST_SSID, true, 1000, null); + } catch (NullPointerException npe) { + fail(); + } + } +} \ No newline at end of file diff --git a/wisefy/src/androidTest/java/com/isupatches/wisefy/GetSavedNetworkTests.java b/wisefy/src/androidTest/java/com/isupatches/wisefy/GetSavedNetworkTests.java index 519018b5..f1bb847a 100644 --- a/wisefy/src/androidTest/java/com/isupatches/wisefy/GetSavedNetworkTests.java +++ b/wisefy/src/androidTest/java/com/isupatches/wisefy/GetSavedNetworkTests.java @@ -1,144 +1,139 @@ -//package com.isupatches.wisefy; -// -// -//import android.net.wifi.WifiConfiguration; -//import com.isupatches.wisefy.base.TestActivity; -//import com.isupatches.wisefy.callbacks.GetSavedNetworkCallbacks; -//import com.isupatches.wisefy.constants.WiseFyCodes; -//import org.junit.Test; -//import static com.isupatches.wisefy.base.TestUtils.TEST_SSID; -//import static junit.framework.Assert.assertEquals; -//import static junit.framework.Assert.fail; -//import static org.mockito.ArgumentMatchers.anyString; -//import static org.mockito.Mockito.mock; -//import static org.mockito.Mockito.timeout; -//import static org.mockito.Mockito.verify; -//import static org.mockito.Mockito.when; -// -// -//public class GetSavedNetworkTests extends BaseTestClass { -// -// public GetSavedNetworkTests() { -// super(TestActivity.class); -// } -// -// @Test -// public void noCallbacks_failure_nullSSIDParam() { -// assertEquals(null, mWiseFy.getSavedNetwork(null)); -// } -// -// @Test -// public void noCallbacks_failure_missingPrerequisite() { -// missingPrerequisite(); -// assertEquals(null, mWiseFy.getSavedNetwork(TEST_SSID)); -// } -// -// @Test -// public void noCallbacks_failure() { -// WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); -// mWiseFy.mWiseFySearch = mockWiseFySearch; -// when(mockWiseFySearch.findSavedNetworkByRegex(anyString())).thenReturn(null); -// -// assertEquals(null, mWiseFy.getSavedNetwork(TEST_SSID)); -// } -// -// @Test -// public void noCallbacks_success() { -// WifiConfiguration wiFiConfiguration = new WifiConfiguration(); -// wiFiConfiguration.SSID = TEST_SSID; -// -// WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); -// mWiseFy.mWiseFySearch = mockWiseFySearch; -// when(mockWiseFySearch.findSavedNetworkByRegex(anyString())).thenReturn(wiFiConfiguration); -// -// assertEquals(wiFiConfiguration, mWiseFy.getSavedNetwork(TEST_SSID)); -// } -// -// @Test -// public void callbacks_failure_nullSSIDParam() { -// GetSavedNetworkCallbacks mockCallbacks = mock(GetSavedNetworkCallbacks.class); -// mWiseFy.getSavedNetwork(null, mockCallbacks); -// verify(mockCallbacks, timeout(2000)).getSavedNetworkWiseFyFailure(WiseFyCodes.MISSING_PARAMETER); -// } -// -// @Test -// public void callbacks_failure_nullSSIDParam_nullCallback() { -// try { -// mWiseFy.getSavedNetwork(null, null); -// } catch (NullPointerException npe) { -// fail(); -// } -// } -// -// @Test -// public void callbacks_failure_missingPrerequisite() { -// missingPrerequisite(); -// GetSavedNetworkCallbacks mockCallbacks = mock(GetSavedNetworkCallbacks.class); -// mWiseFy.getSavedNetwork(TEST_SSID, mockCallbacks); -// verify(mockCallbacks, timeout(2000)).getSavedNetworkWiseFyFailure(WiseFyCodes.MISSING_PREREQUISITE); -// } -// -// @Test -// public void callbacks_failure_missingPrerequisite_nullCallback() { -// missingPrerequisite(); -// try { -// mWiseFy.getSavedNetwork(TEST_SSID, null); -// } catch (NullPointerException npe) { -// fail(); -// } -// } -// -// @Test -// public void callbacks_failure() { -// WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); -// mWiseFy.mWiseFySearch = mockWiseFySearch; -// when(mockWiseFySearch.findSavedNetworkByRegex(anyString())).thenReturn(null); -// -// GetSavedNetworkCallbacks mockCallbacks = mock(GetSavedNetworkCallbacks.class); -// mWiseFy.getSavedNetwork(TEST_SSID, mockCallbacks); -// verify(mockCallbacks, timeout(2000)).savedNetworkNotFound(); -// } -// -// @Test -// public void callbacks_failure_nullCallback() { -// WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); -// mWiseFy.mWiseFySearch = mockWiseFySearch; -// when(mockWiseFySearch.findSavedNetworkByRegex(anyString())).thenReturn(null); -// -// try { -// mWiseFy.getSavedNetwork(TEST_SSID, null); -// } catch (NullPointerException npe) { -// fail(); -// } -// } -// -// @Test -// public void callbacks_success() { -// WifiConfiguration wiFiConfiguration = new WifiConfiguration(); -// wiFiConfiguration.SSID = TEST_SSID; -// -// WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); -// mWiseFy.mWiseFySearch = mockWiseFySearch; -// when(mockWiseFySearch.findSavedNetworkByRegex(anyString())).thenReturn(wiFiConfiguration); -// -// GetSavedNetworkCallbacks mockCallbacks = mock(GetSavedNetworkCallbacks.class); -// mWiseFy.getSavedNetwork(TEST_SSID, mockCallbacks); -// verify(mockCallbacks, timeout(2000)).retrievedSavedNetwork(wiFiConfiguration); -// } -// -// @Test -// public void callbacks_success_nullCallback() { -// WifiConfiguration wiFiConfiguration = new WifiConfiguration(); -// wiFiConfiguration.SSID = TEST_SSID; -// -// WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); -// mWiseFy.mWiseFySearch = mockWiseFySearch; -// when(mockWiseFySearch.findSavedNetworkByRegex(anyString())).thenReturn(wiFiConfiguration); -// -// try { -// mWiseFy.getSavedNetwork(TEST_SSID, null); -// } catch (NullPointerException npe) { -// fail(); -// } -// } -//} +package com.isupatches.wisefy; + + +import android.net.wifi.WifiConfiguration; +import com.isupatches.wisefy.callbacks.GetSavedNetworkCallbacks; +import com.isupatches.wisefy.constants.WiseFyCodes; +import org.junit.Test; +import static com.isupatches.wisefy.base.TestUtils.TEST_SSID; +import static junit.framework.Assert.assertEquals; +import static junit.framework.Assert.fail; +import static org.mockito.ArgumentMatchers.anyString; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.timeout; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; + + +public class GetSavedNetworkTests extends BaseAndroidJUnit4TestClass { + + @Test + public void noCallbacks_failure_nullSSIDParam() { + assertEquals(null, mWiseFy.getSavedNetwork(null)); + } + + @Test + public void noCallbacks_failure_missingPrerequisite() { + missingPrerequisite(); + assertEquals(null, mWiseFy.getSavedNetwork(TEST_SSID)); + } + + @Test + public void noCallbacks_failure() { + WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); + mWiseFy.mWiseFySearch = mockWiseFySearch; + when(mockWiseFySearch.findSavedNetworkByRegex(anyString())).thenReturn(null); + + assertEquals(null, mWiseFy.getSavedNetwork(TEST_SSID)); + } + + @Test + public void noCallbacks_success() { + WifiConfiguration wiFiConfiguration = new WifiConfiguration(); + wiFiConfiguration.SSID = TEST_SSID; + + WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); + mWiseFy.mWiseFySearch = mockWiseFySearch; + when(mockWiseFySearch.findSavedNetworkByRegex(anyString())).thenReturn(wiFiConfiguration); + + assertEquals(wiFiConfiguration, mWiseFy.getSavedNetwork(TEST_SSID)); + } + + @Test + public void callbacks_failure_nullSSIDParam() { + GetSavedNetworkCallbacks mockCallbacks = mock(GetSavedNetworkCallbacks.class); + mWiseFy.getSavedNetwork(null, mockCallbacks); + verify(mockCallbacks, timeout(2000)).getSavedNetworkWiseFyFailure(WiseFyCodes.MISSING_PARAMETER); + } + + @Test + public void callbacks_failure_nullSSIDParam_nullCallback() { + try { + mWiseFy.getSavedNetwork(null, null); + } catch (NullPointerException npe) { + fail(); + } + } + + @Test + public void callbacks_failure_missingPrerequisite() { + missingPrerequisite(); + GetSavedNetworkCallbacks mockCallbacks = mock(GetSavedNetworkCallbacks.class); + mWiseFy.getSavedNetwork(TEST_SSID, mockCallbacks); + verify(mockCallbacks, timeout(2000)).getSavedNetworkWiseFyFailure(WiseFyCodes.MISSING_PREREQUISITE); + } + + @Test + public void callbacks_failure_missingPrerequisite_nullCallback() { + missingPrerequisite(); + try { + mWiseFy.getSavedNetwork(TEST_SSID, null); + } catch (NullPointerException npe) { + fail(); + } + } + + @Test + public void callbacks_failure() { + WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); + mWiseFy.mWiseFySearch = mockWiseFySearch; + when(mockWiseFySearch.findSavedNetworkByRegex(anyString())).thenReturn(null); + + GetSavedNetworkCallbacks mockCallbacks = mock(GetSavedNetworkCallbacks.class); + mWiseFy.getSavedNetwork(TEST_SSID, mockCallbacks); + verify(mockCallbacks, timeout(2000)).savedNetworkNotFound(); + } + + @Test + public void callbacks_failure_nullCallback() { + WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); + mWiseFy.mWiseFySearch = mockWiseFySearch; + when(mockWiseFySearch.findSavedNetworkByRegex(anyString())).thenReturn(null); + + try { + mWiseFy.getSavedNetwork(TEST_SSID, null); + } catch (NullPointerException npe) { + fail(); + } + } + + @Test + public void callbacks_success() { + WifiConfiguration wiFiConfiguration = new WifiConfiguration(); + wiFiConfiguration.SSID = TEST_SSID; + + WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); + mWiseFy.mWiseFySearch = mockWiseFySearch; + when(mockWiseFySearch.findSavedNetworkByRegex(anyString())).thenReturn(wiFiConfiguration); + + GetSavedNetworkCallbacks mockCallbacks = mock(GetSavedNetworkCallbacks.class); + mWiseFy.getSavedNetwork(TEST_SSID, mockCallbacks); + verify(mockCallbacks, timeout(2000)).retrievedSavedNetwork(wiFiConfiguration); + } + + @Test + public void callbacks_success_nullCallback() { + WifiConfiguration wiFiConfiguration = new WifiConfiguration(); + wiFiConfiguration.SSID = TEST_SSID; + + WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); + mWiseFy.mWiseFySearch = mockWiseFySearch; + when(mockWiseFySearch.findSavedNetworkByRegex(anyString())).thenReturn(wiFiConfiguration); + + try { + mWiseFy.getSavedNetwork(TEST_SSID, null); + } catch (NullPointerException npe) { + fail(); + } + } +} diff --git a/wisefy/src/androidTest/java/com/isupatches/wisefy/GetSavedNetworksTests.java b/wisefy/src/androidTest/java/com/isupatches/wisefy/GetSavedNetworksTests.java index 550e8749..f96626d2 100644 --- a/wisefy/src/androidTest/java/com/isupatches/wisefy/GetSavedNetworksTests.java +++ b/wisefy/src/androidTest/java/com/isupatches/wisefy/GetSavedNetworksTests.java @@ -1,243 +1,238 @@ -//package com.isupatches.wisefy; -// -// -//import android.net.wifi.WifiConfiguration; -//import com.isupatches.wisefy.base.TestActivity; -//import com.isupatches.wisefy.callbacks.GetSavedNetworksCallbacks; -//import com.isupatches.wisefy.constants.WiseFyCodes; -//import org.junit.Test; -//import java.util.ArrayList; -//import java.util.List; -//import static com.isupatches.wisefy.base.TestUtils.TEST_SSID; -//import static junit.framework.Assert.assertEquals; -//import static junit.framework.Assert.fail; -//import static org.mockito.Mockito.mock; -//import static org.mockito.Mockito.never; -//import static org.mockito.Mockito.timeout; -//import static org.mockito.Mockito.verify; -//import static org.mockito.Mockito.when; -// -// -//public class GetSavedNetworksTests extends BaseTestClass { -// -// public GetSavedNetworksTests() { -// super(TestActivity.class); -// } -// -// @Test -// public void noCallbacks_failure_missingPrerequisite() { -// missingPrerequisite(); -// assertEquals(null, mWiseFy.getSavedNetworks()); -// verify(mMockWiFiManager, never()).getConfiguredNetworks(); -// } -// -// @Test -// public void noCallbacks_success() { -// List wifiList = new ArrayList<>(); -// WifiConfiguration mWiFiConfiguration = new WifiConfiguration(); -// mWiFiConfiguration.SSID = TEST_SSID; -// wifiList.add(mWiFiConfiguration); -// when(mMockWiFiManager.getConfiguredNetworks()).thenReturn(wifiList); -// -// assertEquals(wifiList, mWiseFy.getSavedNetworks()); -// verify(mMockWiFiManager, timeout(VERIFICATION_TIMEOUT)).getConfiguredNetworks(); -// } -// -// @Test -// public void callbacks_failure_missingPrerequisite() { -// missingPrerequisite(); -// GetSavedNetworksCallbacks mockCallbacks = mock(GetSavedNetworksCallbacks.class); -// mWiseFy.getSavedNetworks(mockCallbacks); -// verify(mockCallbacks, timeout(VERIFICATION_TIMEOUT)).getSavedNetworksWiseFyFailure(WiseFyCodes.MISSING_PREREQUISITE); -// verify(mMockWiFiManager, never()).getConfiguredNetworks(); -// } -// -// @Test -// public void callbacks_failure_missingPrerequisite_nullCallback() { -// missingPrerequisite(); -// try { -// mWiseFy.getSavedNetworks((GetSavedNetworksCallbacks) null); -// verify(mMockWiFiManager, never()).getConfiguredNetworks(); -// } catch (NullPointerException npe) { -// fail(); -// } -// } -// -// @Test -// public void callbacks_failure_nullSavedNetworks() { -// when(mMockWiFiManager.getConfiguredNetworks()).thenReturn(null); -// GetSavedNetworksCallbacks mockCallbacks = mock(GetSavedNetworksCallbacks.class); -// mWiseFy.getSavedNetworks(mockCallbacks); -// verify(mockCallbacks, timeout(VERIFICATION_TIMEOUT)).noSavedNetworksFound(); -// } -// -// @Test -// public void callbacks_failure_nullSavedNetworks_nullCallback() { -// when(mMockWiFiManager.getConfiguredNetworks()).thenReturn(null); -// try { -// mWiseFy.getSavedNetworks((GetSavedNetworksCallbacks) null); -// verify(mMockWiFiManager, never()).getConfiguredNetworks(); -// } catch (NullPointerException npe) { -// fail(); -// } -// } -// -// @Test -// public void callbacks_failure_emptyConfiguredNetworks() { -// when(mMockWiFiManager.getConfiguredNetworks()).thenReturn(new ArrayList()); -// GetSavedNetworksCallbacks mockCallbacks = mock(GetSavedNetworksCallbacks.class); -// mWiseFy.getSavedNetworks(mockCallbacks); -// verify(mockCallbacks, timeout(VERIFICATION_TIMEOUT)).noSavedNetworksFound(); -// } -// -// @Test -// public void callbacks_failure_emptyConfiguredNetworks_nullCallback() { -// when(mMockWiFiManager.getConfiguredNetworks()).thenReturn(new ArrayList()); -// try { -// mWiseFy.getSavedNetworks((GetSavedNetworksCallbacks) null); -// verify(mMockWiFiManager, never()).getConfiguredNetworks(); -// } catch (NullPointerException npe) { -// fail(); -// } -// } -// -// @Test -// public void callbacks_success() { -// List wifiList = new ArrayList<>(); -// WifiConfiguration mWiFiConfiguration = new WifiConfiguration(); -// mWiFiConfiguration.SSID = TEST_SSID; -// wifiList.add(mWiFiConfiguration); -// when(mMockWiFiManager.getConfiguredNetworks()).thenReturn(wifiList); -// -// GetSavedNetworksCallbacks mockCallbacks = mock(GetSavedNetworksCallbacks.class); -// mWiseFy.getSavedNetworks(mockCallbacks); -// verify(mockCallbacks, timeout(VERIFICATION_TIMEOUT)).retrievedSavedNetworks(wifiList); -// verify(mMockWiFiManager, timeout(VERIFICATION_TIMEOUT)).getConfiguredNetworks(); -// } -// -// @Test -// public void callbacks_success_nullCallback() { -// List wifiList = new ArrayList<>(); -// WifiConfiguration mWiFiConfiguration = new WifiConfiguration(); -// mWiFiConfiguration.SSID = TEST_SSID; -// wifiList.add(mWiFiConfiguration); -// when(mMockWiFiManager.getConfiguredNetworks()).thenReturn(wifiList); -// -// try { -// mWiseFy.getSavedNetworks((GetSavedNetworksCallbacks) null); -// verify(mMockWiFiManager, never()).getConfiguredNetworks(); -// } catch (NullPointerException npe) { -// fail(); -// } -// } -// -// @Test -// public void callbacks_failure_withRegex_missingPrerequisite() { -// missingPrerequisite(); -// -// GetSavedNetworksCallbacks mockCallbacks = mock(GetSavedNetworksCallbacks.class); -// mWiseFy.getSavedNetworks(TEST_SSID, mockCallbacks); -// verify(mockCallbacks, timeout(VERIFICATION_TIMEOUT)).getSavedNetworksWiseFyFailure(WiseFyCodes.MISSING_PREREQUISITE); -// verify(mMockWiFiManager, never()).getConfiguredNetworks(); -// } -// -// @Test -// public void noCallbacks_failure_withRegex_missingPrerequisite() { -// missingPrerequisite(); -// assertEquals(null, mWiseFy.getSavedNetworks(TEST_SSID)); -// verify(mMockWiFiManager, never()).getConfiguredNetworks(); -// } -// -// @Test -// public void noCallbacks_success_withRegex() { -// List wifiList = new ArrayList<>(); -// WifiConfiguration mWiFiConfiguration = new WifiConfiguration(); -// mWiFiConfiguration.SSID = TEST_SSID; -// wifiList.add(mWiFiConfiguration); -// when(mMockWiFiManager.getConfiguredNetworks()).thenReturn(wifiList); -// -// assertEquals(wifiList, mWiseFy.getSavedNetworks(TEST_SSID)); -// verify(mMockWiFiManager, timeout(VERIFICATION_TIMEOUT)).getConfiguredNetworks(); -// } -// -// @Test -// public void callbacks_failure_withRegex_missingPrerequisite_nullCallback() { -// missingPrerequisite(); -// -// try{ -// mWiseFy.getSavedNetworks(TEST_SSID, null); -// verify(mMockWiFiManager, never()).getConfiguredNetworks(); -// } catch (NullPointerException npe) { -// fail(); -// } -// } -// -// @Test -// public void callbacks_failure_withRegex_nullSavedNetworks() { -// when(mMockWiFiManager.getConfiguredNetworks()).thenReturn(null); -// GetSavedNetworksCallbacks mockCallbacks = mock(GetSavedNetworksCallbacks.class); -// mWiseFy.getSavedNetworks(TEST_SSID, mockCallbacks); -// verify(mockCallbacks, timeout(VERIFICATION_TIMEOUT)).noSavedNetworksFound(); -// } -// -// @Test -// public void callbacks_failure_withRegex_nullSavedNetworks_nullCallback() { -// when(mMockWiFiManager.getConfiguredNetworks()).thenReturn(null); -// try { -// mWiseFy.getSavedNetworks(TEST_SSID, null); -// verify(mMockWiFiManager, never()).getConfiguredNetworks(); -// } catch (NullPointerException npe) { -// fail(); -// } -// } -// -// @Test -// public void callbacks_failure_withRegex_emptyConfiguredNetworks() { -// when(mMockWiFiManager.getConfiguredNetworks()).thenReturn(new ArrayList()); -// GetSavedNetworksCallbacks mockCallbacks = mock(GetSavedNetworksCallbacks.class); -// mWiseFy.getSavedNetworks(TEST_SSID, mockCallbacks); -// verify(mockCallbacks, timeout(VERIFICATION_TIMEOUT)).noSavedNetworksFound(); -// verify(mMockWiFiManager, timeout(VERIFICATION_TIMEOUT)).getConfiguredNetworks(); -// } -// -// @Test -// public void callbacks_failure_withRegex_emptyConfiguredNetworks_nullCallback() { -// when(mMockWiFiManager.getConfiguredNetworks()).thenReturn(new ArrayList()); -// try { -// mWiseFy.getSavedNetworks(TEST_SSID, null); -// verify(mMockWiFiManager, never()).getConfiguredNetworks(); -// } catch (NullPointerException npe) { -// fail(); -// } -// } -// -// @Test -// public void callbacks_success_withRegex() { -// List wifiList = new ArrayList<>(); -// WifiConfiguration mWiFiConfiguration = new WifiConfiguration(); -// mWiFiConfiguration.SSID = TEST_SSID; -// wifiList.add(mWiFiConfiguration); -// when(mMockWiFiManager.getConfiguredNetworks()).thenReturn(wifiList); -// -// GetSavedNetworksCallbacks mockCallbacks = mock(GetSavedNetworksCallbacks.class); -// mWiseFy.getSavedNetworks(TEST_SSID, mockCallbacks); -// verify(mockCallbacks, timeout(VERIFICATION_TIMEOUT)).retrievedSavedNetworks(wifiList); -// verify(mMockWiFiManager, timeout(VERIFICATION_TIMEOUT)).getConfiguredNetworks(); -// } -// -// @Test -// public void callbacks_success_withRegex_nullCallbacks() { -// List wifiList = new ArrayList<>(); -// WifiConfiguration mWiFiConfiguration = new WifiConfiguration(); -// mWiFiConfiguration.SSID = TEST_SSID; -// wifiList.add(mWiFiConfiguration); -// when(mMockWiFiManager.getConfiguredNetworks()).thenReturn(wifiList); -// -// try { -// mWiseFy.getSavedNetworks(TEST_SSID, null); -// verify(mMockWiFiManager, never()).getConfiguredNetworks(); -// } catch (NullPointerException npe) { -// fail(); -// } -// } -//} +package com.isupatches.wisefy; + + +import android.net.wifi.WifiConfiguration; +import com.isupatches.wisefy.callbacks.GetSavedNetworksCallbacks; +import com.isupatches.wisefy.constants.WiseFyCodes; +import org.junit.Test; +import java.util.ArrayList; +import java.util.List; +import static com.isupatches.wisefy.base.TestUtils.TEST_SSID; +import static junit.framework.Assert.assertEquals; +import static junit.framework.Assert.fail; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.never; +import static org.mockito.Mockito.timeout; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; + + +public class GetSavedNetworksTests extends BaseAndroidJUnit4TestClass { + + @Test + public void noCallbacks_failure_missingPrerequisite() { + missingPrerequisite(); + assertEquals(null, mWiseFy.getSavedNetworks()); + verify(mMockWiFiManager, never()).getConfiguredNetworks(); + } + + @Test + public void noCallbacks_success() { + List wifiList = new ArrayList<>(); + WifiConfiguration mWiFiConfiguration = new WifiConfiguration(); + mWiFiConfiguration.SSID = TEST_SSID; + wifiList.add(mWiFiConfiguration); + when(mMockWiFiManager.getConfiguredNetworks()).thenReturn(wifiList); + + assertEquals(wifiList, mWiseFy.getSavedNetworks()); + verify(mMockWiFiManager, timeout(VERIFICATION_TIMEOUT)).getConfiguredNetworks(); + } + + @Test + public void callbacks_failure_missingPrerequisite() { + missingPrerequisite(); + GetSavedNetworksCallbacks mockCallbacks = mock(GetSavedNetworksCallbacks.class); + mWiseFy.getSavedNetworks(mockCallbacks); + verify(mockCallbacks, timeout(VERIFICATION_TIMEOUT)).getSavedNetworksWiseFyFailure(WiseFyCodes.MISSING_PREREQUISITE); + verify(mMockWiFiManager, never()).getConfiguredNetworks(); + } + + @Test + public void callbacks_failure_missingPrerequisite_nullCallback() { + missingPrerequisite(); + try { + mWiseFy.getSavedNetworks((GetSavedNetworksCallbacks) null); + verify(mMockWiFiManager, never()).getConfiguredNetworks(); + } catch (NullPointerException npe) { + fail(); + } + } + + @Test + public void callbacks_failure_nullSavedNetworks() { + when(mMockWiFiManager.getConfiguredNetworks()).thenReturn(null); + GetSavedNetworksCallbacks mockCallbacks = mock(GetSavedNetworksCallbacks.class); + mWiseFy.getSavedNetworks(mockCallbacks); + verify(mockCallbacks, timeout(VERIFICATION_TIMEOUT)).noSavedNetworksFound(); + } + + @Test + public void callbacks_failure_nullSavedNetworks_nullCallback() { + when(mMockWiFiManager.getConfiguredNetworks()).thenReturn(null); + try { + mWiseFy.getSavedNetworks((GetSavedNetworksCallbacks) null); + verify(mMockWiFiManager, never()).getConfiguredNetworks(); + } catch (NullPointerException npe) { + fail(); + } + } + + @Test + public void callbacks_failure_emptyConfiguredNetworks() { + when(mMockWiFiManager.getConfiguredNetworks()).thenReturn(new ArrayList()); + GetSavedNetworksCallbacks mockCallbacks = mock(GetSavedNetworksCallbacks.class); + mWiseFy.getSavedNetworks(mockCallbacks); + verify(mockCallbacks, timeout(VERIFICATION_TIMEOUT)).noSavedNetworksFound(); + } + + @Test + public void callbacks_failure_emptyConfiguredNetworks_nullCallback() { + when(mMockWiFiManager.getConfiguredNetworks()).thenReturn(new ArrayList()); + try { + mWiseFy.getSavedNetworks((GetSavedNetworksCallbacks) null); + verify(mMockWiFiManager, never()).getConfiguredNetworks(); + } catch (NullPointerException npe) { + fail(); + } + } + + @Test + public void callbacks_success() { + List wifiList = new ArrayList<>(); + WifiConfiguration mWiFiConfiguration = new WifiConfiguration(); + mWiFiConfiguration.SSID = TEST_SSID; + wifiList.add(mWiFiConfiguration); + when(mMockWiFiManager.getConfiguredNetworks()).thenReturn(wifiList); + + GetSavedNetworksCallbacks mockCallbacks = mock(GetSavedNetworksCallbacks.class); + mWiseFy.getSavedNetworks(mockCallbacks); + verify(mockCallbacks, timeout(VERIFICATION_TIMEOUT)).retrievedSavedNetworks(wifiList); + verify(mMockWiFiManager, timeout(VERIFICATION_TIMEOUT)).getConfiguredNetworks(); + } + + @Test + public void callbacks_success_nullCallback() { + List wifiList = new ArrayList<>(); + WifiConfiguration mWiFiConfiguration = new WifiConfiguration(); + mWiFiConfiguration.SSID = TEST_SSID; + wifiList.add(mWiFiConfiguration); + when(mMockWiFiManager.getConfiguredNetworks()).thenReturn(wifiList); + + try { + mWiseFy.getSavedNetworks((GetSavedNetworksCallbacks) null); + verify(mMockWiFiManager, never()).getConfiguredNetworks(); + } catch (NullPointerException npe) { + fail(); + } + } + + @Test + public void callbacks_failure_withRegex_missingPrerequisite() { + missingPrerequisite(); + + GetSavedNetworksCallbacks mockCallbacks = mock(GetSavedNetworksCallbacks.class); + mWiseFy.getSavedNetworks(TEST_SSID, mockCallbacks); + verify(mockCallbacks, timeout(VERIFICATION_TIMEOUT)).getSavedNetworksWiseFyFailure(WiseFyCodes.MISSING_PREREQUISITE); + verify(mMockWiFiManager, never()).getConfiguredNetworks(); + } + + @Test + public void noCallbacks_failure_withRegex_missingPrerequisite() { + missingPrerequisite(); + assertEquals(null, mWiseFy.getSavedNetworks(TEST_SSID)); + verify(mMockWiFiManager, never()).getConfiguredNetworks(); + } + + @Test + public void noCallbacks_success_withRegex() { + List wifiList = new ArrayList<>(); + WifiConfiguration mWiFiConfiguration = new WifiConfiguration(); + mWiFiConfiguration.SSID = TEST_SSID; + wifiList.add(mWiFiConfiguration); + when(mMockWiFiManager.getConfiguredNetworks()).thenReturn(wifiList); + + assertEquals(wifiList, mWiseFy.getSavedNetworks(TEST_SSID)); + verify(mMockWiFiManager, timeout(VERIFICATION_TIMEOUT)).getConfiguredNetworks(); + } + + @Test + public void callbacks_failure_withRegex_missingPrerequisite_nullCallback() { + missingPrerequisite(); + + try{ + mWiseFy.getSavedNetworks(TEST_SSID, null); + verify(mMockWiFiManager, never()).getConfiguredNetworks(); + } catch (NullPointerException npe) { + fail(); + } + } + + @Test + public void callbacks_failure_withRegex_nullSavedNetworks() { + when(mMockWiFiManager.getConfiguredNetworks()).thenReturn(null); + GetSavedNetworksCallbacks mockCallbacks = mock(GetSavedNetworksCallbacks.class); + mWiseFy.getSavedNetworks(TEST_SSID, mockCallbacks); + verify(mockCallbacks, timeout(VERIFICATION_TIMEOUT)).noSavedNetworksFound(); + } + + @Test + public void callbacks_failure_withRegex_nullSavedNetworks_nullCallback() { + when(mMockWiFiManager.getConfiguredNetworks()).thenReturn(null); + try { + mWiseFy.getSavedNetworks(TEST_SSID, null); + verify(mMockWiFiManager, never()).getConfiguredNetworks(); + } catch (NullPointerException npe) { + fail(); + } + } + + @Test + public void callbacks_failure_withRegex_emptyConfiguredNetworks() { + when(mMockWiFiManager.getConfiguredNetworks()).thenReturn(new ArrayList()); + GetSavedNetworksCallbacks mockCallbacks = mock(GetSavedNetworksCallbacks.class); + mWiseFy.getSavedNetworks(TEST_SSID, mockCallbacks); + verify(mockCallbacks, timeout(VERIFICATION_TIMEOUT)).noSavedNetworksFound(); + verify(mMockWiFiManager, timeout(VERIFICATION_TIMEOUT)).getConfiguredNetworks(); + } + + @Test + public void callbacks_failure_withRegex_emptyConfiguredNetworks_nullCallback() { + when(mMockWiFiManager.getConfiguredNetworks()).thenReturn(new ArrayList()); + try { + mWiseFy.getSavedNetworks(TEST_SSID, null); + verify(mMockWiFiManager, never()).getConfiguredNetworks(); + } catch (NullPointerException npe) { + fail(); + } + } + + @Test + public void callbacks_success_withRegex() { + List wifiList = new ArrayList<>(); + WifiConfiguration mWiFiConfiguration = new WifiConfiguration(); + mWiFiConfiguration.SSID = TEST_SSID; + wifiList.add(mWiFiConfiguration); + when(mMockWiFiManager.getConfiguredNetworks()).thenReturn(wifiList); + + GetSavedNetworksCallbacks mockCallbacks = mock(GetSavedNetworksCallbacks.class); + mWiseFy.getSavedNetworks(TEST_SSID, mockCallbacks); + verify(mockCallbacks, timeout(VERIFICATION_TIMEOUT)).retrievedSavedNetworks(wifiList); + verify(mMockWiFiManager, timeout(VERIFICATION_TIMEOUT)).getConfiguredNetworks(); + } + + @Test + public void callbacks_success_withRegex_nullCallbacks() { + List wifiList = new ArrayList<>(); + WifiConfiguration mWiFiConfiguration = new WifiConfiguration(); + mWiFiConfiguration.SSID = TEST_SSID; + wifiList.add(mWiFiConfiguration); + when(mMockWiFiManager.getConfiguredNetworks()).thenReturn(wifiList); + + try { + mWiseFy.getSavedNetworks(TEST_SSID, null); + verify(mMockWiFiManager, never()).getConfiguredNetworks(); + } catch (NullPointerException npe) { + fail(); + } + } +} diff --git a/wisefy/src/androidTest/java/com/isupatches/wisefy/IsDeviceConnectedToMobileNetworkTests.java b/wisefy/src/androidTest/java/com/isupatches/wisefy/IsDeviceConnectedToMobileNetworkTests.java index 5a9a49cd..9353adc7 100644 --- a/wisefy/src/androidTest/java/com/isupatches/wisefy/IsDeviceConnectedToMobileNetworkTests.java +++ b/wisefy/src/androidTest/java/com/isupatches/wisefy/IsDeviceConnectedToMobileNetworkTests.java @@ -1,46 +1,41 @@ -//package com.isupatches.wisefy; -// -// -//import android.net.NetworkInfo; -//import com.isupatches.wisefy.base.TestActivity; -//import org.junit.Test; -//import static junit.framework.Assert.assertFalse; -//import static junit.framework.Assert.assertTrue; -//import static org.mockito.ArgumentMatchers.any; -//import static org.mockito.ArgumentMatchers.anyString; -//import static org.mockito.Mockito.mock; -//import static org.mockito.Mockito.when; -// -// -//public class IsDeviceConnectedToMobileNetworkTests extends BaseTestClass { -// -// public IsDeviceConnectedToMobileNetworkTests() { -// super(TestActivity.class); -// } -// -// @Test -// public void failure_missingPrerequisite() { -// missingPrerequisite(); -// assertFalse(mWiseFy.isDeviceConnectedToMobileNetwork()); -// } -// -// @Test -// public void failure() { -// when(mMockConnectivityManager.getActiveNetworkInfo()).thenReturn(mock(NetworkInfo.class)); -// -// WiseFyConnection mockWiseFyConnection = mock(WiseFyConnection.class); -// mWiseFy.mWiseFyConnection = mockWiseFyConnection; -// when(mockWiseFyConnection.isNetworkConnectedAndMatchesType(any(NetworkInfo.class), anyString())).thenReturn(false); -// assertFalse(mWiseFy.isDeviceConnectedToMobileNetwork()); -// } -// -// @Test -// public void success() { -// when(mMockConnectivityManager.getActiveNetworkInfo()).thenReturn(mock(NetworkInfo.class)); -// -// WiseFyConnection mockWiseFyConnection = mock(WiseFyConnection.class); -// mWiseFy.mWiseFyConnection = mockWiseFyConnection; -// when(mockWiseFyConnection.isNetworkConnectedAndMatchesType(any(NetworkInfo.class), anyString())).thenReturn(true); -// assertTrue(mWiseFy.isDeviceConnectedToMobileNetwork()); -// } -//} +package com.isupatches.wisefy; + + +import android.net.NetworkInfo; +import org.junit.Test; +import static junit.framework.Assert.assertFalse; +import static junit.framework.Assert.assertTrue; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.anyString; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; + + +public class IsDeviceConnectedToMobileNetworkTests extends BaseAndroidJUnit4TestClass { + + @Test + public void failure_missingPrerequisite() { + missingPrerequisite(); + assertFalse(mWiseFy.isDeviceConnectedToMobileNetwork()); + } + + @Test + public void failure() { + when(mMockConnectivityManager.getActiveNetworkInfo()).thenReturn(mock(NetworkInfo.class)); + + WiseFyConnection mockWiseFyConnection = mock(WiseFyConnection.class); + mWiseFy.mWiseFyConnection = mockWiseFyConnection; + when(mockWiseFyConnection.isNetworkConnectedAndMatchesType(any(NetworkInfo.class), anyString())).thenReturn(false); + assertFalse(mWiseFy.isDeviceConnectedToMobileNetwork()); + } + + @Test + public void success() { + when(mMockConnectivityManager.getActiveNetworkInfo()).thenReturn(mock(NetworkInfo.class)); + + WiseFyConnection mockWiseFyConnection = mock(WiseFyConnection.class); + mWiseFy.mWiseFyConnection = mockWiseFyConnection; + when(mockWiseFyConnection.isNetworkConnectedAndMatchesType(any(NetworkInfo.class), anyString())).thenReturn(true); + assertTrue(mWiseFy.isDeviceConnectedToMobileNetwork()); + } +} diff --git a/wisefy/src/androidTest/java/com/isupatches/wisefy/IsDeviceConnectedToMobileOrWifiNetworkTests.java b/wisefy/src/androidTest/java/com/isupatches/wisefy/IsDeviceConnectedToMobileOrWifiNetworkTests.java index 7fe984c9..840bb8d4 100644 --- a/wisefy/src/androidTest/java/com/isupatches/wisefy/IsDeviceConnectedToMobileOrWifiNetworkTests.java +++ b/wisefy/src/androidTest/java/com/isupatches/wisefy/IsDeviceConnectedToMobileOrWifiNetworkTests.java @@ -1,45 +1,41 @@ -//package com.isupatches.wisefy; -// -// -//import android.net.NetworkInfo; -//import com.isupatches.wisefy.base.TestActivity; -//import org.junit.Test; -//import static junit.framework.Assert.assertFalse; -//import static junit.framework.Assert.assertTrue; -//import static org.mockito.ArgumentMatchers.any; -//import static org.mockito.Mockito.mock; -//import static org.mockito.Mockito.when; -// -// -//public class IsDeviceConnectedToMobileOrWifiNetworkTests extends BaseTestClass { -// -// public IsDeviceConnectedToMobileOrWifiNetworkTests() { -// super(TestActivity.class); -// } -// -// @Test -// public void failure_missingPrerequisite() { -// missingPrerequisite(); -// assertFalse(mWiseFy.isDeviceConnectedToMobileOrWifiNetwork()); -// } -// -// @Test -// public void failure() { -// when(mMockConnectivityManager.getActiveNetworkInfo()).thenReturn(mock(NetworkInfo.class)); -// -// WiseFyConnection mockWiseFyConnection = mock(WiseFyConnection.class); -// mWiseFy.mWiseFyConnection = mockWiseFyConnection; -// when(mockWiseFyConnection.isNetworkConnected(any(NetworkInfo.class))).thenReturn(false); -// assertFalse(mWiseFy.isDeviceConnectedToMobileOrWifiNetwork()); -// } -// -// @Test -// public void success() { -// when(mMockConnectivityManager.getActiveNetworkInfo()).thenReturn(mock(NetworkInfo.class)); -// -// WiseFyConnection mockWiseFyConnection = mock(WiseFyConnection.class); -// mWiseFy.mWiseFyConnection = mockWiseFyConnection; -// when(mockWiseFyConnection.isNetworkConnected(any(NetworkInfo.class))).thenReturn(true); -// assertTrue(mWiseFy.isDeviceConnectedToMobileOrWifiNetwork()); -// } -//} +package com.isupatches.wisefy; + + +import android.net.NetworkInfo; +import com.isupatches.wisefy.base.TestActivity; +import org.junit.Test; +import static junit.framework.Assert.assertFalse; +import static junit.framework.Assert.assertTrue; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; + + +public class IsDeviceConnectedToMobileOrWifiNetworkTests extends BaseAndroidJUnit4TestClass { + + @Test + public void failure_missingPrerequisite() { + missingPrerequisite(); + assertFalse(mWiseFy.isDeviceConnectedToMobileOrWifiNetwork()); + } + + @Test + public void failure() { + when(mMockConnectivityManager.getActiveNetworkInfo()).thenReturn(mock(NetworkInfo.class)); + + WiseFyConnection mockWiseFyConnection = mock(WiseFyConnection.class); + mWiseFy.mWiseFyConnection = mockWiseFyConnection; + when(mockWiseFyConnection.isNetworkConnected(any(NetworkInfo.class))).thenReturn(false); + assertFalse(mWiseFy.isDeviceConnectedToMobileOrWifiNetwork()); + } + + @Test + public void success() { + when(mMockConnectivityManager.getActiveNetworkInfo()).thenReturn(mock(NetworkInfo.class)); + + WiseFyConnection mockWiseFyConnection = mock(WiseFyConnection.class); + mWiseFy.mWiseFyConnection = mockWiseFyConnection; + when(mockWiseFyConnection.isNetworkConnected(any(NetworkInfo.class))).thenReturn(true); + assertTrue(mWiseFy.isDeviceConnectedToMobileOrWifiNetwork()); + } +} diff --git a/wisefy/src/androidTest/java/com/isupatches/wisefy/IsDeviceConnectedToSSIDTests.java b/wisefy/src/androidTest/java/com/isupatches/wisefy/IsDeviceConnectedToSSIDTests.java index faadaec3..adceb5d9 100644 --- a/wisefy/src/androidTest/java/com/isupatches/wisefy/IsDeviceConnectedToSSIDTests.java +++ b/wisefy/src/androidTest/java/com/isupatches/wisefy/IsDeviceConnectedToSSIDTests.java @@ -1,48 +1,43 @@ -//package com.isupatches.wisefy; -// -// -//import com.isupatches.wisefy.base.TestActivity; -//import org.junit.Test; -//import static com.isupatches.wisefy.base.TestUtils.TEST_SSID; -//import static junit.framework.Assert.assertFalse; -//import static junit.framework.Assert.assertTrue; -//import static org.mockito.ArgumentMatchers.anyString; -//import static org.mockito.Mockito.mock; -//import static org.mockito.Mockito.when; -// -// -//public class IsDeviceConnectedToSSIDTests extends BaseTestClass { -// -// public IsDeviceConnectedToSSIDTests() { -// super(TestActivity.class); -// } -// -// @Test -// public void noCallbacks_failure_nullSSIDParams() { -// assertFalse(mWiseFy.isDeviceConnectedToSSID(null)); -// } -// -// @Test -// public void noCallbacks_failure_missingPrerequisite() { -// missingPrerequisite(); -// assertFalse(mWiseFy.isDeviceConnectedToSSID(TEST_SSID)); -// } -// -// @Test -// public void noCallbacks_failure() { -// WiseFyConnection mockWiseFyConnection = mock(WiseFyConnection.class); -// mWiseFy.mWiseFyConnection = mockWiseFyConnection; -// when(mockWiseFyConnection.isCurrentNetworkConnectedToSSID(anyString())).thenReturn(false); -// -// assertFalse(mWiseFy.isDeviceConnectedToSSID(TEST_SSID)); -// } -// -// @Test -// public void noCallbacks_success() { -// WiseFyConnection mockWiseFyConnection = mock(WiseFyConnection.class); -// mWiseFy.mWiseFyConnection = mockWiseFyConnection; -// when(mockWiseFyConnection.isCurrentNetworkConnectedToSSID(anyString())).thenReturn(true); -// -// assertTrue(mWiseFy.isDeviceConnectedToSSID(TEST_SSID)); -// } -//} +package com.isupatches.wisefy; + + +import org.junit.Test; +import static com.isupatches.wisefy.base.TestUtils.TEST_SSID; +import static junit.framework.Assert.assertFalse; +import static junit.framework.Assert.assertTrue; +import static org.mockito.ArgumentMatchers.anyString; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; + + +public class IsDeviceConnectedToSSIDTests extends BaseAndroidJUnit4TestClass { + + @Test + public void noCallbacks_failure_nullSSIDParams() { + assertFalse(mWiseFy.isDeviceConnectedToSSID(null)); + } + + @Test + public void noCallbacks_failure_missingPrerequisite() { + missingPrerequisite(); + assertFalse(mWiseFy.isDeviceConnectedToSSID(TEST_SSID)); + } + + @Test + public void noCallbacks_failure() { + WiseFyConnection mockWiseFyConnection = mock(WiseFyConnection.class); + mWiseFy.mWiseFyConnection = mockWiseFyConnection; + when(mockWiseFyConnection.isCurrentNetworkConnectedToSSID(anyString())).thenReturn(false); + + assertFalse(mWiseFy.isDeviceConnectedToSSID(TEST_SSID)); + } + + @Test + public void noCallbacks_success() { + WiseFyConnection mockWiseFyConnection = mock(WiseFyConnection.class); + mWiseFy.mWiseFyConnection = mockWiseFyConnection; + when(mockWiseFyConnection.isCurrentNetworkConnectedToSSID(anyString())).thenReturn(true); + + assertTrue(mWiseFy.isDeviceConnectedToSSID(TEST_SSID)); + } +} diff --git a/wisefy/src/androidTest/java/com/isupatches/wisefy/IsDeviceConnectedToWifiNetworkTests.java b/wisefy/src/androidTest/java/com/isupatches/wisefy/IsDeviceConnectedToWifiNetworkTests.java index 0c4495f6..da3d209d 100644 --- a/wisefy/src/androidTest/java/com/isupatches/wisefy/IsDeviceConnectedToWifiNetworkTests.java +++ b/wisefy/src/androidTest/java/com/isupatches/wisefy/IsDeviceConnectedToWifiNetworkTests.java @@ -1,46 +1,41 @@ -//package com.isupatches.wisefy; -// -// -//import android.net.NetworkInfo; -//import com.isupatches.wisefy.base.TestActivity; -//import org.junit.Test; -//import static junit.framework.Assert.assertFalse; -//import static junit.framework.Assert.assertTrue; -//import static org.mockito.ArgumentMatchers.any; -//import static org.mockito.ArgumentMatchers.anyString; -//import static org.mockito.Mockito.mock; -//import static org.mockito.Mockito.when; -// -// -//public class IsDeviceConnectedToWifiNetworkTests extends BaseTestClass { -// -// public IsDeviceConnectedToWifiNetworkTests() { -// super(TestActivity.class); -// } -// -// @Test -// public void failure_missingPrerequisite() { -// missingPrerequisite(); -// assertFalse(mWiseFy.isDeviceConnectedToWifiNetwork()); -// } -// -// @Test -// public void failure() { -// when(mMockConnectivityManager.getActiveNetworkInfo()).thenReturn(mock(NetworkInfo.class)); -// -// WiseFyConnection mockWiseFyConnection = mock(WiseFyConnection.class); -// mWiseFy.mWiseFyConnection = mockWiseFyConnection; -// when(mockWiseFyConnection.isNetworkConnectedAndMatchesType(any(NetworkInfo.class), anyString())).thenReturn(false); -// assertFalse(mWiseFy.isDeviceConnectedToWifiNetwork()); -// } -// -// @Test -// public void success() { -// when(mMockConnectivityManager.getActiveNetworkInfo()).thenReturn(mock(NetworkInfo.class)); -// -// WiseFyConnection mockWiseFyConnection = mock(WiseFyConnection.class); -// mWiseFy.mWiseFyConnection = mockWiseFyConnection; -// when(mockWiseFyConnection.isNetworkConnectedAndMatchesType(any(NetworkInfo.class), anyString())).thenReturn(true); -// assertTrue(mWiseFy.isDeviceConnectedToWifiNetwork()); -// } -//} +package com.isupatches.wisefy; + + +import android.net.NetworkInfo; +import org.junit.Test; +import static junit.framework.Assert.assertFalse; +import static junit.framework.Assert.assertTrue; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.anyString; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; + + +public class IsDeviceConnectedToWifiNetworkTests extends BaseAndroidJUnit4TestClass { + + @Test + public void failure_missingPrerequisite() { + missingPrerequisite(); + assertFalse(mWiseFy.isDeviceConnectedToWifiNetwork()); + } + + @Test + public void failure() { + when(mMockConnectivityManager.getActiveNetworkInfo()).thenReturn(mock(NetworkInfo.class)); + + WiseFyConnection mockWiseFyConnection = mock(WiseFyConnection.class); + mWiseFy.mWiseFyConnection = mockWiseFyConnection; + when(mockWiseFyConnection.isNetworkConnectedAndMatchesType(any(NetworkInfo.class), anyString())).thenReturn(false); + assertFalse(mWiseFy.isDeviceConnectedToWifiNetwork()); + } + + @Test + public void success() { + when(mMockConnectivityManager.getActiveNetworkInfo()).thenReturn(mock(NetworkInfo.class)); + + WiseFyConnection mockWiseFyConnection = mock(WiseFyConnection.class); + mWiseFy.mWiseFyConnection = mockWiseFyConnection; + when(mockWiseFyConnection.isNetworkConnectedAndMatchesType(any(NetworkInfo.class), anyString())).thenReturn(true); + assertTrue(mWiseFy.isDeviceConnectedToWifiNetwork()); + } +} diff --git a/wisefy/src/androidTest/java/com/isupatches/wisefy/IsDeviceRoamingTests.java b/wisefy/src/androidTest/java/com/isupatches/wisefy/IsDeviceRoamingTests.java index a02cbc6f..7e214cb1 100644 --- a/wisefy/src/androidTest/java/com/isupatches/wisefy/IsDeviceRoamingTests.java +++ b/wisefy/src/androidTest/java/com/isupatches/wisefy/IsDeviceRoamingTests.java @@ -1,42 +1,37 @@ -//package com.isupatches.wisefy; -// -// -//import android.net.NetworkInfo; -//import com.isupatches.wisefy.base.TestActivity; -//import org.junit.Test; -//import static junit.framework.Assert.assertFalse; -//import static junit.framework.Assert.assertTrue; -//import static org.mockito.Mockito.mock; -//import static org.mockito.Mockito.when; -// -// -//public class IsDeviceRoamingTests extends BaseTestClass { -// -// public IsDeviceRoamingTests() { -// super(TestActivity.class); -// } -// -// @Test -// public void failure_missingPrerequisite() { -// missingPrerequisite(); -// assertFalse(mWiseFy.isDeviceRoaming()); -// } -// -// @Test -// public void failure() { -// NetworkInfo networkInfo = mock(NetworkInfo.class); -// when(networkInfo.isRoaming()).thenReturn(false); -// when(mMockConnectivityManager.getActiveNetworkInfo()).thenReturn(networkInfo); -// -// assertFalse(mWiseFy.isDeviceRoaming()); -// } -// -// @Test -// public void success() { -// NetworkInfo networkInfo = mock(NetworkInfo.class); -// when(networkInfo.isRoaming()).thenReturn(true); -// when(mMockConnectivityManager.getActiveNetworkInfo()).thenReturn(networkInfo); -// -// assertTrue(mWiseFy.isDeviceRoaming()); -// } -//} +package com.isupatches.wisefy; + + +import android.net.NetworkInfo; +import org.junit.Test; +import static junit.framework.Assert.assertFalse; +import static junit.framework.Assert.assertTrue; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; + + +public class IsDeviceRoamingTests extends BaseAndroidJUnit4TestClass { + + @Test + public void failure_missingPrerequisite() { + missingPrerequisite(); + assertFalse(mWiseFy.isDeviceRoaming()); + } + + @Test + public void failure() { + NetworkInfo networkInfo = mock(NetworkInfo.class); + when(networkInfo.isRoaming()).thenReturn(false); + when(mMockConnectivityManager.getActiveNetworkInfo()).thenReturn(networkInfo); + + assertFalse(mWiseFy.isDeviceRoaming()); + } + + @Test + public void success() { + NetworkInfo networkInfo = mock(NetworkInfo.class); + when(networkInfo.isRoaming()).thenReturn(true); + when(mMockConnectivityManager.getActiveNetworkInfo()).thenReturn(networkInfo); + + assertTrue(mWiseFy.isDeviceRoaming()); + } +} diff --git a/wisefy/src/androidTest/java/com/isupatches/wisefy/IsNetwork5gHzTests.java b/wisefy/src/androidTest/java/com/isupatches/wisefy/IsNetwork5gHzTests.java index f9de44d0..0af93446 100644 --- a/wisefy/src/androidTest/java/com/isupatches/wisefy/IsNetwork5gHzTests.java +++ b/wisefy/src/androidTest/java/com/isupatches/wisefy/IsNetwork5gHzTests.java @@ -1,102 +1,97 @@ -//package com.isupatches.wisefy; -// -// -//import android.net.wifi.WifiInfo; -//import android.os.Build; -//import com.isupatches.wisefy.base.TestActivity; -//import org.junit.Test; -//import static com.isupatches.wisefy.base.TestUtils.TEST_NETWORK_FREQUENCY_5GHZ; -//import static com.isupatches.wisefy.base.TestUtils.TEST_NETWORK_FREQUENCY_ABOVE_5GHZ; -//import static com.isupatches.wisefy.base.TestUtils.TEST_NETWORK_FREQUENCY_BELOW_5GHZ; -//import static org.junit.Assert.assertEquals; -//import static org.mockito.Mockito.mock; -//import static org.mockito.Mockito.when; -// -// -//public class IsNetwork5gHzTests extends BaseTestClass { -// -// public IsNetwork5gHzTests() { -// super(TestActivity.class); -// } -// -// @Test -// public void currentNetwork_failure_above5ghz() { -// if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { -// WifiInfo mockWifiInfo = mock(WifiInfo.class); -// when(mockWifiInfo.getFrequency()).thenReturn(TEST_NETWORK_FREQUENCY_ABOVE_5GHZ); -// when(mMockWiFiManager.getConnectionInfo()).thenReturn(mockWifiInfo); -// -// assertEquals(false, mWiseFy.isNetwork5gHz()); -// } -// } -// -// @Test -// public void currentNetwork_failure_below5ghz() { -// if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { -// WifiInfo mockWifiInfo = mock(WifiInfo.class); -// when(mockWifiInfo.getFrequency()).thenReturn(TEST_NETWORK_FREQUENCY_BELOW_5GHZ); -// when(mMockWiFiManager.getConnectionInfo()).thenReturn(mockWifiInfo); -// -// assertEquals(false, mWiseFy.isNetwork5gHz()); -// } -// } -// -// @Test -// public void currentNetwork_failure_null() { -// if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { -// when(mMockWiFiManager.getConnectionInfo()).thenReturn(null); -// assertEquals(false, mWiseFy.isNetwork5gHz()); -// } -// } -// -// @Test -// public void currentNetwork_success() { -// if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { -// WifiInfo mockWifiInfo = mock(WifiInfo.class); -// when(mockWifiInfo.getFrequency()).thenReturn(TEST_NETWORK_FREQUENCY_5GHZ); -// when(mMockWiFiManager.getConnectionInfo()).thenReturn(mockWifiInfo); -// -// assertEquals(true, mWiseFy.isNetwork5gHz()); -// } -// } -// -// @Test -// public void provideWifiInfo_failure_above5ghz() { -// if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { -// WifiInfo mockWifiInfo = mock(WifiInfo.class); -// when(mockWifiInfo.getFrequency()).thenReturn(TEST_NETWORK_FREQUENCY_ABOVE_5GHZ); -// when(mMockWiFiManager.getConnectionInfo()).thenReturn(mockWifiInfo); -// -// assertEquals(false, mWiseFy.isNetwork5gHz(mockWifiInfo)); -// } -// } -// -// @Test -// public void provideWifiInfo_failure_below5ghz() { -// if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { -// WifiInfo mockWifiInfo = mock(WifiInfo.class); -// when(mockWifiInfo.getFrequency()).thenReturn(TEST_NETWORK_FREQUENCY_BELOW_5GHZ); -// when(mMockWiFiManager.getConnectionInfo()).thenReturn(mockWifiInfo); -// -// assertEquals(false, mWiseFy.isNetwork5gHz(mockWifiInfo)); -// } -// } -// -// @Test -// public void provideWifiInfo_failure_null() { -// if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { -// assertEquals(false, mWiseFy.isNetwork5gHz(null)); -// } -// } -// -// @Test -// public void provideWifiInfo_success() { -// if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { -// WifiInfo mockWifiInfo = mock(WifiInfo.class); -// when(mockWifiInfo.getFrequency()).thenReturn(TEST_NETWORK_FREQUENCY_5GHZ); -// when(mMockWiFiManager.getConnectionInfo()).thenReturn(mockWifiInfo); -// -// assertEquals(true, mWiseFy.isNetwork5gHz(mockWifiInfo)); -// } -// } -//} +package com.isupatches.wisefy; + + +import android.net.wifi.WifiInfo; +import android.os.Build; +import org.junit.Test; +import static com.isupatches.wisefy.base.TestUtils.TEST_NETWORK_FREQUENCY_5GHZ; +import static com.isupatches.wisefy.base.TestUtils.TEST_NETWORK_FREQUENCY_ABOVE_5GHZ; +import static com.isupatches.wisefy.base.TestUtils.TEST_NETWORK_FREQUENCY_BELOW_5GHZ; +import static org.junit.Assert.assertEquals; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; + + +public class IsNetwork5gHzTests extends BaseAndroidJUnit4TestClass { + + @Test + public void currentNetwork_failure_above5ghz() { + if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { + WifiInfo mockWifiInfo = mock(WifiInfo.class); + when(mockWifiInfo.getFrequency()).thenReturn(TEST_NETWORK_FREQUENCY_ABOVE_5GHZ); + when(mMockWiFiManager.getConnectionInfo()).thenReturn(mockWifiInfo); + + assertEquals(false, mWiseFy.isNetwork5gHz()); + } + } + + @Test + public void currentNetwork_failure_below5ghz() { + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { + WifiInfo mockWifiInfo = mock(WifiInfo.class); + when(mockWifiInfo.getFrequency()).thenReturn(TEST_NETWORK_FREQUENCY_BELOW_5GHZ); + when(mMockWiFiManager.getConnectionInfo()).thenReturn(mockWifiInfo); + + assertEquals(false, mWiseFy.isNetwork5gHz()); + } + } + + @Test + public void currentNetwork_failure_null() { + if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { + when(mMockWiFiManager.getConnectionInfo()).thenReturn(null); + assertEquals(false, mWiseFy.isNetwork5gHz()); + } + } + + @Test + public void currentNetwork_success() { + if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { + WifiInfo mockWifiInfo = mock(WifiInfo.class); + when(mockWifiInfo.getFrequency()).thenReturn(TEST_NETWORK_FREQUENCY_5GHZ); + when(mMockWiFiManager.getConnectionInfo()).thenReturn(mockWifiInfo); + + assertEquals(true, mWiseFy.isNetwork5gHz()); + } + } + + @Test + public void provideWifiInfo_failure_above5ghz() { + if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { + WifiInfo mockWifiInfo = mock(WifiInfo.class); + when(mockWifiInfo.getFrequency()).thenReturn(TEST_NETWORK_FREQUENCY_ABOVE_5GHZ); + when(mMockWiFiManager.getConnectionInfo()).thenReturn(mockWifiInfo); + + assertEquals(false, mWiseFy.isNetwork5gHz(mockWifiInfo)); + } + } + + @Test + public void provideWifiInfo_failure_below5ghz() { + if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { + WifiInfo mockWifiInfo = mock(WifiInfo.class); + when(mockWifiInfo.getFrequency()).thenReturn(TEST_NETWORK_FREQUENCY_BELOW_5GHZ); + when(mMockWiFiManager.getConnectionInfo()).thenReturn(mockWifiInfo); + + assertEquals(false, mWiseFy.isNetwork5gHz(mockWifiInfo)); + } + } + + @Test + public void provideWifiInfo_failure_null() { + if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { + assertEquals(false, mWiseFy.isNetwork5gHz(null)); + } + } + + @Test + public void provideWifiInfo_success() { + if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { + WifiInfo mockWifiInfo = mock(WifiInfo.class); + when(mockWifiInfo.getFrequency()).thenReturn(TEST_NETWORK_FREQUENCY_5GHZ); + when(mMockWiFiManager.getConnectionInfo()).thenReturn(mockWifiInfo); + + assertEquals(true, mWiseFy.isNetwork5gHz(mockWifiInfo)); + } + } +} diff --git a/wisefy/src/androidTest/java/com/isupatches/wisefy/IsNetworkEAPTests.java b/wisefy/src/androidTest/java/com/isupatches/wisefy/IsNetworkEAPTests.java index 608760ca..51a45406 100644 --- a/wisefy/src/androidTest/java/com/isupatches/wisefy/IsNetworkEAPTests.java +++ b/wisefy/src/androidTest/java/com/isupatches/wisefy/IsNetworkEAPTests.java @@ -1,49 +1,44 @@ -//package com.isupatches.wisefy; -// -// -//import android.net.wifi.ScanResult; -//import com.isupatches.wisefy.base.TestActivity; -//import com.isupatches.wisefy.constants.Capabilities; -//import org.junit.Test; -//import static org.junit.Assert.assertEquals; -//import static org.mockito.Mockito.mock; -// -// -//public class IsNetworkEAPTests extends BaseTestClass { -// -// public IsNetworkEAPTests() { -// super(TestActivity.class); -// } -// -// @Test -// public void failure_differentCapability() { -// ScanResult scanResult = mock(ScanResult.class); -// scanResult.capabilities = "Other"; -// assertEquals(false, mWiseFy.isNetworkEAP(scanResult)); -// } -// -// @Test -// public void failure_emptyCapabilities() { -// ScanResult scanResult = mock(ScanResult.class); -// scanResult.capabilities = ""; -// assertEquals(false, mWiseFy.isNetworkEAP(scanResult)); -// } -// -// @Test -// public void failure_nullCapabilities() { -// ScanResult scanResult = mock(ScanResult.class); -// assertEquals(false, mWiseFy.isNetworkEAP(scanResult)); -// } -// -// @Test -// public void failure_nullScanResult() { -// assertEquals(false, mWiseFy.isNetworkEAP(null)); -// } -// -// @Test -// public void success() { -// ScanResult scanResult = mock(ScanResult.class); -// scanResult.capabilities = Capabilities.EAP; -// assertEquals(true, mWiseFy.isNetworkEAP(scanResult)); -// } -//} +package com.isupatches.wisefy; + + +import android.net.wifi.ScanResult; +import com.isupatches.wisefy.constants.Capabilities; +import org.junit.Test; +import static org.junit.Assert.assertEquals; +import static org.mockito.Mockito.mock; + + +public class IsNetworkEAPTests extends BaseAndroidJUnit4TestClass { + + @Test + public void failure_differentCapability() { + ScanResult scanResult = mock(ScanResult.class); + scanResult.capabilities = "Other"; + assertEquals(false, mWiseFy.isNetworkEAP(scanResult)); + } + + @Test + public void failure_emptyCapabilities() { + ScanResult scanResult = mock(ScanResult.class); + scanResult.capabilities = ""; + assertEquals(false, mWiseFy.isNetworkEAP(scanResult)); + } + + @Test + public void failure_nullCapabilities() { + ScanResult scanResult = mock(ScanResult.class); + assertEquals(false, mWiseFy.isNetworkEAP(scanResult)); + } + + @Test + public void failure_nullScanResult() { + assertEquals(false, mWiseFy.isNetworkEAP(null)); + } + + @Test + public void success() { + ScanResult scanResult = mock(ScanResult.class); + scanResult.capabilities = Capabilities.EAP; + assertEquals(true, mWiseFy.isNetworkEAP(scanResult)); + } +} diff --git a/wisefy/src/androidTest/java/com/isupatches/wisefy/IsNetworkInConfigurationListTests.java b/wisefy/src/androidTest/java/com/isupatches/wisefy/IsNetworkInConfigurationListTests.java index b17936f8..b2981cd2 100644 --- a/wisefy/src/androidTest/java/com/isupatches/wisefy/IsNetworkInConfigurationListTests.java +++ b/wisefy/src/androidTest/java/com/isupatches/wisefy/IsNetworkInConfigurationListTests.java @@ -1,99 +1,94 @@ -//package com.isupatches.wisefy; -// -// -//import android.net.wifi.WifiConfiguration; -//import com.isupatches.wisefy.base.TestActivity; -//import org.junit.Test; -//import java.util.ArrayList; -//import java.util.List; -//import static com.isupatches.wisefy.base.TestUtils.TEST_SSID; -//import static com.isupatches.wisefy.base.TestUtils.TEST_SSID2; -//import static com.isupatches.wisefy.base.TestUtils.TEST_SSID3; -//import static org.junit.Assert.assertEquals; -//import static org.mockito.Mockito.when; -// -// -//public class IsNetworkInConfigurationListTests extends BaseTestClass { -// -// public IsNetworkInConfigurationListTests() { -// super(TestActivity.class); -// } -// -// @Test -// public void failure() { -// assertEquals(false, mWiseFy.isNetworkInConfigurationList(TEST_SSID)); -// } -// -// @Test -// public void failure_multipleNetworks() { -// List wifiList = new ArrayList<>(); -// -// WifiConfiguration wifiConfiguration1 = new WifiConfiguration(); -// wifiConfiguration1.SSID = TEST_SSID2; -// wifiList.add(wifiConfiguration1); -// -// WifiConfiguration wiFiConfiguration2 = new WifiConfiguration(); -// wiFiConfiguration2.SSID = TEST_SSID3; -// wifiList.add(wiFiConfiguration2); -// -// when(mMockWiFiManager.getConfiguredNetworks()).thenReturn(wifiList); -// assertEquals(false, mWiseFy.isNetworkInConfigurationList(TEST_SSID)); -// } -// -// @Test -// public void failure_noNetworks() { -// List wifiList = new ArrayList<>(); -// when(mMockWiFiManager.getConfiguredNetworks()).thenReturn(wifiList); -// assertEquals(false, mWiseFy.isNetworkInConfigurationList(TEST_SSID)); -// } -// -// @Test -// public void failure_nullSSID() { -// List wifiList = new ArrayList<>(); -// WifiConfiguration wifiConfiguration = new WifiConfiguration(); -// wifiConfiguration.SSID = null; -// wifiList.add(wifiConfiguration); -// when(mMockWiFiManager.getConfiguredNetworks()).thenReturn(wifiList); -// assertEquals(false, mWiseFy.isNetworkInConfigurationList(TEST_SSID)); -// } -// -// @Test -// public void failure_nullWifiConfiguration() { -// List wifiList = new ArrayList<>(); -// wifiList.add(0, null); -// when(mMockWiFiManager.getConfiguredNetworks()).thenReturn(wifiList); -// assertEquals(false, mWiseFy.isNetworkInConfigurationList(TEST_SSID)); -// } -// -// @Test -// public void failure_nmissingPrerequisite() { -// missingPrerequisite(); -// assertEquals(false, mWiseFy.isNetworkInConfigurationList(TEST_SSID)); -// } -// -// @Test -// public void success() { -// List wifiList = new ArrayList<>(); -// WifiConfiguration mWiFiConfiguration = new WifiConfiguration(); -// mWiFiConfiguration.SSID = TEST_SSID; -// wifiList.add(mWiFiConfiguration); -// when(mMockWiFiManager.getConfiguredNetworks()).thenReturn(wifiList); -// assertEquals(true, mWiseFy.isNetworkInConfigurationList(TEST_SSID)); -// } -// -// @Test -// public void success_multipleNetworks() { -// List wifiList = new ArrayList<>(); -// -// WifiConfiguration wifiConfiguration1 = new WifiConfiguration(); -// wifiConfiguration1.SSID = TEST_SSID; -// wifiList.add(wifiConfiguration1); -// -// WifiConfiguration wiFiConfiguration2 = new WifiConfiguration(); -// wiFiConfiguration2.SSID = TEST_SSID2; -// wifiList.add(wiFiConfiguration2); -// -// when(mMockWiFiManager.getConfiguredNetworks()).thenReturn(wifiList); -// assertEquals(true, mWiseFy.isNetworkInConfigurationList(TEST_SSID)); -// } -//} +package com.isupatches.wisefy; + + +import android.net.wifi.WifiConfiguration; +import org.junit.Test; +import java.util.ArrayList; +import java.util.List; +import static com.isupatches.wisefy.base.TestUtils.TEST_SSID; +import static com.isupatches.wisefy.base.TestUtils.TEST_SSID2; +import static com.isupatches.wisefy.base.TestUtils.TEST_SSID3; +import static org.junit.Assert.assertEquals; +import static org.mockito.Mockito.when; + + +public class IsNetworkInConfigurationListTests extends BaseAndroidJUnit4TestClass { + + @Test + public void failure() { + assertEquals(false, mWiseFy.isNetworkInConfigurationList(TEST_SSID)); + } + + @Test + public void failure_multipleNetworks() { + List wifiList = new ArrayList<>(); + + WifiConfiguration wifiConfiguration1 = new WifiConfiguration(); + wifiConfiguration1.SSID = TEST_SSID2; + wifiList.add(wifiConfiguration1); + + WifiConfiguration wiFiConfiguration2 = new WifiConfiguration(); + wiFiConfiguration2.SSID = TEST_SSID3; + wifiList.add(wiFiConfiguration2); + + when(mMockWiFiManager.getConfiguredNetworks()).thenReturn(wifiList); + assertEquals(false, mWiseFy.isNetworkInConfigurationList(TEST_SSID)); + } + + @Test + public void failure_noNetworks() { + List wifiList = new ArrayList<>(); + when(mMockWiFiManager.getConfiguredNetworks()).thenReturn(wifiList); + assertEquals(false, mWiseFy.isNetworkInConfigurationList(TEST_SSID)); + } + + @Test + public void failure_nullSSID() { + List wifiList = new ArrayList<>(); + WifiConfiguration wifiConfiguration = new WifiConfiguration(); + wifiConfiguration.SSID = null; + wifiList.add(wifiConfiguration); + when(mMockWiFiManager.getConfiguredNetworks()).thenReturn(wifiList); + assertEquals(false, mWiseFy.isNetworkInConfigurationList(TEST_SSID)); + } + + @Test + public void failure_nullWifiConfiguration() { + List wifiList = new ArrayList<>(); + wifiList.add(0, null); + when(mMockWiFiManager.getConfiguredNetworks()).thenReturn(wifiList); + assertEquals(false, mWiseFy.isNetworkInConfigurationList(TEST_SSID)); + } + + @Test + public void failure_nmissingPrerequisite() { + missingPrerequisite(); + assertEquals(false, mWiseFy.isNetworkInConfigurationList(TEST_SSID)); + } + + @Test + public void success() { + List wifiList = new ArrayList<>(); + WifiConfiguration mWiFiConfiguration = new WifiConfiguration(); + mWiFiConfiguration.SSID = TEST_SSID; + wifiList.add(mWiFiConfiguration); + when(mMockWiFiManager.getConfiguredNetworks()).thenReturn(wifiList); + assertEquals(true, mWiseFy.isNetworkInConfigurationList(TEST_SSID)); + } + + @Test + public void success_multipleNetworks() { + List wifiList = new ArrayList<>(); + + WifiConfiguration wifiConfiguration1 = new WifiConfiguration(); + wifiConfiguration1.SSID = TEST_SSID; + wifiList.add(wifiConfiguration1); + + WifiConfiguration wiFiConfiguration2 = new WifiConfiguration(); + wiFiConfiguration2.SSID = TEST_SSID2; + wifiList.add(wiFiConfiguration2); + + when(mMockWiFiManager.getConfiguredNetworks()).thenReturn(wifiList); + assertEquals(true, mWiseFy.isNetworkInConfigurationList(TEST_SSID)); + } +} diff --git a/wisefy/src/androidTest/java/com/isupatches/wisefy/IsNetworkPSKTest.java b/wisefy/src/androidTest/java/com/isupatches/wisefy/IsNetworkPSKTest.java index 7a307f68..5ac26f84 100644 --- a/wisefy/src/androidTest/java/com/isupatches/wisefy/IsNetworkPSKTest.java +++ b/wisefy/src/androidTest/java/com/isupatches/wisefy/IsNetworkPSKTest.java @@ -1,49 +1,44 @@ -//package com.isupatches.wisefy; -// -// -//import android.net.wifi.ScanResult; -//import com.isupatches.wisefy.base.TestActivity; -//import com.isupatches.wisefy.constants.Capabilities; -//import org.junit.Test; -//import static org.junit.Assert.assertEquals; -//import static org.mockito.Mockito.mock; -// -// -//public class IsNetworkPSKTest extends BaseTestClass { -// -// public IsNetworkPSKTest() { -// super(TestActivity.class); -// } -// -// @Test -// public void failure_differentCapability() { -// ScanResult scanResult = mock(ScanResult.class); -// scanResult.capabilities = "Other"; -// assertEquals(false, mWiseFy.isNetworkPSK(scanResult)); -// } -// -// @Test -// public void failure_emptyCapabilities() { -// ScanResult scanResult = mock(ScanResult.class); -// scanResult.capabilities = ""; -// assertEquals(false, mWiseFy.isNetworkPSK(scanResult)); -// } -// -// @Test -// public void failure_nullCapabilities() { -// ScanResult scanResult = mock(ScanResult.class); -// assertEquals(false, mWiseFy.isNetworkPSK(scanResult)); -// } -// -// @Test -// public void failure_nullScanResult() { -// assertEquals(false, mWiseFy.isNetworkPSK(null)); -// } -// -// @Test -// public void success() { -// ScanResult scanResult = mock(ScanResult.class); -// scanResult.capabilities = Capabilities.PSK; -// assertEquals(true, mWiseFy.isNetworkPSK(scanResult)); -// } -//} +package com.isupatches.wisefy; + + +import android.net.wifi.ScanResult; +import com.isupatches.wisefy.constants.Capabilities; +import org.junit.Test; +import static org.junit.Assert.assertEquals; +import static org.mockito.Mockito.mock; + + +public class IsNetworkPSKTest extends BaseAndroidJUnit4TestClass { + + @Test + public void failure_differentCapability() { + ScanResult scanResult = mock(ScanResult.class); + scanResult.capabilities = "Other"; + assertEquals(false, mWiseFy.isNetworkPSK(scanResult)); + } + + @Test + public void failure_emptyCapabilities() { + ScanResult scanResult = mock(ScanResult.class); + scanResult.capabilities = ""; + assertEquals(false, mWiseFy.isNetworkPSK(scanResult)); + } + + @Test + public void failure_nullCapabilities() { + ScanResult scanResult = mock(ScanResult.class); + assertEquals(false, mWiseFy.isNetworkPSK(scanResult)); + } + + @Test + public void failure_nullScanResult() { + assertEquals(false, mWiseFy.isNetworkPSK(null)); + } + + @Test + public void success() { + ScanResult scanResult = mock(ScanResult.class); + scanResult.capabilities = Capabilities.PSK; + assertEquals(true, mWiseFy.isNetworkPSK(scanResult)); + } +} diff --git a/wisefy/src/androidTest/java/com/isupatches/wisefy/IsNetworkSecureTests.java b/wisefy/src/androidTest/java/com/isupatches/wisefy/IsNetworkSecureTests.java index 89a450b1..cd3823ec 100644 --- a/wisefy/src/androidTest/java/com/isupatches/wisefy/IsNetworkSecureTests.java +++ b/wisefy/src/androidTest/java/com/isupatches/wisefy/IsNetworkSecureTests.java @@ -1,77 +1,72 @@ -//package com.isupatches.wisefy; -// -// -//import android.net.wifi.ScanResult; -//import com.isupatches.wisefy.base.TestActivity; -//import com.isupatches.wisefy.constants.Capabilities; -//import org.junit.Test; -//import static org.junit.Assert.assertEquals; -//import static org.mockito.Mockito.mock; -// -// -//public class IsNetworkSecureTests extends BaseTestClass { -// -// public IsNetworkSecureTests() { -// super(TestActivity.class); -// } -// -// @Test -// public void failure_emptyCapabilities() { -// ScanResult scanResult = mock(ScanResult.class); -// scanResult.capabilities = ""; -// assertEquals(false, mWiseFy.isNetworkSecure(scanResult)); -// } -// -// @Test -// public void failure_nullCapabilities() { -// ScanResult scanResult = mock(ScanResult.class); -// assertEquals(false, mWiseFy.isNetworkSecure(scanResult)); -// } -// -// @Test -// public void failure_nullScanResult() { -// assertEquals(false, mWiseFy.isNetworkSecure(null)); -// } -// -// @Test -// public void success_withEAP() { -// ScanResult scanResult = mock(ScanResult.class); -// scanResult.capabilities = Capabilities.EAP; -// assertEquals(true, mWiseFy.isNetworkSecure(scanResult)); -// } -// -// @Test -// public void success_withPSK() { -// ScanResult scanResult = mock(ScanResult.class); -// scanResult.capabilities = Capabilities.PSK; -// assertEquals(true, mWiseFy.isNetworkSecure(scanResult)); -// } -// -// @Test -// public void success_withWEP() { -// ScanResult scanResult = mock(ScanResult.class); -// scanResult.capabilities = Capabilities.WEP; -// assertEquals(true, mWiseFy.isNetworkSecure(scanResult)); -// } -// -// @Test -// public void success_withWPA() { -// ScanResult scanResult = mock(ScanResult.class); -// scanResult.capabilities = Capabilities.WPA; -// assertEquals(true, mWiseFy.isNetworkSecure(scanResult)); -// } -// -// @Test -// public void success_withWPA2() { -// ScanResult scanResult = mock(ScanResult.class); -// scanResult.capabilities = Capabilities.WPA2; -// assertEquals(true, mWiseFy.isNetworkSecure(scanResult)); -// } -// -// @Test -// public void failure_otherCapabilities() { -// ScanResult scanResult = mock(ScanResult.class); -// scanResult.capabilities = "Other"; -// assertEquals(false, mWiseFy.isNetworkSecure(scanResult)); -// } -//} +package com.isupatches.wisefy; + + +import android.net.wifi.ScanResult; +import com.isupatches.wisefy.constants.Capabilities; +import org.junit.Test; +import static org.junit.Assert.assertEquals; +import static org.mockito.Mockito.mock; + + +public class IsNetworkSecureTests extends BaseAndroidJUnit4TestClass { + + @Test + public void failure_emptyCapabilities() { + ScanResult scanResult = mock(ScanResult.class); + scanResult.capabilities = ""; + assertEquals(false, mWiseFy.isNetworkSecure(scanResult)); + } + + @Test + public void failure_nullCapabilities() { + ScanResult scanResult = mock(ScanResult.class); + assertEquals(false, mWiseFy.isNetworkSecure(scanResult)); + } + + @Test + public void failure_nullScanResult() { + assertEquals(false, mWiseFy.isNetworkSecure(null)); + } + + @Test + public void success_withEAP() { + ScanResult scanResult = mock(ScanResult.class); + scanResult.capabilities = Capabilities.EAP; + assertEquals(true, mWiseFy.isNetworkSecure(scanResult)); + } + + @Test + public void success_withPSK() { + ScanResult scanResult = mock(ScanResult.class); + scanResult.capabilities = Capabilities.PSK; + assertEquals(true, mWiseFy.isNetworkSecure(scanResult)); + } + + @Test + public void success_withWEP() { + ScanResult scanResult = mock(ScanResult.class); + scanResult.capabilities = Capabilities.WEP; + assertEquals(true, mWiseFy.isNetworkSecure(scanResult)); + } + + @Test + public void success_withWPA() { + ScanResult scanResult = mock(ScanResult.class); + scanResult.capabilities = Capabilities.WPA; + assertEquals(true, mWiseFy.isNetworkSecure(scanResult)); + } + + @Test + public void success_withWPA2() { + ScanResult scanResult = mock(ScanResult.class); + scanResult.capabilities = Capabilities.WPA2; + assertEquals(true, mWiseFy.isNetworkSecure(scanResult)); + } + + @Test + public void failure_otherCapabilities() { + ScanResult scanResult = mock(ScanResult.class); + scanResult.capabilities = "Other"; + assertEquals(false, mWiseFy.isNetworkSecure(scanResult)); + } +} diff --git a/wisefy/src/androidTest/java/com/isupatches/wisefy/IsNetworkWPA2Test.java b/wisefy/src/androidTest/java/com/isupatches/wisefy/IsNetworkWPA2Test.java index e148472f..48f98ada 100644 --- a/wisefy/src/androidTest/java/com/isupatches/wisefy/IsNetworkWPA2Test.java +++ b/wisefy/src/androidTest/java/com/isupatches/wisefy/IsNetworkWPA2Test.java @@ -1,49 +1,44 @@ -//package com.isupatches.wisefy; -// -// -//import android.net.wifi.ScanResult; -//import com.isupatches.wisefy.base.TestActivity; -//import com.isupatches.wisefy.constants.Capabilities; -//import org.junit.Test; -//import static org.junit.Assert.assertEquals; -//import static org.mockito.Mockito.mock; -// -// -//public class IsNetworkWPA2Test extends BaseTestClass { -// -// public IsNetworkWPA2Test() { -// super(TestActivity.class); -// } -// -// @Test -// public void failure_differentCapability() { -// ScanResult scanResult = mock(ScanResult.class); -// scanResult.capabilities = "Other"; -// assertEquals(false, mWiseFy.isNetworkWPA2(scanResult)); -// } -// -// @Test -// public void failure_emptyCapabilities() { -// ScanResult scanResult = mock(ScanResult.class); -// scanResult.capabilities = ""; -// assertEquals(false, mWiseFy.isNetworkWPA2(scanResult)); -// } -// -// @Test -// public void failure_nullCapabilities() { -// ScanResult scanResult = mock(ScanResult.class); -// assertEquals(false, mWiseFy.isNetworkWPA2(scanResult)); -// } -// -// @Test -// public void failure_nullScanResult() { -// assertEquals(false, mWiseFy.isNetworkWPA2(null)); -// } -// -// @Test -// public void success() { -// ScanResult scanResult = mock(ScanResult.class); -// scanResult.capabilities = Capabilities.WPA2; -// assertEquals(true, mWiseFy.isNetworkWPA2(scanResult)); -// } -//} +package com.isupatches.wisefy; + + +import android.net.wifi.ScanResult; +import com.isupatches.wisefy.constants.Capabilities; +import org.junit.Test; +import static org.junit.Assert.assertEquals; +import static org.mockito.Mockito.mock; + + +public class IsNetworkWPA2Test extends BaseAndroidJUnit4TestClass { + + @Test + public void failure_differentCapability() { + ScanResult scanResult = mock(ScanResult.class); + scanResult.capabilities = "Other"; + assertEquals(false, mWiseFy.isNetworkWPA2(scanResult)); + } + + @Test + public void failure_emptyCapabilities() { + ScanResult scanResult = mock(ScanResult.class); + scanResult.capabilities = ""; + assertEquals(false, mWiseFy.isNetworkWPA2(scanResult)); + } + + @Test + public void failure_nullCapabilities() { + ScanResult scanResult = mock(ScanResult.class); + assertEquals(false, mWiseFy.isNetworkWPA2(scanResult)); + } + + @Test + public void failure_nullScanResult() { + assertEquals(false, mWiseFy.isNetworkWPA2(null)); + } + + @Test + public void success() { + ScanResult scanResult = mock(ScanResult.class); + scanResult.capabilities = Capabilities.WPA2; + assertEquals(true, mWiseFy.isNetworkWPA2(scanResult)); + } +} diff --git a/wisefy/src/androidTest/java/com/isupatches/wisefy/IsNetworkWPATests.java b/wisefy/src/androidTest/java/com/isupatches/wisefy/IsNetworkWPATests.java index b87bebe6..64793f87 100644 --- a/wisefy/src/androidTest/java/com/isupatches/wisefy/IsNetworkWPATests.java +++ b/wisefy/src/androidTest/java/com/isupatches/wisefy/IsNetworkWPATests.java @@ -1,49 +1,44 @@ -//package com.isupatches.wisefy; -// -// -//import android.net.wifi.ScanResult; -//import com.isupatches.wisefy.base.TestActivity; -//import com.isupatches.wisefy.constants.Capabilities; -//import org.junit.Test; -//import static junit.framework.Assert.assertEquals; -//import static org.mockito.Mockito.mock; -// -// -//public class IsNetworkWPATests extends BaseTestClass { -// -// public IsNetworkWPATests() { -// super(TestActivity.class); -// } -// -// @Test -// public void failure_differentCapability() { -// ScanResult scanResult = mock(ScanResult.class); -// scanResult.capabilities = "Other"; -// assertEquals(false, mWiseFy.isNetworkWPA(scanResult)); -// } -// -// @Test -// public void failure_emptyCapabilities() { -// ScanResult scanResult = mock(ScanResult.class); -// scanResult.capabilities = ""; -// assertEquals(false, mWiseFy.isNetworkWPA(scanResult)); -// } -// -// @Test -// public void failure_nullCapabilities() { -// ScanResult scanResult = mock(ScanResult.class); -// assertEquals(false, mWiseFy.isNetworkWPA(scanResult)); -// } -// -// @Test -// public void failure_nullScanResult() { -// assertEquals(false, mWiseFy.isNetworkWPA(null)); -// } -// -// @Test -// public void success() { -// ScanResult scanResult = mock(ScanResult.class); -// scanResult.capabilities = Capabilities.WPA; -// assertEquals(true, mWiseFy.isNetworkWPA(scanResult)); -// } -//} +package com.isupatches.wisefy; + + +import android.net.wifi.ScanResult; +import com.isupatches.wisefy.constants.Capabilities; +import org.junit.Test; +import static junit.framework.Assert.assertEquals; +import static org.mockito.Mockito.mock; + + +public class IsNetworkWPATests extends BaseAndroidJUnit4TestClass { + + @Test + public void failure_differentCapability() { + ScanResult scanResult = mock(ScanResult.class); + scanResult.capabilities = "Other"; + assertEquals(false, mWiseFy.isNetworkWPA(scanResult)); + } + + @Test + public void failure_emptyCapabilities() { + ScanResult scanResult = mock(ScanResult.class); + scanResult.capabilities = ""; + assertEquals(false, mWiseFy.isNetworkWPA(scanResult)); + } + + @Test + public void failure_nullCapabilities() { + ScanResult scanResult = mock(ScanResult.class); + assertEquals(false, mWiseFy.isNetworkWPA(scanResult)); + } + + @Test + public void failure_nullScanResult() { + assertEquals(false, mWiseFy.isNetworkWPA(null)); + } + + @Test + public void success() { + ScanResult scanResult = mock(ScanResult.class); + scanResult.capabilities = Capabilities.WPA; + assertEquals(true, mWiseFy.isNetworkWPA(scanResult)); + } +} diff --git a/wisefy/src/androidTest/java/com/isupatches/wisefy/IsNetworkWepTests.java b/wisefy/src/androidTest/java/com/isupatches/wisefy/IsNetworkWepTests.java index b6bd3176..e94e8d90 100644 --- a/wisefy/src/androidTest/java/com/isupatches/wisefy/IsNetworkWepTests.java +++ b/wisefy/src/androidTest/java/com/isupatches/wisefy/IsNetworkWepTests.java @@ -1,49 +1,44 @@ -//package com.isupatches.wisefy; -// -// -//import android.net.wifi.ScanResult; -//import com.isupatches.wisefy.base.TestActivity; -//import com.isupatches.wisefy.constants.Capabilities; -//import org.junit.Test; -//import static org.junit.Assert.assertEquals; -//import static org.mockito.Mockito.mock; -// -// -//public class IsNetworkWepTests extends BaseTestClass { -// -// public IsNetworkWepTests() { -// super(TestActivity.class); -// } -// -// @Test -// public void failure_differentCapability() { -// ScanResult scanResult = mock(ScanResult.class); -// scanResult.capabilities = "Other"; -// assertEquals(false, mWiseFy.isNetworkWEP(scanResult)); -// } -// -// @Test -// public void failure_emptyCapabilities() { -// ScanResult scanResult = mock(ScanResult.class); -// scanResult.capabilities = ""; -// assertEquals(false, mWiseFy.isNetworkWEP(scanResult)); -// } -// -// @Test -// public void failure_nullCapabilities() { -// ScanResult scanResult = mock(ScanResult.class); -// assertEquals(false, mWiseFy.isNetworkWEP(scanResult)); -// } -// -// @Test -// public void failure_nullScanResult() { -// assertEquals(false, mWiseFy.isNetworkWEP(null)); -// } -// -// @Test -// public void success() { -// ScanResult scanResult = mock(ScanResult.class); -// scanResult.capabilities = Capabilities.WEP; -// assertEquals(true, mWiseFy.isNetworkWEP(scanResult)); -// } -//} +package com.isupatches.wisefy; + + +import android.net.wifi.ScanResult; +import com.isupatches.wisefy.constants.Capabilities; +import org.junit.Test; +import static org.junit.Assert.assertEquals; +import static org.mockito.Mockito.mock; + + +public class IsNetworkWepTests extends BaseAndroidJUnit4TestClass { + + @Test + public void failure_differentCapability() { + ScanResult scanResult = mock(ScanResult.class); + scanResult.capabilities = "Other"; + assertEquals(false, mWiseFy.isNetworkWEP(scanResult)); + } + + @Test + public void failure_emptyCapabilities() { + ScanResult scanResult = mock(ScanResult.class); + scanResult.capabilities = ""; + assertEquals(false, mWiseFy.isNetworkWEP(scanResult)); + } + + @Test + public void failure_nullCapabilities() { + ScanResult scanResult = mock(ScanResult.class); + assertEquals(false, mWiseFy.isNetworkWEP(scanResult)); + } + + @Test + public void failure_nullScanResult() { + assertEquals(false, mWiseFy.isNetworkWEP(null)); + } + + @Test + public void success() { + ScanResult scanResult = mock(ScanResult.class); + scanResult.capabilities = Capabilities.WEP; + assertEquals(true, mWiseFy.isNetworkWEP(scanResult)); + } +} diff --git a/wisefy/src/androidTest/java/com/isupatches/wisefy/IsWifiEnabledTests.java b/wisefy/src/androidTest/java/com/isupatches/wisefy/IsWifiEnabledTests.java index cfd47f86..25bb11cb 100644 --- a/wisefy/src/androidTest/java/com/isupatches/wisefy/IsWifiEnabledTests.java +++ b/wisefy/src/androidTest/java/com/isupatches/wisefy/IsWifiEnabledTests.java @@ -1,33 +1,28 @@ -//package com.isupatches.wisefy; -// -// -//import com.isupatches.wisefy.base.TestActivity; -//import org.junit.Test; -//import static org.junit.Assert.assertEquals; -//import static org.mockito.Mockito.when; -// -// -//public class IsWifiEnabledTests extends BaseTestClass { -// -// public IsWifiEnabledTests() { -// super(TestActivity.class); -// } -// -// @Test -// public void failure() { -// when(mMockWiFiManager.isWifiEnabled()).thenReturn(false); -// assertEquals(false, mWiseFy.isWifiEnabled()); -// } -// -// @Test -// public void failure_missingPrerequisite() { -// missingPrerequisite(); -// assertEquals(false, mWiseFy.isWifiEnabled()); -// } -// -// @Test -// public void success() { -// when(mMockWiFiManager.isWifiEnabled()).thenReturn(true); -// assertEquals(true, mWiseFy.isWifiEnabled()); -// } -//} \ No newline at end of file +package com.isupatches.wisefy; + + +import org.junit.Test; +import static org.junit.Assert.assertEquals; +import static org.mockito.Mockito.when; + + +public class IsWifiEnabledTests extends BaseAndroidJUnit4TestClass { + + @Test + public void failure() { + when(mMockWiFiManager.isWifiEnabled()).thenReturn(false); + assertEquals(false, mWiseFy.isWifiEnabled()); + } + + @Test + public void failure_missingPrerequisite() { + missingPrerequisite(); + assertEquals(false, mWiseFy.isWifiEnabled()); + } + + @Test + public void success() { + when(mMockWiFiManager.isWifiEnabled()).thenReturn(true); + assertEquals(true, mWiseFy.isWifiEnabled()); + } +} \ No newline at end of file diff --git a/wisefy/src/androidTest/java/com/isupatches/wisefy/ManagerUtilTest.java b/wisefy/src/androidTest/java/com/isupatches/wisefy/ManagerUtilTest.java index 3ae49076..43a8da60 100644 --- a/wisefy/src/androidTest/java/com/isupatches/wisefy/ManagerUtilTest.java +++ b/wisefy/src/androidTest/java/com/isupatches/wisefy/ManagerUtilTest.java @@ -1,46 +1,37 @@ -//package com.isupatches.wisefy; -// -// -//import android.net.ConnectivityManager; -//import android.net.wifi.WifiManager; -//import android.support.test.rule.ActivityTestRule; -//import com.isupatches.wisefy.base.TestActivity; -//import com.isupatches.wisefy.util.ManagerUtil; -//import org.junit.Rule; -//import org.junit.Test; -//import static junit.framework.Assert.*; -// -// -//public class ManagerUtilTest extends BaseTestClass { -// -// public ManagerUtilTest() { -// super(TestActivity.class); -// } -// -// @Rule -// public ActivityTestRule mActivityTestRule = new ActivityTestRule<>(TestActivity.class); -// -// @Test -// public void getConnectivityManager_returnsNotNull() { -// ConnectivityManager connectivityManager = ManagerUtil.getInstance().getConnectivityManager(mActivityTestRule.getActivity()); -// assertNotNull(connectivityManager); -// } -// -// @Test -// public void getConnectivityManager_returnsNull_noActivity() { -// ConnectivityManager connectivityManager = ManagerUtil.getInstance().getConnectivityManager(null); -// assertNull(connectivityManager); -// } -// -// @Test -// public void getWiFiManager_returnsNotNull() { -// WifiManager wifiManager = ManagerUtil.getInstance().getWiFiManager(mActivityTestRule.getActivity()); -// assertNotNull(wifiManager); -// } -// -// @Test -// public void getWiFiManager_returnsNull_noActivity() { -// WifiManager wifiManager = ManagerUtil.getInstance().getWiFiManager(null); -// assertNull(wifiManager); -// } -//} \ No newline at end of file +package com.isupatches.wisefy; + + +import android.net.ConnectivityManager; +import android.net.wifi.WifiManager; +import android.support.test.InstrumentationRegistry; +import com.isupatches.wisefy.util.ManagerUtil; +import org.junit.Test; +import static junit.framework.Assert.*; + + +public class ManagerUtilTest extends BaseAndroidJUnit4TestClass { + + @Test + public void getConnectivityManager_returnsNotNull() { + ConnectivityManager connectivityManager = ManagerUtil.getInstance().getConnectivityManager(InstrumentationRegistry.getContext()); + assertNotNull(connectivityManager); + } + + @Test + public void getConnectivityManager_returnsNull_noActivity() { + ConnectivityManager connectivityManager = ManagerUtil.getInstance().getConnectivityManager(null); + assertNull(connectivityManager); + } + + @Test + public void getWiFiManager_returnsNotNull() { + WifiManager wifiManager = ManagerUtil.getInstance().getWiFiManager(InstrumentationRegistry.getContext()); + assertNotNull(wifiManager); + } + + @Test + public void getWiFiManager_returnsNull_noActivity() { + WifiManager wifiManager = ManagerUtil.getInstance().getWiFiManager(null); + assertNull(wifiManager); + } +} \ No newline at end of file diff --git a/wisefy/src/androidTest/java/com/isupatches/wisefy/RemoveNetworkTests.java b/wisefy/src/androidTest/java/com/isupatches/wisefy/RemoveNetworkTests.java index 1de0d46a..ae3f5a42 100644 --- a/wisefy/src/androidTest/java/com/isupatches/wisefy/RemoveNetworkTests.java +++ b/wisefy/src/androidTest/java/com/isupatches/wisefy/RemoveNetworkTests.java @@ -1,210 +1,205 @@ -//package com.isupatches.wisefy; -// -// -//import android.net.wifi.WifiConfiguration; -//import com.isupatches.wisefy.base.TestActivity; -//import com.isupatches.wisefy.callbacks.RemoveNetworkCallbacks; -//import com.isupatches.wisefy.constants.WiseFyCodes; -//import org.junit.Test; -//import static com.isupatches.wisefy.base.TestUtils.TEST_SSID; -//import static org.junit.Assert.assertEquals; -//import static org.junit.Assert.fail; -//import static org.mockito.ArgumentMatchers.anyInt; -//import static org.mockito.ArgumentMatchers.anyString; -//import static org.mockito.Mockito.mock; -//import static org.mockito.Mockito.never; -//import static org.mockito.Mockito.timeout; -//import static org.mockito.Mockito.verify; -//import static org.mockito.Mockito.when; -// -// -//public class RemoveNetworkTests extends BaseTestClass { -// -// public RemoveNetworkTests() { -// super(TestActivity.class); -// } -// -// @Test -// public void noCallbacks_failure_nullSSIDParam() { -// assertEquals(false, mWiseFy.removeNetwork(null)); -// verify(mMockWiFiManager, never()).removeNetwork(anyInt()); -// } -// -// @Test -// public void noCallbacks_failure_missingPrerequisites() { -// missingPrerequisite(); -// assertEquals(false, mWiseFy.removeNetwork(TEST_SSID)); -// verify(mMockWiFiManager, never()).removeNetwork(anyInt()); -// } -// -// @Test -// public void noCallbacks_failure_noSavedNetwork() { -// WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); -// mWiseFy.mWiseFySearch = mockWiseFySearch; -// when(mockWiseFySearch.findSavedNetworkByRegex(anyString())).thenReturn(null); -// -// assertEquals(false, mWiseFy.removeNetwork(TEST_SSID)); -// verify(mMockWiFiManager, never()).removeNetwork(anyInt()); -// } -// -// @Test -// public void noCallbacks_failure() { -// WifiConfiguration wiFiConfiguration = new WifiConfiguration(); -// wiFiConfiguration.SSID = TEST_SSID; -// WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); -// mWiseFy.mWiseFySearch = mockWiseFySearch; -// when(mockWiseFySearch.findSavedNetworkByRegex(anyString())).thenReturn(wiFiConfiguration); -// -// when(mMockWiFiManager.removeNetwork(anyInt())).thenReturn(false); -// -// assertEquals(false, mWiseFy.removeNetwork(TEST_SSID)); -// verify(mMockWiFiManager, timeout(VERIFICATION_TIMEOUT)).removeNetwork(anyInt()); -// -// } -// -// @Test -// public void noCallbacks_success() { -// WifiConfiguration wiFiConfiguration = new WifiConfiguration(); -// wiFiConfiguration.SSID = TEST_SSID; -// WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); -// mWiseFy.mWiseFySearch = mockWiseFySearch; -// when(mockWiseFySearch.findSavedNetworkByRegex(anyString())).thenReturn(wiFiConfiguration); -// -// when(mMockWiFiManager.removeNetwork(anyInt())).thenReturn(true); -// -// assertEquals(true, mWiseFy.removeNetwork(TEST_SSID)); -// verify(mMockWiFiManager, timeout(VERIFICATION_TIMEOUT)).removeNetwork(anyInt()); -// } -// -// @Test -// public void callbacks_failure_nullSSIDParam() { -// RemoveNetworkCallbacks mockCallbacks = mock(RemoveNetworkCallbacks.class); -// mWiseFy.removeNetwork(null, mockCallbacks); -// verify(mockCallbacks, timeout(3000)).removeNetworkWiseFyFailure(WiseFyCodes.MISSING_PARAMETER); -// verify(mMockWiFiManager, never()).removeNetwork(anyInt()); -// } -// -// @Test -// public void callbacks_failure_nullSSIDParam_nullCallback() { -// try { -// mWiseFy.removeNetwork(null, null); -// verify(mMockWiFiManager, never()).removeNetwork(anyInt()); -// } catch (NullPointerException npe) { -// fail(); -// } -// } -// -// @Test -// public void callbacks_failure_missingPrerequisites() { -// missingPrerequisite(); -// RemoveNetworkCallbacks mockCallbacks = mock(RemoveNetworkCallbacks.class); -// mWiseFy.removeNetwork(TEST_SSID, mockCallbacks); -// verify(mockCallbacks, timeout(VERIFICATION_TIMEOUT)).removeNetworkWiseFyFailure(WiseFyCodes.MISSING_PREREQUISITE); -// verify(mMockWiFiManager, never()).removeNetwork(anyInt()); -// } -// -// @Test -// public void callbacks_failure_missingPrerequisites_nullCallback() { -// missingPrerequisite(); -// try { -// mWiseFy.removeNetwork(TEST_SSID, null); -// verify(mMockWiFiManager, never()).removeNetwork(anyInt()); -// } catch (NullPointerException npe) { -// fail(); -// } -// } -// -// @Test -// public void callbacks_failure_noSavedNetwork() { -// WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); -// mWiseFy.mWiseFySearch = mockWiseFySearch; -// when(mockWiseFySearch.findSavedNetworkByRegex(anyString())).thenReturn(null); -// -// RemoveNetworkCallbacks mockCallbacks = mock(RemoveNetworkCallbacks.class); -// mWiseFy.removeNetwork(TEST_SSID, mockCallbacks); -// verify(mockCallbacks, timeout(VERIFICATION_TIMEOUT)).networkNotFoundToRemove(); -// verify(mMockWiFiManager, never()).removeNetwork(anyInt()); -// } -// -// @Test -// public void callbacks_failure_noSavedNetwork_nullCallback() { -// WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); -// mWiseFy.mWiseFySearch = mockWiseFySearch; -// when(mockWiseFySearch.findSavedNetworkByRegex(anyString())).thenReturn(null); -// -// try { -// mWiseFy.removeNetwork(TEST_SSID, null); -// verify(mMockWiFiManager, never()).removeNetwork(anyInt()); -// } catch (NullPointerException npe) { -// fail(); -// } -// } -// -// @Test -// public void callbacks_failure() { -// WifiConfiguration wiFiConfiguration = new WifiConfiguration(); -// wiFiConfiguration.SSID = TEST_SSID; -// WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); -// mWiseFy.mWiseFySearch = mockWiseFySearch; -// when(mockWiseFySearch.findSavedNetworkByRegex(anyString())).thenReturn(wiFiConfiguration); -// -// when(mMockWiFiManager.removeNetwork(anyInt())).thenReturn(false); -// -// RemoveNetworkCallbacks mockCallbacks = mock(RemoveNetworkCallbacks.class); -// mWiseFy.removeNetwork(TEST_SSID, mockCallbacks); -// verify(mockCallbacks, timeout(VERIFICATION_TIMEOUT)).failureRemovingNetwork(); -// verify(mMockWiFiManager, timeout(VERIFICATION_TIMEOUT)).removeNetwork(anyInt()); -// } -// -// @Test -// public void callbacks_failure_nullCallback() { -// WifiConfiguration wiFiConfiguration = new WifiConfiguration(); -// wiFiConfiguration.SSID = TEST_SSID; -// WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); -// mWiseFy.mWiseFySearch = mockWiseFySearch; -// when(mockWiseFySearch.findSavedNetworkByRegex(anyString())).thenReturn(wiFiConfiguration); -// -// when(mMockWiFiManager.removeNetwork(anyInt())).thenReturn(false); -// -// try { -// mWiseFy.removeNetwork(TEST_SSID, null); -// verify(mMockWiFiManager, never()).removeNetwork(anyInt()); -// } catch (NullPointerException npe) { -// fail(); -// } -// } -// -// @Test -// public void callbacks_success() { -// WifiConfiguration wiFiConfiguration = new WifiConfiguration(); -// wiFiConfiguration.SSID = TEST_SSID; -// WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); -// mWiseFy.mWiseFySearch = mockWiseFySearch; -// when(mockWiseFySearch.findSavedNetworkByRegex(anyString())).thenReturn(wiFiConfiguration); -// -// when(mMockWiFiManager.removeNetwork(anyInt())).thenReturn(true); -// -// RemoveNetworkCallbacks mockCallbacks = mock(RemoveNetworkCallbacks.class); -// mWiseFy.removeNetwork(TEST_SSID, mockCallbacks); -// verify(mockCallbacks, timeout(VERIFICATION_TIMEOUT)).networkRemoved(); -// verify(mMockWiFiManager, timeout(VERIFICATION_TIMEOUT)).removeNetwork(anyInt()); -// } -// -// @Test -// public void callbacks_success_nullCallback() { -// WifiConfiguration wiFiConfiguration = new WifiConfiguration(); -// wiFiConfiguration.SSID = TEST_SSID; -// WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); -// mWiseFy.mWiseFySearch = mockWiseFySearch; -// when(mockWiseFySearch.findSavedNetworkByRegex(anyString())).thenReturn(wiFiConfiguration); -// -// when(mMockWiFiManager.removeNetwork(anyInt())).thenReturn(true); -// -// try { -// mWiseFy.removeNetwork(TEST_SSID, null); -// verify(mMockWiFiManager, never()).removeNetwork(anyInt()); -// } catch (NullPointerException npe) { -// fail(); -// } -// } -//} +package com.isupatches.wisefy; + + +import android.net.wifi.WifiConfiguration; +import com.isupatches.wisefy.callbacks.RemoveNetworkCallbacks; +import com.isupatches.wisefy.constants.WiseFyCodes; +import org.junit.Test; +import static com.isupatches.wisefy.base.TestUtils.TEST_SSID; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.fail; +import static org.mockito.ArgumentMatchers.anyInt; +import static org.mockito.ArgumentMatchers.anyString; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.never; +import static org.mockito.Mockito.timeout; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; + + +public class RemoveNetworkTests extends BaseAndroidJUnit4TestClass { + + @Test + public void noCallbacks_failure_nullSSIDParam() { + assertEquals(false, mWiseFy.removeNetwork(null)); + verify(mMockWiFiManager, never()).removeNetwork(anyInt()); + } + + @Test + public void noCallbacks_failure_missingPrerequisites() { + missingPrerequisite(); + assertEquals(false, mWiseFy.removeNetwork(TEST_SSID)); + verify(mMockWiFiManager, never()).removeNetwork(anyInt()); + } + + @Test + public void noCallbacks_failure_noSavedNetwork() { + WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); + mWiseFy.mWiseFySearch = mockWiseFySearch; + when(mockWiseFySearch.findSavedNetworkByRegex(anyString())).thenReturn(null); + + assertEquals(false, mWiseFy.removeNetwork(TEST_SSID)); + verify(mMockWiFiManager, never()).removeNetwork(anyInt()); + } + + @Test + public void noCallbacks_failure() { + WifiConfiguration wiFiConfiguration = new WifiConfiguration(); + wiFiConfiguration.SSID = TEST_SSID; + WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); + mWiseFy.mWiseFySearch = mockWiseFySearch; + when(mockWiseFySearch.findSavedNetworkByRegex(anyString())).thenReturn(wiFiConfiguration); + + when(mMockWiFiManager.removeNetwork(anyInt())).thenReturn(false); + + assertEquals(false, mWiseFy.removeNetwork(TEST_SSID)); + verify(mMockWiFiManager, timeout(VERIFICATION_TIMEOUT)).removeNetwork(anyInt()); + + } + + @Test + public void noCallbacks_success() { + WifiConfiguration wiFiConfiguration = new WifiConfiguration(); + wiFiConfiguration.SSID = TEST_SSID; + WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); + mWiseFy.mWiseFySearch = mockWiseFySearch; + when(mockWiseFySearch.findSavedNetworkByRegex(anyString())).thenReturn(wiFiConfiguration); + + when(mMockWiFiManager.removeNetwork(anyInt())).thenReturn(true); + + assertEquals(true, mWiseFy.removeNetwork(TEST_SSID)); + verify(mMockWiFiManager, timeout(VERIFICATION_TIMEOUT)).removeNetwork(anyInt()); + } + + @Test + public void callbacks_failure_nullSSIDParam() { + RemoveNetworkCallbacks mockCallbacks = mock(RemoveNetworkCallbacks.class); + mWiseFy.removeNetwork(null, mockCallbacks); + verify(mockCallbacks, timeout(3000)).removeNetworkWiseFyFailure(WiseFyCodes.MISSING_PARAMETER); + verify(mMockWiFiManager, never()).removeNetwork(anyInt()); + } + + @Test + public void callbacks_failure_nullSSIDParam_nullCallback() { + try { + mWiseFy.removeNetwork(null, null); + verify(mMockWiFiManager, never()).removeNetwork(anyInt()); + } catch (NullPointerException npe) { + fail(); + } + } + + @Test + public void callbacks_failure_missingPrerequisites() { + missingPrerequisite(); + RemoveNetworkCallbacks mockCallbacks = mock(RemoveNetworkCallbacks.class); + mWiseFy.removeNetwork(TEST_SSID, mockCallbacks); + verify(mockCallbacks, timeout(VERIFICATION_TIMEOUT)).removeNetworkWiseFyFailure(WiseFyCodes.MISSING_PREREQUISITE); + verify(mMockWiFiManager, never()).removeNetwork(anyInt()); + } + + @Test + public void callbacks_failure_missingPrerequisites_nullCallback() { + missingPrerequisite(); + try { + mWiseFy.removeNetwork(TEST_SSID, null); + verify(mMockWiFiManager, never()).removeNetwork(anyInt()); + } catch (NullPointerException npe) { + fail(); + } + } + + @Test + public void callbacks_failure_noSavedNetwork() { + WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); + mWiseFy.mWiseFySearch = mockWiseFySearch; + when(mockWiseFySearch.findSavedNetworkByRegex(anyString())).thenReturn(null); + + RemoveNetworkCallbacks mockCallbacks = mock(RemoveNetworkCallbacks.class); + mWiseFy.removeNetwork(TEST_SSID, mockCallbacks); + verify(mockCallbacks, timeout(VERIFICATION_TIMEOUT)).networkNotFoundToRemove(); + verify(mMockWiFiManager, never()).removeNetwork(anyInt()); + } + + @Test + public void callbacks_failure_noSavedNetwork_nullCallback() { + WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); + mWiseFy.mWiseFySearch = mockWiseFySearch; + when(mockWiseFySearch.findSavedNetworkByRegex(anyString())).thenReturn(null); + + try { + mWiseFy.removeNetwork(TEST_SSID, null); + verify(mMockWiFiManager, never()).removeNetwork(anyInt()); + } catch (NullPointerException npe) { + fail(); + } + } + + @Test + public void callbacks_failure() { + WifiConfiguration wiFiConfiguration = new WifiConfiguration(); + wiFiConfiguration.SSID = TEST_SSID; + WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); + mWiseFy.mWiseFySearch = mockWiseFySearch; + when(mockWiseFySearch.findSavedNetworkByRegex(anyString())).thenReturn(wiFiConfiguration); + + when(mMockWiFiManager.removeNetwork(anyInt())).thenReturn(false); + + RemoveNetworkCallbacks mockCallbacks = mock(RemoveNetworkCallbacks.class); + mWiseFy.removeNetwork(TEST_SSID, mockCallbacks); + verify(mockCallbacks, timeout(VERIFICATION_TIMEOUT)).failureRemovingNetwork(); + verify(mMockWiFiManager, timeout(VERIFICATION_TIMEOUT)).removeNetwork(anyInt()); + } + + @Test + public void callbacks_failure_nullCallback() { + WifiConfiguration wiFiConfiguration = new WifiConfiguration(); + wiFiConfiguration.SSID = TEST_SSID; + WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); + mWiseFy.mWiseFySearch = mockWiseFySearch; + when(mockWiseFySearch.findSavedNetworkByRegex(anyString())).thenReturn(wiFiConfiguration); + + when(mMockWiFiManager.removeNetwork(anyInt())).thenReturn(false); + + try { + mWiseFy.removeNetwork(TEST_SSID, null); + verify(mMockWiFiManager, never()).removeNetwork(anyInt()); + } catch (NullPointerException npe) { + fail(); + } + } + + @Test + public void callbacks_success() { + WifiConfiguration wiFiConfiguration = new WifiConfiguration(); + wiFiConfiguration.SSID = TEST_SSID; + WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); + mWiseFy.mWiseFySearch = mockWiseFySearch; + when(mockWiseFySearch.findSavedNetworkByRegex(anyString())).thenReturn(wiFiConfiguration); + + when(mMockWiFiManager.removeNetwork(anyInt())).thenReturn(true); + + RemoveNetworkCallbacks mockCallbacks = mock(RemoveNetworkCallbacks.class); + mWiseFy.removeNetwork(TEST_SSID, mockCallbacks); + verify(mockCallbacks, timeout(VERIFICATION_TIMEOUT)).networkRemoved(); + verify(mMockWiFiManager, timeout(VERIFICATION_TIMEOUT)).removeNetwork(anyInt()); + } + + @Test + public void callbacks_success_nullCallback() { + WifiConfiguration wiFiConfiguration = new WifiConfiguration(); + wiFiConfiguration.SSID = TEST_SSID; + WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); + mWiseFy.mWiseFySearch = mockWiseFySearch; + when(mockWiseFySearch.findSavedNetworkByRegex(anyString())).thenReturn(wiFiConfiguration); + + when(mMockWiFiManager.removeNetwork(anyInt())).thenReturn(true); + + try { + mWiseFy.removeNetwork(TEST_SSID, null); + verify(mMockWiFiManager, never()).removeNetwork(anyInt()); + } catch (NullPointerException npe) { + fail(); + } + } +} diff --git a/wisefy/src/androidTest/java/com/isupatches/wisefy/SearchForAccessPointTests.java b/wisefy/src/androidTest/java/com/isupatches/wisefy/SearchForAccessPointTests.java index 5f80d28a..b83f885f 100644 --- a/wisefy/src/androidTest/java/com/isupatches/wisefy/SearchForAccessPointTests.java +++ b/wisefy/src/androidTest/java/com/isupatches/wisefy/SearchForAccessPointTests.java @@ -1,272 +1,267 @@ -//package com.isupatches.wisefy; -// -// -//import android.net.wifi.ScanResult; -//import com.isupatches.wisefy.base.TestActivity; -//import com.isupatches.wisefy.callbacks.SearchForAccessPointCallbacks; -//import com.isupatches.wisefy.constants.WiseFyCodes; -//import org.junit.Test; -//import static com.isupatches.wisefy.base.TestUtils.TEST_SSID; -//import static junit.framework.Assert.assertEquals; -//import static junit.framework.Assert.fail; -//import static org.mockito.ArgumentMatchers.anyBoolean; -//import static org.mockito.ArgumentMatchers.anyInt; -//import static org.mockito.ArgumentMatchers.anyString; -//import static org.mockito.Mockito.mock; -//import static org.mockito.Mockito.timeout; -//import static org.mockito.Mockito.verify; -//import static org.mockito.Mockito.when; -// -// -//public class SearchForAccessPointTests extends BaseTestClass { -// -// public SearchForAccessPointTests() { -// super(TestActivity.class); -// } -// -// @Test -// public void noCallbacks_failure_filterDuplicates_false_nullSSIDParam() { -// assertEquals(null, mWiseFy.searchForAccessPoint(null, 1000, false)); -// } -// -// @Test -// public void noCallbacks_failure_filterDuplicates_true_nullSSIDParam() { -// assertEquals(null, mWiseFy.searchForAccessPoint(null, 1000, true)); -// } -// -// @Test -// public void noCallbacks_failure_filterDuplicates_false_missingPrerequisite() { -// missingPrerequisite(); -// assertEquals(null, mWiseFy.searchForAccessPoint(TEST_SSID, 1000, false)); -// } -// -// @Test -// public void noCallbacks_failure_filterDuplicates_true_missingPrerequisite() { -// missingPrerequisite(); -// assertEquals(null, mWiseFy.searchForAccessPoint(TEST_SSID, 1000, true)); -// } -// -// @Test -// public void noCallbacks_failure_filterDuplicates_false() { -// WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); -// mWiseFy.mWiseFySearch = mockWiseFySearch; -// when(mockWiseFySearch.findAccessPointByRegex(anyString(), anyInt(), anyBoolean())).thenReturn(null); -// -// assertEquals(null, mWiseFy.searchForAccessPoint(TEST_SSID, 1000, false)); -// } -// -// @Test -// public void noCallbacks_failure_filterDuplicates_true() { -// WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); -// mWiseFy.mWiseFySearch = mockWiseFySearch; -// when(mockWiseFySearch.findAccessPointByRegex(anyString(), anyInt(), anyBoolean())).thenReturn(null); -// -// assertEquals(null, mWiseFy.searchForAccessPoint(TEST_SSID, 1000, true)); -// } -// -// @Test -// public void noCallbacks_success_filterDuplicates_false() { -// ScanResult accessPoint = mock(ScanResult.class); -// accessPoint.SSID = TEST_SSID; -// -// WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); -// mWiseFy.mWiseFySearch = mockWiseFySearch; -// when(mockWiseFySearch.findAccessPointByRegex(anyString(), anyInt(), anyBoolean())).thenReturn(accessPoint); -// -// assertEquals(accessPoint, mWiseFy.searchForAccessPoint(TEST_SSID, 1000, false)); -// } -// -// @Test -// public void noCallbacks_success_filterDuplicates_true() { -// ScanResult accessPoint = mock(ScanResult.class); -// accessPoint.SSID = TEST_SSID; -// accessPoint.level = -35; -// -// WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); -// mWiseFy.mWiseFySearch = mockWiseFySearch; -// when(mockWiseFySearch.findAccessPointByRegex(anyString(), anyInt(), anyBoolean())).thenReturn(accessPoint); -// -// assertEquals(accessPoint, mWiseFy.searchForAccessPoint(TEST_SSID, 1000, true)); -// } -// -// @Test -// public void callbacks_failure_filterDuplicates_false_nullSSIDParam() { -// SearchForAccessPointCallbacks mockCallbacks = mock(SearchForAccessPointCallbacks.class); -// mWiseFy.searchForAccessPoint(null, 1000, false, mockCallbacks); -// verify(mockCallbacks, timeout(VERIFICATION_TIMEOUT)).searchForAccessPointWiseFyFailure(WiseFyCodes.MISSING_PARAMETER); -// } -// -// @Test -// public void callbacks_failure_filterDuplicates_false_nullSSIDParam_nullCallback() { -// try { -// mWiseFy.searchForAccessPoint(null, 1000, false, null); -// } catch (NullPointerException npe) { -// fail(); -// } -// } -// -// @Test -// public void callbacks_failure_filterDuplicates_true_nullSSIDParam() { -// SearchForAccessPointCallbacks mockCallbacks = mock(SearchForAccessPointCallbacks.class); -// mWiseFy.searchForAccessPoint(null, 1000, true, mockCallbacks); -// verify(mockCallbacks, timeout(VERIFICATION_TIMEOUT)).searchForAccessPointWiseFyFailure(WiseFyCodes.MISSING_PARAMETER); -// } -// -// @Test -// public void callbacks_failure_filterDuplicates_true_nullSSIDParam_nullCallback() { -// try { -// mWiseFy.searchForAccessPoint(null, 1000, true, null); -// } catch (NullPointerException npe) { -// fail(); -// } -// } -// -// @Test -// public void callbacks_failure_filterDuplicates_false_missingPrerequisite() { -// missingPrerequisite(); -// SearchForAccessPointCallbacks mockCallbacks = mock(SearchForAccessPointCallbacks.class); -// mWiseFy.searchForAccessPoint(TEST_SSID, 1000, false, mockCallbacks); -// verify(mockCallbacks, timeout(VERIFICATION_TIMEOUT)).searchForAccessPointWiseFyFailure(WiseFyCodes.MISSING_PREREQUISITE); -// } -// -// @Test -// public void callbacks_failure_filterDuplicates_false_missingPrerequisite_nullCallback() { -// missingPrerequisite(); -// try { -// mWiseFy.searchForAccessPoint(TEST_SSID, 1000, false, null); -// } catch (NullPointerException npe) { -// fail(); -// } -// } -// -// @Test -// public void callbacks_failure_filterDuplicates_true_missingPrerequisite() { -// missingPrerequisite(); -// SearchForAccessPointCallbacks mockCallbacks = mock(SearchForAccessPointCallbacks.class); -// mWiseFy.searchForAccessPoint(TEST_SSID, 1000, true, mockCallbacks); -// verify(mockCallbacks, timeout(VERIFICATION_TIMEOUT)).searchForAccessPointWiseFyFailure(WiseFyCodes.MISSING_PREREQUISITE); -// } -// -// @Test -// public void callbacks_failure_filterDuplicates_true_missingPrerequisite_nullCallback() { -// missingPrerequisite(); -// try { -// mWiseFy.searchForAccessPoint(TEST_SSID, 1000, true, null); -// } catch (NullPointerException npe) { -// fail(); -// } -// } -// -// @Test -// public void callbacks_failure_filterDuplicates_false() { -// WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); -// mWiseFy.mWiseFySearch = mockWiseFySearch; -// when(mockWiseFySearch.findAccessPointByRegex(anyString(), anyInt(), anyBoolean())).thenReturn(null); -// -// SearchForAccessPointCallbacks mockCallbacks = mock(SearchForAccessPointCallbacks.class); -// mWiseFy.searchForAccessPoint(TEST_SSID, 1000, false, mockCallbacks); -// verify(mockCallbacks, timeout(VERIFICATION_TIMEOUT)).accessPointNotFound(); -// } -// -// @Test -// public void callbacks_failure_filterDuplicates_false_nullCallback() { -// WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); -// mWiseFy.mWiseFySearch = mockWiseFySearch; -// when(mockWiseFySearch.findAccessPointByRegex(anyString(), anyInt(), anyBoolean())).thenReturn(null); -// -// try { -// mWiseFy.searchForAccessPoint(TEST_SSID, 1000, false, null); -// } catch (NullPointerException npe) { -// fail(); -// } -// } -// -// @Test -// public void callbacks_failure_filterDuplicates_true() { -// WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); -// mWiseFy.mWiseFySearch = mockWiseFySearch; -// when(mockWiseFySearch.findAccessPointByRegex(anyString(), anyInt(), anyBoolean())).thenReturn(null); -// -// SearchForAccessPointCallbacks mockCallbacks = mock(SearchForAccessPointCallbacks.class); -// mWiseFy.searchForAccessPoint(TEST_SSID, 1000, true, mockCallbacks); -// verify(mockCallbacks, timeout(VERIFICATION_TIMEOUT)).accessPointNotFound(); -// } -// -// -// @Test -// public void callbacks_failure_filterDuplicates_true_nullCallback() { -// WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); -// mWiseFy.mWiseFySearch = mockWiseFySearch; -// when(mockWiseFySearch.findAccessPointByRegex(anyString(), anyInt(), anyBoolean())).thenReturn(null); -// -// try { -// mWiseFy.searchForAccessPoint(TEST_SSID, 1000, true, null); -// } catch (NullPointerException npe) { -// fail(); -// } -// } -// -// @Test -// public void callbacks_success_filterDuplicates_false() { -// ScanResult accessPoint = mock(ScanResult.class); -// accessPoint.SSID = TEST_SSID; -// accessPoint.level = -35; -// -// WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); -// mWiseFy.mWiseFySearch = mockWiseFySearch; -// when(mockWiseFySearch.findAccessPointByRegex(anyString(), anyInt(), anyBoolean())).thenReturn(accessPoint); -// -// SearchForAccessPointCallbacks mockCallbacks = mock(SearchForAccessPointCallbacks.class); -// mWiseFy.searchForAccessPoint(TEST_SSID, 1000, false, mockCallbacks); -// verify(mockCallbacks, timeout(VERIFICATION_TIMEOUT)).accessPointFound(accessPoint); -// } -// -// @Test -// public void callbacks_success_filterDuplicates_false_nullCallback() { -// ScanResult accessPoint = mock(ScanResult.class); -// accessPoint.SSID = TEST_SSID; -// accessPoint.level = -35; -// -// WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); -// mWiseFy.mWiseFySearch = mockWiseFySearch; -// when(mockWiseFySearch.findAccessPointByRegex(anyString(), anyInt(), anyBoolean())).thenReturn(accessPoint); -// -// try { -// mWiseFy.searchForAccessPoint(TEST_SSID, 1000, false, null); -// } catch (NullPointerException npe) { -// fail(); -// } -// } -// -// @Test -// public void callbacks_success_filterDuplicates_true() { -// ScanResult accessPoint = mock(ScanResult.class); -// accessPoint.SSID = TEST_SSID; -// accessPoint.level = -35; -// -// WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); -// mWiseFy.mWiseFySearch = mockWiseFySearch; -// when(mockWiseFySearch.findAccessPointByRegex(anyString(), anyInt(), anyBoolean())).thenReturn(accessPoint); -// -// SearchForAccessPointCallbacks mockCallbacks = mock(SearchForAccessPointCallbacks.class); -// mWiseFy.searchForAccessPoint(TEST_SSID, 1000, true, mockCallbacks); -// verify(mockCallbacks, timeout(VERIFICATION_TIMEOUT)).accessPointFound(accessPoint); -// } -// -// @Test -// public void callbacks_success_filterDuplicates_true_nullCallback() { -// ScanResult accessPoint = mock(ScanResult.class); -// accessPoint.SSID = TEST_SSID; -// accessPoint.level = -35; -// -// WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); -// mWiseFy.mWiseFySearch = mockWiseFySearch; -// when(mockWiseFySearch.findAccessPointByRegex(anyString(), anyInt(), anyBoolean())).thenReturn(accessPoint); -// -// try { -// mWiseFy.searchForAccessPoint(TEST_SSID, 1000, true, null); -// } catch (NullPointerException npe) { -// fail(); -// } -// } -//} +package com.isupatches.wisefy; + + +import android.net.wifi.ScanResult; +import com.isupatches.wisefy.callbacks.SearchForAccessPointCallbacks; +import com.isupatches.wisefy.constants.WiseFyCodes; +import org.junit.Test; +import static com.isupatches.wisefy.base.TestUtils.TEST_SSID; +import static junit.framework.Assert.assertEquals; +import static junit.framework.Assert.fail; +import static org.mockito.ArgumentMatchers.anyBoolean; +import static org.mockito.ArgumentMatchers.anyInt; +import static org.mockito.ArgumentMatchers.anyString; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.timeout; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; + + +public class SearchForAccessPointTests extends BaseAndroidJUnit4TestClass{ + + @Test + public void noCallbacks_failure_filterDuplicates_false_nullSSIDParam() { + assertEquals(null, mWiseFy.searchForAccessPoint(null, 1000, false)); + } + + @Test + public void noCallbacks_failure_filterDuplicates_true_nullSSIDParam() { + assertEquals(null, mWiseFy.searchForAccessPoint(null, 1000, true)); + } + + @Test + public void noCallbacks_failure_filterDuplicates_false_missingPrerequisite() { + missingPrerequisite(); + assertEquals(null, mWiseFy.searchForAccessPoint(TEST_SSID, 1000, false)); + } + + @Test + public void noCallbacks_failure_filterDuplicates_true_missingPrerequisite() { + missingPrerequisite(); + assertEquals(null, mWiseFy.searchForAccessPoint(TEST_SSID, 1000, true)); + } + + @Test + public void noCallbacks_failure_filterDuplicates_false() { + WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); + mWiseFy.mWiseFySearch = mockWiseFySearch; + when(mockWiseFySearch.findAccessPointByRegex(anyString(), anyInt(), anyBoolean())).thenReturn(null); + + assertEquals(null, mWiseFy.searchForAccessPoint(TEST_SSID, 1000, false)); + } + + @Test + public void noCallbacks_failure_filterDuplicates_true() { + WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); + mWiseFy.mWiseFySearch = mockWiseFySearch; + when(mockWiseFySearch.findAccessPointByRegex(anyString(), anyInt(), anyBoolean())).thenReturn(null); + + assertEquals(null, mWiseFy.searchForAccessPoint(TEST_SSID, 1000, true)); + } + + @Test + public void noCallbacks_success_filterDuplicates_false() { + ScanResult accessPoint = mock(ScanResult.class); + accessPoint.SSID = TEST_SSID; + + WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); + mWiseFy.mWiseFySearch = mockWiseFySearch; + when(mockWiseFySearch.findAccessPointByRegex(anyString(), anyInt(), anyBoolean())).thenReturn(accessPoint); + + assertEquals(accessPoint, mWiseFy.searchForAccessPoint(TEST_SSID, 1000, false)); + } + + @Test + public void noCallbacks_success_filterDuplicates_true() { + ScanResult accessPoint = mock(ScanResult.class); + accessPoint.SSID = TEST_SSID; + accessPoint.level = -35; + + WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); + mWiseFy.mWiseFySearch = mockWiseFySearch; + when(mockWiseFySearch.findAccessPointByRegex(anyString(), anyInt(), anyBoolean())).thenReturn(accessPoint); + + assertEquals(accessPoint, mWiseFy.searchForAccessPoint(TEST_SSID, 1000, true)); + } + + @Test + public void callbacks_failure_filterDuplicates_false_nullSSIDParam() { + SearchForAccessPointCallbacks mockCallbacks = mock(SearchForAccessPointCallbacks.class); + mWiseFy.searchForAccessPoint(null, 1000, false, mockCallbacks); + verify(mockCallbacks, timeout(VERIFICATION_TIMEOUT)).searchForAccessPointWiseFyFailure(WiseFyCodes.MISSING_PARAMETER); + } + + @Test + public void callbacks_failure_filterDuplicates_false_nullSSIDParam_nullCallback() { + try { + mWiseFy.searchForAccessPoint(null, 1000, false, null); + } catch (NullPointerException npe) { + fail(); + } + } + + @Test + public void callbacks_failure_filterDuplicates_true_nullSSIDParam() { + SearchForAccessPointCallbacks mockCallbacks = mock(SearchForAccessPointCallbacks.class); + mWiseFy.searchForAccessPoint(null, 1000, true, mockCallbacks); + verify(mockCallbacks, timeout(VERIFICATION_TIMEOUT)).searchForAccessPointWiseFyFailure(WiseFyCodes.MISSING_PARAMETER); + } + + @Test + public void callbacks_failure_filterDuplicates_true_nullSSIDParam_nullCallback() { + try { + mWiseFy.searchForAccessPoint(null, 1000, true, null); + } catch (NullPointerException npe) { + fail(); + } + } + + @Test + public void callbacks_failure_filterDuplicates_false_missingPrerequisite() { + missingPrerequisite(); + SearchForAccessPointCallbacks mockCallbacks = mock(SearchForAccessPointCallbacks.class); + mWiseFy.searchForAccessPoint(TEST_SSID, 1000, false, mockCallbacks); + verify(mockCallbacks, timeout(VERIFICATION_TIMEOUT)).searchForAccessPointWiseFyFailure(WiseFyCodes.MISSING_PREREQUISITE); + } + + @Test + public void callbacks_failure_filterDuplicates_false_missingPrerequisite_nullCallback() { + missingPrerequisite(); + try { + mWiseFy.searchForAccessPoint(TEST_SSID, 1000, false, null); + } catch (NullPointerException npe) { + fail(); + } + } + + @Test + public void callbacks_failure_filterDuplicates_true_missingPrerequisite() { + missingPrerequisite(); + SearchForAccessPointCallbacks mockCallbacks = mock(SearchForAccessPointCallbacks.class); + mWiseFy.searchForAccessPoint(TEST_SSID, 1000, true, mockCallbacks); + verify(mockCallbacks, timeout(VERIFICATION_TIMEOUT)).searchForAccessPointWiseFyFailure(WiseFyCodes.MISSING_PREREQUISITE); + } + + @Test + public void callbacks_failure_filterDuplicates_true_missingPrerequisite_nullCallback() { + missingPrerequisite(); + try { + mWiseFy.searchForAccessPoint(TEST_SSID, 1000, true, null); + } catch (NullPointerException npe) { + fail(); + } + } + + @Test + public void callbacks_failure_filterDuplicates_false() { + WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); + mWiseFy.mWiseFySearch = mockWiseFySearch; + when(mockWiseFySearch.findAccessPointByRegex(anyString(), anyInt(), anyBoolean())).thenReturn(null); + + SearchForAccessPointCallbacks mockCallbacks = mock(SearchForAccessPointCallbacks.class); + mWiseFy.searchForAccessPoint(TEST_SSID, 1000, false, mockCallbacks); + verify(mockCallbacks, timeout(VERIFICATION_TIMEOUT)).accessPointNotFound(); + } + + @Test + public void callbacks_failure_filterDuplicates_false_nullCallback() { + WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); + mWiseFy.mWiseFySearch = mockWiseFySearch; + when(mockWiseFySearch.findAccessPointByRegex(anyString(), anyInt(), anyBoolean())).thenReturn(null); + + try { + mWiseFy.searchForAccessPoint(TEST_SSID, 1000, false, null); + } catch (NullPointerException npe) { + fail(); + } + } + + @Test + public void callbacks_failure_filterDuplicates_true() { + WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); + mWiseFy.mWiseFySearch = mockWiseFySearch; + when(mockWiseFySearch.findAccessPointByRegex(anyString(), anyInt(), anyBoolean())).thenReturn(null); + + SearchForAccessPointCallbacks mockCallbacks = mock(SearchForAccessPointCallbacks.class); + mWiseFy.searchForAccessPoint(TEST_SSID, 1000, true, mockCallbacks); + verify(mockCallbacks, timeout(VERIFICATION_TIMEOUT)).accessPointNotFound(); + } + + + @Test + public void callbacks_failure_filterDuplicates_true_nullCallback() { + WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); + mWiseFy.mWiseFySearch = mockWiseFySearch; + when(mockWiseFySearch.findAccessPointByRegex(anyString(), anyInt(), anyBoolean())).thenReturn(null); + + try { + mWiseFy.searchForAccessPoint(TEST_SSID, 1000, true, null); + } catch (NullPointerException npe) { + fail(); + } + } + + @Test + public void callbacks_success_filterDuplicates_false() { + ScanResult accessPoint = mock(ScanResult.class); + accessPoint.SSID = TEST_SSID; + accessPoint.level = -35; + + WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); + mWiseFy.mWiseFySearch = mockWiseFySearch; + when(mockWiseFySearch.findAccessPointByRegex(anyString(), anyInt(), anyBoolean())).thenReturn(accessPoint); + + SearchForAccessPointCallbacks mockCallbacks = mock(SearchForAccessPointCallbacks.class); + mWiseFy.searchForAccessPoint(TEST_SSID, 1000, false, mockCallbacks); + verify(mockCallbacks, timeout(VERIFICATION_TIMEOUT)).accessPointFound(accessPoint); + } + + @Test + public void callbacks_success_filterDuplicates_false_nullCallback() { + ScanResult accessPoint = mock(ScanResult.class); + accessPoint.SSID = TEST_SSID; + accessPoint.level = -35; + + WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); + mWiseFy.mWiseFySearch = mockWiseFySearch; + when(mockWiseFySearch.findAccessPointByRegex(anyString(), anyInt(), anyBoolean())).thenReturn(accessPoint); + + try { + mWiseFy.searchForAccessPoint(TEST_SSID, 1000, false, null); + } catch (NullPointerException npe) { + fail(); + } + } + + @Test + public void callbacks_success_filterDuplicates_true() { + ScanResult accessPoint = mock(ScanResult.class); + accessPoint.SSID = TEST_SSID; + accessPoint.level = -35; + + WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); + mWiseFy.mWiseFySearch = mockWiseFySearch; + when(mockWiseFySearch.findAccessPointByRegex(anyString(), anyInt(), anyBoolean())).thenReturn(accessPoint); + + SearchForAccessPointCallbacks mockCallbacks = mock(SearchForAccessPointCallbacks.class); + mWiseFy.searchForAccessPoint(TEST_SSID, 1000, true, mockCallbacks); + verify(mockCallbacks, timeout(VERIFICATION_TIMEOUT)).accessPointFound(accessPoint); + } + + @Test + public void callbacks_success_filterDuplicates_true_nullCallback() { + ScanResult accessPoint = mock(ScanResult.class); + accessPoint.SSID = TEST_SSID; + accessPoint.level = -35; + + WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); + mWiseFy.mWiseFySearch = mockWiseFySearch; + when(mockWiseFySearch.findAccessPointByRegex(anyString(), anyInt(), anyBoolean())).thenReturn(accessPoint); + + try { + mWiseFy.searchForAccessPoint(TEST_SSID, 1000, true, null); + } catch (NullPointerException npe) { + fail(); + } + } +} diff --git a/wisefy/src/androidTest/java/com/isupatches/wisefy/SearchForAccessPointsTests.java b/wisefy/src/androidTest/java/com/isupatches/wisefy/SearchForAccessPointsTests.java index 9b4eecd6..7a073b3a 100644 --- a/wisefy/src/androidTest/java/com/isupatches/wisefy/SearchForAccessPointsTests.java +++ b/wisefy/src/androidTest/java/com/isupatches/wisefy/SearchForAccessPointsTests.java @@ -1,286 +1,282 @@ -//package com.isupatches.wisefy; -// -// -//import android.net.wifi.ScanResult; -//import com.isupatches.wisefy.base.TestActivity; -//import com.isupatches.wisefy.callbacks.SearchForAccessPointsCallbacks; -//import com.isupatches.wisefy.constants.WiseFyCodes; -//import org.junit.Test; -//import java.util.ArrayList; -//import java.util.List; -//import static com.isupatches.wisefy.base.TestUtils.TEST_SSID; -//import static junit.framework.Assert.assertEquals; -//import static junit.framework.Assert.fail; -//import static org.mockito.ArgumentMatchers.anyBoolean; -//import static org.mockito.ArgumentMatchers.anyString; -//import static org.mockito.Mockito.mock; -//import static org.mockito.Mockito.timeout; -//import static org.mockito.Mockito.verify; -//import static org.mockito.Mockito.when; -// -// -//public class SearchForAccessPointsTests extends BaseTestClass { -// -// public SearchForAccessPointsTests() { -// super(TestActivity.class); -// } -// -// @Test -// public void noCallbacks_failure_filterDuplicates_false_nullSSIDParam() { -// assertEquals(null, mWiseFy.searchForAccessPoints(null, false)); -// } -// -// @Test -// public void noCallbacks_failure_filterDuplicates_true_nullSSIDParam() { -// assertEquals(null, mWiseFy.searchForAccessPoints(null, true)); -// } -// -// @Test -// public void noCallbacks_failure_filterDuplicates_false_missingPrerequisite() { -// missingPrerequisite(); -// assertEquals(null, mWiseFy.searchForAccessPoints(TEST_SSID, false)); -// } -// -// @Test -// public void noCallbacks_failure_filterDuplicates_true_missingPrerequisite() { -// missingPrerequisite(); -// assertEquals(null, mWiseFy.searchForAccessPoints(TEST_SSID, true)); -// } -// -// @Test -// public void noCallbacks_failure_filterDuplicates_false() { -// WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); -// mWiseFy.mWiseFySearch = mockWiseFySearch; -// when(mockWiseFySearch.findAccessPointsMatchingRegex(anyString(), anyBoolean())).thenReturn(null); -// -// assertEquals(null, mWiseFy.searchForAccessPoints(TEST_SSID, false)); -// } -// -// @Test -// public void noCallbacks_failure_filterDuplicates_true() { -// WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); -// mWiseFy.mWiseFySearch = mockWiseFySearch; -// when(mockWiseFySearch.findAccessPointsMatchingRegex(anyString(), anyBoolean())).thenReturn(null); -// -// assertEquals(null, mWiseFy.searchForAccessPoints(TEST_SSID, true)); -// } -// -// @Test -// public void noCallbacks_success_filterDuplicates_false() { -// List accessPoints = new ArrayList<>(); -// ScanResult accessPoint = mock(ScanResult.class); -// accessPoint.SSID = TEST_SSID; -// accessPoint.level = -35; -// accessPoints.add(accessPoint); -// -// WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); -// mWiseFy.mWiseFySearch = mockWiseFySearch; -// when(mockWiseFySearch.findAccessPointsMatchingRegex(anyString(), anyBoolean())).thenReturn(accessPoints); -// -// assertEquals(accessPoints, mWiseFy.searchForAccessPoints(TEST_SSID, false)); -// } -// -// @Test -// public void noCallbacks_success_filterDuplicates_true() { -// List accessPoints = new ArrayList<>(); -// ScanResult accessPoint = mock(ScanResult.class); -// accessPoint.SSID = TEST_SSID; -// accessPoint.level = -35; -// accessPoints.add(accessPoint); -// -// WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); -// mWiseFy.mWiseFySearch = mockWiseFySearch; -// when(mockWiseFySearch.findAccessPointsMatchingRegex(anyString(), anyBoolean())).thenReturn(accessPoints); -// -// assertEquals(accessPoints, mWiseFy.searchForAccessPoints(TEST_SSID, true)); -// } -// -// @Test -// public void callbacks_failure_filterDuplicates_false_nullSSIDParam() { -// SearchForAccessPointsCallbacks mockCallbacks = mock(SearchForAccessPointsCallbacks.class); -// mWiseFy.searchForAccessPoints(null, false, mockCallbacks); -// verify(mockCallbacks, timeout(VERIFICATION_TIMEOUT)).searchForAccessPointsWiseFyFailure(WiseFyCodes.MISSING_PARAMETER); -// } -// -// @Test -// public void callbacks_failure_filterDuplicates_false_nullSSIDParam_nullCallback() { -// try { -// mWiseFy.searchForAccessPoints(null, false, null); -// } catch (NullPointerException npe) { -// fail(); -// } -// } -// -// @Test -// public void callbacks_failure_filterDuplicates_true_nullSSIDParam() { -// SearchForAccessPointsCallbacks mockCallbacks = mock(SearchForAccessPointsCallbacks.class); -// mWiseFy.searchForAccessPoints(null, true, mockCallbacks); -// verify(mockCallbacks, timeout(VERIFICATION_TIMEOUT)).searchForAccessPointsWiseFyFailure(WiseFyCodes.MISSING_PARAMETER); -// } -// -// @Test -// public void callbacks_failure_filterDuplicates_true_nullSSIDParam_nullCallback() { -// try { -// mWiseFy.searchForAccessPoints(null, true, null); -// } catch (NullPointerException npe) { -// fail(); -// } -// } -// -// @Test -// public void callbacks_failure_filterDuplicates_false_missingPrerequisite() { -// missingPrerequisite(); -// SearchForAccessPointsCallbacks mockCallbacks = mock(SearchForAccessPointsCallbacks.class); -// mWiseFy.searchForAccessPoints(TEST_SSID, false, mockCallbacks); -// verify(mockCallbacks, timeout(VERIFICATION_TIMEOUT)).searchForAccessPointsWiseFyFailure(WiseFyCodes.MISSING_PREREQUISITE); -// } -// -// @Test -// public void callbacks_failure_filterDuplicates_false_missingPrerequisite_nullCallback() { -// missingPrerequisite(); -// try { -// mWiseFy.searchForAccessPoints(TEST_SSID, false, null); -// } catch (NullPointerException npe) { -// fail(); -// } -// } -// -// @Test -// public void callbacks_failure_filterDuplicates_true_missingPrerequisite() { -// missingPrerequisite(); -// SearchForAccessPointsCallbacks mockCallbacks = mock(SearchForAccessPointsCallbacks.class); -// mWiseFy.searchForAccessPoints(TEST_SSID, true, mockCallbacks); -// verify(mockCallbacks, timeout(VERIFICATION_TIMEOUT)).searchForAccessPointsWiseFyFailure(WiseFyCodes.MISSING_PREREQUISITE); -// } -// -// @Test -// public void callbacks_failure_filterDuplicates_true_missingPrerequisite_nullCallback() { -// missingPrerequisite(); -// try { -// mWiseFy.searchForAccessPoints(TEST_SSID, true, null); -// } catch (NullPointerException npe) { -// fail(); -// } -// } -// -// @Test -// public void callbacks_failure_filterDuplicates_false() { -// WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); -// mWiseFy.mWiseFySearch = mockWiseFySearch; -// when(mockWiseFySearch.findAccessPointsMatchingRegex(anyString(), anyBoolean())).thenReturn(null); -// -// SearchForAccessPointsCallbacks mockCallbacks = mock(SearchForAccessPointsCallbacks.class); -// mWiseFy.searchForAccessPoints(TEST_SSID, false, mockCallbacks); -// verify(mockCallbacks, timeout(VERIFICATION_TIMEOUT)).noAccessPointsFound(); -// } -// -// @Test -// public void callbacks_failure_filterDuplicates_false_nullCallback() { -// WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); -// mWiseFy.mWiseFySearch = mockWiseFySearch; -// when(mockWiseFySearch.findAccessPointsMatchingRegex(anyString(), anyBoolean())).thenReturn(null); -// -// try { -// mWiseFy.searchForAccessPoints(TEST_SSID, false, null); -// } catch (NullPointerException npe) { -// fail(); -// } -// } -// -// @Test -// public void callbacks_failure_filterDuplicates_true() { -// WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); -// mWiseFy.mWiseFySearch = mockWiseFySearch; -// when(mockWiseFySearch.findAccessPointsMatchingRegex(anyString(), anyBoolean())).thenReturn(null); -// -// SearchForAccessPointsCallbacks mockCallbacks = mock(SearchForAccessPointsCallbacks.class); -// mWiseFy.searchForAccessPoints(TEST_SSID, true, mockCallbacks); -// verify(mockCallbacks, timeout(VERIFICATION_TIMEOUT)).noAccessPointsFound(); -// } -// -// -// @Test -// public void callbacks_failure_filterDuplicates_true_nullCallback() { -// WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); -// mWiseFy.mWiseFySearch = mockWiseFySearch; -// when(mockWiseFySearch.findAccessPointsMatchingRegex(anyString(), anyBoolean())).thenReturn(null); -// -// try { -// mWiseFy.searchForAccessPoints(TEST_SSID, true, null); -// } catch (NullPointerException npe) { -// fail(); -// } -// } -// -// @Test -// public void callbacks_success_filterDuplicates_false() { -// List accessPoints = new ArrayList<>(); -// ScanResult accessPoint = mock(ScanResult.class); -// accessPoint.SSID = TEST_SSID; -// accessPoint.level = -35; -// accessPoints.add(accessPoint); -// -// WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); -// mWiseFy.mWiseFySearch = mockWiseFySearch; -// when(mockWiseFySearch.findAccessPointsMatchingRegex(anyString(), anyBoolean())).thenReturn(accessPoints); -// -// SearchForAccessPointsCallbacks mockCallbacks = mock(SearchForAccessPointsCallbacks.class); -// mWiseFy.searchForAccessPoints(TEST_SSID, true, mockCallbacks); -// verify(mockCallbacks, timeout(VERIFICATION_TIMEOUT)).foundAccessPoints(accessPoints); -// } -// -// @Test -// public void callbacks_success_filterDuplicates_false_nullCallback() { -// List accessPoints = new ArrayList<>(); -// ScanResult accessPoint = mock(ScanResult.class); -// accessPoint.SSID = TEST_SSID; -// accessPoint.level = -35; -// accessPoints.add(accessPoint); -// -// WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); -// mWiseFy.mWiseFySearch = mockWiseFySearch; -// when(mockWiseFySearch.findAccessPointsMatchingRegex(anyString(), anyBoolean())).thenReturn(accessPoints); -// -// try { -// mWiseFy.searchForAccessPoints(TEST_SSID, true, null); -// } catch (NullPointerException npe) { -// fail(); -// } -// } -// -// @Test -// public void callbacks_success_filterDuplicates_true() { -// List accessPoints = new ArrayList<>(); -// ScanResult accessPoint = mock(ScanResult.class); -// accessPoint.SSID = TEST_SSID; -// accessPoint.level = -35; -// accessPoints.add(accessPoint); -// -// WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); -// mWiseFy.mWiseFySearch = mockWiseFySearch; -// when(mockWiseFySearch.findAccessPointsMatchingRegex(anyString(), anyBoolean())).thenReturn(accessPoints); -// -// SearchForAccessPointsCallbacks mockCallbacks = mock(SearchForAccessPointsCallbacks.class); -// mWiseFy.searchForAccessPoints(TEST_SSID, true, mockCallbacks); -// verify(mockCallbacks, timeout(VERIFICATION_TIMEOUT)).foundAccessPoints(accessPoints); -// } -// -// @Test -// public void callbacks_success_filterDuplicates_true_nullCallback() { -// List accessPoints = new ArrayList<>(); -// ScanResult accessPoint = mock(ScanResult.class); -// accessPoint.SSID = TEST_SSID; -// accessPoint.level = -35; -// accessPoints.add(accessPoint); -// -// WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); -// mWiseFy.mWiseFySearch = mockWiseFySearch; -// when(mockWiseFySearch.findAccessPointsMatchingRegex(anyString(), anyBoolean())).thenReturn(accessPoints); -// -// try { -// mWiseFy.searchForAccessPoints(TEST_SSID, true, null); -// } catch (NullPointerException npe) { -// fail(); -// } -// } -//} +package com.isupatches.wisefy; + + +import android.net.wifi.ScanResult; +import com.isupatches.wisefy.base.TestActivity; +import com.isupatches.wisefy.callbacks.SearchForAccessPointsCallbacks; +import com.isupatches.wisefy.constants.WiseFyCodes; +import org.junit.Test; +import java.util.ArrayList; +import java.util.List; +import static com.isupatches.wisefy.base.TestUtils.TEST_SSID; +import static junit.framework.Assert.assertEquals; +import static junit.framework.Assert.fail; +import static org.mockito.ArgumentMatchers.anyBoolean; +import static org.mockito.ArgumentMatchers.anyString; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.timeout; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; + + +public class SearchForAccessPointsTests extends BaseAndroidJUnit4TestClass { + + @Test + public void noCallbacks_failure_filterDuplicates_false_nullSSIDParam() { + assertEquals(null, mWiseFy.searchForAccessPoints(null, false)); + } + + @Test + public void noCallbacks_failure_filterDuplicates_true_nullSSIDParam() { + assertEquals(null, mWiseFy.searchForAccessPoints(null, true)); + } + + @Test + public void noCallbacks_failure_filterDuplicates_false_missingPrerequisite() { + missingPrerequisite(); + assertEquals(null, mWiseFy.searchForAccessPoints(TEST_SSID, false)); + } + + @Test + public void noCallbacks_failure_filterDuplicates_true_missingPrerequisite() { + missingPrerequisite(); + assertEquals(null, mWiseFy.searchForAccessPoints(TEST_SSID, true)); + } + + @Test + public void noCallbacks_failure_filterDuplicates_false() { + WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); + mWiseFy.mWiseFySearch = mockWiseFySearch; + when(mockWiseFySearch.findAccessPointsMatchingRegex(anyString(), anyBoolean())).thenReturn(null); + + assertEquals(null, mWiseFy.searchForAccessPoints(TEST_SSID, false)); + } + + @Test + public void noCallbacks_failure_filterDuplicates_true() { + WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); + mWiseFy.mWiseFySearch = mockWiseFySearch; + when(mockWiseFySearch.findAccessPointsMatchingRegex(anyString(), anyBoolean())).thenReturn(null); + + assertEquals(null, mWiseFy.searchForAccessPoints(TEST_SSID, true)); + } + + @Test + public void noCallbacks_success_filterDuplicates_false() { + List accessPoints = new ArrayList<>(); + ScanResult accessPoint = mock(ScanResult.class); + accessPoint.SSID = TEST_SSID; + accessPoint.level = -35; + accessPoints.add(accessPoint); + + WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); + mWiseFy.mWiseFySearch = mockWiseFySearch; + when(mockWiseFySearch.findAccessPointsMatchingRegex(anyString(), anyBoolean())).thenReturn(accessPoints); + + assertEquals(accessPoints, mWiseFy.searchForAccessPoints(TEST_SSID, false)); + } + + @Test + public void noCallbacks_success_filterDuplicates_true() { + List accessPoints = new ArrayList<>(); + ScanResult accessPoint = mock(ScanResult.class); + accessPoint.SSID = TEST_SSID; + accessPoint.level = -35; + accessPoints.add(accessPoint); + + WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); + mWiseFy.mWiseFySearch = mockWiseFySearch; + when(mockWiseFySearch.findAccessPointsMatchingRegex(anyString(), anyBoolean())).thenReturn(accessPoints); + + assertEquals(accessPoints, mWiseFy.searchForAccessPoints(TEST_SSID, true)); + } + + @Test + public void callbacks_failure_filterDuplicates_false_nullSSIDParam() { + SearchForAccessPointsCallbacks mockCallbacks = mock(SearchForAccessPointsCallbacks.class); + mWiseFy.searchForAccessPoints(null, false, mockCallbacks); + verify(mockCallbacks, timeout(VERIFICATION_TIMEOUT)).searchForAccessPointsWiseFyFailure(WiseFyCodes.MISSING_PARAMETER); + } + + @Test + public void callbacks_failure_filterDuplicates_false_nullSSIDParam_nullCallback() { + try { + mWiseFy.searchForAccessPoints(null, false, null); + } catch (NullPointerException npe) { + fail(); + } + } + + @Test + public void callbacks_failure_filterDuplicates_true_nullSSIDParam() { + SearchForAccessPointsCallbacks mockCallbacks = mock(SearchForAccessPointsCallbacks.class); + mWiseFy.searchForAccessPoints(null, true, mockCallbacks); + verify(mockCallbacks, timeout(VERIFICATION_TIMEOUT)).searchForAccessPointsWiseFyFailure(WiseFyCodes.MISSING_PARAMETER); + } + + @Test + public void callbacks_failure_filterDuplicates_true_nullSSIDParam_nullCallback() { + try { + mWiseFy.searchForAccessPoints(null, true, null); + } catch (NullPointerException npe) { + fail(); + } + } + + @Test + public void callbacks_failure_filterDuplicates_false_missingPrerequisite() { + missingPrerequisite(); + SearchForAccessPointsCallbacks mockCallbacks = mock(SearchForAccessPointsCallbacks.class); + mWiseFy.searchForAccessPoints(TEST_SSID, false, mockCallbacks); + verify(mockCallbacks, timeout(VERIFICATION_TIMEOUT)).searchForAccessPointsWiseFyFailure(WiseFyCodes.MISSING_PREREQUISITE); + } + + @Test + public void callbacks_failure_filterDuplicates_false_missingPrerequisite_nullCallback() { + missingPrerequisite(); + try { + mWiseFy.searchForAccessPoints(TEST_SSID, false, null); + } catch (NullPointerException npe) { + fail(); + } + } + + @Test + public void callbacks_failure_filterDuplicates_true_missingPrerequisite() { + missingPrerequisite(); + SearchForAccessPointsCallbacks mockCallbacks = mock(SearchForAccessPointsCallbacks.class); + mWiseFy.searchForAccessPoints(TEST_SSID, true, mockCallbacks); + verify(mockCallbacks, timeout(VERIFICATION_TIMEOUT)).searchForAccessPointsWiseFyFailure(WiseFyCodes.MISSING_PREREQUISITE); + } + + @Test + public void callbacks_failure_filterDuplicates_true_missingPrerequisite_nullCallback() { + missingPrerequisite(); + try { + mWiseFy.searchForAccessPoints(TEST_SSID, true, null); + } catch (NullPointerException npe) { + fail(); + } + } + + @Test + public void callbacks_failure_filterDuplicates_false() { + WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); + mWiseFy.mWiseFySearch = mockWiseFySearch; + when(mockWiseFySearch.findAccessPointsMatchingRegex(anyString(), anyBoolean())).thenReturn(null); + + SearchForAccessPointsCallbacks mockCallbacks = mock(SearchForAccessPointsCallbacks.class); + mWiseFy.searchForAccessPoints(TEST_SSID, false, mockCallbacks); + verify(mockCallbacks, timeout(VERIFICATION_TIMEOUT)).noAccessPointsFound(); + } + + @Test + public void callbacks_failure_filterDuplicates_false_nullCallback() { + WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); + mWiseFy.mWiseFySearch = mockWiseFySearch; + when(mockWiseFySearch.findAccessPointsMatchingRegex(anyString(), anyBoolean())).thenReturn(null); + + try { + mWiseFy.searchForAccessPoints(TEST_SSID, false, null); + } catch (NullPointerException npe) { + fail(); + } + } + + @Test + public void callbacks_failure_filterDuplicates_true() { + WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); + mWiseFy.mWiseFySearch = mockWiseFySearch; + when(mockWiseFySearch.findAccessPointsMatchingRegex(anyString(), anyBoolean())).thenReturn(null); + + SearchForAccessPointsCallbacks mockCallbacks = mock(SearchForAccessPointsCallbacks.class); + mWiseFy.searchForAccessPoints(TEST_SSID, true, mockCallbacks); + verify(mockCallbacks, timeout(VERIFICATION_TIMEOUT)).noAccessPointsFound(); + } + + + @Test + public void callbacks_failure_filterDuplicates_true_nullCallback() { + WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); + mWiseFy.mWiseFySearch = mockWiseFySearch; + when(mockWiseFySearch.findAccessPointsMatchingRegex(anyString(), anyBoolean())).thenReturn(null); + + try { + mWiseFy.searchForAccessPoints(TEST_SSID, true, null); + } catch (NullPointerException npe) { + fail(); + } + } + + @Test + public void callbacks_success_filterDuplicates_false() { + List accessPoints = new ArrayList<>(); + ScanResult accessPoint = mock(ScanResult.class); + accessPoint.SSID = TEST_SSID; + accessPoint.level = -35; + accessPoints.add(accessPoint); + + WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); + mWiseFy.mWiseFySearch = mockWiseFySearch; + when(mockWiseFySearch.findAccessPointsMatchingRegex(anyString(), anyBoolean())).thenReturn(accessPoints); + + SearchForAccessPointsCallbacks mockCallbacks = mock(SearchForAccessPointsCallbacks.class); + mWiseFy.searchForAccessPoints(TEST_SSID, true, mockCallbacks); + verify(mockCallbacks, timeout(VERIFICATION_TIMEOUT)).foundAccessPoints(accessPoints); + } + + @Test + public void callbacks_success_filterDuplicates_false_nullCallback() { + List accessPoints = new ArrayList<>(); + ScanResult accessPoint = mock(ScanResult.class); + accessPoint.SSID = TEST_SSID; + accessPoint.level = -35; + accessPoints.add(accessPoint); + + WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); + mWiseFy.mWiseFySearch = mockWiseFySearch; + when(mockWiseFySearch.findAccessPointsMatchingRegex(anyString(), anyBoolean())).thenReturn(accessPoints); + + try { + mWiseFy.searchForAccessPoints(TEST_SSID, true, null); + } catch (NullPointerException npe) { + fail(); + } + } + + @Test + public void callbacks_success_filterDuplicates_true() { + List accessPoints = new ArrayList<>(); + ScanResult accessPoint = mock(ScanResult.class); + accessPoint.SSID = TEST_SSID; + accessPoint.level = -35; + accessPoints.add(accessPoint); + + WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); + mWiseFy.mWiseFySearch = mockWiseFySearch; + when(mockWiseFySearch.findAccessPointsMatchingRegex(anyString(), anyBoolean())).thenReturn(accessPoints); + + SearchForAccessPointsCallbacks mockCallbacks = mock(SearchForAccessPointsCallbacks.class); + mWiseFy.searchForAccessPoints(TEST_SSID, true, mockCallbacks); + verify(mockCallbacks, timeout(VERIFICATION_TIMEOUT)).foundAccessPoints(accessPoints); + } + + @Test + public void callbacks_success_filterDuplicates_true_nullCallback() { + List accessPoints = new ArrayList<>(); + ScanResult accessPoint = mock(ScanResult.class); + accessPoint.SSID = TEST_SSID; + accessPoint.level = -35; + accessPoints.add(accessPoint); + + WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); + mWiseFy.mWiseFySearch = mockWiseFySearch; + when(mockWiseFySearch.findAccessPointsMatchingRegex(anyString(), anyBoolean())).thenReturn(accessPoints); + + try { + mWiseFy.searchForAccessPoints(TEST_SSID, true, null); + } catch (NullPointerException npe) { + fail(); + } + } +} diff --git a/wisefy/src/androidTest/java/com/isupatches/wisefy/SearchForSSIDTests.java b/wisefy/src/androidTest/java/com/isupatches/wisefy/SearchForSSIDTests.java index b1202443..947b92df 100644 --- a/wisefy/src/androidTest/java/com/isupatches/wisefy/SearchForSSIDTests.java +++ b/wisefy/src/androidTest/java/com/isupatches/wisefy/SearchForSSIDTests.java @@ -1,149 +1,144 @@ -//package com.isupatches.wisefy; -// -// -//import android.net.wifi.ScanResult; -//import com.isupatches.wisefy.base.TestActivity; -//import com.isupatches.wisefy.callbacks.SearchForSSIDCallbacks; -//import com.isupatches.wisefy.constants.WiseFyCodes; -//import org.junit.Test; -//import static com.isupatches.wisefy.base.TestUtils.TEST_SSID; -//import static junit.framework.Assert.fail; -//import static org.junit.Assert.assertEquals; -//import static org.mockito.ArgumentMatchers.anyBoolean; -//import static org.mockito.ArgumentMatchers.anyInt; -//import static org.mockito.ArgumentMatchers.anyString; -//import static org.mockito.Mockito.mock; -//import static org.mockito.Mockito.timeout; -//import static org.mockito.Mockito.verify; -//import static org.mockito.Mockito.when; -// -// -//public class SearchForSSIDTests extends BaseTestClass { -// -// public SearchForSSIDTests() { -// super(TestActivity.class); -// } -// -// @Test -// public void noCallbacks_failure_nullSSIDParam() { -// assertEquals(null, mWiseFy.searchForSSID(null, 1000)); -// } -// -// @Test -// public void noCallbacks_failure_missingPrerequisite() { -// missingPrerequisite(); -// assertEquals(null, mWiseFy.searchForSSID(TEST_SSID, 1000)); -// } -// -// @Test -// public void noCallbacks_failure() { -// WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); -// mWiseFy.mWiseFySearch = mockWiseFySearch; -// when(mockWiseFySearch.findAccessPointByRegex(anyString(), anyInt(), anyBoolean())).thenReturn(null); -// -// assertEquals(null, mWiseFy.searchForSSID(TEST_SSID, 1000)); -// } -// -// @Test -// public void noCallbacks_success() { -// ScanResult accessPoint = mock(ScanResult.class); -// accessPoint.SSID = TEST_SSID; -// accessPoint.level = -35; -// -// WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); -// mWiseFy.mWiseFySearch = mockWiseFySearch; -// when(mockWiseFySearch.findAccessPointByRegex(anyString(), anyInt(), anyBoolean())).thenReturn(accessPoint); -// -// assertEquals(TEST_SSID, mWiseFy.searchForSSID(TEST_SSID, 1000)); -// } -// -// @Test -// public void callbacks_failure_nullSSIDParam() { -// SearchForSSIDCallbacks mockCallbacks = mock(SearchForSSIDCallbacks.class); -// mWiseFy.searchForSSID(null, 1000, mockCallbacks); -// verify(mockCallbacks, timeout(VERIFICATION_TIMEOUT)).searchForSSIDWiseFyFailure(WiseFyCodes.MISSING_PARAMETER); -// } -// -// @Test -// public void callbacks_failure_nullSSIDParam_nullCallback() { -// try { -// mWiseFy.searchForSSID(null, 1000, null); -// } catch (NullPointerException npe) { -// fail(); -// } -// } -// -// @Test -// public void callbacks_failure_missingPrerequisite() { -// missingPrerequisite(); -// SearchForSSIDCallbacks mockCallbacks = mock(SearchForSSIDCallbacks.class); -// mWiseFy.searchForSSID(TEST_SSID, 1000, mockCallbacks); -// verify(mockCallbacks, timeout(VERIFICATION_TIMEOUT)).searchForSSIDWiseFyFailure(WiseFyCodes.MISSING_PREREQUISITE); -// } -// -// @Test -// public void callbacks_failure_missingPrerequisite_nullCallback() { -// missingPrerequisite(); -// try { -// mWiseFy.searchForSSID(TEST_SSID, 1000, null); -// } catch (NullPointerException npe) { -// fail(); -// } -// } -// -// @Test -// public void callbacks_failure() { -// WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); -// mWiseFy.mWiseFySearch = mockWiseFySearch; -// when(mockWiseFySearch.findAccessPointByRegex(anyString(), anyInt(), anyBoolean())).thenReturn(null); -// -// SearchForSSIDCallbacks mockCallbacks = mock(SearchForSSIDCallbacks.class); -// mWiseFy.searchForSSID(TEST_SSID, 1000, mockCallbacks); -// verify(mockCallbacks, timeout(VERIFICATION_TIMEOUT)).ssidNotFound(); -// } -// -// -// @Test -// public void callbacks_failure_nullCallback() { -// WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); -// mWiseFy.mWiseFySearch = mockWiseFySearch; -// when(mockWiseFySearch.findAccessPointByRegex(anyString(), anyInt(), anyBoolean())).thenReturn(null); -// -// try { -// mWiseFy.searchForSSID(TEST_SSID, 1000, null); -// } catch (NullPointerException npe) { -// fail(); -// } -// } -// -// @Test -// public void callbacks_success() { -// ScanResult accessPoint = mock(ScanResult.class); -// accessPoint.SSID = TEST_SSID; -// accessPoint.level = -35; -// -// WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); -// mWiseFy.mWiseFySearch = mockWiseFySearch; -// when(mockWiseFySearch.findAccessPointByRegex(anyString(), anyInt(), anyBoolean())).thenReturn(accessPoint); -// -// SearchForSSIDCallbacks mockCallbacks = mock(SearchForSSIDCallbacks.class); -// mWiseFy.searchForSSID(TEST_SSID, 1000, mockCallbacks); -// verify(mockCallbacks, timeout(VERIFICATION_TIMEOUT)).ssidFound(TEST_SSID); -// } -// -// @Test -// public void callbacks_success_nullCallback() { -// ScanResult accessPoint = mock(ScanResult.class); -// accessPoint.SSID = TEST_SSID; -// -// WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); -// mWiseFy.mWiseFySearch = mockWiseFySearch; -// when(mockWiseFySearch.findAccessPointByRegex(anyString(), anyInt(), anyBoolean())).thenReturn(accessPoint); -// -// try { -// mWiseFy.searchForSSID(TEST_SSID, 1000, null); -// } catch (NullPointerException npe) { -// fail(); -// } -// } -//} +package com.isupatches.wisefy; + + +import android.net.wifi.ScanResult; +import com.isupatches.wisefy.callbacks.SearchForSSIDCallbacks; +import com.isupatches.wisefy.constants.WiseFyCodes; +import org.junit.Test; +import static com.isupatches.wisefy.base.TestUtils.TEST_SSID; +import static junit.framework.Assert.fail; +import static org.junit.Assert.assertEquals; +import static org.mockito.ArgumentMatchers.anyBoolean; +import static org.mockito.ArgumentMatchers.anyInt; +import static org.mockito.ArgumentMatchers.anyString; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.timeout; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; + + +public class SearchForSSIDTests extends BaseAndroidJUnit4TestClass { + + @Test + public void noCallbacks_failure_nullSSIDParam() { + assertEquals(null, mWiseFy.searchForSSID(null, 1000)); + } + + @Test + public void noCallbacks_failure_missingPrerequisite() { + missingPrerequisite(); + assertEquals(null, mWiseFy.searchForSSID(TEST_SSID, 1000)); + } + + @Test + public void noCallbacks_failure() { + WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); + mWiseFy.mWiseFySearch = mockWiseFySearch; + when(mockWiseFySearch.findAccessPointByRegex(anyString(), anyInt(), anyBoolean())).thenReturn(null); + + assertEquals(null, mWiseFy.searchForSSID(TEST_SSID, 1000)); + } + + @Test + public void noCallbacks_success() { + ScanResult accessPoint = mock(ScanResult.class); + accessPoint.SSID = TEST_SSID; + accessPoint.level = -35; + + WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); + mWiseFy.mWiseFySearch = mockWiseFySearch; + when(mockWiseFySearch.findAccessPointByRegex(anyString(), anyInt(), anyBoolean())).thenReturn(accessPoint); + + assertEquals(TEST_SSID, mWiseFy.searchForSSID(TEST_SSID, 1000)); + } + + @Test + public void callbacks_failure_nullSSIDParam() { + SearchForSSIDCallbacks mockCallbacks = mock(SearchForSSIDCallbacks.class); + mWiseFy.searchForSSID(null, 1000, mockCallbacks); + verify(mockCallbacks, timeout(VERIFICATION_TIMEOUT)).searchForSSIDWiseFyFailure(WiseFyCodes.MISSING_PARAMETER); + } + + @Test + public void callbacks_failure_nullSSIDParam_nullCallback() { + try { + mWiseFy.searchForSSID(null, 1000, null); + } catch (NullPointerException npe) { + fail(); + } + } + + @Test + public void callbacks_failure_missingPrerequisite() { + missingPrerequisite(); + SearchForSSIDCallbacks mockCallbacks = mock(SearchForSSIDCallbacks.class); + mWiseFy.searchForSSID(TEST_SSID, 1000, mockCallbacks); + verify(mockCallbacks, timeout(VERIFICATION_TIMEOUT)).searchForSSIDWiseFyFailure(WiseFyCodes.MISSING_PREREQUISITE); + } + + @Test + public void callbacks_failure_missingPrerequisite_nullCallback() { + missingPrerequisite(); + try { + mWiseFy.searchForSSID(TEST_SSID, 1000, null); + } catch (NullPointerException npe) { + fail(); + } + } + + @Test + public void callbacks_failure() { + WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); + mWiseFy.mWiseFySearch = mockWiseFySearch; + when(mockWiseFySearch.findAccessPointByRegex(anyString(), anyInt(), anyBoolean())).thenReturn(null); + + SearchForSSIDCallbacks mockCallbacks = mock(SearchForSSIDCallbacks.class); + mWiseFy.searchForSSID(TEST_SSID, 1000, mockCallbacks); + verify(mockCallbacks, timeout(VERIFICATION_TIMEOUT)).ssidNotFound(); + } + + + @Test + public void callbacks_failure_nullCallback() { + WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); + mWiseFy.mWiseFySearch = mockWiseFySearch; + when(mockWiseFySearch.findAccessPointByRegex(anyString(), anyInt(), anyBoolean())).thenReturn(null); + + try { + mWiseFy.searchForSSID(TEST_SSID, 1000, null); + } catch (NullPointerException npe) { + fail(); + } + } + + @Test + public void callbacks_success() { + ScanResult accessPoint = mock(ScanResult.class); + accessPoint.SSID = TEST_SSID; + accessPoint.level = -35; + + WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); + mWiseFy.mWiseFySearch = mockWiseFySearch; + when(mockWiseFySearch.findAccessPointByRegex(anyString(), anyInt(), anyBoolean())).thenReturn(accessPoint); + + SearchForSSIDCallbacks mockCallbacks = mock(SearchForSSIDCallbacks.class); + mWiseFy.searchForSSID(TEST_SSID, 1000, mockCallbacks); + verify(mockCallbacks, timeout(VERIFICATION_TIMEOUT)).ssidFound(TEST_SSID); + } + + @Test + public void callbacks_success_nullCallback() { + ScanResult accessPoint = mock(ScanResult.class); + accessPoint.SSID = TEST_SSID; + + WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); + mWiseFy.mWiseFySearch = mockWiseFySearch; + when(mockWiseFySearch.findAccessPointByRegex(anyString(), anyInt(), anyBoolean())).thenReturn(accessPoint); + + try { + mWiseFy.searchForSSID(TEST_SSID, 1000, null); + } catch (NullPointerException npe) { + fail(); + } + } +} diff --git a/wisefy/src/androidTest/java/com/isupatches/wisefy/SearchForSSIDsTests.java b/wisefy/src/androidTest/java/com/isupatches/wisefy/SearchForSSIDsTests.java index 07edf930..0e241871 100644 --- a/wisefy/src/androidTest/java/com/isupatches/wisefy/SearchForSSIDsTests.java +++ b/wisefy/src/androidTest/java/com/isupatches/wisefy/SearchForSSIDsTests.java @@ -1,146 +1,141 @@ -//package com.isupatches.wisefy; -// -// -//import com.isupatches.wisefy.base.TestActivity; -//import com.isupatches.wisefy.callbacks.SearchForSSIDsCallbacks; -//import com.isupatches.wisefy.constants.WiseFyCodes; -//import org.junit.Test; -//import java.util.ArrayList; -//import java.util.List; -//import static com.isupatches.wisefy.base.TestUtils.TEST_SSID; -//import static junit.framework.Assert.fail; -//import static org.junit.Assert.assertEquals; -//import static org.mockito.ArgumentMatchers.anyString; -//import static org.mockito.Mockito.mock; -//import static org.mockito.Mockito.timeout; -//import static org.mockito.Mockito.verify; -//import static org.mockito.Mockito.when; -// -// -//public class SearchForSSIDsTests extends BaseTestClass { -// -// public SearchForSSIDsTests() { -// super(TestActivity.class); -// } -// -// @Test -// public void noCallbacks_failure_nullSSIDParam() { -// assertEquals(null, mWiseFy.searchForSSIDs(null)); -// } -// -// @Test -// public void noCallbacks_failure_missingPrerequisite() { -// missingPrerequisite(); -// assertEquals(null, mWiseFy.searchForSSIDs(TEST_SSID)); -// } -// -// @Test -// public void noCallbacks_failure() { -// WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); -// mWiseFy.mWiseFySearch = mockWiseFySearch; -// when(mockWiseFySearch.findSSIDsMatchingRegex(anyString())).thenReturn(null); -// -// assertEquals(null, mWiseFy.searchForSSIDs(TEST_SSID)); -// } -// -// @Test -// public void noCallbacks_success() { -// List ssids = new ArrayList<>(); -// ssids.add(TEST_SSID); -// -// WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); -// mWiseFy.mWiseFySearch = mockWiseFySearch; -// when(mockWiseFySearch.findSSIDsMatchingRegex(anyString())).thenReturn(ssids); -// -// assertEquals(ssids, mWiseFy.searchForSSIDs(TEST_SSID)); -// } -// -// @Test -// public void callbacks_failure_nullSSIDParam() { -// SearchForSSIDsCallbacks mockCallbacks = mock(SearchForSSIDsCallbacks.class); -// mWiseFy.searchForSSIDs(null, mockCallbacks); -// verify(mockCallbacks, timeout(VERIFICATION_TIMEOUT)).searchForSSIDsWiseFyFailure(WiseFyCodes.MISSING_PARAMETER); -// } -// -// @Test -// public void callbacks_failure_nullSSIDParam_nullCallback() { -// try { -// mWiseFy.searchForSSIDs(null, null); -// } catch (NullPointerException npe) { -// fail(); -// } -// } -// -// @Test -// public void callbacks_failure_missingPrerequisite() { -// missingPrerequisite(); -// SearchForSSIDsCallbacks mockCallbacks = mock(SearchForSSIDsCallbacks.class); -// mWiseFy.searchForSSIDs(TEST_SSID, mockCallbacks); -// verify(mockCallbacks, timeout(VERIFICATION_TIMEOUT)).searchForSSIDsWiseFyFailure(WiseFyCodes.MISSING_PREREQUISITE); -// } -// -// @Test -// public void callbacks_failure_missingPrerequisite_nullCallback() { -// missingPrerequisite(); -// try { -// mWiseFy.searchForSSIDs(TEST_SSID, null); -// } catch (NullPointerException npe) { -// fail(); -// } -// } -// -// @Test -// public void callbacks_failure() { -// WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); -// mWiseFy.mWiseFySearch = mockWiseFySearch; -// when(mockWiseFySearch.findSSIDsMatchingRegex(anyString())).thenReturn(null); -// -// SearchForSSIDsCallbacks mockCallbacks = mock(SearchForSSIDsCallbacks.class); -// mWiseFy.searchForSSIDs(TEST_SSID, mockCallbacks); -// verify(mockCallbacks, timeout(VERIFICATION_TIMEOUT)).noSSIDsFound(); -// } -// -// -// @Test -// public void callbacks_failure_nullCallback() { -// WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); -// mWiseFy.mWiseFySearch = mockWiseFySearch; -// when(mockWiseFySearch.findSSIDsMatchingRegex(anyString())).thenReturn(null); -// -// try { -// mWiseFy.searchForSSIDs(TEST_SSID, null); -// } catch (NullPointerException npe) { -// fail(); -// } -// } -// -// @Test -// public void callbacks_success() { -// List ssids = new ArrayList<>(); -// ssids.add(TEST_SSID); -// -// WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); -// mWiseFy.mWiseFySearch = mockWiseFySearch; -// when(mockWiseFySearch.findSSIDsMatchingRegex(anyString())).thenReturn(ssids); -// -// SearchForSSIDsCallbacks mockCallbacks = mock(SearchForSSIDsCallbacks.class); -// mWiseFy.searchForSSIDs(TEST_SSID, mockCallbacks); -// verify(mockCallbacks, timeout(VERIFICATION_TIMEOUT)).retrievedSSIDs(ssids); -// } -// -// @Test -// public void callbacks_success_nullCallback() { -// List ssids = new ArrayList<>(); -// ssids.add(TEST_SSID); -// -// WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); -// mWiseFy.mWiseFySearch = mockWiseFySearch; -// when(mockWiseFySearch.findSSIDsMatchingRegex(anyString())).thenReturn(ssids); -// -// try { -// mWiseFy.searchForSSIDs(TEST_SSID, null); -// } catch (NullPointerException npe) { -// fail(); -// } -// } -//} +package com.isupatches.wisefy; + + +import com.isupatches.wisefy.callbacks.SearchForSSIDsCallbacks; +import com.isupatches.wisefy.constants.WiseFyCodes; +import org.junit.Test; +import java.util.ArrayList; +import java.util.List; +import static com.isupatches.wisefy.base.TestUtils.TEST_SSID; +import static junit.framework.Assert.fail; +import static org.junit.Assert.assertEquals; +import static org.mockito.ArgumentMatchers.anyString; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.timeout; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; + + +public class SearchForSSIDsTests extends BaseAndroidJUnit4TestClass { + + @Test + public void noCallbacks_failure_nullSSIDParam() { + assertEquals(null, mWiseFy.searchForSSIDs(null)); + } + + @Test + public void noCallbacks_failure_missingPrerequisite() { + missingPrerequisite(); + assertEquals(null, mWiseFy.searchForSSIDs(TEST_SSID)); + } + + @Test + public void noCallbacks_failure() { + WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); + mWiseFy.mWiseFySearch = mockWiseFySearch; + when(mockWiseFySearch.findSSIDsMatchingRegex(anyString())).thenReturn(null); + + assertEquals(null, mWiseFy.searchForSSIDs(TEST_SSID)); + } + + @Test + public void noCallbacks_success() { + List ssids = new ArrayList<>(); + ssids.add(TEST_SSID); + + WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); + mWiseFy.mWiseFySearch = mockWiseFySearch; + when(mockWiseFySearch.findSSIDsMatchingRegex(anyString())).thenReturn(ssids); + + assertEquals(ssids, mWiseFy.searchForSSIDs(TEST_SSID)); + } + + @Test + public void callbacks_failure_nullSSIDParam() { + SearchForSSIDsCallbacks mockCallbacks = mock(SearchForSSIDsCallbacks.class); + mWiseFy.searchForSSIDs(null, mockCallbacks); + verify(mockCallbacks, timeout(VERIFICATION_TIMEOUT)).searchForSSIDsWiseFyFailure(WiseFyCodes.MISSING_PARAMETER); + } + + @Test + public void callbacks_failure_nullSSIDParam_nullCallback() { + try { + mWiseFy.searchForSSIDs(null, null); + } catch (NullPointerException npe) { + fail(); + } + } + + @Test + public void callbacks_failure_missingPrerequisite() { + missingPrerequisite(); + SearchForSSIDsCallbacks mockCallbacks = mock(SearchForSSIDsCallbacks.class); + mWiseFy.searchForSSIDs(TEST_SSID, mockCallbacks); + verify(mockCallbacks, timeout(VERIFICATION_TIMEOUT)).searchForSSIDsWiseFyFailure(WiseFyCodes.MISSING_PREREQUISITE); + } + + @Test + public void callbacks_failure_missingPrerequisite_nullCallback() { + missingPrerequisite(); + try { + mWiseFy.searchForSSIDs(TEST_SSID, null); + } catch (NullPointerException npe) { + fail(); + } + } + + @Test + public void callbacks_failure() { + WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); + mWiseFy.mWiseFySearch = mockWiseFySearch; + when(mockWiseFySearch.findSSIDsMatchingRegex(anyString())).thenReturn(null); + + SearchForSSIDsCallbacks mockCallbacks = mock(SearchForSSIDsCallbacks.class); + mWiseFy.searchForSSIDs(TEST_SSID, mockCallbacks); + verify(mockCallbacks, timeout(VERIFICATION_TIMEOUT)).noSSIDsFound(); + } + + + @Test + public void callbacks_failure_nullCallback() { + WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); + mWiseFy.mWiseFySearch = mockWiseFySearch; + when(mockWiseFySearch.findSSIDsMatchingRegex(anyString())).thenReturn(null); + + try { + mWiseFy.searchForSSIDs(TEST_SSID, null); + } catch (NullPointerException npe) { + fail(); + } + } + + @Test + public void callbacks_success() { + List ssids = new ArrayList<>(); + ssids.add(TEST_SSID); + + WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); + mWiseFy.mWiseFySearch = mockWiseFySearch; + when(mockWiseFySearch.findSSIDsMatchingRegex(anyString())).thenReturn(ssids); + + SearchForSSIDsCallbacks mockCallbacks = mock(SearchForSSIDsCallbacks.class); + mWiseFy.searchForSSIDs(TEST_SSID, mockCallbacks); + verify(mockCallbacks, timeout(VERIFICATION_TIMEOUT)).retrievedSSIDs(ssids); + } + + @Test + public void callbacks_success_nullCallback() { + List ssids = new ArrayList<>(); + ssids.add(TEST_SSID); + + WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); + mWiseFy.mWiseFySearch = mockWiseFySearch; + when(mockWiseFySearch.findSSIDsMatchingRegex(anyString())).thenReturn(ssids); + + try { + mWiseFy.searchForSSIDs(TEST_SSID, null); + } catch (NullPointerException npe) { + fail(); + } + } +} diff --git a/wisefy/src/androidTest/java/com/isupatches/wisefy/WiseFyConnectionTests.java b/wisefy/src/androidTest/java/com/isupatches/wisefy/WiseFyConnectionTests.java index 9d0d5889..e721eb62 100644 --- a/wisefy/src/androidTest/java/com/isupatches/wisefy/WiseFyConnectionTests.java +++ b/wisefy/src/androidTest/java/com/isupatches/wisefy/WiseFyConnectionTests.java @@ -1,364 +1,359 @@ -//package com.isupatches.wisefy; -// -// -//import android.net.NetworkInfo; -//import android.net.wifi.WifiInfo; -//import com.isupatches.wisefy.base.TestActivity; -//import org.junit.Before; -//import org.junit.Test; -//import static com.isupatches.wisefy.base.TestUtils.TEST_SSID; -//import static com.isupatches.wisefy.base.TestUtils.TEST_SSID2; -//import static com.isupatches.wisefy.base.TestUtils.TEST_TYPE1; -//import static com.isupatches.wisefy.base.TestUtils.TEST_TYPE2; -//import static junit.framework.Assert.assertFalse; -//import static junit.framework.Assert.assertTrue; -//import static org.mockito.Mockito.mock; -//import static org.mockito.Mockito.when; -// -// -//public class WiseFyConnectionTests extends BaseTestClass { -// -// public WiseFyConnectionTests() { -// super(TestActivity.class); -// } -// -// @Before -// public void setUp() { -// super.setUp(); -// WiseFyConnection.getInstance().mWiseFyPrerequisites.setWifiManager(mMockWiFiManager); -// WiseFyConnection.getInstance().mWiseFyPrerequisites.setConnectivityManager(mMockConnectivityManager); -// } -// -// /* -// * isCurrentNetworkConnectedToSSID tests -// */ -// -// @Test -// public void isCurrentNetworkConnectedToSSID_failure_nullSSIDParam() { -// assertFalse(WiseFyConnection.getInstance().isCurrentNetworkConnectedToSSID(null)); -// } -// -// @Test -// public void isCurrentNetworkConnectedToSSID_failure_nullConnectionInfo() { -// when(mMockWiFiManager.getConnectionInfo()).thenReturn(null); -// assertFalse(WiseFyConnection.getInstance().isCurrentNetworkConnectedToSSID(TEST_SSID)); -// } -// -// @Test -// public void isCurrentNetworkConnectedToSSID_failure_nullSSID() { -// WifiInfo currentNetwork = mock(WifiInfo.class); -// when(currentNetwork.getSSID()).thenReturn(null); -// when(mMockWiFiManager.getConnectionInfo()).thenReturn(currentNetwork); -// assertFalse(WiseFyConnection.getInstance().isCurrentNetworkConnectedToSSID(null)); -// } -// -// @Test -// public void isCurrentNetworkConnectedToSSID_failure_differentSSID() { -// WifiInfo currentNetwork = mock(WifiInfo.class); -// when(currentNetwork.getSSID()).thenReturn(TEST_SSID2); -// when(mMockWiFiManager.getConnectionInfo()).thenReturn(currentNetwork); -// assertFalse(WiseFyConnection.getInstance().isCurrentNetworkConnectedToSSID(TEST_SSID)); -// } -// -// @Test -// public void isCurrentNetworkConnectedToSSID_failure_notAvailable() { -// WifiInfo currentNetwork = mock(WifiInfo.class); -// when(currentNetwork.getSSID()).thenReturn(TEST_SSID); -// when(mMockWiFiManager.getConnectionInfo()).thenReturn(currentNetwork); -// -// NetworkInfo networkInfo = mock(NetworkInfo.class); -// when(networkInfo.isAvailable()).thenReturn(false); -// when(networkInfo.isConnected()).thenReturn(true); -// when(mMockConnectivityManager.getActiveNetworkInfo()).thenReturn(networkInfo); -// -// assertFalse(WiseFyConnection.getInstance().isCurrentNetworkConnectedToSSID(TEST_SSID)); -// } -// -// @Test -// public void isCurrentNetworkConnectedToSSID_failure_notAvailableOrConnected() { -// WifiInfo currentNetwork = mock(WifiInfo.class); -// when(currentNetwork.getSSID()).thenReturn(TEST_SSID); -// when(mMockWiFiManager.getConnectionInfo()).thenReturn(currentNetwork); -// -// NetworkInfo networkInfo = mock(NetworkInfo.class); -// when(networkInfo.isAvailable()).thenReturn(false); -// when(networkInfo.isConnected()).thenReturn(false); -// when(mMockConnectivityManager.getActiveNetworkInfo()).thenReturn(networkInfo); -// -// assertFalse(WiseFyConnection.getInstance().isCurrentNetworkConnectedToSSID(TEST_SSID)); -// } -// -// @Test -// public void isCurrentNetworkConnectedToSSID_failure_notConnected() { -// WifiInfo currentNetwork = mock(WifiInfo.class); -// when(currentNetwork.getSSID()).thenReturn(TEST_SSID); -// when(mMockWiFiManager.getConnectionInfo()).thenReturn(currentNetwork); -// -// NetworkInfo networkInfo = mock(NetworkInfo.class); -// when(networkInfo.isAvailable()).thenReturn(true); -// when(networkInfo.isConnected()).thenReturn(false); -// when(mMockConnectivityManager.getActiveNetworkInfo()).thenReturn(networkInfo); -// -// assertFalse(WiseFyConnection.getInstance().isCurrentNetworkConnectedToSSID(TEST_SSID)); -// } -// -// @Test -// public void isCurrentNetworkConnectedToSSID_success() { -// WifiInfo currentNetwork = mock(WifiInfo.class); -// when(currentNetwork.getSSID()).thenReturn(TEST_SSID); -// when(mMockWiFiManager.getConnectionInfo()).thenReturn(currentNetwork); -// -// NetworkInfo networkInfo = mock(NetworkInfo.class); -// when(networkInfo.isAvailable()).thenReturn(true); -// when(networkInfo.isConnected()).thenReturn(true); -// when(mMockConnectivityManager.getActiveNetworkInfo()).thenReturn(networkInfo); -// -// assertTrue(WiseFyConnection.getInstance().isCurrentNetworkConnectedToSSID(TEST_SSID)); -// } -// -// /* -// * isNetworkConnected tests -// */ -// -// @Test -// public void isNetworkConnected_failure_nullNetworkInfoParam() { -// NetworkInfo networkInfo = mock(NetworkInfo.class); -// when(networkInfo.isAvailable()).thenReturn(false); -// when(networkInfo.isConnected()).thenReturn(true); -// when(mMockConnectivityManager.getActiveNetworkInfo()).thenReturn(networkInfo); -// -// assertFalse(WiseFyConnection.getInstance().isNetworkConnected(null)); -// } -// -// @Test -// public void isNetworkConnected_failure_notAvailable() { -// NetworkInfo networkInfo = mock(NetworkInfo.class); -// when(networkInfo.isAvailable()).thenReturn(false); -// when(networkInfo.isConnected()).thenReturn(true); -// when(mMockConnectivityManager.getActiveNetworkInfo()).thenReturn(networkInfo); -// -// assertFalse(WiseFyConnection.getInstance().isNetworkConnected(networkInfo)); -// } -// -// @Test -// public void isNetworkConnected_failure_notAvailableOrConnected() { -// NetworkInfo networkInfo = mock(NetworkInfo.class); -// when(networkInfo.isAvailable()).thenReturn(false); -// when(networkInfo.isConnected()).thenReturn(false); -// when(mMockConnectivityManager.getActiveNetworkInfo()).thenReturn(networkInfo); -// -// assertFalse(WiseFyConnection.getInstance().isNetworkConnected(networkInfo)); -// } -// -// @Test -// public void isNetworkConnected_failure_notConnected() { -// NetworkInfo networkInfo = mock(NetworkInfo.class); -// when(networkInfo.isAvailable()).thenReturn(true); -// when(networkInfo.isConnected()).thenReturn(false); -// when(mMockConnectivityManager.getActiveNetworkInfo()).thenReturn(networkInfo); -// -// assertFalse(WiseFyConnection.getInstance().isNetworkConnected(networkInfo)); -// } -// -// @Test -// public void isNetworkConnected_success() { -// NetworkInfo networkInfo = mock(NetworkInfo.class); -// when(networkInfo.isAvailable()).thenReturn(true); -// when(networkInfo.isConnected()).thenReturn(true); -// when(mMockConnectivityManager.getActiveNetworkInfo()).thenReturn(networkInfo); -// -// assertTrue(WiseFyConnection.getInstance().isNetworkConnected(networkInfo)); -// } -// -// /* -// * isNetworkConnectedAndMatchesType tests -// */ -// -// @Test -// public void isNetworkConnectedAndMatchesType_failure_nullNetworkInfoParam() { -// WifiInfo currentNetwork = mock(WifiInfo.class); -// when(currentNetwork.getSSID()).thenReturn(TEST_SSID); -// when(mMockWiFiManager.getConnectionInfo()).thenReturn(currentNetwork); -// -// NetworkInfo networkInfo = mock(NetworkInfo.class); -// when(networkInfo.isAvailable()).thenReturn(false); -// when(networkInfo.isConnected()).thenReturn(true); -// when(mMockConnectivityManager.getActiveNetworkInfo()).thenReturn(networkInfo); -// -// assertFalse(WiseFyConnection.getInstance().isNetworkConnectedAndMatchesType(null, TEST_TYPE1)); -// } -// -// @Test -// public void isNetworkConnectedAndMatchesType_failure_notAvailable() { -// WifiInfo currentNetwork = mock(WifiInfo.class); -// when(currentNetwork.getSSID()).thenReturn(TEST_SSID); -// when(mMockWiFiManager.getConnectionInfo()).thenReturn(currentNetwork); -// -// NetworkInfo networkInfo = mock(NetworkInfo.class); -// when(networkInfo.isAvailable()).thenReturn(false); -// when(networkInfo.isConnected()).thenReturn(true); -// when(mMockConnectivityManager.getActiveNetworkInfo()).thenReturn(networkInfo); -// -// assertFalse(WiseFyConnection.getInstance().isNetworkConnectedAndMatchesType(networkInfo, TEST_TYPE1)); -// } -// -// @Test -// public void isNetworkConnectedAndMatchesType_failure_notAvailableOrConnected() { -// WifiInfo currentNetwork = mock(WifiInfo.class); -// when(currentNetwork.getSSID()).thenReturn(TEST_SSID); -// when(mMockWiFiManager.getConnectionInfo()).thenReturn(currentNetwork); -// -// NetworkInfo networkInfo = mock(NetworkInfo.class); -// when(networkInfo.isAvailable()).thenReturn(false); -// when(networkInfo.isConnected()).thenReturn(false); -// when(mMockConnectivityManager.getActiveNetworkInfo()).thenReturn(networkInfo); -// -// assertFalse(WiseFyConnection.getInstance().isNetworkConnectedAndMatchesType(networkInfo, TEST_TYPE1)); -// } -// -// @Test -// public void isNetworkConnectedAndMatchesType_failure_notConnected() { -// WifiInfo currentNetwork = mock(WifiInfo.class); -// when(currentNetwork.getSSID()).thenReturn(TEST_SSID); -// when(mMockWiFiManager.getConnectionInfo()).thenReturn(currentNetwork); -// -// NetworkInfo networkInfo = mock(NetworkInfo.class); -// when(networkInfo.isAvailable()).thenReturn(true); -// when(networkInfo.isConnected()).thenReturn(false); -// when(mMockConnectivityManager.getActiveNetworkInfo()).thenReturn(networkInfo); -// -// assertFalse(WiseFyConnection.getInstance().isNetworkConnectedAndMatchesType(networkInfo, TEST_TYPE1)); -// } -// -// @Test -// public void isNetworkConnectedAndMatchesType_failure_nullTypeName() { -// WifiInfo currentNetwork = mock(WifiInfo.class); -// when(currentNetwork.getSSID()).thenReturn(TEST_SSID); -// when(mMockWiFiManager.getConnectionInfo()).thenReturn(currentNetwork); -// -// NetworkInfo networkInfo = mock(NetworkInfo.class); -// when(networkInfo.isAvailable()).thenReturn(true); -// when(networkInfo.isConnected()).thenReturn(true); -// when(networkInfo.getTypeName()).thenReturn(null); -// when(mMockConnectivityManager.getActiveNetworkInfo()).thenReturn(networkInfo); -// -// assertFalse(WiseFyConnection.getInstance().isNetworkConnectedAndMatchesType(networkInfo, TEST_TYPE1)); -// } -// -// @Test -// public void isNetworkConnectedAndMatchesType_failure_differentTypeName() { -// WifiInfo currentNetwork = mock(WifiInfo.class); -// when(currentNetwork.getSSID()).thenReturn(TEST_SSID); -// when(mMockWiFiManager.getConnectionInfo()).thenReturn(currentNetwork); -// -// NetworkInfo networkInfo = mock(NetworkInfo.class); -// when(networkInfo.isAvailable()).thenReturn(true); -// when(networkInfo.isConnected()).thenReturn(true); -// when(networkInfo.getTypeName()).thenReturn(TEST_TYPE2); -// when(mMockConnectivityManager.getActiveNetworkInfo()).thenReturn(networkInfo); -// -// assertFalse(WiseFyConnection.getInstance().isNetworkConnectedAndMatchesType(networkInfo, TEST_TYPE1)); -// } -// -// @Test -// public void isNetworkConnectedAndMatchesType_success() { -// WifiInfo currentNetwork = mock(WifiInfo.class); -// when(currentNetwork.getSSID()).thenReturn(TEST_SSID); -// when(mMockWiFiManager.getConnectionInfo()).thenReturn(currentNetwork); -// -// NetworkInfo networkInfo = mock(NetworkInfo.class); -// when(networkInfo.isAvailable()).thenReturn(true); -// when(networkInfo.isConnected()).thenReturn(true); -// when(networkInfo.getTypeName()).thenReturn(TEST_TYPE1); -// when(mMockConnectivityManager.getActiveNetworkInfo()).thenReturn(networkInfo); -// -// assertTrue(WiseFyConnection.getInstance().isNetworkConnectedAndMatchesType(networkInfo, TEST_TYPE1)); -// } -// -// /* -// * waitToConnectToSSID tests -// */ -// -// @Test -// public void waitToConnectToSSID_failure_nullSSIDParam() { -// assertFalse(WiseFyConnection.getInstance().waitToConnectToSSID(null, 1000)); -// } -// -// @Test -// public void waitToConnectToSSID_failure_nullConnectionInfo() { -// when(mMockWiFiManager.getConnectionInfo()).thenReturn(null); -// assertFalse(WiseFyConnection.getInstance().waitToConnectToSSID(TEST_SSID, 1000)); -// } -// -// @Test -// public void waitToConnectToSSID_failure_nullSSID() { -// WifiInfo currentNetwork = mock(WifiInfo.class); -// when(currentNetwork.getSSID()).thenReturn(null); -// when(mMockWiFiManager.getConnectionInfo()).thenReturn(currentNetwork); -// assertFalse(WiseFyConnection.getInstance().waitToConnectToSSID(null, 1000)); -// } -// -// @Test -// public void waitToConnectToSSID_failure_differentSSID() { -// WifiInfo currentNetwork = mock(WifiInfo.class); -// when(currentNetwork.getSSID()).thenReturn(TEST_SSID2); -// when(mMockWiFiManager.getConnectionInfo()).thenReturn(currentNetwork); -// assertFalse(WiseFyConnection.getInstance().waitToConnectToSSID(TEST_SSID, 1000)); -// } -// -// @Test -// public void waitToConnectToSSID_failure_notAvailable() { -// WifiInfo currentNetwork = mock(WifiInfo.class); -// when(currentNetwork.getSSID()).thenReturn(TEST_SSID); -// when(mMockWiFiManager.getConnectionInfo()).thenReturn(currentNetwork); -// -// NetworkInfo networkInfo = mock(NetworkInfo.class); -// when(networkInfo.isAvailable()).thenReturn(false); -// when(networkInfo.isConnected()).thenReturn(true); -// when(mMockConnectivityManager.getActiveNetworkInfo()).thenReturn(networkInfo); -// -// assertFalse(WiseFyConnection.getInstance().waitToConnectToSSID(TEST_SSID, 1000)); -// } -// -// @Test -// public void waitToConnectToSSID_failure_notAvailableOrConnected() { -// WifiInfo currentNetwork = mock(WifiInfo.class); -// when(currentNetwork.getSSID()).thenReturn(TEST_SSID); -// when(mMockWiFiManager.getConnectionInfo()).thenReturn(currentNetwork); -// -// NetworkInfo networkInfo = mock(NetworkInfo.class); -// when(networkInfo.isAvailable()).thenReturn(false); -// when(networkInfo.isConnected()).thenReturn(false); -// when(mMockConnectivityManager.getActiveNetworkInfo()).thenReturn(networkInfo); -// -// assertFalse(WiseFyConnection.getInstance().waitToConnectToSSID(TEST_SSID, 1000)); -// } -// -// @Test -// public void waitToConnectToSSID_failure_notConnected() { -// WifiInfo currentNetwork = mock(WifiInfo.class); -// when(currentNetwork.getSSID()).thenReturn(TEST_SSID); -// when(mMockWiFiManager.getConnectionInfo()).thenReturn(currentNetwork); -// -// NetworkInfo networkInfo = mock(NetworkInfo.class); -// when(networkInfo.isAvailable()).thenReturn(true); -// when(networkInfo.isConnected()).thenReturn(false); -// when(mMockConnectivityManager.getActiveNetworkInfo()).thenReturn(networkInfo); -// -// assertFalse(WiseFyConnection.getInstance().waitToConnectToSSID(TEST_SSID, 1000)); -// } -// -// @Test -// public void waitToConnectToSSID_success() { -// WifiInfo currentNetwork = mock(WifiInfo.class); -// when(currentNetwork.getSSID()).thenReturn(TEST_SSID); -// when(mMockWiFiManager.getConnectionInfo()).thenReturn(currentNetwork); -// -// NetworkInfo networkInfo = mock(NetworkInfo.class); -// when(networkInfo.isAvailable()).thenReturn(true); -// when(networkInfo.isConnected()).thenReturn(true); -// when(mMockConnectivityManager.getActiveNetworkInfo()).thenReturn(networkInfo); -// -// assertTrue(WiseFyConnection.getInstance().waitToConnectToSSID(TEST_SSID, 1000)); -// } -//} +package com.isupatches.wisefy; + + +import android.net.NetworkInfo; +import android.net.wifi.WifiInfo; +import org.junit.Before; +import org.junit.Test; +import static com.isupatches.wisefy.base.TestUtils.TEST_SSID; +import static com.isupatches.wisefy.base.TestUtils.TEST_SSID2; +import static com.isupatches.wisefy.base.TestUtils.TEST_TYPE1; +import static com.isupatches.wisefy.base.TestUtils.TEST_TYPE2; +import static junit.framework.Assert.assertFalse; +import static junit.framework.Assert.assertTrue; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; + + +public class WiseFyConnectionTests extends BaseAndroidJUnit4TestClass { + + @Before + public void setUp() { + super.setUp(); + WiseFyConnection.getInstance().mWiseFyPrerequisites.setWifiManager(mMockWiFiManager); + WiseFyConnection.getInstance().mWiseFyPrerequisites.setConnectivityManager(mMockConnectivityManager); + } + + /* + * isCurrentNetworkConnectedToSSID tests + */ + + @Test + public void isCurrentNetworkConnectedToSSID_failure_nullSSIDParam() { + assertFalse(WiseFyConnection.getInstance().isCurrentNetworkConnectedToSSID(null)); + } + + @Test + public void isCurrentNetworkConnectedToSSID_failure_nullConnectionInfo() { + when(mMockWiFiManager.getConnectionInfo()).thenReturn(null); + assertFalse(WiseFyConnection.getInstance().isCurrentNetworkConnectedToSSID(TEST_SSID)); + } + + @Test + public void isCurrentNetworkConnectedToSSID_failure_nullSSID() { + WifiInfo currentNetwork = mock(WifiInfo.class); + when(currentNetwork.getSSID()).thenReturn(null); + when(mMockWiFiManager.getConnectionInfo()).thenReturn(currentNetwork); + assertFalse(WiseFyConnection.getInstance().isCurrentNetworkConnectedToSSID(null)); + } + + @Test + public void isCurrentNetworkConnectedToSSID_failure_differentSSID() { + WifiInfo currentNetwork = mock(WifiInfo.class); + when(currentNetwork.getSSID()).thenReturn(TEST_SSID2); + when(mMockWiFiManager.getConnectionInfo()).thenReturn(currentNetwork); + assertFalse(WiseFyConnection.getInstance().isCurrentNetworkConnectedToSSID(TEST_SSID)); + } + + @Test + public void isCurrentNetworkConnectedToSSID_failure_notAvailable() { + WifiInfo currentNetwork = mock(WifiInfo.class); + when(currentNetwork.getSSID()).thenReturn(TEST_SSID); + when(mMockWiFiManager.getConnectionInfo()).thenReturn(currentNetwork); + + NetworkInfo networkInfo = mock(NetworkInfo.class); + when(networkInfo.isAvailable()).thenReturn(false); + when(networkInfo.isConnected()).thenReturn(true); + when(mMockConnectivityManager.getActiveNetworkInfo()).thenReturn(networkInfo); + + assertFalse(WiseFyConnection.getInstance().isCurrentNetworkConnectedToSSID(TEST_SSID)); + } + + @Test + public void isCurrentNetworkConnectedToSSID_failure_notAvailableOrConnected() { + WifiInfo currentNetwork = mock(WifiInfo.class); + when(currentNetwork.getSSID()).thenReturn(TEST_SSID); + when(mMockWiFiManager.getConnectionInfo()).thenReturn(currentNetwork); + + NetworkInfo networkInfo = mock(NetworkInfo.class); + when(networkInfo.isAvailable()).thenReturn(false); + when(networkInfo.isConnected()).thenReturn(false); + when(mMockConnectivityManager.getActiveNetworkInfo()).thenReturn(networkInfo); + + assertFalse(WiseFyConnection.getInstance().isCurrentNetworkConnectedToSSID(TEST_SSID)); + } + + @Test + public void isCurrentNetworkConnectedToSSID_failure_notConnected() { + WifiInfo currentNetwork = mock(WifiInfo.class); + when(currentNetwork.getSSID()).thenReturn(TEST_SSID); + when(mMockWiFiManager.getConnectionInfo()).thenReturn(currentNetwork); + + NetworkInfo networkInfo = mock(NetworkInfo.class); + when(networkInfo.isAvailable()).thenReturn(true); + when(networkInfo.isConnected()).thenReturn(false); + when(mMockConnectivityManager.getActiveNetworkInfo()).thenReturn(networkInfo); + + assertFalse(WiseFyConnection.getInstance().isCurrentNetworkConnectedToSSID(TEST_SSID)); + } + + @Test + public void isCurrentNetworkConnectedToSSID_success() { + WifiInfo currentNetwork = mock(WifiInfo.class); + when(currentNetwork.getSSID()).thenReturn(TEST_SSID); + when(mMockWiFiManager.getConnectionInfo()).thenReturn(currentNetwork); + + NetworkInfo networkInfo = mock(NetworkInfo.class); + when(networkInfo.isAvailable()).thenReturn(true); + when(networkInfo.isConnected()).thenReturn(true); + when(mMockConnectivityManager.getActiveNetworkInfo()).thenReturn(networkInfo); + + assertTrue(WiseFyConnection.getInstance().isCurrentNetworkConnectedToSSID(TEST_SSID)); + } + + /* + * isNetworkConnected tests + */ + + @Test + public void isNetworkConnected_failure_nullNetworkInfoParam() { + NetworkInfo networkInfo = mock(NetworkInfo.class); + when(networkInfo.isAvailable()).thenReturn(false); + when(networkInfo.isConnected()).thenReturn(true); + when(mMockConnectivityManager.getActiveNetworkInfo()).thenReturn(networkInfo); + + assertFalse(WiseFyConnection.getInstance().isNetworkConnected(null)); + } + + @Test + public void isNetworkConnected_failure_notAvailable() { + NetworkInfo networkInfo = mock(NetworkInfo.class); + when(networkInfo.isAvailable()).thenReturn(false); + when(networkInfo.isConnected()).thenReturn(true); + when(mMockConnectivityManager.getActiveNetworkInfo()).thenReturn(networkInfo); + + assertFalse(WiseFyConnection.getInstance().isNetworkConnected(networkInfo)); + } + + @Test + public void isNetworkConnected_failure_notAvailableOrConnected() { + NetworkInfo networkInfo = mock(NetworkInfo.class); + when(networkInfo.isAvailable()).thenReturn(false); + when(networkInfo.isConnected()).thenReturn(false); + when(mMockConnectivityManager.getActiveNetworkInfo()).thenReturn(networkInfo); + + assertFalse(WiseFyConnection.getInstance().isNetworkConnected(networkInfo)); + } + + @Test + public void isNetworkConnected_failure_notConnected() { + NetworkInfo networkInfo = mock(NetworkInfo.class); + when(networkInfo.isAvailable()).thenReturn(true); + when(networkInfo.isConnected()).thenReturn(false); + when(mMockConnectivityManager.getActiveNetworkInfo()).thenReturn(networkInfo); + + assertFalse(WiseFyConnection.getInstance().isNetworkConnected(networkInfo)); + } + + @Test + public void isNetworkConnected_success() { + NetworkInfo networkInfo = mock(NetworkInfo.class); + when(networkInfo.isAvailable()).thenReturn(true); + when(networkInfo.isConnected()).thenReturn(true); + when(mMockConnectivityManager.getActiveNetworkInfo()).thenReturn(networkInfo); + + assertTrue(WiseFyConnection.getInstance().isNetworkConnected(networkInfo)); + } + + /* + * isNetworkConnectedAndMatchesType tests + */ + + @Test + public void isNetworkConnectedAndMatchesType_failure_nullNetworkInfoParam() { + WifiInfo currentNetwork = mock(WifiInfo.class); + when(currentNetwork.getSSID()).thenReturn(TEST_SSID); + when(mMockWiFiManager.getConnectionInfo()).thenReturn(currentNetwork); + + NetworkInfo networkInfo = mock(NetworkInfo.class); + when(networkInfo.isAvailable()).thenReturn(false); + when(networkInfo.isConnected()).thenReturn(true); + when(mMockConnectivityManager.getActiveNetworkInfo()).thenReturn(networkInfo); + + assertFalse(WiseFyConnection.getInstance().isNetworkConnectedAndMatchesType(null, TEST_TYPE1)); + } + + @Test + public void isNetworkConnectedAndMatchesType_failure_notAvailable() { + WifiInfo currentNetwork = mock(WifiInfo.class); + when(currentNetwork.getSSID()).thenReturn(TEST_SSID); + when(mMockWiFiManager.getConnectionInfo()).thenReturn(currentNetwork); + + NetworkInfo networkInfo = mock(NetworkInfo.class); + when(networkInfo.isAvailable()).thenReturn(false); + when(networkInfo.isConnected()).thenReturn(true); + when(mMockConnectivityManager.getActiveNetworkInfo()).thenReturn(networkInfo); + + assertFalse(WiseFyConnection.getInstance().isNetworkConnectedAndMatchesType(networkInfo, TEST_TYPE1)); + } + + @Test + public void isNetworkConnectedAndMatchesType_failure_notAvailableOrConnected() { + WifiInfo currentNetwork = mock(WifiInfo.class); + when(currentNetwork.getSSID()).thenReturn(TEST_SSID); + when(mMockWiFiManager.getConnectionInfo()).thenReturn(currentNetwork); + + NetworkInfo networkInfo = mock(NetworkInfo.class); + when(networkInfo.isAvailable()).thenReturn(false); + when(networkInfo.isConnected()).thenReturn(false); + when(mMockConnectivityManager.getActiveNetworkInfo()).thenReturn(networkInfo); + + assertFalse(WiseFyConnection.getInstance().isNetworkConnectedAndMatchesType(networkInfo, TEST_TYPE1)); + } + + @Test + public void isNetworkConnectedAndMatchesType_failure_notConnected() { + WifiInfo currentNetwork = mock(WifiInfo.class); + when(currentNetwork.getSSID()).thenReturn(TEST_SSID); + when(mMockWiFiManager.getConnectionInfo()).thenReturn(currentNetwork); + + NetworkInfo networkInfo = mock(NetworkInfo.class); + when(networkInfo.isAvailable()).thenReturn(true); + when(networkInfo.isConnected()).thenReturn(false); + when(mMockConnectivityManager.getActiveNetworkInfo()).thenReturn(networkInfo); + + assertFalse(WiseFyConnection.getInstance().isNetworkConnectedAndMatchesType(networkInfo, TEST_TYPE1)); + } + + @Test + public void isNetworkConnectedAndMatchesType_failure_nullTypeName() { + WifiInfo currentNetwork = mock(WifiInfo.class); + when(currentNetwork.getSSID()).thenReturn(TEST_SSID); + when(mMockWiFiManager.getConnectionInfo()).thenReturn(currentNetwork); + + NetworkInfo networkInfo = mock(NetworkInfo.class); + when(networkInfo.isAvailable()).thenReturn(true); + when(networkInfo.isConnected()).thenReturn(true); + when(networkInfo.getTypeName()).thenReturn(null); + when(mMockConnectivityManager.getActiveNetworkInfo()).thenReturn(networkInfo); + + assertFalse(WiseFyConnection.getInstance().isNetworkConnectedAndMatchesType(networkInfo, TEST_TYPE1)); + } + + @Test + public void isNetworkConnectedAndMatchesType_failure_differentTypeName() { + WifiInfo currentNetwork = mock(WifiInfo.class); + when(currentNetwork.getSSID()).thenReturn(TEST_SSID); + when(mMockWiFiManager.getConnectionInfo()).thenReturn(currentNetwork); + + NetworkInfo networkInfo = mock(NetworkInfo.class); + when(networkInfo.isAvailable()).thenReturn(true); + when(networkInfo.isConnected()).thenReturn(true); + when(networkInfo.getTypeName()).thenReturn(TEST_TYPE2); + when(mMockConnectivityManager.getActiveNetworkInfo()).thenReturn(networkInfo); + + assertFalse(WiseFyConnection.getInstance().isNetworkConnectedAndMatchesType(networkInfo, TEST_TYPE1)); + } + + @Test + public void isNetworkConnectedAndMatchesType_success() { + WifiInfo currentNetwork = mock(WifiInfo.class); + when(currentNetwork.getSSID()).thenReturn(TEST_SSID); + when(mMockWiFiManager.getConnectionInfo()).thenReturn(currentNetwork); + + NetworkInfo networkInfo = mock(NetworkInfo.class); + when(networkInfo.isAvailable()).thenReturn(true); + when(networkInfo.isConnected()).thenReturn(true); + when(networkInfo.getTypeName()).thenReturn(TEST_TYPE1); + when(mMockConnectivityManager.getActiveNetworkInfo()).thenReturn(networkInfo); + + assertTrue(WiseFyConnection.getInstance().isNetworkConnectedAndMatchesType(networkInfo, TEST_TYPE1)); + } + + /* + * waitToConnectToSSID tests + */ + + @Test + public void waitToConnectToSSID_failure_nullSSIDParam() { + assertFalse(WiseFyConnection.getInstance().waitToConnectToSSID(null, 1000)); + } + + @Test + public void waitToConnectToSSID_failure_nullConnectionInfo() { + when(mMockWiFiManager.getConnectionInfo()).thenReturn(null); + assertFalse(WiseFyConnection.getInstance().waitToConnectToSSID(TEST_SSID, 1000)); + } + + @Test + public void waitToConnectToSSID_failure_nullSSID() { + WifiInfo currentNetwork = mock(WifiInfo.class); + when(currentNetwork.getSSID()).thenReturn(null); + when(mMockWiFiManager.getConnectionInfo()).thenReturn(currentNetwork); + assertFalse(WiseFyConnection.getInstance().waitToConnectToSSID(null, 1000)); + } + + @Test + public void waitToConnectToSSID_failure_differentSSID() { + WifiInfo currentNetwork = mock(WifiInfo.class); + when(currentNetwork.getSSID()).thenReturn(TEST_SSID2); + when(mMockWiFiManager.getConnectionInfo()).thenReturn(currentNetwork); + assertFalse(WiseFyConnection.getInstance().waitToConnectToSSID(TEST_SSID, 1000)); + } + + @Test + public void waitToConnectToSSID_failure_notAvailable() { + WifiInfo currentNetwork = mock(WifiInfo.class); + when(currentNetwork.getSSID()).thenReturn(TEST_SSID); + when(mMockWiFiManager.getConnectionInfo()).thenReturn(currentNetwork); + + NetworkInfo networkInfo = mock(NetworkInfo.class); + when(networkInfo.isAvailable()).thenReturn(false); + when(networkInfo.isConnected()).thenReturn(true); + when(mMockConnectivityManager.getActiveNetworkInfo()).thenReturn(networkInfo); + + assertFalse(WiseFyConnection.getInstance().waitToConnectToSSID(TEST_SSID, 1000)); + } + + @Test + public void waitToConnectToSSID_failure_notAvailableOrConnected() { + WifiInfo currentNetwork = mock(WifiInfo.class); + when(currentNetwork.getSSID()).thenReturn(TEST_SSID); + when(mMockWiFiManager.getConnectionInfo()).thenReturn(currentNetwork); + + NetworkInfo networkInfo = mock(NetworkInfo.class); + when(networkInfo.isAvailable()).thenReturn(false); + when(networkInfo.isConnected()).thenReturn(false); + when(mMockConnectivityManager.getActiveNetworkInfo()).thenReturn(networkInfo); + + assertFalse(WiseFyConnection.getInstance().waitToConnectToSSID(TEST_SSID, 1000)); + } + + @Test + public void waitToConnectToSSID_failure_notConnected() { + WifiInfo currentNetwork = mock(WifiInfo.class); + when(currentNetwork.getSSID()).thenReturn(TEST_SSID); + when(mMockWiFiManager.getConnectionInfo()).thenReturn(currentNetwork); + + NetworkInfo networkInfo = mock(NetworkInfo.class); + when(networkInfo.isAvailable()).thenReturn(true); + when(networkInfo.isConnected()).thenReturn(false); + when(mMockConnectivityManager.getActiveNetworkInfo()).thenReturn(networkInfo); + + assertFalse(WiseFyConnection.getInstance().waitToConnectToSSID(TEST_SSID, 1000)); + } + + @Test + public void waitToConnectToSSID_success() { + WifiInfo currentNetwork = mock(WifiInfo.class); + when(currentNetwork.getSSID()).thenReturn(TEST_SSID); + when(mMockWiFiManager.getConnectionInfo()).thenReturn(currentNetwork); + + NetworkInfo networkInfo = mock(NetworkInfo.class); + when(networkInfo.isAvailable()).thenReturn(true); + when(networkInfo.isConnected()).thenReturn(true); + when(mMockConnectivityManager.getActiveNetworkInfo()).thenReturn(networkInfo); + + assertTrue(WiseFyConnection.getInstance().waitToConnectToSSID(TEST_SSID, 1000)); + } +} diff --git a/wisefy/src/androidTest/java/com/isupatches/wisefy/WiseFyPrerequisitesTests.java b/wisefy/src/androidTest/java/com/isupatches/wisefy/WiseFyPrerequisitesTests.java index 4aebf88f..f3f17a3d 100644 --- a/wisefy/src/androidTest/java/com/isupatches/wisefy/WiseFyPrerequisitesTests.java +++ b/wisefy/src/androidTest/java/com/isupatches/wisefy/WiseFyPrerequisitesTests.java @@ -1,54 +1,49 @@ -//package com.isupatches.wisefy; -// -// -//import com.isupatches.wisefy.base.TestActivity; -//import org.junit.Test; -//import static junit.framework.Assert.*; -// -// -//public class WiseFyPrerequisitesTests extends BaseTestClass { -// -// public WiseFyPrerequisitesTests() { -// super(TestActivity.class); -// } -// -// @Test -// public void hasPrerequisites_nullWifiManager() { -// WiseFyPrerequisites.getInstance().setConnectivityManager(mMockConnectivityManager); -// WiseFyPrerequisites.getInstance().setWifiManager(null); -// assertFalse(WiseFyPrerequisites.getInstance().hasPrerequisites()); -// } -// -// @Test -// public void hasPrerequisites_nullConnectivityManager() { -// WiseFyPrerequisites.getInstance().setConnectivityManager(null); -// WiseFyPrerequisites.getInstance().setWifiManager(mMockWiFiManager); -// assertFalse(WiseFyPrerequisites.getInstance().hasPrerequisites()); -// } -// -// @Test -// public void hasPrerequisites_noManagers() { -// WiseFyPrerequisites.getInstance().setConnectivityManager(null); -// WiseFyPrerequisites.getInstance().setWifiManager(null); -// assertFalse(WiseFyPrerequisites.getInstance().hasPrerequisites()); -// } -// -// @Test -// public void hasPrerequisites_bothManagers() { -// WiseFyPrerequisites.getInstance().setConnectivityManager(mMockConnectivityManager); -// WiseFyPrerequisites.getInstance().setWifiManager(mMockWiFiManager); -// assertTrue(WiseFyPrerequisites.getInstance().hasPrerequisites()); -// } -// -// @Test -// public void connectivityManager_getterAndSetter() { -// WiseFyPrerequisites.getInstance().setConnectivityManager(mMockConnectivityManager); -// assertEquals(mMockConnectivityManager, WiseFyPrerequisites.getInstance().getConnectivityManager()); -// } -// -// @Test -// public void wifiManager_getterAndSetter() { -// WiseFyPrerequisites.getInstance().setWifiManager(mMockWiFiManager); -// assertEquals(mMockWiFiManager, WiseFyPrerequisites.getInstance().getWifiManager()); -// } -//} +package com.isupatches.wisefy; + + +import org.junit.Test; +import static junit.framework.Assert.*; + + +public class WiseFyPrerequisitesTests extends BaseAndroidJUnit4TestClass { + + @Test + public void hasPrerequisites_nullWifiManager() { + WiseFyPrerequisites.getInstance().setConnectivityManager(mMockConnectivityManager); + WiseFyPrerequisites.getInstance().setWifiManager(null); + assertFalse(WiseFyPrerequisites.getInstance().hasPrerequisites()); + } + + @Test + public void hasPrerequisites_nullConnectivityManager() { + WiseFyPrerequisites.getInstance().setConnectivityManager(null); + WiseFyPrerequisites.getInstance().setWifiManager(mMockWiFiManager); + assertFalse(WiseFyPrerequisites.getInstance().hasPrerequisites()); + } + + @Test + public void hasPrerequisites_noManagers() { + WiseFyPrerequisites.getInstance().setConnectivityManager(null); + WiseFyPrerequisites.getInstance().setWifiManager(null); + assertFalse(WiseFyPrerequisites.getInstance().hasPrerequisites()); + } + + @Test + public void hasPrerequisites_bothManagers() { + WiseFyPrerequisites.getInstance().setConnectivityManager(mMockConnectivityManager); + WiseFyPrerequisites.getInstance().setWifiManager(mMockWiFiManager); + assertTrue(WiseFyPrerequisites.getInstance().hasPrerequisites()); + } + + @Test + public void connectivityManager_getterAndSetter() { + WiseFyPrerequisites.getInstance().setConnectivityManager(mMockConnectivityManager); + assertEquals(mMockConnectivityManager, WiseFyPrerequisites.getInstance().getConnectivityManager()); + } + + @Test + public void wifiManager_getterAndSetter() { + WiseFyPrerequisites.getInstance().setWifiManager(mMockWiFiManager); + assertEquals(mMockWiFiManager, WiseFyPrerequisites.getInstance().getWifiManager()); + } +} diff --git a/wisefy/src/androidTest/java/com/isupatches/wisefy/WiseFySearchTests.java b/wisefy/src/androidTest/java/com/isupatches/wisefy/WiseFySearchTests.java index a452837c..a69d045a 100644 --- a/wisefy/src/androidTest/java/com/isupatches/wisefy/WiseFySearchTests.java +++ b/wisefy/src/androidTest/java/com/isupatches/wisefy/WiseFySearchTests.java @@ -1,860 +1,856 @@ -//package com.isupatches.wisefy; -// -// -//import android.net.wifi.ScanResult; -//import android.net.wifi.WifiConfiguration; -//import com.isupatches.wisefy.base.TestActivity; -//import org.junit.Test; -//import java.util.ArrayList; -//import java.util.List; -//import static com.isupatches.wisefy.base.TestUtils.TEST_SSID; -//import static com.isupatches.wisefy.base.TestUtils.TEST_SSID2; -//import static com.isupatches.wisefy.base.TestUtils.TEST_SSID3; -//import static junit.framework.Assert.assertEquals; -//import static org.mockito.Mockito.mock; -//import static org.mockito.Mockito.when; -// -// -//public class WiseFySearchTests extends BaseTestClass { -// -// public WiseFySearchTests() { -// super(TestActivity.class); -// } -// -// /* -// * findAccessPointByRegex tests -// */ -// -// @Test -// public void findAccessPointByRegex_failure_nullAccessPoints_takeHighest_false() { -// when(mMockWiFiManager.getScanResults()).thenReturn(null); -// assertEquals(null, mWiseFy.mWiseFySearch.findAccessPointByRegex(TEST_SSID, 1000, false)); -// } -// -// @Test -// public void findAccessPointByRegex_failure_nullAccessPoints_takeHighest_true() { -// when(mMockWiFiManager.getScanResults()).thenReturn(null); -// assertEquals(null, mWiseFy.mWiseFySearch.findAccessPointByRegex(TEST_SSID, 1000, true)); -// } -// -// @Test -// public void findAccessPointByRegex_failure_emptyAccessPointList_takeHighest_false() { -// when(mMockWiFiManager.getScanResults()).thenReturn(new ArrayList()); -// assertEquals(null, mWiseFy.mWiseFySearch.findAccessPointByRegex(TEST_SSID, 1000, false)); -// } -// -// @Test -// public void findAccessPointByRegex_failure_emptyAccessPointList_takeHighest_true() { -// when(mMockWiFiManager.getScanResults()).thenReturn(new ArrayList()); -// assertEquals(null, mWiseFy.mWiseFySearch.findAccessPointByRegex(TEST_SSID, 1000, true)); -// } -// -// @Test -// public void findAccessPointByRegex_failure_nullAccessPoint_takeHighest_false() { -// List accessPoints = new ArrayList<>(); -// accessPoints.add(null); -// -// when(mMockWiFiManager.getScanResults()).thenReturn(accessPoints); -// assertEquals(null, mWiseFy.mWiseFySearch.findAccessPointByRegex(TEST_SSID, 1000, false)); -// } -// -// @Test -// public void findAccessPointByRegex_failure_nullAccessPoint_takeHighest_true() { -// List accessPoints = new ArrayList<>(); -// accessPoints.add(null); -// -// when(mMockWiFiManager.getScanResults()).thenReturn(accessPoints); -// assertEquals(null, mWiseFy.mWiseFySearch.findAccessPointByRegex(TEST_SSID, 1000, true)); -// } -// -// @Test -// public void findAccessPointByRegex_failure_nullSSID_takeHighest_false() { -// List accessPoints = new ArrayList<>(); -// -// ScanResult accessPoint= mock(ScanResult.class); -// accessPoint.SSID = null; -// accessPoints.add(accessPoint); -// -// when(mMockWiFiManager.getScanResults()).thenReturn(accessPoints); -// assertEquals(null, mWiseFy.mWiseFySearch.findAccessPointByRegex(TEST_SSID, 1000, false)); -// } -// -// @Test -// public void findAccessPointByRegex_failure_nullSSID_takeHighest_true() { -// List accessPoints = new ArrayList<>(); -// -// ScanResult accessPoint= mock(ScanResult.class); -// accessPoint.SSID = null; -// accessPoints.add(accessPoint); -// -// when(mMockWiFiManager.getScanResults()).thenReturn(accessPoints); -// assertEquals(null, mWiseFy.mWiseFySearch.findAccessPointByRegex(TEST_SSID, 1000, true)); -// } -// -// @Test -// public void findAccessPointByRegex_failure_nonMatchingSSID_takeHighest_false() { -// List accessPoints = new ArrayList<>(); -// -// ScanResult accessPoint= mock(ScanResult.class); -// accessPoint.SSID = TEST_SSID2; -// accessPoints.add(accessPoint); -// -// when(mMockWiFiManager.getScanResults()).thenReturn(accessPoints); -// assertEquals(null, mWiseFy.mWiseFySearch.findAccessPointByRegex(TEST_SSID, 1000, false)); -// } -// -// @Test -// public void findAccessPointByRegex_failure_nonMatchingSSID_takeHighest_true() { -// List accessPoints = new ArrayList<>(); -// -// ScanResult accessPoint= mock(ScanResult.class); -// accessPoint.SSID = TEST_SSID2; -// accessPoints.add(accessPoint); -// -// when(mMockWiFiManager.getScanResults()).thenReturn(accessPoints); -// assertEquals(null, mWiseFy.mWiseFySearch.findAccessPointByRegex(TEST_SSID, 1000, true)); -// } -// -// @Test -// public void findAccessPointByRegex_failure_multipleNonMatchingSSIDs_takeHighest_false() { -// List accessPoints = new ArrayList<>(); -// -// ScanResult accessPoint1 = mock(ScanResult.class); -// accessPoint1.SSID = TEST_SSID2; -// accessPoints.add(accessPoint1); -// -// ScanResult accessPoint2 = mock(ScanResult.class); -// accessPoint2.SSID = TEST_SSID3; -// accessPoints.add(accessPoint2); -// -// when(mMockWiFiManager.getScanResults()).thenReturn(accessPoints); -// assertEquals(null, mWiseFy.mWiseFySearch.findAccessPointByRegex(TEST_SSID, 1000, false)); -// } -// -// @Test -// public void findAccessPointByRegex_failure_multipleNnonMatchingSSIDs_takeHighest_true() { -// List accessPoints = new ArrayList<>(); -// -// ScanResult accessPoint1= mock(ScanResult.class); -// accessPoint1.SSID = TEST_SSID2; -// accessPoints.add(accessPoint1); -// -// ScanResult accessPoint2 = mock(ScanResult.class); -// accessPoint2.SSID = TEST_SSID3; -// accessPoints.add(accessPoint2); -// -// when(mMockWiFiManager.getScanResults()).thenReturn(accessPoints); -// assertEquals(null, mWiseFy.mWiseFySearch.findAccessPointByRegex(TEST_SSID, 1000, true)); -// } -// -// @Test -// public void findAccessPointByRegex_success_takeHighest_false() { -// List accessPoints = new ArrayList<>(); -// -// ScanResult accessPoint = mock(ScanResult.class); -// accessPoint.SSID = TEST_SSID; -// accessPoints.add(accessPoint); -// -// when(mMockWiFiManager.getScanResults()).thenReturn(accessPoints); -// assertEquals(accessPoint, mWiseFy.mWiseFySearch.findAccessPointByRegex(TEST_SSID, 1000, false)); -// } -// -// @Test -// public void findAccessPointByRegex_success_takeHighest_true() { -// List accessPoints = new ArrayList<>(); -// -// ScanResult accessPoint = mock(ScanResult.class); -// accessPoint.SSID = TEST_SSID; -// accessPoints.add(accessPoint); -// -// when(mMockWiFiManager.getScanResults()).thenReturn(accessPoints); -// assertEquals(accessPoint, mWiseFy.mWiseFySearch.findAccessPointByRegex(TEST_SSID, 1000, true)); -// } -// -// @Test -// public void findAccessPointByRegex_success_multipleSSIDs_takeHighest_false() { -// List accessPoints = new ArrayList<>(); -// -// ScanResult accessPoint1 = mock(ScanResult.class); -// accessPoint1.SSID = TEST_SSID; -// accessPoint1.level = -70; -// accessPoints.add(accessPoint1); -// -// ScanResult accessPoint2 = mock(ScanResult.class); -// accessPoint2.SSID = TEST_SSID2; -// accessPoint2.level = -50; -// accessPoints.add(accessPoint2); -// -// when(mMockWiFiManager.getScanResults()).thenReturn(accessPoints); -// assertEquals(accessPoint1, mWiseFy.mWiseFySearch.findAccessPointByRegex(TEST_SSID, 1000, false)); -// } -// -// @Test -// public void findAccessPointByRegex_success_multipleSSIDs_takeHighest_true() { -// List accessPoints = new ArrayList<>(); -// -// ScanResult accessPoint1 = mock(ScanResult.class); -// accessPoint1.SSID = TEST_SSID; -// accessPoint1.level = -70; -// accessPoints.add(accessPoint1); -// -// ScanResult accessPoint2 = mock(ScanResult.class); -// accessPoint2.SSID = TEST_SSID2; -// accessPoint2.level = -50; -// accessPoints.add(accessPoint2); -// -// when(mMockWiFiManager.getScanResults()).thenReturn(accessPoints); -// assertEquals(accessPoint1, mWiseFy.mWiseFySearch.findAccessPointByRegex(TEST_SSID, 1000, true)); -// } -// -// @Test -// public void findAccessPointByRegex_success_multipleSameSSIDs_takeHighest_false() { -// List accessPoints = new ArrayList<>(); -// -// ScanResult accessPoint1 = mock(ScanResult.class); -// accessPoint1.SSID = TEST_SSID; -// accessPoint1.level = -70; -// accessPoints.add(accessPoint1); -// -// ScanResult accessPoint2 = mock(ScanResult.class); -// accessPoint2.SSID = TEST_SSID; -// accessPoint2.level = -50; -// accessPoints.add(accessPoint2); -// -// when(mMockWiFiManager.getScanResults()).thenReturn(accessPoints); -// assertEquals(accessPoint1, mWiseFy.mWiseFySearch.findAccessPointByRegex(TEST_SSID, 1000, false)); -// } -// -// @Test -// public void findAccessPointByRegex_success_multipleSameSSIDs_takeHighest_true() { -// List accessPoints = new ArrayList<>(); -// -// ScanResult accessPoint1 = mock(ScanResult.class); -// accessPoint1.SSID = TEST_SSID; -// accessPoint1.level = -70; -// accessPoints.add(accessPoint1); -// -// ScanResult accessPoint2 = mock(ScanResult.class); -// accessPoint2.SSID = TEST_SSID; -// accessPoint2.level = -50; -// accessPoints.add(accessPoint2); -// -// when(mMockWiFiManager.getScanResults()).thenReturn(accessPoints); -// assertEquals(accessPoint2, mWiseFy.mWiseFySearch.findAccessPointByRegex(TEST_SSID, 1000, true)); -// } -// -// /* -// * findAccessPointsMatchingRegex tests -// */ -// -// @Test -// public void findAccessPointsMatchingRegex_failure_nullAccessPoints_takeHighest_false() { -// when(mMockWiFiManager.getScanResults()).thenReturn(null); -// assertEquals(null, mWiseFy.mWiseFySearch.findAccessPointsMatchingRegex(TEST_SSID, false)); -// } -// -// @Test -// public void findAccessPointsMatchingRegex_failure_nullAccessPoints_takeHighest_true() { -// when(mMockWiFiManager.getScanResults()).thenReturn(null); -// assertEquals(null, mWiseFy.mWiseFySearch.findAccessPointsMatchingRegex(TEST_SSID, true)); -// } -// -// @Test -// public void findAccessPointsMatchingRegex_failure_emptyAccessPointList_takeHighest_false() { -// when(mMockWiFiManager.getScanResults()).thenReturn(new ArrayList()); -// assertEquals(null, mWiseFy.mWiseFySearch.findAccessPointsMatchingRegex(TEST_SSID, false)); -// } -// -// @Test -// public void findAccessPointsMatchingRegex_failure_emptyAccessPointList_takeHighest_true() { -// when(mMockWiFiManager.getScanResults()).thenReturn(new ArrayList()); -// assertEquals(null, mWiseFy.mWiseFySearch.findAccessPointsMatchingRegex(TEST_SSID, true)); -// } -// -// @Test -// public void findAccessPointsMatchingRegex_failure_nullAccessPoint_takeHighest_false() { -// List accessPoints = new ArrayList<>(); -// accessPoints.add(null); -// -// when(mMockWiFiManager.getScanResults()).thenReturn(accessPoints); -// assertEquals(null, mWiseFy.mWiseFySearch.findAccessPointsMatchingRegex(TEST_SSID, false)); -// } -// -// @Test -// public void findAccessPointsMatchingRegex_failure_nullAccessPoint_takeHighest_true() { -// List accessPoints = new ArrayList<>(); -// accessPoints.add(null); -// -// when(mMockWiFiManager.getScanResults()).thenReturn(accessPoints); -// assertEquals(null, mWiseFy.mWiseFySearch.findAccessPointsMatchingRegex(TEST_SSID, true)); -// } -// -// @Test -// public void findAccessPointsMatchingRegex_failure_nullSSID_takeHighest_false() { -// List accessPoints = new ArrayList<>(); -// -// ScanResult accessPoint= mock(ScanResult.class); -// accessPoint.SSID = null; -// accessPoints.add(accessPoint); -// -// when(mMockWiFiManager.getScanResults()).thenReturn(accessPoints); -// assertEquals(null, mWiseFy.mWiseFySearch.findAccessPointsMatchingRegex(TEST_SSID, false)); -// } -// -// @Test -// public void findAccessPointsMatchingRegex_failure_nullSSID_takeHighest_true() { -// List accessPoints = new ArrayList<>(); -// -// ScanResult accessPoint= mock(ScanResult.class); -// accessPoint.SSID = null; -// accessPoints.add(accessPoint); -// -// when(mMockWiFiManager.getScanResults()).thenReturn(accessPoints); -// assertEquals(null, mWiseFy.mWiseFySearch.findAccessPointsMatchingRegex(TEST_SSID, true)); -// } -// -// @Test -// public void findAccessPointsMatchingRegex_failure_nonMatchingSSID_takeHighest_false() { -// List accessPoints = new ArrayList<>(); -// -// ScanResult accessPoint= mock(ScanResult.class); -// accessPoint.SSID = TEST_SSID2; -// accessPoints.add(accessPoint); -// -// when(mMockWiFiManager.getScanResults()).thenReturn(accessPoints); -// assertEquals(null, mWiseFy.mWiseFySearch.findAccessPointsMatchingRegex(TEST_SSID, false)); -// } -// -// @Test -// public void findAccessPointsMatchingRegex_failure_nonMatchingSSID_takeHighest_true() { -// List accessPoints = new ArrayList<>(); -// -// ScanResult accessPoint= mock(ScanResult.class); -// accessPoint.SSID = TEST_SSID2; -// accessPoints.add(accessPoint); -// -// when(mMockWiFiManager.getScanResults()).thenReturn(accessPoints); -// assertEquals(null, mWiseFy.mWiseFySearch.findAccessPointsMatchingRegex(TEST_SSID, true)); -// } -// -// @Test -// public void findAccessPointsMatchingRegex_failure_multipleNonMatchingSSIDs_takeHighest_false() { -// List accessPoints = new ArrayList<>(); -// -// ScanResult accessPoint1 = mock(ScanResult.class); -// accessPoint1.SSID = TEST_SSID2; -// accessPoints.add(accessPoint1); -// -// ScanResult accessPoint2 = mock(ScanResult.class); -// accessPoint2.SSID = TEST_SSID3; -// accessPoints.add(accessPoint2); -// -// when(mMockWiFiManager.getScanResults()).thenReturn(accessPoints); -// assertEquals(null, mWiseFy.mWiseFySearch.findAccessPointsMatchingRegex(TEST_SSID, false)); -// } -// -// @Test -// public void findAccessPointsMatchingRegex_failure_multipleNnonMatchingSSIDs_takeHighest_true() { -// List accessPoints = new ArrayList<>(); -// -// ScanResult accessPoint1= mock(ScanResult.class); -// accessPoint1.SSID = TEST_SSID2; -// accessPoints.add(accessPoint1); -// -// ScanResult accessPoint2 = mock(ScanResult.class); -// accessPoint2.SSID = TEST_SSID3; -// accessPoints.add(accessPoint2); -// -// when(mMockWiFiManager.getScanResults()).thenReturn(accessPoints); -// assertEquals(null, mWiseFy.mWiseFySearch.findAccessPointsMatchingRegex(TEST_SSID, true)); -// } -// -// @Test -// public void findAccessPointsMatchingRegex_success_takeHighest_false() { -// List accessPoints = new ArrayList<>(); -// -// ScanResult accessPoint = mock(ScanResult.class); -// accessPoint.SSID = TEST_SSID; -// accessPoints.add(accessPoint); -// -// when(mMockWiFiManager.getScanResults()).thenReturn(accessPoints); -// assertEquals(accessPoints, mWiseFy.mWiseFySearch.findAccessPointsMatchingRegex(TEST_SSID, false)); -// } -// -// @Test -// public void findAccessPointsMatchingRegex_success_takeHighest_true() { -// List accessPoints = new ArrayList<>(); -// -// ScanResult accessPoint = mock(ScanResult.class); -// accessPoint.SSID = TEST_SSID; -// accessPoints.add(accessPoint); -// -// when(mMockWiFiManager.getScanResults()).thenReturn(accessPoints); -// assertEquals(accessPoints, mWiseFy.mWiseFySearch.findAccessPointsMatchingRegex(TEST_SSID, true)); -// } -// -// @Test -// public void findAccessPointsMatchingRegex_success_multipleSSIDs_takeHighest_false() { -// List accessPoints = new ArrayList<>(); -// List expectedResults = new ArrayList<>(); -// -// ScanResult accessPoint1 = mock(ScanResult.class); -// accessPoint1.SSID = TEST_SSID; -// accessPoint1.level = -70; -// accessPoints.add(accessPoint1); -// expectedResults.add(accessPoint1); -// -// ScanResult accessPoint2 = mock(ScanResult.class); -// accessPoint2.SSID = TEST_SSID2; -// accessPoint2.level = -50; -// accessPoints.add(accessPoint2); -// -// when(mMockWiFiManager.getScanResults()).thenReturn(accessPoints); -// assertEquals(expectedResults, mWiseFy.mWiseFySearch.findAccessPointsMatchingRegex(TEST_SSID, false)); -// } -// -// @Test -// public void findAccessPointsMatchingRegex_success_multipleSSIDs_takeHighest_true() { -// List accessPoints = new ArrayList<>(); -// List expectedResults = new ArrayList<>(); -// -// ScanResult accessPoint1 = mock(ScanResult.class); -// accessPoint1.SSID = TEST_SSID; -// accessPoint1.level = -70; -// accessPoints.add(accessPoint1); -// expectedResults.add(accessPoint1); -// -// ScanResult accessPoint2 = mock(ScanResult.class); -// accessPoint2.SSID = TEST_SSID2; -// accessPoint2.level = -50; -// accessPoints.add(accessPoint2); -// -// when(mMockWiFiManager.getScanResults()).thenReturn(accessPoints); -// assertEquals(expectedResults, mWiseFy.mWiseFySearch.findAccessPointsMatchingRegex(TEST_SSID, true)); -// } -// -// @Test -// public void findAccessPointsMatchingRegex_success_multipleSameSSIDs_takeHighest_false() { -// List accessPoints = new ArrayList<>(); -// List expectedResults = new ArrayList<>(); -// -// ScanResult accessPoint1 = mock(ScanResult.class); -// accessPoint1.SSID = TEST_SSID; -// accessPoint1.level = -70; -// accessPoints.add(accessPoint1); -// expectedResults.add(accessPoint1); -// -// ScanResult accessPoint2 = mock(ScanResult.class); -// accessPoint2.SSID = TEST_SSID; -// accessPoint2.level = -50; -// accessPoints.add(accessPoint2); -// expectedResults.add(accessPoint2); -// -// when(mMockWiFiManager.getScanResults()).thenReturn(accessPoints); -// assertEquals(expectedResults, mWiseFy.mWiseFySearch.findAccessPointsMatchingRegex(TEST_SSID, false)); -// } -// -// @Test -// public void findAccessPointsMatchingRegex_success_multipleSameSSIDs_takeHighest_true() { -// List accessPoints = new ArrayList<>(); -// List expectedResults = new ArrayList<>(); -// -// ScanResult accessPoint1 = mock(ScanResult.class); -// accessPoint1.SSID = TEST_SSID; -// accessPoint1.level = -70; -// accessPoints.add(accessPoint1); -// -// ScanResult accessPoint2 = mock(ScanResult.class); -// accessPoint2.SSID = TEST_SSID; -// accessPoint2.level = -50; -// accessPoints.add(accessPoint2); -// expectedResults.add(accessPoint2); -// -// when(mMockWiFiManager.getScanResults()).thenReturn(accessPoints); -// assertEquals(expectedResults, mWiseFy.mWiseFySearch.findAccessPointsMatchingRegex(TEST_SSID, true)); -// } -// -// /* -// * findSavedNetworkByRegex tests -// */ -// -// @Test -// public void findSavedNetworkByRegex_failure_nullSavedNetworkList() { -// when(mMockWiFiManager.getConfiguredNetworks()).thenReturn(null); -// assertEquals(null, mWiseFy.mWiseFySearch.findSavedNetworkByRegex(TEST_SSID)); -// } -// -// @Test -// public void findSavedNetworkByRegex_failure_emptySavedNetworkList() { -// when(mMockWiFiManager.getConfiguredNetworks()).thenReturn(new ArrayList()); -// assertEquals(null, mWiseFy.mWiseFySearch.findSavedNetworkByRegex(TEST_SSID)); -// } -// -// @Test -// public void findSavedNetworkByRegex_failure_nullWifiConfiguration() { -// List wifiList = new ArrayList<>(); -// wifiList.add(null); -// -// when(mMockWiFiManager.getConfiguredNetworks()).thenReturn(wifiList); -// assertEquals(null, mWiseFy.mWiseFySearch.findSavedNetworkByRegex(TEST_SSID)); -// } -// -// @Test -// public void findSavedNetworkByRegex_failure_nullSSID() { -// List wifiList = new ArrayList<>(); -// WifiConfiguration mWiFiConfiguration = new WifiConfiguration(); -// mWiFiConfiguration.SSID = null; -// wifiList.add(mWiFiConfiguration); -// -// when(mMockWiFiManager.getConfiguredNetworks()).thenReturn(wifiList); -// assertEquals(null, mWiseFy.mWiseFySearch.findSavedNetworkByRegex(TEST_SSID)); -// } -// -// @Test -// public void findSavedNetworkByRegex_failure_nonMatchingSSID() { -// List wifiList = new ArrayList<>(); -// -// WifiConfiguration mWiFiConfiguration = new WifiConfiguration(); -// mWiFiConfiguration.SSID = TEST_SSID2; -// wifiList.add(mWiFiConfiguration); -// -// when(mMockWiFiManager.getConfiguredNetworks()).thenReturn(wifiList); -// assertEquals(null, mWiseFy.mWiseFySearch.findSavedNetworkByRegex(TEST_SSID)); -// } -// -// @Test -// public void findSavedNetworkByRegex_failure_multipleNonMatchingSSIDs() { -// List wifiList = new ArrayList<>(); -// -// WifiConfiguration mWiFiConfiguration1 = new WifiConfiguration(); -// mWiFiConfiguration1.SSID = TEST_SSID2; -// wifiList.add(mWiFiConfiguration1); -// -// WifiConfiguration mWiFiConfiguration2 = new WifiConfiguration(); -// mWiFiConfiguration2.SSID = TEST_SSID3; -// wifiList.add(mWiFiConfiguration2); -// -// when(mMockWiFiManager.getConfiguredNetworks()).thenReturn(wifiList); -// assertEquals(null, mWiseFy.mWiseFySearch.findSavedNetworkByRegex(TEST_SSID)); -// } -// -// @Test -// public void findSavedNetworkByRegex_success() { -// List wifiList = new ArrayList<>(); -// -// WifiConfiguration mWiFiConfiguration = new WifiConfiguration(); -// mWiFiConfiguration.SSID = TEST_SSID; -// wifiList.add(mWiFiConfiguration); -// -// when(mMockWiFiManager.getConfiguredNetworks()).thenReturn(wifiList); -// assertEquals(mWiFiConfiguration, mWiseFy.mWiseFySearch.findSavedNetworkByRegex(TEST_SSID)); -// } -// -// @Test -// public void findSavedNetworkByRegex_success_multipleSSIDs() { -// List wifiList = new ArrayList<>(); -// -// WifiConfiguration mWiFiConfiguration1 = new WifiConfiguration(); -// mWiFiConfiguration1.SSID = TEST_SSID; -// wifiList.add(mWiFiConfiguration1); -// -// WifiConfiguration mWiFiConfiguration2 = new WifiConfiguration(); -// mWiFiConfiguration2.SSID = TEST_SSID2; -// wifiList.add(mWiFiConfiguration2); -// -// when(mMockWiFiManager.getConfiguredNetworks()).thenReturn(wifiList); -// assertEquals(mWiFiConfiguration1, mWiseFy.mWiseFySearch.findSavedNetworkByRegex(TEST_SSID)); -// } -// -// /* -// * findSavedNetworksMatchingRegex tests -// */ -// -// @Test -// public void findSavedNetworksMatchingRegex_failure_nullSavedNetworkList() { -// when(mMockWiFiManager.getConfiguredNetworks()).thenReturn(null); -// assertEquals(null, mWiseFy.mWiseFySearch.findSavedNetworksMatchingRegex(TEST_SSID)); -// } -// -// @Test -// public void findSavedNetworksMatchingRegex_failure_emptySavedNetworkList() { -// when(mMockWiFiManager.getConfiguredNetworks()).thenReturn(new ArrayList()); -// assertEquals(null, mWiseFy.mWiseFySearch.findSavedNetworksMatchingRegex(TEST_SSID)); -// } -// -// @Test -// public void findSavedNetworksMatchingRegex_failure_nullWifiConfiguration() { -// List wifiList = new ArrayList<>(); -// wifiList.add(null); -// -// when(mMockWiFiManager.getConfiguredNetworks()).thenReturn(wifiList); -// assertEquals(null, mWiseFy.mWiseFySearch.findSavedNetworksMatchingRegex(TEST_SSID)); -// } -// -// @Test -// public void findSavedNetworksMatchingRegex_failure_nullSSID() { -// List wifiList = new ArrayList<>(); -// WifiConfiguration mWiFiConfiguration = new WifiConfiguration(); -// mWiFiConfiguration.SSID = null; -// wifiList.add(mWiFiConfiguration); -// -// when(mMockWiFiManager.getConfiguredNetworks()).thenReturn(wifiList); -// assertEquals(null, mWiseFy.mWiseFySearch.findSavedNetworksMatchingRegex(TEST_SSID)); -// } -// -// @Test -// public void findSavedNetworksMatchingRegex_failure_nonMatchingSSID() { -// List wifiList = new ArrayList<>(); -// WifiConfiguration mWiFiConfiguration = new WifiConfiguration(); -// mWiFiConfiguration.SSID = TEST_SSID2; -// wifiList.add(mWiFiConfiguration); -// -// when(mMockWiFiManager.getConfiguredNetworks()).thenReturn(wifiList); -// assertEquals(null, mWiseFy.mWiseFySearch.findSavedNetworksMatchingRegex(TEST_SSID)); -// } -// -// @Test -// public void findSavedNetworksMatchingRegex_failure_multipleNonMatchingSSIDs() { -// List wifiList = new ArrayList<>(); -// -// WifiConfiguration mWiFiConfiguration1 = new WifiConfiguration(); -// mWiFiConfiguration1.SSID = TEST_SSID2; -// wifiList.add(mWiFiConfiguration1); -// -// WifiConfiguration mWiFiConfiguration2 = new WifiConfiguration(); -// mWiFiConfiguration2.SSID = TEST_SSID3; -// wifiList.add(mWiFiConfiguration2); -// -// when(mMockWiFiManager.getConfiguredNetworks()).thenReturn(wifiList); -// assertEquals(null, mWiseFy.mWiseFySearch.findSavedNetworksMatchingRegex(TEST_SSID)); -// } -// -// @Test -// public void findSavedNetworksMatchingRegex_success() { -// List wifiList = new ArrayList<>(); -// -// WifiConfiguration mWiFiConfiguration = new WifiConfiguration(); -// mWiFiConfiguration.SSID = TEST_SSID; -// wifiList.add(mWiFiConfiguration); -// -// when(mMockWiFiManager.getConfiguredNetworks()).thenReturn(wifiList); -// assertEquals(wifiList, mWiseFy.mWiseFySearch.findSavedNetworksMatchingRegex(TEST_SSID)); -// } -// -// @Test -// public void findSavedNetworksMatchingRegex_success_multipleSSIDs() { -// List wifiList = new ArrayList<>(); -// -// WifiConfiguration mWiFiConfiguration1 = new WifiConfiguration(); -// mWiFiConfiguration1.SSID = TEST_SSID; -// wifiList.add(mWiFiConfiguration1); -// -// WifiConfiguration mWiFiConfiguration2 = new WifiConfiguration(); -// mWiFiConfiguration2.SSID = TEST_SSID2; -// wifiList.add(mWiFiConfiguration2); -// -// when(mMockWiFiManager.getConfiguredNetworks()).thenReturn(wifiList); -// assertEquals(wifiList, mWiseFy.mWiseFySearch.findSavedNetworksMatchingRegex(".*Test.*")); -// } -// -// /* -// * findSSIDsMatchingRegex tests -// */ -// -// @Test -// public void findSSIDsMatchingRegex_failure_nullAccessPoints() { -// when(mMockWiFiManager.getScanResults()).thenReturn(null); -// assertEquals(null, mWiseFy.mWiseFySearch.findSSIDsMatchingRegex(TEST_SSID)); -// } -// -// @Test -// public void findSSIDsMatchingRegex_failure_emptySavedNetworkList() { -// when(mMockWiFiManager.getScanResults()).thenReturn(new ArrayList()); -// assertEquals(null, mWiseFy.mWiseFySearch.findSSIDsMatchingRegex(TEST_SSID)); -// } -// -// @Test -// public void findSSIDsMatchingRegex_failure_nullWifiConfiguration() { -// List accessPoints = new ArrayList<>(); -// accessPoints.add(null); -// -// when(mMockWiFiManager.getScanResults()).thenReturn(accessPoints); -// assertEquals(null, mWiseFy.mWiseFySearch.findSSIDsMatchingRegex(TEST_SSID)); -// } -// -// @Test -// public void findSSIDsMatchingRegex_failure_nullSSID() { -// List accessPoints = new ArrayList<>(); -// -// ScanResult accessPoint = mock(ScanResult.class); -// accessPoint.SSID = null; -// accessPoints.add(accessPoint); -// -// when(mMockWiFiManager.getScanResults()).thenReturn(accessPoints); -// assertEquals(null, mWiseFy.mWiseFySearch.findSSIDsMatchingRegex(TEST_SSID)); -// } -// -// @Test -// public void findSSIDsMatchingRegex_failure_nonMatchingSSID() { -// List accessPoints = new ArrayList<>(); -// -// ScanResult accessPoint = mock(ScanResult.class); -// accessPoint.SSID = TEST_SSID2; -// accessPoints.add(accessPoint); -// -// when(mMockWiFiManager.getScanResults()).thenReturn(accessPoints); -// assertEquals(null, mWiseFy.mWiseFySearch.findSSIDsMatchingRegex(TEST_SSID)); -// } -// -// @Test -// public void findSSIDsMatchingRegex_failure_multipleNonMatchingSSIDs() { -// List accessPoints = new ArrayList<>(); -// -// ScanResult accessPoint1 = mock(ScanResult.class); -// accessPoint1.SSID = TEST_SSID2; -// accessPoints.add(accessPoint1); -// -// ScanResult accessPoint2 = mock(ScanResult.class); -// accessPoint2.SSID = TEST_SSID3; -// accessPoints.add(accessPoint2); -// -// when(mMockWiFiManager.getScanResults()).thenReturn(accessPoints); -// assertEquals(null, mWiseFy.mWiseFySearch.findSSIDsMatchingRegex(TEST_SSID)); -// } -// -// @Test -// public void findSSIDsMatchingRegex_success() { -// List accessPoints = new ArrayList<>(); -// List expectedResults = new ArrayList<>(); -// -// ScanResult accessPoint = mock(ScanResult.class); -// accessPoint.SSID = TEST_SSID; -// accessPoints.add(accessPoint); -// expectedResults.add(TEST_SSID); -// -// when(mMockWiFiManager.getScanResults()).thenReturn(accessPoints); -// assertEquals(expectedResults, mWiseFy.mWiseFySearch.findSSIDsMatchingRegex(TEST_SSID)); -// } -// -// @Test -// public void findSSIDsMatchingRegex_success_multipleSSIDs() { -// List accessPoints = new ArrayList<>(); -// List expectedResults = new ArrayList<>(); -// -// ScanResult accessPoint1 = mock(ScanResult.class); -// accessPoint1.SSID = TEST_SSID; -// accessPoints.add(accessPoint1); -// expectedResults.add(TEST_SSID); -// -// ScanResult accessPoint2 = mock(ScanResult.class); -// accessPoint2.SSID = TEST_SSID; -// accessPoints.add(accessPoint2); -// expectedResults.add(TEST_SSID); -// -// when(mMockWiFiManager.getScanResults()).thenReturn(accessPoints); -// assertEquals(expectedResults, mWiseFy.mWiseFySearch.findSSIDsMatchingRegex(".*Test.*")); -// } -// -// /* -// * isNetworkASavedConfiguration tests -// */ -// -// @Test -// public void isNetworkASavedConfiguration_failure() { -// when(mMockWiFiManager.getConfiguredNetworks()).thenReturn(new ArrayList()); -// assertEquals(false, mWiseFy.mWiseFySearch.isNetworkASavedConfiguration(TEST_SSID)); -// } -// -// @Test -// public void isNetworkASavedConfiguration_success() { -// List wifiList = new ArrayList<>(); -// -// WifiConfiguration mWiFiConfiguration = new WifiConfiguration(); -// mWiFiConfiguration.SSID = TEST_SSID; -// wifiList.add(mWiFiConfiguration); -// -// when(mMockWiFiManager.getConfiguredNetworks()).thenReturn(wifiList); -// assertEquals(true, mWiseFy.mWiseFySearch.isNetworkASavedConfiguration(TEST_SSID)); -// } -// -// /* -// * removeEntriesWithLowerSignalStrength tests -// */ -// -// @Test -// public void removeEntriesWithLowerSignalStrength_differentSSIDs() { -// List accessPoints = new ArrayList<>(); -// List expectedResults = new ArrayList<>(); -// -// ScanResult accessPoint1 = mock(ScanResult.class); -// accessPoint1.SSID = TEST_SSID; -// accessPoint1.level = -70; -// accessPoints.add(accessPoint1); -// expectedResults.add(accessPoint1); -// -// ScanResult accessPoint2 = mock(ScanResult.class); -// accessPoint2.SSID = TEST_SSID2; -// accessPoint2.level = -50; -// accessPoints.add(accessPoint2); -// expectedResults.add(accessPoint2); -// -// assertEquals(expectedResults, mWiseFy.mWiseFySearch.removeEntriesWithLowerSignalStrength(accessPoints)); -// } -// -// @Test -// public void removeEntriesWithLowerSignalStrength_sameSignalLevels() { -// List accessPoints = new ArrayList<>(); -// List expectedResults = new ArrayList<>(); -// -// ScanResult accessPoint1 = mock(ScanResult.class); -// accessPoint1.SSID = TEST_SSID; -// accessPoint1.level = -70; -// accessPoints.add(accessPoint1); -// expectedResults.add(accessPoint1); -// -// ScanResult accessPoint2 = mock(ScanResult.class); -// accessPoint2.SSID = TEST_SSID; -// accessPoint2.level = -70; -// accessPoints.add(accessPoint2); -// -// assertEquals(expectedResults, mWiseFy.mWiseFySearch.removeEntriesWithLowerSignalStrength(accessPoints)); -// } -// -// @Test -// public void removeEntriesWithLowerSignalStrength_accessPoint1Higher() { -// List accessPoints = new ArrayList<>(); -// List expectedResults = new ArrayList<>(); -// -// ScanResult accessPoint1 = mock(ScanResult.class); -// accessPoint1.SSID = TEST_SSID; -// accessPoint1.level = -50; -// accessPoints.add(accessPoint1); -// expectedResults.add(accessPoint1); -// -// ScanResult accessPoint2 = mock(ScanResult.class); -// accessPoint2.SSID = TEST_SSID; -// accessPoint2.level = -70; -// accessPoints.add(accessPoint2); -// -// assertEquals(expectedResults , mWiseFy.mWiseFySearch.removeEntriesWithLowerSignalStrength(accessPoints)); -// } -// -// @Test -// public void removeEntriesWithLowerSignalStrength_accessPoint2Higher() { -// List accessPoints = new ArrayList<>(); -// List expectedResults = new ArrayList<>(); -// -// ScanResult accessPoint1 = mock(ScanResult.class); -// accessPoint1.SSID = TEST_SSID; -// accessPoints.add(accessPoint1); -// accessPoint1.level = -70; -// -// ScanResult accessPoint2 = mock(ScanResult.class); -// accessPoint2.SSID = TEST_SSID; -// accessPoint2.level = -50; -// accessPoints.add(accessPoint2); -// expectedResults.add(accessPoint2); -// -// assertEquals(expectedResults , mWiseFy.mWiseFySearch.removeEntriesWithLowerSignalStrength(accessPoints)); -// } -//} +package com.isupatches.wisefy; + + +import android.net.wifi.ScanResult; +import android.net.wifi.WifiConfiguration; +import org.junit.Test; +import java.util.ArrayList; +import java.util.List; +import static com.isupatches.wisefy.base.TestUtils.TEST_SSID; +import static com.isupatches.wisefy.base.TestUtils.TEST_SSID2; +import static com.isupatches.wisefy.base.TestUtils.TEST_SSID3; +import static junit.framework.Assert.assertEquals; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; + + +public class WiseFySearchTests extends BaseAndroidJUnit4TestClass { + + + /* + * findAccessPointByRegex tests + */ + + @Test + public void findAccessPointByRegex_failure_nullAccessPoints_takeHighest_false() { + when(mMockWiFiManager.getScanResults()).thenReturn(null); + assertEquals(null, mWiseFy.mWiseFySearch.findAccessPointByRegex(TEST_SSID, 1000, false)); + } + + @Test + public void findAccessPointByRegex_failure_nullAccessPoints_takeHighest_true() { + when(mMockWiFiManager.getScanResults()).thenReturn(null); + assertEquals(null, mWiseFy.mWiseFySearch.findAccessPointByRegex(TEST_SSID, 1000, true)); + } + + @Test + public void findAccessPointByRegex_failure_emptyAccessPointList_takeHighest_false() { + when(mMockWiFiManager.getScanResults()).thenReturn(new ArrayList()); + assertEquals(null, mWiseFy.mWiseFySearch.findAccessPointByRegex(TEST_SSID, 1000, false)); + } + + @Test + public void findAccessPointByRegex_failure_emptyAccessPointList_takeHighest_true() { + when(mMockWiFiManager.getScanResults()).thenReturn(new ArrayList()); + assertEquals(null, mWiseFy.mWiseFySearch.findAccessPointByRegex(TEST_SSID, 1000, true)); + } + + @Test + public void findAccessPointByRegex_failure_nullAccessPoint_takeHighest_false() { + List accessPoints = new ArrayList<>(); + accessPoints.add(null); + + when(mMockWiFiManager.getScanResults()).thenReturn(accessPoints); + assertEquals(null, mWiseFy.mWiseFySearch.findAccessPointByRegex(TEST_SSID, 1000, false)); + } + + @Test + public void findAccessPointByRegex_failure_nullAccessPoint_takeHighest_true() { + List accessPoints = new ArrayList<>(); + accessPoints.add(null); + + when(mMockWiFiManager.getScanResults()).thenReturn(accessPoints); + assertEquals(null, mWiseFy.mWiseFySearch.findAccessPointByRegex(TEST_SSID, 1000, true)); + } + + @Test + public void findAccessPointByRegex_failure_nullSSID_takeHighest_false() { + List accessPoints = new ArrayList<>(); + + ScanResult accessPoint= mock(ScanResult.class); + accessPoint.SSID = null; + accessPoints.add(accessPoint); + + when(mMockWiFiManager.getScanResults()).thenReturn(accessPoints); + assertEquals(null, mWiseFy.mWiseFySearch.findAccessPointByRegex(TEST_SSID, 1000, false)); + } + + @Test + public void findAccessPointByRegex_failure_nullSSID_takeHighest_true() { + List accessPoints = new ArrayList<>(); + + ScanResult accessPoint= mock(ScanResult.class); + accessPoint.SSID = null; + accessPoints.add(accessPoint); + + when(mMockWiFiManager.getScanResults()).thenReturn(accessPoints); + assertEquals(null, mWiseFy.mWiseFySearch.findAccessPointByRegex(TEST_SSID, 1000, true)); + } + + @Test + public void findAccessPointByRegex_failure_nonMatchingSSID_takeHighest_false() { + List accessPoints = new ArrayList<>(); + + ScanResult accessPoint= mock(ScanResult.class); + accessPoint.SSID = TEST_SSID2; + accessPoints.add(accessPoint); + + when(mMockWiFiManager.getScanResults()).thenReturn(accessPoints); + assertEquals(null, mWiseFy.mWiseFySearch.findAccessPointByRegex(TEST_SSID, 1000, false)); + } + + @Test + public void findAccessPointByRegex_failure_nonMatchingSSID_takeHighest_true() { + List accessPoints = new ArrayList<>(); + + ScanResult accessPoint= mock(ScanResult.class); + accessPoint.SSID = TEST_SSID2; + accessPoints.add(accessPoint); + + when(mMockWiFiManager.getScanResults()).thenReturn(accessPoints); + assertEquals(null, mWiseFy.mWiseFySearch.findAccessPointByRegex(TEST_SSID, 1000, true)); + } + + @Test + public void findAccessPointByRegex_failure_multipleNonMatchingSSIDs_takeHighest_false() { + List accessPoints = new ArrayList<>(); + + ScanResult accessPoint1 = mock(ScanResult.class); + accessPoint1.SSID = TEST_SSID2; + accessPoints.add(accessPoint1); + + ScanResult accessPoint2 = mock(ScanResult.class); + accessPoint2.SSID = TEST_SSID3; + accessPoints.add(accessPoint2); + + when(mMockWiFiManager.getScanResults()).thenReturn(accessPoints); + assertEquals(null, mWiseFy.mWiseFySearch.findAccessPointByRegex(TEST_SSID, 1000, false)); + } + + @Test + public void findAccessPointByRegex_failure_multipleNnonMatchingSSIDs_takeHighest_true() { + List accessPoints = new ArrayList<>(); + + ScanResult accessPoint1= mock(ScanResult.class); + accessPoint1.SSID = TEST_SSID2; + accessPoints.add(accessPoint1); + + ScanResult accessPoint2 = mock(ScanResult.class); + accessPoint2.SSID = TEST_SSID3; + accessPoints.add(accessPoint2); + + when(mMockWiFiManager.getScanResults()).thenReturn(accessPoints); + assertEquals(null, mWiseFy.mWiseFySearch.findAccessPointByRegex(TEST_SSID, 1000, true)); + } + + @Test + public void findAccessPointByRegex_success_takeHighest_false() { + List accessPoints = new ArrayList<>(); + + ScanResult accessPoint = mock(ScanResult.class); + accessPoint.SSID = TEST_SSID; + accessPoints.add(accessPoint); + + when(mMockWiFiManager.getScanResults()).thenReturn(accessPoints); + assertEquals(accessPoint, mWiseFy.mWiseFySearch.findAccessPointByRegex(TEST_SSID, 1000, false)); + } + + @Test + public void findAccessPointByRegex_success_takeHighest_true() { + List accessPoints = new ArrayList<>(); + + ScanResult accessPoint = mock(ScanResult.class); + accessPoint.SSID = TEST_SSID; + accessPoints.add(accessPoint); + + when(mMockWiFiManager.getScanResults()).thenReturn(accessPoints); + assertEquals(accessPoint, mWiseFy.mWiseFySearch.findAccessPointByRegex(TEST_SSID, 1000, true)); + } + + @Test + public void findAccessPointByRegex_success_multipleSSIDs_takeHighest_false() { + List accessPoints = new ArrayList<>(); + + ScanResult accessPoint1 = mock(ScanResult.class); + accessPoint1.SSID = TEST_SSID; + accessPoint1.level = -70; + accessPoints.add(accessPoint1); + + ScanResult accessPoint2 = mock(ScanResult.class); + accessPoint2.SSID = TEST_SSID2; + accessPoint2.level = -50; + accessPoints.add(accessPoint2); + + when(mMockWiFiManager.getScanResults()).thenReturn(accessPoints); + assertEquals(accessPoint1, mWiseFy.mWiseFySearch.findAccessPointByRegex(TEST_SSID, 1000, false)); + } + + @Test + public void findAccessPointByRegex_success_multipleSSIDs_takeHighest_true() { + List accessPoints = new ArrayList<>(); + + ScanResult accessPoint1 = mock(ScanResult.class); + accessPoint1.SSID = TEST_SSID; + accessPoint1.level = -70; + accessPoints.add(accessPoint1); + + ScanResult accessPoint2 = mock(ScanResult.class); + accessPoint2.SSID = TEST_SSID2; + accessPoint2.level = -50; + accessPoints.add(accessPoint2); + + when(mMockWiFiManager.getScanResults()).thenReturn(accessPoints); + assertEquals(accessPoint1, mWiseFy.mWiseFySearch.findAccessPointByRegex(TEST_SSID, 1000, true)); + } + + @Test + public void findAccessPointByRegex_success_multipleSameSSIDs_takeHighest_false() { + List accessPoints = new ArrayList<>(); + + ScanResult accessPoint1 = mock(ScanResult.class); + accessPoint1.SSID = TEST_SSID; + accessPoint1.level = -70; + accessPoints.add(accessPoint1); + + ScanResult accessPoint2 = mock(ScanResult.class); + accessPoint2.SSID = TEST_SSID; + accessPoint2.level = -50; + accessPoints.add(accessPoint2); + + when(mMockWiFiManager.getScanResults()).thenReturn(accessPoints); + assertEquals(accessPoint1, mWiseFy.mWiseFySearch.findAccessPointByRegex(TEST_SSID, 1000, false)); + } + + @Test + public void findAccessPointByRegex_success_multipleSameSSIDs_takeHighest_true() { + List accessPoints = new ArrayList<>(); + + ScanResult accessPoint1 = mock(ScanResult.class); + accessPoint1.SSID = TEST_SSID; + accessPoint1.level = -70; + accessPoints.add(accessPoint1); + + ScanResult accessPoint2 = mock(ScanResult.class); + accessPoint2.SSID = TEST_SSID; + accessPoint2.level = -50; + accessPoints.add(accessPoint2); + + when(mMockWiFiManager.getScanResults()).thenReturn(accessPoints); + assertEquals(accessPoint2, mWiseFy.mWiseFySearch.findAccessPointByRegex(TEST_SSID, 1000, true)); + } + + /* + * findAccessPointsMatchingRegex tests + */ + + @Test + public void findAccessPointsMatchingRegex_failure_nullAccessPoints_takeHighest_false() { + when(mMockWiFiManager.getScanResults()).thenReturn(null); + assertEquals(null, mWiseFy.mWiseFySearch.findAccessPointsMatchingRegex(TEST_SSID, false)); + } + + @Test + public void findAccessPointsMatchingRegex_failure_nullAccessPoints_takeHighest_true() { + when(mMockWiFiManager.getScanResults()).thenReturn(null); + assertEquals(null, mWiseFy.mWiseFySearch.findAccessPointsMatchingRegex(TEST_SSID, true)); + } + + @Test + public void findAccessPointsMatchingRegex_failure_emptyAccessPointList_takeHighest_false() { + when(mMockWiFiManager.getScanResults()).thenReturn(new ArrayList()); + assertEquals(null, mWiseFy.mWiseFySearch.findAccessPointsMatchingRegex(TEST_SSID, false)); + } + + @Test + public void findAccessPointsMatchingRegex_failure_emptyAccessPointList_takeHighest_true() { + when(mMockWiFiManager.getScanResults()).thenReturn(new ArrayList()); + assertEquals(null, mWiseFy.mWiseFySearch.findAccessPointsMatchingRegex(TEST_SSID, true)); + } + + @Test + public void findAccessPointsMatchingRegex_failure_nullAccessPoint_takeHighest_false() { + List accessPoints = new ArrayList<>(); + accessPoints.add(null); + + when(mMockWiFiManager.getScanResults()).thenReturn(accessPoints); + assertEquals(null, mWiseFy.mWiseFySearch.findAccessPointsMatchingRegex(TEST_SSID, false)); + } + + @Test + public void findAccessPointsMatchingRegex_failure_nullAccessPoint_takeHighest_true() { + List accessPoints = new ArrayList<>(); + accessPoints.add(null); + + when(mMockWiFiManager.getScanResults()).thenReturn(accessPoints); + assertEquals(null, mWiseFy.mWiseFySearch.findAccessPointsMatchingRegex(TEST_SSID, true)); + } + + @Test + public void findAccessPointsMatchingRegex_failure_nullSSID_takeHighest_false() { + List accessPoints = new ArrayList<>(); + + ScanResult accessPoint= mock(ScanResult.class); + accessPoint.SSID = null; + accessPoints.add(accessPoint); + + when(mMockWiFiManager.getScanResults()).thenReturn(accessPoints); + assertEquals(null, mWiseFy.mWiseFySearch.findAccessPointsMatchingRegex(TEST_SSID, false)); + } + + @Test + public void findAccessPointsMatchingRegex_failure_nullSSID_takeHighest_true() { + List accessPoints = new ArrayList<>(); + + ScanResult accessPoint= mock(ScanResult.class); + accessPoint.SSID = null; + accessPoints.add(accessPoint); + + when(mMockWiFiManager.getScanResults()).thenReturn(accessPoints); + assertEquals(null, mWiseFy.mWiseFySearch.findAccessPointsMatchingRegex(TEST_SSID, true)); + } + + @Test + public void findAccessPointsMatchingRegex_failure_nonMatchingSSID_takeHighest_false() { + List accessPoints = new ArrayList<>(); + + ScanResult accessPoint= mock(ScanResult.class); + accessPoint.SSID = TEST_SSID2; + accessPoints.add(accessPoint); + + when(mMockWiFiManager.getScanResults()).thenReturn(accessPoints); + assertEquals(null, mWiseFy.mWiseFySearch.findAccessPointsMatchingRegex(TEST_SSID, false)); + } + + @Test + public void findAccessPointsMatchingRegex_failure_nonMatchingSSID_takeHighest_true() { + List accessPoints = new ArrayList<>(); + + ScanResult accessPoint= mock(ScanResult.class); + accessPoint.SSID = TEST_SSID2; + accessPoints.add(accessPoint); + + when(mMockWiFiManager.getScanResults()).thenReturn(accessPoints); + assertEquals(null, mWiseFy.mWiseFySearch.findAccessPointsMatchingRegex(TEST_SSID, true)); + } + + @Test + public void findAccessPointsMatchingRegex_failure_multipleNonMatchingSSIDs_takeHighest_false() { + List accessPoints = new ArrayList<>(); + + ScanResult accessPoint1 = mock(ScanResult.class); + accessPoint1.SSID = TEST_SSID2; + accessPoints.add(accessPoint1); + + ScanResult accessPoint2 = mock(ScanResult.class); + accessPoint2.SSID = TEST_SSID3; + accessPoints.add(accessPoint2); + + when(mMockWiFiManager.getScanResults()).thenReturn(accessPoints); + assertEquals(null, mWiseFy.mWiseFySearch.findAccessPointsMatchingRegex(TEST_SSID, false)); + } + + @Test + public void findAccessPointsMatchingRegex_failure_multipleNnonMatchingSSIDs_takeHighest_true() { + List accessPoints = new ArrayList<>(); + + ScanResult accessPoint1= mock(ScanResult.class); + accessPoint1.SSID = TEST_SSID2; + accessPoints.add(accessPoint1); + + ScanResult accessPoint2 = mock(ScanResult.class); + accessPoint2.SSID = TEST_SSID3; + accessPoints.add(accessPoint2); + + when(mMockWiFiManager.getScanResults()).thenReturn(accessPoints); + assertEquals(null, mWiseFy.mWiseFySearch.findAccessPointsMatchingRegex(TEST_SSID, true)); + } + + @Test + public void findAccessPointsMatchingRegex_success_takeHighest_false() { + List accessPoints = new ArrayList<>(); + + ScanResult accessPoint = mock(ScanResult.class); + accessPoint.SSID = TEST_SSID; + accessPoints.add(accessPoint); + + when(mMockWiFiManager.getScanResults()).thenReturn(accessPoints); + assertEquals(accessPoints, mWiseFy.mWiseFySearch.findAccessPointsMatchingRegex(TEST_SSID, false)); + } + + @Test + public void findAccessPointsMatchingRegex_success_takeHighest_true() { + List accessPoints = new ArrayList<>(); + + ScanResult accessPoint = mock(ScanResult.class); + accessPoint.SSID = TEST_SSID; + accessPoints.add(accessPoint); + + when(mMockWiFiManager.getScanResults()).thenReturn(accessPoints); + assertEquals(accessPoints, mWiseFy.mWiseFySearch.findAccessPointsMatchingRegex(TEST_SSID, true)); + } + + @Test + public void findAccessPointsMatchingRegex_success_multipleSSIDs_takeHighest_false() { + List accessPoints = new ArrayList<>(); + List expectedResults = new ArrayList<>(); + + ScanResult accessPoint1 = mock(ScanResult.class); + accessPoint1.SSID = TEST_SSID; + accessPoint1.level = -70; + accessPoints.add(accessPoint1); + expectedResults.add(accessPoint1); + + ScanResult accessPoint2 = mock(ScanResult.class); + accessPoint2.SSID = TEST_SSID2; + accessPoint2.level = -50; + accessPoints.add(accessPoint2); + + when(mMockWiFiManager.getScanResults()).thenReturn(accessPoints); + assertEquals(expectedResults, mWiseFy.mWiseFySearch.findAccessPointsMatchingRegex(TEST_SSID, false)); + } + + @Test + public void findAccessPointsMatchingRegex_success_multipleSSIDs_takeHighest_true() { + List accessPoints = new ArrayList<>(); + List expectedResults = new ArrayList<>(); + + ScanResult accessPoint1 = mock(ScanResult.class); + accessPoint1.SSID = TEST_SSID; + accessPoint1.level = -70; + accessPoints.add(accessPoint1); + expectedResults.add(accessPoint1); + + ScanResult accessPoint2 = mock(ScanResult.class); + accessPoint2.SSID = TEST_SSID2; + accessPoint2.level = -50; + accessPoints.add(accessPoint2); + + when(mMockWiFiManager.getScanResults()).thenReturn(accessPoints); + assertEquals(expectedResults, mWiseFy.mWiseFySearch.findAccessPointsMatchingRegex(TEST_SSID, true)); + } + + @Test + public void findAccessPointsMatchingRegex_success_multipleSameSSIDs_takeHighest_false() { + List accessPoints = new ArrayList<>(); + List expectedResults = new ArrayList<>(); + + ScanResult accessPoint1 = mock(ScanResult.class); + accessPoint1.SSID = TEST_SSID; + accessPoint1.level = -70; + accessPoints.add(accessPoint1); + expectedResults.add(accessPoint1); + + ScanResult accessPoint2 = mock(ScanResult.class); + accessPoint2.SSID = TEST_SSID; + accessPoint2.level = -50; + accessPoints.add(accessPoint2); + expectedResults.add(accessPoint2); + + when(mMockWiFiManager.getScanResults()).thenReturn(accessPoints); + assertEquals(expectedResults, mWiseFy.mWiseFySearch.findAccessPointsMatchingRegex(TEST_SSID, false)); + } + + @Test + public void findAccessPointsMatchingRegex_success_multipleSameSSIDs_takeHighest_true() { + List accessPoints = new ArrayList<>(); + List expectedResults = new ArrayList<>(); + + ScanResult accessPoint1 = mock(ScanResult.class); + accessPoint1.SSID = TEST_SSID; + accessPoint1.level = -70; + accessPoints.add(accessPoint1); + + ScanResult accessPoint2 = mock(ScanResult.class); + accessPoint2.SSID = TEST_SSID; + accessPoint2.level = -50; + accessPoints.add(accessPoint2); + expectedResults.add(accessPoint2); + + when(mMockWiFiManager.getScanResults()).thenReturn(accessPoints); + assertEquals(expectedResults, mWiseFy.mWiseFySearch.findAccessPointsMatchingRegex(TEST_SSID, true)); + } + + /* + * findSavedNetworkByRegex tests + */ + + @Test + public void findSavedNetworkByRegex_failure_nullSavedNetworkList() { + when(mMockWiFiManager.getConfiguredNetworks()).thenReturn(null); + assertEquals(null, mWiseFy.mWiseFySearch.findSavedNetworkByRegex(TEST_SSID)); + } + + @Test + public void findSavedNetworkByRegex_failure_emptySavedNetworkList() { + when(mMockWiFiManager.getConfiguredNetworks()).thenReturn(new ArrayList()); + assertEquals(null, mWiseFy.mWiseFySearch.findSavedNetworkByRegex(TEST_SSID)); + } + + @Test + public void findSavedNetworkByRegex_failure_nullWifiConfiguration() { + List wifiList = new ArrayList<>(); + wifiList.add(null); + + when(mMockWiFiManager.getConfiguredNetworks()).thenReturn(wifiList); + assertEquals(null, mWiseFy.mWiseFySearch.findSavedNetworkByRegex(TEST_SSID)); + } + + @Test + public void findSavedNetworkByRegex_failure_nullSSID() { + List wifiList = new ArrayList<>(); + WifiConfiguration mWiFiConfiguration = new WifiConfiguration(); + mWiFiConfiguration.SSID = null; + wifiList.add(mWiFiConfiguration); + + when(mMockWiFiManager.getConfiguredNetworks()).thenReturn(wifiList); + assertEquals(null, mWiseFy.mWiseFySearch.findSavedNetworkByRegex(TEST_SSID)); + } + + @Test + public void findSavedNetworkByRegex_failure_nonMatchingSSID() { + List wifiList = new ArrayList<>(); + + WifiConfiguration mWiFiConfiguration = new WifiConfiguration(); + mWiFiConfiguration.SSID = TEST_SSID2; + wifiList.add(mWiFiConfiguration); + + when(mMockWiFiManager.getConfiguredNetworks()).thenReturn(wifiList); + assertEquals(null, mWiseFy.mWiseFySearch.findSavedNetworkByRegex(TEST_SSID)); + } + + @Test + public void findSavedNetworkByRegex_failure_multipleNonMatchingSSIDs() { + List wifiList = new ArrayList<>(); + + WifiConfiguration mWiFiConfiguration1 = new WifiConfiguration(); + mWiFiConfiguration1.SSID = TEST_SSID2; + wifiList.add(mWiFiConfiguration1); + + WifiConfiguration mWiFiConfiguration2 = new WifiConfiguration(); + mWiFiConfiguration2.SSID = TEST_SSID3; + wifiList.add(mWiFiConfiguration2); + + when(mMockWiFiManager.getConfiguredNetworks()).thenReturn(wifiList); + assertEquals(null, mWiseFy.mWiseFySearch.findSavedNetworkByRegex(TEST_SSID)); + } + + @Test + public void findSavedNetworkByRegex_success() { + List wifiList = new ArrayList<>(); + + WifiConfiguration mWiFiConfiguration = new WifiConfiguration(); + mWiFiConfiguration.SSID = TEST_SSID; + wifiList.add(mWiFiConfiguration); + + when(mMockWiFiManager.getConfiguredNetworks()).thenReturn(wifiList); + assertEquals(mWiFiConfiguration, mWiseFy.mWiseFySearch.findSavedNetworkByRegex(TEST_SSID)); + } + + @Test + public void findSavedNetworkByRegex_success_multipleSSIDs() { + List wifiList = new ArrayList<>(); + + WifiConfiguration mWiFiConfiguration1 = new WifiConfiguration(); + mWiFiConfiguration1.SSID = TEST_SSID; + wifiList.add(mWiFiConfiguration1); + + WifiConfiguration mWiFiConfiguration2 = new WifiConfiguration(); + mWiFiConfiguration2.SSID = TEST_SSID2; + wifiList.add(mWiFiConfiguration2); + + when(mMockWiFiManager.getConfiguredNetworks()).thenReturn(wifiList); + assertEquals(mWiFiConfiguration1, mWiseFy.mWiseFySearch.findSavedNetworkByRegex(TEST_SSID)); + } + + /* + * findSavedNetworksMatchingRegex tests + */ + + @Test + public void findSavedNetworksMatchingRegex_failure_nullSavedNetworkList() { + when(mMockWiFiManager.getConfiguredNetworks()).thenReturn(null); + assertEquals(null, mWiseFy.mWiseFySearch.findSavedNetworksMatchingRegex(TEST_SSID)); + } + + @Test + public void findSavedNetworksMatchingRegex_failure_emptySavedNetworkList() { + when(mMockWiFiManager.getConfiguredNetworks()).thenReturn(new ArrayList()); + assertEquals(null, mWiseFy.mWiseFySearch.findSavedNetworksMatchingRegex(TEST_SSID)); + } + + @Test + public void findSavedNetworksMatchingRegex_failure_nullWifiConfiguration() { + List wifiList = new ArrayList<>(); + wifiList.add(null); + + when(mMockWiFiManager.getConfiguredNetworks()).thenReturn(wifiList); + assertEquals(null, mWiseFy.mWiseFySearch.findSavedNetworksMatchingRegex(TEST_SSID)); + } + + @Test + public void findSavedNetworksMatchingRegex_failure_nullSSID() { + List wifiList = new ArrayList<>(); + WifiConfiguration mWiFiConfiguration = new WifiConfiguration(); + mWiFiConfiguration.SSID = null; + wifiList.add(mWiFiConfiguration); + + when(mMockWiFiManager.getConfiguredNetworks()).thenReturn(wifiList); + assertEquals(null, mWiseFy.mWiseFySearch.findSavedNetworksMatchingRegex(TEST_SSID)); + } + + @Test + public void findSavedNetworksMatchingRegex_failure_nonMatchingSSID() { + List wifiList = new ArrayList<>(); + WifiConfiguration mWiFiConfiguration = new WifiConfiguration(); + mWiFiConfiguration.SSID = TEST_SSID2; + wifiList.add(mWiFiConfiguration); + + when(mMockWiFiManager.getConfiguredNetworks()).thenReturn(wifiList); + assertEquals(null, mWiseFy.mWiseFySearch.findSavedNetworksMatchingRegex(TEST_SSID)); + } + + @Test + public void findSavedNetworksMatchingRegex_failure_multipleNonMatchingSSIDs() { + List wifiList = new ArrayList<>(); + + WifiConfiguration mWiFiConfiguration1 = new WifiConfiguration(); + mWiFiConfiguration1.SSID = TEST_SSID2; + wifiList.add(mWiFiConfiguration1); + + WifiConfiguration mWiFiConfiguration2 = new WifiConfiguration(); + mWiFiConfiguration2.SSID = TEST_SSID3; + wifiList.add(mWiFiConfiguration2); + + when(mMockWiFiManager.getConfiguredNetworks()).thenReturn(wifiList); + assertEquals(null, mWiseFy.mWiseFySearch.findSavedNetworksMatchingRegex(TEST_SSID)); + } + + @Test + public void findSavedNetworksMatchingRegex_success() { + List wifiList = new ArrayList<>(); + + WifiConfiguration mWiFiConfiguration = new WifiConfiguration(); + mWiFiConfiguration.SSID = TEST_SSID; + wifiList.add(mWiFiConfiguration); + + when(mMockWiFiManager.getConfiguredNetworks()).thenReturn(wifiList); + assertEquals(wifiList, mWiseFy.mWiseFySearch.findSavedNetworksMatchingRegex(TEST_SSID)); + } + + @Test + public void findSavedNetworksMatchingRegex_success_multipleSSIDs() { + List wifiList = new ArrayList<>(); + + WifiConfiguration mWiFiConfiguration1 = new WifiConfiguration(); + mWiFiConfiguration1.SSID = TEST_SSID; + wifiList.add(mWiFiConfiguration1); + + WifiConfiguration mWiFiConfiguration2 = new WifiConfiguration(); + mWiFiConfiguration2.SSID = TEST_SSID2; + wifiList.add(mWiFiConfiguration2); + + when(mMockWiFiManager.getConfiguredNetworks()).thenReturn(wifiList); + assertEquals(wifiList, mWiseFy.mWiseFySearch.findSavedNetworksMatchingRegex(".*Test.*")); + } + + /* + * findSSIDsMatchingRegex tests + */ + + @Test + public void findSSIDsMatchingRegex_failure_nullAccessPoints() { + when(mMockWiFiManager.getScanResults()).thenReturn(null); + assertEquals(null, mWiseFy.mWiseFySearch.findSSIDsMatchingRegex(TEST_SSID)); + } + + @Test + public void findSSIDsMatchingRegex_failure_emptySavedNetworkList() { + when(mMockWiFiManager.getScanResults()).thenReturn(new ArrayList()); + assertEquals(null, mWiseFy.mWiseFySearch.findSSIDsMatchingRegex(TEST_SSID)); + } + + @Test + public void findSSIDsMatchingRegex_failure_nullWifiConfiguration() { + List accessPoints = new ArrayList<>(); + accessPoints.add(null); + + when(mMockWiFiManager.getScanResults()).thenReturn(accessPoints); + assertEquals(null, mWiseFy.mWiseFySearch.findSSIDsMatchingRegex(TEST_SSID)); + } + + @Test + public void findSSIDsMatchingRegex_failure_nullSSID() { + List accessPoints = new ArrayList<>(); + + ScanResult accessPoint = mock(ScanResult.class); + accessPoint.SSID = null; + accessPoints.add(accessPoint); + + when(mMockWiFiManager.getScanResults()).thenReturn(accessPoints); + assertEquals(null, mWiseFy.mWiseFySearch.findSSIDsMatchingRegex(TEST_SSID)); + } + + @Test + public void findSSIDsMatchingRegex_failure_nonMatchingSSID() { + List accessPoints = new ArrayList<>(); + + ScanResult accessPoint = mock(ScanResult.class); + accessPoint.SSID = TEST_SSID2; + accessPoints.add(accessPoint); + + when(mMockWiFiManager.getScanResults()).thenReturn(accessPoints); + assertEquals(null, mWiseFy.mWiseFySearch.findSSIDsMatchingRegex(TEST_SSID)); + } + + @Test + public void findSSIDsMatchingRegex_failure_multipleNonMatchingSSIDs() { + List accessPoints = new ArrayList<>(); + + ScanResult accessPoint1 = mock(ScanResult.class); + accessPoint1.SSID = TEST_SSID2; + accessPoints.add(accessPoint1); + + ScanResult accessPoint2 = mock(ScanResult.class); + accessPoint2.SSID = TEST_SSID3; + accessPoints.add(accessPoint2); + + when(mMockWiFiManager.getScanResults()).thenReturn(accessPoints); + assertEquals(null, mWiseFy.mWiseFySearch.findSSIDsMatchingRegex(TEST_SSID)); + } + + @Test + public void findSSIDsMatchingRegex_success() { + List accessPoints = new ArrayList<>(); + List expectedResults = new ArrayList<>(); + + ScanResult accessPoint = mock(ScanResult.class); + accessPoint.SSID = TEST_SSID; + accessPoints.add(accessPoint); + expectedResults.add(TEST_SSID); + + when(mMockWiFiManager.getScanResults()).thenReturn(accessPoints); + assertEquals(expectedResults, mWiseFy.mWiseFySearch.findSSIDsMatchingRegex(TEST_SSID)); + } + + @Test + public void findSSIDsMatchingRegex_success_multipleSSIDs() { + List accessPoints = new ArrayList<>(); + List expectedResults = new ArrayList<>(); + + ScanResult accessPoint1 = mock(ScanResult.class); + accessPoint1.SSID = TEST_SSID; + accessPoints.add(accessPoint1); + expectedResults.add(TEST_SSID); + + ScanResult accessPoint2 = mock(ScanResult.class); + accessPoint2.SSID = TEST_SSID; + accessPoints.add(accessPoint2); + expectedResults.add(TEST_SSID); + + when(mMockWiFiManager.getScanResults()).thenReturn(accessPoints); + assertEquals(expectedResults, mWiseFy.mWiseFySearch.findSSIDsMatchingRegex(".*Test.*")); + } + + /* + * isNetworkASavedConfiguration tests + */ + + @Test + public void isNetworkASavedConfiguration_failure() { + when(mMockWiFiManager.getConfiguredNetworks()).thenReturn(new ArrayList()); + assertEquals(false, mWiseFy.mWiseFySearch.isNetworkASavedConfiguration(TEST_SSID)); + } + + @Test + public void isNetworkASavedConfiguration_success() { + List wifiList = new ArrayList<>(); + + WifiConfiguration mWiFiConfiguration = new WifiConfiguration(); + mWiFiConfiguration.SSID = TEST_SSID; + wifiList.add(mWiFiConfiguration); + + when(mMockWiFiManager.getConfiguredNetworks()).thenReturn(wifiList); + assertEquals(true, mWiseFy.mWiseFySearch.isNetworkASavedConfiguration(TEST_SSID)); + } + + /* + * removeEntriesWithLowerSignalStrength tests + */ + + @Test + public void removeEntriesWithLowerSignalStrength_differentSSIDs() { + List accessPoints = new ArrayList<>(); + List expectedResults = new ArrayList<>(); + + ScanResult accessPoint1 = mock(ScanResult.class); + accessPoint1.SSID = TEST_SSID; + accessPoint1.level = -70; + accessPoints.add(accessPoint1); + expectedResults.add(accessPoint1); + + ScanResult accessPoint2 = mock(ScanResult.class); + accessPoint2.SSID = TEST_SSID2; + accessPoint2.level = -50; + accessPoints.add(accessPoint2); + expectedResults.add(accessPoint2); + + assertEquals(expectedResults, mWiseFy.mWiseFySearch.removeEntriesWithLowerSignalStrength(accessPoints)); + } + + @Test + public void removeEntriesWithLowerSignalStrength_sameSignalLevels() { + List accessPoints = new ArrayList<>(); + List expectedResults = new ArrayList<>(); + + ScanResult accessPoint1 = mock(ScanResult.class); + accessPoint1.SSID = TEST_SSID; + accessPoint1.level = -70; + accessPoints.add(accessPoint1); + expectedResults.add(accessPoint1); + + ScanResult accessPoint2 = mock(ScanResult.class); + accessPoint2.SSID = TEST_SSID; + accessPoint2.level = -70; + accessPoints.add(accessPoint2); + + assertEquals(expectedResults, mWiseFy.mWiseFySearch.removeEntriesWithLowerSignalStrength(accessPoints)); + } + + @Test + public void removeEntriesWithLowerSignalStrength_accessPoint1Higher() { + List accessPoints = new ArrayList<>(); + List expectedResults = new ArrayList<>(); + + ScanResult accessPoint1 = mock(ScanResult.class); + accessPoint1.SSID = TEST_SSID; + accessPoint1.level = -50; + accessPoints.add(accessPoint1); + expectedResults.add(accessPoint1); + + ScanResult accessPoint2 = mock(ScanResult.class); + accessPoint2.SSID = TEST_SSID; + accessPoint2.level = -70; + accessPoints.add(accessPoint2); + + assertEquals(expectedResults , mWiseFy.mWiseFySearch.removeEntriesWithLowerSignalStrength(accessPoints)); + } + + @Test + public void removeEntriesWithLowerSignalStrength_accessPoint2Higher() { + List accessPoints = new ArrayList<>(); + List expectedResults = new ArrayList<>(); + + ScanResult accessPoint1 = mock(ScanResult.class); + accessPoint1.SSID = TEST_SSID; + accessPoints.add(accessPoint1); + accessPoint1.level = -70; + + ScanResult accessPoint2 = mock(ScanResult.class); + accessPoint2.SSID = TEST_SSID; + accessPoint2.level = -50; + accessPoints.add(accessPoint2); + expectedResults.add(accessPoint2); + + assertEquals(expectedResults , mWiseFy.mWiseFySearch.removeEntriesWithLowerSignalStrength(accessPoints)); + } +} diff --git a/wisefy/src/androidTest/java/com/isupatches/wisefy/WiseFyTests.java b/wisefy/src/androidTest/java/com/isupatches/wisefy/WiseFyTests.java index e7892ecb..a1acaabb 100644 --- a/wisefy/src/androidTest/java/com/isupatches/wisefy/WiseFyTests.java +++ b/wisefy/src/androidTest/java/com/isupatches/wisefy/WiseFyTests.java @@ -1,47 +1,44 @@ -//package com.isupatches.wisefy; -// -// -//import com.google.android.gms.iid.InstanceID; -//import com.isupatches.wisefy.base.TestActivity; -//import org.junit.Test; -//import static org.junit.Assert.*; -// -// -//public class WiseFyTests extends BaseTestClass { -// -// public WiseFyTests() { -// super(TestActivity.class); -// } -// -// @Test -// public void builder_loggingFalse() { -// WiseFy wiseFy = new WiseFy.brains(mActivityTestRule.getActivity()).logging(false).getSmarts(); -// assertEquals(false, wiseFy.mWiseFyConfiguration.isLoggingEnabled()); -// assertEquals(false, wiseFy.isLoggingEnabled()); -// } -// -// @Test -// public void builder_loggingTrue() { -// WiseFy wiseFy = new WiseFy.brains(mActivityTestRule.getActivity()).logging(true).getSmarts(); -// assertEquals(true, wiseFy.mWiseFyConfiguration.isLoggingEnabled()); -// assertEquals(true, wiseFy.isLoggingEnabled()); -// } -// -// @Test -// public void calculateBars() { -// int result = mWiseFy.calculateBars(-35, 5); -// assertEquals(4, result); -// } -// -// @Test -// public void compareSignalLevel() { -// int result = mWiseFy.compareSignalLevel(-35, -70); -// assertEquals(35, result); -// } -// -// @Test -// public void olderGcm_IllegalAccessError_notThrown() { -// InstanceID instanceID = InstanceID.getInstance(mActivityTestRule.getActivity()); -// assertNotNull(instanceID); -// } -//} \ No newline at end of file +package com.isupatches.wisefy; + + +import android.support.test.InstrumentationRegistry; + +import com.google.android.gms.iid.InstanceID; +import org.junit.Test; +import static org.junit.Assert.*; + + +public class WiseFyTests extends BaseAndroidJUnit4TestClass { + + @Test + public void builder_loggingFalse() { + WiseFy wiseFy = new WiseFy.brains(InstrumentationRegistry.getContext()).logging(false).getSmarts(); + assertEquals(false, wiseFy.mWiseFyConfiguration.isLoggingEnabled()); + assertEquals(false, wiseFy.isLoggingEnabled()); + } + + @Test + public void builder_loggingTrue() { + WiseFy wiseFy = new WiseFy.brains(InstrumentationRegistry.getContext()).logging(true).getSmarts(); + assertEquals(true, wiseFy.mWiseFyConfiguration.isLoggingEnabled()); + assertEquals(true, wiseFy.isLoggingEnabled()); + } + + @Test + public void calculateBars() { + int result = mWiseFy.calculateBars(-35, 5); + assertEquals(4, result); + } + + @Test + public void compareSignalLevel() { + int result = mWiseFy.compareSignalLevel(-35, -70); + assertEquals(35, result); + } + + @Test + public void olderGcm_IllegalAccessError_notThrown() { + InstanceID instanceID = InstanceID.getInstance(InstrumentationRegistry.getContext()); + assertNotNull(instanceID); + } +} \ No newline at end of file diff --git a/wisefy/src/androidTest/java/com/isupatches/wisefy/test/BuilderTests.java b/wisefy/src/androidTest/java/com/isupatches/wisefy/test/BuilderTests.java index e829d4e8..041e3edf 100644 --- a/wisefy/src/androidTest/java/com/isupatches/wisefy/test/BuilderTests.java +++ b/wisefy/src/androidTest/java/com/isupatches/wisefy/test/BuilderTests.java @@ -1,32 +1,23 @@ -//package com.isupatches.wisefy.test; -// -// -//import android.support.test.rule.ActivityTestRule; -//import com.isupatches.wisefy.WiseFy; -//import com.isupatches.wisefy.base.TestActivity; -//import org.junit.Rule; -//import org.junit.Test; -//import static org.junit.Assert.assertEquals; -// -// -//public class BuilderTests extends ActivityTestRule { -// -// @Rule -// public ActivityTestRule mActivityTestRule = new ActivityTestRule<>(TestActivity.class); -// -// public BuilderTests() { -// super(TestActivity.class); -// } -// -// @Test -// public void builder_loggingFalse() { -// WiseFy wiseFy = new WiseFy.brains(mActivityTestRule.getActivity()).logging(false).getSmarts(); -// assertEquals(false, wiseFy.isLoggingEnabled()); -// } -// -// @Test -// public void builder_loggingTrue() { -// WiseFy wiseFy = new WiseFy.brains(mActivityTestRule.getActivity()).logging(true).getSmarts(); -// assertEquals(true, wiseFy.isLoggingEnabled()); -// } -//} +package com.isupatches.wisefy.test; + + +import android.support.test.InstrumentationRegistry; +import com.isupatches.wisefy.WiseFy; +import org.junit.Test; +import static org.junit.Assert.assertEquals; + + +public class BuilderTests { + + @Test + public void builder_loggingFalse() { + WiseFy wiseFy = new WiseFy.brains(InstrumentationRegistry.getContext()).logging(false).getSmarts(); + assertEquals(false, wiseFy.isLoggingEnabled()); + } + + @Test + public void builder_loggingTrue() { + WiseFy wiseFy = new WiseFy.brains(InstrumentationRegistry.getContext()).logging(true).getSmarts(); + assertEquals(true, wiseFy.isLoggingEnabled()); + } +} diff --git a/wisefy/src/androidTest/java/com/isupatches/wisefy/test/PublicApiVisibilityTests.java b/wisefy/src/test/java/com/isupatches/wisefy/test/PublicApiVisibilityTests.java similarity index 97% rename from wisefy/src/androidTest/java/com/isupatches/wisefy/test/PublicApiVisibilityTests.java rename to wisefy/src/test/java/com/isupatches/wisefy/test/PublicApiVisibilityTests.java index 19bccbeb..5ea07b6b 100644 --- a/wisefy/src/androidTest/java/com/isupatches/wisefy/test/PublicApiVisibilityTests.java +++ b/wisefy/src/test/java/com/isupatches/wisefy/test/PublicApiVisibilityTests.java @@ -1,13 +1,10 @@ package com.isupatches.wisefy.test; -import android.content.Intent; import android.net.wifi.ScanResult; import android.net.wifi.WifiConfiguration; import android.net.wifi.WifiInfo; -import android.support.test.rule.ActivityTestRule; import com.isupatches.wisefy.WiseFy; -import com.isupatches.wisefy.base.TestActivity; import com.isupatches.wisefy.callbacks.AddOpenNetworkCallbacks; import com.isupatches.wisefy.callbacks.AddWEPNetworkCallbacks; import com.isupatches.wisefy.callbacks.AddWPA2NetworkCallbacks; @@ -27,7 +24,6 @@ import com.isupatches.wisefy.callbacks.SearchForSSIDCallbacks; import com.isupatches.wisefy.callbacks.SearchForSSIDsCallbacks; import org.junit.Before; -import org.junit.Rule; import org.junit.Test; import java.util.List; import static junit.framework.Assert.assertEquals; @@ -39,21 +35,12 @@ import static org.mockito.Mockito.verify; -public class PublicApiVisibilityTests extends ActivityTestRule { - - @Rule - public ActivityTestRule mActivityTestRule = new ActivityTestRule<>(TestActivity.class); +public class PublicApiVisibilityTests { private WiseFy mWiseFy; - public PublicApiVisibilityTests() { - super(TestActivity.class); - } - @Before public void setUp() { - mActivityTestRule.launchActivity(new Intent()); - mWiseFy = mock(WiseFy.class); } From 9181c121bdbcb4bf1b2a255653edeb014d24a38d Mon Sep 17 00:00:00 2001 From: isuPatches Date: Sun, 23 Jul 2017 22:34:44 -0500 Subject: [PATCH 74/74] Add codecov badge close #78 --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index a985ac19..c98320c6 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ Wifi configuration and util library built for Android. > >
Supports Android SDK levels 16-26

-[![Android Weekly](https://img.shields.io/badge/Android%20Weekly-%23230-blue.svg)](http://androidweekly.net/issues/issue-230) [![Build Status](https://travis-ci.org/isuPatches/WiseFy.svg?branch=master)](https://travis-ci.org/isuPatches/WiseFy) [ ![Download](https://api.bintray.com/packages/isupatches/Maven/wisefy/images/download.svg) ](https://bintray.com/isupatches/Maven/wisefy/_latestVersion) +[![Android Weekly](https://img.shields.io/badge/Android%20Weekly-%23230-blue.svg)](http://androidweekly.net/issues/issue-230) [![Build Status](https://travis-ci.org/isuPatches/WiseFy.svg?branch=master)](https://travis-ci.org/isuPatches/WiseFy) [ ![Download](https://api.bintray.com/packages/isupatches/Maven/wisefy/images/download.svg) ](https://bintray.com/isupatches/Maven/wisefy/_latestVersion) [![codecov.io](https://codecov.io/github/codecov/wisefy/branch/2.x/graph/badge.svg)](https://codecov.io/github/codecov/wisefy) ## What's New in 2.x