Skip to content

Commit 151a877

Browse files
Update dependencies
1 parent 6779e66 commit 151a877

10 files changed

Lines changed: 157 additions & 119 deletions

File tree

app/build.gradle

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,12 @@ dependencies {
3333
implementation fileTree(include: ["*.jar"], dir: "libs")
3434
implementation 'com.google.android.material:material:1.12.0'
3535
implementation 'androidx.annotation:annotation:1.9.1'
36-
implementation 'androidx.appcompat:appcompat:1.7.0'
36+
implementation 'androidx.appcompat:appcompat:1.7.1'
3737
implementation 'androidx.collection:collection-ktx:1.5.0'
3838
implementation 'androidx.core:core-ktx:1.16.0'
3939
implementation 'androidx.core:core-splashscreen:1.0.1'
4040
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
41-
implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.9.0'
41+
implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.9.1'
4242
implementation 'androidx.media:media:1.7.0'
4343
implementation 'androidx.preference:preference-ktx:1.2.1'
4444
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
@@ -49,7 +49,7 @@ dependencies {
4949
testImplementation 'junit:junit:4.13.2'
5050
testImplementation 'org.mockito:mockito-core:5.18.0'
5151
testImplementation 'org.mockito.kotlin:mockito-kotlin:5.4.0'
52-
testImplementation 'org.robolectric:robolectric:4.14.1'
52+
testImplementation 'org.robolectric:robolectric:4.15.1'
5353
testImplementation "org.jetbrains.kotlin:kotlin-test:$kotlin_version"
5454
testImplementation "org.jetbrains.kotlin:kotlin-test-junit:$kotlin_version"
5555
testImplementation 'org.slf4j:slf4j-simple:2.0.17'
@@ -113,13 +113,13 @@ android {
113113
}
114114

115115
compileOptions {
116-
sourceCompatibility JavaVersion.VERSION_11
117-
targetCompatibility JavaVersion.VERSION_11
116+
sourceCompatibility JavaVersion.VERSION_17
117+
targetCompatibility JavaVersion.VERSION_17
118118
}
119-
120119
kotlinOptions {
121-
jvmTarget = "11"
120+
jvmTarget = "17"
122121
}
122+
123123
lint {
124124
lintConfig = file("lint.xml")
125125
}

app/build.properties

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#Build Properties
2-
#Sat Jun 14 10:07:48 EDT 2025
3-
version_build=0
2+
#Sat Jun 28 07:35:54 EDT 2025
3+
version_build=1
44
version_major=3
55
version_minor=2
66
version_patch=1

app/src/main/kotlin/com/vrem/wifianalyzer/wifi/band/WiFiChannels.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ class WiFiChannels(
6262

6363
private fun wiFiChannel(frequency: Int): WiFiChannel {
6464
val firstChannel = (channelRange.first.channel + if (channelRange.first.channel < 0) -0.5 else 0.5).toInt()
65-
val channel = ((frequency - channelRange.first.frequency) / FREQUENCY_SPREAD + firstChannel).toInt()
65+
val channel = (frequency - channelRange.first.frequency) / FREQUENCY_SPREAD + firstChannel
6666
return WiFiChannel(channel, frequency)
6767
}
6868

app/src/main/kotlin/com/vrem/wifianalyzer/wifi/channelgraph/ChannelGraphAdapter.kt

Lines changed: 0 additions & 34 deletions
This file was deleted.

app/src/main/kotlin/com/vrem/wifianalyzer/wifi/channelgraph/ChannelGraphFragment.kt

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,12 @@ import androidx.swiperefreshlayout.widget.SwipeRefreshLayout.OnRefreshListener
2727
import com.vrem.util.buildVersionP
2828
import com.vrem.wifianalyzer.MainContext
2929
import com.vrem.wifianalyzer.databinding.GraphContentBinding
30+
import com.vrem.wifianalyzer.wifi.band.WiFiBand
31+
import com.vrem.wifianalyzer.wifi.graphutils.GraphAdapter
3032

3133
class ChannelGraphFragment : Fragment(), OnRefreshListener {
3234
private lateinit var swipeRefreshLayout: SwipeRefreshLayout
33-
lateinit var channelGraphAdapter: ChannelGraphAdapter
35+
lateinit var graphAdapter: GraphAdapter
3436
private set
3537

3638
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View {
@@ -41,8 +43,9 @@ class ChannelGraphFragment : Fragment(), OnRefreshListener {
4143
swipeRefreshLayout.isRefreshing = false
4244
swipeRefreshLayout.isEnabled = false
4345
}
44-
channelGraphAdapter = ChannelGraphAdapter()
45-
channelGraphAdapter.graphViews().forEach { binding.graphFlipper.addView(it) }
46+
val graphViews = WiFiBand.entries.map { wiFiBand -> ChannelGraphView(wiFiBand) }
47+
graphAdapter = GraphAdapter(graphViews)
48+
graphAdapter.graphViews().forEach { binding.graphFlipper.addView(it) }
4649
return binding.root
4750
}
4851

@@ -54,12 +57,12 @@ class ChannelGraphFragment : Fragment(), OnRefreshListener {
5457

5558
override fun onResume() {
5659
super.onResume()
57-
MainContext.INSTANCE.scannerService.register(channelGraphAdapter)
60+
MainContext.INSTANCE.scannerService.register(graphAdapter)
5861
onRefresh()
5962
}
6063

6164
override fun onPause() {
62-
MainContext.INSTANCE.scannerService.unregister(channelGraphAdapter)
65+
MainContext.INSTANCE.scannerService.unregister(graphAdapter)
6366
super.onPause()
6467
}
6568

Lines changed: 133 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,133 @@
1+
package com.vrem.wifianalyzer
2+
3+
import android.Manifest
4+
import android.app.AlertDialog
5+
import android.app.Application
6+
import android.os.Build
7+
import android.os.Looper
8+
import android.view.View
9+
import androidx.appcompat.widget.Toolbar
10+
import androidx.test.core.app.ApplicationProvider
11+
import androidx.test.ext.junit.runners.AndroidJUnit4
12+
import com.google.android.material.navigation.NavigationView
13+
import org.assertj.core.api.Assertions
14+
import org.junit.After
15+
import org.junit.Before
16+
import org.junit.Test
17+
import org.junit.runner.RunWith
18+
import org.robolectric.Robolectric
19+
import org.robolectric.Shadows
20+
import org.robolectric.android.controller.ActivityController
21+
import org.robolectric.annotation.Config
22+
import org.robolectric.shadows.ShadowAlertDialog
23+
24+
@RunWith(AndroidJUnit4::class)
25+
@Config(sdk = [Build.VERSION_CODES.VANILLA_ICE_CREAM])
26+
class MainRobolectricTest {
27+
private val pause = "Pause"
28+
private val play = "Play"
29+
30+
private lateinit var activityController: ActivityController<MainActivity>
31+
private lateinit var activity: MainActivity
32+
33+
@Before
34+
fun setUp() {
35+
val application = ApplicationProvider.getApplicationContext<Application>()
36+
val shadowApplication = Shadows.shadowOf(application)
37+
shadowApplication.grantPermissions(
38+
Manifest.permission.ACCESS_COARSE_LOCATION,
39+
Manifest.permission.ACCESS_FINE_LOCATION,
40+
Manifest.permission.ACCESS_WIFI_STATE,
41+
Manifest.permission.CHANGE_WIFI_STATE
42+
)
43+
activityController = Robolectric.buildActivity(MainActivity::class.java)
44+
.create()
45+
.start()
46+
.resume()
47+
.visible()
48+
activity = activityController.get()
49+
Shadows.shadowOf(Looper.getMainLooper()).idle()
50+
}
51+
52+
@After
53+
fun tearDown() {
54+
activityController.destroy()
55+
}
56+
57+
@Test
58+
fun navigation() {
59+
val navigationView = activity.findViewById<NavigationView>(R.id.nav_drawer)
60+
val toolbar = activity.findViewById<Toolbar>(R.id.toolbar)
61+
62+
fun selectMenuItem(index: Int, expectedTitle: String) {
63+
val menuItem = navigationView.menu.getItem(index)
64+
activity.onNavigationItemSelected(menuItem)
65+
Shadows.shadowOf(Looper.getMainLooper()).idle()
66+
Assertions.assertThat(toolbar.title.toString()).isEqualTo(expectedTitle)
67+
}
68+
69+
fun selectMenuItemAndGoBack(index: Int, expectedTitle: String) {
70+
selectMenuItem(index, expectedTitle)
71+
activity.onBackPressedDispatcher.onBackPressed()
72+
Shadows.shadowOf(Looper.getMainLooper()).idle()
73+
}
74+
75+
listOf(
76+
1 to "Channel Rating",
77+
2 to "Channel Graph",
78+
3 to "Time Graph",
79+
0 to "Access Points",
80+
5 to "Available Channels",
81+
6 to "Vendors"
82+
).forEach { (id, title) ->
83+
selectMenuItem(id, title)
84+
}
85+
86+
listOf(
87+
7 to "Settings",
88+
8 to "About"
89+
).forEach { (id, title) ->
90+
selectMenuItemAndGoBack(id, title)
91+
}
92+
}
93+
94+
@Test
95+
fun scanner() {
96+
val toolbar = activity.findViewById<Toolbar>(R.id.toolbar)
97+
val scannerMenuItem = toolbar.menu.findItem(R.id.action_scanner)
98+
Assertions.assertThat(scannerMenuItem).isNotNull
99+
Assertions.assertThat(scannerMenuItem.isVisible).isTrue
100+
101+
val scannerActionView = toolbar.findViewById<View>(R.id.action_scanner)
102+
Assertions.assertThat(scannerActionView.contentDescription).isEqualTo(pause)
103+
104+
activity.onOptionsItemSelected(scannerMenuItem)
105+
Shadows.shadowOf(Looper.getMainLooper()).idle()
106+
107+
Assertions.assertThat(scannerActionView.contentDescription).isEqualTo(play)
108+
109+
activity.onOptionsItemSelected(scannerMenuItem)
110+
Shadows.shadowOf(Looper.getMainLooper()).idle()
111+
112+
Assertions.assertThat(scannerActionView.contentDescription).isEqualTo(pause)
113+
}
114+
115+
@Test
116+
fun filter() {
117+
val toolbar = activity.findViewById<Toolbar>(R.id.toolbar)
118+
val filterMenuItem = toolbar.menu.findItem(R.id.action_filter)
119+
Assertions.assertThat(filterMenuItem).isNotNull
120+
121+
activity.onOptionsItemSelected(filterMenuItem)
122+
Shadows.shadowOf(Looper.getMainLooper()).idle()
123+
124+
val dialog = ShadowAlertDialog.getLatestAlertDialog()
125+
Assertions.assertThat(dialog).isNotNull
126+
Assertions.assertThat(dialog.isShowing).isTrue
127+
128+
dialog.getButton(AlertDialog.BUTTON_NEUTRAL).performClick()
129+
Shadows.shadowOf(Looper.getMainLooper()).idle()
130+
131+
Assertions.assertThat(dialog.isShowing).isFalse
132+
}
133+
}

app/src/test/kotlin/com/vrem/wifianalyzer/wifi/channelgraph/ChannelGraphAdapterTest.kt

Lines changed: 0 additions & 64 deletions
This file was deleted.

app/src/test/kotlin/com/vrem/wifianalyzer/wifi/channelgraph/ChannelGraphFragmentTest.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ class ChannelGraphFragmentTest {
5050
// validate
5151
assertThat(fixture).isNotNull()
5252
verify(scanner).update()
53-
verify(scanner).register(fixture.channelGraphAdapter)
53+
verify(scanner).register(fixture.graphAdapter)
5454
}
5555

5656
@Test
@@ -70,7 +70,7 @@ class ChannelGraphFragmentTest {
7070
fixture.onResume()
7171
// validate
7272
verify(scanner, times(2)).update()
73-
verify(scanner, times(2)).register(fixture.channelGraphAdapter)
73+
verify(scanner, times(2)).register(fixture.graphAdapter)
7474
}
7575

7676
@Test
@@ -80,7 +80,7 @@ class ChannelGraphFragmentTest {
8080
// execute
8181
fixture.onPause()
8282
// validate
83-
verify(scanner).unregister(fixture.channelGraphAdapter)
83+
verify(scanner).unregister(fixture.graphAdapter)
8484
}
8585

8686
@Config(sdk = [Build.VERSION_CODES.P])

build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,14 @@
2020

2121
buildscript {
2222
ext {
23-
kotlin_version = '2.1.21'
23+
kotlin_version = '2.2.0'
2424
}
2525
repositories {
2626
google()
2727
mavenCentral()
2828
}
2929
dependencies {
30-
classpath 'com.android.tools.build:gradle:8.10.1'
30+
classpath 'com.android.tools.build:gradle:8.11.0'
3131
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
3232
classpath "org.jetbrains.kotlin:kotlin-allopen:$kotlin_version"
3333
}

gradle/wrapper/gradle-wrapper.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
33
distributionPath=wrapper/dists
44
zipStoreBase=GRADLE_USER_HOME
55
zipStorePath=wrapper/dists
6-
distributionUrl=https\://services.gradle.org/distributions/gradle-8.11.1-bin.zip
6+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.14.2-bin.zip

0 commit comments

Comments
 (0)