1use crate::{BackgroundExecutor, DisplayId, ForegroundExecutor, Platform, PlatformTextSystem};
2use anyhow::{anyhow, Result};
3use std::sync::Arc;
4
5pub struct TestPlatform {
6 background_executor: BackgroundExecutor,
7 foreground_executor: ForegroundExecutor,
8}
9
10impl TestPlatform {
11 pub fn new(executor: BackgroundExecutor, foreground_executor: ForegroundExecutor) -> Self {
12 TestPlatform {
13 background_executor: executor,
14 foreground_executor,
15 }
16 }
17}
18
19// todo!("implement out what our tests needed in GPUI 1")
20impl Platform for TestPlatform {
21 fn background_executor(&self) -> BackgroundExecutor {
22 self.background_executor.clone()
23 }
24
25 fn foreground_executor(&self) -> ForegroundExecutor {
26 self.foreground_executor.clone()
27 }
28
29 fn text_system(&self) -> Arc<dyn PlatformTextSystem> {
30 Arc::new(crate::platform::mac::MacTextSystem::new())
31 }
32
33 fn run(&self, _on_finish_launching: Box<dyn FnOnce()>) {
34 unimplemented!()
35 }
36
37 fn quit(&self) {
38 unimplemented!()
39 }
40
41 fn restart(&self) {
42 unimplemented!()
43 }
44
45 fn activate(&self, _ignoring_other_apps: bool) {
46 unimplemented!()
47 }
48
49 fn hide(&self) {
50 unimplemented!()
51 }
52
53 fn hide_other_apps(&self) {
54 unimplemented!()
55 }
56
57 fn unhide_other_apps(&self) {
58 unimplemented!()
59 }
60
61 fn displays(&self) -> Vec<std::rc::Rc<dyn crate::PlatformDisplay>> {
62 unimplemented!()
63 }
64
65 fn display(&self, _id: DisplayId) -> Option<std::rc::Rc<dyn crate::PlatformDisplay>> {
66 unimplemented!()
67 }
68
69 fn main_window(&self) -> Option<crate::AnyWindowHandle> {
70 unimplemented!()
71 }
72
73 fn open_window(
74 &self,
75 _handle: crate::AnyWindowHandle,
76 _options: crate::WindowOptions,
77 ) -> Box<dyn crate::PlatformWindow> {
78 unimplemented!()
79 }
80
81 fn set_display_link_output_callback(
82 &self,
83 _display_id: DisplayId,
84 _callback: Box<dyn FnMut(&crate::VideoTimestamp, &crate::VideoTimestamp)>,
85 ) {
86 unimplemented!()
87 }
88
89 fn start_display_link(&self, _display_id: DisplayId) {
90 unimplemented!()
91 }
92
93 fn stop_display_link(&self, _display_id: DisplayId) {
94 unimplemented!()
95 }
96
97 fn open_url(&self, _url: &str) {
98 unimplemented!()
99 }
100
101 fn on_open_urls(&self, _callback: Box<dyn FnMut(Vec<String>)>) {
102 unimplemented!()
103 }
104
105 fn prompt_for_paths(
106 &self,
107 _options: crate::PathPromptOptions,
108 ) -> futures::channel::oneshot::Receiver<Option<Vec<std::path::PathBuf>>> {
109 unimplemented!()
110 }
111
112 fn prompt_for_new_path(
113 &self,
114 _directory: &std::path::Path,
115 ) -> futures::channel::oneshot::Receiver<Option<std::path::PathBuf>> {
116 unimplemented!()
117 }
118
119 fn reveal_path(&self, _path: &std::path::Path) {
120 unimplemented!()
121 }
122
123 fn on_become_active(&self, _callback: Box<dyn FnMut()>) {
124 unimplemented!()
125 }
126
127 fn on_resign_active(&self, _callback: Box<dyn FnMut()>) {
128 unimplemented!()
129 }
130
131 fn on_quit(&self, _callback: Box<dyn FnMut()>) {
132 unimplemented!()
133 }
134
135 fn on_reopen(&self, _callback: Box<dyn FnMut()>) {
136 unimplemented!()
137 }
138
139 fn on_event(&self, _callback: Box<dyn FnMut(crate::InputEvent) -> bool>) {
140 unimplemented!()
141 }
142
143 fn os_name(&self) -> &'static str {
144 "test"
145 }
146
147 fn os_version(&self) -> Result<crate::SemanticVersion> {
148 Err(anyhow!("os_version called on TestPlatform"))
149 }
150
151 fn app_version(&self) -> Result<crate::SemanticVersion> {
152 Err(anyhow!("app_version called on TestPlatform"))
153 }
154
155 fn app_path(&self) -> Result<std::path::PathBuf> {
156 unimplemented!()
157 }
158
159 fn local_timezone(&self) -> time::UtcOffset {
160 unimplemented!()
161 }
162
163 fn path_for_auxiliary_executable(&self, _name: &str) -> Result<std::path::PathBuf> {
164 unimplemented!()
165 }
166
167 fn set_cursor_style(&self, _style: crate::CursorStyle) {
168 unimplemented!()
169 }
170
171 fn should_auto_hide_scrollbars(&self) -> bool {
172 unimplemented!()
173 }
174
175 fn write_to_clipboard(&self, _item: crate::ClipboardItem) {
176 unimplemented!()
177 }
178
179 fn read_from_clipboard(&self) -> Option<crate::ClipboardItem> {
180 unimplemented!()
181 }
182
183 fn write_credentials(&self, _url: &str, _username: &str, _password: &[u8]) -> Result<()> {
184 Ok(())
185 }
186
187 fn read_credentials(&self, _url: &str) -> Result<Option<(String, Vec<u8>)>> {
188 Ok(None)
189 }
190
191 fn delete_credentials(&self, _url: &str) -> Result<()> {
192 Ok(())
193 }
194}