Bring back zed.rs tests (#3907)
At present 3 tests still fail; 2 are related to keymap issues that (I believe) @maxbrunsfeld is working on. The other one (`test_open_paths_action`) I'll look into. edit: done This PR also fixes workspace unregistration, as we've put the code to do that behind `debug_assert` (https://github.com/zed-industries/zed/pull/3907/files#diff-041673bbd1947a35d45945636c0055429dfc8b5985faf93f8a8a960c9ad31e28L649). Release Notes: - N/A
This commit is contained in:
parent
d475f1373a
commit
53564fb269
7 changed files with 2132 additions and 1869 deletions
|
@ -532,6 +532,33 @@ impl<'a> VisualTestContext {
|
||||||
}
|
}
|
||||||
self.background_executor.run_until_parked();
|
self.background_executor.run_until_parked();
|
||||||
}
|
}
|
||||||
|
/// Returns true if the window was closed.
|
||||||
|
pub fn simulate_close(&mut self) -> bool {
|
||||||
|
let handler = self
|
||||||
|
.cx
|
||||||
|
.update_window(self.window, |_, cx| {
|
||||||
|
cx.window
|
||||||
|
.platform_window
|
||||||
|
.as_test()
|
||||||
|
.unwrap()
|
||||||
|
.0
|
||||||
|
.lock()
|
||||||
|
.should_close_handler
|
||||||
|
.take()
|
||||||
|
})
|
||||||
|
.unwrap();
|
||||||
|
if let Some(mut handler) = handler {
|
||||||
|
let should_close = handler();
|
||||||
|
self.cx
|
||||||
|
.update_window(self.window, |_, cx| {
|
||||||
|
cx.window.platform_window.on_should_close(handler);
|
||||||
|
})
|
||||||
|
.unwrap();
|
||||||
|
should_close
|
||||||
|
} else {
|
||||||
|
false
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Context for VisualTestContext {
|
impl Context for VisualTestContext {
|
||||||
|
|
|
@ -266,7 +266,7 @@ impl Platform for TestPlatform {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn local_timezone(&self) -> time::UtcOffset {
|
fn local_timezone(&self) -> time::UtcOffset {
|
||||||
unimplemented!()
|
time::UtcOffset::UTC
|
||||||
}
|
}
|
||||||
|
|
||||||
fn path_for_auxiliary_executable(&self, _name: &str) -> Result<std::path::PathBuf> {
|
fn path_for_auxiliary_executable(&self, _name: &str) -> Result<std::path::PathBuf> {
|
||||||
|
|
|
@ -18,7 +18,7 @@ pub struct TestWindowState {
|
||||||
pub(crate) edited: bool,
|
pub(crate) edited: bool,
|
||||||
platform: Weak<TestPlatform>,
|
platform: Weak<TestPlatform>,
|
||||||
sprite_atlas: Arc<dyn PlatformAtlas>,
|
sprite_atlas: Arc<dyn PlatformAtlas>,
|
||||||
|
pub(crate) should_close_handler: Option<Box<dyn FnMut() -> bool>>,
|
||||||
input_callback: Option<Box<dyn FnMut(InputEvent) -> bool>>,
|
input_callback: Option<Box<dyn FnMut(InputEvent) -> bool>>,
|
||||||
active_status_change_callback: Option<Box<dyn FnMut(bool)>>,
|
active_status_change_callback: Option<Box<dyn FnMut(bool)>>,
|
||||||
resize_callback: Option<Box<dyn FnMut(Size<Pixels>, f32)>>,
|
resize_callback: Option<Box<dyn FnMut(Size<Pixels>, f32)>>,
|
||||||
|
@ -44,7 +44,7 @@ impl TestWindow {
|
||||||
sprite_atlas: Arc::new(TestAtlas::new()),
|
sprite_atlas: Arc::new(TestAtlas::new()),
|
||||||
title: Default::default(),
|
title: Default::default(),
|
||||||
edited: false,
|
edited: false,
|
||||||
|
should_close_handler: None,
|
||||||
input_callback: None,
|
input_callback: None,
|
||||||
active_status_change_callback: None,
|
active_status_change_callback: None,
|
||||||
resize_callback: None,
|
resize_callback: None,
|
||||||
|
@ -117,6 +117,9 @@ impl TestWindow {
|
||||||
|
|
||||||
self.0.lock().input_handler = Some(input_handler);
|
self.0.lock().input_handler = Some(input_handler);
|
||||||
}
|
}
|
||||||
|
pub fn edited(&self) -> bool {
|
||||||
|
self.0.lock().edited
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl PlatformWindow for TestWindow {
|
impl PlatformWindow for TestWindow {
|
||||||
|
@ -235,8 +238,8 @@ impl PlatformWindow for TestWindow {
|
||||||
self.0.lock().moved_callback = Some(callback)
|
self.0.lock().moved_callback = Some(callback)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn on_should_close(&self, _callback: Box<dyn FnMut() -> bool>) {
|
fn on_should_close(&self, callback: Box<dyn FnMut() -> bool>) {
|
||||||
unimplemented!()
|
self.0.lock().should_close_handler = Some(callback);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn on_close(&self, _callback: Box<dyn FnOnce()>) {
|
fn on_close(&self, _callback: Box<dyn FnOnce()>) {
|
||||||
|
|
|
@ -6,7 +6,7 @@ use crate::{
|
||||||
};
|
};
|
||||||
use anyhow::{Context, Result};
|
use anyhow::{Context, Result};
|
||||||
use std::{
|
use std::{
|
||||||
any::TypeId,
|
any::{type_name, TypeId},
|
||||||
fmt,
|
fmt,
|
||||||
hash::{Hash, Hasher},
|
hash::{Hash, Hasher},
|
||||||
};
|
};
|
||||||
|
@ -104,6 +104,14 @@ impl<V> Clone for View<V> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl<T> std::fmt::Debug for View<T> {
|
||||||
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
|
f.debug_struct(&format!("View<{}>", type_name::<T>()))
|
||||||
|
.field("entity_id", &self.model.entity_id)
|
||||||
|
.finish_non_exhaustive()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl<V> Hash for View<V> {
|
impl<V> Hash for View<V> {
|
||||||
fn hash<H: Hasher>(&self, state: &mut H) {
|
fn hash<H: Hasher>(&self, state: &mut H) {
|
||||||
self.model.hash(state);
|
self.model.hash(state);
|
||||||
|
|
|
@ -658,7 +658,7 @@ impl Workspace {
|
||||||
cx.on_release(|this, window, cx| {
|
cx.on_release(|this, window, cx| {
|
||||||
this.app_state.workspace_store.update(cx, |store, _| {
|
this.app_state.workspace_store.update(cx, |store, _| {
|
||||||
let window = window.downcast::<Self>().unwrap();
|
let window = window.downcast::<Self>().unwrap();
|
||||||
debug_assert!(store.workspaces.remove(&window));
|
store.workspaces.remove(&window);
|
||||||
})
|
})
|
||||||
}),
|
}),
|
||||||
];
|
];
|
||||||
|
|
|
@ -146,8 +146,7 @@ uuid.workspace = true
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
call = { path = "../call", features = ["test-support"] }
|
call = { path = "../call", features = ["test-support"] }
|
||||||
# client = { path = "../client", features = ["test-support"] }
|
# client = { path = "../client", features = ["test-support"] }
|
||||||
# editor = { path = "../editor", features = ["test-support"] }
|
editor = { path = "../editor", features = ["test-support"] }
|
||||||
# gpui = { path = "../gpui", features = ["test-support"] }
|
|
||||||
gpui = { path = "../gpui", features = ["test-support"] }
|
gpui = { path = "../gpui", features = ["test-support"] }
|
||||||
language = { path = "../language", features = ["test-support"] }
|
language = { path = "../language", features = ["test-support"] }
|
||||||
# lsp = { path = "../lsp", features = ["test-support"] }
|
# lsp = { path = "../lsp", features = ["test-support"] }
|
||||||
|
@ -156,7 +155,7 @@ project = { path = "../project", features = ["test-support"] }
|
||||||
# settings = { path = "../settings", features = ["test-support"] }
|
# settings = { path = "../settings", features = ["test-support"] }
|
||||||
text = { path = "../text", features = ["test-support"] }
|
text = { path = "../text", features = ["test-support"] }
|
||||||
# util = { path = "../util", features = ["test-support"] }
|
# util = { path = "../util", features = ["test-support"] }
|
||||||
# workspace = { path = "../workspace", features = ["test-support"] }
|
workspace = { path = "../workspace", features = ["test-support"] }
|
||||||
unindent.workspace = true
|
unindent.workspace = true
|
||||||
|
|
||||||
[package.metadata.bundle-dev]
|
[package.metadata.bundle-dev]
|
||||||
|
|
File diff suppressed because it is too large
Load diff
Loading…
Add table
Add a link
Reference in a new issue