Skip to content

Commit e3fed29

Browse files
committed
add ThemeInstrumentedTest to verify theme settings and functionality
1 parent 05e6eaa commit e3fed29

2 files changed

Lines changed: 71 additions & 0 deletions

File tree

app/src/androidTest/kotlin/com/vrem/wifianalyzer/MainInstrumentedTest.kt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,4 +115,9 @@ class MainInstrumentedTest {
115115
fun settings() {
116116
SettingsInstrumentedTest().run()
117117
}
118+
119+
@Test
120+
fun theme() {
121+
ThemeInstrumentedTest().run()
122+
}
118123
}
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
/*
2+
* WiFiAnalyzer
3+
* Copyright (C) 2026 VREM Software Development <VREMSoftwareDevelopment@gmail.com>
4+
*
5+
* This program is free software: you can redistribute it and/or modify
6+
* it under the terms of the GNU General Public License as published by
7+
* the Free Software Foundation, either version 3 of the License, or
8+
* (at your option) any later version.
9+
*
10+
* This program is distributed in the hope that it will be useful,
11+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13+
* GNU General Public License for more details.
14+
*
15+
* You should have received a copy of the GNU General Public License
16+
* along with this program. If not, see <http://www.gnu.org/licenses/>
17+
*/
18+
package com.vrem.wifianalyzer
19+
20+
import androidx.appcompat.app.AppCompatDelegate
21+
import androidx.test.espresso.Espresso.onView
22+
import androidx.test.espresso.Espresso.pressBack
23+
import androidx.test.espresso.action.ViewActions.click
24+
import androidx.test.espresso.assertion.ViewAssertions.matches
25+
import androidx.test.espresso.matcher.ViewMatchers.isDisplayed
26+
import androidx.test.espresso.matcher.ViewMatchers.withText
27+
import org.junit.Assert.assertEquals
28+
29+
internal class ThemeInstrumentedTest : Runnable {
30+
override fun run() {
31+
verifyThemeSettings()
32+
33+
listOf(
34+
"Dark" to AppCompatDelegate.MODE_NIGHT_YES,
35+
"Light" to AppCompatDelegate.MODE_NIGHT_NO,
36+
"System" to AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM,
37+
"Black" to AppCompatDelegate.MODE_NIGHT_YES,
38+
).forEach { (themeName, expectedNightMode) ->
39+
changeThemeAndVerify(themeName, expectedNightMode)
40+
}
41+
}
42+
43+
private fun verifyThemeSettings() {
44+
selectMenuItem(R.id.nav_drawer_settings, "Settings")
45+
scrollToAndVerify("Theme")
46+
pressBack()
47+
}
48+
49+
private fun changeThemeAndVerify(
50+
themeName: String,
51+
expectedNightMode: Int,
52+
) {
53+
selectMenuItem(R.id.nav_drawer_settings, "Settings")
54+
scrollToAndVerify("Theme")
55+
onView(withText("Theme")).perform(click())
56+
pauseShort()
57+
onView(withText(themeName)).check(matches(isDisplayed()))
58+
onView(withText(themeName)).perform(click())
59+
pauseShort()
60+
assertEquals(
61+
"Theme $themeName should set night mode to $expectedNightMode",
62+
expectedNightMode,
63+
AppCompatDelegate.getDefaultNightMode(),
64+
)
65+
}
66+
}

0 commit comments

Comments
 (0)