test for center layout

This commit is contained in:
Will McGugan
2022-08-07 11:27:33 +01:00
parent 85e3409309
commit 5d7a821e1f
2 changed files with 36 additions and 4 deletions

View File

@@ -0,0 +1,33 @@
from textual.geometry import Region, Size
from textual.widget import Widget
from textual.layouts.center import CenterLayout
from textual._layout import WidgetPlacement
def test_center_layout():
widget = Widget()
widget._size = Size(80, 24)
child = Widget()
child.styles.width = 10
child.styles.height = 5
layout = CenterLayout()
placements, widgets = layout.arrange(widget, [child], Size(60, 20))
assert widgets == {child}
expected = [
WidgetPlacement(
region=Region(x=25, y=7, width=10, height=5),
widget=child,
order=0,
fixed=False,
),
WidgetPlacement(
region=Region(x=25, y=7, width=10, height=5),
widget=None,
order=0,
fixed=False,
),
]
assert placements == expected