From 1699c771c8d09aa3354c1821bbea14bb34064895 Mon Sep 17 00:00:00 2001 From: Nickiel12 <35903114+Nickiel12@users.noreply.github.com> Date: Fri, 10 Dec 2021 16:02:18 -0800 Subject: [PATCH] added basic enums --- src/modules/stream_states/enums.rs | 5 +-- .../stream_states/stream_states_class.rs | 44 +++++++++++++++++++ src/tests/stream_states_tests.rs | 37 +++++++++++++--- src/tests/tests.rs | 2 - 4 files changed, 76 insertions(+), 12 deletions(-) diff --git a/src/modules/stream_states/enums.rs b/src/modules/stream_states/enums.rs index cc03ac1..5874c16 100644 --- a/src/modules/stream_states/enums.rs +++ b/src/modules/stream_states/enums.rs @@ -1,12 +1,11 @@ -pub enum CameraScenes { +#[derive(PartialEq, Debug)] +pub enum Scenes { CameraDefault, CameraWithUpperRight, CameraWithLargeUpperRight, CameraWithLowerRight, -} -pub enum ScreenScenes { ScreenDefault, ScreenWithUpperRight, ScreenWithLowerRight, diff --git a/src/modules/stream_states/stream_states_class.rs b/src/modules/stream_states/stream_states_class.rs index 139597f..534fadf 100644 --- a/src/modules/stream_states/stream_states_class.rs +++ b/src/modules/stream_states/stream_states_class.rs @@ -1,2 +1,46 @@ +use super::enums::{self}; +pub struct StreamStates { + pub stream_running: bool, + pub stream_is_muted: bool, + pub computer_sound_is_on: bool, + + pub change_scene_on_change_slide_hotkey: bool, + pub scene_is_augmented: bool, + + pub timer_can_run: bool, + pub timer_length: f32, + pub timer_text: String, + + pub current_scene: enums::Scenes, + pub camera_sub_scene: enums::Scenes, + pub screen_sub_scene: enums::Scenes, +} + +impl Default for StreamStates { + fn default() -> Self { + StreamStates { + stream_running: false, + stream_is_muted: false, + computer_sound_is_on: true, + + change_scene_on_change_slide_hotkey: true, + scene_is_augmented: false, + + timer_can_run: true, + timer_length: 15.0, + timer_text: String::from("0.0"), + + current_scene: enums::Scenes::CameraDefault, + camera_sub_scene: enums::Scenes::CameraDefault, + screen_sub_scene: enums::Scenes::ScreenDefault, + } + } +} + +impl StreamStates { + pub fn new() -> Self { + StreamStates{..Default::default()} + } +} diff --git a/src/tests/stream_states_tests.rs b/src/tests/stream_states_tests.rs index f36c3cb..247bdf1 100644 --- a/src/tests/stream_states_tests.rs +++ b/src/tests/stream_states_tests.rs @@ -5,20 +5,43 @@ use crate::modules::stream_states as s_s; fn has_all_enums() { { let members = [ - s_s::enums::CameraScenes::CameraDefault, - s_s::enums::CameraScenes::CameraWithUpperRight, - s_s::enums::CameraScenes::CameraWithLowerRight, - s_s::enums::CameraScenes::CameraWithLargeUpperRight, + s_s::enums::Scenes::CameraDefault, + s_s::enums::Scenes::CameraWithUpperRight, + s_s::enums::Scenes::CameraWithLowerRight, + s_s::enums::Scenes::CameraWithLargeUpperRight, ]; assert_eq!(members.len(), 4); } { let members = [ - s_s::enums::ScreenScenes::ScreenDefault, - s_s::enums::ScreenScenes::ScreenWithUpperRight, - s_s::enums::ScreenScenes::ScreenWithLowerRight, + s_s::enums::Scenes::ScreenDefault, + s_s::enums::Scenes::ScreenWithUpperRight, + s_s::enums::Scenes::ScreenWithLowerRight, ]; assert_eq!(members.len(), 3); } +} +#[test] +fn create_stream_states_class() { + let stream_state = s_s::stream_states_class::StreamStates::new(); + assert_eq!(stream_state.stream_running, false); + assert_eq!(stream_state.stream_is_muted, false); + assert_eq!(stream_state.computer_sound_is_on, true); + assert_eq!(stream_state.change_scene_on_change_slide_hotkey, true); + assert_eq!(stream_state.scene_is_augmented, false); + + assert_eq!(stream_state.timer_text, "0.0"); + assert_eq!(stream_state.timer_length, 15.0); + assert_eq!(stream_state.timer_can_run, true); + + assert_eq!(stream_state.current_scene, s_s::enums::Scenes::CameraDefault); + assert_eq!(stream_state.camera_sub_scene, s_s::enums::Scenes::CameraDefault); + assert_eq!(stream_state.screen_sub_scene, s_s::enums::Scenes::ScreenDefault); + +} + +#[test] +fn sub_scene_correctness(){ + assert_eq!(true, false, "not implemented yet"); } \ No newline at end of file diff --git a/src/tests/tests.rs b/src/tests/tests.rs index 676c985..da13ea1 100644 --- a/src/tests/tests.rs +++ b/src/tests/tests.rs @@ -4,5 +4,3 @@ fn it_works() { let result = 2 + 2; assert_eq!(result, 4); } - -//Stream States Tests