use cbf::data::execution::BrowsingContextExecutionState;
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum ChromeTabExecutionState {
Running,
Suspended,
}
impl From<BrowsingContextExecutionState> for ChromeTabExecutionState {
fn from(value: BrowsingContextExecutionState) -> Self {
match value {
BrowsingContextExecutionState::Running => Self::Running,
BrowsingContextExecutionState::Suspended => Self::Suspended,
}
}
}
impl From<ChromeTabExecutionState> for BrowsingContextExecutionState {
fn from(value: ChromeTabExecutionState) -> Self {
match value {
ChromeTabExecutionState::Running => Self::Running,
ChromeTabExecutionState::Suspended => Self::Suspended,
}
}
}
#[cfg(test)]
mod tests {
use cbf::data::execution::BrowsingContextExecutionState;
use super::ChromeTabExecutionState;
#[test]
fn execution_state_round_trips_between_generic_and_chrome_types() {
let state = ChromeTabExecutionState::from(BrowsingContextExecutionState::Suspended);
assert_eq!(state, ChromeTabExecutionState::Suspended);
assert_eq!(
BrowsingContextExecutionState::from(state),
BrowsingContextExecutionState::Suspended
);
}
}