Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,9 @@ server, never a real one.
## Privacy and credits

- [`docs/privacy.md`](docs/privacy.md) (Android) and [`docs/privacy-tvos.md`](docs/privacy-tvos.md) (Apple TV) say what
the app keeps on the device and what it sends: only to your Seerr server, and to plex.tv if you sign in with Plex.
the app keeps on the device and what it sends: to your Seerr server, to plex.tv if you sign in with Plex, and to TMDB's
image server for pictures. Pictures come from your server, or from TMDB's image server when your server doesn't keep
its own copies (Seerr's Image Caching off).
- Film and series data comes from [TMDB](https://www.themoviedb.org) through Seerr. This product uses the TMDB API but
is not endorsed or certified by TMDB ([`docs/attribution.md`](docs/attribution.md)).
- [`THIRD-PARTY.md`](THIRD-PARTY.md) lists the code, fonts and marks Hither uses and their licences.
Expand Down
4 changes: 2 additions & 2 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ android {
applicationId = "com.tomdebres.hither"
minSdk = libs.versions.minSdk.get().toInt()
targetSdk = libs.versions.targetSdk.get().toInt()
versionCode = 16
versionName = "0.7.0"
versionCode = 17
versionName = "0.7.1"
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,9 @@ class ApprovalsTest {
/** The server answers a decision with a 500 (A5: the failure's dialog). */
@Volatile private var decideFails = false

/** Decisions the source has answered (or refused), counted as each returns: they run on the model's work thread. */
private val decisionsBack = java.util.concurrent.atomic.AtomicInteger()

/** A9: the first ask for a later page fails; every later ask answers. The asks for page 2, counted. */
@Volatile private var laterPageFailsOnce = false
private val secondPageAsks = java.util.concurrent.atomic.AtomicInteger()
Expand All @@ -106,10 +109,12 @@ class ApprovalsTest {
return RequestPage(PageInfo(results = chosen.size), chosen.drop(skip).take(take))
}
override suspend fun title(type: MediaType, tmdbId: Int) = RequestTitle("Title $tmdbId", "2026", null, null)
override suspend fun decide(requestId: Int, approve: Boolean): MediaRequest {
override suspend fun decide(requestId: Int, approve: Boolean): MediaRequest = try {
decided += requestId to approve
if (decideFails) throw SeerrException.Http(500, "boom")
return requests.single { it.id == requestId }
requests.single { it.id == requestId }
} finally {
decisionsBack.incrementAndGet()
}
}

Expand Down Expand Up @@ -284,12 +289,16 @@ class ApprovalsTest {
assertTrue("no dialog for a decision that went through", !shown("decision problem"))
}

/** With the clock stopped: whatever the source and the page have to do now, then [frames] frames. */
private fun settle(frames: Int) {
repeat(3) {
Thread.sleep(150)
rule.waitForIdle()
}
/**
* With the clock stopped: [answered] first (nothing, by default), then [frames] frames. The scripted source answers on
* the model's `work` thread (`Dispatchers.Default`), which the test clock does not drive: `advanceTimeBy` would move
* the page's clock on without the answer in, and `waitForIdle` does not wait for that thread. So the wait
* for an answer is in real time, but for the answer itself (its call back), not a guess at how long one takes (A9's
* three sleeps of 150 ms, which a slow host could outlast). After a press that sends nothing, the test clock alone.
*/
private fun settle(frames: Int, answered: () -> Boolean = { true }) {
rule.waitUntil(5_000) { answered() }
rule.waitForIdle()
repeat(frames) { rule.mainClock.advanceTimeByFrame() }
rule.waitForIdle()
}
Expand All @@ -308,7 +317,7 @@ class ApprovalsTest {
// the clock stopped: the decision fails at once, and the moment before its dialog is the test's
rule.mainClock.autoAdvance = false
rule.onRoot().performKeyInput { pressKey(Key.DirectionCenter) }
settle(frames = 6)
settle(frames = 6) { decisionsBack.get() == 1 }
assertEquals("focus back on the lockup as the dialog went", "approval request:1", focusedTag())
rule.onRoot().performKeyInput { pressKey(Key.DirectionRight) }
settle(frames = 3)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.tomdebres.hither.ui

import com.tomdebres.hither.core.rules.ImageSource
import androidx.activity.ComponentActivity
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Arrangement
Expand Down Expand Up @@ -177,7 +178,7 @@ class ControlFocusTest {
val model = remember {
DiscoverModel(
DiscoverSource { row, _ ->
DiscoverPage("http://seerr.test", Page(results = (1..8).map { MediaResult(id = row.ordinal * 100 + it, mediaType = "movie", title = "Film") }))
DiscoverPage(ImageSource.unknown("http://seerr.test"), Page(results = (1..8).map { MediaResult(id = row.ordinal * 100 + it, mediaType = "movie", title = "Film") }))
},
session,
scope,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.tomdebres.hither.ui

import com.tomdebres.hither.core.rules.ImageSource
import androidx.activity.ComponentActivity
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
Expand Down Expand Up @@ -125,7 +126,7 @@ class ControlShadowTest {
val model = remember {
DiscoverModel(
DiscoverSource { row, _ ->
DiscoverPage("http://seerr.test", Page(results = (1..8).map { MediaResult(id = row.ordinal * 100 + it, mediaType = "movie", title = "Film") }))
DiscoverPage(ImageSource.unknown("http://seerr.test"), Page(results = (1..8).map { MediaResult(id = row.ordinal * 100 + it, mediaType = "movie", title = "Film") }))
},
session,
scope,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.tomdebres.hither.ui

import com.tomdebres.hither.core.rules.ImageSource
import androidx.activity.ComponentActivity
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.fillMaxSize
Expand Down Expand Up @@ -76,7 +77,7 @@ class DiscoverDrawTest {
private fun requests(vararg ids: Int) = Requests(RequestPage(PageInfo(results = ids.size), ids.map { request(it) }))

private val rows = DiscoverSource { row, _ ->
DiscoverPage("http://seerr.test", Page(results = (1..8).map { MediaResult(id = row.ordinal * 100 + it, mediaType = "movie", title = "Film") }))
DiscoverPage(ImageSource.unknown("http://seerr.test"), Page(results = (1..8).map { MediaResult(id = row.ordinal * 100 + it, mediaType = "movie", title = "Film") }))
}

private fun show(requests: RequestsSource?, startOnRows: Boolean = false) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.tomdebres.hither.ui

import com.tomdebres.hither.core.rules.ImageSource
import com.tomdebres.hither.core.model.RequestPage
import androidx.compose.runtime.remember
import androidx.compose.runtime.rememberCoroutineScope
Expand Down Expand Up @@ -69,7 +70,7 @@ class DiscoverFocusTest {

/** Row n's cards are films n*100+1 .. n*100+[count], with no posters (nothing to fetch). */
private fun page(row: DiscoverRow, count: Int = 20) = DiscoverPage(
base,
ImageSource.unknown(base),
Page(
page = 1,
totalPages = 1,
Expand Down Expand Up @@ -297,7 +298,7 @@ class DiscoverFocusTest {
show { row, number ->
when {
row != DiscoverRow.TRENDING -> page(row)
number == 1 -> DiscoverPage(base, Page(page = 1, totalPages = 2, results = (1..8).map { MediaResult(id = it, mediaType = "movie", title = "Film $it") }))
number == 1 -> DiscoverPage(ImageSource.unknown(base), Page(page = 1, totalPages = 2, results = (1..8).map { MediaResult(id = it, mediaType = "movie", title = "Film $it") }))
second.incrementAndGet() == 1 -> throw SeerrException.Unreachable(RuntimeException("down"))
else -> retried.await()
}
Expand All @@ -315,7 +316,7 @@ class DiscoverFocusTest {
// out: the card stays, reading "Trying…", and keeps focus; the repeated Select asked nothing
rule.onNodeWithTag("retry more", useUnmergedTree = true).assertExists()
assertFocused("retry more")
retried.complete(DiscoverPage(base, Page(page = 2, totalPages = 2, results = (9..12).map { MediaResult(id = it, mediaType = "movie", title = "Film $it") })))
retried.complete(DiscoverPage(ImageSource.unknown(base), Page(page = 2, totalPages = 2, results = (9..12).map { MediaResult(id = it, mediaType = "movie", title = "Film $it") })))
awaitCard(card(DiscoverRow.TRENDING, 9))
// the page has come: focus is on its first card, where Try Again was
rule.waitUntil(3_000) { focusedTag() == card(DiscoverRow.TRENDING, 9) }
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.tomdebres.hither.ui

import com.tomdebres.hither.core.rules.ImageSource
import com.tomdebres.hither.ui.theme.PlaceholderLockup
import androidx.compose.ui.unit.dp
import androidx.compose.foundation.layout.padding
Expand Down Expand Up @@ -97,7 +98,7 @@ class DiscoverPolishTest {
private fun requests(vararg ids: Int) = Requests { RequestPage(PageInfo(results = ids.size), ids.map { request(it) }) }

private val rows = DiscoverSource { row, _ ->
DiscoverPage("http://seerr.test", Page(results = (1..8).map { MediaResult(id = row.ordinal * 100 + it, mediaType = "movie", title = "Film") }))
DiscoverPage(ImageSource.unknown("http://seerr.test"), Page(results = (1..8).map { MediaResult(id = row.ordinal * 100 + it, mediaType = "movie", title = "Film") }))
}

private lateinit var discover: DiscoverModel
Expand Down Expand Up @@ -281,8 +282,8 @@ class DiscoverPolishTest {
val source = DiscoverSource { row, _ ->
when (row) {
DiscoverRow.POPULAR_SERIES -> throw IllegalStateException("this row does not load")
DiscoverRow.UPCOMING_MOVIES -> DiscoverPage("http://seerr.test", Page(results = emptyList()))
else -> DiscoverPage("http://seerr.test", Page(results = (1..8).map { MediaResult(id = row.ordinal * 100 + it, mediaType = "movie", title = "Film") }))
DiscoverRow.UPCOMING_MOVIES -> DiscoverPage(ImageSource.unknown("http://seerr.test"), Page(results = emptyList()))
else -> DiscoverPage(ImageSource.unknown("http://seerr.test"), Page(results = (1..8).map { MediaResult(id = row.ordinal * 100 + it, mediaType = "movie", title = "Film") }))
}
}
show(null, source)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.tomdebres.hither.ui

import com.tomdebres.hither.core.rules.ImageSource
import android.util.Log
import androidx.activity.ComponentActivity
import androidx.compose.runtime.CompositionLocalProvider
Expand Down Expand Up @@ -81,7 +82,7 @@ class DiscoverRecompositionTest {

/** Row n's cards are films n*100+1 .. n*100+20, one page, no posters (nothing to fetch). */
private fun page(row: DiscoverRow) = DiscoverPage(
"http://seerr.test",
ImageSource.unknown("http://seerr.test"),
Page(
page = 1,
totalPages = 1,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.tomdebres.hither.ui

import com.tomdebres.hither.core.rules.ImageSource
import androidx.activity.ComponentActivity
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.fillMaxSize
Expand Down Expand Up @@ -61,7 +62,7 @@ class DiscoverRowsTest {

private val rows = DiscoverSource { row, _ ->
DiscoverPage(
"http://seerr.test",
ImageSource.unknown("http://seerr.test"),
Page(results = (1..8).map { MediaResult(id = row.ordinal * 100 + it, mediaType = "movie", title = "Film ${row.ordinal * 100 + it}", overview = "About film ${row.ordinal * 100 + it}.") }),
)
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.tomdebres.hither.ui

import com.tomdebres.hither.core.rules.ImageSource
import androidx.activity.ComponentActivity
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.fillMaxSize
Expand Down Expand Up @@ -67,7 +68,7 @@ class DiscoverStartTest {
private val session = Session(User(id = 8, displayName = "TV", permissions = 32), PublicSettings(applicationTitle = "Seerr", localLogin = true))

private val rows = DiscoverSource { row, _ ->
DiscoverPage("http://seerr.test", Page(results = (1..8).map { MediaResult(id = row.ordinal * 100 + it, mediaType = "movie", title = "Film") }))
DiscoverPage(ImageSource.unknown("http://seerr.test"), Page(results = (1..8).map { MediaResult(id = row.ordinal * 100 + it, mediaType = "movie", title = "Film") }))
}

private fun show(plan: CompletableDeferred<DiscoverPlan>) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.tomdebres.hither.ui

import com.tomdebres.hither.core.rules.ImageSource
import androidx.activity.ComponentActivity
import androidx.compose.runtime.remember
import androidx.compose.runtime.rememberCoroutineScope
Expand Down Expand Up @@ -50,7 +51,7 @@ class FocusShadowTest {
private val session = Session(User(id = 8, displayName = "TV", permissions = 32), PublicSettings(applicationTitle = "Seerr", localLogin = true))

private fun page(row: DiscoverRow) = DiscoverPage(
"http://seerr.test",
ImageSource.unknown("http://seerr.test"),
Page(page = 1, totalPages = 1, results = (1..20).map { MediaResult(id = row.ordinal * 100 + it, mediaType = "movie", title = "Film ${row.ordinal * 100 + it}") }),
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ import io.ktor.http.HttpStatusCode
import io.ktor.http.content.TextContent
import io.ktor.http.headersOf
import java.util.concurrent.CopyOnWriteArrayList
import java.util.concurrent.atomic.AtomicInteger
import org.junit.Assert.assertEquals
import org.junit.Assert.assertTrue
import androidx.compose.ui.unit.dp
Expand Down Expand Up @@ -82,6 +83,12 @@ class IssuesPageTest {
/** The server answers a report with a 500 (A5: the failure's dialog). */
@Volatile private var reportFails = false

/** Every report the page sent, whatever the server answered. */
private val reportsSent = AtomicInteger()

/** Calls through the page's access still out (they run on the models' work thread). */
private val inFlight = AtomicInteger()

/** The issues list answered by a proxy's HTML 403 (`/fake/forbid`'s kind), not Seerr's. */
@Volatile private var issuesForbidden = false
private val listed = CopyOnWriteArrayList<String>()
Expand All @@ -91,6 +98,7 @@ class IssuesPageTest {
MockEngine { request ->
val path = request.url.encodedPath
val json = SeerrClient.json
if (path == "/api/v1/issue" && request.method == HttpMethod.Post) reportsSent.incrementAndGet()
val body = when {
path == "/api/v1/settings/public" -> json.encodeToString(PublicSettings.serializer(), session.settings)
path == "/api/v1/auth/me" -> json.encodeToString(User.serializer(), session.user)
Expand Down Expand Up @@ -142,7 +150,14 @@ class IssuesPageTest {
AcceptAllCookiesStorage(),
)

override suspend fun <T> call(call: suspend (SeerrClient) -> T): T = call(client)
override suspend fun <T> call(call: suspend (SeerrClient) -> T): T {
inFlight.incrementAndGet()
try {
return call(client)
} finally {
inFlight.decrementAndGet()
}
}
}

private fun show() {
Expand Down Expand Up @@ -225,17 +240,22 @@ class IssuesPageTest {
* 600 ms) is the test's: the answer comes, the page takes it in, and two frames go by. The clock stays stopped.
*/
private fun submitAndHoldTheClock() {
val sent = reportsSent.get()
rule.mainClock.autoAdvance = false
rule.onRoot().performKeyInput { pressKey(Key.DirectionCenter) }
settle()
settle { reportsSent.get() == sent + 1 && inFlight.get() == 0 }
}

/** With the clock stopped: whatever the server and the page have to do now, then [frames] frames. */
private fun settle(frames: Int = 2) {
repeat(3) {
Thread.sleep(150)
rule.waitForIdle()
}
/**
* With the clock stopped: [answered] first (nothing, by default), then [frames] frames. The scripted server answers on
* the models' `work` thread (`Dispatchers.Default`) and Ktor's, which the test clock does not drive: `advanceTimeBy`
* would move the page's clock on without the answer in, and `waitForIdle` does not wait for those threads. So the wait
* for an answer is in real time, but for the answer itself (its call back), not a guess at how long one takes (A9's
* three sleeps of 150 ms, which a slow host could outlast). After a press that sends nothing, the test clock alone.
*/
private fun settle(frames: Int = 2, answered: () -> Boolean = { true }) {
rule.waitUntil(5_000) { answered() }
rule.waitForIdle()
repeat(frames) { rule.mainClock.advanceTimeByFrame() }
rule.waitForIdle()
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.tomdebres.hither.ui

import com.tomdebres.hither.core.rules.ImageSource
import android.graphics.Bitmap
import android.util.Log
import androidx.activity.ComponentActivity
Expand Down Expand Up @@ -88,7 +89,7 @@ class LockupTest {
private val session = Session(User(id = 8, displayName = "TV", permissions = 32), PublicSettings(applicationTitle = "Seerr", localLogin = true))

private val rows = DiscoverSource { row, _ ->
DiscoverPage("http://seerr.test", Page(results = (1..8).map { MediaResult(id = row.ordinal * 100 + it, mediaType = "movie", title = "Film ${row.ordinal * 100 + it}", releaseDate = "2026-01-02") }))
DiscoverPage(ImageSource.unknown("http://seerr.test"), Page(results = (1..8).map { MediaResult(id = row.ordinal * 100 + it, mediaType = "movie", title = "Film ${row.ordinal * 100 + it}", releaseDate = "2026-01-02") }))
}

private class Requests(private val ids: List<Int>) : RequestsSource {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.tomdebres.hither.ui

import com.tomdebres.hither.core.rules.ImageSource
import android.app.Activity
import android.app.Instrumentation
import android.content.Intent
Expand Down Expand Up @@ -104,7 +105,7 @@ class MediaDetailsTest {
watchProviders = listOf(WatchProviders("US", flatrate = listOf(WatchProvider(8, "Netflix", "/n.png")))),
mediaInfo = media,
),
MediaPages.BASE,
ImageSource.unknown(MediaPages.BASE),
MediaPages.server,
MediaPages.account,
)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.tomdebres.hither.ui

import com.tomdebres.hither.core.rules.ImageSource
import com.tomdebres.hither.core.Permission
import com.tomdebres.hither.core.model.CastMember
import com.tomdebres.hither.core.model.Credits
Expand Down Expand Up @@ -40,7 +41,7 @@ internal object MediaPages {
credits = Credits(cast = (1..castSize).map { CastMember(id = it, name = "Person $it", character = "Part $it") }),
mediaInfo = media,
),
BASE,
ImageSource.unknown(BASE),
server,
account.copy(permissions = permissions),
)
Expand All @@ -63,7 +64,7 @@ internal object MediaPages {
seasons = listOf(MediaSeason(seasonNumber = 1, status = 5)),
),
),
BASE,
ImageSource.unknown(BASE),
settings,
account.copy(permissions = permissions),
)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.tomdebres.hither.ui

import com.tomdebres.hither.core.rules.ImageSource
import android.util.Log
import androidx.activity.ComponentActivity
import androidx.compose.runtime.CompositionLocalProvider
Expand Down Expand Up @@ -78,7 +79,7 @@ class MediaRecompositionTest {
credits = Credits(cast = (1..12).map { CastMember(id = it, name = "Person $it", character = "Part $it") }),
keywords = (1..4).map { Keyword(it, "keyword $it") },
),
MediaPages.BASE,
ImageSource.unknown(MediaPages.BASE),
MediaPages.server,
MediaPages.account,
)
Expand Down
Loading
Loading