team-ljyzipelo

공개
876줄27 KB
1mod conflicts;
2#[cfg(feature = "ui")]
3mod dialogs;
4mod fake;
5#[cfg(feature = "ui")]
6mod native_dialogs;
7mod preview;
8use fake::*;
9use std::path::PathBuf;
10use zipelo_ui_memory_app::archive_ui::*;
11
12fn path(name: &str) -> PathBuf {
13 std::env::current_dir().unwrap().join(name)
14}
15fn pump(m: &mut Model) {
16 for _ in 0..100 {
17 m.poll();
18 if !m.busy() {
19 return;
20 }
21 }
22 panic!("가짜 작업자 종료 누락: {}", m.status());
23}
24fn list(m: &mut Model, f: &mut FakeFactory) {
25 assert!(m.begin(
26 Start::List {
27 archive: path("example.zip")
28 },
29 f
30 ));
31 pump(m);
32 assert!(m.list_id.is_some());
33}
34
35#[test]
36fn open_lists_only_after_terminal_eofs_and_wait() {
37 let mut f = FakeFactory::default();
38 let mut m = Model::default();
39 assert!(m.begin(
40 Start::List {
41 archive: path("example.zip")
42 },
43 &mut f
44 ));
45 while m.terminal.is_none() {
46 m.poll();
47 assert!(m.list_id.is_none());
48 assert!(!m.can_extract());
49 }
50 assert!(m.busy());
51 assert!(!m.begin(
52 Start::List {
53 archive: path("replacement.zip")
54 },
55 &mut f
56 ));
57 pump(&mut m);
58 assert_eq!(m.entries[0].name, "읽어주세요.txt");
59 assert!(m.can_extract());
60 assert!(m.confirmed);
61}
62#[test]
63fn extract_uses_list_token_selection_and_destination() {
64 let mut f = FakeFactory::default();
65 let mut m = Model::default();
66 list(&mut m, &mut f);
67 let token = m.list_id.clone().unwrap();
68 m.selected.insert(0);
69 assert!(m.extract(path("output"), true, None, &mut f));
70 pump(&mut m);
71 assert!(
72 matches!(f.state.borrow().starts.last(),Some(Start::Extract {selection:Selection::EntryIds(ids),list_id,..}) if ids==&vec![0]&&*list_id==token)
73 );
74 assert_eq!(m.terminal.unwrap().publication, Publication::Complete);
75}
76#[test]
77fn gzip_requires_explicit_leaf() {
78 let mut f = FakeFactory::default();
79 let mut m = Model::default();
80 assert!(m.begin(
81 Start::List {
82 archive: path("sample.gz")
83 },
84 &mut f
85 ));
86 pump(&mut m);
87 for name in [None, Some("../escape".into()), Some("sub/file".into())] {
88 assert!(!m.extract(path("output"), false, name, &mut f));
89 }
90 assert!(m.extract(path("output"), false, Some("압축 해제 파일".into()), &mut f));
91 pump(&mut m);
92}
93#[test]
94fn creates_zip_and_reports_progress_outputs() {
95 let mut f = FakeFactory::default();
96 let mut m = Model::default();
97 assert!(m.begin(
98 Start::CreateZip {
99 sources: vec![(path("one.txt"), "one.txt".into())],
100 output_file: path("new.zip"),
101 method: Method::Deflate,
102 aes256: false
103 },
104 &mut f
105 ));
106 pump(&mut m);
107 assert_eq!(m.progress.unwrap().1, 31);
108 assert_eq!(m.outputs.len(), 1);
109 assert_eq!(m.status(), "작업 완료");
110}
111#[test]
112fn password_challenge_is_answered_without_retaining_secret() {
113 let mut f = FakeFactory::default();
114 let mut m = Model::default();
115 assert!(m.begin(
116 Start::List {
117 archive: path("locked.zip")
118 },
119 &mut f
120 ));
121 for _ in 0..10 {
122 m.poll();
123 if m.challenge.is_some() {
124 break;
125 }
126 }
127 assert_eq!(m.challenge, Some((17, 1, false)));
128 assert!(!m.password(String::new()));
129 assert!(m.password("synthetic password".into()));
130 pump(&mut m);
131 assert!(f.state.borrow().password_seen);
132 assert!(m.challenge.is_none());
133 assert!(m.list_id.is_some());
134}
135#[test]
136fn cancel_close_retract_preserves_request_and_waits_for_exit() {
137 let mut f = FakeFactory::default();
138 let mut m = Model::default();
139 assert!(m.begin(
140 Start::List {
141 archive: path("one.zip")
142 },
143 &mut f
144 ));
145 m.poll();
146 m.request_close();
147 assert_eq!(m.close, Close::Confirm);
148 m.confirm_close();
149 m.keep_open();
150 m.cancel();
151 pump(&mut m);
152 assert_eq!(m.close, Close::Open);
153 assert_eq!(m.cancel, Some(CancelStatus::Requested));
154 assert_eq!(m.terminal.unwrap().outcome, Outcome::Cancelled);
155 assert_eq!(
156 f.state
157 .borrow()
158 .requests
159 .iter()
160 .filter(|(_, k)| *k == "cancel")
161 .count(),
162 1
163 );
164}
165#[test]
166fn terminal_race_needs_no_cancel_ack() {
167 let mut f = FakeFactory::manual();
168 let mut m = Model::default();
169 assert!(m.begin(
170 Start::List {
171 archive: path("one.zip")
172 },
173 &mut f
174 ));
175 {
176 let mut s = f.state.borrow_mut();
177 s.frame(Event::Accepted { encryption: false });
178 s.finish(Outcome::Cancelled, Publication::None);
179 }
180 m.cancel();
181 pump(&mut m);
182 assert!(m.cancel.is_none());
183 assert_eq!(m.status(), "작업 취소됨");
184}
185#[test]
186fn eof_exit_without_terminal_never_means_success() {
187 let mut f = FakeFactory::manual();
188 let mut m = Model::default();
189 assert!(m.begin(
190 Start::List {
191 archive: path("one.zip")
192 },
193 &mut f
194 ));
195 {
196 let mut s = f.state.borrow_mut();
197 s.queue.extend([
198 HostEvent::StdoutEof,
199 HostEvent::StderrEof,
200 HostEvent::Exited { success: true },
201 ]);
202 }
203 pump(&mut m);
204 assert!(!m.confirmed);
205 assert!(m.list_id.is_none());
206 assert!(m.error.is_some());
207}
208#[test]
209fn stale_sequence_and_job_are_protocol_errors() {
210 for bad_job in [true, false] {
211 let mut f = FakeFactory::manual();
212 let mut m = Model::default();
213 assert!(m.begin(
214 Start::List {
215 archive: path("one.zip")
216 },
217 &mut f
218 ));
219 let id = m.job_id().unwrap();
220 f.state.borrow_mut().queue.push_back(HostEvent::Frame {
221 job_id: if bad_job { id + 1 } else { id },
222 sequence: if bad_job { 0 } else { 1 },
223 event: Event::Accepted { encryption: false },
224 });
225 m.poll();
226 assert!(m.error.is_some());
227 assert!(m.busy());
228 }
229}
230#[test]
231fn source_changed_invalidates_selection_without_retry() {
232 let mut f = FakeFactory::default();
233 let mut m = Model::default();
234 list(&mut m, &mut f);
235 m.selected.insert(0);
236 f.state.borrow_mut().manual = true;
237 assert!(m.extract(path("out"), true, None, &mut f));
238 {
239 let mut s = f.state.borrow_mut();
240 s.frame(Event::Accepted { encryption: false });
241 s.frame(Event::Terminal(Terminal {
242 outcome: Outcome::Failed,
243 error: Some(ErrorCode::SourceChanged),
244 publication: Publication::None,
245 created_count: 0,
246 retained_partial_count: 0,
247 durability: Durability::NotApplicable,
248 cleanup: Cleanup::Complete,
249 }));
250 s.queue.extend([
251 HostEvent::StdoutEof,
252 HostEvent::StderrEof,
253 HostEvent::Exited { success: true },
254 ]);
255 }
256 pump(&mut m);
257 assert!(m.list_id.is_none());
258 assert!(m.selected.is_empty());
259 assert_eq!(f.state.borrow().starts.len(), 2);
260}
261#[test]
262fn partial_and_uncertain_results_are_preserved() {
263 let mut f = FakeFactory::manual();
264 let mut m = Model::default();
265 assert!(m.begin(
266 Start::CreateZip {
267 sources: vec![(path("one"), "one".into())],
268 output_file: path("out.zip"),
269 method: Method::Store,
270 aes256: false
271 },
272 &mut f
273 ));
274 {
275 let mut s = f.state.borrow_mut();
276 s.frame(Event::Accepted { encryption: false });
277 s.frame(Event::Output {
278 entry_id: None,
279 relative_name: "out.zip".into(),
280 disposition: Disposition::CommitUncertain,
281 });
282 s.frame(Event::Terminal(Terminal {
283 outcome: Outcome::Failed,
284 error: Some(ErrorCode::Io),
285 publication: Publication::Uncertain,
286 created_count: 0,
287 retained_partial_count: 1,
288 durability: Durability::Failed,
289 cleanup: Cleanup::Unconfirmed,
290 }));
291 s.queue.extend([
292 HostEvent::StdoutEof,
293 HostEvent::StderrEof,
294 HostEvent::Exited { success: true },
295 ]);
296 }
297 pump(&mut m);
298 let t = m.terminal.as_ref().unwrap();
299 assert_eq!(t.publication, Publication::Uncertain);
300 assert_eq!(t.retained_partial_count, 1);
301 assert_eq!(t.durability, Durability::Failed);
302 assert_eq!(m.outputs[0].1, Disposition::CommitUncertain);
303}
304#[test]
305fn close_requires_result_acknowledgement() {
306 let mut f = FakeFactory::default();
307 let mut m = Model::default();
308 assert!(m.begin(
309 Start::List {
310 archive: path("one.zip")
311 },
312 &mut f
313 ));
314 m.request_close();
315 m.confirm_close();
316 m.acknowledge_close();
317 assert_eq!(m.close, Close::Waiting);
318 pump(&mut m);
319 assert_eq!(m.close, Close::Review);
320 m.acknowledge_close();
321 assert_eq!(m.close, Close::Allowed);
322}
323#[test]
324fn unsupported_worker_and_unsafe_inputs_do_not_start() {
325 let mut m = Model::default();
326 assert!(!m.begin(
327 Start::List {
328 archive: path("one.zip")
329 },
330 &mut Unavailable
331 ));
332 assert!(m.error.as_ref().unwrap().contains("준비"));
333 let mut f = FakeFactory::default();
334 assert!(!m.begin(
335 Start::List {
336 archive: "relative.zip".into()
337 },
338 &mut f
339 ));
340 assert!(!m.begin(
341 Start::CreateZip {
342 sources: vec![(path("one"), "../one".into())],
343 output_file: path("out.zip"),
344 method: Method::Store,
345 aes256: false
346 },
347 &mut f
348 ));
349 assert!(f.state.borrow().starts.is_empty());
350}
351#[cfg(feature = "ui")]
352#[test]
353fn renders_every_flow_with_actual_egui_widgets() {
354 use eframe::egui::{self, epaint::Shape};
355 use zipelo_ui_memory_app::archive_screen::ArchiveApp;
356 fn text(shapes: &[egui::epaint::ClippedShape]) -> Vec<(String, egui::Pos2)> {
357 fn walk(shape: &Shape, result: &mut Vec<(String, egui::Pos2)>) {
358 match shape {
359 Shape::Text(t) => result.push((
360 t.galley.job.text.clone(),
361 t.pos + t.galley.rect.size() / 2.0,
362 )),
363 Shape::Vec(v) => {
364 for shape in v {
365 walk(shape, result);
366 }
367 }
368 _ => {}
369 }
370 }
371 let mut result = Vec::new();
372 for shape in shapes {
373 walk(&shape.shape, &mut result);
374 }
375 result
376 }
377 let ctx = egui::Context::default();
378 let f = FakeFactory::default();
379 let mut app = ArchiveApp::new(Box::new(f.clone()), None, true);
380 // 압축하기는 운영체제 폴더 선택 창을 여므로 시험 응답으로 바꿈.
381 let folder = std::env::temp_dir().join(format!("zipelo-ui-create-{}", std::process::id()));
382 std::fs::create_dir_all(&folder).unwrap();
383 let dialogs = dialogs::TestDialogs::default();
384 dialogs
385 .0
386 .borrow_mut()
387 .answers
388 .push_back(Some(vec![folder.clone()]));
389 app.set_dialogs(Box::new(dialogs));
390 let render = |app: &mut ArchiveApp, events: Vec<egui::Event>, width: f32| {
391 let mut output = ctx.run_ui(
392 egui::RawInput {
393 screen_rect: Some(egui::Rect::from_min_size(
394 egui::Pos2::ZERO,
395 egui::vec2(width, 720.0),
396 )),
397 events,
398 ..Default::default()
399 },
400 |ui| app.show(ui),
401 );
402 output.textures_delta.clear();
403 assert!(!output.shapes.is_empty());
404 text(&output.shapes)
405 };
406 render(&mut app, vec![], 1060.0);
407 render(&mut app, vec![], 1060.0);
408 let initial = render(&mut app, vec![], 1060.0);
409 let point = initial
410 .iter()
411 .rev()
412 .find(|(t, _)| t == "압축하기")
413 .unwrap()
414 .1;
415 render(
416 &mut app,
417 vec![
418 egui::Event::PointerMoved(point),
419 egui::Event::PointerButton {
420 pos: point,
421 button: egui::PointerButton::Primary,
422 pressed: true,
423 modifiers: egui::Modifiers::default(),
424 },
425 ],
426 1060.0,
427 );
428 render(
429 &mut app,
430 vec![egui::Event::PointerButton {
431 pos: point,
432 button: egui::PointerButton::Primary,
433 pressed: false,
434 modifiers: egui::Modifiers::default(),
435 }],
436 1060.0,
437 );
438 let create = render(&mut app, vec![], 1060.0);
439 assert!(create.iter().any(|(t, _)| t == "암호로 보호하기"));
440 let mut app = ArchiveApp::new(Box::new(f.clone()), Some(path("locked.zip")), true);
441 for _ in 0..8 {
442 app.model.poll();
443 }
444 for width in [760.0, 1060.0] {
445 render(&mut app, vec![], width);
446 render(&mut app, vec![], width);
447 let password = render(&mut app, vec![], width);
448 assert!(password.iter().any(|(t, _)| t == "암호가 필요합니다"));
449 }
450 assert!(app.model.password("synthetic secret".into()));
451 pump(&mut app.model);
452 let listed = render(&mut app, vec![], 1060.0);
453 assert!(listed.iter().any(|(t, _)| t == "읽어주세요.txt"));
454 assert!(!listed.iter().any(|(t, _)| t.contains("synthetic secret")));
455 assert!(app.model.extract(path("out"), false, None, &mut f.clone()));
456 render(&mut app, vec![], 1060.0);
457 app.model.request_close();
458 render(&mut app, vec![], 1060.0);
459 let confirm = render(&mut app, vec![], 1060.0);
460 assert!(confirm.iter().any(|(t, _)| t == "작업 중 닫기"));
461 app.model.confirm_close();
462 pump(&mut app.model);
463 render(&mut app, vec![], 1060.0);
464 let result = render(&mut app, vec![], 1060.0);
465 // 작업 정리가 끝나면 결과 확인 안내 없이 바로 닫힘.
466 assert!(!result.iter().any(|(t, _)| t == "결과 확인 후 닫기"));
467 assert_eq!(app.model.close, Close::Allowed);
468}
469
470#[test]
471fn file_association_arguments_preserve_native_paths() {
472 let cwd = std::env::current_dir().unwrap();
473 let (fixture, archive) =
474 launch_args(vec!["--ui-fixture".into(), "한글.zip".into()], cwd.clone()).unwrap();
475 assert!(fixture);
476 assert_eq!(archive, Some(cwd.join("한글.zip")));
477 assert!(launch_args(vec!["a".into(), "b".into()], cwd.clone()).is_err());
478 #[cfg(unix)]
479 {
480 use std::os::unix::ffi::OsStringExt;
481 let name = std::ffi::OsString::from_vec(vec![b'/', 0xff, b'a']);
482 assert_eq!(
483 launch_args(vec![name.clone()], cwd).unwrap().1,
484 Some(PathBuf::from(name))
485 );
486 }
487}
488
489#[cfg(feature = "ui")]
490#[test]
491fn dropped_native_file_opens_without_ui_reading_contents() {
492 use eframe::egui;
493 use zipelo_ui_memory_app::archive_screen::ArchiveApp;
494 #[derive(Debug)]
495 struct DropFile(PathBuf);
496 impl egui::DroppedFile for DropFile {
497 fn path(&self) -> &std::path::Path {
498 &self.0
499 }
500 fn bytes(&self) -> Result<Vec<u8>, String> {
501 panic!("화면이 압축파일을 직접 읽으면 안 됨")
502 }
503 }
504 let ctx = egui::Context::default();
505 let f = FakeFactory::default();
506 let mut app = ArchiveApp::new(Box::new(f.clone()), None, true);
507 let scratch = presentation::Folder::new();
508 let file = scratch.0.join("dropped.zip");
509 std::fs::write(&file, b"fixture").unwrap();
510 let mut output = ctx.run_ui(
511 egui::RawInput {
512 dropped_files: vec![std::sync::Arc::new(DropFile(file.clone()))],
513 ..Default::default()
514 },
515 |ui| app.show(ui),
516 );
517 output.textures_delta.clear();
518 assert_eq!(app.model.archive, Some(file));
519 assert_eq!(f.state.borrow().starts.len(), 1);
520 pump(&mut app.model);
521 assert!(app.model.can_extract());
522}
523
524#[test]
525fn failed_start_retains_connection_until_both_eofs_and_child_wait() {
526 for missing in 0..3 {
527 let mut factory = FakeFactory::manual();
528 factory.state.borrow_mut().fail_start = true;
529 let mut model = Model::default();
530 assert!(!model.begin(
531 Start::List {
532 archive: path("failed.zip")
533 },
534 &mut factory
535 ));
536 assert!(model.busy());
537 assert_eq!(factory.state.borrow().dropped_connections, 0);
538 assert_eq!(model.job_id(), Some(1));
539 model.request_close();
540 model.confirm_close();
541 assert_eq!(model.close, Close::Waiting);
542 assert_eq!(factory.state.borrow().requests, vec![(0, "start")]);
543 let event = |index| match index {
544 0 => HostEvent::StdoutEof,
545 1 => HostEvent::StderrEof,
546 _ => HostEvent::Exited { success: false },
547 };
548 for index in 0..3 {
549 if index != missing {
550 factory.state.borrow_mut().queue.push_back(event(index));
551 }
552 }
553 for _ in 0..20 {
554 model.poll();
555 }
556 assert!(model.busy());
557 assert!(!model.can_extract());
558 assert_eq!(factory.state.borrow().dropped_connections, 0);
559 model.acknowledge_close();
560 assert_eq!(model.close, Close::Waiting);
561 assert!(!model.begin(
562 Start::List {
563 archive: path("replacement.zip")
564 },
565 &mut factory
566 ));
567 factory.state.borrow_mut().queue.push_back(event(missing));
568 pump(&mut model);
569 assert!(!model.confirmed);
570 assert!(model.terminal.is_none());
571 assert_eq!(model.error.as_deref(), Some("Start 전송 실패"));
572 assert_eq!(factory.state.borrow().dropped_connections, 1);
573 assert_eq!(model.close, Close::Review);
574 if missing == 0 {
575 model.acknowledge_close();
576 assert_eq!(model.close, Close::Allowed);
577 } else {
578 model.keep_open();
579 factory.state.borrow_mut().fail_start = false;
580 assert!(model.begin(
581 Start::List {
582 archive: path("replacement.zip")
583 },
584 &mut factory
585 ));
586 assert_eq!(model.job_id(), Some(2));
587 }
588 }
589}
590
591#[test]
592fn non_gzip_formats_reject_a_gzip_output_name_before_connect() {
593 for format in [Format::Zip, Format::Tar, Format::TarGzip] {
594 let mut factory = FakeFactory::default();
595 factory.state.borrow_mut().list_format = Some(format);
596 let mut model = Model::default();
597 list(&mut model, &mut factory);
598 let count = factory.state.borrow().starts.len();
599 assert!(!model.extract(path("out"), false, Some("stale.txt".into()), &mut factory));
600 assert!(!model.busy());
601 assert_eq!(factory.state.borrow().starts.len(), count);
602 assert!(model.extract(path("out"), false, None, &mut factory));
603 pump(&mut model);
604 }
605}
606
607#[cfg(feature = "ui")]
608#[test]
609fn extract_button_sends_gzip_name_only_for_raw_gzip() {
610 use eframe::egui::{self, epaint::Shape};
611 use zipelo_ui_memory_app::archive_screen::ArchiveApp;
612 for format in [Format::Zip, Format::Tar, Format::TarGzip, Format::Gzip] {
613 let ctx = egui::Context::default();
614 let factory = FakeFactory::default();
615 factory.state.borrow_mut().list_format = Some(format);
616 let mut app = ArchiveApp::new(Box::new(factory.clone()), Some(path("input.archive")), true);
617 pump(&mut app.model);
618 let render = |app: &mut ArchiveApp, events| {
619 fn walk(shape: &Shape, output: &mut Vec<(String, egui::Pos2)>) {
620 match shape {
621 Shape::Text(text) => output.push((
622 text.galley.job.text.clone(),
623 text.pos + text.galley.rect.size() / 2.0,
624 )),
625 Shape::Vec(shapes) => {
626 for shape in shapes {
627 walk(shape, output);
628 }
629 }
630 _ => {}
631 }
632 }
633 let mut frame = ctx.run_ui(
634 egui::RawInput {
635 screen_rect: Some(egui::Rect::from_min_size(
636 egui::Pos2::ZERO,
637 egui::vec2(1060.0, 720.0),
638 )),
639 events,
640 ..Default::default()
641 },
642 |ui| app.show(ui),
643 );
644 frame.textures_delta.clear();
645 let mut output = Vec::new();
646 for shape in frame.shapes {
647 walk(&shape.shape, &mut output);
648 }
649 output
650 };
651 let click = |app: &mut ArchiveApp, point| {
652 render(
653 app,
654 vec![
655 egui::Event::PointerMoved(point),
656 egui::Event::PointerButton {
657 pos: point,
658 button: egui::PointerButton::Primary,
659 pressed: true,
660 modifiers: Default::default(),
661 },
662 ],
663 );
664 render(
665 app,
666 vec![egui::Event::PointerButton {
667 pos: point,
668 button: egui::PointerButton::Primary,
669 pressed: false,
670 modifiers: Default::default(),
671 }],
672 );
673 };
674 let scratch = presentation::Folder::new();
675 app.choose_destination(scratch.0.clone());
676 render(&mut app, vec![]);
677 let dialogs = dialogs::TestDialogs::default();
678 dialogs
679 .0
680 .borrow_mut()
681 .answers
682 .push_back(Some(vec![if format == Format::Gzip {
683 scratch.0.join("압축 해제 파일")
684 } else {
685 scratch.0.clone()
686 }]));
687 app.set_dialogs(Box::new(dialogs));
688 let texts = render(&mut app, vec![]);
689 let button = texts
690 .iter()
691 .rev()
692 .find(|(text, _)| text == "압축해제")
693 .unwrap()
694 .1;
695 click(&mut app, button);
696 let state = factory.state.borrow();
697 assert_eq!(
698 state.starts.len(),
699 2,
700 "풀기 버튼의 Start 요청 누락: {format:?}"
701 );
702 match state.starts.last().unwrap() {
703 Start::Extract {
704 gzip_output_name, ..
705 } => assert_eq!(
706 gzip_output_name,
707 &if format == Format::Gzip {
708 Some("압축 해제 파일".into())
709 } else {
710 None
711 }
712 ),
713 _ => panic!("Extract 요청 누락"),
714 }
715 }
716}
717
718#[test]
719fn fake_worker_rejects_invalid_format_specific_output_names() {
720 for (format, name) in [
721 (Format::Zip, Some("stale.txt".into())),
722 (Format::Tar, Some(String::new())),
723 (Format::TarGzip, Some("stale.txt".into())),
724 (Format::Gzip, None),
725 (Format::Gzip, Some("../escape".into())),
726 ] {
727 let mut factory = FakeFactory::default();
728 factory.state.borrow_mut().list_format = Some(format);
729 let mut model = Model::default();
730 list(&mut model, &mut factory);
731 let mut connection = factory.connect(2).unwrap();
732 let previous = factory.state.borrow().starts.len();
733 assert!(
734 connection
735 .send(Request {
736 job_id: 2,
737 sequence: 0,
738 command: Command::Start(Start::Extract {
739 archive: model.archive.clone().unwrap(),
740 destination: path("output"),
741 selection: Selection::All,
742 list_id: model.list_id.clone().unwrap(),
743 gzip_output_name: name,
744 }),
745 })
746 .is_err()
747 );
748 assert_eq!(factory.state.borrow().starts.len(), previous);
749 }
750}
751
752#[test]
753fn cleanup_marker_without_error_does_not_replace_eofs() {
754 let mut factory = FakeFactory::manual();
755 let mut model = Model::default();
756 assert!(model.begin(
757 Start::List {
758 archive: path("sample.zip")
759 },
760 &mut factory
761 ));
762 factory
763 .state
764 .borrow_mut()
765 .queue
766 .push_back(HostEvent::CleanupComplete);
767 factory
768 .state
769 .borrow_mut()
770 .queue
771 .push_back(HostEvent::Exited { success: true });
772 for _ in 0..10 {
773 model.poll();
774 }
775 assert!(model.busy());
776 factory
777 .state
778 .borrow_mut()
779 .queue
780 .push_back(HostEvent::StdoutEof);
781 for _ in 0..10 {
782 model.poll();
783 }
784 assert!(model.busy());
785 factory
786 .state
787 .borrow_mut()
788 .queue
789 .push_back(HostEvent::StderrEof);
790 pump(&mut model);
791 assert!(!model.confirmed);
792}
793
794#[test]
795fn error_cleanup_requires_child_wait_without_fabricating_terminal() {
796 let mut factory = FakeFactory::manual();
797 let mut model = Model::default();
798 assert!(model.begin(
799 Start::List {
800 archive: path("sample.zip")
801 },
802 &mut factory
803 ));
804 factory
805 .state
806 .borrow_mut()
807 .queue
808 .push_back(HostEvent::Fault("pipe error".into()));
809 factory
810 .state
811 .borrow_mut()
812 .queue
813 .push_back(HostEvent::CleanupComplete);
814 model.request_close();
815 model.confirm_close();
816 for _ in 0..10 {
817 model.poll();
818 }
819 assert!(model.busy());
820 assert_eq!(model.close, Close::Waiting);
821 factory
822 .state
823 .borrow_mut()
824 .queue
825 .push_back(HostEvent::Exited { success: false });
826 pump(&mut model);
827 assert!(!model.confirmed);
828 assert!(model.terminal.is_none());
829 assert_eq!(model.error.as_deref(), Some("pipe error"));
830 assert_eq!(model.close, Close::Review);
831}
832
833#[test]
834fn password_validation_and_retry_do_not_erase_transport_failure() {
835 let mut factory = FakeFactory::default();
836 let mut model = Model::default();
837 assert!(model.begin(
838 Start::List {
839 archive: path("locked.zip")
840 },
841 &mut factory
842 ));
843 for _ in 0..10 {
844 model.poll();
845 if model.challenge.is_some() {
846 break;
847 }
848 }
849 assert!(model.challenge.is_some());
850 factory
851 .state
852 .borrow_mut()
853 .queue
854 .push_back(HostEvent::Fault("pipe error".into()));
855 for _ in 0..10 {
856 model.poll();
857 if model.error.is_some() {
858 break;
859 }
860 }
861 assert_eq!(model.error.as_deref(), Some("pipe error"));
862 assert!(!model.password(String::new()));
863 assert!(model.input_error.as_ref().unwrap().contains("1~1024바이트"));
864 assert_eq!(model.error.as_deref(), Some("pipe error"));
865 assert!(model.password("synthetic password".into()));
866 pump(&mut model);
867 assert!(model.input_error.is_none());
868 assert_eq!(model.error.as_deref(), Some("pipe error"));
869 assert!(!model.confirmed);
870}
871
872mod presentation;
873
874mod windows_paths;
875
876mod guarded;