Linux 파일 창 실패와 취소를 구분하고 안내를 표시함
- 작성자
- 호시노 히나타
- 작성 시각
- 커밋
8e66fe78e4f9132e38f994a67b3176ccbcdd534b- 부모
- fa871ad
변경된 파일 12개
+374-42| @@ -4599,7 +4599,9 @@ dependencies = [ | ||
| 4599 | 4599 | name = "zipelo-ui-memory-app" |
| 4600 | 4600 | version = "0.1.0" |
| 4601 | 4601 | dependencies = [ |
| 4602 | 추가: "ashpd", | |
| 4602 | 4603 | "eframe", |
| 4604 | 추가: "pollster 0.4.0", | |
| 4603 | 4605 | "rfd", |
| 4604 | 4606 | "wgpu", |
| 4605 | 4607 | "zipelo-app-core-memory", |
| @@ -14,7 +14,7 @@ doctest = false | ||
| 14 | 14 | |
| 15 | 15 | [features] |
| 16 | 16 | default = [] |
| 17 | 삭제: ui = ["dep:eframe", "dep:wgpu", "dep:rfd"] | |
| 17 | 추가: ui = ["dep:eframe", "dep:wgpu", "dep:rfd", "dep:ashpd", "dep:pollster"] | |
| 18 | 18 | ui-fixture = ["ui"] |
| 19 | 19 | |
| 20 | 20 | [dependencies] |
| @@ -44,6 +44,8 @@ name = "format_contract" | ||
| 44 | 44 | path = "../../tests/rust-app-real-worker/formats.rs" |
| 45 | 45 | |
| 46 | 46 | [target.'cfg(target_os = "linux")'.dependencies] |
| 47 | 추가: ashpd = { version = "=0.11.1", optional = true, default-features = false, features = ["async-std"] } | |
| 48 | 추가: pollster = { version = "=0.4.0", optional = true } | |
| 47 | 49 | rfd = { version = "=0.16.0", optional = true, default-features = false, features = ["xdg-portal", "async-std"] } |
| 48 | 50 | |
| 49 | 51 | [target.'cfg(not(target_os = "linux"))'.dependencies] |
| @@ -45,39 +45,133 @@ pub fn archive_filters() -> Vec<(&'static str, Vec<String>)> { | ||
| 45 | 45 | #[derive(Default)] |
| 46 | 46 | pub struct NativeDialogs; |
| 47 | 47 | |
| 48 | 추가: pub const DIALOG_UNAVAILABLE: &str = | |
| 49 | 추가: "파일 선택 창을 열 수 없습니다. 파일을 창으로 끌어 놓아 주세요."; | |
| 50 | 추가: | |
| 48 | 51 | impl Dialogs for NativeDialogs { |
| 49 | 52 | fn choose(&mut self, request: DialogRequest) -> Result<Option<Vec<PathBuf>>, String> { |
| 50 | 삭제: let dialog = rfd::FileDialog::new().set_directory(request.directory); | |
| 51 | 삭제: let answer = | |
| 52 | 삭제: std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| match request.purpose { | |
| 53 | 삭제: Purpose::Open => { | |
| 54 | 삭제: let mut dialog = dialog.set_title("압축파일 열기"); | |
| 55 | 삭제: for (name, extensions) in archive_filters() { | |
| 56 | 삭제: dialog = dialog.add_filter(name, &extensions); | |
| 57 | 삭제: } | |
| 58 | 삭제: dialog.pick_file().map(|path| vec![path]) | |
| 59 | 삭제: } | |
| 60 | 삭제: Purpose::Files => dialog.set_title("파일 추가").pick_files(), | |
| 61 | 삭제: Purpose::Folder => dialog | |
| 62 | 삭제: .set_title("폴더 추가") | |
| 63 | 삭제: .pick_folder() | |
| 64 | 삭제: .map(|path| vec![path]), | |
| 65 | 삭제: Purpose::Destination | Purpose::Retry => dialog | |
| 66 | 삭제: .set_title("압축을 풀 폴더 선택") | |
| 67 | 삭제: .pick_folder() | |
| 68 | 삭제: .map(|path| vec![path]), | |
| 69 | 삭제: Purpose::SaveGzip | Purpose::RetryGzip => dialog | |
| 70 | 삭제: .set_title("압축 해제 파일 저장") | |
| 71 | 삭제: .set_file_name(request.file_name) | |
| 72 | 삭제: .save_file() | |
| 73 | 삭제: .map(|path| vec![path]), | |
| 74 | 삭제: Purpose::SaveZip => dialog | |
| 75 | 삭제: .set_title("ZIP 파일 저장") | |
| 76 | 삭제: .set_file_name(request.file_name) | |
| 77 | 삭제: .add_filter("ZIP 압축파일", &["zip"]) | |
| 78 | 삭제: .save_file() | |
| 79 | 삭제: .map(|path| vec![path]), | |
| 80 | 삭제: })); | |
| 81 | 삭제: answer.map_err(|_| "파일 선택 창을 열지 못했습니다. 다시 시도하세요".to_owned()) | |
| 53 | 추가: std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| { | |
| 54 | 추가: #[cfg(target_os = "linux")] | |
| 55 | 추가: { | |
| 56 | 추가: choose_portal(request) | |
| 57 | 추가: } | |
| 58 | 추가: #[cfg(not(target_os = "linux"))] | |
| 59 | 추가: { | |
| 60 | 추가: choose_native(request) | |
| 61 | 추가: } | |
| 62 | 추가: })) | |
| 63 | 추가: .unwrap_or_else(|_| Err(DIALOG_UNAVAILABLE.into())) | |
| 64 | 추가: } | |
| 65 | 추가: } | |
| 66 | 추가: | |
| 67 | 추가: #[cfg(target_os = "linux")] | |
| 68 | 추가: pub fn portal_response( | |
| 69 | 추가: response: Result<Vec<PathBuf>, ashpd::Error>, | |
| 70 | 추가: ) -> Result<Option<Vec<PathBuf>>, String> { | |
| 71 | 추가: match response { | |
| 72 | 추가: Ok(paths) if !paths.is_empty() => Ok(Some(paths)), | |
| 73 | 추가: Err(ashpd::Error::Response(ashpd::desktop::ResponseError::Cancelled)) | |
| 74 | 추가: | Err(ashpd::Error::Portal(ashpd::PortalError::Cancelled(_))) => Ok(None), | |
| 75 | 추가: _ => Err(DIALOG_UNAVAILABLE.into()), | |
| 82 | 76 | } |
| 83 | 77 | } |
| 78 | 추가: | |
| 79 | 추가: #[cfg(target_os = "linux")] | |
| 80 | 추가: fn choose_portal(request: DialogRequest) -> Result<Option<Vec<PathBuf>>, String> { | |
| 81 | 추가: use ashpd::desktop::file_chooser::{FileFilter, OpenFileRequest, SaveFileRequest}; | |
| 82 | 추가: let filters = match request.purpose { | |
| 83 | 추가: Purpose::Open => archive_filters(), | |
| 84 | 추가: Purpose::SaveZip => vec![("ZIP 압축파일", vec!["zip".into()])], | |
| 85 | 추가: _ => Vec::new(), | |
| 86 | 추가: } | |
| 87 | 추가: .into_iter() | |
| 88 | 추가: .map(|(name, extensions)| { | |
| 89 | 추가: extensions | |
| 90 | 추가: .into_iter() | |
| 91 | 추가: .fold(FileFilter::new(name), |filter, extension| { | |
| 92 | 추가: let glob = if extension == "*" { | |
| 93 | 추가: "*".to_owned() | |
| 94 | 추가: } else { | |
| 95 | 추가: format!("*.{extension}") | |
| 96 | 추가: }; | |
| 97 | 추가: filter.glob(&glob) | |
| 98 | 추가: }) | |
| 99 | 추가: }) | |
| 100 | 추가: .collect::<Vec<_>>(); | |
| 101 | 추가: portal_response(pollster::block_on(async move { | |
| 102 | 추가: let selected = match request.purpose { | |
| 103 | 추가: Purpose::SaveZip | Purpose::SaveGzip | Purpose::RetryGzip => SaveFileRequest::default() | |
| 104 | 추가: .title(if request.purpose == Purpose::SaveZip { | |
| 105 | 추가: "ZIP 파일 저장" | |
| 106 | 추가: } else { | |
| 107 | 추가: "압축 해제 파일 저장" | |
| 108 | 추가: }) | |
| 109 | 추가: .current_name(Some(request.file_name.as_str())) | |
| 110 | 추가: .filters(filters) | |
| 111 | 추가: .current_folder::<&PathBuf>(Some(&request.directory))? | |
| 112 | 추가: .send() | |
| 113 | 추가: .await? | |
| 114 | 추가: .response()?, | |
| 115 | 추가: purpose => OpenFileRequest::default() | |
| 116 | 추가: .title(match purpose { | |
| 117 | 추가: Purpose::Open => "압축파일 열기", | |
| 118 | 추가: Purpose::Files => "파일 추가", | |
| 119 | 추가: Purpose::Folder => "폴더 추가", | |
| 120 | 추가: _ => "압축을 풀 폴더 선택", | |
| 121 | 추가: }) | |
| 122 | 추가: .multiple(purpose == Purpose::Files) | |
| 123 | 추가: .directory(matches!( | |
| 124 | 추가: purpose, | |
| 125 | 추가: Purpose::Folder | Purpose::Destination | Purpose::Retry | |
| 126 | 추가: )) | |
| 127 | 추가: .filters(filters) | |
| 128 | 추가: .current_folder::<&PathBuf>(Some(&request.directory))? | |
| 129 | 추가: .send() | |
| 130 | 추가: .await? | |
| 131 | 추가: .response()?, | |
| 132 | 추가: }; | |
| 133 | 추가: selected | |
| 134 | 추가: .uris() | |
| 135 | 추가: .iter() | |
| 136 | 추가: .map(|uri| { | |
| 137 | 추가: uri.to_file_path() | |
| 138 | 추가: .map_err(|_| ashpd::Error::ParseError("파일 경로 응답 오류")) | |
| 139 | 추가: }) | |
| 140 | 추가: .collect::<Result<Vec<_>, _>>() | |
| 141 | 추가: })) | |
| 142 | 추가: } | |
| 143 | 추가: | |
| 144 | 추가: #[cfg(not(target_os = "linux"))] | |
| 145 | 추가: fn choose_native(request: DialogRequest) -> Result<Option<Vec<PathBuf>>, String> { | |
| 146 | 추가: let dialog = rfd::FileDialog::new().set_directory(request.directory); | |
| 147 | 추가: let answer = match request.purpose { | |
| 148 | 추가: Purpose::Open => { | |
| 149 | 추가: let mut dialog = dialog.set_title("압축파일 열기"); | |
| 150 | 추가: for (name, extensions) in archive_filters() { | |
| 151 | 추가: dialog = dialog.add_filter(name, &extensions); | |
| 152 | 추가: } | |
| 153 | 추가: dialog.pick_file().map(|path| vec![path]) | |
| 154 | 추가: } | |
| 155 | 추가: Purpose::Files => dialog.set_title("파일 추가").pick_files(), | |
| 156 | 추가: Purpose::Folder => dialog | |
| 157 | 추가: .set_title("폴더 추가") | |
| 158 | 추가: .pick_folder() | |
| 159 | 추가: .map(|path| vec![path]), | |
| 160 | 추가: Purpose::Destination | Purpose::Retry => dialog | |
| 161 | 추가: .set_title("압축을 풀 폴더 선택") | |
| 162 | 추가: .pick_folder() | |
| 163 | 추가: .map(|path| vec![path]), | |
| 164 | 추가: Purpose::SaveGzip | Purpose::RetryGzip => dialog | |
| 165 | 추가: .set_title("압축 해제 파일 저장") | |
| 166 | 추가: .set_file_name(request.file_name) | |
| 167 | 추가: .save_file() | |
| 168 | 추가: .map(|path| vec![path]), | |
| 169 | 추가: Purpose::SaveZip => dialog | |
| 170 | 추가: .set_title("ZIP 파일 저장") | |
| 171 | 추가: .set_file_name(request.file_name) | |
| 172 | 추가: .add_filter("ZIP 압축파일", &["zip"]) | |
| 173 | 추가: .save_file() | |
| 174 | 추가: .map(|path| vec![path]), | |
| 175 | 추가: }; | |
| 176 | 추가: Ok(answer) | |
| 177 | 추가: } |
| @@ -316,7 +316,13 @@ impl ArchiveApp { | ||
| 316 | 316 | self.zip_name.clone() |
| 317 | 317 | }, |
| 318 | 318 | }; |
| 319 | 삭제: match self.dialogs.choose(request) { | |
| 319 | 추가: let answer = self.dialogs.choose(request); | |
| 320 | 추가: if answer.is_ok() | |
| 321 | 추가: && self.ui_error.as_deref() == Some(crate::archive_dialog::DIALOG_UNAVAILABLE) | |
| 322 | 추가: { | |
| 323 | 추가: self.ui_error = None; | |
| 324 | 추가: } | |
| 325 | 추가: match answer { | |
| 320 | 326 | Ok(Some(paths)) if !paths.is_empty() => { |
| 321 | 327 | let path = paths[0].clone(); |
| 322 | 328 | match purpose { |
| @@ -529,7 +535,7 @@ impl ArchiveApp { | ||
| 529 | 535 | }); |
| 530 | 536 | }); |
| 531 | 537 | }); |
| 532 | 삭제: if self.model.busy() || self.result_visible() || self.ui_error.is_some() { | |
| 538 | 추가: if self.model.busy() || self.result_visible() || (self.ui_error.is_some() && !self.create) { | |
| 533 | 539 | egui::Panel::bottom("archive-work") |
| 534 | 540 | .frame(theme::panel(theme::PANEL).corner_radius(0)) |
| 535 | 541 | .show(root, |ui| self.work_area(ui)); |
| @@ -826,14 +832,28 @@ impl ArchiveApp { | ||
| 826 | 832 | }) |
| 827 | 833 | } |
| 828 | 834 | |
| 835 | 추가: fn error_notice(ui: &mut egui::Ui, error: &str) { | |
| 836 | 추가: let response = theme::panel(theme::ERROR_BG) | |
| 837 | 추가: .show(ui, |ui| { | |
| 838 | 추가: ui.horizontal_wrapped(|ui| { | |
| 839 | 추가: theme::icon(ui, Icon::Error, 24.0); | |
| 840 | 추가: ui.colored_label(theme::ERROR, error); | |
| 841 | 추가: }); | |
| 842 | 추가: }) | |
| 843 | 추가: .response; | |
| 844 | 추가: response.widget_info(|| egui::WidgetInfo::labeled(egui::Role::Alert, true, error)); | |
| 845 | 추가: } | |
| 846 | 추가: | |
| 829 | 847 | fn work_area(&mut self, ui: &mut egui::Ui) { |
| 830 | 848 | if self.model.busy() { |
| 831 | 849 | self.progress(ui); |
| 832 | 850 | } else if self.result_visible() { |
| 833 | 851 | self.result(ui); |
| 834 | 852 | } |
| 835 | 삭제: if let Some(error) = &self.ui_error { | |
| 836 | 삭제: ui.colored_label(theme::ERROR, error); | |
| 853 | 추가: if !self.create | |
| 854 | 추가: && let Some(error) = &self.ui_error | |
| 855 | 추가: { | |
| 856 | 추가: Self::error_notice(ui, error); | |
| 837 | 857 | if error == present::FOLDER_ERROR |
| 838 | 858 | && theme::action(ui, "폴더 바꾸기", false, true).clicked() |
| 839 | 859 | { |
| @@ -1158,9 +1178,17 @@ impl ArchiveApp { | ||
| 1158 | 1178 | cancel = close.clicked(); |
| 1159 | 1179 | }); |
| 1160 | 1180 | }); |
| 1181 | 추가: if let Some(error) = &self.ui_error { | |
| 1182 | 추가: Self::error_notice(ui, error); | |
| 1183 | 추가: } | |
| 1161 | 1184 | egui::ScrollArea::vertical() |
| 1162 | 1185 | .id_salt("create-fields") |
| 1163 | 삭제: .max_height((ctx.content_rect().height() - 180.0).max(180.0)) | |
| 1186 | 추가: .max_height( | |
| 1187 | 추가: (ctx.content_rect().height() | |
| 1188 | 추가: - 180.0 | |
| 1189 | 추가: - if self.ui_error.is_some() { 96.0 } else { 0.0 }) | |
| 1190 | 추가: .max(120.0), | |
| 1191 | 추가: ) | |
| 1164 | 1192 | .show(ui, |ui| { |
| 1165 | 1193 | ui.add_space(16.0); |
| 1166 | 1194 | let frame = theme::panel(theme::STRIPE) |
| @@ -1236,9 +1264,6 @@ impl ArchiveApp { | ||
| 1236 | 1264 | }); |
| 1237 | 1265 | let check = ui.checkbox(&mut self.aes256, "암호로 보호하기"); |
| 1238 | 1266 | theme::focus(&check); |
| 1239 | 삭제: if let Some(error) = &self.ui_error { | |
| 1240 | 삭제: ui.colored_label(theme::ERROR, error); | |
| 1241 | 삭제: } | |
| 1242 | 1267 | ui.add_space(16.0); |
| 1243 | 1268 | }); |
| 1244 | 1269 | let (dismiss, confirm) = |
| @@ -7,6 +7,7 @@ pub struct DialogState { | ||
| 7 | 7 | pub answers: VecDeque<Option<Vec<PathBuf>>>, |
| 8 | 8 | pub save_name: Option<String>, |
| 9 | 9 | pub cancel_save: bool, |
| 10 | 추가: pub error: Option<String>, | |
| 10 | 11 | } |
| 11 | 12 | |
| 12 | 13 | #[derive(Clone, Default)] |
| @@ -16,6 +17,9 @@ impl Dialogs for TestDialogs { | ||
| 16 | 17 | fn choose(&mut self, request: DialogRequest) -> Result<Option<Vec<PathBuf>>, String> { |
| 17 | 18 | let mut state = self.0.borrow_mut(); |
| 18 | 19 | state.requests.push(request.clone()); |
| 20 | 추가: if let Some(error) = &state.error { | |
| 21 | 추가: return Err(error.clone()); | |
| 22 | 추가: } | |
| 19 | 23 | if let Some(answer) = state.answers.pop_front() { |
| 20 | 24 | return Ok(answer); |
| 21 | 25 | } |
| @@ -75,3 +75,106 @@ fn gzip_suggested_names_are_portable_and_preserve_valid_stems() { | ||
| 75 | 75 | } |
| 76 | 76 | assert!(valid_output_leaf("사용자 이름.txt")); |
| 77 | 77 | } |
| 78 | 추가: | |
| 79 | 추가: #[cfg(target_os = "linux")] | |
| 80 | 추가: #[test] | |
| 81 | 추가: fn portal_response_distinguishes_cancellation_from_backend_failure() { | |
| 82 | 추가: use ashpd::{Error, PortalError, desktop::ResponseError}; | |
| 83 | 추가: use zipelo_ui_memory_app::archive_dialog::{DIALOG_UNAVAILABLE, portal_response}; | |
| 84 | 추가: for error in [ | |
| 85 | 추가: Error::Response(ResponseError::Cancelled), | |
| 86 | 추가: Error::Portal(PortalError::Cancelled("cancelled".into())), | |
| 87 | 추가: ] { | |
| 88 | 추가: assert_eq!(portal_response(Err(error)), Ok(None)); | |
| 89 | 추가: } | |
| 90 | 추가: for error in [ | |
| 91 | 추가: Error::Response(ResponseError::Other), | |
| 92 | 추가: Error::Portal(PortalError::Failed("failed".into())), | |
| 93 | 추가: Error::Portal(PortalError::WindowDestroyed("destroyed".into())), | |
| 94 | 추가: Error::NoResponse, | |
| 95 | 추가: Error::PortalNotFound("org.freedesktop.portal.FileChooser".try_into().unwrap()), | |
| 96 | 추가: Error::IO(std::io::Error::other("backend unavailable")), | |
| 97 | 추가: Error::ParseError("invalid URI"), | |
| 98 | 추가: ] { | |
| 99 | 추가: assert_eq!(portal_response(Err(error)), Err(DIALOG_UNAVAILABLE.into())); | |
| 100 | 추가: } | |
| 101 | 추가: assert_eq!(portal_response(Ok(vec![])), Err(DIALOG_UNAVAILABLE.into())); | |
| 102 | 추가: let path = Path::new("/selected/archive.zip").to_path_buf(); | |
| 103 | 추가: assert_eq!( | |
| 104 | 추가: portal_response(Ok(vec![path.clone()])), | |
| 105 | 추가: Ok(Some(vec![path])) | |
| 106 | 추가: ); | |
| 107 | 추가: } | |
| 108 | 추가: | |
| 109 | 추가: #[cfg(target_os = "linux")] | |
| 110 | 추가: #[test] | |
| 111 | 추가: fn missing_portal_returns_errors_for_every_dialog() { | |
| 112 | 추가: use std::{ | |
| 113 | 추가: process::{Command, Stdio}, | |
| 114 | 추가: time::{Duration, Instant}, | |
| 115 | 추가: }; | |
| 116 | 추가: use zipelo_ui_memory_app::archive_dialog::{ | |
| 117 | 추가: DIALOG_UNAVAILABLE, DialogRequest, Dialogs, NativeDialogs, Purpose, | |
| 118 | 추가: }; | |
| 119 | 추가: if std::env::var_os("ZIPELO_NO_PORTAL_CHILD").is_some() { | |
| 120 | 추가: let mut dialogs = NativeDialogs; | |
| 121 | 추가: for purpose in [ | |
| 122 | 추가: Purpose::Open, | |
| 123 | 추가: Purpose::Files, | |
| 124 | 추가: Purpose::Folder, | |
| 125 | 추가: Purpose::Destination, | |
| 126 | 추가: Purpose::Retry, | |
| 127 | 추가: Purpose::SaveZip, | |
| 128 | 추가: Purpose::SaveGzip, | |
| 129 | 추가: Purpose::RetryGzip, | |
| 130 | 추가: ] { | |
| 131 | 추가: let result = dialogs.choose(DialogRequest { | |
| 132 | 추가: purpose, | |
| 133 | 추가: directory: std::env::current_dir().unwrap(), | |
| 134 | 추가: file_name: "output.zip".into(), | |
| 135 | 추가: }); | |
| 136 | 추가: assert_eq!(result, Err(DIALOG_UNAVAILABLE.into()), "{purpose:?}"); | |
| 137 | 추가: } | |
| 138 | 추가: return; | |
| 139 | 추가: } | |
| 140 | 추가: let endpoint = Path::new(env!("CARGO_MANIFEST_DIR")).join(format!( | |
| 141 | 추가: "../../tests/rust-app-ui/runs/no-bus-{}", | |
| 142 | 추가: std::process::id() | |
| 143 | 추가: )); | |
| 144 | 추가: assert!(!endpoint.exists()); | |
| 145 | 추가: let mut child = Command::new(std::env::current_exe().unwrap()) | |
| 146 | 추가: .args([ | |
| 147 | 추가: "--exact", | |
| 148 | 추가: "native_dialogs::missing_portal_returns_errors_for_every_dialog", | |
| 149 | 추가: "--nocapture", | |
| 150 | 추가: ]) | |
| 151 | 추가: .env("ZIPELO_NO_PORTAL_CHILD", "1") | |
| 152 | 추가: .env( | |
| 153 | 추가: "DBUS_SESSION_BUS_ADDRESS", | |
| 154 | 추가: format!("unix:path={}", endpoint.display()), | |
| 155 | 추가: ) | |
| 156 | 추가: .env_remove("DBUS_STARTER_ADDRESS") | |
| 157 | 추가: .stdout(Stdio::piped()) | |
| 158 | 추가: .stderr(Stdio::piped()) | |
| 159 | 추가: .spawn() | |
| 160 | 추가: .unwrap(); | |
| 161 | 추가: let deadline = Instant::now() + Duration::from_secs(15); | |
| 162 | 추가: loop { | |
| 163 | 추가: if child.try_wait().unwrap().is_some() { | |
| 164 | 추가: break; | |
| 165 | 추가: } | |
| 166 | 추가: if Instant::now() >= deadline { | |
| 167 | 추가: child.kill().unwrap(); | |
| 168 | 추가: child.wait().unwrap(); | |
| 169 | 추가: panic!("portal 실패 응답 시간 초과"); | |
| 170 | 추가: } | |
| 171 | 추가: std::thread::sleep(Duration::from_millis(10)); | |
| 172 | 추가: } | |
| 173 | 추가: let output = child.wait_with_output().unwrap(); | |
| 174 | 추가: assert!( | |
| 175 | 추가: output.status.success(), | |
| 176 | 추가: "{}{}", | |
| 177 | 추가: String::from_utf8_lossy(&output.stdout), | |
| 178 | 추가: String::from_utf8_lossy(&output.stderr) | |
| 179 | 추가: ); | |
| 180 | 추가: } |
| @@ -345,3 +345,73 @@ fn gzip_save_cancel_and_invalid_output_do_not_start_an_extraction() { | ||
| 345 | 345 | assert_eq!(factory.state.borrow().starts.len(), 1); |
| 346 | 346 | assert!(!app.model.busy()); |
| 347 | 347 | } |
| 348 | 추가: | |
| 349 | 추가: #[test] | |
| 350 | 추가: fn dialog_failures_show_alerts_while_cancelled_dialogs_remain_silent() { | |
| 351 | 추가: use zipelo_ui_memory_app::archive_dialog::DIALOG_UNAVAILABLE; | |
| 352 | 추가: for failed in [false, true] { | |
| 353 | 추가: for purpose in [ | |
| 354 | 추가: Purpose::Open, | |
| 355 | 추가: Purpose::Files, | |
| 356 | 추가: Purpose::Folder, | |
| 357 | 추가: Purpose::Destination, | |
| 358 | 추가: Purpose::SaveZip, | |
| 359 | 추가: Purpose::SaveGzip, | |
| 360 | 추가: ] { | |
| 361 | 추가: let scratch = Folder::new(); | |
| 362 | 추가: let factory = FakeFactory::default(); | |
| 363 | 추가: if purpose == Purpose::SaveGzip { | |
| 364 | 추가: factory.state.borrow_mut().list_format = Some(Format::Gzip); | |
| 365 | 추가: } | |
| 366 | 추가: let mut app = loaded(&scratch, &factory); | |
| 367 | 추가: let dialogs = TestDialogs::default(); | |
| 368 | 추가: dialogs.0.borrow_mut().cancel_save = true; | |
| 369 | 추가: if failed { | |
| 370 | 추가: dialogs.0.borrow_mut().error = Some(DIALOG_UNAVAILABLE.into()); | |
| 371 | 추가: } | |
| 372 | 추가: app.set_dialogs(Box::new(dialogs.clone())); | |
| 373 | 추가: let ctx = egui::Context::default(); | |
| 374 | 추가: let label = match purpose { | |
| 375 | 추가: Purpose::Open => "열기", | |
| 376 | 추가: Purpose::Files | Purpose::Folder | Purpose::SaveZip => { | |
| 377 | 추가: policy_click(&ctx, &mut app, "압축하기"); | |
| 378 | 추가: if purpose == Purpose::SaveZip { | |
| 379 | 추가: let source = scratch.0.join("source.txt"); | |
| 380 | 추가: fs::write(&source, b"preserve").unwrap(); | |
| 381 | 추가: app.add_sources(vec![source]); | |
| 382 | 추가: } | |
| 383 | 추가: match purpose { | |
| 384 | 추가: Purpose::Files => "파일 추가", | |
| 385 | 추가: Purpose::Folder => "폴더 추가", | |
| 386 | 추가: _ => "압축하기", | |
| 387 | 추가: } | |
| 388 | 추가: } | |
| 389 | 추가: _ => "압축해제", | |
| 390 | 추가: }; | |
| 391 | 추가: policy_click(&ctx, &mut app, label); | |
| 392 | 추가: let shown = policy_render(&ctx, &mut app, vec![]); | |
| 393 | 추가: assert_eq!( | |
| 394 | 추가: shown.iter().any(|(text, _)| text == DIALOG_UNAVAILABLE), | |
| 395 | 추가: failed, | |
| 396 | 추가: "{purpose:?}" | |
| 397 | 추가: ); | |
| 398 | 추가: assert_eq!(factory.state.borrow().starts.len(), 1, "{purpose:?}"); | |
| 399 | 추가: assert!(!app.model.busy()); | |
| 400 | 추가: assert_eq!(dialogs.0.borrow().requests.last().unwrap().purpose, purpose); | |
| 401 | 추가: assert_eq!( | |
| 402 | 추가: shown | |
| 403 | 추가: .iter() | |
| 404 | 추가: .filter(|(text, _)| text == DIALOG_UNAVAILABLE) | |
| 405 | 추가: .count(), | |
| 406 | 추가: usize::from(failed) | |
| 407 | 추가: ); | |
| 408 | 추가: if failed { | |
| 409 | 추가: dialogs.0.borrow_mut().error = None; | |
| 410 | 추가: policy_click(&ctx, &mut app, label); | |
| 411 | 추가: let recovered = policy_render(&ctx, &mut app, vec![]); | |
| 412 | 추가: assert!(!recovered.iter().any(|(text, _)| text == DIALOG_UNAVAILABLE)); | |
| 413 | 추가: assert_eq!(factory.state.borrow().starts.len(), 1); | |
| 414 | 추가: } | |
| 415 | 추가: } | |
| 416 | 추가: } | |
| 417 | 추가: } |
| @@ -18,6 +18,8 @@ Enter는 초점이 있는 버튼만 활성화하며 암호 입력란 제출만 | ||
| 18 | 18 | |
| 19 | 19 | 단일 파일 GZ는 운영체제 저장 창에서 출력 이름과 위치를 선택하며 TAR.GZ는 폴더 선택을 유지함. 빈 이름, 금지 문자와 예약 이름은 안전한 기본 이름으로 제안하고 반환된 이름도 검증함. native_dialog_flows.rs는 GZ의 취소, 충돌 뒤 이름 변경, 원본 보존과 대소문자 ZIP 열기를 실제 작업자로 확인함. native_dialogs.rs는 확장자 대소문자 조합 30개와 모든 파일 선택지 및 GZ 기본 이름을 검증함. |
| 20 | 20 | |
| 21 | 추가: Linux는 rfd가 사용하는 기존 ashpd backend의 오류 응답을 직접 받아 사용자 취소와 구분함. portal_response_distinguishes_cancellation_from_backend_failure는 취소 코드, backend 실패와 잘못된 성공 응답을 구분함. missing_portal_returns_errors_for_every_dialog는 별도 자식 프로세스의 연결 불가 bus로 실제 native backend 8개 경로를 확인하며 부모의 세션 환경은 바꾸지 않음. dialog_failures_show_alerts_while_cancelled_dialogs_remain_silent는 열기, 파일 추가, 폴더 추가, 풀 위치, ZIP 저장과 GZ 저장에서 실패 안내와 취소 무작업을 대조함. | |
| 22 | 추가: | |
| 21 | 23 | ## 화면 재현 |
| 22 | 24 | |
| 23 | 25 | Xvfb, xdotool, ImageMagick import와 시스템 CJK 글꼴이 필요함. 촬영 실행 파일은 실제 eframe 컴포넌트에 합성 목록을 전달하며 압축파일을 읽거나 결과물을 저장하지 않음. |
| @@ -29,7 +29,19 @@ def capture(binary, variant, state, output, environment, width, height): | ||
| 29 | 29 | automatic.rmdir() |
| 30 | 30 | except OSError: |
| 31 | 31 | pass |
| 32 | 삭제: mode = "opened" if state in {"picker", "selected-empty"} else state | |
| 32 | 추가: environment = dict(environment) | |
| 33 | 추가: if state in {"dialog-unavailable", "create-dialog-unavailable"}: | |
| 34 | 추가: endpoint = ROOT / "tests/ui-redesign/runs/no-portal-bus" | |
| 35 | 추가: if endpoint.exists(): | |
| 36 | 추가: raise RuntimeError("실패 시험용 bus 경로가 이미 존재함") | |
| 37 | 추가: environment["DBUS_SESSION_BUS_ADDRESS"] = f"unix:path={endpoint}" | |
| 38 | 추가: environment.pop("DBUS_STARTER_ADDRESS", None) | |
| 39 | 추가: mode = { | |
| 40 | 추가: "picker": "opened", | |
| 41 | 추가: "selected-empty": "opened", | |
| 42 | 추가: "dialog-unavailable": "toolbar-root", | |
| 43 | 추가: "create-dialog-unavailable": "toolbar-create", | |
| 44 | 추가: }.get(state, state) | |
| 33 | 45 | log = ROOT / "tests/ui-redesign/runs" / f"{variant}-{state}.log" |
| 34 | 46 | with log.open("w") as stream: |
| 35 | 47 | app = subprocess.Popen([str(binary), mode], cwd=ROOT, env=environment, stdout=stream, stderr=stream) |
| @@ -55,6 +67,10 @@ def capture(binary, variant, state, output, environment, width, height): | ||
| 55 | 67 | command(["xdotool", "mousemove", "--window", window, str(x), str(y), "click", "1"], environment) |
| 56 | 68 | time.sleep(0.4) |
| 57 | 69 | |
| 70 | 추가: if state == "dialog-unavailable": | |
| 71 | 추가: click(70, 45) | |
| 72 | 추가: elif state == "create-dialog-unavailable": | |
| 73 | 추가: click(width // 2 - 250, height // 2 + 54) | |
| 58 | 74 | if state == "create" or (state == "create-filled" and variant == "before"): |
| 59 | 75 | click(180 if variant == "before" else width - 90, 18 if variant == "before" else 40) |
| 60 | 76 | if state == "create-filled" and variant == "before": |
| @@ -0,0 +1,14 @@ | ||
| 1 | 추가: [ | |
| 2 | 추가: { | |
| 3 | 추가: "state": "dialog-unavailable", | |
| 4 | 추가: "path": "tests/ui-redesign/screenshots/portal-failure/dialog-unavailable.png", | |
| 5 | 추가: "width": 1060, | |
| 6 | 추가: "height": 720 | |
| 7 | 추가: }, | |
| 8 | 추가: { | |
| 9 | 추가: "state": "create-dialog-unavailable", | |
| 10 | 추가: "path": "tests/ui-redesign/screenshots/portal-failure/create-dialog-unavailable.png", | |
| 11 | 추가: "width": 1060, | |
| 12 | 추가: "height": 720 | |
| 13 | 추가: } | |
| 14 | 추가: ] |
바이너리 파일이라 Diff를 표시하지 않아요.
파일 내려받기바이너리 파일이라 Diff를 표시하지 않아요.
파일 내려받기