forge
Explore
Log in

Don't you dare go Hollow

edith

Clone
★ 0

0 watching0 forksRust18.3 MiBff99ad6Tahinli6 days ago1055 commits

medfix.rs34 lines, 1.2 KiBHistoryRawDownload
1//! The Media tab's missing-file, menu and filter rules.
2
3use crate::menus::RowItem;
4use crate::oracle::{Enable, RowCtx, row_enable, row_items};
5
6fn ctx() -> RowCtx {
7 RowCtx { timeline: true, usable: true, ..RowCtx::default() }
8}
9
10#[test]
11fn a_missing_file_can_only_be_relinked() {
12 let gone = RowCtx { offline: true, ..ctx() };
13 assert!(row_enable(RowItem::Relink, gone).yes());
14 for item in [RowItem::Add, RowItem::Preview, RowItem::Proxy] {
15 assert_eq!(row_enable(item, gone), Enable::No("the file is missing"));
16 }
17 assert!(row_items(gone).contains(&RowItem::Relink));
18 assert!(!row_items(ctx()).contains(&RowItem::Relink));
19}
20
21#[test]
22fn a_refused_remove_says_why_in_plain_words() {
23 let used = RowCtx { placed: 1, ..ctx() };
24 assert_eq!(row_enable(RowItem::Remove, used), Enable::No("It's used on the timeline"));
25}
26
27#[test]
28fn the_type_filter_tells_video_audio_and_images_apart() {
29 let ext = |name: &str| std::path::PathBuf::from(name);
30 assert!(crate::ui::dock_stance::kind_matches(1, &ext("a.mp4")));
31 assert!(crate::ui::dock_stance::kind_matches(2, &ext("a.wav")));
32 assert!(crate::ui::dock_stance::kind_matches(3, &ext("a.png")));
33 assert!(!crate::ui::dock_stance::kind_matches(1, &ext("a.png")));
34}