waft_test/
caption_style.rs1use std::cell::RefCell;
5use std::rc::Rc;
6
7use waft_embedder::{CaptionSettings, CaptionStyle, MediaChangeFuture};
8
9use crate::media::Changes;
10
11#[derive(Clone)]
14pub struct MockCaptionSettings(Rc<CaptionSettingsShared>);
15
16struct CaptionSettingsShared {
17 style: RefCell<CaptionStyle>,
18 changes: Changes,
19}
20
21impl MockCaptionSettings {
22 pub fn new(style: CaptionStyle) -> MockCaptionSettings {
24 MockCaptionSettings(Rc::new(CaptionSettingsShared {
25 style: RefCell::new(style),
26 changes: Changes::default(),
27 }))
28 }
29
30 pub fn set_style(&self, style: CaptionStyle) {
33 *self.0.style.borrow_mut() = style;
34 self.0.changes.notify();
35 }
36}
37
38impl CaptionSettings for MockCaptionSettings {
39 fn style(&self) -> CaptionStyle {
40 self.0.style.borrow().clone()
41 }
42
43 fn changed(&self) -> MediaChangeFuture {
44 self.0.changes.next()
45 }
46}