Hold the full painted backdrop until incoming hero art is ready
This commit is contained in:
parent
60b0c307aa
commit
9988a193de
4 changed files with 24 additions and 9 deletions
|
|
@ -46,6 +46,7 @@ class DiscoverHeroSequenceTest {
|
|||
private val artAvailable = mutableStateOf(true)
|
||||
private val reduced = mutableStateOf(false)
|
||||
private var previousPixel: Int? = null
|
||||
private var lowerPixel = 0
|
||||
private var largestJump = 0
|
||||
private var previousLayers = emptyMap<String, Pair<Float, Float>>()
|
||||
private val previousDotWidths = mutableMapOf<Int, Float>()
|
||||
|
|
@ -99,9 +100,14 @@ class DiscoverHeroSequenceTest {
|
|||
launch("slow")
|
||||
sample("settled", 0)
|
||||
val original = previousPixel
|
||||
val originalLower = lowerPixel
|
||||
rule.runOnIdle { artAvailable.value = false }
|
||||
press(Key.DirectionRight)
|
||||
frames("pending", 24)
|
||||
repeat(24) { frame ->
|
||||
rule.mainClock.advanceTimeBy(16)
|
||||
sample("pending", frame)
|
||||
assertEquals("Pending art cannot expose a placeholder beneath the hero", originalLower, lowerPixel)
|
||||
}
|
||||
assertEquals("Pending art must not replace the painted backdrop", original, previousPixel)
|
||||
assertEquals(state.heroes.first().key, copyIdentities().single())
|
||||
rule.runOnIdle { artAvailable.value = true }
|
||||
|
|
@ -169,7 +175,10 @@ class DiscoverHeroSequenceTest {
|
|||
val file = File(directory, "$phase-${index.toString().padStart(2, '0')}.png")
|
||||
rule.onRoot().captureRoboImage(file.absolutePath)
|
||||
val bitmap = BitmapFactory.decodeFile(file.absolutePath)
|
||||
val pixel = try { bitmap.getPixel(1600, 200) } finally { bitmap.recycle() }
|
||||
val pixel = try {
|
||||
lowerPixel = bitmap.getPixel(1600, 800)
|
||||
bitmap.getPixel(1600, 200)
|
||||
} finally { bitmap.recycle() }
|
||||
val channels = channels(pixel)
|
||||
previousPixel?.let { old -> largestJump = maxOf(largestJump, channels.zip(channels(old)).maxOf { (a, b) -> kotlin.math.abs(a - b) }) }
|
||||
previousPixel = pixel
|
||||
|
|
@ -197,7 +206,7 @@ class DiscoverHeroSequenceTest {
|
|||
} }
|
||||
previousSelection = state.slide
|
||||
samples.put(JSONObject().put("phase", phase).put("frame", index).put("timeMs", rule.mainClock.currentTime)
|
||||
.put("selection", state.slide).put("rgb", JSONArray(channels)).put("copy", copy).put("layers", layers).put("dots", dots).put("navFocused", shell.navFocused))
|
||||
.put("selection", state.slide).put("rgb", JSONArray(channels)).put("lowerRgb", JSONArray(channels(lowerPixel))).put("copy", copy).put("layers", layers).put("dots", dots).put("navFocused", shell.navFocused))
|
||||
}
|
||||
|
||||
private fun layerSamples(): JSONArray {
|
||||
|
|
|
|||
|
|
@ -62,16 +62,22 @@ class HeroMotionTest {
|
|||
val probe = BitmapFactory.decodeFile(probeFile.absolutePath)
|
||||
try {
|
||||
for (y in listOf(380, 400, 420, 600, 800)) {
|
||||
assertEquals("The outgoing hero must stop at its 400px boundary: y=$y",
|
||||
(if (y < 400) Color.Red else Color.Blue).toArgb(), probe.getPixel(100, y))
|
||||
assertEquals("Pending artwork cannot replace any part of the painted backdrop: y=$y",
|
||||
Color.Red.toArgb(), probe.getPixel(100, y))
|
||||
}
|
||||
assertEquals(400f, rule.onNodeWithTag("hero-outgoing").fetchSemanticsNode().boundsInRoot.height, .01f)
|
||||
} finally { probe.recycle() }
|
||||
update { ready.value = true }
|
||||
rule.mainClock.advanceTimeBy(176)
|
||||
val mixed = pixel(directory, 100)
|
||||
assertNotEquals(Color.Red.toArgb(), mixed)
|
||||
assertNotEquals(Color.Blue.toArgb(), mixed)
|
||||
val blendedProbe = BitmapFactory.decodeFile(probeFile.absolutePath)
|
||||
try {
|
||||
assertEquals("Only the outgoing blend is clipped at its 400px boundary",
|
||||
400f, rule.onNodeWithTag("hero-outgoing").fetchSemanticsNode().boundsInRoot.height, .01f)
|
||||
assertEquals(Color.Blue.toArgb(), blendedProbe.getPixel(100, 400))
|
||||
assertEquals(Color.Blue.toArgb(), blendedProbe.getPixel(100, 800))
|
||||
} finally { blendedProbe.recycle() }
|
||||
rule.mainClock.advanceTimeBy(400)
|
||||
assertEquals(Color.Blue.toArgb(), pixel(directory, 100))
|
||||
update { selected.value = "green"; ready.value = false }
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue