Fix warnings and tests
This commit is contained in:
parent
e4f18947de
commit
ab5db0bc1e
4 changed files with 47 additions and 35 deletions
|
@ -3992,12 +3992,7 @@ mod tests {
|
||||||
|
|
||||||
let actions_clone = actions.clone();
|
let actions_clone = actions.clone();
|
||||||
cx.add_global_action(move |_: &Action, _: &mut MutableAppContext| {
|
cx.add_global_action(move |_: &Action, _: &mut MutableAppContext| {
|
||||||
actions_clone.borrow_mut().push("global a".to_string());
|
actions_clone.borrow_mut().push("global".to_string());
|
||||||
});
|
|
||||||
|
|
||||||
let actions_clone = actions.clone();
|
|
||||||
cx.add_global_action(move |_: &Action, _: &mut MutableAppContext| {
|
|
||||||
actions_clone.borrow_mut().push("global b".to_string());
|
|
||||||
});
|
});
|
||||||
|
|
||||||
let actions_clone = actions.clone();
|
let actions_clone = actions.clone();
|
||||||
|
@ -4053,7 +4048,7 @@ mod tests {
|
||||||
|
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
*actions.borrow(),
|
*actions.borrow(),
|
||||||
vec!["4 d", "4 c", "3 b", "3 a", "2 d", "2 c", "global b", "global a"]
|
vec!["4 d", "4 c", "3 b", "3 a", "2 d", "2 c", "global"]
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1153,7 +1153,8 @@ mod tests {
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.await;
|
.await
|
||||||
|
.unwrap();
|
||||||
workspace_b.read_with(&cx_b, |workspace, cx| {
|
workspace_b.read_with(&cx_b, |workspace, cx| {
|
||||||
let active_pane = workspace.active_pane().read(cx);
|
let active_pane = workspace.active_pane().read(cx);
|
||||||
assert!(active_pane.active_item().is_some());
|
assert!(active_pane.active_item().is_some());
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
use crate::{assets::Assets, build_window_options, AppState, build_workspace};
|
use crate::{assets::Assets, build_window_options, build_workspace, AppState};
|
||||||
use client::{http::ServerResponse, test::FakeHttpClient, ChannelList, Client, UserStore};
|
use client::{http::ServerResponse, test::FakeHttpClient, ChannelList, Client, UserStore};
|
||||||
use gpui::{AssetSource, MutableAppContext};
|
use gpui::{AssetSource, MutableAppContext};
|
||||||
use language::LanguageRegistry;
|
use language::LanguageRegistry;
|
||||||
|
|
|
@ -31,7 +31,6 @@ const MIN_FONT_SIZE: f32 = 6.0;
|
||||||
|
|
||||||
pub fn init(app_state: &Arc<AppState>, cx: &mut gpui::MutableAppContext) {
|
pub fn init(app_state: &Arc<AppState>, cx: &mut gpui::MutableAppContext) {
|
||||||
cx.add_global_action(quit);
|
cx.add_global_action(quit);
|
||||||
|
|
||||||
cx.add_global_action({
|
cx.add_global_action({
|
||||||
let settings_tx = app_state.settings_tx.clone();
|
let settings_tx = app_state.settings_tx.clone();
|
||||||
|
|
||||||
|
@ -175,7 +174,9 @@ mod tests {
|
||||||
#[gpui::test]
|
#[gpui::test]
|
||||||
async fn test_new_empty_workspace(mut cx: gpui::TestAppContext) {
|
async fn test_new_empty_workspace(mut cx: gpui::TestAppContext) {
|
||||||
let app_state = cx.update(test_app_state);
|
let app_state = cx.update(test_app_state);
|
||||||
cx.update(|cx| init(&app_state, cx));
|
cx.update(|cx| {
|
||||||
|
workspace::init(cx);
|
||||||
|
});
|
||||||
cx.dispatch_global_action(workspace::OpenNew(app_state.clone()));
|
cx.dispatch_global_action(workspace::OpenNew(app_state.clone()));
|
||||||
let window_id = *cx.window_ids().first().unwrap();
|
let window_id = *cx.window_ids().first().unwrap();
|
||||||
let workspace = cx.root_view::<Workspace>(window_id).unwrap();
|
let workspace = cx.root_view::<Workspace>(window_id).unwrap();
|
||||||
|
@ -241,10 +242,11 @@ mod tests {
|
||||||
let file3 = entries[2].clone();
|
let file3 = entries[2].clone();
|
||||||
|
|
||||||
// Open the first entry
|
// Open the first entry
|
||||||
workspace
|
let entry_1 = workspace
|
||||||
.update(&mut cx, |w, cx| w.open_entry(file1.clone(), cx))
|
.update(&mut cx, |w, cx| w.open_entry(file1.clone(), cx))
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.await;
|
.await
|
||||||
|
.unwrap();
|
||||||
cx.read(|cx| {
|
cx.read(|cx| {
|
||||||
let pane = workspace.read(cx).active_pane().read(cx);
|
let pane = workspace.read(cx).active_pane().read(cx);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
|
@ -258,7 +260,8 @@ mod tests {
|
||||||
workspace
|
workspace
|
||||||
.update(&mut cx, |w, cx| w.open_entry(file2.clone(), cx))
|
.update(&mut cx, |w, cx| w.open_entry(file2.clone(), cx))
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.await;
|
.await
|
||||||
|
.unwrap();
|
||||||
cx.read(|cx| {
|
cx.read(|cx| {
|
||||||
let pane = workspace.read(cx).active_pane().read(cx);
|
let pane = workspace.read(cx).active_pane().read(cx);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
|
@ -269,9 +272,12 @@ mod tests {
|
||||||
});
|
});
|
||||||
|
|
||||||
// Open the first entry again. The existing pane item is activated.
|
// Open the first entry again. The existing pane item is activated.
|
||||||
workspace.update(&mut cx, |w, cx| {
|
let entry_1b = workspace
|
||||||
assert!(w.open_entry(file1.clone(), cx).is_none())
|
.update(&mut cx, |w, cx| w.open_entry(file1.clone(), cx).unwrap())
|
||||||
});
|
.await
|
||||||
|
.unwrap();
|
||||||
|
assert_eq!(entry_1.id(), entry_1b.id());
|
||||||
|
|
||||||
cx.read(|cx| {
|
cx.read(|cx| {
|
||||||
let pane = workspace.read(cx).active_pane().read(cx);
|
let pane = workspace.read(cx).active_pane().read(cx);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
|
@ -282,9 +288,15 @@ mod tests {
|
||||||
});
|
});
|
||||||
|
|
||||||
// Split the pane with the first entry, then open the second entry again.
|
// Split the pane with the first entry, then open the second entry again.
|
||||||
workspace.update(&mut cx, |w, cx| {
|
workspace
|
||||||
|
.update(&mut cx, |w, cx| {
|
||||||
w.split_pane(w.active_pane().clone(), SplitDirection::Right, cx);
|
w.split_pane(w.active_pane().clone(), SplitDirection::Right, cx);
|
||||||
assert!(w.open_entry(file2.clone(), cx).is_none());
|
w.open_entry(file2.clone(), cx).unwrap()
|
||||||
|
})
|
||||||
|
.await
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
|
workspace.read_with(&cx, |w, cx| {
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
w.active_pane()
|
w.active_pane()
|
||||||
.read(cx)
|
.read(cx)
|
||||||
|
@ -302,8 +314,8 @@ mod tests {
|
||||||
w.open_entry(file3.clone(), cx).unwrap(),
|
w.open_entry(file3.clone(), cx).unwrap(),
|
||||||
)
|
)
|
||||||
});
|
});
|
||||||
t1.await;
|
t1.await.unwrap();
|
||||||
t2.await;
|
t2.await.unwrap();
|
||||||
cx.read(|cx| {
|
cx.read(|cx| {
|
||||||
let pane = workspace.read(cx).active_pane().read(cx);
|
let pane = workspace.read(cx).active_pane().read(cx);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
|
@ -524,18 +536,21 @@ mod tests {
|
||||||
// Open the same newly-created file in another pane item. The new editor should reuse
|
// Open the same newly-created file in another pane item. The new editor should reuse
|
||||||
// the same buffer.
|
// the same buffer.
|
||||||
cx.dispatch_action(window_id, vec![workspace.id()], OpenNew(app_state.clone()));
|
cx.dispatch_action(window_id, vec![workspace.id()], OpenNew(app_state.clone()));
|
||||||
workspace.update(&mut cx, |workspace, cx| {
|
workspace
|
||||||
|
.update(&mut cx, |workspace, cx| {
|
||||||
workspace.split_pane(workspace.active_pane().clone(), SplitDirection::Right, cx);
|
workspace.split_pane(workspace.active_pane().clone(), SplitDirection::Right, cx);
|
||||||
assert!(workspace
|
workspace
|
||||||
.open_entry(
|
.open_entry(
|
||||||
ProjectPath {
|
ProjectPath {
|
||||||
worktree_id: worktree.id(),
|
worktree_id: worktree.id(),
|
||||||
path: Path::new("the-new-name.rs").into()
|
path: Path::new("the-new-name.rs").into(),
|
||||||
},
|
},
|
||||||
cx
|
cx,
|
||||||
)
|
)
|
||||||
.is_none());
|
.unwrap()
|
||||||
});
|
})
|
||||||
|
.await
|
||||||
|
.unwrap();
|
||||||
let editor2 = workspace.update(&mut cx, |workspace, cx| {
|
let editor2 = workspace.update(&mut cx, |workspace, cx| {
|
||||||
workspace
|
workspace
|
||||||
.active_item(cx)
|
.active_item(cx)
|
||||||
|
@ -631,7 +646,8 @@ mod tests {
|
||||||
workspace
|
workspace
|
||||||
.update(&mut cx, |w, cx| w.open_entry(file1.clone(), cx))
|
.update(&mut cx, |w, cx| w.open_entry(file1.clone(), cx))
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.await;
|
.await
|
||||||
|
.unwrap();
|
||||||
cx.read(|cx| {
|
cx.read(|cx| {
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
pane_1.read(cx).active_item().unwrap().project_path(cx),
|
pane_1.read(cx).active_item().unwrap().project_path(cx),
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue