scene_management_mocks/
mock_scene_manager.rs1use anyhow::Error;
6use async_trait::async_trait;
7use fidl_fuchsia_ui_views::ViewRef;
8use scene_management::{DisplayMetrics, InjectorViewportSubscriber, SceneManagerTrait};
9use std::cell::Cell;
10use {fidl_fuchsia_ui_app as ui_app, fidl_fuchsia_ui_views as ui_views};
11
12pub struct MockSceneManager {
13 was_present_root_view_called: Cell<bool>,
14 was_set_root_view_called: Cell<bool>,
15 set_root_view_viewport_token: Cell<Option<ui_views::ViewportCreationToken>>,
16 set_root_view_view_ref: Cell<Option<ViewRef>>,
17}
18
19impl MockSceneManager {
20 pub fn new() -> Self {
21 MockSceneManager {
22 was_present_root_view_called: Cell::new(false),
23 was_set_root_view_called: Cell::new(false),
24 set_root_view_viewport_token: Cell::new(None),
25 set_root_view_view_ref: Cell::new(None),
26 }
27 }
28
29 pub fn assert_present_root_view_called(&self) {
30 assert!(self.was_present_root_view_called.get() == true);
31 self.was_present_root_view_called.set(false);
32 }
33
34 pub fn get_set_root_view_called_args(
35 &self,
36 ) -> (ui_views::ViewportCreationToken, Option<ui_views::ViewRef>) {
37 assert!(self.was_set_root_view_called.get() == true);
38 (
39 self.set_root_view_viewport_token
40 .take()
41 .expect("Expected to have a viewport_token from a previous call to set_root_view."),
42 self.set_root_view_view_ref.take(),
43 )
44 }
45}
46
47#[async_trait]
48#[allow(unused_variables)]
49impl SceneManagerTrait for MockSceneManager {
50 fn present_root_view(&self) {
51 self.was_present_root_view_called.set(true);
52 }
53
54 async fn set_root_view(
55 &mut self,
56 viewport_creation_token: ui_views::ViewportCreationToken,
57 view_ref: Option<ui_views::ViewRef>,
58 ) -> Result<(), Error> {
59 self.was_set_root_view_called.set(true);
60 self.set_root_view_viewport_token.set(Some(viewport_creation_token));
61 self.set_root_view_view_ref.set(view_ref);
62 Ok(())
63 }
64
65 async fn set_root_view_deprecated(
68 &mut self,
69 view_provider: ui_app::ViewProviderProxy,
70 ) -> Result<ui_views::ViewRef, Error> {
71 unimplemented!()
72 }
73
74 fn set_cursor_position(&mut self, position_physical_px: input_pipeline::Position) {
75 unimplemented!()
76 }
77
78 fn set_cursor_visibility(&mut self, visible: bool) {
79 unimplemented!()
80 }
81
82 fn get_pointerinjection_view_refs(&self) -> (ui_views::ViewRef, ui_views::ViewRef) {
83 unimplemented!()
84 }
85
86 fn get_pointerinjection_display_size(&self) -> input_pipeline::Size {
87 unimplemented!()
88 }
89
90 fn get_pointerinjector_viewport_watcher_subscription(&self) -> InjectorViewportSubscriber {
91 unimplemented!()
92 }
93
94 fn get_display_metrics(&self) -> &DisplayMetrics {
95 unimplemented!()
96 }
97}