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 = pygame_gui.UIManager(resolution) menu = UIDropDownMenu(options_list=['eggs', 'flour', 'sugar'], starting_option='eggs', 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)
def test_show_of_dropdown(self, _init_pygame, default_ui_manager): menu = UIDropDownMenu(options_list=['eggs', 'flour', 'sugar'], starting_option='eggs', relative_rect=pygame.Rect(10, 10, 200, 30), manager=default_ui_manager, visible=0) assert menu.visible == 0 assert menu.current_state == menu.menu_states['closed'] assert menu.menu_states["closed"].visible == 0 assert menu.menu_states["closed"].selected_option_button.visible == 0 assert menu.menu_states["closed"].open_button.visible == 0 menu.show() assert menu.visible == 1 assert menu.current_state == menu.menu_states['closed'] assert menu.menu_states["closed"].visible == 1 assert menu.menu_states["closed"].selected_option_button.visible == 1 assert menu.menu_states["closed"].open_button.visible == 1