settings/display/
display_configuration.rs1use std::rc::Rc;
10use std::sync::Mutex;
11
12use serde::{Deserialize, Serialize};
13
14use crate::config::default_settings::DefaultSetting;
15use crate::inspect::config_logger::InspectConfigLogger;
16
17#[derive(PartialEq, Debug, Clone, Copy, Serialize, Deserialize)]
20pub enum ConfigurationThemeMode {
21 Auto,
22}
23
24#[derive(PartialEq, Debug, Clone, Copy, Serialize, Deserialize)]
27pub enum ConfigurationThemeType {
28 Light,
29}
30
31#[derive(PartialEq, Debug, Clone, Deserialize)]
34pub struct DisplayConfiguration {
35 pub theme: ThemeConfiguration,
36}
37
38#[derive(PartialEq, Debug, Clone, Deserialize)]
41pub struct ThemeConfiguration {
42 pub theme_mode: Vec<ConfigurationThemeMode>,
43 pub theme_type: ConfigurationThemeType,
44}
45
46pub fn build_display_default_settings(
47 config_logger: Rc<Mutex<InspectConfigLogger>>,
48) -> DefaultSetting<DisplayConfiguration, &'static str> {
49 DefaultSetting::new(None, "/config/data/display_configuration.json", config_logger)
50}
51
52#[cfg(test)]
53mod test {
54 use super::*;
55 use fuchsia_inspect::component;
56
57 #[fuchsia::test(allow_stalls = false)]
58 async fn test_display_configuration() {
59 let config_logger =
60 Rc::new(Mutex::new(InspectConfigLogger::new(component::inspector().root())));
61 let default_value = build_display_default_settings(config_logger)
62 .load_default_value()
63 .expect("Invalid display configuration")
64 .expect("Unable to parse configuration");
65
66 assert_eq!(default_value.theme.theme_mode, vec![ConfigurationThemeMode::Auto]);
67 assert_eq!(default_value.theme.theme_type, ConfigurationThemeType::Light);
68 }
69}