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), let text = "aa bbb cccc ddddd eeee".into();
// bold.with_len(1), let lines = text_system
// normal.with_len(7), .shape_text(
// ], text,
// None, px(16.),
// ) &[
// .unwrap(); normal.with_len(4),
// let line = &lines[0]; bold.with_len(5),
normal.with_len(6),
// let mut wrapper = LineWrapper::new( bold.with_len(1),
// text_system.font_id(&normal.font).unwrap(), normal.with_len(7),
// px(16.), ],
// text_system.platform_text_system.clone(), Some(px(72.)),
// ); )
// assert_eq!( .unwrap();
// wrapper
// .wrap_shaped_line(&text, &line, px(72.)) assert_eq!(
// .collect::<Vec<_>>(), lines[0].layout.wrap_boundaries(),
// &[ &[
// ShapedBoundary { WrapBoundary {
// run_ix: 1, run_ix: 1,
// glyph_ix: 3 glyph_ix: 3
// }, },
// ShapedBoundary { WrapBoundary {
// run_ix: 2, run_ix: 2,
// glyph_ix: 3 glyph_ix: 3
// }, },
// ShapedBoundary { WrapBoundary {
// run_ix: 4, run_ix: 4,
// glyph_ix: 2 glyph_ix: 2
// } }
// ], ],
// ); );
// }); });
// } }
} }