def test_change_floatslider_range(gslider: QRangeSlider, qtbot): with qtbot.waitSignals([gslider.rangeChanged, gslider.valueChanged]): gslider.setMinimum(30) assert gslider.value()[0] == 30 == gslider.minimum() assert gslider.maximum() == 99 with qtbot.waitSignal(gslider.rangeChanged): gslider.setMaximum(70) assert gslider.value()[0] == 30 == gslider.minimum() assert gslider.value()[1] == 70 == gslider.maximum() with qtbot.waitSignals([gslider.rangeChanged, gslider.valueChanged]): gslider.setRange(40, 60) assert gslider.value()[0] == 40 == gslider.minimum() assert gslider.maximum() == 60 with qtbot.waitSignal(gslider.valueChanged): gslider.setValue([40, 50]) assert gslider.value()[0] == 40 == gslider.minimum() assert gslider.value()[1] == 50 with qtbot.waitSignals([gslider.rangeChanged, gslider.valueChanged]): gslider.setMaximum(45) assert gslider.value()[0] == 40 == gslider.minimum() assert gslider.value()[1] == 45 == gslider.maximum()
def test_float_values(gslider: QRangeSlider, qtbot): with qtbot.waitSignal(gslider.rangeChanged): gslider.setRange(0.1, 0.9) assert gslider.minimum() == 0.1 assert gslider.maximum() == 0.9 with qtbot.waitSignal(gslider.valueChanged): gslider.setValue([0.4, 0.6]) assert gslider.value() == (0.4, 0.6) with qtbot.waitSignal(gslider.valueChanged): gslider.setValue([0, 1.9]) assert gslider.value()[0] == 0.1 == gslider.minimum() assert gslider.value()[1] == 0.9 == gslider.maximum()
def test_range(qtbot, orientation): rs = QRangeSlider(getattr(Qt, orientation)) qtbot.addWidget(rs) rs.setValue([10, 20]) assert rs.value() == (10, 20) rs.setRange(15, 20) assert rs.value() == (15, 20) assert rs.minimum() == 15 assert rs.maximum() == 20