summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorAndy Shaw <andy.shaw@digia.com>2013-09-17 20:07:37 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-10-15 13:01:59 +0200
commit89c01c3242079f12421da234f2a21abfee4b71e1 (patch)
treeacd5be145277b75689ed9cda2aa757900000b6b4 /tests
parent4684f2179be7182d32d50067e1ca0fa87619792e (diff)
Only emit messageChanged() if the message has actually changed
This fixes QStatusBar so it is back to the original behavior of only emitting the signal when the message has changed. The intention of the code that caused this to break in the first place is kept intact. Change-Id: I2f57c2abec01246ed924626ad954ac9ff9889855 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@digia.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/widgets/widgets/qstatusbar/tst_qstatusbar.cpp27
1 files changed, 27 insertions, 0 deletions
diff --git a/tests/auto/widgets/widgets/qstatusbar/tst_qstatusbar.cpp b/tests/auto/widgets/widgets/qstatusbar/tst_qstatusbar.cpp
index 3bdf583153..a301d51c4c 100644
--- a/tests/auto/widgets/widgets/qstatusbar/tst_qstatusbar.cpp
+++ b/tests/auto/widgets/widgets/qstatusbar/tst_qstatusbar.cpp
@@ -74,6 +74,7 @@ private slots:
void task194017_hiddenWidget();
void QTBUG4334_hiddenOnMaximizedWindow();
void QTBUG25492_msgtimeout();
+ void messageChangedSignal();
private:
QStatusBar *testWidget;
@@ -95,6 +96,8 @@ void tst_QStatusBar::init()
QWidget *item1 = new QWidget(testWidget);
testWidget->addWidget(item1);
+ // currentMessage needs to be null as the code relies on this
+ currentMessage = QString();
}
void tst_QStatusBar::cleanup()
@@ -316,6 +319,30 @@ void tst_QStatusBar::QTBUG25492_msgtimeout()
QCOMPARE(testWidget->currentMessage(), currentMessage);
}
+void tst_QStatusBar::messageChangedSignal()
+{
+ QVERIFY(testWidget->currentMessage().isNull());
+ QVERIFY(currentMessage.isNull());
+ testWidget->show();
+
+ QSignalSpy spy(testWidget, SIGNAL(messageChanged(QString)));
+ testWidget->showMessage("Ready", 0);
+ QCOMPARE(testWidget->currentMessage(), QString("Ready"));
+ QCOMPARE(testWidget->currentMessage(), currentMessage);
+ QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.takeFirst().at(0).toString(), currentMessage);
+ testWidget->clearMessage();
+ QCOMPARE(testWidget->currentMessage(), QString());
+ QCOMPARE(testWidget->currentMessage(), currentMessage);
+ QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.takeFirst().at(0).toString(), currentMessage);
+ testWidget->showMessage("Ready", 0);
+ testWidget->showMessage("Ready", 0);
+ QCOMPARE(testWidget->currentMessage(), QString("Ready"));
+ QCOMPARE(testWidget->currentMessage(), currentMessage);
+ QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.takeFirst().at(0).toString(), currentMessage);
+}
QTEST_MAIN(tst_QStatusBar)
#include "tst_qstatusbar.moc"