압축 작업 화면과 파일 선택 흐름을 재구성함
- 작성자
- 호시노 히나타
- 작성 시각
- 커밋
85c6f3d67877f7964dd1009ebfb828661ba871b9- 부모
- b10c7ee
변경된 파일 64개
+2,537-90| @@ -51,3 +51,8 @@ eframe = { version = "=0.37.0", optional = true, default-features = false, featu | ||
| 51 | 51 | name = "renderer_fallback" |
| 52 | 52 | path = "../../tests/rust-app-ui/renderer_fallback.rs" |
| 53 | 53 | required-features = ["ui"] |
| 54 | 추가: | |
| 55 | 추가: [[bin]] | |
| 56 | 추가: name = "zipelo-ui-capture" | |
| 57 | 추가: path = "../../tests/rust-app-ui/capture.rs" | |
| 58 | 추가: required-features = ["ui-fixture"] |
| @@ -0,0 +1,258 @@ | ||
| 1 | 추가: use crate::{archive_present as present, archive_theme as theme}; | |
| 2 | 추가: use eframe::egui::{self, Align, Layout}; | |
| 3 | 추가: use std::path::{Path, PathBuf}; | |
| 4 | 추가: | |
| 5 | 추가: #[derive(Clone, Copy, PartialEq)] | |
| 6 | 추가: pub enum Purpose { | |
| 7 | 추가: Open, | |
| 8 | 추가: Destination, | |
| 9 | 추가: Retry, | |
| 10 | 추가: Files, | |
| 11 | 추가: Folder, | |
| 12 | 추가: ZipFolder, | |
| 13 | 추가: } | |
| 14 | 추가: | |
| 15 | 추가: pub enum Choice { | |
| 16 | 추가: Cancel, | |
| 17 | 추가: Paths(Vec<PathBuf>), | |
| 18 | 추가: } | |
| 19 | 추가: | |
| 20 | 추가: pub struct Picker { | |
| 21 | 추가: pub purpose: Purpose, | |
| 22 | 추가: current: PathBuf, | |
| 23 | 추가: entries: Vec<present::BrowserEntry>, | |
| 24 | 추가: selected: Vec<PathBuf>, | |
| 25 | 추가: error: bool, | |
| 26 | 추가: } | |
| 27 | 추가: | |
| 28 | 추가: impl Picker { | |
| 29 | 추가: pub fn new(purpose: Purpose, start: &Path) -> Self { | |
| 30 | 추가: let current = if start.is_dir() { | |
| 31 | 추가: start.to_path_buf() | |
| 32 | 추가: } else { | |
| 33 | 추가: start | |
| 34 | 추가: .parent() | |
| 35 | 추가: .filter(|p| p.is_dir()) | |
| 36 | 추가: .map(Path::to_path_buf) | |
| 37 | 추가: .unwrap_or_else(present::home_directory) | |
| 38 | 추가: }; | |
| 39 | 추가: let mut picker = Self { | |
| 40 | 추가: purpose, | |
| 41 | 추가: current, | |
| 42 | 추가: entries: Vec::new(), | |
| 43 | 추가: selected: Vec::new(), | |
| 44 | 추가: error: false, | |
| 45 | 추가: }; | |
| 46 | 추가: picker.reload(); | |
| 47 | 추가: picker | |
| 48 | 추가: } | |
| 49 | 추가: | |
| 50 | 추가: fn reload(&mut self) { | |
| 51 | 추가: self.selected.clear(); | |
| 52 | 추가: match present::directory_entries(&self.current) { | |
| 53 | 추가: Ok(entries) => { | |
| 54 | 추가: self.entries = entries; | |
| 55 | 추가: self.error = false; | |
| 56 | 추가: } | |
| 57 | 추가: Err(_) => { | |
| 58 | 추가: self.entries.clear(); | |
| 59 | 추가: self.error = true; | |
| 60 | 추가: } | |
| 61 | 추가: } | |
| 62 | 추가: } | |
| 63 | 추가: | |
| 64 | 추가: fn directory_mode(&self) -> bool { | |
| 65 | 추가: matches!( | |
| 66 | 추가: self.purpose, | |
| 67 | 추가: Purpose::Destination | Purpose::Retry | Purpose::Folder | Purpose::ZipFolder | |
| 68 | 추가: ) | |
| 69 | 추가: } | |
| 70 | 추가: | |
| 71 | 추가: pub fn show(&mut self, ctx: &egui::Context) -> Option<Choice> { | |
| 72 | 추가: let mut choice = None; | |
| 73 | 추가: let mut navigate = None; | |
| 74 | 추가: let width = (ctx.content_rect().width() - 64.0).min(720.0); | |
| 75 | 추가: let height = (ctx.content_rect().height() - 280.0).clamp(160.0, 340.0); | |
| 76 | 추가: let title = match self.purpose { | |
| 77 | 추가: Purpose::Open => "파일 열기", | |
| 78 | 추가: Purpose::Destination | Purpose::Retry => "풀 위치 선택", | |
| 79 | 추가: Purpose::Files => "묶을 파일 선택", | |
| 80 | 추가: Purpose::Folder => "묶을 폴더 선택", | |
| 81 | 추가: Purpose::ZipFolder => "ZIP 저장 폴더 선택", | |
| 82 | 추가: }; | |
| 83 | 추가: let title = if self.purpose == Purpose::Open { | |
| 84 | 추가: "파일 열기" | |
| 85 | 추가: } else { | |
| 86 | 추가: title | |
| 87 | 추가: }; | |
| 88 | 추가: let modal = egui::Modal::new(egui::Id::unique("archive-picker")).show(ctx, |ui| { | |
| 89 | 추가: ui.set_width(width); | |
| 90 | 추가: ui.heading(title); | |
| 91 | 추가: egui::ScrollArea::horizontal() | |
| 92 | 추가: .id_salt("breadcrumbs") | |
| 93 | 추가: .show(ui, |ui| { | |
| 94 | 추가: ui.horizontal(|ui| { | |
| 95 | 추가: let mut ancestors = self.current.ancestors().collect::<Vec<_>>(); | |
| 96 | 추가: ancestors.reverse(); | |
| 97 | 추가: for path in ancestors { | |
| 98 | 추가: let label = path | |
| 99 | 추가: .file_name() | |
| 100 | 추가: .unwrap_or(path.as_os_str()) | |
| 101 | 추가: .to_string_lossy(); | |
| 102 | 추가: if ui | |
| 103 | 추가: .button(label.as_ref()) | |
| 104 | 추가: .on_hover_text(path.display().to_string()) | |
| 105 | 추가: .clicked() | |
| 106 | 추가: { | |
| 107 | 추가: navigate = Some(path.to_path_buf()); | |
| 108 | 추가: } | |
| 109 | 추가: } | |
| 110 | 추가: }); | |
| 111 | 추가: }); | |
| 112 | 추가: ui.separator(); | |
| 113 | 추가: ui.horizontal_top(|ui| { | |
| 114 | 추가: ui.allocate_ui_with_layout( | |
| 115 | 추가: egui::vec2(128.0, height), | |
| 116 | 추가: Layout::top_down(Align::Min), | |
| 117 | 추가: |ui| { | |
| 118 | 추가: ui.set_min_size(egui::vec2(128.0, height)); | |
| 119 | 추가: for (label, path) in present::shortcuts() { | |
| 120 | 추가: if theme::action(ui, &label, false, true).clicked() { | |
| 121 | 추가: navigate = Some(path); | |
| 122 | 추가: } | |
| 123 | 추가: } | |
| 124 | 추가: if let Some(parent) = self.current.parent() { | |
| 125 | 추가: if theme::action(ui, "상위 폴더", false, true).clicked() { | |
| 126 | 추가: navigate = Some(parent.to_path_buf()); | |
| 127 | 추가: } | |
| 128 | 추가: } | |
| 129 | 추가: }, | |
| 130 | 추가: ); | |
| 131 | 추가: ui.add_space(theme::SPACE); | |
| 132 | 추가: ui.allocate_ui_with_layout( | |
| 133 | 추가: egui::vec2((width - 160.0).max(240.0), height), | |
| 134 | 추가: Layout::top_down(Align::Min), | |
| 135 | 추가: |ui| { | |
| 136 | 추가: ui.set_min_size(egui::vec2((width - 160.0).max(240.0), height)); | |
| 137 | 추가: if self.error { | |
| 138 | 추가: ui.colored_label( | |
| 139 | 추가: theme::ERROR, | |
| 140 | 추가: "이 폴더를 열 수 없습니다. 접근 권한을 확인하세요", | |
| 141 | 추가: ); | |
| 142 | 추가: } else if self.entries.is_empty() { | |
| 143 | 추가: ui.label("이 폴더는 비어 있습니다"); | |
| 144 | 추가: } | |
| 145 | 추가: egui::ScrollArea::vertical() | |
| 146 | 추가: .id_salt("picker-entries") | |
| 147 | 추가: .max_height(height) | |
| 148 | 추가: .show_rows(ui, theme::ROW, self.entries.len(), |ui, rows| { | |
| 149 | 추가: for index in rows { | |
| 150 | 추가: let entry = &self.entries[index]; | |
| 151 | 추가: let selected = self.selected.contains(&entry.path); | |
| 152 | 추가: let response = ui | |
| 153 | 추가: .horizontal(|ui| { | |
| 154 | 추가: theme::icon( | |
| 155 | 추가: ui, | |
| 156 | 추가: if entry.directory { | |
| 157 | 추가: theme::Icon::Folder | |
| 158 | 추가: } else { | |
| 159 | 추가: theme::Icon::File | |
| 160 | 추가: }, | |
| 161 | 추가: 20.0, | |
| 162 | 추가: ); | |
| 163 | 추가: let name = if entry.link { | |
| 164 | 추가: format!("{} (링크)", entry.name) | |
| 165 | 추가: } else { | |
| 166 | 추가: entry.name.clone() | |
| 167 | 추가: }; | |
| 168 | 추가: ui.add_sized( | |
| 169 | 추가: [ui.available_width(), theme::ROW], | |
| 170 | 추가: egui::Button::new("") | |
| 171 | 추가: .left_text(present::middle_text(&name, 38)) | |
| 172 | 추가: .selected(selected), | |
| 173 | 추가: ) | |
| 174 | 추가: .on_hover_text(entry.path.display().to_string()) | |
| 175 | 추가: }) | |
| 176 | 추가: .inner; | |
| 177 | 추가: theme::focus(&response); | |
| 178 | 추가: if response.clicked() { | |
| 179 | 추가: if self.purpose == Purpose::Files | |
| 180 | 추가: && ui.input(|i| i.modifiers.command || i.modifiers.ctrl) | |
| 181 | 추가: { | |
| 182 | 추가: if selected { | |
| 183 | 추가: self.selected.retain(|p| p != &entry.path); | |
| 184 | 추가: } else if !entry.directory { | |
| 185 | 추가: self.selected.push(entry.path.clone()); | |
| 186 | 추가: } | |
| 187 | 추가: } else { | |
| 188 | 추가: self.selected = vec![entry.path.clone()]; | |
| 189 | 추가: } | |
| 190 | 추가: } | |
| 191 | 추가: if response.double_clicked() { | |
| 192 | 추가: if entry.directory && !entry.link { | |
| 193 | 추가: navigate = Some(entry.path.clone()); | |
| 194 | 추가: } else if !self.directory_mode() { | |
| 195 | 추가: choice = Some(Choice::Paths(vec![entry.path.clone()])); | |
| 196 | 추가: } | |
| 197 | 추가: } | |
| 198 | 추가: } | |
| 199 | 추가: }); | |
| 200 | 추가: }, | |
| 201 | 추가: ); | |
| 202 | 추가: }); | |
| 203 | 추가: ui.separator(); | |
| 204 | 추가: ui.horizontal(|ui| { | |
| 205 | 추가: if self.purpose == Purpose::Files { | |
| 206 | 추가: ui.label("Ctrl을 누르면 여러 파일을 고를 수 있습니다"); | |
| 207 | 추가: } | |
| 208 | 추가: ui.with_layout(Layout::right_to_left(Align::Center), |ui| { | |
| 209 | 추가: let selected_directory = self.selected.first().filter(|path| { | |
| 210 | 추가: self.entries | |
| 211 | 추가: .iter() | |
| 212 | 추가: .any(|e| &e.path == *path && (e.directory || e.link)) | |
| 213 | 추가: }); | |
| 214 | 추가: let paths = if self.directory_mode() { | |
| 215 | 추가: vec![ | |
| 216 | 추가: selected_directory | |
| 217 | 추가: .cloned() | |
| 218 | 추가: .unwrap_or_else(|| self.current.clone()), | |
| 219 | 추가: ] | |
| 220 | 추가: } else { | |
| 221 | 추가: self.selected | |
| 222 | 추가: .iter() | |
| 223 | 추가: .filter(|path| { | |
| 224 | 추가: self.entries | |
| 225 | 추가: .iter() | |
| 226 | 추가: .any(|e| &e.path == *path && !e.directory) | |
| 227 | 추가: }) | |
| 228 | 추가: .cloned() | |
| 229 | 추가: .collect() | |
| 230 | 추가: }; | |
| 231 | 추가: let label = if self.directory_mode() { | |
| 232 | 추가: "이 폴더 선택" | |
| 233 | 추가: } else if self.purpose == Purpose::Files { | |
| 234 | 추가: "추가" | |
| 235 | 추가: } else { | |
| 236 | 추가: "열기" | |
| 237 | 추가: }; | |
| 238 | 추가: let enabled = !paths.is_empty() && !self.error; | |
| 239 | 추가: let (cancel, confirm) = theme::action_pair(ui, "취소", Some((label, enabled))); | |
| 240 | 추가: if confirm || (enabled && ui.input(|i| i.key_pressed(egui::Key::Enter))) { | |
| 241 | 추가: choice = Some(Choice::Paths(paths)); | |
| 242 | 추가: } | |
| 243 | 추가: if cancel { | |
| 244 | 추가: choice = Some(Choice::Cancel); | |
| 245 | 추가: } | |
| 246 | 추가: }); | |
| 247 | 추가: }); | |
| 248 | 추가: }); | |
| 249 | 추가: if modal.should_close() { | |
| 250 | 추가: choice = Some(Choice::Cancel); | |
| 251 | 추가: } | |
| 252 | 추가: if let Some(path) = navigate { | |
| 253 | 추가: self.current = path; | |
| 254 | 추가: self.reload(); | |
| 255 | 추가: } | |
| 256 | 추가: choice | |
| 257 | 추가: } | |
| 258 | 추가: } |
| @@ -0,0 +1,308 @@ | ||
| 1 | 추가: use crate::archive_ui::*; | |
| 2 | 추가: use std::{ | |
| 3 | 추가: collections::BTreeSet, | |
| 4 | 추가: fs, io, | |
| 5 | 추가: path::{Path, PathBuf}, | |
| 6 | 추가: }; | |
| 7 | 추가: | |
| 8 | 추가: pub const UNCERTAIN: &str = "저장이 끝났는지 확인하지 못했습니다. 풀 위치 폴더를 확인하세요."; | |
| 9 | 추가: pub const PARTIAL: &str = "일부 파일만 풀렸습니다. 풀린 파일은 풀 위치 폴더에 남아 있습니다."; | |
| 10 | 추가: pub const LEFTOVERS: &str = | |
| 11 | 추가: "선택한 파일은 모두 저장했지만 임시 파일을 지우지 못했습니다. 풀 위치 폴더를 확인하세요."; | |
| 12 | 추가: pub const SYNC_WARNING: &str = "파일을 디스크에 완전히 저장했는지 확인하지 못했습니다."; | |
| 13 | 추가: pub const CLEANUP_WARNING: &str = | |
| 14 | 추가: "임시 파일을 지우지 못했습니다. 풀 위치 폴더에 남은 임시 파일이 있을 수 있습니다."; | |
| 15 | 추가: pub const INTERNAL: &str = "내부 오류가 발생했습니다. 프로그램을 다시 시작해 주세요"; | |
| 16 | 추가: pub const FOLDER_ERROR: &str = "풀 위치 폴더를 만들 수 없습니다. 접근 권한을 확인하세요"; | |
| 17 | 추가: | |
| 18 | 추가: pub fn error_text(code: ErrorCode) -> &'static str { | |
| 19 | 추가: match code { | |
| 20 | 추가: ErrorCode::Integrity => "압축파일이 손상됐습니다", | |
| 21 | 추가: ErrorCode::UnsupportedFormat => "지원하지 않는 압축 형식입니다", | |
| 22 | 추가: ErrorCode::UnsupportedFeature => "아직 지원하지 않는 기능입니다", | |
| 23 | 추가: ErrorCode::WrongPassword => "암호가 올바르지 않습니다", | |
| 24 | 추가: ErrorCode::UnsafePath => "파일 경로의 안전성을 확인할 수 없어 중단했습니다", | |
| 25 | 추가: ErrorCode::Conflict => "같은 이름의 파일이 이미 있습니다. 다른 폴더를 선택하세요", | |
| 26 | 추가: ErrorCode::Limit => "처리 한도를 초과했습니다", | |
| 27 | 추가: ErrorCode::Io => "파일을 읽거나 쓰지 못했습니다. 파일과 폴더의 접근 권한을 확인하세요", | |
| 28 | 추가: ErrorCode::DiskFull => "디스크 여유 공간이 부족합니다. 공간을 확보한 뒤 다시 시도하세요", | |
| 29 | 추가: ErrorCode::SourceChanged => "원본 파일이 바뀌었습니다. 압축파일을 다시 여세요", | |
| 30 | 추가: ErrorCode::InvalidRequest => "풀 위치와 선택한 항목을 확인하세요", | |
| 31 | 추가: ErrorCode::Protocol | ErrorCode::Internal => INTERNAL, | |
| 32 | 추가: } | |
| 33 | 추가: } | |
| 34 | 추가: | |
| 35 | 추가: pub fn progress_text(stage: Stage, creating: bool) -> &'static str { | |
| 36 | 추가: match stage { | |
| 37 | 추가: Stage::Scan | Stage::Read => "압축파일을 읽는 중", | |
| 38 | 추가: Stage::Decode if creating => "압축하는 중", | |
| 39 | 추가: Stage::Decode => "압축을 푸는 중", | |
| 40 | 추가: Stage::Write => "파일을 저장하는 중", | |
| 41 | 추가: Stage::Verify => "확인하는 중", | |
| 42 | 추가: Stage::Commit => "마무리하는 중", | |
| 43 | 추가: } | |
| 44 | 추가: } | |
| 45 | 추가: | |
| 46 | 추가: pub fn bytes_text(bytes: u64) -> String { | |
| 47 | 추가: for (unit, size) in [("GB", 1_u64 << 30), ("MB", 1 << 20), ("KB", 1 << 10)] { | |
| 48 | 추가: if bytes >= size { | |
| 49 | 추가: return format!("{:.1} {unit}", bytes as f64 / size as f64); | |
| 50 | 추가: } | |
| 51 | 추가: } | |
| 52 | 추가: format!("{bytes} B") | |
| 53 | 추가: } | |
| 54 | 추가: | |
| 55 | 추가: pub fn middle_text(text: &str, max_chars: usize) -> String { | |
| 56 | 추가: let chars = text.chars().collect::<Vec<_>>(); | |
| 57 | 추가: if chars.len() <= max_chars || max_chars < 5 { | |
| 58 | 추가: return text.into(); | |
| 59 | 추가: } | |
| 60 | 추가: let left = (max_chars - 1) / 2; | |
| 61 | 추가: chars[..left] | |
| 62 | 추가: .iter() | |
| 63 | 추가: .chain(std::iter::once(&'…')) | |
| 64 | 추가: .chain(chars[chars.len() - (max_chars - left - 1)..].iter()) | |
| 65 | 추가: .collect() | |
| 66 | 추가: } | |
| 67 | 추가: | |
| 68 | 추가: pub fn default_destination(archive: &Path) -> PathBuf { | |
| 69 | 추가: let name = archive.file_name().unwrap_or_default().to_string_lossy(); | |
| 70 | 추가: let lower = name.to_ascii_lowercase(); | |
| 71 | 추가: let stem = if lower.ends_with(".tar.gz") { | |
| 72 | 추가: &name[..name.len() - 7] | |
| 73 | 추가: } else { | |
| 74 | 추가: name.rsplit_once('.') | |
| 75 | 추가: .map_or(name.as_ref(), |(stem, _)| stem) | |
| 76 | 추가: }; | |
| 77 | 추가: archive.with_file_name(if stem.is_empty() { | |
| 78 | 추가: "압축 해제" | |
| 79 | 추가: } else { | |
| 80 | 추가: stem | |
| 81 | 추가: }) | |
| 82 | 추가: } | |
| 83 | 추가: | |
| 84 | 추가: pub fn prepare_destination(path: &Path, automatic: bool) -> io::Result<bool> { | |
| 85 | 추가: match fs::symlink_metadata(path) { | |
| 86 | 추가: Ok(metadata) if metadata.is_dir() && !metadata.file_type().is_symlink() => Ok(false), | |
| 87 | 추가: Ok(_) => Err(io::Error::other(FOLDER_ERROR)), | |
| 88 | 추가: Err(error) if error.kind() == io::ErrorKind::NotFound && automatic => { | |
| 89 | 추가: fs::create_dir(path)?; | |
| 90 | 추가: Ok(true) | |
| 91 | 추가: } | |
| 92 | 추가: Err(error) => Err(error), | |
| 93 | 추가: } | |
| 94 | 추가: } | |
| 95 | 추가: | |
| 96 | 추가: pub fn remove_owned_empty(path: &Path) { | |
| 97 | 추가: // 이번 요청에서 만든 폴더만 호출하며 비어 있지 않으면 보존함. | |
| 98 | 추가: let _ = fs::remove_dir(path); | |
| 99 | 추가: } | |
| 100 | 추가: | |
| 101 | 추가: pub fn target_files( | |
| 102 | 추가: entries: &[Entry], | |
| 103 | 추가: selected: &BTreeSet<u32>, | |
| 104 | 추가: only: bool, | |
| 105 | 추가: gzip: Option<&str>, | |
| 106 | 추가: ) -> Option<BTreeSet<String>> { | |
| 107 | 추가: let selected_names = entries | |
| 108 | 추가: .iter() | |
| 109 | 추가: .filter(|e| selected.contains(&e.id)) | |
| 110 | 추가: .map(|e| (e.name.as_str(), e.kind)) | |
| 111 | 추가: .collect::<Vec<_>>(); | |
| 112 | 추가: let mut names = BTreeSet::new(); | |
| 113 | 추가: for entry in entries.iter().filter(|e| e.kind == Kind::File) { | |
| 114 | 추가: let included = !only | |
| 115 | 추가: || selected_names.iter().any(|(name, kind)| { | |
| 116 | 추가: *name == entry.name | |
| 117 | 추가: || (*kind == Kind::Directory | |
| 118 | 추가: && entry | |
| 119 | 추가: .name | |
| 120 | 추가: .starts_with(&format!("{}/", name.trim_end_matches('/')))) | |
| 121 | 추가: }); | |
| 122 | 추가: if included && !names.insert(gzip.unwrap_or(&entry.name).replace('\\', "/")) { | |
| 123 | 추가: return None; | |
| 124 | 추가: } | |
| 125 | 추가: } | |
| 126 | 추가: Some(names) | |
| 127 | 추가: } | |
| 128 | 추가: | |
| 129 | 추가: pub fn warnings( | |
| 130 | 추가: terminal: Option<&Terminal>, | |
| 131 | 추가: confirmed: bool, | |
| 132 | 추가: targets: Option<&BTreeSet<String>>, | |
| 133 | 추가: outputs: &[(String, Disposition)], | |
| 134 | 추가: ) -> Vec<&'static str> { | |
| 135 | 추가: let Some(t) = terminal.filter(|_| confirmed) else { | |
| 136 | 추가: return vec![UNCERTAIN]; | |
| 137 | 추가: }; | |
| 138 | 추가: let created = outputs | |
| 139 | 추가: .iter() | |
| 140 | 추가: .filter(|(_, state)| *state == Disposition::Created) | |
| 141 | 추가: .map(|(name, _)| name.replace('\\', "/")) | |
| 142 | 추가: .collect::<BTreeSet<_>>(); | |
| 143 | 추가: let created_reports = outputs | |
| 144 | 추가: .iter() | |
| 145 | 추가: .filter(|(_, state)| *state == Disposition::Created) | |
| 146 | 추가: .count(); | |
| 147 | 추가: let uncertain = t.publication == Publication::Uncertain | |
| 148 | 추가: || outputs | |
| 149 | 추가: .iter() | |
| 150 | 추가: .any(|(_, state)| *state == Disposition::CommitUncertain) | |
| 151 | 추가: || created.len() != created_reports | |
| 152 | 추가: || created_reports as u64 != t.created_count | |
| 153 | 추가: || (t.publication == Publication::None && !created.is_empty()); | |
| 154 | 추가: let retained = t.retained_partial_count > 0 | |
| 155 | 추가: || outputs | |
| 156 | 추가: .iter() | |
| 157 | 추가: .any(|(_, state)| *state == Disposition::PartialRetained); | |
| 158 | 추가: let mut result = Vec::new(); | |
| 159 | 추가: let mut all_saved_with_leftovers = false; | |
| 160 | 추가: if uncertain { | |
| 161 | 추가: result.push(UNCERTAIN); | |
| 162 | 추가: } else if let Some(targets) = targets { | |
| 163 | 추가: let saved = targets.intersection(&created).count(); | |
| 164 | 추가: if !targets.is_empty() && saved == targets.len() && retained { | |
| 165 | 추가: result.push(LEFTOVERS); | |
| 166 | 추가: all_saved_with_leftovers = true; | |
| 167 | 추가: } else if saved > 0 && saved < targets.len() && t.outcome != Outcome::Completed { | |
| 168 | 추가: result.push(PARTIAL); | |
| 169 | 추가: } else if (saved == 0 && !created.is_empty()) | |
| 170 | 추가: || (retained && saved == 0) | |
| 171 | 추가: || (t.outcome == Outcome::Completed && saved != targets.len()) | |
| 172 | 추가: { | |
| 173 | 추가: result.push(UNCERTAIN); | |
| 174 | 추가: } | |
| 175 | 추가: } else { | |
| 176 | 추가: result.push(UNCERTAIN); | |
| 177 | 추가: } | |
| 178 | 추가: if matches!(t.durability, Durability::Failed | Durability::Unconfirmed) { | |
| 179 | 추가: result.push(SYNC_WARNING); | |
| 180 | 추가: } | |
| 181 | 추가: if (retained || t.cleanup != Cleanup::Complete) && !all_saved_with_leftovers { | |
| 182 | 추가: result.push(CLEANUP_WARNING); | |
| 183 | 추가: } | |
| 184 | 추가: result | |
| 185 | 추가: } | |
| 186 | 추가: | |
| 187 | 추가: pub fn definitely_unsaved( | |
| 188 | 추가: t: Option<&Terminal>, | |
| 189 | 추가: confirmed: bool, | |
| 190 | 추가: outputs: &[(String, Disposition)], | |
| 191 | 추가: ) -> bool { | |
| 192 | 추가: t.is_some_and(|t| { | |
| 193 | 추가: confirmed | |
| 194 | 추가: && t.publication == Publication::None | |
| 195 | 추가: && t.created_count == 0 | |
| 196 | 추가: && t.retained_partial_count == 0 | |
| 197 | 추가: && t.cleanup == Cleanup::Complete | |
| 198 | 추가: && outputs | |
| 199 | 추가: .iter() | |
| 200 | 추가: .all(|(_, state)| *state == Disposition::Removed) | |
| 201 | 추가: }) | |
| 202 | 추가: } | |
| 203 | 추가: | |
| 204 | 추가: #[derive(Clone)] | |
| 205 | 추가: pub struct BrowserEntry { | |
| 206 | 추가: pub path: PathBuf, | |
| 207 | 추가: pub name: String, | |
| 208 | 추가: pub directory: bool, | |
| 209 | 추가: pub link: bool, | |
| 210 | 추가: } | |
| 211 | 추가: | |
| 212 | 추가: pub fn directory_entries(path: &Path) -> io::Result<Vec<BrowserEntry>> { | |
| 213 | 추가: if fs::symlink_metadata(path)?.file_type().is_symlink() { | |
| 214 | 추가: return Err(io::Error::other("링크 폴더는 탐색하지 않음")); | |
| 215 | 추가: } | |
| 216 | 추가: let mut entries = Vec::new(); | |
| 217 | 추가: for item in fs::read_dir(path)? { | |
| 218 | 추가: let item = item?; | |
| 219 | 추가: let kind = item.file_type()?; | |
| 220 | 추가: entries.push(BrowserEntry { | |
| 221 | 추가: path: item.path(), | |
| 222 | 추가: name: item.file_name().to_string_lossy().into(), | |
| 223 | 추가: directory: kind.is_dir(), | |
| 224 | 추가: link: kind.is_symlink(), | |
| 225 | 추가: }); | |
| 226 | 추가: } | |
| 227 | 추가: entries.sort_by(|a, b| { | |
| 228 | 추가: b.directory | |
| 229 | 추가: .cmp(&a.directory) | |
| 230 | 추가: .then_with(|| a.name.to_lowercase().cmp(&b.name.to_lowercase())) | |
| 231 | 추가: }); | |
| 232 | 추가: Ok(entries) | |
| 233 | 추가: } | |
| 234 | 추가: | |
| 235 | 추가: pub fn home_directory() -> PathBuf { | |
| 236 | 추가: std::env::var_os(if cfg!(windows) { "USERPROFILE" } else { "HOME" }) | |
| 237 | 추가: .map(PathBuf::from) | |
| 238 | 추가: .filter(|p| p.is_absolute()) | |
| 239 | 추가: .unwrap_or_else(|| std::env::current_dir().unwrap_or_else(|_| PathBuf::from("/"))) | |
| 240 | 추가: } | |
| 241 | 추가: | |
| 242 | 추가: pub fn shortcuts() -> Vec<(String, PathBuf)> { | |
| 243 | 추가: let home = home_directory(); | |
| 244 | 추가: let mut paths = vec![("홈".into(), home.clone())]; | |
| 245 | 추가: for (label, candidates) in [ | |
| 246 | 추가: ("바탕 화면", ["Desktop", "바탕화면"]), | |
| 247 | 추가: ("문서", ["Documents", "문서"]), | |
| 248 | 추가: ("다운로드", ["Downloads", "다운로드"]), | |
| 249 | 추가: ] { | |
| 250 | 추가: if let Some(path) = candidates | |
| 251 | 추가: .iter() | |
| 252 | 추가: .map(|name| home.join(name)) | |
| 253 | 추가: .find(|p| p.is_dir()) | |
| 254 | 추가: { | |
| 255 | 추가: paths.push((label.into(), path)); | |
| 256 | 추가: } | |
| 257 | 추가: } | |
| 258 | 추가: #[cfg(windows)] | |
| 259 | 추가: for drive in b'A'..=b'Z' { | |
| 260 | 추가: let path = PathBuf::from(format!("{}:\\", drive as char)); | |
| 261 | 추가: if path.is_dir() { | |
| 262 | 추가: paths.push((format!("{}:", drive as char), path)); | |
| 263 | 추가: } | |
| 264 | 추가: } | |
| 265 | 추가: paths | |
| 266 | 추가: } | |
| 267 | 추가: | |
| 268 | 추가: pub fn folder_command(path: &Path) -> std::process::Command { | |
| 269 | 추가: let mut command = std::process::Command::new(if cfg!(windows) { | |
| 270 | 추가: "explorer" | |
| 271 | 추가: } else { | |
| 272 | 추가: "xdg-open" | |
| 273 | 추가: }); | |
| 274 | 추가: command.arg(path); | |
| 275 | 추가: command | |
| 276 | 추가: } | |
| 277 | 추가: | |
| 278 | 추가: pub const UNCONFIRMED_FINISH: &str = | |
| 279 | 추가: "작업이 정상적으로 끝났는지 확인하지 못했습니다. 풀 위치 폴더를 확인하세요"; | |
| 280 | 추가: | |
| 281 | 추가: pub fn client_error_text(error: &str) -> &'static str { | |
| 282 | 추가: if error.starts_with("작업자 종료 결과를 확인할 수 없습니다") { | |
| 283 | 추가: UNCONFIRMED_FINISH | |
| 284 | 추가: } else { | |
| 285 | 추가: INTERNAL | |
| 286 | 추가: } | |
| 287 | 추가: } | |
| 288 | 추가: | |
| 289 | 추가: pub fn activity_text(model: &Model, creating: bool) -> &'static str { | |
| 290 | 추가: if model.terminal.is_some() | |
| 291 | 추가: || matches!( | |
| 292 | 추가: model.cancel, | |
| 293 | 추가: Some(CancelStatus::TooLate | CancelStatus::Finished) | |
| 294 | 추가: ) | |
| 295 | 추가: { | |
| 296 | 추가: "마무리하는 중" | |
| 297 | 추가: } else if model.cancellation_requested() || model.cancel.is_some() { | |
| 298 | 추가: "취소하는 중..." | |
| 299 | 추가: } else if model.challenge.is_some() { | |
| 300 | 추가: "암호를 입력하세요" | |
| 301 | 추가: } else { | |
| 302 | 추가: model | |
| 303 | 추가: .progress | |
| 304 | 추가: .map_or("압축파일을 읽는 중", |(stage, _, _, _)| { | |
| 305 | 추가: progress_text(stage, creating) | |
| 306 | 추가: }) | |
| 307 | 추가: } | |
| 308 | 추가: } |
Diff가 표시 한도를 넘어서 생략했어요.
Raw로 열기| @@ -0,0 +1,278 @@ | ||
| 1 | 추가: use eframe::egui::{self, Color32, FontId, Stroke, TextStyle}; | |
| 2 | 추가: | |
| 3 | 추가: pub const BACKGROUND: Color32 = Color32::from_rgb(247, 248, 250); | |
| 4 | 추가: pub const PANEL: Color32 = Color32::WHITE; | |
| 5 | 추가: pub const STRIPE: Color32 = Color32::from_rgb(243, 245, 248); | |
| 6 | 추가: pub const BORDER: Color32 = Color32::from_rgb(217, 222, 229); | |
| 7 | 추가: pub const TEXT: Color32 = Color32::from_rgb(31, 41, 51); | |
| 8 | 추가: pub const MUTED: Color32 = Color32::from_rgb(91, 102, 115); | |
| 9 | 추가: pub const BLUE: Color32 = Color32::from_rgb(37, 99, 235); | |
| 10 | 추가: pub const BLUE_HOVER: Color32 = Color32::from_rgb(29, 78, 216); | |
| 11 | 추가: pub const BLUE_ACTIVE: Color32 = Color32::from_rgb(30, 64, 175); | |
| 12 | 추가: pub const SELECTED: Color32 = Color32::from_rgb(232, 240, 254); | |
| 13 | 추가: pub const DROP: Color32 = Color32::from_rgb(238, 244, 255); | |
| 14 | 추가: pub const DASH: Color32 = Color32::from_rgb(170, 180, 192); | |
| 15 | 추가: pub const SUCCESS: Color32 = Color32::from_rgb(21, 128, 61); | |
| 16 | 추가: pub const SUCCESS_BG: Color32 = Color32::from_rgb(232, 245, 236); | |
| 17 | 추가: pub const WARNING: Color32 = Color32::from_rgb(180, 83, 9); | |
| 18 | 추가: pub const WARNING_BG: Color32 = Color32::from_rgb(255, 247, 232); | |
| 19 | 추가: pub const ERROR: Color32 = Color32::from_rgb(185, 28, 28); | |
| 20 | 추가: pub const ERROR_BG: Color32 = Color32::from_rgb(253, 237, 237); | |
| 21 | 추가: pub const FOLDER: Color32 = Color32::from_rgb(224, 165, 38); | |
| 22 | 추가: pub const FILE: Color32 = Color32::from_rgb(123, 135, 148); | |
| 23 | 추가: pub const SPACE: f32 = 8.0; | |
| 24 | 추가: pub const PAD: i8 = 16; | |
| 25 | 추가: pub const ROW: f32 = 32.0; | |
| 26 | 추가: pub const BUTTON: f32 = 40.0; | |
| 27 | 추가: pub const BODY: f32 = 15.0; | |
| 28 | 추가: pub const TITLE: f32 = 22.0; | |
| 29 | 추가: | |
| 30 | 추가: pub fn apply(ctx: &egui::Context) { | |
| 31 | 추가: ctx.set_theme(egui::Theme::Light); | |
| 32 | 추가: ctx.set_visuals(egui::Visuals::light()); | |
| 33 | 추가: ctx.style_mut_of(egui::Theme::Light, |style| { | |
| 34 | 추가: style | |
| 35 | 추가: .text_styles | |
| 36 | 추가: .insert(TextStyle::Body, FontId::proportional(BODY)); | |
| 37 | 추가: style | |
| 38 | 추가: .text_styles | |
| 39 | 추가: .insert(TextStyle::Button, FontId::proportional(BODY)); | |
| 40 | 추가: style | |
| 41 | 추가: .text_styles | |
| 42 | 추가: .insert(TextStyle::Small, FontId::proportional(BODY)); | |
| 43 | 추가: style | |
| 44 | 추가: .text_styles | |
| 45 | 추가: .insert(TextStyle::Heading, FontId::proportional(TITLE)); | |
| 46 | 추가: style.visuals.override_text_color = Some(TEXT); | |
| 47 | 추가: style.visuals.panel_fill = BACKGROUND; | |
| 48 | 추가: style.visuals.window_fill = PANEL; | |
| 49 | 추가: style.visuals.extreme_bg_color = PANEL; | |
| 50 | 추가: style.visuals.faint_bg_color = STRIPE; | |
| 51 | 추가: style.visuals.selection.bg_fill = SELECTED; | |
| 52 | 추가: style.visuals.selection.stroke = Stroke::new(2.0, BLUE); | |
| 53 | 추가: style.visuals.widgets.inactive.bg_fill = PANEL; | |
| 54 | 추가: style.visuals.widgets.inactive.weak_bg_fill = PANEL; | |
| 55 | 추가: style.visuals.widgets.inactive.bg_stroke = Stroke::new(1.0, BORDER); | |
| 56 | 추가: style.visuals.widgets.hovered.bg_fill = DROP; | |
| 57 | 추가: style.visuals.widgets.hovered.weak_bg_fill = DROP; | |
| 58 | 추가: style.visuals.widgets.hovered.bg_stroke = Stroke::new(1.0, BLUE); | |
| 59 | 추가: style.visuals.widgets.active.bg_stroke = Stroke::new(2.0, BLUE); | |
| 60 | 추가: for widget in [ | |
| 61 | 추가: &mut style.visuals.widgets.inactive, | |
| 62 | 추가: &mut style.visuals.widgets.hovered, | |
| 63 | 추가: &mut style.visuals.widgets.active, | |
| 64 | 추가: &mut style.visuals.widgets.noninteractive, | |
| 65 | 추가: ] { | |
| 66 | 추가: widget.corner_radius = egui::CornerRadius::same(6); | |
| 67 | 추가: widget.fg_stroke = Stroke::new(1.5, TEXT); | |
| 68 | 추가: } | |
| 69 | 추가: style.visuals.window_corner_radius = egui::CornerRadius::same(8); | |
| 70 | 추가: style.spacing.item_spacing = egui::vec2(SPACE, SPACE); | |
| 71 | 추가: style.spacing.button_padding = egui::vec2(16.0, SPACE); | |
| 72 | 추가: style.spacing.interact_size.y = ROW; | |
| 73 | 추가: style.spacing.window_margin = egui::Margin::same(PAD); | |
| 74 | 추가: style.visuals.disabled_alpha = 0.4; | |
| 75 | 추가: }); | |
| 76 | 추가: } | |
| 77 | 추가: | |
| 78 | 추가: pub fn focus(response: &egui::Response) { | |
| 79 | 추가: if response.has_focus() { | |
| 80 | 추가: response.ctx.layer_painter(response.layer_id).rect_stroke( | |
| 81 | 추가: response.rect.expand(2.0), | |
| 82 | 추가: 6, | |
| 83 | 추가: Stroke::new(2.0, BLUE), | |
| 84 | 추가: egui::StrokeKind::Outside, | |
| 85 | 추가: ); | |
| 86 | 추가: } | |
| 87 | 추가: } | |
| 88 | 추가: | |
| 89 | 추가: pub fn action(ui: &mut egui::Ui, text: &str, primary: bool, enabled: bool) -> egui::Response { | |
| 90 | 추가: let response = ui | |
| 91 | 추가: .scope(|ui| { | |
| 92 | 추가: if primary { | |
| 93 | 추가: let style = ui.style_mut(); | |
| 94 | 추가: style.visuals.widgets.inactive.bg_fill = BLUE; | |
| 95 | 추가: style.visuals.widgets.inactive.weak_bg_fill = BLUE; | |
| 96 | 추가: style.visuals.widgets.hovered.bg_fill = BLUE_HOVER; | |
| 97 | 추가: style.visuals.widgets.hovered.weak_bg_fill = BLUE_HOVER; | |
| 98 | 추가: style.visuals.widgets.active.bg_fill = BLUE_ACTIVE; | |
| 99 | 추가: style.visuals.widgets.active.weak_bg_fill = BLUE_ACTIVE; | |
| 100 | 추가: } | |
| 101 | 추가: ui.add_enabled( | |
| 102 | 추가: enabled, | |
| 103 | 추가: egui::Button::new(egui::RichText::new(text).strong().color(if primary { | |
| 104 | 추가: PANEL | |
| 105 | 추가: } else if text == "취소" { | |
| 106 | 추가: ERROR | |
| 107 | 추가: } else { | |
| 108 | 추가: TEXT | |
| 109 | 추가: })) | |
| 110 | 추가: .min_size(egui::vec2( | |
| 111 | 추가: if primary { 112.0 } else { 0.0 }, | |
| 112 | 추가: if primary { BUTTON } else { 36.0 }, | |
| 113 | 추가: )) | |
| 114 | 추가: .stroke(Stroke::new(1.0, if primary { BLUE } else { BORDER })), | |
| 115 | 추가: ) | |
| 116 | 추가: }) | |
| 117 | 추가: .inner; | |
| 118 | 추가: focus(&response); | |
| 119 | 추가: response | |
| 120 | 추가: } | |
| 121 | 추가: | |
| 122 | 추가: pub fn panel(fill: Color32) -> egui::Frame { | |
| 123 | 추가: egui::Frame::new() | |
| 124 | 추가: .fill(fill) | |
| 125 | 추가: .inner_margin(egui::Margin::same(PAD)) | |
| 126 | 추가: .corner_radius(8) | |
| 127 | 추가: } | |
| 128 | 추가: | |
| 129 | 추가: #[derive(Clone, Copy)] | |
| 130 | 추가: pub enum Icon { | |
| 131 | 추가: File, | |
| 132 | 추가: Folder, | |
| 133 | 추가: Archive, | |
| 134 | 추가: Lock, | |
| 135 | 추가: Success, | |
| 136 | 추가: Warning, | |
| 137 | 추가: Error, | |
| 138 | 추가: } | |
| 139 | 추가: | |
| 140 | 추가: pub fn icon(ui: &mut egui::Ui, kind: Icon, size: f32) { | |
| 141 | 추가: let (rect, _) = ui.allocate_exact_size(egui::vec2(size, size), egui::Sense::hover()); | |
| 142 | 추가: let p = ui.painter(); | |
| 143 | 추가: let color = match kind { | |
| 144 | 추가: Icon::Folder => FOLDER, | |
| 145 | 추가: Icon::Archive => BLUE, | |
| 146 | 추가: Icon::Lock | Icon::Warning => WARNING, | |
| 147 | 추가: Icon::Success => SUCCESS, | |
| 148 | 추가: Icon::Error => ERROR, | |
| 149 | 추가: Icon::File => FILE, | |
| 150 | 추가: }; | |
| 151 | 추가: let s = Stroke::new(if size > 32.0 { 2.5 } else { 1.5 }, color); | |
| 152 | 추가: let point = |x, y| rect.min + egui::vec2(x * size, y * size); | |
| 153 | 추가: let box_at = |x, y, w, h| egui::Rect::from_min_max(point(x, y), point(x + w, y + h)); | |
| 154 | 추가: match kind { | |
| 155 | 추가: Icon::Folder => { | |
| 156 | 추가: p.rect_filled(box_at(0.08, 0.22, 0.42, 0.22), 2, color); | |
| 157 | 추가: p.rect_filled(box_at(0.08, 0.34, 0.84, 0.50), 2, color); | |
| 158 | 추가: } | |
| 159 | 추가: Icon::File | Icon::Archive => { | |
| 160 | 추가: p.rect_stroke( | |
| 161 | 추가: box_at(0.19, 0.08, 0.62, 0.84), | |
| 162 | 추가: 2, | |
| 163 | 추가: s, | |
| 164 | 추가: egui::StrokeKind::Inside, | |
| 165 | 추가: ); | |
| 166 | 추가: p.line_segment([point(0.60, 0.08), point(0.60, 0.30)], s); | |
| 167 | 추가: p.line_segment([point(0.60, 0.30), point(0.81, 0.30)], s); | |
| 168 | 추가: if matches!(kind, Icon::Archive) { | |
| 169 | 추가: for y in [0.42, 0.57, 0.72] { | |
| 170 | 추가: p.line_segment([point(0.39, y), point(0.59, y)], s); | |
| 171 | 추가: } | |
| 172 | 추가: } | |
| 173 | 추가: } | |
| 174 | 추가: Icon::Lock => { | |
| 175 | 추가: p.circle_stroke(point(0.50, 0.35), size * 0.23, s); | |
| 176 | 추가: p.rect_filled(box_at(0.18, 0.39, 0.64, 0.47), 2, color); | |
| 177 | 추가: } | |
| 178 | 추가: Icon::Success | Icon::Error => { | |
| 179 | 추가: p.circle_stroke(rect.center(), size * 0.40, s); | |
| 180 | 추가: if matches!(kind, Icon::Success) { | |
| 181 | 추가: p.line_segment([point(0.28, 0.50), point(0.44, 0.66)], s); | |
| 182 | 추가: p.line_segment([point(0.44, 0.66), point(0.74, 0.33)], s); | |
| 183 | 추가: } else { | |
| 184 | 추가: p.line_segment([point(0.34, 0.34), point(0.66, 0.66)], s); | |
| 185 | 추가: p.line_segment([point(0.66, 0.34), point(0.34, 0.66)], s); | |
| 186 | 추가: } | |
| 187 | 추가: } | |
| 188 | 추가: Icon::Warning => { | |
| 189 | 추가: p.add(egui::Shape::closed_line( | |
| 190 | 추가: vec![point(0.50, 0.08), point(0.94, 0.86), point(0.06, 0.86)], | |
| 191 | 추가: s, | |
| 192 | 추가: )); | |
| 193 | 추가: p.line_segment([point(0.50, 0.32), point(0.50, 0.57)], s); | |
| 194 | 추가: p.circle_filled(point(0.50, 0.73), size * 0.035, color); | |
| 195 | 추가: } | |
| 196 | 추가: } | |
| 197 | 추가: } | |
| 198 | 추가: | |
| 199 | 추가: pub fn column_label( | |
| 200 | 추가: ui: &mut egui::Ui, | |
| 201 | 추가: text: impl Into<egui::WidgetText>, | |
| 202 | 추가: width: f32, | |
| 203 | 추가: align: egui::Align, | |
| 204 | 추가: ) -> egui::Response { | |
| 205 | 추가: let layout = if align == egui::Align::Max { | |
| 206 | 추가: egui::Layout::right_to_left(egui::Align::Center) | |
| 207 | 추가: } else { | |
| 208 | 추가: egui::Layout::left_to_right(egui::Align::Center) | |
| 209 | 추가: }; | |
| 210 | 추가: ui.allocate_ui_with_layout(egui::vec2(width, ROW), layout, |ui| { | |
| 211 | 추가: ui.set_min_width(width); | |
| 212 | 추가: ui.set_max_width(width); | |
| 213 | 추가: ui.add(egui::Label::new(text).truncate()) | |
| 214 | 추가: }) | |
| 215 | 추가: .inner | |
| 216 | 추가: } | |
| 217 | 추가: | |
| 218 | 추가: pub fn action_pair( | |
| 219 | 추가: ui: &mut egui::Ui, | |
| 220 | 추가: secondary: &str, | |
| 221 | 추가: primary: Option<(&str, bool)>, | |
| 222 | 추가: ) -> (bool, bool) { | |
| 223 | 추가: let text_width = |text: &str| { | |
| 224 | 추가: ui.painter() | |
| 225 | 추가: .layout_no_wrap(text.into(), FontId::proportional(BODY), TEXT) | |
| 226 | 추가: .size() | |
| 227 | 추가: .x | |
| 228 | 추가: }; | |
| 229 | 추가: let width = text_width(secondary) | |
| 230 | 추가: + 32.0 | |
| 231 | 추가: + primary.map_or(0.0, |(label, _)| { | |
| 232 | 추가: SPACE + (text_width(label) + 32.0).max(112.0) | |
| 233 | 추가: }); | |
| 234 | 추가: ui.horizontal(|ui| { | |
| 235 | 추가: ui.with_layout(egui::Layout::left_to_right(egui::Align::Center), |ui| { | |
| 236 | 추가: ui.add_space((ui.available_width() - width).max(0.0)); | |
| 237 | 추가: let secondary = action(ui, secondary, false, true).clicked(); | |
| 238 | 추가: let primary = primary.is_some_and(|(label, enabled)| { | |
| 239 | 추가: action(ui, label, true, enabled) | |
| 240 | 추가: .on_disabled_hover_text(match label { | |
| 241 | 추가: "만들기" => "묶을 파일이나 폴더를 추가하세요", | |
| 242 | 추가: "다른 폴더에 풀기" => "기존 풀 위치 폴더를 먼저 확인하세요", | |
| 243 | 추가: _ => "입력한 내용을 확인하세요", | |
| 244 | 추가: }) | |
| 245 | 추가: .clicked() | |
| 246 | 추가: }); | |
| 247 | 추가: (secondary, primary) | |
| 248 | 추가: }) | |
| 249 | 추가: .inner | |
| 250 | 추가: }) | |
| 251 | 추가: .inner | |
| 252 | 추가: } | |
| 253 | 추가: | |
| 254 | 추가: pub fn indeterminate(ui: &mut egui::Ui) { | |
| 255 | 추가: let (rect, response) = ui.allocate_exact_size( | |
| 256 | 추가: egui::vec2(ui.available_width(), SPACE * 2.0), | |
| 257 | 추가: egui::Sense::hover(), | |
| 258 | 추가: ); | |
| 259 | 추가: ui.painter().rect_filled(rect, 8, BORDER); | |
| 260 | 추가: let phase = if ui.style().animation_time > 0.0 { | |
| 261 | 추가: ui.input(|i| (i.time * 0.6).fract()) as f32 | |
| 262 | 추가: } else { | |
| 263 | 추가: 0.5 | |
| 264 | 추가: }; | |
| 265 | 추가: let width = (SPACE * 8.0).min(rect.width()); | |
| 266 | 추가: let pulse = egui::Rect::from_min_size( | |
| 267 | 추가: rect.min + egui::vec2((rect.width() - width) * phase, 0.0), | |
| 268 | 추가: egui::vec2(width, rect.height()), | |
| 269 | 추가: ); | |
| 270 | 추가: ui.painter().rect_filled(pulse, 8, BLUE); | |
| 271 | 추가: response.widget_info(|| { | |
| 272 | 추가: egui::WidgetInfo::labeled( | |
| 273 | 추가: egui::Role::ProgressIndicator, | |
| 274 | 추가: ui.is_enabled(), | |
| 275 | 추가: "전체 크기를 알 수 없는 작업 진행 중", | |
| 276 | 추가: ) | |
| 277 | 추가: }); | |
| 278 | 추가: } |
| @@ -280,6 +280,11 @@ impl Model { | ||
| 280 | 280 | pub fn busy(&self) -> bool { |
| 281 | 281 | self.running.is_some() |
| 282 | 282 | } |
| 283 | 추가: pub fn cancellation_requested(&self) -> bool { | |
| 284 | 추가: self.running | |
| 285 | 추가: .as_ref() | |
| 286 | 추가: .is_some_and(|run| run.cancel_sequence.is_some()) | |
| 287 | 추가: } | |
| 283 | 288 | pub fn job_id(&self) -> Option<u64> { |
| 284 | 289 | self.running.as_ref().map(|r| r.id) |
| 285 | 290 | } |
| @@ -7,7 +7,7 @@ mod fake; | ||
| 7 | 7 | mod renderer; |
| 8 | 8 | #[path = "system_font.rs"] |
| 9 | 9 | mod system_font; |
| 10 | 삭제: use eframe::egui::{self, Color32, FontData, FontDefinitions, FontFamily, FontId, TextStyle}; | |
| 10 | 추가: use eframe::egui::{self, FontData, FontDefinitions, FontFamily}; | |
| 11 | 11 | fn main() -> eframe::Result { |
| 12 | 12 | let result = run(); |
| 13 | 13 | #[cfg(target_os = "windows")] |
| @@ -63,23 +63,7 @@ fn run() -> eframe::Result { | ||
| 63 | 63 | .families |
| 64 | 64 | .insert(FontFamily::Proportional, vec!["noto-kr".into()]); |
| 65 | 65 | cc.egui_ctx.set_fonts(fonts); |
| 66 | 삭제: cc.egui_ctx.set_visuals(egui::Visuals::light()); | |
| 67 | 삭제: cc.egui_ctx.style_mut_of(egui::Theme::Light, |style| { | |
| 68 | 삭제: style | |
| 69 | 삭제: .text_styles | |
| 70 | 삭제: .insert(TextStyle::Body, FontId::proportional(18.0)); | |
| 71 | 삭제: style | |
| 72 | 삭제: .text_styles | |
| 73 | 삭제: .insert(TextStyle::Button, FontId::proportional(18.0)); | |
| 74 | 삭제: style | |
| 75 | 삭제: .text_styles | |
| 76 | 삭제: .insert(TextStyle::Heading, FontId::proportional(26.0)); | |
| 77 | 삭제: style.visuals.panel_fill = Color32::WHITE; | |
| 78 | 삭제: style.visuals.override_text_color = Some(Color32::from_rgb(24, 39, 57)); | |
| 79 | 삭제: style.visuals.selection.bg_fill = Color32::from_rgb(211, 230, 246); | |
| 80 | 삭제: style.spacing.item_spacing = egui::vec2(12.0, 10.0); | |
| 81 | 삭제: style.spacing.button_padding = egui::vec2(14.0, 10.0); | |
| 82 | 삭제: }); | |
| 66 | 추가: zipelo_ui_memory_app::archive_theme::apply(&cc.egui_ctx); | |
| 83 | 67 | let (fixture, startup) = zipelo_ui_memory_app::archive_ui::launch_args( |
| 84 | 68 | std::env::args_os().skip(1).collect(), |
| 85 | 69 | std::env::current_dir()?, |
| @@ -11,3 +11,10 @@ pub mod archive_ui; | ||
| 11 | 11 | pub mod archive_screen; |
| 12 | 12 | |
| 13 | 13 | pub mod archive_process; |
| 14 | 추가: | |
| 15 | 추가: pub mod archive_present; | |
| 16 | 추가: | |
| 17 | 추가: #[cfg(feature = "ui")] | |
| 18 | 추가: pub mod archive_picker; | |
| 19 | 추가: #[cfg(feature = "ui")] | |
| 20 | 추가: pub mod archive_theme; |
| @@ -230,9 +230,17 @@ mod screen { | ||
| 230 | 230 | let point = self.locate(label); |
| 231 | 231 | self.click_at(point); |
| 232 | 232 | } |
| 233 | 삭제: fn fill(&mut self, label: &str, offset: egui::Vec2, value: &Path) { | |
| 234 | 삭제: let point = self.locate(label) + offset; | |
| 233 | 추가: fn set_text(&mut self, id: &str, value: &str) { | |
| 234 | 추가: self.render(vec![]); | |
| 235 | 추가: let point = self | |
| 236 | 추가: .context | |
| 237 | 추가: .read_response(egui::Id::unique(id)) | |
| 238 | 추가: .unwrap() | |
| 239 | 추가: .rect | |
| 240 | 추가: .center(); | |
| 235 | 241 | self.click_at(point); |
| 242 | 추가: self.context | |
| 243 | 추가: .memory_mut(|memory| memory.request_focus(egui::Id::unique(id))); | |
| 236 | 244 | self.render(vec![ |
| 237 | 245 | egui::Event::Key { |
| 238 | 246 | key: egui::Key::A, |
| @@ -241,9 +249,18 @@ mod screen { | ||
| 241 | 249 | repeat: false, |
| 242 | 250 | modifiers: egui::Modifiers::COMMAND, |
| 243 | 251 | }, |
| 244 | 삭제: egui::Event::Text(value.to_str().unwrap().to_string()), | |
| 252 | 추가: egui::Event::Text(value.into()), | |
| 245 | 253 | ]); |
| 246 | 254 | } |
| 255 | 추가: fn escape(&mut self) { | |
| 256 | 추가: self.render(vec![egui::Event::Key { | |
| 257 | 추가: key: egui::Key::Escape, | |
| 258 | 추가: physical_key: None, | |
| 259 | 추가: pressed: true, | |
| 260 | 추가: repeat: false, | |
| 261 | 추가: modifiers: egui::Modifiers::NONE, | |
| 262 | 추가: }]); | |
| 263 | 추가: } | |
| 247 | 264 | fn settle(&mut self) { |
| 248 | 265 | let deadline = Instant::now() + Duration::from_secs(10); |
| 249 | 266 | while self.app.model.busy() { |
| @@ -254,14 +271,12 @@ mod screen { | ||
| 254 | 271 | completed(&self.app.model); |
| 255 | 272 | } |
| 256 | 273 | fn open(&mut self, archive: &Path) { |
| 257 | 삭제: self.click("파일 열기"); | |
| 258 | 삭제: self.fill("압축파일 절대 경로", egui::vec2(0.0, 22.0), archive); | |
| 259 | 삭제: self.click("열기"); | |
| 274 | 추가: self.app.open_path(archive.to_path_buf()); | |
| 260 | 275 | assert!(self.app.model.busy()); |
| 261 | 276 | self.settle(); |
| 262 | 277 | } |
| 263 | 278 | fn extract(&mut self, destination: &Path) { |
| 264 | 삭제: self.fill("출력 폴더", egui::vec2(100.0, 0.0), destination); | |
| 279 | 추가: self.app.choose_destination(destination.to_path_buf()); | |
| 265 | 280 | self.click("풀기"); |
| 266 | 281 | assert!(self.app.model.busy()); |
| 267 | 282 | self.settle(); |
| @@ -345,14 +360,10 @@ mod screen { | ||
| 345 | 360 | let output = make_directory(&scratch.path("output")); |
| 346 | 361 | let (factory, observed) = observed_factory(); |
| 347 | 362 | let mut screen = Screen::new(factory); |
| 348 | 삭제: screen.click("ZIP 만들기"); | |
| 349 | 삭제: screen.fill( | |
| 350 | 삭제: "원본 파일 절대 경로 / 한 줄에 하나", | |
| 351 | 삭제: egui::vec2(0.0, 25.0), | |
| 352 | 삭제: &source, | |
| 353 | 삭제: ); | |
| 354 | 삭제: screen.fill("저장할 ZIP 절대 경로", egui::vec2(0.0, 22.0), &archive); | |
| 355 | 삭제: screen.click("ZIP 만들기"); | |
| 363 | 추가: screen.app.add_sources(vec![source.clone()]); | |
| 364 | 추가: screen.render(vec![]); | |
| 365 | 추가: screen.set_text("zip-name", archive.file_name().unwrap().to_str().unwrap()); | |
| 366 | 추가: screen.click("만들기"); | |
| 356 | 367 | assert!(screen.app.model.busy()); |
| 357 | 368 | screen.settle(); |
| 358 | 369 | assert!(archive.is_file()); |
| @@ -30,7 +30,7 @@ impl Screen { | ||
| 30 | 30 | self.render(vec![]); |
| 31 | 31 | let input = self |
| 32 | 32 | .context |
| 33 | 삭제: .read_response(egui::Id::new("archive-password-input")) | |
| 33 | 추가: .read_response(egui::Id::unique("archive-password-input")) | |
| 34 | 34 | .expect("암호 입력란이 없음") |
| 35 | 35 | .rect |
| 36 | 36 | .center(); |
| @@ -48,10 +48,13 @@ impl Screen { | ||
| 48 | 48 | if !text.is_empty() { |
| 49 | 49 | assert!(!rendered.iter().any(|(value, _)| value.contains(text))); |
| 50 | 50 | } |
| 51 | 삭제: self.click("암호 전달"); | |
| 51 | 추가: if self.app.model.challenge.is_some_and(|(_, _, encrypt)| encrypt) { | |
| 52 | 추가: self.set_text("archive-password-confirm", text); | |
| 53 | 추가: } | |
| 54 | 추가: self.click("확인"); | |
| 52 | 55 | } |
| 53 | 56 | fn start_password_extract(&mut self, output: &Path) { |
| 54 | 삭제: self.fill("출력 폴더", egui::vec2(100.0, 0.0), output); | |
| 57 | 추가: self.app.choose_destination(output.to_path_buf()); | |
| 55 | 58 | self.click("풀기"); |
| 56 | 59 | assert!(self.app.model.busy()); |
| 57 | 60 | } |
| @@ -67,15 +70,11 @@ impl Screen { | ||
| 67 | 70 | assert!(self.app.model.challenge.is_none()); |
| 68 | 71 | } |
| 69 | 72 | fn start_encrypted_zip(&mut self, source: &Path, archive: &Path) { |
| 70 | 삭제: self.click("ZIP 만들기"); | |
| 71 | 삭제: self.fill( | |
| 72 | 삭제: "원본 파일 절대 경로 / 한 줄에 하나", | |
| 73 | 삭제: egui::vec2(0.0, 25.0), | |
| 74 | 삭제: source, | |
| 75 | 삭제: ); | |
| 76 | 삭제: self.fill("저장할 ZIP 절대 경로", egui::vec2(0.0, 22.0), archive); | |
| 77 | 삭제: self.click("암호로 보호"); | |
| 78 | 삭제: self.click("ZIP 만들기"); | |
| 73 | 추가: self.app.add_sources(vec![source.to_path_buf()]); | |
| 74 | 추가: self.render(vec![]); | |
| 75 | 추가: self.set_text("zip-name", archive.file_name().unwrap().to_str().unwrap()); | |
| 76 | 추가: self.click("암호로 보호하기"); | |
| 77 | 추가: self.click("만들기"); | |
| 79 | 78 | assert!(self.app.model.busy(), "{}", self.app.model.status()); |
| 80 | 79 | } |
| 81 | 80 | } |
| @@ -131,17 +130,9 @@ fn wrong_password_retry_clears_input_and_succeeds_without_partial_output() { | ||
| 131 | 130 | .iter() |
| 132 | 131 | .any(|(value, _)| value == "암호가 맞지 않습니다. 다시 입력하세요") |
| 133 | 132 | ); |
| 134 | 삭제: screen.click("암호 전달"); | |
| 133 | 추가: screen.click("확인"); | |
| 135 | 134 | assert_eq!(screen.app.model.challenge, Some((second, 2, false))); |
| 136 | 삭제: assert!( | |
| 137 | 삭제: screen | |
| 138 | 삭제: .app | |
| 139 | 삭제: .model | |
| 140 | 삭제: .input_error | |
| 141 | 삭제: .as_ref() | |
| 142 | 삭제: .unwrap() | |
| 143 | 삭제: .contains("1~1024바이트") | |
| 144 | 삭제: ); | |
| 135 | 추가: assert!(screen.app.model.input_error.is_none()); | |
| 145 | 136 | screen.render(vec![]); |
| 146 | 137 | screen.password_answer(FIXTURE_PASSWORD); |
| 147 | 138 | screen.finish_password_job(Outcome::Completed); |
| @@ -181,7 +172,7 @@ fn cancel_password_extraction_waits_for_cleanup_without_writes() { | ||
| 181 | 172 | screen.open(&archive); |
| 182 | 173 | screen.start_password_extract(&output); |
| 183 | 174 | screen.password_request(1, false); |
| 184 | 삭제: screen.click("작업 취소"); | |
| 175 | 추가: screen.escape(); | |
| 185 | 176 | screen.app.model.request_close(); |
| 186 | 177 | screen.app.model.confirm_close(); |
| 187 | 178 | assert!(matches!( |
| @@ -234,7 +225,7 @@ fn cancel_password_creation_does_not_create_an_archive() { | ||
| 234 | 225 | let mut screen = Screen::new(factory); |
| 235 | 226 | screen.start_encrypted_zip(&source, &archive); |
| 236 | 227 | screen.password_request(1, true); |
| 237 | 삭제: screen.click("작업 취소"); | |
| 228 | 추가: screen.escape(); | |
| 238 | 229 | screen.finish_password_job(Outcome::Cancelled); |
| 239 | 230 | assert!(!archive.exists()); |
| 240 | 231 | assert_eq!(fs::read(source).unwrap(), b"preserve"); |
| @@ -254,15 +245,7 @@ fn oversized_utf8_password_stays_in_dialog_then_accepts_valid_input() { | ||
| 254 | 245 | let id = screen.password_request(1, false); |
| 255 | 246 | screen.password_answer(&"가".repeat(342)); |
| 256 | 247 | assert_eq!(screen.app.model.challenge, Some((id, 1, false))); |
| 257 | 삭제: assert!( | |
| 258 | 삭제: screen | |
| 259 | 삭제: .app | |
| 260 | 삭제: .model | |
| 261 | 삭제: .input_error | |
| 262 | 삭제: .as_ref() | |
| 263 | 삭제: .unwrap() | |
| 264 | 삭제: .contains("1~1024바이트") | |
| 265 | 삭제: ); | |
| 248 | 추가: assert!(screen.render(vec![]).iter().any(|(text, _)| text.contains("1~1024바이트"))); | |
| 266 | 249 | assert_eq!(fs::read_dir(&output).unwrap().count(), 0); |
| 267 | 250 | screen.password_answer(FIXTURE_PASSWORD); |
| 268 | 251 | screen.finish_password_job(Outcome::Completed); |
| @@ -280,14 +263,18 @@ fn invalid_password_then_cancel(invalid: &str, close: bool) { | ||
| 280 | 263 | let challenge = screen.password_request(1, true); |
| 281 | 264 | screen.password_answer(invalid); |
| 282 | 265 | assert_eq!(screen.app.model.challenge, Some((challenge, 1, true))); |
| 283 | 삭제: assert!(screen.app.model.status().contains("1~1024바이트")); | |
| 266 | 추가: if invalid.is_empty() { | |
| 267 | 추가: assert!(screen.app.model.input_error.is_none()); | |
| 268 | 추가: } else { | |
| 269 | 추가: assert!(screen.render(vec![]).iter().any(|(text, _)| text.contains("1~1024바이트"))); | |
| 270 | 추가: } | |
| 284 | 271 | if close { |
| 285 | 272 | screen.app.model.request_close(); |
| 286 | 273 | screen.app.model.confirm_close(); |
| 287 | 274 | assert_eq!(screen.app.model.close, Close::Waiting); |
| 288 | 275 | assert!(!screen.app.model.confirmed); |
| 289 | 276 | } else { |
| 290 | 삭제: screen.click("작업 취소"); | |
| 277 | 추가: screen.escape(); | |
| 291 | 278 | } |
| 292 | 279 | screen.finish_password_job(Outcome::Cancelled); |
| 293 | 280 | assert_eq!(screen.app.model.status(), "작업 취소됨"); |
| @@ -0,0 +1,335 @@ | ||
| 1 | 추가: use eframe::egui::{self, FontData, FontDefinitions, FontFamily, FontId, TextStyle}; | |
| 2 | 추가: use std::{collections::VecDeque, path::PathBuf}; | |
| 3 | 추가: use zipelo_ui_memory_app::{archive_screen::ArchiveApp, archive_ui::*}; | |
| 4 | 추가: #[path = "../../experiments/rust-ui-memory-app/src/renderer.rs"] | |
| 5 | 추가: mod renderer; | |
| 6 | 추가: #[path = "../../experiments/rust-ui-memory-app/src/system_font.rs"] | |
| 7 | 추가: mod system_font; | |
| 8 | 추가: | |
| 9 | 추가: #[derive(Clone)] | |
| 10 | 추가: struct CaptureFactory { | |
| 11 | 추가: mode: String, | |
| 12 | 추가: } | |
| 13 | 추가: struct CaptureConnection { | |
| 14 | 추가: job: u64, | |
| 15 | 추가: sequence: u64, | |
| 16 | 추가: mode: String, | |
| 17 | 추가: queue: VecDeque<HostEvent>, | |
| 18 | 추가: create_name: Option<String>, | |
| 19 | 추가: } | |
| 20 | 추가: impl CaptureConnection { | |
| 21 | 추가: fn event(&mut self, event: Event) { | |
| 22 | 추가: self.queue.push_back(HostEvent::Frame { | |
| 23 | 추가: job_id: self.job, | |
| 24 | 추가: sequence: self.sequence, | |
| 25 | 추가: event, | |
| 26 | 추가: }); | |
| 27 | 추가: self.sequence += 1; | |
| 28 | 추가: } | |
| 29 | 추가: fn terminal(&mut self, terminal: Terminal) { | |
| 30 | 추가: self.event(Event::Terminal(terminal)); | |
| 31 | 추가: self.queue.extend([ | |
| 32 | 추가: HostEvent::StdoutEof, | |
| 33 | 추가: HostEvent::StderrEof, | |
| 34 | 추가: HostEvent::Exited { success: true }, | |
| 35 | 추가: ]); | |
| 36 | 추가: } | |
| 37 | 추가: fn finish(&mut self, listing: bool) { | |
| 38 | 추가: let error = !listing && self.mode == "error"; | |
| 39 | 추가: let cancelled = !listing && self.mode == "cancelled"; | |
| 40 | 추가: let mut count = 0; | |
| 41 | 추가: if !listing && !error && !cancelled { | |
| 42 | 추가: let names = self | |
| 43 | 추가: .create_name | |
| 44 | 추가: .clone() | |
| 45 | 추가: .map(|name| vec![name]) | |
| 46 | 추가: .unwrap_or_else(|| { | |
| 47 | 추가: vec![ | |
| 48 | 추가: "읽어주세요.txt".into(), | |
| 49 | 추가: "여행 일정.pdf".into(), | |
| 50 | 추가: "사진".into(), | |
| 51 | 추가: ] | |
| 52 | 추가: }); | |
| 53 | 추가: for name in names { | |
| 54 | 추가: self.event(Event::Output { | |
| 55 | 추가: entry_id: None, | |
| 56 | 추가: relative_name: name, | |
| 57 | 추가: disposition: Disposition::Created, | |
| 58 | 추가: }); | |
| 59 | 추가: count += 1; | |
| 60 | 추가: } | |
| 61 | 추가: } | |
| 62 | 추가: self.terminal(Terminal { | |
| 63 | 추가: outcome: if error { | |
| 64 | 추가: Outcome::Failed | |
| 65 | 추가: } else if cancelled { | |
| 66 | 추가: Outcome::Cancelled | |
| 67 | 추가: } else { | |
| 68 | 추가: Outcome::Completed | |
| 69 | 추가: }, | |
| 70 | 추가: error: error.then_some(ErrorCode::DiskFull), | |
| 71 | 추가: publication: if listing || error || cancelled { | |
| 72 | 추가: Publication::None | |
| 73 | 추가: } else { | |
| 74 | 추가: Publication::Complete | |
| 75 | 추가: }, | |
| 76 | 추가: created_count: count, | |
| 77 | 추가: retained_partial_count: 0, | |
| 78 | 추가: durability: if listing { | |
| 79 | 추가: Durability::NotApplicable | |
| 80 | 추가: } else { | |
| 81 | 추가: Durability::Synced | |
| 82 | 추가: }, | |
| 83 | 추가: cleanup: Cleanup::Complete, | |
| 84 | 추가: }); | |
| 85 | 추가: } | |
| 86 | 추가: } | |
| 87 | 추가: fn entries() -> Vec<Entry> { | |
| 88 | 추가: vec![ | |
| 89 | 추가: Entry { | |
| 90 | 추가: id: 0, | |
| 91 | 추가: name: "읽어주세요.txt".into(), | |
| 92 | 추가: kind: Kind::File, | |
| 93 | 추가: bytes: Some(4096), | |
| 94 | 추가: packed: Some(1800), | |
| 95 | 추가: encrypted: false, | |
| 96 | 추가: }, | |
| 97 | 추가: Entry { | |
| 98 | 추가: id: 1, | |
| 99 | 추가: name: "여행 일정.pdf".into(), | |
| 100 | 추가: kind: Kind::File, | |
| 101 | 추가: bytes: Some(1_287_952), | |
| 102 | 추가: packed: Some(900_000), | |
| 103 | 추가: encrypted: true, | |
| 104 | 추가: }, | |
| 105 | 추가: Entry { | |
| 106 | 추가: id: 2, | |
| 107 | 추가: name: "사진".into(), | |
| 108 | 추가: kind: Kind::Directory, | |
| 109 | 추가: bytes: Some(0), | |
| 110 | 추가: packed: None, | |
| 111 | 추가: encrypted: false, | |
| 112 | 추가: }, | |
| 113 | 추가: ] | |
| 114 | 추가: } | |
| 115 | 추가: impl Factory for CaptureFactory { | |
| 116 | 추가: fn connect(&mut self, job: u64) -> Result<Box<dyn Connection>, String> { | |
| 117 | 추가: Ok(Box::new(CaptureConnection { | |
| 118 | 추가: job, | |
| 119 | 추가: sequence: 0, | |
| 120 | 추가: mode: self.mode.clone(), | |
| 121 | 추가: queue: VecDeque::new(), | |
| 122 | 추가: create_name: None, | |
| 123 | 추가: })) | |
| 124 | 추가: } | |
| 125 | 추가: } | |
| 126 | 추가: impl Connection for CaptureConnection { | |
| 127 | 추가: fn send(&mut self, request: Request) -> Result<(), String> { | |
| 128 | 추가: match request.command { | |
| 129 | 추가: Command::Start(start) => { | |
| 130 | 추가: self.event(Event::Accepted { encryption: true }); | |
| 131 | 추가: match start { | |
| 132 | 추가: Start::List { .. } => { | |
| 133 | 추가: for entry in entries() { | |
| 134 | 추가: self.event(Event::Entry(entry)); | |
| 135 | 추가: } | |
| 136 | 추가: self.event(Event::ListEnd { | |
| 137 | 추가: entry_count: 3, | |
| 138 | 추가: list_id: ListId { | |
| 139 | 추가: catalog_version: 1, | |
| 140 | 추가: format: Format::Zip, | |
| 141 | 추가: source_object: SourceObject::Unix { | |
| 142 | 추가: device: 1, | |
| 143 | 추가: inode: 1, | |
| 144 | 추가: }, | |
| 145 | 추가: archive_bytes: 902000, | |
| 146 | 추가: archive_sha256: [7; 32], | |
| 147 | 추가: }, | |
| 148 | 추가: }); | |
| 149 | 추가: self.finish(true); | |
| 150 | 추가: } | |
| 151 | 추가: Start::Extract { .. } => { | |
| 152 | 추가: if self.mode.starts_with("password") { | |
| 153 | 추가: self.event(Event::PasswordRequired { | |
| 154 | 추가: challenge_id: 17, | |
| 155 | 추가: attempt: if self.mode == "password-retry" { 2 } else { 1 }, | |
| 156 | 추가: encrypt: false, | |
| 157 | 추가: }); | |
| 158 | 추가: } else if self.mode.starts_with("progress") || self.mode == "cancelling" { | |
| 159 | 추가: self.event(Event::Progress { | |
| 160 | 추가: stage: Stage::Decode, | |
| 161 | 추가: processed: 38 << 20, | |
| 162 | 추가: total: (self.mode != "progress-unknown").then_some(61 << 20), | |
| 163 | 추가: completed_entries: 12, | |
| 164 | 추가: }); | |
| 165 | 추가: } else { | |
| 166 | 추가: self.finish(false); | |
| 167 | 추가: } | |
| 168 | 추가: } | |
| 169 | 추가: Start::CreateZip { | |
| 170 | 추가: output_file, | |
| 171 | 추가: aes256, | |
| 172 | 추가: .. | |
| 173 | 추가: } => { | |
| 174 | 추가: self.create_name = | |
| 175 | 추가: Some(output_file.file_name().unwrap().to_string_lossy().into()); | |
| 176 | 추가: if aes256 { | |
| 177 | 추가: self.event(Event::PasswordRequired { | |
| 178 | 추가: challenge_id: 17, | |
| 179 | 추가: attempt: 1, | |
| 180 | 추가: encrypt: true, | |
| 181 | 추가: }); | |
| 182 | 추가: } else { | |
| 183 | 추가: self.finish(false); | |
| 184 | 추가: } | |
| 185 | 추가: } | |
| 186 | 추가: } | |
| 187 | 추가: } | |
| 188 | 추가: Command::Password { .. } => self.finish(false), | |
| 189 | 추가: Command::Cancel => { | |
| 190 | 추가: self.event(Event::CancelAck { | |
| 191 | 추가: request_sequence: request.sequence, | |
| 192 | 추가: status: CancelStatus::Requested, | |
| 193 | 추가: }); | |
| 194 | 추가: if self.mode != "cancelling" { | |
| 195 | 추가: self.terminal(Terminal { | |
| 196 | 추가: outcome: Outcome::Cancelled, | |
| 197 | 추가: error: None, | |
| 198 | 추가: publication: Publication::None, | |
| 199 | 추가: created_count: 0, | |
| 200 | 추가: retained_partial_count: 0, | |
| 201 | 추가: durability: Durability::NotApplicable, | |
| 202 | 추가: cleanup: Cleanup::Complete, | |
| 203 | 추가: }); | |
| 204 | 추가: } | |
| 205 | 추가: } | |
| 206 | 추가: } | |
| 207 | 추가: Ok(()) | |
| 208 | 추가: } | |
| 209 | 추가: fn poll(&mut self) -> Option<HostEvent> { | |
| 210 | 추가: self.queue.pop_front() | |
| 211 | 추가: } | |
| 212 | 추가: } | |
| 213 | 추가: struct Capture { | |
| 214 | 추가: app: ArchiveApp, | |
| 215 | 추가: mode: String, | |
| 216 | 추가: factory: CaptureFactory, | |
| 217 | 추가: triggered: bool, | |
| 218 | 추가: } | |
| 219 | 추가: impl eframe::App for Capture { | |
| 220 | 추가: fn ui(&mut self, root: &mut egui::Ui, _: &mut eframe::Frame) { | |
| 221 | 추가: if self.mode == "hover" { | |
| 222 | 추가: root.ctx().input_mut(|i| { | |
| 223 | 추가: i.raw.hovered_files = vec![egui::HoveredFile { | |
| 224 | 추가: path: Some(PathBuf::from("여행.zip")), | |
| 225 | 추가: ..Default::default() | |
| 226 | 추가: }] | |
| 227 | 추가: }); | |
| 228 | 추가: } | |
| 229 | 추가: if !self.triggered && self.app.model.list_id.is_some() { | |
| 230 | 추가: self.triggered = true; | |
| 231 | 추가: if [ | |
| 232 | 추가: "password", | |
| 233 | 추가: "password-retry", | |
| 234 | 추가: "password-create", | |
| 235 | 추가: "progress", | |
| 236 | 추가: "progress-unknown", | |
| 237 | 추가: "cancelling", | |
| 238 | 추가: "success", | |
| 239 | 추가: "error", | |
| 240 | 추가: "cancelled", | |
| 241 | 추가: ] | |
| 242 | 추가: .contains(&self.mode.as_str()) | |
| 243 | 추가: { | |
| 244 | 추가: let archive = self.app.model.archive.clone().unwrap(); | |
| 245 | 추가: let start = if self.mode == "password-create" { | |
| 246 | 추가: Start::CreateZip { | |
| 247 | 추가: sources: vec![(archive.clone(), "자료".into())], | |
| 248 | 추가: output_file: archive.with_file_name("보호한 자료.zip"), | |
| 249 | 추가: method: Method::Deflate, | |
| 250 | 추가: aes256: true, | |
| 251 | 추가: } | |
| 252 | 추가: } else { | |
| 253 | 추가: Start::Extract { | |
| 254 | 추가: archive, | |
| 255 | 추가: destination: std::env::current_dir().unwrap(), | |
| 256 | 추가: selection: Selection::All, | |
| 257 | 추가: list_id: self.app.model.list_id.clone().unwrap(), | |
| 258 | 추가: gzip_output_name: None, | |
| 259 | 추가: } | |
| 260 | 추가: }; | |
| 261 | 추가: // 이전 화면과 같은 공개 상태 API로 암호 및 진행 상태를 재현함. | |
| 262 | 추가: if self.mode == "password-create" { | |
| 263 | 추가: self.app.model.begin(start, &mut self.factory); | |
| 264 | 추가: } else { | |
| 265 | 추가: self.app.begin_extract(); | |
| 266 | 추가: } | |
| 267 | 추가: } | |
| 268 | 추가: } | |
| 269 | 추가: self.app.show(root); | |
| 270 | 추가: root.ctx() | |
| 271 | 추가: .request_repaint_after(std::time::Duration::from_millis(30)); | |
| 272 | 추가: } | |
| 273 | 추가: } | |
| 274 | 추가: fn main() -> eframe::Result { | |
| 275 | 추가: let mode = std::env::args().nth(1).unwrap_or_else(|| "empty".into()); | |
| 276 | 추가: let base = std::env::current_dir() | |
| 277 | 추가: .unwrap() | |
| 278 | 추가: .join("tests/ui-redesign/runs/fixtures"); | |
| 279 | 추가: std::fs::create_dir_all(&base).unwrap(); | |
| 280 | 추가: std::fs::write(base.join("읽어주세요.txt"), "화면 검증 입력").unwrap(); | |
| 281 | 추가: std::fs::create_dir_all(base.join("사진")).unwrap(); | |
| 282 | 추가: let font = system_font::load().map_err(|e| eframe::Error::AppCreation(Box::new(e)))?; | |
| 283 | 추가: let title = format!("Zipelo UI capture {mode}"); | |
| 284 | 추가: renderer::run_native( | |
| 285 | 추가: &title, | |
| 286 | 추가: eframe::NativeOptions { | |
| 287 | 추가: viewport: egui::ViewportBuilder::default() | |
| 288 | 추가: .with_inner_size([1060.0, 720.0]) | |
| 289 | 추가: .with_min_inner_size([760.0, 540.0]), | |
| 290 | 추가: ..Default::default() | |
| 291 | 추가: }, | |
| 292 | 추가: || { | |
| 293 | 추가: let mode = mode.clone(); | |
| 294 | 추가: let base = base.clone(); | |
| 295 | 추가: let bytes = font.bytes.clone(); | |
| 296 | 추가: let face_index = font.face_index; | |
| 297 | 추가: Box::new(move |cc| { | |
| 298 | 추가: let mut fonts = FontDefinitions::empty(); | |
| 299 | 추가: let mut data = FontData::from_owned(bytes.clone()); | |
| 300 | 추가: data.index = face_index; | |
| 301 | 추가: fonts.font_data.insert("noto-kr".into(), data.into()); | |
| 302 | 추가: fonts | |
| 303 | 추가: .families | |
| 304 | 추가: .insert(FontFamily::Proportional, vec!["noto-kr".into()]); | |
| 305 | 추가: cc.egui_ctx.set_fonts(fonts); | |
| 306 | 추가: cc.egui_ctx.set_visuals(egui::Visuals::light()); | |
| 307 | 추가: cc.egui_ctx.style_mut_of(egui::Theme::Light, |style| { | |
| 308 | 추가: style | |
| 309 | 추가: .text_styles | |
| 310 | 추가: .insert(TextStyle::Body, FontId::proportional(18.0)); | |
| 311 | 추가: style | |
| 312 | 추가: .text_styles | |
| 313 | 추가: .insert(TextStyle::Button, FontId::proportional(18.0)); | |
| 314 | 추가: style | |
| 315 | 추가: .text_styles | |
| 316 | 추가: .insert(TextStyle::Heading, FontId::proportional(26.0)); | |
| 317 | 추가: }); | |
| 318 | 추가: let factory = CaptureFactory { mode: mode.clone() }; | |
| 319 | 추가: let startup = (!["empty", "hover", "create", "create-filled"] | |
| 320 | 추가: .contains(&mode.as_str())) | |
| 321 | 추가: .then(|| base.join("여행.zip")); | |
| 322 | 추가: let mut app = ArchiveApp::new(Box::new(factory.clone()), startup, true); | |
| 323 | 추가: if mode == "create-filled" { | |
| 324 | 추가: app.add_sources(vec![base.join("읽어주세요.txt"), base.join("사진")]); | |
| 325 | 추가: } | |
| 326 | 추가: Ok(Box::new(Capture { | |
| 327 | 추가: app, | |
| 328 | 추가: mode, | |
| 329 | 추가: factory, | |
| 330 | 추가: triggered: false, | |
| 331 | 추가: })) | |
| 332 | 추가: }) | |
| 333 | 추가: }, | |
| 334 | 추가: ) | |
| 335 | 추가: } |
| @@ -0,0 +1,762 @@ | ||
| 1 | 추가: use super::*; | |
| 2 | 추가: use std::{ | |
| 3 | 추가: collections::BTreeSet, | |
| 4 | 추가: fs, | |
| 5 | 추가: sync::atomic::{AtomicU64, Ordering}, | |
| 6 | 추가: }; | |
| 7 | 추가: use zipelo_ui_memory_app::archive_present::*; | |
| 8 | 추가: | |
| 9 | 추가: fn terminal() -> Terminal { | |
| 10 | 추가: Terminal { | |
| 11 | 추가: outcome: Outcome::Failed, | |
| 12 | 추가: error: Some(ErrorCode::Io), | |
| 13 | 추가: publication: Publication::Partial, | |
| 14 | 추가: created_count: 1, | |
| 15 | 추가: retained_partial_count: 0, | |
| 16 | 추가: durability: Durability::Synced, | |
| 17 | 추가: cleanup: Cleanup::Complete, | |
| 18 | 추가: } | |
| 19 | 추가: } | |
| 20 | 추가: fn targets() -> BTreeSet<String> { | |
| 21 | 추가: ["one.txt".into(), "two.txt".into()].into_iter().collect() | |
| 22 | 추가: } | |
| 23 | 추가: | |
| 24 | 추가: #[test] | |
| 25 | 추가: fn partial_extraction_requires_matching_file_reports() { | |
| 26 | 추가: let t = terminal(); | |
| 27 | 추가: assert_eq!( | |
| 28 | 추가: warnings( | |
| 29 | 추가: Some(&t), | |
| 30 | 추가: true, | |
| 31 | 추가: Some(&targets()), | |
| 32 | 추가: &[("one.txt".into(), Disposition::Created)] | |
| 33 | 추가: ), | |
| 34 | 추가: vec![PARTIAL] | |
| 35 | 추가: ); | |
| 36 | 추가: } | |
| 37 | 추가: #[test] | |
| 38 | 추가: fn all_saved_with_temporary_leftover_is_not_partial_extraction() { | |
| 39 | 추가: let mut t = terminal(); | |
| 40 | 추가: t.retained_partial_count = 1; | |
| 41 | 추가: t.cleanup = Cleanup::Failed; | |
| 42 | 추가: let files = ["one.txt".into()].into_iter().collect(); | |
| 43 | 추가: assert_eq!( | |
| 44 | 추가: warnings( | |
| 45 | 추가: Some(&t), | |
| 46 | 추가: true, | |
| 47 | 추가: Some(&files), | |
| 48 | 추가: &[ | |
| 49 | 추가: ("one.txt".into(), Disposition::Created), | |
| 50 | 추가: ("temp".into(), Disposition::PartialRetained) | |
| 51 | 추가: ] | |
| 52 | 추가: ), | |
| 53 | 추가: vec![LEFTOVERS] | |
| 54 | 추가: ); | |
| 55 | 추가: } | |
| 56 | 추가: #[test] | |
| 57 | 추가: fn leftover_without_file_reports_and_commit_uncertainty_are_unknown() { | |
| 58 | 추가: let mut t = terminal(); | |
| 59 | 추가: t.created_count = 0; | |
| 60 | 추가: t.retained_partial_count = 1; | |
| 61 | 추가: for outputs in [ | |
| 62 | 추가: vec![("temp".into(), Disposition::PartialRetained)], | |
| 63 | 추가: vec![("one.txt".into(), Disposition::CommitUncertain)], | |
| 64 | 추가: ] { | |
| 65 | 추가: assert!(warnings(Some(&t), true, Some(&targets()), &outputs).contains(&UNCERTAIN)); | |
| 66 | 추가: assert!(!warnings(Some(&t), true, Some(&targets()), &outputs).contains(&PARTIAL)); | |
| 67 | 추가: } | |
| 68 | 추가: } | |
| 69 | 추가: #[test] | |
| 70 | 추가: fn synchronization_and_cleanup_warnings_are_both_visible() { | |
| 71 | 추가: let mut t = terminal(); | |
| 72 | 추가: t.created_count = 0; | |
| 73 | 추가: t.durability = Durability::Unconfirmed; | |
| 74 | 추가: t.cleanup = Cleanup::Failed; | |
| 75 | 추가: let result = warnings(Some(&t), true, Some(&targets()), &[]); | |
| 76 | 추가: assert!(result.contains(&SYNC_WARNING)); | |
| 77 | 추가: assert!(result.contains(&CLEANUP_WARNING)); | |
| 78 | 추가: } | |
| 79 | 추가: #[test] | |
| 80 | 추가: fn missing_terminal_exit_or_contradictory_reports_never_claim_unsaved() { | |
| 81 | 추가: let mut t = terminal(); | |
| 82 | 추가: t.publication = Publication::None; | |
| 83 | 추가: t.created_count = 0; | |
| 84 | 추가: assert!(definitely_unsaved(Some(&t), true, &[])); | |
| 85 | 추가: assert!(!definitely_unsaved(None, true, &[])); | |
| 86 | 추가: assert!(!definitely_unsaved(Some(&t), false, &[])); | |
| 87 | 추가: let reports = [("one.txt".into(), Disposition::Created)]; | |
| 88 | 추가: assert!(!definitely_unsaved(Some(&t), true, &reports)); | |
| 89 | 추가: assert!(warnings(Some(&t), true, Some(&targets()), &reports).contains(&UNCERTAIN)); | |
| 90 | 추가: } | |
| 91 | 추가: #[test] | |
| 92 | 추가: fn unsafe_path_and_conflict_preserve_result_classification() { | |
| 93 | 추가: for code in [ErrorCode::UnsafePath, ErrorCode::Conflict] { | |
| 94 | 추가: let mut t = terminal(); | |
| 95 | 추가: t.error = Some(code); | |
| 96 | 추가: assert_eq!( | |
| 97 | 추가: warnings( | |
| 98 | 추가: Some(&t), | |
| 99 | 추가: true, | |
| 100 | 추가: Some(&targets()), | |
| 101 | 추가: &[("one.txt".into(), Disposition::Created)] | |
| 102 | 추가: ), | |
| 103 | 추가: vec![PARTIAL] | |
| 104 | 추가: ); | |
| 105 | 추가: t.publication = Publication::Uncertain; | |
| 106 | 추가: assert!(warnings(Some(&t), true, Some(&targets()), &[]).contains(&UNCERTAIN)); | |
| 107 | 추가: t.publication = Publication::None; | |
| 108 | 추가: t.created_count = 0; | |
| 109 | 추가: assert!(definitely_unsaved(Some(&t), true, &[])); | |
| 110 | 추가: } | |
| 111 | 추가: } | |
| 112 | 추가: #[test] | |
| 113 | 추가: fn every_error_and_stage_has_user_facing_text() { | |
| 114 | 추가: for code in [ | |
| 115 | 추가: ErrorCode::Integrity, | |
| 116 | 추가: ErrorCode::UnsupportedFormat, | |
| 117 | 추가: ErrorCode::UnsupportedFeature, | |
| 118 | 추가: ErrorCode::WrongPassword, | |
| 119 | 추가: ErrorCode::UnsafePath, | |
| 120 | 추가: ErrorCode::Conflict, | |
| 121 | 추가: ErrorCode::Limit, | |
| 122 | 추가: ErrorCode::Io, | |
| 123 | 추가: ErrorCode::DiskFull, | |
| 124 | 추가: ErrorCode::Protocol, | |
| 125 | 추가: ErrorCode::Internal, | |
| 126 | 추가: ErrorCode::SourceChanged, | |
| 127 | 추가: ErrorCode::InvalidRequest, | |
| 128 | 추가: ] { | |
| 129 | 추가: assert!(!error_text(code).is_empty()); | |
| 130 | 추가: assert!(!error_text(code).contains("작업자")); | |
| 131 | 추가: } | |
| 132 | 추가: assert_eq!(error_text(ErrorCode::Protocol), INTERNAL); | |
| 133 | 추가: assert_eq!(error_text(ErrorCode::Internal), INTERNAL); | |
| 134 | 추가: assert_eq!(progress_text(Stage::Decode, true), "압축하는 중"); | |
| 135 | 추가: assert_eq!(progress_text(Stage::Decode, false), "압축을 푸는 중"); | |
| 136 | 추가: } | |
| 137 | 추가: #[test] | |
| 138 | 추가: fn folder_selection_expands_only_matching_descendants() { | |
| 139 | 추가: let entries = vec![ | |
| 140 | 추가: Entry { | |
| 141 | 추가: id: 0, | |
| 142 | 추가: name: "docs".into(), | |
| 143 | 추가: kind: Kind::Directory, | |
| 144 | 추가: bytes: None, | |
| 145 | 추가: packed: None, | |
| 146 | 추가: encrypted: false, | |
| 147 | 추가: }, | |
| 148 | 추가: Entry { | |
| 149 | 추가: id: 1, | |
| 150 | 추가: name: "docs/one.txt".into(), | |
| 151 | 추가: kind: Kind::File, | |
| 152 | 추가: bytes: None, | |
| 153 | 추가: packed: None, | |
| 154 | 추가: encrypted: false, | |
| 155 | 추가: }, | |
| 156 | 추가: Entry { | |
| 157 | 추가: id: 2, | |
| 158 | 추가: name: "docs-old/two.txt".into(), | |
| 159 | 추가: kind: Kind::File, | |
| 160 | 추가: bytes: None, | |
| 161 | 추가: packed: None, | |
| 162 | 추가: encrypted: false, | |
| 163 | 추가: }, | |
| 164 | 추가: ]; | |
| 165 | 추가: assert_eq!( | |
| 166 | 추가: target_files(&entries, &[0].into_iter().collect(), true, None), | |
| 167 | 추가: Some(["docs/one.txt".into()].into_iter().collect()) | |
| 168 | 추가: ); | |
| 169 | 추가: } | |
| 170 | 추가: #[test] | |
| 171 | 추가: fn duplicate_names_prevent_file_completion_assumptions() { | |
| 172 | 추가: let entry = Entry { | |
| 173 | 추가: id: 0, | |
| 174 | 추가: name: "same.txt".into(), | |
| 175 | 추가: kind: Kind::File, | |
| 176 | 추가: bytes: None, | |
| 177 | 추가: packed: None, | |
| 178 | 추가: encrypted: false, | |
| 179 | 추가: }; | |
| 180 | 추가: assert!(target_files(&[entry.clone(), entry], &BTreeSet::new(), false, None).is_none()); | |
| 181 | 추가: assert_eq!( | |
| 182 | 추가: warnings(Some(&terminal()), true, None, &[]), | |
| 183 | 추가: vec![UNCERTAIN] | |
| 184 | 추가: ); | |
| 185 | 추가: } | |
| 186 | 추가: #[test] | |
| 187 | 추가: fn default_names_and_middle_truncation_preserve_unicode() { | |
| 188 | 추가: assert_eq!(default_destination(&path("자료.tar.gz")), path("자료")); | |
| 189 | 추가: assert_eq!(default_destination(&path("자료.zip")), path("자료")); | |
| 190 | 추가: assert_eq!(middle_text("가나다라마바사아자차", 7), "가나다…아자차"); | |
| 191 | 추가: assert_eq!(bytes_text(21), "21 B"); | |
| 192 | 추가: } | |
| 193 | 추가: | |
| 194 | 추가: static SCRATCH_ID: AtomicU64 = AtomicU64::new(0); | |
| 195 | 추가: pub(super) struct Folder(pub(super) PathBuf); | |
| 196 | 추가: impl Folder { | |
| 197 | 추가: pub(super) fn new() -> Self { | |
| 198 | 추가: let root = PathBuf::from(env!("CARGO_MANIFEST_DIR")).join("../../tests/rust-app-ui/runs"); | |
| 199 | 추가: fs::create_dir_all(&root).unwrap(); | |
| 200 | 추가: let path = root.join(format!( | |
| 201 | 추가: "presentation-{}-{}", | |
| 202 | 추가: std::process::id(), | |
| 203 | 추가: SCRATCH_ID.fetch_add(1, Ordering::Relaxed) | |
| 204 | 추가: )); | |
| 205 | 추가: fs::create_dir(&path).unwrap(); | |
| 206 | 추가: Self(path.canonicalize().unwrap()) | |
| 207 | 추가: } | |
| 208 | 추가: } | |
| 209 | 추가: impl Drop for Folder { | |
| 210 | 추가: fn drop(&mut self) { | |
| 211 | 추가: fs::remove_dir_all(&self.0).unwrap(); | |
| 212 | 추가: } | |
| 213 | 추가: } | |
| 214 | 추가: | |
| 215 | 추가: #[test] | |
| 216 | 추가: fn automatic_destination_creation_and_failure_are_distinct() { | |
| 217 | 추가: let scratch = Folder::new(); | |
| 218 | 추가: let output = scratch.0.join("output"); | |
| 219 | 추가: assert!(prepare_destination(&output, true).unwrap()); | |
| 220 | 추가: assert!(!prepare_destination(&output, true).unwrap()); | |
| 221 | 추가: assert!(prepare_destination(&scratch.0.join("missing/child"), true).is_err()); | |
| 222 | 추가: assert!(prepare_destination(&scratch.0.join("chosen-missing"), false).is_err()); | |
| 223 | 추가: let file = scratch.0.join("file"); | |
| 224 | 추가: fs::write(&file, "existing").unwrap(); | |
| 225 | 추가: assert!(prepare_destination(&file, true).is_err()); | |
| 226 | 추가: assert_eq!(fs::read_to_string(file).unwrap(), "existing"); | |
| 227 | 추가: } | |
| 228 | 추가: #[test] | |
| 229 | 추가: fn only_new_empty_output_is_removed_and_nonempty_is_preserved() { | |
| 230 | 추가: let scratch = Folder::new(); | |
| 231 | 추가: let empty = scratch.0.join("empty"); | |
| 232 | 추가: assert!(prepare_destination(&empty, true).unwrap()); | |
| 233 | 추가: remove_owned_empty(&empty); | |
| 234 | 추가: assert!(!empty.exists()); | |
| 235 | 추가: let nonempty = scratch.0.join("nonempty"); | |
| 236 | 추가: assert!(prepare_destination(&nonempty, true).unwrap()); | |
| 237 | 추가: fs::write(nonempty.join("existing"), "keep").unwrap(); | |
| 238 | 추가: remove_owned_empty(&nonempty); | |
| 239 | 추가: assert_eq!( | |
| 240 | 추가: fs::read_to_string(nonempty.join("existing")).unwrap(), | |
| 241 | 추가: "keep" | |
| 242 | 추가: ); | |
| 243 | 추가: assert!(!prepare_destination(&scratch.0, false).unwrap()); | |
| 244 | 추가: assert!(scratch.0.is_dir()); | |
| 245 | 추가: } | |
| 246 | 추가: #[cfg(unix)] | |
| 247 | 추가: #[test] | |
| 248 | 추가: fn browser_and_output_do_not_follow_symbolic_links() { | |
| 249 | 추가: let scratch = Folder::new(); | |
| 250 | 추가: let link = scratch.0.join("link"); | |
| 251 | 추가: std::os::unix::fs::symlink(&scratch.0, &link).unwrap(); | |
| 252 | 추가: let rows = directory_entries(&scratch.0).unwrap(); | |
| 253 | 추가: assert!(rows.iter().any(|entry| entry.link && entry.path == link)); | |
| 254 | 추가: assert!(directory_entries(&link).is_err()); | |
| 255 | 추가: assert!(prepare_destination(&link, true).is_err()); | |
| 256 | 추가: } | |
| 257 | 추가: | |
| 258 | 추가: #[cfg(feature = "ui")] | |
| 259 | 추가: mod widgets { | |
| 260 | 추가: use super::*; | |
| 261 | 추가: use eframe::egui::{self, epaint::Shape}; | |
| 262 | 추가: use zipelo_ui_memory_app::{ | |
| 263 | 추가: archive_picker::{Choice, Picker, Purpose}, | |
| 264 | 추가: archive_screen::ArchiveApp, | |
| 265 | 추가: }; | |
| 266 | 추가: | |
| 267 | 추가: fn labels(shapes: &[egui::epaint::ClippedShape]) -> Vec<(String, egui::Pos2)> { | |
| 268 | 추가: fn walk(shape: &Shape, result: &mut Vec<(String, egui::Pos2)>) { | |
| 269 | 추가: match shape { | |
| 270 | 추가: Shape::Text(text) => result.push(( | |
| 271 | 추가: text.galley.job.text.clone(), | |
| 272 | 추가: text.pos + text.galley.rect.size() / 2.0, | |
| 273 | 추가: )), | |
| 274 | 추가: Shape::Vec(shapes) => { | |
| 275 | 추가: for shape in shapes { | |
| 276 | 추가: walk(shape, result); | |
| 277 | 추가: } | |
| 278 | 추가: } | |
| 279 | 추가: _ => {} | |
| 280 | 추가: } | |
| 281 | 추가: } | |
| 282 | 추가: let mut result = Vec::new(); | |
| 283 | 추가: for shape in shapes { | |
| 284 | 추가: walk(&shape.shape, &mut result); | |
| 285 | 추가: } | |
| 286 | 추가: result | |
| 287 | 추가: } | |
| 288 | 추가: fn render( | |
| 289 | 추가: ctx: &egui::Context, | |
| 290 | 추가: app: &mut ArchiveApp, | |
| 291 | 추가: events: Vec<egui::Event>, | |
| 292 | 추가: ) -> Vec<(String, egui::Pos2)> { | |
| 293 | 추가: let mut output = ctx.run_ui( | |
| 294 | 추가: egui::RawInput { | |
| 295 | 추가: screen_rect: Some(egui::Rect::from_min_size( | |
| 296 | 추가: egui::Pos2::ZERO, | |
| 297 | 추가: egui::vec2(760.0, 540.0), | |
| 298 | 추가: )), | |
| 299 | 추가: events, | |
| 300 | 추가: ..Default::default() | |
| 301 | 추가: }, | |
| 302 | 추가: |ui| app.show(ui), | |
| 303 | 추가: ); | |
| 304 | 추가: output.textures_delta.clear(); | |
| 305 | 추가: labels(&output.shapes) | |
| 306 | 추가: } | |
| 307 | 추가: fn click(ctx: &egui::Context, app: &mut ArchiveApp, label: &str) { | |
| 308 | 추가: render(ctx, app, vec![]); | |
| 309 | 추가: let point = render(ctx, app, vec![]) | |
| 310 | 추가: .into_iter() | |
| 311 | 추가: .filter(|(text, _)| text == label) | |
| 312 | 추가: .max_by(|a, b| a.1.y.total_cmp(&b.1.y)) | |
| 313 | 추가: .unwrap_or_else(|| panic!("항목 없음: {label}")) | |
| 314 | 추가: .1; | |
| 315 | 추가: for pressed in [true, false] { | |
| 316 | 추가: render( | |
| 317 | 추가: ctx, | |
| 318 | 추가: app, | |
| 319 | 추가: vec![ | |
| 320 | 추가: egui::Event::PointerMoved(point), | |
| 321 | 추가: egui::Event::PointerButton { | |
| 322 | 추가: pos: point, | |
| 323 | 추가: button: egui::PointerButton::Primary, | |
| 324 | 추가: pressed, | |
| 325 | 추가: modifiers: egui::Modifiers::NONE, | |
| 326 | 추가: }, | |
| 327 | 추가: ], | |
| 328 | 추가: ); | |
| 329 | 추가: } | |
| 330 | 추가: } | |
| 331 | 추가: fn key(key: egui::Key) -> egui::Event { | |
| 332 | 추가: egui::Event::Key { | |
| 333 | 추가: key, | |
| 334 | 추가: physical_key: None, | |
| 335 | 추가: pressed: true, | |
| 336 | 추가: repeat: false, | |
| 337 | 추가: modifiers: egui::Modifiers::NONE, | |
| 338 | 추가: } | |
| 339 | 추가: } | |
| 340 | 추가: fn text(ctx: &egui::Context, app: &mut ArchiveApp, id: &str, value: &str) { | |
| 341 | 추가: ctx.memory_mut(|memory| memory.request_focus(egui::Id::unique(id))); | |
| 342 | 추가: render( | |
| 343 | 추가: ctx, | |
| 344 | 추가: app, | |
| 345 | 추가: vec![ | |
| 346 | 추가: egui::Event::Key { | |
| 347 | 추가: key: egui::Key::A, | |
| 348 | 추가: physical_key: None, | |
| 349 | 추가: pressed: true, | |
| 350 | 추가: repeat: false, | |
| 351 | 추가: modifiers: egui::Modifiers::COMMAND, | |
| 352 | 추가: }, | |
| 353 | 추가: egui::Event::Text(value.into()), | |
| 354 | 추가: ], | |
| 355 | 추가: ); | |
| 356 | 추가: } | |
| 357 | 추가: fn loaded(scratch: &Folder, factory: &FakeFactory) -> ArchiveApp { | |
| 358 | 추가: let mut app = ArchiveApp::new( | |
| 359 | 추가: Box::new(factory.clone()), | |
| 360 | 추가: Some(scratch.0.join("sample.zip")), | |
| 361 | 추가: false, | |
| 362 | 추가: ); | |
| 363 | 추가: pump(&mut app.model); | |
| 364 | 추가: app | |
| 365 | 추가: } | |
| 366 | 추가: #[test] | |
| 367 | 추가: fn empty_view_has_no_internal_status_and_keyboard_focus_is_reachable() { | |
| 368 | 추가: let ctx = egui::Context::default(); | |
| 369 | 추가: let mut app = ArchiveApp::new(Box::new(FakeFactory::default()), None, false); | |
| 370 | 추가: render(&ctx, &mut app, vec![]); | |
| 371 | 추가: let shown = render(&ctx, &mut app, vec![key(egui::Key::Tab)]); | |
| 372 | 추가: assert!( | |
| 373 | 추가: shown | |
| 374 | 추가: .iter() | |
| 375 | 추가: .any(|(text, _)| text == "압축파일을 여기에 끌어 놓으세요") | |
| 376 | 추가: ); | |
| 377 | 추가: assert!(!shown.iter().any(|(text, _)| text.contains("게시") | |
| 378 | 추가: || text.contains("동기화") | |
| 379 | 추가: || text.contains("시험 모드"))); | |
| 380 | 추가: assert!(ctx.memory(|memory| memory.focused().is_some())); | |
| 381 | 추가: app.model.request_close(); | |
| 382 | 추가: let closing = render(&ctx, &mut app, vec![]); | |
| 383 | 추가: assert!(!closing.iter().any(|(text, _)| text == UNCERTAIN)); | |
| 384 | 추가: } | |
| 385 | 추가: #[test] | |
| 386 | 추가: fn empty_selection_and_empty_zip_sources_do_not_start_work() { | |
| 387 | 추가: let scratch = Folder::new(); | |
| 388 | 추가: let ctx = egui::Context::default(); | |
| 389 | 추가: let factory = FakeFactory::default(); | |
| 390 | 추가: let mut app = loaded(&scratch, &factory); | |
| 391 | 추가: render(&ctx, &mut app, vec![]); | |
| 392 | 추가: click(&ctx, &mut app, "선택한 항목만 풀기"); | |
| 393 | 추가: click(&ctx, &mut app, "풀기"); | |
| 394 | 추가: assert_eq!(factory.state.borrow().starts.len(), 1); | |
| 395 | 추가: click(&ctx, &mut app, "ZIP 만들기"); | |
| 396 | 추가: click(&ctx, &mut app, "만들기"); | |
| 397 | 추가: assert_eq!(factory.state.borrow().starts.len(), 1); | |
| 398 | 추가: assert!(!app.model.busy()); | |
| 399 | 추가: } | |
| 400 | 추가: #[test] | |
| 401 | 추가: fn destination_failure_sends_no_request_and_explains_folder_change() { | |
| 402 | 추가: let scratch = Folder::new(); | |
| 403 | 추가: let factory = FakeFactory::default(); | |
| 404 | 추가: let mut app = loaded(&scratch, &factory); | |
| 405 | 추가: let file = scratch.0.join("existing.txt"); | |
| 406 | 추가: fs::write(&file, "preserve").unwrap(); | |
| 407 | 추가: app.choose_destination(file.clone()); | |
| 408 | 추가: assert!(!app.begin_extract()); | |
| 409 | 추가: assert_eq!(factory.state.borrow().starts.len(), 1); | |
| 410 | 추가: let ctx = egui::Context::default(); | |
| 411 | 추가: render(&ctx, &mut app, vec![]); | |
| 412 | 추가: assert!( | |
| 413 | 추가: render(&ctx, &mut app, vec![]) | |
| 414 | 추가: .iter() | |
| 415 | 추가: .any(|(text, _)| text == FOLDER_ERROR) | |
| 416 | 추가: ); | |
| 417 | 추가: assert_eq!(fs::read_to_string(file).unwrap(), "preserve"); | |
| 418 | 추가: } | |
| 419 | 추가: #[test] | |
| 420 | 추가: fn cancelling_removes_only_automatically_created_empty_folder() { | |
| 421 | 추가: for case in ["automatic-empty", "automatic-nonempty", "chosen-empty"] { | |
| 422 | 추가: let scratch = Folder::new(); | |
| 423 | 추가: let factory = FakeFactory::default(); | |
| 424 | 추가: let mut app = loaded(&scratch, &factory); | |
| 425 | 추가: factory.state.borrow_mut().manual = true; | |
| 426 | 추가: let destination = if case == "chosen-empty" { | |
| 427 | 추가: let path = scratch.0.join("chosen"); | |
| 428 | 추가: fs::create_dir(&path).unwrap(); | |
| 429 | 추가: app.choose_destination(path.clone()); | |
| 430 | 추가: path | |
| 431 | 추가: } else { | |
| 432 | 추가: scratch.0.join("sample") | |
| 433 | 추가: }; | |
| 434 | 추가: assert!(app.begin_extract()); | |
| 435 | 추가: if case == "automatic-nonempty" { | |
| 436 | 추가: fs::write(destination.join("preserve"), "keep").unwrap(); | |
| 437 | 추가: } | |
| 438 | 추가: { | |
| 439 | 추가: let mut state = factory.state.borrow_mut(); | |
| 440 | 추가: state.frame(Event::Accepted { encryption: true }); | |
| 441 | 추가: state.finish(Outcome::Cancelled, Publication::None); | |
| 442 | 추가: } | |
| 443 | 추가: let ctx = egui::Context::default(); | |
| 444 | 추가: for _ in 0..30 { | |
| 445 | 추가: render(&ctx, &mut app, vec![]); | |
| 446 | 추가: } | |
| 447 | 추가: assert!(!app.model.busy()); | |
| 448 | 추가: assert_eq!(destination.exists(), case != "automatic-empty"); | |
| 449 | 추가: } | |
| 450 | 추가: } | |
| 451 | 추가: #[test] | |
| 452 | 추가: fn password_confirmation_requires_match_and_enter_sends_once() { | |
| 453 | 추가: let scratch = Folder::new(); | |
| 454 | 추가: let factory = FakeFactory::manual(); | |
| 455 | 추가: let mut app = ArchiveApp::new(Box::new(factory.clone()), None, false); | |
| 456 | 추가: assert!(app.model.begin( | |
| 457 | 추가: Start::CreateZip { | |
| 458 | 추가: sources: vec![(scratch.0.join("source"), "source".into())], | |
| 459 | 추가: output_file: scratch.0.join("new.zip"), | |
| 460 | 추가: method: Method::Deflate, | |
| 461 | 추가: aes256: true | |
| 462 | 추가: }, | |
| 463 | 추가: &mut factory.clone() | |
| 464 | 추가: )); | |
| 465 | 추가: { | |
| 466 | 추가: let mut state = factory.state.borrow_mut(); | |
| 467 | 추가: state.frame(Event::Accepted { encryption: true }); | |
| 468 | 추가: state.frame(Event::PasswordRequired { | |
| 469 | 추가: challenge_id: 17, | |
| 470 | 추가: attempt: 1, | |
| 471 | 추가: encrypt: true, | |
| 472 | 추가: }); | |
| 473 | 추가: } | |
| 474 | 추가: let ctx = egui::Context::default(); | |
| 475 | 추가: for _ in 0..12 { | |
| 476 | 추가: render(&ctx, &mut app, vec![]); | |
| 477 | 추가: } | |
| 478 | 추가: assert_eq!( | |
| 479 | 추가: ctx.memory(|memory| memory.focused()), | |
| 480 | 추가: Some(egui::Id::unique("archive-password-input")) | |
| 481 | 추가: ); | |
| 482 | 추가: text(&ctx, &mut app, "archive-password-input", "fixture-secret"); | |
| 483 | 추가: text(&ctx, &mut app, "archive-password-confirm", "different"); | |
| 484 | 추가: click(&ctx, &mut app, "확인"); | |
| 485 | 추가: assert!(!factory.state.borrow().password_seen); | |
| 486 | 추가: text(&ctx, &mut app, "archive-password-confirm", "fixture-secret"); | |
| 487 | 추가: let shown = render(&ctx, &mut app, vec![key(egui::Key::Enter)]); | |
| 488 | 추가: assert!( | |
| 489 | 추가: !shown | |
| 490 | 추가: .iter() | |
| 491 | 추가: .any(|(text, _)| text.contains("fixture-secret")) | |
| 492 | 추가: ); | |
| 493 | 추가: assert!(factory.state.borrow().password_seen); | |
| 494 | 추가: assert!(app.model.challenge.is_none()); | |
| 495 | 추가: } | |
| 496 | 추가: #[test] | |
| 497 | 추가: fn picker_fits_minimum_window_and_opens_selected_file_with_enter() { | |
| 498 | 추가: let scratch = Folder::new(); | |
| 499 | 추가: let file = scratch.0.join("one.zip"); | |
| 500 | 추가: fs::write(&file, "fixture").unwrap(); | |
| 501 | 추가: let ctx = egui::Context::default(); | |
| 502 | 추가: let mut picker = Picker::new(Purpose::Open, &scratch.0); | |
| 503 | 추가: let mut result = None; | |
| 504 | 추가: let mut draw = |events| { | |
| 505 | 추가: let mut output = ctx.run_ui( | |
| 506 | 추가: egui::RawInput { | |
| 507 | 추가: screen_rect: Some(egui::Rect::from_min_size( | |
| 508 | 추가: egui::Pos2::ZERO, | |
| 509 | 추가: egui::vec2(760.0, 540.0), | |
| 510 | 추가: )), | |
| 511 | 추가: events, | |
| 512 | 추가: ..Default::default() | |
| 513 | 추가: }, | |
| 514 | 추가: |_ui| { | |
| 515 | 추가: result = picker.show(&ctx); | |
| 516 | 추가: }, | |
| 517 | 추가: ); | |
| 518 | 추가: output.textures_delta.clear(); | |
| 519 | 추가: labels(&output.shapes) | |
| 520 | 추가: }; | |
| 521 | 추가: draw(vec![]); | |
| 522 | 추가: let shown = draw(vec![]); | |
| 523 | 추가: for label in ["파일 열기", "열기", "홈"] { | |
| 524 | 추가: let (_, point) = shown.iter().find(|(text, _)| text == label).unwrap(); | |
| 525 | 추가: assert!((0.0..540.0).contains(&point.y), "{label}: {point:?}"); | |
| 526 | 추가: } | |
| 527 | 추가: let cancel = shown.iter().find(|(text, _)| text == "취소").unwrap().1; | |
| 528 | 추가: let confirm = shown.iter().find(|(text, _)| text == "열기").unwrap().1; | |
| 529 | 추가: assert!(cancel.x < confirm.x); | |
| 530 | 추가: let point = shown.iter().find(|(text, _)| text == "one.zip").unwrap().1; | |
| 531 | 추가: for pressed in [true, false] { | |
| 532 | 추가: draw(vec![ | |
| 533 | 추가: egui::Event::PointerMoved(point), | |
| 534 | 추가: egui::Event::PointerButton { | |
| 535 | 추가: pos: point, | |
| 536 | 추가: button: egui::PointerButton::Primary, | |
| 537 | 추가: pressed, | |
| 538 | 추가: modifiers: egui::Modifiers::NONE, | |
| 539 | 추가: }, | |
| 540 | 추가: ]); | |
| 541 | 추가: } | |
| 542 | 추가: draw(vec![key(egui::Key::Enter)]); | |
| 543 | 추가: assert!(matches!(result, Some(Choice::Paths(ref paths)) if paths == &vec![file])); | |
| 544 | 추가: } | |
| 545 | 추가: } | |
| 546 | 추가: | |
| 547 | 추가: #[cfg(feature = "ui")] | |
| 548 | 추가: #[test] | |
| 549 | 추가: fn conflict_retry_waits_for_folder_choice_and_preserves_selection() { | |
| 550 | 추가: use eframe::egui; | |
| 551 | 추가: use zipelo_ui_memory_app::archive_screen::ArchiveApp; | |
| 552 | 추가: let scratch = Folder::new(); | |
| 553 | 추가: let factory = FakeFactory::default(); | |
| 554 | 추가: let mut app = ArchiveApp::new( | |
| 555 | 추가: Box::new(factory.clone()), | |
| 556 | 추가: Some(scratch.0.join("sample.zip")), | |
| 557 | 추가: false, | |
| 558 | 추가: ); | |
| 559 | 추가: pump(&mut app.model); | |
| 560 | 추가: app.model.selected.insert(0); | |
| 561 | 추가: factory.state.borrow_mut().manual = true; | |
| 562 | 추가: let ctx = egui::Context::default(); | |
| 563 | 추가: let render = |app: &mut ArchiveApp, events| { | |
| 564 | 추가: let mut output = ctx.run_ui( | |
| 565 | 추가: egui::RawInput { | |
| 566 | 추가: screen_rect: Some(egui::Rect::from_min_size( | |
| 567 | 추가: egui::Pos2::ZERO, | |
| 568 | 추가: egui::vec2(760.0, 540.0), | |
| 569 | 추가: )), | |
| 570 | 추가: events, | |
| 571 | 추가: ..Default::default() | |
| 572 | 추가: }, | |
| 573 | 추가: |ui| app.show(ui), | |
| 574 | 추가: ); | |
| 575 | 추가: output.textures_delta.clear(); | |
| 576 | 추가: fn walk(shape: &egui::epaint::Shape, labels: &mut Vec<(String, egui::Pos2)>) { | |
| 577 | 추가: match shape { | |
| 578 | 추가: egui::epaint::Shape::Text(text) => labels.push(( | |
| 579 | 추가: text.galley.job.text.clone(), | |
| 580 | 추가: text.pos + text.galley.rect.size() / 2.0, | |
| 581 | 추가: )), | |
| 582 | 추가: egui::epaint::Shape::Vec(shapes) => { | |
| 583 | 추가: for shape in shapes { | |
| 584 | 추가: walk(shape, labels); | |
| 585 | 추가: } | |
| 586 | 추가: } | |
| 587 | 추가: _ => {} | |
| 588 | 추가: } | |
| 589 | 추가: } | |
| 590 | 추가: let mut labels = Vec::new(); | |
| 591 | 추가: for shape in &output.shapes { | |
| 592 | 추가: walk(&shape.shape, &mut labels); | |
| 593 | 추가: } | |
| 594 | 추가: labels | |
| 595 | 추가: }; | |
| 596 | 추가: let click = |app: &mut ArchiveApp, text: &str| { | |
| 597 | 추가: render(app, vec![]); | |
| 598 | 추가: let point = render(app, vec![]) | |
| 599 | 추가: .into_iter() | |
| 600 | 추가: .filter(|(value, _)| value == text) | |
| 601 | 추가: .max_by(|a, b| a.1.y.total_cmp(&b.1.y)) | |
| 602 | 추가: .unwrap_or_else(|| panic!("항목 없음: {text}")) | |
| 603 | 추가: .1; | |
| 604 | 추가: for pressed in [true, false] { | |
| 605 | 추가: render( | |
| 606 | 추가: app, | |
| 607 | 추가: vec![ | |
| 608 | 추가: egui::Event::PointerMoved(point), | |
| 609 | 추가: egui::Event::PointerButton { | |
| 610 | 추가: pos: point, | |
| 611 | 추가: button: egui::PointerButton::Primary, | |
| 612 | 추가: pressed, | |
| 613 | 추가: modifiers: egui::Modifiers::NONE, | |
| 614 | 추가: }, | |
| 615 | 추가: ], | |
| 616 | 추가: ); | |
| 617 | 추가: } | |
| 618 | 추가: }; | |
| 619 | 추가: render(&mut app, vec![]); | |
| 620 | 추가: click(&mut app, "선택한 항목만 풀기"); | |
| 621 | 추가: assert!(app.begin_extract()); | |
| 622 | 추가: let old = scratch.0.join("sample"); | |
| 623 | 추가: fs::write(old.join("existing"), "preserve").unwrap(); | |
| 624 | 추가: let chosen = scratch.0.join("chosen"); | |
| 625 | 추가: fs::create_dir(&chosen).unwrap(); | |
| 626 | 추가: { | |
| 627 | 추가: let mut state = factory.state.borrow_mut(); | |
| 628 | 추가: state.frame(Event::Accepted { encryption: true }); | |
| 629 | 추가: state.frame(Event::Terminal(Terminal { | |
| 630 | 추가: outcome: Outcome::Failed, | |
| 631 | 추가: error: Some(ErrorCode::Conflict), | |
| 632 | 추가: publication: Publication::None, | |
| 633 | 추가: created_count: 0, | |
| 634 | 추가: retained_partial_count: 0, | |
| 635 | 추가: durability: Durability::NotApplicable, | |
| 636 | 추가: cleanup: Cleanup::Complete, | |
| 637 | 추가: })); | |
| 638 | 추가: state.queue.extend([ | |
| 639 | 추가: HostEvent::StdoutEof, | |
| 640 | 추가: HostEvent::StderrEof, | |
| 641 | 추가: HostEvent::Exited { success: true }, | |
| 642 | 추가: ]); | |
| 643 | 추가: } | |
| 644 | 추가: for _ in 0..30 { | |
| 645 | 추가: render(&mut app, vec![]); | |
| 646 | 추가: } | |
| 647 | 추가: assert_eq!(factory.state.borrow().starts.len(), 2); | |
| 648 | 추가: click(&mut app, "다른 폴더에 풀기"); | |
| 649 | 추가: assert_eq!(factory.state.borrow().starts.len(), 2); | |
| 650 | 추가: click(&mut app, "상위 폴더"); | |
| 651 | 추가: click(&mut app, "chosen"); | |
| 652 | 추가: click(&mut app, "이 폴더 선택"); | |
| 653 | 추가: assert!(matches!(factory.state.borrow().starts.last(), | |
| 654 | 추가: Some(Start::Extract { destination, selection: Selection::EntryIds(ids), .. }) | |
| 655 | 추가: if destination == &chosen && ids == &vec![0])); | |
| 656 | 추가: assert_eq!( | |
| 657 | 추가: fs::read_to_string(old.join("existing")).unwrap(), | |
| 658 | 추가: "preserve" | |
| 659 | 추가: ); | |
| 660 | 추가: } | |
| 661 | 추가: | |
| 662 | 추가: #[cfg(feature = "ui")] | |
| 663 | 추가: #[test] | |
| 664 | 추가: fn create_dialog_keeps_title_and_actions_visible_after_resize() { | |
| 665 | 추가: use eframe::egui::{self, epaint::Shape}; | |
| 666 | 추가: use zipelo_ui_memory_app::archive_screen::ArchiveApp; | |
| 667 | 추가: let scratch = Folder::new(); | |
| 668 | 추가: let mut app = ArchiveApp::new(Box::new(FakeFactory::default()), None, false); | |
| 669 | 추가: app.add_sources(vec![scratch.0.join("one.txt"), scratch.0.join("photos")]); | |
| 670 | 추가: let ctx = egui::Context::default(); | |
| 671 | 추가: for size in [egui::vec2(1060.0, 720.0), egui::vec2(760.0, 540.0)] { | |
| 672 | 추가: let mut texts = Vec::new(); | |
| 673 | 추가: for _ in 0..8 { | |
| 674 | 추가: let mut output = ctx.run_ui( | |
| 675 | 추가: egui::RawInput { | |
| 676 | 추가: screen_rect: Some(egui::Rect::from_min_size(egui::Pos2::ZERO, size)), | |
| 677 | 추가: ..Default::default() | |
| 678 | 추가: }, | |
| 679 | 추가: |ui| app.show(ui), | |
| 680 | 추가: ); | |
| 681 | 추가: output.textures_delta.clear(); | |
| 682 | 추가: fn walk(shape: &Shape, output: &mut Vec<(String, egui::Pos2)>) { | |
| 683 | 추가: match shape { | |
| 684 | 추가: Shape::Text(text) => output.push(( | |
| 685 | 추가: text.galley.job.text.clone(), | |
| 686 | 추가: text.pos + text.galley.rect.size() / 2.0, | |
| 687 | 추가: )), | |
| 688 | 추가: Shape::Vec(shapes) => { | |
| 689 | 추가: for shape in shapes { | |
| 690 | 추가: walk(shape, output); | |
| 691 | 추가: } | |
| 692 | 추가: } | |
| 693 | 추가: _ => {} | |
| 694 | 추가: } | |
| 695 | 추가: } | |
| 696 | 추가: texts.clear(); | |
| 697 | 추가: for shape in &output.shapes { | |
| 698 | 추가: walk(&shape.shape, &mut texts); | |
| 699 | 추가: } | |
| 700 | 추가: } | |
| 701 | 추가: for label in ["ZIP 만들기", "만들기", "취소"] { | |
| 702 | 추가: let positions = texts | |
| 703 | 추가: .iter() | |
| 704 | 추가: .filter(|(text, _)| text == label) | |
| 705 | 추가: .map(|(_, p)| p) | |
| 706 | 추가: .collect::<Vec<_>>(); | |
| 707 | 추가: assert!(!positions.is_empty(), "{label}"); | |
| 708 | 추가: assert!( | |
| 709 | 추가: positions.iter().all(|p| p.y >= 0.0 && p.y <= size.y), | |
| 710 | 추가: "{label}: {positions:?}" | |
| 711 | 추가: ); | |
| 712 | 추가: } | |
| 713 | 추가: } | |
| 714 | 추가: } | |
| 715 | 추가: #[test] | |
| 716 | 추가: fn folder_open_command_preserves_shell_characters_as_one_argument() { | |
| 717 | 추가: let path = path("한글 폴더 ; $(touch unexpected)"); | |
| 718 | 추가: let command = folder_command(&path); | |
| 719 | 추가: assert_eq!( | |
| 720 | 추가: command.get_program(), | |
| 721 | 추가: if cfg!(windows) { | |
| 722 | 추가: "explorer" | |
| 723 | 추가: } else { | |
| 724 | 추가: "xdg-open" | |
| 725 | 추가: } | |
| 726 | 추가: ); | |
| 727 | 추가: assert_eq!( | |
| 728 | 추가: command.get_args().collect::<Vec<_>>(), | |
| 729 | 추가: vec![path.as_os_str()] | |
| 730 | 추가: ); | |
| 731 | 추가: } | |
| 732 | 추가: | |
| 733 | 추가: #[test] | |
| 734 | 추가: fn late_cancel_and_terminal_wait_use_finishing_text() { | |
| 735 | 추가: let mut model = Model::default(); | |
| 736 | 추가: model.progress = Some((Stage::Decode, 1, Some(2), 0)); | |
| 737 | 추가: assert_eq!(activity_text(&model, false), "압축을 푸는 중"); | |
| 738 | 추가: model.cancel = Some(CancelStatus::Requested); | |
| 739 | 추가: assert_eq!(activity_text(&model, false), "취소하는 중..."); | |
| 740 | 추가: for state in [CancelStatus::TooLate, CancelStatus::Finished] { | |
| 741 | 추가: model.cancel = Some(state); | |
| 742 | 추가: assert_eq!(activity_text(&model, false), "마무리하는 중"); | |
| 743 | 추가: } | |
| 744 | 추가: model.cancel = Some(CancelStatus::Requested); | |
| 745 | 추가: model.terminal = Some(terminal()); | |
| 746 | 추가: assert_eq!(activity_text(&model, false), "마무리하는 중"); | |
| 747 | 추가: } | |
| 748 | 추가: #[test] | |
| 749 | 추가: fn client_protocol_errors_hide_internal_terms_but_preserve_exit_uncertainty() { | |
| 750 | 추가: for error in [ | |
| 751 | 추가: "작업 ID 한도에 도달했습니다", | |
| 752 | 추가: "작업자 응답 순서나 작업 ID가 일치하지 않습니다", | |
| 753 | 추가: "작업 승인 응답이 없습니다", | |
| 754 | 추가: "출력 보고 한도 초과", | |
| 755 | 추가: ] { | |
| 756 | 추가: assert_eq!(client_error_text(error), INTERNAL); | |
| 757 | 추가: } | |
| 758 | 추가: assert_eq!( | |
| 759 | 추가: client_error_text("작업자 종료 결과를 확인할 수 없습니다. 출력 상태를 확인하세요"), | |
| 760 | 추가: UNCONFIRMED_FINISH | |
| 761 | 추가: ); | |
| 762 | 추가: } |
| @@ -413,7 +413,7 @@ fn renders_every_flow_with_actual_egui_widgets() { | ||
| 413 | 413 | 1060.0, |
| 414 | 414 | ); |
| 415 | 415 | let create = render(&mut app, vec![], 1060.0); |
| 416 | 삭제: assert!(create.iter().any(|(t, _)| t == "저장할 ZIP 절대 경로")); | |
| 416 | 추가: assert!(create.iter().any(|(t, _)| t == "2. 저장 위치")); | |
| 417 | 417 | let mut app = ArchiveApp::new(Box::new(f.clone()), Some(path("locked.zip")), true); |
| 418 | 418 | for _ in 0..8 { |
| 419 | 419 | app.model.poll(); |
| @@ -422,7 +422,7 @@ fn renders_every_flow_with_actual_egui_widgets() { | ||
| 422 | 422 | render(&mut app, vec![], width); |
| 423 | 423 | render(&mut app, vec![], width); |
| 424 | 424 | let password = render(&mut app, vec![], width); |
| 425 | 삭제: assert!(password.iter().any(|(t, _)| t.contains("암호 전달"))); | |
| 425 | 추가: assert!(password.iter().any(|(t, _)| t == "암호가 필요합니다")); | |
| 426 | 426 | } |
| 427 | 427 | assert!(app.model.password("synthetic secret".into())); |
| 428 | 428 | pump(&mut app.model); |
| @@ -644,29 +644,31 @@ fn extract_button_sends_gzip_name_only_for_raw_gzip() { | ||
| 644 | 644 | }], |
| 645 | 645 | ); |
| 646 | 646 | }; |
| 647 | 추가: let scratch = presentation::Folder::new(); | |
| 648 | 추가: app.choose_destination(scratch.0.clone()); | |
| 647 | 649 | 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 | 650 | if format == Format::Gzip { |
| 662 | 삭제: let texts = render(&mut app, vec![]); | |
| 663 | 삭제: let name = texts | |
| 664 | 삭제: .iter() | |
| 665 | 삭제: .find(|(text, _)| text == "출력 파일명") | |
| 651 | 추가: render(&mut app, vec![]); | |
| 652 | 추가: let input = ctx | |
| 653 | 추가: .read_response(egui::Id::unique("gzip-name")) | |
| 666 | 654 | .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())]); | |
| 655 | 추가: .rect | |
| 656 | 추가: .center(); | |
| 657 | 추가: click(&mut app, input); | |
| 658 | 추가: ctx.memory_mut(|memory| memory.request_focus(egui::Id::unique("gzip-name"))); | |
| 659 | 추가: render( | |
| 660 | 추가: &mut app, | |
| 661 | 추가: vec![ | |
| 662 | 추가: egui::Event::Key { | |
| 663 | 추가: key: egui::Key::A, | |
| 664 | 추가: physical_key: None, | |
| 665 | 추가: pressed: true, | |
| 666 | 추가: repeat: false, | |
| 667 | 추가: modifiers: egui::Modifiers::COMMAND, | |
| 668 | 추가: }, | |
| 669 | 추가: egui::Event::Text("plain.txt".into()), | |
| 670 | 추가: ], | |
| 671 | 추가: ); | |
| 670 | 672 | } |
| 671 | 673 | let texts = render(&mut app, vec![]); |
| 672 | 674 | let button = texts.iter().find(|(text, _)| text == "풀기").unwrap().1; |
| @@ -846,3 +848,5 @@ fn password_validation_and_retry_do_not_erase_transport_failure() { | ||
| 846 | 848 | assert_eq!(model.error.as_deref(), Some("pipe error")); |
| 847 | 849 | assert!(!model.confirmed); |
| 848 | 850 | } |
| 851 | 추가: | |
| 852 | 추가: mod presentation; |
| @@ -0,0 +1,32 @@ | ||
| 1 | 추가: # Zipelo 화면 회귀 확인 | |
| 2 | 추가: | |
| 3 | 추가: 설계 기준은 docs/ui-design-v0.1.md의 수용 기준 23개이며, 비교 기준 커밋은 b10c7eedddd202f83766aa8f001142cdfdb4097c임. | |
| 4 | 추가: | |
| 5 | 추가: ## 기능 시험 | |
| 6 | 추가: | |
| 7 | 추가: 프로젝트 루트에서 실행함. | |
| 8 | 추가: | |
| 9 | 추가: ```sh | |
| 10 | 추가: python3 tests/ci/run_rust.py local | |
| 11 | 추가: ``` | |
| 12 | 추가: | |
| 13 | 추가: tests/rust-app-ui/presentation.rs에서 결과 안내, 오류 문구, 폴더 생성과 정리, 선택창, 암호 확인, 키보드 입력과 최소 크기를 검증함. tests/rust-app-real-worker/flows.rs와 password_flows.rs는 실제 작업자를 사용해 파일 생성과 재해제, 암호 재입력 및 취소 후 파일 보존을 검증함. | |
| 14 | 추가: | |
| 15 | 추가: ## 전후 화면 재현 | |
| 16 | 추가: | |
| 17 | 추가: Linux의 Xvfb, xdotool, ImageMagick import와 시스템 CJK 글꼴이 필요함. 제품 의존성은 추가하지 않음. 실행 파일 준비는 로컬 Git 객체와 기존 Cargo 오프라인 캐시를 사용함. 기존 산출물은 지우지 않으며 새 output 폴더를 지정함. | |
| 18 | 추가: | |
| 19 | 추가: ```sh | |
| 20 | 추가: python3 tests/ui-redesign/prepare.py --output tests/ui-redesign/runs/reproduce --target-dir tests/ui-redesign/runs/target | |
| 21 | 추가: python3 tests/ui-redesign/capture.py --binary tests/ui-redesign/runs/reproduce/before-capture --variant before | |
| 22 | 추가: python3 tests/ui-redesign/capture.py --binary tests/ui-redesign/runs/reproduce/after-capture --variant after | |
| 23 | 추가: python3 tests/ui-redesign/capture.py --binary tests/ui-redesign/runs/reproduce/after-capture --variant after --width 760 --height 540 --output tests/ui-redesign/screenshots/minimum | |
| 24 | 추가: ``` | |
| 25 | 추가: | |
| 26 | 추가: 촬영기는 전용 Xvfb를 만들고 X11을 지정하며 종료 시 자신이 만든 창과 서버만 종료함. 결과는 screenshots/before, screenshots/after, screenshots/minimum에 저장함. 15개 상태를 각각 촬영하며 capture.json에 크기와 경로를 기록함. | |
| 27 | 추가: | |
| 28 | 추가: 촬영 화면은 tests/rust-app-ui/capture.rs의 합성 입력임. 글꼴과 eframe 렌더러 및 실제 화면 컴포넌트를 사용하고 "화면 시험 모드"를 표시함. 암호 불일치 화면에는 고정된 시험 문자열만 입력함. 합성 작업자는 실제 압축 파일을 읽거나 결과 파일을 저장하지 않으며, 기본 풀 위치 생성은 tests/ui-redesign/runs/fixtures 아래에서 확인함. 실제 파일 작업 검증은 별도의 real_worker 시험 결과와 구분함. | |
| 29 | 추가: | |
| 30 | 추가: 기준 화면 준비 시 같은 촬영 도우미를 기준 커밋 소스에 넣고, 새 화면 전용 메서드 두 곳만 기존 공개 모델 호출로 바꿈. 기준 제품 소스는 바꾸지 않음. --states 옵션으로 일부 상태만 다시 촬영할 수 있으며 다른 상태의 기록은 보존함. | |
| 31 | 추가: | |
| 32 | 추가: 최소 크기에서 ZIP 만들기 본문은 내부 스크롤로 모든 설정에 접근함. 주 버튼과 취소 버튼은 본문 스크롤 밖에 고정함. 폴더 열기는 셸 없이 운영체제 명령에 경로 하나를 인자로 전달하며, 특수 문자가 있는 경로도 시험함. Windows 실제 화면과 운영체제 파일 탐색기 실행 확인은 이 Linux 촬영 기록에 포함하지 않음. |
| @@ -0,0 +1,130 @@ | ||
| 1 | 추가: """격리한 Xvfb에서 상태별 실제 창을 촬영함.""" | |
| 2 | 추가: | |
| 3 | 추가: import argparse | |
| 4 | 추가: import json | |
| 5 | 추가: import os | |
| 6 | 추가: from pathlib import Path | |
| 7 | 추가: import subprocess | |
| 8 | 추가: import time | |
| 9 | 추가: | |
| 10 | 추가: ROOT = Path(__file__).resolve().parents[2] | |
| 11 | 추가: | |
| 12 | 추가: | |
| 13 | 추가: def command(args, environment, **kwargs): | |
| 14 | 추가: return subprocess.run(args, env=environment, check=True, **kwargs) | |
| 15 | 추가: | |
| 16 | 추가: | |
| 17 | 추가: def stop(process): | |
| 18 | 추가: process.terminate() | |
| 19 | 추가: try: | |
| 20 | 추가: process.wait(timeout=3) | |
| 21 | 추가: except subprocess.TimeoutExpired: | |
| 22 | 추가: process.kill() | |
| 23 | 추가: process.wait() | |
| 24 | 추가: | |
| 25 | 추가: | |
| 26 | 추가: def capture(binary, variant, state, output, environment, width, height): | |
| 27 | 추가: automatic = ROOT / "tests/ui-redesign/runs/fixtures/여행" | |
| 28 | 추가: try: | |
| 29 | 추가: automatic.rmdir() | |
| 30 | 추가: except OSError: | |
| 31 | 추가: pass | |
| 32 | 추가: mode = "opened" if state in {"picker", "selected-empty"} else state | |
| 33 | 추가: log = ROOT / "tests/ui-redesign/runs" / f"{variant}-{state}.log" | |
| 34 | 추가: with log.open("w") as stream: | |
| 35 | 추가: app = subprocess.Popen([str(binary), mode], cwd=ROOT, env=environment, stdout=stream, stderr=stream) | |
| 36 | 추가: try: | |
| 37 | 추가: deadline = time.monotonic() + 15 | |
| 38 | 추가: window = None | |
| 39 | 추가: while time.monotonic() < deadline and app.poll() is None: | |
| 40 | 추가: found = subprocess.run( | |
| 41 | 추가: ["xdotool", "search", "--onlyvisible", "--name", "^Zipelo UI capture"], | |
| 42 | 추가: env=environment, capture_output=True, text=True, | |
| 43 | 추가: ) | |
| 44 | 추가: if found.returncode == 0: | |
| 45 | 추가: window = found.stdout.splitlines()[0] | |
| 46 | 추가: break | |
| 47 | 추가: time.sleep(0.1) | |
| 48 | 추가: if window is None: | |
| 49 | 추가: raise RuntimeError(f"창 열기 실패: {log}") | |
| 50 | 추가: command(["xdotool", "windowsize", window, str(width), str(height)], environment) | |
| 51 | 추가: command(["xdotool", "windowfocus", "--sync", window], environment) | |
| 52 | 추가: time.sleep(0.7) | |
| 53 | 추가: | |
| 54 | 추가: def click(x, y): | |
| 55 | 추가: command(["xdotool", "mousemove", "--window", window, str(x), str(y), "click", "1"], environment) | |
| 56 | 추가: time.sleep(0.4) | |
| 57 | 추가: | |
| 58 | 추가: if state == "create" or (state == "create-filled" and variant == "before"): | |
| 59 | 추가: click(180 if variant == "before" else width - 90, 18 if variant == "before" else 40) | |
| 60 | 추가: if state == "create-filled" and variant == "before": | |
| 61 | 추가: base = ROOT / "tests/ui-redesign/runs/fixtures" | |
| 62 | 추가: click(100, 105) | |
| 63 | 추가: command(["xdotool", "type", "--clearmodifiers", "--delay", "0", | |
| 64 | 추가: str(ROOT / "tests/ui-redesign/README.md")], environment) | |
| 65 | 추가: command(["xdotool", "key", "Return"], environment) | |
| 66 | 추가: command(["xdotool", "type", "--clearmodifiers", "--delay", "0", str(base)], environment) | |
| 67 | 추가: click(100, 200) | |
| 68 | 추가: command(["xdotool", "type", "--clearmodifiers", "--delay", "0", str(base / "archive.zip")], environment) | |
| 69 | 추가: elif state == "picker": | |
| 70 | 추가: click(97 if variant == "before" else width - 90, 18 if variant == "before" else height - 80) | |
| 71 | 추가: elif state == "selected-empty": | |
| 72 | 추가: click(16 if variant == "before" else 24, 126 if variant == "before" else height - 36) | |
| 73 | 추가: elif state == "cancelling": | |
| 74 | 추가: click(260 if variant == "before" else width - 60, 18 if variant == "before" else height - 36) | |
| 75 | 추가: if state == "password-create" and variant == "after": | |
| 76 | 추가: click(width // 2 - 56, height // 2 - 12) | |
| 77 | 추가: command(["xdotool", "type", "--clearmodifiers", "--delay", "0", "fixture-password"], environment) | |
| 78 | 추가: command(["xdotool", "key", "Tab", "Tab"], environment) | |
| 79 | 추가: command(["xdotool", "type", "--clearmodifiers", "--delay", "0", "different"], environment) | |
| 80 | 추가: command(["xdotool", "mousemove", "--window", window, "2", "2"], environment) | |
| 81 | 추가: time.sleep(0.3) | |
| 82 | 추가: destination = output / f"{state}.png" | |
| 83 | 추가: command(["import", "-window", window, str(destination)], environment) | |
| 84 | 추가: return {"state": state, "path": str(destination.relative_to(ROOT)), "width": width, "height": height} | |
| 85 | 추가: finally: | |
| 86 | 추가: stop(app) | |
| 87 | 추가: | |
| 88 | 추가: | |
| 89 | 추가: def main(): | |
| 90 | 추가: parser = argparse.ArgumentParser(description=__doc__) | |
| 91 | 추가: parser.add_argument("--binary", type=Path, required=True) | |
| 92 | 추가: parser.add_argument("--variant", choices=["before", "after"], required=True) | |
| 93 | 추가: parser.add_argument("--states", nargs="+", default=["empty", "hover", "opened", "selected-empty", "picker", "create", "create-filled", "password", "password-retry", "password-create", "progress", "progress-unknown", "cancelling", "success", "error"]) | |
| 94 | 추가: parser.add_argument("--width", type=int, default=1060) | |
| 95 | 추가: parser.add_argument("--height", type=int, default=720) | |
| 96 | 추가: parser.add_argument("--output", type=Path) | |
| 97 | 추가: args = parser.parse_args() | |
| 98 | 추가: output = (args.output or ROOT / "tests/ui-redesign/screenshots" / args.variant).resolve() | |
| 99 | 추가: if not output.is_relative_to(ROOT / "tests"): | |
| 100 | 추가: raise ValueError("촬영 결과는 tests/ 안에만 저장함") | |
| 101 | 추가: output.mkdir(parents=True, exist_ok=True) | |
| 102 | 추가: read_fd, write_fd = os.pipe() | |
| 103 | 추가: server = subprocess.Popen( | |
| 104 | 추가: ["Xvfb", "-displayfd", str(write_fd), "-screen", "0", "1280x900x24", "-nolisten", "tcp"], | |
| 105 | 추가: pass_fds=(write_fd,), stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, | |
| 106 | 추가: ) | |
| 107 | 추가: os.close(write_fd) | |
| 108 | 추가: try: | |
| 109 | 추가: with os.fdopen(read_fd) as stream: | |
| 110 | 추가: display = stream.readline().strip() | |
| 111 | 추가: if not display: | |
| 112 | 추가: raise RuntimeError("Xvfb를 시작하지 못함") | |
| 113 | 추가: environment = dict(os.environ, DISPLAY=f":{display}", LIBGL_ALWAYS_SOFTWARE="1", WINIT_UNIX_BACKEND="x11", XDG_SESSION_TYPE="x11") | |
| 114 | 추가: environment.pop("WAYLAND_DISPLAY", None) | |
| 115 | 추가: results = [ | |
| 116 | 추가: capture(args.binary.resolve(), args.variant, state, output, environment, args.width, args.height) | |
| 117 | 추가: for state in args.states | |
| 118 | 추가: ] | |
| 119 | 추가: metadata = output / "capture.json" | |
| 120 | 추가: existing = json.loads(metadata.read_text()) if metadata.exists() else [] | |
| 121 | 추가: merged = {row["state"]: row for row in existing} | |
| 122 | 추가: merged.update({row["state"]: row for row in results}) | |
| 123 | 추가: metadata.write_text(json.dumps(list(merged.values()), ensure_ascii=False, indent=4) + "\n") | |
| 124 | 추가: print(json.dumps(results, ensure_ascii=False)) | |
| 125 | 추가: finally: | |
| 126 | 추가: stop(server) | |
| 127 | 추가: | |
| 128 | 추가: | |
| 129 | 추가: if __name__ == "__main__": | |
| 130 | 추가: main() |
| @@ -0,0 +1,65 @@ | ||
| 1 | 추가: """현재 화면과 로컬 Git 기준 화면의 촬영 실행 파일을 준비함.""" | |
| 2 | 추가: | |
| 3 | 추가: import argparse | |
| 4 | 추가: import os | |
| 5 | 추가: from pathlib import Path | |
| 6 | 추가: import subprocess | |
| 7 | 추가: import tarfile | |
| 8 | 추가: | |
| 9 | 추가: ROOT = Path(__file__).resolve().parents[2] | |
| 10 | 추가: MANIFEST = Path("experiments/rust-ui-memory-app/Cargo.toml") | |
| 11 | 추가: HELPER = Path("tests/rust-app-ui/capture.rs") | |
| 12 | 추가: BIN = '\n[[bin]]\nname = "zipelo-ui-capture"\npath = "../../tests/rust-app-ui/capture.rs"\nrequired-features = ["ui-fixture"]\n' | |
| 13 | 추가: | |
| 14 | 추가: | |
| 15 | 추가: def main(): | |
| 16 | 추가: parser = argparse.ArgumentParser(description=__doc__) | |
| 17 | 추가: parser.add_argument("--before-ref", default="b10c7eedddd202f83766aa8f001142cdfdb4097c") | |
| 18 | 추가: parser.add_argument("--output", type=Path, default=ROOT / "tests/ui-redesign/runs") | |
| 19 | 추가: parser.add_argument("--target-dir", type=Path, required=True) | |
| 20 | 추가: args = parser.parse_args() | |
| 21 | 추가: output = args.output.resolve() | |
| 22 | 추가: if not output.is_relative_to(ROOT / "tests"): | |
| 23 | 추가: raise ValueError("기준 소스와 실행 파일은 tests/ 안에만 저장함") | |
| 24 | 추가: before = output / "before-src" | |
| 25 | 추가: if before.exists(): | |
| 26 | 추가: raise ValueError("기존 기준 소스는 보존함. 새 --output 폴더를 지정하세요") | |
| 27 | 추가: before.mkdir(parents=True) | |
| 28 | 추가: revision = subprocess.check_output( | |
| 29 | 추가: ["git", "rev-parse", "--verify", "--end-of-options", args.before_ref + "^{commit}"], | |
| 30 | 추가: cwd=ROOT, text=True, | |
| 31 | 추가: ).strip() | |
| 32 | 추가: with subprocess.Popen(["git", "archive", revision], cwd=ROOT, stdout=subprocess.PIPE) as archive: | |
| 33 | 추가: with tarfile.open(fileobj=archive.stdout, mode="r|") as source: | |
| 34 | 추가: source.extractall(before, filter="data") | |
| 35 | 추가: if archive.wait() != 0: | |
| 36 | 추가: raise RuntimeError("로컬 기준 소스를 읽지 못함") | |
| 37 | 추가: helper = (ROOT / HELPER).read_text() | |
| 38 | 추가: helper = helper.replace( | |
| 39 | 추가: "self.app.begin_extract();", | |
| 40 | 추가: "self.app.model.begin(start, &mut self.factory);", | |
| 41 | 추가: ) | |
| 42 | 추가: helper = helper.replace( | |
| 43 | 추가: 'app.add_sources(vec![base.join("읽어주세요.txt"), base.join("사진")]);', | |
| 44 | 추가: "let _ = &mut app;", | |
| 45 | 추가: ) | |
| 46 | 추가: (before / HELPER).write_text(helper) | |
| 47 | 추가: original = before / MANIFEST | |
| 48 | 추가: original.write_text(original.read_text() + BIN) | |
| 49 | 추가: environment = dict(os.environ, CARGO_TARGET_DIR=str(args.target_dir.resolve())) | |
| 50 | 추가: for variant, root in [("before", before), ("after", ROOT)]: | |
| 51 | 추가: with (output / f"{variant}-build.log").open("w") as log: | |
| 52 | 추가: subprocess.run( | |
| 53 | 추가: ["cargo", "+1.99.1", "build", "--locked", "--offline", "--manifest-path", | |
| 54 | 추가: str(root / MANIFEST), "--features", "ui-fixture", "--bin", "zipelo-ui-capture"], | |
| 55 | 추가: cwd=ROOT, env=environment, stdout=log, stderr=log, check=True, | |
| 56 | 추가: ) | |
| 57 | 추가: executable = args.target_dir.resolve() / "debug/zipelo-ui-capture" | |
| 58 | 추가: destination = output / f"{variant}-capture" | |
| 59 | 추가: destination.write_bytes(executable.read_bytes()) | |
| 60 | 추가: destination.chmod(executable.stat().st_mode) | |
| 61 | 추가: print(f"기준 커밋 {revision}, 촬영 실행 파일 {output}") | |
| 62 | 추가: | |
| 63 | 추가: | |
| 64 | 추가: if __name__ == "__main__": | |
| 65 | 추가: main() |
바이너리 파일이라 Diff를 표시하지 않아요.
파일 내려받기| @@ -0,0 +1,92 @@ | ||
| 1 | 추가: [ | |
| 2 | 추가: { | |
| 3 | 추가: "state": "empty", | |
| 4 | 추가: "path": "tests/ui-redesign/screenshots/after/empty.png", | |
| 5 | 추가: "width": 1060, | |
| 6 | 추가: "height": 720 | |
| 7 | 추가: }, | |
| 8 | 추가: { | |
| 9 | 추가: "state": "hover", | |
| 10 | 추가: "path": "tests/ui-redesign/screenshots/after/hover.png", | |
| 11 | 추가: "width": 1060, | |
| 12 | 추가: "height": 720 | |
| 13 | 추가: }, | |
| 14 | 추가: { | |
| 15 | 추가: "state": "opened", | |
| 16 | 추가: "path": "tests/ui-redesign/screenshots/after/opened.png", | |
| 17 | 추가: "width": 1060, | |
| 18 | 추가: "height": 720 | |
| 19 | 추가: }, | |
| 20 | 추가: { | |
| 21 | 추가: "state": "selected-empty", | |
| 22 | 추가: "path": "tests/ui-redesign/screenshots/after/selected-empty.png", | |
| 23 | 추가: "width": 1060, | |
| 24 | 추가: "height": 720 | |
| 25 | 추가: }, | |
| 26 | 추가: { | |
| 27 | 추가: "state": "picker", | |
| 28 | 추가: "path": "tests/ui-redesign/screenshots/after/picker.png", | |
| 29 | 추가: "width": 1060, | |
| 30 | 추가: "height": 720 | |
| 31 | 추가: }, | |
| 32 | 추가: { | |
| 33 | 추가: "state": "create", | |
| 34 | 추가: "path": "tests/ui-redesign/screenshots/after/create.png", | |
| 35 | 추가: "width": 1060, | |
| 36 | 추가: "height": 720 | |
| 37 | 추가: }, | |
| 38 | 추가: { | |
| 39 | 추가: "state": "create-filled", | |
| 40 | 추가: "path": "tests/ui-redesign/screenshots/after/create-filled.png", | |
| 41 | 추가: "width": 1060, | |
| 42 | 추가: "height": 720 | |
| 43 | 추가: }, | |
| 44 | 추가: { | |
| 45 | 추가: "state": "password", | |
| 46 | 추가: "path": "tests/ui-redesign/screenshots/after/password.png", | |
| 47 | 추가: "width": 1060, | |
| 48 | 추가: "height": 720 | |
| 49 | 추가: }, | |
| 50 | 추가: { | |
| 51 | 추가: "state": "password-retry", | |
| 52 | 추가: "path": "tests/ui-redesign/screenshots/after/password-retry.png", | |
| 53 | 추가: "width": 1060, | |
| 54 | 추가: "height": 720 | |
| 55 | 추가: }, | |
| 56 | 추가: { | |
| 57 | 추가: "state": "password-create", | |
| 58 | 추가: "path": "tests/ui-redesign/screenshots/after/password-create.png", | |
| 59 | 추가: "width": 1060, | |
| 60 | 추가: "height": 720 | |
| 61 | 추가: }, | |
| 62 | 추가: { | |
| 63 | 추가: "state": "progress", | |
| 64 | 추가: "path": "tests/ui-redesign/screenshots/after/progress.png", | |
| 65 | 추가: "width": 1060, | |
| 66 | 추가: "height": 720 | |
| 67 | 추가: }, | |
| 68 | 추가: { | |
| 69 | 추가: "state": "progress-unknown", | |
| 70 | 추가: "path": "tests/ui-redesign/screenshots/after/progress-unknown.png", | |
| 71 | 추가: "width": 1060, | |
| 72 | 추가: "height": 720 | |
| 73 | 추가: }, | |
| 74 | 추가: { | |
| 75 | 추가: "state": "cancelling", | |
| 76 | 추가: "path": "tests/ui-redesign/screenshots/after/cancelling.png", | |
| 77 | 추가: "width": 1060, | |
| 78 | 추가: "height": 720 | |
| 79 | 추가: }, | |
| 80 | 추가: { | |
| 81 | 추가: "state": "success", | |
| 82 | 추가: "path": "tests/ui-redesign/screenshots/after/success.png", | |
| 83 | 추가: "width": 1060, | |
| 84 | 추가: "height": 720 | |
| 85 | 추가: }, | |
| 86 | 추가: { | |
| 87 | 추가: "state": "error", | |
| 88 | 추가: "path": "tests/ui-redesign/screenshots/after/error.png", | |
| 89 | 추가: "width": 1060, | |
| 90 | 추가: "height": 720 | |
| 91 | 추가: } | |
| 92 | 추가: ] |
바이너리 파일이라 Diff를 표시하지 않아요.
파일 내려받기바이너리 파일이라 Diff를 표시하지 않아요.
파일 내려받기바이너리 파일이라 Diff를 표시하지 않아요.
파일 내려받기바이너리 파일이라 Diff를 표시하지 않아요.
파일 내려받기바이너리 파일이라 Diff를 표시하지 않아요.
파일 내려받기바이너리 파일이라 Diff를 표시하지 않아요.
파일 내려받기바이너리 파일이라 Diff를 표시하지 않아요.
파일 내려받기바이너리 파일이라 Diff를 표시하지 않아요.
파일 내려받기바이너리 파일이라 Diff를 표시하지 않아요.
파일 내려받기바이너리 파일이라 Diff를 표시하지 않아요.
파일 내려받기바이너리 파일이라 Diff를 표시하지 않아요.
파일 내려받기바이너리 파일이라 Diff를 표시하지 않아요.
파일 내려받기바이너리 파일이라 Diff를 표시하지 않아요.
파일 내려받기바이너리 파일이라 Diff를 표시하지 않아요.
파일 내려받기바이너리 파일이라 Diff를 표시하지 않아요.
파일 내려받기| @@ -0,0 +1,92 @@ | ||
| 1 | 추가: [ | |
| 2 | 추가: { | |
| 3 | 추가: "state": "empty", | |
| 4 | 추가: "path": "tests/ui-redesign/screenshots/before/empty.png", | |
| 5 | 추가: "width": 1060, | |
| 6 | 추가: "height": 720 | |
| 7 | 추가: }, | |
| 8 | 추가: { | |
| 9 | 추가: "state": "hover", | |
| 10 | 추가: "path": "tests/ui-redesign/screenshots/before/hover.png", | |
| 11 | 추가: "width": 1060, | |
| 12 | 추가: "height": 720 | |
| 13 | 추가: }, | |
| 14 | 추가: { | |
| 15 | 추가: "state": "opened", | |
| 16 | 추가: "path": "tests/ui-redesign/screenshots/before/opened.png", | |
| 17 | 추가: "width": 1060, | |
| 18 | 추가: "height": 720 | |
| 19 | 추가: }, | |
| 20 | 추가: { | |
| 21 | 추가: "state": "selected-empty", | |
| 22 | 추가: "path": "tests/ui-redesign/screenshots/before/selected-empty.png", | |
| 23 | 추가: "width": 1060, | |
| 24 | 추가: "height": 720 | |
| 25 | 추가: }, | |
| 26 | 추가: { | |
| 27 | 추가: "state": "picker", | |
| 28 | 추가: "path": "tests/ui-redesign/screenshots/before/picker.png", | |
| 29 | 추가: "width": 1060, | |
| 30 | 추가: "height": 720 | |
| 31 | 추가: }, | |
| 32 | 추가: { | |
| 33 | 추가: "state": "create", | |
| 34 | 추가: "path": "tests/ui-redesign/screenshots/before/create.png", | |
| 35 | 추가: "width": 1060, | |
| 36 | 추가: "height": 720 | |
| 37 | 추가: }, | |
| 38 | 추가: { | |
| 39 | 추가: "state": "create-filled", | |
| 40 | 추가: "path": "tests/ui-redesign/screenshots/before/create-filled.png", | |
| 41 | 추가: "width": 1060, | |
| 42 | 추가: "height": 720 | |
| 43 | 추가: }, | |
| 44 | 추가: { | |
| 45 | 추가: "state": "password", | |
| 46 | 추가: "path": "tests/ui-redesign/screenshots/before/password.png", | |
| 47 | 추가: "width": 1060, | |
| 48 | 추가: "height": 720 | |
| 49 | 추가: }, | |
| 50 | 추가: { | |
| 51 | 추가: "state": "password-retry", | |
| 52 | 추가: "path": "tests/ui-redesign/screenshots/before/password-retry.png", | |
| 53 | 추가: "width": 1060, | |
| 54 | 추가: "height": 720 | |
| 55 | 추가: }, | |
| 56 | 추가: { | |
| 57 | 추가: "state": "password-create", | |
| 58 | 추가: "path": "tests/ui-redesign/screenshots/before/password-create.png", | |
| 59 | 추가: "width": 1060, | |
| 60 | 추가: "height": 720 | |
| 61 | 추가: }, | |
| 62 | 추가: { | |
| 63 | 추가: "state": "progress", | |
| 64 | 추가: "path": "tests/ui-redesign/screenshots/before/progress.png", | |
| 65 | 추가: "width": 1060, | |
| 66 | 추가: "height": 720 | |
| 67 | 추가: }, | |
| 68 | 추가: { | |
| 69 | 추가: "state": "progress-unknown", | |
| 70 | 추가: "path": "tests/ui-redesign/screenshots/before/progress-unknown.png", | |
| 71 | 추가: "width": 1060, | |
| 72 | 추가: "height": 720 | |
| 73 | 추가: }, | |
| 74 | 추가: { | |
| 75 | 추가: "state": "cancelling", | |
| 76 | 추가: "path": "tests/ui-redesign/screenshots/before/cancelling.png", | |
| 77 | 추가: "width": 1060, | |
| 78 | 추가: "height": 720 | |
| 79 | 추가: }, | |
| 80 | 추가: { | |
| 81 | 추가: "state": "success", | |
| 82 | 추가: "path": "tests/ui-redesign/screenshots/before/success.png", | |
| 83 | 추가: "width": 1060, | |
| 84 | 추가: "height": 720 | |
| 85 | 추가: }, | |
| 86 | 추가: { | |
| 87 | 추가: "state": "error", | |
| 88 | 추가: "path": "tests/ui-redesign/screenshots/before/error.png", | |
| 89 | 추가: "width": 1060, | |
| 90 | 추가: "height": 720 | |
| 91 | 추가: } | |
| 92 | 추가: ] |
바이너리 파일이라 Diff를 표시하지 않아요.
파일 내려받기바이너리 파일이라 Diff를 표시하지 않아요.
파일 내려받기바이너리 파일이라 Diff를 표시하지 않아요.
파일 내려받기바이너리 파일이라 Diff를 표시하지 않아요.
파일 내려받기바이너리 파일이라 Diff를 표시하지 않아요.
파일 내려받기바이너리 파일이라 Diff를 표시하지 않아요.
파일 내려받기바이너리 파일이라 Diff를 표시하지 않아요.
파일 내려받기바이너리 파일이라 Diff를 표시하지 않아요.
파일 내려받기바이너리 파일이라 Diff를 표시하지 않아요.
파일 내려받기바이너리 파일이라 Diff를 표시하지 않아요.
파일 내려받기바이너리 파일이라 Diff를 표시하지 않아요.
파일 내려받기바이너리 파일이라 Diff를 표시하지 않아요.
파일 내려받기바이너리 파일이라 Diff를 표시하지 않아요.
파일 내려받기바이너리 파일이라 Diff를 표시하지 않아요.
파일 내려받기바이너리 파일이라 Diff를 표시하지 않아요.
파일 내려받기| @@ -0,0 +1,92 @@ | ||
| 1 | 추가: [ | |
| 2 | 추가: { | |
| 3 | 추가: "state": "empty", | |
| 4 | 추가: "path": "tests/ui-redesign/screenshots/minimum/empty.png", | |
| 5 | 추가: "width": 760, | |
| 6 | 추가: "height": 540 | |
| 7 | 추가: }, | |
| 8 | 추가: { | |
| 9 | 추가: "state": "hover", | |
| 10 | 추가: "path": "tests/ui-redesign/screenshots/minimum/hover.png", | |
| 11 | 추가: "width": 760, | |
| 12 | 추가: "height": 540 | |
| 13 | 추가: }, | |
| 14 | 추가: { | |
| 15 | 추가: "state": "opened", | |
| 16 | 추가: "path": "tests/ui-redesign/screenshots/minimum/opened.png", | |
| 17 | 추가: "width": 760, | |
| 18 | 추가: "height": 540 | |
| 19 | 추가: }, | |
| 20 | 추가: { | |
| 21 | 추가: "state": "selected-empty", | |
| 22 | 추가: "path": "tests/ui-redesign/screenshots/minimum/selected-empty.png", | |
| 23 | 추가: "width": 760, | |
| 24 | 추가: "height": 540 | |
| 25 | 추가: }, | |
| 26 | 추가: { | |
| 27 | 추가: "state": "picker", | |
| 28 | 추가: "path": "tests/ui-redesign/screenshots/minimum/picker.png", | |
| 29 | 추가: "width": 760, | |
| 30 | 추가: "height": 540 | |
| 31 | 추가: }, | |
| 32 | 추가: { | |
| 33 | 추가: "state": "create", | |
| 34 | 추가: "path": "tests/ui-redesign/screenshots/minimum/create.png", | |
| 35 | 추가: "width": 760, | |
| 36 | 추가: "height": 540 | |
| 37 | 추가: }, | |
| 38 | 추가: { | |
| 39 | 추가: "state": "create-filled", | |
| 40 | 추가: "path": "tests/ui-redesign/screenshots/minimum/create-filled.png", | |
| 41 | 추가: "width": 760, | |
| 42 | 추가: "height": 540 | |
| 43 | 추가: }, | |
| 44 | 추가: { | |
| 45 | 추가: "state": "password", | |
| 46 | 추가: "path": "tests/ui-redesign/screenshots/minimum/password.png", | |
| 47 | 추가: "width": 760, | |
| 48 | 추가: "height": 540 | |
| 49 | 추가: }, | |
| 50 | 추가: { | |
| 51 | 추가: "state": "password-retry", | |
| 52 | 추가: "path": "tests/ui-redesign/screenshots/minimum/password-retry.png", | |
| 53 | 추가: "width": 760, | |
| 54 | 추가: "height": 540 | |
| 55 | 추가: }, | |
| 56 | 추가: { | |
| 57 | 추가: "state": "password-create", | |
| 58 | 추가: "path": "tests/ui-redesign/screenshots/minimum/password-create.png", | |
| 59 | 추가: "width": 760, | |
| 60 | 추가: "height": 540 | |
| 61 | 추가: }, | |
| 62 | 추가: { | |
| 63 | 추가: "state": "progress", | |
| 64 | 추가: "path": "tests/ui-redesign/screenshots/minimum/progress.png", | |
| 65 | 추가: "width": 760, | |
| 66 | 추가: "height": 540 | |
| 67 | 추가: }, | |
| 68 | 추가: { | |
| 69 | 추가: "state": "progress-unknown", | |
| 70 | 추가: "path": "tests/ui-redesign/screenshots/minimum/progress-unknown.png", | |
| 71 | 추가: "width": 760, | |
| 72 | 추가: "height": 540 | |
| 73 | 추가: }, | |
| 74 | 추가: { | |
| 75 | 추가: "state": "cancelling", | |
| 76 | 추가: "path": "tests/ui-redesign/screenshots/minimum/cancelling.png", | |
| 77 | 추가: "width": 760, | |
| 78 | 추가: "height": 540 | |
| 79 | 추가: }, | |
| 80 | 추가: { | |
| 81 | 추가: "state": "success", | |
| 82 | 추가: "path": "tests/ui-redesign/screenshots/minimum/success.png", | |
| 83 | 추가: "width": 760, | |
| 84 | 추가: "height": 540 | |
| 85 | 추가: }, | |
| 86 | 추가: { | |
| 87 | 추가: "state": "error", | |
| 88 | 추가: "path": "tests/ui-redesign/screenshots/minimum/error.png", | |
| 89 | 추가: "width": 760, | |
| 90 | 추가: "height": 540 | |
| 91 | 추가: } | |
| 92 | 추가: ] |
바이너리 파일이라 Diff를 표시하지 않아요.
파일 내려받기바이너리 파일이라 Diff를 표시하지 않아요.
파일 내려받기바이너리 파일이라 Diff를 표시하지 않아요.
파일 내려받기바이너리 파일이라 Diff를 표시하지 않아요.
파일 내려받기바이너리 파일이라 Diff를 표시하지 않아요.
파일 내려받기바이너리 파일이라 Diff를 표시하지 않아요.
파일 내려받기바이너리 파일이라 Diff를 표시하지 않아요.
파일 내려받기바이너리 파일이라 Diff를 표시하지 않아요.
파일 내려받기바이너리 파일이라 Diff를 표시하지 않아요.
파일 내려받기바이너리 파일이라 Diff를 표시하지 않아요.
파일 내려받기바이너리 파일이라 Diff를 표시하지 않아요.
파일 내려받기바이너리 파일이라 Diff를 표시하지 않아요.
파일 내려받기바이너리 파일이라 Diff를 표시하지 않아요.
파일 내려받기바이너리 파일이라 Diff를 표시하지 않아요.
파일 내려받기