Exemplo n.º 1
0
    def test_show_hide_rendering(self, _init_pygame, default_ui_manager,
                                 _display_surface_return_none):
        resolution = (600, 600)
        empty_surface = pygame.Surface(resolution)
        empty_surface.fill(pygame.Color(0, 0, 0))

        surface = empty_surface.copy()
        manager = UIManager(resolution)

        message_window = UIMessageWindow(
            rect=pygame.Rect(100, 100, 250, 300),
            window_title="Test Message",
            html_message="This is a bold test of the "
            "message box functionality.",
            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))
        message_window.show()
        manager.update(0.01)
        manager.draw_ui(surface)
        assert not compare_surfaces(empty_surface, surface)

        surface.fill(pygame.Color(0, 0, 0))
        message_window.hide()
        manager.update(0.01)
        manager.draw_ui(surface)
        assert compare_surfaces(empty_surface, surface)
Exemplo n.º 2
0
    def test_hide(self, _init_pygame, default_ui_manager,
                  _display_surface_return_none):
        message_window = UIMessageWindow(
            rect=pygame.Rect(100, 100, 250, 300),
            window_title="Test Message",
            html_message="This is a bold test of the "
            "message box functionality.",
            manager=default_ui_manager)

        assert message_window.visible == 1

        assert message_window.close_window_button.visible == 1
        assert message_window.dismiss_button.visible == 1
        assert message_window.text_block.visible == 1

        message_window.hide()

        assert message_window.visible == 0

        assert message_window.close_window_button.visible == 0
        assert message_window.dismiss_button.visible == 0
        assert message_window.text_block.visible == 0