mirror of
https://github.com/zed-industries/zed.git
synced 2025-02-03 08:54:04 +00:00
WIP start setting up test infrastructure for editor diff actions
Co-Authored-By: Kay Simmons <kay@zed.dev>
This commit is contained in:
parent
c4b21a0ab5
commit
ae2021e073
4 changed files with 65 additions and 3 deletions
|
@ -7,8 +7,9 @@ use unindent::Unindent;
|
|||
|
||||
use super::*;
|
||||
use crate::test::{
|
||||
assert_text_with_selections, build_editor, editor_lsp_test_context::EditorLspTestContext,
|
||||
editor_test_context::EditorTestContext, select_ranges,
|
||||
assert_text_with_selections, build_editor, editor_git_test_context::EditorGitTestContext,
|
||||
editor_lsp_test_context::EditorLspTestContext, editor_test_context::EditorTestContext,
|
||||
select_ranges,
|
||||
};
|
||||
use gpui::{
|
||||
geometry::rect::RectF,
|
||||
|
@ -5079,6 +5080,11 @@ fn test_combine_syntax_and_fuzzy_match_highlights() {
|
|||
);
|
||||
}
|
||||
|
||||
#[gpui::test]
|
||||
fn go_to_hunk(cx: &mut gpui::TestAppContext) {
|
||||
let mut cx = EditorGitTestContext::new(cx);
|
||||
}
|
||||
|
||||
fn empty_range(row: usize, column: usize) -> Range<DisplayPoint> {
|
||||
let point = DisplayPoint::new(row as u32, column as u32);
|
||||
point..point
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
pub mod editor_git_test_context;
|
||||
pub mod editor_lsp_test_context;
|
||||
pub mod editor_test_context;
|
||||
|
||||
|
|
56
crates/editor/src/test/editor_git_test_context.rs
Normal file
56
crates/editor/src/test/editor_git_test_context.rs
Normal file
|
@ -0,0 +1,56 @@
|
|||
use std::ops::{Deref, DerefMut};
|
||||
|
||||
use gpui::ModelHandle;
|
||||
use language::Buffer;
|
||||
use settings::Settings;
|
||||
|
||||
use crate::MultiBuffer;
|
||||
|
||||
use super::{build_editor, editor_test_context::EditorTestContext};
|
||||
|
||||
pub struct EditorGitTestContext<'a> {
|
||||
pub cx: EditorTestContext<'a>,
|
||||
pub buffer: ModelHandle<Buffer>,
|
||||
}
|
||||
|
||||
impl<'a> EditorGitTestContext<'a> {
|
||||
pub async fn new(cx: &'a mut gpui::TestAppContext) -> EditorGitTestContext<'a> {
|
||||
let (window_id, buffer, editor) = cx.update(|cx| {
|
||||
cx.set_global(Settings::test(cx));
|
||||
crate::init(cx);
|
||||
|
||||
let buffer = cx.add_model(|cx| Buffer::new(0, "", cx));
|
||||
let multibuffer = cx.add_model(|cx| MultiBuffer::singleton(buffer.clone(), cx));
|
||||
|
||||
let (window_id, editor) =
|
||||
cx.add_window(Default::default(), |cx| build_editor(multibuffer, cx));
|
||||
|
||||
editor.update(cx, |_, cx| cx.focus_self());
|
||||
|
||||
(window_id, buffer, editor)
|
||||
});
|
||||
|
||||
Self {
|
||||
cx: EditorTestContext {
|
||||
cx,
|
||||
window_id,
|
||||
editor,
|
||||
},
|
||||
buffer,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> Deref for EditorGitTestContext<'a> {
|
||||
type Target = EditorTestContext<'a>;
|
||||
|
||||
fn deref(&self) -> &Self::Target {
|
||||
&self.cx
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> DerefMut for EditorGitTestContext<'a> {
|
||||
fn deref_mut(&mut self) -> &mut Self::Target {
|
||||
&mut self.cx
|
||||
}
|
||||
}
|
|
@ -3257,7 +3257,6 @@ mod tests {
|
|||
}
|
||||
},
|
||||
"c.txt": "",
|
||||
|
||||
}));
|
||||
|
||||
let http_client = FakeHttpClient::with_404_response();
|
||||
|
|
Loading…
Reference in a new issue