Repository: MyreMylar/pygame_gui
Pull request #291 (2022-08-05 07:40:17)

Further improvements to UI Elements testing coverage
Just doing this in batches for my sanity.


Patch:
diff --git a/pygame_gui/core/interfaces/text_owner_interface.py b/pygame_gui/core/interfaces/text_owner_interface.py
index e6c1a81..712e147 100644
--- a/pygame_gui/core/interfaces/text_owner_interface.py
+++ b/pygame_gui/core/interfaces/text_owner_interface.py
@@ -14,7 +14,7 @@ class IUITextOwnerInterface(metaclass=ABCMeta):
     """
 
     @abstractmethod
-    def set_text_alpha(self, alpha: int, sub_chunk: Optional['TextLineChunkFTFont']):
+    def set_text_alpha(self, alpha: int, sub_chunk: Optional['TextLineChunkFTFont'] = None):
         """
         Set the global alpha value for the text
 
@@ -24,7 +24,7 @@ class IUITextOwnerInterface(metaclass=ABCMeta):
 
     @abstractmethod
     def set_text_offset_pos(self, offset: Tuple[int, int],
-                            sub_chunk: Optional['TextLineChunkFTFont']):
+                            sub_chunk: Optional['TextLineChunkFTFont'] = None):
         """
         Move the text around by this offset.
 
@@ -35,7 +35,7 @@ class IUITextOwnerInterface(metaclass=ABCMeta):
 
     @abstractmethod
     def set_text_rotation(self, rotation: int,
-                          sub_chunk: Optional['TextLineChunkFTFont']):
+                          sub_chunk: Optional['TextLineChunkFTFont'] = None):
         """
         rotate the text by this int in degrees
 
@@ -45,7 +45,7 @@ class IUITextOwnerInterface(metaclass=ABCMeta):
         """
 
     @abstractmethod
-    def set_text_scale(self, scale: float,  sub_chunk: Optional['TextLineChunkFTFont']):
+    def set_text_scale(self, scale: float,  sub_chunk: Optional['TextLineChunkFTFont'] = None):
         """
         Scale the text by this float
 
@@ -55,7 +55,7 @@ class IUITextOwnerInterface(metaclass=ABCMeta):
         """
 
     @abstractmethod
-    def clear_text_surface(self, sub_chunk: Optional['TextLineChunkFTFont']):
+    def clear_text_surface(self, sub_chunk: Optional['TextLineChunkFTFont'] = None):
         """
         Clear the text surface
 
@@ -63,7 +63,7 @@ class IUITextOwnerInterface(metaclass=ABCMeta):
         """
 
     @abstractmethod
-    def get_text_letter_count(self, sub_chunk: Optional['TextLineChunkFTFont']) -> int:
+    def get_text_letter_count(self, sub_chunk: Optional['TextLineChunkFTFont'] = None) -> int:
         """
         The amount of letters in the text
 
@@ -72,7 +72,7 @@ class IUITextOwnerInterface(metaclass=ABCMeta):
         :return: number of letters as an int
         """
     @abstractmethod
-    def update_text_end_position(self, end_pos: int, sub_chunk: Optional['TextLineChunkFTFont']):
+    def update_text_end_position(self, end_pos: int, sub_chunk: Optional['TextLineChunkFTFont'] = None):
         """
         The position in the text to render up to.
 
@@ -120,7 +120,7 @@ class IUITextOwnerInterface(metaclass=ABCMeta):
         """
 
     @abstractmethod
-    def stop_finished_effect(self, sub_chunk: Optional['TextLineChunkFTFont']):
+    def stop_finished_effect(self, sub_chunk: Optional['TextLineChunkFTFont'] = None):
         """
         Stops a finished effect. Will leave effected text in the state it was in when effect
         ended. Used when an effect reaches a natural end where we might want to keep it in
@@ -130,7 +130,7 @@ class IUITextOwnerInterface(metaclass=ABCMeta):
         """
 
     @abstractmethod
-    def clear_all_active_effects(self, sub_chunk: Optional['TextLineChunkFTFont']):
+    def clear_all_active_effects(self, sub_chunk: Optional['TextLineChunkFTFont'] = None):
         """
         Clears any active effects and redraws the text. A full reset, usually called before
         firing off a new effect if one is already in progress.
