Fix TV startup navigation and complete title pages #39
1 changed files with 28 additions and 6 deletions
|
|
@ -26,6 +26,8 @@ import org.jellyfin.sdk.api.operations.ItemsApi
|
|||
import org.jellyfin.sdk.api.operations.UserViewsApi
|
||||
import org.jellyfin.sdk.model.api.*
|
||||
import org.junit.Assert.*
|
||||
import org.junit.After
|
||||
import org.junit.Before
|
||||
import org.junit.Rule
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
|
|
@ -41,13 +43,29 @@ import org.robolectric.annotation.Config
|
|||
@Config(sdk = [34], application = Application::class, qualifiers = "w960dp-h540dp-xhdpi")
|
||||
class FirstSignInNavigationTest {
|
||||
@get:Rule val rule = createAndroidComposeRule<ComponentActivity>()
|
||||
private lateinit var previousUrl: String
|
||||
private var previousFixtures = false
|
||||
private var previousScreens = true
|
||||
|
||||
@Before fun captureGlobalPreferences() {
|
||||
ConductarrPreference.initialize(rule.activity)
|
||||
WolfskinScreenPreference.initialize(rule.activity)
|
||||
previousUrl = ConductarrPreference.baseUrl
|
||||
previousFixtures = ConductarrPreference.fixtures
|
||||
previousScreens = WolfskinScreenPreference.enabled
|
||||
rule.mainClock.autoAdvance = true
|
||||
}
|
||||
|
||||
@After fun restoreGlobalPreferences() {
|
||||
ConductarrPreference.updateBaseUrl(previousUrl)
|
||||
ConductarrPreference.updateFixtures(previousFixtures)
|
||||
WolfskinScreenPreference.enabled = previousScreens
|
||||
rule.mainClock.autoAdvance = true
|
||||
}
|
||||
|
||||
@Test fun firstContinueThenMoviesRendersMindelsGridWithoutReenteringThePicker() {
|
||||
ConductarrPreference.initialize(rule.activity)
|
||||
ConductarrPreference.updateFixtures(false)
|
||||
WolfskinScreenPreference.initialize(rule.activity)
|
||||
WolfskinScreenPreference.enabled = true
|
||||
val previousUrl = ConductarrPreference.baseUrl
|
||||
FakeConductarr().use { fake ->
|
||||
fake.audiencesBody = """{"audiences":[{"is_anime":false,"libraries":["Mindel Movies"],"media_type":"movie","owner":"mindel","users":["mindel"]},{"is_anime":false,"libraries":["Mindel Shows"],"media_type":"tv","owner":"mindel","users":["mindel"]}]}"""
|
||||
ConductarrPreference.updateBaseUrl(fake.url)
|
||||
|
|
@ -95,6 +113,7 @@ class FirstSignInNavigationTest {
|
|||
pressKey(Key.DirectionRight)
|
||||
pressKey(Key.DirectionCenter)
|
||||
}
|
||||
rule.waitForIdle()
|
||||
rule.waitUntil(10_000) {
|
||||
Shadows.shadowOf(Looper.getMainLooper()).idle()
|
||||
rule.onAllNodesWithTag("library-grid").fetchSemanticsNodes().isNotEmpty()
|
||||
|
|
@ -105,10 +124,12 @@ class FirstSignInNavigationTest {
|
|||
assertEquals(6, session.state!!.view.library!!.source.size)
|
||||
assertFalse(session.state!!.person.hasAnime)
|
||||
rule.onNodeWithText("Shows").performClick()
|
||||
rule.waitForIdle()
|
||||
try {
|
||||
rule.waitUntil(10_000) {
|
||||
rule.waitUntil(timeoutMillis = 15_000) {
|
||||
Shadows.shadowOf(Looper.getMainLooper()).idle()
|
||||
session.state!!.view.library?.source?.size == 29
|
||||
rule.onAllNodes(hasTestTag("library-grid") and
|
||||
hasAnyDescendant(hasText("Mindel Shows title 0"))).fetchSemanticsNodes().isNotEmpty()
|
||||
}
|
||||
} catch (timeout: ComposeTimeoutException) {
|
||||
val shell = session.state!!
|
||||
|
|
@ -118,13 +139,14 @@ class FirstSignInNavigationTest {
|
|||
"${shell.rememberedView("shows").library?.status}", timeout)
|
||||
}
|
||||
rule.onNodeWithTag("library-grid").assertIsDisplayed()
|
||||
assertEquals(29, session.state!!.view.library!!.source.size)
|
||||
rule.onAllNodesWithText("Mindel Shows title 0")[0].assertIsDisplayed()
|
||||
rule.onNodeWithText("Home").performClick()
|
||||
rule.waitForIdle()
|
||||
rule.onNodeWithText("Desperate Housewives").assertIsDisplayed()
|
||||
assertFalse("Returning Home must not reopen the picker", session.state!!.pickerVisible)
|
||||
} finally { model.viewModelScope.cancel() }
|
||||
}
|
||||
}
|
||||
ConductarrPreference.updateBaseUrl(previousUrl)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue