diff options
author | Stian Sandvik Thomassen <stian.thomassen@nokia.com> | 2009-06-18 04:53:03 (GMT) |
---|---|---|
committer | Stian Sandvik Thomassen <stian.thomassen@nokia.com> | 2009-06-18 04:53:03 (GMT) |
commit | 75e8aaae5e8a0cbaa62fd4cd2a8235544f974a73 (patch) | |
tree | 717950251fdea94664532ed1a8304544068ddd53 /tests | |
parent | 688454f4fa508e5262786070a149f604156d5197 (diff) | |
download | Qt-75e8aaae5e8a0cbaa62fd4cd2a8235544f974a73.zip Qt-75e8aaae5e8a0cbaa62fd4cd2a8235544f974a73.tar.gz Qt-75e8aaae5e8a0cbaa62fd4cd2a8235544f974a73.tar.bz2 |
Made QInputDialog::getText() return null QString when rejected
This reverts a behavior change introduced with Qt 4.5.0 where
QInputDialog::getText() returned the line edit's text when the dialog
was rejected.
However, the behavior since Qt 4.0 has been to return a null QString
when the dialog is rejected.
Task-number: 256299
Reviewed-by: Andy Shaw
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/qinputdialog/tst_qinputdialog.cpp | 25 |
1 files changed, 23 insertions, 2 deletions
diff --git a/tests/auto/qinputdialog/tst_qinputdialog.cpp b/tests/auto/qinputdialog/tst_qinputdialog.cpp index a658aeb..7e4b828 100644 --- a/tests/auto/qinputdialog/tst_qinputdialog.cpp +++ b/tests/auto/qinputdialog/tst_qinputdialog.cpp @@ -56,6 +56,7 @@ class tst_QInputDialog : public QObject { Q_OBJECT QWidget *parent; + QDialog::DialogCode doneCode; void (*testFunc)(QInputDialog *); static void testFuncGetInteger(QInputDialog *dialog); static void testFuncGetDouble(QInputDialog *dialog); @@ -72,6 +73,7 @@ private slots: void getText(); void getItem_data(); void getItem(); + void task256299_getTextReturnNullStringOnRejected(); }; QString stripFraction(const QString &s) @@ -245,8 +247,9 @@ void tst_QInputDialog::timerEvent(QTimerEvent *event) killTimer(event->timerId()); QInputDialog *dialog = qFindChild<QInputDialog *>(parent); Q_ASSERT(dialog); - testFunc(dialog); - dialog->done(QDialog::Accepted); // cause static function call to return + if (testFunc) + testFunc(dialog); + dialog->done(doneCode); // cause static function call to return } void tst_QInputDialog::getInteger_data() @@ -266,6 +269,7 @@ void tst_QInputDialog::getInteger() QFETCH(int, max); Q_ASSERT(min < max); parent = new QWidget; + doneCode = QDialog::Accepted; testFunc = &tst_QInputDialog::testFuncGetInteger; startTimer(0); bool ok = false; @@ -305,6 +309,7 @@ void tst_QInputDialog::getDouble() QFETCH(int, decimals); Q_ASSERT(min < max && decimals >= 0 && decimals <= 13); parent = new QWidget; + doneCode = QDialog::Accepted; testFunc = &tst_QInputDialog::testFuncGetDouble; startTimer(0); bool ok = false; @@ -322,6 +327,7 @@ void tst_QInputDialog::getDouble() void tst_QInputDialog::task255502getDouble() { parent = new QWidget; + doneCode = QDialog::Accepted; testFunc = &tst_QInputDialog::testFuncGetDouble; startTimer(0); bool ok = false; @@ -347,6 +353,7 @@ void tst_QInputDialog::getText() { QFETCH(QString, text); parent = new QWidget; + doneCode = QDialog::Accepted; testFunc = &tst_QInputDialog::testFuncGetText; startTimer(0); bool ok = false; @@ -356,6 +363,19 @@ void tst_QInputDialog::getText() delete parent; } +void tst_QInputDialog::task256299_getTextReturnNullStringOnRejected() +{ + parent = new QWidget; + doneCode = QDialog::Rejected; + testFunc = 0; + startTimer(0); + bool ok = true; + const QString result = QInputDialog::getText(parent, "", "", QLineEdit::Normal, "foobar", &ok); + QVERIFY(!ok); + QVERIFY(result.isNull()); + delete parent; +} + void tst_QInputDialog::getItem_data() { QTest::addColumn<QStringList>("items"); @@ -373,6 +393,7 @@ void tst_QInputDialog::getItem() QFETCH(QStringList, items); QFETCH(bool, editable); parent = new QWidget; + doneCode = QDialog::Accepted; testFunc = &tst_QInputDialog::testFuncGetItem; startTimer(0); bool ok = false; |