def test_check_has_moved_recently(self, _init_pygame, default_ui_manager, _display_surface_return_none): scroll_bar = UIVerticalScrollBar(relative_rect=pygame.Rect(100, 100, 30, 150), visible_percentage=0.7, manager=default_ui_manager) # move the scroll bar a bit scroll_bar.bottom_button.held = True scroll_bar.update(0.2) assert scroll_bar.check_has_moved_recently() is True
def test_check_update_buttons(self, _init_pygame, default_ui_manager, _display_surface_return_none): scroll_bar = UIVerticalScrollBar(relative_rect=pygame.Rect(100, 100, 30, 150), visible_percentage=0.7, manager=default_ui_manager) # scroll down a bit then up again to exercise update scroll_bar.bottom_button.held = True scroll_bar.update(0.3) scroll_bar.bottom_button.held = False scroll_bar.top_button.held = True scroll_bar.update(0.3) assert scroll_bar.check_has_moved_recently() is True
def test_check_update_sliding_bar(self, _init_pygame, default_ui_manager, _display_surface_return_none): scroll_bar = UIVerticalScrollBar(relative_rect=pygame.Rect(0, 0, 30, 150), visible_percentage=0.7, manager=default_ui_manager) # scroll down a bit then up again to exercise update default_ui_manager.mouse_position = (15, 100) scroll_bar.sliding_button.held = True scroll_bar.update(0.3) assert scroll_bar.grabbed_slider is True scroll_bar.sliding_button.held = False scroll_bar.update(0.3) assert scroll_bar.grabbed_slider is False
def test_disable(self, _init_pygame: None, default_ui_manager: UIManager, _display_surface_return_none: None): scroll_bar = UIVerticalScrollBar(relative_rect=pygame.Rect(0, 100, 30, 200), visible_percentage=0.25, manager=default_ui_manager) scroll_bar.disable() # process a mouse button down event scroll_bar.bottom_button.process_event( pygame.event.Event(pygame.MOUSEBUTTONDOWN, {'button': 1, 'pos': scroll_bar.bottom_button.rect.center})) scroll_bar.update(0.1) # process a mouse button up event scroll_bar.bottom_button.process_event( pygame.event.Event(pygame.MOUSEBUTTONUP, {'button': 1, 'pos': scroll_bar.bottom_button.rect.center})) assert scroll_bar.scroll_position == 0.0 and scroll_bar.is_enabled is False