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) text_box = UITextBox(html_text="some test text", relative_rect=pygame.Rect(100, 100, 400, 400), manager=manager, wrap_to_height=False, 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)
def test_hide_with_scrollbar(self, _init_pygame, default_ui_manager, _display_surface_return_none): x = 640 y = 360 width = 100 height = 32 text = "this is a test, this is a test, this is a test, this is a test, this is a test, this is a test" rect = pygame.Rect((x, y), (width, height)) text_box = UITextBox(html_text=text, relative_rect=rect, manager=default_ui_manager, wrap_to_height=False, layer_starting_height=100, object_id="screen_message") assert text_box.visible == 1 assert text_box.scroll_bar.visible == 1 assert text_box.scroll_bar.button_container.visible == 1 assert text_box.scroll_bar.sliding_button.visible == 1 assert text_box.scroll_bar.top_button.visible == 1 assert text_box.scroll_bar.bottom_button.visible == 1 text_box.hide() assert text_box.visible == 0 assert text_box.scroll_bar.visible == 0 assert text_box.scroll_bar.button_container.visible == 0 assert text_box.scroll_bar.sliding_button.visible == 0 assert text_box.scroll_bar.top_button.visible == 0 assert text_box.scroll_bar.bottom_button.visible == 0