Isolate the artwork test singleton lifecycle
All checks were successful
review/code-claude B1 (artwork credential scoped to the exact Jellyfin scheme/host/port by a network interceptor, fresh ImageLoader, redirect-safe, 2-host test) and B2 (audiences null keeps the name rule, foreground recovery, test) verified by firstmate reading the 9-file delta; final gates green
All checks were successful
review/code-claude B1 (artwork credential scoped to the exact Jellyfin scheme/host/port by a network interceptor, fresh ImageLoader, redirect-safe, 2-host test) and B2 (audiences null keeps the name rule, foreground recovery, test) verified by firstmate reading the 9-file delta; final gates green
This commit is contained in:
parent
34ea983a51
commit
ec32346c71
1 changed files with 8 additions and 0 deletions
|
|
@ -8,6 +8,7 @@ import androidx.compose.runtime.LaunchedEffect
|
||||||
import androidx.compose.ui.test.junit4.createAndroidComposeRule
|
import androidx.compose.ui.test.junit4.createAndroidComposeRule
|
||||||
import coil3.request.SuccessResult
|
import coil3.request.SuccessResult
|
||||||
import coil3.imageLoader
|
import coil3.imageLoader
|
||||||
|
import coil3.SingletonImageLoader
|
||||||
import coil3.request.CachePolicy
|
import coil3.request.CachePolicy
|
||||||
import coil3.request.ImageRequest
|
import coil3.request.ImageRequest
|
||||||
import com.github.damontecres.wholphin.data.ServerRepository
|
import com.github.damontecres.wholphin.data.ServerRepository
|
||||||
|
|
@ -38,6 +39,7 @@ import org.robolectric.annotation.GraphicsMode
|
||||||
class WolfskinArtworkTest {
|
class WolfskinArtworkTest {
|
||||||
@get:Rule val rule = createAndroidComposeRule<ComponentActivity>()
|
@get:Rule val rule = createAndroidComposeRule<ComponentActivity>()
|
||||||
|
|
||||||
|
@OptIn(coil3.annotation.DelicateCoilApi::class)
|
||||||
@Test fun inheritedAuthenticatedFetcherCannotSendTheJellyfinTokenToAnotherArtworkHost() {
|
@Test fun inheritedAuthenticatedFetcherCannotSendTheJellyfinTokenToAnotherArtworkHost() {
|
||||||
MockWebServer().use { jellyfin ->
|
MockWebServer().use { jellyfin ->
|
||||||
MockWebServer().use { artwork ->
|
MockWebServer().use { artwork ->
|
||||||
|
|
@ -60,7 +62,10 @@ class WolfskinArtworkTest {
|
||||||
artwork.url("/public.png").newBuilder().host("127.0.0.1").build(),
|
artwork.url("/public.png").newBuilder().host("127.0.0.1").build(),
|
||||||
artwork.url("/another-port.png"))
|
artwork.url("/another-port.png"))
|
||||||
val results = CopyOnWriteArrayList<coil3.request.ImageResult>()
|
val results = CopyOnWriteArrayList<coil3.request.ImageResult>()
|
||||||
|
val previousParent = context.applicationContext.imageLoader
|
||||||
try {
|
try {
|
||||||
|
// Other screen tests may already have created Coil's process singleton.
|
||||||
|
SingletonImageLoader.reset()
|
||||||
rule.setContent {
|
rule.setContent {
|
||||||
CoilConfig(1024 * 1024L, authenticated, debugLogging = false, enableCache = false)
|
CoilConfig(1024 * 1024L, authenticated, debugLogging = false, enableCache = false)
|
||||||
LaunchedEffect(network) {
|
LaunchedEffect(network) {
|
||||||
|
|
@ -82,6 +87,9 @@ class WolfskinArtworkTest {
|
||||||
assertNull(artwork.takeRequest().headers["Authorization"])
|
assertNull(artwork.takeRequest().headers["Authorization"])
|
||||||
} finally {
|
} finally {
|
||||||
WolfskinImages.loader(context).shutdown()
|
WolfskinImages.loader(context).shutdown()
|
||||||
|
val testParent = context.applicationContext.imageLoader
|
||||||
|
SingletonImageLoader.setUnsafe(previousParent)
|
||||||
|
testParent.shutdown()
|
||||||
authenticated.dispatcher.executorService.shutdown()
|
authenticated.dispatcher.executorService.shutdown()
|
||||||
authenticated.connectionPool.evictAll()
|
authenticated.connectionPool.evictAll()
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue