cbf_chrome/data/
execution.rs1use cbf::data::execution::BrowsingContextExecutionState;
4
5#[derive(Debug, Clone, Copy, PartialEq, Eq)]
7pub enum ChromeTabExecutionState {
8 Running,
9 Suspended,
10}
11
12impl From<BrowsingContextExecutionState> for ChromeTabExecutionState {
13 fn from(value: BrowsingContextExecutionState) -> Self {
14 match value {
15 BrowsingContextExecutionState::Running => Self::Running,
16 BrowsingContextExecutionState::Suspended => Self::Suspended,
17 }
18 }
19}
20
21impl From<ChromeTabExecutionState> for BrowsingContextExecutionState {
22 fn from(value: ChromeTabExecutionState) -> Self {
23 match value {
24 ChromeTabExecutionState::Running => Self::Running,
25 ChromeTabExecutionState::Suspended => Self::Suspended,
26 }
27 }
28}
29
30#[cfg(test)]
31mod tests {
32 use cbf::data::execution::BrowsingContextExecutionState;
33
34 use super::ChromeTabExecutionState;
35
36 #[test]
37 fn execution_state_round_trips_between_generic_and_chrome_types() {
38 let state = ChromeTabExecutionState::from(BrowsingContextExecutionState::Suspended);
39
40 assert_eq!(state, ChromeTabExecutionState::Suspended);
41 assert_eq!(
42 BrowsingContextExecutionState::from(state),
43 BrowsingContextExecutionState::Suspended
44 );
45 }
46}