diff --git a/pygame_gui/elements/ui_label.py b/pygame_gui/elements/ui_label.py
index e812c07..72d4eb2 100644
--- a/pygame_gui/elements/ui_label.py
+++ b/pygame_gui/elements/ui_label.py
@@ -298,15 +298,15 @@ class UILabel(UIElement, IUITextOwnerInterface):
         self.drawable_shape.set_text_alpha(alpha)
 
     def set_text_offset_pos(self, offset: Tuple[int, int],
-                            sub_chunk: Optional[TextLineChunkFTFont]):
+                            sub_chunk: Optional[TextLineChunkFTFont] = None):
         pass
 
     def set_text_rotation(self, rotation: int,
-                          sub_chunk: Optional[TextLineChunkFTFont]):
+                          sub_chunk: Optional[TextLineChunkFTFont] = None):
         pass
 
     def set_text_scale(self, scale: int,
-                       sub_chunk: Optional[TextLineChunkFTFont]):
+                       sub_chunk: Optional[TextLineChunkFTFont] = None):
         pass
 
     def clear_text_surface(self, sub_chunk: Optional[TextLineChunkFTFont] = None):
diff --git a/pygame_gui/elements/ui_text_box.py b/pygame_gui/elements/ui_text_box.py
index b0820a7..f2f4e27 100644
--- a/pygame_gui/elements/ui_text_box.py
+++ b/pygame_gui/elements/ui_text_box.py
@@ -1045,4 +1045,3 @@ class UITextBox(UIElement, IUITextOwnerInterface):
         self.html_text = html_text
         self.appended_text = ""  # clear appended text as it feels odd to set the text and still have appended text
         self._reparse_and_rebuild()
-


Test patch:
diff --git a/tests/data/themes/ui_drop_down_menu_bad_values.json b/tests/data/themes/ui_drop_down_menu_bad_values.json
index 8eaad59..11870ad 100644
--- a/tests/data/themes/ui_drop_down_menu_bad_values.json
+++ b/tests/data/themes/ui_drop_down_menu_bad_values.json
@@ -14,5 +14,14 @@
              "border_width": "0.6",
              "shadow_width": "french"
          }
+    },
+    "drop_down_menu.#drop_down_options_list":
+    {
+      "misc":
+      {
+        "shadow_width": "goose",
+        "border_width": "goose",
+        "list_item_height": "goose"
+      }
     }
 }
\ No newline at end of file
diff --git a/tests/data/themes/ui_drop_down_menu_non_default.json b/tests/data/themes/ui_drop_down_menu_non_default.json
index b28f79c..3e15ec0 100644
--- a/tests/data/themes/ui_drop_down_menu_non_default.json
+++ b/tests/data/themes/ui_drop_down_menu_non_default.json
@@ -12,7 +12,8 @@
              "shape_corner_radius": "6",
              "expand_direction": "up",
              "border_width": "0",
-             "shadow_width": "3"
+             "shadow_width": "3",
+             "open_button_width": "25"
 
          }
     },
diff --git a/tests/test_core/test_text/test_text_effects.py b/tests/test_core/test_text/test_text_effects.py
index 9d4fc6e..a721c46 100644
--- a/tests/test_core/test_text/test_text_effects.py
+++ b/tests/test_core/test_text/test_text_effects.py
@@ -42,18 +42,22 @@ class TestTypingAppearEffect:
 
         assert typing_effect.text_progress == 2
 
-        label = UILabel(pygame.Rect((10, 10), (200, 100)), 'Hello world',
+        label = UILabel(pygame.Rect((10, 10), (200, 100)), 'Hell',
                         default_ui_manager)
         label_typing_effect = TypingAppearEffect(text_owner=label)
 
         assert label_typing_effect.text_progress == 0
 
-        label_typing_effect.update(time_delta=0.06)
-        label_typing_effect.update(time_delta=0.06)
-        label_typing_effect.update(time_delta=0.06)
-        label_typing_effect.update(time_delta=0.06)
+        label.update(time_delta=0.06)
+        label.update(time_delta=0.06)
+        label.update(time_delta=0.06)
+        label.update(time_delta=0.06)
+        label.update(time_delta=0.06)
+        label.update(time_delta=0.06)
+        label.update(time_delta=0.06)
+        label.update(time_delta=0.06)
 
-        assert label_typing_effect.text_progress == 2
+        assert label_typing_effect.text_progress == 0
 
     def test_has_text_changed(self, _init_pygame, default_ui_manager: UIManager):
         text_box = UITextBox('hello <font color=#FF0000>this is a</font> test',
diff --git a/tests/test_elements/test_ui_drop_down_menu.py b/tests/test_elements/test_ui_drop_down_menu.py
index 162a5ef..f84fb7e 100644
--- a/tests/test_elements/test_ui_drop_down_menu.py
+++ b/tests/test_elements/test_ui_drop_down_menu.py
@@ -20,6 +20,32 @@ class TestUIDropDownMenu:
                               manager=default_ui_manager)
         assert menu.image is not None
 
+    def test_focus(self, _init_pygame, default_ui_manager, _display_surface_return_none):
+        menu = UIDropDownMenu(options_list=['eggs', 'flour', 'sugar'],
+                              starting_option='eggs',
+                              relative_rect=pygame.Rect(100, 100, 200, 30),
+                              manager=default_ui_manager)
+
+        menu.focus()
+
+        assert menu.is_focused
+
+        menu.unfocus()
+
+        assert not menu.is_focused
+
+        # test expanded too
+        menu.current_state.should_transition = True
+        menu.update(0.01)
+
+        menu.focus()
+
+        assert menu.is_focused
+
+        menu.unfocus()
+
+        assert not menu.is_focused
+
     def test_addition(self, _init_pygame, default_ui_manager,
                       _display_surface_return_none):
         menu = UIDropDownMenu(options_list=['eggs', 'flour', 'sugar'],
@@ -201,6 +227,26 @@ class TestUIDropDownMenu:
                               manager=manager)
         assert menu.image is not None
 
+    @pytest.mark.filterwarnings("ignore:Invalid value")
+    @pytest.mark.filterwarnings("ignore:Colour hex code")
+    def test_rebuild_from_theme_data_bad_values_live(self, _init_pygame,
+                                                     _display_surface_return_none):
+        manager = UIManager((800, 600))
+
+        menu = UIDropDownMenu(options_list=['eggs', 'flour', 'sugar'],
+                              starting_option='eggs',
+                              relative_rect=pygame.Rect(100, 100, 200, 30),
+                              manager=manager)
+
+        # load new theme
+        manager.ui_theme.load_theme(os.path.join("tests", "data", "themes", "ui_drop_down_menu_bad_values.json"))
+
+        # switch to expanded state
+        menu.current_state.should_transition = True
+        menu.update(0.01)
+
+        assert menu.image is not None
+
     def test_set_position(self, _init_pygame, default_ui_manager,
                           _display_surface_return_none):
         test_container = UIContainer(relative_rect=pygame.Rect(10, 10, 300, 300),
@@ -295,6 +341,41 @@ class TestUIDropDownMenu:
         # if we successfully clicked on the moved menu then this button should be True
         assert menu.current_state.close_button.held is True
 
+        # now with non default theming values
+        manager = UIManager((800, 600), os.path.join("tests", "data",
+                                                     "themes", "ui_drop_down_menu_non_default.json"))
+
+        non_default_menu = UIDropDownMenu(options_list=['eggs', 'flour', 'sugar'],
+                                          starting_option='eggs',
+                                          relative_rect=pygame.Rect(100, 100, 200, 30),
+                                          manager=manager)
+        non_default_menu.set_dimensions((300, 50))
+
+        assert (non_default_menu.current_state.open_button.relative_rect.right ==
+                300 - (non_default_menu.border_width + non_default_menu.shadow_width))
+
+        assert (non_default_menu.current_state.open_button.relative_rect.bottom ==
+                50 - (non_default_menu.border_width + non_default_menu.shadow_width))
+
+        # try to click on the menu
+        manager.process_events(pygame.event.Event(pygame.MOUSEBUTTONDOWN,
+                                                  {'button': pygame.BUTTON_LEFT,
+                                                   'pos': (390, 125)}))
+        # if we successfully clicked on the moved menu then this button should be True
+        assert non_default_menu.current_state.open_button.held is True
+
+        non_default_menu.current_state.should_transition = True
+        non_default_menu.update(0.01)
+
+        non_default_menu.set_dimensions((200, 30))
+
+        # try to click on the menu
+        manager.process_events(pygame.event.Event(pygame.MOUSEBUTTONDOWN,
+                                                  {'button': 1,
+                                                   'pos': (290, 115)}))
+        # if we successfully clicked on the moved menu then this button should be True
+        assert non_default_menu.current_state.close_button.held is True
+
     def test_on_fresh_drawable_shape_ready(self, _init_pygame, default_ui_manager):
         menu = UIDropDownMenu(options_list=['eggs', 'flour', 'sugar'],
                               starting_option='eggs',
diff --git a/tests/test_elements/test_ui_horizontal_scroll_bar.py b/tests/test_elements/test_ui_horizontal_scroll_bar.py
index c2d3f8c..14f0910 100644
--- a/tests/test_elements/test_ui_horizontal_scroll_bar.py
+++ b/tests/test_elements/test_ui_horizontal_scroll_bar.py
@@ -32,6 +32,12 @@ class TestUIHorizontalScrollBar:
         scroll_bar.rebuild()
         assert scroll_bar.image is not None
 
+        scroll_bar.enable_arrow_buttons = False
+
+        scroll_bar.rebuild()
+
+        assert scroll_bar.left_button is None and scroll_bar.right_button is None
+
     def test_check_has_moved_recently(self, _init_pygame, default_ui_manager,
                                       _display_surface_return_none):
         scroll_bar = UIHorizontalScrollBar(relative_rect=pygame.Rect(100, 100, 150, 30),
@@ -84,6 +90,12 @@ class TestUIHorizontalScrollBar:
         scroll_bar.redraw_scrollbar()
         assert scroll_bar.sliding_button is not None
 
+        scroll_bar.sliding_button.kill()
+        scroll_bar.sliding_button = None
+
+        scroll_bar.redraw_scrollbar()
+        assert scroll_bar.sliding_button is not None
+
     def test_reset_scroll_position(self, _init_pygame, default_ui_manager,
                                    _display_surface_return_none):
         scroll_bar = UIHorizontalScrollBar(relative_rect=pygame.Rect(100, 100, 150, 30),
@@ -242,8 +254,14 @@ class TestUIHorizontalScrollBar:
         scroll_bar = UIHorizontalScrollBar(relative_rect=pygame.Rect(0, 0, 200, 30),
                                            visible_percentage=0.25, manager=default_ui_manager)
 
+        scroll_bar.sliding_button.hovered = True
+
+        assert scroll_bar.process_event(pygame.event.Event(pygame.MOUSEWHEEL, {'x': 1.0}))
+
         scroll_bar.disable()
 
+        assert not scroll_bar.process_event(pygame.event.Event(pygame.MOUSEWHEEL, {'x': 1.0}))
+
         # process a mouse button down event
         scroll_bar.right_button.process_event(
             pygame.event.Event(pygame.MOUSEBUTTONDOWN,
diff --git a/tests/test_elements/test_ui_horizontal_slider.py b/tests/test_elements/test_ui_horizontal_slider.py
index a9ad47f..b7c8452 100644
--- a/tests/test_elements/test_ui_horizontal_slider.py
+++ b/tests/test_elements/test_ui_horizontal_slider.py
@@ -1,130 +1,142 @@
 import os
-import pytest
-import pygame
 
-from tests.shared_comparators import compare_surfaces
+import pygame
+import pytest
 
-from pygame_gui.ui_manager import UIManager
-from pygame_gui.elements.ui_horizontal_slider import UIHorizontalSlider
-from pygame_gui.core.ui_container import UIContainer
 from pygame_gui.core.interfaces import IUIManagerInterface
+from pygame_gui.core.ui_container import UIContainer
+from pygame_gui.elements.ui_horizontal_slider import UIHorizontalSlider
+from pygame_gui.ui_manager import UIManager
+from tests.shared_comparators import compare_surfaces
+from pygame_gui import UI_BUTTON_PRESSED
 
 
 class TestUIHorizontalSlider:
 
     def test_creation(self, _init_pygame, default_ui_manager: IUIManagerInterface,
                       _display_surface_return_none):
-        scroll_bar = UIHorizontalSlider(relative_rect=pygame.Rect(100, 100, 200, 30),
-                                        start_value=50,
-                                        value_range=(0, 100),
-                                        manager=default_ui_manager)
-        assert scroll_bar.image is not None
+        slider = UIHorizontalSlider(relative_rect=pygame.Rect(100, 100, 200, 30),
+                                    start_value=50,
+                                    value_range=(0, 100),
+                                    manager=default_ui_manager)
+        assert slider.image is not None
 
     def test_rebuild(self, _init_pygame, default_ui_manager: IUIManagerInterface,
                      _display_surface_return_none):
-        scroll_bar = UIHorizontalSlider(relative_rect=pygame.Rect(100, 100, 200, 30),
-                                        start_value=50,
-                                        value_range=(0, 100),
-                                        manager=default_ui_manager)
-        scroll_bar.rebuild()
-        assert scroll_bar.image is not None
+        slider = UIHorizontalSlider(relative_rect=pygame.Rect(100, 100, 200, 30),
+                                    start_value=50,
+                                    value_range=(0, 100),
+                                    manager=default_ui_manager)
+        slider.rebuild()
+
+        assert slider.image is not None
+
+        slider.enable_arrow_buttons = False
+
+        slider.rebuild()
+
+        assert slider.left_button is None and slider.right_button is None
 
     def test_kill(self, _init_pygame, default_ui_manager: IUIManagerInterface,
                   _display_surface_return_none):
-        scroll_bar = UIHorizontalSlider(relative_rect=pygame.Rect(100, 100, 200, 30),
-                                        start_value=50,
-                                        value_range=(0, 100),
-                                        manager=default_ui_manager)
+        slider = UIHorizontalSlider(relative_rect=pygame.Rect(100, 100, 200, 30),
+                                    start_value=50,
+                                    value_range=(0, 100),
+                                    manager=default_ui_manager)
 
         assert len(default_ui_manager.get_root_container().elements) == 2
         assert len(default_ui_manager.get_sprite_group().sprites()) == 6
         assert default_ui_manager.get_sprite_group().sprites() == [default_ui_manager.get_root_container(),
-                                                                   scroll_bar,
-                                                                   scroll_bar.button_container,
-                                                                   scroll_bar.left_button,
-                                                                   scroll_bar.right_button,
-                                                                   scroll_bar.sliding_button]
-        scroll_bar.kill()
+                                                                   slider,
+                                                                   slider.button_container,
+                                                                   slider.left_button,
+                                                                   slider.right_button,
+                                                                   slider.sliding_button]
+        slider.kill()
         assert len(default_ui_manager.get_root_container().elements) == 0
         assert len(default_ui_manager.get_sprite_group().sprites()) == 1
         assert default_ui_manager.get_sprite_group().sprites() == [default_ui_manager.get_root_container()]
 
     def test_check_has_moved_recently(self, _init_pygame, default_ui_manager,
                                       _display_surface_return_none):
-        scroll_bar = UIHorizontalSlider(relative_rect=pygame.Rect(100, 100, 200, 30),
-                                        start_value=50,
-                                        value_range=(0, 100),
-                                        manager=default_ui_manager)
+        slider = UIHorizontalSlider(relative_rect=pygame.Rect(100, 100, 200, 30),
+                                    start_value=50,
+                                    value_range=(0, 100),
+                                    manager=default_ui_manager)
 
         # move the scroll bar a bit
-        scroll_bar.left_button.held = True
-        scroll_bar.update(0.2)
-        assert scroll_bar.has_moved_recently is True
+        slider.left_button.held = True
+        slider.update(0.2)
+        assert slider.has_moved_recently is True
 
     def test_check_update_buttons(self, _init_pygame, default_ui_manager,
                                   _display_surface_return_none):
-        scroll_bar = UIHorizontalSlider(relative_rect=pygame.Rect(100, 100, 200, 30),
-                                        start_value=50,
-                                        value_range=(0, 100),
-                                        manager=default_ui_manager)
+        slider = UIHorizontalSlider(relative_rect=pygame.Rect(100, 100, 200, 30),
+                                    start_value=50,
+                                    value_range=(0, 100),
+                                    manager=default_ui_manager)
 
         # scroll down a bit then up again to exercise update
-        scroll_bar.get_current_value()  # Clear has moved this turn
-        scroll_bar.left_button.held = True
-        scroll_bar.update(0.5)
-        scroll_bar.left_button.held = False
-        scroll_bar.right_button.held = True
-        scroll_bar.update(0.5)
+        slider.get_current_value()  # Clear has moved this turn
+        slider.left_button.held = True
+        slider.update(0.5)
+        slider.left_button.held = False
+        slider.right_button.held = True
+        slider.update(0.5)
 
-        assert scroll_bar.has_moved_recently is True
+        assert slider.has_moved_recently is True
 
     def test_check_update_sliding_bar(self, _init_pygame, default_ui_manager,
                                       _display_surface_return_none):
-        scroll_bar = UIHorizontalSlider(relative_rect=pygame.Rect(0, 0, 200, 30),
-                                        start_value=50,
-                                        value_range=(0, 100),
-                                        manager=default_ui_manager)
+        slider = UIHorizontalSlider(relative_rect=pygame.Rect(0, 0, 200, 30),
+                                    start_value=50,
+                                    value_range=(0, 100),
+                                    manager=default_ui_manager)
 
         # scroll down a bit then up again to exercise update
         default_ui_manager.mouse_position = (100, 15)
-        scroll_bar.sliding_button.held = True
-        scroll_bar.update(0.3)
+        slider.sliding_button.held = True
+        slider.update(0.3)
 
-        assert scroll_bar.grabbed_slider is True
+        assert slider.grabbed_slider is True
 
-        scroll_bar.sliding_button.held = False
-        scroll_bar.update(0.3)
+        slider.sliding_button.held = False
+        slider.update(0.3)
 
-        assert scroll_bar.grabbed_slider is False
+        assert slider.grabbed_slider is False
 
     def test_get_current_value(self, _init_pygame, default_ui_manager,
                                _display_surface_return_none):
-        scroll_bar = UIHorizontalSlider(relative_rect=pygame.Rect(100, 100, 200, 30),
-                                        start_value=50,
-                                        value_range=(0, 100),
-                                        manager=default_ui_manager)
+        slider = UIHorizontalSlider(relative_rect=pygame.Rect(100, 100, 200, 30),
+                                    start_value=50,
+                                    value_range=(0, 100),
+                                    manager=default_ui_manager)
 
-        assert scroll_bar.get_current_value() == 50
+        assert slider.get_current_value() == 50
 
     def test_set_current_value_in_range(self, _init_pygame, default_ui_manager,
                                         _display_surface_return_none):
-        scroll_bar = UIHorizontalSlider(relative_rect=pygame.Rect(100, 100, 200, 30),
-                                        start_value=50,
-                                        value_range=(0, 100),
-                                        manager=default_ui_manager)
+        slider = UIHorizontalSlider(relative_rect=pygame.Rect(100, 100, 200, 30),
+                                    start_value=50,
+                                    value_range=(0, 100),
+                                    manager=default_ui_manager)
 
-        scroll_bar.set_current_value(75)
-        assert scroll_bar.get_current_value() == 75
+        slider.set_current_value(75)
+        assert slider.get_current_value() == 75
 
     def test_set_current_value_out_of_range(self, _init_pygame, default_ui_manager,
                                             _display_surface_return_none):
-        scroll_bar = UIHorizontalSlider(relative_rect=pygame.Rect(100, 100, 200, 30),
-                                        start_value=50,
-                                        value_range=(0, 100),
-                                        manager=default_ui_manager)
+        slider = UIHorizontalSlider(relative_rect=pygame.Rect(100, 100, 200, 30),
+                                    start_value=50,
+                                    value_range=(0, 100),
+                                    manager=default_ui_manager)
 
         with pytest.warns(UserWarning, match='value not in range'):
-            scroll_bar.set_current_value(200)
+            slider.set_current_value(200)
+
+        slider.set_current_value(200, warn=False)
+
+        assert slider.current_value == 100
 
     def test_rebuild_from_theme_data_non_default(self, _init_pygame,
                                                  _display_surface_return_none):
@@ -132,11 +144,11 @@ class TestUIHorizontalSlider:
                                                      "themes",
                                                      "ui_horizontal_slider_non_default.json"))
 
-        scroll_bar = UIHorizontalSlider(relative_rect=pygame.Rect(100, 100, 200, 30),
-                                        start_value=50,
-                                        value_range=(0, 100),
-                                        manager=manager)
-        assert scroll_bar.image is not None
+        slider = UIHorizontalSlider(relative_rect=pygame.Rect(100, 100, 200, 30),
+                                    start_value=50,
+                                    value_range=(0, 100),
+                                    manager=manager)
+        assert slider.image is not None
 
     def test_rebuild_from_theme_data_no_arrow_buttons(self, _init_pygame,
                                                       _display_surface_return_none):
@@ -145,14 +157,14 @@ class TestUIHorizontalSlider:
                                                      "themes",
                                                      "ui_horizontal_slider_no_arrows.json"))
 
-        scroll_bar = UIHorizontalSlider(relative_rect=pygame.Rect(100, 100, 200, 30),
-                                        start_value=50,
-                                        value_range=(0, 100),
-                                        manager=manager)
+        slider = UIHorizontalSlider(relative_rect=pygame.Rect(100, 100, 200, 30),
+                                    start_value=50,
+                                    value_range=(0, 100),
+                                    manager=manager)
 
-        assert scroll_bar.left_button is None
-        assert scroll_bar.right_button is None
-        assert scroll_bar.image is not None
+        assert slider.left_button is None
+        assert slider.right_button is None
+        assert slider.image is not None
 
     @pytest.mark.filterwarnings("ignore:Invalid value")
     @pytest.mark.filterwarnings("ignore:Colour hex code")
@@ -163,11 +175,11 @@ class TestUIHorizontalSlider:
                                                      "themes",
                                                      "ui_horizontal_slider_bad_values.json"))
 
