settings/display/
display_configuration.rsuse std::rc::Rc;
use std::sync::Mutex;
use serde::{Deserialize, Serialize};
use crate::config::default_settings::DefaultSetting;
use crate::inspect::config_logger::InspectConfigLogger;
#[derive(PartialEq, Debug, Clone, Copy, Serialize, Deserialize)]
pub enum ConfigurationThemeMode {
Auto,
}
#[derive(PartialEq, Debug, Clone, Copy, Serialize, Deserialize)]
pub enum ConfigurationThemeType {
Light,
}
#[derive(PartialEq, Debug, Clone, Deserialize)]
pub struct DisplayConfiguration {
pub theme: ThemeConfiguration,
}
#[derive(PartialEq, Debug, Clone, Deserialize)]
pub struct ThemeConfiguration {
pub theme_mode: Vec<ConfigurationThemeMode>,
pub theme_type: ConfigurationThemeType,
}
pub fn build_display_default_settings(
config_logger: Rc<Mutex<InspectConfigLogger>>,
) -> DefaultSetting<DisplayConfiguration, &'static str> {
DefaultSetting::new(None, "/config/data/display_configuration.json", config_logger)
}
#[cfg(test)]
mod test {
use super::*;
use fuchsia_inspect::component;
#[fuchsia::test(allow_stalls = false)]
async fn test_display_configuration() {
let config_logger =
Rc::new(Mutex::new(InspectConfigLogger::new(component::inspector().root())));
let default_value = build_display_default_settings(config_logger)
.load_default_value()
.expect("Invalid display configuration")
.expect("Unable to parse configuration");
assert_eq!(default_value.theme.theme_mode, vec![ConfigurationThemeMode::Auto]);
assert_eq!(default_value.theme.theme_type, ConfigurationThemeType::Light);
}
}