mirror of
https://github.com/blender/blender
synced 2026-09-29 04:37:17 +03:00
Tests: UI: Add UI tests for fullscreen and stacked fullscreen handling
There are a lot of (fragile) cases we can cover with tests here, this is just a start. Pull Request: https://projects.blender.org/blender/blender/pulls/151722
This commit is contained in:
parent
32dc6f8d5f
commit
871fc1e4a1
2 changed files with 98 additions and 0 deletions
|
|
@ -1497,6 +1497,8 @@ if(WITH_UI_TESTS)
|
|||
test_workspace.sanity_check_storyboarding
|
||||
test_workspace.sanity_check_vfx
|
||||
test_workspace.sanity_check_video_editing
|
||||
test_fullscreen.wm_toggle_fullscreen
|
||||
test_fullscreen.wm_toggle_stacked_fullscreen_file_browser
|
||||
)
|
||||
foreach(ui_test ${_ui_tests})
|
||||
add_blender_test_ui(
|
||||
|
|
|
|||
96
tests/python/ui_simulate/test_fullscreen.py
Normal file
96
tests/python/ui_simulate/test_fullscreen.py
Normal file
|
|
@ -0,0 +1,96 @@
|
|||
# SPDX-FileCopyrightText: 2025 Blender Authors
|
||||
#
|
||||
# SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
"""
|
||||
This file does not run anything, its methods are accessed for tests by ``run_blender_setup.py``.
|
||||
"""
|
||||
|
||||
|
||||
def _test_window(windows_exclude=None):
|
||||
import bpy
|
||||
wm = bpy.data.window_managers[0]
|
||||
if windows_exclude is None:
|
||||
return wm.windows[0]
|
||||
for window in wm.windows:
|
||||
if window not in windows_exclude:
|
||||
return window
|
||||
return None
|
||||
|
||||
|
||||
def _test_vars(window):
|
||||
import unittest
|
||||
from modules.easy_keys import EventGenerate
|
||||
return (
|
||||
EventGenerate(window),
|
||||
unittest.TestCase(),
|
||||
)
|
||||
|
||||
|
||||
def _call_by_name(e, text: str):
|
||||
yield e.f3()
|
||||
yield e.text(text)
|
||||
yield e.ret()
|
||||
|
||||
|
||||
def wm_toggle_fullscreen():
|
||||
e, t = _test_vars(window := _test_window())
|
||||
|
||||
t.assertNotEqual(len(window.screen.areas), 1, "Expected a window with more than one area")
|
||||
|
||||
yield from _call_by_name(e, "Toggle Maximize Area")
|
||||
yield e.ret()
|
||||
t.assertEqual(len(window.screen.areas), 1)
|
||||
|
||||
yield from _call_by_name(e, "Toggle Maximize Area")
|
||||
yield e.ret()
|
||||
t.assertNotEqual(len(window.screen.areas), 1)
|
||||
|
||||
|
||||
def wm_toggle_stacked_fullscreen_file_browser():
|
||||
import bpy
|
||||
|
||||
e, t = _test_vars(window := _test_window())
|
||||
|
||||
t.assertNotEqual(len(window.screen.areas), 1, "Expected a window with more than one area")
|
||||
|
||||
# Ensure temporary file browsers will be opened in a maximized screen.
|
||||
bpy.context.preferences.view.filebrowser_display_type = 'SCREEN'
|
||||
|
||||
# Open temporary file browser.
|
||||
yield e.ctrl.o()
|
||||
t.assertEqual(len(window.screen.areas), 1)
|
||||
t.assertEqual(window.screen.areas[0].type, 'FILE_BROWSER')
|
||||
|
||||
# Escape should leave the temporary file browser maximized screen.
|
||||
yield e.esc()
|
||||
t.assertNotEqual(len(window.screen.areas), 1)
|
||||
t.assertNotEqual(window.screen.areas[0].type, 'FILE_BROWSER')
|
||||
|
||||
# Maximize a normal area.
|
||||
yield from _call_by_name(e, "Toggle Maximize Area")
|
||||
yield e.ret()
|
||||
t.assertEqual(len(window.screen.areas), 1)
|
||||
t.assertNotEqual(window.screen.areas[0].type, 'FILE_BROWSER')
|
||||
|
||||
# Open a file browser in a stacked fullscreen.
|
||||
yield e.ctrl.o()
|
||||
t.assertEqual(len(window.screen.areas), 1)
|
||||
t.assertEqual(window.screen.areas[0].type, 'FILE_BROWSER')
|
||||
|
||||
# Pressing 'Escape' should return to the previous full screen.
|
||||
yield e.esc()
|
||||
t.assertEqual(len(window.screen.areas), 1)
|
||||
t.assertNotEqual(window.screen.areas[0].type, 'FILE_BROWSER')
|
||||
restored_area = window.screen.areas[0]
|
||||
|
||||
# Pressing 'Escape' again shouldn't cause any change.
|
||||
yield e.esc()
|
||||
t.assertEqual(len(window.screen.areas), 1)
|
||||
t.assertNotEqual(window.screen.areas[0].type, 'FILE_BROWSER')
|
||||
t.assertEqual(restored_area, window.screen.areas[0])
|
||||
|
||||
# Restore to non-maximized area.
|
||||
yield from _call_by_name(e, "Toggle Maximize Area")
|
||||
yield e.ret()
|
||||
t.assertNotEqual(len(window.screen.areas), 1)
|
||||
Loading…
Add table
Add a link
Reference in a new issue