示例#1
0
 def test_creation(self, _init_pygame, _display_surface_return_none):
     dictionary = UIFontDictionary(BlockingThreadedResourceLoader())
     style = CharStyle()
     StyledChunk(font_size=14, font_name='fira_code',
                 chunk='text', style=style, colour=pygame.Color('#FFFF00'),
                 bg_colour=pygame.Color('#000000'),
                 is_link=False, link_href='test', link_style=CharStyle(),
                 position=(0, 0), font_dictionary=dictionary)
示例#2
0
 def test_redraw_bg_and_fg_gradient(self, _init_pygame):
     dictionary = UIFontDictionary(BlockingThreadedResourceLoader())
     style = CharStyle()
     gradient = ColourGradient(0, pygame.Color('#FFFF00'), pygame.Color('#FF0000'))
     chunk = StyledChunk(font_size=14, font_name='fira_code',
                         chunk='text', style=style, colour=gradient,
                         bg_colour=gradient,
                         is_link=False, link_href='test', link_style=CharStyle(),
                         position=(0, 0), font_dictionary=dictionary)
     chunk.redraw()
示例#3
0
    def test_comparison_not_equal(self, _init_pygame):
        text_line_1 = TextLineContext(font_size=14, font_name='fira_code', style=CharStyle(),
                                      color=pygame.Color('#FFFFFF'), bg_color=pygame.Color('#000000'),
                                      is_link=True, link_href='None')

        text_line_2 = TextLineContext(font_size=14, font_name='fira_code', style=CharStyle(),
                                      color=pygame.Color('#FF0000'), bg_color=pygame.Color('#000000'),
                                      is_link=False, link_href='gui')

        assert text_line_1 != text_line_2
示例#4
0
    def test_creation_scale_vert_to_text(self, _init_pygame):
        dictionary = UIFontDictionary()
        style = CharStyle()
        styled_chunk = StyledChunk(font_size=14, font_name='fira_code',
                                   chunk='text', style=style, colour=pygame.Color('#FFFF00'),
                                   bg_colour=pygame.Color('#000000'),
                                   is_link=False, link_href='test', link_style=CharStyle(),
                                   position=(0, 0), font_dictionary=dictionary)

        TextBlock(text='test', rect=pygame.Rect(0, 0, -1, 100),
                  indexed_styles={0: styled_chunk}, font_dict=dictionary, link_style=style,
                  bg_colour=pygame.Color('#FF0000'), wrap_to_height=True)
示例#5
0
 def test_creation(self, _init_pygame):
     dictionary = UIFontDictionary()
     style = CharStyle()
     StyledChunk(font_size=14,
                 font_name='fira_code',
                 chunk='text',
                 style=style,
                 color=pygame.Color('#FFFF00'),
                 bg_color=pygame.Color('#000000'),
                 is_link=False,
                 link_href='test',
                 link_style=CharStyle(),
                 position=(0, 0),
                 font_dictionary=dictionary)
示例#6
0
 def test_creation(self, _init_pygame):
     TextLineContext(font_size=14,
                     font_name='fira_code',
                     style=CharStyle(),
                     colour=pygame.Color('#FFFFFF'),
                     bg_colour=pygame.Color('#000000'),
                     is_link=True,
                     link_href='None')
示例#7
0
 def test_redraw_changed_metrics(self, _init_pygame):
     dictionary = UIFontDictionary()
     style = CharStyle()
     gradient = ColourGradient(0, pygame.Color('#FFFF00'),
                               pygame.Color('#FF0000'))
     chunk = StyledChunk(font_size=14,
                         font_name='fira_code',
                         chunk='text',
                         style=style,
                         color=pygame.Color('#FFFF00'),
                         bg_color=gradient,
                         is_link=False,
                         link_href='test',
                         link_style=CharStyle(),
                         position=(0, 0),
                         font_dictionary=dictionary)
     chunk.chunk = 'testy'
     chunk.redraw()
