MCPcopy
hub / github.com/beeware/toga / test_position_cascade

Function test_position_cascade

core/tests/window/test_window.py:240–279  ·  view source on GitHub ↗

The initial position of windows will cascade.

(app)

Source from the content-addressed store, hash-verified

238
239
240def test_position_cascade(app):
241 """The initial position of windows will cascade."""
242 windows = [app.main_window]
243
244 for i in range(14):
245 win = toga.Window(title=f"Window {i}")
246 # The for the first 14 new windows (the app creates the first window)
247 # the x and y coordinates must be the same
248 assert win.position[0] == win.position[1]
249 # The position of the window should cascade down
250 assert win.position[0] > windows[-1].position[0]
251 assert win.position[1] > windows[-1].position[1]
252
253 windows.append(win)
254
255 # The 15th window will come back to the y origin, but shift along the x axis.
256 win = toga.Window(title=f"Window {i}")
257 assert win.position[0] > windows[0].position[0]
258 assert win.position[1] == windows[0].position[1]
259
260 windows.append(win)
261
262 # Cascade another 15 windows
263 for i in range(16, 30):
264 win = toga.Window(title=f"Window {i}")
265 # The position of the window should cascade down
266 assert win.position[0] > windows[-1].position[0]
267 assert win.position[1] > windows[-1].position[1]
268
269 # The y coordinate of these windows should be the same
270 # as 15 windows ago; the x coordinate is shifted right
271 assert win.position[0] > windows[i - 15].position[0]
272 assert win.position[1] == windows[i - 15].position[1]
273
274 windows.append(win)
275
276 # The 30 window will come back to the y origin, but shift along the x axis.
277 win = toga.Window(title=f"Window {i}")
278 assert win.position[0] > windows[15].position[0]
279 assert win.position[1] == windows[15].position[1]
280
281
282def test_set_size(window):

Callers

nothing calls this directly

Calls 1

appendMethod · 0.45

Tested by

no test coverage detected