feat: constrain flex bases and redistribute bounded growth and shrink
Verify Tessera GUI / verify (push) Failing after 9m4s

This commit is contained in:
2026-10-23 00:42:48 +08:00
parent 78fb66277d
commit 1fda07ebc5
12 changed files with 298 additions and 55 deletions
+48
View File
@@ -3889,6 +3889,54 @@ page.render(block)
);
}
#[test]
fn bounded_flex_redistributes_growth_and_scaled_shrink() {
let (mut session, initial) = ReplSession::load(
r#"
class Wide: Row {
function measure(self: Wide, mount: Mount, constraints: Constraints): MeasureResult { return MeasureResult(340, 60) }
}
first = RectBlock(20, 20)
second = RectBlock(40, 20)
fixed = RectBlock(60, 20)
first.flex = 1
second.flex = 3
first.flexBasis = 100
second.flexBasis = 100
first.flexMax = 105
row = Wide(10, 10, first, second, fixed)
page = Page()
page.render(row)
"#,
"app.main",
267,
1,
)
.unwrap();
initial.validate().unwrap();
let width = |session: &mut ReplSession, name| {
session
.execute(&format!("{name}.mounts().at(0).bounds().width"), "app.main")
.unwrap()
.value
};
assert_eq!(width(&mut session, "first"), "105");
assert_eq!(width(&mut session, "second"), "135");
session.execute(
"first.flex = 0\nsecond.flex = 0\nfirst.flexMax = 300\nfirst.flexMin = 150\nfirst.flexBasis = 200\nsecond.flexBasis = 200\nfirst.flexShrink = 1\nsecond.flexShrink = 1",
"app.main",
).unwrap();
assert_eq!(width(&mut session, "first"), "150");
assert_eq!(width(&mut session, "second"), "90");
assert_eq!(width(&mut session, "fixed"), "60");
session.execute(
"first.flexMin = 0\nfirst.flexMax = 1000000\nfirst.flexBasis = \"auto\"\nsecond.flexBasis = \"auto\"",
"app.main",
).unwrap();
assert_eq!(width(&mut session, "first"), "20");
assert_eq!(width(&mut session, "second"), "40");
}
#[test]
fn native_flex_reflows_shared_text_per_occurrence() {
let (mut session, initial) = ReplSession::load(