summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/qchar/tst_qchar.cpp13
-rw-r--r--tests/auto/qnetworksession/test/tst_qnetworksession.cpp63
-rw-r--r--tests/auto/qtextcodec/tst_qtextcodec.cpp16
-rw-r--r--tests/auto/qtimer/tst_qtimer.cpp12
-rw-r--r--tests/auto/qurl/tst_qurl.cpp9
-rw-r--r--tests/auto/qxmlstream/XML-Test-Suite/xmlconf/ibm/valid/P02/ibm02v01.xml2
-rw-r--r--tests/auto/qxmlstream/XML-Test-Suite/xmlconf/ibm/valid/P66/ibm66v01.xml2
-rw-r--r--tests/auto/qxmlstream/XML-Test-Suite/xmlconf/ibm/valid/P66/out/ibm66v01.xml2
-rw-r--r--tests/auto/qxmlstream/XML-Test-Suite/xmlconf/xmltest/valid/sa/089.xml2
-rw-r--r--tests/auto/qxmlstream/XML-Test-Suite/xmlconf/xmltest/valid/sa/out/089.xml2
-rw-r--r--tests/auto/utf8/tst_utf8.cpp85
-rw-r--r--tests/benchmarks/corelib/kernel/qtimer_vs_qmetaobject/qtimer_vs_qmetaobject.pro11
-rw-r--r--tests/benchmarks/corelib/kernel/qtimer_vs_qmetaobject/tst_qtimer_vs_qmetaobject.cpp96
13 files changed, 290 insertions, 25 deletions
diff --git a/tests/auto/qchar/tst_qchar.cpp b/tests/auto/qchar/tst_qchar.cpp
index 547147c..6227c2e 100644
--- a/tests/auto/qchar/tst_qchar.cpp
+++ b/tests/auto/qchar/tst_qchar.cpp
@@ -72,6 +72,7 @@ private slots:
void toLower();
void toTitle();
void toCaseFolded();
+ void isPrint();
void isUpper();
void isLower();
void category();
@@ -218,6 +219,12 @@ void tst_QChar::toCaseFolded()
QVERIFY(QChar::toCaseFolded((ushort)0xb5) == 0x3bc);
}
+void tst_QChar::isPrint()
+{
+ QVERIFY(QChar('A').isPrint());
+ QVERIFY(!QChar(0x1aff).isPrint()); // General_Gategory =Cn
+}
+
void tst_QChar::isUpper()
{
QVERIFY(QChar('A').isUpper());
@@ -259,6 +266,12 @@ void tst_QChar::category()
QVERIFY(QChar::category(0xd900u) == QChar::Other_Surrogate);
QVERIFY(QChar::category(0xdc00u) == QChar::Other_Surrogate);
QVERIFY(QChar::category(0xdc01u) == QChar::Other_Surrogate);
+
+ QVERIFY(QChar::category((uint)0x10fffdu) == QChar::Other_PrivateUse);
+ QVERIFY(QChar::category((uint)0x110000u) == QChar::NoCategory);
+
+ QVERIFY(QChar::category((uint)0x1aff) == QChar::Other_NotAssigned);
+ QVERIFY(QChar::category((uint)0x10ffffu) == QChar::Other_NotAssigned);
}
void tst_QChar::direction()
diff --git a/tests/auto/qnetworksession/test/tst_qnetworksession.cpp b/tests/auto/qnetworksession/test/tst_qnetworksession.cpp
index 58b1a48..4b56f77 100644
--- a/tests/auto/qnetworksession/test/tst_qnetworksession.cpp
+++ b/tests/auto/qnetworksession/test/tst_qnetworksession.cpp
@@ -85,6 +85,9 @@ private slots:
void sessionOpenCloseStop_data();
void sessionOpenCloseStop();
+ void sessionAutoClose_data();
+ void sessionAutoClose();
+
private:
QNetworkConfigurationManager manager;
@@ -1202,7 +1205,67 @@ bool closeSession(QNetworkSession *session, bool lastSessionOnConfiguration) {
return true;
}
+void tst_QNetworkSession::sessionAutoClose_data()
+{
+ QTest::addColumn<QNetworkConfiguration>("configuration");
+
+ bool testData = false;
+ foreach (const QNetworkConfiguration &config,
+ manager.allConfigurations(QNetworkConfiguration::Discovered)) {
+ QNetworkSession session(config);
+ if (!session.sessionProperty(QLatin1String("AutoCloseSessionTimeout")).isValid())
+ continue;
+
+ testData = true;
+
+ const QString name = config.name().isEmpty() ? QString("<Hidden>") : config.name();
+ QTest::newRow(name.toLocal8Bit().constData()) << config;
+ }
+
+ if (!testData)
+ QSKIP("No applicable configurations to test", SkipAll);
+}
+
+void tst_QNetworkSession::sessionAutoClose()
+{
+ QFETCH(QNetworkConfiguration, configuration);
+
+ QNetworkSession session(configuration);
+
+ QVERIFY(session.configuration() == configuration);
+ QVariant autoCloseSession = session.sessionProperty(QLatin1String("AutoCloseSessionTimeout"));
+
+ QVERIFY(autoCloseSession.isValid());
+
+ // property defaults to false
+ QCOMPARE(autoCloseSession.toInt(), -1);
+
+ QSignalSpy closeSpy(&session, SIGNAL(closed()));
+
+ session.open();
+ session.waitForOpened();
+
+ if (!session.isOpen())
+ QSKIP("Session not open", SkipSingle);
+
+ // set session to auto close at next polling interval.
+ session.setSessionProperty(QLatin1String("AutoCloseSessionTimeout"), 0);
+
+ QTRY_VERIFY(!closeSpy.isEmpty());
+
+ QCOMPARE(session.state(), QNetworkSession::Connected);
+
+ QVERIFY(!session.isOpen());
+
+ QVERIFY(session.configuration() == configuration);
+
+ autoCloseSession = session.sessionProperty(QLatin1String("AutoCloseSessionTimeout"));
+
+ QVERIFY(autoCloseSession.isValid());
+
+ QCOMPARE(autoCloseSession.toInt(), -1);
+}
QTEST_MAIN(tst_QNetworkSession)
diff --git a/tests/auto/qtextcodec/tst_qtextcodec.cpp b/tests/auto/qtextcodec/tst_qtextcodec.cpp
index 07fd480..1c64ade 100644
--- a/tests/auto/qtextcodec/tst_qtextcodec.cpp
+++ b/tests/auto/qtextcodec/tst_qtextcodec.cpp
@@ -431,9 +431,12 @@ void tst_QTextCodec::flagCodepointFFFF() const
Q_ASSERT(codec);
const QByteArray asDecoded(codec->fromUnicode(input));
+ QCOMPARE(asDecoded, QByteArray("?"));
+
+ QByteArray ffff("\357\277\277");
QTextCodec::ConverterState state(QTextCodec::ConvertInvalidToNull);
- QVERIFY(codec->toUnicode(asDecoded.constData(), asDecoded.length(), &state) == QChar(0));
- QVERIFY(codec->toUnicode(asDecoded) == QChar(0xfffd));
+ QVERIFY(codec->toUnicode(ffff.constData(), ffff.length(), &state) == QChar(0));
+ QVERIFY(codec->toUnicode(ffff) == QChar(0xfffd));
}
void tst_QTextCodec::flagF7808080() const
@@ -494,12 +497,11 @@ void tst_QTextCodec::flagEFBFBF() const
/* When 0xEFBFBF is preceeded by what seems to be an arbitrary character,
* QTextCodec fails to flag it. */
{
- QEXPECT_FAIL("", "This is a bug and needs to be fixed.", Continue);
QByteArray start("B");
start.append(invalidInput);
QTextCodec::ConverterState state(QTextCodec::ConvertInvalidToNull);
- QVERIFY(codec->toUnicode(start.constData(), start.length(), &state) == QChar(0));
+ QVERIFY(codec->toUnicode(start.constData(), start.length(), &state) == QString::fromLatin1("B\0", 2));
}
}
@@ -744,15 +746,15 @@ void tst_QTextCodec::utf8Codec_data()
str = QChar(QChar::ReplacementCharacter);
QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 2.3.3") << utf8 << str << -1;
- // 2.3.4 U+0010FFFF
+ // 2.3.4 U+0010FFFD
utf8.clear();
utf8 += char(0xf4);
utf8 += char(0x8f);
utf8 += char(0xbf);
- utf8 += char(0xbf);
+ utf8 += char(0xbd);
str.clear();
str += QChar(0xdbff);
- str += QChar(0xdfff);
+ str += QChar(0xdffd);
QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 2.3.4") << utf8 << str << -1;
// 2.3.5 U+00110000
diff --git a/tests/auto/qtimer/tst_qtimer.cpp b/tests/auto/qtimer/tst_qtimer.cpp
index cc97e4e..a0408ef 100644
--- a/tests/auto/qtimer/tst_qtimer.cpp
+++ b/tests/auto/qtimer/tst_qtimer.cpp
@@ -85,6 +85,7 @@ private slots:
void timerFiresOnlyOncePerProcessEvents();
void timerIdPersistsAfterThreadExit();
void cancelLongTimer();
+ void singleShotStaticFunctionZeroTimeout();
};
class TimerHelper : public QObject
@@ -611,5 +612,16 @@ void tst_QTimer::cancelLongTimer()
QVERIFY(!timer.isActive());
}
+void tst_QTimer::singleShotStaticFunctionZeroTimeout()
+{
+ TimerHelper helper;
+
+ QTimer::singleShot(0, &helper, SLOT(timeout()));
+ QTest::qWait(500);
+ QCOMPARE(helper.count, 1);
+ QTest::qWait(500);
+ QCOMPARE(helper.count, 1);
+}
+
QTEST_MAIN(tst_QTimer)
#include "tst_qtimer.moc"
diff --git a/tests/auto/qurl/tst_qurl.cpp b/tests/auto/qurl/tst_qurl.cpp
index 83109b5..b7cbdb8 100644
--- a/tests/auto/qurl/tst_qurl.cpp
+++ b/tests/auto/qurl/tst_qurl.cpp
@@ -193,6 +193,7 @@ private slots:
void fromUserInput();
void task_199967();
void task_240612();
+ void taskQTBUG_6962();
#ifdef QT3_SUPPORT
void dirPath();
@@ -3860,5 +3861,13 @@ void tst_QUrl::resolvedWithAbsoluteSchemes_data() const
<< QUrl::fromEncoded("http://www.foo.com:8080/newfile.html");
}
+void tst_QUrl::taskQTBUG_6962()
+{
+ //bug 6962: empty authority ignored by setAuthority
+ QUrl url("http://example.com/something");
+ url.setAuthority(QString());
+ QCOMPARE(url.authority(), QString());
+}
+
QTEST_MAIN(tst_QUrl)
#include "tst_qurl.moc"
diff --git a/tests/auto/qxmlstream/XML-Test-Suite/xmlconf/ibm/valid/P02/ibm02v01.xml b/tests/auto/qxmlstream/XML-Test-Suite/xmlconf/ibm/valid/P02/ibm02v01.xml
index 60479f4..2363b97 100644
--- a/tests/auto/qxmlstream/XML-Test-Suite/xmlconf/ibm/valid/P02/ibm02v01.xml
+++ b/tests/auto/qxmlstream/XML-Test-Suite/xmlconf/ibm/valid/P02/ibm02v01.xml
@@ -5,6 +5,6 @@
discrete legal characters for production 02. -->
<?NAME_09- _0A-
_0D-
-_20- _D7FF-퟿_6c0f-氏_E000-_FFFD-�_effe-_010000-𐀀_10FFFF-􏿿_08ffff-򏿿 This is a PI target ?>
+_20- _D7FF-퟿_6c0f-氏_E000-_FFFD-�_effd-_010000-𐀀_10FFFD-􏿽_08fffd-򏿽 This is a PI target ?>
]>
<book/>
diff --git a/tests/auto/qxmlstream/XML-Test-Suite/xmlconf/ibm/valid/P66/ibm66v01.xml b/tests/auto/qxmlstream/XML-Test-Suite/xmlconf/ibm/valid/P66/ibm66v01.xml
index 7ac675e..d7f7722 100644
--- a/tests/auto/qxmlstream/XML-Test-Suite/xmlconf/ibm/valid/P66/ibm66v01.xml
+++ b/tests/auto/qxmlstream/XML-Test-Suite/xmlconf/ibm/valid/P66/ibm66v01.xml
@@ -11,6 +11,6 @@ Test all valid Charater references for P66:
&#67; &#x43; &#x5f;
&#x20; &#xD7A3; &#xAC00;
&#xF900; &#xFFFD;
-&#x10000; &#x10FFFF;
+&#x10000; &#x10FFFD;
</root>
<!--* a valid test for P66 *-->
diff --git a/tests/auto/qxmlstream/XML-Test-Suite/xmlconf/ibm/valid/P66/out/ibm66v01.xml b/tests/auto/qxmlstream/XML-Test-Suite/xmlconf/ibm/valid/P66/out/ibm66v01.xml
index 1b04b6d..ed05e61 100644
--- a/tests/auto/qxmlstream/XML-Test-Suite/xmlconf/ibm/valid/P66/out/ibm66v01.xml
+++ b/tests/auto/qxmlstream/XML-Test-Suite/xmlconf/ibm/valid/P66/out/ibm66v01.xml
@@ -1 +1 @@
-<root>&#10;Test all valid Charater references for P66:&#10;&#9;&#9;&#9;&#10;&#10;&#10;&#10;&#10;&#10;&#13;&#10;« « Í Í ï ï&#10;C C _&#10; 힣 가&#10;豈 �&#10;𐀀 􏿿&#10;</root> \ No newline at end of file
+<root>&#10;Test all valid Charater references for P66:&#10;&#9;&#9;&#9;&#10;&#10;&#10;&#10;&#10;&#10;&#13;&#10;« « Í Í ï ï&#10;C C _&#10; 힣 가&#10;豈 �&#10;𐀀 􏿽&#10;</root> \ No newline at end of file
diff --git a/tests/auto/qxmlstream/XML-Test-Suite/xmlconf/xmltest/valid/sa/089.xml b/tests/auto/qxmlstream/XML-Test-Suite/xmlconf/xmltest/valid/sa/089.xml
index 2d80c8f..42ffcb6 100644
--- a/tests/auto/qxmlstream/XML-Test-Suite/xmlconf/xmltest/valid/sa/089.xml
+++ b/tests/auto/qxmlstream/XML-Test-Suite/xmlconf/xmltest/valid/sa/089.xml
@@ -1,5 +1,5 @@
<!DOCTYPE doc [
-<!ENTITY e "&#x10000;&#x10FFFD;&#x10FFFF;">
+<!ENTITY e "&#x10000;&#x10FFFD;">
<!ELEMENT doc (#PCDATA)>
]>
<doc>&e;</doc>
diff --git a/tests/auto/qxmlstream/XML-Test-Suite/xmlconf/xmltest/valid/sa/out/089.xml b/tests/auto/qxmlstream/XML-Test-Suite/xmlconf/xmltest/valid/sa/out/089.xml
index e01d86e..f5a0484 100644
--- a/tests/auto/qxmlstream/XML-Test-Suite/xmlconf/xmltest/valid/sa/out/089.xml
+++ b/tests/auto/qxmlstream/XML-Test-Suite/xmlconf/xmltest/valid/sa/out/089.xml
@@ -1 +1 @@
-<doc>𐀀􏿽􏿿</doc> \ No newline at end of file
+<doc>𐀀􏿽</doc> \ No newline at end of file
diff --git a/tests/auto/utf8/tst_utf8.cpp b/tests/auto/utf8/tst_utf8.cpp
index 1183b81..7bbbfab 100644
--- a/tests/auto/utf8/tst_utf8.cpp
+++ b/tests/auto/utf8/tst_utf8.cpp
@@ -73,6 +73,9 @@ private slots:
void invalidUtf8_data();
void invalidUtf8();
+
+ void nonCharacters_data();
+ void nonCharacters();
};
void tst_Utf8::initTestCase()
@@ -134,8 +137,8 @@ void tst_Utf8::roundTrip_data()
static const uint utf32_5[] = { 0x010203 };
QTest::newRow("utf8_5") << QByteArray(utf8_5) << QString::fromUcs4(utf32_5, 1);
- static const char utf8_6[] = "\364\217\277\277"; // U+10FFFF
- static const uint utf32_6[] = { 0x10FFFF };
+ static const char utf8_6[] = "\364\217\277\275"; // U+10FFFD
+ static const uint utf32_6[] = { 0x10FFFD };
QTest::newRow("utf8_6") << QByteArray(utf8_6) << QString::fromUcs4(utf32_6, 1);
static const char utf8_7[] = "abc\302\240\303\241\303\251\307\275 \342\202\254def";
@@ -144,10 +147,10 @@ void tst_Utf8::roundTrip_data()
' ', 0x20AC, 'd', 'e', 'f', 0 };
QTest::newRow("utf8_7") << QByteArray(utf8_7) << QString::fromUtf16(utf16_7);
- static const char utf8_8[] = "abc\302\240\303\241\303\251\307\275 \364\217\277\277 \342\202\254def";
+ static const char utf8_8[] = "abc\302\240\303\241\303\251\307\275 \364\217\277\275 \342\202\254def";
static const uint utf32_8[] = { 'a', 'b', 'c', 0x00A0,
0x00E1, 0x00E9, 0x01FD,
- ' ', 0x10FFFF, ' ',
+ ' ', 0x10FFFD, ' ',
0x20AC, 'd', 'e', 'f', 0 };
QTest::newRow("utf8_8") << QByteArray(utf8_8) << QString::fromUcs4(utf32_8);
}
@@ -214,14 +217,6 @@ void tst_Utf8::invalidUtf8_data()
QTest::newRow("4chars-2") << QByteArray("\xF0\x90\xC0\x80");
QTest::newRow("4chars-3") << QByteArray("\xF0\xC0\x80\x80");
- // U+FFFE and U+FFFF are non-characters and must not be present
- // U+FFFE: 1111 11 1111 11 1110
- // encoding: xxxz:1111 xz11:1111 xz11:1110
- QTest::newRow("fffe") << QByteArray("\xEF\xBF\xBE");
- // U+FFFF: 1111 11 1111 11 1111
- // encoding: xxxz:1111 xz11:1111 xz11:1111
- QTest::newRow("ffff") << QByteArray("\xEF\xBF\xBF");
-
// Surrogate pairs must now be present either
// U+D800: 1101 10 0000 00 0000
// encoding: xxxz:1101 xz10:0000 xz00:0000
@@ -302,7 +297,7 @@ void tst_Utf8::invalidUtf8()
QFETCH_GLOBAL(bool, useLocale);
QSharedPointer<QTextDecoder> decoder = QSharedPointer<QTextDecoder>(codec->makeDecoder());
- QString decoded = decoder->toUnicode(utf8);
+ decoder->toUnicode(utf8);
// Only enforce correctness on our UTF-8 decoder
// The system's UTF-8 codec is sometimes buggy
@@ -314,5 +309,69 @@ void tst_Utf8::invalidUtf8()
qWarning("System codec does not report failure when it should. Should report bug upstream.");
}
+void tst_Utf8::nonCharacters_data()
+{
+ QTest::addColumn<QByteArray>("utf8");
+ QTest::addColumn<QString>("utf16");
+
+ // Unicode has a couple of "non-characters" that one can use internally,
+ // but are not allowed to be used for text interchange.
+ //
+ // Those are the last two entries each Unicode Plane (U+FFFE, U+FFFF,
+ // U+1FFFE, U+1FFFF, etc.) as well as the entries between U+FDD0 and
+ // U+FDEF (inclusive)
+
+ // U+FDD0 through U+FDEF
+ for (int i = 0; i < 16; ++i) {
+ char utf8[] = { 0357, 0267, 0220 + i, 0 };
+ QString utf16 = QChar(0xfdd0 + i);
+ QTest::newRow(qPrintable(QString::number(0xfdd0 + i, 16))) << QByteArray(utf8) << utf16;
+ }
+
+ // the last two in Planes 1 through 16
+ for (uint plane = 1; plane <= 16; ++plane) {
+ for (uint lower = 0xfffe; lower < 0x10000; ++lower) {
+ uint ucs4 = (plane << 16) | lower;
+ char utf8[] = { 0xf0 | uchar(ucs4 >> 18),
+ 0x80 | (uchar(ucs4 >> 12) & 0x3f),
+ 0x80 | (uchar(ucs4 >> 6) & 0x3f),
+ 0x80 | (uchar(ucs4) & 0x3f),
+ 0 };
+ ushort utf16[] = { QChar::highSurrogate(ucs4), QChar::lowSurrogate(ucs4), 0 };
+
+ QTest::newRow(qPrintable(QString::number(ucs4, 16))) << QByteArray(utf8) << QString::fromUtf16(utf16);
+ }
+ }
+
+ QTest::newRow("fffe") << QByteArray("\xEF\xBF\xBE") << QString(QChar(0xfffe));
+ QTest::newRow("ffff") << QByteArray("\xEF\xBF\xBF") << QString(QChar(0xffff));
+}
+
+void tst_Utf8::nonCharacters()
+{
+ QFETCH(QByteArray, utf8);
+ QFETCH(QString, utf16);
+ QFETCH_GLOBAL(bool, useLocale);
+
+ QSharedPointer<QTextDecoder> decoder = QSharedPointer<QTextDecoder>(codec->makeDecoder());
+ decoder->toUnicode(utf8);
+
+ // Only enforce correctness on our UTF-8 decoder
+ // The system's UTF-8 codec is sometimes buggy
+ // GNU libc's iconv is known to accept U+FFFF and U+FFFE encoded as UTF-8
+ // OS X's iconv is known to accept those, plus surrogates and codepoints above U+10FFFF
+ if (!useLocale)
+ QVERIFY(decoder->hasFailure());
+ else if (!decoder->hasFailure())
+ qWarning("System codec does not report failure when it should. Should report bug upstream.");
+
+ QSharedPointer<QTextEncoder> encoder(codec->makeEncoder());
+ encoder->fromUnicode(utf16);
+ if (!useLocale)
+ QVERIFY(encoder->hasFailure());
+ else if (!encoder->hasFailure())
+ qWarning("System codec does not report failure when it should. Should report bug upstream.");
+}
+
QTEST_MAIN(tst_Utf8)
#include "tst_utf8.moc"
diff --git a/tests/benchmarks/corelib/kernel/qtimer_vs_qmetaobject/qtimer_vs_qmetaobject.pro b/tests/benchmarks/corelib/kernel/qtimer_vs_qmetaobject/qtimer_vs_qmetaobject.pro
new file mode 100644
index 0000000..9c6b16b
--- /dev/null
+++ b/tests/benchmarks/corelib/kernel/qtimer_vs_qmetaobject/qtimer_vs_qmetaobject.pro
@@ -0,0 +1,11 @@
+load(qttest_p4)
+TEMPLATE = app
+TARGET = qtimer_vs_qmetaobject
+DEPENDPATH += .
+INCLUDEPATH += .
+
+CONFIG += release
+#CONFIG += debug
+
+
+SOURCES += tst_qtimer_vs_qmetaobject.cpp
diff --git a/tests/benchmarks/corelib/kernel/qtimer_vs_qmetaobject/tst_qtimer_vs_qmetaobject.cpp b/tests/benchmarks/corelib/kernel/qtimer_vs_qmetaobject/tst_qtimer_vs_qmetaobject.cpp
new file mode 100644
index 0000000..2f265bf
--- /dev/null
+++ b/tests/benchmarks/corelib/kernel/qtimer_vs_qmetaobject/tst_qtimer_vs_qmetaobject.cpp
@@ -0,0 +1,96 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtCore>
+#include <QtTest/QtTest>
+
+#define INVOKE_COUNT 10000
+
+class qtimer_vs_qmetaobject : public QObject
+{
+ Q_OBJECT
+private slots:
+ void testZeroTimerSingleShot();
+ void testQueuedInvokeMethod();
+};
+
+class InvokeCounter : public QObject {
+ Q_OBJECT
+public:
+ InvokeCounter() : count(0) { };
+public slots:
+ void invokeSlot() {
+ count++;
+ if (count == INVOKE_COUNT)
+ QTestEventLoop::instance().exitLoop();
+ }
+protected:
+ int count;
+};
+
+void qtimer_vs_qmetaobject::testZeroTimerSingleShot()
+{
+ QBENCHMARK {
+ InvokeCounter invokeCounter;
+ for(int i = 0; i < INVOKE_COUNT; ++i) {
+ QTimer::singleShot(0, &invokeCounter, SLOT(invokeSlot()));
+ }
+ QTestEventLoop::instance().enterLoop(10);
+ QVERIFY(!QTestEventLoop::instance().timeout());
+ }
+}
+
+void qtimer_vs_qmetaobject::testQueuedInvokeMethod()
+{
+ QBENCHMARK {
+ InvokeCounter invokeCounter;
+ for(int i = 0; i < INVOKE_COUNT; ++i) {
+ QMetaObject::invokeMethod(&invokeCounter, "invokeSlot", Qt::QueuedConnection);
+ }
+ QTestEventLoop::instance().enterLoop(10);
+ QVERIFY(!QTestEventLoop::instance().timeout());
+ }
+}
+
+
+QTEST_MAIN(qtimer_vs_qmetaobject)
+
+#include "tst_qtimer_vs_qmetaobject.moc"