Skip to content

Commit

Permalink
test cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
VREMSoftwareDevelopment committed Feb 15, 2024
1 parent 67928b3 commit 9887572
Show file tree
Hide file tree
Showing 140 changed files with 948 additions and 1,171 deletions.
4 changes: 2 additions & 2 deletions app/build.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Build Properties
#Wed Feb 14 20:27:19 EST 2024
version_build=8
#Thu Feb 15 07:58:17 EST 2024
version_build=9
version_major=3
version_minor=1
version_patch=2
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,21 +33,21 @@ class MainInstrumentedTest {
val activityTestRule: ActivityScenarioRule<MainActivity> = activityScenarioRule()

@Test
fun testNavigation() {
fun navigation() {
pauseShort()
NavigationInstrumentedTest().run()
pauseShort()
}

@Test
fun testScanner() {
fun scanner() {
pauseShort()
ScannerInstrumentedTest().run()
pauseShort()
}

@Test
fun testFilter() {
fun filter() {
pauseShort()
FilterInstrumentedTest().run()
pauseShort()
Expand Down
16 changes: 8 additions & 8 deletions app/src/test/kotlin/com/vrem/util/CompatUtilsTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ class CompatUtilsTest {
}

@Test
fun testCreateContext() {
fun createContext() {
// setup
whenever(context.resources).thenReturn(resources)
whenever(resources.configuration).thenReturn(configuration)
Expand All @@ -95,7 +95,7 @@ class CompatUtilsTest {
}

@Test
fun testContextPackageInfo() {
fun contextPackageInfo() {
// setup
val packageName = "Package Name"
whenever(context.packageManager).thenReturn(packageManager)
Expand All @@ -112,7 +112,7 @@ class CompatUtilsTest {

@Test
@Config(sdk = [Build.VERSION_CODES.S_V2])
fun testContextPackageInfoLegacy() {
fun contextPackageInfoLegacy() {
// setup
val packageName = "Package Name"
whenever(context.packageManager).thenReturn(packageManager)
Expand All @@ -128,7 +128,7 @@ class CompatUtilsTest {
}

@Test
fun testScanResultSSID() {
fun scanResultSSID() {
// setup
val expected = "SSID"
val ssid = "\"$expected\""
Expand All @@ -142,7 +142,7 @@ class CompatUtilsTest {
}

@Test
fun testScanResultSSIDWhenWifiSsidNull() {
fun scanResultSSIDWhenWifiSsidNull() {
// setup
whenever(scanResult.wifiSsid).thenReturn(null)
// execute
Expand All @@ -153,7 +153,7 @@ class CompatUtilsTest {
}

@Test
fun testScanResultSSIDWhenNull() {
fun scanResultSSIDWhenNull() {
// setup
whenever(scanResult.wifiSsid).thenReturn(wifiSsid)
whenever(wifiSsid.toString()).thenReturn(null)
Expand All @@ -167,7 +167,7 @@ class CompatUtilsTest {
@Test
@Config(sdk = [Build.VERSION_CODES.S_V2])
@Suppress("DEPRECATION")
fun testScanResultSSIDLegacy() {
fun scanResultSSIDLegacy() {
// setup
val expected = "SSID"
val ssid = "\"$expected\""
Expand All @@ -181,7 +181,7 @@ class CompatUtilsTest {
@Test
@Config(sdk = [Build.VERSION_CODES.S_V2])
@Suppress("DEPRECATION")
fun testScanResultSSIDLegacyWhenNull() {
fun scanResultSSIDLegacyWhenNull() {
// setup
scanResult.SSID = null
// execute
Expand Down
14 changes: 7 additions & 7 deletions app/src/test/kotlin/com/vrem/util/EnumUtilsTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import org.junit.Test
class EnumUtilsTest {

@Test
fun testOrdinals() {
fun ordinals() {
// setup
val expected = TestObject.entries
// execute
Expand All @@ -37,7 +37,7 @@ class EnumUtilsTest {
}

@Test
fun testFindSetUsingOrdinals() {
fun findSetUsingOrdinals() {
// setup
val expected = TestObject.entries.toSet()
val ordinals: Set<String> = setOf("" + TestObject.VALUE1.ordinal, "" + TestObject.VALUE2.ordinal, "" + TestObject.VALUE3.ordinal)
Expand All @@ -48,7 +48,7 @@ class EnumUtilsTest {
}

@Test
fun testFindSetUsingOrdinalsWithEmptyInput() {
fun findSetUsingOrdinalsWithEmptyInput() {
// setup
val expected = TestObject.entries.toSet()
// execute
Expand All @@ -58,7 +58,7 @@ class EnumUtilsTest {
}

@Test
fun testFindSetUsingOrdinalsWithInvalidInput() {
fun findSetUsingOrdinalsWithInvalidInput() {
// setup
val expected = TestObject.VALUE2
val ordinals: Set<String> = setOf("-1")
Expand All @@ -70,7 +70,7 @@ class EnumUtilsTest {
}

@Test
fun testFindOneUsingIndex() {
fun findOneUsingIndex() {
TestObject.entries.forEach {
// execute
val actual = findOne(TestObject.entries, it.ordinal, TestObject.VALUE2)
Expand All @@ -80,7 +80,7 @@ class EnumUtilsTest {
}

@Test
fun testFindOneUsingInvalidLowIndex() {
fun findOneUsingInvalidLowIndex() {
// setup
val index = -1
val expected = TestObject.VALUE3
Expand All @@ -91,7 +91,7 @@ class EnumUtilsTest {
}

@Test
fun testFindOneUsingInvalidHighIndex() {
fun findOneUsingInvalidHighIndex() {
// setup
val index = TestObject.entries.size
val expected = TestObject.VALUE3
Expand Down
4 changes: 2 additions & 2 deletions app/src/test/kotlin/com/vrem/util/FileUtilsTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class FileUtilsTest {
}

@Test
fun testReadFile() {
fun readFile() {
// setup
val id = 11
val expected = "Line-1\nLine-2\n"
Expand All @@ -54,7 +54,7 @@ class FileUtilsTest {
}

@Test
fun testReadFileHandleException() {
fun readFileHandleException() {
// setup
val id = 11
whenever(resources.openRawResource(id)).thenThrow(NotFoundException::class.java)
Expand Down
22 changes: 10 additions & 12 deletions app/src/test/kotlin/com/vrem/util/LocaleUtilsTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,13 @@
*/
package com.vrem.util

import org.junit.Assert.assertEquals
import org.junit.Assert.assertNotEquals
import org.junit.Assert.assertTrue
import org.junit.Assert.*
import org.junit.Test
import java.util.Locale

class LocaleUtilsTest {
@Test
fun testAllCountries() {
fun allSupportedCountries() {
// execute
val actual = allCountries()
// validate
Expand All @@ -34,7 +32,7 @@ class LocaleUtilsTest {
}

@Test
fun testFindByCountryCode() {
fun findByCountryCodeWithKnownCode() {
// setup
val expected = allCountries()[0]
// execute
Expand All @@ -48,36 +46,36 @@ class LocaleUtilsTest {
}

@Test
fun testFindByCountryCodeWithUnknownCode() {
fun findByCountryCodeWithUnknownCode() {
// execute
val actual = findByCountryCode("WW")
// validate
assertEquals(Locale.getDefault(), actual)
}

@Test
fun testToLanguageTag() {
fun toLanguageTagWithKnownCode() {
assertEquals(Locale.US.language + "_" + Locale.US.country, toLanguageTag(Locale.US))
assertEquals(Locale.ENGLISH.language + "_", toLanguageTag(Locale.ENGLISH))
}

@Test
fun testFindByLanguageTagWithUnknownTag() {
fun findByLanguageTagWithUnknownTag() {
val defaultLocal = Locale.getDefault()
assertEquals(defaultLocal, findByLanguageTag(String.EMPTY))
assertEquals(defaultLocal, findByLanguageTag("WW"))
assertEquals(defaultLocal, findByLanguageTag("WW_HH_TT"))
}

@Test
fun testFindByLanguageTag() {
fun findByLanguageTagWithKnownTag() {
assertEquals(Locale.SIMPLIFIED_CHINESE, findByLanguageTag(toLanguageTag(Locale.SIMPLIFIED_CHINESE)))
assertEquals(Locale.TRADITIONAL_CHINESE, findByLanguageTag(toLanguageTag(Locale.TRADITIONAL_CHINESE)))
assertEquals(Locale.ENGLISH, findByLanguageTag(toLanguageTag(Locale.ENGLISH)))
}

@Test
fun testSupportedLanguages() {
fun allSupportedLanguages() {
// setup
val expected: Set<Locale> = setOf(
BULGARIAN,
Expand Down Expand Up @@ -107,12 +105,12 @@ class LocaleUtilsTest {
}

@Test
fun testDefaultCountryCode() {
fun currentDefaultCountryCode() {
assertEquals(Locale.getDefault().country, defaultCountryCode())
}

@Test
fun testDefaultLanguageTag() {
fun currentDefaultLanguageTag() {
assertEquals(toLanguageTag(Locale.getDefault()), defaultLanguageTag())
}
}
8 changes: 4 additions & 4 deletions app/src/test/kotlin/com/vrem/util/StringUtilsTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import java.util.Locale
class StringUtilsTest {

@Test
fun testSpecialTrim() {
fun specialTrim() {
// setup
val expected = "ABS ADF"
val value = " ABS ADF "
Expand All @@ -35,7 +35,7 @@ class StringUtilsTest {
}

@Test
fun testToCapitalize() {
fun toCapitalize() {
// setup
val expected = "Value"
val value = "value"
Expand All @@ -46,7 +46,7 @@ class StringUtilsTest {
}

@Test
fun testNullToEmptyWhenNull() {
fun nullToEmptyWhenNull() {
// setup
val expected = String.EMPTY
val value = null
Expand All @@ -57,7 +57,7 @@ class StringUtilsTest {
}

@Test
fun testNullToEmpty() {
fun nullToEmpty() {
// setup
val expected = "value"
val value = "value"
Expand Down
16 changes: 6 additions & 10 deletions app/src/test/kotlin/com/vrem/wifianalyzer/ActivityUtilsTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,7 @@ import androidx.appcompat.widget.Toolbar
import org.junit.After
import org.junit.Assert.assertEquals
import org.junit.Test
import org.mockito.kotlin.any
import org.mockito.kotlin.mock
import org.mockito.kotlin.verify
import org.mockito.kotlin.verifyNoMoreInteractions
import org.mockito.kotlin.whenever
import org.mockito.kotlin.*

class ActivityUtilsTest {
private val window: Window = mock()
Expand All @@ -52,7 +48,7 @@ class ActivityUtilsTest {
}

@Test
fun testSetupToolbar() {
fun setupToolbar() {
// setup
whenever<Any>(mainActivity.findViewById(R.id.toolbar)).thenReturn(toolbar)
whenever(mainActivity.supportActionBar).thenReturn(actionBar)
Expand All @@ -68,7 +64,7 @@ class ActivityUtilsTest {
}

@Test
fun testKeepScreenOnSwitchOn() {
fun keepScreenOnSwitchOn() {
// setup
whenever(settings.keepScreenOn()).thenReturn(true)
whenever(mainActivity.window).thenReturn(window)
Expand All @@ -81,7 +77,7 @@ class ActivityUtilsTest {
}

@Test
fun testKeepScreenOnSwitchOff() {
fun keepScreenOnSwitchOff() {
// setup
whenever(settings.keepScreenOn()).thenReturn(false)
whenever(mainActivity.window).thenReturn(window)
Expand All @@ -94,15 +90,15 @@ class ActivityUtilsTest {
}

@Test
fun testStartWiFiSettings() {
fun startWiFiSettings() {
// execute
mainActivity.startWiFiSettings()
// validate
verify(mainActivity).startActivity(any())
}

@Test
fun testStartLocationSettings() {
fun startLocationSettings() {
// execute
mainActivity.startLocationSettings()
// validate
Expand Down
Loading

0 comments on commit 9887572

Please sign in to comment.