| | @@ -1063,7 +1063,7 @@ mod widgets { |
| 1063 | 1063 | } |
| 1064 | 1064 | |
| 1065 | 1065 | #[test] |
| 1066 | | -삭제: fn completed_results_keep_folder_action_and_show_durability_only_in_details() { |
| 1066 | +추가: fn completed_results_keep_folder_action_and_distinguish_durability() { |
| 1067 | 1067 | for creating in [false, true] { |
| 1068 | 1068 | for durability in [ |
| 1069 | 1069 | Durability::Synced, |
| | @@ -1127,20 +1127,25 @@ mod widgets { |
| 1127 | 1127 | "{durability:?}: {shown:?}" |
| 1128 | 1128 | ); |
| 1129 | 1129 | assert!(shown.iter().any(|(text, _)| text == "폴더 열기")); |
| 1130 | | -삭제: assert!( |
| 1131 | | -삭제: !shown |
| 1132 | | -삭제: .iter() |
| 1133 | | -삭제: .any(|(text, _)| text == "다시 시도" || text == SYNC_WARNING) |
| 1130 | +추가: assert!(!shown.iter().any(|(text, _)| text == "다시 시도")); |
| 1131 | +추가: assert!(!shown.iter().any(|(text, _)| text == SYNC_WARNING)); |
| 1132 | +추가: assert_eq!( |
| 1133 | +추가: shown.iter().any(|(text, _)| text == "파일을 디스크에 완전히 저장하지 못했습니다. 풀 위치 폴더를 확인하세요."), |
| 1134 | +추가: durability == Durability::Failed |
| 1134 | 1135 | ); |
| 1135 | 1136 | policy_click(&ctx, &mut app, "자세히 보기"); |
| 1136 | 1137 | let details = policy_render(&ctx, &mut app, vec![]); |
| 1137 | 1138 | assert_eq!( |
| 1138 | 1139 | details.iter().any(|(text, _)| text == SYNC_WARNING), |
| 1139 | | -삭제: durability != Durability::Synced |
| 1140 | +추가: durability == Durability::Unconfirmed |
| 1140 | 1141 | ); |
| 1141 | 1142 | policy_click(&ctx, &mut app, "자세히 닫기"); |
| 1142 | 1143 | let closed = policy_render(&ctx, &mut app, vec![]); |
| 1143 | 1144 | assert!(!closed.iter().any(|(text, _)| text == SYNC_WARNING)); |
| 1145 | +추가: assert_eq!( |
| 1146 | +추가: closed.iter().any(|(text, _)| text == "파일을 디스크에 완전히 저장하지 못했습니다. 풀 위치 폴더를 확인하세요."), |
| 1147 | +추가: durability == Durability::Failed |
| 1148 | +추가: ); |
| 1144 | 1149 | assert!(closed.iter().any(|(text, _)| text == "폴더 열기")); |
| 1145 | 1150 | } |
| 1146 | 1151 | } |
| | @@ -1153,86 +1158,103 @@ mod widgets { |
| 1153 | 1158 | (Outcome::Failed, Publication::None, 0, 1), |
| 1154 | 1159 | (Outcome::Failed, Publication::Partial, 1, 2), |
| 1155 | 1160 | ] { |
| 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); |
| 1161 | +추가: for durability in [ |
| 1162 | +추가: Durability::Synced, |
| 1163 | +추가: Durability::Unconfirmed, |
| 1164 | +추가: Durability::Failed, |
| 1165 | +추가: ] { |
| 1166 | +추가: let scratch = Folder::new(); |
| 1167 | +추가: let factory = FakeFactory::default(); |
| 1168 | +추가: let mut app = loaded(&scratch, &factory); |
| 1169 | +추가: app.model.entries = (0..expected_files) |
| 1170 | +추가: .map(|id| Entry { |
| 1171 | +추가: id, |
| 1172 | +추가: name: format!("{id}.txt"), |
| 1173 | +추가: kind: Kind::File, |
| 1174 | +추가: bytes: Some(1), |
| 1175 | +추가: packed: None, |
| 1176 | +추가: encrypted: false, |
| 1177 | +추가: }) |
| 1178 | +추가: .collect(); |
| 1179 | +추가: factory.state.borrow_mut().manual = true; |
| 1180 | +추가: assert!(app.begin_extract()); |
| 1181 | +추가: { |
| 1182 | +추가: let mut worker = factory.state.borrow_mut(); |
| 1183 | +추가: worker.frame(Event::Accepted { encryption: false }); |
| 1184 | +추가: if saved > 0 { |
| 1185 | +추가: worker.frame(Event::Output { |
| 1186 | +추가: entry_id: Some(0), |
| 1187 | +추가: relative_name: "0.txt".into(), |
| 1188 | +추가: disposition: Disposition::Created, |
| 1189 | +추가: }); |
| 1190 | +추가: } |
| 1191 | +추가: worker.finish(outcome, publication); |
| 1192 | +추가: for event in &mut worker.queue { |
| 1193 | +추가: if let HostEvent::Frame { |
| 1194 | +추가: event: Event::Terminal(terminal), |
| 1195 | +추가: .. |
| 1196 | +추가: } = event |
| 1197 | +추가: { |
| 1198 | +추가: terminal.created_count = saved; |
| 1199 | +추가: terminal.durability = durability; |
| 1200 | +추가: terminal.error = (outcome == Outcome::Failed).then_some(ErrorCode::Io); |
| 1201 | +추가: } |
| 1191 | 1202 | } |
| 1192 | 1203 | } |
| 1204 | +추가: let ctx = egui::Context::default(); |
| 1205 | +추가: for _ in 0..30 { |
| 1206 | +추가: policy_render(&ctx, &mut app, vec![]); |
| 1207 | +추가: } |
| 1208 | +추가: let completed = outcome == Outcome::Completed; |
| 1209 | +추가: let shown = policy_render(&ctx, &mut app, vec![]); |
| 1210 | +추가: let warning = match durability { |
| 1211 | +추가: Durability::Unconfirmed => Some(SYNC_WARNING), |
| 1212 | +추가: Durability::Failed => Some( |
| 1213 | +추가: "파일을 디스크에 완전히 저장하지 못했습니다. 풀 위치 폴더를 확인하세요.", |
| 1214 | +추가: ), |
| 1215 | +추가: _ => None, |
| 1216 | +추가: }; |
| 1217 | +추가: let visible = |
| 1218 | +추가: warning.is_some() && !(completed && durability == Durability::Unconfirmed); |
| 1219 | +추가: assert_eq!( |
| 1220 | +추가: shown.iter().any(|(text, _)| Some(text.as_str()) == warning), |
| 1221 | +추가: visible, |
| 1222 | +추가: "{outcome:?}/{publication:?}: {shown:?}" |
| 1223 | +추가: ); |
| 1224 | +추가: assert_eq!(shown.iter().any(|(text, _)| text == "폴더 열기"), completed); |
| 1225 | +추가: assert_eq!( |
| 1226 | +추가: shown.iter().any(|(text, _)| text == "압축을 풀었습니다"), |
| 1227 | +추가: completed |
| 1228 | +추가: ); |
| 1229 | +추가: assert_eq!( |
| 1230 | +추가: shown |
| 1231 | +추가: .iter() |
| 1232 | +추가: .any(|(text, _)| text == "압축을 풀지 못했습니다"), |
| 1233 | +추가: !completed |
| 1234 | +추가: ); |
| 1235 | +추가: assert_eq!( |
| 1236 | +추가: shown.iter().any(|(text, _)| text == PARTIAL), |
| 1237 | +추가: publication == Publication::Partial |
| 1238 | +추가: ); |
| 1239 | +추가: policy_click(&ctx, &mut app, "자세히 보기"); |
| 1240 | +추가: let details = policy_render(&ctx, &mut app, vec![]); |
| 1241 | +추가: assert_eq!( |
| 1242 | +추가: details |
| 1243 | +추가: .iter() |
| 1244 | +추가: .filter(|(text, _)| Some(text.as_str()) == warning) |
| 1245 | +추가: .count(), |
| 1246 | +추가: usize::from(warning.is_some()), |
| 1247 | +추가: "{outcome:?}/{publication:?}: {details:?}" |
| 1248 | +추가: ); |
| 1249 | +추가: policy_click(&ctx, &mut app, "자세히 닫기"); |
| 1250 | +추가: let closed = policy_render(&ctx, &mut app, vec![]); |
| 1251 | +추가: assert_eq!( |
| 1252 | +추가: closed |
| 1253 | +추가: .iter() |
| 1254 | +추가: .any(|(text, _)| Some(text.as_str()) == warning), |
| 1255 | +추가: visible |
| 1256 | +추가: ); |
| 1193 | 1257 | } |
| 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 | 1258 | } |
| 1237 | 1259 | } |
| 1238 | 1260 | |