Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
MyreMylar committed Jun 24, 2020
1 parent dc0efc1 commit 5603245
Show file tree
Hide file tree
Showing 20 changed files with 61 additions and 16 deletions.
3 changes: 3 additions & 0 deletions tests/test_elements/test_ui_button.py
Original file line number Diff line number Diff line change
Expand Up @@ -678,16 +678,19 @@ def test_show_hide_rendering(self, _init_pygame, default_ui_manager, _display_su
button = UIButton(relative_rect=pygame.Rect(25, 25, 375, 150),
text="Test Button",
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))
button.show()
manager.update(0.01)
manager.draw_ui(surface)
assert not compare_surfaces(empty_surface, surface)

surface.fill(pygame.Color(0, 0, 0))
button.hide()
manager.update(0.01)
manager.draw_ui(surface)
assert compare_surfaces(empty_surface, surface)

Expand Down
3 changes: 3 additions & 0 deletions tests/test_elements/test_ui_drop_down_menu.py
Original file line number Diff line number Diff line change
Expand Up @@ -534,16 +534,19 @@ def test_show_hide_rendering(self, _init_pygame, default_ui_manager, _display_su
relative_rect=pygame.Rect(25, 25, 375, 150),
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))
menu.show()
manager.update(0.01)
manager.draw_ui(surface)
assert not compare_surfaces(empty_surface, surface)

surface.fill(pygame.Color(0, 0, 0))
menu.hide()
manager.update(0.01)
manager.draw_ui(surface)
assert compare_surfaces(empty_surface, surface)

Expand Down
4 changes: 3 additions & 1 deletion tests/test_elements/test_ui_horizontal_scroll_bar.py
Original file line number Diff line number Diff line change
Expand Up @@ -334,16 +334,18 @@ def test_show_hide_rendering(self, _init_pygame, default_ui_manager, _display_su
visible_percentage=0.25,
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))
scroll_bar.show()
manager.update(0.01)
manager.draw_ui(surface)
assert not compare_surfaces(empty_surface, surface)

surface.fill(pygame.Color(0, 0, 0))
scroll_bar.hide()
manager.update(0.01)
manager.draw_ui(surface)
assert compare_surfaces(empty_surface, surface)
4 changes: 3 additions & 1 deletion tests/test_elements/test_ui_horizontal_slider.py
Original file line number Diff line number Diff line change
Expand Up @@ -375,16 +375,18 @@ def test_show_hide_rendering(self, _init_pygame, default_ui_manager, _display_su
manager = UIManager(resolution)
slider = UIHorizontalSlider(relative_rect=pygame.Rect(25, 25, 375, 150), start_value=50,
value_range=(0, 200), 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))
slider.show()
manager.update(0.01)
manager.draw_ui(surface)
assert not compare_surfaces(empty_surface, surface)

surface.fill(pygame.Color(0, 0, 0))
slider.hide()
manager.update(0.01)
manager.draw_ui(surface)
assert compare_surfaces(empty_surface, surface)
4 changes: 3 additions & 1 deletion tests/test_elements/test_ui_image.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,16 +84,18 @@ def test_show_hide_rendering(self, _init_pygame, default_ui_manager, _display_su
image_surface=loaded_image,
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))
ui_image.show()
manager.update(0.01)
manager.draw_ui(surface)
assert not compare_surfaces(empty_surface, surface)

surface.fill(pygame.Color(0, 0, 0))
ui_image.hide()
manager.update(0.01)
manager.draw_ui(surface)
assert compare_surfaces(empty_surface, surface)
3 changes: 3 additions & 0 deletions tests/test_elements/test_ui_label.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,15 +159,18 @@ def test_show_hide_rendering(self, _init_pygame, default_ui_manager, _display_su
label = UILabel(relative_rect=pygame.Rect(25, 25, 375, 150),
text="Test Button",
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))
label.show()
manager.update(0.01)
manager.draw_ui(surface)
assert not compare_surfaces(empty_surface, surface)

surface.fill(pygame.Color(0, 0, 0))
label.hide()
manager.update(0.01)
manager.draw_ui(surface)
assert compare_surfaces(empty_surface, surface)
4 changes: 3 additions & 1 deletion tests/test_elements/test_ui_panel.py
Original file line number Diff line number Diff line change
Expand Up @@ -577,16 +577,18 @@ def test_show_hide_rendering(self, _init_pygame, default_ui_manager, _display_su
button = UIButton(relative_rect=pygame.Rect(0, 0, 50, 50), text="",
manager=manager, container=panel)


manager.update(0.01)
manager.draw_ui(surface)
assert compare_surfaces(empty_surface, surface)

surface.fill(pygame.Color(0, 0, 0))
panel.show()
manager.update(0.01)
manager.draw_ui(surface)
assert not compare_surfaces(empty_surface, surface)

surface.fill(pygame.Color(0, 0, 0))
panel.hide()
manager.update(0.01)
manager.draw_ui(surface)
assert compare_surfaces(empty_surface, surface)
4 changes: 3 additions & 1 deletion tests/test_elements/test_ui_screen_space_health_bar.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,16 +184,18 @@ def test_show_hide_rendering(self, _init_pygame, default_ui_manager, _display_su
sprite_to_monitor=healthy_sprite,
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))
health_bar.show()
manager.update(0.01)
manager.draw_ui(surface)
assert not compare_surfaces(empty_surface, surface)

surface.fill(pygame.Color(0, 0, 0))
health_bar.hide()
manager.update(0.01)
manager.draw_ui(surface)
assert compare_surfaces(empty_surface, surface)
4 changes: 3 additions & 1 deletion tests/test_elements/test_ui_scrolling_container.py
Original file line number Diff line number Diff line change
Expand Up @@ -250,16 +250,18 @@ def test_show_hide_rendering(self, _init_pygame, default_ui_manager, _display_su
manager=manager,
visible=0)
container.set_scrollable_area_dimensions((600, 600))

manager.update(0.01)
manager.draw_ui(surface)
assert compare_surfaces(empty_surface, surface)

surface.fill(pygame.Color(0, 0, 0))
container.show()
manager.update(0.01)
manager.draw_ui(surface)
assert not compare_surfaces(empty_surface, surface)

surface.fill(pygame.Color(0, 0, 0))
container.hide()
manager.update(0.01)
manager.draw_ui(surface)
assert compare_surfaces(empty_surface, surface)
4 changes: 3 additions & 1 deletion tests/test_elements/test_ui_selection_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -768,16 +768,18 @@ def test_show_hide_rendering(self, _init_pygame, default_ui_manager, _display_su
manager=manager,
allow_multi_select=True,
visible=0)

manager.update(0.01)
manager.draw_ui(surface)
assert compare_surfaces(empty_surface, surface)

surface.fill(pygame.Color(0, 0, 0))
selection_list.show()
manager.update(0.01)
manager.draw_ui(surface)
assert not compare_surfaces(empty_surface, surface)

surface.fill(pygame.Color(0, 0, 0))
selection_list.hide()
manager.update(0.01)
manager.draw_ui(surface)
assert compare_surfaces(empty_surface, surface)
4 changes: 3 additions & 1 deletion tests/test_elements/test_ui_text_box.py
Original file line number Diff line number Diff line change
Expand Up @@ -771,16 +771,18 @@ def test_show_hide_rendering(self, _init_pygame, default_ui_manager, _display_su
layer_starting_height=100,
object_id="screen_message",
visible=0)

manager.update(0.01)
manager.draw_ui(surface)
assert compare_surfaces(empty_surface, surface)

surface.fill(pygame.Color(0, 0, 0))
text_box.show()
manager.update(0.01)
manager.draw_ui(surface)
assert not compare_surfaces(empty_surface, surface)

surface.fill(pygame.Color(0, 0, 0))
text_box.hide()
manager.update(0.01)
manager.draw_ui(surface)
assert compare_surfaces(empty_surface, surface)
4 changes: 3 additions & 1 deletion tests/test_elements/test_ui_text_entry_line.py
Original file line number Diff line number Diff line change
Expand Up @@ -920,16 +920,18 @@ def test_show_hide_rendering(self, _init_pygame, default_ui_manager, _display_su
text_entry = UITextEntryLine(relative_rect=pygame.Rect(100, 100, 400, 400),
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))
text_entry.show()
manager.update(0.01)
manager.draw_ui(surface)
assert not compare_surfaces(empty_surface, surface)

surface.fill(pygame.Color(0, 0, 0))
text_entry.hide()
manager.update(0.01)
manager.draw_ui(surface)
assert compare_surfaces(empty_surface, surface)
4 changes: 3 additions & 1 deletion tests/test_elements/test_ui_vertical_scroll_bar.py
Original file line number Diff line number Diff line change
Expand Up @@ -335,16 +335,18 @@ def test_show_hide_rendering(self, _init_pygame, default_ui_manager, _display_su
visible_percentage=0.25,
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))
scroll_bar.show()
manager.update(0.01)
manager.draw_ui(surface)
assert not compare_surfaces(empty_surface, surface)

surface.fill(pygame.Color(0, 0, 0))
scroll_bar.hide()
manager.update(0.01)
manager.draw_ui(surface)
assert compare_surfaces(empty_surface, surface)
4 changes: 3 additions & 1 deletion tests/test_elements/test_ui_window.py
Original file line number Diff line number Diff line change
Expand Up @@ -554,16 +554,18 @@ def test_show_hide_rendering(self, _init_pygame, default_ui_manager, _display_su
window_display_title="Test Window",
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))
window.show()
manager.update(0.01)
manager.draw_ui(surface)
assert not compare_surfaces(empty_surface, surface)

surface.fill(pygame.Color(0, 0, 0))
window.hide()
manager.update(0.01)
manager.draw_ui(surface)
assert compare_surfaces(empty_surface, surface)
4 changes: 3 additions & 1 deletion tests/test_elements/test_ui_world_space_health_bar.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,16 +146,18 @@ def test_show_hide_rendering(self, _init_pygame, default_ui_manager, _display_su
sprite_to_monitor=healthy_sprite,
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))
health_bar.show()
manager.update(0.01)
manager.draw_ui(surface)
assert not compare_surfaces(empty_surface, surface)

surface.fill(pygame.Color(0, 0, 0))
health_bar.hide()
manager.update(0.01)
manager.draw_ui(surface)
assert compare_surfaces(empty_surface, surface)
2 changes: 1 addition & 1 deletion tests/test_ui_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ def test_draw_ui(self, _init_pygame, _display_surface_return_none):
test_surface = pygame.display.set_mode((150, 30), 0, 32)
manager = UIManager((150, 30))
UIButton(relative_rect=pygame.Rect(0, 0, 150, 30), text="Test", manager=manager)
# manager.update(0.01)
manager.update(0.01)
manager.draw_ui(test_surface)
plat = platform.system().upper()
if plat == 'WINDOWS':
Expand Down
7 changes: 6 additions & 1 deletion tests/test_windows/test_ui_colour_picker_dialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -225,16 +225,19 @@ def test_show_hide_rendering(self, _init_pygame, default_ui_manager, _display_su

channel_editor.set_dimensions((200, 29))

manager.update(0.01)
manager.draw_ui(surface)
assert compare_surfaces(empty_surface, surface)

surface.fill(pygame.Color(0, 0, 0))
channel_editor.show()
manager.update(0.01)
manager.draw_ui(surface)
assert not compare_surfaces(empty_surface, surface)

surface.fill(pygame.Color(0, 0, 0))
channel_editor.hide()
manager.update(0.01)
manager.draw_ui(surface)
assert compare_surfaces(empty_surface, surface)

Expand Down Expand Up @@ -537,16 +540,18 @@ def test_show_hide_rendering(self, _init_pygame, default_ui_manager, _display_su
manager=manager,
initial_colour=pygame.Color(200, 220, 50, 255),
visible=0)

manager.update(0.01)
manager.draw_ui(surface)
assert compare_surfaces(empty_surface, surface)

surface.fill(pygame.Color(0, 0, 0))
colour_picker.show()
manager.update(0.01)
manager.draw_ui(surface)
assert not compare_surfaces(empty_surface, surface)

surface.fill(pygame.Color(0, 0, 0))
colour_picker.hide()
manager.update(0.01)
manager.draw_ui(surface)
assert compare_surfaces(empty_surface, surface)
3 changes: 3 additions & 0 deletions tests/test_windows/test_ui_confirmation_dialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -258,15 +258,18 @@ def test_show_hide_rendering(self, _init_pygame, _display_surface_return_none):
window_title="Confirm",
action_short_name="Confirm",
visible=0)
manager.update(0.01)
manager.draw_ui(surface)
assert compare_surfaces(empty_surface, surface)

surface.fill(pygame.Color(0, 0, 0))
confirm_dialog.show()
manager.update(0.01)
manager.draw_ui(surface)
assert not compare_surfaces(empty_surface, surface)

surface.fill(pygame.Color(0, 0, 0))
confirm_dialog.hide()
manager.update(0.01)
manager.draw_ui(surface)
assert compare_surfaces(empty_surface, surface)
4 changes: 3 additions & 1 deletion tests/test_windows/test_ui_file_dialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -343,16 +343,18 @@ def test_show_hide_rendering(self, _init_pygame, default_ui_manager, _display_su
manager=manager,
visible=0)
file_dialog.file_path_text_line.set_text('tests/data/images')

manager.update(0.01)
manager.draw_ui(surface)
assert compare_surfaces(empty_surface, surface)

surface.fill(pygame.Color(0, 0, 0))
file_dialog.show()
manager.update(0.01)
manager.draw_ui(surface)
assert not compare_surfaces(empty_surface, surface)

surface.fill(pygame.Color(0, 0, 0))
file_dialog.hide()
manager.update(0.01)
manager.draw_ui(surface)
assert compare_surfaces(empty_surface, surface)
Loading

0 comments on commit 5603245

Please sign in to comment.