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) scroll_bar = UIHorizontalScrollBar(relative_rect=pygame.Rect( 25, 25, 375, 150), 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)
def test_hide(self, _init_pygame, default_ui_manager, _display_surface_return_none): scroll_bar = UIHorizontalScrollBar(relative_rect=pygame.Rect( 100, 0, 200, 30), visible_percentage=0.25, manager=default_ui_manager) assert scroll_bar.visible == 1 assert scroll_bar.button_container.visible == 1 assert scroll_bar.sliding_button.visible == 1 assert scroll_bar.left_button.visible == 1 assert scroll_bar.right_button.visible == 1 scroll_bar.hide() assert scroll_bar.visible == 0 assert scroll_bar.button_container.visible == 0 assert scroll_bar.sliding_button.visible == 0 assert scroll_bar.left_button.visible == 0 assert scroll_bar.right_button.visible == 0