Exemplo n.º 1
0
 def setup_theme(self):
     self.theme = Theme()
     self.theme_2 = Theme()
     self.theme_3 = Theme()
     self.theme_4 = Theme()
     self.theme.set_font(24, arcade.color.BLACK)
     self.set_button_textures()
Exemplo n.º 2
0
 def setup_theme(self):
     self.theme = Theme()
     self.themeDisabled = Theme()
     self.theme.set_font(20, arcade.color.WHITE)
     self.themeDisabled.set_font(20, arcade.color.WHITE)
     self.set_button_textures()
     self.set_button_textures_disabled()
Exemplo n.º 3
0
def test_theme_dialogut_box_texture():
    theme = Theme()
    assert theme.dialogue_box_texture == ""

    theme.add_dialogue_box_texture(
        ":resources:gui_themes/Fantasy/DialogueBox/DialogueBox.png")
    assert isinstance(theme.dialogue_box_texture, arcade.Texture)
Exemplo n.º 4
0
def test_theme_box_texture():
    theme = Theme()
    assert theme.text_box_texture == ""

    theme.add_text_box_texture(
        ":resources:gui_themes/Fantasy/TextBox/Brown.png")
    assert isinstance(theme.text_box_texture, arcade.Texture)
Exemplo n.º 5
0
def test_theme_delete_font_ban():
    theme = Theme()
    theme_font = theme.font

    with pytest.raises(Exception):
        del theme.font

    assert theme.font is theme_font
Exemplo n.º 6
0
def test_setup_button_font_with_theme():
    theme = Theme()
    button = TextButton(center_x=50,
                        center_y=20,
                        width=30,
                        height=10,
                        text='Click me',
                        theme=theme)
    assert button.font is theme.font
Exemplo n.º 7
0
def test_theme_set_new_font_ban():
    theme = Theme()
    theme_font = theme.font
    new_font = Font()

    with pytest.raises(Exception):
        theme.font = new_font

    assert theme.font is theme_font
Exemplo n.º 8
0
def test_theme_font():
    theme = Theme()
    assert theme.font_color == Theme.DEFAULT_FONT_COLOR
    assert theme.font_size == Theme.DEFAULT_FONT_SIZE
    assert theme.font_name == Theme.DEFAULT_FONT_NAME

    theme.set_font(10, arcade.color.WHITE, "verdana")
    assert theme.font_color == arcade.color.WHITE
    assert theme.font_size == 10
    assert theme.font_name == "verdana"

    theme.set_font(12, arcade.color.WENGE)
    assert theme.font_name == Theme.DEFAULT_FONT_NAME
Exemplo n.º 9
0
def test_draw_when_theme_set_and_text_is_empty(mocker):
    mocker.patch.object(TextButton, 'draw_texture_theme')
    mocker.patch.object(TextButton, 'draw_color_theme')
    mocker.patch('arcade.draw_text')

    button = TextButton(center_x=50,
                        center_y=20,
                        width=30,
                        height=10,
                        text='',
                        theme=Theme())
    button.draw()
    button.draw_color_theme.assert_not_called()
    button.draw_texture_theme.assert_called_once()
    arcade.draw_text.assert_not_called()
Exemplo n.º 10
0
def test_theme_font():
    theme = Theme()
    assert isinstance(theme.font, Font)

    assert theme.font.color == Font.DEFAULT_COLOR
    assert theme.font.size == Font.DEFAULT_SIZE
    assert theme.font.name == Font.DEFAULT_NAME

    theme.font.size = 10
    theme.font.color = arcade.color.WHITE
    theme.font.name = "verdana"
    assert theme.font.color == arcade.color.WHITE
    assert theme.font.size == 10
    assert theme.font.name == "verdana"

    theme.font.size = 12
    theme.font.name = Font.DEFAULT_NAME
    assert theme.font.name == Font.DEFAULT_NAME
Exemplo n.º 11
0
def test_theme_button_texture():
    theme = Theme()
    assert theme.button_textures == {
        "normal": "",
        "hover": "",
        "clicked": "",
        "locked": ""
    }

    theme.add_button_textures(
        ":resources:gui_themes/Fantasy/Buttons/Normal.png",
        ":resources:gui_themes/Fantasy/Buttons/Hover.png",
        ":resources:gui_themes/Fantasy/Buttons/Clicked.png",
        ":resources:gui_themes/Fantasy/Buttons/Locked.png")

    for button_texture in theme.button_textures.values():
        assert isinstance(button_texture, arcade.Texture)

    theme.add_button_textures(
        ":resources:gui_themes/Fantasy/Buttons/Normal.png")
    assert isinstance(theme.button_textures["normal"], arcade.Texture)
    assert theme.button_textures["normal"] is theme.button_textures["hover"]
    assert theme.button_textures["normal"] is theme.button_textures["clicked"]
    assert theme.button_textures["normal"] is theme.button_textures["locked"]
Exemplo n.º 12
0
def test_draw_when_theme_set(mocker):
    mocker.patch.object(TextButton, 'draw_texture_theme')
    mocker.patch.object(TextButton, 'draw_color_theme')
    mocker.patch('arcade.draw_text')

    button = TextButton(center_x=50,
                        center_y=20,
                        width=30,
                        height=10,
                        text='Click me',
                        theme=Theme())
    button.draw()
    button.draw_color_theme.assert_not_called()
    button.draw_texture_theme.assert_called_once()
    arcade.draw_text.assert_called_once_with('Click me',
                                             50,
                                             20,
                                             button.font.color,
                                             font_size=button.font.size,
                                             font_name=button.font.name,
                                             width=button.width,
                                             align="center",
                                             anchor_x="center",
                                             anchor_y="center")
Exemplo n.º 13
0
def test_theme_window_texture():
    theme = Theme()
    assert theme.window_texture == ""

    theme.add_window_texture(":resources:gui_themes/Fantasy/Window/Window.png")
    assert isinstance(theme.window_texture, arcade.Texture)
Exemplo n.º 14
0
def test_theme_menu_texture():
    theme = Theme()
    assert theme.menu_texture == ""

    theme.add_menu_texture(":resources:gui_themes/Fantasy/Menu/Menu.png")
    assert isinstance(theme.menu_texture, arcade.Texture)
Exemplo n.º 15
0
 def setup_theme(self):
     self.theme = Theme()
     self.theme.set_font(24, arcade.color.WHITE)
     self.set_button_textures()