fix(battlenet): use the right artwork for each game (#2092)

* fix(battlenet): use the right artwork for each game

World of Warcraft: Forever took retail art and its logo from a loose name lookup, and only fetched its own art when the Store tab was opened. Shop pages also supplied trailer stills and seasonal promos.

Each game now has chosen Blizzard key art with the shop page as a fallback, installed games fetch their art without opening the store, and lookups by name must match exactly. Art found by the old lookup is fetched again once.

* fix(battlenet): keep cached art if the new art cannot be fetched

Classic's variants fetch through the shared title, and a failing chosen image falls back to the shop page.
This commit is contained in:
MaxsTechReview authored and GitHub committed 2026-11-04 14:12:16 -05:00
1 parent 5cf69732ef
commit f1c1ca59fe
7 files changed
+146 -19

No files matched your search

@@ -24,12 +24,12 @@ class AddedGameArtFillTest {
private val coverBytes = byteArrayOf(9, 9, 9)
private fun game(name: String, appId: Long, cover: Boolean = true, source: String = Library.ADDED): AddedGames.Game {
private fun game(name: String, appId: Long, cover: Boolean = true, source: String = Library.ADDED, storeId: String? = null): AddedGames.Game {
val dir = tmp.newFolder(name)
File(dir, "steam_appid.txt").writeText("504230")
if (cover) File(dir, "cover.jpg").writeBytes(coverBytes)
val exe = File(dir, "$name.exe").apply { writeText("x") }
return AddedGames.Game(dir, name, exe, "/g/$name.exe", "/g", appId, appId, emptyList(), source = source)
return AddedGames.Game(dir, name, exe, "/g/$name.exe", "/g", appId, appId, emptyList(), source = source, storeId = storeId)
}
private class Calls {
@@ -167,6 +167,29 @@ class AddedGameArtFillTest {
sgdb = { _, _, _, _ -> false },
)
@Test fun nameMatchedBattleNetArtIsForgottenOnce() {
val game = game("World of Warcraft: Forever", 9001, source = com.droiddeck.launcher.stores.Store.BATTLENET.id, storeId = "wow_forever")
val cache = AddedGameArt.cacheDir(app, game).apply { mkdirs() }
File(cache, "logo.png").writeBytes(byteArrayOf(1))
File(cache, "p.jpg").writeBytes(byteArrayOf(3))
File(cache, "sgdb-id").writeText("5")
assertTrue(AddedGameArt.forgetNameMatchedBattleNetArt(app, game))
assertFalse(File(cache, "logo.png").isFile)
assertTrue(File(cache, "p.jpg").isFile)
assertFalse(File(cache, "sgdb-id").isFile)
File(cache, "logo.png").writeBytes(byteArrayOf(2))
assertFalse(AddedGameArt.forgetNameMatchedBattleNetArt(app, game))
assertTrue(File(cache, "logo.png").isFile)
}
@Test fun battleNetArtFoundByItsSteamIdIsKept() {
val game = game("Call of Duty: Modern Warfare III", 9002, source = com.droiddeck.launcher.stores.Store.BATTLENET.id, storeId = "pinta")
val cache = AddedGameArt.cacheDir(app, game).apply { mkdirs() }
File(cache, "logo.png").writeBytes(byteArrayOf(1))
assertFalse(AddedGameArt.forgetNameMatchedBattleNetArt(app, game))
assertTrue(File(cache, "logo.png").isFile)
}
@Test fun artOfTheAppTheFilesNamedBeforeIsFetchedAgain() {
val g = game("Peak", 0x8100000AL, cover = false)
File(g.folder, "steam_appid.txt").writeText("1029210")
@@ -195,4 +195,9 @@ class AddedGameArtLookupTest {
assertEquals("grids/game/5?dimensions=600x900&nsfw=false&humor=false", SteamGridDb.path(5, AddedGameArt.Slot.COVER))
assertEquals("grids/game/5?dimensions=460x215,920x430&nsfw=false&humor=false", SteamGridDb.path(5, AddedGameArt.Slot.WIDE))
}
@Test fun anExactLookupDoesNotTakeTheBaseGameForASubtitledOne() {
assertNull(SteamGridDb.exactMatch("World of Warcraft: Forever", listOf(1 to "World of Warcraft")))
assertEquals(2, SteamGridDb.exactMatch("World of Warcraft: Forever", listOf(1 to "World of Warcraft", 2 to "World of Warcraft: Forever")))
}
}
@@ -2,6 +2,7 @@ package com.droiddeck.launcher.stores.battlenet
import org.junit.Assert.assertEquals
import org.junit.Assert.assertNull
import org.junit.Assert.assertTrue
import org.junit.Test
class BlizzardArtTest {
@@ -27,4 +28,23 @@ class BlizzardArtTest {
assertNull(BlizzardArt.imageUrl("""<meta property="og:image" content="https://example.com/art.png">"""))
assertNull(BlizzardArt.imageUrl("""\"imageUrl\":\"//catalog.blzstatic.com//ff9/a-prod-thumb_bundle.jpg\""""))
}
@Test fun everyChosenImageComesFromBlizzardsHosts() {
BlizzardArt.KEY_ART.values.forEach { assertTrue(it, BlizzardArt.allowed(it)) }
}
@Test fun everyChosenImageBelongsToAKnownTitle() {
val codes = com.droiddeck.launcher.runtime.BattleNet.TITLES.map { it.code }.toSet()
BlizzardArt.KEY_ART.keys.forEach { assertTrue(it, it in codes) }
}
@Test fun classicVariantsShareTheClassicArtTitle() {
val battleNet = com.droiddeck.launcher.runtime.BattleNet
val era = battleNet.TITLES.first { it.uid == "wow_classic_era" }
assertEquals("wow_classic", battleNet.artTitle(era).uid)
}
@Test fun worldOfWarcraftForeverUsesItsOwnArt() {
assertTrue("WoW_Forever" in BlizzardArt.KEY_ART.getValue("WoWF"))
}
}