-        scroll_bar = UIHorizontalSlider(relative_rect=pygame.Rect(100, 100, 200, 30),
-                                        start_value=51,
-                                        value_range=(0, 100),
-                                        manager=manager)
-        assert scroll_bar.image is not None
+        slider = UIHorizontalSlider(relative_rect=pygame.Rect(100, 100, 200, 30),
+                                    start_value=51,
+                                    value_range=(0, 100),
+                                    manager=manager)
+        assert slider.image is not None
 
     def test_set_position(self, _init_pygame, default_ui_manager, _display_surface_return_none):
         slider = UIHorizontalSlider(relative_rect=pygame.Rect(300, 400, 150, 40), start_value=50,
@@ -245,6 +257,9 @@ class TestUIHorizontalSlider:
         slider = UIHorizontalSlider(relative_rect=pygame.Rect(0, 0, 150, 40), start_value=50,
                                     value_range=(0, 200), manager=default_ui_manager)
 
+        assert slider.process_event(pygame.event.Event(UI_BUTTON_PRESSED, {'ui_element': slider.left_button}))
+        assert not slider.process_event(pygame.event.Event(UI_BUTTON_PRESSED, {'ui_element': None}))
+
         slider.disable()
 
         # process a mouse button down event
@@ -259,7 +274,7 @@ class TestUIHorizontalSlider:
             pygame.event.Event(pygame.MOUSEBUTTONUP, {'button': 1,
                                                       'pos': slider.left_button.rect.center}))
 
