team-ljyzipelo

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