Restore GPUI test

This commit is contained in:
Mikayla 2024-01-10 11:43:52 -08:00
parent 9553759899
commit 4bcac68c8c
No known key found for this signature in database

View file

@ -137,7 +137,7 @@ impl Boundary {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use super::*; use super::*;
use crate::{font, TestAppContext, TestDispatcher}; use crate::{font, TestAppContext, TestDispatcher, TextRun, WrapBoundary};
use rand::prelude::*; use rand::prelude::*;
#[test] #[test]
@ -206,75 +206,70 @@ mod tests {
}); });
} }
// todo!("move this to a test on TextSystem::layout_text") // For compatibility with the test macro
// todo! repeat this test use crate as gpui;
// #[test]
// fn test_wrap_shaped_line() {
// App::test().run(|cx| {
// let text_system = cx.text_system().clone();
// let normal = TextRun { #[crate::test]
// len: 0, fn test_wrap_shaped_line(cx: &mut TestAppContext) {
// font: font("Helvetica"), cx.update(|cx| {
// color: Default::default(), let text_system = cx.text_system().clone();
// underline: Default::default(),
// };
// let bold = TextRun {
// len: 0,
// font: font("Helvetica").bold(),
// color: Default::default(),
// underline: Default::default(),
// };
// impl TextRun { let normal = TextRun {
// fn with_len(&self, len: usize) -> Self { len: 0,
// let mut this = self.clone(); font: font("Helvetica"),
// this.len = len; color: Default::default(),
// this underline: Default::default(),
// } background_color: None,
// } };
let bold = TextRun {
len: 0,
font: font("Helvetica").bold(),
color: Default::default(),
underline: Default::default(),
background_color: None,
};
// let text = "aa bbb cccc ddddd eeee".into(); impl TextRun {
// let lines = text_system fn with_len(&self, len: usize) -> Self {
// .layout_text( let mut this = self.clone();
// &text, this.len = len;
// px(16.), this
// &[ }
// normal.with_len(4), }
// bold.with_len(5),
// normal.with_len(6),
// bold.with_len(1),
// normal.with_len(7),
// ],
// None,
// )
// .unwrap();
// let line = &lines[0];
// let mut wrapper = LineWrapper::new( let text = "aa bbb cccc ddddd eeee".into();
// text_system.font_id(&normal.font).unwrap(), let lines = text_system
// px(16.), .shape_text(
// text_system.platform_text_system.clone(), text,
// ); px(16.),
// assert_eq!( &[
// wrapper normal.with_len(4),
// .wrap_shaped_line(&text, &line, px(72.)) bold.with_len(5),
// .collect::<Vec<_>>(), normal.with_len(6),
// &[ bold.with_len(1),
// ShapedBoundary { normal.with_len(7),
// run_ix: 1, ],
// glyph_ix: 3 Some(px(72.)),
// }, )
// ShapedBoundary { .unwrap();
// run_ix: 2,
// glyph_ix: 3 assert_eq!(
// }, lines[0].layout.wrap_boundaries(),
// ShapedBoundary { &[
// run_ix: 4, WrapBoundary {
// glyph_ix: 2 run_ix: 1,
// } glyph_ix: 3
// ], },
// ); WrapBoundary {
// }); run_ix: 2,
// } glyph_ix: 3
},
WrapBoundary {
run_ix: 4,
glyph_ix: 2
}
],
);
});
}
} }