Skip to content

Commit c1ce3f5

Browse files
committed
add Placeholder example test and images
1 parent 4fe80c5 commit c1ce3f5

File tree

8 files changed

+55
-6
lines changed

8 files changed

+55
-6
lines changed

sdk/python/examples/controls/placeholder/__init__.py

Whitespace-only changes.

sdk/python/examples/controls/placeholder/basic.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,13 @@ def main(page: ft.Page):
55
page.add(
66
ft.Placeholder(
77
expand=True,
8-
color=ft.Colors.random(),
8+
color=ft.Colors.GREEN_ACCENT,
9+
fallback_height=200,
10+
fallback_width=300,
11+
stroke_width=20,
912
)
1013
)
1114

1215

13-
ft.run(main)
16+
if __name__ == "__main__":
17+
ft.run(main)

sdk/python/packages/flet/docs/controls/placeholder.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
---
22
class_name: flet.Placeholder
33
examples: ../../examples/controls/placeholder
4-
example_images: ../examples/controls/placeholder/media
4+
example_images: ../test-images/examples/core/golden/macos/placeholder
55
---
66

7-
{{ class_summary(class_name) }}
7+
{{ class_summary(class_name, example_images + "/image_for_docs.png", image_caption="Placeholder") }}
88

99
## Examples
1010

3.53 KB
Loading
48.2 KB
Loading
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import pytest
2+
3+
import flet as ft
4+
import flet.testing as ftt
5+
6+
from examples.controls.placeholder import basic
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+
# await flet_app_function.assert_control_screenshot(
13+
# request.node.name,
14+
# ft.Placeholder(
15+
# expand=True,
16+
# color=ft.Colors.RED_500,
17+
# ),
18+
# )
19+
20+
21+
@pytest.mark.parametrize(
22+
"flet_app_function",
23+
[{"flet_app_main": basic.main}],
24+
indirect=True,
25+
)
26+
@pytest.mark.asyncio(loop_scope="function")
27+
async def test_basic(flet_app_function: ftt.FletTestApp):
28+
flet_app_function.page.enable_screenshots = True
29+
flet_app_function.resize_page(200, 200)
30+
flet_app_function.page.update()
31+
await flet_app_function.tester.pump_and_settle()
32+
flet_app_function.assert_screenshot(
33+
"basic",
34+
await flet_app_function.page.take_screenshot(
35+
pixel_ratio=flet_app_function.screenshots_pixel_ratio
36+
),
37+
)

sdk/python/packages/flet/integration_tests/examples/material/test_popup_menu_button.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,13 +46,13 @@ async def test_image_for_docs(flet_app_function: ftt.FletTestApp, request):
4646
indirect=True,
4747
)
4848
@pytest.mark.asyncio(loop_scope="function")
49-
async def test_determinate_and_indeterminate(flet_app_function: ftt.FletTestApp):
49+
async def test_basic(flet_app_function: ftt.FletTestApp):
5050
flet_app_function.page.theme_mode = ft.ThemeMode.LIGHT
5151
flet_app_function.page.enable_screenshots = True
5252
pb = await flet_app_function.tester.find_by_key("popup")
5353
await flet_app_function.tester.tap(pb)
5454
await flet_app_function.tester.pump_and_settle()
5555
flet_app_function.assert_screenshot(
56-
"determinate_and_indeterminate",
56+
"basic",
5757
await flet_app_function.page.take_screenshot(delay=ft.Duration(seconds=15)),
5858
)

sdk/python/packages/flet/src/flet/controls/core/placeholder.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,14 @@
1313
class Placeholder(LayoutControl):
1414
"""
1515
A placeholder box.
16+
17+
```python
18+
ft.Placeholder(
19+
expand=True,
20+
color=ft.Colors.RED_500,
21+
)
22+
```
23+
1624
"""
1725

1826
content: Optional[Control] = None

0 commit comments

Comments
 (0)