Verify expected warnings in QSettings autotest.
authorJason McDonald <jason.mcdonald@nokia.com>
Tue, 13 Mar 2012 06:36:38 +0000 (16:36 +1000)
committerQt by Nokia <qt-info@nokia.com>
Thu, 15 Mar 2012 05:00:52 +0000 (06:00 +0100)
Use QTest::ignoreMessage() so that the warnings don't appear in the test
output and so that the test will fail if the warnings are not produced.

Change-Id: I418d78819fc9dbfd7da2a8b6c0a1ebfa967347e2
Reviewed-by: Rohan McGovern <rohan.mcgovern@nokia.com>
tests/auto/corelib/io/qsettings/tst_qsettings.cpp

index b9ade8e..d294eec 100644 (file)
@@ -880,8 +880,10 @@ void tst_QSettings::beginGroup()
     QCOMPARE(settings1.value("geometry").toInt(), 777);
 
     // endGroup() should do nothing if group() is empty
-    for (int i = 0; i < 10; ++i)
+    for (int i = 0; i < 10; ++i) {
+        QTest::ignoreMessage(QtWarningMsg, "QSettings::endGroup: No matching beginGroup()");
         settings2.endGroup();
+    }
     QCOMPARE(settings2.value("geometry").toInt(), 5);
     QCOMPARE(settings2.value("alpha/geometry").toInt(), 66);
     QCOMPARE(settings2.value("alpha/beta/geometry").toInt(), 777);
@@ -2167,6 +2169,16 @@ void tst_QSettings::testArrays()
         endArray() and vice versa. This is not documented, but this
         is the behavior that we have chosen.
     */
+    QTest::ignoreMessage(QtWarningMsg, "QSettings::setArrayIndex: Missing beginArray()");
+    QTest::ignoreMessage(QtWarningMsg, "QSettings::setArrayIndex: Missing beginArray()");
+    QTest::ignoreMessage(QtWarningMsg, "QSettings::setArrayIndex: Missing beginArray()");
+    QTest::ignoreMessage(QtWarningMsg, "QSettings::setArrayIndex: Missing beginArray()");
+    QTest::ignoreMessage(QtWarningMsg, "QSettings::setArrayIndex: Missing beginArray()");
+    QTest::ignoreMessage(QtWarningMsg, "QSettings::endArray: Expected endGroup() instead");
+    QTest::ignoreMessage(QtWarningMsg, "QSettings::endGroup: Expected endArray() instead");
+    QTest::ignoreMessage(QtWarningMsg, "QSettings::endArray: Expected endGroup() instead");
+    QTest::ignoreMessage(QtWarningMsg, "QSettings::endGroup: No matching beginGroup()");
+
     QSettings settings1(format, QSettings::UserScope, "software.org", "KillerAPP");
     settings1.clear();
     settings1.beginGroup("/alpha");
@@ -2217,7 +2229,6 @@ void tst_QSettings::testArrays()
     QCOMPARE(settings1.group(), QString());
     settings1.endGroup();
     QCOMPARE(settings1.group(), QString());
-
     /*
         Now, let's make sure that things work well if an array
         is spread across multiple files.