MCPcopy Create free account
hub / github.com/KDE/labplot / numberSpinBoxFeedback2

Method numberSpinBoxFeedback2

tests/commonfrontend/widgets/SpinBoxTest.cpp:954–973  ·  view source on GitHub ↗

set value called directly when valueChanged() is called. This can happen if the other side directly sets another value, because the received value is invalid.

Source from the content-addressed store, hash-verified

952// set value called directly when valueChanged() is called. This can happen if the other side directly sets another
953// value, because the received value is invalid.
954void SpinBoxTest::numberSpinBoxFeedback2() {
955 NumberSpinBox sb(5);
956 sb.setFeedback(true);
957
958 int valueChangedCounter = 0;
959 double lastValue = NAN;
960 connect(&sb, QOverload<double>::of(&NumberSpinBox::valueChanged), [&sb, &valueChangedCounter, &lastValue](double value) {
961 valueChangedCounter++;
962 lastValue = value; // value is 6
963 QVERIFY(5 != value);
964 sb.setValue(5); // Important other value
965 });
966
967 sb.lineEdit()->setCursorPosition(1);
968 QKeyEvent event(QKeyEvent::Type::KeyPress, Qt::Key_Up, Qt::KeyboardModifier::NoModifier);
969 sb.keyPressEvent(&event);
970
971 QCOMPARE(valueChangedCounter, 1);
972 QCOMPARE(sb.toolTip(), i18n("Invalid value entered. Valid value: %1", 5));
973}
974
975void SpinBoxTest::numberSpinBoxFeedbackCursorPosition() {
976 NumberSpinBox sb(5.11);

Callers

nothing calls this directly

Calls 6

setFeedbackMethod · 0.80
setCursorPositionMethod · 0.80
lineEditMethod · 0.80
setValueMethod · 0.45
keyPressEventMethod · 0.45
toolTipMethod · 0.45

Tested by

no test coverage detected