mirror of
https://github.com/storytold/pdfcraft.git
synced 2026-12-01 02:36:02 +01:00
Exercise protected document controls and localized prompts after layout settles
This commit is contained in:
1 parent
1dfd996c5c
commit
04bf3e7e25
2 files changed
+24
-11
No files matched your search
@@ -2803,7 +2803,8 @@ fn the_security_notice_wraps_beside_its_buttons_and_lines_up_with_them() {
|
||||
}
|
||||
}
|
||||
// Wide: one line. Narrower: wrapped. Narrowest: actions stack below the message.
|
||||
for (width, wraps) in [(1700.0, false), (1600.0, true), (1250.0, false), (900.0, false)] {
|
||||
let (mut single, mut wrapped, mut stacked) = (false, false, false);
|
||||
for width in [1800.0, 1650.0, 1550.0, 1500.0, 1450.0, 1400.0, 1350.0, 1300.0, 1250.0, 900.0] {
|
||||
let mut h = Harness::builder().with_size(egui::vec2(width, 800.0)).build_eframe(|cc| {
|
||||
crate::support::install_runtime(&cc.egui_ctx);
|
||||
{
|
||||
@@ -2819,8 +2820,9 @@ fn the_security_notice_wraps_beside_its_buttons_and_lines_up_with_them() {
|
||||
h.output().shapes.iter().find_map(|shape| message_rect(&shape.shape)).expect("the security message is painted");
|
||||
let button = h.get_by_label("Security settings").rect();
|
||||
let dismiss = h.get_by_label("Dismiss").rect();
|
||||
if width <= 1250.0 {
|
||||
assert!(button.top() >= msg.bottom(), "{width}: stacked actions stay below the message: {msg:?} vs {button:?}");
|
||||
if button.top() >= msg.bottom() {
|
||||
stacked = true;
|
||||
assert!(dismiss.top() >= msg.bottom(), "{width}: stacked actions stay below the message: {msg:?} vs {button:?}");
|
||||
assert!(!button.intersects(dismiss), "{width}: the actions stay apart: {button:?} vs {dismiss:?}");
|
||||
continue;
|
||||
}
|
||||
@@ -2830,8 +2832,13 @@ fn the_security_notice_wraps_beside_its_buttons_and_lines_up_with_them() {
|
||||
assert!(msg.top() >= button.top(), "{width}: the message stays inside the bar: {msg:?} vs {button:?}");
|
||||
let first_line = msg.top() + first_line_offset;
|
||||
assert!((first_line - button.center().y).abs() <= 1.5, "{width}: first line centred on the buttons: {msg:?} vs {button:?}");
|
||||
assert_eq!(msg.height() > button.height(), wraps, "{width}: {msg:?}");
|
||||
if msg.height() > button.height() {
|
||||
wrapped = true;
|
||||
} else {
|
||||
single = true;
|
||||
}
|
||||
}
|
||||
assert!(single && wrapped && stacked, "the notice handles single-line, wrapped and stacked layouts");
|
||||
}
|
||||
|
||||
/// #995, #1077: a file with only a permissions password opens without asking, restricted. Its
|
||||
@@ -4920,14 +4927,17 @@ fn page_context_menu_items_disabled_on_protected_pdf() {
|
||||
assert!(!doc.allows_assembly());
|
||||
assert!(!doc.allows_annotation());
|
||||
|
||||
let r = h.state().views[0].page_screen_rect(0).expect("on screen");
|
||||
let c = r.center();
|
||||
// Right click on page in Select mode
|
||||
h.hover_at(c);
|
||||
let view = &h.state().views[0];
|
||||
let visible_page = view.page_screen_rect(0).expect("on screen").intersect(view.viewport_rect());
|
||||
assert!(visible_page.is_positive());
|
||||
let at = visible_page.center();
|
||||
h.hover_at(at);
|
||||
h.run_steps(1);
|
||||
h.event(egui::Event::PointerButton { pos: c, button: egui::PointerButton::Secondary, pressed: true, modifiers: Default::default() });
|
||||
h.event(egui::Event::PointerButton { pos: c, button: egui::PointerButton::Secondary, pressed: false, modifiers: Default::default() });
|
||||
h.run_steps(2);
|
||||
h.event(egui::Event::PointerButton { pos: at, button: egui::PointerButton::Secondary, pressed: true, modifiers: Default::default() });
|
||||
h.run_steps(1);
|
||||
h.event(egui::Event::PointerButton { pos: at, button: egui::PointerButton::Secondary, pressed: false, modifiers: Default::default() });
|
||||
h.run_steps(3);
|
||||
h.get_by_label("Take a snapshot");
|
||||
|
||||
let is_disabled =
|
||||
|h: &mut Harness<'static, PdfCraftApp>, label: &str| h.query_by(|n| n.label().as_deref() == Some(label) && n.is_disabled()).is_some();
|
||||
|
||||
@@ -386,6 +386,9 @@ fn native_script_prompt_uses_the_german_catalog_when_available() {
|
||||
assert_eq!(tr(german, source), heading);
|
||||
let mut h = harness();
|
||||
h.set_option("language", "de").unwrap();
|
||||
// The translated tools change the fitted page width. A script started before that layout
|
||||
// settles would correctly be discarded when its recorded page zoom becomes stale.
|
||||
h.run_steps(5);
|
||||
let id = h.state().active_ids().unwrap().1;
|
||||
h.run_button_script(id, "hello", "app.response({cQuestion:'Test',bPassword:true});");
|
||||
wait_for_prompt(&mut h, heading, |h| h.query_by_role_and_label(egui::accesskit::Role::Dialog, heading).is_some());
|
||||
|
||||
Reference in new issue
Block a user