mirror of
https://github.com/storytold/pdfcraft.git
synced 2026-11-26 03:49:11 +00:00
Merge branch 'regress/rest' into area/app-1
This commit is contained in:
@@ -458,7 +458,9 @@ fn frame_shapes(h: &Rig) -> Vec<&egui::Shape> {
|
||||
/// The picture of the preview pane: the largest uploaded texture painted over the pager, the pane being
|
||||
/// the pager's neighbour above.
|
||||
fn preview_picture(h: &Rig) -> Option<Picture> {
|
||||
let pager_rect = h.query_by(is_pager)?.rect();
|
||||
let caption = h.query_by(is_pager)?;
|
||||
let row = caption.parent()?;
|
||||
let pager_rect = caption.rect().union(row.query_by_label("Previous")?.rect()).union(row.query_by_label("Next")?.rect());
|
||||
let uploads = h.uploads.0.lock().unwrap();
|
||||
frame_shapes(h)
|
||||
.into_iter()
|
||||
|
||||
@@ -335,7 +335,8 @@ fn edit_text_over_a_linked_word_offers_the_move_arrow() {
|
||||
|
||||
#[test]
|
||||
fn select_tool_over_a_comment_on_text_offers_the_move_arrow() {
|
||||
let mut h = open(comment_on_text_pdf(), "150", false);
|
||||
// Keep the text clear of the floating quick toolbar.
|
||||
let mut h = open(comment_on_text_pdf(), "100", false);
|
||||
// Inside the rectangle where there is no text, and inside it over a word.
|
||||
let blank = at(&h, 120.0, 315.0);
|
||||
let on_text = at(&h, 60.0, 303.0);
|
||||
@@ -429,7 +430,8 @@ fn a_click_on_stacked_comments_selects_the_one_drawn_on_top() {
|
||||
|
||||
#[test]
|
||||
fn a_comments_tip_shows_with_every_tool_beside_its_cursor() {
|
||||
let mut h = open(comment_on_text_pdf(), "150", false);
|
||||
// Keep the text clear of the floating quick toolbar.
|
||||
let mut h = open(comment_on_text_pdf(), "100", false);
|
||||
// Inside the rectangle comment by "Reviewer": where there is no text, and over a word.
|
||||
let (blank, on_text) = (at(&h, 120.0, 315.0), at(&h, 60.0, 303.0));
|
||||
let hover = |h: &mut Harness<'static, PdfCraftApp>, tool: QuickTool, p: egui::Pos2, want: egui::CursorIcon| {
|
||||
@@ -1449,7 +1451,8 @@ fn with_prepare_a_drag_from_a_highlight_draws_the_selection_rectangle() {
|
||||
/// is the one selected, and leaves the selection as it is.
|
||||
#[test]
|
||||
fn a_right_click_with_the_button_held_opens_the_selected_comments_menu() {
|
||||
let mut h = open(comment_on_text_pdf(), "150", false);
|
||||
// Keep the drag clear of the floating quick toolbar.
|
||||
let mut h = open(comment_on_text_pdf(), "100", false);
|
||||
// On the rectangle's left edge: an unfilled one takes a press on its border.
|
||||
let edge = at(&h, 30.0, 303.0);
|
||||
wait_for_cursor(&mut h, edge, |c| c != egui::CursorIcon::Default);
|
||||
|
||||
@@ -73,6 +73,11 @@ fn app_on(clipboard: RecordingClipboard) -> PdfCraftApp {
|
||||
crate::support::app_with_clipboard(clipboard)
|
||||
}
|
||||
|
||||
// Keep the word under test clear of the floating quick toolbar.
|
||||
fn readable_zoom(app: &mut PdfCraftApp) {
|
||||
app.set_option(&egui::Context::default(), "zoom", "100%").unwrap();
|
||||
}
|
||||
|
||||
/// What Copy with formatting wrote to the clipboard: `(html, plain text)` per write that had HTML.
|
||||
fn html_sets(clipboard: &RecordingClipboard) -> Vec<(String, String)> {
|
||||
// PLAN: assumed RecordingClipboard::writes() -> Vec<Vec<Flavor>> recording every attempt, with `mime` and `data`.
|
||||
@@ -184,7 +189,7 @@ fn copied(clipboard: &RecordingClipboard, want: &str) -> bool {
|
||||
fn selected_text_copy_edit_and_context_menus() {
|
||||
use egui_kittest::kittest::Queryable;
|
||||
let clipboard = RecordingClipboard::default();
|
||||
let (mut h, at) = harness_clip(two_lines(), clipboard.clone(), |_| {});
|
||||
let (mut h, at) = harness_clip(two_lines(), clipboard.clone(), readable_zoom);
|
||||
click(&mut h, at);
|
||||
click(&mut h, at);
|
||||
h.state_mut().quick_tool = pdfcraft_ui_egui::QuickTool::Hand;
|
||||
@@ -215,7 +220,7 @@ fn selected_text_copy_edit_and_context_menus() {
|
||||
#[test]
|
||||
fn selected_text_copy_command_requires_selection() {
|
||||
let clipboard = RecordingClipboard::default();
|
||||
let (mut h, at) = harness_clip(two_lines(), clipboard.clone(), |_| {});
|
||||
let (mut h, at) = harness_clip(two_lines(), clipboard.clone(), readable_zoom);
|
||||
assert!(!h.execute("edit.copy"));
|
||||
click(&mut h, at);
|
||||
click(&mut h, at);
|
||||
@@ -285,7 +290,7 @@ fn any_copy_text(h: &Harness<'static, PdfCraftApp>) -> bool {
|
||||
#[test]
|
||||
fn selected_text_copy_keeps_the_formatting_as_html() {
|
||||
let clipboard = RecordingClipboard::default();
|
||||
let (mut h, at) = harness_clip(two_lines(), clipboard.clone(), |_| {});
|
||||
let (mut h, at) = harness_clip(two_lines(), clipboard.clone(), readable_zoom);
|
||||
click(&mut h, at);
|
||||
click(&mut h, at);
|
||||
assert!(h.execute("edit.copy"));
|
||||
@@ -311,7 +316,7 @@ fn selected_text_copy_keeps_the_formatting_as_html() {
|
||||
fn selected_text_copy_falls_back_to_plain_text_when_html_is_refused() {
|
||||
// PLAN: assumed RecordingClipboard::refusing(mime) refuses a write that has that flavour, and records the attempt.
|
||||
let clipboard = RecordingClipboard::refusing("text/html");
|
||||
let (mut h, at) = harness_clip(two_lines(), clipboard.clone(), |_| {});
|
||||
let (mut h, at) = harness_clip(two_lines(), clipboard.clone(), readable_zoom);
|
||||
click(&mut h, at);
|
||||
click(&mut h, at);
|
||||
assert!(h.execute("edit.copy"));
|
||||
@@ -335,7 +340,12 @@ fn selected_text_copy_with_formatting_honours_permissions() {
|
||||
.unwrap();
|
||||
let bytes = pdfcraft_cos::write_full(&doc, &Default::default()).unwrap();
|
||||
let clipboard = RecordingClipboard::default();
|
||||
let (mut h, at) = harness_clip(bytes, clipboard.clone(), |app| app.submit_password(&egui::Context::default(), Some("pw".into())));
|
||||
let (mut h, _) = harness_clip(bytes, clipboard.clone(), |app| app.submit_password(&egui::Context::default(), Some("pw".into())));
|
||||
h.set_option("zoom", "100%").unwrap();
|
||||
h.run_steps(2);
|
||||
let at = h.state().views[0].glyph_screen_pos(0, 5).expect("text layer loaded");
|
||||
h.hover_at(at);
|
||||
h.run_steps(1);
|
||||
click(&mut h, at);
|
||||
click(&mut h, at);
|
||||
assert_eq!(h.state().views[0].selected_text().as_deref(), Some("quick"));
|
||||
|
||||
@@ -1748,7 +1748,7 @@ fn required_fields_get_a_red_border_when_highlighting() {
|
||||
let at = egui::pos2(r.min.x + r.width() * (50.0 / 300.0) + 0.75, r.min.y + r.height() * (1.0 - 315.0 / 400.0));
|
||||
let img = h.render().expect("renders");
|
||||
let px = *img.get_pixel((at.x * ppp) as u32, (at.y * ppp) as u32);
|
||||
let theme = craft::theme::builtins().iter().find(|theme| theme.id.as_str() == craft::theme::SUITE_DEFAULT).unwrap();
|
||||
let theme = craft::theme::builtins().iter().find(|theme| theme.id.as_str() == "craft.graphite").unwrap();
|
||||
let appearance = craft::theme::Appearance {
|
||||
mode: craft::theme::Mode::Light,
|
||||
contrast: craft::theme::Contrast::Standard,
|
||||
|
||||
@@ -2088,7 +2088,9 @@ fn a_short_page_gone_to_from_the_pages_panel_stays_current() {
|
||||
|
||||
#[test]
|
||||
fn pages_panel_thumbnails_have_a_context_menu() {
|
||||
let mut h = pages_panel_harness(&[(200, 300); 4]);
|
||||
// Landscape thumbnails leave the third page in view at comfortable density.
|
||||
let mut h = pages_panel_harness(&[(300, 200); 4]);
|
||||
assert!(in_panel_view(&h, thumbnail_rect(&h, 3)), "page 3 is reachable before right-clicking it");
|
||||
let at = thumbnail(&h, "Page 3");
|
||||
press(&mut h, at, egui::PointerButton::Secondary);
|
||||
h.run_steps(2);
|
||||
|
||||
Reference in New Issue
Block a user