Panics · P27 Files: gone owner picks replace local ones and mark none, stale path folders go unmarked, duplicate marks never take a last copy
This commit is contained in:
1 parent
922cd53a8c
commit
c9b4a04a4f
11 files changed
+192
-86
No files matched your search
@@ -168,13 +168,6 @@ fn each_folder_on_the_path_is_listed() {
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[should_panic(expected = "no entry Ghost.md")]
|
||||
fn the_pick_is_in_the_folder_shown() {
|
||||
let here = vec![DirEntry::file("Brief.md", 10, then())];
|
||||
let _ = FileExplorer::new("explorer", ["Home"], [here], FileView::List).selected("Ghost.md");
|
||||
}
|
||||
|
||||
/// An explorer that goes where it is sent, over a small tree, and the files it opened.
|
||||
struct Walking {
|
||||
path: Vec<SharedString>,
|
||||
@@ -242,15 +235,3 @@ fn a_new_folder_at_a_depth_starts_its_column_fresh(cx: &mut TestAppContext) {
|
||||
["Contract.docx"]
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[should_panic(expected = "Projects is no folder in Home")]
|
||||
fn each_folder_on_the_path_is_listed_in_its_parent() {
|
||||
let root = vec![DirEntry::file("Projects", 10, then())];
|
||||
let _ = FileExplorer::new(
|
||||
"explorer",
|
||||
["Home", "Projects"],
|
||||
[root, Vec::new()],
|
||||
FileView::List,
|
||||
);
|
||||
}
|
||||
@@ -255,17 +255,6 @@ fn the_last_copy_stays_and_remove_takes_the_marked(cx: &mut TestAppContext) {
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[should_panic(expected = "every copy of a.jpg is marked")]
|
||||
fn a_group_keeps_a_copy() {
|
||||
let group = Duplicates {
|
||||
name: "a.jpg".into(),
|
||||
size: 1,
|
||||
paths: vec!["x".into(), "y".into()],
|
||||
};
|
||||
let _ = DuplicateFinder::new("dupes", [group]).marked(["x", "y"]);
|
||||
}
|
||||
|
||||
/// An archive of four files in two folders, and the files it handed over.
|
||||
struct Unpacking {
|
||||
opened: Vec<SharedString>,
|
||||
|
||||
+15
-6
@@ -9,6 +9,7 @@ use crate::{lists::DirEntry, primitives::FocusNext, theme::Theme};
|
||||
|
||||
mod explorer;
|
||||
mod find;
|
||||
mod stale;
|
||||
mod transfers;
|
||||
|
||||
pub(super) fn setup(cx: &mut TestAppContext) {
|
||||
@@ -113,6 +114,20 @@ fn the_arrows_move_by_tile_and_by_row_and_enter_opens(cx: &mut TestAppContext) {
|
||||
assert_eq!(opened, ["g"]);
|
||||
}
|
||||
|
||||
#[gpui::test]
|
||||
fn an_owner_pick_gone_from_the_grid_replaces_the_local_one(cx: &mut TestAppContext) {
|
||||
let (view, cx) = tiled(None, cx);
|
||||
cx.update(|window, cx| window.focus_next(cx));
|
||||
press("right", cx);
|
||||
view.update(cx, |view, cx| {
|
||||
view.selected = Some("Ghost.md".into());
|
||||
cx.notify();
|
||||
});
|
||||
settle(cx);
|
||||
press("enter", cx);
|
||||
assert_eq!(heard(&view, cx).1, Vec::<SharedString>::new());
|
||||
}
|
||||
|
||||
#[gpui::test]
|
||||
fn the_keys_start_from_the_tile_picked(cx: &mut TestAppContext) {
|
||||
let (view, cx) = tiled(Some("c"), cx);
|
||||
@@ -155,12 +170,6 @@ fn a_name_is_listed_once() {
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[should_panic(expected = "no entry z")]
|
||||
fn the_pick_is_one_of_the_entries() {
|
||||
let _ = FileGrid::new("grid", [DirEntry::file("a", 1, then())]).selected("z");
|
||||
}
|
||||
|
||||
/// One tile whose name runs long.
|
||||
struct Named;
|
||||
|
||||
|
||||
@@ -0,0 +1,115 @@
|
||||
use gpui::{
|
||||
Context, IntoElement, Modifiers, ParentElement, Render, Styled, TestAppContext, Window, div,
|
||||
point, px,
|
||||
};
|
||||
|
||||
use super::{settle, setup, then};
|
||||
use crate::{
|
||||
files::{
|
||||
FileExplorer, FileGrid, FileOperation, FileOperationProgress, FileView, TransferState,
|
||||
},
|
||||
lists::DirEntry,
|
||||
};
|
||||
|
||||
/// A path its folders no longer hold, gone picks, and bytes past their total.
|
||||
struct Lagging;
|
||||
|
||||
impl Render for Lagging {
|
||||
fn render(&mut self, _: &mut Window, _: &mut Context<Self>) -> impl IntoElement {
|
||||
let root = vec![DirEntry::file("Projects", 10, then())];
|
||||
let here = vec![DirEntry::file("Brief.md", 10, then())];
|
||||
div()
|
||||
.w(px(640.0))
|
||||
.h(px(480.0))
|
||||
.child(
|
||||
FileExplorer::new(
|
||||
"explorer",
|
||||
["Home", "Projects"],
|
||||
[root, here.clone()],
|
||||
FileView::List,
|
||||
)
|
||||
.selected("Ghost.md"),
|
||||
)
|
||||
.child(FileGrid::new("grid", here).selected("Ghost.md"))
|
||||
.child(FileOperationProgress::new(
|
||||
"copy",
|
||||
FileOperation::Copy,
|
||||
3,
|
||||
"Backup",
|
||||
(12, 10),
|
||||
TransferState::Moving { rate: 4 },
|
||||
))
|
||||
}
|
||||
}
|
||||
|
||||
#[gpui::test]
|
||||
fn stale_paths_picks_and_overruns_draw(cx: &mut TestAppContext) {
|
||||
setup(cx);
|
||||
let (_, cx) = cx.add_window_view(|_, _| Lagging);
|
||||
settle(cx);
|
||||
}
|
||||
|
||||
/// Columns down a path whose folder became a file of the same name.
|
||||
struct Replaced;
|
||||
|
||||
impl Render for Replaced {
|
||||
fn render(&mut self, _: &mut Window, _: &mut Context<Self>) -> impl IntoElement {
|
||||
let root = vec![DirEntry::file("Projects", 10, then())];
|
||||
let here = vec![DirEntry::file("Brief.md", 10, then())];
|
||||
div().w(px(640.0)).h(px(480.0)).child(FileExplorer::new(
|
||||
"explorer",
|
||||
["Home", "Projects"],
|
||||
[root, here],
|
||||
FileView::Columns,
|
||||
))
|
||||
}
|
||||
}
|
||||
|
||||
#[gpui::test]
|
||||
fn a_file_where_a_path_folder_stood_is_not_marked(cx: &mut TestAppContext) {
|
||||
setup(cx);
|
||||
let (_, cx) = cx.add_window_view(|_, _| Replaced);
|
||||
settle(cx);
|
||||
assert!(cx.debug_bounds("item-selected-Projects").is_none());
|
||||
}
|
||||
|
||||
/// A list the owner may point at an entry the folder lost.
|
||||
struct Listing {
|
||||
selected: Option<&'static str>,
|
||||
}
|
||||
|
||||
impl Render for Listing {
|
||||
fn render(&mut self, _: &mut Window, _: &mut Context<Self>) -> impl IntoElement {
|
||||
let here = vec![
|
||||
DirEntry::file("Brief.md", 10, then()),
|
||||
DirEntry::file("Notes.md", 10, then()),
|
||||
];
|
||||
let explorer = FileExplorer::new("explorer", ["Home"], [here], FileView::List);
|
||||
div().w(px(640.0)).h(px(480.0)).child(match self.selected {
|
||||
Some(name) => explorer.selected(name),
|
||||
None => explorer,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
#[gpui::test]
|
||||
fn an_owner_pick_gone_from_the_list_replaces_the_local_one(cx: &mut TestAppContext) {
|
||||
setup(cx);
|
||||
let (view, cx) = cx.add_window_view(|_, _| Listing { selected: None });
|
||||
cx.update(|window, _| window.activate_window());
|
||||
settle(cx);
|
||||
let header = cx.debug_bounds("listing-name").expect("the name header");
|
||||
let first = point(header.center().x, header.bottom() + px(12.0));
|
||||
cx.simulate_click(first, Modifiers::none());
|
||||
settle(cx);
|
||||
assert!(
|
||||
cx.debug_bounds("item-selected-Brief.md").is_some(),
|
||||
"the press picks it"
|
||||
);
|
||||
view.update(cx, |view, cx| {
|
||||
view.selected = Some("Ghost.md");
|
||||
cx.notify();
|
||||
});
|
||||
settle(cx);
|
||||
assert!(cx.debug_bounds("item-selected-Brief.md").is_none());
|
||||
}
|
||||
Reference in new issue
Block a user