Option to combine top bar with the app switcher

This commit is contained in:
James Babcock committed 2026-10-02 00:45:17 -07:00
1 parent eab839f811
commit 756e21feb8
19 files changed
+462 -168

No files matched your search

+142 -52
View File
@@ -14,7 +14,7 @@ function geometry() {
displayModeSetting: '576x288', verticalPositionSetting: 'middle',
navigateDisplayModeSetting: 'global', navigateVerticalPositionSetting: 'global',
terminalDisplayModeSetting: 'default', terminalVerticalPositionSetting: 'global',
appSwitcherPositionSetting: 'left', uiDepthSetting: '0',
appSwitcherPositionSetting: 'left', uiDepthSetting: '0', statusBarPositionSetting: 'top',
}).map(([name, value]) => [name, { value, get() { return this.value; } }]));
const context = { exports: {}, require: (name) => {
if (name === '../../graphics/image') return { G2_LENS_WIDTH: 640, G2_LENS_HEIGHT: 480 };
@@ -66,8 +66,9 @@ test('Terminal can disable its tall default, inherit position or override both d
test('all explicit size/position combinations stay within the display and align content below the bar', () => {
const g = geometry();
for (const switcher of ['left', 'right', 'bottom']) {
for (const [switcher, statusBar] of [['left', 'top'], ['right', 'top'], ['bottom', 'top'], ['bottom', 'switcher'], ['left', 'switcher']]) {
g.settings.appSwitcherPositionSetting.value = switcher;
g.settings.statusBarPositionSetting.value = statusBar;
for (const globalMode of ['576x288', '576x480', '640x480']) {
g.settings.displayModeSetting.value = globalMode;
for (const appId of ['navigate', 'terminal']) {
@@ -79,8 +80,11 @@ test('all explicit size/position combinations stay within the display and align
const rect = g.rect(heightMode, appId);
const fullPanel = g.displayMode(appId) === '640x480';
assert.equal(rect.x + rect.width, fullPanel ? 640 : { left: 640, right: 576, bottom: 608 }[switcher]);
assert.equal(rect.y, g.windowTop(heightMode, appId) + g.TOP_BAR_HEIGHT);
assert.ok(rect.y >= 28 && rect.y + rect.height <= 480 - g.switcherRowHeight(appId));
const header = g.windowHeaderHeight(appId);
assert.equal(header, g.statusInSwitcherRow(appId) ? 1 : g.TOP_BAR_HEIGHT);
assert.equal(g.statusInSwitcherRow(appId), statusBar === 'switcher' && g.switcherRowHeight(appId) > 0);
assert.equal(rect.y, g.windowTop(heightMode, appId) + header);
assert.ok(rect.y >= header && rect.y + rect.height <= 480 - g.switcherRowHeight(appId));
const row = g.switcherRect(heightMode, appId);
assert.ok(row.y + row.height <= 480);
// A reserved bottom row hangs right under the window, as wide as it.
@@ -140,23 +144,32 @@ test('a bottom app switcher centres 576-wide windows and hangs one tall tab unde
assert.equal(g.windowFramed(), false);
});
test('a bottom app switcher frames the foreground window\'s content in a rounded border', () => {
const g = geometry();
g.settings.appSwitcherPositionSetting.value = 'bottom';
g.settings.uiDepthSetting.value = '62';
const graphics = require('../.test-build/app/graphics/image.js');
const shellScene = require('../.test-build/app/graphics/shell-scene.js');
const font = { lineHeight: 12, ascent: 10, measureText: (text) => text.length * 4, drawText() {} };
// The real chrome layer over the given geometry, with platform pieces stubbed:
// a 4px-per-character font that paints each character as a 2x6 block, up to
// `notifications` 24px notification icons, and a phone battery at 80%.
const graphics = require('../.test-build/app/graphics/image.js');
const shellScene = require('../.test-build/app/graphics/shell-scene.js');
const displayList = require('../.test-build/app/graphics/display-list.js');
function chromeLayer(g, { notifications = 0, phoneBattery = null, windows = 1, trayIcons = [] } = {}) {
const font = { lineHeight: 12, ascent: 10, measureText: (text) => text.length * 4,
drawText: (image, x, y, text, value) => { for (let i = 0; i < text.length; i++) image.fillRect(x + i * 4, y + 2, 2, 6, value); } };
let nextKey = 100;
const requested = [];
const settings = { get: () => 'always' };
const modules = {
'../../graphics/shell-scene': shellScene, '../../graphics/image': graphics,
'../../graphics/ui-fonts': { getDefaultSmallFont: () => font, getDefaultMediumFont: () => font },
'../../graphics/display-list': displayList, '../../graphics/ui-fonts': { getDefaultSmallFont: () => font, getDefaultMediumFont: () => font },
'../../graphics/battery': require('../.test-build/app/graphics/battery.js'),
'./ambient-cards': { activeAmbientCards: () => [] },
'../../native/notification-icons': { readActiveNotificationIcons: () => ({ icons: [], stale: false }) },
'../../native/phone-battery': { readPhoneBatteryState: () => ({ battery: null }) },
'../../native/notification-icons': { readActiveNotificationIcons: (max) => {
requested.push(max);
return { icons: Array.from({ length: Math.min(max, notifications) }, () => new graphics.GrayImage(24, 24, 200)), stale: false };
} },
'../../native/phone-battery': { readPhoneBatteryState: () => ({ battery: phoneBattery, charging: false }) },
'../../util/render-freshness': { renderPassAllowsStaleData: () => false },
'../dashboard-settings': { batteryDisplayModeSetting: { get: () => 'icon' } },
'../clock-format': { formatClockDate: () => '', formatClockTime: () => '' },
'../dashboard-settings': { batteryDisplayModeSetting: { get: () => 'icon' }, phoneBatteryVisibilitySetting: settings,
batteryIndicatorVisible: () => true },
'../clock-format': { formatClockDate: () => 'Thu Oct 2', formatClockTime: () => '9:41' },
'../layers': { LayerStack: { allocateShellKey: () => nextKey++ } },
'../menu': { scrollToKeepSelectionVisible: () => 0 },
'./geometry': g,
@@ -164,51 +177,128 @@ test('a bottom app switcher frames the foreground window\'s content in a rounded
const context = { exports: {}, require: (name) => modules[name] ?? {} };
vm.runInNewContext(js(read('app/ui/shell/chrome-layer.ts')), context);
const state = {
windows: [{ attention: false, drawIcon() {} }], selectedIndex: 0, focus: 'window', foregroundHeightMode: 'min',
battery: { headset: null, ring: null, watch: null }, trayIcons: [],
windows: Array.from({ length: windows }, () => ({ attention: false, drawIcon: (image, x, y, size) => image.fillRect(x, y, size, size, 120) })),
selectedIndex: 0, focus: 'window', foregroundHeightMode: 'min',
battery: { headset: null, ring: null, watch: null }, trayIcons,
};
const chrome = new context.exports.ShellChromeLayer(() => state);
return { chrome: new context.exports.ShellChromeLayer(() => state), state, requested };
}
test('a bottom app switcher frames the foreground window\'s content in a rounded border', () => {
const g = geometry();
g.settings.appSwitcherPositionSetting.value = 'bottom';
g.settings.uiDepthSetting.value = '62';
const { chrome } = chromeLayer(g);
const parts = chrome.paintParts();
// The min band's content spans y=106..365, between the bar's bottom row
// (the frame's top) at 105 and the row's top edge (its bottom) at 366.
// Just the top bar and then the row: the frame is no surface of its own.
const part = (key) => parts.find((p) => p.shellKey === key);
const [left, right, top, strip] = [part(100), part(101), part(102), part(1)];
assert.deepEqual([left.x, left.y, left.image.width, left.image.height], [31, 105, 8, 261]);
assert.deepEqual([right.x, right.image.width], [601, 8]);
assert.deepEqual([top.x, top.y, top.image.width, top.image.height], [39, 105, 562, 1]);
assert.ok(!left.depth && !right.depth && !top.depth);
const [bar, strip] = [part(2), part(1)];
assert.deepEqual(Array.from(parts, (p) => p.shellKey), [2, 1]);
// The min band's content spans y=106..365, between the bar's bottom row
// (the frame's top) at 105 and the row's top edge (its bottom) at 366. The
// frame is one rounded rect riding on the row, replayed after the bar.
const frames = (image) => image.draws.filter((d) => d.presentation?.displayList);
const [frame] = frames(strip.image);
assert.deepEqual([strip.x + frame.x, strip.y + frame.y, frame.source.width, frame.source.height, frame.presentation.depth], [31, 105, 578, 262, 0]);
assert.deepEqual(JSON.parse(JSON.stringify(frame.presentation.displayList.calls)), [{ op: displayList.DrawOp.ROUNDED_RECT, x: 0, y: 0, width: 578, height: 262,
radius: 8, background: 0, border: 3, outside: 0, clip: { x: 0, y: 0, width: 578, height: 261 } }]);
// Over a lit screen: the sides just outside the window, the top along the
// bar's bottom row, the content's corners cut black, its interior left
// alone, and the bottom row left to the separator.
const lit = new Uint8Array(640 * 480).fill(255);
displayList.paintDisplayList(lit, lit.slice(), 640, 480, { displayList: frame.presentation.displayList,
x: strip.x + frame.x, y: strip.y + frame.y, width: 578, height: 262, depth: 0 });
const px = (x, y) => lit[y * 640 + x];
assert.deepEqual([px(31, 200), px(608, 200), px(300, 105)], [48, 48, 48]);
assert.deepEqual([px(31, 105), px(32, 106), px(32, 365), px(607, 365)], [0, 0, 0, 0]);
assert.deepEqual([px(36, 105), px(300, 200), px(300, 366), px(36, 366)], [48, 255, 255, 255]);
const at = (p, x, y) => p.image.pixels[(y - p.y) * p.image.width + x - p.x];
// Straight sides just outside the window; the top along the bar's bottom row.
assert.equal(at(left, 31, 200), 40);
assert.equal(at(right, 608, 200), 40);
assert.equal(at(top, 300, 105), 40);
// Rounded corners: black outside the curve, the window's own corner masked.
assert.equal(at(left, 31, 105), 1);
assert.equal(at(left, 36, 105), 40);
assert.equal(at(left, 32, 106), 1);
assert.equal(at(left, 32, 365), 1);
assert.equal(at(right, 607, 365), 1);
// The separator is the bottom side, starting where the corner's curve ends.
assert.equal(at(strip, 35, 366), 1);
assert.equal(at(strip, 36, 366), 40);
assert.equal(at(strip, 603, 366), 40);
assert.equal(at(strip, 604, 366), 1);
// Parts after the -2 top bar, so the frame draws over it.
assert.ok(parts.indexOf(part(2)) < parts.indexOf(left));
assert.deepEqual([at(strip, 35, 366), at(strip, 36, 366), at(strip, 603, 366), at(strip, 604, 366)], [1, 40, 40, 1]);
// The bar's own divider gives way to the frame's top.
assert.equal(at(bar, 300, 105), 1);
shellScene.encodeShellScene(parts, g.uiDepth());
// The flat paint matches. The bar's own divider gives way to the frame's
// top, and the frame stops short of the bar.
// The flat paint carries the same frame.
const image = chrome.paint();
assert.equal(image.pixels[200 * 640 + 31], 40);
assert.equal(image.pixels[200 * 640 + 608], 40);
assert.equal(image.pixels[105 * 640 + 33], 1);
assert.equal(image.pixels[105 * 640 + 300], 40);
assert.equal(image.pixels[90 * 640 + 31], 0);
const bar = part(2);
assert.equal(bar.image.pixels[(105 - bar.y) * bar.image.width + 300 - bar.x], 1);
assert.deepEqual(frames(image).map((d) => [d.x, d.y]), [[31, 105]]);
// No frame in the full-panel mode.
g.settings.displayModeSetting.value = '640x480';
assert.equal(chrome.paintParts().filter((p) => p.shellKey >= 100).length, 0);
assert.equal(chrome.paintParts().flatMap((p) => frames(p.image)).length, 0);
});
test('the status bar can join a bottom app switcher, and windows grow into the top bar', () => {
const g = geometry();
g.settings.statusBarPositionSetting.value = 'switcher';
// Only beside a reserved bottom row.
assert.equal(g.statusInSwitcherRow(), false);
g.settings.appSwitcherPositionSetting.value = 'bottom';
assert.equal(g.statusInSwitcherRow(), true);
// A one-row header (the frame's top) replaces the 28px top bar; medium
// windows keep a 288px (EvenHub) content area.
assert.equal(g.windowHeaderHeight(), 1);
assert.deepEqual(g.rect('min'), { x: 32, y: 79, width: 576, height: 287 });
assert.deepEqual(g.rect('medium'), { x: 32, y: 79, width: 576, height: 288 });
assert.deepEqual(g.rect('max', 'terminal'), { x: 32, y: 1, width: 576, height: 443 });
assert.deepEqual({ ...g.switcherRect('min') }, { x: 32, y: 366, width: 576, height: 36 });
// The full-panel mode keeps the top bar: its row shows only while focused.
g.settings.displayModeSetting.value = '640x480';
assert.equal(g.statusInSwitcherRow(), false);
assert.deepEqual(g.rect('max'), { x: 0, y: 28, width: 640, height: 452 });
});
test('the switcher row lays out windows, free space, notifications, widgets, batteries and the clock', () => {
const g = geometry();
g.settings.appSwitcherPositionSetting.value = 'bottom';
g.settings.statusBarPositionSetting.value = 'switcher';
const tray = new graphics.GrayImage(30, 20, 180);
const { chrome, requested } = chromeLayer(g, { notifications: 2, phoneBattery: 80, trayIcons: [tray] });
const parts = chrome.paintParts();
// No top bar: the row, then the status bar on the top bar's surface and depth.
assert.deepEqual(Array.from(parts, (p) => [p.shellKey, p.depth ?? 0]), [[1, 0], [2, -2]]);
const [row, status] = parts;
// Right to left from the row's end (x=608), centred under its separator
// line (y=366): "Thu Oct 2 9:41" (56px) 10px in; the battery block (label
// 20 + gap 5 + gauge 21) 16px before it; the 30px widget 10px before that;
// then the two notification icons, 8px clear of the widget.
const clockX = 608 - 10 - 56, batteryLeft = clockX - 16 - 46, trayLeft = batteryLeft - 40, iconsLeft = trayLeft - 8 - 56 + 4;
assert.deepEqual([status.x, status.y, status.image.width, status.image.height], [iconsLeft, 367, 608 - iconsLeft, 35]);
const at = (p, x, y) => p.image.withDrawsBaked().pixels[(y - p.y) * p.image.width + x - p.x];
// The clock's text runs 8 rows down the top bar's layout, which sits 5 rows into the row.
assert.deepEqual([at(status, clockX, 366 + 5 + 8 + 2), at(status, trayLeft, 366 + 5 + 4), at(status, iconsLeft, 366 + 5 + 2)], [210, 180, 200]);
assert.equal(at(status, batteryLeft, 366 + 5 + 8 + 2), 150, 'battery label');
// Windows take what the status bar leaves; the rest is free space.
assert.equal(at(row, 40 + 2, 366 + 2), 120, 'first window icon');
assert.equal(chrome.windowIndexAt(45, 380, 1), 0);
assert.equal(chrome.windowIndexAt(iconsLeft + 2, 380, 1), null);
// Notification icons stop short of the one window slot's room (with the
// row's margins and the gap to the status bar).
assert.equal(requested.at(-1), Math.floor((trayLeft - 8 - (32 + 20 + 40 - 8 + 8) + 4) / 28));
// No top bar, but the frame is still there, its top one row above the content.
const [frame] = row.image.draws.filter((d) => d.presentation?.displayList);
assert.deepEqual([row.x + frame.x, row.y + frame.y, frame.source.height], [31, 78, 289]);
shellScene.encodeShellScene(parts, g.uiDepth());
});
test('many windows scroll in what the notification icons leave them', () => {
const g = geometry();
g.settings.appSwitcherPositionSetting.value = 'bottom';
g.settings.statusBarPositionSetting.value = 'switcher';
const { chrome, requested } = chromeLayer(g, { notifications: 40, windows: 12 });
const [row, status] = chrome.paintParts();
// Clock only (no batteries or widgets): notifications end 8px before its
// 8px lead-in, and stop where three window slots plus margins remain.
const trayLeft = 608 - 10 - 56 - 8, floor = 32 + 20 + 3 * 40 - 8 + 8;
const max = Math.floor((trayLeft - 8 - floor + 4) / 28);
assert.equal(requested.at(-1), max);
const iconsLeft = trayLeft - 8 - max * 28 + 4;
assert.equal(status.x, iconsLeft);
// Three windows fit before the status bar's gap; the rest scroll, with the
// chevron at the end of the windows rather than of the row.
assert.equal(chrome.windowIndexAt(32 + 10 + 2 * 40 + 4, 380, 12), 2);
assert.equal(chrome.windowIndexAt(32 + 10 + 3 * 40 + 4, 380, 12), null);
const windowsRight = iconsLeft - 8;
const chevron = row.image.pixels.findIndex((v, i) => v === 140);
assert.equal(chevron % row.image.width + row.x, windowsRight - 6);
});
// Exercise the real worker message handler with platform work stubbed out.
+26 -2
View File
@@ -5,7 +5,7 @@ const { DrawOp, SCREEN, encodeDisplayList, readDisplayList, paintDisplayList } =
const { GrayImage } = require('../.test-build/app/graphics/image.js');
const { encodePresentation } = require('../.test-build/app/graphics/presentation-wire.js');
// Also consumed by FrameDisplayListTest.kt: bridge bytes, not independently rebuilt native calls.
const MENU = '077e0000000300020002000200022a00000096000000010002000200ffffffff0200080000ff24017e30020000000001812c8001812c1611010017328001812c16103001812c3023414031ff24017c30020000000001812c8001812c1611010017328001812c16103001812c302341403102000200010001030400000000000000001f';
const MENU = '077f0000000300020002000200022a00000096000000010002000200ffffffff0200080000ff24017e30020000000001812c8001812c1611010017328001812c16103001812c3023414031ff24017c30020000000001812c8001812c1611010017328001812c16103001812c30234140310200020001000103100400000000000000001f';
const MULTI = '0744000000030002000400010002000000000000000002000200010000ff010001006003000400000000000000001f0200000100000001000100020002feffffff7f00010001007f00';
test('extended integers agree with firmware widths and sign extension', () => {
@@ -90,9 +90,33 @@ test('frame submission supports resource-free lists and plain PRESENT-relative t
// the font and image ids it registers: a clipped clear, a clipped rounded rect,
// and replayed glyph + icon draws clipped while sliding up. REPLAY_PIXELS is
// what the list paints over a nibble-1 screen, 16x8 at 4 bits per pixel.
const REPLAY = '0780000000020003000800040000070000006400000000000300890000000000000600040002880000010001000200020000000400030000000510a00000000000000600040000ff2502000080c002000000000180c8800180c8161101001732800180c81610300180c830234031020000efbe4100000000000000ff01bebafeca04000100';
const REPLAY = '078100000002000300080004000007000000640000000000030089000000000000060004000288000001000100020002000000040003000000051010a00000000000000600040000ff2502000080c002000000000180c8800180c8161101001732800180c81610300180c830234031020000efbe4100000000000000ff01bebafeca04000100';
const REPLAY_PIXELS = '11111111111111111111111111111111111111111111111111fff28f111111111125522211111111112552221111111111222222111111111111111111111111';
// Also consumed by FrameDisplayListTest.kt: a window-frame rounded rect with no
// fill, a border of 3 and black outside the curve (revision 36), clipped short
// of its bottom row, and what it paints over a nibble-9 12x8 screen.
const FRAME = '072b00000002000100080006000000000000000000000000010088000000000000080005000000080006000300000300';
const FRAME_PIXELS = '999999999999990333333099993399993399993999999399993999999399993399993399999999999999999999999999';
test('a rounded rect outside color encodes, decodes and paints over the corners', () => {
const placed = { x: 2, y: 1, width: 8, height: 6, depth: 0, displayList: { resources: [], calls: [
{ op: DrawOp.ROUNDED_RECT, x: 0, y: 0, width: 8, height: 6, radius: 3, background: 0, border: 3, outside: 0, clip: { x: 0, y: 0, width: 8, height: 5 } },
] } };
assert.equal(Buffer.from(encodeDisplayList(placed, 0)).toString('hex'), FRAME);
const output = new Uint8Array(12 * 8).fill(9 * 16);
paintDisplayList(output, output.slice(), 12, 8, placed, false, 0);
assert.equal(Array.from(output, (v) => (v >> 4).toString(16)).join(''), FRAME_PIXELS);
const [rect] = readDisplayList(Buffer.from(FRAME, 'hex'), 0, 0).placed.displayList.calls;
assert.equal(rect.outside, 0);
// Without one, the call decodes without it and leaves the corners alone.
const plain = { ...placed, displayList: { resources: [], calls: [{ ...placed.displayList.calls[0], outside: undefined }] } };
assert.equal('outside' in readDisplayList(encodeDisplayList(plain, 0), 0, 0).placed.displayList.calls[0], false);
const corners = new Uint8Array(12 * 8).fill(9 * 16);
paintDisplayList(corners, corners.slice(), 12, 8, plain, false, 0);
assert.deepEqual([corners[12 + 2] >> 4, corners[12 + 5] >> 4], [9, 3]);
});
function replayList() {
// 'A' is 3x2 ink one row below a 4px line top; the icon is 2x2.
const font = { fingerprintId: 9001, atlasKey: 'stub-font', ascent: 3, lineHeight: 4 };
@@ -96,7 +96,9 @@ class DrawWireTest {
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))
// A rounded rect may end in one outside-color byte (revision 36), but not one past 15.
val overlong = if (call[0].toInt() == DRAW_OP_ROUNDED_RECT) byteArrayOf(16) else byteArrayOf(0)
val malformed = (0 until call.size).map { call.copyOf(it) } + listOf(call + overlong, call + byteArrayOf(0, 0))
for (bad in malformed) {
assertFails { renderer.execute(DrawProtocol.sequence(listOf(valid, bad, valid)), target) }
assertContentEquals(ByteArray(16) { 0x12 }, screen)
@@ -4,13 +4,13 @@ import kotlin.test.*
class FrameDisplayListTest {
// Golden records emitted by display-list-authoring.test.cjs.
private val menu = "077e0000000300020002000200022a00000096000000010002000200ffffffff0200080000ff24017e30020000000001812c8001812c1611010017328001812c16103001812c3023414031ff24017c30020000000001812c8001812c1611010017328001812c16103001812c302341403102000200010001030400000000000000001f"
private val menu = "077f0000000300020002000200022a00000096000000010002000200ffffffff0200080000ff24017e30020000000001812c8001812c1611010017328001812c16103001812c3023414031ff24017c30020000000001812c8001812c1611010017328001812c16103001812c30234140310200020001000103100400000000000000001f"
private val multi = "0744000000030002000400010002000000000000000002000200010000ff010001006003000400000000000000001f0200000100000001000100020002feffffff7f00010001007f00"
private val scroll = "078a000000030002000400020000070000009600000001000200040011223344556677880200020000000000ff250100300102300180f0800180f0161101001732800180f01610300180f0302341403101001102000200010008000000ff280101300100300180f0800180f0161101001732800180f01610300180f030234140310100170100160400020000000103"
private val scroll = "078b000000030002000400020000070000009600000001000200040011223344556677880200020000000000ff250100300102300180f0800180f0161101001732800180f01610300180f0302341403101001102000200010008000000ff280101300100300180f0800180f0161101001732800180f01610300180f03023414031010017010016040002000000010310"
// Clipped clear, clipped rounded rect, and replayed glyph + icon records with
// placeholder atlas ids 0xbeef / 0xcafebabe, plus what they paint over a
// nibble-1 16x8 screen (display-list-authoring.test.cjs).
private val replay = "0780000000020003000800040000070000006400000000000300890000000000000600040002880000010001000200020000000400030000000510a00000000000000600040000ff2502000080c002000000000180c8800180c8161101001732800180c81610300180c830234031020000efbe4100000000000000ff01bebafeca04000100"
private val replay = "078100000002000300080004000007000000640000000000030089000000000000060004000288000001000100020002000000040003000000051010a00000000000000600040000ff2502000080c002000000000180c8800180c8161101001732800180c81610300180c830234031020000efbe4100000000000000ff01bebafeca04000100"
private val replayPixels = "11111111111111111111111111111111111111111111111111fff28f111111111125522211111111112552221111111111222222111111111111111111111111"
private fun hex(s: String) = s.chunked(2).map { it.toInt(16).toByte() }.toByteArray()
private fun read(bytes: ByteArray, now: Long = 1150): FrameDisplayList {
@@ -141,6 +141,28 @@ class FrameDisplayListTest {
assertEquals(replayPixels, nibbles)
}
// A window-frame rounded rect (display-list-authoring.test.cjs): no fill, a
// border of 3, black outside the curve (revision 36), clipped short of its
// bottom row, over a nibble-9 12x8 screen.
private val frame = "072b00000002000100080006000000000000000000000000010088000000000000080005000000080006000300000300"
private val framePixels = "999999999999990333333099993399993399993999999399993999999399993399993399999999999999999999999999"
@Test fun roundedRectOutsideColorBridgesToTheTrailingByteAndPaintsLikeTheSoftwareRenderer() {
val call = read(hex(frame)).calls(IntArray(0), 0).single()
val plain = DrawProtocol.roundedRect(DrawValue.Integer(2), DrawValue.Integer(1), 8, 6, 3, 0, 3,
depth = 0, clip = DrawClip(2, 1, 8, 5))
assertContentEquals(plain + byteArrayOf(0), call)
val target = DisplayListRenderer.Target(ByteArray(48) { 0x99.toByte() }, 12, 8)
DisplayListRenderer(emptyMap()).execute(DrawProtocol.sequence(listOf(call)), target)
assertEquals(framePixels, (0 until 96).joinToString("") { target.get(it % 12, it / 12).toString(16) })
// Without the trailing byte the corners keep what was there; a color past 15 is rejected.
val corners = DisplayListRenderer.Target(ByteArray(48) { 0x99.toByte() }, 12, 8)
DisplayListRenderer(emptyMap()).execute(DrawProtocol.sequence(listOf(plain)), corners)
assertEquals(9, corners.get(2, 1)); assertEquals(3, corners.get(5, 1))
assertFails { DisplayListRenderer(emptyMap()).execute(DrawProtocol.sequence(listOf(plain + byteArrayOf(16))), corners) }
assertFails { DrawProtocol.roundedRect(DrawValue.Integer(0), DrawValue.Integer(0), 8, 6, 3, 0, 3, outside = 16) }
}
@Test fun replayWithAnUnknownRecordDrawsNothing() {
val list = read(registeredReplay(imageKnown = false), 1100)
assertTrue(list.resources.isEmpty())
+1 -1
View File
@@ -73,7 +73,7 @@ test('system menu bridge shifts its surface and selected row together by +4',()=
test('unselected sidebar icons retain -2 depth through shell cropping, including attention badges',()=>{
const shellScene=require('../.test-build/app/graphics/shell-scene.js');
const {ShellChromeLayer}=load('app/ui/shell/chrome-layer.ts',{
'../../graphics/shell-scene':shellScene,'../../graphics/image':graphics,
'../../graphics/shell-scene':shellScene,'../../graphics/image':graphics,'../../graphics/display-list':require('../.test-build/app/graphics/display-list.js'),
'../../graphics/ui-fonts':{getDefaultSmallFont:()=>font,getDefaultMediumFont:()=>font},
'../../graphics/textwrap':{},'./ambient-cards':{},'../../graphics/battery':{},
'../../native/notification-icons':{},'../../native/phone-battery':{},'../../util/render-freshness':{},
+1 -1
View File
@@ -11,7 +11,7 @@ const { MENU_BOUNCE_DURATION_MS, scrollOffsetExpression } = require('../.test-bu
const { encodePresentation } = require('../.test-build/app/graphics/presentation-wire.js');
const { setMenuAnimationReader } = require('../.test-build/app/ui/menu-animation-pref.js');
// Also consumed by FrameDisplayListTest.kt.
const SCROLL = '078a000000030002000400020000070000009600000001000200040011223344556677880200020000000000ff250100300102300180f0800180f0161101001732800180f01610300180f0302341403101001102000200010008000000ff280101300100300180f0800180f0161101001732800180f01610300180f030234140310100170100160400020000000103';
const SCROLL = '078b000000030002000400020000070000009600000001000200040011223344556677880200020000000000ff250100300102300180f0800180f0161101001732800180f01610300180f0302341403101001102000200010008000000ff280101300100300180f0800180f0161101001732800180f01610300180f03023414031010017010016040002000000010310';
const BOX = { x: 10, y: 5, width: 40, height: 60 };
const ITEMS = ['a', 'b', 'c', 'd', 'e', 'f', 'g'];