Esempio n. 1
0
    def test_get_surface(self, _init_pygame, default_ui_manager: UIManager,
                         _display_surface_return_none):
        normal_state = DrawableShapeState('normal')
        selected_state = DrawableShapeState('selected')
        states = {'normal': normal_state, 'selected': selected_state}
        assert isinstance(normal_state.get_surface(), pygame.Surface)

        normal_state.transition = DrawableStateTransition(
            states=states,
            start_state_id='normal',
            target_state_id='selected',
            duration=0.8)

        assert isinstance(normal_state.get_surface(), pygame.Surface)
Esempio n. 2
0
    def test_update(self, _init_pygame, default_ui_manager: UIManager):
        normal_state = DrawableShapeState('normal')
        selected_state = DrawableShapeState('selected')
        states = {'normal': normal_state, 'selected': selected_state}

        normal_state.transition = DrawableStateTransition(
            states=states,
            start_state_id='normal',
            target_state_id='selected',
            duration=0.8)
        normal_state.update(0.1)

        assert normal_state.has_fresh_surface

        normal_state.update(0.9)

        assert normal_state.transition is None