Return file drops to setup tab
This commit is contained in:
parent
e93bc13206
commit
db290555a5
|
|
@ -147,6 +147,7 @@ impl App {
|
|||
self.error = None;
|
||||
}
|
||||
fn set_input(&mut self, path: PathBuf) {
|
||||
self.tab = Tab::Setup;
|
||||
self.input = path.to_string_lossy().into();
|
||||
self.output = path.with_extension("ontime.json").to_string_lossy().into();
|
||||
self.profile = "{}".into();
|
||||
|
|
@ -853,6 +854,22 @@ mod tests {
|
|||
);
|
||||
assert!(!output.shapes.is_empty());
|
||||
}
|
||||
fn drop_file(app: &mut App, path: PathBuf) {
|
||||
let ctx = egui::Context::default();
|
||||
configure_style(&ctx);
|
||||
let mut input = egui::RawInput {
|
||||
screen_rect: Some(egui::Rect::from_min_size(
|
||||
egui::Pos2::ZERO,
|
||||
egui::vec2(860.0, 620.0),
|
||||
)),
|
||||
..Default::default()
|
||||
};
|
||||
input.dropped_files.push(egui::DroppedFile {
|
||||
path: Some(path),
|
||||
..Default::default()
|
||||
});
|
||||
let _ = ctx.run(input, |ctx| app.draw(ctx));
|
||||
}
|
||||
fn wait(app: &mut App) {
|
||||
let deadline = std::time::Instant::now() + Duration::from_secs(5);
|
||||
while app.rx.is_some() {
|
||||
|
|
@ -895,6 +912,20 @@ mod tests {
|
|||
assert!(app.error.is_some());
|
||||
frame(&mut app, 860.0, 620.0);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn dropping_a_new_workbook_returns_to_setup() {
|
||||
let mut app = App {
|
||||
tab: Tab::Details,
|
||||
..App::default()
|
||||
};
|
||||
let source = fixture();
|
||||
drop_file(&mut app, source.clone());
|
||||
assert!(app.tab == Tab::Setup);
|
||||
assert_eq!(PathBuf::from(&app.input), source);
|
||||
assert!(app.rx.is_some());
|
||||
wait(&mut app);
|
||||
}
|
||||
#[test]
|
||||
fn errors_cancellation_and_changed_inputs_invalidate_exports() {
|
||||
let mut app = App {
|
||||
|
|
|
|||
Loading…
Reference in New Issue