team-ljyzipelo

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