| | @@ -1146,6 +1146,96 @@ mod widgets { |
| 1146 | 1146 | } |
| 1147 | 1147 | } |
| 1148 | 1148 | |
| 1149 | +추가: #[test] |
| 1150 | +추가: fn durability_warning_visibility_matches_completed_failed_and_partial_results() { |
| 1151 | +추가: for (outcome, publication, saved, expected_files) in [ |
| 1152 | +추가: (Outcome::Completed, Publication::Complete, 1, 1), |
| 1153 | +추가: (Outcome::Failed, Publication::None, 0, 1), |
| 1154 | +추가: (Outcome::Failed, Publication::Partial, 1, 2), |
| 1155 | +추가: ] { |
| 1156 | +추가: let scratch = Folder::new(); |
| 1157 | +추가: let factory = FakeFactory::default(); |
| 1158 | +추가: let mut app = loaded(&scratch, &factory); |
| 1159 | +추가: app.model.entries = (0..expected_files) |
| 1160 | +추가: .map(|id| Entry { |
| 1161 | +추가: id, |
| 1162 | +추가: name: format!("{id}.txt"), |
| 1163 | +추가: kind: Kind::File, |
| 1164 | +추가: bytes: Some(1), |
| 1165 | +추가: packed: None, |
| 1166 | +추가: encrypted: false, |
| 1167 | +추가: }) |
| 1168 | +추가: .collect(); |
| 1169 | +추가: factory.state.borrow_mut().manual = true; |
| 1170 | +추가: assert!(app.begin_extract()); |
| 1171 | +추가: { |
| 1172 | +추가: let mut worker = factory.state.borrow_mut(); |
| 1173 | +추가: worker.frame(Event::Accepted { encryption: false }); |
| 1174 | +추가: if saved > 0 { |
| 1175 | +추가: worker.frame(Event::Output { |
| 1176 | +추가: entry_id: Some(0), |
| 1177 | +추가: relative_name: "0.txt".into(), |
| 1178 | +추가: disposition: Disposition::Created, |
| 1179 | +추가: }); |
| 1180 | +추가: } |
| 1181 | +추가: worker.finish(outcome, publication); |
| 1182 | +추가: for event in &mut worker.queue { |
| 1183 | +추가: if let HostEvent::Frame { |
| 1184 | +추가: event: Event::Terminal(terminal), |
| 1185 | +추가: .. |
| 1186 | +추가: } = event |
| 1187 | +추가: { |
| 1188 | +추가: terminal.created_count = saved; |
| 1189 | +추가: terminal.durability = Durability::Unconfirmed; |
| 1190 | +추가: terminal.error = (outcome == Outcome::Failed).then_some(ErrorCode::Io); |
| 1191 | +추가: } |
| 1192 | +추가: } |
| 1193 | +추가: } |
| 1194 | +추가: let ctx = egui::Context::default(); |
| 1195 | +추가: for _ in 0..30 { |
| 1196 | +추가: policy_render(&ctx, &mut app, vec![]); |
| 1197 | +추가: } |
| 1198 | +추가: let completed = outcome == Outcome::Completed; |
| 1199 | +추가: let shown = policy_render(&ctx, &mut app, vec![]); |
| 1200 | +추가: assert_eq!( |
| 1201 | +추가: shown.iter().any(|(text, _)| text == SYNC_WARNING), |
| 1202 | +추가: !completed, |
| 1203 | +추가: "{outcome:?}/{publication:?}: {shown:?}" |
| 1204 | +추가: ); |
| 1205 | +추가: assert_eq!(shown.iter().any(|(text, _)| text == "폴더 열기"), completed); |
| 1206 | +추가: assert_eq!( |
| 1207 | +추가: shown.iter().any(|(text, _)| text == "압축을 풀었습니다"), |
| 1208 | +추가: completed |
| 1209 | +추가: ); |
| 1210 | +추가: assert_eq!( |
| 1211 | +추가: shown |
| 1212 | +추가: .iter() |
| 1213 | +추가: .any(|(text, _)| text == "압축을 풀지 못했습니다"), |
| 1214 | +추가: !completed |
| 1215 | +추가: ); |
| 1216 | +추가: assert_eq!( |
| 1217 | +추가: shown.iter().any(|(text, _)| text == PARTIAL), |
| 1218 | +추가: publication == Publication::Partial |
| 1219 | +추가: ); |
| 1220 | +추가: policy_click(&ctx, &mut app, "자세히 보기"); |
| 1221 | +추가: let details = policy_render(&ctx, &mut app, vec![]); |
| 1222 | +추가: assert_eq!( |
| 1223 | +추가: details |
| 1224 | +추가: .iter() |
| 1225 | +추가: .filter(|(text, _)| text == SYNC_WARNING) |
| 1226 | +추가: .count(), |
| 1227 | +추가: 1, |
| 1228 | +추가: "{outcome:?}/{publication:?}: {details:?}" |
| 1229 | +추가: ); |
| 1230 | +추가: policy_click(&ctx, &mut app, "자세히 닫기"); |
| 1231 | +추가: let closed = policy_render(&ctx, &mut app, vec![]); |
| 1232 | +추가: assert_eq!( |
| 1233 | +추가: closed.iter().any(|(text, _)| text == SYNC_WARNING), |
| 1234 | +추가: !completed |
| 1235 | +추가: ); |
| 1236 | +추가: } |
| 1237 | +추가: } |
| 1238 | +추가: |
| 1149 | 1239 | fn picker_frame( |
| 1150 | 1240 | ctx: &egui::Context, |
| 1151 | 1241 | picker: &mut Picker, |