team-ljyzipelo

공개

UI 상황별 실행 명령과 가이드를 추가

작성자
호시노 히나타
작성 시각
커밋
17f7a8216863a57a47cd0ad07261244fb420ebc2
부모
59d05a6
이 시점의 파일 보기

변경된 파일 11개

+805-9
수정docs/ui-design-v0.1.md+2-0
@@ -2,6 +2,8 @@
22
33이 문서는 v0.1 앱 화면의 배치, 문구, 색과 간격, 구현 수용 기준을 정한다. 구현은 frontend 담당이 하고, 이 문서는 구현 요청의 기준이다. 기준은 이준영 님의 초기 시안과 이후 직접 올려 병합된 UI 변경이다. 진행/결과 창과 ZIP 만들기 흐름은 PR95와 PR100이 병합된 main 97357bd의 동작을 반영한다.
44
5추가: 화면을 상황별로 바로 띄우는 방법은 [UI 상황 디버깅 가이드](ui-scenario-guide.md)를 따른다.
6추가:
57## 1. 전제와 제약
68
79- 처음 쓰는 사람이 설명 없이 "열기 후 풀기"와 "ZIP 만들기"를 끝낼 수 있어야 한다.
추가docs/ui-scenario-guide.md+95-0
@@ -0,0 +1,95 @@
1추가: # UI 상황 디버깅 가이드
2추가:
3추가: 실제 압축파일이나 작업자 프로세스 없이 원하는 화면을 바로 연다. 현재 제품의 위젯과 배치를 그대로 사용하며 진행률은 고정된다. 화면을 검토하기 위한 미리보기이므로 버튼, 암호 입력, 파일 끌어 놓기 등 조작은 받지 않는다. 창을 닫고 다른 상황 이름으로 다시 실행한다. 실제 조작 시험에는 기존 --ui-fixture 실행을 사용한다.
4추가:
5추가: 이 기능은 debug_assertions가 켜지고 ui-fixture feature를 활성화한 개발 빌드에서만 제공한다. 일반 빌드와 --release 빌드에는 상황 목록과 구성 코드가 들어가지 않는다. 릴리스 설치 파일은 ui feature만 사용한다. 화면에 표시되는 /Samples와 C:\Samples 경로는 가상 경로이며 파일이나 폴더를 만들 필요가 없다.
6추가:
7추가: ## Ubuntu
8추가:
9추가: 저장소 최상위에서 실행한다. Rust 1.99.1과 기존 프로젝트의 Linux GUI 빌드 도구가 필요하다. 빌드 결과와 임시 파일은 tests/work 안에 둔다.
10추가:
11추가: ~~~bash
12추가: mkdir -p tests/work/tmp
13추가: export TMPDIR="$PWD/tests/work/tmp"
14추가: export CARGO_TARGET_DIR="$PWD/tests/work/ui-scenario-target"
15추가: cargo +1.99.1 build --locked --manifest-path experiments/rust-ui-memory-app/Cargo.toml --features ui-fixture --bin zipelo-ui-memory-app
16추가:
17추가: "$CARGO_TARGET_DIR/debug/zipelo-ui-memory-app" --list-ui-scenarios
18추가: "$CARGO_TARGET_DIR/debug/zipelo-ui-memory-app" --ui-scenario password
19추가: "$CARGO_TARGET_DIR/debug/zipelo-ui-memory-app" --ui-scenario create-encrypted
20추가: ~~~
21추가:
22추가: 현재 데스크톱 세션에서 실행한다. 목록과 이름 오류 확인은 DISPLAY나 Wayland 연결 없이도 된다.
23추가:
24추가: ## Windows
25추가:
26추가: Rust 1.99.1, Visual Studio C++ 빌드 도구와 Windows SDK가 설치된 환경의 PowerShell에서 저장소 최상위로 이동해 실행한다. 프로젝트 자체의 외부 crate는 추가하지 않는다.
27추가:
28추가: ~~~powershell
29추가: New-Item -ItemType Directory -Force tests/work/tmp | Out-Null
30추가: $env:TMP = Join-Path $PWD "tests/work/tmp"
31추가: $env:TEMP = $env:TMP
32추가: $env:CARGO_TARGET_DIR = Join-Path $PWD "tests/work/ui-scenario-target"
33추가: cargo +1.99.1 build --locked --manifest-path experiments/rust-ui-memory-app/Cargo.toml --features ui-fixture --bin zipelo-ui-memory-app
34추가:
35추가: & "$env:CARGO_TARGET_DIR/debug/zipelo-ui-memory-app.exe" --list-ui-scenarios
36추가: & "$env:CARGO_TARGET_DIR/debug/zipelo-ui-memory-app.exe" --ui-scenario password
37추가: & "$env:CARGO_TARGET_DIR/debug/zipelo-ui-memory-app.exe" --ui-scenario create-encrypted
38추가: ~~~
39추가:
40추가: 개발 빌드는 목록과 오류를 콘솔에 출력한다. MSVC 아이콘 컴파일러가 없는 환경에서는 기존 정책대로 경고 후 아이콘 없이 빌드할 수 있다.
41추가:
42추가: ## 상황과 확인할 점
43추가:
44추가: - empty: 빈 첫 화면. 파일 열기 안내와 툴바 배치를 확인한다.
45추가: - archive: 파일과 폴더가 있는 압축파일. 이름, 크기, 잠금 아이콘과 상태 줄을 확인한다.
46추가: - folder: 사진 폴더 내부. 상위 폴더 이동과 경로 줄을 확인한다.
47추가: - many-items: 기본 5개 외에 500개 파일을 추가한 목록. 스크롤바와 행 배치를 확인한다.
48추가: - selection: 파일과 폴더 두 항목 선택. 파란 선택 배경과 선택 수를 확인한다.
49추가: - marquee: 끌어서 선택 중인 고정 화면. 반투명 파란 면, 테두리와 아래 행의 가독성을 확인한다.
50추가: - search-empty: 검색 결과 없음. 검색 입력과 빈 결과 안내를 확인한다.
51추가: - password: 암호 입력 창. 입력칸과 보기, 취소, 확인 버튼 배치를 확인한다.
52추가: - password-retry: 두 번째 암호 입력 요청. 틀린 암호 안내와 입력칸 배치를 확인한다.
53추가: - extract-progress: 압축 해제 중. 62% 진행 막대와 취소 버튼을 확인한다.
54추가: - extract-unknown: 전체 크기를 모르는 압축 해제. 진행 중 안내와 처리량을 확인한다.
55추가: - extract-complete: 압축 해제 완료. 완료 문구와 결과 행동을 확인한다.
56추가: - extract-cancelled: 취소 완료. 취소 안내와 다시 시도 배치를 확인한다.
57추가: - cancelling: 취소 요청 후 대기. 취소 중 표시와 비활성 취소 버튼을 확인한다.
58추가: - conflict: 같은 이름 파일이 있는 오류. 오류 설명과 복구 행동을 확인한다.
59추가: - unsupported: 지원하지 않는 형식. 파일 열기 실패 안내를 확인한다.
60추가: - damaged: 손상된 파일. 무결성 오류 안내를 확인한다.
61추가: - create: 암호를 사용하지 않는 ZIP 만들기 창. 원본 목록과 압축 설정을 확인한다.
62추가: - create-encrypted: 암호 설정이 켜진 ZIP 만들기 창. 두 암호 입력칸과 실행 버튼 상태를 확인한다.
63추가: - create-progress: ZIP 만들기 중. 진행 문구와 취소 버튼을 확인한다.
64추가: - create-complete: ZIP 만들기 완료. 압축 해제 완료와 다른 문구를 확인한다.
65추가: - folder-empty: 빈 하위 폴더. 목록의 빈 폴더 안내를 확인한다.
66추가: - gzip-conflict: 단일 GZ 이름 충돌. 다른 이름으로 저장 버튼과 안내를 확인한다.
67추가: - extract-partial: 일부 추출 후 실패. 이미 풀린 파일이 남는다는 경고를 확인한다.
68추가: - extract-uncertain: 저장 여부 불확실. 결과 확인을 권하는 경고를 확인한다.
69추가: - extract-unsynced: 완료 뒤 저장 확인 미완료. 완료 안내를 유지하고 자세히 보기에 경고가 있는지 확인한다.
70추가: - source-changed: 원본 변경. 다시 시도 대신 압축파일 다시 열기 버튼을 확인한다.
71추가: - dialog-error: 운영체제 파일 선택 창을 열지 못함. 파일 끌어 놓기 대안 안내를 확인한다.
72추가: - create-error: ZIP 만들기 실패. 디스크 여유 공간 안내를 확인한다.
73추가: - password-create: 암호 ZIP 생성 중 작업자 암호 요청. 암호와 암호 확인 입력 배치를 확인한다.
74추가: - close-confirm: 진행 중 창 닫기 확인. 작업 취소와 유지 선택지를 확인한다.
75추가:
76추가: --ui-scenario에는 이름 하나만 지정한다. 없는 이름, 누락된 이름, 다른 옵션이나 경로와의 혼합은 사용 가능한 목록을 출력하고 실패로 끝난다. --list-ui-scenarios도 단독으로 사용한다. 기존 파일 연결 실행과 --ui-fixture의 인자 해석은 유지한다.
77추가:
78추가: ## 검증
79추가:
80추가: ~~~bash
81추가: cargo +1.99.1 test --locked --manifest-path experiments/rust-ui-memory-app/Cargo.toml --features ui-fixture --test ui_scenarios
82추가: python3 tests/ci/run_rust.py local
83추가: ~~~
84추가:
85추가: 첫 명령은 이름 해석, 잘못된 인자, 화면 연결 없이 목록 출력, 전체 상황의 실제 egui 그리기를 확인한다. 모든 상황을 1060x720과 최소 크기 760x540에서 그린다. 별도 운영체제 창을 만들 수 없는 시험에서는 기존 내장 창 대체 배치를 사용한다. 운영체제별 창 테두리와 글꼴, 자식 창 배치는 실제 실행으로 추가 확인한다. 자동 그리기 통과만으로 Windows의 실제 화면 확인을 대신하지 않는다.
86추가:
87추가: ## 새 상황 추가
88추가:
89추가: 1. tests/rust-app-ui/scenarios.rs의 SCENARIOS를 만드는 catalog! 목록에 이름과 한국어 설명을 추가한다. 이름은 영문 소문자와 하이픈을 사용한다.
90추가: 2. Scenario::build에 기존 ArchiveApp 상태를 구성하는 분기를 추가한다. 작업 상태는 FakeFactory::manual과 기존 Event로 구성하며 작업자 계약을 바꾸지 않는다. 실제 파일이나 프로세스를 사용하지 않는다.
91추가: 3. tests/rust-app-ui/scenario_tests.rs에 새 상황의 화면 문구나 상태 검증을 추가한다. 전체 상황 그리기 시험은 목록에 추가된 상황도 자동으로 검사한다.
92추가: 4. 이 문서에 확인할 점을 적고 대표 화면을 직접 살핀다. 새 위젯을 별도의 가짜 화면으로 다시 만들지 않는다.
93추가:
94추가: 화면에 새 창, 버튼, 메시지, 상태 또는 오류를 추가하거나 바꾸면 같은 PR에서 상황, 시험과 이 가이드를 갱신한다. 화면 변화가 없으면 PR 본문에 "UI 변경 없음"이라고 적는다. 사용자가 직접 올린 UI 변경에서 빠진 상황은 병합 뒤 프론트엔드 담당이 보완한다.
95추가:
수정experiments/rust-ui-memory-app/Cargo.toml+5-0
@@ -64,3 +64,8 @@ required-features = ["ui"]
6464name = "zipelo-ui-capture"
6565path = "../../tests/rust-app-ui/capture.rs"
6666required-features = ["ui-fixture"]
67추가:
68추가: [[test]]
69추가: name = "ui_scenarios"
70추가: path = "../../tests/rust-app-ui/scenario_tests.rs"
71추가: required-features = ["ui-fixture"]
수정experiments/rust-ui-memory-app/src/archive_screen.rs+26-0
@@ -1,3 +1,7 @@
1추가: #[cfg(all(feature = "ui-fixture", debug_assertions))]
2추가: #[path = "../../../tests/rust-app-ui/scenarios.rs"]
3추가: pub mod scenarios;
4추가:
15use crate::{
26 archive_browser as browser,
37 archive_dialog::{
@@ -237,6 +241,10 @@ pub struct ArchiveApp {
237241 checked_destination: bool,
238242 ui_error: Option<String>,
239243 initialized: bool,
244추가: #[cfg(all(feature = "ui-fixture", debug_assertions))]
245추가: scenario_marquee: Option<egui::Rect>,
246추가: #[cfg(all(feature = "ui-fixture", debug_assertions))]
247추가: scenario_sources: Option<std::rc::Rc<Vec<SourceRow>>>,
240248}
241249
242250impl ArchiveApp {
@@ -289,6 +297,10 @@ impl ArchiveApp {
289297 checked_destination: false,
290298 ui_error: None,
291299 initialized: false,
300추가: #[cfg(all(feature = "ui-fixture", debug_assertions))]
301추가: scenario_marquee: None,
302추가: #[cfg(all(feature = "ui-fixture", debug_assertions))]
303추가: scenario_sources: None,
292304 };
293305 if let Some(path) = startup {
294306 app.open_path(path);
@@ -388,6 +400,10 @@ impl ArchiveApp {
388400 }
389401
390402 fn create_rows(&mut self) -> Option<std::rc::Rc<Vec<SourceRow>>> {
403추가: #[cfg(all(feature = "ui-fixture", debug_assertions))]
404추가: if let Some(rows) = &self.scenario_sources {
405추가: return Some(rows.clone());
406추가: }
391407 let Some(root) = self.create_root() else {
392408 return Some(std::rc::Rc::new(
393409 self.sources.iter().map(|path| source_row(path)).collect(),
@@ -1395,6 +1411,16 @@ impl ArchiveApp {
13951411 });
13961412 });
13971413 }
1414추가: #[cfg(all(feature = "ui-fixture", debug_assertions))]
1415추가: if let Some(rect) = self.scenario_marquee {
1416추가: ui.painter().with_clip_rect(clip).rect(
1417추가: rect.translate(origin.to_vec2()),
1418추가: 0,
1419추가: theme::BLUE.gamma_multiply(0.16),
1420추가: egui::Stroke::new(1.0, theme::BLUE),
1421추가: egui::StrokeKind::Inside,
1422추가: );
1423추가: }
13981424 if let Some(drag) = &self.marquee
13991425 && drag.moved
14001426 && let Some(point) = point
수정experiments/rust-ui-memory-app/src/desktop.rs+59-9
@@ -1,4 +1,10 @@
1삭제: #![cfg_attr(target_os = "windows", windows_subsystem = "windows")]
1추가: #![cfg_attr(
2추가: all(
3추가: target_os = "windows",
4추가: not(all(feature = "ui-fixture", debug_assertions))
5추가: ),
6추가: windows_subsystem = "windows"
7추가: )]
28
39#[cfg(feature = "ui-fixture")]
410#[path = "../../../tests/rust-app-ui/fake.rs"]
@@ -10,7 +16,10 @@ mod system_font;
1016use eframe::egui;
1117fn main() -> eframe::Result {
1218 let result = run();
13삭제: #[cfg(target_os = "windows")]
19추가: #[cfg(all(
20추가: target_os = "windows",
21추가: not(all(feature = "ui-fixture", debug_assertions))
22추가: ))]
1423 if let Err(error) = &result {
1524 let message = if matches!(error, eframe::Error::AppCreation(_)) {
1625 "앱을 시작하지 못했습니다. 설치 파일을 다시 설치한 뒤 시도해 주세요."
@@ -22,7 +31,10 @@ fn main() -> eframe::Result {
2231 result
2332}
2433
25삭제: #[cfg(target_os = "windows")]
34추가: #[cfg(all(
35추가: target_os = "windows",
36추가: not(all(feature = "ui-fixture", debug_assertions))
37추가: ))]
2638fn show_startup_error(message: &str) {
2739 #[link(name = "user32")]
2840 unsafe extern "system" {
@@ -42,6 +54,35 @@ fn show_startup_error(message: &str) {
4254}
4355
4456fn run() -> eframe::Result {
57추가: let args: Vec<_> = std::env::args_os().skip(1).collect();
58추가: #[cfg(all(feature = "ui-fixture", debug_assertions))]
59추가: let (args, scenario) = {
60추가: use zipelo_ui_memory_app::archive_screen::scenarios::{self, Launch};
61추가: match scenarios::launch(args)
62추가: .map_err(|e| eframe::Error::AppCreation(Box::new(std::io::Error::other(e))))?
63추가: {
64추가: Launch::List => {
65추가: print!("{}", scenarios::listing());
66추가: return Ok(());
67추가: }
68추가: Launch::Scenario(scenario) => (Vec::new(), Some(scenario)),
69추가: Launch::Normal(args) => (args, None),
70추가: }
71추가: };
72추가: #[cfg(not(all(feature = "ui-fixture", debug_assertions)))]
73추가: if args
74추가: .iter()
75추가: .any(|arg| arg == "--ui-scenario" || arg == "--list-ui-scenarios")
76추가: {
77추가: return Err(eframe::Error::AppCreation(Box::new(std::io::Error::other(
78추가: "지원하지 않는 명령줄 옵션입니다",
79추가: ))));
80추가: }
81추가: let (fixture, startup) = zipelo_ui_memory_app::archive_ui::launch_args(
82추가: args,
83추가: std::env::current_dir().map_err(|e| eframe::Error::AppCreation(Box::new(e)))?,
84추가: )
85추가: .map_err(|e| eframe::Error::AppCreation(Box::new(std::io::Error::other(e))))?;
4586 let custom_frame = zipelo_ui_memory_app::window_frame::custom_frame_needed();
4687 // 운영체제 한글 글꼴은 Pretendard에 없는 글자를 위한 대체 글꼴로만 씀.
4788 let fallback = system_font::load()
@@ -58,15 +99,22 @@ fn run() -> eframe::Result {
5899 },
59100 || {
60101 let fallback = fallback.clone();
102추가: let startup = startup.clone();
61103 Box::new(move |cc| {
62104 cc.egui_ctx
63105 .set_fonts(zipelo_ui_memory_app::archive_theme::fonts(fallback));
64106 zipelo_ui_memory_app::archive_theme::apply(&cc.egui_ctx);
65삭제: let (fixture, startup) = zipelo_ui_memory_app::archive_ui::launch_args(
66삭제: std::env::args_os().skip(1).collect(),
67삭제: std::env::current_dir()?,
68삭제: )
69삭제: .map_err(std::io::Error::other)?;
107추가: #[cfg(all(feature = "ui-fixture", debug_assertions))]
108추가: if let Some(scenario) = scenario {
109추가: let mut app = scenario.build();
110추가: app.set_custom_frame(custom_frame);
111추가: return Ok(Box::new(
112추가: zipelo_ui_memory_app::archive_screen::scenarios::Preview::new(
113추가: app,
114추가: &cc.egui_ctx,
115추가: ),
116추가: ) as Box<dyn eframe::App>);
117추가: }
70118 let factory: Box<dyn zipelo_ui_memory_app::archive_ui::Factory> = if fixture {
71119 #[cfg(feature = "ui-fixture")]
72120 {
@@ -85,7 +133,9 @@ fn run() -> eframe::Result {
85133 )
86134 };
87135 let mut app = zipelo_ui_memory_app::archive_screen::ArchiveApp::new(
88삭제: factory, startup, fixture,
136추가: factory,
137추가: startup.clone(),
138추가: fixture,
89139 );
90140 app.set_custom_frame(custom_frame);
91141 Ok(Box::new(app))
수정experiments/rust-ui-memory-app/src/lib.rs+3-0
@@ -1,5 +1,8 @@
11#![forbid(unsafe_code)]
22
3추가: #[cfg(all(feature = "ui-fixture", debug_assertions))]
4추가: extern crate self as zipelo_ui_memory_app;
5추가:
36pub use core_memory as core;
47pub mod controller;
58pub mod runtime;
추가tests/rust-app-ui/scenario-screenshots/create-encrypted.png

바이너리 파일이라 Diff를 표시하지 않아요.

파일 내려받기
추가tests/rust-app-ui/scenario-screenshots/marquee.png

바이너리 파일이라 Diff를 표시하지 않아요.

파일 내려받기
추가tests/rust-app-ui/scenario-screenshots/password-retry.png

바이너리 파일이라 Diff를 표시하지 않아요.

파일 내려받기
추가tests/rust-app-ui/scenario_tests.rs+191-0
@@ -0,0 +1,191 @@
1추가: #![cfg(debug_assertions)]
2추가:
3추가: use eframe::egui;
4추가: use std::{collections::BTreeSet, ffi::OsString};
5추가: use zipelo_ui_memory_app::archive_screen::scenarios::{self, Launch, SCENARIOS};
6추가:
7추가: #[test]
8추가: fn 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]
30추가: fn 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추가:
50추가: fn 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]
73추가: fn 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| app.show(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추가: let expected = match scenario.name {
99추가: "empty" => "압축파일",
100추가: "folder-empty" => "이 폴더는 비어 있습니다",
101추가: "dialog-error" => "파일 선택 창을 열 수 없습니다",
102추가: "extract-partial" => "일부 파일만 풀렸습니다",
103추가: "extract-uncertain" => "저장이 끝났는지 확인하지 못했습니다",
104추가: "extract-unsynced" => "파일을 디스크에 완전히 저장했는지 확인하지 못했습니다",
105추가: "source-changed" => "압축파일 다시 열기",
106추가: "gzip-conflict" => "다른 이름으로 저장",
107추가: "create-error" => "ZIP 파일을 만들지 못했습니다",
108추가: "password-create" => "암호 확인",
109추가: "folder" => "바다.jpg",
110추가: "search-empty" => "일치하는 항목이 없습니다",
111추가: "password" | "password-retry" => "암호",
112추가: "extract-complete" => "압축을 풀었습니다",
113추가: "extract-cancelled" => "작업을 취소했습니다",
114추가: "create-complete" => "ZIP 파일을 만들었습니다",
115추가: "create" | "create-encrypted" => "암호로 보호하기",
116추가: "unsupported" | "damaged" => "압축파일을 열지 못했습니다",
117추가: "conflict" => "압축을 풀지 못했습니다",
118추가: "close-confirm" => "닫",
119추가: _ => "읽어주세요.txt",
120추가: };
121추가: assert!(labels.contains(expected), "{}: {labels}", scenario.name);
122추가: if scenario.name == "many-items" {
123추가: assert_eq!(app.model.entries.len(), 505);
124추가: }
125추가: if matches!(scenario.name, "selection" | "marquee") {
126추가: assert_eq!(app.model.selected.len(), 4);
127추가: assert!(labels.contains("선택 2개"));
128추가: }
129추가: if scenario.name == "password-retry" {
130추가: assert_eq!(app.model.challenge.unwrap().1, 2);
131추가: }
132추가: }
133추가: }
134추가: }
135추가:
136추가: #[test]
137추가: fn command_line_catalog_and_errors_work_without_a_display() {
138추가: let run = |args: &[&str]| {
139추가: std::process::Command::new(env!("CARGO_BIN_EXE_zipelo-ui-memory-app"))
140추가: .args(args)
141추가: .env_remove("DISPLAY")
142추가: .env_remove("WAYLAND_DISPLAY")
143추가: .output()
144추가: .unwrap()
145추가: };
146추가: let listed = run(&["--list-ui-scenarios"]);
147추가: assert!(listed.status.success());
148추가: assert_eq!(
149추가: String::from_utf8(listed.stdout).unwrap(),
150추가: scenarios::listing()
151추가: );
152추가: for args in [vec!["--ui-scenario", "unknown"], vec!["--ui-scenario"]] {
153추가: let failed = run(&args);
154추가: assert!(!failed.status.success());
155추가: let stderr = String::from_utf8_lossy(&failed.stderr);
156추가: for scenario in SCENARIOS {
157추가: assert!(stderr.contains(scenario.name));
158추가: }
159추가: }
160추가: }
161추가:
162추가: #[test]
163추가: fn preview_ignores_password_submission() {
164추가: let ctx = egui::Context::default();
165추가: let mut preview = scenarios::Preview::new(scenarios::parse("password").unwrap().build(), &ctx);
166추가: for _ in 0..3 {
167추가: let mut output = ctx.run_ui(
168추가: egui::RawInput {
169추가: screen_rect: Some(egui::Rect::from_min_size(
170추가: egui::Pos2::ZERO,
171추가: egui::vec2(1060.0, 720.0),
172추가: )),
173추가: events: vec![
174추가: egui::Event::Text("화면 검토".into()),
175추가: egui::Event::Key {
176추가: key: egui::Key::Enter,
177추가: physical_key: None,
178추가: pressed: true,
179추가: repeat: false,
180추가: modifiers: egui::Modifiers::NONE,
181추가: },
182추가: ],
183추가: ..Default::default()
184추가: },
185추가: |ui| preview.0.show(ui),
186추가: );
187추가: output.textures_delta.clear();
188추가: }
189추가: assert_eq!(preview.0.model.challenge, Some((17, 1, false)));
190추가: assert!(preview.0.model.busy());
191추가: }
추가tests/rust-app-ui/scenarios.rs+424-0
@@ -0,0 +1,424 @@
1추가: use super::*;
2추가: use std::ffi::OsString;
3추가:
4추가: #[path = "fake.rs"]
5추가: mod fake;
6추가: use fake::FakeFactory;
7추가:
8추가: #[derive(Clone, Copy, Debug, Eq, PartialEq)]
9추가: pub struct Scenario {
10추가: pub name: &'static str,
11추가: pub description: &'static str,
12추가: }
13추가:
14추가: macro_rules! catalog {
15추가: ($($name:literal => $description:literal),+ $(,)?) => {
16추가: pub const SCENARIOS: &[Scenario] = &[$(Scenario {
17추가: name: $name,
18추가: description: $description,
19추가: }),+];
20추가: };
21추가: }
22추가:
23추가: catalog! {
24추가: "empty" => "빈 첫 화면",
25추가: "archive" => "폴더와 파일이 있는 압축파일",
26추가: "folder" => "사진 하위 폴더",
27추가: "many-items" => "500개 항목과 세로 스크롤",
28추가: "selection" => "여러 파일과 폴더 선택",
29추가: "marquee" => "반투명 사각형으로 끌어서 선택 중",
30추가: "search-empty" => "검색 결과 없음",
31추가: "password" => "압축 해제 암호 입력",
32추가: "password-retry" => "암호가 틀린 뒤 다시 입력",
33추가: "extract-progress" => "압축 해제 진행률 62%",
34추가: "extract-unknown" => "전체 크기를 모르는 압축 해제",
35추가: "extract-complete" => "압축 해제 완료",
36추가: "extract-cancelled" => "압축 해제 취소 완료",
37추가: "cancelling" => "취소 요청 후 작업 종료 대기",
38추가: "conflict" => "같은 이름 파일 충돌",
39추가: "unsupported" => "지원하지 않는 압축 형식",
40추가: "damaged" => "손상된 압축파일",
41추가: "create" => "암호 없는 ZIP 만들기 창",
42추가: "create-encrypted" => "암호 설정이 켜진 ZIP 만들기 창",
43추가: "create-progress" => "ZIP 만들기 진행률 62%",
44추가: "create-complete" => "ZIP 만들기 완료",
45추가: "folder-empty" => "항목이 없는 하위 폴더",
46추가: "gzip-conflict" => "단일 GZ 파일 이름 충돌",
47추가: "extract-partial" => "일부 파일만 풀린 결과",
48추가: "extract-uncertain" => "저장 여부를 확인할 수 없는 결과",
49추가: "extract-unsynced" => "완료 뒤 저장 확인 경고의 상세 정보",
50추가: "source-changed" => "목록을 연 뒤 원본이 바뀐 오류",
51추가: "dialog-error" => "운영체제 파일 선택 창 실행 실패",
52추가: "create-error" => "ZIP 만들기 중 디스크 공간 부족",
53추가: "password-create" => "암호 ZIP 생성의 작업자 암호 요청",
54추가: "close-confirm" => "진행 중 창 닫기 확인",
55추가: }
56추가:
57추가: pub fn listing() -> String {
58추가: SCENARIOS
59추가: .iter()
60추가: .map(|s| format!("{}\t{}\n", s.name, s.description))
61추가: .collect()
62추가: }
63추가:
64추가: pub fn parse(name: &str) -> Result<Scenario, String> {
65추가: SCENARIOS
66추가: .iter()
67추가: .copied()
68추가: .find(|s| s.name == name)
69추가: .ok_or_else(|| {
70추가: format!(
71추가: "알 수 없는 UI 상황: {name}\n사용 가능한 상황:\n{}",
72추가: listing()
73추가: )
74추가: })
75추가: }
76추가:
77추가: #[derive(Debug, PartialEq)]
78추가: pub enum Launch {
79추가: Normal(Vec<OsString>),
80추가: Scenario(Scenario),
81추가: List,
82추가: }
83추가:
84추가: pub fn launch(args: Vec<OsString>) -> Result<Launch, String> {
85추가: let requested = args
86추가: .iter()
87추가: .any(|a| a == "--ui-scenario" || a == "--list-ui-scenarios");
88추가: if !requested {
89추가: return Ok(Launch::Normal(args));
90추가: }
91추가: if args.len() == 1 && args[0] == "--list-ui-scenarios" {
92추가: return Ok(Launch::List);
93추가: }
94추가: if args.len() == 2 && args[0] == "--ui-scenario" {
95추가: return args[1]
96추가: .to_str()
97추가: .ok_or_else(|| format!("상황 이름은 UTF-8이어야 합니다\n{}", listing()))
98추가: .and_then(parse)
99추가: .map(Launch::Scenario);
100추가: }
101추가: Err(format!(
102추가: "사용법: --ui-scenario <이름> 또는 --list-ui-scenarios\n{}",
103추가: listing()
104추가: ))
105추가: }
106추가:
107추가: fn sample_root() -> PathBuf {
108추가: PathBuf::from(if cfg!(target_os = "windows") {
109추가: "C:\\Samples"
110추가: } else {
111추가: "/Samples"
112추가: })
113추가: }
114추가:
115추가: fn entries(many: bool) -> Vec<Entry> {
116추가: let mut entries = vec![
117추가: ("사진", Kind::Directory),
118추가: ("읽어주세요.txt", Kind::File),
119추가: ("여행 일정.pdf", Kind::File),
120추가: ("사진/바다.jpg", Kind::File),
121추가: ("사진/풍경.jpg", Kind::File),
122추가: ]
123추가: .into_iter()
124추가: .enumerate()
125추가: .map(|(id, (name, kind))| Entry {
126추가: id: id as u32,
127추가: name: name.into(),
128추가: kind,
129추가: bytes: Some(if kind == Kind::Directory {
130추가: 0
131추가: } else {
132추가: 1_287_952
133추가: }),
134추가: packed: Some(900_000),
135추가: encrypted: id == 2,
136추가: })
137추가: .collect::<Vec<_>>();
138추가: if many {
139추가: entries.extend((5..505).map(|id| Entry {
140추가: id,
141추가: name: format!("자료-{id:03}.txt"),
142추가: kind: Kind::File,
143추가: bytes: Some(4096),
144추가: packed: Some(1800),
145추가: encrypted: false,
146추가: }));
147추가: }
148추가: entries
149추가: }
150추가:
151추가: impl Scenario {
152추가: /// 실제 파일과 작업자를 사용하지 않고 기존 화면 상태를 준비함.
153추가: pub fn build(self) -> ArchiveApp {
154추가: let factory = FakeFactory::manual();
155추가: let state = factory.state.clone();
156추가: let mut app = ArchiveApp::new(Box::new(factory), None, true);
157추가: let base = sample_root();
158추가: app.destination = base.join("풀린 자료");
159추가: app.automatic_destination = false;
160추가: app.zip_folder = base.clone();
161추가: app.zip_name = "여행 자료.zip".into();
162추가: if self.name == "empty" {
163추가: return app;
164추가: }
165추가: let archive = base.join(if self.name == "gzip-conflict" {
166추가: "여행 자료.gz"
167추가: } else {
168추가: "여행 자료.zip"
169추가: });
170추가: app.model.archive = Some(archive.clone());
171추가: app.model.entries = entries(self.name == "many-items");
172추가: app.model.list_id = Some(ListId {
173추가: catalog_version: 1,
174추가: format: Format::Zip,
175추가: source_object: SourceObject::Unix {
176추가: device: 1,
177추가: inode: 1,
178추가: },
179추가: archive_bytes: 2_700_000,
180추가: archive_sha256: [7; 32],
181추가: });
182추가: app.model.confirmed = true;
183추가: match self.name {
184추가: "archive" | "many-items" => return app,
185추가: "folder-empty" => {
186추가: app.browse_folder("빈 폴더");
187추가: return app;
188추가: }
189추가: "dialog-error" => {
190추가: app.ui_error = Some(DIALOG_UNAVAILABLE.into());
191추가: return app;
192추가: }
193추가: "folder" => {
194추가: app.browse_folder("사진");
195추가: return app;
196추가: }
197추가: "search-empty" => {
198추가: app.search = "없는 파일".into();
199추가: return app;
200추가: }
201추가: "selection" | "marquee" => {
202추가: app.model
203추가: .selected
204추가: .extend([0, 3, 4, if self.name == "marquee" { 2 } else { 1 }]);
205추가: if self.name == "marquee" {
206추가: app.scenario_marquee = Some(egui::Rect::from_min_size(
207추가: egui::pos2(22.0, 8.0),
208추가: egui::vec2(360.0, 62.0),
209추가: ));
210추가: }
211추가: return app;
212추가: }
213추가: "create" | "create-encrypted" => {
214추가: app.sources = vec![base.join("읽어주세요.txt"), base.join("사진")];
215추가: app.scenario_sources = Some(std::rc::Rc::new(vec![
216추가: SourceRow {
217추가: name: "사진".into(),
218추가: directory: true,
219추가: bytes: Some(0),
220추가: },
221추가: SourceRow {
222추가: name: "읽어주세요.txt".into(),
223추가: directory: false,
224추가: bytes: Some(4096),
225추가: },
226추가: ]));
227추가: app.show_create(self.name == "create-encrypted");
228추가: return app;
229추가: }
230추가: _ => {}
231추가: }
232추가: let creating = self.name.starts_with("create-") || self.name == "password-create";
233추가: let listing_error = matches!(self.name, "unsupported" | "damaged");
234추가: if self.name == "gzip-conflict" {
235추가: app.model.list_id.as_mut().unwrap().format = Format::Gzip;
236추가: app.model.entries = vec![Entry {
237추가: id: 0,
238추가: name: "여행 자료".into(),
239추가: kind: Kind::File,
240추가: bytes: Some(1_287_952),
241추가: packed: Some(900_000),
242추가: encrypted: false,
243추가: }];
244추가: app.gzip_name = "여행 자료".into();
245추가: }
246추가: let request = if creating {
247추가: Start::CreateZip {
248추가: sources: vec![(base.join("사진"), "사진".into())],
249추가: output_file: base.join("여행 자료.zip"),
250추가: method: Method::Deflate,
251추가: aes256: self.name == "password-create",
252추가: }
253추가: } else if listing_error {
254추가: Start::List { archive }
255추가: } else {
256추가: Start::Extract {
257추가: archive,
258추가: destination: app.destination.clone(),
259추가: selection: Selection::All,
260추가: list_id: app.model.list_id.clone().unwrap(),
261추가: gzip_output_name: (self.name == "gzip-conflict").then(|| app.gzip_name.clone()),
262추가: }
263추가: };
264추가: app.targets = Some(if creating {
265추가: BTreeSet::from(["여행 자료.zip".into()])
266추가: } else if self.name == "gzip-conflict" {
267추가: BTreeSet::from(["여행 자료".into()])
268추가: } else {
269추가: BTreeSet::from([
270추가: "읽어주세요.txt".into(),
271추가: "여행 일정.pdf".into(),
272추가: "사진/바다.jpg".into(),
273추가: "사진/풍경.jpg".into(),
274추가: ])
275추가: });
276추가: assert!(app.start(request));
277추가: {
278추가: let mut state = state.borrow_mut();
279추가: state.frame(Event::Accepted { encryption: true });
280추가: match self.name {
281추가: "password" | "password-retry" | "password-create" => {
282추가: state.frame(Event::PasswordRequired {
283추가: challenge_id: 17,
284추가: attempt: if self.name == "password-retry" { 2 } else { 1 },
285추가: encrypt: self.name == "password-create",
286추가: })
287추가: }
288추가: "extract-complete" | "create-complete" | "extract-unsynced" => {
289추가: let names = app.targets.as_ref().unwrap();
290추가: for name in names {
291추가: state.frame(Event::Output {
292추가: entry_id: None,
293추가: relative_name: name.clone(),
294추가: disposition: Disposition::Created,
295추가: });
296추가: }
297추가: state.frame(Event::Terminal(Terminal {
298추가: outcome: Outcome::Completed,
299추가: error: None,
300추가: publication: Publication::Complete,
301추가: created_count: names.len() as u64,
302추가: retained_partial_count: 0,
303추가: durability: if self.name == "extract-unsynced" {
304추가: Durability::Unconfirmed
305추가: } else {
306추가: Durability::Synced
307추가: },
308추가: cleanup: Cleanup::Complete,
309추가: }));
310추가: state.queue.extend([
311추가: HostEvent::StdoutEof,
312추가: HostEvent::StderrEof,
313추가: HostEvent::Exited { success: true },
314추가: ]);
315추가: }
316추가: "extract-cancelled" => state.finish(Outcome::Cancelled, Publication::None),
317추가: "extract-partial" | "extract-uncertain" => {
318추가: let partial = self.name == "extract-partial";
319추가: if partial {
320추가: state.frame(Event::Output {
321추가: entry_id: Some(1),
322추가: relative_name: "읽어주세요.txt".into(),
323추가: disposition: Disposition::Created,
324추가: });
325추가: }
326추가: state.frame(Event::Terminal(Terminal {
327추가: outcome: Outcome::Failed,
328추가: error: Some(ErrorCode::Io),
329추가: publication: if partial {
330추가: Publication::Partial
331추가: } else {
332추가: Publication::Uncertain
333추가: },
334추가: created_count: u64::from(partial),
335추가: retained_partial_count: 0,
336추가: durability: Durability::Synced,
337추가: cleanup: Cleanup::Complete,
338추가: }));
339추가: state.queue.extend([
340추가: HostEvent::StdoutEof,
341추가: HostEvent::StderrEof,
342추가: HostEvent::Exited { success: true },
343추가: ]);
344추가: }
345추가: "conflict" | "gzip-conflict" | "unsupported" | "damaged" | "source-changed"
346추가: | "create-error" => {
347추가: state.frame(Event::Terminal(Terminal {
348추가: outcome: Outcome::Failed,
349추가: error: Some(match self.name {
350추가: "conflict" | "gzip-conflict" => ErrorCode::Conflict,
351추가: "source-changed" => ErrorCode::SourceChanged,
352추가: "create-error" => ErrorCode::DiskFull,
353추가: "unsupported" => ErrorCode::UnsupportedFormat,
354추가: _ => ErrorCode::Integrity,
355추가: }),
356추가: publication: Publication::None,
357추가: created_count: 0,
358추가: retained_partial_count: 0,
359추가: durability: Durability::NotApplicable,
360추가: cleanup: Cleanup::Complete,
361추가: }));
362추가: state.queue.extend([
363추가: HostEvent::StdoutEof,
364추가: HostEvent::StderrEof,
365추가: HostEvent::Exited { success: true },
366추가: ]);
367추가: }
368추가: _ => state.frame(Event::Progress {
369추가: stage: if creating {
370추가: Stage::Write
371추가: } else {
372추가: Stage::Decode
373추가: },
374추가: processed: 38 << 20,
375추가: total: (self.name != "extract-unknown").then_some(61 << 20),
376추가: completed_entries: 12,
377추가: }),
378추가: }
379추가: }
380추가: for _ in 0..64 {
381추가: app.model.poll();
382추가: }
383추가: if self.name == "extract-unsynced" {
384추가: app.details = true;
385추가: }
386추가: if self.name == "cancelling" {
387추가: app.model.cancel();
388추가: }
389추가: if self.name == "close-confirm" {
390추가: app.model.request_close();
391추가: }
392추가: app
393추가: }
394추가: }
395추가:
396추가: /// 화면을 고정하고 실제 파일 조작을 막는 미리보기임.
397추가: pub struct Preview(pub ArchiveApp);
398추가: impl Preview {
399추가: pub fn new(app: ArchiveApp, ctx: &egui::Context) -> Self {
400추가: ctx.on_begin_pass(
401추가: "ui-scenario-readonly",
402추가: std::sync::Arc::new(|ctx| {
403추가: ctx.input_mut(|i| {
404추가: i.events.clear();
405추가: i.pointer = Default::default();
406추가: i.keys_down.clear();
407추가: i.modifiers = Default::default();
408추가: i.raw.dropped_files.clear();
409추가: i.raw.hovered_files.clear();
410추가: });
411추가: }),
412추가: );
413추가: Self(app)
414추가: }
415추가: }
416추가: impl eframe::App for Preview {
417추가: fn ui(&mut self, root: &mut egui::Ui, _: &mut eframe::Frame) {
418추가: if root.ctx().input(|i| i.viewport().close_requested()) {
419추가: root.ctx().send_viewport_cmd(egui::ViewportCommand::Close);
420추가: return;
421추가: }
422추가: self.0.show(root);
423추가: }
424추가: }