summaryrefslogtreecommitdiffstats
path: root/tests/auto/qintvalidator
diff options
context:
space:
mode:
authorCharles Yin <charles.yin@nokia.com>2011-07-26 13:46:54 +1000
committerQt by Nokia <qt-info@nokia.com>2011-07-29 02:21:16 +0200
commita2c0390468b91a3f8a97a3bbabc2f9c98e0d105a (patch)
treea2f8206a8d42d18d21bc051fe1a6df1584c10dcc /tests/auto/qintvalidator
parentade2ef0a3e2fcf92a153f5e44f726ee603df12aa (diff)
Add notify signals for QIntvalidator, QDoubleValidator, QRegExpValidator
Task-number:QTBUG-19956 Change-Id: I5ab5e4494189ece5b0eb1f63e73e49cb2c4e9656 Reviewed-by:Michael Brasser Reviewed-on: http://codereview.qt.nokia.com/2147 Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com> Reviewed-by: Michael Brasser <michael.brasser@nokia.com>
Diffstat (limited to 'tests/auto/qintvalidator')
-rw-r--r--tests/auto/qintvalidator/tst_qintvalidator.cpp33
1 files changed, 32 insertions, 1 deletions
diff --git a/tests/auto/qintvalidator/tst_qintvalidator.cpp b/tests/auto/qintvalidator/tst_qintvalidator.cpp
index d53763566d..369e3254e8 100644
--- a/tests/auto/qintvalidator/tst_qintvalidator.cpp
+++ b/tests/auto/qintvalidator/tst_qintvalidator.cpp
@@ -51,6 +51,7 @@ private slots:
void validate();
void validateArabic();
void validateFrench();
+ void notifySignals();
};
Q_DECLARE_METATYPE(QValidator::State);
@@ -189,7 +190,6 @@ void tst_QIntValidator::validateFrench()
QIntValidator validator(-2000, 2000, 0);
validator.setLocale(QLocale::French);
int i;
-
QString s = QLatin1String("1 ");
QCOMPARE(validator.validate(s, i), QValidator::Acceptable);
validator.fixup(s);
@@ -220,5 +220,36 @@ void tst_QIntValidator::validate()
QCOMPARE((int)iv.validate(value, dummy), (int)state);
}
+void tst_QIntValidator::notifySignals()
+{
+ QIntValidator iv(0, 10, 0);
+ QSignalSpy topSpy(&iv, SIGNAL(topChanged(int)));
+ QSignalSpy bottomSpy(&iv, SIGNAL(bottomChanged(int)));
+ iv.setTop(9);
+ QCOMPARE(topSpy.count(), 1);
+ QVERIFY(iv.top() == 9);
+ iv.setBottom(1);
+ QCOMPARE(bottomSpy.count(), 1);
+ QVERIFY(iv.bottom() == 1);
+
+ iv.setRange(1, 8);
+ QCOMPARE(topSpy.count(), 2);
+ QCOMPARE(bottomSpy.count(), 1);
+ QVERIFY(iv.top() == 8);
+ QVERIFY(iv.bottom() == 1);
+
+ iv.setRange(2, 8);
+ QCOMPARE(topSpy.count(), 2);
+ QCOMPARE(bottomSpy.count(), 2);
+ QVERIFY(iv.top() == 8);
+ QVERIFY(iv.bottom() == 2);
+
+ iv.setRange(3, 7);
+ QCOMPARE(topSpy.count(), 3);
+ QCOMPARE(bottomSpy.count(), 3);
+ QVERIFY(iv.top() == 7);
+ QVERIFY(iv.bottom() == 3);
+}
+
QTEST_MAIN(tst_QIntValidator)
#include "tst_qintvalidator.moc"