()
| 1158 | #[rustfmt::skip] |
| 1159 | #[test] |
| 1160 | fn test_begin() { |
| 1161 | let mut ply = Ply::<()>::new_headless(Dimensions::new(800.0, 600.0)); |
| 1162 | |
| 1163 | ply.set_measure_text_function(|_, _| { |
| 1164 | Dimensions::new(100.0, 24.0) |
| 1165 | }); |
| 1166 | |
| 1167 | let mut ui = ply.begin(); |
| 1168 | |
| 1169 | ui.element().width(fixed!(100.0)).height(fixed!(100.0)) |
| 1170 | .background_color(0xFFFFFF) |
| 1171 | .children(|ui| { |
| 1172 | ui.element().width(fixed!(100.0)).height(fixed!(100.0)) |
| 1173 | .background_color(0xFFFFFF) |
| 1174 | .children(|ui| { |
| 1175 | ui.element().width(fixed!(100.0)).height(fixed!(100.0)) |
| 1176 | .background_color(0xFFFFFF) |
| 1177 | .children(|ui| { |
| 1178 | ui.text("test", |t| t |
| 1179 | .color(0xFFFFFF) |
| 1180 | .font_size(24) |
| 1181 | ); |
| 1182 | }); |
| 1183 | }); |
| 1184 | }); |
| 1185 | |
| 1186 | ui.element() |
| 1187 | .border(|b| b |
| 1188 | .color(0xFFFF00) |
| 1189 | .all(2) |
| 1190 | ) |
| 1191 | .corner_radius(10.0) |
| 1192 | .children(|ui| { |
| 1193 | ui.element().width(fixed!(50.0)).height(fixed!(50.0)) |
| 1194 | .background_color(0x00FFFF) |
| 1195 | .empty(); |
| 1196 | }); |
| 1197 | |
| 1198 | let items = ui.eval(); |
| 1199 | |
| 1200 | for item in &items { |
| 1201 | println!( |
| 1202 | "id: {}\nbbox: {:?}\nconfig: {:?}", |
| 1203 | item.id, item.bounding_box, item.config, |
| 1204 | ); |
| 1205 | } |
| 1206 | |
| 1207 | assert_eq!(items.len(), 6); |
| 1208 | |
| 1209 | assert_eq!(items[0].bounding_box.x, 0.0); |
| 1210 | assert_eq!(items[0].bounding_box.y, 0.0); |
| 1211 | assert_eq!(items[0].bounding_box.width, 100.0); |
| 1212 | assert_eq!(items[0].bounding_box.height, 100.0); |
| 1213 | match &items[0].config { |
| 1214 | render_commands::RenderCommandConfig::Rectangle(rect) => { |
| 1215 | assert_eq!(rect.color.r, 255.0); |
| 1216 | assert_eq!(rect.color.g, 255.0); |
| 1217 | assert_eq!(rect.color.b, 255.0); |
nothing calls this directly
no test coverage detected