mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-11-21 05:46:03 +00:00
test(settings): cover catalog routing and navigation history
This commit is contained in:
1 parent
7f1a743733
commit
cf556596f0
2 files changed
+91
No files matched your search
@@ -0,0 +1,62 @@
|
||||
package com.droiddeck.launcher.ui
|
||||
|
||||
import org.junit.Assert.assertEquals
|
||||
import org.junit.Assert.assertFalse
|
||||
import org.junit.Assert.assertTrue
|
||||
import org.junit.Test
|
||||
|
||||
class SettingsCatalogTest {
|
||||
private fun targets(query: String) = SettingsCatalog.search(query).map { it.target }.toSet()
|
||||
|
||||
@Test fun allEightCategoriesAreRepresentedAndEveryDestinationIsUnique() {
|
||||
assertEquals(SettingsCategory.entries.toSet(), SettingsCatalog.entries.map { it.category }.toSet())
|
||||
val targetIds = SettingsCatalog.entries.map { it.target }
|
||||
assertEquals("Each search result must have one unambiguous route", targetIds.size, targetIds.toSet().size)
|
||||
}
|
||||
|
||||
@Test fun searchTrimsAndMatchesAliasesWithoutReturningResultsForBlankQueries() {
|
||||
assertTrue(SettingsCatalog.search(" ").isEmpty())
|
||||
assertEquals(setOf("theme"), targets(" COLORS "))
|
||||
assertTrue(targets("wireless debugging").contains("phantom-process"))
|
||||
assertTrue(targets("anisotropic filtering").contains("textures-anisotropy"))
|
||||
}
|
||||
|
||||
@Test fun protonDefaultsInstalledBuildsAndComponentNamesRouteToTheirOwnPages() {
|
||||
assertEquals(setOf("components"), targets("default proton"))
|
||||
assertEquals(setOf("protons"), targets("installed proton"))
|
||||
assertTrue(targets("DXVK").contains("components"))
|
||||
assertTrue(targets("VKD3D").contains("components"))
|
||||
assertFalse(SettingsCatalog.entries.any { it.target == "steam-menu" || it.target == "open-qam" })
|
||||
}
|
||||
|
||||
@Test fun routesPreserveDestinationCategoryAndMode() {
|
||||
val resolution = SettingsCatalog.entries.single { it.target == "res" }
|
||||
assertEquals(SettingsCategory.DISPLAY, resolution.category)
|
||||
assertEquals("steam", resolution.mode)
|
||||
|
||||
val renderer = SettingsCatalog.entries.single { it.target == "renderer" }
|
||||
assertEquals(SettingsCategory.SESSIONS, renderer.category)
|
||||
assertEquals("desktop", renderer.mode)
|
||||
|
||||
val overlay = SettingsCatalog.entries.single { it.target == "mangoapp" }
|
||||
assertEquals(SettingsCategory.DISPLAY, overlay.category)
|
||||
assertEquals("steam", overlay.mode)
|
||||
}
|
||||
|
||||
@Test fun commonSearchTermsRouteToTheirSettingsPages() {
|
||||
assertEquals(setOf("res"), targets("resolution"))
|
||||
assertEquals(setOf("gpu-drivers"), targets("driver"))
|
||||
assertTrue(targets("Proton").contains("protons"))
|
||||
assertTrue(targets("Proton").contains("components"))
|
||||
assertTrue(targets("microphone").contains("mic"))
|
||||
assertTrue(targets("ROM").contains("roms"))
|
||||
|
||||
val updates = SettingsCatalog.entries.filter { it.target == "updates" }.single()
|
||||
assertEquals(SettingsCategory.SUPPORT, updates.category)
|
||||
}
|
||||
|
||||
@Test fun controllerKeyboardButtonRemainsSearchableAsASetting() {
|
||||
assertTrue(targets("keyboard button").contains("controller-keyboard"))
|
||||
assertFalse(SettingsCatalog.entries.any { it.target == "keyboard" || it.target == "second-screen" })
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package com.droiddeck.launcher.ui
|
||||
|
||||
import org.junit.Assert.assertEquals
|
||||
import org.junit.Assert.assertNull
|
||||
import org.junit.Test
|
||||
|
||||
class SettingsHistoryTest {
|
||||
@Test fun specialistBackRestoresCategoryAndMode() {
|
||||
val category = SettingsDestination.Category(SettingsCategory.SESSIONS, "desktop", "renderer")
|
||||
val history = SettingsHistory().open(category).open(SettingsDestination.Components("gpu"))
|
||||
assertEquals(category, history.back().current)
|
||||
assertNull(history.back().back().current)
|
||||
}
|
||||
|
||||
@Test fun changingModeReplacesCurrentPage() {
|
||||
val category = SettingsDestination.Category(SettingsCategory.DISPLAY)
|
||||
val history = SettingsHistory().open(category).replace(category.copy(mode = "desktop"))
|
||||
assertEquals("desktop", (history.current as SettingsDestination.Category).mode)
|
||||
assertNull(history.back().current)
|
||||
}
|
||||
|
||||
@Test fun repeatedDestinationsDoNotAddBackSteps() {
|
||||
val destination = SettingsDestination.Performance()
|
||||
val history = SettingsHistory().open(destination).open(destination)
|
||||
assertEquals(1, history.destinations.size)
|
||||
assertNull(history.back().back().current)
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user