427 lines
23 KiB
TypeScript
427 lines
23 KiB
TypeScript
import { test } from 'node:test';
|
|
import { strict as assert } from 'node:assert';
|
|
import { readFileSync } from 'node:fs';
|
|
import { join } from 'node:path';
|
|
import { ART, CELEBRATION_FONT_UUID, FONT_UUID } from '../assets/orchard/scripts/OrchardAssets';
|
|
import { GIFT_REFERENCE, REFERENCE_IMAGES, type DialogBox } from '../assets/orchard/scripts/DialogReferenceLayout';
|
|
|
|
// These tests inspect saved scene data and imported assets. Live state changes are browser checks.
|
|
type Entry = Record<string, any>;
|
|
const scene: Entry[] = JSON.parse(readFileSync('assets/Orchard.scene', 'utf8'));
|
|
const nodes = scene.filter(entry => entry.__type__ === 'cc.Node');
|
|
const WHITE = { __type__: 'cc.Color', r: 255, g: 255, b: 255, a: 255 };
|
|
const TOLERANCE = 1;
|
|
|
|
function dereference(ref: Entry): Entry {
|
|
assert.ok(ref && Number.isInteger(ref.__id__), 'expected a saved scene reference');
|
|
const entry = scene[ref.__id__];
|
|
assert.ok(entry, `missing scene entry ${ref.__id__}`);
|
|
return entry;
|
|
}
|
|
|
|
function node(name: string): Entry {
|
|
const matches = nodes.filter(entry => entry._name === name);
|
|
assert.equal(matches.length, 1, `expected one saved ${name}`);
|
|
return matches[0];
|
|
}
|
|
|
|
function children(owner: Entry): Entry[] {
|
|
return owner._children.map(dereference);
|
|
}
|
|
|
|
function components(owner: Entry, type: string): Entry[] {
|
|
return owner._components.map(dereference).filter((entry: Entry) => entry.__type__ === type);
|
|
}
|
|
|
|
function component(owner: Entry, type: string): Entry {
|
|
const matches = components(owner, type);
|
|
assert.equal(matches.length, 1, `${owner._name}: expected one ${type}`);
|
|
assert.equal(dereference(matches[0].node), owner);
|
|
return matches[0];
|
|
}
|
|
|
|
function near(actual: number, expected: number, description: string): void {
|
|
assert.ok(Number.isFinite(actual) && Math.abs(actual - expected) <= TOLERANCE,
|
|
`${description}: expected ${expected} +/- ${TOLERANCE}px, got ${actual}`);
|
|
}
|
|
|
|
// Accumulate saved ancestor offsets, so moving an entire modal cannot hide a layout regression.
|
|
function referenceCenter(owner: Entry): { x: number; y: number } {
|
|
let x = 0, y = 0;
|
|
const visited = new Set<Entry>();
|
|
while (owner.__type__ === 'cc.Node') {
|
|
assert.ok(!visited.has(owner), 'saved hierarchy must not cycle');
|
|
visited.add(owner);
|
|
assert.deepEqual(owner._lscale, { __type__: 'cc.Vec3', x: 1, y: 1, z: 1 }, owner._name);
|
|
assert.deepEqual(owner._lrot, { __type__: 'cc.Quat', x: 0, y: 0, z: 0, w: 1 }, owner._name);
|
|
assert.equal(owner._lpos.z, 0, owner._name);
|
|
x += owner._lpos.x;
|
|
y += owner._lpos.y;
|
|
owner = dereference(owner._parent);
|
|
}
|
|
return { x, y: 1920 - y };
|
|
}
|
|
|
|
function assertBox(name: string, x: number, y: number, width: number, height: number): void {
|
|
const owner = node(name);
|
|
const transform = component(owner, 'cc.UITransform');
|
|
assert.deepEqual(transform._anchorPoint, { __type__: 'cc.Vec2', x: .5, y: .5 }, name);
|
|
const center = referenceCenter(owner);
|
|
near(center.x, x, `${name} reference center x`);
|
|
near(center.y, y, `${name} reference center y`);
|
|
near(transform._contentSize.width, width, `${name} width`);
|
|
near(transform._contentSize.height, height, `${name} height`);
|
|
}
|
|
|
|
function imageMeta(key: string): Entry {
|
|
const meta = JSON.parse(readFileSync(join('assets', 'orchard', 'dialogs', `${key}.png.meta`), 'utf8'));
|
|
assert.equal(meta.importer, 'image', key);
|
|
assert.equal(meta.imported, true, key);
|
|
const frames = (Object.values(meta.subMetas) as Entry[]).filter(entry => entry.importer === 'sprite-frame');
|
|
assert.equal(frames.length, 1, key);
|
|
assert.equal(frames[0].uuid, ART[key], `${key}: imported frame UUID`);
|
|
return meta;
|
|
}
|
|
|
|
function assertPicture(name: string, box: DialogBox, parent: string): void {
|
|
const [key, x, y, width, height] = box;
|
|
assertBox(name, x, y, width, height);
|
|
const owner = node(name);
|
|
assert.equal(dereference(owner._parent), node(parent), name);
|
|
const sprite = component(owner, 'cc.Sprite');
|
|
assert.equal(sprite._spriteFrame?.__uuid__, ART[key], `${name}: ${key}`);
|
|
imageMeta(key);
|
|
}
|
|
|
|
function assertWhiteSystemLabel(name: string, value: string): Entry {
|
|
const label = component(node(name), 'cc.Label');
|
|
assert.equal(label._string, value, name);
|
|
assert.equal(label._font, null, name);
|
|
assert.equal(label._isSystemFontUsed, true, name);
|
|
assert.equal(label._fontFamily, 'Arial', name);
|
|
assert.deepEqual(label._color, WHITE, name);
|
|
assert.equal(label._enableWrapText, false, name);
|
|
return label;
|
|
}
|
|
|
|
// Independent full-image measurements in 1080x1920 reference pixels (top-left origin).
|
|
// Do not derive these values from the authoring functions or their source strings.
|
|
const MEASURED_IMAGES: Record<string, DialogBox> = {
|
|
PreferencesShell: ['preferences-shell', 538, 856, 884, 1050],
|
|
PreferencesTitle: ['preferences-heading', 539.5, 465.5, 505, 85],
|
|
PreferencesFlourish: ['preferences-flourish', 540.5, 529.5, 471, 43],
|
|
PreferencesMusicRow: ['melody-row', 540, 650.5, 788, 155],
|
|
PreferencesSoundRow: ['effects-row', 540, 816, 788, 155],
|
|
PreferencesVibrationRow: ['haptics-row', 540, 981.5, 788, 155],
|
|
PreferencesMusicToggle: ['toggle-lit', 791, 650.5, 210, 91],
|
|
PreferencesSoundToggle: ['toggle-lit', 791, 816, 210, 91],
|
|
PreferencesVibrationToggle: ['toggle-lit', 791, 981.5, 210, 91],
|
|
PreferencesGuide: ['instructions-pill', 540, 1159.5, 630, 133],
|
|
PreferencesClose: ['dismiss-orb', 890.5, 415.5, 123, 121],
|
|
RepeatShell: ['repeat-shell', 536.5, 1009, 905, 980],
|
|
RepeatGarnish: ['repeat-garnish', 544, 521.5, 228, 213],
|
|
RepeatTitle: ['repeat-title', 537, 663.5, 684, 157],
|
|
RepeatStart: ['repeat-confirm', 535, 1303.5, 808, 203],
|
|
RepeatClose: ['dismiss-orb', 902, 595, 114, 112],
|
|
EmptyWalletShell: ['empty-wallet-shell', 534.5, 957.5, 879, 1135],
|
|
EmptyWalletTitle: ['empty-wallet-heading', 536.5, 531.5, 747, 329],
|
|
EmptyWalletGarnish: ['empty-wallet-garnish', 531.5, 845.5, 707, 391],
|
|
EmptyWalletNote: ['empty-wallet-note', 539.5, 1095.5, 539, 111],
|
|
EmptyWalletGift: ['empty-wallet-gift', 539, 1262, 780, 175],
|
|
EmptyWalletLater: ['empty-wallet-later', 537, 1409, 354, 86],
|
|
EmptyWalletClose: ['shortfall-dismiss', 897, 425, 116, 116],
|
|
BonusAwardScatter1: ['bonus-award-emblem', 265, 638, 270, 266],
|
|
BonusAwardScatter2: ['bonus-award-emblem', 538.5, 618.5, 289, 285],
|
|
BonusAwardScatter3: ['bonus-award-emblem', 815, 638, 270, 266],
|
|
BonusAwardTitle: ['bonus-award-title', 542, 864, 952, 282],
|
|
BonusAwardCaption: ['bonus-award-caption', 535, 1323, 756, 122],
|
|
BonusAwardStart: ['bonus-begin', 541, 1503.5, 646, 219],
|
|
BonusSummaryShell: ['bonus-summary-shell', 538, 994, 996, 960],
|
|
BonusSummaryGarnish: ['bonus-summary-garnish', 540.5, 506.5, 499, 259],
|
|
BonusSummaryTitle: ['bonus-summary-title', 539, 754, 762, 248],
|
|
BonusSummaryCaption: ['bonus-summary-caption', 543.5, 934, 831, 90],
|
|
BonusSummaryAmountPlate: ['bonus-summary-amount', 539, 1075.5, 870, 229],
|
|
BonusSummaryContinue: ['bonus-dismiss', 540, 1291, 684, 206],
|
|
};
|
|
|
|
const MEASURED_GIFTS: Record<'available' | 'claimed', Record<string, DialogBox>> = {
|
|
available: {
|
|
GiftShell: ['gift-shell', 537, 938.5, 960, 1247],
|
|
GiftTitle: ['gift-heading', 545, 454, 584, 104],
|
|
GiftGarnish: ['gift-garnish', 530.5, 743.5, 407, 389],
|
|
GiftAmountPlate: ['gift-amount', 538, 1012.5, 766, 163],
|
|
GiftDailyLabel: ['gift-daily', 546.5, 1149.5, 731, 65],
|
|
GiftClaim: ['gift-collect', 537, 1306, 648, 198],
|
|
GiftClose: ['gift-dismiss', 917, 399, 116, 116],
|
|
},
|
|
claimed: {
|
|
GiftShell: ['claimed-shell', 536, 958, 934, 1212],
|
|
GiftTitle: ['claimed-heading', 537.5, 517, 763, 372],
|
|
GiftGarnish: ['claimed-garnish', 540, 844.5, 348, 247],
|
|
GiftAmountPlate: ['claimed-amount', 535, 1035, 750, 168],
|
|
GiftDailyLabel: ['claimed-caption', 538.5, 1180.5, 749, 61],
|
|
GiftCollected: ['gift-collected', 533.5, 1311.5, 567, 143],
|
|
GiftClose: ['claimed-dismiss', 892, 474, 106, 106],
|
|
},
|
|
};
|
|
|
|
for (const prefix of ['Preferences', 'Repeat', 'EmptyWallet', 'BonusAward', 'BonusSummary']) {
|
|
test(`saved ${prefix} artwork matches independent reference measurements within one pixel`, () => {
|
|
for (const [name, box] of Object.entries(MEASURED_IMAGES).filter(([name]) => name.startsWith(prefix))) {
|
|
assert.deepEqual(REFERENCE_IMAGES[name], box, `${name}: published reference measurement`);
|
|
assertPicture(name, box, `${prefix}Dialog`);
|
|
}
|
|
});
|
|
}
|
|
|
|
test('settings legal links are regular white underlined text below the reference guide button', () => {
|
|
assert.ok(!nodes.some(entry => entry._name === 'PreferencesNote'));
|
|
for (const [name, value, x, width] of [
|
|
['PreferencesPrivacy', 'Privacy Policy', 335, 260],
|
|
['PreferencesTerms', 'Terms of Service', 726, 310],
|
|
] as const) {
|
|
assertBox(name, x, 1281, width, 62);
|
|
const label = assertWhiteSystemLabel(name, value);
|
|
assert.equal(label._isBold, false, name);
|
|
assert.equal(label._isUnderline, true, name);
|
|
assert.equal(label._fontSize, 34, name);
|
|
assert.equal(label._lineHeight, 42, name);
|
|
assert.equal(component(node(name), 'cc.Button')._interactable, true, name);
|
|
assert.equal(dereference(node(name)._parent), node('PreferencesDialog'));
|
|
}
|
|
const legal = node('PreferencesDialog')._components.map(dereference).filter((entry: Entry) =>
|
|
entry.privacyButton && entry.termsButton && entry.notice);
|
|
assert.equal(legal.length, 1, 'one saved legal-link binding');
|
|
assert.equal(dereference(legal[0].privacyButton), component(node('PreferencesPrivacy'), 'cc.Button'));
|
|
assert.equal(dereference(legal[0].termsButton), component(node('PreferencesTerms'), 'cc.Button'));
|
|
assert.equal(dereference(legal[0].notice), component(node('PreferencesLegalNotice'), 'cc.Label'));
|
|
assert.equal(node('PreferencesLegalNotice')._active, false);
|
|
});
|
|
|
|
test('automatic spin options retain measured positions, the selected 25 frame and white captions', () => {
|
|
for (const [count, key, x, y] of [
|
|
[10, 'ten-idle', 356, 917], [25, 'quarter-picked', 727, 917],
|
|
[50, 'half-idle', 355, 1092], [100, 'century-idle', 730, 1092],
|
|
] as const) {
|
|
const selected = count === 25;
|
|
const name = `RepeatCount${count}`;
|
|
assertPicture(name, [key, x, y, selected ? 377 : 364, selected ? 178 : 172], 'RepeatDialog');
|
|
assert.equal(component(node(name), 'cc.Button')._interactable, true);
|
|
}
|
|
assertBox('RepeatHint', 540, 777, 740, 76);
|
|
assert.equal(assertWhiteSystemLabel('RepeatHint', 'Choose number of spins')._fontSize, 48);
|
|
assertBox('RepeatFooter', 540, 1414, 480, 60);
|
|
assert.equal(assertWhiteSystemLabel('RepeatFooter', 'Stop anytime')._fontSize, 38);
|
|
});
|
|
|
|
test('available gift is saved with full white coin units and a claim button at least 128px on both axes', () => {
|
|
for (const [name, box] of Object.entries(MEASURED_GIFTS.available)) assertPicture(name, box, 'GiftDialog');
|
|
assertBox('GiftAmount', 600, 1012.5, 550, 120);
|
|
const amount = assertWhiteSystemLabel('GiftAmount', '20,000 COINS');
|
|
assert.equal(amount._fontSize, 82);
|
|
assert.equal(amount._isBold, true);
|
|
const claim = component(node('GiftClaim'), 'cc.Button');
|
|
assert.equal(claim._enabled, true);
|
|
assert.equal(claim._interactable, true);
|
|
assert.equal(claim._transition, 3, 'scale feedback');
|
|
assert.equal(claim._zoomScale, .96);
|
|
const { width, height } = component(node('GiftClaim'), 'cc.UITransform')._contentSize;
|
|
assert.ok(width >= 128 && height >= 128, 'claim touch target must remain usable');
|
|
assert.equal(node('GiftClaim')._active, true);
|
|
assert.equal(node('GiftCollected')._active, false);
|
|
assertPicture('GiftCollected', MEASURED_GIFTS.claimed.GiftCollected, 'GiftDialog');
|
|
assert.equal(components(node('GiftCollected'), 'cc.Button').length, 0, 'claimed artwork is not another claim action');
|
|
assertBox('GiftCountdown', 540, 1446, 820, 60);
|
|
const footer = assertWhiteSystemLabel('GiftCountdown', 'Available once per UTC day.');
|
|
assert.equal(footer._isBold, false);
|
|
});
|
|
|
|
test('gift state data owns independently measured art, plate, close and button geometry for both states', () => {
|
|
assert.deepEqual(Object.keys(GIFT_REFERENCE).sort(), ['available', 'claimed']);
|
|
for (const state of ['available', 'claimed'] as const) {
|
|
assert.deepEqual(GIFT_REFERENCE[state], MEASURED_GIFTS[state], `${state}: independent measured layout`);
|
|
for (const [name, [key]] of Object.entries(MEASURED_GIFTS[state])) {
|
|
assert.equal(dereference(node(name)._parent), node('GiftDialog'), name);
|
|
imageMeta(key);
|
|
}
|
|
}
|
|
for (const name of ['GiftShell', 'GiftTitle', 'GiftGarnish', 'GiftAmountPlate', 'GiftDailyLabel', 'GiftClose']) {
|
|
const available = MEASURED_GIFTS.available[name];
|
|
const claimed = MEASURED_GIFTS.claimed[name];
|
|
assert.notEqual(ART[available[0]], ART[claimed[0]], `${name}: independent state assets`);
|
|
assert.notDeepEqual(available.slice(1), claimed.slice(1), `${name}: independently measured geometry`);
|
|
}
|
|
// The claimed state is runtime-applied, not a second saved GiftDialog; no source-string simulation.
|
|
});
|
|
|
|
test('each close control resolves to its own reference artwork rather than a shared generic replacement', () => {
|
|
for (const [name, key] of [
|
|
['PreferencesClose', 'dismiss-orb'], ['RepeatClose', 'dismiss-orb'],
|
|
['GiftClose', 'gift-dismiss'], ['EmptyWalletClose', 'shortfall-dismiss'],
|
|
]) {
|
|
assert.equal(component(node(name), 'cc.Sprite')._spriteFrame.__uuid__, ART[key], name);
|
|
assert.equal(component(node(name), 'cc.Button')._interactable, true, name);
|
|
}
|
|
assert.equal(GIFT_REFERENCE.claimed.GiftClose[0], 'claimed-dismiss');
|
|
const distinct = ['dismiss-orb', 'gift-dismiss', 'claimed-dismiss', 'shortfall-dismiss'];
|
|
assert.equal(new Set(distinct.map(key => ART[key])).size, 4);
|
|
distinct.forEach(imageMeta);
|
|
});
|
|
|
|
test('free-spin trigger has no shell and has eighteen separately rendered decoration nodes behind its content', () => {
|
|
assert.ok(!nodes.some(entry => entry._name === 'BonusAwardShell'));
|
|
const award = node('BonusAwardDialog');
|
|
const decor = node('BonusAwardCelebrationDecor');
|
|
assert.equal(dereference(decor._parent), award);
|
|
assert.equal(children(award)[0], decor, 'decorations stay behind scatter/title/count');
|
|
assertBox('BonusAwardCelebrationDecor', 540, 960, 1080, 1920);
|
|
const pieces = children(decor);
|
|
assert.equal(pieces.length, 18, 'eighteen independently rendered decorations, excluding the container');
|
|
assert.equal(new Set(pieces).size, 18);
|
|
assert.equal(new Set(pieces.map(entry => entry._name)).size, 18);
|
|
for (const piece of pieces) {
|
|
assert.equal(dereference(piece._parent), decor, piece._name);
|
|
assert.match(piece._name, /^BonusAward.+Decor$/);
|
|
assert.equal(children(piece).length, 0, piece._name);
|
|
component(piece, 'cc.UITransform');
|
|
const renderers = [...components(piece, 'cc.Graphics'), ...components(piece, 'cc.Sprite')];
|
|
assert.equal(renderers.length, 1, `${piece._name}: independent graphics or sprite`);
|
|
assert.equal(renderers[0]._enabled, true, piece._name);
|
|
assert.equal(piece._active, true, piece._name);
|
|
assert.equal(components(piece, 'cc.Label').length, 0);
|
|
assert.equal(components(piece, 'cc.Button').length, 0);
|
|
}
|
|
});
|
|
|
|
test('free-spin scatter trio, title, 325px count, award caption and start keep reference screen and draw order', () => {
|
|
const names = ['BonusAwardCelebrationDecor', 'BonusAwardScatter1', 'BonusAwardScatter2',
|
|
'BonusAwardScatter3', 'BonusAwardTitle', 'BonusAwardCount', 'BonusAwardCaption', 'BonusAwardStart'];
|
|
assert.deepEqual(children(node('BonusAwardDialog')).map(entry => entry._name), names);
|
|
const scatters = children(node('BonusAwardDialog')).filter(entry => /^BonusAwardScatter\d+$/.test(entry._name));
|
|
assert.equal(scatters.length, 3);
|
|
assert.ok(referenceCenter(scatters[0]).x < referenceCenter(scatters[1]).x);
|
|
assert.ok(referenceCenter(scatters[1]).x < referenceCenter(scatters[2]).x);
|
|
assert.ok(referenceCenter(scatters[1]).y < referenceCenter(scatters[0]).y, 'middle scatter rises above the sides');
|
|
const sequence = ['BonusAwardTitle', 'BonusAwardCount', 'BonusAwardCaption', 'BonusAwardStart'];
|
|
const titleY = referenceCenter(node('BonusAwardTitle')).y;
|
|
assert.ok(scatters.every(scatter => referenceCenter(scatter).y < titleY));
|
|
for (let index = 1; index < sequence.length; index++) {
|
|
assert.ok(referenceCenter(node(sequence[index - 1])).y < referenceCenter(node(sequence[index])).y,
|
|
`${sequence[index - 1]} is above ${sequence[index]}`);
|
|
}
|
|
assertBox('BonusAwardCount', 534, 1116, 620, 350);
|
|
const count = component(node('BonusAwardCount'), 'cc.Label');
|
|
assert.equal(count._string, '8');
|
|
assert.equal(count._fontSize, 325);
|
|
assert.equal(count._lineHeight, 325, 'native line height prevents SHRINK from reducing the reference digit');
|
|
assert.equal(count._font.__uuid__, CELEBRATION_FONT_UUID);
|
|
assert.equal(count._isSystemFontUsed, false);
|
|
assert.equal(count._enableWrapText, false);
|
|
const buttons = children(node('BonusAwardDialog')).filter(entry => components(entry, 'cc.Button').length);
|
|
assert.deepEqual(buttons.map(entry => entry._name), ['BonusAwardStart']);
|
|
});
|
|
|
|
const fontDirectory = join('assets', 'orchard', 'typefaces');
|
|
function celebrationFontMeta(): Entry {
|
|
return JSON.parse(readFileSync(join(fontDirectory, 'celebration-numerals.fnt.meta'), 'utf8'));
|
|
}
|
|
|
|
function numericFields(line: string): Record<string, number> {
|
|
return Object.fromEntries([...line.matchAll(/\b([A-Za-z]+)=(-?\d+)\b/g)].map(match => [match[1], Number(match[2])]));
|
|
}
|
|
|
|
test('celebration font page, imported metadata and atlas retain the renamed asset and exactly digits 0-9', () => {
|
|
const font = celebrationFontMeta();
|
|
assert.equal(font.importer, 'bitmap-font');
|
|
assert.equal(font.imported, true);
|
|
assert.equal(font.uuid, CELEBRATION_FONT_UUID);
|
|
assert.notEqual(font.uuid, FONT_UUID);
|
|
const text = readFileSync(join(fontDirectory, 'celebration-numerals.fnt'), 'utf8');
|
|
const pages = [...text.matchAll(/^page\s+id=(\d+)\s+file="([^"]+)"\s*$/gm)];
|
|
assert.equal(pages.length, 1);
|
|
assert.equal(pages[0][1], '0');
|
|
assert.equal(pages[0][2], 'celebration-glyphs.png');
|
|
const atlas = JSON.parse(readFileSync(join(fontDirectory, 'celebration-glyphs.png.meta'), 'utf8'));
|
|
assert.equal(atlas.importer, 'image');
|
|
assert.equal(atlas.imported, true);
|
|
assert.equal(font.userData.textureUuid, atlas.uuid);
|
|
const textures = (Object.values(atlas.subMetas) as Entry[]).filter(entry => entry.importer === 'texture');
|
|
assert.equal(textures.length, 1);
|
|
assert.equal(textures[0].imported, true);
|
|
assert.equal(textures[0].userData.imageUuidOrDatabaseUri, atlas.uuid);
|
|
const config = font.userData._fntConfig;
|
|
assert.equal(config.atlasName, 'celebration-glyphs.png');
|
|
assert.equal(config.fontSize, 325);
|
|
assert.equal(config.commonHeight, 325);
|
|
assert.equal(font.userData.fontSize, 325);
|
|
assert.match(text, /^info\s+.*\bsize=325\b/m);
|
|
assert.match(text, /^chars\s+count=10\s*$/m);
|
|
const common = numericFields(text.split(/\r?\n/).find(line => line.startsWith('common '))!);
|
|
assert.equal(common.lineHeight, 325);
|
|
assert.equal(common.pages, 1);
|
|
const png = readFileSync(join(fontDirectory, pages[0][2]));
|
|
assert.equal(png.subarray(0, 8).toString('hex'), '89504e470d0a1a0a');
|
|
assert.equal(png.readUInt32BE(16), common.scaleW);
|
|
assert.equal(png.readUInt32BE(20), common.scaleH);
|
|
const glyphs = text.split(/\r?\n/).filter(line => line.startsWith('char ')).map(numericFields);
|
|
const digits = Array.from({ length: 10 }, (_, digit) => 48 + digit);
|
|
assert.deepEqual(glyphs.map(glyph => glyph.id).sort((a, b) => a - b), digits);
|
|
assert.deepEqual(Object.keys(config.fontDefDictionary).map(Number).sort((a, b) => a - b), digits);
|
|
for (const glyph of glyphs) {
|
|
assert.equal(glyph.page, 0);
|
|
assert.ok(glyph.x >= 0 && glyph.y >= 0 && glyph.width > 0 && glyph.height > 0 && glyph.xadvance > 0);
|
|
assert.ok(glyph.x + glyph.width <= common.scaleW && glyph.y + glyph.height <= common.scaleH);
|
|
assert.deepEqual(config.fontDefDictionary[glyph.id], {
|
|
rect: { x: glyph.x, y: glyph.y, width: glyph.width, height: glyph.height },
|
|
xOffset: glyph.xoffset, yOffset: glyph.yoffset, xAdvance: glyph.xadvance,
|
|
}, `digit ${String.fromCharCode(glyph.id)} metadata matches the imported font`);
|
|
}
|
|
assert.match(text, /^kernings\s+count=0\s*$/m);
|
|
assert.deepEqual(config.kerningDict, {});
|
|
});
|
|
|
|
for (const award of [8, 12, 16]) {
|
|
test(`dedicated font fits free-spin award ${award} in the saved 620px count at full 325px size`, () => {
|
|
const label = component(node('BonusAwardCount'), 'cc.Label');
|
|
const { width, height } = component(node('BonusAwardCount'), 'cc.UITransform')._contentSize;
|
|
assert.equal(width, 620);
|
|
assert.equal(label._fontSize, 325);
|
|
const config = celebrationFontMeta().userData._fntConfig;
|
|
const scale = label._fontSize / config.fontSize;
|
|
let advance = 0, right = 0, left = 0, bottom = 0;
|
|
for (const digit of String(award)) {
|
|
const glyph = config.fontDefDictionary[digit.charCodeAt(0)];
|
|
assert.ok(glyph, `missing digit ${digit}`);
|
|
left = Math.min(left, advance + glyph.xOffset);
|
|
right = Math.max(right, advance + glyph.xOffset + glyph.rect.width);
|
|
bottom = Math.max(bottom, glyph.yOffset + glyph.rect.height);
|
|
advance += glyph.xAdvance;
|
|
}
|
|
const requiredWidth = (Math.max(advance, right) - left) * scale;
|
|
assert.ok(requiredWidth > 0 && requiredWidth <= width, `${award}: ${requiredWidth}px must fit ${width}px without shrinking`);
|
|
assert.ok(bottom * scale <= height, `${award}: glyphs must fit the saved count height`);
|
|
});
|
|
}
|
|
|
|
test('free-spin result amount retains amber numerals inside its independently measured plate', () => {
|
|
assertBox('BonusSummaryAmount', 619, 1075.5, 480, 146);
|
|
const label = component(node('BonusSummaryAmount'), 'cc.Label');
|
|
assert.equal(label._font.__uuid__, FONT_UUID);
|
|
assert.equal(label._isSystemFontUsed, false);
|
|
assert.equal(label._fontSize, 126);
|
|
assert.equal(component(node('BonusSummaryContinue'), 'cc.Button')._interactable, true);
|
|
});
|
|
|
|
test('saved ModalLayer preserves Shade plus all eight independent dialog groups at the Canvas origin', () => {
|
|
const layer = node('ModalLayer');
|
|
assert.equal(dereference(layer._parent), node('Canvas'));
|
|
const groups = ['RepeatDialog', 'PreferencesDialog', 'GiftDialog', 'EmptyWalletDialog',
|
|
'BonusAwardDialog', 'BonusSummaryDialog', 'GuideDialog', 'ErrorDialog'];
|
|
assert.deepEqual(children(layer).map(entry => entry._name).sort(), ['Shade', ...groups].sort());
|
|
assert.equal(children(layer)[0], node('Shade'));
|
|
component(node('Shade'), 'cc.BlockInputEvents');
|
|
for (const owner of [layer, ...groups.map(node)]) {
|
|
assert.deepEqual(owner._lpos, { __type__: 'cc.Vec3', x: 0, y: 0, z: 0 }, owner._name);
|
|
if (owner !== layer) assert.equal(dereference(owner._parent), layer, owner._name);
|
|
}
|
|
}); |