|
| 1 | +import pytest |
| 2 | + |
| 3 | +import flet as ft |
| 4 | +import flet.testing as ftt |
| 5 | + |
| 6 | +from examples.controls.menu_bar import nested_submenus |
| 7 | + |
| 8 | + |
| 9 | +@pytest.mark.asyncio(loop_scope="function") |
| 10 | +async def test_image_for_docs(flet_app_function: ftt.FletTestApp, request): |
| 11 | + flet_app_function.page.theme_mode = ft.ThemeMode.LIGHT |
| 12 | + flet_app_function.page.enable_screenshots = True |
| 13 | + flet_app_function.resize_page(100, 200) |
| 14 | + flet_app_function.page.update() |
| 15 | + mb = ft.MenuBar( |
| 16 | + controls=[ |
| 17 | + ft.SubmenuButton( |
| 18 | + content=ft.Text("Submenu"), |
| 19 | + controls=[ |
| 20 | + ft.MenuItemButton(content=ft.Text("Item 1")), |
| 21 | + ft.MenuItemButton(content=ft.Text("Item 2")), |
| 22 | + ft.MenuItemButton(content=ft.Text("Item 3")), |
| 23 | + ], |
| 24 | + ), |
| 25 | + ], |
| 26 | + ) |
| 27 | + flet_app_function.page.add(mb) |
| 28 | + flet_app_function.page.update() |
| 29 | + await flet_app_function.tester.pump_and_settle() |
| 30 | + btn = await flet_app_function.tester.find_by_text("Submenu") |
| 31 | + await flet_app_function.tester.tap(btn) |
| 32 | + await flet_app_function.tester.pump_and_settle() |
| 33 | + |
| 34 | + flet_app_function.assert_screenshot( |
| 35 | + "image_for_docs", |
| 36 | + await flet_app_function.page.take_screenshot(), |
| 37 | + ) |
| 38 | + |
| 39 | + |
| 40 | +# @pytest.mark.parametrize( |
| 41 | +# "flet_app_function", |
| 42 | +# [{"flet_app_main": nested_submenus.main}], |
| 43 | +# indirect=True, |
| 44 | +# ) |
| 45 | +# @pytest.mark.asyncio(loop_scope="function") |
| 46 | +# async def test_nested_submenus(flet_app_function: ftt.FletTestApp): |
| 47 | +# flet_app_function.page.enable_screenshots = True |
| 48 | +# flet_app_function.resize_page(400, 400) |
| 49 | +# flet_app_function.page.update() |
| 50 | +# await flet_app_function.tester.pump_and_settle( |
| 51 | +# duration=ft.Duration(milliseconds=500) |
| 52 | +# ) |
| 53 | +# flet_app_function.assert_screenshot( |
| 54 | +# "nested_submenus1", |
| 55 | +# await flet_app_function.page.take_screenshot( |
| 56 | +# pixel_ratio=flet_app_function.screenshots_pixel_ratio |
| 57 | +# ), |
| 58 | +# ) |
| 59 | +# smb = await flet_app_function.tester.find_by_text("File") |
| 60 | +# await flet_app_function.tester.tap(smb) |
| 61 | +# await flet_app_function.tester.pump_and_settle() |
| 62 | +# flet_app_function.assert_screenshot( |
| 63 | +# "nested_submenus2", |
| 64 | +# await flet_app_function.page.take_screenshot( |
| 65 | +# pixel_ratio=flet_app_function.screenshots_pixel_ratio |
| 66 | +# ), |
| 67 | +# ) |
| 68 | +# mib = await flet_app_function.tester.find_by_text("Save") |
| 69 | +# await flet_app_function.tester.tap(mib) |
| 70 | +# await flet_app_function.tester.pump_and_settle() |
| 71 | +# flet_app_function.assert_screenshot( |
| 72 | +# "nested_submenus3", |
| 73 | +# await flet_app_function.page.take_screenshot( |
| 74 | +# pixel_ratio=flet_app_function.screenshots_pixel_ratio |
| 75 | +# ), |
| 76 | +# ) |
| 77 | + |
| 78 | +# flet_app_function.create_gif( |
| 79 | +# ["nested_submenus1", "nested_submenus2", "nested_submenus3"], |
| 80 | +# "nested_submenus", |
| 81 | +# duration=1600, |
| 82 | +# ) |
0 commit comments