File: test_overflow_change.py

package info (click to toggle)
textual 2.1.2-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 55,084 kB
  • sloc: python: 85,423; lisp: 1,669; makefile: 101
file content (35 lines) | stat: -rw-r--r-- 1,049 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
"""Regression test for #1616 https://github.com/Textualize/textual/issues/1616"""

from textual.app import App
from textual.containers import VerticalScroll


async def test_overflow_change_updates_virtual_size_appropriately():
    class MyApp(App):
        def compose(self):
            yield VerticalScroll()

    app = MyApp()

    async with app.run_test() as pilot:
        vertical = app.query_one(VerticalScroll)

        height = vertical.virtual_size.height

        vertical.styles.overflow_x = "scroll"
        await pilot.pause()  # Let changes propagate.
        assert vertical.virtual_size.height < height

        vertical.styles.overflow_x = "hidden"
        await pilot.pause()
        assert vertical.virtual_size.height == height

        width = vertical.virtual_size.width

        vertical.styles.overflow_y = "scroll"
        await pilot.pause()
        assert vertical.virtual_size.width < width

        vertical.styles.overflow_y = "hidden"
        await pilot.pause()
        assert vertical.virtual_size.width == width