team-ljyzipelo

공개

Merge pull request #62 from Team-LJY/features/rust-app-ui

가짜 작업자로 Rust 압축 앱 화면 흐름 구현
작성자
LeeJunyoung
작성 시각
커밋
f2d2b566b14ac4fd09e9c3f93873a00af26ea334
이 시점의 파일 보기

변경된 파일 11개

+2,361-1
수정experiments/rust-ui-memory-app/Cargo.toml+6-1
@@ -15,6 +15,7 @@ doctest = false
1515[features]
1616default = []
1717ui = ["dep:eframe"]
18추가: ui-fixture = ["ui"]
1819
1920[dependencies]
2021core_memory = { package = "zipelo-app-core-memory", path = "../rust-app-core-memory" }
@@ -22,9 +23,13 @@ eframe = { version = "=0.37.0", optional = true, default-features = false, featu
2223
2324[[bin]]
2425name = "zipelo-ui-memory-app"
25삭제: path = "src/app.rs"
26추가: path = "src/desktop.rs"
2627required-features = ["ui"]
2728
2829[[test]]
2930name = "ui_memory"
3031path = "../../tests/rust-ui-memory-app/regressions.rs"
32추가:
33추가: [[test]]
34추가: name = "archive_ui"
35추가: path = "../../tests/rust-app-ui/regressions.rs"
추가experiments/rust-ui-memory-app/src/archive_screen.rs+383-0
@@ -0,0 +1,383 @@
1추가: use crate::archive_ui::*;
2추가: use eframe::egui;
3추가: use std::path::PathBuf;
4추가:
5추가: pub struct ArchiveApp {
6추가: pub model: Model,
7추가: factory: Box<dyn Factory>,
8추가: open_text: String,
9추가: destination: String,
10추가: gzip_name: String,
11추가: sources: String,
12추가: zip_output: String,
13추가: password: String,
14추가: create: bool,
15추가: open: bool,
16추가: selected_only: bool,
17추가: method: Method,
18추가: fixture: bool,
19추가: }
20추가: impl ArchiveApp {
21추가: pub fn new(factory: Box<dyn Factory>, startup: Option<PathBuf>, fixture: bool) -> Self {
22추가: let mut app = Self {
23추가: model: Model::default(),
24추가: factory,
25추가: open_text: String::new(),
26추가: destination: String::new(),
27추가: gzip_name: String::new(),
28추가: sources: String::new(),
29추가: zip_output: String::new(),
30추가: password: String::new(),
31추가: create: false,
32추가: open: false,
33추가: selected_only: false,
34추가: method: Method::Deflate,
35추가: fixture,
36추가: };
37추가: if let Some(path) = startup {
38추가: app.open_path(path);
39추가: }
40추가: app
41추가: }
42추가: pub fn open_path(&mut self, archive: PathBuf) {
43추가: self.password.clear();
44추가: self.model
45추가: .begin(Start::List { archive }, self.factory.as_mut());
46추가: }
47추가: fn on_drop(&mut self, paths: Vec<PathBuf>) {
48추가: if self.model.busy() || paths.is_empty() {
49추가: return;
50추가: }
51추가: if paths.len() == 1 && !self.create {
52추가: self.open_path(paths[0].clone());
53추가: } else if paths.iter().all(|p| p.to_str().is_some()) {
54추가: self.sources = paths
55추가: .iter()
56추가: .map(|p| p.to_str().unwrap())
57추가: .collect::<Vec<_>>()
58추가: .join("\n");
59추가: self.create = true;
60추가: } else {
61추가: self.model.error = Some("ZIP 생성 경로는 현재 UTF-8 입력만 지원합니다".into());
62추가: }
63추가: }
64추가: }
65추가: impl ArchiveApp {
66추가: pub fn show(&mut self, root: &mut egui::Ui) {
67추가: self.model.poll();
68추가: if self.model.challenge.is_none() {
69추가: self.password.clear();
70추가: }
71추가: let ctx = root.ctx().clone();
72추가: let dropped = ctx.input(|i| {
73추가: i.raw
74추가: .dropped_files
75추가: .iter()
76추가: .map(|f| f.path().to_path_buf())
77추가: .collect::<Vec<_>>()
78추가: });
79추가: self.on_drop(dropped);
80추가: if ctx.input(|i| i.viewport().close_requested()) {
81추가: self.model.request_close();
82추가: if self.model.close != Close::Allowed {
83추가: ctx.send_viewport_cmd(egui::ViewportCommand::CancelClose);
84추가: }
85추가: }
86추가: if self.model.close == Close::Allowed {
87추가: ctx.send_viewport_cmd(egui::ViewportCommand::Close);
88추가: }
89추가: egui::Panel::top("archive-actions").show(root, |ui| {
90추가: ui.horizontal_wrapped(|ui| {
91추가: ui.heading("Zipelo");
92추가: ui.add_enabled_ui(
93추가: !self.model.busy() && self.model.close == Close::Open,
94추가: |ui| {
95추가: if ui.button("파일 열기").clicked() {
96추가: self.open = true;
97추가: }
98추가: if ui.button("ZIP 만들기").clicked() {
99추가: self.create = true;
100추가: }
101추가: },
102추가: );
103추가: if ui
104추가: .add_enabled(self.model.busy(), egui::Button::new("취소 요청"))
105추가: .clicked()
106추가: {
107추가: self.password.clear();
108추가: self.model.cancel();
109추가: }
110추가: });
111추가: if self.fixture {
112추가: ui.colored_label(
113추가: egui::Color32::from_rgb(143, 69, 0),
114추가: "화면 시험 모드 / 파일을 읽거나 저장하지 않습니다",
115추가: );
116추가: }
117추가: });
118추가: egui::Panel::bottom("archive-status").show(root, |ui| {
119추가: ui.label(self.model.status());
120추가: if let Some((stage, done, total, entries)) =
121추가: self.model.progress.filter(|_| self.model.busy())
122추가: {
123추가: ui.label(format!(
124추가: "{} / {done}바이트 / {entries}개 처리",
125추가: stage_label(stage)
126추가: ));
127추가: if let Some(total) = total.filter(|n| *n > 0) {
128추가: ui.add(
129추가: egui::ProgressBar::new((done as f64 / total as f64).clamp(0.0, 1.0) as f32)
130추가: .show_percentage(),
131추가: );
132추가: } else if self.model.busy() {
133추가: ui.spinner();
134추가: }
135추가: }
136추가: if !self.model.busy() {
137추가: if let Some(t) = &self.model.terminal {
138추가: for line in terminal_lines(t) {
139추가: ui.label(line);
140추가: }
141추가: }
142추가: }
143추가: });
144추가: egui::CentralPanel::default_margins().show(root, |ui| {
145추가: if let Some(path) = &self.model.archive {
146추가: ui.heading(
147추가: path.file_name()
148추가: .unwrap_or(path.as_os_str())
149추가: .to_string_lossy(),
150추가: );
151추가: ui.label(path.display().to_string());
152추가: } else {
153추가: ui.heading("압축파일을 여기로 끌어 놓으세요");
154추가: }
155추가: if self.model.list_id.is_some() {
156추가: ui.add_enabled_ui(self.model.can_extract(), |ui| {
157추가: ui.horizontal_wrapped(|ui| {
158추가: ui.label("출력 폴더");
159추가: ui.text_edit_singleline(&mut self.destination);
160추가: });
161추가: if self
162추가: .model
163추가: .list_id
164추가: .as_ref()
165추가: .is_some_and(|id| id.format == Format::Gzip)
166추가: {
167추가: ui.horizontal(|ui| {
168추가: ui.label("출력 파일명");
169추가: ui.text_edit_singleline(&mut self.gzip_name);
170추가: });
171추가: }
172추가: ui.horizontal_wrapped(|ui| {
173추가: ui.checkbox(&mut self.selected_only, "선택한 항목만 풀기");
174추가: if ui.button("풀기").clicked() {
175추가: self.model.extract(
176추가: PathBuf::from(&self.destination),
177추가: self.selected_only,
178추가: self.model
179추가: .list_id
180추가: .as_ref()
181추가: .filter(|id| id.format == Format::Gzip)
182추가: .map(|_| self.gzip_name.clone()),
183추가: self.factory.as_mut(),
184추가: );
185추가: }
186추가: });
187추가: });
188추가: }
189추가: ui.separator();
190추가: egui::ScrollArea::both().show(ui, |ui| {
191추가: egui::Grid::new("archive-list")
192추가: .striped(true)
193추가: .min_col_width(90.0)
194추가: .show(ui, |ui| {
195추가: ui.label("선택");
196추가: ui.label("이름");
197추가: ui.label("크기");
198추가: ui.label("형식");
199추가: ui.label("암호");
200추가: ui.end_row();
201추가: for entry in &self.model.entries {
202추가: let mut selected = self.model.selected.contains(&entry.id);
203추가: if ui
204추가: .add_enabled(
205추가: !self.model.busy()
206추가: && matches!(entry.kind, Kind::File | Kind::Directory),
207추가: egui::Checkbox::without_text(&mut selected),
208추가: )
209추가: .on_hover_text(format!("{} 선택", entry.name))
210추가: .changed()
211추가: {
212추가: if selected {
213추가: self.model.selected.insert(entry.id);
214추가: } else {
215추가: self.model.selected.remove(&entry.id);
216추가: }
217추가: }
218추가: ui.label(&entry.name);
219추가: ui.label(
220추가: entry
221추가: .bytes
222추가: .map_or("알 수 없음".into(), |n| format!("{n} B")),
223추가: );
224추가: ui.label(match entry.kind {
225추가: Kind::File => "파일",
226추가: Kind::Directory => "폴더",
227추가: Kind::Link => "링크",
228추가: Kind::Other => "기타",
229추가: });
230추가: ui.label(if entry.encrypted { "있음" } else { "없음" });
231추가: ui.end_row();
232추가: }
233추가: });
234추가: if self.model.entries.is_empty() && self.model.list_id.is_some() {
235추가: ui.label("압축파일에 항목이 없습니다");
236추가: }
237추가: for (name, state) in &self.model.outputs {
238추가: ui.label(format!("{name}: {}", disposition_label(*state)));
239추가: }
240추가: });
241추가: });
242추가: if self.open {
243추가: egui::Window::new("파일 열기")
244추가: .collapsible(false)
245추가: .show(&ctx, |ui| {
246추가: ui.label("압축파일 절대 경로");
247추가: ui.text_edit_singleline(&mut self.open_text);
248추가: if ui.button("열기").clicked() {
249추가: self.open_path(self.open_text.clone().into());
250추가: self.open = false;
251추가: }
252추가: if ui.button("닫기").clicked() {
253추가: self.open = false;
254추가: }
255추가: });
256추가: }
257추가: if self.create {
258추가: egui::Window::new("ZIP 만들기")
259추가: .collapsible(false)
260추가: .show(&ctx, |ui| {
261추가: ui.add_enabled_ui(!self.model.busy(), |ui| {
262추가: ui.label("원본 파일 절대 경로 / 한 줄에 하나");
263추가: ui.add(egui::TextEdit::multiline(&mut self.sources).desired_rows(4));
264추가: ui.label("저장할 ZIP 절대 경로");
265추가: ui.text_edit_singleline(&mut self.zip_output);
266추가: ui.horizontal(|ui| {
267추가: ui.selectable_value(&mut self.method, Method::Deflate, "압축");
268추가: ui.selectable_value(&mut self.method, Method::Store, "묶기");
269추가: });
270추가: ui.label("암호 ZIP 생성은 작업자 지원 후 활성화됩니다");
271추가: if ui.button("ZIP 만들기").clicked() {
272추가: let sources = self
273추가: .sources
274추가: .lines()
275추가: .map(|s| {
276추가: let path = PathBuf::from(s);
277추가: let name = path
278추가: .file_name()
279추가: .and_then(|n| n.to_str())
280추가: .unwrap_or("")
281추가: .to_owned();
282추가: (path, name)
283추가: })
284추가: .collect();
285추가: if self.model.begin(
286추가: Start::CreateZip {
287추가: sources,
288추가: output_file: self.zip_output.clone().into(),
289추가: method: self.method,
290추가: aes256: false,
291추가: },
292추가: self.factory.as_mut(),
293추가: ) {
294추가: self.create = false;
295추가: }
296추가: }
297추가: });
298추가: if ui.button("닫기").clicked() {
299추가: self.create = false;
300추가: }
301추가: });
302추가: }
303추가: if let Some((_, attempt, encrypt)) = self.model.challenge {
304추가: egui::Window::new(if encrypt {
305추가: "ZIP 암호 설정"
306추가: } else {
307추가: "압축파일 암호"
308추가: })
309추가: .collapsible(false)
310추가: .show(&ctx, |ui| {
311추가: ui.label(format!("암호 입력 요청 {attempt}"));
312추가: let edit = ui.add(
313추가: egui::TextEdit::singleline(&mut self.password)
314추가: .password(true)
315추가: .char_limit(1024),
316추가: );
317추가: if ui.button("암호 전달").clicked()
318추가: || (edit.lost_focus() && ui.input(|i| i.key_pressed(egui::Key::Enter)))
319추가: {
320추가: let text = std::mem::take(&mut self.password);
321추가: self.model.password(text);
322추가: }
323추가: if ui.button("작업 취소").clicked() {
324추가: self.password.clear();
325추가: self.model.cancel();
326추가: }
327추가: });
328추가: }
329추가: match self.model.close {
330추가: Close::Confirm => {
331추가: egui::Window::new("작업 중 닫기")
332추가: .collapsible(false)
333추가: .show(&ctx, |ui| {
334추가: ui.label("취소를 요청하고 작업자 종료를 기다릴까요?");
335추가: if ui.button("계속 열기").clicked() {
336추가: self.model.keep_open();
337추가: }
338추가: if ui.button("취소 후 기다리기").clicked() {
339추가: self.model.confirm_close();
340추가: }
341추가: });
342추가: }
343추가: Close::Waiting => {
344추가: egui::Window::new("종료 확인 중")
345추가: .collapsible(false)
346추가: .show(&ctx, |ui| {
347추가: ui.label("취소 결과와 프로세스 종료를 기다립니다");
348추가: if ui.button("닫기 철회").clicked() {
349추가: self.model.keep_open();
350추가: }
351추가: });
352추가: }
353추가: Close::Review => {
354추가: egui::Window::new("결과 확인 후 닫기")
355추가: .collapsible(false)
356추가: .show(&ctx, |ui| {
357추가: ui.label(self.model.status());
358추가: if let Some(t) = &self.model.terminal {
359추가: for line in terminal_lines(t) {
360추가: ui.label(line);
361추가: }
362추가: }
363추가: if ui.button("계속 열기").clicked() {
364추가: self.model.keep_open();
365추가: }
366추가: if ui.button("닫기").clicked() {
367추가: self.model.acknowledge_close();
368추가: }
369추가: });
370추가: }
371추가: _ => {}
372추가: }
373추가: if self.model.busy() {
374추가: ctx.request_repaint_after(std::time::Duration::from_millis(30));
375추가: }
376추가: }
377추가: }
378추가:
379추가: impl eframe::App for ArchiveApp {
380추가: fn ui(&mut self, root: &mut egui::Ui, _: &mut eframe::Frame) {
381추가: self.show(root);
382추가: }
383추가: }
추가experiments/rust-ui-memory-app/src/archive_ui.rs+806-0
@@ -0,0 +1,806 @@
1추가: use std::{collections::BTreeSet, path::PathBuf};
2추가:
3추가: #[derive(Clone, Copy, Debug, Eq, PartialEq)]
4추가: pub enum Format {
5추가: Zip,
6추가: Tar,
7추가: Gzip,
8추가: TarGzip,
9추가: }
10추가: #[derive(Clone, Debug, Eq, PartialEq)]
11추가: pub enum SourceObject {
12추가: Unix { device: u64, inode: u64 },
13추가: Windows { volume: u64, file_id: [u8; 16] },
14추가: }
15추가: #[derive(Clone, Debug, Eq, PartialEq)]
16추가: pub struct ListId {
17추가: pub catalog_version: u16,
18추가: pub format: Format,
19추가: pub source_object: SourceObject,
20추가: pub archive_bytes: u64,
21추가: pub archive_sha256: [u8; 32],
22추가: }
23추가: #[derive(Clone, Debug, Eq, PartialEq)]
24추가: pub enum Selection {
25추가: All,
26추가: EntryIds(Vec<u32>),
27추가: }
28추가: #[derive(Clone, Copy, Debug, Eq, PartialEq)]
29추가: pub enum Method {
30추가: Store,
31추가: Deflate,
32추가: }
33추가: #[derive(Clone, Debug, Eq, PartialEq)]
34추가: pub enum Start {
35추가: List {
36추가: archive: PathBuf,
37추가: },
38추가: Extract {
39추가: archive: PathBuf,
40추가: destination: PathBuf,
41추가: selection: Selection,
42추가: list_id: ListId,
43추가: gzip_output_name: Option<String>,
44추가: },
45추가: CreateZip {
46추가: sources: Vec<(PathBuf, String)>,
47추가: output_file: PathBuf,
48추가: method: Method,
49추가: aes256: bool,
50추가: },
51추가: }
52추가: // 암호를 Debug와 로그에서 제외하고 소유 버퍼를 해제 전에 지움.
53추가: pub struct Secret(Vec<u8>);
54추가: impl Secret {
55추가: pub fn new(text: String) -> Result<Self, &'static str> {
56추가: if text.is_empty() || text.len() > 1024 {
57추가: return Err("암호는 UTF-8 1~1024바이트로 입력하세요");
58추가: }
59추가: Ok(Self(text.into_bytes()))
60추가: }
61추가: pub fn as_bytes(&self) -> &[u8] {
62추가: &self.0
63추가: }
64추가: }
65추가: impl Drop for Secret {
66추가: fn drop(&mut self) {
67추가: self.0.fill(0);
68추가: }
69추가: }
70추가: pub enum Command {
71추가: Start(Start),
72추가: Password { challenge_id: u64, secret: Secret },
73추가: Cancel,
74추가: }
75추가: pub struct Request {
76추가: pub job_id: u64,
77추가: pub sequence: u64,
78추가: pub command: Command,
79추가: }
80추가: #[derive(Clone, Copy, Debug, Eq, PartialEq)]
81추가: pub enum Kind {
82추가: File,
83추가: Directory,
84추가: Link,
85추가: Other,
86추가: }
87추가: #[derive(Clone, Debug, Eq, PartialEq)]
88추가: pub struct Entry {
89추가: pub id: u32,
90추가: pub name: String,
91추가: pub kind: Kind,
92추가: pub bytes: Option<u64>,
93추가: pub packed: Option<u64>,
94추가: pub encrypted: bool,
95추가: }
96추가: #[derive(Clone, Copy, Debug, Eq, PartialEq)]
97추가: pub enum CancelStatus {
98추가: Requested,
99추가: AlreadyRequested,
100추가: TooLate,
101추가: Finished,
102추가: }
103추가: #[derive(Clone, Copy, Debug, Eq, PartialEq)]
104추가: pub enum Stage {
105추가: Scan,
106추가: Read,
107추가: Decode,
108추가: Write,
109추가: Verify,
110추가: Commit,
111추가: }
112추가: #[derive(Clone, Copy, Debug, Eq, PartialEq)]
113추가: pub enum Outcome {
114추가: Completed,
115추가: Failed,
116추가: Cancelled,
117추가: }
118추가: #[derive(Clone, Copy, Debug, Eq, PartialEq)]
119추가: pub enum ErrorCode {
120추가: Integrity,
121추가: UnsupportedFormat,
122추가: UnsupportedFeature,
123추가: WrongPassword,
124추가: UnsafePath,
125추가: Conflict,
126추가: Limit,
127추가: Io,
128추가: Protocol,
129추가: Internal,
130추가: SourceChanged,
131추가: InvalidRequest,
132추가: }
133추가: #[derive(Clone, Copy, Debug, Eq, PartialEq)]
134추가: pub enum Publication {
135추가: None,
136추가: Partial,
137추가: Complete,
138추가: Uncertain,
139추가: }
140추가: #[derive(Clone, Copy, Debug, Eq, PartialEq)]
141추가: pub enum Durability {
142추가: NotApplicable,
143추가: Synced,
144추가: Unconfirmed,
145추가: Failed,
146추가: }
147추가: #[derive(Clone, Copy, Debug, Eq, PartialEq)]
148추가: pub enum Cleanup {
149추가: Complete,
150추가: Failed,
151추가: Unconfirmed,
152추가: }
153추가: #[derive(Clone, Copy, Debug, Eq, PartialEq)]
154추가: pub enum Disposition {
155추가: Created,
156추가: PartialRetained,
157추가: Removed,
158추가: CommitUncertain,
159추가: }
160추가: #[derive(Clone, Debug)]
161추가: pub struct Terminal {
162추가: pub outcome: Outcome,
163추가: pub error: Option<ErrorCode>,
164추가: pub publication: Publication,
165추가: pub created_count: u64,
166추가: pub retained_partial_count: u64,
167추가: pub durability: Durability,
168추가: pub cleanup: Cleanup,
169추가: }
170추가: #[derive(Clone, Debug)]
171추가: pub enum Event {
172추가: Accepted {
173추가: encryption: bool,
174추가: },
175추가: Entry(Entry),
176추가: ListEnd {
177추가: entry_count: u32,
178추가: list_id: ListId,
179추가: },
180추가: PasswordRequired {
181추가: challenge_id: u64,
182추가: attempt: u32,
183추가: encrypt: bool,
184추가: },
185추가: Progress {
186추가: stage: Stage,
187추가: processed: u64,
188추가: total: Option<u64>,
189추가: completed_entries: u64,
190추가: },
191추가: Output {
192추가: entry_id: Option<u32>,
193추가: relative_name: String,
194추가: disposition: Disposition,
195추가: },
196추가: CancelAck {
197추가: request_sequence: u64,
198추가: status: CancelStatus,
199추가: },
200추가: Terminal(Terminal),
201추가: }
202추가: pub enum HostEvent {
203추가: Frame {
204추가: job_id: u64,
205추가: sequence: u64,
206추가: event: Event,
207추가: },
208추가: StdoutEof,
209추가: StderrEof,
210추가: Exited {
211추가: success: bool,
212추가: },
213추가: }
214추가: // 바이트 codec과 프로세스 소유는 작업자 어댑터에서 담당함.
215추가: // 전송 실패 후에도 poll로 양쪽 EOF와 자식 회수 결과를 전달함.
216추가: pub trait Connection {
217추가: fn send(&mut self, request: Request) -> Result<(), String>;
218추가: fn poll(&mut self) -> Option<HostEvent>;
219추가: }
220추가: pub trait Factory {
221추가: fn connect(&mut self, job_id: u64) -> Result<Box<dyn Connection>, String>;
222추가: }
223추가: pub struct Unavailable;
224추가: impl Factory for Unavailable {
225추가: fn connect(&mut self, _: u64) -> Result<Box<dyn Connection>, String> {
226추가: Err("작업자 연결이 아직 준비되지 않았습니다".into())
227추가: }
228추가: }
229추가: struct Running {
230추가: id: u64,
231추가: outgoing: u64,
232추가: incoming: u64,
233추가: accepted: bool,
234추가: start_failed: bool,
235추가: start: Start,
236추가: connection: Box<dyn Connection>,
237추가: entries: Vec<Entry>,
238추가: list_end: Option<(u32, ListId)>,
239추가: stdout_eof: bool,
240추가: stderr_eof: bool,
241추가: exit: Option<bool>,
242추가: cancel_sequence: Option<u64>,
243추가: }
244추가: #[derive(Clone, Copy, Debug, Default, Eq, PartialEq)]
245추가: pub enum Close {
246추가: #[default]
247추가: Open,
248추가: Confirm,
249추가: Waiting,
250추가: Review,
251추가: Allowed,
252추가: }
253추가: #[derive(Default)]
254추가: pub struct Model {
255추가: running: Option<Running>,
256추가: next_id: u64,
257추가: pub archive: Option<PathBuf>,
258추가: pub entries: Vec<Entry>,
259추가: pub list_id: Option<ListId>,
260추가: pub selected: BTreeSet<u32>,
261추가: pub terminal: Option<Terminal>,
262추가: pub challenge: Option<(u64, u32, bool)>,
263추가: pub progress: Option<(Stage, u64, Option<u64>, u64)>,
264추가: pub outputs: Vec<(String, Disposition)>,
265추가: pub cancel: Option<CancelStatus>,
266추가: pub error: Option<String>,
267추가: pub encryption: bool,
268추가: pub close: Close,
269추가: pub confirmed: bool,
270추가: }
271추가: impl Model {
272추가: pub fn busy(&self) -> bool {
273추가: self.running.is_some()
274추가: }
275추가: pub fn job_id(&self) -> Option<u64> {
276추가: self.running.as_ref().map(|r| r.id)
277추가: }
278추가: pub fn can_extract(&self) -> bool {
279추가: !self.busy()
280추가: && self.list_id.is_some()
281추가: && self.archive.is_some()
282추가: && self.close == Close::Open
283추가: }
284추가: pub fn begin(&mut self, start: Start, factory: &mut dyn Factory) -> bool {
285추가: if self.busy() || self.close != Close::Open {
286추가: return false;
287추가: }
288추가: let validation = match &start {
289추가: Start::List { archive } => archive.is_absolute(),
290추가: Start::Extract {
291추가: archive,
292추가: destination,
293추가: selection,
294추가: gzip_output_name,
295추가: list_id,
296추가: } => {
297추가: archive.is_absolute()
298추가: && destination.is_absolute()
299추가: && self.archive.as_ref() == Some(archive)
300추가: && self.list_id.as_ref() == Some(list_id)
301추가: && match list_id.format {
302추가: Format::Gzip => gzip_output_name.as_ref().is_some_and(|s| valid_leaf(s)),
303추가: _ => gzip_output_name.is_none(),
304추가: }
305추가: && match selection {
306추가: Selection::All => true,
307추가: Selection::EntryIds(ids) => {
308추가: !ids.is_empty()
309추가: && ids.iter().collect::<BTreeSet<_>>().len() == ids.len()
310추가: && ids.iter().all(|id| {
311추가: self.entries.iter().any(|e| {
312추가: e.id == *id
313추가: && matches!(e.kind, Kind::File | Kind::Directory)
314추가: })
315추가: })
316추가: }
317추가: }
318추가: }
319추가: Start::CreateZip {
320추가: sources,
321추가: output_file,
322추가: aes256,
323추가: ..
324추가: } => {
325추가: !sources.is_empty()
326추가: && output_file.is_absolute()
327추가: && (!aes256 || self.encryption)
328추가: && sources
329추가: .iter()
330추가: .all(|(p, n)| p.is_absolute() && valid_relative(n))
331추가: }
332추가: };
333추가: if !validation {
334추가: self.error = Some("입력 경로, 출력명과 선택한 목록을 확인하세요".into());
335추가: return false;
336추가: }
337추가: let Some(id) = self.next_id.checked_add(1) else {
338추가: self.error = Some("작업 ID 한도에 도달했습니다".into());
339추가: return false;
340추가: };
341추가: let mut connection = match factory.connect(id) {
342추가: Ok(c) => c,
343추가: Err(e) => {
344추가: self.error = Some(e);
345추가: return false;
346추가: }
347추가: };
348추가: let send_error = connection
349추가: .send(Request {
350추가: job_id: id,
351추가: sequence: 0,
352추가: command: Command::Start(start.clone()),
353추가: })
354추가: .err();
355추가: let started = send_error.is_none();
356추가: if let Start::List { archive } = &start
357추가: && started
358추가: {
359추가: self.archive = Some(archive.clone());
360추가: self.list_id = None;
361추가: self.entries.clear();
362추가: self.selected.clear();
363추가: }
364추가: self.next_id = id;
365추가: self.terminal = None;
366추가: self.challenge = None;
367추가: self.progress = None;
368추가: self.outputs.clear();
369추가: self.cancel = None;
370추가: self.error = send_error;
371추가: self.confirmed = false;
372추가: self.running = Some(Running {
373추가: id,
374추가: outgoing: 1,
375추가: incoming: 0,
376추가: accepted: false,
377추가: start_failed: !started,
378추가: start,
379추가: connection,
380추가: entries: Vec::new(),
381추가: list_end: None,
382추가: stdout_eof: false,
383추가: stderr_eof: false,
384추가: exit: None,
385추가: cancel_sequence: None,
386추가: });
387추가: started
388추가: }
389추가: pub fn extract(
390추가: &mut self,
391추가: destination: PathBuf,
392추가: selected_only: bool,
393추가: gzip_output_name: Option<String>,
394추가: factory: &mut dyn Factory,
395추가: ) -> bool {
396추가: if !self.can_extract() {
397추가: return false;
398추가: }
399추가: self.begin(
400추가: Start::Extract {
401추가: archive: self.archive.clone().unwrap(),
402추가: destination,
403추가: selection: if selected_only {
404추가: Selection::EntryIds(self.selected.iter().copied().collect())
405추가: } else {
406추가: Selection::All
407추가: },
408추가: list_id: self.list_id.clone().unwrap(),
409추가: gzip_output_name,
410추가: },
411추가: factory,
412추가: )
413추가: }
414추가: pub fn password(&mut self, text: String) -> bool {
415추가: let Some((challenge_id, _, _)) = self.challenge else {
416추가: return false;
417추가: };
418추가: let secret = match Secret::new(text) {
419추가: Ok(s) => s,
420추가: Err(e) => {
421추가: self.error = Some(e.into());
422추가: return false;
423추가: }
424추가: };
425추가: if self
426추가: .send(Command::Password {
427추가: challenge_id,
428추가: secret,
429추가: })
430추가: .is_some()
431추가: {
432추가: self.challenge = None;
433추가: self.error = None;
434추가: true
435추가: } else {
436추가: false
437추가: }
438추가: }
439추가: fn send(&mut self, command: Command) -> Option<u64> {
440추가: let run = self.running.as_mut()?;
441추가: if run.start_failed || self.terminal.is_some() || run.exit.is_some() {
442추가: return None;
443추가: }
444추가: let seq = run.outgoing;
445추가: let Some(next) = seq.checked_add(1) else {
446추가: self.error = Some("요청 순서 한도 초과".into());
447추가: return None;
448추가: };
449추가: match run.connection.send(Request {
450추가: job_id: run.id,
451추가: sequence: seq,
452추가: command,
453추가: }) {
454추가: Ok(()) => {
455추가: run.outgoing = next;
456추가: Some(seq)
457추가: }
458추가: Err(e) => {
459추가: self.error = Some(e);
460추가: None
461추가: }
462추가: }
463추가: }
464추가: pub fn cancel(&mut self) {
465추가: if self
466추가: .running
467추가: .as_ref()
468추가: .is_some_and(|r| r.cancel_sequence.is_none())
469추가: {
470추가: if let Some(seq) = self.send(Command::Cancel) {
471추가: self.running.as_mut().unwrap().cancel_sequence = Some(seq);
472추가: self.challenge = None;
473추가: }
474추가: }
475추가: }
476추가: pub fn request_close(&mut self) {
477추가: if self.close == Close::Open {
478추가: self.close = if self.busy() {
479추가: Close::Confirm
480추가: } else {
481추가: Close::Review
482추가: };
483추가: }
484추가: }
485추가: pub fn confirm_close(&mut self) {
486추가: if self.close == Close::Confirm {
487추가: self.cancel();
488추가: self.close = if self.busy() {
489추가: Close::Waiting
490추가: } else {
491추가: Close::Review
492추가: };
493추가: }
494추가: }
495추가: pub fn keep_open(&mut self) {
496추가: if self.close != Close::Allowed {
497추가: self.close = Close::Open;
498추가: }
499추가: }
500추가: pub fn acknowledge_close(&mut self) {
501추가: if !self.busy() && self.close == Close::Review {
502추가: self.close = Close::Allowed;
503추가: }
504추가: }
505추가: pub fn poll(&mut self) {
506추가: for _ in 0..128 {
507추가: let Some(event) = self.running.as_mut().and_then(|r| r.connection.poll()) else {
508추가: break;
509추가: };
510추가: self.receive(event);
511추가: }
512추가: let complete = self
513추가: .running
514추가: .as_ref()
515추가: .is_some_and(|r| r.stdout_eof && r.stderr_eof && r.exit.is_some());
516추가: if complete {
517추가: let run = self.running.take().unwrap();
518추가: self.confirmed =
519추가: self.terminal.is_some() && run.exit == Some(true) && self.error.is_none();
520추가: if !self.confirmed {
521추가: self.error.get_or_insert(
522추가: "작업자 종료 결과를 확인할 수 없습니다. 출력 상태를 확인하세요".into(),
523추가: );
524추가: }
525추가: if self.confirmed
526추가: && self
527추가: .terminal
528추가: .as_ref()
529추가: .is_some_and(|t| t.outcome == Outcome::Completed)
530추가: {
531추가: if matches!(run.start, Start::List { .. }) {
532추가: if let Some((count, id)) = run
533추가: .list_end
534추가: .filter(|(n, _)| *n as usize == run.entries.len())
535추가: {
536추가: let _ = count;
537추가: self.entries = run.entries;
538추가: self.list_id = Some(id);
539추가: } else {
540추가: self.error = Some("목록 완료 정보가 일치하지 않습니다. 다시 여세요".into());
541추가: self.confirmed = false;
542추가: }
543추가: }
544추가: }
545추가: if self
546추가: .terminal
547추가: .as_ref()
548추가: .is_some_and(|t| t.error == Some(ErrorCode::SourceChanged))
549추가: {
550추가: self.list_id = None;
551추가: self.selected.clear();
552추가: }
553추가: self.challenge = None;
554추가: if matches!(self.close, Close::Waiting | Close::Confirm) {
555추가: self.close = Close::Review;
556추가: }
557추가: }
558추가: }
559추가: fn receive(&mut self, host: HostEvent) {
560추가: let run = self.running.as_mut().unwrap();
561추가: match host {
562추가: HostEvent::StdoutEof => run.stdout_eof = true,
563추가: HostEvent::StderrEof => run.stderr_eof = true,
564추가: HostEvent::Exited { success } => run.exit = Some(success),
565추가: HostEvent::Frame {
566추가: job_id,
567추가: sequence,
568추가: event,
569추가: } => {
570추가: if job_id != run.id
571추가: || sequence != run.incoming
572추가: || self.terminal.is_some()
573추가: || run.stdout_eof
574추가: || sequence >= 1_000_000
575추가: {
576추가: self.error = Some("작업자 응답 순서나 작업 ID가 일치하지 않습니다".into());
577추가: return;
578추가: }
579추가: run.incoming += 1;
580추가: if !run.accepted && !matches!(event, Event::Accepted { .. }) {
581추가: self.error = Some("작업 승인 응답이 없습니다".into());
582추가: return;
583추가: }
584추가: match event {
585추가: Event::Accepted { encryption } => {
586추가: if run.accepted {
587추가: self.error = Some("작업 승인 중복".into());
588추가: }
589추가: run.accepted = true;
590추가: self.encryption = encryption;
591추가: }
592추가: Event::Entry(entry) => {
593추가: if !matches!(run.start, Start::List { .. })
594추가: || run.list_end.is_some()
595추가: || entry.id as usize != run.entries.len()
596추가: || entry.name.len() > 4096
597추가: || run.entries.len() >= 100_000
598추가: {
599추가: self.error = Some("목록 응답이 유효하지 않습니다".into());
600추가: } else {
601추가: run.entries.push(entry);
602추가: }
603추가: }
604추가: Event::ListEnd {
605추가: entry_count,
606추가: list_id,
607추가: } => {
608추가: if !matches!(run.start, Start::List { .. })
609추가: || run.list_end.is_some()
610추가: || list_id.catalog_version != 1
611추가: {
612추가: self.error = Some("목록 완료 응답이 유효하지 않습니다".into());
613추가: } else {
614추가: run.list_end = Some((entry_count, list_id));
615추가: }
616추가: }
617추가: Event::PasswordRequired {
618추가: challenge_id,
619추가: attempt,
620추가: encrypt,
621추가: } => {
622추가: if self.challenge.is_some() || challenge_id == 0 {
623추가: self.error = Some("암호 요청이 유효하지 않습니다".into());
624추가: } else {
625추가: self.challenge = Some((challenge_id, attempt, encrypt));
626추가: }
627추가: }
628추가: Event::Progress {
629추가: stage,
630추가: processed,
631추가: total,
632추가: completed_entries,
633추가: } => self.progress = Some((stage, processed, total, completed_entries)),
634추가: Event::Output {
635추가: relative_name,
636추가: disposition,
637추가: ..
638추가: } => {
639추가: if self.outputs.len() < 100_000 && relative_name.len() <= 4096 {
640추가: self.outputs.push((relative_name, disposition));
641추가: } else {
642추가: self.error = Some("출력 보고 한도 초과".into());
643추가: }
644추가: }
645추가: Event::CancelAck {
646추가: request_sequence,
647추가: status,
648추가: } => {
649추가: if run.cancel_sequence == Some(request_sequence) && self.cancel.is_none() {
650추가: self.cancel = Some(status);
651추가: } else {
652추가: self.error = Some("취소 응답이 요청과 일치하지 않습니다".into());
653추가: }
654추가: }
655추가: Event::Terminal(t) => {
656추가: self.challenge = None;
657추가: self.terminal = Some(t);
658추가: }
659추가: }
660추가: }
661추가: }
662추가: }
663추가: pub fn status(&self) -> String {
664추가: if let Some(error) = &self.error {
665추가: return error.clone();
666추가: }
667추가: if self.busy() {
668추가: if self.terminal.is_some() {
669추가: return "작업 결과 수신 / 프로세스 종료 확인 중".into();
670추가: }
671추가: if self.challenge.is_some() {
672추가: return "암호를 입력하세요".into();
673추가: }
674추가: if let Some(c) = self.cancel {
675추가: return match c {
676추가: CancelStatus::Requested | CancelStatus::AlreadyRequested => {
677추가: "취소 요청 접수 / 최종 결과 대기"
678추가: }
679추가: CancelStatus::TooLate => "취소할 수 없는 단계 / 최종 결과 대기",
680추가: CancelStatus::Finished => "처리 종료 응답 / 프로세스 종료 확인 중",
681추가: }
682추가: .into();
683추가: }
684추가: if self
685추가: .running
686추가: .as_ref()
687추가: .is_some_and(|r| r.cancel_sequence.is_some())
688추가: {
689추가: return "취소 요청 전송 / 최종 결과 대기".into();
690추가: }
691추가: return "작업 중".into();
692추가: }
693추가: match self
694추가: .terminal
695추가: .as_ref()
696추가: .filter(|_| self.confirmed)
697추가: .map(|t| t.outcome)
698추가: {
699추가: Some(Outcome::Completed) => "작업 완료",
700추가: Some(Outcome::Cancelled) => "작업 취소됨",
701추가: Some(Outcome::Failed) => "작업 실패",
702추가: None => "압축파일을 열거나 ZIP 파일을 만드세요",
703추가: }
704추가: .into()
705추가: }
706추가: }
707추가: pub fn valid_leaf(name: &str) -> bool {
708추가: valid_relative(name) && !name.contains('/') && !name.contains('\\')
709추가: }
710추가: pub fn valid_relative(name: &str) -> bool {
711추가: !name.is_empty()
712추가: && !name.contains('\0')
713추가: && !name.contains(':')
714추가: && !name.starts_with('/')
715추가: && !name.starts_with('\\')
716추가: && name
717추가: .split(['/', '\\'])
718추가: .all(|p| !p.is_empty() && p != "." && p != "..")
719추가: }
720추가:
721추가: // 파일 연결로 전달된 원형 경로를 손실 변환 없이 보존함.
722추가: pub fn launch_args(
723추가: args: Vec<std::ffi::OsString>,
724추가: cwd: PathBuf,
725추가: ) -> Result<(bool, Option<PathBuf>), &'static str> {
726추가: let fixture = args.iter().any(|arg| arg == "--ui-fixture");
727추가: let paths = args
728추가: .into_iter()
729추가: .filter(|arg| arg != "--ui-fixture")
730추가: .collect::<Vec<_>>();
731추가: if paths.len() > 1 {
732추가: return Err("압축파일 하나를 지정하세요");
733추가: }
734추가: let path = paths
735추가: .into_iter()
736추가: .next()
737추가: .map(PathBuf::from)
738추가: .map(|p| if p.is_absolute() { p } else { cwd.join(p) });
739추가: Ok((fixture, path))
740추가: }
741추가:
742추가: pub fn stage_label(stage: Stage) -> &'static str {
743추가: match stage {
744추가: Stage::Scan => "목록 읽는 중",
745추가: Stage::Read => "파일 읽는 중",
746추가: Stage::Decode => "압축 푸는 중",
747추가: Stage::Write => "파일 쓰는 중",
748추가: Stage::Verify => "검증 중",
749추가: Stage::Commit => "저장 마무리 중",
750추가: }
751추가: }
752추가: pub fn disposition_label(disposition: Disposition) -> &'static str {
753추가: match disposition {
754추가: Disposition::Created => "생성됨",
755추가: Disposition::PartialRetained => "일부 파일 남음",
756추가: Disposition::Removed => "작업 임시 파일 정리됨",
757추가: Disposition::CommitUncertain => "저장 여부 불확실",
758추가: }
759추가: }
760추가: pub fn terminal_lines(t: &Terminal) -> Vec<String> {
761추가: let publication = match t.publication {
762추가: Publication::None => "게시된 파일 없음",
763추가: Publication::Partial => "일부 파일 게시됨",
764추가: Publication::Complete => "파일 게시 완료",
765추가: Publication::Uncertain => "파일 게시 여부 불확실 / 출력 폴더를 확인하세요",
766추가: };
767추가: let durability = match t.durability {
768추가: Durability::NotApplicable => "동기화 해당 없음",
769추가: Durability::Synced => "디스크 동기화 완료",
770추가: Durability::Unconfirmed => "디스크 동기화 미확인",
771추가: Durability::Failed => "디스크 동기화 실패",
772추가: };
773추가: let cleanup = match t.cleanup {
774추가: Cleanup::Complete => "작업 임시 파일 정리 완료",
775추가: Cleanup::Failed => "작업 임시 파일 정리 실패",
776추가: Cleanup::Unconfirmed => "작업 임시 파일 정리 미확인",
777추가: };
778추가: let mut lines = vec![
779추가: publication.into(),
780추가: format!(
781추가: "생성 {}개 / 남은 임시 파일 {}개",
782추가: t.created_count, t.retained_partial_count
783추가: ),
784추가: format!("{durability} / {cleanup}"),
785추가: ];
786추가: if let Some(error) = t.error {
787추가: lines.push(
788추가: match error {
789추가: ErrorCode::Integrity => "압축파일이 손상됐습니다",
790추가: ErrorCode::UnsupportedFormat => "지원하지 않는 압축 형식입니다",
791추가: ErrorCode::UnsupportedFeature => "아직 지원하지 않는 기능입니다",
792추가: ErrorCode::WrongPassword => "암호가 올바르지 않습니다",
793추가: ErrorCode::UnsafePath => "안전하지 않은 경로가 있어 중단했습니다",
794추가: ErrorCode::Conflict => "같은 이름의 파일이 있습니다. 다른 출력 폴더를 선택하세요",
795추가: ErrorCode::Limit => "처리 한도를 초과했습니다",
796추가: ErrorCode::Io => "파일을 읽거나 쓰지 못했습니다",
797추가: ErrorCode::Protocol => "작업자 응답이 올바르지 않습니다",
798추가: ErrorCode::Internal => "작업자 처리 오류입니다",
799추가: ErrorCode::SourceChanged => "원본 파일이 바뀌었습니다. 압축파일을 다시 여세요",
800추가: ErrorCode::InvalidRequest => "입력과 선택한 항목을 확인하세요",
801추가: }
802추가: .into(),
803추가: );
804추가: }
805추가: lines
806추가: }
추가experiments/rust-ui-memory-app/src/desktop.rs+68-0
@@ -0,0 +1,68 @@
1추가: #[cfg(feature = "ui-fixture")]
2추가: #[path = "../../../tests/rust-app-ui/fake.rs"]
3추가: mod fake;
4추가: #[path = "system_font.rs"]
5추가: mod system_font;
6추가: use eframe::egui::{self, Color32, FontData, FontDefinitions, FontFamily, FontId, TextStyle};
7추가: fn main() -> eframe::Result {
8추가: let font = system_font::load().map_err(|e| eframe::Error::AppCreation(Box::new(e)))?;
9추가: eframe::run_native(
10추가: "Zipelo",
11추가: eframe::NativeOptions {
12추가: renderer: eframe::Renderer::Glow,
13추가: viewport: egui::ViewportBuilder::default()
14추가: .with_inner_size([1060.0, 720.0])
15추가: .with_min_inner_size([760.0, 540.0]),
16추가: ..Default::default()
17추가: },
18추가: Box::new(move |cc| {
19추가: let mut fonts = FontDefinitions::empty();
20추가: let mut data = FontData::from_owned(font.bytes);
21추가: data.index = font.face_index;
22추가: fonts.font_data.insert("noto-kr".into(), data.into());
23추가: fonts
24추가: .families
25추가: .insert(FontFamily::Proportional, vec!["noto-kr".into()]);
26추가: cc.egui_ctx.set_fonts(fonts);
27추가: cc.egui_ctx.set_visuals(egui::Visuals::light());
28추가: cc.egui_ctx.style_mut_of(egui::Theme::Light, |style| {
29추가: style
30추가: .text_styles
31추가: .insert(TextStyle::Body, FontId::proportional(18.0));
32추가: style
33추가: .text_styles
34추가: .insert(TextStyle::Button, FontId::proportional(18.0));
35추가: style
36추가: .text_styles
37추가: .insert(TextStyle::Heading, FontId::proportional(26.0));
38추가: style.visuals.panel_fill = Color32::WHITE;
39추가: style.visuals.override_text_color = Some(Color32::from_rgb(24, 39, 57));
40추가: style.visuals.selection.bg_fill = Color32::from_rgb(211, 230, 246);
41추가: style.spacing.item_spacing = egui::vec2(12.0, 10.0);
42추가: style.spacing.button_padding = egui::vec2(14.0, 10.0);
43추가: });
44추가: let (fixture, startup) = zipelo_ui_memory_app::archive_ui::launch_args(
45추가: std::env::args_os().skip(1).collect(),
46추가: std::env::current_dir()?,
47추가: )
48추가: .map_err(std::io::Error::other)?;
49추가: let factory: Box<dyn zipelo_ui_memory_app::archive_ui::Factory> = if fixture {
50추가: #[cfg(feature = "ui-fixture")]
51추가: {
52추가: Box::new(fake::FakeFactory::default())
53추가: }
54추가: #[cfg(not(feature = "ui-fixture"))]
55추가: {
56추가: return Err(Box::new(std::io::Error::other(
57추가: "ui-fixture feature가 필요합니다",
58추가: )));
59추가: }
60추가: } else {
61추가: Box::new(zipelo_ui_memory_app::archive_ui::Unavailable)
62추가: };
63추가: Ok(Box::new(
64추가: zipelo_ui_memory_app::archive_screen::ArchiveApp::new(factory, startup, fixture),
65추가: ))
66추가: }),
67추가: )
68추가: }
수정experiments/rust-ui-memory-app/src/lib.rs+5-0
@@ -4,3 +4,8 @@ pub use core_memory as core;
44pub mod controller;
55pub mod runtime;
66pub mod transport;
7추가:
8추가: pub mod archive_ui;
9추가:
10추가: #[cfg(feature = "ui")]
11추가: pub mod archive_screen;
추가tests/rust-app-ui/.gitignore+3-0
@@ -0,0 +1,3 @@
1추가: screens/
2추가: screens-*/
3추가: __pycache__/
추가tests/rust-app-ui/README.md+19-0
@@ -0,0 +1,19 @@
1추가: # 앱 화면 흐름 시험
2추가:
3추가: 가짜 작업자는 계약 revision 2의 의미를 따르는 프론트엔드 어댑터임. 바이너리 codec, 실제 프로세스 실행, 파일 읽기와 쓰기, 암호 해독은 수행하지 않음. 실제 codec은 backend 소유이며 이 PR에서 중복 구현하지 않음.
4추가:
5추가: `python3 tests/ci/run_rust.py local`은 기존 시험과 새 `archive_ui` 시험을 all-features로 실행함. Windows 결과는 교차 빌드이며 Windows 실제 실행은 별도 확인해야 함.
6추가:
7추가: 화면 직접 확인:
8추가:
9추가: ```sh
10추가: cargo +1.99.1 run --locked --manifest-path experiments/rust-ui-memory-app/Cargo.toml --features ui-fixture -- --ui-fixture /absolute/example.zip
11추가: ```
12추가:
13추가: `locked.zip` 이름은 가짜 암호 요청을 만듦. 아무 비어 있지 않은 합성 암호를 받으며 암호를 기록하거나 저장하지 않음. 실제 암호나 사용자 자료를 입력할 필요가 없음. 시험 모드는 화면에 명시되고 실제 파일을 만들지 않음. `ui-fixture` 없이 실행하면 작업자 미연결 오류를 표시하며 가짜 성공으로 대체하지 않음.
14추가:
15추가: 범위는 목록 확인, 선택 해제, GZ 출력명, ZIP 생성, 암호 요청, 진행률, 취소와 닫기 철회, Terminal/EOF/child wait 분리, 오래된 ID/sequence 거부, SourceChanged 재열람, 부분 출력과 불확실 게시 보존임. 구성한 이벤트 시험은 실제 OS 종료나 파일 보안 검증의 증거가 아님.
16추가:
17추가: 디자인은 흰 바탕 #FFFFFF, 글자 #182739, 선택 #D3E6F6, 강조 #174C7C를 사용함. 기존 한글 시스템 폰트와 본문/버튼 18px, 제목 26px를 유지함. 상단 작업 버튼, 가운데 파일 목록, 하단 진행/결과의 왼쪽 정렬 구조이며 작은 부가 설명, 장식 카드와 새 아이콘을 추가하지 않음.
18추가:
19추가: 풀기 버튼은 raw GZ에만 출력명을 보내며 ZIP/TAR/TAR.GZ에는 None을 보냄. 모델과 가짜 작업자도 이 계약을 검증함. Start 전송 실패 시에는 연결을 보존하고 추가 요청을 막으며, 양쪽 EOF와 child wait가 모두 올 때까지 교체와 닫기를 허용하지 않음. 이때 Terminal이 없어도 종료 후 오류 확인 화면으로 이동하며 성공으로 표시하지 않음.
추가tests/rust-app-ui/fake.rs+213-0
@@ -0,0 +1,213 @@
1추가: use std::{cell::RefCell, collections::VecDeque, rc::Rc};
2추가: use zipelo_ui_memory_app::archive_ui::*;
3추가:
4추가: #[derive(Default)]
5추가: pub struct State {
6추가: pub requests: Vec<(u64, &'static str)>,
7추가: pub starts: Vec<Start>,
8추가: pub password_seen: bool,
9추가: pub job: u64,
10추가: sequence: u64,
11추가: pub queue: VecDeque<HostEvent>,
12추가: pub manual: bool,
13추가: pub list_format: Option<Format>,
14추가: pub fail_start: bool,
15추가: pub dropped_connections: usize,
16추가: pause: bool,
17추가: }
18추가: #[derive(Default, Clone)]
19추가: pub struct FakeFactory {
20추가: pub state: Rc<RefCell<State>>,
21추가: }
22추가: impl FakeFactory {
23추가: pub fn manual() -> Self {
24추가: let f = Self::default();
25추가: f.state.borrow_mut().manual = true;
26추가: f
27추가: }
28추가: }
29추가: impl State {
30추가: pub fn frame(&mut self, event: Event) {
31추가: let sequence = self.sequence;
32추가: self.sequence += 1;
33추가: self.queue.push_back(HostEvent::Frame {
34추가: job_id: self.job,
35추가: sequence,
36추가: event,
37추가: });
38추가: }
39추가: pub fn finish(&mut self, outcome: Outcome, publication: Publication) {
40추가: self.frame(Event::Terminal(Terminal {
41추가: outcome,
42추가: error: None,
43추가: publication,
44추가: created_count: if publication == Publication::Complete {
45추가: 1
46추가: } else {
47추가: 0
48추가: },
49추가: retained_partial_count: 0,
50추가: durability: Durability::Synced,
51추가: cleanup: Cleanup::Complete,
52추가: }));
53추가: self.queue.push_back(HostEvent::StdoutEof);
54추가: self.queue.push_back(HostEvent::StderrEof);
55추가: self.queue.push_back(HostEvent::Exited { success: true });
56추가: }
57추가: fn complete_action(&mut self) {
58추가: match self.starts.last().cloned().unwrap() {
59추가: Start::List { archive } => {
60추가: self.frame(Event::Entry(Entry {
61추가: id: 0,
62추가: name: "읽어주세요.txt".into(),
63추가: kind: Kind::File,
64추가: bytes: Some(31),
65추가: packed: Some(54),
66추가: encrypted: false,
67추가: }));
68추가: let format = self.list_format.unwrap_or_else(|| {
69추가: if archive.extension().is_some_and(|x| x == "gz") {
70추가: Format::Gzip
71추가: } else {
72추가: Format::Zip
73추가: }
74추가: });
75추가: self.frame(Event::ListEnd {
76추가: entry_count: 1,
77추가: list_id: ListId {
78추가: catalog_version: 1,
79추가: format,
80추가: source_object: SourceObject::Unix {
81추가: device: 1,
82추가: inode: 1,
83추가: },
84추가: archive_bytes: 54,
85추가: archive_sha256: [7; 32],
86추가: },
87추가: });
88추가: self.finish(Outcome::Completed, Publication::None);
89추가: }
90추가: _ => {
91추가: self.frame(Event::Progress {
92추가: stage: Stage::Write,
93추가: processed: 31,
94추가: total: Some(31),
95추가: completed_entries: 1,
96추가: });
97추가: self.frame(Event::Output {
98추가: entry_id: Some(0),
99추가: relative_name: "읽어주세요.txt".into(),
100추가: disposition: Disposition::Created,
101추가: });
102추가: self.finish(Outcome::Completed, Publication::Complete);
103추가: }
104추가: }
105추가: }
106추가: }
107추가: struct FakeConnection {
108추가: state: Rc<RefCell<State>>,
109추가: }
110추가: impl Drop for FakeConnection {
111추가: fn drop(&mut self) {
112추가: self.state.borrow_mut().dropped_connections += 1;
113추가: }
114추가: }
115추가: impl Factory for FakeFactory {
116추가: fn connect(&mut self, job: u64) -> Result<Box<dyn Connection>, String> {
117추가: let mut s = self.state.borrow_mut();
118추가: s.job = job;
119추가: s.sequence = 0;
120추가: s.queue.clear();
121추가: s.pause = false;
122추가: Ok(Box::new(FakeConnection {
123추가: state: self.state.clone(),
124추가: }))
125추가: }
126추가: }
127추가: impl Connection for FakeConnection {
128추가: fn send(&mut self, request: Request) -> Result<(), String> {
129추가: let mut s = self.state.borrow_mut();
130추가: assert_eq!(s.job, request.job_id);
131추가: match request.command {
132추가: Command::Start(start) => {
133추가: if let Start::Extract {
134추가: list_id,
135추가: gzip_output_name,
136추가: ..
137추가: } = &start
138추가: {
139추가: let valid = match list_id.format {
140추가: Format::Gzip => gzip_output_name.as_deref().is_some_and(valid_leaf),
141추가: _ => gzip_output_name.is_none(),
142추가: };
143추가: if !valid {
144추가: return Err("형식에 맞지 않는 GZIP 출력명".into());
145추가: }
146추가: }
147추가: s.requests.push((request.sequence, "start"));
148추가: s.starts.push(start.clone());
149추가: if s.fail_start {
150추가: return Err("Start 전송 실패".into());
151추가: }
152추가: if !s.manual {
153추가: s.frame(Event::Accepted { encryption: false });
154추가: s.frame(Event::Progress {
155추가: stage: Stage::Scan,
156추가: processed: 0,
157추가: total: None,
158추가: completed_entries: 0,
159추가: });
160추가: if matches!(&start,Start::List {archive} if archive.file_name().is_some_and(|n|n.to_string_lossy().contains("locked")))
161추가: {
162추가: s.frame(Event::PasswordRequired {
163추가: challenge_id: 17,
164추가: attempt: 1,
165추가: encrypt: false,
166추가: });
167추가: } else {
168추가: s.complete_action();
169추가: }
170추가: }
171추가: }
172추가: Command::Password {
173추가: challenge_id,
174추가: secret,
175추가: } => {
176추가: assert_eq!(challenge_id, 17);
177추가: assert!(!secret.as_bytes().is_empty());
178추가: s.password_seen = true;
179추가: s.requests.push((request.sequence, "password"));
180추가: if !s.manual {
181추가: s.complete_action();
182추가: }
183추가: }
184추가: Command::Cancel => {
185추가: s.requests.push((request.sequence, "cancel"));
186추가: if !s.manual {
187추가: let consumed = s
188추가: .queue
189추가: .iter()
190추가: .filter(|e| matches!(e, HostEvent::Frame { .. }))
191추가: .count() as u64;
192추가: s.sequence -= consumed;
193추가: s.queue.clear();
194추가: s.frame(Event::CancelAck {
195추가: request_sequence: request.sequence,
196추가: status: CancelStatus::Requested,
197추가: });
198추가: s.finish(Outcome::Cancelled, Publication::None);
199추가: }
200추가: }
201추가: }
202추가: Ok(())
203추가: }
204추가: fn poll(&mut self) -> Option<HostEvent> {
205추가: let mut s = self.state.borrow_mut();
206추가: if s.pause {
207추가: s.pause = false;
208추가: return None;
209추가: }
210추가: s.pause = true;
211추가: s.queue.pop_front()
212추가: }
213추가: }
추가tests/rust-app-ui/native_smoke.py+64-0
@@ -0,0 +1,64 @@
1추가: import os
2추가: from pathlib import Path
3추가: import select
4추가: import signal
5추가: import subprocess
6추가: import time
7추가:
8추가:
9추가: ROOT = Path(__file__).resolve().parents[2]
10추가: OUTPUT = ROOT / "tests/rust-app-ui" / ("screens-" + str(time.time_ns()))
11추가:
12추가:
13추가: def main():
14추가: OUTPUT.mkdir(exist_ok=True)
15추가: display = subprocess.Popen(
16추가: ["Xvfb", "-displayfd", "1", "-screen", "0", "1280x900x24", "-nolisten", "tcp"],
17추가: stdout=subprocess.PIPE, stderr=subprocess.PIPE, start_new_session=True,
18추가: )
19추가: app = None
20추가: try:
21추가: if not select.select([display.stdout], [], [], 15)[0]:
22추가: raise RuntimeError("Xvfb 준비 시간 초과")
23추가: number = display.stdout.readline().decode().strip()
24추가: if not number.isdecimal():
25추가: raise RuntimeError("Xvfb display 응답 오류")
26추가: env = {**os.environ, "DISPLAY": ":" + number, "WINIT_UNIX_BACKEND": "x11"}
27추가: env.pop("WAYLAND_DISPLAY", None)
28추가: with (OUTPUT / "app.stdout").open("wb") as stdout, (OUTPUT / "app.stderr").open("wb") as stderr:
29추가: app = subprocess.Popen(
30추가: [str(ROOT / "tests/ci/target/debug/zipelo-ui-memory-app"), "--ui-fixture", "/synthetic/example.zip"],
31추가: env=env, stdout=stdout, stderr=stderr, start_new_session=True,
32추가: )
33추가: deadline = time.monotonic() + 30
34추가: while True:
35추가: if app.poll() is not None:
36추가: raise RuntimeError(f"화면 조기 종료: {app.returncode}")
37추가: window = subprocess.run(["xdotool", "search", "--all", "--pid", str(app.pid), "--name", "Zipelo"], env=env, timeout=5, capture_output=True)
38추가: if window.returncode == 0:
39추가: break
40추가: if time.monotonic() >= deadline:
41추가: raise RuntimeError("소유 창 표시 시간 초과")
42추가: time.sleep(0.1)
43추가: time.sleep(1)
44추가: subprocess.run(["import", "-window", "root", str(OUTPUT / "list.png")], env=env, timeout=10, check=True)
45추가: subprocess.run(["xdotool", "search", "--pid", str(app.pid), "--name", "Zipelo"], env=env, timeout=10, check=True)
46추가: print(str(OUTPUT / "list.png"))
47추가: finally:
48추가: for process in [app, display]:
49추가: if process is not None:
50추가: if process.poll() is None:
51추가: os.killpg(process.pid, signal.SIGTERM)
52추가: try:
53추가: process.wait(timeout=5)
54추가: except subprocess.TimeoutExpired:
55추가: os.killpg(process.pid, signal.SIGKILL)
56추가: process.wait(timeout=5)
57추가: if display.stdout:
58추가: display.stdout.close()
59추가: if display.stderr:
60추가: display.stderr.close()
61추가:
62추가:
63추가: if __name__ == "__main__":
64추가: main()
추가tests/rust-app-ui/regressions.rs+728-0
@@ -0,0 +1,728 @@
1추가: mod fake;
2추가: use fake::*;
3추가: use std::path::PathBuf;
4추가: use zipelo_ui_memory_app::archive_ui::*;
5추가:
6추가: fn path(name: &str) -> PathBuf {
7추가: std::env::current_dir().unwrap().join(name)
8추가: }
9추가: fn pump(m: &mut Model) {
10추가: for _ in 0..100 {
11추가: m.poll();
12추가: if !m.busy() {
13추가: return;
14추가: }
15추가: }
16추가: panic!("가짜 작업자 종료 누락: {}", m.status());
17추가: }
18추가: fn list(m: &mut Model, f: &mut FakeFactory) {
19추가: assert!(m.begin(
20추가: Start::List {
21추가: archive: path("example.zip")
22추가: },
23추가: f
24추가: ));
25추가: pump(m);
26추가: assert!(m.list_id.is_some());
27추가: }
28추가:
29추가: #[test]
30추가: fn open_lists_only_after_terminal_eofs_and_wait() {
31추가: let mut f = FakeFactory::default();
32추가: let mut m = Model::default();
33추가: assert!(m.begin(
34추가: Start::List {
35추가: archive: path("example.zip")
36추가: },
37추가: &mut f
38추가: ));
39추가: while m.terminal.is_none() {
40추가: m.poll();
41추가: assert!(m.list_id.is_none());
42추가: assert!(!m.can_extract());
43추가: }
44추가: assert!(m.busy());
45추가: assert!(!m.begin(
46추가: Start::List {
47추가: archive: path("replacement.zip")
48추가: },
49추가: &mut f
50추가: ));
51추가: pump(&mut m);
52추가: assert_eq!(m.entries[0].name, "읽어주세요.txt");
53추가: assert!(m.can_extract());
54추가: assert!(m.confirmed);
55추가: }
56추가: #[test]
57추가: fn extract_uses_list_token_selection_and_destination() {
58추가: let mut f = FakeFactory::default();
59추가: let mut m = Model::default();
60추가: list(&mut m, &mut f);
61추가: let token = m.list_id.clone().unwrap();
62추가: m.selected.insert(0);
63추가: assert!(m.extract(path("output"), true, None, &mut f));
64추가: pump(&mut m);
65추가: assert!(
66추가: matches!(f.state.borrow().starts.last(),Some(Start::Extract {selection:Selection::EntryIds(ids),list_id,..}) if ids==&vec![0]&&*list_id==token)
67추가: );
68추가: assert_eq!(m.terminal.unwrap().publication, Publication::Complete);
69추가: }
70추가: #[test]
71추가: fn gzip_requires_explicit_leaf() {
72추가: let mut f = FakeFactory::default();
73추가: let mut m = Model::default();
74추가: assert!(m.begin(
75추가: Start::List {
76추가: archive: path("sample.gz")
77추가: },
78추가: &mut f
79추가: ));
80추가: pump(&mut m);
81추가: for name in [None, Some("../escape".into()), Some("sub/file".into())] {
82추가: assert!(!m.extract(path("output"), false, name, &mut f));
83추가: }
84추가: assert!(m.extract(path("output"), false, Some("plain.txt".into()), &mut f));
85추가: pump(&mut m);
86추가: }
87추가: #[test]
88추가: fn creates_zip_and_reports_progress_outputs() {
89추가: let mut f = FakeFactory::default();
90추가: let mut m = Model::default();
91추가: assert!(m.begin(
92추가: Start::CreateZip {
93추가: sources: vec![(path("one.txt"), "one.txt".into())],
94추가: output_file: path("new.zip"),
95추가: method: Method::Deflate,
96추가: aes256: false
97추가: },
98추가: &mut f
99추가: ));
100추가: pump(&mut m);
101추가: assert_eq!(m.progress.unwrap().1, 31);
102추가: assert_eq!(m.outputs.len(), 1);
103추가: assert_eq!(m.status(), "작업 완료");
104추가: }
105추가: #[test]
106추가: fn password_challenge_is_answered_without_retaining_secret() {
107추가: let mut f = FakeFactory::default();
108추가: let mut m = Model::default();
109추가: assert!(m.begin(
110추가: Start::List {
111추가: archive: path("locked.zip")
112추가: },
113추가: &mut f
114추가: ));
115추가: for _ in 0..10 {
116추가: m.poll();
117추가: if m.challenge.is_some() {
118추가: break;
119추가: }
120추가: }
121추가: assert_eq!(m.challenge, Some((17, 1, false)));
122추가: assert!(!m.password(String::new()));
123추가: assert!(m.password("synthetic password".into()));
124추가: pump(&mut m);
125추가: assert!(f.state.borrow().password_seen);
126추가: assert!(m.challenge.is_none());
127추가: assert!(m.list_id.is_some());
128추가: }
129추가: #[test]
130추가: fn cancel_close_retract_preserves_request_and_waits_for_exit() {
131추가: let mut f = FakeFactory::default();
132추가: let mut m = Model::default();
133추가: assert!(m.begin(
134추가: Start::List {
135추가: archive: path("one.zip")
136추가: },
137추가: &mut f
138추가: ));
139추가: m.poll();
140추가: m.request_close();
141추가: assert_eq!(m.close, Close::Confirm);
142추가: m.confirm_close();
143추가: m.keep_open();
144추가: m.cancel();
145추가: pump(&mut m);
146추가: assert_eq!(m.close, Close::Open);
147추가: assert_eq!(m.cancel, Some(CancelStatus::Requested));
148추가: assert_eq!(m.terminal.unwrap().outcome, Outcome::Cancelled);
149추가: assert_eq!(
150추가: f.state
151추가: .borrow()
152추가: .requests
153추가: .iter()
154추가: .filter(|(_, k)| *k == "cancel")
155추가: .count(),
156추가: 1
157추가: );
158추가: }
159추가: #[test]
160추가: fn terminal_race_needs_no_cancel_ack() {
161추가: let mut f = FakeFactory::manual();
162추가: let mut m = Model::default();
163추가: assert!(m.begin(
164추가: Start::List {
165추가: archive: path("one.zip")
166추가: },
167추가: &mut f
168추가: ));
169추가: {
170추가: let mut s = f.state.borrow_mut();
171추가: s.frame(Event::Accepted { encryption: false });
172추가: s.finish(Outcome::Cancelled, Publication::None);
173추가: }
174추가: m.cancel();
175추가: pump(&mut m);
176추가: assert!(m.cancel.is_none());
177추가: assert_eq!(m.status(), "작업 취소됨");
178추가: }
179추가: #[test]
180추가: fn eof_exit_without_terminal_never_means_success() {
181추가: let mut f = FakeFactory::manual();
182추가: let mut m = Model::default();
183추가: assert!(m.begin(
184추가: Start::List {
185추가: archive: path("one.zip")
186추가: },
187추가: &mut f
188추가: ));
189추가: {
190추가: let mut s = f.state.borrow_mut();
191추가: s.queue.extend([
192추가: HostEvent::StdoutEof,
193추가: HostEvent::StderrEof,
194추가: HostEvent::Exited { success: true },
195추가: ]);
196추가: }
197추가: pump(&mut m);
198추가: assert!(!m.confirmed);
199추가: assert!(m.list_id.is_none());
200추가: assert!(m.error.is_some());
201추가: }
202추가: #[test]
203추가: fn stale_sequence_and_job_are_protocol_errors() {
204추가: for bad_job in [true, false] {
205추가: let mut f = FakeFactory::manual();
206추가: let mut m = Model::default();
207추가: assert!(m.begin(
208추가: Start::List {
209추가: archive: path("one.zip")
210추가: },
211추가: &mut f
212추가: ));
213추가: let id = m.job_id().unwrap();
214추가: f.state.borrow_mut().queue.push_back(HostEvent::Frame {
215추가: job_id: if bad_job { id + 1 } else { id },
216추가: sequence: if bad_job { 0 } else { 1 },
217추가: event: Event::Accepted { encryption: false },
218추가: });
219추가: m.poll();
220추가: assert!(m.error.is_some());
221추가: assert!(m.busy());
222추가: }
223추가: }
224추가: #[test]
225추가: fn source_changed_invalidates_selection_without_retry() {
226추가: let mut f = FakeFactory::default();
227추가: let mut m = Model::default();
228추가: list(&mut m, &mut f);
229추가: m.selected.insert(0);
230추가: f.state.borrow_mut().manual = true;
231추가: assert!(m.extract(path("out"), true, None, &mut f));
232추가: {
233추가: let mut s = f.state.borrow_mut();
234추가: s.frame(Event::Accepted { encryption: false });
235추가: s.frame(Event::Terminal(Terminal {
236추가: outcome: Outcome::Failed,
237추가: error: Some(ErrorCode::SourceChanged),
238추가: publication: Publication::None,
239추가: created_count: 0,
240추가: retained_partial_count: 0,
241추가: durability: Durability::NotApplicable,
242추가: cleanup: Cleanup::Complete,
243추가: }));
244추가: s.queue.extend([
245추가: HostEvent::StdoutEof,
246추가: HostEvent::StderrEof,
247추가: HostEvent::Exited { success: true },
248추가: ]);
249추가: }
250추가: pump(&mut m);
251추가: assert!(m.list_id.is_none());
252추가: assert!(m.selected.is_empty());
253추가: assert_eq!(f.state.borrow().starts.len(), 2);
254추가: }
255추가: #[test]
256추가: fn partial_and_uncertain_results_are_preserved() {
257추가: let mut f = FakeFactory::manual();
258추가: let mut m = Model::default();
259추가: assert!(m.begin(
260추가: Start::CreateZip {
261추가: sources: vec![(path("one"), "one".into())],
262추가: output_file: path("out.zip"),
263추가: method: Method::Store,
264추가: aes256: false
265추가: },
266추가: &mut f
267추가: ));
268추가: {
269추가: let mut s = f.state.borrow_mut();
270추가: s.frame(Event::Accepted { encryption: false });
271추가: s.frame(Event::Output {
272추가: entry_id: None,
273추가: relative_name: "out.zip".into(),
274추가: disposition: Disposition::CommitUncertain,
275추가: });
276추가: s.frame(Event::Terminal(Terminal {
277추가: outcome: Outcome::Failed,
278추가: error: Some(ErrorCode::Io),
279추가: publication: Publication::Uncertain,
280추가: created_count: 0,
281추가: retained_partial_count: 1,
282추가: durability: Durability::Failed,
283추가: cleanup: Cleanup::Unconfirmed,
284추가: }));
285추가: s.queue.extend([
286추가: HostEvent::StdoutEof,
287추가: HostEvent::StderrEof,
288추가: HostEvent::Exited { success: true },
289추가: ]);
290추가: }
291추가: pump(&mut m);
292추가: let t = m.terminal.as_ref().unwrap();
293추가: assert_eq!(t.publication, Publication::Uncertain);
294추가: assert_eq!(t.retained_partial_count, 1);
295추가: assert_eq!(t.durability, Durability::Failed);
296추가: assert_eq!(m.outputs[0].1, Disposition::CommitUncertain);
297추가: }
298추가: #[test]
299추가: fn close_requires_result_acknowledgement() {
300추가: let mut f = FakeFactory::default();
301추가: let mut m = Model::default();
302추가: assert!(m.begin(
303추가: Start::List {
304추가: archive: path("one.zip")
305추가: },
306추가: &mut f
307추가: ));
308추가: m.request_close();
309추가: m.confirm_close();
310추가: m.acknowledge_close();
311추가: assert_eq!(m.close, Close::Waiting);
312추가: pump(&mut m);
313추가: assert_eq!(m.close, Close::Review);
314추가: m.acknowledge_close();
315추가: assert_eq!(m.close, Close::Allowed);
316추가: }
317추가: #[test]
318추가: fn unsupported_worker_and_unsafe_inputs_do_not_start() {
319추가: let mut m = Model::default();
320추가: assert!(!m.begin(
321추가: Start::List {
322추가: archive: path("one.zip")
323추가: },
324추가: &mut Unavailable
325추가: ));
326추가: assert!(m.error.as_ref().unwrap().contains("준비"));
327추가: let mut f = FakeFactory::default();
328추가: assert!(!m.begin(
329추가: Start::List {
330추가: archive: "relative.zip".into()
331추가: },
332추가: &mut f
333추가: ));
334추가: assert!(!m.begin(
335추가: Start::CreateZip {
336추가: sources: vec![(path("one"), "../one".into())],
337추가: output_file: path("out.zip"),
338추가: method: Method::Store,
339추가: aes256: false
340추가: },
341추가: &mut f
342추가: ));
343추가: assert!(f.state.borrow().starts.is_empty());
344추가: }
345추가: #[cfg(feature = "ui")]
346추가: #[test]
347추가: fn renders_every_flow_with_actual_egui_widgets() {
348추가: use eframe::egui::{self, epaint::Shape};
349추가: use zipelo_ui_memory_app::archive_screen::ArchiveApp;
350추가: fn text(shapes: &[egui::epaint::ClippedShape]) -> Vec<(String, egui::Pos2)> {
351추가: fn walk(shape: &Shape, result: &mut Vec<(String, egui::Pos2)>) {
352추가: match shape {
353추가: Shape::Text(t) => result.push((
354추가: t.galley.job.text.clone(),
355추가: t.pos + t.galley.rect.size() / 2.0,
356추가: )),
357추가: Shape::Vec(v) => {
358추가: for shape in v {
359추가: walk(shape, result);
360추가: }
361추가: }
362추가: _ => {}
363추가: }
364추가: }
365추가: let mut result = Vec::new();
366추가: for shape in shapes {
367추가: walk(&shape.shape, &mut result);
368추가: }
369추가: result
370추가: }
371추가: let ctx = egui::Context::default();
372추가: let f = FakeFactory::default();
373추가: let mut app = ArchiveApp::new(Box::new(f.clone()), None, true);
374추가: let render = |app: &mut ArchiveApp, events: Vec<egui::Event>, width: f32| {
375추가: let mut output = ctx.run_ui(
376추가: egui::RawInput {
377추가: screen_rect: Some(egui::Rect::from_min_size(
378추가: egui::Pos2::ZERO,
379추가: egui::vec2(width, 720.0),
380추가: )),
381추가: events,
382추가: ..Default::default()
383추가: },
384추가: |ui| app.show(ui),
385추가: );
386추가: output.textures_delta.clear();
387추가: assert!(!output.shapes.is_empty());
388추가: text(&output.shapes)
389추가: };
390추가: let initial = render(&mut app, vec![], 1060.0);
391추가: let point = initial.iter().find(|(t, _)| t == "ZIP 만들기").unwrap().1;
392추가: render(
393추가: &mut app,
394추가: vec![
395추가: egui::Event::PointerMoved(point),
396추가: egui::Event::PointerButton {
397추가: pos: point,
398추가: button: egui::PointerButton::Primary,
399추가: pressed: true,
400추가: modifiers: egui::Modifiers::default(),
401추가: },
402추가: ],
403추가: 1060.0,
404추가: );
405추가: render(
406추가: &mut app,
407추가: vec![egui::Event::PointerButton {
408추가: pos: point,
409추가: button: egui::PointerButton::Primary,
410추가: pressed: false,
411추가: modifiers: egui::Modifiers::default(),
412추가: }],
413추가: 1060.0,
414추가: );
415추가: let create = render(&mut app, vec![], 1060.0);
416추가: assert!(create.iter().any(|(t, _)| t == "저장할 ZIP 절대 경로"));
417추가: let mut app = ArchiveApp::new(Box::new(f.clone()), Some(path("locked.zip")), true);
418추가: for _ in 0..8 {
419추가: app.model.poll();
420추가: }
421추가: for width in [760.0, 1060.0] {
422추가: render(&mut app, vec![], width);
423추가: render(&mut app, vec![], width);
424추가: let password = render(&mut app, vec![], width);
425추가: assert!(password.iter().any(|(t, _)| t.contains("암호 전달")));
426추가: }
427추가: assert!(app.model.password("synthetic secret".into()));
428추가: pump(&mut app.model);
429추가: let listed = render(&mut app, vec![], 1060.0);
430추가: assert!(listed.iter().any(|(t, _)| t == "읽어주세요.txt"));
431추가: assert!(!listed.iter().any(|(t, _)| t.contains("synthetic secret")));
432추가: assert!(app.model.extract(path("out"), false, None, &mut f.clone()));
433추가: render(&mut app, vec![], 1060.0);
434추가: app.model.request_close();
435추가: render(&mut app, vec![], 1060.0);
436추가: let confirm = render(&mut app, vec![], 1060.0);
437추가: assert!(confirm.iter().any(|(t, _)| t == "작업 중 닫기"));
438추가: app.model.confirm_close();
439추가: pump(&mut app.model);
440추가: render(&mut app, vec![], 1060.0);
441추가: let result = render(&mut app, vec![], 1060.0);
442추가: assert!(result.iter().any(|(t, _)| t == "결과 확인 후 닫기"));
443추가: }
444추가:
445추가: #[test]
446추가: fn file_association_arguments_preserve_native_paths() {
447추가: let cwd = std::env::current_dir().unwrap();
448추가: let (fixture, archive) =
449추가: launch_args(vec!["--ui-fixture".into(), "한글.zip".into()], cwd.clone()).unwrap();
450추가: assert!(fixture);
451추가: assert_eq!(archive, Some(cwd.join("한글.zip")));
452추가: assert!(launch_args(vec!["a".into(), "b".into()], cwd.clone()).is_err());
453추가: #[cfg(unix)]
454추가: {
455추가: use std::os::unix::ffi::OsStringExt;
456추가: let name = std::ffi::OsString::from_vec(vec![b'/', 0xff, b'a']);
457추가: assert_eq!(
458추가: launch_args(vec![name.clone()], cwd).unwrap().1,
459추가: Some(PathBuf::from(name))
460추가: );
461추가: }
462추가: }
463추가:
464추가: #[cfg(feature = "ui")]
465추가: #[test]
466추가: fn dropped_native_file_opens_without_ui_reading_contents() {
467추가: use eframe::egui;
468추가: use zipelo_ui_memory_app::archive_screen::ArchiveApp;
469추가: #[derive(Debug)]
470추가: struct DropFile(PathBuf);
471추가: impl egui::DroppedFile for DropFile {
472추가: fn path(&self) -> &std::path::Path {
473추가: &self.0
474추가: }
475추가: fn bytes(&self) -> Result<Vec<u8>, String> {
476추가: panic!("화면이 압축파일을 직접 읽으면 안 됨")
477추가: }
478추가: }
479추가: let ctx = egui::Context::default();
480추가: let f = FakeFactory::default();
481추가: let mut app = ArchiveApp::new(Box::new(f.clone()), None, true);
482추가: let file = path("dropped.zip");
483추가: let mut output = ctx.run_ui(
484추가: egui::RawInput {
485추가: dropped_files: vec![std::sync::Arc::new(DropFile(file.clone()))],
486추가: ..Default::default()
487추가: },
488추가: |ui| app.show(ui),
489추가: );
490추가: output.textures_delta.clear();
491추가: assert_eq!(app.model.archive, Some(file));
492추가: assert_eq!(f.state.borrow().starts.len(), 1);
493추가: pump(&mut app.model);
494추가: assert!(app.model.can_extract());
495추가: }
496추가:
497추가: #[test]
498추가: fn failed_start_retains_connection_until_both_eofs_and_child_wait() {
499추가: for missing in 0..3 {
500추가: let mut factory = FakeFactory::manual();
501추가: factory.state.borrow_mut().fail_start = true;
502추가: let mut model = Model::default();
503추가: assert!(!model.begin(
504추가: Start::List {
505추가: archive: path("failed.zip")
506추가: },
507추가: &mut factory
508추가: ));
509추가: assert!(model.busy());
510추가: assert_eq!(factory.state.borrow().dropped_connections, 0);
511추가: assert_eq!(model.job_id(), Some(1));
512추가: model.request_close();
513추가: model.confirm_close();
514추가: assert_eq!(model.close, Close::Waiting);
515추가: assert_eq!(factory.state.borrow().requests, vec![(0, "start")]);
516추가: let event = |index| match index {
517추가: 0 => HostEvent::StdoutEof,
518추가: 1 => HostEvent::StderrEof,
519추가: _ => HostEvent::Exited { success: false },
520추가: };
521추가: for index in 0..3 {
522추가: if index != missing {
523추가: factory.state.borrow_mut().queue.push_back(event(index));
524추가: }
525추가: }
526추가: for _ in 0..20 {
527추가: model.poll();
528추가: }
529추가: assert!(model.busy());
530추가: assert!(!model.can_extract());
531추가: assert_eq!(factory.state.borrow().dropped_connections, 0);
532추가: model.acknowledge_close();
533추가: assert_eq!(model.close, Close::Waiting);
534추가: assert!(!model.begin(
535추가: Start::List {
536추가: archive: path("replacement.zip")
537추가: },
538추가: &mut factory
539추가: ));
540추가: factory.state.borrow_mut().queue.push_back(event(missing));
541추가: pump(&mut model);
542추가: assert!(!model.confirmed);
543추가: assert!(model.terminal.is_none());
544추가: assert_eq!(model.error.as_deref(), Some("Start 전송 실패"));
545추가: assert_eq!(factory.state.borrow().dropped_connections, 1);
546추가: assert_eq!(model.close, Close::Review);
547추가: if missing == 0 {
548추가: model.acknowledge_close();
549추가: assert_eq!(model.close, Close::Allowed);
550추가: } else {
551추가: model.keep_open();
552추가: factory.state.borrow_mut().fail_start = false;
553추가: assert!(model.begin(
554추가: Start::List {
555추가: archive: path("replacement.zip")
556추가: },
557추가: &mut factory
558추가: ));
559추가: assert_eq!(model.job_id(), Some(2));
560추가: }
561추가: }
562추가: }
563추가:
564추가: #[test]
565추가: fn non_gzip_formats_reject_a_gzip_output_name_before_connect() {
566추가: for format in [Format::Zip, Format::Tar, Format::TarGzip] {
567추가: let mut factory = FakeFactory::default();
568추가: factory.state.borrow_mut().list_format = Some(format);
569추가: let mut model = Model::default();
570추가: list(&mut model, &mut factory);
571추가: let count = factory.state.borrow().starts.len();
572추가: assert!(!model.extract(path("out"), false, Some("stale.txt".into()), &mut factory));
573추가: assert!(!model.busy());
574추가: assert_eq!(factory.state.borrow().starts.len(), count);
575추가: assert!(model.extract(path("out"), false, None, &mut factory));
576추가: pump(&mut model);
577추가: }
578추가: }
579추가:
580추가: #[cfg(feature = "ui")]
581추가: #[test]
582추가: fn extract_button_sends_gzip_name_only_for_raw_gzip() {
583추가: use eframe::egui::{self, epaint::Shape};
584추가: use zipelo_ui_memory_app::archive_screen::ArchiveApp;
585추가: for format in [Format::Zip, Format::Tar, Format::TarGzip, Format::Gzip] {
586추가: let ctx = egui::Context::default();
587추가: let factory = FakeFactory::default();
588추가: factory.state.borrow_mut().list_format = Some(format);
589추가: let mut app = ArchiveApp::new(Box::new(factory.clone()), Some(path("input.archive")), true);
590추가: pump(&mut app.model);
591추가: let render = |app: &mut ArchiveApp, events| {
592추가: fn walk(shape: &Shape, output: &mut Vec<(String, egui::Pos2)>) {
593추가: match shape {
594추가: Shape::Text(text) => output.push((
595추가: text.galley.job.text.clone(),
596추가: text.pos + text.galley.rect.size() / 2.0,
597추가: )),
598추가: Shape::Vec(shapes) => {
599추가: for shape in shapes {
600추가: walk(shape, output);
601추가: }
602추가: }
603추가: _ => {}
604추가: }
605추가: }
606추가: let mut frame = ctx.run_ui(
607추가: egui::RawInput {
608추가: screen_rect: Some(egui::Rect::from_min_size(
609추가: egui::Pos2::ZERO,
610추가: egui::vec2(1060.0, 720.0),
611추가: )),
612추가: events,
613추가: ..Default::default()
614추가: },
615추가: |ui| app.show(ui),
616추가: );
617추가: frame.textures_delta.clear();
618추가: let mut output = Vec::new();
619추가: for shape in frame.shapes {
620추가: walk(&shape.shape, &mut output);
621추가: }
622추가: output
623추가: };
624추가: let click = |app: &mut ArchiveApp, point| {
625추가: render(
626추가: app,
627추가: vec![
628추가: egui::Event::PointerMoved(point),
629추가: egui::Event::PointerButton {
630추가: pos: point,
631추가: button: egui::PointerButton::Primary,
632추가: pressed: true,
633추가: modifiers: Default::default(),
634추가: },
635추가: ],
636추가: );
637추가: render(
638추가: app,
639추가: vec![egui::Event::PointerButton {
640추가: pos: point,
641추가: button: egui::PointerButton::Primary,
642추가: pressed: false,
643추가: modifiers: Default::default(),
644추가: }],
645추가: );
646추가: };
647추가: render(&mut app, vec![]);
648추가: let texts = render(&mut app, vec![]);
649추가: let folder = texts
650추가: .iter()
651추가: .find(|(text, _)| text == "출력 폴더")
652추가: .unwrap()
653추가: .1;
654추가: click(&mut app, folder + egui::vec2(100.0, 0.0));
655추가: render(
656추가: &mut app,
657추가: vec![egui::Event::Text(
658추가: path("button-output").to_string_lossy().into_owned(),
659추가: )],
660추가: );
661추가: if format == Format::Gzip {
662추가: let texts = render(&mut app, vec![]);
663추가: let name = texts
664추가: .iter()
665추가: .find(|(text, _)| text == "출력 파일명")
666추가: .unwrap()
667추가: .1;
668추가: click(&mut app, name + egui::vec2(100.0, 0.0));
669추가: render(&mut app, vec![egui::Event::Text("plain.txt".into())]);
670추가: }
671추가: let texts = render(&mut app, vec![]);
672추가: let button = texts.iter().find(|(text, _)| text == "풀기").unwrap().1;
673추가: click(&mut app, button);
674추가: let state = factory.state.borrow();
675추가: assert_eq!(
676추가: state.starts.len(),
677추가: 2,
678추가: "풀기 버튼의 Start 요청 누락: {format:?}"
679추가: );
680추가: match state.starts.last().unwrap() {
681추가: Start::Extract {
682추가: gzip_output_name, ..
683추가: } => assert_eq!(
684추가: gzip_output_name,
685추가: &if format == Format::Gzip {
686추가: Some("plain.txt".into())
687추가: } else {
688추가: None
689추가: }
690추가: ),
691추가: _ => panic!("Extract 요청 누락"),
692추가: }
693추가: }
694추가: }
695추가:
696추가: #[test]
697추가: fn fake_worker_rejects_invalid_format_specific_output_names() {
698추가: for (format, name) in [
699추가: (Format::Zip, Some("stale.txt".into())),
700추가: (Format::Tar, Some(String::new())),
701추가: (Format::TarGzip, Some("stale.txt".into())),
702추가: (Format::Gzip, None),
703추가: (Format::Gzip, Some("../escape".into())),
704추가: ] {
705추가: let mut factory = FakeFactory::default();
706추가: factory.state.borrow_mut().list_format = Some(format);
707추가: let mut model = Model::default();
708추가: list(&mut model, &mut factory);
709추가: let mut connection = factory.connect(2).unwrap();
710추가: let previous = factory.state.borrow().starts.len();
711추가: assert!(
712추가: connection
713추가: .send(Request {
714추가: job_id: 2,
715추가: sequence: 0,
716추가: command: Command::Start(Start::Extract {
717추가: archive: model.archive.clone().unwrap(),
718추가: destination: path("output"),
719추가: selection: Selection::All,
720추가: list_id: model.list_id.clone().unwrap(),
721추가: gzip_output_name: name,
722추가: }),
723추가: })
724추가: .is_err()
725추가: );
726추가: assert_eq!(factory.state.borrow().starts.len(), previous);
727추가: }
728추가: }
추가tests/rust-app-ui/validation.json+66-0
@@ -0,0 +1,66 @@
1추가: {
2추가: "command": "python3 tests/ci/run_rust.py local",
3추가: "platform": "linux-desktop-2",
4추가: "base_remote_main": "486fe9ae64a73f999cc5122c2eb9bbeb62fb2fb3",
5추가: "local_baseline_head": "6ea0b8b3b7444c35bb0845b58bf5638ac58f5e58",
6추가: "source_state": "Committed frontend review fixes over the existing local baseline whose tree equals remote main. Tested file hashes identify the reviewed implementation.",
7추가: "linux_build_crates": 17,
8추가: "linux_test_targets": 17,
9추가: "rust_tests_passed": 827,
10추가: "new_archive_ui_tests_passed": 20,
11추가: "windows_cross_build_crates": 17,
12추가: "windows_runtime_tested": false,
13추가: "native_visual_check": "Owned Xvfb screen displayed Korean synthetic file list; initial capture missed Xvfb because inherited Wayland selected host backend; corrected capture removes Wayland only in owned process environment. Not complete native interaction coverage.",
14추가: "prior_failures": "Retained locally: first build drop API/legacy harness references; second and third egui renderer harness texture/first-frame setup; final runner passed.",
15추가: "limitations": [
16추가: "Fake transport projects agreed revision2 semantics; no binary codec, actual worker process, filesystem extraction or encryption in this frontend PR.",
17추가: "Default executable explicitly reports unavailable worker. ui-fixture feature AND --ui-fixture flag select test-only fake; UI labels it.",
18추가: "Entry listing is metadata, not integrity proof. Partial publication/durability/cleanup remain separate.",
19추가: "UTF-8 text fields for manual paths; native CLI/drop archive paths stay PathBuf. ZIP multi-source manual entry is UTF-8 only."
20추가: ],
21추가: "tested_files": [
22추가: {
23추가: "path": "experiments/rust-ui-memory-app/Cargo.toml",
24추가: "sha256": "1b161c74260b64de926b37528d61fd73de4074d250f711d8458ed770c0af69d8"
25추가: },
26추가: {
27추가: "path": "experiments/rust-ui-memory-app/src/lib.rs",
28추가: "sha256": "335104e14b4fd69fd20e29941a1cc40c7c123bd7b853c09206c39d10b55fda2c"
29추가: },
30추가: {
31추가: "path": "experiments/rust-ui-memory-app/src/desktop.rs",
32추가: "sha256": "5d0e14f72cdebc6fe02952539db55c682cb5978fd883e072bd08d461807c8106"
33추가: },
34추가: {
35추가: "path": "experiments/rust-ui-memory-app/src/archive_ui.rs",
36추가: "sha256": "f06fd50c557e178cb5cb98cb39e3ba5e04088a774f60ec92774bc37ed3323b87"
37추가: },
38추가: {
39추가: "path": "experiments/rust-ui-memory-app/src/archive_screen.rs",
40추가: "sha256": "04b7a55c7405d89467fc821db27e0714fb0aa00612e614835b5fee901e5ca940"
41추가: },
42추가: {
43추가: "path": "tests/rust-app-ui/regressions.rs",
44추가: "sha256": "461e9a36bc5b742bf523fe0f1bfb7900c1b97a884e3e8f6040f85fe474efdf4e"
45추가: },
46추가: {
47추가: "path": "tests/rust-app-ui/fake.rs",
48추가: "sha256": "f0d7fc88a1399f12f95aa045c2c55e3ff2d8057625a6d615d88f9bee10a36b51"
49추가: },
50추가: {
51추가: "path": "tests/rust-app-ui/native_smoke.py",
52추가: "sha256": "303cff6a9452b43db62af21ad906aef49279f7bf23136e2166793d4118d951dc"
53추가: },
54추가: {
55추가: "path": "tests/rust-app-ui/README.md",
56추가: "sha256": "942e108820d43ba9a70ba013cd7f1683d8bb90699315bda179ca95c4a15a736e"
57추가: }
58추가: ],
59추가: "review_regressions": [
60추가: "실제 풀기 버튼의 ZIP/TAR/TAR.GZ/GZIP 출력명 계약",
61추가: "비 GZIP 출력명 요청의 연결 전 거부",
62추가: "가짜 작업자의 형식별 출력명 검증",
63추가: "Start 전송 실패 시 양쪽 EOF/child wait까지 연결 보존과 닫기/교체 차단"
64추가: ],
65추가: "before_review_fix": "Targeted regressions reproduced 3 failures with 16 existing tests passing before the product fix; final targeted suite passed 20 tests."
66추가: }