def test_show_hide_rendering(self, _init_pygame, default_ui_manager, _display_surface_return_none): resolution = (400, 400) empty_surface = pygame.Surface(resolution) empty_surface.fill(pygame.Color(0, 0, 0)) surface = empty_surface.copy() manager = UIManager(resolution) panel = UIPanel(pygame.Rect(25, 25, 375, 150), manager=manager, visible=0, starting_layer_height=1) 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)
def test_visible_panel_children_behaviour_on_hide( self, _init_pygame, default_ui_manager: IUIManagerInterface, _display_surface_return_none): panel = UIPanel(pygame.Rect(100, 100, 200, 200), manager=default_ui_manager, visible=1, starting_layer_height=5) button = UIButton(relative_rect=pygame.Rect(0, 0, 50, 50), text="", manager=default_ui_manager, container=panel) assert panel.visible == 1 assert button.visible == 1 panel.hide() assert panel.visible == 0 assert button.visible == 0