mirror of
https://github.com/gpxstudio/gpx.studio.git
synced 2026-11-01 12:17:18 +00:00
34 lines
954 B
Rust
34 lines
954 B
Rust
//! Shared helpers for the tests of the commands.
|
|||
|
|
|
||
|
|
use std::collections::HashSet;
|
||
|
|
|
||
|
|
use crate::{Clipboard, FileId, FileOrder, Files, Selection, State, TrackpointCategories};
|
||
|
|
|
||
|
|
#[derive(Default)]
|
||
|
|
pub struct Fixture {
|
||
|
|
pub files: Files,
|
||
|
|
pub selection: Selection,
|
||
|
|
pub order: FileOrder,
|
||
|
|
pub clipboard: Option<Clipboard>,
|
||
|
|
pub categories: TrackpointCategories,
|
||
|
|
}
|
||
|
|
|
||
|
|
impl Fixture {
|
||
|
|
pub fn state(&mut self) -> State<'_> {
|
||
|
|
State {
|
||
|
|
categories: &mut self.categories,
|
||
|
|
files: &mut self.files,
|
||
|
|
selection: &mut self.selection,
|
||
|
|
order: &mut self.order,
|
||
|
|
clipboard: &mut self.clipboard,
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
/// Ids of the selected files, empty unless the selection is a file selection.
|
||
|
|
pub fn selected_files(&self) -> HashSet<FileId> {
|
||
|
|
match &self.selection {
|
||
|
|
Selection::File { file_ids } => file_ids.clone(),
|
||
|
|
_ => HashSet::new(),
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|