mirror of
https://github.com/storytold/wordcraft.git
synced 2026-12-06 23:09:47 +00:00
Both tests failing on main CI since #8720 (f333552fe5) hit the same
asynchronous TextureLoader wake race (loader.rs:208) introduced when the
canvas settles page rects and requests a 1:1 device-pixel re-render:
- chrome::tests::status_bar_controls_width_cache_is_per_window_and_avoids_discard_loops:
WordApp::new and Kit::new used ThreadJobs, so the background page
rasterization triggered after the 400 -> 1200 resize could finish during
the verification pass and wake the context (delay 0ns). Run jobs inline
via InlineJobs on both Kit and Host, wait for two consecutive calm
passes (up to 8), and assert that steady state was reached.
- tests::dialogs_tests::nav_pane_switching_tabs_keeps_search_highlights:
#8720 raised max_steps to 8 in the sibling nav_pane_tabs_switch_on_click
test but missed this test (#9229), causing Harness::run to exceed its
default 4-step limit when TextureLoader wakes the harness. Use InlineJobs
and with_max_steps(8) so tab switching settles deterministically.
Test-only change; production behaviour unchanged. Refs #8720.
This commit is contained in:
@@ -638,15 +638,24 @@ fn status_fit_settles_and_resizes_without_discard_loops() {
|
||||
/// #5886: status bar controls fit is per-window and settles without repaint or discard loops across wide and narrow windows.
|
||||
#[test]
|
||||
fn status_bar_controls_width_cache_is_per_window_and_avoids_discard_loops() {
|
||||
use std::sync::Arc;
|
||||
use std::time::Duration;
|
||||
|
||||
use craft::host::{Host, InlineJobs};
|
||||
use craft::ui::InstallSpec;
|
||||
use craft::ui::testing::windows::FakeSystem;
|
||||
use craft_ui_test_kit::windows::Windows as Kit;
|
||||
use egui::{Pos2, Rect, ViewportId, ViewportInfo, vec2};
|
||||
|
||||
// 1. Multi-window rendering (`Kit`): both wide (800 pt root) and narrow (400 pt child) windows
|
||||
// render together on the same egui context each frame without overwriting each other's `status_fit`.
|
||||
let kit = Kit::new();
|
||||
let mut a = WordApp::new(wordcraft_engine::Session::new(wordcraft_doc::Document::from_text("Hello")), crate::Services::default());
|
||||
// Run background texture renders inline so a page-picture wake from `TextureLoader` cannot race
|
||||
// the verification pass's `delay > Duration::ZERO` assertion.
|
||||
let jobs = Arc::new(InlineJobs);
|
||||
let kit = Kit::with(InstallSpec::new(craft::host::target::ShellInfo::default(), Arc::new(FakeSystem::new())).jobs(jobs.clone()));
|
||||
let host = Host::builder(crate::APP).i18n(crate::i18n::catalogs()).lang(craft::i18n::Lang::EN).jobs(jobs).build();
|
||||
let mut a = WordApp::new(wordcraft_engine::Session::new(wordcraft_doc::Document::from_text("Hello")), crate::Services::default())
|
||||
.with_host(Arc::new(host));
|
||||
|
||||
let win1 = a.windows.shown();
|
||||
a.new_window();
|
||||
@@ -724,13 +733,19 @@ fn status_bar_controls_width_cache_is_per_window_and_avoids_discard_loops() {
|
||||
full.drop_without_applying_deltas();
|
||||
(passes, delay)
|
||||
};
|
||||
for _ in 0..4 {
|
||||
// The canvas requests one repaint when its page places settle, and the next pass renders the page picture
|
||||
// inline (`InlineJobs`) and requests one more repaint to upload it; wait for two consecutive calm passes
|
||||
// so both the status bar and the page view are at rest before asserting the single-pass steady state.
|
||||
let mut calm = 0;
|
||||
for _ in 0..8 {
|
||||
let (_, delay) = run_pass(app);
|
||||
let step_ok = if expect_compact { app.chrome.status_fit.step() >= 1 } else { app.chrome.status_fit.step() == 0 };
|
||||
if delay > Duration::ZERO && step_ok {
|
||||
calm = if delay > Duration::ZERO && step_ok { calm + 1 } else { 0 };
|
||||
if calm >= 2 {
|
||||
break;
|
||||
}
|
||||
}
|
||||
assert!(calm >= 2, "width {width}: failed to reach steady state within 8 passes");
|
||||
let settled = app.chrome.status_fit.clone();
|
||||
if expect_compact {
|
||||
assert!(settled.step() >= 1, "width {width}: settled at compact step: {settled:?}");
|
||||
|
||||
@@ -490,7 +490,19 @@ fn nav_pane_tabs_switch_on_click() {
|
||||
/// #9229: switching Navigation pane tabs keeps the active search highlights in the document.
|
||||
#[test]
|
||||
fn nav_pane_switching_tabs_keeps_search_highlights() {
|
||||
let mut h = crate::test_harness::builder().with_size(egui::vec2(800.0, 500.0)).build_eframe(|_| app());
|
||||
// A page view that comes to rest draws once more at its exact size, and inline jobs keep page picture
|
||||
// renders deterministic instead of racing the harness's settle loop on a background thread.
|
||||
let jobs = Arc::new(craft::host::InlineJobs);
|
||||
let mut h = crate::test_harness::builder_with({
|
||||
let jobs = jobs.clone();
|
||||
move || crate::test_harness::install_spec().jobs(jobs)
|
||||
})
|
||||
.with_size(egui::vec2(800.0, 500.0))
|
||||
.with_max_steps(8)
|
||||
.build_eframe(move |_| {
|
||||
let host = Host::builder(crate::APP).files(Arc::new(ScriptedFiles::new())).jobs(jobs.clone()).build();
|
||||
WordApp::new(Session::new(wordcraft_doc::Document::new()), Services::default()).with_host(Arc::new(host))
|
||||
});
|
||||
h.state_mut().run("document.setText", json!({"text": "Kilns fire clay. Kilns cool."})).unwrap();
|
||||
h.state_mut().session.view.nav_pane = true;
|
||||
for _ in 0..2 {
|
||||
|
||||
Reference in New Issue
Block a user