team-ljyzipelo

공개

Enter 활성화 규칙과 폴더 추출 결과를 정리함

작성자
호시노 히나타
작성 시각
커밋
d144f7f2e26d26c49e5afb50fa04c6a6157ec8a9
부모
d2338d3
이 시점의 파일 보기

변경된 파일 5개

+551-17
수정experiments/rust-ui-memory-app/src/archive_picker.rs+1-3
@@ -242,9 +242,7 @@ impl Picker {
242242 };
243243 let enabled = !paths.is_empty() && !self.error;
244244 let (cancel, confirm) = theme::action_pair(ui, "취소", Some((label, enabled)));
245삭제: if navigate.is_none()
246삭제: && (confirm || (enabled && ui.input(|i| i.key_pressed(egui::Key::Enter))))
247삭제: {
245추가: if navigate.is_none() && confirm {
248246 choice = Some(Choice::Paths(paths));
249247 }
250248 if cancel {
수정experiments/rust-ui-memory-app/src/archive_present.rs+59-3
@@ -126,10 +126,56 @@ pub fn target_files(
126126 Some(names)
127127}
128128
129추가: pub fn target_directories(
130추가: entries: &[Entry],
131추가: selected: &BTreeSet<u32>,
132추가: only: bool,
133추가: ) -> BTreeSet<String> {
134추가: let selected_directories = entries
135추가: .iter()
136추가: .filter(|entry| entry.kind == Kind::Directory && selected.contains(&entry.id))
137추가: .map(|entry| {
138추가: entry
139추가: .name
140추가: .replace('\\', "/")
141추가: .trim_end_matches('/')
142추가: .to_owned()
143추가: })
144추가: .collect::<BTreeSet<_>>();
145추가: let mut directories = BTreeSet::new();
146추가: for entry in entries
147추가: .iter()
148추가: .filter(|entry| matches!(entry.kind, Kind::File | Kind::Directory))
149추가: {
150추가: let normalized = entry.name.replace('\\', "/");
151추가: let name = normalized.trim_end_matches('/');
152추가: let mut parent = name;
153추가: let mut ancestors = Vec::new();
154추가: while let Some((directory, _)) = parent.rsplit_once('/') {
155추가: ancestors.push(directory);
156추가: parent = directory;
157추가: }
158추가: if only
159추가: && !selected.contains(&entry.id)
160추가: && !ancestors
161추가: .iter()
162추가: .any(|directory| selected_directories.contains(*directory))
163추가: {
164추가: continue;
165추가: }
166추가: if entry.kind == Kind::Directory {
167추가: directories.insert(name.to_owned());
168추가: }
169추가: directories.extend(ancestors.into_iter().map(str::to_owned));
170추가: }
171추가: directories
172추가: }
173추가:
129174pub fn warnings(
130175 terminal: Option<&Terminal>,
131176 confirmed: bool,
132177 targets: Option<&BTreeSet<String>>,
178추가: directories: &BTreeSet<String>,
133179 outputs: &[(String, Disposition)],
134180) -> Vec<&'static str> {
135181 let Some(t) = terminal.filter(|_| confirmed) else {
@@ -160,13 +206,23 @@ pub fn warnings(
160206 if uncertain {
161207 result.push(UNCERTAIN);
162208 } else if let Some(targets) = targets {
163삭제: let saved = targets.intersection(&created).count();
164삭제: if !targets.is_empty() && saved == targets.len() && retained {
209추가: let files = created
210추가: .difference(directories)
211추가: .cloned()
212추가: .collect::<BTreeSet<_>>();
213추가: let saved = targets.intersection(&files).count();
214추가: let unknown = !targets.is_disjoint(directories)
215추가: || created
216추가: .iter()
217추가: .any(|name| !targets.contains(name) && !directories.contains(name));
218추가: if unknown {
219추가: result.push(UNCERTAIN);
220추가: } else if !targets.is_empty() && saved == targets.len() && retained {
165221 result.push(LEFTOVERS);
166222 all_saved_with_leftovers = true;
167223 } else if saved > 0 && saved < targets.len() && t.outcome != Outcome::Completed {
168224 result.push(PARTIAL);
169삭제: } else if (saved == 0 && !created.is_empty())
225추가: } else if (saved == 0 && !files.is_empty())
170226 || (retained && saved == 0)
171227 || (t.outcome == Outcome::Completed && saved != targets.len())
172228 {
수정experiments/rust-ui-memory-app/src/archive_screen.rs+20-5
@@ -32,6 +32,7 @@ pub struct ArchiveApp {
3232 picker: Option<Picker>,
3333 last_request: Option<Start>,
3434 targets: Option<BTreeSet<String>>,
35추가: directories: BTreeSet<String>,
3536 dismissed: bool,
3637 details: bool,
3738 checked_destination: bool,
@@ -63,6 +64,7 @@ impl ArchiveApp {
6364 picker: None,
6465 last_request: None,
6566 targets: None,
67추가: directories: BTreeSet::new(),
6668 dismissed: false,
6769 details: false,
6870 checked_destination: false,
@@ -99,6 +101,7 @@ impl ArchiveApp {
99101 .into();
100102 self.selected_only = false;
101103 self.targets = None;
104추가: self.directories.clear();
102105 self.start(Start::List { archive });
103106 }
104107
@@ -163,6 +166,15 @@ impl ArchiveApp {
163166 self.selected_only,
164167 gzip.then_some(self.gzip_name.as_str()),
165168 );
169추가: self.directories = if gzip {
170추가: BTreeSet::new()
171추가: } else {
172추가: present::target_directories(
173추가: &self.model.entries,
174추가: &self.model.selected,
175추가: self.selected_only,
176추가: )
177추가: };
166178 let request = Start::Extract {
167179 archive: self.model.archive.clone().unwrap(),
168180 destination: self.destination.clone(),
@@ -212,6 +224,7 @@ impl ArchiveApp {
212224 sources.push((path.clone(), name.to_owned()));
213225 }
214226 self.targets = Some([self.zip_name.clone()].into_iter().collect());
227추가: self.directories.clear();
215228 if self.start(Start::CreateZip {
216229 sources,
217230 output_file,
@@ -762,10 +775,6 @@ impl ArchiveApp {
762775 if theme::action(ui, "풀기", true, enabled)
763776 .on_disabled_hover_text("풀 항목을 선택하세요")
764777 .clicked()
765삭제: || (enabled
766삭제: && !self.create
767삭제: && self.picker.is_none()
768삭제: && ui.input(|i| i.key_pressed(egui::Key::Enter)))
769778 {
770779 self.begin_extract();
771780 }
@@ -852,6 +861,7 @@ impl ArchiveApp {
852861 t.as_ref(),
853862 self.model.confirmed,
854863 self.targets.as_ref(),
864추가: &self.directories,
855865 &self.model.outputs,
856866 )
857867 };
@@ -1182,6 +1192,10 @@ impl ArchiveApp {
11821192 let (_, attempt, encrypt) = self.model.challenge.unwrap();
11831193 let mut submit = false;
11841194 let mut cancel = false;
1195추가: let password_enter = ctx.memory(|memory| memory.focused()).is_some_and(|id| {
1196추가: id == egui::Id::unique("archive-password-input")
1197추가: || id == egui::Id::unique("archive-password-confirm")
1198추가: }) && ctx.input(|input| input.key_pressed(egui::Key::Enter));
11851199 let modal = egui::Modal::new(egui::Id::unique("archive-password")).show(ctx, |ui| {
11861200 ui.set_width((ctx.content_rect().width() - 64.0).min(420.0));
11871201 ui.heading(if encrypt {
@@ -1254,7 +1268,7 @@ impl ArchiveApp {
12541268 && (!encrypt || self.password == self.password_confirm);
12551269 let actions = theme::action_pair(ui, "취소", Some(("확인", valid)));
12561270 cancel = actions.0;
1257삭제: submit = actions.1 || (valid && ui.input(|i| i.key_pressed(egui::Key::Enter)));
1271추가: submit = actions.1 || (valid && password_enter);
12581272 });
12591273 if modal.should_close() || cancel {
12601274 self.clear_password();
@@ -1317,6 +1331,7 @@ impl ArchiveApp {
13171331 self.model.terminal.as_ref(),
13181332 self.model.confirmed,
13191333 self.targets.as_ref(),
1334추가: &self.directories,
13201335 &self.model.outputs,
13211336 ) {
13221337 ui.colored_label(theme::WARNING, warning);
수정tests/rust-app-real-worker/flows.rs+43-0
@@ -351,6 +351,49 @@ mod screen {
351351 fn targz_open_and_extract_via_actual_widgets_and_worker() {
352352 archive_flow("sample.tar.gz", Format::TarGzip);
353353 }
354추가:
355추가: #[test]
356추가: fn empty_directory_zip_extracts_successfully_with_existing_directory_reuse() {
357추가: let scratch = Scratch::new();
358추가: let source = make_directory(&scratch.path("empty-source"));
359추가: fs::create_dir(source.join("child")).unwrap();
360추가: let archive = scratch.path("empty-source.zip");
361추가: let output = make_directory(&scratch.path("output"));
362추가: let (factory, observed) = observed_factory();
363추가: let mut screen = Screen::new(factory);
364추가: screen.app.add_sources(vec![source]);
365추가: screen.render(vec![]);
366추가: screen.click("만들기");
367추가: screen.settle();
368추가: assert!(archive.is_file());
369추가: screen.open(&archive);
370추가: assert!(
371추가: screen
372추가: .app
373추가: .model
374추가: .entries
375추가: .iter()
376추가: .all(|entry| entry.kind == Kind::Directory)
377추가: );
378추가: for expected in [2, 0] {
379추가: screen.extract(&output);
380추가: assert!(output.join("empty-source/child").is_dir());
381추가: assert_eq!(
382추가: screen.app.model.terminal.as_ref().unwrap().created_count,
383추가: expected
384추가: );
385추가: let shown = screen.render(vec![]);
386추가: assert!(shown.iter().any(|(text, _)| text == "압축을 풀었습니다"));
387추가: assert!(
388추가: !shown
389추가: .iter()
390추가: .any(|(text, _)| text.contains("저장이 끝났는지"))
391추가: );
392추가: screen.click("확인");
393추가: }
394추가: assert_reaped(&observed);
395추가: }
396추가:
354397 #[test]
355398 fn create_zip_reopen_and_extract_via_actual_widgets_and_worker() {
356399 let scratch = Scratch::new();
수정tests/rust-app-ui/presentation.rs+428-6
@@ -29,6 +29,7 @@ fn partial_extraction_requires_matching_file_reports() {
2929 Some(&t),
3030 true,
3131 Some(&targets()),
32추가: &BTreeSet::new(),
3233 &[("one.txt".into(), Disposition::Created)]
3334 ),
3435 vec![PARTIAL]
@@ -45,6 +46,7 @@ fn all_saved_with_temporary_leftover_is_not_partial_extraction() {
4546 Some(&t),
4647 true,
4748 Some(&files),
49추가: &BTreeSet::new(),
4850 &[
4951 ("one.txt".into(), Disposition::Created),
5052 ("temp".into(), Disposition::PartialRetained)
@@ -62,8 +64,14 @@ fn leftover_without_file_reports_and_commit_uncertainty_are_unknown() {
6264 vec![("temp".into(), Disposition::PartialRetained)],
6365 vec![("one.txt".into(), Disposition::CommitUncertain)],
6466 ] {
65삭제: assert!(warnings(Some(&t), true, Some(&targets()), &outputs).contains(&UNCERTAIN));
66삭제: assert!(!warnings(Some(&t), true, Some(&targets()), &outputs).contains(&PARTIAL));
67추가: assert!(
68추가: warnings(Some(&t), true, Some(&targets()), &BTreeSet::new(), &outputs)
69추가: .contains(&UNCERTAIN)
70추가: );
71추가: assert!(
72추가: !warnings(Some(&t), true, Some(&targets()), &BTreeSet::new(), &outputs)
73추가: .contains(&PARTIAL)
74추가: );
6775 }
6876}
6977#[test]
@@ -72,7 +80,7 @@ fn synchronization_and_cleanup_warnings_are_both_visible() {
7280 t.created_count = 0;
7381 t.durability = Durability::Unconfirmed;
7482 t.cleanup = Cleanup::Failed;
75삭제: let result = warnings(Some(&t), true, Some(&targets()), &[]);
83추가: let result = warnings(Some(&t), true, Some(&targets()), &BTreeSet::new(), &[]);
7684 assert!(result.contains(&SYNC_WARNING));
7785 assert!(result.contains(&CLEANUP_WARNING));
7886}
@@ -86,7 +94,9 @@ fn missing_terminal_exit_or_contradictory_reports_never_claim_unsaved() {
8694 assert!(!definitely_unsaved(Some(&t), false, &[]));
8795 let reports = [("one.txt".into(), Disposition::Created)];
8896 assert!(!definitely_unsaved(Some(&t), true, &reports));
89삭제: assert!(warnings(Some(&t), true, Some(&targets()), &reports).contains(&UNCERTAIN));
97추가: assert!(
98추가: warnings(Some(&t), true, Some(&targets()), &BTreeSet::new(), &reports).contains(&UNCERTAIN)
99추가: );
90100}
91101#[test]
92102fn unsafe_path_and_conflict_preserve_result_classification() {
@@ -98,12 +108,15 @@ fn unsafe_path_and_conflict_preserve_result_classification() {
98108 Some(&t),
99109 true,
100110 Some(&targets()),
111추가: &BTreeSet::new(),
101112 &[("one.txt".into(), Disposition::Created)]
102113 ),
103114 vec![PARTIAL]
104115 );
105116 t.publication = Publication::Uncertain;
106삭제: assert!(warnings(Some(&t), true, Some(&targets()), &[]).contains(&UNCERTAIN));
117추가: assert!(
118추가: warnings(Some(&t), true, Some(&targets()), &BTreeSet::new(), &[]).contains(&UNCERTAIN)
119추가: );
107120 t.publication = Publication::None;
108121 t.created_count = 0;
109122 assert!(definitely_unsaved(Some(&t), true, &[]));
@@ -167,6 +180,114 @@ fn folder_selection_expands_only_matching_descendants() {
167180 Some(["docs/one.txt".into()].into_iter().collect())
168181 );
169182}
183추가:
184추가: #[test]
185추가: fn directory_reports_allow_empty_and_mixed_archives_without_hiding_unknown_outputs() {
186추가: let directories = ["parent".into(), "parent/empty".into()]
187추가: .into_iter()
188추가: .collect();
189추가: let empty = BTreeSet::new();
190추가: let mut t = terminal();
191추가: t.outcome = Outcome::Completed;
192추가: t.error = None;
193추가: t.publication = Publication::Complete;
194추가: t.created_count = 2;
195추가: let reports = [
196추가: ("parent".into(), Disposition::Created),
197추가: ("parent/empty".into(), Disposition::Created),
198추가: ];
199추가: assert!(warnings(Some(&t), true, Some(&empty), &directories, &reports).is_empty());
200추가: t.created_count = 0;
201추가: assert!(warnings(Some(&t), true, Some(&empty), &directories, &[]).is_empty());
202추가: let files = ["parent/file.txt".into()].into_iter().collect();
203추가: t.created_count = 2;
204추가: let reports = [
205추가: ("parent".into(), Disposition::Created),
206추가: ("parent/file.txt".into(), Disposition::Created),
207추가: ];
208추가: assert!(warnings(Some(&t), true, Some(&files), &directories, &reports).is_empty());
209추가: t.created_count = 1;
210추가: assert!(
211추가: warnings(
212추가: Some(&t),
213추가: true,
214추가: Some(&files),
215추가: &directories,
216추가: &[("parent".into(), Disposition::Created)]
217추가: )
218추가: .contains(&UNCERTAIN)
219추가: );
220추가: assert!(
221추가: warnings(
222추가: Some(&t),
223추가: true,
224추가: Some(&empty),
225추가: &directories,
226추가: &[("unknown".into(), Disposition::Created)]
227추가: )
228추가: .contains(&UNCERTAIN)
229추가: );
230추가: t.publication = Publication::Uncertain;
231추가: assert!(
232추가: warnings(
233추가: Some(&t),
234추가: true,
235추가: Some(&empty),
236추가: &directories,
237추가: &[("parent".into(), Disposition::CommitUncertain)]
238추가: )
239추가: .contains(&UNCERTAIN)
240추가: );
241추가: }
242추가:
243추가: #[test]
244추가: fn directory_targets_include_selected_members_and_implicit_parents() {
245추가: let entries = [
246추가: Entry {
247추가: id: 0,
248추가: name: "top".into(),
249추가: kind: Kind::Directory,
250추가: bytes: None,
251추가: packed: None,
252추가: encrypted: false,
253추가: },
254추가: Entry {
255추가: id: 1,
256추가: name: "top/empty".into(),
257추가: kind: Kind::Directory,
258추가: bytes: None,
259추가: packed: None,
260추가: encrypted: false,
261추가: },
262추가: Entry {
263추가: id: 2,
264추가: name: "top/nested/file.txt".into(),
265추가: kind: Kind::File,
266추가: bytes: None,
267추가: packed: None,
268추가: encrypted: false,
269추가: },
270추가: Entry {
271추가: id: 3,
272추가: name: "other/empty".into(),
273추가: kind: Kind::Directory,
274추가: bytes: None,
275추가: packed: None,
276추가: encrypted: false,
277추가: },
278추가: ];
279추가: assert_eq!(
280추가: target_directories(&entries, &[0].into_iter().collect(), true),
281추가: ["top".into(), "top/empty".into(), "top/nested".into()]
282추가: .into_iter()
283추가: .collect()
284추가: );
285추가: assert_eq!(
286추가: target_directories(&entries, &[2].into_iter().collect(), true),
287추가: ["top".into(), "top/nested".into()].into_iter().collect()
288추가: );
289추가: }
290추가:
170291#[test]
171292fn duplicate_names_prevent_file_completion_assumptions() {
172293 let entry = Entry {
@@ -179,7 +300,7 @@ fn duplicate_names_prevent_file_completion_assumptions() {
179300 };
180301 assert!(target_files(&[entry.clone(), entry], &BTreeSet::new(), false, None).is_none());
181302 assert_eq!(
182삭제: warnings(Some(&terminal()), true, None, &[]),
303추가: warnings(Some(&terminal()), true, None, &BTreeSet::new(), &[]),
183304 vec![UNCERTAIN]
184305 );
185306}
@@ -539,6 +660,26 @@ mod widgets {
539660 },
540661 ]);
541662 }
663추가: for _ in 0..40 {
664추가: if ctx
665추가: .memory(|memory| memory.focused())
666추가: .and_then(|id| ctx.read_response(id))
667추가: .is_some_and(|response| response.rect.contains(confirm))
668추가: {
669추가: break;
670추가: }
671추가: draw(vec![key(egui::Key::Tab)]);
672추가: let mut released = key(egui::Key::Tab);
673추가: if let egui::Event::Key { pressed, .. } = &mut released {
674추가: *pressed = false;
675추가: }
676추가: draw(vec![released]);
677추가: }
678추가: assert!(
679추가: ctx.memory(|memory| memory.focused())
680추가: .and_then(|id| ctx.read_response(id))
681추가: .is_some_and(|response| response.rect.contains(confirm))
682추가: );
542683 draw(vec![key(egui::Key::Enter)]);
543684 assert!(matches!(result, Some(Choice::Paths(ref paths)) if paths == &vec![file]));
544685 }
@@ -626,6 +767,287 @@ mod widgets {
626767 }
627768 }
628769
770추가: fn policy_render(
771추가: ctx: &egui::Context,
772추가: app: &mut ArchiveApp,
773추가: events: Vec<egui::Event>,
774추가: ) -> Vec<(String, egui::Pos2)> {
775추가: let mut output = ctx.run_ui(
776추가: egui::RawInput {
777추가: screen_rect: Some(egui::Rect::from_min_size(
778추가: egui::Pos2::ZERO,
779추가: egui::vec2(1060.0, 720.0),
780추가: )),
781추가: events,
782추가: ..Default::default()
783추가: },
784추가: |ui| app.show(ui),
785추가: );
786추가: output.textures_delta.clear();
787추가: labels(&output.shapes)
788추가: }
789추가:
790추가: fn policy_focus(ctx: &egui::Context, app: &mut ArchiveApp, label: &str) {
791추가: policy_render(ctx, app, vec![]);
792추가: for _ in 0..100 {
793추가: let shown = policy_render(ctx, app, vec![]);
794추가: let point = shown
795추가: .iter()
796추가: .rev()
797추가: .find(|(text, _)| text == label)
798추가: .unwrap_or_else(|| panic!("표시 없음: {label}"))
799추가: .1;
800추가: if ctx
801추가: .memory(|memory| memory.focused())
802추가: .and_then(|id| ctx.read_response(id))
803추가: .is_some_and(|response| response.rect.contains(point))
804추가: {
805추가: return;
806추가: }
807추가: policy_render(ctx, app, vec![key(egui::Key::Tab)]);
808추가: let mut released = key(egui::Key::Tab);
809추가: if let egui::Event::Key { pressed, .. } = &mut released {
810추가: *pressed = false;
811추가: }
812추가: policy_render(ctx, app, vec![released]);
813추가: }
814추가: panic!("키보드 초점 없음: {label}");
815추가: }
816추가:
817추가: fn policy_click(ctx: &egui::Context, app: &mut ArchiveApp, label: &str) {
818추가: policy_render(ctx, app, vec![]);
819추가: let point = policy_render(ctx, app, vec![])
820추가: .iter()
821추가: .rev()
822추가: .find(|(text, _)| text == label)
823추가: .unwrap()
824추가: .1;
825추가: for pressed in [true, false] {
826추가: policy_render(
827추가: ctx,
828추가: app,
829추가: vec![
830추가: egui::Event::PointerMoved(point),
831추가: egui::Event::PointerButton {
832추가: pos: point,
833추가: button: egui::PointerButton::Primary,
834추가: pressed,
835추가: modifiers: egui::Modifiers::NONE,
836추가: },
837추가: ],
838추가: );
839추가: }
840추가: }
841추가:
842추가: #[test]
843추가: fn secondary_button_enter_matrix_never_starts_creation_or_extraction() {
844추가: let cases = vec![
845추가: ("archive", "ZIP 만들기"),
846추가: ("archive", "다른 파일"),
847추가: ("archive", "폴더 바꾸기"),
848추가: ("archive", "선택한 항목만 풀기"),
849추가: ("create", "파일 추가"),
850추가: ("create", "폴더 추가"),
851추가: ("create", "빼기"),
852추가: ("create", "폴더 바꾸기"),
853추가: ("create", "암호로 보호하기"),
854추가: ("create", "자세한 설정"),
855추가: ("create", "취소"),
856추가: ("result", "자세히 보기"),
857추가: ("result", "자세히 닫기"),
858추가: ("result", "확인"),
859추가: ("progress", "취소"),
860추가: ("close-confirm", "계속 작업"),
861추가: ("close-confirm", "취소하고 닫기"),
862추가: ("close-wait", "닫기 취소"),
863추가: ("close-review", "계속 작업"),
864추가: ("close-review", "닫기"),
865추가: ];
866추가: let mut cases = cases
867추가: .into_iter()
868추가: .map(|(state, label)| (state, label.to_owned()))
869추가: .collect::<Vec<_>>();
870추가: for state in [
871추가: "picker-open",
872추가: "picker-destination",
873추가: "picker-files",
874추가: "picker-folder",
875추가: "picker-zip",
876추가: ] {
877추가: for (label, _) in shortcuts() {
878추가: cases.push((state, label));
879추가: }
880추가: for label in ["상위 폴더", "취소", "breadcrumb"] {
881추가: cases.push((state, label.to_owned()));
882추가: }
883추가: }
884추가: for (state, label) in cases {
885추가: let scratch = Folder::new();
886추가: let factory = FakeFactory::default();
887추가: let ctx = egui::Context::default();
888추가: let creating = matches!(
889추가: state,
890추가: "create" | "picker-files" | "picker-folder" | "picker-zip"
891추가: );
892추가: let mut app = ArchiveApp::new(
893추가: Box::new(factory.clone()),
894추가: (!creating).then(|| scratch.0.join("sample.zip")),
895추가: false,
896추가: );
897추가: if !creating {
898추가: pump(&mut app.model);
899추가: }
900추가: factory.state.borrow_mut().manual = true;
901추가: if creating {
902추가: let source = scratch.0.join("source.txt");
903추가: fs::write(&source, "fixture").unwrap();
904추가: app.add_sources(vec![source]);
905추가: }
906추가: if matches!(
907추가: state,
908추가: "progress" | "result" | "close-confirm" | "close-wait" | "close-review"
909추가: ) {
910추가: assert!(app.begin_extract());
911추가: if matches!(state, "result" | "close-review") {
912추가: let mut worker = factory.state.borrow_mut();
913추가: worker.frame(Event::Accepted { encryption: false });
914추가: worker.finish(Outcome::Failed, Publication::None);
915추가: drop(worker);
916추가: for _ in 0..30 {
917추가: policy_render(&ctx, &mut app, vec![]);
918추가: }
919추가: }
920추가: if state.starts_with("close-") {
921추가: app.model.request_close();
922추가: if state == "close-wait" {
923추가: app.model.confirm_close();
924추가: }
925추가: }
926추가: }
927추가: match state {
928추가: "picker-open" => policy_click(&ctx, &mut app, "다른 파일"),
929추가: "picker-destination" | "picker-zip" => policy_click(&ctx, &mut app, "폴더 바꾸기"),
930추가: "picker-files" => policy_click(&ctx, &mut app, "파일 추가"),
931추가: "picker-folder" => policy_click(&ctx, &mut app, "폴더 추가"),
932추가: _ => {}
933추가: }
934추가: if state == "result" && label == "자세히 닫기" {
935추가: policy_click(&ctx, &mut app, "자세히 보기");
936추가: }
937추가: let before = factory.state.borrow().starts.len();
938추가: let label = if label == "breadcrumb" {
939추가: scratch
940추가: .0
941추가: .ancestors()
942추가: .last()
943추가: .unwrap()
944추가: .as_os_str()
945추가: .to_str()
946추가: .unwrap()
947추가: } else {
948추가: label.as_str()
949추가: };
950추가: policy_focus(&ctx, &mut app, label);
951추가: policy_render(&ctx, &mut app, vec![key(egui::Key::Enter)]);
952추가: policy_render(&ctx, &mut app, vec![]);
953추가: assert_eq!(
954추가: factory.state.borrow().starts.len(),
955추가: before,
956추가: "{state}: {label}"
957추가: );
958추가: }
959추가: let scratch = Folder::new();
960추가: let factory = FakeFactory::default();
961추가: let mut app = loaded(&scratch, &factory);
962추가: factory.state.borrow_mut().manual = true;
963추가: let ctx = egui::Context::default();
964추가: policy_focus(&ctx, &mut app, "풀기");
965추가: policy_render(&ctx, &mut app, vec![key(egui::Key::Enter)]);
966추가: assert!(matches!(
967추가: factory.state.borrow().starts.last(),
968추가: Some(Start::Extract { .. })
969추가: ));
970추가: assert_eq!(factory.state.borrow().starts.len(), 2);
971추가: }
972추가:
973추가: #[test]
974추가: fn password_secondary_enter_does_not_submit_valid_input() {
975추가: for encrypt in [false, true] {
976추가: for label in ["보기", "숨기기", "취소"] {
977추가: let scratch = Folder::new();
978추가: let factory = FakeFactory::manual();
979추가: let mut app = ArchiveApp::new(Box::new(factory.clone()), None, false);
980추가: assert!(app.model.begin(
981추가: Start::CreateZip {
982추가: sources: vec![(scratch.0.join("source"), "source".into())],
983추가: output_file: scratch.0.join("output.zip"),
984추가: method: Method::Deflate,
985추가: aes256: true
986추가: },
987추가: &mut factory.clone()
988추가: ));
989추가: {
990추가: let mut worker = factory.state.borrow_mut();
991추가: worker.frame(Event::Accepted { encryption: true });
992추가: worker.frame(Event::PasswordRequired {
993추가: challenge_id: 17,
994추가: attempt: 1,
995추가: encrypt,
996추가: });
997추가: }
998추가: let ctx = egui::Context::default();
999추가: for _ in 0..12 {
1000추가: policy_render(&ctx, &mut app, vec![]);
1001추가: }
1002추가: text(&ctx, &mut app, "archive-password-input", "fixture-secret");
1003추가: if encrypt {
1004추가: text(&ctx, &mut app, "archive-password-confirm", "fixture-secret");
1005추가: }
1006추가: if label == "숨기기" {
1007추가: policy_click(&ctx, &mut app, "보기");
1008추가: }
1009추가: policy_focus(&ctx, &mut app, label);
1010추가: policy_render(&ctx, &mut app, vec![key(egui::Key::Enter)]);
1011추가: assert!(!factory.state.borrow().password_seen, "{label}");
1012추가: assert_eq!(factory.state.borrow().starts.len(), 1);
1013추가: }
1014추가: }
1015추가: }
1016추가:
1017추가: #[test]
1018추가: fn directory_only_extraction_displays_success() {
1019추가: let scratch = Folder::new();
1020추가: let factory = FakeFactory::default();
1021추가: let mut app = loaded(&scratch, &factory);
1022추가: app.model.entries = vec![Entry {
1023추가: id: 0,
1024추가: name: "empty".into(),
1025추가: kind: Kind::Directory,
1026추가: bytes: Some(0),
1027추가: packed: None,
1028추가: encrypted: false,
1029추가: }];
1030추가: factory.state.borrow_mut().manual = true;
1031추가: assert!(app.begin_extract());
1032추가: {
1033추가: let mut worker = factory.state.borrow_mut();
1034추가: worker.frame(Event::Accepted { encryption: false });
1035추가: worker.frame(Event::Output {
1036추가: entry_id: None,
1037추가: relative_name: "empty".into(),
1038추가: disposition: Disposition::Created,
1039추가: });
1040추가: worker.finish(Outcome::Completed, Publication::Complete);
1041추가: }
1042추가: let ctx = egui::Context::default();
1043추가: for _ in 0..30 {
1044추가: policy_render(&ctx, &mut app, vec![]);
1045추가: }
1046추가: let shown = policy_render(&ctx, &mut app, vec![]);
1047추가: assert!(shown.iter().any(|(text, _)| text == "압축을 풀었습니다"));
1048추가: assert!(!shown.iter().any(|(text, _)| text == UNCERTAIN));
1049추가: }
1050추가:
6291051 fn picker_frame(
6301052 ctx: &egui::Context,
6311053 picker: &mut Picker,