mirror of
https://github.com/Textualize/textual.git
synced 2025-10-17 02:38:12 +03:00
test for center layout
This commit is contained in:
33
tests/test_layouts_center.py
Normal file
33
tests/test_layouts_center.py
Normal 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
|
||||
Reference in New Issue
Block a user