added start of next module
This commit is contained in:
parent
023fd854a1
commit
ef8fbbd444
3 changed files with 31 additions and 30 deletions
|
@ -12,3 +12,16 @@ pub enum Scenes {
|
|||
|
||||
Augmented
|
||||
}
|
||||
|
||||
#[derive(Debug, PartialEq, Clone)]
|
||||
pub enum StateUpdate {
|
||||
StreamRunning(bool),
|
||||
StreamIsMuted(bool),
|
||||
ComputerSoundIsOn(bool),
|
||||
ChangeSceneOnChangeSlideHotkey(bool),
|
||||
SceneIsAugmented(bool),
|
||||
TimerCanRun(bool),
|
||||
TimerLength(f32),
|
||||
TimerText(String),
|
||||
Scene(Scenes),
|
||||
}
|
|
@ -1,17 +1,4 @@
|
|||
use super::enums::{self};
|
||||
|
||||
#[derive(Debug, PartialEq, Clone)]
|
||||
pub enum StateUpdate {
|
||||
StreamRunning(bool),
|
||||
StreamIsMuted(bool),
|
||||
ComputerSoundIsOn(bool),
|
||||
ChangeSceneOnChangeSlideHotkey(bool),
|
||||
SceneIsAugmented(bool),
|
||||
TimerCanRun(bool),
|
||||
TimerLength(f32),
|
||||
TimerText(String),
|
||||
Scene(enums::Scenes),
|
||||
}
|
||||
use super::enums::{self, StateUpdate};
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct StreamStates {
|
||||
|
|
|
@ -2,6 +2,7 @@ use std::sync::mpsc;
|
|||
use std::thread;
|
||||
|
||||
use crate::modules::stream_states as s_s;
|
||||
use crate::modules::stream_states::enums::{StateUpdate};
|
||||
|
||||
#[test]
|
||||
fn has_all_enums() {
|
||||
|
@ -50,37 +51,37 @@ fn scene_correctness(){
|
|||
assert_eq!(stream_state.get_current_camera_sub_scene(), s_s::enums::Scenes::CameraDefault);
|
||||
assert_eq!(stream_state.get_current_screen_sub_scene(), s_s::enums::Scenes::ScreenDefault);
|
||||
|
||||
stream_state = stream_state.update(s_s::stream_states_class::StateUpdate::Scene(s_s::enums::Scenes::CameraWithUpperRight));
|
||||
stream_state = stream_state.update(StateUpdate::Scene(s_s::enums::Scenes::CameraWithUpperRight));
|
||||
|
||||
assert_eq!(stream_state.get_current_scene(), s_s::enums::Scenes::CameraWithUpperRight);
|
||||
assert_eq!(stream_state.get_current_camera_sub_scene(), s_s::enums::Scenes::CameraWithUpperRight);
|
||||
assert_eq!(stream_state.get_current_screen_sub_scene(), s_s::enums::Scenes::ScreenDefault);
|
||||
|
||||
stream_state = stream_state.update(s_s::stream_states_class::StateUpdate::Scene(s_s::enums::Scenes::CameraWithLargeUpperRight));
|
||||
stream_state = stream_state.update(StateUpdate::Scene(s_s::enums::Scenes::CameraWithLargeUpperRight));
|
||||
|
||||
assert_eq!(stream_state.get_current_scene(), s_s::enums::Scenes::CameraWithLargeUpperRight);
|
||||
assert_eq!(stream_state.get_current_camera_sub_scene(), s_s::enums::Scenes::CameraWithLargeUpperRight);
|
||||
assert_eq!(stream_state.get_current_screen_sub_scene(), s_s::enums::Scenes::ScreenDefault);
|
||||
|
||||
stream_state = stream_state.update(s_s::stream_states_class::StateUpdate::Scene(s_s::enums::Scenes::CameraWithLowerRight));
|
||||
stream_state = stream_state.update(StateUpdate::Scene(s_s::enums::Scenes::CameraWithLowerRight));
|
||||
|
||||
assert_eq!(stream_state.get_current_scene(), s_s::enums::Scenes::CameraWithLowerRight);
|
||||
assert_eq!(stream_state.get_current_camera_sub_scene(), s_s::enums::Scenes::CameraWithLowerRight);
|
||||
assert_eq!(stream_state.get_current_screen_sub_scene(), s_s::enums::Scenes::ScreenDefault);
|
||||
|
||||
stream_state = stream_state.update(s_s::stream_states_class::StateUpdate::Scene(s_s::enums::Scenes::ScreenDefault));
|
||||
stream_state = stream_state.update(StateUpdate::Scene(s_s::enums::Scenes::ScreenDefault));
|
||||
|
||||
assert_eq!(stream_state.get_current_scene(), s_s::enums::Scenes::ScreenDefault);
|
||||
assert_eq!(stream_state.get_current_screen_sub_scene(), s_s::enums::Scenes::ScreenDefault);
|
||||
assert_eq!(stream_state.get_current_camera_sub_scene(), s_s::enums::Scenes::CameraWithLowerRight);
|
||||
|
||||
stream_state = stream_state.update(s_s::stream_states_class::StateUpdate::Scene(s_s::enums::Scenes::ScreenWithLowerRight));
|
||||
stream_state = stream_state.update(StateUpdate::Scene(s_s::enums::Scenes::ScreenWithLowerRight));
|
||||
|
||||
assert_eq!(stream_state.get_current_scene(), s_s::enums::Scenes::ScreenWithLowerRight);
|
||||
assert_eq!(stream_state.get_current_screen_sub_scene(), s_s::enums::Scenes::ScreenWithLowerRight);
|
||||
assert_eq!(stream_state.get_current_camera_sub_scene(), s_s::enums::Scenes::CameraWithLowerRight);
|
||||
|
||||
stream_state = stream_state.update(s_s::stream_states_class::StateUpdate::Scene(s_s::enums::Scenes::ScreenWithUpperRight));
|
||||
stream_state = stream_state.update(StateUpdate::Scene(s_s::enums::Scenes::ScreenWithUpperRight));
|
||||
|
||||
assert_eq!(stream_state.get_current_scene(), s_s::enums::Scenes::ScreenWithUpperRight);
|
||||
assert_eq!(stream_state.get_current_screen_sub_scene(), s_s::enums::Scenes::ScreenWithUpperRight);
|
||||
|
@ -93,35 +94,35 @@ fn test_updating() {
|
|||
let mut stream_state = s_s::stream_states_class::StreamStates::new();
|
||||
|
||||
assert_eq!(stream_state.timer_can_run, true);
|
||||
stream_state = stream_state.update(s_s::stream_states_class::StateUpdate::TimerCanRun(false));
|
||||
stream_state = stream_state.update(StateUpdate::TimerCanRun(false));
|
||||
assert_eq!(stream_state.timer_can_run, false);
|
||||
|
||||
assert_eq!(stream_state.timer_length, 15.0);
|
||||
stream_state = stream_state.update(s_s::stream_states_class::StateUpdate::TimerLength(7.5));
|
||||
stream_state = stream_state.update(StateUpdate::TimerLength(7.5));
|
||||
assert_eq!(stream_state.timer_length, 7.5);
|
||||
|
||||
assert_eq!(stream_state.timer_text, "0.0");
|
||||
stream_state = stream_state.update(s_s::stream_states_class::StateUpdate::TimerText(String::from("7.5")));
|
||||
stream_state = stream_state.update(StateUpdate::TimerText(String::from("7.5")));
|
||||
assert_eq!(stream_state.timer_text, "7.5");
|
||||
|
||||
assert_eq!(stream_state.stream_running, false);
|
||||
stream_state = stream_state.update(s_s::stream_states_class::StateUpdate::StreamRunning(true));
|
||||
stream_state = stream_state.update(StateUpdate::StreamRunning(true));
|
||||
assert_eq!(stream_state.stream_running, true);
|
||||
|
||||
assert_eq!(stream_state.stream_is_muted, false);
|
||||
stream_state = stream_state.update(s_s::stream_states_class::StateUpdate::StreamIsMuted(true));
|
||||
stream_state = stream_state.update(StateUpdate::StreamIsMuted(true));
|
||||
assert_eq!(stream_state.stream_is_muted, true);
|
||||
|
||||
assert_eq!(stream_state.computer_sound_is_on, true);
|
||||
stream_state = stream_state.update(s_s::stream_states_class::StateUpdate::ComputerSoundIsOn(false));
|
||||
stream_state = stream_state.update(StateUpdate::ComputerSoundIsOn(false));
|
||||
assert_eq!(stream_state.computer_sound_is_on, false);
|
||||
|
||||
assert_eq!(stream_state.change_scene_on_change_slide_hotkey, true);
|
||||
stream_state = stream_state.update(s_s::stream_states_class::StateUpdate::ChangeSceneOnChangeSlideHotkey(false));
|
||||
stream_state = stream_state.update(StateUpdate::ChangeSceneOnChangeSlideHotkey(false));
|
||||
assert_eq!(stream_state.change_scene_on_change_slide_hotkey, false);
|
||||
|
||||
assert_eq!(stream_state.scene_is_augmented, false);
|
||||
stream_state = stream_state.update(s_s::stream_states_class::StateUpdate::SceneIsAugmented(true));
|
||||
stream_state = stream_state.update(StateUpdate::SceneIsAugmented(true));
|
||||
assert_eq!(stream_state.scene_is_augmented, true);
|
||||
}
|
||||
|
||||
|
@ -133,14 +134,14 @@ fn can_run_in_thread() {
|
|||
let rx_thread = thread::spawn(move || {
|
||||
let mut stream_state = s_s::stream_states_class::StreamStates::new();
|
||||
for received in rx {
|
||||
assert_eq!(received, s_s::stream_states_class::StateUpdate::StreamRunning(true));
|
||||
assert_eq!(received, StateUpdate::StreamRunning(true));
|
||||
stream_state = stream_state.update(received);
|
||||
assert_eq!(stream_state.stream_running, true);
|
||||
break;
|
||||
}
|
||||
});
|
||||
|
||||
tx.send(s_s::stream_states_class::StateUpdate::StreamRunning(true)).unwrap();
|
||||
tx.send(StateUpdate::StreamRunning(true)).unwrap();
|
||||
let result = rx_thread.join();
|
||||
match result {
|
||||
Ok(_) => return,
|
||||
|
|
Loading…
Reference in a new issue