diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/qabstractnetworkcache/tst_qabstractnetworkcache.cpp | 6 | ||||
-rw-r--r-- | tests/auto/qapplication/heart.svg | 55 | ||||
-rw-r--r-- | tests/auto/qapplication/test/test.pro | 4 | ||||
-rw-r--r-- | tests/auto/qapplication/tst_qapplication.cpp | 88 | ||||
-rw-r--r-- | tests/auto/qaudiodeviceinfo/tst_qaudiodeviceinfo.cpp | 16 | ||||
-rw-r--r-- | tests/auto/qaudioformat/tst_qaudioformat.cpp | 26 | ||||
-rw-r--r-- | tests/auto/qaudioinput/tst_qaudioinput.cpp | 8 | ||||
-rw-r--r-- | tests/auto/qaudiooutput/tst_qaudiooutput.cpp | 8 | ||||
-rw-r--r-- | tests/auto/qnetworkreply/tst_qnetworkreply.cpp | 203 | ||||
-rw-r--r-- | tests/auto/qstylesheetstyle/tst_qstylesheetstyle.cpp | 14 | ||||
-rw-r--r-- | tests/benchmarks/benchmarks.pro | 1 | ||||
-rw-r--r-- | tests/benchmarks/qgraphicsscene/tst_qgraphicsscene.cpp | 17 | ||||
-rw-r--r-- | tests/benchmarks/qtext/bidi.txt | 4 | ||||
-rw-r--r-- | tests/benchmarks/qtext/main.cpp | 125 | ||||
-rw-r--r-- | tests/benchmarks/qtext/qtext.pro | 7 |
15 files changed, 546 insertions, 36 deletions
diff --git a/tests/auto/qabstractnetworkcache/tst_qabstractnetworkcache.cpp b/tests/auto/qabstractnetworkcache/tst_qabstractnetworkcache.cpp index 7fd994d..e5646c1 100644 --- a/tests/auto/qabstractnetworkcache/tst_qabstractnetworkcache.cpp +++ b/tests/auto/qabstractnetworkcache/tst_qabstractnetworkcache.cpp @@ -136,7 +136,7 @@ void tst_QAbstractNetworkCache::expires_data() QTest::newRow("200-0") << QNetworkRequest::AlwaysNetwork << "httpcachetest_expires200.cgi" << AlwaysFalse; QTest::newRow("200-1") << QNetworkRequest::PreferNetwork << "httpcachetest_expires200.cgi" << false; QTest::newRow("200-2") << QNetworkRequest::AlwaysCache << "httpcachetest_expires200.cgi" << AlwaysTrue; - QTest::newRow("200-3") << QNetworkRequest::PreferCache << "httpcachetest_expires200.cgi" << true; + QTest::newRow("200-3") << QNetworkRequest::PreferCache << "httpcachetest_expires200.cgi" << false; } void tst_QAbstractNetworkCache::expires() @@ -158,7 +158,7 @@ void tst_QAbstractNetworkCache::lastModified_data() QTest::newRow("200-0") << QNetworkRequest::AlwaysNetwork << "httpcachetest_lastModified200.cgi" << AlwaysFalse; QTest::newRow("200-1") << QNetworkRequest::PreferNetwork << "httpcachetest_lastModified200.cgi" << false; QTest::newRow("200-2") << QNetworkRequest::AlwaysCache << "httpcachetest_lastModified200.cgi" << AlwaysTrue; - QTest::newRow("200-3") << QNetworkRequest::PreferCache << "httpcachetest_lastModified200.cgi" << true; + QTest::newRow("200-3") << QNetworkRequest::PreferCache << "httpcachetest_lastModified200.cgi" << false; } void tst_QAbstractNetworkCache::lastModified() @@ -180,7 +180,7 @@ void tst_QAbstractNetworkCache::etag_data() QTest::newRow("200-0") << QNetworkRequest::AlwaysNetwork << "httpcachetest_etag200.cgi" << AlwaysFalse; QTest::newRow("200-1") << QNetworkRequest::PreferNetwork << "httpcachetest_etag200.cgi" << false; QTest::newRow("200-2") << QNetworkRequest::AlwaysCache << "httpcachetest_etag200.cgi" << AlwaysTrue; - QTest::newRow("200-3") << QNetworkRequest::PreferCache << "httpcachetest_etag200.cgi" << true; + QTest::newRow("200-3") << QNetworkRequest::PreferCache << "httpcachetest_etag200.cgi" << false; } void tst_QAbstractNetworkCache::etag() diff --git a/tests/auto/qapplication/heart.svg b/tests/auto/qapplication/heart.svg new file mode 100644 index 0000000..8c982cd --- /dev/null +++ b/tests/auto/qapplication/heart.svg @@ -0,0 +1,55 @@ +<?xml version="1.0" encoding="UTF-8" standalone="no"?> +<!-- Created with Inkscape (http://www.inkscape.org/) --><svg viewBox="100 200 550 500" height="841.88976pt" id="svg1" inkscape:version="0.40+cvs" sodipodi:docbase="C:\Documents and Settings\Jon Phillips\My Documents\projects\clipart-project\submissions" sodipodi:docname="heart-left-highlight.svg" sodipodi:version="0.32" width="595.27559pt" xmlns="http://www.w3.org/2000/svg" xmlns:cc="http://web.resource.org/cc/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:sodipodi="http://inkscape.sourceforge.net/DTD/sodipodi-0.dtd" xmlns:svg="http://www.w3.org/2000/svg"> +<metadata> +<rdf:RDF xmlns:cc="http://web.resource.org/cc/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"> +<cc:Work rdf:about=""> +<dc:title>Heart Left-Highlight</dc:title> +<dc:description>This is a normal valentines day heart.</dc:description> +<dc:subject> +<rdf:Bag> +<rdf:li>holiday</rdf:li> +<rdf:li>valentines</rdf:li> +<rdf:li></rdf:li> +<rdf:li>valentine</rdf:li> +<rdf:li>hash(0x8a091c0)</rdf:li> +<rdf:li>hash(0x8a0916c)</rdf:li> +<rdf:li>signs_and_symbols</rdf:li> +<rdf:li>hash(0x8a091f0)</rdf:li> +<rdf:li>day</rdf:li> +</rdf:Bag> +</dc:subject> +<dc:publisher> +<cc:Agent rdf:about="http://www.openclipart.org"> +<dc:title>Jon Phillips</dc:title> +</cc:Agent> +</dc:publisher> +<dc:creator> +<cc:Agent> +<dc:title>Jon Phillips</dc:title> +</cc:Agent> +</dc:creator> +<dc:rights> +<cc:Agent> +<dc:title>Jon Phillips</dc:title> +</cc:Agent> +</dc:rights> +<dc:date></dc:date> +<dc:format>image/svg+xml</dc:format> +<dc:type rdf:resource="http://purl.org/dc/dcmitype/StillImage"/> +<cc:license rdf:resource="http://web.resource.org/cc/PublicDomain"/> +<dc:language>en</dc:language> +</cc:Work> +<cc:License rdf:about="http://web.resource.org/cc/PublicDomain"> +<cc:permits rdf:resource="http://web.resource.org/cc/Reproduction"/> +<cc:permits rdf:resource="http://web.resource.org/cc/Distribution"/> +<cc:permits rdf:resource="http://web.resource.org/cc/DerivativeWorks"/> +</cc:License> +</rdf:RDF> +</metadata> +<defs id="defs3"/> +<sodipodi:namedview bordercolor="#666666" borderopacity="1.0" id="base" inkscape:current-layer="layer1" inkscape:cx="549.40674" inkscape:cy="596.00159" inkscape:document-units="px" inkscape:guide-bbox="true" inkscape:pageopacity="0.0" inkscape:pageshadow="2" inkscape:window-height="615" inkscape:window-width="866" inkscape:window-x="88" inkscape:window-y="116" inkscape:zoom="0.35000000" pagecolor="#ffffff" showguides="true"/> +<g id="layer1" inkscape:groupmode="layer" inkscape:label="Layer 1"> +<path d="M 263.41570,235.14588 C 197.17570,235.14588 143.41575,288.90587 143.41575,355.14588 C 143.41575,489.90139 279.34890,525.23318 371.97820,658.45392 C 459.55244,526.05056 600.54070,485.59932 600.54070,355.14588 C 600.54070,288.90588 546.78080,235.14587 480.54070,235.14588 C 432.49280,235.14588 391.13910,263.51631 371.97820,304.33338 C 352.81740,263.51630 311.46370,235.14587 263.41570,235.14588 z " id="path7" sodipodi:nodetypes="ccccccc" style="fill:#e60000;fill-opacity:1.0000000;stroke:#000000;stroke-width:18.700001;stroke-miterlimit:4.0000000;stroke-opacity:1.0000000"/> +<path d="M 265.00000,253.59375 C 207.04033,253.59375 160.00000,300.63407 160.00000,358.59375 C 160.00000,476.50415 278.91857,507.43251 359.96875,624.00000 C 366.52868,614.08205 220.00000,478.47309 220.00000,378.59375 C 220.00000,320.63407 267.04033,273.59375 325.00000,273.59375 C 325.50453,273.59375 325.99718,273.64912 326.50000,273.65625 C 309.22436,261.07286 288.00557,253.59374 265.00000,253.59375 z " id="path220" sodipodi:nodetypes="ccccccc" style="fill:#e6e6e6;fill-opacity:0.64556962;stroke:none;stroke-width:18.700001;stroke-miterlimit:4.0000000;stroke-opacity:1.0000000"/> +</g> +</svg> diff --git a/tests/auto/qapplication/test/test.pro b/tests/auto/qapplication/test/test.pro index 7c3de3c..e68af26 100644 --- a/tests/auto/qapplication/test/test.pro +++ b/tests/auto/qapplication/test/test.pro @@ -16,7 +16,9 @@ symbian*: { additional.path = desktopsettingsaware someTest.sources = test.pro someTest.path = test - DEPLOYMENT = additional deploy someTest + windowIcon.sources = ../heart.svg + DEPLOYMENT = additional deploy someTest windowIcon + LIBS += -lcone -lavkon } win32 { diff --git a/tests/auto/qapplication/tst_qapplication.cpp b/tests/auto/qapplication/tst_qapplication.cpp index afd3b3a..b464867 100644 --- a/tests/auto/qapplication/tst_qapplication.cpp +++ b/tests/auto/qapplication/tst_qapplication.cpp @@ -53,6 +53,9 @@ #ifdef Q_OS_WINCE #include <windows.h> #endif +#ifdef Q_OS_SYMBIAN +#include <aknenv.h> +#endif //TESTED_CLASS= //TESTED_FILES= @@ -138,6 +141,8 @@ private slots: void touchEventPropagation(); + void symbianNoApplicationPanes(); + void symbianNeedForTraps(); void symbianLeaveThroughMain(); }; @@ -2036,6 +2041,89 @@ void tst_QApplication::touchEventPropagation() } } +void tst_QApplication::symbianNoApplicationPanes() +{ +#ifndef Q_OS_SYMBIAN + QSKIP("This is a Symbian only test", SkipAll); +#else + QApplication::setAttribute(Qt::AA_S60DontConstructApplicationPanes); + + // Run in a block so that QApplication is destroyed before resetting the attribute. + { + // Actually I wasn't able to get the forced orientation change to work properly, + // but I'll leave the code here for the future in case we manage to test that + // later. If someone knows how to force an orientation switch in an autotest, do + // feel free to fix this testcase. + int argc = 0; + QApplication app(argc, 0); + QWidget *w; + + w = new QWidget; + w->show(); + QT_TRAP_THROWING(static_cast<CAknAppUi *>(CCoeEnv::Static()->AppUi()) + ->SetOrientationL(CAknAppUi::EAppUiOrientationLandscape)); + app.processEvents(); + delete w; + + w = new QWidget; + w->show(); + QT_TRAP_THROWING(static_cast<CAknAppUi *>(CCoeEnv::Static()->AppUi()) + ->SetOrientationL(CAknAppUi::EAppUiOrientationPortrait)); + app.processEvents(); + delete w; + + w = new QWidget; + w->showMaximized(); + QT_TRAP_THROWING(static_cast<CAknAppUi *>(CCoeEnv::Static()->AppUi()) + ->SetOrientationL(CAknAppUi::EAppUiOrientationLandscape)); + app.processEvents(); + delete w; + + w = new QWidget; + w->showMaximized(); + QT_TRAP_THROWING(static_cast<CAknAppUi *>(CCoeEnv::Static()->AppUi()) + ->SetOrientationL(CAknAppUi::EAppUiOrientationPortrait)); + app.processEvents(); + delete w; + + w = new QWidget; + w->showFullScreen(); + QT_TRAP_THROWING(static_cast<CAknAppUi *>(CCoeEnv::Static()->AppUi()) + ->SetOrientationL(CAknAppUi::EAppUiOrientationLandscape)); + app.processEvents(); + delete w; + + w = new QWidget; + w->showFullScreen(); + QT_TRAP_THROWING(static_cast<CAknAppUi *>(CCoeEnv::Static()->AppUi()) + ->SetOrientationL(CAknAppUi::EAppUiOrientationPortrait)); + app.processEvents(); + delete w; + + // These will have no effect, since there is no status pane, but they shouldn't + // crash either. + w = new QWidget; + w->show(); + w->setWindowTitle("Testing title"); + app.processEvents(); + delete w; + + w = new QWidget; + w->show(); + w->setWindowIcon(QIcon(QPixmap("heart.svg"))); + app.processEvents(); + delete w; + + QDesktopWidget desktop; + QCOMPARE(desktop.availableGeometry(), desktop.screenGeometry()); + } + + QApplication::setAttribute(Qt::AA_S60DontConstructApplicationPanes, false); + + // No other error condition. Program will crash if unsuccessful. +#endif +} + #ifdef Q_OS_SYMBIAN class CBaseDummy : public CBase { diff --git a/tests/auto/qaudiodeviceinfo/tst_qaudiodeviceinfo.cpp b/tests/auto/qaudiodeviceinfo/tst_qaudiodeviceinfo.cpp index d3d81e6..e332e11 100644 --- a/tests/auto/qaudiodeviceinfo/tst_qaudiodeviceinfo.cpp +++ b/tests/auto/qaudiodeviceinfo/tst_qaudiodeviceinfo.cpp @@ -128,7 +128,7 @@ void tst_QAudioDeviceInfo::codecs() void tst_QAudioDeviceInfo::channels() { if(available) { - QList<int> avail = device->supportedChannels(); + QList<int> avail = device->supportedChannelCounts(); QVERIFY(avail.size() > 0); } } @@ -160,7 +160,7 @@ void tst_QAudioDeviceInfo::sampleTypes() void tst_QAudioDeviceInfo::frequencies() { if(available) { - QList<int> avail = device->supportedFrequencies(); + QList<int> avail = device->supportedSampleRates(); QVERIFY(avail.size() > 0); } } @@ -169,8 +169,8 @@ void tst_QAudioDeviceInfo::isformat() { if(available) { QAudioFormat format; - format.setFrequency(44100); - format.setChannels(2); + format.setSampleRate(44100); + format.setChannelCount(2); format.setSampleType(QAudioFormat::SignedInt); format.setByteOrder(QAudioFormat::LittleEndian); format.setSampleSize(16); @@ -185,8 +185,8 @@ void tst_QAudioDeviceInfo::preferred() { if(available) { QAudioFormat format = device->preferredFormat(); - QVERIFY(format.frequency() == 44100); - QVERIFY(format.channels() == 2); + QVERIFY(format.sampleRate() == 44100); + QVERIFY(format.channelCount() == 2); } } @@ -194,9 +194,9 @@ void tst_QAudioDeviceInfo::nearest() { if(available) { QAudioFormat format1, format2; - format1.setFrequency(8000); + format1.setSampleRate(8000); format2 = device->nearestFormat(format1); - QVERIFY(format2.frequency() == 44100); + QVERIFY(format2.sampleRate() == 44100); } } diff --git a/tests/auto/qaudioformat/tst_qaudioformat.cpp b/tests/auto/qaudioformat/tst_qaudioformat.cpp index 0206798..a7200c4 100644 --- a/tests/auto/qaudioformat/tst_qaudioformat.cpp +++ b/tests/auto/qaudioformat/tst_qaudioformat.cpp @@ -77,8 +77,8 @@ void tst_QAudioFormat::checkNull() QAudioFormat audioFormat1(audioFormat0); QVERIFY(!audioFormat1.isValid()); - audioFormat0.setFrequency(44100); - audioFormat0.setChannels(2); + audioFormat0.setSampleRate(44100); + audioFormat0.setChannelCount(2); audioFormat0.setSampleSize(16); audioFormat0.setCodec("audio/pcm"); audioFormat0.setSampleType(QAudioFormat::SignedInt); @@ -88,15 +88,15 @@ void tst_QAudioFormat::checkNull() void tst_QAudioFormat::checkFrequency() { QAudioFormat audioFormat; - audioFormat.setFrequency(44100); - QVERIFY(audioFormat.frequency() == 44100); + audioFormat.setSampleRate(44100); + QVERIFY(audioFormat.sampleRate() == 44100); } void tst_QAudioFormat::checkChannels() { QAudioFormat audioFormat; - audioFormat.setChannels(2); - QVERIFY(audioFormat.channels() == 2); + audioFormat.setChannelCount(2); + QVERIFY(audioFormat.channelCount() == 2); } void tst_QAudioFormat::checkSampleSize() @@ -137,15 +137,15 @@ void tst_QAudioFormat::checkEquality() QVERIFY(!(audioFormat0 != audioFormat1)); // on filled formats - audioFormat0.setFrequency(8000); - audioFormat0.setChannels(1); + audioFormat0.setSampleRate(8000); + audioFormat0.setChannelCount(1); audioFormat0.setSampleSize(8); audioFormat0.setCodec("audio/pcm"); audioFormat0.setByteOrder(QAudioFormat::LittleEndian); audioFormat0.setSampleType(QAudioFormat::UnSignedInt); - audioFormat1.setFrequency(8000); - audioFormat1.setChannels(1); + audioFormat1.setSampleRate(8000); + audioFormat1.setChannelCount(1); audioFormat1.setSampleSize(8); audioFormat1.setCodec("audio/pcm"); audioFormat1.setByteOrder(QAudioFormat::LittleEndian); @@ -154,7 +154,7 @@ void tst_QAudioFormat::checkEquality() QVERIFY(audioFormat0 == audioFormat1); QVERIFY(!(audioFormat0 != audioFormat1)); - audioFormat0.setFrequency(44100); + audioFormat0.setSampleRate(44100); QVERIFY(audioFormat0 != audioFormat1); QVERIFY(!(audioFormat0 == audioFormat1)); } @@ -164,8 +164,8 @@ void tst_QAudioFormat::checkAssignment() QAudioFormat audioFormat0; QAudioFormat audioFormat1; - audioFormat0.setFrequency(8000); - audioFormat0.setChannels(1); + audioFormat0.setSampleRate(8000); + audioFormat0.setChannelCount(1); audioFormat0.setSampleSize(8); audioFormat0.setCodec("audio/pcm"); audioFormat0.setByteOrder(QAudioFormat::LittleEndian); diff --git a/tests/auto/qaudioinput/tst_qaudioinput.cpp b/tests/auto/qaudioinput/tst_qaudioinput.cpp index 40b7fbb..9468413 100644 --- a/tests/auto/qaudioinput/tst_qaudioinput.cpp +++ b/tests/auto/qaudioinput/tst_qaudioinput.cpp @@ -68,8 +68,8 @@ private: void tst_QAudioInput::initTestCase() { - format.setFrequency(8000); - format.setChannels(1); + format.setSampleRate(8000); + format.setChannelCount(1); format.setSampleSize(8); format.setCodec("audio/pcm"); format.setByteOrder(QAudioFormat::LittleEndian); @@ -94,8 +94,8 @@ void tst_QAudioInput::settings() // Confirm the setting we added in the init function. QAudioFormat f = audio->format(); - QVERIFY(format.channels() == f.channels()); - QVERIFY(format.frequency() == f.frequency()); + QVERIFY(format.channelCount() == f.channelCount()); + QVERIFY(format.sampleRate() == f.sampleRate()); QVERIFY(format.sampleSize() == f.sampleSize()); QVERIFY(format.codec() == f.codec()); QVERIFY(format.byteOrder() == f.byteOrder()); diff --git a/tests/auto/qaudiooutput/tst_qaudiooutput.cpp b/tests/auto/qaudiooutput/tst_qaudiooutput.cpp index aeb2286..5005838 100644 --- a/tests/auto/qaudiooutput/tst_qaudiooutput.cpp +++ b/tests/auto/qaudiooutput/tst_qaudiooutput.cpp @@ -71,8 +71,8 @@ private: void tst_QAudioOutput::initTestCase() { - format.setFrequency(8000); - format.setChannels(1); + format.setSampleRate(8000); + format.setChannelCount(1); format.setSampleSize(8); format.setCodec("audio/pcm"); format.setByteOrder(QAudioFormat::LittleEndian); @@ -95,8 +95,8 @@ void tst_QAudioOutput::settings() // Confirm the setting we added in the init function. QAudioFormat f = audio->format(); - QVERIFY(format.channels() == f.channels()); - QVERIFY(format.frequency() == f.frequency()); + QVERIFY(format.channelCount() == f.channelCount()); + QVERIFY(format.sampleRate() == f.sampleRate()); QVERIFY(format.sampleSize() == f.sampleSize()); QVERIFY(format.codec() == f.codec()); QVERIFY(format.byteOrder() == f.byteOrder()); diff --git a/tests/auto/qnetworkreply/tst_qnetworkreply.cpp b/tests/auto/qnetworkreply/tst_qnetworkreply.cpp index 20cf922..33753f1 100644 --- a/tests/auto/qnetworkreply/tst_qnetworkreply.cpp +++ b/tests/auto/qnetworkreply/tst_qnetworkreply.cpp @@ -54,6 +54,7 @@ #include <QtNetwork/QLocalServer> #include <QtNetwork/QHostInfo> #include <QtNetwork/QFtp> +#include <QtNetwork/QAbstractNetworkCache> #include <QtNetwork/qauthenticator.h> #include <QtNetwork/qnetworkaccessmanager.h> #include <QtNetwork/qnetworkrequest.h> @@ -198,6 +199,8 @@ private Q_SLOTS: #endif void ioGetFromHttpBrokenServer_data(); void ioGetFromHttpBrokenServer(); + void ioGetFromHttpWithCache_data(); + void ioGetFromHttpWithCache(); void ioGetWithManyProxies_data(); void ioGetWithManyProxies(); @@ -318,8 +321,9 @@ public: QByteArray dataToTransmit; QByteArray receivedData; bool doClose; + int totalConnections; - MiniHttpServer(const QByteArray &data) : client(0), dataToTransmit(data), doClose(true) + MiniHttpServer(const QByteArray &data) : client(0), dataToTransmit(data), doClose(true), totalConnections(0) { listen(); connect(this, SIGNAL(newConnection()), this, SLOT(doAccept())); @@ -329,6 +333,7 @@ public slots: void doAccept() { client = nextPendingConnection(); + ++totalConnections; connect(client, SIGNAL(readyRead()), this, SLOT(sendData())); } @@ -379,6 +384,61 @@ public: } }; +class MyMemoryCache: public QAbstractNetworkCache +{ +public: + typedef QPair<QNetworkCacheMetaData, QByteArray> CachedContent; + typedef QHash<QByteArray, CachedContent> CacheData; + CacheData cache; + + MyMemoryCache(QObject *parent) : QAbstractNetworkCache(parent) {} + + QNetworkCacheMetaData metaData(const QUrl &url) + { + return cache.value(url.toEncoded()).first; + } + + void updateMetaData(const QNetworkCacheMetaData &metaData) + { + cache[metaData.url().toEncoded()].first = metaData; + } + + QIODevice *data(const QUrl &url) + { + CacheData::ConstIterator it = cache.find(url.toEncoded()); + if (it == cache.constEnd()) + return 0; + QBuffer *io = new QBuffer(this); + io->setData(it->second); + io->open(QIODevice::ReadOnly); + io->seek(0); + return io; + } + + bool remove(const QUrl &url) + { + cache.remove(url.toEncoded()); + return true; + } + + qint64 cacheSize() const + { + qint64 total = 0; + foreach (const CachedContent &entry, cache) + total += entry.second.size(); + return total; + } + + QIODevice *prepare(const QNetworkCacheMetaData &) + { Q_ASSERT(0 && "Should not have tried to add to the cache"); return 0; } + void insert(QIODevice *) + { Q_ASSERT(0 && "Should not have tried to add to the cache"); } + + void clear() { cache.clear(); } +}; +Q_DECLARE_METATYPE(MyMemoryCache::CachedContent) +Q_DECLARE_METATYPE(MyMemoryCache::CacheData) + class DataReader: public QObject { Q_OBJECT @@ -762,6 +822,7 @@ void tst_QNetworkReply::cleanup() // clear the internal cache QNetworkAccessManagerPrivate::clearCache(&manager); manager.setProxy(QNetworkProxy()); + manager.setCache(0); // clear cookies cookieJar->setAllCookies(QList<QNetworkCookie>()); @@ -1984,6 +2045,146 @@ void tst_QNetworkReply::ioGetFromHttpBrokenServer() QVERIFY(reply->error() != QNetworkReply::NoError); } +void tst_QNetworkReply::ioGetFromHttpWithCache_data() +{ + qRegisterMetaType<MyMemoryCache::CachedContent>(); + QTest::addColumn<QByteArray>("dataToSend"); + QTest::addColumn<QString>("body"); + QTest::addColumn<MyMemoryCache::CachedContent>("cachedReply"); + QTest::addColumn<int>("cacheMode"); + QTest::addColumn<bool>("loadedFromCache"); + QTest::addColumn<bool>("networkUsed"); + + QByteArray reply200 = + "HTTP/1.0 200\r\n" + "Connection: keep-alive\r\n" + "Content-Type: text/plain\r\n" + "Cache-control: no-cache\r\n" + "Content-length: 8\r\n" + "\r\n" + "Reloaded"; + QByteArray reply304 = + "HTTP/1.0 304 Use Cache\r\n" + "Connection: keep-alive\r\n" + "\r\n"; + + QTest::newRow("not-cached,always-network") + << reply200 << "Reloaded" << MyMemoryCache::CachedContent() << int(QNetworkRequest::AlwaysNetwork) << false << true; + QTest::newRow("not-cached,prefer-network") + << reply200 << "Reloaded" << MyMemoryCache::CachedContent() << int(QNetworkRequest::PreferNetwork) << false << true; + QTest::newRow("not-cached,prefer-cache") + << reply200 << "Reloaded" << MyMemoryCache::CachedContent() << int(QNetworkRequest::PreferCache) << false << true; + + QDateTime present = QDateTime::currentDateTime().toUTC(); + QDateTime past = present.addSecs(-3600); + QDateTime future = present.addSecs(3600); + static const char dateFormat[] = "ddd, dd MMM yyyy hh:mm:ss 'GMT'"; + + QNetworkCacheMetaData::RawHeaderList rawHeaders; + MyMemoryCache::CachedContent content; + content.second = "Not-reloaded"; + content.first.setLastModified(past); + + // + // Set to expired + // + rawHeaders.clear(); + rawHeaders << QNetworkCacheMetaData::RawHeader("Date", QLocale::c().toString(past, dateFormat).toLatin1()) + << QNetworkCacheMetaData::RawHeader("Cache-control", "max-age=0"); // isn't used in cache loading + content.first.setRawHeaders(rawHeaders); + content.first.setLastModified(past); + + QTest::newRow("expired,200,prefer-network") + << reply200 << "Reloaded" << content << int(QNetworkRequest::PreferNetwork) << false << true; + QTest::newRow("expired,200,prefer-cache") + << reply200 << "Reloaded" << content << int(QNetworkRequest::PreferCache) << false << true; + + QTest::newRow("expired,304,prefer-network") + << reply304 << "Not-reloaded" << content << int(QNetworkRequest::PreferNetwork) << true << true; + QTest::newRow("expired,304,prefer-cache") + << reply304 << "Not-reloaded" << content << int(QNetworkRequest::PreferCache) << true << true; + + // + // Set to not-expired + // + rawHeaders.clear(); + rawHeaders << QNetworkCacheMetaData::RawHeader("Date", QLocale::c().toString(past, dateFormat).toLatin1()) + << QNetworkCacheMetaData::RawHeader("Cache-control", "max-age=7200"); // isn't used in cache loading + content.first.setRawHeaders(rawHeaders); + content.first.setExpirationDate(future); + + QTest::newRow("not-expired,200,always-network") + << reply200 << "Reloaded" << content << int(QNetworkRequest::AlwaysNetwork) << false << true; + QTest::newRow("not-expired,200,prefer-network") + << reply200 << "Not-reloaded" << content << int(QNetworkRequest::PreferNetwork) << true << false; + QTest::newRow("not-expired,200,prefer-cache") + << reply200 << "Not-reloaded" << content << int(QNetworkRequest::PreferCache) << true << false; + QTest::newRow("not-expired,200,always-cache") + << reply200 << "Not-reloaded" << content << int(QNetworkRequest::AlwaysCache) << true << false; + + QTest::newRow("not-expired,304,prefer-network") + << reply304 << "Not-reloaded" << content << int(QNetworkRequest::PreferNetwork) << true << false; + QTest::newRow("not-expired,304,prefer-cache") + << reply304 << "Not-reloaded" << content << int(QNetworkRequest::PreferCache) << true << false; + QTest::newRow("not-expired,304,always-cache") + << reply304 << "Not-reloaded" << content << int(QNetworkRequest::AlwaysCache) << true << false; + + // + // Set must-revalidate now + // + rawHeaders.clear(); + rawHeaders << QNetworkCacheMetaData::RawHeader("Date", QLocale::c().toString(past, dateFormat).toLatin1()) + << QNetworkCacheMetaData::RawHeader("Cache-control", "max-age=7200, must-revalidate"); // must-revalidate is used + content.first.setRawHeaders(rawHeaders); + + QTest::newRow("must-revalidate,200,always-network") + << reply200 << "Reloaded" << content << int(QNetworkRequest::AlwaysNetwork) << false << true; + QTest::newRow("must-revalidate,200,prefer-network") + << reply200 << "Reloaded" << content << int(QNetworkRequest::PreferNetwork) << false << true; + QTest::newRow("must-revalidate,200,prefer-cache") + << reply200 << "Not-reloaded" << content << int(QNetworkRequest::PreferCache) << true << false; + QTest::newRow("must-revalidate,200,always-cache") + << reply200 << "Not-reloaded" << content << int(QNetworkRequest::AlwaysCache) << true << false; + + QTest::newRow("must-revalidate,304,prefer-network") + << reply304 << "Not-reloaded" << content << int(QNetworkRequest::PreferNetwork) << true << true; + QTest::newRow("must-revalidate,304,prefer-cache") + << reply304 << "Not-reloaded" << content << int(QNetworkRequest::PreferCache) << true << false; + QTest::newRow("must-revalidate,304,always-cache") + << reply304 << "Not-reloaded" << content << int(QNetworkRequest::AlwaysCache) << true << false; +} + +void tst_QNetworkReply::ioGetFromHttpWithCache() +{ + QFETCH(QByteArray, dataToSend); + MiniHttpServer server(dataToSend); + server.doClose = false; + + MyMemoryCache *memoryCache = new MyMemoryCache(&manager); + manager.setCache(memoryCache); + + QFETCH(MyMemoryCache::CachedContent, cachedReply); + QUrl url = "http://localhost:" + QString::number(server.serverPort()); + cachedReply.first.setUrl(url); + if (!cachedReply.second.isNull()) + memoryCache->cache.insert(url.toEncoded(), cachedReply); + + QFETCH(int, cacheMode); + QNetworkRequest request(url); + request.setAttribute(QNetworkRequest::CacheLoadControlAttribute, cacheMode); + request.setAttribute(QNetworkRequest::CacheSaveControlAttribute, false); + QNetworkReplyPtr reply = manager.get(request); + + connect(reply, SIGNAL(finished()), &QTestEventLoop::instance(), SLOT(exitLoop())); + QTestEventLoop::instance().enterLoop(10); + QVERIFY(!QTestEventLoop::instance().timeout()); + + QTEST(reply->attribute(QNetworkRequest::SourceIsFromCacheAttribute).toBool(), "loadedFromCache"); + QTEST(server.totalConnections > 0, "networkUsed"); + QFETCH(QString, body); + QCOMPARE(reply->readAll().constData(), qPrintable(body)); +} + void tst_QNetworkReply::ioGetWithManyProxies_data() { QTest::addColumn<QList<QNetworkProxy> >("proxyList"); diff --git a/tests/auto/qstylesheetstyle/tst_qstylesheetstyle.cpp b/tests/auto/qstylesheetstyle/tst_qstylesheetstyle.cpp index 1b2f268..e0512a9 100644 --- a/tests/auto/qstylesheetstyle/tst_qstylesheetstyle.cpp +++ b/tests/auto/qstylesheetstyle/tst_qstylesheetstyle.cpp @@ -1114,7 +1114,10 @@ class ProxyStyle : public QStyle const QStyleOption* opt, const QWidget* w) const { - return style->subElementRect(se, opt, w); + Q_UNUSED(se); + Q_UNUSED(opt); + Q_UNUSED(w); + return QRect(0, 0, 3, 3); } void drawComplexControl(QStyle::ComplexControl cc, @@ -1232,7 +1235,7 @@ void tst_QStyleSheetStyle::proxyStyle() pb4->setStyleSheet(styleSheet); // We are creating our Proxy based on current style... - // In this case it would be the QStyleSheetStyle that is delete + // In this case it would be the QStyleSheetStyle that is deleted // later on. We need to get access to the "real" QStyle to be able to // draw correctly. ProxyStyle* newProxy = new ProxyStyle(qApp->style()); @@ -1248,6 +1251,13 @@ void tst_QStyleSheetStyle::proxyStyle() w->show(); QTest::qWait(100); + + // Test for QTBUG-7198 - style sheet overrides custom element size + QStyleOptionViewItemV4 opt; + opt.initFrom(w); + opt.features |= QStyleOptionViewItemV2::HasCheckIndicator; + QVERIFY(pb5->style()->subElementRect(QStyle::SE_ItemViewItemCheckIndicator, + &opt, pb5).width() == 3); delete w; delete proxy; delete newProxy; diff --git a/tests/benchmarks/benchmarks.pro b/tests/benchmarks/benchmarks.pro index 7bb4bb1..1c78f1f 100644 --- a/tests/benchmarks/benchmarks.pro +++ b/tests/benchmarks/benchmarks.pro @@ -8,6 +8,7 @@ SUBDIRS = containers-associative \ qhostinfo \ qpainter \ qtestlib-simple events \ + qtext \ qiodevice \ qpixmap \ blendbench \ diff --git a/tests/benchmarks/qgraphicsscene/tst_qgraphicsscene.cpp b/tests/benchmarks/qgraphicsscene/tst_qgraphicsscene.cpp index d2f8090..5bd07f9 100644 --- a/tests/benchmarks/qgraphicsscene/tst_qgraphicsscene.cpp +++ b/tests/benchmarks/qgraphicsscene/tst_qgraphicsscene.cpp @@ -64,6 +64,7 @@ private slots: void addItem(); void itemAt_data(); void itemAt(); + void initialShow(); }; tst_QGraphicsScene::tst_QGraphicsScene() @@ -227,5 +228,21 @@ void tst_QGraphicsScene::itemAt() qApp->processEvents(); } +void tst_QGraphicsScene::initialShow() +{ + QGraphicsScene scene; + + QBENCHMARK { + for (int y = 0; y < 30000; ++y) { + QGraphicsRectItem *item = new QGraphicsRectItem(0, 0, 50, 50); + item->setPos((y/2) * item->rect().width(), (y/2) * item->rect().height()); + scene.addItem(item); + } + scene.itemAt(0, 0); // triggers indexing + //This call polish the items so we bench their processing too. + qApp->processEvents(); + } +} + QTEST_MAIN(tst_QGraphicsScene) #include "tst_qgraphicsscene.moc" diff --git a/tests/benchmarks/qtext/bidi.txt b/tests/benchmarks/qtext/bidi.txt new file mode 100644 index 0000000..7c74cb4 --- /dev/null +++ b/tests/benchmarks/qtext/bidi.txt @@ -0,0 +1,4 @@ +chinese +欧洲,软件+互联网
用统一码 (Unicode) 走遍世界
将于1997年 3 月10日-12日在德国 Mainz 市举行的第十届统一码国际研讨会现在开始注册。 本次会议将汇集各方面的专家。 涉及的领域包括: 国际互联网和统一码 ,国际化和本地化 ,统一码在操作系统和应用软件中的实现 ,字型 ,文本格式以及多文种计算等。
当世界需要沟通时,请用Unicode! +hebrew-bidi +אײראָפּע: פּראָגראַמװאַרג און די װעלטנעץ: אוניקאָד איבער דער גאָרער װעלט פֿאַרשרײַבט זיך שױן אױף דער צענטער אינטערנאַציאָנאַלער אוניקאָד-קאָנפֿערענץ, װאָס װעט פֿאָרקומען דעם 10טן ביזן 12טן מאַרץ, 1997, אין מײַנץ, דײַטשלאַנד. די קאָנפֿערענץ װעט צוזאַמענברענגן מבֿינים פֿון װעלטנעץ, אוניקאָד, אי אַלװעלטלעכן אי סבֿיבֿהדיקן פּראָגראַמװאַרג, אַרײַנשטעלן אוניקאָד אין אָפּעריר-סיסטעמען און אָנװענדונגען, שריפֿטן, טעקסט-אױסשטעל, און מערשפּראַכיקע קאָמפּיוטערײַ. diff --git a/tests/benchmarks/qtext/main.cpp b/tests/benchmarks/qtext/main.cpp new file mode 100644 index 0000000..3c973b6 --- /dev/null +++ b/tests/benchmarks/qtext/main.cpp @@ -0,0 +1,125 @@ +/**************************************************************************** +** +** 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 <QDebug> +#include <QTextDocument> +#include <QTextLayout> +#include <QFile> +#include <qtest.h> + +class tst_QText: public QObject +{ + Q_OBJECT +private slots: + void loadHtml_data(); + void loadHtml(); + + void shaping_data(); + void shaping(); +}; + +void tst_QText::loadHtml_data() +{ + QTest::addColumn<QString>("source"); + QTest::newRow("empty") << QString(); + QTest::newRow("simple") << QString::fromLatin1("<html><b>Foo</b></html>"); + QTest::newRow("simple2") << QString::fromLatin1("<b>Foo</b>"); + + QString parag = QString::fromLatin1("<p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat. <b>Duis <i>autem</i> vel eum </b> iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio dignissim qui blandit praesent luptatum zzril delenit augue duis dolore te feugait nulla facilisi.</p>"); + QString header = QString::fromLatin1("<html><head><title>test</title></head><body>"); + QTest::newRow("long") << QString::fromLatin1("<html><head><title>test</title></head><body>") + parag + parag + parag + + parag + parag + parag + parag + parag + parag + parag + parag + parag + parag + parag + parag + parag + parag + + QString::fromLatin1("</html>"); + QTest::newRow("table") << header + QLatin1String("<table border=\"1\"1><tr><td>xx</td></tr><tr><td colspan=\"2\">") + + parag + QLatin1String("</td></tr></table></html"); + QTest::newRow("crappy") << header + QLatin1String("<table border=\"1\"1><tr><td>xx</td></tr><tr><td colspan=\"2\">") + + parag; +} + +void tst_QText::loadHtml() +{ + QFETCH(QString, source); + QTextDocument doc; + QBENCHMARK { + doc.setHtml(source); + } +} + +void tst_QText::shaping_data() +{ + QTest::addColumn<QString>("parag"); + QTest::newRow("empty") << QString(); + QTest::newRow("lorem") << QString::fromLatin1("Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat. Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio dignissim qui blandit praesent luptatum zzril delenit augue duis dolore te feugait nulla facilisi."); + QTest::newRow("short") << QString::fromLatin1("Lorem ipsum dolor sit amet"); + + QFile file(QString::fromLatin1(SRCDIR) + QLatin1String("/bidi.txt")); + QVERIFY(file.open(QFile::ReadOnly)); + QByteArray data = file.readAll(); + QVERIFY(data.count() > 1000); + QStringList list = QString::fromUtf8(data.data()).split(QLatin1Char('\n'), QString::SkipEmptyParts); + QVERIFY(list.count() %2 == 0); // even amount as we have title and then content. + for (int i=0; i < list.count(); i+=2) { + QTest::newRow(list.at(i).toLatin1()) << list.at(i+1); + } +} + +void tst_QText::shaping() +{ + QFETCH(QString, parag); + + QTextLayout lay(parag); + lay.setCacheEnabled(false); + + // do one run to make sure any fonts are loaded. + lay.beginLayout(); + lay.createLine(); + lay.endLayout(); + + QBENCHMARK { + lay.beginLayout(); + lay.createLine(); + lay.endLayout(); + } +} + +QTEST_MAIN(tst_QText) + +#include "main.moc" diff --git a/tests/benchmarks/qtext/qtext.pro b/tests/benchmarks/qtext/qtext.pro new file mode 100644 index 0000000..ce4f604 --- /dev/null +++ b/tests/benchmarks/qtext/qtext.pro @@ -0,0 +1,7 @@ +load(qttest_p4) +TEMPLATE = app +TARGET = tst_QText + +SOURCES += main.cpp + +DEFINES += SRCDIR=\\\"$$PWD/\\\" |