-
Notifications
You must be signed in to change notification settings - Fork 599
Owen/control docs p8 #5887
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Owen/control docs p8 #5887
Changes from 5 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
9a1586c
add navigation bar example tests and images
OwenMcDonnell e3b028b
add menuitembutton example tests and images
OwenMcDonnell 588f770
add menu bar example tests and images
OwenMcDonnell 5d55a09
add list view example tests and images
OwenMcDonnell 9fecf6f
unccoment menu bar test
OwenMcDonnell 0151810
add pixel_ratio parameter to screenshots, fix navigation bar width
OwenMcDonnell d44500b
change submenu example width
OwenMcDonnell 1f6401c
add cupertino timer picker example tests and images
OwenMcDonnell 198465f
update navigation bar and badge golden images
OwenMcDonnell File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Empty file.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -67,4 +67,5 @@ def handle_on_hover(e: ft.Event[ft.MenuItemButton]): | |
| ) | ||
|
|
||
|
|
||
| ft.run(main) | ||
| if __name__ == "__main__": | ||
| ft.run(main) | ||
Empty file.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -19,4 +19,5 @@ def main(page: ft.Page): | |
| page.add(ft.Text("Body!")) | ||
|
|
||
|
|
||
| ft.run(main) | ||
| if __name__ == "__main__": | ||
| ft.run(main) | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file added
BIN
+4.85 KB
.../flet/integration_tests/examples/core/golden/macos/list_view/image_for_docs.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
18 changes: 18 additions & 0 deletions
18
sdk/python/packages/flet/integration_tests/examples/core/test_list_view.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| import pytest | ||
|
|
||
| import flet as ft | ||
| import flet.testing as ftt | ||
|
|
||
|
|
||
| @pytest.mark.asyncio(loop_scope="function") | ||
| async def test_image_for_docs(flet_app_function: ftt.FletTestApp, request): | ||
| flet_app_function.page.theme_mode = ft.ThemeMode.LIGHT | ||
| flet_app_function.resize_page(100, 300) | ||
| flet_app_function.page.update() | ||
| await flet_app_function.assert_control_screenshot( | ||
| request.node.name, | ||
| ft.ListView( | ||
| controls=[ft.Text(f"Item {i}") for i in range(1, 6)], | ||
| divider_thickness=1, | ||
| ), | ||
| ) |
Binary file added
BIN
+10.8 KB
...et/integration_tests/examples/material/golden/macos/menu_bar/image_for_docs.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+24.9 KB
...t/integration_tests/examples/material/golden/macos/menu_bar/nested_submenus.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+11.5 KB
.../integration_tests/examples/material/golden/macos/menu_bar/nested_submenus1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+20.9 KB
.../integration_tests/examples/material/golden/macos/menu_bar/nested_submenus2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+17.8 KB
.../integration_tests/examples/material/golden/macos/menu_bar/nested_submenus3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+24.8 KB
...let/integration_tests/examples/material/golden/macos/menu_item_button/basic.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+16.7 KB
...et/integration_tests/examples/material/golden/macos/menu_item_button/basic1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+25.6 KB
...et/integration_tests/examples/material/golden/macos/menu_item_button/basic2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+14.5 KB
...et/integration_tests/examples/material/golden/macos/menu_item_button/basic3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+4.79 KB
...ration_tests/examples/material/golden/macos/menu_item_button/image_for_docs.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+16.6 KB
.../flet/integration_tests/examples/material/golden/macos/navigation_bar/basic.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+7.88 KB
...egration_tests/examples/material/golden/macos/navigation_bar/image_for_docs.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
82 changes: 82 additions & 0 deletions
82
sdk/python/packages/flet/integration_tests/examples/material/test_menu_bar.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,82 @@ | ||
| import pytest | ||
|
|
||
| import flet as ft | ||
| import flet.testing as ftt | ||
|
|
||
| from examples.controls.menu_bar import nested_submenus | ||
|
|
||
|
|
||
| @pytest.mark.asyncio(loop_scope="function") | ||
| async def test_image_for_docs(flet_app_function: ftt.FletTestApp, request): | ||
| flet_app_function.page.theme_mode = ft.ThemeMode.LIGHT | ||
| flet_app_function.page.enable_screenshots = True | ||
| flet_app_function.resize_page(100, 200) | ||
| flet_app_function.page.update() | ||
| mb = ft.MenuBar( | ||
| controls=[ | ||
| ft.SubmenuButton( | ||
| content=ft.Text("Submenu"), | ||
| controls=[ | ||
| ft.MenuItemButton(content=ft.Text("Item 1")), | ||
| ft.MenuItemButton(content=ft.Text("Item 2")), | ||
| ft.MenuItemButton(content=ft.Text("Item 3")), | ||
| ], | ||
| ), | ||
| ], | ||
| ) | ||
| flet_app_function.page.add(mb) | ||
| flet_app_function.page.update() | ||
| await flet_app_function.tester.pump_and_settle() | ||
| btn = await flet_app_function.tester.find_by_text("Submenu") | ||
| await flet_app_function.tester.tap(btn) | ||
| await flet_app_function.tester.pump_and_settle() | ||
|
|
||
| flet_app_function.assert_screenshot( | ||
| "image_for_docs", | ||
| await flet_app_function.page.take_screenshot(), | ||
| ) | ||
|
|
||
|
|
||
| @pytest.mark.parametrize( | ||
| "flet_app_function", | ||
| [{"flet_app_main": nested_submenus.main}], | ||
| indirect=True, | ||
| ) | ||
| @pytest.mark.asyncio(loop_scope="function") | ||
| async def test_nested_submenus(flet_app_function: ftt.FletTestApp): | ||
| flet_app_function.page.enable_screenshots = True | ||
| flet_app_function.resize_page(400, 400) | ||
| flet_app_function.page.update() | ||
| await flet_app_function.tester.pump_and_settle( | ||
| duration=ft.Duration(milliseconds=500) | ||
| ) | ||
| flet_app_function.assert_screenshot( | ||
| "nested_submenus1", | ||
| await flet_app_function.page.take_screenshot( | ||
| pixel_ratio=flet_app_function.screenshots_pixel_ratio | ||
| ), | ||
| ) | ||
| smb = await flet_app_function.tester.find_by_text("File") | ||
| await flet_app_function.tester.tap(smb) | ||
| await flet_app_function.tester.pump_and_settle() | ||
| flet_app_function.assert_screenshot( | ||
| "nested_submenus2", | ||
| await flet_app_function.page.take_screenshot( | ||
| pixel_ratio=flet_app_function.screenshots_pixel_ratio | ||
| ), | ||
| ) | ||
| mib = await flet_app_function.tester.find_by_text("Save") | ||
| await flet_app_function.tester.tap(mib) | ||
| await flet_app_function.tester.pump_and_settle() | ||
| flet_app_function.assert_screenshot( | ||
| "nested_submenus3", | ||
| await flet_app_function.page.take_screenshot( | ||
| pixel_ratio=flet_app_function.screenshots_pixel_ratio | ||
| ), | ||
| ) | ||
|
|
||
| flet_app_function.create_gif( | ||
| ["nested_submenus1", "nested_submenus2", "nested_submenus3"], | ||
| "nested_submenus", | ||
| duration=1600, | ||
| ) |
80 changes: 80 additions & 0 deletions
80
sdk/python/packages/flet/integration_tests/examples/material/test_menu_item_button.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,80 @@ | ||
| import pytest | ||
|
|
||
| import flet as ft | ||
| import flet.testing as ftt | ||
|
|
||
| from examples.controls.menu_item_button import basic | ||
|
|
||
|
|
||
| @pytest.mark.asyncio(loop_scope="function") | ||
| async def test_image_for_docs(flet_app_function: ftt.FletTestApp, request): | ||
| flet_app_function.page.theme_mode = ft.ThemeMode.LIGHT | ||
| await flet_app_function.assert_control_screenshot( | ||
| request.node.name, | ||
| ft.Row( | ||
| controls=[ | ||
| ft.MenuItemButton( | ||
| content=ft.Text("Yes"), | ||
| on_click=lambda e: print("yes"), | ||
| autofocus=True, | ||
| ), | ||
| ft.MenuItemButton( | ||
| content=ft.Text("No"), | ||
| on_click=lambda e: print("no"), | ||
| ), | ||
| ft.MenuItemButton( | ||
| content=ft.Text("Maybe"), | ||
| on_click=lambda e: print("maybe"), | ||
| ), | ||
| ], | ||
| alignment=ft.MainAxisAlignment.CENTER, | ||
| height=50, | ||
| width=200, | ||
| expand=True, | ||
| ), | ||
| ) | ||
|
|
||
|
|
||
| @pytest.mark.parametrize( | ||
| "flet_app_function", | ||
| [{"flet_app_main": basic.main}], | ||
| indirect=True, | ||
| ) | ||
| @pytest.mark.asyncio(loop_scope="function") | ||
| async def test_basic(flet_app_function: ftt.FletTestApp): | ||
| flet_app_function.page.enable_screenshots = True | ||
| flet_app_function.resize_page(400, 400) | ||
| flet_app_function.page.update() | ||
| await flet_app_function.tester.pump_and_settle( | ||
| duration=ft.Duration(milliseconds=500) | ||
| ) | ||
| flet_app_function.assert_screenshot( | ||
| "basic1", | ||
| await flet_app_function.page.take_screenshot( | ||
| pixel_ratio=flet_app_function.screenshots_pixel_ratio | ||
| ), | ||
| ) | ||
| btn = await flet_app_function.tester.find_by_text("BgColors") | ||
| await flet_app_function.tester.tap(btn) | ||
| await flet_app_function.tester.pump_and_settle() | ||
| flet_app_function.assert_screenshot( | ||
| "basic2", | ||
| await flet_app_function.page.take_screenshot( | ||
| pixel_ratio=flet_app_function.screenshots_pixel_ratio | ||
| ), | ||
| ) | ||
| mib = await flet_app_function.tester.find_by_text("Green") | ||
| await flet_app_function.tester.tap(mib) | ||
| await flet_app_function.tester.pump_and_settle() | ||
| flet_app_function.assert_screenshot( | ||
| "basic3", | ||
| await flet_app_function.page.take_screenshot( | ||
| pixel_ratio=flet_app_function.screenshots_pixel_ratio | ||
| ), | ||
| ) | ||
|
|
||
| flet_app_function.create_gif( | ||
| ["basic1", "basic2", "basic3"], | ||
| "basic", | ||
| duration=1600, | ||
| ) |
47 changes: 47 additions & 0 deletions
47
sdk/python/packages/flet/integration_tests/examples/material/test_navigation_bar.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,47 @@ | ||
| import pytest | ||
|
|
||
| import flet as ft | ||
| import flet.testing as ftt | ||
|
|
||
| from examples.controls.navigation_bar import basic | ||
|
|
||
|
|
||
| @pytest.mark.asyncio(loop_scope="function") | ||
| async def test_image_for_docs(flet_app_function: ftt.FletTestApp, request): | ||
| flet_app_function.page.theme_mode = ft.ThemeMode.LIGHT | ||
| flet_app_function.page.enable_screenshots = True | ||
| nvb = ft.NavigationBar( | ||
| destinations=[ | ||
| ft.NavigationBarDestination(icon=ft.Icons.CIRCLE, label="Item 1"), | ||
| ft.NavigationBarDestination(icon=ft.Icons.SQUARE, label="Item 2"), | ||
| ft.NavigationBarDestination(icon=ft.Icons.HEXAGON, label="Item 3"), | ||
| ], | ||
| ) | ||
| flet_app_function.resize_page(300, 100) | ||
| flet_app_function.page.navigation_bar = nvb | ||
| flet_app_function.page.update() | ||
| await flet_app_function.tester.pump_and_settle( | ||
| duration=ft.Duration(milliseconds=800) | ||
| ) | ||
| flet_app_function.assert_screenshot( | ||
| "image_for_docs", | ||
| await flet_app_function.page.take_screenshot(), | ||
| ) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. and while you are there you may make this screenshot wider to remove horizontal scrollbar: https://github.com/flet-dev/flet/pull/5887/files#diff-e60ac2b820dd5525c3013f9ce6bbae7a779531b432745ba86a4308ab276ea6c1 |
||
|
|
||
|
|
||
| @pytest.mark.parametrize( | ||
| "flet_app_function", | ||
| [{"flet_app_main": basic.main}], | ||
| indirect=True, | ||
| ) | ||
| @pytest.mark.asyncio(loop_scope="function") | ||
| async def test_basic(flet_app_function: ftt.FletTestApp): | ||
| flet_app_function.page.theme_mode = ft.ThemeMode.LIGHT | ||
| flet_app_function.page.enable_screenshots = True | ||
| flet_app_function.resize_page(300, 300) | ||
| flet_app_function.page.update() | ||
| await flet_app_function.tester.pump_and_settle() | ||
| flet_app_function.assert_screenshot( | ||
| "basic", | ||
| await flet_app_function.page.take_screenshot(), | ||
| ) | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pixel ration argument should be passed into
page.take_screenshot()call, otherwise the test will be failing in CI environment with non-hi-res virtual display.Make sure this is fixed everywhere.