summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorMartin Smith <msmith@trolltech.com>2010-01-08 11:50:06 (GMT)
committerMartin Smith <msmith@trolltech.com>2010-01-08 11:50:06 (GMT)
commit2530a32d5e02f2cde0cdf3d6d4e42a0079d669fd (patch)
tree479a98d12ffb6df51965c8355f4f0dae4226c38b /tests
parent3aa77d64608f944592939c5d673f1b7dabec730f (diff)
parent4ba439f78aec1caef268dba0f229b8a0242e4c8d (diff)
downloadQt-2530a32d5e02f2cde0cdf3d6d4e42a0079d669fd.zip
Qt-2530a32d5e02f2cde0cdf3d6d4e42a0079d669fd.tar.gz
Qt-2530a32d5e02f2cde0cdf3d6d4e42a0079d669fd.tar.bz2
Merge branch '4.6' of git@scm.dev.nokia.troll.no:qt/oslo-staging-1 into 4.6
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/qaudiodeviceinfo/tst_qaudiodeviceinfo.cpp16
-rw-r--r--tests/auto/qaudioformat/tst_qaudioformat.cpp26
-rw-r--r--tests/auto/qaudioinput/tst_qaudioinput.cpp8
-rw-r--r--tests/auto/qaudiooutput/tst_qaudiooutput.cpp8
-rw-r--r--tests/auto/qfile/tst_qfile.cpp4
-rw-r--r--tests/auto/qnetworkreply/tst_qnetworkreply.cpp207
-rw-r--r--tests/auto/qstylesheetstyle/tst_qstylesheetstyle.cpp14
-rw-r--r--tests/benchmarks/qgraphicsscene/tst_qgraphicsscene.cpp17
8 files changed, 265 insertions, 35 deletions
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/qfile/tst_qfile.cpp b/tests/auto/qfile/tst_qfile.cpp
index 453434d..f407b12 100644
--- a/tests/auto/qfile/tst_qfile.cpp
+++ b/tests/auto/qfile/tst_qfile.cpp
@@ -2119,15 +2119,17 @@ void tst_QFile::fullDisk()
file.write(&c, 0);
QVERIFY(!file.flush());
QCOMPARE(file.error(), QFile::ResourceError);
- file.write(&c, 1);
+ QCOMPARE(file.write(&c, 1), qint64(1));
QVERIFY(!file.flush());
QCOMPARE(file.error(), QFile::ResourceError);
file.close();
QVERIFY(!file.isOpen());
QCOMPARE(file.error(), QFile::ResourceError);
+
file.open(QIODevice::WriteOnly);
QCOMPARE(file.error(), QFile::NoError);
+ QVERIFY(file.flush()); // Shouldn't inherit write buffer
file.close();
QCOMPARE(file.error(), QFile::NoError);
diff --git a/tests/auto/qnetworkreply/tst_qnetworkreply.cpp b/tests/auto/qnetworkreply/tst_qnetworkreply.cpp
index 8f393fe..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();
@@ -223,7 +226,7 @@ private Q_SLOTS:
void ioPostToHttpFromMiddleOfQBufferFiveBytes();
void ioPostToHttpNoBufferFlag();
void ioPostToHttpUploadProgress();
- void ioPostToHttpEmtpyUploadProgress();
+ void ioPostToHttpEmptyUploadProgress();
void lastModifiedHeaderForFile();
void lastModifiedHeaderForHttp();
@@ -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");
@@ -2921,7 +3122,7 @@ void tst_QNetworkReply::ioPostToHttpUploadProgress()
server.close();
}
-void tst_QNetworkReply::ioPostToHttpEmtpyUploadProgress()
+void tst_QNetworkReply::ioPostToHttpEmptyUploadProgress()
{
QByteArray ba;
ba.resize(0);
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/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"