Skip to content

Commit

Permalink
add more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
VREMSoftwareDevelopment committed Jul 3, 2021
1 parent 914dfdf commit b964c13
Show file tree
Hide file tree
Showing 10 changed files with 104 additions and 15 deletions.
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
## News:
- WiFi Analyzer rated as one of the 15 most useful apps for Android by [Android Authority](https://www.androidauthority.com/most-useful-apps-for-android-603100/amp)
- [Gizmodo](https://gizmodo.com/the-best-wifi-analyzer-apps-to-troubleshoot-your-networ-1843957301) rates WiFi Analyzer one of The Best Apps for Fixing Your WiFi
- WiFi Analyzer featured in [The NY Times Wirecutter](https://www.nytimes.com/wirecutter/reviews/best-wi-fi-router) – The Best Wi-fi Router

[<img src="https://play.google.com/intl/en_us/badges/images/generic/en_badge_web_generic.png" alt="Get it on Google Play" height="80">](https://play.google.com/store/apps/details?id=com.vrem.wifianalyzer)
[<img src="https://f-droid.org/badge/get-it-on.png" alt="Get it on F-Droid" height="80">](https://f-droid.org/repository/browse/?fdid=com.vrem.wifianalyzer)
Expand Down
2 changes: 1 addition & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ apply plugin: "kotlin-allopen"
dependencies {
// Compile Build Dependencies
implementation fileTree(include: ["*.jar"], dir: "libs")
implementation 'com.google.android.material:material:1.3.0'
implementation 'com.google.android.material:material:1.4.0'
implementation 'androidx.annotation:annotation:1.2.0'
implementation 'androidx.collection:collection-ktx:1.1.0'
implementation 'androidx.core:core-ktx:1.6.0'
Expand Down
4 changes: 2 additions & 2 deletions app/build.properties
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#Build Properties
#Fri Jul 02 17:40:05 EDT 2021
#Sat Jul 03 15:59:32 EDT 2021
version_minor=0
version_store=56
version_patch=4
version_build=11
version_build=12
version_major=3
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,11 @@ package com.vrem.wifianalyzer.navigation
import android.view.MenuItem
import android.view.View
import androidx.annotation.IdRes
import com.google.android.material.bottomnavigation.BottomNavigationView
import com.google.android.material.navigation.NavigationBarView
import com.google.android.material.navigation.NavigationView

interface NavigationMenuControl : NavigationView.OnNavigationItemSelectedListener, BottomNavigationView.OnNavigationItemSelectedListener {
interface NavigationMenuControl : NavigationView.OnNavigationItemSelectedListener,
NavigationBarView.OnItemSelectedListener {
fun currentMenuItem(): MenuItem
fun currentNavigationMenu(): NavigationMenu
fun currentNavigationMenu(navigationMenu: NavigationMenu)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,6 @@ class NavigationMenuController(
NavigationGroup.values().forEach { it.populateMenuItems(navigationView.menu) }
navigationView.setNavigationItemSelectedListener(navigationMenuControl)
NavigationGroup.GROUP_FEATURE.populateMenuItems(bottomNavigationView.menu)
bottomNavigationView.setOnNavigationItemSelectedListener(navigationMenuControl)
bottomNavigationView.setOnItemSelectedListener(navigationMenuControl)
}
}
15 changes: 11 additions & 4 deletions app/src/main/kotlin/com/vrem/wifianalyzer/wifi/band/WiFiBand.kt
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,19 @@
package com.vrem.wifianalyzer.wifi.band

import androidx.annotation.StringRes
import com.vrem.wifianalyzer.MainContext
import com.vrem.wifianalyzer.R

enum class WiFiBand(@StringRes val textResource: Int, val wiFiChannels: WiFiChannels) {
GHZ2(R.string.wifi_band_2ghz, WiFiChannelsGHZ2()),
GHZ5(R.string.wifi_band_5ghz, WiFiChannelsGHZ5()),
GHZ6(R.string.wifi_band_6ghz, WiFiChannelsGHZ6());
typealias Available = () -> Boolean

internal val availableGHZ2: Available = { true }
internal val availableGHZ5: Available = { MainContext.INSTANCE.wiFiManagerWrapper.is5GHzBandSupported() }
internal val availableGHZ6: Available = { MainContext.INSTANCE.wiFiManagerWrapper.is6GHzBandSupported() }

enum class WiFiBand(@StringRes val textResource: Int, val wiFiChannels: WiFiChannels, val available: Available) {
GHZ2(R.string.wifi_band_2ghz, WiFiChannelsGHZ2(), availableGHZ2),
GHZ5(R.string.wifi_band_5ghz, WiFiChannelsGHZ5(), availableGHZ5),
GHZ6(R.string.wifi_band_6ghz, WiFiChannelsGHZ6(), availableGHZ6);

fun toggle(): WiFiBand = if (ghz5()) GHZ2 else GHZ5

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,9 @@ internal val calculateCenter160: CalculateCenter = { primary, center ->
in 5170..5330 -> 5250
in 5490..5730 -> 5570
in 5735..5895 -> 5815
in 5955..6095 -> 6025
in 6115..6255 -> 6185
in 6275..6415 -> 6345
in 5950..6100 -> 6025
in 6110..6260 -> 6185
in 6270..6420 -> 6345
else -> center
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,38 @@
*/
package com.vrem.wifianalyzer.wifi.band

import com.nhaarman.mockitokotlin2.verify
import com.nhaarman.mockitokotlin2.verifyNoMoreInteractions
import com.nhaarman.mockitokotlin2.whenever
import com.vrem.wifianalyzer.MainContextHelper
import com.vrem.wifianalyzer.R
import com.vrem.wifianalyzer.wifi.band.WiFiBand.Companion.find
import org.junit.After
import org.junit.Assert.*
import org.junit.Test

class WiFiBandTest {
private val wiFiManagerWrapper = MainContextHelper.INSTANCE.wiFiManagerWrapper

@After
fun tearDown() {
MainContextHelper.INSTANCE.restore()
verifyNoMoreInteractions(wiFiManagerWrapper)
}


@Test
fun testWiFiBand() {
assertEquals(3, WiFiBand.values().size)
}

@Test
fun testAvailable() {
assertTrue(WiFiBand.GHZ2.available.javaClass.isInstance(availableGHZ2))
assertTrue(WiFiBand.GHZ5.available.javaClass.isInstance(availableGHZ5))
assertTrue(WiFiBand.GHZ6.available.javaClass.isInstance(availableGHZ6))
}

@Test
fun testTextResource() {
assertEquals(R.string.wifi_band_2ghz, WiFiBand.GHZ2.textResource)
Expand Down Expand Up @@ -65,4 +86,35 @@ class WiFiBandTest {
assertEquals(WiFiBand.GHZ6, find(7125))
assertEquals(WiFiBand.GHZ2, find(7126))
}

@Test
fun testAvailableGHZ2() {
// execute
val actual = WiFiBand.GHZ2.available()
// validate
assertTrue(actual)
}

@Test
fun testAvailableGHZ5() {
// setup
whenever(wiFiManagerWrapper.is5GHzBandSupported()).thenReturn(true)
// execute
val actual = WiFiBand.GHZ5.available()
// validate
assertTrue(actual)
verify(wiFiManagerWrapper).is5GHzBandSupported()
}

@Test
fun testAvailableGHZ6() {
// setup
whenever(wiFiManagerWrapper.is6GHzBandSupported()).thenReturn(true)
// execute
val actual = WiFiBand.GHZ6.available()
// validate
assertTrue(actual)
verify(wiFiManagerWrapper).is6GHzBandSupported()
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,36 @@ class WiFiWidthTest {
}
}

@Test
fun testCalculateCenter160_UNII_5_1() {
// execute & validate
for (value in 5950..6100) {
assertEquals(6025, calculateCenter160(value, Int.MIN_VALUE))
assertEquals(6025, calculateCenter160(value, 0))
assertEquals(6025, calculateCenter160(value, Int.MAX_VALUE))
}
}

@Test
fun testCalculateCenter160_UNII_5_2() {
// execute & validate
for (value in 6110..6260) {
assertEquals(6185, calculateCenter160(value, Int.MIN_VALUE))
assertEquals(6185, calculateCenter160(value, 0))
assertEquals(6185, calculateCenter160(value, Int.MAX_VALUE))
}
}

@Test
fun testCalculateCenter160_UNII_5_3() {
// execute & validate
for (value in 6270..6420) {
assertEquals(6345, calculateCenter160(value, Int.MIN_VALUE))
assertEquals(6345, calculateCenter160(value, 0))
assertEquals(6345, calculateCenter160(value, Int.MAX_VALUE))
}
}

@Test
fun testCalculateCenter160Invalid() {
// execute & validate
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ buildscript {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:4.2.1'
classpath 'com.android.tools.build:gradle:4.2.2'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath "org.jetbrains.kotlin:kotlin-allopen:$kotlin_version"
}
Expand Down

0 comments on commit b964c13

Please sign in to comment.