|
| 1 | +import pytest |
| 2 | + |
| 3 | +import flet as ft |
| 4 | +import flet.testing as ftt |
| 5 | + |
| 6 | + |
| 7 | +@pytest.mark.asyncio(loop_scope="module") |
| 8 | +async def test_navigation_drawer_position_end(flet_app: ftt.FletTestApp, request): |
| 9 | + flet_app.page.theme_mode = ft.ThemeMode.LIGHT |
| 10 | + |
| 11 | + end_drawer = ft.NavigationDrawer( |
| 12 | + position=ft.NavigationDrawerPosition.END, |
| 13 | + controls=[ |
| 14 | + ft.NavigationDrawerDestination( |
| 15 | + icon=ft.Icons.ADD_TO_HOME_SCREEN_SHARP, |
| 16 | + label="Item 1", |
| 17 | + ), |
| 18 | + ft.NavigationDrawerDestination( |
| 19 | + icon=ft.Icon(ft.Icons.ADD_COMMENT), |
| 20 | + label="Item 2", |
| 21 | + ), |
| 22 | + ], |
| 23 | + ) |
| 24 | + |
| 25 | + flet_app.page.enable_screenshots = True |
| 26 | + flet_app.page.window.width = 400 |
| 27 | + flet_app.page.window.height = 600 |
| 28 | + flet_app.page.show_dialog(end_drawer) |
| 29 | + flet_app.page.update() |
| 30 | + await flet_app.tester.pump_and_settle() |
| 31 | + |
| 32 | + flet_app.assert_screenshot( |
| 33 | + "navigation_drawer_position_end", |
| 34 | + await flet_app.page.take_screenshot( |
| 35 | + pixel_ratio=flet_app.screenshots_pixel_ratio |
| 36 | + ), |
| 37 | + ) |
| 38 | + |
| 39 | + |
| 40 | +@pytest.mark.asyncio(loop_scope="module") |
| 41 | +async def test_navigation_drawer_default_position(flet_app: ftt.FletTestApp, request): |
| 42 | + flet_app.page.theme_mode = ft.ThemeMode.LIGHT |
| 43 | + |
| 44 | + end_drawer = ft.NavigationDrawer( |
| 45 | + controls=[ |
| 46 | + ft.NavigationDrawerDestination( |
| 47 | + icon=ft.Icons.ADD_TO_HOME_SCREEN_SHARP, |
| 48 | + label="Item 1", |
| 49 | + ), |
| 50 | + ft.NavigationDrawerDestination( |
| 51 | + icon=ft.Icon(ft.Icons.ADD_COMMENT), |
| 52 | + label="Item 2", |
| 53 | + ), |
| 54 | + ], |
| 55 | + ) |
| 56 | + |
| 57 | + flet_app.page.enable_screenshots = True |
| 58 | + flet_app.page.window.width = 400 |
| 59 | + flet_app.page.window.height = 600 |
| 60 | + flet_app.page.show_dialog(end_drawer) |
| 61 | + flet_app.page.update() |
| 62 | + await flet_app.tester.pump_and_settle() |
| 63 | + |
| 64 | + # normal state |
| 65 | + flet_app.assert_screenshot( |
| 66 | + "navigation_drawer_default_position", |
| 67 | + await flet_app.page.take_screenshot( |
| 68 | + pixel_ratio=flet_app.screenshots_pixel_ratio |
| 69 | + ), |
| 70 | + ) |
0 commit comments