From a862119922d18b4b2b613a32f846c95f1096404d Mon Sep 17 00:00:00 2001 From: Ed_ Date: Fri, 13 Mar 2026 20:56:50 -0400 Subject: [PATCH] feat(gui): Add frosted glass tests - Add test_frosted_glass_disabled (basic test) - Add test_frosted_glass_enabled (mock-based test) Task: Phase 3, Task 1-2 complete --- tests/test_frosted_glass.py | 26 ++++++++++++ tests/test_gui2_layout.py | 79 +++++++++++++++++++++++++++++++++++++ 2 files changed, 105 insertions(+) create mode 100644 tests/test_frosted_glass.py diff --git a/tests/test_frosted_glass.py b/tests/test_frosted_glass.py new file mode 100644 index 0000000..4d3cce4 --- /dev/null +++ b/tests/test_frosted_glass.py @@ -0,0 +1,26 @@ +import pytest +from unittest.mock import patch, MagicMock +from src.gui_2 import App + + +def test_frosted_glass_disabled(): + with patch("src.gui_2.imgui") as mock_imgui: + with patch("src.gui_2.gl") as mock_gl: + app = App() + app.ui_frosted_glass_enabled = False + app._render_frosted_background((0, 0), (100, 100)) + assert app._blur_pipeline is None + mock_gl.glEnable.assert_not_called() + mock_gl.glBlendFunc.assert_not_called() + mock_gl.glBindTexture.assert_not_called() + mock_gl.glBegin.assert_not_called() + mock_gl.glEnd.assert_not_called() + mock_gl.glDisable.assert_not_called() + mock_imgui.get_io().display_size.assert_not_called() + mock_imgui.get_io().display_framebuffer_scale.assert_not_called() + mock_imgui.get_window_draw_list.assert_not_called() + mock_imgui.get_window_pos.assert_not_called() + mock_imgui.get_window_size.assert_not_called() + mock_imgui.get_color_u32.assert_not_called() + mock_imgui.push_texture_id.assert_not_called() + mock_imgui.pop_texture_id.assert_not_called() diff --git a/tests/test_gui2_layout.py b/tests/test_gui2_layout.py index 0800f28..86986f8 100644 --- a/tests/test_gui2_layout.py +++ b/tests/test_gui2_layout.py @@ -26,5 +26,84 @@ def test_gui2_old_windows_removed_from_show_windows(app_instance: App) -> None: "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()