Skip to content

Commit f45ecff

Browse files
committed
updated tests
1 parent 0cb2b3a commit f45ecff

1 file changed

Lines changed: 60 additions & 67 deletions

File tree

sdk/python/packages/flet/integration_tests/controls/test_list_tile.py

Lines changed: 60 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -172,70 +172,52 @@ async def test_properties2(flet_app: ftt.FletTestApp, request):
172172

173173
@pytest.mark.asyncio(loop_scope="function")
174174
async def test_properties3(flet_app: ftt.FletTestApp, request):
175-
flet_app.page.enable_screenshots = True
176-
flet_app.page.window.width = 400
177-
flet_app.page.window.height = 600
178-
179-
lt = ft.ListTile(
180-
key="lt",
181-
title="List Tile without three line",
182-
subtitle="Long Long Long Long Long Long Long Long Long Long Long "
183-
"Long Long Long Long Long Long Long Long Long Long Long"
184-
"Long Subtitle with is_three_line = False",
185-
# is_three_line=True,
186-
leading=ft.Icon(ft.Icons.STAR),
187-
trailing=ft.Icon(ft.Icons.ARROW_FORWARD),
188-
bgcolor=ft.Colors.LIGHT_BLUE_ACCENT_100,
189-
splash_color=ft.Colors.GREEN_200, # is not shown on screenshot
190-
hover_color=ft.Colors.YELLOW_200,
191-
)
192-
193-
lt1 = ft.ListTile(
194-
title="List Tile with three line",
195-
subtitle="Long Long Long Long Long Long Long Long Long Long Long "
196-
"Long Long Long Long Long Long Long Long Long Long Long"
197-
"Long Subtitle with is_three_line = True",
198-
is_three_line=True, # not sure if this behaviour is correct or not.
199-
# Tested it in flutter, it also shows more than 3 lines
200-
leading=ft.Icon(ft.Icons.STAR),
201-
trailing=ft.Icon(ft.Icons.ARROW_FORWARD),
202-
bgcolor=ft.Colors.LIGHT_BLUE_ACCENT_100,
203-
splash_color=ft.Colors.GREEN_200, # is not shown on screenshot
204-
hover_color=ft.Colors.YELLOW_200,
205-
)
206-
207-
lt2 = ft.ListTile(
208-
title="List Tile with Compact visual density",
209-
subtitle="Long Long Long Long Long Long Long Long Long Long Long "
210-
"Long Long Long Long Long Long Long Long Long Long Long"
211-
"Long Subtitle with is_three_line = False",
212-
leading=ft.Icon(ft.Icons.STAR),
213-
trailing=ft.Icon(ft.Icons.ARROW_FORWARD),
214-
bgcolor=ft.Colors.LIGHT_BLUE_ACCENT_100,
215-
visual_density=ft.VisualDensity.COMPACT,
216-
)
217-
218-
flet_app.page.add(lt, lt1, lt2)
219-
flet_app.page.update()
220-
await flet_app.tester.pump_and_settle()
221-
222-
flet_app.assert_screenshot(
223-
"properties_3_normal",
224-
await flet_app.page.take_screenshot(
225-
pixel_ratio=flet_app.screenshots_pixel_ratio
226-
),
227-
)
228-
229-
# test hover
230-
tile = await flet_app.tester.find_by_key("lt")
231-
assert tile.count == 1
232-
await flet_app.tester.mouse_hover(tile)
233-
await flet_app.tester.pump_and_settle()
234-
235-
flet_app.assert_screenshot(
236-
"properties_3_hover",
237-
await flet_app.page.take_screenshot(
238-
pixel_ratio=flet_app.screenshots_pixel_ratio
175+
await flet_app.assert_control_screenshot(
176+
request.node.name,
177+
ft.Column(
178+
controls=[
179+
ft.ListTile(
180+
title="List Tile without three line",
181+
subtitle="Long Long Long Long Long Long Long Long Long Long Long "
182+
"Long Long Long Long Long Long Long Long Long Long Long"
183+
"Long Subtitle with is_three_line = False",
184+
# is_three_line=True,
185+
leading=ft.Icon(ft.Icons.STAR),
186+
trailing=ft.Icon(ft.Icons.ARROW_FORWARD),
187+
bgcolor=ft.Colors.LIGHT_BLUE_ACCENT_100,
188+
),
189+
ft.ListTile(
190+
title="List Tile with three line",
191+
subtitle="Long Long Long Long Long Long Long Long Long Long Long "
192+
"Long Long Long Long Long Long Long Long Long Long Long"
193+
"Long Subtitle with is_three_line = True",
194+
is_three_line=True, # not sure if this behaviour is correct or not.
195+
# Tested it in flutter, it also shows more than 3 lines
196+
leading=ft.Icon(ft.Icons.STAR),
197+
trailing=ft.Icon(ft.Icons.ARROW_FORWARD),
198+
bgcolor=ft.Colors.LIGHT_BLUE_ACCENT_100,
199+
),
200+
ft.ListTile(
201+
title="List Tile with Compact visual density",
202+
subtitle="Long Long Long Long Long Long Long Long Long Long Long "
203+
"Long Long Long Long Long Long Long Long Long Long Long"
204+
"Long Subtitle with is_three_line = False",
205+
leading=ft.Icon(ft.Icons.STAR),
206+
trailing=ft.Icon(ft.Icons.ARROW_FORWARD),
207+
bgcolor=ft.Colors.LIGHT_BLUE_ACCENT_100,
208+
visual_density=ft.VisualDensity.COMPACT,
209+
),
210+
ft.ListTile(
211+
title="List Tile with Standard visual density",
212+
subtitle="Long Long Long Long Long Long Long Long Long Long Long "
213+
"Long Long Long Long Long Long Long Long Long Long Long"
214+
"Long Subtitle with is_three_line = False",
215+
leading=ft.Icon(ft.Icons.STAR),
216+
trailing=ft.Icon(ft.Icons.ARROW_FORWARD),
217+
bgcolor=ft.Colors.LIGHT_BLUE_ACCENT_100,
218+
visual_density=ft.VisualDensity.STANDARD,
219+
),
220+
]
239221
),
240222
)
241223

@@ -254,6 +236,7 @@ async def test_toggle_inputs(flet_app: ftt.FletTestApp, request):
254236
trailing=ft.Checkbox(),
255237
bgcolor=ft.Colors.LIGHT_BLUE_ACCENT_100,
256238
style=ft.ListTileStyle.LIST,
239+
hover_color=ft.Colors.YELLOW_200,
257240
toggle_inputs=True,
258241
)
259242

@@ -262,20 +245,30 @@ async def test_toggle_inputs(flet_app: ftt.FletTestApp, request):
262245
await flet_app.tester.pump_and_settle()
263246

264247
flet_app.assert_screenshot(
265-
"toggle_initial",
248+
"toggle_inputs_initial",
266249
await flet_app.page.take_screenshot(
267250
pixel_ratio=flet_app.screenshots_pixel_ratio
268251
),
269252
)
270253

271-
# test click1
254+
# test hover
272255
tile = await flet_app.tester.find_by_key("lt")
273256
assert tile.count == 1
257+
await flet_app.tester.mouse_hover(tile)
258+
await flet_app.tester.pump_and_settle()
259+
260+
flet_app.assert_screenshot(
261+
"toggle_inputs_hover",
262+
await flet_app.page.take_screenshot(
263+
pixel_ratio=flet_app.screenshots_pixel_ratio
264+
),
265+
)
266+
274267
await flet_app.tester.tap(tile)
275268
await flet_app.tester.pump_and_settle()
276269

277270
flet_app.assert_screenshot(
278-
"toggle_click1",
271+
"toggle_inputs_click1",
279272
await flet_app.page.take_screenshot(
280273
pixel_ratio=flet_app.screenshots_pixel_ratio
281274
),

0 commit comments

Comments
 (0)