Skip to content

Commit

Permalink
add test to ensure slider width is not using handle width and is retu…
Browse files Browse the repository at this point in the history
…rning expected values
  • Loading branch information
ericleonardis committed Dec 21, 2024
1 parent de3a73c commit a06c954
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion tests/gui/test_slider.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,4 +82,23 @@ def test_toVal(qtbot, slider_width, x_value, min_value, max_value):
)

# Assert that the raw transformation matches the expected value
assert slider._toVal(x_value) == expected_value
assert slider._toVal(x_value) == expected_value

def test_slider_width_property(qtbot):
"""
Test the _slider_width property to ensure it accurately reflects
the visual width of the slider's box_rect.
"""
slider = VideoSlider(min=0, max=1000, val=15, marks=(10, 15)) # Initialize slider

# Test various box_rect widths
for width in [800, 1000, 1200, 1500]:
slider.box_rect.setWidth(width) # Simulate setting the visual width
assert slider._slider_width == width, f"Expected _slider_width to be {width}, but got {slider._slider_width}"

# Test edge cases with very small and large widths
slider.box_rect.setWidth(0)
assert slider._slider_width == 0, "Expected _slider_width to be 0 when box_rect width is 0"

slider.box_rect.setWidth(10000)
assert slider._slider_width == 10000, "Expected _slider_width to handle large values correctly"

0 comments on commit a06c954

Please sign in to comment.