Compare commits

...
2 changed files with 37 additions and 1 deletions
+4 -1
View File
@@ -129,6 +129,8 @@ struct Strings {
numeral_id: String,
proofing_language: String,
autosave_reason: String,
/// The Initials box's placeholder: the initials an empty box falls back to (#8018).
initials_hint: String,
}
impl Strings {
@@ -199,6 +201,7 @@ impl Strings {
numeral_id,
proofing_language,
autosave_reason: crate::AutoSaveBlock::Browser.reason().to_string(),
initials_hint: app.session.user_initials(),
}
}
}
@@ -357,7 +360,7 @@ impl PreferencesModel for OptionsModel<'_> {
Some(tl!("Personalize")),
vec![
RowSpec::new("general.userName", tl!("User name:"), RowKind::Text(&app.session.author)).enabled(!protected),
RowSpec::new("general.initials", tl!("Initials:"), RowKind::Text(&app.session.initials)),
RowSpec::new("general.initials", tl!("Initials:"), RowKind::Text(&app.session.initials)).placeholder(&s.initials_hint),
],
),
],
+33
View File
@@ -539,3 +539,36 @@ fn folder_settings_have_apply_and_clear() {
}
let _ = std::fs::remove_dir_all(&dir);
}
/// #8018: an empty Initials box paints the initials it falls back to.
#[test]
fn empty_initials_box_paints_the_default_initials() {
fn painted(shapes: &[egui::epaint::ClippedShape], out: &mut Vec<String>) {
fn walk(shape: &egui::Shape, out: &mut Vec<String>) {
match shape {
egui::Shape::Text(t) => out.push(t.galley.text().to_string()),
egui::Shape::Vec(v) => v.iter().for_each(|c| walk(c, out)),
_ => {}
}
}
shapes.iter().for_each(|c| walk(&c.shape, out));
}
let shown = || {
let mut a = app();
a.session.author = "Zora Quentin".into();
a.run("ui.backstage", json!({"value": true, "page": "options", "pane": "general"})).unwrap();
let mut h = crate::test_harness::builder().build_ui_state(
|ui, app: &mut WordApp| {
let ctx = ui.ctx().clone();
app.logic(&ctx);
app.ui(ui);
},
a,
);
options_frames(&mut h, 3);
let mut texts = Vec::new();
painted(&h.output().shapes, &mut texts);
texts
};
assert!(shown().iter().any(|t| t == "ZQ"), "empty box paints the default initials");
}