team-ljyzipelo

공개
734줄29 KB
1#![cfg(debug_assertions)]
2
3use eframe::egui;
4use std::{collections::BTreeSet, ffi::OsString};
5use zipelo_ui_memory_app::archive_screen::scenarios::{self, Launch, SCENARIOS};
6
7#[test]
8fn every_name_round_trips_and_listing_has_no_duplicates() {
9 let names: BTreeSet<_> = SCENARIOS.iter().map(|s| s.name).collect();
10 assert_eq!(names.len(), SCENARIOS.len());
11 for scenario in SCENARIOS {
12 assert_eq!(scenarios::parse(scenario.name), Ok(*scenario));
13 assert!(scenarios::listing().contains(scenario.description));
14 assert!(
15 include_str!("../../docs/ui-scenario-guide.md")
16 .contains(&format!("- {}:", scenario.name))
17 );
18 assert_eq!(
19 scenarios::launch(vec!["--ui-scenario".into(), scenario.name.into()]),
20 Ok(Launch::Scenario(*scenario)),
21 );
22 }
23 assert_eq!(
24 scenarios::launch(vec!["--list-ui-scenarios".into()]),
25 Ok(Launch::List)
26 );
27}
28
29#[test]
30fn unknown_missing_and_conflicting_arguments_are_rejected_with_catalog() {
31 for args in [
32 vec!["--ui-scenario", "missing"],
33 vec!["--ui-scenario"],
34 vec!["--ui-scenario", "archive", "file.zip"],
35 vec!["--list-ui-scenarios", "file.zip"],
36 vec!["--ui-fixture", "--ui-scenario", "archive"],
37 ] {
38 let error = scenarios::launch(args.into_iter().map(OsString::from).collect()).unwrap_err();
39 for scenario in SCENARIOS {
40 assert!(error.contains(scenario.name));
41 }
42 }
43 let original = vec![OsString::from("압축 자료.zip")];
44 assert_eq!(
45 scenarios::launch(original.clone()),
46 Ok(Launch::Normal(original))
47 );
48}
49
50fn text(shapes: &[egui::epaint::ClippedShape]) -> String {
51 fn collect(shape: &egui::Shape, result: &mut String) {
52 match shape {
53 egui::Shape::Text(t) => {
54 result.push_str(t.galley.text());
55 result.push('\n');
56 }
57 egui::Shape::Vec(shapes) => {
58 for shape in shapes {
59 collect(shape, result);
60 }
61 }
62 _ => {}
63 }
64 }
65 let mut result = String::new();
66 for shape in shapes {
67 collect(&shape.shape, &mut result);
68 }
69 result
70}
71
72#[test]
73fn every_listed_scenario_draws_and_keeps_its_expected_screen() {
74 for scenario in SCENARIOS {
75 for size in [egui::vec2(1060.0, 720.0), egui::vec2(760.0, 540.0)] {
76 let ctx = egui::Context::default();
77 let mut app = scenario.build();
78 let mut labels = String::new();
79 for _ in 0..3 {
80 let mut output = ctx.run_ui(
81 egui::RawInput {
82 screen_rect: Some(egui::Rect::from_min_size(egui::Pos2::ZERO, size)),
83 ..Default::default()
84 },
85 |ui| scenario.show(&mut app, ui),
86 );
87 assert!(!output.shapes.is_empty(), "{}", scenario.name);
88 labels = text(&output.shapes);
89 output.textures_delta.clear();
90 }
91 assert!(
92 app.model.error.is_none(),
93 "{}: {:?}",
94 scenario.name,
95 app.model.error
96 );
97 assert!(app.model.input_error.is_none(), "{}", scenario.name);
98 if scenario.name.starts_with("recovery-") {
99 let expected = match scenario.name {
100 "recovery-complete" => "복구본 저장 완료",
101 "recovery-partial" => "일부 항목만 복구함",
102 "recovery-unknown" => "전체 목록을 알 수 없어",
103 "recovery-impossible" => "복구 가능한 항목 없음",
104 "recovery-save-error" | "recovery-retained" => {
105 "복구본 저장을 완료하지 못했습니다"
106 }
107 "recovery-cancelled" => "복구를 취소했습니다",
108 "recovery-resource" => "이 작업 허용",
109 _ => "ZIP 복구 중",
110 };
111 assert!(labels.contains(expected), "{}: {labels}", scenario.name);
112 assert_eq!(
113 labels.contains("복구본 열기"),
114 matches!(
115 scenario.name,
116 "recovery-complete" | "recovery-partial" | "recovery-unknown"
117 )
118 );
119 assert!(!labels.contains("100%"));
120 if scenario.name == "recovery-retained" {
121 assert!(labels.contains("남은 임시 파일:"), "{labels}");
122 assert!(labels.contains(".zipelo-42-1.tmp"), "{labels}");
123 assert!(app.model.confirmed);
124 assert!(!app.model.can_retry_expanded());
125 }
126 }
127 if scenario.name == "split-archive" {
128 assert!(app.model.list_id.as_ref().unwrap().is_split());
129 assert!(!app.model.can_preview());
130 }
131 let expected = match scenario.name {
132 "split-archive" => "읽어주세요.txt",
133 "split-first-volume" => "첫 조각 여행.7z.001을 선택해 다시 여세요.",
134 "split-missing-volume" => "여행.7z.003 조각이 없습니다",
135 "split-incomplete" => "분할 묶음이 불완전하거나 손상됐습니다",
136 "split-unsupported" => "분할 ZIP과 RAR",
137 "split-source-changed" => "원본 파일이 바뀌었습니다",
138 "preview-implicit-folder" => "자료",
139 "preview-catalog-approval" | "preview-catalog-bytes-approval" => {
140 "큰 작업을 허용할까요?"
141 }
142 "preview-loading" => "미리보기를 불러오는 중입니다",
143 "preview-text" => "여행 준비 목록",
144 "preview-image" => "미리보기",
145 "preview-empty" => "빈 텍스트 파일입니다",
146 "preview-limit" => "미리보기 크기 또는 처리 한도를 초과했습니다",
147 "preview-damaged" => "파일이 손상됐거나 UTF-8 텍스트가 아닙니다",
148 "preview-unsupported" => "이 파일 형식은 미리보기를 지원하지 않습니다",
149 "resource-approval" => "큰 작업을 허용할까요?",
150 "resource-ratio" => "압축률이 매우 높습니다",
151 "resource-retry" => "한도를 늘려 다시 시도",
152 "resource-partial" => "저장 위치를 확인하세요",
153 "uninstall-windows" => "제거 전에 다른 앱을 선택하세요",
154 "uninstall-settings-error" => "Windows 설정을 열지 못했습니다",
155 "uninstall-ubuntu-missing" => "이전 앱을 복원할 수 없습니다",
156 "uninstall-ubuntu-unknown-user" => "사용자 기본 앱 설정은 변경하지 않습니다",
157 "conflict-choice" | "conflict-apply" | "gzip-conflict-choice" => {
158 "나머지 파일에도 같게 적용"
159 }
160 "extract-skipped" => "모든 파일을 건너뛰었습니다",
161 "extract-rename-failed" => "아무 파일도 풀지 않았습니다",
162 "extract-renamed" => "이름 바꿔 저장: 읽어주세요 (1).txt",
163 "empty" => "TAR.BZ2, TAR.XZ",
164 "tar-bz2" | "tar-xz" => "읽어주세요.txt",
165 "folder-empty" => "이 폴더는 비어 있습니다",
166 "dialog-error" => "파일 선택 창을 열 수 없습니다",
167 "extract-disk-full" => "디스크 여유 공간이 부족합니다",
168 "extract-cleanup-failed" => "풀 위치 폴더에 남은 임시 파일이 있을 수 있습니다",
169 "extract-partial" => "일부 파일만 풀렸습니다",
170 "extract-uncertain" => "저장이 끝났는지 확인하지 못했습니다",
171 "extract-unsynced" => "파일을 디스크에 완전히 저장했는지 확인하지 못했습니다",
172 "source-changed" => "압축파일 다시 열기",
173 "gzip-conflict" => "다른 이름으로 저장",
174 "create-sevenzip" => "7z는 암호를 지원하지 않습니다",
175 "create-sevenzip-progress" => "파일을 저장하는 중",
176 "create-sevenzip-complete" => "7z 파일을 만들었습니다",
177 "create-sevenzip-error" => "7z 파일을 만들지 못했습니다",
178 "create-sevenzip-cancelled" => "작업을 취소했습니다",
179 "create-sevenzip-resource" => "큰 작업을 허용할까요?",
180 "create-error" => "ZIP 파일을 만들지 못했습니다",
181 "password-create" => "암호 확인",
182 "folder" => "바다.jpg",
183 "search-empty" => "일치하는 항목이 없습니다",
184 "password" | "password-retry" => "암호",
185 "extract-complete" => "압축을 풀었습니다",
186 "extract-cancelled" => "작업을 취소했습니다",
187 "create-complete" => "ZIP 파일을 만들었습니다",
188 "create" | "create-encrypted" => "암호로 보호하기",
189 "unsupported" | "damaged" => "압축파일을 열지 못했습니다",
190 "conflict" => "압축을 풀지 못했습니다",
191 "close-confirm" => "닫",
192 _ => "읽어주세요.txt",
193 };
194 assert!(labels.contains(expected), "{}: {labels}", scenario.name);
195 if matches!(
196 scenario.name,
197 "extract-disk-full" | "extract-cleanup-failed"
198 ) {
199 use zipelo_ui_memory_app::archive_ui::{Cleanup, ErrorCode, Outcome, Publication};
200 let cleanup_failed = scenario.name == "extract-cleanup-failed";
201 let terminal = app.model.terminal.as_ref().unwrap();
202 assert!(app.model.confirmed);
203 assert_eq!(terminal.outcome, Outcome::Failed);
204 assert_eq!(terminal.publication, Publication::None);
205 assert_eq!(terminal.created_count, 0);
206 assert_eq!(terminal.retained_partial_count, 0);
207 assert_eq!(
208 terminal.error,
209 Some(if cleanup_failed {
210 ErrorCode::Io
211 } else {
212 ErrorCode::DiskFull
213 })
214 );
215 assert_eq!(
216 terminal.cleanup,
217 if cleanup_failed {
218 Cleanup::Failed
219 } else {
220 Cleanup::Complete
221 }
222 );
223 assert!(labels.contains("압축을 풀지 못했습니다"), "{labels}");
224 assert!(!labels.contains("압축을 풀었습니다"), "{labels}");
225 assert_eq!(
226 labels.contains("임시 파일을 지우지 못했습니다"),
227 cleanup_failed
228 );
229 if cleanup_failed {
230 assert!(!labels.contains("아무 파일도 풀지 않았습니다"), "{labels}");
231 } else {
232 assert!(
233 labels.contains("공간을 확보한 뒤 다시 시도하세요"),
234 "{labels}"
235 );
236 assert!(labels.contains("아무 파일도 풀지 않았습니다"), "{labels}");
237 }
238 }
239 if scenario.name == "extract-rename-failed" {
240 assert!(labels.contains("파일을 읽거나 쓰지 못했습니다"), "{labels}");
241 assert!(!labels.contains("이름 바꿔 저장:"), "{labels}");
242 }
243 if matches!(scenario.name, "tar-bz2" | "tar-xz") {
244 assert!(app.model.entries.iter().all(|entry| !entry.encrypted));
245 assert_eq!(
246 app.model.list_id.as_ref().unwrap().format,
247 zipelo_ui_memory_app::archive_ui::Format::Tar
248 );
249 }
250 if scenario.name == "many-items" {
251 assert_eq!(app.model.entries.len(), 505);
252 }
253 if matches!(scenario.name, "selection" | "marquee") {
254 assert_eq!(app.model.selected.len(), 4);
255 assert!(labels.contains("선택 2개"));
256 }
257 if scenario.name == "password-retry" {
258 assert_eq!(app.model.challenge.unwrap().1, 2);
259 }
260 }
261 }
262}
263
264#[test]
265fn command_line_catalog_and_errors_work_without_a_display() {
266 let run = |args: &[&str]| {
267 std::process::Command::new(env!("CARGO_BIN_EXE_zipelo-ui-memory-app"))
268 .args(args)
269 .env_remove("DISPLAY")
270 .env_remove("WAYLAND_DISPLAY")
271 .output()
272 .unwrap()
273 };
274 let listed = run(&["--list-ui-scenarios"]);
275 assert!(listed.status.success());
276 assert_eq!(
277 String::from_utf8(listed.stdout).unwrap(),
278 scenarios::listing()
279 );
280 for args in [vec!["--ui-scenario", "unknown"], vec!["--ui-scenario"]] {
281 let failed = run(&args);
282 assert!(!failed.status.success());
283 let stderr = String::from_utf8_lossy(&failed.stderr);
284 for scenario in SCENARIOS {
285 assert!(stderr.contains(scenario.name));
286 }
287 }
288}
289
290#[test]
291fn preview_ignores_password_submission() {
292 let ctx = egui::Context::default();
293 let mut preview = scenarios::Preview::new(scenarios::parse("password").unwrap().build(), &ctx);
294 for _ in 0..3 {
295 let mut output = ctx.run_ui(
296 egui::RawInput {
297 screen_rect: Some(egui::Rect::from_min_size(
298 egui::Pos2::ZERO,
299 egui::vec2(1060.0, 720.0),
300 )),
301 events: vec![
302 egui::Event::Text("화면 검토".into()),
303 egui::Event::Key {
304 key: egui::Key::Enter,
305 physical_key: None,
306 pressed: true,
307 repeat: false,
308 modifiers: egui::Modifiers::NONE,
309 },
310 ],
311 ..Default::default()
312 },
313 |ui| preview.0.show(ui),
314 );
315 output.textures_delta.clear();
316 }
317 assert_eq!(preview.0.model.challenge, Some((17, 1, false)));
318 assert!(preview.0.model.busy());
319}
320
321#[test]
322fn uninstall_previews_match_packaged_notices_and_do_not_start_jobs() {
323 let installer = include_str!("../../packaging/windows/rust/installer.nsi");
324 let prerm = include_str!("../../packaging/ubuntu/rust/prerm");
325 let helper = include_str!("../../packaging/ubuntu/rust/default-apps");
326 for (name, source, expected) in [
327 (
328 "uninstall-windows",
329 installer,
330 "직접 고른 기본 앱은 자동으로 바꾸지 않습니다.",
331 ),
332 (
333 "uninstall-settings-error",
334 installer,
335 "Windows 설정을 열지 못했습니다.",
336 ),
337 (
338 "uninstall-ubuntu-missing",
339 helper,
340 "이전 앱을 복원할 수 없습니다:",
341 ),
342 (
343 "uninstall-ubuntu-unknown-user",
344 prerm,
345 "제거를 요청한 사용자를 확인할 수 없어 사용자 기본 앱 설정은 변경하지 않습니다.",
346 ),
347 ] {
348 assert!(source.contains(expected));
349 let scenario = scenarios::parse(name).unwrap();
350 let ctx = egui::Context::default();
351 let mut preview = scenarios::Preview::new(scenario.build(), &ctx).with_scenario(scenario);
352 let mut output = ctx.run_ui(
353 egui::RawInput {
354 screen_rect: Some(egui::Rect::from_min_size(
355 egui::Pos2::ZERO,
356 egui::vec2(760.0, 540.0),
357 )),
358 events: vec![egui::Event::Key {
359 key: egui::Key::Enter,
360 physical_key: None,
361 pressed: true,
362 repeat: false,
363 modifiers: egui::Modifiers::NONE,
364 }],
365 ..Default::default()
366 },
367 |ui| preview.show(ui),
368 );
369 assert!(text(&output.shapes).contains(expected), "{name}");
370 assert!(!preview.0.model.busy());
371 assert!(preview.0.model.archive.is_none());
372 assert!(output.platform_output.commands.is_empty());
373 output.textures_delta.clear();
374 }
375}
376
377fn result_labels(
378 app: &mut zipelo_ui_memory_app::archive_screen::ArchiveApp,
379 size: egui::Vec2,
380) -> String {
381 let ctx = egui::Context::default();
382 let mut labels = String::new();
383 for _ in 0..3 {
384 let mut output = ctx.run_ui(
385 egui::RawInput {
386 screen_rect: Some(egui::Rect::from_min_size(egui::Pos2::ZERO, size)),
387 ..Default::default()
388 },
389 |ui| app.show(ui),
390 );
391 labels = text(&output.shapes);
392 output.textures_delta.clear();
393 }
394 labels
395}
396
397#[test]
398fn rename_without_created_output_never_claims_saved_name() {
399 use zipelo_ui_memory_app::archive_ui::*;
400 for size in [egui::vec2(1060.0, 720.0), egui::vec2(760.0, 540.0)] {
401 for disposition in [
402 None,
403 Some(Disposition::PartialRetained),
404 Some(Disposition::Removed),
405 Some(Disposition::CommitUncertain),
406 ] {
407 let mut app = scenarios::parse("extract-renamed").unwrap().build();
408 app.model.outputs = disposition
409 .into_iter()
410 .map(|d| ("읽어주세요 (1).txt".into(), d))
411 .collect();
412 app.model.terminal = Some(Terminal {
413 outcome: Outcome::Failed,
414 error: Some(ErrorCode::Io),
415 publication: if disposition.is_none() {
416 Publication::None
417 } else {
418 Publication::Uncertain
419 },
420 created_count: 0,
421 retained_partial_count: 0,
422 durability: Durability::NotApplicable,
423 cleanup: Cleanup::Complete,
424 });
425 let labels = result_labels(&mut app, size);
426 assert!(labels.contains("파일을 읽거나 쓰지 못했습니다"), "{labels}");
427 if disposition.is_none() {
428 assert!(labels.contains("아무 파일도 풀지 않았습니다"), "{labels}");
429 }
430 assert!(
431 !labels.contains("이름 바꿔 저장: 읽어주세요 (1).txt"),
432 "{labels}"
433 );
434 }
435 }
436}
437
438#[test]
439fn rename_saved_before_later_failure_remains_reported() {
440 use zipelo_ui_memory_app::archive_ui::*;
441 for size in [egui::vec2(1060.0, 720.0), egui::vec2(760.0, 540.0)] {
442 let mut app = scenarios::parse("extract-renamed").unwrap().build();
443 app.model.resolutions.push(Resolution {
444 entry_id: 2,
445 relative_name: "여행 일정 (1).pdf".into(),
446 choice: ConflictChoice::Rename,
447 });
448 app.model.terminal.as_mut().unwrap().outcome = Outcome::Failed;
449 app.model.terminal.as_mut().unwrap().error = Some(ErrorCode::Io);
450 app.model.terminal.as_mut().unwrap().publication = Publication::Partial;
451 let labels = result_labels(&mut app, size);
452 assert!(
453 labels.contains("이름 바꿔 저장: 읽어주세요 (1).txt"),
454 "{labels}"
455 );
456 assert!(
457 !labels.contains("이름 바꿔 저장: 여행 일정 (1).pdf"),
458 "{labels}"
459 );
460 assert!(labels.contains("파일을 읽거나 쓰지 못했습니다"), "{labels}");
461 }
462}
463
464fn resource_frame(
465 app: &mut zipelo_ui_memory_app::archive_screen::ArchiveApp,
466 ctx: &egui::Context,
467 events: Vec<egui::Event>,
468) -> Vec<egui::epaint::ClippedShape> {
469 let mut out = ctx.run_ui(
470 egui::RawInput {
471 screen_rect: Some(egui::Rect::from_min_size(
472 egui::Pos2::ZERO,
473 egui::vec2(760.0, 540.0),
474 )),
475 events,
476 ..Default::default()
477 },
478 |ui| app.show(ui),
479 );
480 out.textures_delta.clear();
481 out.shapes
482}
483fn find_resource_action(shapes: &[egui::epaint::ClippedShape], label: &str) -> egui::Pos2 {
484 fn find(s: &egui::Shape, label: &str) -> Option<egui::Pos2> {
485 match s {
486 egui::Shape::Text(t) if t.galley.text() == label => {
487 Some(t.pos + t.galley.rect.size() / 2.0)
488 }
489 egui::Shape::Vec(shapes) => shapes.iter().find_map(|s| find(s, label)),
490 _ => None,
491 }
492 }
493 shapes.iter().find_map(|s| find(&s.shape, label)).unwrap()
494}
495#[test]
496fn resource_dialog_requires_explicit_click_and_escape_cancels() {
497 for allow in [false, true] {
498 let ctx = egui::Context::default();
499 let mut app = scenarios::parse("resource-ratio").unwrap().build();
500 let mut shapes = Vec::new();
501 for _ in 0..3 {
502 shapes = resource_frame(&mut app, &ctx, vec![]);
503 }
504 assert!(text(&shapes).contains("미확인"));
505 resource_frame(
506 &mut app,
507 &ctx,
508 vec![egui::Event::Key {
509 key: egui::Key::Enter,
510 physical_key: None,
511 pressed: true,
512 repeat: false,
513 modifiers: Default::default(),
514 }],
515 );
516 assert!(app.model.resource.is_some());
517 if allow {
518 let point = find_resource_action(&shapes, "이 작업 허용");
519 resource_frame(
520 &mut app,
521 &ctx,
522 vec![
523 egui::Event::PointerMoved(point),
524 egui::Event::PointerButton {
525 pos: point,
526 button: egui::PointerButton::Primary,
527 pressed: true,
528 modifiers: Default::default(),
529 },
530 ],
531 );
532 resource_frame(
533 &mut app,
534 &ctx,
535 vec![egui::Event::PointerButton {
536 pos: point,
537 button: egui::PointerButton::Primary,
538 pressed: false,
539 modifiers: Default::default(),
540 }],
541 );
542 assert!(!app.model.cancellation_requested());
543 } else {
544 resource_frame(
545 &mut app,
546 &ctx,
547 vec![egui::Event::Key {
548 key: egui::Key::Escape,
549 physical_key: None,
550 pressed: true,
551 repeat: false,
552 modifiers: Default::default(),
553 }],
554 );
555 assert!(app.model.cancellation_requested());
556 }
557 assert!(app.model.resource.is_none());
558 }
559}
560#[test]
561fn partial_limit_result_never_offers_expanded_retry() {
562 let ctx = egui::Context::default();
563 let mut app = scenarios::parse("resource-partial").unwrap().build();
564 let mut shapes = Vec::new();
565 for _ in 0..3 {
566 shapes = resource_frame(&mut app, &ctx, vec![]);
567 }
568 assert!(!text(&shapes).contains("한도를 늘려 다시 시도"));
569 assert!(text(&shapes).contains("풀린 자료"));
570}
571
572#[test]
573fn preview_escape_discards_content_and_returns_to_list_without_changing_selection() {
574 for name in ["preview-text", "preview-image", "preview-loading"] {
575 let ctx = egui::Context::default();
576 let mut app = scenarios::parse(name).unwrap().build();
577 let selected = app.model.selected.clone();
578 for _ in 0..3 {
579 resource_frame(&mut app, &ctx, vec![]);
580 }
581 assert!(text(&resource_frame(&mut app, &ctx, vec![])).contains("미리보기"));
582 resource_frame(
583 &mut app,
584 &ctx,
585 vec![egui::Event::Key {
586 key: egui::Key::Escape,
587 physical_key: None,
588 pressed: true,
589 repeat: false,
590 modifiers: Default::default(),
591 }],
592 );
593 for _ in 0..3 {
594 resource_frame(&mut app, &ctx, vec![]);
595 }
596 assert!(app.model.preview.is_none());
597 assert_eq!(app.model.selected, selected);
598 if name == "preview-loading" {
599 assert!(app.model.cancellation_requested());
600 } else {
601 assert_eq!(
602 ctx.memory(|m| m.focused()),
603 Some(egui::Id::unique("archive-list"))
604 );
605 }
606 }
607}
608
609#[test]
610fn preview_image_respects_renderer_texture_limit() {
611 let ctx = egui::Context::default();
612 let mut app = scenarios::parse("preview-image").unwrap().build();
613 app.model.preview = Some(zipelo_ui_memory_app::archive_ui::Preview {
614 info: zipelo_ui_memory_app::archive_ui::PreviewInfo {
615 entry_id: 1,
616 format: zipelo_ui_memory_app::archive_ui::PreviewFormat::Rgba8,
617 width: 2048,
618 height: 1,
619 total_bytes: 8192,
620 },
621 data: vec![255; 8192],
622 });
623 let mut image_seen = false;
624 for _ in 0..3 {
625 let mut result = ctx.run_ui(
626 egui::RawInput {
627 max_texture_side: Some(1024),
628 screen_rect: Some(egui::Rect::from_min_size(
629 egui::Pos2::ZERO,
630 egui::vec2(760.0, 540.0),
631 )),
632 ..Default::default()
633 },
634 |ui| app.show(ui),
635 );
636 for (id, delta) in &result.textures_delta.set {
637 if *id == egui::TextureId::Managed(0) {
638 continue;
639 }
640 for image in delta {
641 assert!(image.image.size().iter().all(|n| *n <= 1024));
642 }
643 image_seen = true;
644 }
645 result.textures_delta.clear();
646 }
647 assert!(image_seen);
648}
649
650#[test]
651fn split_errors_use_main_modal_without_native_child() {
652 for name in [
653 "split-first-volume",
654 "split-missing-volume",
655 "split-incomplete",
656 "split-unsupported",
657 ] {
658 let scenario = scenarios::parse(name).unwrap();
659 let mut app = scenario.build();
660 let ctx = egui::Context::default();
661 ctx.set_embed_viewports(false);
662 let mut labels = String::new();
663 for _ in 0..3 {
664 let mut output = ctx.run_ui(
665 egui::RawInput {
666 screen_rect: Some(egui::Rect::from_min_size(
667 egui::Pos2::ZERO,
668 egui::vec2(1060.0, 720.0),
669 )),
670 ..Default::default()
671 },
672 |ui| scenario.show(&mut app, ui),
673 );
674 labels = text(&output.shapes);
675 output.textures_delta.clear();
676 assert!(
677 output
678 .viewport_output
679 .keys()
680 .all(|id| *id == egui::ViewportId::ROOT),
681 "{name}"
682 );
683 }
684 assert!(labels.contains("작업 결과"), "{name}: {labels}");
685 }
686}
687
688#[test]
689fn excluded_split_errors_show_support_guidance_in_main_modal() {
690 use zipelo_ui_memory_app::archive_ui::ErrorCode;
691
692 for code in [ErrorCode::UnsupportedFeature, ErrorCode::UnsupportedFormat] {
693 for archive in ["sample.zip.001", "sample.z01", "sample.rar", "sample.7z"] {
694 let scenario = scenarios::parse("split-unsupported").unwrap();
695 let mut app = scenario.build();
696 let ctx = egui::Context::default();
697 ctx.set_embed_viewports(false);
698 let input = || egui::RawInput {
699 screen_rect: Some(egui::Rect::from_min_size(
700 egui::Pos2::ZERO,
701 egui::vec2(1060.0, 720.0),
702 )),
703 ..Default::default()
704 };
705 for _ in 0..3 {
706 let mut output = ctx.run_ui(input(), |ui| scenario.show(&mut app, ui));
707 output.textures_delta.clear();
708 }
709 assert_eq!(
710 app.model.terminal.as_ref().unwrap().error,
711 Some(ErrorCode::UnsupportedFeature)
712 );
713 app.model.terminal.as_mut().unwrap().error = Some(code);
714 app.model.archive = Some(archive.into());
715 let mut output = ctx.run_ui(input(), |ui| scenario.show(&mut app, ui));
716 let labels = text(&output.shapes);
717 output.textures_delta.clear();
718 if archive == "sample.7z" {
719 assert!(!labels.contains("분할 ZIP과 RAR"));
720 } else {
721 assert!(
722 labels.contains("분할 ZIP과 RAR"),
723 "{code:?} {archive}: {labels}"
724 );
725 assert!(
726 output
727 .viewport_output
728 .keys()
729 .all(|id| *id == egui::ViewportId::ROOT)
730 );
731 }
732 }
733 }
734}