Fix WebGL page cache and flip sequencing
This commit is contained in:
@@ -27,6 +27,7 @@ async function main() {
|
||||
const minLabel = document.getElementById('webgl_book_nav_min_label');
|
||||
const maxLabel = document.getElementById('webgl_book_nav_max_label');
|
||||
const textureInfo = window.BookLabDebug.getTextureInfo();
|
||||
const runtimeInvariants = window.BookLabDebug.getRuntimeInvariants?.() || {};
|
||||
const initialBookState = window.BookLabDebug.getBookState();
|
||||
const initialSliderMax = slider?.max || null;
|
||||
const initialMinLabel = minLabel?.textContent || '';
|
||||
@@ -56,6 +57,12 @@ async function main() {
|
||||
spreadCount: 8,
|
||||
writtenPageLimit: 10
|
||||
});
|
||||
const initialNavigationDisabled = {
|
||||
topBackward: Boolean(document.getElementById('flip_backward')?.disabled),
|
||||
topFastBackward: Boolean(document.getElementById('fast_flip_backward')?.disabled),
|
||||
bottomStart: Boolean(document.getElementById('webgl_book_nav_start')?.disabled),
|
||||
bottomBack: Boolean(document.getElementById('webgl_book_nav_back')?.disabled)
|
||||
};
|
||||
slider.value = '100';
|
||||
slider.dispatchEvent(new Event('input', { bubbles: true }));
|
||||
await new Promise(resolve => {
|
||||
@@ -158,9 +165,21 @@ async function main() {
|
||||
new Promise(resolve => window.setTimeout(() => resolve(false), 5000))
|
||||
]);
|
||||
const postTargetFlipState = window.BookLabDebug.getBookState();
|
||||
window.BookLabDebug.setPaginationStateForTest({
|
||||
spreadIndex: 5,
|
||||
spreadCount: 8,
|
||||
writtenPageLimit: 10
|
||||
});
|
||||
const endNavigationDisabled = {
|
||||
topForward: Boolean(document.getElementById('flip_forward')?.disabled),
|
||||
topFastForward: Boolean(document.getElementById('fast_flip_forward')?.disabled),
|
||||
bottomForward: Boolean(document.getElementById('webgl_book_nav_forward')?.disabled),
|
||||
bottomEnd: Boolean(document.getElementById('webgl_book_nav_end')?.disabled)
|
||||
};
|
||||
|
||||
return {
|
||||
navExists: Boolean(nav),
|
||||
runtimeInvariants,
|
||||
initialSliderMax,
|
||||
initialMinLabel,
|
||||
initialMaxLabel,
|
||||
@@ -176,6 +195,7 @@ async function main() {
|
||||
height: cacheProbeResult?.height || 0
|
||||
},
|
||||
grownBookState,
|
||||
initialNavigationDisabled,
|
||||
clampedSliderValue,
|
||||
percentReserveState,
|
||||
overlayLayout,
|
||||
@@ -186,6 +206,7 @@ async function main() {
|
||||
targetFlipFinished,
|
||||
targetFlipEventDetail,
|
||||
postTargetFlipState,
|
||||
endNavigationDisabled,
|
||||
textureInfo
|
||||
};
|
||||
});
|
||||
@@ -202,6 +223,11 @@ async function main() {
|
||||
if (result.initialBookState?.pageCount !== 300) failures.push(`expected initial pageCount 300, got ${result.initialBookState?.pageCount}`);
|
||||
if (result.initialBookState?.pageReserve !== 50) failures.push(`expected initial pageReserve 50, got ${result.initialBookState?.pageReserve}`);
|
||||
if (result.initialBookState?.progress !== 0) failures.push(`expected initial progress 0, got ${result.initialBookState?.progress}`);
|
||||
if (Math.abs(Number(result.runtimeInvariants?.targetFrameDurationMs || 0) - (1000 / 60)) > 0.001) {
|
||||
failures.push(`expected 60fps target frame duration, got ${result.runtimeInvariants?.targetFrameDurationMs}`);
|
||||
}
|
||||
if (result.runtimeInvariants?.flipFrontBackShareMaterial) failures.push('flip front/back materials are shared instead of independently switchable');
|
||||
if (!result.runtimeInvariants?.mirrorRefreshesEveryFrame) failures.push('mirror reflection is not marked for per-frame refresh');
|
||||
if (JSON.stringify(result.pageSpreadMap) !== JSON.stringify([[0, 0], [1, 1], [2, 2], [3, 2], [4, 3], [5, 3]])) {
|
||||
failures.push(`unexpected page-to-spread map ${JSON.stringify(result.pageSpreadMap)}`);
|
||||
}
|
||||
@@ -213,6 +239,9 @@ async function main() {
|
||||
failures.push(`WebGL page cache probe failed: ${JSON.stringify(result.pageCacheProbe)}`);
|
||||
}
|
||||
if (result.grownBookState?.pageCount !== 310) failures.push(`expected page count to grow to 310 at writable limit, got ${result.grownBookState?.pageCount}`);
|
||||
if (!result.initialNavigationDisabled?.topBackward || !result.initialNavigationDisabled?.topFastBackward || !result.initialNavigationDisabled?.bottomStart || !result.initialNavigationDisabled?.bottomBack) {
|
||||
failures.push(`backward navigation should be disabled at first page: ${JSON.stringify(result.initialNavigationDisabled)}`);
|
||||
}
|
||||
if (result.finalSliderMax !== '310') failures.push(`expected final slider max 310, got ${result.finalSliderMax}`);
|
||||
if (result.finalMaxLabel !== '310') failures.push(`expected final max label 310, got ${result.finalMaxLabel}`);
|
||||
if (result.clampedSliderValue !== '10') failures.push(`expected slider clamp to written page 10, got ${result.clampedSliderValue}`);
|
||||
@@ -233,6 +262,9 @@ async function main() {
|
||||
eventDetail: result.targetFlipEventDetail
|
||||
})}`);
|
||||
if (result.postTargetFlipState?.spreadIndex !== 2) failures.push(`targeted page flip should commit spread 2, got ${result.postTargetFlipState?.spreadIndex}`);
|
||||
if (!result.endNavigationDisabled?.topForward || !result.endNavigationDisabled?.topFastForward || !result.endNavigationDisabled?.bottomForward || !result.endNavigationDisabled?.bottomEnd) {
|
||||
failures.push(`forward navigation should be disabled at written end: ${JSON.stringify(result.endNavigationDisabled)}`);
|
||||
}
|
||||
if (!result.textureInfo?.debug?.left?.painted || !result.textureInfo?.debug?.right?.painted) failures.push('page texture publish did not paint both pages');
|
||||
|
||||
if (failures.length) {
|
||||
|
||||
Reference in New Issue
Block a user