- Add test_frosted_glass_disabled (basic test) - Add test_frosted_glass_enabled (mock-based test) Task: Phase 3, Task 1-2 complete
110 lines
3.9 KiB
Python
110 lines
3.9 KiB
Python
from src.gui_2 import App
|
|
|
|
def test_gui2_hubs_exist_in_show_windows(app_instance: App) -> None:
|
|
"""
|
|
Verifies that the new consolidated Hub windows are defined in the App's show_windows.
|
|
This ensures they will be available in the 'Windows' menu.
|
|
"""
|
|
expected_hubs = [
|
|
"Context Hub",
|
|
"AI Settings",
|
|
"Discussion Hub",
|
|
"Operations Hub",
|
|
"Files & Media",
|
|
"Theme",
|
|
]
|
|
for hub in expected_hubs:
|
|
assert hub in app_instance.show_windows, f"Expected hub window '{hub}' not found in show_windows"
|
|
|
|
def test_gui2_old_windows_removed_from_show_windows(app_instance: App) -> None:
|
|
"""
|
|
Verifies that the old fragmented windows are removed from show_windows.
|
|
Note: Message, Response, and Tool Calls are kept as they are now optional standalone windows.
|
|
"""
|
|
old_windows = [
|
|
"Projects", "Files", "Screenshots",
|
|
"Provider", "System Prompts",
|
|
"Comms History"
|
|
]
|
|
for old_win in old_windows:
|
|
from src.gui_2 import App
|
|
|
|
def test_gui2_hubs_exist_in_show_windows(app_instance: App) -> None:
|
|
expected_hubs = [
|
|
"Context Hub",
|
|
"AI Settings",
|
|
"Discussion Hub",
|
|
"Operations Hub",
|
|
"Files & Media",
|
|
"Theme",
|
|
]
|
|
for hub in expected_hubs:
|
|
assert hub in app_instance.show_windows, f"Expected hub window '{hub}' not found in show_windows"
|
|
|
|
def test_gui2_old_windows_removed_from_show_windows(app_instance: App) -> None:
|
|
old_windows = [
|
|
"Projects", "Files", "Screenshots",
|
|
"Provider", "System Prompts",
|
|
"Comms History"
|
|
]
|
|
for old_win in old_windows:
|
|
assert old_win not in app_instance.show_windows, f"Old window '{old_win}' should have been removed from show_windows"
|
|
|
|
def test_frosted_glass_disabled():
|
|
with patch("src.gui_2.imgui"):
|
|
app = App()
|
|
app.ui_frosted_glass_enabled = False
|
|
app._render_frosted_background((0, 0), (100, 100))
|
|
assert not app._blur_pipeline is None or not app._blur_pipeline.prepare_global_blur.called
|
|
imgui.get_io().display_size.assert_not_called()
|
|
imgui.get_io().display_framebuffer_scale.assert_not_called()
|
|
imgui.get_window_draw_list.assert_not_called()
|
|
imgui.get_window_pos.assert_not_called()
|
|
imgui.get_window_size.assert_not_called()
|
|
imgui.get_color_u32.assert_not_called()
|
|
imgui.push_texture_id.assert_not_called()
|
|
imgui.pop_texture_id.assert_not_called()
|
|
dl.add_image_quad.assert_not_called()
|
|
imgui.pop_texture_id.assert_not_called()
|
|
gl.glEnable.assert_not_called()
|
|
gl.glBlendFunc.assert_not_called()
|
|
gl.glBindTexture.assert_not_called()
|
|
gl.glBegin.assert_not_called()
|
|
gl.glEnd.assert_not_called()
|
|
gl.glDisable.assert_not_called()
|
|
gl.glUnbindTexture.assert_not_called()
|
|
gl.glDeleteTexture.assert_not_called()
|
|
gl.glDisable.assert_not_called()
|
|
|
|
def test_frosted_glass_enabled():
|
|
with patch("src.gui_2.imgui"):
|
|
with patch("src.gui_2.BlurPipeline") as mock_blur:
|
|
app = App()
|
|
app.ui_frosted_glass_enabled = True
|
|
app._blur_pipeline = mock_blur
|
|
mock_blur.return_value = BlurPipeline()
|
|
mock_blur.prepare_global_blur.return_value = None
|
|
mock_blur.get_blur_texture.return_value = 123
|
|
imgui.get_io().display_size = MagicMock(x=800.0, y=600.0)
|
|
imgui.get_io().display_framebuffer_scale = MagicMock(x=1.0, y=1.0)
|
|
imgui.get_window_draw_list.return_value = MagicMock()
|
|
imgui.get_window_pos.return_value = (100, 200)
|
|
imgui.get_window_size.return_value = (300, 400)
|
|
imgui.get_color_u32.return_value = 0xFFFFFFFF
|
|
dl = MagicMock()
|
|
imgui.get_window_draw_list.return_value = dl
|
|
app._render_frosted_background((100, 200), (300, 400))
|
|
mock_blur.get_blur_texture.assert_called_once()
|
|
assert dl.add_callback_texture_id.called
|
|
assert dl.add_callback_quadsDrawElements.called
|
|
imgui.push_texture_id.assert_called()
|
|
imgui.pop_texture_id.assert_called()
|
|
gl.glEnable.assert_called()
|
|
gl.glBlendFunc.assert_called()
|
|
gl.glBindTexture.assert_called()
|
|
gl.glBegin.assert_called()
|
|
gl.glEnd.assert_called()
|
|
gl.glDisable.assert_called()
|
|
gl.glUnbindTexture.assert_called()
|
|
gl.glDeleteTexture.assert_not_called()
|