team-ljyzipelo

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