From ce1c228e6ecc29871523576b179d96e84db59b32 Mon Sep 17 00:00:00 2001 From: Nathan Sobo Date: Sun, 14 Dec 2025 10:48:11 -0700 Subject: [PATCH] Rename TestAppWindow to TestWindow, internal TestWindow to TestPlatformWindow - Public API: TestWindow - the new typed test window wrapper - Internal: TestPlatformWindow - the platform-level mock window (pub(crate)) --- crates/gpui/src/app/test_app.rs | 14 +++++++------- crates/gpui/src/app/test_context.rs | 8 ++++---- crates/gpui/src/platform.rs | 2 +- crates/gpui/src/platform/test/platform.rs | 8 ++++---- crates/gpui/src/platform/test/window.rs | 16 ++++++++-------- 5 files changed, 24 insertions(+), 24 deletions(-) diff --git a/crates/gpui/src/app/test_app.rs b/crates/gpui/src/app/test_app.rs index 8299da132e9e951be9074fe7a448ee29231062b6..b75a11bb35963a3d452ef1655ff0dd9ef1edfb55 100644 --- a/crates/gpui/src/app/test_app.rs +++ b/crates/gpui/src/app/test_app.rs @@ -122,7 +122,7 @@ impl TestApp { pub fn open_window( &mut self, build_view: impl FnOnce(&mut Window, &mut Context) -> V, - ) -> TestAppWindow { + ) -> TestWindow { let bounds = self.read(|cx| Bounds::maximized(None, cx)); let handle = self.update(|cx| { cx.open_window( @@ -135,7 +135,7 @@ impl TestApp { .unwrap() }); - TestAppWindow { + TestWindow { handle, app: self.app.clone(), platform: self.platform.clone(), @@ -148,13 +148,13 @@ impl TestApp { &mut self, options: WindowOptions, build_view: impl FnOnce(&mut Window, &mut Context) -> V, - ) -> TestAppWindow { + ) -> TestWindow { let handle = self.update(|cx| { cx.open_window(options, |window, cx| cx.new(|cx| build_view(window, cx))) .unwrap() }); - TestAppWindow { + TestWindow { handle, app: self.app.clone(), platform: self.platform.clone(), @@ -286,14 +286,14 @@ impl Default for TestApp { } /// A test window with inspection and simulation capabilities. -pub struct TestAppWindow { +pub struct TestWindow { handle: WindowHandle, app: Rc, platform: Rc, background_executor: BackgroundExecutor, } -impl TestAppWindow { +impl TestWindow { /// Get the window handle. pub fn handle(&self) -> WindowHandle { self.handle @@ -485,7 +485,7 @@ impl TestAppWindow { } } -impl Clone for TestAppWindow { +impl Clone for TestWindow { fn clone(&self) -> Self { Self { handle: self.handle, diff --git a/crates/gpui/src/app/test_context.rs b/crates/gpui/src/app/test_context.rs index 5be2e394e8edfd26a25c70c79c321a7fb8fdc8ba..2cc3c1b3255f9b0f3874d232e181423ef12b77b1 100644 --- a/crates/gpui/src/app/test_context.rs +++ b/crates/gpui/src/app/test_context.rs @@ -4,7 +4,7 @@ use crate::{ Element, Empty, EventEmitter, ForegroundExecutor, Global, InputEvent, Keystroke, Modifiers, ModifiersChangedEvent, MouseButton, MouseDownEvent, MouseMoveEvent, MouseUpEvent, Pixels, Platform, Point, Render, Result, Size, Task, TestDispatcher, TestPlatform, - TestScreenCaptureSource, TestWindow, TextSystem, VisualContext, Window, WindowBounds, + TestScreenCaptureSource, TestPlatformWindow, TextSystem, VisualContext, Window, WindowBounds, WindowHandle, WindowOptions, app::GpuiMode, }; use anyhow::{anyhow, bail}; @@ -220,7 +220,7 @@ impl TestAppContext { f(&cx) } - /// Adds a new window. The Window will always be backed by a `TestWindow` which + /// Adds a new window. The Window will always be backed by a `TestPlatformWindow` which /// can be retrieved with `self.test_window(handle)` pub fn add_window(&mut self, build_window: F) -> WindowHandle where @@ -465,8 +465,8 @@ impl TestAppContext { .unwrap(); } - /// Returns the `TestWindow` backing the given handle. - pub(crate) fn test_window(&self, window: AnyWindowHandle) -> TestWindow { + /// Returns the `TestPlatformWindow` backing the given handle. + pub(crate) fn test_window(&self, window: AnyWindowHandle) -> TestPlatformWindow { self.app .borrow_mut() .windows diff --git a/crates/gpui/src/platform.rs b/crates/gpui/src/platform.rs index f120e075fea7f9336e2f6e10c51611d8ba03564d..de2c10cec6a3ba9412112e5e46c2367264f51475 100644 --- a/crates/gpui/src/platform.rs +++ b/crates/gpui/src/platform.rs @@ -561,7 +561,7 @@ pub(crate) trait PlatformWindow: HasWindowHandle + HasDisplayHandle { fn update_ime_position(&self, _bounds: Bounds); #[cfg(any(test, feature = "test-support"))] - fn as_test(&mut self) -> Option<&mut TestWindow> { + fn as_test(&mut self) -> Option<&mut TestPlatformWindow> { None } } diff --git a/crates/gpui/src/platform/test/platform.rs b/crates/gpui/src/platform/test/platform.rs index dfada364667989792325e02f8530e6c91bdf4716..62d5101cbb0d1d6649b70d0ec7c2cdcf7a50233b 100644 --- a/crates/gpui/src/platform/test/platform.rs +++ b/crates/gpui/src/platform/test/platform.rs @@ -3,7 +3,7 @@ use crate::{ DummyKeyboardMapper, ForegroundExecutor, Keymap, NoopTextSystem, Platform, PlatformDisplay, PlatformKeyboardLayout, PlatformKeyboardMapper, PlatformTextSystem, PromptButton, ScreenCaptureFrame, ScreenCaptureSource, ScreenCaptureStream, SourceMetadata, Task, - TestDisplay, TestWindow, WindowAppearance, WindowParams, size, + TestDisplay, TestPlatformWindow, WindowAppearance, WindowParams, size, }; use anyhow::Result; use collections::VecDeque; @@ -26,7 +26,7 @@ pub(crate) struct TestPlatform { background_executor: BackgroundExecutor, foreground_executor: ForegroundExecutor, - pub(crate) active_window: RefCell>, + pub(crate) active_window: RefCell>, active_display: Rc, active_cursor: Mutex, current_clipboard_item: Mutex>, @@ -196,7 +196,7 @@ impl TestPlatform { rx } - pub(crate) fn set_active_window(&self, window: Option) { + pub(crate) fn set_active_window(&self, window: Option) { let executor = self.foreground_executor(); let previous_window = self.active_window.borrow_mut().take(); self.active_window.borrow_mut().clone_from(&window); @@ -314,7 +314,7 @@ impl Platform for TestPlatform { handle: AnyWindowHandle, params: WindowParams, ) -> anyhow::Result> { - let window = TestWindow::new( + let window = TestPlatformWindow::new( handle, params, self.weak.clone(), diff --git a/crates/gpui/src/platform/test/window.rs b/crates/gpui/src/platform/test/window.rs index 9e87f4504ddd61e34b645ea69ea394c4940f9d55..e60096acc76a04a20c463b7ef2f9cd66491b3ebe 100644 --- a/crates/gpui/src/platform/test/window.rs +++ b/crates/gpui/src/platform/test/window.rs @@ -12,7 +12,7 @@ use std::{ sync::{self, Arc}, }; -pub(crate) struct TestWindowState { +pub(crate) struct TestPlatformWindowState { pub(crate) bounds: Bounds, pub(crate) handle: AnyWindowHandle, display: Rc, @@ -32,9 +32,9 @@ pub(crate) struct TestWindowState { } #[derive(Clone)] -pub(crate) struct TestWindow(pub(crate) Rc>); +pub(crate) struct TestPlatformWindow(pub(crate) Rc>); -impl HasWindowHandle for TestWindow { +impl HasWindowHandle for TestPlatformWindow { fn window_handle( &self, ) -> Result, raw_window_handle::HandleError> { @@ -42,7 +42,7 @@ impl HasWindowHandle for TestWindow { } } -impl HasDisplayHandle for TestWindow { +impl HasDisplayHandle for TestPlatformWindow { fn display_handle( &self, ) -> Result, raw_window_handle::HandleError> { @@ -50,14 +50,14 @@ impl HasDisplayHandle for TestWindow { } } -impl TestWindow { +impl TestPlatformWindow { pub fn new( handle: AnyWindowHandle, params: WindowParams, platform: Weak, display: Rc, ) -> Self { - Self(Rc::new(Mutex::new(TestWindowState { + Self(Rc::new(Mutex::new(TestPlatformWindowState { bounds: params.bounds, display, platform, @@ -111,7 +111,7 @@ impl TestWindow { } } -impl PlatformWindow for TestWindow { +impl PlatformWindow for TestPlatformWindow { fn bounds(&self) -> Bounds { self.0.lock().bounds } @@ -272,7 +272,7 @@ impl PlatformWindow for TestWindow { self.0.lock().sprite_atlas.clone() } - fn as_test(&mut self) -> Option<&mut TestWindow> { + fn as_test(&mut self) -> Option<&mut TestPlatformWindow> { Some(self) }