ferroui_base/diagnostics/
value_store_diagnostic.rs1use super::IValueFrameDiagnostic;
2use std::rc::Rc;
3
4pub struct ValueStoreDiagnostic {
6 applied_frames: Vec<Rc<dyn IValueFrameDiagnostic>>,
7}
8
9impl ValueStoreDiagnostic {
10 pub(crate) fn new(applied_frames: Vec<Rc<dyn IValueFrameDiagnostic>>) -> Self {
11 Self { applied_frames }
12 }
13
14 pub fn applied_frames(&self) -> &[Rc<dyn IValueFrameDiagnostic>] {
16 &self.applied_frames
17 }
18}
19
20#[cfg(test)]
21mod tests {
22 use crate::data::BindingPriority;
25 use crate::diagnostics::{FerroObjectDiagnosticExtensions, IValueFrameDiagnosticFrameType};
26 use crate::styling::{Style, ThemeVariant};
27
28 #[test]
29 fn an_object_without_values_has_no_frames() {
30 let target = Style::new();
31
32 assert!(target.get_value_store_diagnostic().applied_frames().is_empty());
33 }
34
35 #[test]
36 fn local_values_are_the_first_frame() {
37 let property = ThemeVariant::actual_theme_variant_property();
38 let target = Style::new();
39 target.set_value(property, Some(ThemeVariant::light()));
40
41 let diagnostic = target.get_value_store_diagnostic();
42
43 assert_eq!(1, diagnostic.applied_frames().len());
44 let frame = &diagnostic.applied_frames()[0];
45 assert!(frame.source().is_none());
46 assert_eq!(IValueFrameDiagnosticFrameType::Local, frame.type_());
47 assert!(frame.is_active());
48 assert_eq!(BindingPriority::LocalValue, frame.priority());
49 assert_eq!(1, frame.values().len());
50 assert!(std::ptr::eq(property.as_property(), frame.values()[0].property));
51 }
52}