team-ljyzipelo

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