Tests: the engine-language test runs a Japanese frame again

the_engine_follows_the_interface_language drew only English frames
after 6efe9df3e, because a Japanese frame set the drawing language for
every test running beside it. It set the engine's language by hand and
never checked that a Japanese frame hands the engine ja. Since #2570
each unit-test thread has its own drawing language.

The test again runs a frame with the interface preference set to
Japanese and checks that the engine gets ja, then runs a frame with
the preference back on auto and checks that it gets en. It also checks
that a thread started after the Japanese frame still draws in English.
With the drawing language process-wide, as before #2570, the test
fails, and the zoom hint test beside it showed its hint in Japanese in
12 of 200 runs.
This commit is contained in:
dotCooCoo
2026-10-21 16:55:16 +07:00
committed by bflatastic
parent 68d8a9c755
commit 3cd2ae2f12
+12 -6
View File
@@ -209,7 +209,8 @@ fn partial_catalogs_only_translate_strings_the_ui_shows() {
}
/// The engine learns the language the UI is drawn in each frame: new type takes the Japanese
/// defaults while it is Japanese (#432). The frames stay in English.
/// defaults while it is Japanese (#432). A Japanese frame draws in Japanese on this test's thread
/// only: the tests running beside it on other threads still draw in English.
#[test]
fn the_engine_follows_the_interface_language() {
let mut app = crate::VectorcraftApp::new(vectorcraft_engine::Session::new(), crate::Services::default());
@@ -220,14 +221,19 @@ fn the_engine_follows_the_interface_language() {
frame(&mut app);
assert_eq!(app.session.ui_language.as_deref(), Some("en"), "tests resolve `auto` to English");
assert!(!app.session.japanese_interface());
// Each frame hands the engine the language it draws in, whatever the engine had.
app.session.ui_language = Some("ja".into());
app.session.prefs.interface_language = "ja".into();
frame(&mut app);
assert_eq!(app.session.ui_language.as_deref(), Some("ja"));
assert!(app.session.japanese_interface());
assert_eq!(current().code(), "ja");
// A test running beside this one on another thread still draws in English.
assert_eq!(std::thread::spawn(|| (current(), t("Layers"))).join().unwrap(), (Lang::EN, "Layers"));
// With the preference back on `auto`, the next frame hands the engine `en` again.
app.session.prefs.interface_language = "auto".into();
frame(&mut app);
assert_eq!(app.session.ui_language.as_deref(), Some("en"));
// The language a frame would draw in follows the preference.
app.session.prefs.interface_language = "ja".into();
assert_eq!(app.ui_language().code(), "ja");
assert!(!app.session.japanese_interface());
assert_eq!(current(), Lang::EN);
}
/// `app.language` sets the `interfaceLanguage` preference, which is what persists; the checked