Skip to content

Commit 718f8fe

Browse files
committed
add progress ring example tests and imgaes
1 parent f221b79 commit 718f8fe

File tree

9 files changed

+66
-6
lines changed

9 files changed

+66
-6
lines changed

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

Whitespace-only changes.

sdk/python/examples/controls/progress_ring/determinate_and_indeterminate.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,4 +35,5 @@ async def main(page: ft.Page):
3535
page.update()
3636

3737

38-
ft.run(main)
38+
if __name__ == "__main__":
39+
ft.run(main)

sdk/python/examples/controls/progress_ring/gauge_with_progress.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,5 @@ def main(page: ft.Page):
1414
)
1515

1616

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

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

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
---
22
class_name: flet.ProgressRing
33
examples: ../../examples/controls/progress_ring
4-
example_images: ../examples/controls/progress_ring/media
4+
example_images: ../test-images/examples/material/golden/macos/progress_ring
5+
example_media: ../examples/controls/progress_ring/media
56
---
67

7-
{{ class_summary(class_name) }}
8+
{{ class_summary(class_name, example_images + "/image_for_docs.png", image_caption="Fixed progress ring") }}
89

910
## Examples
1011

@@ -16,7 +17,7 @@ example_images: ../examples/controls/progress_ring/media
1617
--8<-- "{{ examples }}/determinate_and_indeterminate.py"
1718
```
1819

19-
{{ image(example_images + "/determinate_and_indeterminate.gif", alt="determinate-and-indeterminate", width="80%") }}
20+
{{ image(example_media + "/determinate_and_indeterminate.gif", alt="determinate-and-indeterminate", width="80%") }}
2021

2122

2223
### Gauge with progress
@@ -25,4 +26,6 @@ example_images: ../examples/controls/progress_ring/media
2526
--8<-- "{{ examples }}/gauge_with_progress.py"
2627
```
2728

29+
{{ image(example_images + "/gauge_with_progress.png", alt="determinate-and-indeterminate", width="80%") }}
30+
2831
{{ class_members(class_name) }}
7.42 KB
Loading
1.49 KB
Loading
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
import pytest
2+
3+
import flet as ft
4+
import flet.testing as ftt
5+
6+
from examples.controls.progress_ring import (
7+
gauge_with_progress,
8+
determinate_and_indeterminate,
9+
)
10+
11+
12+
@pytest.mark.asyncio(loop_scope="function")
13+
async def test_image_for_docs(flet_app_function: ftt.FletTestApp, request):
14+
flet_app_function.page.theme_mode = ft.ThemeMode.LIGHT
15+
await flet_app_function.assert_control_screenshot(
16+
request.node.name,
17+
ft.ProgressRing(value=0.4, padding=ft.Padding.all(10)),
18+
)
19+
20+
21+
@pytest.mark.parametrize(
22+
"flet_app_function",
23+
[{"flet_app_main": gauge_with_progress.main}],
24+
indirect=True,
25+
)
26+
@pytest.mark.asyncio(loop_scope="function")
27+
async def test_gauge_with_progress(flet_app_function: ftt.FletTestApp):
28+
flet_app_function.page.theme_mode = ft.ThemeMode.LIGHT
29+
flet_app_function.assert_screenshot(
30+
"gauge_with_progress",
31+
await flet_app_function.take_page_controls_screenshot(),
32+
)
33+
34+
35+
@pytest.mark.skip(reason="Test runs asynchronously")
36+
@pytest.mark.parametrize(
37+
"flet_app_function",
38+
[{"flet_app_main": determinate_and_indeterminate.main}],
39+
indirect=True,
40+
)
41+
@pytest.mark.asyncio(loop_scope="function")
42+
async def test_determinate_and_indeterminate(flet_app_function: ftt.FletTestApp):
43+
flet_app_function.page.theme_mode = ft.ThemeMode.LIGHT
44+
flet_app_function.page.enable_screenshots = True
45+
flet_app_function.page.update()
46+
47+
flet_app_function.assert_screenshot(
48+
"determinate_and_indeterminate",
49+
await flet_app_function.page.take_screenshot(delay=ft.Duration(seconds=15)),
50+
)

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import flet as ft
44
import flet.testing as ftt
55

6-
from examples.controls.radio import basic, handling_selection_changes, styled
6+
from examples.controls.radio import basic, handling_selection_changes
77

88

99
@pytest.mark.asyncio(loop_scope="function")

sdk/python/packages/flet/src/flet/controls/material/progress_ring.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,11 @@ class ProgressRing(LayoutControl):
1616
application is busy.
1717
1818
A control that shows progress along a circle.
19+
20+
```python
21+
ft.ProgressRing(value=0.4, padding=ft.Padding.all(10))
22+
```
23+
1924
"""
2025

2126
value: Optional[Number] = None

0 commit comments

Comments
 (0)