Display-list based menu slide animation

This commit is contained in:
James Babcock committed 2026-09-23 01:13:03 -07:00
1 parent 92e8def0f0
commit c8d835176f
28 files changed
+1546 -263

No files matched your search

+1
View File
@@ -27,6 +27,7 @@ const layers = load('app/ui/layers.ts', {
'../native/frame-timings': { spanCurrent: (_name, paint) => paint() },
});
const menu = load('app/ui/menu.ts', {
'./menu-highlight-motion': require('../.test-build/app/ui/menu-highlight-motion.js'),
'../graphics/image': graphics, '../graphics/ui-fonts': fonts, '../graphics/textwrap': textwrap,
'../util/numeric-util': numeric, './gestures': gestures, './metrics': load('app/ui/metrics.ts'),
});
@@ -75,7 +75,7 @@ class DisplayListTest {
@Test fun roundedRectsAndNestedOddNegativeDepthMatchFirmwareOnBothLenses() {
val resources = mapOf(
40 to hex("0404000200f00f0ff0"),
41 to hex("0202000f00080202010001000c0008000300040a0a000402022800050004001f"),
41 to hex("0202000d0008020201010c0008000300040a0a000402022800050004001f"),
42 to hex("02010005000702fd2900"))
val screen = hex("012345601234560112345601234560122345601234560123345601234560123445601234560123455601234f60123456601234560123456001234560123456011234560123456012234560123456012334560123456012344560123456012345")
val expected = listOf("01234560123456011aaaaaaaaaa56012aa45644444aa0123a4564444456a1234a564f44f564a2345a6444fff644a3456a4444456444a4560aa44456444aa56011aaaaaaaaaa56012234560123456012334560123456012344560123456012345", "012345601234560112aaaaaaaaaa60122aa56444445aa1233a5644444564a2344a644f44f644a3455a4444ff6444a4566a4444564444a5600aa44564444aa60112aaaaaaaaaa6012234560123456012334560123456012344560123456012345")
@@ -0,0 +1,140 @@
package com.faceclaw.app
import kotlin.test.*
class DrawExpressionTest {
private fun hex(s: String) = s.chunked(2).map { it.toInt(16).toByte() }.toByteArray()
private fun evaluate(code: ByteArray, elapsed: Long = 0): Pair<Int, Boolean> {
val frame = DrawEvaluation(elapsed)
return DrawExpression.evaluate(DrawReader(code), frame) to frame.animationPending
}
@Test fun integerWidthsSignExtensionAndReservedPrefixes() {
val signed = mapOf(
0 to "00", 63 to "3f", -64 to "40", -1 to "7f", 64 to "8040", -65 to "bfbf",
8191 to "9fff", -8192 to "a000", 8192 to "c02000", -8193 to "dfdfff",
1048575 to "cfffff", -1048576 to "d00000", 1048576 to "e0100000",
-1048577 to "efefffff", 134217727 to "e7ffffff", -134217728 to "e8000000",
134217728 to "f008000000", Int.MAX_VALUE to "f07fffffff", Int.MIN_VALUE to "f080000000",
)
for ((number, bytes) in signed) {
assertContentEquals(hex(bytes), ExtendedVarint.signed(number))
assertEquals(number, ExtendedVarint.read(DrawReader(hex(bytes)), true))
}
for (value in listOf(0u, 127u, 128u, 16383u, 16384u, 2097151u, 2097152u, 268435455u, 268435456u, UInt.MAX_VALUE)) {
val bytes = ExtendedVarint.unsigned(value)
assertEquals(value, ExtendedVarint.read(DrawReader(bytes), false).toUInt())
for (n in 0 until bytes.size) assertFails { ExtendedVarint.read(DrawReader(bytes.copyOf(n)), false) }
}
for (prefix in 0xf1..0xff) assertFails { ExtendedVarint.read(DrawReader(byteArrayOf(prefix.toByte())), true) }
assertEquals(-1, ExtendedVarint.read(DrawReader(hex("bfff")), true)) // valid non-minimal form
assertFails { ExtendedVarint.evaluate(DrawReader(hex("ff05")), DrawEvaluation(0)) }
}
@Test fun arithmeticTypesStackErrorsAndTimeTracking() {
val vectors = listOf(
"0107010510" to 12, "0107010511" to 2, "0107010512" to 35,
"0179010213" to -3, "0179010214" to -1, "017915" to 7,
"0107010516" to 5, "0107010517" to 7, "01010109" to 9,
"01040310" to 8, "010401070504" to 7,
"010430010230202431" to -6,
"020000c03f02000000402231" to 3,
"01003001806430020000003f4031" to 50,
"01f07fffffff010110" to Int.MIN_VALUE,
"01f080000000017f13" to Int.MIN_VALUE,
"01f080000000017f14" to 0,
)
for ((code, expected) in vectors) assertEquals(expected to false, evaluate(hex(code)), code)
for (bad in listOf("", "10", "0101010013", "010130010110", "020000807f", "ff", "0180", "01013210")) {
assertEquals(0 to false, evaluate(hex(bad)), bad)
}
assertEquals(0 to false, evaluate(ByteArray(66) { if (it % 2 == 0) 1 else 0 })) // stack overflow
assertEquals(0 to false, evaluate(ByteArray(1025)))
for (op in DrawExpression.SMOOTHSTEP..DrawExpression.EASE_IN_OUT_CUBIC) {
assertEquals(0 to false, evaluate(hex("0200000000") + byteArrayOf(op.toByte(), 49)))
assertEquals(1 to false, evaluate(hex("020000803f") + byteArrayOf(op.toByte(), 49)))
}
assertEquals(499 to true, evaluate(hex("0181f432"), 499))
assertEquals(500 to false, evaluate(hex("0181f432"), 500))
assertEquals(500 to false, evaluate(hex("0181f432"), 900))
assertEquals(0 to false, evaluate(hex("0181f432ff"), 250)) // errors discard pending time
}
@Test fun smoothstepCoordinatesMatchFirmwareAndSurvivePresentTimeReset() {
val value = DrawValue.animate(10, 110) as DrawValue.Expression
val code = "010a3001806e300181f432010010300181f43023414031"
assertContentEquals(hex(code), value.program)
for ((time, expected) in listOf(0L to 10, 125L to 25, 250L to 60, 375L to 94, 500L to 110, 900L to 110)) {
assertEquals(expected to (time < 500), evaluate(value.program, time))
}
val continued = DrawValue.animate(10, 110, elapsedMs = 250) as DrawValue.Expression
assertEquals(60 to true, evaluate(continued.program, 0))
assertEquals(110 to false, evaluate(continued.program, 250))
}
@Test fun animatedMenuBridgePreservesElapsedTimeAndTranslation() {
// Tag 6 record emitted by the TypeScript bridge: elapsed=200, delta=(-2,-4).
val wire = hex("06030002000200020001001030020000fefffcffc8002a000000ffffffff")
val input = ArrayByteReader(wire)
assertEquals(6, input.get().toInt())
val row = MenuSelection.read(input, 6).translated(10, 10)
assertEquals(0, input.remaining())
val motion = assertNotNull(row.animation)
assertEquals(42, motion.token)
assertEquals(-2, motion.dx)
assertEquals(-4, motion.dy)
val call = row.calls(7, motion.startedAt + 200).first()
for ((elapsed, expected) in listOf(0L to (11 to 9), 300L to (13 to 12))) {
val reader = DrawReader(call)
assertEquals(8, reader.readU8())
assertEquals(DRAW_FLAG_DEPTH, reader.readU8())
assertEquals(2, reader.readS8())
val frame = DrawEvaluation(elapsed)
assertEquals(expected.first, ExtendedVarint.evaluate(reader, frame))
assertEquals(expected.second, ExtendedVarint.evaluate(reader, frame))
assertEquals(elapsed < 300, frame.animationPending)
}
for (end in 1 until wire.size) assertFails {
MenuSelection.read(ArrayByteReader(wire.copyOf(end), 1), 6)
}
}
@Test fun playerSchedulesOnlyUnfinishedFramesAndCancelsStaleCallbacks() {
val call = DrawProtocol.roundedRect(DrawValue.Integer(0), DrawValue.animate(0, 4), 2, 2, 0, 15)
val renderer = DisplayListRenderer(mapOf(1 to DrawProtocol.displayList(listOf(call))))
val screen = DisplayListRenderer.Target(ByteArray(16), 4, 8)
val output = DisplayListRenderer.Target(ByteArray(16), 4, 8)
var now = 1000L
val queued = mutableListOf<() -> Unit>()
var cancelled = 0
var displayed = 0
val player = DisplayListPlayer(renderer, screen, output, { now }, { delay, callback ->
assertEquals(45, delay)
queued.add(callback);
{ cancelled++ }
}, { displayed++ })
player.present(1)
assertEquals(15, output.get(0, 0))
val first = queued.removeAt(0)
now += 250
first()
assertEquals(15, output.get(0, 2))
assertEquals(0, output.get(0, 0))
val stale = queued.removeAt(0)
player.present(1)
assertEquals(15, output.get(0, 0))
stale()
assertEquals(3, displayed)
now += 500
queued.removeAt(0)()
assertEquals(15, output.get(0, 4))
assertFalse(renderer.animationPending)
assertTrue(queued.isEmpty())
player.present(1)
val stopped = queued.removeAt(0)
player.stop()
stopped()
assertEquals(5, displayed)
assertTrue(cancelled >= 2)
}
}
@@ -0,0 +1,128 @@
package com.faceclaw.app
import kotlin.test.*
class DrawWireTest {
private fun hex(value: String) = value.chunked(2).map { it.toInt(16).toByte() }.toByteArray()
@Test fun encodersUseRevision27CoordinatesAndPreserveOtherWireBytes() {
// Literal vectors pin the firmware grammar independently of the reader.
val calls = listOf(
DrawProtocol.image(0x1234, -32768, 32767, 0x1f, target = 511, depth = -128) to
"0403ff018034120080ff7f1f",
DrawProtocol.rectCopy(DrawProtocol.CURRENT, 1, 2, 3, 4, -5, -6) to
"0200feff0100020003000400fbfffaff",
DrawProtocol.stockText(-1, 2, 15, hex("41c3a9")) to "0300ffff02000f0341c3a9",
DrawProtocol.text(511, -2, 3, 31, hex("01417f")) to "0500ff01feff03001f0301417f",
DrawProtocol.playList(511, depth = 127) to "07027fff01",
DrawProtocol.roundedRect(-1, 2, 640, 480, 65535, 15, 16) to
"08007f028002e001ffff0f10",
DrawProtocol.lut(640, 480, 256) to "0600000000008002e0010123456789abcdef",
DrawProtocol.bbox(hex("ffffffffffffffff"), 4, 0, 0, 8, 2) to "010000000002010f10",
DrawProtocol.bbox(hex("0f"), 1, 1, 0, 1, 1) to "01000101000000010001001f",
)
for ((call, expected) in calls) assertContentEquals(hex(expected), call)
assertContentEquals(hex("0100050007027fff01"), DrawProtocol.sequence(listOf(calls[4].first)))
assertContentEquals(hex("1a0100050007027fff01"), DrawProtocol.message(listOf(calls[4].first)))
assertContentEquals(hex("020100050007027fff01"), DrawProtocol.displayList(listOf(calls[4].first)))
assertContentEquals(hex("1bffff"), DrawProtocol.root(DrawProtocol.SCREEN))
}
@Test fun optimizerFieldsAreReencodedAndOpaqueBytesArePreserved() {
val records = listOf(
"1300020080ff7f1f" to "040000020080ff7f1f",
"14ff01ffff02000f0341017f" to "0500ff01ffff02000f0341017f",
"0fffff02001f0341c3a9" to "0300ffff02001f0341c3a9",
"030001020134120f10" to "010000000102010f10",
"060f10" to "01000100000000080002000f10",
"090100020003000400fbfffaff" to "0200feff0100020003000400fbfffaff",
)
for ((record, expected) in records) {
val calls = DrawProtocol.fromOptimized(hex(record), 8, 2)
assertEquals(1, calls.size)
assertContentEquals(hex(expected), calls.single(), record)
}
val nested = hex("0802") + records.take(2).fold(byteArrayOf()) { bytes, (record, _) ->
val payload = hex(record)
bytes + DrawProtocol.word(payload.size) + payload
}
val calls = DrawProtocol.fromOptimized(nested)
assertEquals(2, calls.size)
for (i in calls.indices) assertContentEquals(hex(records[i].second), calls[i])
assertFails { DrawProtocol.fromOptimized(hex("1300020080ff7f")) }
assertFails { DrawProtocol.fromOptimized(hex("1300020080ff7f1f00")) }
assertFails { DrawProtocol.fromOptimized(hex("0fffff02001f0441c3a9")) }
}
@Test fun everyTruncatedOrOverlongCallIsRejectedBeforeMutation() {
val font = ByteArray(197)
font[0] = 1
font[67] = 193.toByte() // Glyph A.
hex("0801011f").copyInto(font, 193)
val resources = mapOf(
1 to hex("0401000100f0"),
2 to font,
3 to DrawProtocol.displayList(emptyList()),
)
val renderer = DisplayListRenderer(resources, builtin = { _, _ ->
DisplayListRenderer.BuiltinGlyph(hex("0801011f"), 1)
})
val calls = listOf(
DrawProtocol.image(1, 0, 0, target = 1, depth = -1),
DrawProtocol.rectCopy(DrawProtocol.CURRENT, 0, 0, 2, 2, 1, 1),
DrawProtocol.stockText(0, 0, 15, hex("41")),
DrawProtocol.text(2, 0, 0, 15, hex("41")),
DrawProtocol.playList(3),
DrawProtocol.roundedRect(0, 0, 4, 4, 1, 15),
DrawProtocol.lut(8, 4, 128),
DrawProtocol.bbox(ByteArray(16) { -1 }, 4, 0, 0, 8, 4),
)
val screen = ByteArray(16) { 0x12 }
val target = DisplayListRenderer.Target(screen, 8, 4)
val valid = DrawProtocol.roundedRect(0, 0, 4, 4, 0, 15)
for (call in calls) {
// Establish that each fixture is valid before testing malformed forms.
renderer.execute(DrawProtocol.sequence(listOf(call)), target)
screen.fill(0x12)
val savedResources = resources.mapValues { it.value.copyOf() }
val malformed = (0 until call.size).map { call.copyOf(it) } + listOf(call + byteArrayOf(0))
for (bad in malformed) {
assertFails { renderer.execute(DrawProtocol.sequence(listOf(valid, bad, valid)), target) }
assertContentEquals(ByteArray(16) { 0x12 }, screen)
for ((id, bytes) in savedResources) assertContentEquals(bytes, resources[id])
}
}
val sequence = DrawProtocol.sequence(listOf(valid))
for (length in 0 until sequence.size) {
assertFails { renderer.execute(sequence.copyOf(length), target) }
assertContentEquals(ByteArray(16) { 0x12 }, screen)
}
assertFails { renderer.execute(sequence + byteArrayOf(0), target) }
assertContentEquals(ByteArray(16) { 0x12 }, screen)
}
@Test fun batchesRespectEncodedLengthsAndCallBudget() {
val call = DrawProtocol.playList(511)
val messages = DrawProtocol.messages(List(3) { call }, maxBytes = 15)
assertEquals(listOf(15, 9), messages.map { it.size })
assertContentEquals(hex("1a020004000700ff0104000700ff01"), messages[0])
assertFails { DrawProtocol.messages(listOf(call), maxBytes = 8) }
val many = DrawProtocol.messages(List(4097) { call })
assertEquals(listOf(4096, 1), many.map { DrawProtocol.u16(it, 1) })
assertTrue(DrawProtocol.messages(emptyList()).isEmpty())
}
@Test fun resourceReaderViewsUseRelativeOffsetsAndCannotEscapeTheirBounds() {
val reader = ArrayByteReader(hex("ff123456ee"), 1, 4)
assertEquals(0x12.toByte(), reader.get(0))
assertEquals(0x3412.toShort(), reader.getShort())
assertEquals(1, reader.remaining())
assertFails { reader.get(ByteArray(2)) }
assertEquals(0x56.toByte(), reader.get())
assertEquals(0, reader.remaining())
assertFails { reader.get() }
assertFails { reader.get(3) }
assertFails { reader.get(-1) }
assertFails { ArrayByteReader(byteArrayOf(1), 1, 2) }
}
}
@@ -0,0 +1,36 @@
package com.faceclaw.app
import kotlin.test.Test
import kotlin.test.assertTrue
import platform.Foundation.NSDate
import platform.Foundation.NSDefaultRunLoopMode
import platform.Foundation.NSRunLoop
import platform.Foundation.NSThread
import platform.Foundation.dateWithTimeIntervalSinceNow
import platform.Foundation.runMode
class IosBleCentralTest {
/** Registering a state listener must create the central and report a state without any scan. */
@Test
fun scanListenerAloneReceivesABluetoothStateReport() {
val central = IosBleCentral(IosProtocolPlatform)
val states = ArrayList<Int>()
var offMain = 0
central.setScanListener(object : IosBleScanListener {
override fun onBluetoothState(state: Int, authorization: Int) {
if (!NSThread.isMainThread) offMain++
states.add(state)
}
override fun onAdvertisement(identifier: String, name: String, manufacturerDataHex: String, rssi: Int, connectable: Boolean) {}
})
val deadline = IosProtocolPlatform.elapsedRealtimeMs() + 5_000
while (IosProtocolPlatform.elapsedRealtimeMs() < deadline && states.none { it != 0 }) {
NSRunLoop.mainRunLoop.runMode(NSDefaultRunLoopMode, NSDate.dateWithTimeIntervalSinceNow(0.02))
}
// The simulator reports unsupported/powered-off; a real phone powered-on. Any non-unknown state proves the central exists.
assertTrue(states.any { it != 0 }, "no CBManagerState reported: $states")
assertTrue(offMain == 0, "state reports must arrive on the main queue")
central.close()
}
}
+9 -8
View File
@@ -18,7 +18,8 @@ const font={lineHeight:12,ascent:10,descent:2,measureText:text=>text.length*4,
const {MenuLayer}=load('app/ui/menu.ts',{
'../graphics/image':graphics,'../graphics/textwrap':{},'../graphics/ui-fonts':{getDefaultSmallFont:()=>font},
'../util/numeric-util':{clamp:(n,a,b)=>Math.max(a,Math.min(b,n))},'./gestures':{},
'./metrics':require('../.test-build/app/ui/metrics.js'),
'./menu-highlight-motion': require('../.test-build/app/ui/menu-highlight-motion.js'),
'./metrics':require('../.test-build/app/ui/metrics.js'),
});
const {prepareFrameDraws}=load('app/graphics/glyph-wire.ts',{'./presentation-wire':wire,'../native/texture-atlas':{textureAtlasAvailable:()=>false}});
function menu() {
@@ -26,9 +27,9 @@ function menu() {
const context={stack:{getBaseSize:()=>({width:80,height:80}),isFocused:()=>true}};
return {layer,paint:()=>layer.paint(context,()=>new graphics.GrayImage(80,80)),context};
}
test('menu retains the selected text and rounded highlight at depth +2',async()=>{
test('menu retains the selected text and rounded highlight on the menu plane',async()=>{
const m=menu(),image=m.paint(),row=image.draws.find(d=>d.presentation);
assert.equal(row.presentation.depth,2);assert.equal(row.presentation.radius,8);
assert.equal(row.presentation.depth,0);assert.equal(row.presentation.radius,8);
assert.ok(row.source.pixels.some(v=>v===255));assert.ok(!image.withDrawsBaked(false).pixels.some(v=>v===255));
const flat=planes.flattenPlanesWithDraws([{image,x:0,y:0}]);
const records=wire.presentationRecords(prepareFrameDraws(flat.draws));assert.equal(records.length,1);
@@ -37,7 +38,7 @@ test('menu retains the selected text and rounded highlight at depth +2',async()=
const screen=flat.image.pixels.slice(),preview=c.composite();
assert.ok(preview.some(v=>v===240));assert.deepEqual(flat.image.pixels,screen);
await m.layer.handleInput({type:'scroll-down'},m.context);
const next=m.paint().draws.find(d=>d.presentation);assert.ok(next.y>row.y);assert.equal(next.presentation.depth,2);
const next=m.paint().draws.find(d=>d.presentation);assert.ok(next.y>row.y);assert.equal(next.presentation.depth,0);
});
test('shell menu selection survives serialization and is not baked into its surface',()=>{
const image=menu().paint(),bytes=encodeShellScene([{image,x:0,y:0,shellKey:7}]);
@@ -58,14 +59,14 @@ test('later opaque planes occlude a replayed selection without erasing its visib
const {LayerStack,noopLayerActions}=load('app/ui/layers.ts',{
'../graphics/image':graphics,'../graphics/plane':planes,'../native/frame-timings':{spanCurrent:(_name,fn)=>fn()},'./gestures':{},
});
test('context menu surface uses +4 and selected row +6 without changing the app screen',()=>{
test('context menu surface and selected row both use +4 without changing the app screen',()=>{
const base=new graphics.GrayImage(100,90,96);
const stack=new LayerStack({paint:()=>base},noopLayerActions,{width:100,height:90});
stack.push(new MenuLayer(null,[{label:'FIRST',onSelect(){}}],{x:10,y:8,width:80,minHeight:70,maxHeight:70,depth:4}));
const frame=planes.flattenPlanesWithDraws(stack.paint());
assert.deepEqual(frame.image.pixels,base.pixels);
const records=wire.presentationRecords(prepareFrameDraws(frame.draws));
assert.deepEqual(records.map(r=>r.depth),[4,6]);assert.equal(records[0].mode,'masked-image');
assert.deepEqual(records.map(r=>r.depth),[4,4]);assert.equal(records[0].mode,'masked-image');
const c=new SurfaceCompositor(100,90);c.configureSurface('app',{x:0,y:0,width:100,height:90,zOrder:0,transparency:'opaque'});
c.submitSurfaceFrame('app',frame.image.pixels,{x:0,y:0,width:100,height:90},prepareFrameDraws(frame.draws));
const preview=c.composite();
@@ -77,11 +78,11 @@ test('context menu surface uses +4 and selected row +6 without changing the app
c.submitSurfaceFrame('app',closed.image.pixels,{x:0,y:0,width:100,height:90},prepareFrameDraws(closed.draws));
assert.deepEqual(c.composite(),base.pixels);
});
test('system menu bridge shifts its surface +4 and selected row +6',()=>{
test('system menu bridge shifts its surface and selected row together by +4',()=>{
const image=menu().paint(),bytes=encodeShellScene([{image,x:8,y:0,shellKey:7,depth:4}]);
const view=new DataView(bytes.buffer),w=view.getUint16(8,true),h=view.getUint16(10,true);
assert.equal(view.getInt16(16,true),4);
assert.equal(wire.readPresentation(bytes,18+w*h).selection.depth,6);
assert.equal(wire.readPresentation(bytes,18+w*h).selection.depth,4);
const c=new SurfaceCompositor(100,80);c.setShellScene(bytes);const preview=c.composite();
assert.equal(preview[40*100+8],0);assert.equal(preview[40*100+10],80);
});
+44
View File
@@ -0,0 +1,44 @@
const test = require('node:test');
const assert = require('node:assert/strict');
const { MenuHighlightMotion } = require('../.test-build/app/ui/menu-highlight-motion.js');
const { GrayImage } = require('../.test-build/app/graphics/image.js');
const { encodePresentation, readPresentation } = require('../.test-build/app/graphics/presentation-wire.js');
test('highlight animates only navigation that preserves the scroll window', () => {
const motion = new MenuHighlightMotion();
assert.equal(motion.paint(0, 0, 10, 20, 100, 20, 0), undefined);
motion.navigate(0, false);
const moved = motion.paint(1, 0, 10, 40, 100, 20, 100);
assert.equal(moved.dx, 0);
assert.equal(moved.dy, -20);
assert.equal(motion.paint(1, 0, 10, 40, 100, 20, 350).token, moved.token);
motion.navigate(1, false);
const next = motion.paint(2, 0, 10, 60, 100, 20, 350);
assert.equal(next.dy, -30, 'continue from the halfway position');
motion.navigate(2, false);
assert.equal(motion.paint(3, 1, 10, 60, 100, 20, 400), undefined, 'scroll snaps');
motion.navigate(3, true);
assert.equal(motion.paint(0, 0, 10, 20, 100, 20, 500), undefined, 'wrap snaps');
motion.navigate(0, false);
motion.paint(1, 0, 10, 40, 100, 20, 600);
assert.equal(motion.paint(1, 0, 10, 40, 100, 20, 1100), undefined, 'finished after 500 ms');
assert.equal(motion.paint(2, 0, 10, 60, 100, 20, 1200), undefined, 'programmatic changes snap');
});
test('animated selection bridge carries relative start, elapsed time and stable token', () => {
const now = Date.now;
Date.now = () => 1200;
try {
const image = new GrayImage(8, 4);
image.drawMenuSelection(new GrayImage(2, 2, 255), 3, 2, 16, 48, 1, 2,
{ dx: -2, dy: -4, startedAt: 1000, token: 42 });
const bytes = encodePresentation(image.draws[0]);
assert.equal(bytes[0], 6);
assert.equal(bytes.length, 30);
const record = readPresentation(bytes, 0);
assert.equal(record.end, bytes.length);
assert.deepEqual(record.selection.animation, { dx: -2, dy: -4, startedAt: 1000, token: 42 });
assert.equal(record.selection.x, 3);
assert.equal(record.selection.y, 2);
} finally { Date.now = now; }
});
+1
View File
@@ -153,6 +153,7 @@ test('Music settings keeps toggles and selection when a new app arrives and supp
'../graphics/textwrap': textwrap,
'../graphics/ui-fonts': { getDefaultSmallFont: () => font },
'../util/numeric-util': { clamp: (n, lo, hi) => Math.max(lo, Math.min(hi, n)) },
'./menu-highlight-motion': require('../.test-build/app/ui/menu-highlight-motion.js'),
'./metrics': load('app/ui/metrics.ts'), './gestures': {},
};
const menu = load('app/ui/menu.ts', (name) => deps[name]);
+1
View File
@@ -84,6 +84,7 @@ function ui(fontSize = 12) {
'../native/notification-sources': prefs,
'../native/notification-access': { isNotificationListenerEnabled: () => true },
'../util/render-freshness': { renderPassAllowsStaleData: () => false },
'./menu-highlight-motion': require('../.test-build/app/ui/menu-highlight-motion.js'),
'./metrics': load('app/ui/metrics.ts'),
'./gestures': {},
};