Skip to content

Commit ffa4468

Browse files
add more tests
1 parent 730c093 commit ffa4468

File tree

11 files changed

+219
-37
lines changed

11 files changed

+219
-37
lines changed

app/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ dependencies {
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.1'
41+
implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.9.2'
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"
@@ -48,7 +48,7 @@ dependencies {
4848
testImplementation 'com.googlecode.junit-toolbox:junit-toolbox:2.4'
4949
testImplementation 'junit:junit:4.13.2'
5050
testImplementation 'org.mockito:mockito-core:5.18.0'
51-
testImplementation 'org.mockito.kotlin:mockito-kotlin:5.4.0'
51+
testImplementation 'org.mockito.kotlin:mockito-kotlin:6.0.0'
5252
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"

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-
#Sun Jul 13 12:33:53 EDT 2025
3-
version_build=13
2+
#Sat Jul 19 09:27:24 EDT 2025
3+
version_build=14
44
version_major=3
55
version_minor=2
66
version_patch=1

app/jacoco.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ def jacocoCoverageVerificationProvider = tasks.register('jacocoTestCoverageVerif
7373
}
7474
limit {
7575
counter = 'BRANCH'
76-
minimum = 0.90
76+
minimum = 0.91
7777
}
7878
limit {
7979
counter = 'COMPLEXITY'

app/src/main/kotlin/com/vrem/wifianalyzer/wifi/graphutils/SeriesOptions.kt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ private fun BaseSeries<GraphDataPoint>.highlightConnected(connected: Boolean) {
3232
this.thickness = thickness
3333
this.setTextBold(connected)
3434
}
35+
else -> throw IllegalArgumentException("Unsupported series type: ${this::class.java}")
3536
}
3637
}
3738

@@ -41,13 +42,15 @@ private fun BaseSeries<GraphDataPoint>.seriesColor(graphColors: GraphColors) {
4142
when (this) {
4243
is LineGraphSeries<GraphDataPoint> -> this.backgroundColor = graphColor.background.toInt()
4344
is TitleLineGraphSeries<GraphDataPoint> -> this.backgroundColor = graphColor.background.toInt()
45+
else -> throw IllegalArgumentException("Unsupported series type: ${this::class.java}")
4446
}
4547
}
4648

4749
private fun BaseSeries<GraphDataPoint>.drawBackground(drawBackground: Boolean) {
4850
when (this) {
4951
is LineGraphSeries<GraphDataPoint> -> this.isDrawBackground = drawBackground
5052
is TitleLineGraphSeries<GraphDataPoint> -> this.isDrawBackground = drawBackground
53+
else -> throw IllegalArgumentException("Unsupported series type: ${this::class.java}")
5154
}
5255
}
5356

app/src/main/res/values-ru/strings.xml

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,17 @@
1515
~
1616
~ You should have received a copy of the GNU General Public License
1717
~ along with this program. If not, see <http://www.gnu.org/licenses/>
18-
--><resources>
18+
-->
19+
20+
<resources>
1921
<string name="app_copyright">"Авторские права \u00A9 2015 \u002D "</string>
22+
2023
<string name="navigation_drawer_open">"Открыть панель навигации"</string>
2124
<string name="navigation_drawer_close">"Закрыть панель навигации"</string>
22-
<string name="scanner_message">"Сканирование "</string>
25+
<string name="scanner_message">"Сканирование &#8230;"</string>
2326
<string name="scanner_pause">"Приостановить"</string>
2427
<string name="scanner_play">"Воспроизвести"</string>
28+
2529
<!-- action start -->
2630
<string name="action_access_points">"Точки доступа"</string>
2731
<string name="action_channel_rating">"Оценка каналов"</string>
@@ -41,47 +45,62 @@
4145
<string name="throttling_msg">"В Android 9 введено регулирование сканирования Wi-Fi. В Android 10 появилась новая опция разработчика, позволяющая отключить регулирование в (Настройки - Параметры разработчика - Сеть - Регулирование сканирования Wi-Fi)."</string>
4246
<string name="export_not_available">"Экспорт не доступен"</string>
4347
<string name="current_connection">"Текущее соединение"</string>
48+
4449
<string name="channel_rating_best">"Лучшие каналы:"</string>
4550
<string name="channel_rating_best_none">"Нет"</string>
4651
<string name="channel_rating_best_alternative">"%s, попробуйте альтернативный Wi-Fi диапазон %s"</string>
4752
<string name="channel_rating_heading_rating">"Оценка каналов"</string>
4853
<string name="channel_rating_heading_number">"Номер канала"</string>
4954
<string name="channel_rating_heading_count">"Число точек доступа"</string>
5055
<string name="channel_short_name">"CH"</string>
56+
5157
<string name="graph_channel_axis_x">"Wi-Fi каналы"</string>
5258
<string name="graph_time_axis_x">"Число сканирований"</string>
5359
<string name="graph_axis_y">"Уровень сигнала (dBm)"</string>
60+
5461
<!-- settings start -->
5562
<string name="country_code_title">"Страна"</string>
63+
5664
<string name="scan_speed_title">"Интервал сканирования"</string>
5765
<string name="scan_speed_summary">"%s секунд между каждым сканированием"</string>
66+
5867
<string name="sort_by_title">"Сортировка"</string>
5968
<string name="sort_by_signal_strength">"Уровень сигнала"</string>
6069
<string name="sort_by_channel">"Канал"</string>
70+
6171
<string name="group_by_title">"Группировка"</string>
6272
<string name="group_by_none">"Нет"</string>
6373
<string name="group_by_channel">"Канал"</string>
6474
<string name="group_by_virtual">"Виртуально"</string>
75+
6576
<string name="connection_view_title">"Дисплей соединение"</string>
6677
<string name="connection_view_complete">"Полный"</string>
6778
<string name="connection_view_compact">"Компактный"</string>
6879
<string name="connection_view_hide">"Скрыть"</string>
80+
6981
<string name="ap_view_title">"Точка доступа"</string>
7082
<string name="ap_view_complete">"Полный"</string>
7183
<string name="ap_view_compact">"Компактный"</string>
84+
7285
<string name="graph_maximum_y_title">"Максимальная сила сигнала графика"</string>
86+
7387
<string name="channel_graph_legend_title">"Показать легенду графика каналa"</string>
7488
<string name="time_graph_legend_title">"Показать легенду графика времени"</string>
7589
<string name="graph_legend_left">"Слева"</string>
7690
<string name="graph_legend_right">"Справа"</string>
7791
<string name="graph_legend_hide">"Скрыть"</string>
92+
7893
<string name="theme_title">"Цветовая тема"</string>
7994
<string name="theme_dark">"Темная"</string>
8095
<string name="theme_light">"Светлая"</string>
8196
<string name="theme_system">"Система"</string>
97+
8298
<string name="wifi_off_on_exit_title">"Wi-Fi выключен при выходе"</string>
99+
83100
<string name="keep_screen_on_title">"Экран всегда включен"</string>
101+
84102
<string name="language_title">"Язык"</string>
103+
85104
<string name="reset_title">"Сброс"</string>
86105
<!-- settings end -->
87106

@@ -90,6 +109,10 @@
90109
<string name="about_description_title">"Описание:"</string>
91110
<string name="about_description_text">"Оптимизация сети Wi-Fi путем проверки состояния Wi-Fi, уровня сигнала и определения переполненных каналов используя WiFiAnalyzer для Android"</string>
92111
<string name="about_libraries_title">"Использованные библиотеки:"</string>
112+
<string name="about_documentation">Документация:</string>
113+
<string name="about_how_to">Инструкция:</string>
114+
<string name="about_faq">FAQ:</string>
115+
<string name="about_privacy_policy">Политика Конфиденциальности:</string>
93116
<string name="about_contributor_title">"Авторы"</string>
94117
<string name="about_write_review">"Написать отзыв"</string>
95118
<!-- about end -->
@@ -113,8 +136,4 @@
113136
<string name="wifi_throttling_on">"Регулирование сканирования Wi-Fi включено"</string>
114137
<string name="wifi_throttling_off">"Регулирование сканирования Wi-Fi отключено"</string>
115138
<!-- wifi throttling end -->
116-
<string name="about_documentation">Документация:</string>
117-
<string name="about_how_to">Инструкция:</string>
118-
<string name="about_faq">FAQ:</string>
119-
<string name="about_privacy_policy">Политика Конфиденциальности:</string>
120139
</resources>

app/src/test/kotlin/com/vrem/wifianalyzer/wifi/channelrating/ChannelRatingAdapterTest.kt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ import com.vrem.wifianalyzer.wifi.model.Strength.Companion.reverse
3737
import com.vrem.wifianalyzer.wifi.predicate.Predicate
3838
import com.vrem.wifianalyzer.wifi.predicate.predicate
3939
import org.assertj.core.api.Assertions.assertThat
40-
import org.assertj.core.api.Assertions.assertThatExceptionOfType
40+
import org.assertj.core.api.Assertions.assertThatThrownBy
4141
import org.junit.After
4242
import org.junit.Test
4343
import org.junit.runner.RunWith
@@ -131,9 +131,9 @@ class ChannelRatingAdapterTest {
131131
doReturn(wiFiBand).whenever(settings).wiFiBand()
132132
val viewGroup = mainActivity.findViewById<ViewGroup>(android.R.id.content)
133133
// execute & validate
134-
assertThatExceptionOfType(IndexOutOfBoundsException::class.java)
135-
.isThrownBy { fixture.getView(0, null, viewGroup) }
136-
.withMessage("Index 0 out of bounds for length 0")
134+
assertThatThrownBy({ fixture.getView(0, null, viewGroup) })
135+
.isInstanceOf(IndexOutOfBoundsException::class.java)
136+
.hasMessage("Index 0 out of bounds for length 0")
137137
verify(settings).wiFiBand()
138138
}
139139

app/src/test/kotlin/com/vrem/wifianalyzer/wifi/graphutils/GraphColorsTest.kt

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,17 +75,38 @@ class GraphColorsTest {
7575
}
7676

7777
@Test
78-
fun addColorDoesNotAddNonExistingColor() {
78+
fun addColorDoesNotAddExistingColor() {
79+
// setup
80+
val graphColors = withGraphColors()
81+
val expected = graphColors[2]
82+
// validate & execute
83+
assertThat(fixture.graphColor()).isEqualTo(expected)
84+
fixture.addColor(expected.primary)
85+
fixture.addColor(expected.primary)
86+
assertThat(fixture.graphColor()).isEqualTo(expected)
87+
}
88+
89+
@Test
90+
fun addColorWithNonExistingColor() {
91+
// setup
92+
val size = fixture.graphColor()
93+
// execute
94+
fixture.addColor(123)
95+
// validate
96+
assertThat(fixture.graphColor()).isNotEqualTo(size)
97+
}
98+
99+
@Test
100+
fun graphColorCyclesThroughColors() {
79101
// setup
80102
val graphColors = withGraphColors()
81103
val expected = graphColors[1]
82-
val graphColor = graphColors[2]
83104
val original = fixture.graphColor()
84105
// execute
85106
val actual = fixture.graphColor()
86107
// validate
87108
assertThat(actual).isEqualTo(expected)
88-
assertThat(original).isEqualTo(graphColor)
109+
assertThat(original).isEqualTo(graphColors[2])
89110
}
90111

91112
private fun withColors(): Array<String> {
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
package com.vrem.wifianalyzer.wifi.graphutils
2+
3+
import org.assertj.core.api.Assertions.assertThat
4+
import org.junit.Test
5+
6+
class GraphDataPointTest {
7+
8+
private val fixture:GraphDataPoint = GraphDataPoint(111, 222)
9+
10+
@Test
11+
fun getX() {
12+
// Validate
13+
assertThat(fixture.x).isEqualTo(111)
14+
}
15+
16+
@Test
17+
fun getY() {
18+
// Validate
19+
assertThat(fixture.y).isEqualTo(222)
20+
}
21+
22+
}

app/src/test/kotlin/com/vrem/wifianalyzer/wifi/graphutils/GraphViewBuilderTest.kt

Lines changed: 28 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,21 @@ class GraphViewBuilderTest {
4545
}
4646

4747
@Test
48-
fun graphViewLayout() {
48+
fun graphViewBuilderWithHorizontalLabelsVisible() {
4949
// setup
50-
val fixture = GraphViewBuilder(numHorizontalLabels, MAX_Y_DEFAULT, ThemeStyle.DARK, true)
50+
val fixture = GraphViewBuilder(numHorizontalLabels, MAX_Y_DEFAULT, ThemeStyle.DARK)
51+
val layoutParams = fixture.layoutParams
52+
// execute
53+
graphView.layout(layoutParams)
54+
// validate
55+
verify(graphView).layoutParams = layoutParams
56+
verify(graphView).visibility = View.GONE
57+
}
58+
59+
@Test
60+
fun graphViewBuilderWithHorizontalLabelsNotVisible() {
61+
// setup
62+
val fixture = GraphViewBuilder(numHorizontalLabels, MAX_Y_DEFAULT, ThemeStyle.DARK, false)
5163
val layoutParams = fixture.layoutParams
5264
// execute
5365
graphView.layout(layoutParams)
@@ -76,11 +88,20 @@ class GraphViewBuilderTest {
7688
@Test
7789
fun gridLabelRendererLabelFormat() {
7890
// execute
79-
gridLabelRenderer.labelFormat(labelFormatter)
91+
val actual = gridLabelRenderer.labelFormat(labelFormatter)
8092
// validate
93+
assertThat(actual).isSameAs(gridLabelRenderer)
8194
verify(gridLabelRenderer).labelFormatter = labelFormatter
8295
}
8396

97+
@Test
98+
fun gridLabelRendererLabelFormatNull() {
99+
// execute
100+
val actual = gridLabelRenderer.labelFormat(null)
101+
// validate
102+
assertThat(actual).isSameAs(gridLabelRenderer)
103+
}
104+
84105
@Test
85106
fun gridLabelRendererLabels() {
86107
// setup
@@ -111,8 +132,9 @@ class GraphViewBuilderTest {
111132
val expectedSize = textSize * AXIS_TEXT_SIZE_ADJUSTMENT
112133
whenever(gridLabelRenderer.verticalAxisTitleTextSize).thenReturn(textSize)
113134
// execute
114-
gridLabelRenderer.verticalTitle(verticalTitle)
135+
val actual = gridLabelRenderer.verticalTitle(verticalTitle)
115136
// validate
137+
assertThat(actual).isSameAs(gridLabelRenderer)
116138
verify(gridLabelRenderer).verticalAxisTitleTextSize = expectedSize
117139
verify(gridLabelRenderer).verticalAxisTitleTextSize
118140
verify(gridLabelRenderer).verticalAxisTitle = verticalTitle
@@ -121,10 +143,11 @@ class GraphViewBuilderTest {
121143
@Test
122144
fun gridLabelRendererVerticalTitleEmpty() {
123145
// execute
124-
gridLabelRenderer.verticalTitle("")
146+
val actual = gridLabelRenderer.verticalTitle("")
125147
// validate
126148
verify(gridLabelRenderer, never()).verticalAxisTitle = any()
127149
verify(gridLabelRenderer, never()).verticalAxisTitleTextSize = any()
150+
assertThat(actual).isSameAs(gridLabelRenderer)
128151
}
129152

130153
@Test

0 commit comments

Comments
 (0)