forge
Explore
Log in

Don't you dare go Hollow

edith

Clone
★ 0

0 watching0 forksRust18.3 MiBff99ad6Tahinli6 days ago1055 commits

fixes1.rs83 lines, 4.2 KiBHistoryRawDownload
1//! Regressions from the UX bug batch: the export range keys, the seam click, scrubs released
2//! outside the window, the zoomed picture's rectangle, plain menu words, the New project dialog.
3
4use crate::keymap::ActionId;
5use crate::player::project_dialogs::project_file_name;
6use crate::viewer_view::{Zoom, picture_rect};
7use gpui::{Pixels, Point, point, px};
8
9/// The Export tab is up while the range is marked: I and O must still reach the timeline.
10#[test]
11fn the_export_tab_lets_the_range_marks_through() {
12 let km = crate::keymap::Keymap::defaults();
13 for key in ["i", "o"] {
14 let action = km.lookup(key, false, false, false).expect("a mark key");
15 assert!(crate::ui::stance::export_tab_action(action), "{key} is swallowed by the Export tab");
16 }
17 assert!(crate::ui::stance::export_tab_action(ActionId::ClearRange));
18 // Editing strokes stay the room's, not the tab's.
19 assert!(!crate::ui::stance::export_tab_action(ActionId::Delete));
20}
21
22/// A press on a seam that never moves is a click: it changes nothing and saves nothing.
23#[test]
24fn a_seam_click_without_travel_is_not_a_drag() {
25 use crate::player::timeline_edit::split_travelled;
26 let at = |x: f32, y: f32| -> Point<Pixels> { point(px(x), px(y)) };
27 assert!(!split_travelled(at(500., 400.), at(500., 400.)));
28 assert!(!split_travelled(at(500., 400.), at(501., 402.)));
29 assert!(split_travelled(at(500., 400.), at(500., 410.)));
30}
31
32/// A number being scrubbed is committed when the pointer leaves the window, because its
33/// release is never delivered there.
34#[test]
35fn leaving_the_window_commits_the_scrubs() {
36 let src = include_str!("../player/timeline_edit.rs");
37 let at = src.find("pub(crate) fn drag_left_window").expect("the leave handler");
38 let body = &src[at..at + src[at..].find("\n }\n").unwrap()];
39 assert!(body.contains("pan_scrub_end"), "a pan scrub dropped on leave");
40 assert!(body.contains("title_scrub_end"), "a title scrub dropped on leave");
41}
42
43/// Titles and captions are placed against the picture as drawn: zoomed it is the zoomed rectangle.
44#[test]
45fn the_zoomed_picture_has_its_own_rectangle() {
46 let native = (1920., 1080.);
47 let bx = (800., 450.);
48 // Fit: the frame letterboxed into the box, centred.
49 assert_eq!(picture_rect(Zoom::Fit, native, bx, (0., 0.), (0., 0.), 1.), (0., 0., 800., 450.));
50 // 50%: 960x540 in an 800x450 box, centred, so it overhangs by 80 and 45 on each side.
51 assert_eq!(picture_rect(Zoom::P50, native, bx, (0., 0.), (0., 0.), 1.), (-80., -45., 960., 540.));
52 // Panned: moved by the pan, held inside the overhang.
53 assert_eq!(picture_rect(Zoom::P50, native, bx, (0., 0.), (30., 0.), 1.), (-50., -45., 960., 540.));
54 assert_eq!(picture_rect(Zoom::P50, native, bx, (0., 0.), (500., 0.), 1.).0, 0.);
55 // 25%: smaller than the box, centred.
56 assert_eq!(picture_rect(Zoom::P25, native, bx, (0., 0.), (0., 0.), 1.), (160., 90., 480., 270.));
57 // Neither the titles nor the captions are dropped while zoomed any more.
58 let render = include_str!("../render.rs");
59 assert!(!render.contains("== crate::viewer_view::Zoom::Fit))"), "an overlay is hidden while zoomed");
60}
61
62/// The clip menu reads plainly, and Trim out has its icon like Trim in.
63#[test]
64fn the_clip_menu_words_are_plain_and_trim_out_has_an_icon() {
65 assert_eq!(ActionId::Detach.label(), "Unlink audio and video");
66 assert_eq!(ActionId::Regroup.label(), "Join clips back");
67 assert!(crate::menus::note(ActionId::Detach).is_some(), "Unlink says what it does on hover");
68 assert!(crate::menus::icon(ActionId::TrimOut).is_some());
69 assert!(crate::menus::icon(ActionId::TrimIn).is_some());
70 for action in crate::menus::MENU_ITEMS {
71 let label = action.label();
72 assert!(!label.contains("group") && !label.contains("Group") || action == ActionId::Group, "{label}");
73 }
74}
75
76#[test]
77fn a_typed_project_name_makes_a_safe_file_name() {
78 assert_eq!(project_file_name("Trip"), Some("Trip.edith".into()));
79 assert_eq!(project_file_name(" Trip.edith "), Some("Trip.edith".into()));
80 assert_eq!(project_file_name("a/b"), Some("a-b.edith".into()));
81 assert_eq!(project_file_name(" "), None);
82 assert_eq!(project_file_name(".."), None);
83}