示例#8
0
    def test_word_split(self, _init_pygame):
        dictionary = UIFontDictionary()
        dictionary.preload_font(font_size=25, font_name='fira_code')
        style = CharStyle()
        styled_chunk_1 = StyledChunk(font_size=14, font_name='fira_code',
                                     chunk='text_text_text_text ', style=style, color=pygame.Color('#FFFF00'),
                                     bg_color=pygame.Color('#000000'),
                                     is_link=False, link_href='test', link_style=CharStyle(),
                                     position=(0, 0), font_dictionary=dictionary)

        styled_chunk_2 = StyledChunk(font_size=25, font_name='fira_code',
                                     chunk='DAN', style=style, color=pygame.Color('#FFFF00'),
                                     bg_color=pygame.Color('#000000'),
                                     is_link=False, link_href='test', link_style=CharStyle(),
                                     position=(0, 0), font_dictionary=dictionary)

        TextBlock(text='text_text_text_text DAN', rect=pygame.Rect(0, 0, 100, 100),
                  indexed_styles={0: styled_chunk_1, 21: styled_chunk_2}, font_dict=dictionary, link_style=style,
                  bg_colour=pygame.Color('#FF0000'), wrap_to_height=True)
示例#9
0
    def test_word_split(self, _init_pygame, _display_surface_return_none):
        loader = BlockingThreadedResourceLoader()
        dictionary = UIFontDictionary(loader)
        dictionary.preload_font(font_size=25, font_name='fira_code')
        loader.start()
        loader.update()
        style = CharStyle()
        styled_chunk_1 = StyledChunk(font_size=14,
                                     font_name='fira_code',
                                     chunk='text_text_text_text ',
                                     style=style,
                                     colour=pygame.Color('#FFFF00'),
                                     bg_colour=pygame.Color('#000000'),
                                     is_link=False,
                                     link_href='test',
                                     link_style=CharStyle(),
                                     position=(0, 0),
                                     font_dictionary=dictionary)

        styled_chunk_2 = StyledChunk(font_size=25,
                                     font_name='fira_code',
                                     chunk='DAN',
                                     style=style,
                                     colour=pygame.Color('#FFFF00'),
                                     bg_colour=pygame.Color('#000000'),
                                     is_link=False,
                                     link_href='test',
                                     link_style=CharStyle(),
                                     position=(0, 0),
                                     font_dictionary=dictionary)

        TextBlock(text='text_text_text_text DAN',
                  rect=pygame.Rect(0, 0, 100, 100),
                  indexed_styles={
                      0: styled_chunk_1,
                      21: styled_chunk_2
                  },
                  font_dict=dictionary,
                  link_style=style,
                  bg_colour=pygame.Color('#FF0000'),
                  wrap_to_height=True)
示例#10
0
    def test_creation(self, _init_pygame, _display_surface_return_none):
        dictionary = UIFontDictionary(BlockingThreadedResourceLoader())
        style = CharStyle()
        styled_chunk = StyledChunk(font_size=14,
                                   font_name='fira_code',
                                   chunk='text',
                                   style=style,
                                   colour=pygame.Color('#FFFF00'),
                                   bg_colour=pygame.Color('#000000'),
                                   is_link=False,
                                   link_href='test',
                                   link_style=CharStyle(),
                                   position=(0, 0),
                                   font_dictionary=dictionary)

        TextBlock(text='test',
                  rect=pygame.Rect(0, 0, 100, 100),
                  indexed_styles={0: styled_chunk},
                  font_dict=dictionary,
                  link_style=style,
                  bg_colour=pygame.Color('#FF0000'),
                  wrap_to_height=True)
示例#11
0
 def test_comparison(self, _init_pygame):
     assert CharStyle() == CharStyle()
示例#12
0
 def test_creation(self, _init_pygame):
     CharStyle()