|
| 1 | +import flet as ft |
| 2 | +import flet.testing as ftt |
| 3 | +import pytest |
| 4 | + |
| 5 | + |
| 6 | +@pytest.mark.asyncio(loop_scope="module") |
| 7 | +async def test_cupertino_bottom_sheet_basic(flet_app: ftt.FletTestApp, request): |
| 8 | + flet_app.page.theme_mode = ft.ThemeMode.LIGHT |
| 9 | + action_sheet = ft.CupertinoActionSheet( |
| 10 | + title=ft.Row( |
| 11 | + controls=[ft.Text("Title"), ft.Icon(ft.Icons.BEDTIME)], |
| 12 | + alignment=ft.MainAxisAlignment.CENTER, |
| 13 | + ), |
| 14 | + message=ft.Row( |
| 15 | + controls=[ft.Text("Description"), ft.Icon(ft.Icons.AUTO_AWESOME)], |
| 16 | + alignment=ft.MainAxisAlignment.CENTER, |
| 17 | + ), |
| 18 | + cancel=ft.CupertinoActionSheetAction( |
| 19 | + content=ft.Text("Cancel"), |
| 20 | + ), |
| 21 | + actions=[ |
| 22 | + ft.CupertinoActionSheetAction( |
| 23 | + content=ft.Text("Default Action"), |
| 24 | + default=True, |
| 25 | + ), |
| 26 | + ft.CupertinoActionSheetAction( |
| 27 | + content=ft.Text("Normal Action"), |
| 28 | + ), |
| 29 | + ft.CupertinoActionSheetAction( |
| 30 | + content=ft.Text("Destructive Action"), |
| 31 | + destructive=True, |
| 32 | + ), |
| 33 | + ], |
| 34 | + ) |
| 35 | + |
| 36 | + cupertino_bottom_sheet = ft.CupertinoBottomSheet(action_sheet) |
| 37 | + flet_app.page.enable_screenshots = True |
| 38 | + flet_app.page.window.width = 400 |
| 39 | + flet_app.page.window.height = 600 |
| 40 | + flet_app.page.show_dialog(cupertino_bottom_sheet) |
| 41 | + flet_app.page.update() |
| 42 | + await flet_app.tester.pump_and_settle() |
| 43 | + |
| 44 | + flet_app.assert_screenshot( |
| 45 | + "cupertino_bottom_sheet_basic", |
| 46 | + await flet_app.page.take_screenshot( |
| 47 | + pixel_ratio=flet_app.screenshots_pixel_ratio |
| 48 | + ), |
| 49 | + ) |
0 commit comments