-        assert slider.get_current_value() == 50 and slider.is_enabled is False
+        assert slider.get_current_value() == 49 and slider.is_enabled is False
 
     def test_enable(self, _init_pygame: None, default_ui_manager: UIManager,
                     _display_surface_return_none: None):
diff --git a/tests/test_elements/test_ui_image.py b/tests/test_elements/test_ui_image.py
index b98e18f..89b914d 100644
--- a/tests/test_elements/test_ui_image.py
+++ b/tests/test_elements/test_ui_image.py
@@ -59,10 +59,20 @@ class TestUIImage:
                            manager=default_ui_manager,
                            container=container)
 
-        ui_image.set_dimensions((50, 50))
         ui_image.set_dimensions((350, 350))
         ui_image.set_dimensions((128, 128))
 
+        container = UIScrollingContainer(pygame.Rect(100, 100, 200, 200),
+                                         manager=default_ui_manager)
+
+        ui_image = UIImage(relative_rect=pygame.Rect(10, 10, 128, 128),
+                           image_surface=loaded_image,
+                           manager=default_ui_manager,
+                           container=container)
+
+        ui_image.set_dimensions((50, 50))
+        ui_image.set_dimensions((128, 128))
+
         container.set_dimensions((50, 50))
         ui_image.set_dimensions((35, 35))
         container.set_dimensions((300, 300))
