summaryrefslogtreecommitdiffstats
path: root/tests/auto/widgets/widgets
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/widgets/widgets')
-rw-r--r--tests/auto/widgets/widgets/qlineedit/tst_qlineedit.cpp51
-rw-r--r--tests/auto/widgets/widgets/qscrollbar/tst_qscrollbar.cpp40
2 files changed, 77 insertions, 14 deletions
diff --git a/tests/auto/widgets/widgets/qlineedit/tst_qlineedit.cpp b/tests/auto/widgets/widgets/qlineedit/tst_qlineedit.cpp
index bf4d1f2ebd..fec79326c8 100644
--- a/tests/auto/widgets/widgets/qlineedit/tst_qlineedit.cpp
+++ b/tests/auto/widgets/widgets/qlineedit/tst_qlineedit.cpp
@@ -2512,6 +2512,7 @@ void tst_QLineEdit::setValidator_QIntValidator_data()
QTest::addColumn<QString>("expectedText");
QTest::addColumn<bool>("useKeys");
QTest::addColumn<bool>("is_valid");
+ QTest::addColumn<uint>("echoMode");
for (int i=0; i<2; i++) {
bool useKeys = false;
@@ -2528,7 +2529,8 @@ void tst_QLineEdit::setValidator_QIntValidator_data()
<< QString("1")
<< QString("1")
<< bool(useKeys)
- << bool(true);
+ << bool(true)
+ << uint(QLineEdit::Normal);
QTest::newRow(QString(inputMode + "range [3,7] valid '3'").toLatin1())
<< 3
@@ -2536,7 +2538,8 @@ void tst_QLineEdit::setValidator_QIntValidator_data()
<< QString("3")
<< QString("3")
<< bool(useKeys)
- << bool(true);
+ << bool(true)
+ << uint(QLineEdit::Normal);
QTest::newRow(QString(inputMode + "range [3,7] valid '7'").toLatin1())
<< 3
@@ -2544,7 +2547,8 @@ void tst_QLineEdit::setValidator_QIntValidator_data()
<< QString("7")
<< QString("7")
<< bool(useKeys)
- << bool(true);
+ << bool(true)
+ << uint(QLineEdit::Normal);
QTest::newRow(QString(inputMode + "range [0,100] valid '9'").toLatin1())
<< 0
@@ -2552,7 +2556,8 @@ void tst_QLineEdit::setValidator_QIntValidator_data()
<< QString("9")
<< QString("9")
<< bool(useKeys)
- << bool(true);
+ << bool(true)
+ << uint(QLineEdit::Normal);
QTest::newRow(QString(inputMode + "range [0,100] valid '12'").toLatin1())
<< 0
@@ -2560,7 +2565,8 @@ void tst_QLineEdit::setValidator_QIntValidator_data()
<< QString("12")
<< QString("12")
<< bool(useKeys)
- << bool(true);
+ << bool(true)
+ << uint(QLineEdit::Normal);
QTest::newRow(QString(inputMode + "range [-100,100] valid '-12'").toLatin1())
<< -100
@@ -2568,7 +2574,8 @@ void tst_QLineEdit::setValidator_QIntValidator_data()
<< QString("-12")
<< QString("-12")
<< bool(useKeys)
- << bool(true);
+ << bool(true)
+ << uint(QLineEdit::Normal);
// invalid data
// characters not allowed in QIntValidator
@@ -2578,7 +2585,8 @@ void tst_QLineEdit::setValidator_QIntValidator_data()
<< QString("a")
<< QString("")
<< bool(useKeys)
- << bool(false);
+ << bool(false)
+ << uint(QLineEdit::Normal);
QTest::newRow(QString(inputMode + "range [0,9] inv 'A'").toLatin1())
<< 0
@@ -2586,7 +2594,8 @@ void tst_QLineEdit::setValidator_QIntValidator_data()
<< QString("A")
<< QString("")
<< bool(useKeys)
- << bool(false);
+ << bool(false)
+ << uint(QLineEdit::Normal);
// minus sign only allowed with a range on the negative side
QTest::newRow(QString(inputMode + "range [0,100] inv '-'").toLatin1())
<< 0
@@ -2594,36 +2603,48 @@ void tst_QLineEdit::setValidator_QIntValidator_data()
<< QString("-")
<< QString("")
<< bool(useKeys)
- << bool(false);
+ << bool(false)
+ << uint(QLineEdit::Normal);
QTest::newRow(QString(inputMode + "range [0,100] int '153'").toLatin1())
<< 0
<< 100
<< QString("153")
<< QString(useKeys ? "15" : "")
<< bool(useKeys)
- << bool(useKeys ? true : false);
+ << bool(useKeys ? true : false)
+ << uint(QLineEdit::Normal);
QTest::newRow(QString(inputMode + "range [-100,100] int '-153'").toLatin1())
<< -100
<< 100
<< QString("-153")
<< QString(useKeys ? "-15" : "")
<< bool(useKeys)
- << bool(useKeys ? true : false);
+ << bool(useKeys ? true : false)
+ << uint(QLineEdit::Normal);
QTest::newRow(QString(inputMode + "range [3,7] int '2'").toLatin1())
<< 3
<< 7
<< QString("2")
<< QString("2")
<< bool(useKeys)
- << bool(false);
-
+ << bool(false)
+ << uint(QLineEdit::Normal);
QTest::newRow(QString(inputMode + "range [3,7] int '8'").toLatin1())
<< 3
<< 7
<< QString("8")
<< QString("")
<< bool(useKeys)
- << bool(false);
+ << bool(false)
+ << uint(QLineEdit::Normal);
+ QTest::newRow(QString(inputMode + "range [0,99] inv 'a-a'").toLatin1())
+ << 0
+ << 99
+ << QString("19a")
+ << QString(useKeys ? "19" : "")
+ << bool(useKeys)
+ << bool(useKeys ? true : false)
+ << uint(QLineEdit::Password);
}
}
@@ -2635,9 +2656,11 @@ void tst_QLineEdit::setValidator_QIntValidator()
QFETCH(QString, expectedText);
QFETCH(bool, useKeys);
QFETCH(bool, is_valid);
+ QFETCH(uint, echoMode);
QIntValidator intValidator(mini, maxi, 0);
QLineEdit *testWidget = ensureTestWidget();
+ testWidget->setEchoMode((QLineEdit::EchoMode)echoMode);
testWidget->setValidator(&intValidator);
QVERIFY(testWidget->text().isEmpty());
//qDebug("1 input: '" + input + "' Exp: '" + expectedText + "'");
diff --git a/tests/auto/widgets/widgets/qscrollbar/tst_qscrollbar.cpp b/tests/auto/widgets/widgets/qscrollbar/tst_qscrollbar.cpp
index cb0383c398..008d3b2435 100644
--- a/tests/auto/widgets/widgets/qscrollbar/tst_qscrollbar.cpp
+++ b/tests/auto/widgets/widgets/qscrollbar/tst_qscrollbar.cpp
@@ -58,6 +58,7 @@ private slots:
#ifndef QT_NO_WHEELEVENT
void QTBUG_27308();
#endif
+ void QTBUG_42871();
};
class SingleStepTestScrollBar : public QScrollBar {
@@ -169,5 +170,44 @@ void tst_QScrollBar::QTBUG_27308()
}
#endif
+class QTBUG_42871_Handler : public QObject {
+ Q_OBJECT
+public:
+ int updatesCount;
+ QTBUG_42871_Handler() : QObject(), updatesCount(0) {}
+public slots:
+ void valueUpdated(int) { ++updatesCount; QTest::qSleep(600); }
+};
+
+void tst_QScrollBar::QTBUG_42871()
+{
+ QTBUG_42871_Handler myHandler;
+ QScrollBar scrollBarWidget(Qt::Vertical);
+ bool connection = connect(&scrollBarWidget, SIGNAL(valueChanged(int)), &myHandler, SLOT(valueUpdated(int)));
+ QVERIFY(connection);
+ scrollBarWidget.resize(100, scrollBarWidget.height());
+ centerOnScreen(&scrollBarWidget);
+ scrollBarWidget.show();
+ QTest::qWaitForWindowExposed(&scrollBarWidget);
+ QSignalSpy spy(&scrollBarWidget, SIGNAL(actionTriggered(int)));
+ QVERIFY(spy.isValid());
+ QCOMPARE(myHandler.updatesCount, 0);
+ QCOMPARE(spy.count(), 0);
+
+ // Simulate a mouse click on the "scroll down button".
+ const QPoint pressPoint(scrollBarWidget.width() / 2, scrollBarWidget.height() - 10);
+ const QPoint globalPressPoint = scrollBarWidget.mapToGlobal(pressPoint);
+ QMouseEvent mousePressEvent(QEvent::MouseButtonPress, pressPoint, globalPressPoint,
+ Qt::LeftButton, Qt::LeftButton, 0);
+ QApplication::sendEvent(&scrollBarWidget, &mousePressEvent);
+ QTest::qWait(1);
+ QMouseEvent mouseReleaseEvent(QEvent::MouseButtonRelease, pressPoint, globalPressPoint,
+ Qt::LeftButton, Qt::LeftButton, 0);
+ QApplication::sendEvent(&scrollBarWidget, &mouseReleaseEvent);
+ // Check that the action was triggered once.
+ QCOMPARE(myHandler.updatesCount, 1);
+ QCOMPARE(spy.count(), 1);
+}
+
QTEST_MAIN(tst_QScrollBar)
#include "tst_qscrollbar.moc"