()
| 8 | |
| 9 | |
| 10 | async def test_content_box(): |
| 11 | one = Fraction(1) |
| 12 | |
| 13 | class TestWidget(Widget): |
| 14 | def get_content_width(self, container: Size, parent: Size) -> int: |
| 15 | assert False, "must not be called" |
| 16 | |
| 17 | def get_content_height(self, container: Size, parent: Size) -> int: |
| 18 | assert False, "must not be called" |
| 19 | |
| 20 | widget = TestWidget() |
| 21 | |
| 22 | # border-box is default |
| 23 | assert widget.styles.box_sizing == "border-box" |
| 24 | |
| 25 | widget.styles.width = 10 |
| 26 | widget.styles.height = 8 |
| 27 | widget.styles.padding = 1 |
| 28 | widget.styles.border = ("solid", "red") |
| 29 | |
| 30 | box_model = widget._get_box_model( |
| 31 | Size(60, 20), |
| 32 | Size(80, 24), |
| 33 | one, |
| 34 | one, |
| 35 | ) |
| 36 | # Size should be inclusive of padding / border |
| 37 | assert box_model == BoxModel(Fraction(10), Fraction(8), Spacing(0, 0, 0, 0)) |
| 38 | |
| 39 | # Switch to content-box |
| 40 | widget.styles.box_sizing = "content-box" |
| 41 | |
| 42 | box_model = widget._get_box_model(Size(60, 20), Size(80, 24), one, one) |
| 43 | # width and height have added padding / border to accommodate content |
| 44 | assert box_model == BoxModel(Fraction(14), Fraction(12), Spacing(0, 0, 0, 0)) |
| 45 | |
| 46 | |
| 47 | async def test_width(): |
nothing calls this directly
no test coverage detected
searching dependent graphs…