Skip to content

PdfCraft: An open-source PDF reader and editor written by scratch in pure Rust

test(forms): type export values through the properties widget

FredApps0e8d4d70fabb
diff --git a/crates/ui-egui/tests/prepare.rs b/crates/ui-egui/tests/prepare.rs
index 81359d8bc..896eeff19 100644
--- a/crates/ui-egui/tests/prepare.rs
+++ b/crates/ui-egui/tests/prepare.rs
@@ -500,6 +500,14 @@ fn actions_tab_adds_and_removes_actions() {
#[test]
fn button_export_properties_apply_cancel_and_undo() {
+ fn retype(h: &mut Harness<'static, PdfCraftApp>, value: &str) {
+ use egui::accesskit::Role;
+ h.get_by_role_and_label(Role::TextInput, "Export Value: ").click();
+ h.run_steps(1);
+ h.key_press_modifiers(egui::Modifiers::COMMAND, egui::Key::A);
+ h.get_by_role_and_label(Role::TextInput, "Export Value: ").type_text(value);
+ h.run_steps(2);
+ }
let mut h = harness();
h.state_mut().execute("form.prepare");
h.run_steps(2);
@@ -508,13 +516,15 @@ fn button_export_properties_apply_cancel_and_undo() {
h.get_by_label("Options").click();
h.run_steps(2);
let original = h.state().field_props.as_ref().unwrap().export_value.clone();
- h.state_mut().field_props.as_mut().unwrap().export_value = "Accepted".into();
+ retype(&mut h, "Accepted");
h.get_by_label("Cancel").click();
h.run_steps(2);
h.state_mut().open_field_props("agree", 0);
h.run_steps(2);
assert_eq!(h.state().field_props.as_ref().unwrap().export_value, original);
- h.state_mut().field_props.as_mut().unwrap().export_value = "Accepted".into();
+ h.get_by_label("Options").click();
+ h.run_steps(2);
+ retype(&mut h, "Accepted");
h.get_by_label("OK").click();
h.run_steps(3);
{