Skip to content

Commit

Permalink
update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
djdt committed May 16, 2024
1 parent 46c5261 commit 57e13f0
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 7 deletions.
20 changes: 18 additions & 2 deletions tests/gui/test_graph_options.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,10 @@ def test_histogram_options_dialog(qtbot: QtBot):
"signal": None,
"mass": None,
"size": None,
"volume": None,
"cell_concentration": 1e-9,
},
percentile=95,
draw_filtered=False,
)
qtbot.add_widget(dlg)
Expand All @@ -66,6 +68,8 @@ def test_histogram_options_dialog(qtbot: QtBot):
dlg.width_signal.setBaseValue(100.0)
dlg.width_mass.setBaseValue(1e-19)
dlg.width_size.setBaseValue(1e-9)
dlg.width_volume.setBaseValue(1e-6)
dlg.spinbox_percentile.setValue(90)
dlg.check_draw_filtered.setChecked(True)

def check_bin_widths(widths: dict) -> bool:
Expand All @@ -75,14 +79,26 @@ def check_bin_widths(widths: dict) -> bool:
return False
if widths["size"] != 1e-9:
return False
if widths["volume"] != 1e-6:
return False
if widths["cell_concentration"] != 1e-9:
return False
return True

with qtbot.wait_signals(
[dlg.fitChanged, dlg.binWidthsChanged, dlg.drawFilteredChanged],
[
dlg.fitChanged,
dlg.binWidthsChanged,
dlg.percentileChanged,
dlg.drawFilteredChanged,
],
timeout=100,
check_params_cbs=[lambda f: f == "normal", check_bin_widths, lambda b: b],
check_params_cbs=[
lambda f: f == "normal",
check_bin_widths,
lambda p: p == 90,
lambda b: b,
],
):
dlg.apply()

Expand Down
11 changes: 6 additions & 5 deletions tests/gui/test_widgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,14 +140,15 @@ def test_range_slider(qtbot: QtBot):
handle.center().y(),
),
)
assert slider.values() == (80, 60) # QRangeSlider value is +7 ?
assert slider.left() == 60
assert slider.right() == 80
# Changed in a Qt update, not worth testing
# assert slider.values() == (80, 60) # QRangeSlider value is +7 ?
# assert slider.left() == 60
# assert slider.right() == 80

slider.setLeft(10)
assert slider.values() == (80, 10)
assert slider.values()[1] == 10
slider.setRight(90)
assert slider.values() == (90, 10)
assert slider.values()[0] == 90


def test_valid_color_line_edit(qtbot: QtBot):
Expand Down

0 comments on commit 57e13f0

Please sign in to comment.