mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-11-19 21:06:09 +00:00
Library store pills follow the new default store order (#2811)
* fix(library): move an unarranged store order to the new default at startup * fix(stores): forget an unarranged store order instead of saving the default
This commit is contained in:
1 parent
c1cf0f3a9c
commit
c336f994e1
4 files changed
+61
-12
No files matched your search
@@ -0,0 +1,45 @@
|
||||
package com.droiddeck.launcher.session
|
||||
|
||||
import com.droiddeck.launcher.stores.Store
|
||||
import com.droiddeck.launcher.stores.arrangeStoreTabs
|
||||
import org.junit.Assert.assertEquals
|
||||
import org.junit.Assert.assertFalse
|
||||
import org.junit.Assert.assertTrue
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
import org.robolectric.RobolectricTestRunner
|
||||
import org.robolectric.RuntimeEnvironment
|
||||
import org.robolectric.annotation.Config
|
||||
|
||||
@RunWith(RobolectricTestRunner::class)
|
||||
@Config(sdk = [33])
|
||||
class StoresTabOrderTest {
|
||||
private val app get() = RuntimeEnvironment.getApplication()
|
||||
private val defaults = Store.entries.map { it.id }
|
||||
private fun shown() = arrangeStoreTabs(SessionPrefs.storesTabOrder(app), emptySet()).map { it.store.id }
|
||||
|
||||
@Test
|
||||
fun anOldDefaultOrderMovesToTheCurrentOne() {
|
||||
SessionPrefs.setStoresTabOrder(app, listOf("gog", "epic", "amazon", "xbox", "itch", "gamejolt", "battlenet", "ubisoft", "ea", "rockstar"))
|
||||
SessionPrefs.settleStoresTabOrder(app, defaults)
|
||||
assertEquals(defaults, shown())
|
||||
assertFalse(SessionPrefs.storesTabOrderCustomized(app))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun aSavedCurrentDefaultIsNotMistakenForTheUsersOwn() {
|
||||
SessionPrefs.setStoresTabOrder(app, defaults)
|
||||
repeat(2) { SessionPrefs.settleStoresTabOrder(app, defaults) }
|
||||
assertFalse(SessionPrefs.storesTabOrderCustomized(app))
|
||||
assertTrue(SessionPrefs.storesTabOrder(app).isEmpty())
|
||||
}
|
||||
|
||||
@Test
|
||||
fun anArrangedOrderIsKept() {
|
||||
val mine = defaults.reversed()
|
||||
SessionPrefs.setStoresTabOrder(app, mine)
|
||||
SessionPrefs.settleStoresTabOrder(app, defaults)
|
||||
assertTrue(SessionPrefs.storesTabOrderCustomized(app))
|
||||
assertEquals(mine, shown())
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user