mirror of
https://github.com/storytold/designcraft.git
synced 2026-12-02 20:21:15 -05:00
Merge pull request #2777
This commit is contained in:
commit
82fff1f0cb
1 file changed
+66
@@ -3303,3 +3303,69 @@ fn document_setup_sends_the_binding_it_holds() {
|
||||
assert_eq!(sent["binding"].as_str(), Some("rightToLeft"), "payload: {sent}");
|
||||
assert!(app.session.active().unwrap().doc.settings.right_to_left_binding, "the document takes it");
|
||||
}
|
||||
|
||||
/// The number fields of Insert Table and of Paragraph Style Options' sections are named from the
|
||||
/// captions beside them, not from their internal keys; each name listed is found exactly once.
|
||||
#[test]
|
||||
fn dialog_number_fields_are_named_from_their_captions() {
|
||||
use super::table_layout_kit as kit;
|
||||
use egui::accesskit::Role;
|
||||
use egui_kittest::kittest::Queryable;
|
||||
let para = |section: &str, extra: Value| {
|
||||
let mut fields = json!({"name": designcraft_doc::story::BASIC_PARAGRAPH, "section": section});
|
||||
if let (Some(f), Value::Object(extra)) = (fields.as_object_mut(), extra) {
|
||||
f.extend(extra);
|
||||
}
|
||||
Dialog::new("paragraphStyleOptions", fields)
|
||||
};
|
||||
let cases: Vec<(Dialog, &[&str])> = vec![
|
||||
(Dialog::new("insertTable", Value::Null), &["Body Rows:", "Columns:", "Header Rows:", "Footer Rows:"]),
|
||||
(para("chars", json!({})), &["Size:", "Leading:", "Tracking:"]),
|
||||
(para("advanced", json!({})), &["Horizontal Scale:", "Vertical Scale:", "Baseline Shift:", "Skew:"]),
|
||||
(para("indents", json!({})), &["Left Indent:", "First Line Indent:", "Right Indent:", "Space Before:", "Space After:"]),
|
||||
(para("tabs", json!({})), &["X:"]),
|
||||
(para("rules", json!({})), &["Weight:", "Tint:", "Gap Tint:", "Offset:", "Left Indent:", "Right Indent:"]),
|
||||
(para("border", json!({})), &["Tint:", "Gap Tint:", "Top Left Corner", "Bottom Right Corner"]),
|
||||
(para("shading", json!({})), &["Tint:", "Top Left Corner"]),
|
||||
(para("keep", json!({})), &["Keep with Next:", "Start:", "End:"]),
|
||||
(para("hyph", json!({})), &["Words with at Least:", "After First:", "Before Last:", "Hyphen Limit:", "Hyphenation Zone:"]),
|
||||
(para("justify", json!({})), &["Auto Leading:"]),
|
||||
(para("nested", json!({})), &["Lines:", "Characters:"]),
|
||||
(
|
||||
para("bullets", json!({"p.listType": "numbers", "p.startAt": 1, "p.listTab": 18})),
|
||||
&["Level:", "Start At", "Left Indent:", "First Line Indent:", "Tab Position:"],
|
||||
),
|
||||
(para("color", json!({})), &["Tint:", "Weight:"]),
|
||||
(para("underline", json!({})), &["Weight:", "Offset:", "Tint:"]),
|
||||
];
|
||||
for (dialog, names) in cases {
|
||||
let what = format!("{} {}", dialog.id, dialog.s("section"));
|
||||
let mut app = kit::app(1, false);
|
||||
app.ui.dialog = Some(dialog);
|
||||
let h = kit::harness_sized(app, egui::vec2(1400.0, 1000.0));
|
||||
for name in names {
|
||||
let count = h.query_all_by_role_and_label(Role::SpinButton, name).count() + h.query_all_by_role_and_label(Role::TextInput, name).count();
|
||||
assert_eq!(count, 1, "{what}: the {name} field");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// In a Chinese interface the number fields are named from the Chinese captions beside them.
|
||||
#[test]
|
||||
fn dialog_number_fields_are_named_from_translated_captions() {
|
||||
use super::table_layout_kit as kit;
|
||||
use egui::accesskit::Role;
|
||||
use egui_kittest::kittest::Queryable;
|
||||
let cases: [(&str, &[&str]); 2] = [("chars", &["Size:", "Leading:", "Tracking:"]), ("advanced", &["Baseline Shift:", "Skew:"])];
|
||||
for (section, captions) in cases {
|
||||
let mut app = kit::app(1, false);
|
||||
app.ui.language = "zh".into();
|
||||
app.ui.dialog = Some(Dialog::new("paragraphStyleOptions", json!({"name": designcraft_doc::story::BASIC_PARAGRAPH, "section": section})));
|
||||
let h = kit::harness_sized(app, egui::vec2(1400.0, 1000.0));
|
||||
for caption in captions {
|
||||
let name = crate::i18n::tr("zh", caption);
|
||||
assert_ne!(name, *caption, "the catalog has a Chinese row for {caption}");
|
||||
assert_eq!(h.query_all_by_role_and_label(Role::SpinButton, name).count(), 1, "{section}: the {name} field");
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user