platform.rs

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