mod common;
use common::{settle, window};
use taut::text::Font;
use taut::{Color, Ui};
#[test]
fn text_taller_than_its_box_is_drawn_the_same_in_strips_and_whole() {
let mut ui = window(1.0);
settle(&mut ui, |ui: &mut Ui| {
ui.el().size(100.0, 58.0).show();
ui.el().size(100.0, 3.0).text("Hello", Font::new(16.0), Color::rgb(0xff0000)).show();
});
}
#[test]
fn a_list_in_a_column_asks_only_for_the_rows_the_window_shows() {
let mut ui = window(1.0);
let mut asked = 0..0;
let mut build = |ui: &mut Ui| {
ui.column().open();
asked = ui.list(100_000, 15.0);
for row in asked.clone() {
ui.row().key(row).open();
ui.label("x");
ui.close();
}
ui.close();
ui.close();
};
ui.run(&mut build);
ui.run(&mut build);
assert!(asked.len() <= 300 / 15 + 2, "{} rows were asked for, in a window that shows 20", asked.len());
}
#[test]
fn a_slider_with_its_range_backwards_takes_the_arrow_keys() {
let mut ui = window(1.0);
let mut value = 0.5;
let knob = std::cell::Cell::new(taut::geom::rect(0.0, 0.0, 0.0, 0.0));
let mut build = |ui: &mut Ui| knob.set(ui.slider(&mut value, 1.0..=0.0).rect);
settle(&mut ui, &mut build);
common::click(&mut ui, common::middle(knob.get()), &mut build);
common::key(&mut ui, taut::Key::Right, taut::Mods::NONE, &mut build);
}