finished coverage of tests and implementation
This commit is contained in:
parent
25de5872e4
commit
9f83884a18
2 changed files with 23 additions and 15 deletions
|
@ -7,8 +7,8 @@ use serde_json::Value;
|
||||||
#[derive(Debug, PartialEq, Clone)]
|
#[derive(Debug, PartialEq, Clone)]
|
||||||
pub enum StateUpdate {
|
pub enum StateUpdate {
|
||||||
StreamRunning(bool),
|
StreamRunning(bool),
|
||||||
StreamIsMuted(bool),
|
StreamSoundToggleOn(bool),
|
||||||
ComputerSoundIsOn(bool),
|
ToggleComputerSoundOn(bool),
|
||||||
ComputerMediaDoPause(bool),
|
ComputerMediaDoPause(bool),
|
||||||
ChangeSceneOnChangeSlide(bool),
|
ChangeSceneOnChangeSlide(bool),
|
||||||
SceneIsAugmented(bool),
|
SceneIsAugmented(bool),
|
||||||
|
@ -52,7 +52,7 @@ impl StateUpdate {
|
||||||
"Screen_None" => {StateUpdate::SubScene(SubScenes::ScreenDefault)},
|
"Screen_None" => {StateUpdate::SubScene(SubScenes::ScreenDefault)},
|
||||||
"Screen_Top_Right" => {StateUpdate::SubScene(SubScenes::ScreenWithUpperRight)},
|
"Screen_Top_Right" => {StateUpdate::SubScene(SubScenes::ScreenWithUpperRight)},
|
||||||
"Screen_Bottom_Right" => {StateUpdate::SubScene(SubScenes::ScreenWithLowerRight)},
|
"Screen_Bottom_Right" => {StateUpdate::SubScene(SubScenes::ScreenWithLowerRight)},
|
||||||
_ => {panic!("unkown SubScene! {}", subscene)}
|
_ => {panic!("unknown SubScene! {}", subscene)}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -61,13 +61,14 @@ impl StateUpdate {
|
||||||
"Change_With_Clicker" => {StateUpdate::ChangeSceneOnChangeSlide(string_to_bool(incoming_json["data"].as_str().unwrap()))},
|
"Change_With_Clicker" => {StateUpdate::ChangeSceneOnChangeSlide(string_to_bool(incoming_json["data"].as_str().unwrap()))},
|
||||||
"Timer_Length" => {
|
"Timer_Length" => {
|
||||||
let new_timer_length = &incoming_json["data"];
|
let new_timer_length = &incoming_json["data"];
|
||||||
StateUpdate::TimerLength(new_timer_length.as_f64().unwrap() as f32)
|
StateUpdate::TimerLength(new_timer_length.as_str().unwrap().parse::<f32>().unwrap())
|
||||||
},
|
},
|
||||||
|
|
||||||
//Extra Toggles
|
//Extra Toggles
|
||||||
"Toggle_Computer_Volume" => {StateUpdate::ComputerSoundIsOn(string_to_bool(incoming_json["data"].as_str().unwrap()))},
|
"Toggle_Computer_Volume" => {StateUpdate::ToggleComputerSoundOn(string_to_bool(incoming_json["data"].as_str().unwrap()))},
|
||||||
"Toggle_Stream_Volume" => {StateUpdate::StreamIsMuted(string_to_bool(incoming_json["data"].as_str().unwrap()))},
|
"Toggle_Stream_Volume" => {StateUpdate::StreamSoundToggleOn(string_to_bool(incoming_json["data"].as_str().unwrap()))},
|
||||||
"Media_Pause_Play" => {StateUpdate::ComputerMediaDoPause(string_to_bool(incoming_json["data"].as_str().unwrap()))},
|
"Media_Pause_Play" => {StateUpdate::ComputerMediaDoPause(string_to_bool(incoming_json["data"].as_str().unwrap()))},
|
||||||
|
"Timer_Text" => {StateUpdate::TimerText(incoming_json["data"].as_str().unwrap().to_string())}
|
||||||
|
|
||||||
"all" => {StateUpdate::UpdateClient},
|
"all" => {StateUpdate::UpdateClient},
|
||||||
|
|
||||||
|
@ -89,10 +90,10 @@ impl StateUpdate {
|
||||||
let (update_type, data) = match self {
|
let (update_type, data) = match self {
|
||||||
StateUpdate::StreamRunning(is_true) => {
|
StateUpdate::StreamRunning(is_true) => {
|
||||||
("Stream_Running", is_true.to_string())},
|
("Stream_Running", is_true.to_string())},
|
||||||
StateUpdate::StreamIsMuted(is_true) => {
|
StateUpdate::StreamSoundToggleOn(is_true) => {
|
||||||
("Stream_Is_Muted", is_true.to_string())},
|
("Toggle_Stream_Volume", is_true.to_string())},
|
||||||
StateUpdate::ComputerSoundIsOn(is_true) => {
|
StateUpdate::ToggleComputerSoundOn(is_true) => {
|
||||||
("Computer_Sound_Is_On", is_true.to_string())},
|
("Toggle_Computer_Volume", is_true.to_string())},
|
||||||
StateUpdate::ChangeSceneOnChangeSlide(is_true) => {
|
StateUpdate::ChangeSceneOnChangeSlide(is_true) => {
|
||||||
("Change_With_Clicker", is_true.to_string())},
|
("Change_With_Clicker", is_true.to_string())},
|
||||||
StateUpdate::SceneIsAugmented(is_true) => {
|
StateUpdate::SceneIsAugmented(is_true) => {
|
||||||
|
@ -109,8 +110,15 @@ impl StateUpdate {
|
||||||
("Scene", scene.to_string())},
|
("Scene", scene.to_string())},
|
||||||
StateUpdate::ComputerMediaDoPause(is_true) => {
|
StateUpdate::ComputerMediaDoPause(is_true) => {
|
||||||
("Toggle_Computer_Volume", is_true.to_string())},
|
("Toggle_Computer_Volume", is_true.to_string())},
|
||||||
StateUpdate::ChangeSlide(value) => todo!(),
|
StateUpdate::ChangeSlide(value) => {
|
||||||
StateUpdate::UpdateClient => todo!(),
|
match value {
|
||||||
|
SlideChange::Next => {("Next_Slide", "".to_string())},
|
||||||
|
SlideChange::Previous => {("Prev_Slide", "".to_string())},
|
||||||
|
}
|
||||||
|
},
|
||||||
|
StateUpdate::UpdateClient => {
|
||||||
|
("all", "".to_string())
|
||||||
|
},
|
||||||
};
|
};
|
||||||
serde_json::json!({
|
serde_json::json!({
|
||||||
"type": "update",
|
"type": "update",
|
||||||
|
|
|
@ -112,11 +112,11 @@ fn test_updating() {
|
||||||
assert_eq!(stream_state.stream_running, true);
|
assert_eq!(stream_state.stream_running, true);
|
||||||
|
|
||||||
assert_eq!(stream_state.stream_is_muted, false);
|
assert_eq!(stream_state.stream_is_muted, false);
|
||||||
stream_state.update(StateUpdate::StreamIsMuted(true));
|
stream_state.update(StateUpdate::StreamSoundToggleOn(true));
|
||||||
assert_eq!(stream_state.stream_is_muted, true);
|
assert_eq!(stream_state.stream_is_muted, true);
|
||||||
|
|
||||||
assert_eq!(stream_state.computer_sound_is_on, true);
|
assert_eq!(stream_state.computer_sound_is_on, true);
|
||||||
stream_state.update(StateUpdate::ComputerSoundIsOn(false));
|
stream_state.update(StateUpdate::ToggleComputerSoundOn(false));
|
||||||
assert_eq!(stream_state.computer_sound_is_on, false);
|
assert_eq!(stream_state.computer_sound_is_on, false);
|
||||||
|
|
||||||
assert_eq!(stream_state.change_scene_on_change_slide_hotkey, true);
|
assert_eq!(stream_state.change_scene_on_change_slide_hotkey, true);
|
||||||
|
|
Loading…
Reference in a new issue