From 56032456280559027107e1127d15b9c8d721ad8c Mon Sep 17 00:00:00 2001 From: MyreMylar Date: Wed, 24 Jun 2020 18:15:44 +0100 Subject: [PATCH] fix tests --- tests/test_elements/test_ui_button.py | 3 +++ tests/test_elements/test_ui_drop_down_menu.py | 3 +++ tests/test_elements/test_ui_horizontal_scroll_bar.py | 4 +++- tests/test_elements/test_ui_horizontal_slider.py | 4 +++- tests/test_elements/test_ui_image.py | 4 +++- tests/test_elements/test_ui_label.py | 3 +++ tests/test_elements/test_ui_panel.py | 4 +++- tests/test_elements/test_ui_screen_space_health_bar.py | 4 +++- tests/test_elements/test_ui_scrolling_container.py | 4 +++- tests/test_elements/test_ui_selection_list.py | 4 +++- tests/test_elements/test_ui_text_box.py | 4 +++- tests/test_elements/test_ui_text_entry_line.py | 4 +++- tests/test_elements/test_ui_vertical_scroll_bar.py | 4 +++- tests/test_elements/test_ui_window.py | 4 +++- tests/test_elements/test_ui_world_space_health_bar.py | 4 +++- tests/test_ui_manager.py | 2 +- tests/test_windows/test_ui_colour_picker_dialog.py | 7 ++++++- tests/test_windows/test_ui_confirmation_dialog.py | 3 +++ tests/test_windows/test_ui_file_dialog.py | 4 +++- tests/test_windows/test_ui_message_window.py | 4 +++- 20 files changed, 61 insertions(+), 16 deletions(-) diff --git a/tests/test_elements/test_ui_button.py b/tests/test_elements/test_ui_button.py index b243d671..071434c8 100644 --- a/tests/test_elements/test_ui_button.py +++ b/tests/test_elements/test_ui_button.py @@ -678,16 +678,19 @@ def test_show_hide_rendering(self, _init_pygame, default_ui_manager, _display_su button = UIButton(relative_rect=pygame.Rect(25, 25, 375, 150), text="Test Button", manager=manager, visible=0) + manager.update(0.01) manager.draw_ui(surface) assert compare_surfaces(empty_surface, surface) surface.fill(pygame.Color(0, 0, 0)) button.show() + manager.update(0.01) manager.draw_ui(surface) assert not compare_surfaces(empty_surface, surface) surface.fill(pygame.Color(0, 0, 0)) button.hide() + manager.update(0.01) manager.draw_ui(surface) assert compare_surfaces(empty_surface, surface) diff --git a/tests/test_elements/test_ui_drop_down_menu.py b/tests/test_elements/test_ui_drop_down_menu.py index bebc1fe3..5c1a553e 100644 --- a/tests/test_elements/test_ui_drop_down_menu.py +++ b/tests/test_elements/test_ui_drop_down_menu.py @@ -534,16 +534,19 @@ def test_show_hide_rendering(self, _init_pygame, default_ui_manager, _display_su relative_rect=pygame.Rect(25, 25, 375, 150), manager=manager, visible=0) + manager.update(0.01) manager.draw_ui(surface) assert compare_surfaces(empty_surface, surface) surface.fill(pygame.Color(0, 0, 0)) menu.show() + manager.update(0.01) manager.draw_ui(surface) assert not compare_surfaces(empty_surface, surface) surface.fill(pygame.Color(0, 0, 0)) menu.hide() + manager.update(0.01) manager.draw_ui(surface) assert compare_surfaces(empty_surface, surface) diff --git a/tests/test_elements/test_ui_horizontal_scroll_bar.py b/tests/test_elements/test_ui_horizontal_scroll_bar.py index 1d92af28..18ccabdd 100644 --- a/tests/test_elements/test_ui_horizontal_scroll_bar.py +++ b/tests/test_elements/test_ui_horizontal_scroll_bar.py @@ -334,16 +334,18 @@ def test_show_hide_rendering(self, _init_pygame, default_ui_manager, _display_su visible_percentage=0.25, manager=manager, visible=0) - + manager.update(0.01) manager.draw_ui(surface) assert compare_surfaces(empty_surface, surface) surface.fill(pygame.Color(0, 0, 0)) scroll_bar.show() + manager.update(0.01) manager.draw_ui(surface) assert not compare_surfaces(empty_surface, surface) surface.fill(pygame.Color(0, 0, 0)) scroll_bar.hide() + manager.update(0.01) manager.draw_ui(surface) assert compare_surfaces(empty_surface, surface) diff --git a/tests/test_elements/test_ui_horizontal_slider.py b/tests/test_elements/test_ui_horizontal_slider.py index 51803fe3..647b5779 100644 --- a/tests/test_elements/test_ui_horizontal_slider.py +++ b/tests/test_elements/test_ui_horizontal_slider.py @@ -375,16 +375,18 @@ def test_show_hide_rendering(self, _init_pygame, default_ui_manager, _display_su manager = UIManager(resolution) slider = UIHorizontalSlider(relative_rect=pygame.Rect(25, 25, 375, 150), start_value=50, value_range=(0, 200), manager=manager, visible=0) - + manager.update(0.01) manager.draw_ui(surface) assert compare_surfaces(empty_surface, surface) surface.fill(pygame.Color(0, 0, 0)) slider.show() + manager.update(0.01) manager.draw_ui(surface) assert not compare_surfaces(empty_surface, surface) surface.fill(pygame.Color(0, 0, 0)) slider.hide() + manager.update(0.01) manager.draw_ui(surface) assert compare_surfaces(empty_surface, surface) diff --git a/tests/test_elements/test_ui_image.py b/tests/test_elements/test_ui_image.py index 5b5682b6..12e30df7 100644 --- a/tests/test_elements/test_ui_image.py +++ b/tests/test_elements/test_ui_image.py @@ -84,16 +84,18 @@ def test_show_hide_rendering(self, _init_pygame, default_ui_manager, _display_su image_surface=loaded_image, manager=manager, visible=0) - + manager.update(0.01) manager.draw_ui(surface) assert compare_surfaces(empty_surface, surface) surface.fill(pygame.Color(0, 0, 0)) ui_image.show() + manager.update(0.01) manager.draw_ui(surface) assert not compare_surfaces(empty_surface, surface) surface.fill(pygame.Color(0, 0, 0)) ui_image.hide() + manager.update(0.01) manager.draw_ui(surface) assert compare_surfaces(empty_surface, surface) diff --git a/tests/test_elements/test_ui_label.py b/tests/test_elements/test_ui_label.py index 52ac00a9..b7fccab2 100644 --- a/tests/test_elements/test_ui_label.py +++ b/tests/test_elements/test_ui_label.py @@ -159,15 +159,18 @@ def test_show_hide_rendering(self, _init_pygame, default_ui_manager, _display_su label = UILabel(relative_rect=pygame.Rect(25, 25, 375, 150), text="Test Button", manager=manager, visible=0) + manager.update(0.01) manager.draw_ui(surface) assert compare_surfaces(empty_surface, surface) surface.fill(pygame.Color(0, 0, 0)) label.show() + manager.update(0.01) manager.draw_ui(surface) assert not compare_surfaces(empty_surface, surface) surface.fill(pygame.Color(0, 0, 0)) label.hide() + manager.update(0.01) manager.draw_ui(surface) assert compare_surfaces(empty_surface, surface) diff --git a/tests/test_elements/test_ui_panel.py b/tests/test_elements/test_ui_panel.py index 40029a74..1f3bcb9e 100644 --- a/tests/test_elements/test_ui_panel.py +++ b/tests/test_elements/test_ui_panel.py @@ -577,16 +577,18 @@ def test_show_hide_rendering(self, _init_pygame, default_ui_manager, _display_su button = UIButton(relative_rect=pygame.Rect(0, 0, 50, 50), text="", manager=manager, container=panel) - + manager.update(0.01) manager.draw_ui(surface) assert compare_surfaces(empty_surface, surface) surface.fill(pygame.Color(0, 0, 0)) panel.show() + manager.update(0.01) manager.draw_ui(surface) assert not compare_surfaces(empty_surface, surface) surface.fill(pygame.Color(0, 0, 0)) panel.hide() + manager.update(0.01) manager.draw_ui(surface) assert compare_surfaces(empty_surface, surface) diff --git a/tests/test_elements/test_ui_screen_space_health_bar.py b/tests/test_elements/test_ui_screen_space_health_bar.py index 983c2c94..8369c876 100644 --- a/tests/test_elements/test_ui_screen_space_health_bar.py +++ b/tests/test_elements/test_ui_screen_space_health_bar.py @@ -184,16 +184,18 @@ def test_show_hide_rendering(self, _init_pygame, default_ui_manager, _display_su sprite_to_monitor=healthy_sprite, manager=manager, visible=0) - + manager.update(0.01) manager.draw_ui(surface) assert compare_surfaces(empty_surface, surface) surface.fill(pygame.Color(0, 0, 0)) health_bar.show() + manager.update(0.01) manager.draw_ui(surface) assert not compare_surfaces(empty_surface, surface) surface.fill(pygame.Color(0, 0, 0)) health_bar.hide() + manager.update(0.01) manager.draw_ui(surface) assert compare_surfaces(empty_surface, surface) diff --git a/tests/test_elements/test_ui_scrolling_container.py b/tests/test_elements/test_ui_scrolling_container.py index 51942e50..e47421ea 100644 --- a/tests/test_elements/test_ui_scrolling_container.py +++ b/tests/test_elements/test_ui_scrolling_container.py @@ -250,16 +250,18 @@ def test_show_hide_rendering(self, _init_pygame, default_ui_manager, _display_su manager=manager, visible=0) container.set_scrollable_area_dimensions((600, 600)) - + manager.update(0.01) manager.draw_ui(surface) assert compare_surfaces(empty_surface, surface) surface.fill(pygame.Color(0, 0, 0)) container.show() + manager.update(0.01) manager.draw_ui(surface) assert not compare_surfaces(empty_surface, surface) surface.fill(pygame.Color(0, 0, 0)) container.hide() + manager.update(0.01) manager.draw_ui(surface) assert compare_surfaces(empty_surface, surface) diff --git a/tests/test_elements/test_ui_selection_list.py b/tests/test_elements/test_ui_selection_list.py index 2f8f03aa..6d85ec79 100644 --- a/tests/test_elements/test_ui_selection_list.py +++ b/tests/test_elements/test_ui_selection_list.py @@ -768,16 +768,18 @@ def test_show_hide_rendering(self, _init_pygame, default_ui_manager, _display_su manager=manager, allow_multi_select=True, visible=0) - + manager.update(0.01) manager.draw_ui(surface) assert compare_surfaces(empty_surface, surface) surface.fill(pygame.Color(0, 0, 0)) selection_list.show() + manager.update(0.01) manager.draw_ui(surface) assert not compare_surfaces(empty_surface, surface) surface.fill(pygame.Color(0, 0, 0)) selection_list.hide() + manager.update(0.01) manager.draw_ui(surface) assert compare_surfaces(empty_surface, surface) diff --git a/tests/test_elements/test_ui_text_box.py b/tests/test_elements/test_ui_text_box.py index c2c1059b..a4e797f8 100644 --- a/tests/test_elements/test_ui_text_box.py +++ b/tests/test_elements/test_ui_text_box.py @@ -771,16 +771,18 @@ def test_show_hide_rendering(self, _init_pygame, default_ui_manager, _display_su layer_starting_height=100, object_id="screen_message", visible=0) - + manager.update(0.01) manager.draw_ui(surface) assert compare_surfaces(empty_surface, surface) surface.fill(pygame.Color(0, 0, 0)) text_box.show() + manager.update(0.01) manager.draw_ui(surface) assert not compare_surfaces(empty_surface, surface) surface.fill(pygame.Color(0, 0, 0)) text_box.hide() + manager.update(0.01) manager.draw_ui(surface) assert compare_surfaces(empty_surface, surface) diff --git a/tests/test_elements/test_ui_text_entry_line.py b/tests/test_elements/test_ui_text_entry_line.py index 4e9963fd..dd583461 100644 --- a/tests/test_elements/test_ui_text_entry_line.py +++ b/tests/test_elements/test_ui_text_entry_line.py @@ -920,16 +920,18 @@ def test_show_hide_rendering(self, _init_pygame, default_ui_manager, _display_su text_entry = UITextEntryLine(relative_rect=pygame.Rect(100, 100, 400, 400), manager=manager, visible=0) - + manager.update(0.01) manager.draw_ui(surface) assert compare_surfaces(empty_surface, surface) surface.fill(pygame.Color(0, 0, 0)) text_entry.show() + manager.update(0.01) manager.draw_ui(surface) assert not compare_surfaces(empty_surface, surface) surface.fill(pygame.Color(0, 0, 0)) text_entry.hide() + manager.update(0.01) manager.draw_ui(surface) assert compare_surfaces(empty_surface, surface) diff --git a/tests/test_elements/test_ui_vertical_scroll_bar.py b/tests/test_elements/test_ui_vertical_scroll_bar.py index fbda0360..dc90fde1 100644 --- a/tests/test_elements/test_ui_vertical_scroll_bar.py +++ b/tests/test_elements/test_ui_vertical_scroll_bar.py @@ -335,16 +335,18 @@ def test_show_hide_rendering(self, _init_pygame, default_ui_manager, _display_su visible_percentage=0.25, manager=manager, visible=0) - + manager.update(0.01) manager.draw_ui(surface) assert compare_surfaces(empty_surface, surface) surface.fill(pygame.Color(0, 0, 0)) scroll_bar.show() + manager.update(0.01) manager.draw_ui(surface) assert not compare_surfaces(empty_surface, surface) surface.fill(pygame.Color(0, 0, 0)) scroll_bar.hide() + manager.update(0.01) manager.draw_ui(surface) assert compare_surfaces(empty_surface, surface) diff --git a/tests/test_elements/test_ui_window.py b/tests/test_elements/test_ui_window.py index 5093c96b..da4745e0 100644 --- a/tests/test_elements/test_ui_window.py +++ b/tests/test_elements/test_ui_window.py @@ -554,16 +554,18 @@ def test_show_hide_rendering(self, _init_pygame, default_ui_manager, _display_su window_display_title="Test Window", manager=manager, visible=0) - + manager.update(0.01) manager.draw_ui(surface) assert compare_surfaces(empty_surface, surface) surface.fill(pygame.Color(0, 0, 0)) window.show() + manager.update(0.01) manager.draw_ui(surface) assert not compare_surfaces(empty_surface, surface) surface.fill(pygame.Color(0, 0, 0)) window.hide() + manager.update(0.01) manager.draw_ui(surface) assert compare_surfaces(empty_surface, surface) diff --git a/tests/test_elements/test_ui_world_space_health_bar.py b/tests/test_elements/test_ui_world_space_health_bar.py index bce20916..b8642e71 100644 --- a/tests/test_elements/test_ui_world_space_health_bar.py +++ b/tests/test_elements/test_ui_world_space_health_bar.py @@ -146,16 +146,18 @@ def test_show_hide_rendering(self, _init_pygame, default_ui_manager, _display_su sprite_to_monitor=healthy_sprite, manager=manager, visible=0) - + manager.update(0.01) manager.draw_ui(surface) assert compare_surfaces(empty_surface, surface) surface.fill(pygame.Color(0, 0, 0)) health_bar.show() + manager.update(0.01) manager.draw_ui(surface) assert not compare_surfaces(empty_surface, surface) surface.fill(pygame.Color(0, 0, 0)) health_bar.hide() + manager.update(0.01) manager.draw_ui(surface) assert compare_surfaces(empty_surface, surface) diff --git a/tests/test_ui_manager.py b/tests/test_ui_manager.py index ae66ebfa..9e7526f8 100644 --- a/tests/test_ui_manager.py +++ b/tests/test_ui_manager.py @@ -205,7 +205,7 @@ def test_draw_ui(self, _init_pygame, _display_surface_return_none): test_surface = pygame.display.set_mode((150, 30), 0, 32) manager = UIManager((150, 30)) UIButton(relative_rect=pygame.Rect(0, 0, 150, 30), text="Test", manager=manager) - # manager.update(0.01) + manager.update(0.01) manager.draw_ui(test_surface) plat = platform.system().upper() if plat == 'WINDOWS': diff --git a/tests/test_windows/test_ui_colour_picker_dialog.py b/tests/test_windows/test_ui_colour_picker_dialog.py index 3ffc01d0..1d4cc510 100644 --- a/tests/test_windows/test_ui_colour_picker_dialog.py +++ b/tests/test_windows/test_ui_colour_picker_dialog.py @@ -225,16 +225,19 @@ def test_show_hide_rendering(self, _init_pygame, default_ui_manager, _display_su channel_editor.set_dimensions((200, 29)) + manager.update(0.01) manager.draw_ui(surface) assert compare_surfaces(empty_surface, surface) surface.fill(pygame.Color(0, 0, 0)) channel_editor.show() + manager.update(0.01) manager.draw_ui(surface) assert not compare_surfaces(empty_surface, surface) surface.fill(pygame.Color(0, 0, 0)) channel_editor.hide() + manager.update(0.01) manager.draw_ui(surface) assert compare_surfaces(empty_surface, surface) @@ -537,16 +540,18 @@ def test_show_hide_rendering(self, _init_pygame, default_ui_manager, _display_su manager=manager, initial_colour=pygame.Color(200, 220, 50, 255), visible=0) - + manager.update(0.01) manager.draw_ui(surface) assert compare_surfaces(empty_surface, surface) surface.fill(pygame.Color(0, 0, 0)) colour_picker.show() + manager.update(0.01) manager.draw_ui(surface) assert not compare_surfaces(empty_surface, surface) surface.fill(pygame.Color(0, 0, 0)) colour_picker.hide() + manager.update(0.01) manager.draw_ui(surface) assert compare_surfaces(empty_surface, surface) diff --git a/tests/test_windows/test_ui_confirmation_dialog.py b/tests/test_windows/test_ui_confirmation_dialog.py index 83068c0f..8fa42dfe 100644 --- a/tests/test_windows/test_ui_confirmation_dialog.py +++ b/tests/test_windows/test_ui_confirmation_dialog.py @@ -258,15 +258,18 @@ def test_show_hide_rendering(self, _init_pygame, _display_surface_return_none): window_title="Confirm", action_short_name="Confirm", visible=0) + manager.update(0.01) manager.draw_ui(surface) assert compare_surfaces(empty_surface, surface) surface.fill(pygame.Color(0, 0, 0)) confirm_dialog.show() + manager.update(0.01) manager.draw_ui(surface) assert not compare_surfaces(empty_surface, surface) surface.fill(pygame.Color(0, 0, 0)) confirm_dialog.hide() + manager.update(0.01) manager.draw_ui(surface) assert compare_surfaces(empty_surface, surface) diff --git a/tests/test_windows/test_ui_file_dialog.py b/tests/test_windows/test_ui_file_dialog.py index 430d4942..4ae6f442 100644 --- a/tests/test_windows/test_ui_file_dialog.py +++ b/tests/test_windows/test_ui_file_dialog.py @@ -343,16 +343,18 @@ def test_show_hide_rendering(self, _init_pygame, default_ui_manager, _display_su manager=manager, visible=0) file_dialog.file_path_text_line.set_text('tests/data/images') - + manager.update(0.01) manager.draw_ui(surface) assert compare_surfaces(empty_surface, surface) surface.fill(pygame.Color(0, 0, 0)) file_dialog.show() + manager.update(0.01) manager.draw_ui(surface) assert not compare_surfaces(empty_surface, surface) surface.fill(pygame.Color(0, 0, 0)) file_dialog.hide() + manager.update(0.01) manager.draw_ui(surface) assert compare_surfaces(empty_surface, surface) diff --git a/tests/test_windows/test_ui_message_window.py b/tests/test_windows/test_ui_message_window.py index 4b01ba76..f0051c32 100644 --- a/tests/test_windows/test_ui_message_window.py +++ b/tests/test_windows/test_ui_message_window.py @@ -221,17 +221,19 @@ def test_show_hide_rendering(self, _init_pygame, default_ui_manager, _display_su "message box functionality.", manager=manager, visible=0) - + manager.update(0.01) manager.draw_ui(surface) assert compare_surfaces(empty_surface, surface) surface.fill(pygame.Color(0, 0, 0)) message_window.show() + manager.update(0.01) manager.draw_ui(surface) assert not compare_surfaces(empty_surface, surface) surface.fill(pygame.Color(0, 0, 0)) message_window.hide() + manager.update(0.01) manager.draw_ui(surface) assert compare_surfaces(empty_surface, surface)