mirror of
https://github.com/storytold/vectorcraft.git
synced 2026-11-29 01:34:29 +01:00
Merge pull request #9898 from dotCooCoo/fix/hyphenation-dialog-test-timing
Tests: Japanese dialog clicks wait for the CJK font lookup
This commit is contained in:
3 files changed
+23
No files matched your search
@@ -724,6 +724,8 @@ mod tests {
|
||||
use egui::accesskit::Role;
|
||||
use egui::{Event, Modifiers, MouseWheelSource, MouseWheelUnit, PointerButton, Pos2, RawInput, Rect, TouchPhase, pos2, vec2};
|
||||
|
||||
// The Japanese pass measures OK when the dialog opens and clicks it after other edits.
|
||||
crate::testing::wait_for_cjk_fonts();
|
||||
let viewport = Rect::from_min_size(Pos2::ZERO, vec2(800.0, 500.0));
|
||||
let mut preview_heights = Vec::new();
|
||||
for language in ["en", "de", "ja"] {
|
||||
|
||||
@@ -175,6 +175,8 @@ mod tests {
|
||||
ui["dialogs"].as_array().unwrap().iter().find(|dialog| dialog["key"] == KIND).expect("open Hyphenation dialog")["fields"].clone()
|
||||
}
|
||||
|
||||
// The Japanese pass measures the controls once and clicks them frames later.
|
||||
crate::testing::wait_for_cjk_fonts();
|
||||
let screen = Rect::from_min_size(Pos2::ZERO, vec2(800.0, 500.0));
|
||||
let mut failures = Vec::new();
|
||||
for lang in ["en", "de", "fr", "ja"] {
|
||||
|
||||
@@ -29,6 +29,25 @@ pub(crate) fn windowed(mut app: crate::VectorcraftApp) -> crate::VectorcraftApp
|
||||
app
|
||||
}
|
||||
|
||||
/// Waits until the process's lookup of the installed CJK faces has ended: fontconfig's scan on Linux, which
|
||||
/// [`crate::ui_fonts`]'s loader starts the first time a CJK character has no glyph. Nothing waits on macOS and Windows.
|
||||
/// While the scan runs, Japanese, Chinese and Korean text draws without glyphs; the pass after it ends registers the
|
||||
/// face it found, and the next frame lays the text out again, wider or narrower, moving the controls around it. A test
|
||||
/// that measures controls in one frame and clicks them in a later one calls this first; then each new context
|
||||
/// registers its face after its first pass, and the controls hold still from the second frame on.
|
||||
pub(crate) fn wait_for_cjk_fonts() {
|
||||
use craft::ui::fonts::{FontCandidates as _, SystemCandidates};
|
||||
// `pending` starts the scan when it has not started.
|
||||
if !SystemCandidates.pending() {
|
||||
return;
|
||||
}
|
||||
let (ended, wait) = std::sync::mpsc::channel();
|
||||
SystemCandidates.wake_when_ready(craft::host::Wake::new(move || {
|
||||
let _ = ended.send(());
|
||||
}));
|
||||
let _ = wait.recv();
|
||||
}
|
||||
|
||||
/// A context with the runtime, the app's interface fonts and its root theme installed.
|
||||
pub(crate) fn ui_context() -> egui::Context {
|
||||
let ctx = egui::Context::default();
|
||||
|
||||
Reference in new issue
Block a user