test_layout_with_placeholder_text_and_blocks (incomplete, one assert commented out)
We need to wire up a field from element state
This commit is contained in:
@@ -3235,7 +3235,7 @@ mod tests {
|
|||||||
editor_tests::{init_test, update_test_language_settings},
|
editor_tests::{init_test, update_test_language_settings},
|
||||||
Editor, MultiBuffer,
|
Editor, MultiBuffer,
|
||||||
};
|
};
|
||||||
use gpui::TestAppContext;
|
use gpui::{EmptyView, TestAppContext};
|
||||||
use language::language_settings;
|
use language::language_settings;
|
||||||
use log::info;
|
use log::info;
|
||||||
use std::{num::NonZeroU32, sync::Arc};
|
use std::{num::NonZeroU32, sync::Arc};
|
||||||
@@ -3458,60 +3458,68 @@ mod tests {
|
|||||||
assert_eq!(local_selections[1].head, DisplayPoint::new(10, 0));
|
assert_eq!(local_selections[1].head, DisplayPoint::new(10, 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
// #[gpui::test]
|
#[gpui::test]
|
||||||
// fn test_layout_with_placeholder_text_and_blocks(cx: &mut TestAppContext) {
|
fn test_layout_with_placeholder_text_and_blocks(cx: &mut TestAppContext) {
|
||||||
// init_test(cx, |_| {});
|
init_test(cx, |_| {});
|
||||||
|
|
||||||
// let editor = cx
|
let window = cx.add_window(|cx| {
|
||||||
// .add_window(|cx| {
|
let buffer = MultiBuffer::build_simple("", cx);
|
||||||
// let buffer = MultiBuffer::build_simple("", cx);
|
Editor::new(EditorMode::Full, buffer, None, cx)
|
||||||
// Editor::new(EditorMode::Full, buffer, None, None, cx)
|
});
|
||||||
// })
|
let editor = window.root(cx).unwrap();
|
||||||
// .root(cx);
|
let style = cx.update(|cx| editor.read(cx).style().unwrap().clone());
|
||||||
|
window
|
||||||
|
.update(cx, |editor, cx| {
|
||||||
|
editor.set_placeholder_text("hello", cx);
|
||||||
|
editor.insert_blocks(
|
||||||
|
[BlockProperties {
|
||||||
|
style: BlockStyle::Fixed,
|
||||||
|
disposition: BlockDisposition::Above,
|
||||||
|
height: 3,
|
||||||
|
position: Anchor::min(),
|
||||||
|
render: Arc::new(|_| div().into_any()),
|
||||||
|
}],
|
||||||
|
None,
|
||||||
|
cx,
|
||||||
|
);
|
||||||
|
|
||||||
// editor.update(cx, |editor, cx| {
|
// Blur the editor so that it displays placeholder text.
|
||||||
// editor.set_placeholder_text("hello", cx);
|
cx.blur();
|
||||||
// editor.insert_blocks(
|
})
|
||||||
// [BlockProperties {
|
.unwrap();
|
||||||
// style: BlockStyle::Fixed,
|
|
||||||
// disposition: BlockDisposition::Above,
|
|
||||||
// height: 3,
|
|
||||||
// position: Anchor::min(),
|
|
||||||
// render: Arc::new(|_| Empty::new().into_any),
|
|
||||||
// }],
|
|
||||||
// None,
|
|
||||||
// cx,
|
|
||||||
// );
|
|
||||||
|
|
||||||
// // Blur the editor so that it displays placeholder text.
|
let mut element = EditorElement::new(&editor, style);
|
||||||
// cx.blur();
|
let mut state = cx
|
||||||
// });
|
.update_window(window.into(), |_, cx| {
|
||||||
|
element.compute_layout(
|
||||||
|
Bounds {
|
||||||
|
origin: point(px(500.), px(500.)),
|
||||||
|
size: size(px(500.), px(500.)),
|
||||||
|
},
|
||||||
|
cx,
|
||||||
|
)
|
||||||
|
})
|
||||||
|
.unwrap();
|
||||||
|
let size = state.position_map.size;
|
||||||
|
|
||||||
// let mut element = EditorElement::new(editor.read_with(cx, |editor, cx| editor.style(cx)));
|
assert_eq!(state.position_map.line_layouts.len(), 4);
|
||||||
// let (size, mut state) = editor.update(cx, |editor, cx| {
|
// todo!() uncomment this assert
|
||||||
// element.layout(
|
// assert_eq!(
|
||||||
// SizeConstraint::new(point(500., 500.), point(500., 500.)),
|
// state
|
||||||
// editor,
|
// .line_number_layouts
|
||||||
// cx,
|
// .iter()
|
||||||
// )
|
// .map(Option::is_some)
|
||||||
// });
|
// .collect::<Vec<_>>(),
|
||||||
|
// &[false, false, false, true]
|
||||||
|
// );
|
||||||
|
|
||||||
// assert_eq!(state.position_map.line_layouts.len(), 4);
|
// Don't panic.
|
||||||
// assert_eq!(
|
let bounds = Bounds::<Pixels>::new(Default::default(), size);
|
||||||
// state
|
cx.update_window(window.into(), |_, cx| {
|
||||||
// .line_number_layouts
|
element.paint(bounds, &mut (), cx);
|
||||||
// .iter()
|
})
|
||||||
// .map(Option::is_some)
|
.unwrap()
|
||||||
// .collect::<Vec<_>>(),
|
}
|
||||||
// &[false, false, false, true]
|
|
||||||
// );
|
|
||||||
|
|
||||||
// // Don't panic.
|
|
||||||
// let bounds = Bounds::<Pixels>::new(Default::default(), size);
|
|
||||||
// editor.update(cx, |editor, cx| {
|
|
||||||
// element.paint(bounds, bounds, &mut state, editor, cx);
|
|
||||||
// });
|
|
||||||
// }
|
|
||||||
|
|
||||||
#[gpui::test]
|
#[gpui::test]
|
||||||
fn test_all_invisibles_drawing(cx: &mut TestAppContext) {
|
fn test_all_invisibles_drawing(cx: &mut TestAppContext) {
|
||||||
|
|||||||
Reference in New Issue
Block a user