diff --git a/tests/test_elements/test_ui_label.py b/tests/test_elements/test_ui_label.py
index ee3c8fc..63b892c 100644
--- a/tests/test_elements/test_ui_label.py
+++ b/tests/test_elements/test_ui_label.py
@@ -26,6 +26,13 @@ class TestUILabel:
         label.set_text("new text")
         assert label.image is not None
 
+        # dynamic width
+        label = UILabel(relative_rect=pygame.Rect(100, 100, -1, 30),
+                        text="Test Label",
+                        manager=default_ui_manager)
+        label.set_text("new text")
+        assert label.image is not None and label.rect.width == 64
+
     def test_kwargs_set_text(self, _init_pygame, default_ui_manager,
                              _display_surface_return_none):
         label = UILabel(relative_rect=pygame.Rect(100, 100, 150, 30),
@@ -208,6 +215,13 @@ class TestUILabel:
 
         assert label.drawable_shape.theming['text'] == "Anglaise"
 
+        label = UILabel(pygame.Rect((10, 100), (-1, 30)),
+                        'pygame-gui.English',
+                        default_ui_manager)
+        default_ui_manager.set_locale('fr')
+
+        assert label.drawable_shape.theming['text'] == "Anglaise"
+
         label = UILabel(pygame.Rect((10, 100), (-1, -1)),
                         'pygame-gui.English',
                         default_ui_manager)
@@ -215,6 +229,19 @@ class TestUILabel:
 
         assert label.drawable_shape.theming['text'] == "英語"
 
+    def test_text_owner_interface(self, _init_pygame, default_ui_manager,
+                                  _display_surface_return_none):
+        label = UILabel(relative_rect=pygame.Rect(100, 100, 150, 30),
+                        text="Test Label",
+                        manager=default_ui_manager)
+
+        # right now these functions do nothing for the label
+        label.set_text_offset_pos((0, 0))
+        label.set_text_rotation(0)
+        label.set_text_scale(0)
+
+        assert label.image is not None
+
 
 if __name__ == '__main__':
     pytest.console_main()
diff --git a/tests/test_ui_manager.py b/tests/test_ui_manager.py
index 4f09388..173158c 100644
--- a/tests/test_ui_manager.py
+++ b/tests/test_ui_manager.py
@@ -349,4 +349,5 @@ class TestUIManager:
 
 
 if __name__ == '__main__':
+    os.chdir('..')
     pytest.console_main()