cells tests: Image extent is rounded up
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
bc66506c24
commit
441c9dc549
1 changed files with 4 additions and 1 deletions
|
|
@ -1,10 +1,11 @@
|
||||||
//! The Cells text engine: pinned widths, sanitizing, wrapping, and that `measure` and `text`
|
//! The Cells text engine: pinned widths, sanitizing, wrapping, and that `measure` and `text`
|
||||||
//! agree. Vectors were checked against unicode-width 0.2.3 (ambiguous width narrow).
|
//! agree. Vectors were checked against unicode-width 0.2.3 (ambiguous width narrow).
|
||||||
|
|
||||||
use thing_contract::NodeId;
|
use thing_contract::{AssetEntry, NodeId};
|
||||||
use thing_core::bind::Bound;
|
use thing_core::bind::Bound;
|
||||||
use thing_core::layout::{Avail, Constraint, Leaf, Measure, Run, TextRequest};
|
use thing_core::layout::{Avail, Constraint, Leaf, Measure, Run, TextRequest};
|
||||||
use thing_core::text::{CellMeasure, CellText};
|
use thing_core::text::{CellMeasure, CellText};
|
||||||
|
use thing_testkit::build::count;
|
||||||
|
|
||||||
fn widths(s: &str) -> Vec<u8> {
|
fn widths(s: &str) -> Vec<u8> {
|
||||||
CellText::new(s).clusters().map(|(_, w)| w).collect()
|
CellText::new(s).clusters().map(|(_, w)| w).collect()
|
||||||
|
|
@ -160,6 +161,8 @@ fn controls_have_shipped_sizes() {
|
||||||
assert_eq!(m.measure(&Leaf::Slider { node: &node }, c), (20.0, 1.0));
|
assert_eq!(m.measure(&Leaf::Slider { node: &node }, c), (20.0, 1.0));
|
||||||
assert_eq!(m.measure(&Leaf::Select { node: &node, selected: &text }, c), (20.0, 1.0));
|
assert_eq!(m.measure(&Leaf::Select { node: &node, selected: &text }, c), (20.0, 1.0));
|
||||||
assert_eq!(m.measure(&Leaf::Image { node: &node, asset: &Bound::Absent }, c), (0.0, 0.0));
|
assert_eq!(m.measure(&Leaf::Image { node: &node, asset: &Bound::Absent }, c), (0.0, 0.0));
|
||||||
|
let entry = AssetEntry { id: "a".into(), media_type: "image/png".into(), uri: "asset://a".into(), width: count(17), height: count(33) };
|
||||||
|
assert_eq!(m.measure(&Leaf::Image { node: &node, asset: &Bound::Asset(entry) }, c), (3.0, 3.0), "extent over (8, 16), rounded up");
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Random strings, every control among them, never panic and never put a control character into
|
/// Random strings, every control among them, never panic and never put a control character into
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue