summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorMichael Brasser <michael.brasser@nokia.com>2009-05-22 04:41:04 (GMT)
committerMichael Brasser <michael.brasser@nokia.com>2009-05-22 04:41:04 (GMT)
commitba9caa7181282109ea8def0994838b6538da0b13 (patch)
treef1ae3f595fe6f601ce411d69179d6c0c8c650386 /tests
parent2575eac4c26ad92dde95959a82f576edc3e76e1d (diff)
parentf9d26f0bebd5bcc32d15c4a627251c44cf78389e (diff)
downloadQt-ba9caa7181282109ea8def0994838b6538da0b13.zip
Qt-ba9caa7181282109ea8def0994838b6538da0b13.tar.gz
Qt-ba9caa7181282109ea8def0994838b6538da0b13.tar.bz2
Merge branch 'master' of git@scm.dev.nokia.troll.no:qt/qt into kinetic-declarativeui
Conflicts: src/corelib/kernel/kernel.pri src/corelib/tools/tools.pri tools/qdoc3/htmlgenerator.cpp tools/qdoc3/htmlgenerator.h
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/macgui/tst_gui.cpp7
-rw-r--r--tests/auto/network-settings.h9
-rw-r--r--tests/auto/q3socketdevice/tst_q3socketdevice.cpp7
-rw-r--r--tests/auto/qcalendarwidget/tst_qcalendarwidget.cpp53
-rw-r--r--tests/auto/qcombobox/tst_qcombobox.cpp24
-rw-r--r--tests/auto/qcssparser/tst_cssparser.cpp13
-rw-r--r--tests/auto/qfuture/tst_qfuture.cpp2
-rw-r--r--tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp13
-rw-r--r--tests/auto/qgraphicsscene/tst_qgraphicsscene.cpp4
-rw-r--r--tests/auto/qgraphicsview/tst_qgraphicsview.cpp2
-rw-r--r--tests/auto/qhttpnetworkconnection/tst_qhttpnetworkconnection.cpp9
-rw-r--r--tests/auto/qhttpsocketengine/tst_qhttpsocketengine.cpp25
-rw-r--r--tests/auto/qimage/images/image.tifbin0 -> 2242 bytes
-rw-r--r--tests/auto/qimage/tst_qimage.cpp9
-rw-r--r--tests/auto/qimagereader/images/image_100dpi.tifbin0 -> 2242 bytes
-rw-r--r--tests/auto/qimagereader/qimagereader.pro2
-rw-r--r--tests/auto/qimagereader/qimagereader.qrc1
-rw-r--r--tests/auto/qimagereader/tst_qimagereader.cpp421
-rw-r--r--tests/auto/qimagewriter/tst_qimagewriter.cpp44
-rw-r--r--tests/auto/qiodevice/tst_qiodevice.cpp4
-rw-r--r--tests/auto/qitemmodel/tst_qitemmodel.cpp2
-rw-r--r--tests/auto/qitemview/tst_qitemview.cpp2
-rw-r--r--tests/auto/qmake/testcompiler.cpp6
-rw-r--r--tests/auto/qmap/tst_qmap.cpp17
-rw-r--r--tests/auto/qnativesocketengine/tst_qnativesocketengine.cpp16
-rw-r--r--tests/auto/qnetworkdiskcache/tst_qnetworkdiskcache.cpp3
-rw-r--r--tests/auto/qnetworkreply/tst_qnetworkreply.cpp58
-rw-r--r--tests/auto/qobjectrace/tst_qobjectrace.cpp113
-rw-r--r--tests/auto/qpixmapcache/tst_qpixmapcache.cpp258
-rw-r--r--tests/auto/qprinter/tst_qprinter.cpp5
-rw-r--r--tests/auto/qsharedpointer/tst_qsharedpointer.cpp137
-rw-r--r--tests/auto/qsocks5socketengine/tst_qsocks5socketengine.cpp46
-rw-r--r--tests/auto/qsplitter/tst_qsplitter.cpp5
-rw-r--r--tests/auto/qsslsocket/qsslsocket.pro6
-rw-r--r--tests/auto/qsslsocket/tst_qsslsocket.cpp69
-rw-r--r--tests/auto/qtcpserver/tst_qtcpserver.cpp2
-rw-r--r--tests/auto/qtessellator/testtessellator.cpp2
-rw-r--r--tests/auto/qtessellator/tst_tessellator.cpp8
-rw-r--r--tests/auto/qtessellator/utils.cpp2
-rw-r--r--tests/auto/qthreadonce/tst_qthreadonce.cpp2
-rw-r--r--tests/auto/qwidget/tst_qwidget.cpp1
-rw-r--r--tests/auto/selftests/expected_xunit.txt13
-rw-r--r--tests/auto/selftests/xunit/tst_xunit.cpp29
-rw-r--r--tests/auto/uic/baseline/languagesdialog.ui.h12
-rw-r--r--tests/auto/utf8/tst_utf8.cpp2
-rw-r--r--tests/benchmarks/qgraphicsview/tst_qgraphicsview.cpp1
-rw-r--r--tests/benchmarks/qpixmapcache/qpixmapcache.pro6
-rw-r--r--tests/benchmarks/qpixmapcache/tst_qpixmapcache.cpp226
48 files changed, 1315 insertions, 383 deletions
diff --git a/tests/auto/macgui/tst_gui.cpp b/tests/auto/macgui/tst_gui.cpp
index b302f8b..641e596 100644
--- a/tests/auto/macgui/tst_gui.cpp
+++ b/tests/auto/macgui/tst_gui.cpp
@@ -69,8 +69,7 @@ private slots:
QPixmap grabWindowContents(QWidget * widget)
{
- const int titleBarHeight = widget->frameGeometry().height() - widget->height();
- return QPixmap::grabWindow(widget->winId(), 0, titleBarHeight, -1, widget->height());
+ return QPixmap::grabWindow(widget->winId());
}
/*
@@ -79,10 +78,6 @@ QPixmap grabWindowContents(QWidget * widget)
*/
void tst_gui::scrollbarPainting()
{
-#if defined (Q_WS_MAC) && defined (__i386__)
- QSKIP("This test fails on scruffy when run by the autotest system (but not when you run it manually).", SkipAll);
-#endif
-
ColorWidget colorWidget;
colorWidget.resize(400, 400);
diff --git a/tests/auto/network-settings.h b/tests/auto/network-settings.h
index b2a449a..5a2f9c3 100644
--- a/tests/auto/network-settings.h
+++ b/tests/auto/network-settings.h
@@ -39,6 +39,7 @@
**
****************************************************************************/
#include <QString>
+#include <QtNetwork/QHostInfo>
class QtNetworkSettings
{
@@ -63,4 +64,12 @@ public:
{
return "qt-test-server.wildcard.dev." + serverDomainName();
}
+
+#ifdef QT_NETWORK_LIB
+ static QHostAddress serverIP()
+ {
+ return QHostInfo::fromName(serverName()).addresses().first();
+ }
+#endif
+
};
diff --git a/tests/auto/q3socketdevice/tst_q3socketdevice.cpp b/tests/auto/q3socketdevice/tst_q3socketdevice.cpp
index 2b0c606..6255aee 100644
--- a/tests/auto/q3socketdevice/tst_q3socketdevice.cpp
+++ b/tests/auto/q3socketdevice/tst_q3socketdevice.cpp
@@ -45,6 +45,8 @@
#include <q3socketdevice.h>
+#include "../network-settings.h"
+
//TESTED_CLASS=
//TESTED_FILES=
@@ -97,8 +99,7 @@ void tst_Q3SocketDevice::readNull()
int attempts = 10;
while (attempts--) {
- // connect to imap.troll.no
- if (device.connect(QHostAddress("62.70.27.18"), 143))
+ if (device.connect(QtNetworkSettings::serverIP(), 143))
break;
}
@@ -117,7 +118,7 @@ void tst_Q3SocketDevice::readNull()
#endif
QCOMPARE(device.peerPort(), quint16(143));
QCOMPARE(device.peerAddress().toString(),
- QHostAddress("62.70.27.18").toString());
+ QtNetworkSettings::serverIP().toString());
QCOMPARE(device.error(), Q3SocketDevice::NoError);
// write a logout notice
diff --git a/tests/auto/qcalendarwidget/tst_qcalendarwidget.cpp b/tests/auto/qcalendarwidget/tst_qcalendarwidget.cpp
index 67a822f..617832b 100644
--- a/tests/auto/qcalendarwidget/tst_qcalendarwidget.cpp
+++ b/tests/auto/qcalendarwidget/tst_qcalendarwidget.cpp
@@ -47,6 +47,8 @@
#include <qspinbox.h>
#include <qmenu.h>
#include <qdebug.h>
+#include <qdatetime.h>
+#include <qtextformat.h>
//TESTED_CLASS=
@@ -68,6 +70,11 @@ public slots:
private slots:
void getSetCheck();
void buttonClickCheck();
+
+ void setTextFormat();
+ void resetTextFormat();
+
+ void setWeekdayFormat();
};
// Testing get/set functions
@@ -215,6 +222,52 @@ void tst_QCalendarWidget::buttonClickCheck()
}
+void tst_QCalendarWidget::setTextFormat()
+{
+ QCalendarWidget calendar;
+ QTextCharFormat format;
+ format.setFontItalic(true);
+ format.setForeground(Qt::green);
+
+ const QDate date(1984, 10, 20);
+ calendar.setDateTextFormat(date, format);
+ QCOMPARE(calendar.dateTextFormat(date), format);
+}
+
+void tst_QCalendarWidget::resetTextFormat()
+{
+ QCalendarWidget calendar;
+ QTextCharFormat format;
+ format.setFontItalic(true);
+ format.setForeground(Qt::green);
+
+ const QDate date(1984, 10, 20);
+ calendar.setDateTextFormat(date, format);
+
+ calendar.setDateTextFormat(QDate(), QTextCharFormat());
+ QCOMPARE(calendar.dateTextFormat(date), QTextCharFormat());
+}
+
+void tst_QCalendarWidget::setWeekdayFormat()
+{
+ QCalendarWidget calendar;
+
+ QTextCharFormat format;
+ format.setFontItalic(true);
+ format.setForeground(Qt::green);
+
+ calendar.setWeekdayTextFormat(Qt::Wednesday, format);
+
+ // check the format of the a given month
+ for (int i = 1; i <= 31; ++i) {
+ const QDate date(1984, 10, i);
+ const Qt::DayOfWeek dayOfWeek = static_cast<Qt::DayOfWeek>(date.dayOfWeek());
+ if (dayOfWeek == Qt::Wednesday)
+ QCOMPARE(calendar.weekdayTextFormat(dayOfWeek), format);
+ else
+ QVERIFY(calendar.weekdayTextFormat(dayOfWeek) != format);
+ }
+}
tst_QCalendarWidget::tst_QCalendarWidget()
{
diff --git a/tests/auto/qcombobox/tst_qcombobox.cpp b/tests/auto/qcombobox/tst_qcombobox.cpp
index 6a87e3c..2fff6d0 100644
--- a/tests/auto/qcombobox/tst_qcombobox.cpp
+++ b/tests/auto/qcombobox/tst_qcombobox.cpp
@@ -76,6 +76,7 @@
#endif
#include <qabstractitemview.h>
#include "../../shared/util.h"
+#include <qstyleditemdelegate.h>
//TESTED_CLASS=
//TESTED_FILES=
@@ -141,6 +142,8 @@ private slots:
void setModelColumn();
void noScrollbar_data();
void noScrollbar();
+ void setItemDelegate();
+ void task253944_itemDelegateIsReset();
protected slots:
void onEditTextChanged( const QString &newString );
@@ -2206,5 +2209,26 @@ void tst_QComboBox::noScrollbar()
}
}
+void tst_QComboBox::setItemDelegate()
+{
+ QComboBox comboBox;
+ QStyledItemDelegate *itemDelegate = new QStyledItemDelegate;
+ comboBox.setItemDelegate(itemDelegate);
+ QCOMPARE(comboBox.itemDelegate(), itemDelegate);
+}
+
+void tst_QComboBox::task253944_itemDelegateIsReset()
+{
+ QComboBox comboBox;
+ QStyledItemDelegate *itemDelegate = new QStyledItemDelegate;
+ comboBox.setItemDelegate(itemDelegate);
+
+ comboBox.setEditable(true);
+ QCOMPARE(comboBox.itemDelegate(), itemDelegate);
+
+ comboBox.setStyleSheet("QComboBox { border: 1px solid gray; }");
+ QCOMPARE(comboBox.itemDelegate(), itemDelegate);
+}
+
QTEST_MAIN(tst_QComboBox)
#include "tst_qcombobox.moc"
diff --git a/tests/auto/qcssparser/tst_cssparser.cpp b/tests/auto/qcssparser/tst_cssparser.cpp
index ab6bad6..7c4fac1 100644
--- a/tests/auto/qcssparser/tst_cssparser.cpp
+++ b/tests/auto/qcssparser/tst_cssparser.cpp
@@ -123,7 +123,7 @@ static void debug(const QVector<QCss::Symbol> &symbols, int index = -1)
qDebug() << "failure at index" << index;
}
-static void debug(const QCss::Parser &p) { debug(p.symbols); }
+//static void debug(const QCss::Parser &p) { debug(p.symbols); }
void tst_CssParser::scanner()
{
@@ -1473,7 +1473,12 @@ void tst_CssParser::extractFontFamily_data()
QTest::newRow("quoted-family-name") << "font-family: 'Times New Roman'" << QString("Times New Roman");
QTest::newRow("unquoted-family-name") << "font-family: Times New Roman" << QString("Times New Roman");
QTest::newRow("unquoted-family-name2") << "font-family: Times New Roman" << QString("Times New Roman");
- QTest::newRow("multiple") << "font-family: Times New Roman , foobar, 'baz'" << QString("Times New Roman");
+ QTest::newRow("multiple") << "font-family: Times New Roman , foobar, 'baz'" << QString("Times New Roman");
+ QTest::newRow("multiple2") << "font-family: invalid, Times New Roman " << QString("Times New Roman");
+ QTest::newRow("invalid") << "font-family: invalid" << QFont().family();
+ QTest::newRow("shorthand") << "font: 12pt Times New Roman" << QString("Times New Roman");
+ QTest::newRow("shorthand multiple quote") << "font: 12pt invalid, \"Times New Roman\" " << QString("Times New Roman");
+ QTest::newRow("shorthand multiple") << "font: 12pt invalid, Times New Roman " << QString("Times New Roman");
}
void tst_CssParser::extractFontFamily()
@@ -1497,8 +1502,8 @@ void tst_CssParser::extractFontFamily()
int adjustment = 0;
QFont fnt;
extractor.extractFont(&fnt, &adjustment);
-
- QTEST(fnt.family(), "expectedFamily");
+ QFontInfo info(fnt);
+ QTEST(info.family(), "expectedFamily");
}
void tst_CssParser::extractBorder_data()
diff --git a/tests/auto/qfuture/tst_qfuture.cpp b/tests/auto/qfuture/tst_qfuture.cpp
index 43fd614..383ecba 100644
--- a/tests/auto/qfuture/tst_qfuture.cpp
+++ b/tests/auto/qfuture/tst_qfuture.cpp
@@ -45,7 +45,7 @@
#include <QtTest/QtTest>
#include <qfuture.h>
-#include <versioncheck.h>
+#include "versioncheck.h"
#include <qfuturewatcher.h>
#include <qtconcurrentresultstore.h>
#include <qtconcurrentexception.h>
diff --git a/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp b/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp
index 8602307..b3ae60a 100644
--- a/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp
+++ b/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp
@@ -247,50 +247,59 @@ void tst_QGraphicsItem::construction()
QCOMPARE(int(item->type()), int(QGraphicsEllipseItem::Type));
QCOMPARE(qgraphicsitem_cast<QGraphicsEllipseItem *>(item), (QGraphicsEllipseItem *)item);
QCOMPARE(qgraphicsitem_cast<QGraphicsRectItem *>(item), (QGraphicsRectItem *)0);
+ QCOMPARE(item->flags(), 0);
break;
case 1:
item = new QGraphicsLineItem;
QCOMPARE(int(item->type()), int(QGraphicsLineItem::Type));
QCOMPARE(qgraphicsitem_cast<QGraphicsLineItem *>(item), (QGraphicsLineItem *)item);
QCOMPARE(qgraphicsitem_cast<QGraphicsRectItem *>(item), (QGraphicsRectItem *)0);
+ QCOMPARE(item->flags(), 0);
break;
case 2:
item = new QGraphicsPathItem;
QCOMPARE(int(item->type()), int(QGraphicsPathItem::Type));
QCOMPARE(qgraphicsitem_cast<QGraphicsPathItem *>(item), (QGraphicsPathItem *)item);
QCOMPARE(qgraphicsitem_cast<QGraphicsRectItem *>(item), (QGraphicsRectItem *)0);
+ QCOMPARE(item->flags(), 0);
break;
case 3:
item = new QGraphicsPixmapItem;
QCOMPARE(int(item->type()), int(QGraphicsPixmapItem::Type));
QCOMPARE(qgraphicsitem_cast<QGraphicsPixmapItem *>(item), (QGraphicsPixmapItem *)item);
QCOMPARE(qgraphicsitem_cast<QGraphicsRectItem *>(item), (QGraphicsRectItem *)0);
+ QCOMPARE(item->flags(), 0);
break;
case 4:
item = new QGraphicsPolygonItem;
QCOMPARE(int(item->type()), int(QGraphicsPolygonItem::Type));
QCOMPARE(qgraphicsitem_cast<QGraphicsPolygonItem *>(item), (QGraphicsPolygonItem *)item);
QCOMPARE(qgraphicsitem_cast<QGraphicsRectItem *>(item), (QGraphicsRectItem *)0);
+ QCOMPARE(item->flags(), 0);
break;
case 5:
item = new QGraphicsRectItem;
QCOMPARE(int(item->type()), int(QGraphicsRectItem::Type));
QCOMPARE(qgraphicsitem_cast<QGraphicsRectItem *>(item), (QGraphicsRectItem *)item);
QCOMPARE(qgraphicsitem_cast<QGraphicsLineItem *>(item), (QGraphicsLineItem *)0);
+ QCOMPARE(item->flags(), 0);
break;
case 6:
- default:
item = new QGraphicsTextItem;
QCOMPARE(int(item->type()), int(QGraphicsTextItem::Type));
QCOMPARE(qgraphicsitem_cast<QGraphicsTextItem *>(item), (QGraphicsTextItem *)item);
QCOMPARE(qgraphicsitem_cast<QGraphicsRectItem *>(item), (QGraphicsRectItem *)0);
+ // This is the only item that uses an extended style option.
+ QCOMPARE(item->flags(), QGraphicsItem::GraphicsItemFlags(QGraphicsItem::ItemUsesExtendedStyleOption));
+ break;
+ default:
+ qFatal("You broke the logic, please fix!");
break;
}
QCOMPARE(item->scene(), (QGraphicsScene *)0);
QCOMPARE(item->parentItem(), (QGraphicsItem *)0);
QVERIFY(item->children().isEmpty());
- QCOMPARE(item->flags(), 0);
QVERIFY(item->isVisible());
QVERIFY(item->isEnabled());
QVERIFY(!item->isSelected());
diff --git a/tests/auto/qgraphicsscene/tst_qgraphicsscene.cpp b/tests/auto/qgraphicsscene/tst_qgraphicsscene.cpp
index da99c30..0c5ebf6 100644
--- a/tests/auto/qgraphicsscene/tst_qgraphicsscene.cpp
+++ b/tests/auto/qgraphicsscene/tst_qgraphicsscene.cpp
@@ -47,6 +47,7 @@
#include <QtGui>
#include <math.h>
+#include "../../shared/util.h"
#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE)
#include <windows.h>
@@ -3537,8 +3538,7 @@ void tst_QGraphicsScene::changedSignal()
scene.addItem(rect);
QCOMPARE(cl.changes.size(), 0);
- qApp->processEvents();
- QCOMPARE(cl.changes.size(), 1);
+ QTRY_COMPARE(cl.changes.size(), 1);
QCOMPARE(cl.changes.at(0).size(), 1);
QCOMPARE(cl.changes.at(0).first(), QRectF(0, 0, 10, 10));
diff --git a/tests/auto/qgraphicsview/tst_qgraphicsview.cpp b/tests/auto/qgraphicsview/tst_qgraphicsview.cpp
index 920cba7..8e490ad 100644
--- a/tests/auto/qgraphicsview/tst_qgraphicsview.cpp
+++ b/tests/auto/qgraphicsview/tst_qgraphicsview.cpp
@@ -2371,7 +2371,7 @@ public:
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *viewport)
{
- lastLod = option->levelOfDetail;
+ lastLod = option->levelOfDetailFromTransform(painter->worldTransform());
QGraphicsRectItem::paint(painter, option, viewport);
}
diff --git a/tests/auto/qhttpnetworkconnection/tst_qhttpnetworkconnection.cpp b/tests/auto/qhttpnetworkconnection/tst_qhttpnetworkconnection.cpp
index b22397f..eb30147 100644
--- a/tests/auto/qhttpnetworkconnection/tst_qhttpnetworkconnection.cpp
+++ b/tests/auto/qhttpnetworkconnection/tst_qhttpnetworkconnection.cpp
@@ -42,6 +42,7 @@
#include <QtTest/QtTest>
#include "private/qhttpnetworkconnection_p.h"
+#include "private/qnoncontiguousbytedevice_p.h"
#include <QAuthenticator>
#include "../network-settings.h"
@@ -303,8 +304,8 @@ void tst_QHttpNetworkConnection::put()
QHttpNetworkRequest request(protocol + host + path, QHttpNetworkRequest::Put);
QByteArray array = data.toLatin1();
- QBuffer buffer(&array);
- request.setData(&buffer);
+ QNonContiguousByteDevice *bd = QNonContiguousByteDeviceFactory::create(&array);
+ request.setUploadByteDevice(bd);
finishedCalled = false;
finishedWithErrorCalled = false;
@@ -393,8 +394,8 @@ void tst_QHttpNetworkConnection::post()
QHttpNetworkRequest request(protocol + host + path, QHttpNetworkRequest::Post);
QByteArray array = data.toLatin1();
- QBuffer buffer(&array);
- request.setData(&buffer);
+ QNonContiguousByteDevice *bd = QNonContiguousByteDeviceFactory::create(&array);
+ request.setUploadByteDevice(bd);
QHttpNetworkReply *reply = connection.sendRequest(request);
diff --git a/tests/auto/qhttpsocketengine/tst_qhttpsocketengine.cpp b/tests/auto/qhttpsocketengine/tst_qhttpsocketengine.cpp
index 9ef8f9a..7eaf7c7 100644
--- a/tests/auto/qhttpsocketengine/tst_qhttpsocketengine.cpp
+++ b/tests/auto/qhttpsocketengine/tst_qhttpsocketengine.cpp
@@ -137,8 +137,6 @@ public slots:
}
};
-static const char *IMAP_IP = "62.70.27.18";
-
tst_QHttpSocketEngine::tst_QHttpSocketEngine()
{
}
@@ -307,12 +305,11 @@ void tst_QHttpSocketEngine::simpleConnectToIMAP()
socketDevice.setProxy(QNetworkProxy(QNetworkProxy::HttpProxy, QtNetworkSettings::serverName(), 3128));
- // Connect to imap.trolltech.com's IP
- QVERIFY(!socketDevice.connectToHost(QHostAddress(IMAP_IP), 143));
+ QVERIFY(!socketDevice.connectToHost(QtNetworkSettings::serverIP(), 143));
QVERIFY(socketDevice.state() == QAbstractSocket::ConnectingState);
QVERIFY(socketDevice.waitForWrite());
QVERIFY(socketDevice.state() == QAbstractSocket::ConnectedState);
- QVERIFY(socketDevice.peerAddress() == QHostAddress(IMAP_IP));
+ QVERIFY(socketDevice.peerAddress() == QtNetworkSettings::serverIP());
QVERIFY(!socketDevice.localAddress().isNull());
QVERIFY(socketDevice.localPort() > 0);
@@ -328,7 +325,7 @@ void tst_QHttpSocketEngine::simpleConnectToIMAP()
// Check that the greeting is what we expect it to be
QCOMPARE(array.constData(),
- "* OK esparsett Cyrus IMAP4 v2.2.8 server ready\r\n");
+ "* OK [CAPABILITY IMAP4 IMAP4rev1 LITERAL+ ID STARTTLS LOGINDISABLED] qt-test-server.qt-test-net Cyrus IMAP4 v2.3.11-Mandriva-RPM-2.3.11-6mdv2008.1 server ready\r\n");
// Write a logout message
QByteArray array2 = "XXXX LOGOUT\r\n";
@@ -369,7 +366,6 @@ void tst_QHttpSocketEngine::simpleErrorsAndStates()
QVERIFY(!socketDevice.connectToHost(QHostAddress(QtNetworkSettings::serverName()), 8088));
QVERIFY(socketDevice.state() == QAbstractSocket::ConnectingState);
if (socketDevice.waitForWrite(15000)) {
- qDebug() << socketDevice.state();
QVERIFY(socketDevice.state() == QAbstractSocket::ConnectedState ||
socketDevice.state() == QAbstractSocket::UnconnectedState);
} else {
@@ -451,14 +447,14 @@ void tst_QHttpSocketEngine::tcpSocketBlockingTest()
QTcpSocket socket;
// Connect
- socket.connectToHost("imap.troll.no", 143);
+ socket.connectToHost(QtNetworkSettings::serverName(), 143);
QVERIFY(socket.waitForConnected());
QCOMPARE(socket.state(), QTcpSocket::ConnectedState);
// Read greeting
QVERIFY(socket.waitForReadyRead(5000));
QString s = socket.readLine();
- QCOMPARE(s.toLatin1().constData(), "* OK esparsett Cyrus IMAP4 v2.2.8 server ready\r\n");
+ QCOMPARE(s.toLatin1().constData(), "* OK [CAPABILITY IMAP4 IMAP4rev1 LITERAL+ ID STARTTLS LOGINDISABLED] qt-test-server.qt-test-net Cyrus IMAP4 v2.3.11-Mandriva-RPM-2.3.11-6mdv2008.1 server ready\r\n");
// Write NOOP
QCOMPARE((int) socket.write("1 NOOP\r\n", 8), 8);
@@ -508,7 +504,7 @@ void tst_QHttpSocketEngine::tcpSocketNonBlockingTest()
tcpSocketNonBlocking_socket = &socket;
// Connect
- socket.connectToHost("imap.troll.no", 143);
+ socket.connectToHost(QtNetworkSettings::serverName(), 143);
QCOMPARE(socket.state(), QTcpSocket::HostLookupState);
QTestEventLoop::instance().enterLoop(30);
@@ -533,7 +529,7 @@ void tst_QHttpSocketEngine::tcpSocketNonBlockingTest()
// Read greeting
QVERIFY(!tcpSocketNonBlocking_data.isEmpty());
QCOMPARE(tcpSocketNonBlocking_data.at(0).toLatin1().constData(),
- "* OK esparsett Cyrus IMAP4 v2.2.8 server ready\r\n");
+ "* OK [CAPABILITY IMAP4 IMAP4rev1 LITERAL+ ID STARTTLS LOGINDISABLED] qt-test-server.qt-test-net Cyrus IMAP4 v2.3.11-Mandriva-RPM-2.3.11-6mdv2008.1 server ready\r\n");
tcpSocketNonBlocking_data.clear();
tcpSocketNonBlocking_totalWritten = 0;
@@ -696,12 +692,11 @@ void tst_QHttpSocketEngine::passwordAuth()
socketDevice.setProxy(QNetworkProxy(QNetworkProxy::HttpProxy, QtNetworkSettings::serverName(), 3128, "qsockstest", "password"));
- // Connect to imap.trolltech.com's IP
- QVERIFY(!socketDevice.connectToHost(QHostAddress(IMAP_IP), 143));
+ QVERIFY(!socketDevice.connectToHost(QtNetworkSettings::serverIP(), 143));
QVERIFY(socketDevice.state() == QAbstractSocket::ConnectingState);
QVERIFY(socketDevice.waitForWrite());
QVERIFY(socketDevice.state() == QAbstractSocket::ConnectedState);
- QVERIFY(socketDevice.peerAddress() == QHostAddress(IMAP_IP));
+ QVERIFY(socketDevice.peerAddress() == QtNetworkSettings::serverIP());
// Wait for the greeting
QVERIFY(socketDevice.waitForRead());
@@ -715,7 +710,7 @@ void tst_QHttpSocketEngine::passwordAuth()
// Check that the greeting is what we expect it to be
QCOMPARE(array.constData(),
- "* OK esparsett Cyrus IMAP4 v2.2.8 server ready\r\n");
+ "* OK [CAPABILITY IMAP4 IMAP4rev1 LITERAL+ ID STARTTLS LOGINDISABLED] qt-test-server.qt-test-net Cyrus IMAP4 v2.3.11-Mandriva-RPM-2.3.11-6mdv2008.1 server ready\r\n");
// Write a logout message
QByteArray array2 = "XXXX LOGOUT\r\n";
diff --git a/tests/auto/qimage/images/image.tif b/tests/auto/qimage/images/image.tif
new file mode 100644
index 0000000..ee0637c
--- /dev/null
+++ b/tests/auto/qimage/images/image.tif
Binary files differ
diff --git a/tests/auto/qimage/tst_qimage.cpp b/tests/auto/qimage/tst_qimage.cpp
index ee4ece2..c6b0560 100644
--- a/tests/auto/qimage/tst_qimage.cpp
+++ b/tests/auto/qimage/tst_qimage.cpp
@@ -274,6 +274,9 @@ void tst_QImage::formatHandlersInput_data()
QTest::newRow("PPM") << "PPM" << prefix + "image.ppm";
QTest::newRow("XBM") << "XBM" << prefix + "image.xbm";
QTest::newRow("XPM") << "XPM" << prefix + "image.xpm";
+#if defined QTEST_HAVE_TIFF
+ QTest::newRow("TIFF") << "TIFF" << prefix + "image.tif";
+#endif
}
void tst_QImage::formatHandlersInput()
@@ -1454,9 +1457,9 @@ void tst_QImage::smoothScale3()
QRgb cb = b.pixel(x, y);
// tolerate a little bit of rounding errors
- QVERIFY(compare(qRed(ca), qRed(cb), 2));
- QVERIFY(compare(qGreen(ca), qGreen(cb), 2));
- QVERIFY(compare(qBlue(ca), qBlue(cb), 2));
+ QVERIFY(compare(qRed(ca), qRed(cb), 3));
+ QVERIFY(compare(qGreen(ca), qGreen(cb), 3));
+ QVERIFY(compare(qBlue(ca), qBlue(cb), 3));
}
}
}
diff --git a/tests/auto/qimagereader/images/image_100dpi.tif b/tests/auto/qimagereader/images/image_100dpi.tif
new file mode 100644
index 0000000..fcf3cd8
--- /dev/null
+++ b/tests/auto/qimagereader/images/image_100dpi.tif
Binary files differ
diff --git a/tests/auto/qimagereader/qimagereader.pro b/tests/auto/qimagereader/qimagereader.pro
index b178823..2c9510e 100644
--- a/tests/auto/qimagereader/qimagereader.pro
+++ b/tests/auto/qimagereader/qimagereader.pro
@@ -3,6 +3,7 @@ SOURCES += tst_qimagereader.cpp
MOC_DIR=tmp
QT += network
RESOURCES += qimagereader.qrc
+DEFINES += SRCDIR=\\\"$$PWD\\\"
!contains(QT_CONFIG, no-gif):DEFINES += QTEST_HAVE_GIF
!contains(QT_CONFIG, no-jpeg):DEFINES += QTEST_HAVE_JPEG
@@ -22,5 +23,6 @@ wince*: {
imagePlugins.path = imageformats
DEPLOYMENT += images imagePlugins
+ DEFINES += SRCDIR=\\\".\\\"
}
diff --git a/tests/auto/qimagereader/qimagereader.qrc b/tests/auto/qimagereader/qimagereader.qrc
index 13ce582..3c674ad 100644
--- a/tests/auto/qimagereader/qimagereader.qrc
+++ b/tests/auto/qimagereader/qimagereader.qrc
@@ -30,6 +30,7 @@
<file>images/image.pgm</file>
<file>images/image.png</file>
<file>images/image.ppm</file>
+ <file>images/image.tif</file>
<file>images/kollada.png</file>
<file>images/marble.xpm</file>
<file>images/namedcolors.xpm</file>
diff --git a/tests/auto/qimagereader/tst_qimagereader.cpp b/tests/auto/qimagereader/tst_qimagereader.cpp
index 8f7094c..f5313eb 100644
--- a/tests/auto/qimagereader/tst_qimagereader.cpp
+++ b/tests/auto/qimagereader/tst_qimagereader.cpp
@@ -158,6 +158,8 @@ private slots:
void pixelCompareWithBaseline();
};
+static const QLatin1String prefix(SRCDIR "/images/");
+
// Testing get/set functions
void tst_QImageReader::getSetCheck()
{
@@ -232,7 +234,7 @@ void tst_QImageReader::readImage()
QFETCH(QByteArray, format);
for (int i = 0; i < 2; ++i) {
- QImageReader io("images/" + fileName, i ? QByteArray() : format);
+ QImageReader io(prefix + fileName, i ? QByteArray() : format);
if (success) {
if (!io.supportsAnimation())
QVERIFY(io.imageCount() > 0);
@@ -248,16 +250,16 @@ void tst_QImageReader::readImage()
QVERIFY2(!image.isNull(), io.errorString().toLatin1().constData());
// No format
- QImageReader io2("images/" + fileName);
+ QImageReader io2(prefix + fileName);
QVERIFY2(!io2.read().isNull(), io.errorString().toLatin1().constData());
// No extension, no format
- QImageReader io3("images/" + fileName.left(fileName.lastIndexOf(QLatin1Char('.'))));
+ QImageReader io3(prefix + fileName.left(fileName.lastIndexOf(QLatin1Char('.'))));
QVERIFY2(!io3.read().isNull(), io.errorString().toLatin1().constData());
// Read into \a image2
QImage image2;
- QImageReader image2Reader("images/" + fileName, i ? QByteArray() : format);
+ QImageReader image2Reader(prefix + fileName, i ? QByteArray() : format);
QCOMPARE(image2Reader.format(), format);
QVERIFY(image2Reader.read(&image2));
if (image2Reader.canRead()) {
@@ -281,8 +283,8 @@ void tst_QImageReader::readImage()
void tst_QImageReader::jpegRgbCmyk()
{
- QImage image1(QLatin1String("images/YCbCr_cmyk.jpg"));
- QImage image2(QLatin1String("images/YCbCr_cmyk.png"));
+ QImage image1(prefix + QLatin1String("YCbCr_cmyk.jpg"));
+ QImage image2(prefix + QLatin1String("YCbCr_cmyk.png"));
QCOMPARE(image1, image2);
}
@@ -293,24 +295,24 @@ void tst_QImageReader::setScaledSize_data()
QTest::addColumn<QSize>("newSize");
QTest::addColumn<QByteArray>("format");
- QTest::newRow("BMP: colorful") << "images/colorful" << QSize(200, 200) << QByteArray("bmp");
- QTest::newRow("BMP: font") << "images/font" << QSize(200, 200) << QByteArray("bmp");
- QTest::newRow("XPM: marble") << "images/marble" << QSize(200, 200) << QByteArray("xpm");
- QTest::newRow("PNG: kollada") << "images/kollada" << QSize(200, 200) << QByteArray("png");
- QTest::newRow("PPM: teapot") << "images/teapot" << QSize(200, 200) << QByteArray("ppm");
- QTest::newRow("PPM: runners") << "images/runners.ppm" << QSize(400, 400) << QByteArray("ppm");
- QTest::newRow("PPM: test") << "images/test.ppm" << QSize(10, 10) << QByteArray("ppm");
- QTest::newRow("XBM: gnus") << "images/gnus" << QSize(200, 200) << QByteArray("xbm");
+ QTest::newRow("BMP: colorful") << "colorful" << QSize(200, 200) << QByteArray("bmp");
+ QTest::newRow("BMP: font") << "font" << QSize(200, 200) << QByteArray("bmp");
+ QTest::newRow("XPM: marble") << "marble" << QSize(200, 200) << QByteArray("xpm");
+ QTest::newRow("PNG: kollada") << "kollada" << QSize(200, 200) << QByteArray("png");
+ QTest::newRow("PPM: teapot") << "teapot" << QSize(200, 200) << QByteArray("ppm");
+ QTest::newRow("PPM: runners") << "runners.ppm" << QSize(400, 400) << QByteArray("ppm");
+ QTest::newRow("PPM: test") << "test.ppm" << QSize(10, 10) << QByteArray("ppm");
+ QTest::newRow("XBM: gnus") << "gnus" << QSize(200, 200) << QByteArray("xbm");
#ifdef QTEST_HAVE_JPEG
- QTest::newRow("JPEG: beavis") << "images/beavis" << QSize(200, 200) << QByteArray("jpeg");
+ QTest::newRow("JPEG: beavis") << "beavis" << QSize(200, 200) << QByteArray("jpeg");
#endif // QTEST_HAVE_JPEG
#ifdef QTEST_HAVE_GIF
- QTest::newRow("GIF: earth") << "images/earth" << QSize(200, 200) << QByteArray("gif");
- QTest::newRow("GIF: trolltech") << "images/trolltech" << QSize(200, 200) << QByteArray("gif");
+ QTest::newRow("GIF: earth") << "earth" << QSize(200, 200) << QByteArray("gif");
+ QTest::newRow("GIF: trolltech") << "trolltech" << QSize(200, 200) << QByteArray("gif");
#endif // QTEST_HAVE_GIF
#ifdef QTEST_HAVE_MNG
- QTest::newRow("MNG: ball") << "images/ball" << QSize(200, 200) << QByteArray("mng");
- QTest::newRow("MNG: fire") << "images/fire" << QSize(200, 200) << QByteArray("mng");
+ QTest::newRow("MNG: ball") << "ball" << QSize(200, 200) << QByteArray("mng");
+ QTest::newRow("MNG: fire") << "fire" << QSize(200, 200) << QByteArray("mng");
#endif // QTEST_HAVE_MNG
}
@@ -323,7 +325,7 @@ void tst_QImageReader::setScaledSize()
if (!format.isEmpty() && !QImageReader::supportedImageFormats().contains(format))
QSKIP("Qt does not support reading the \"" + format + "\" format", SkipSingle);
- QImageReader reader(fileName);
+ QImageReader reader(prefix + fileName);
reader.setScaledSize(newSize);
QImage image = reader.read();
QVERIFY(!image.isNull());
@@ -336,25 +338,25 @@ void tst_QImageReader::setClipRect_data()
QTest::addColumn<QString>("fileName");
QTest::addColumn<QRect>("newRect");
QTest::addColumn<QByteArray>("format");
- QTest::newRow("BMP: colorful") << "images/colorful" << QRect(0, 0, 50, 50) << QByteArray("bmp");
- QTest::newRow("BMP: font") << "images/font" << QRect(0, 0, 50, 50) << QByteArray("bmp");
- QTest::newRow("BMP: 4bpp uncompressed") << "images/tst7.bmp" << QRect(0, 0, 31, 31) << QByteArray("bmp");
- QTest::newRow("XPM: marble") << "images/marble" << QRect(0, 0, 50, 50) << QByteArray("xpm");
- QTest::newRow("PNG: kollada") << "images/kollada" << QRect(0, 0, 50, 50) << QByteArray("png");
- QTest::newRow("PPM: teapot") << "images/teapot" << QRect(0, 0, 50, 50) << QByteArray("ppm");
- QTest::newRow("PPM: runners") << "images/runners.ppm" << QRect(0, 0, 50, 50) << QByteArray("ppm");
- QTest::newRow("PPM: test") << "images/test.ppm" << QRect(0, 0, 50, 50) << QByteArray("ppm");
- QTest::newRow("XBM: gnus") << "images/gnus" << QRect(0, 0, 50, 50) << QByteArray("xbm");
+ QTest::newRow("BMP: colorful") << "colorful" << QRect(0, 0, 50, 50) << QByteArray("bmp");
+ QTest::newRow("BMP: font") << "font" << QRect(0, 0, 50, 50) << QByteArray("bmp");
+ QTest::newRow("BMP: 4bpp uncompressed") << "tst7.bmp" << QRect(0, 0, 31, 31) << QByteArray("bmp");
+ QTest::newRow("XPM: marble") << "marble" << QRect(0, 0, 50, 50) << QByteArray("xpm");
+ QTest::newRow("PNG: kollada") << "kollada" << QRect(0, 0, 50, 50) << QByteArray("png");
+ QTest::newRow("PPM: teapot") << "teapot" << QRect(0, 0, 50, 50) << QByteArray("ppm");
+ QTest::newRow("PPM: runners") << "runners.ppm" << QRect(0, 0, 50, 50) << QByteArray("ppm");
+ QTest::newRow("PPM: test") << "test.ppm" << QRect(0, 0, 50, 50) << QByteArray("ppm");
+ QTest::newRow("XBM: gnus") << "gnus" << QRect(0, 0, 50, 50) << QByteArray("xbm");
#ifdef QTEST_HAVE_JPEG
- QTest::newRow("JPEG: beavis") << "images/beavis" << QRect(0, 0, 50, 50) << QByteArray("jpeg");
+ QTest::newRow("JPEG: beavis") << "beavis" << QRect(0, 0, 50, 50) << QByteArray("jpeg");
#endif // QTEST_HAVE_JPEG
#ifdef QTEST_HAVE_GIF
- QTest::newRow("GIF: earth") << "images/earth" << QRect(0, 0, 50, 50) << QByteArray("gif");
- QTest::newRow("GIF: trolltech") << "images/trolltech" << QRect(0, 0, 50, 50) << QByteArray("gif");
+ QTest::newRow("GIF: earth") << "earth" << QRect(0, 0, 50, 50) << QByteArray("gif");
+ QTest::newRow("GIF: trolltech") << "trolltech" << QRect(0, 0, 50, 50) << QByteArray("gif");
#endif // QTEST_HAVE_GIF
#ifdef QTEST_HAVE_MNG
- QTest::newRow("MNG: ball") << "images/ball" << QRect(0, 0, 50, 50) << QByteArray("mng");
- QTest::newRow("MNG: fire") << "images/fire" << QRect(0, 0, 50, 50) << QByteArray("mng");
+ QTest::newRow("MNG: ball") << "ball" << QRect(0, 0, 50, 50) << QByteArray("mng");
+ QTest::newRow("MNG: fire") << "fire" << QRect(0, 0, 50, 50) << QByteArray("mng");
#endif // QTEST_HAVE_MNG
}
@@ -367,13 +369,13 @@ void tst_QImageReader::setClipRect()
if (!format.isEmpty() && !QImageReader::supportedImageFormats().contains(format))
QSKIP("Qt does not support reading the \"" + format + "\" format", SkipSingle);
- QImageReader reader(fileName);
+ QImageReader reader(prefix + fileName);
reader.setClipRect(newRect);
QImage image = reader.read();
QVERIFY(!image.isNull());
QCOMPARE(image.rect(), newRect);
- QImageReader originalReader(fileName);
+ QImageReader originalReader(prefix + fileName);
QImage originalImage = originalReader.read();
QCOMPARE(originalImage.copy(newRect), image);
}
@@ -384,24 +386,24 @@ void tst_QImageReader::setScaledClipRect_data()
QTest::addColumn<QRect>("newRect");
QTest::addColumn<QByteArray>("format");
- QTest::newRow("BMP: colorful") << "images/colorful" << QRect(0, 0, 50, 50) << QByteArray("bmp");
- QTest::newRow("BMP: font") << "images/font" << QRect(0, 0, 50, 50) << QByteArray("bmp");
- QTest::newRow("XPM: marble") << "images/marble" << QRect(0, 0, 50, 50) << QByteArray("xpm");
- QTest::newRow("PNG: kollada") << "images/kollada" << QRect(0, 0, 50, 50) << QByteArray("png");
- QTest::newRow("PPM: teapot") << "images/teapot" << QRect(0, 0, 50, 50) << QByteArray("ppm");
- QTest::newRow("PPM: runners") << "images/runners.ppm" << QRect(0, 0, 50, 50) << QByteArray("ppm");
- QTest::newRow("PPM: test") << "images/test.ppm" << QRect(0, 0, 50, 50) << QByteArray("ppm");
- QTest::newRow("XBM: gnus") << "images/gnus" << QRect(0, 0, 50, 50) << QByteArray("xbm");
+ QTest::newRow("BMP: colorful") << "colorful" << QRect(0, 0, 50, 50) << QByteArray("bmp");
+ QTest::newRow("BMP: font") << "font" << QRect(0, 0, 50, 50) << QByteArray("bmp");
+ QTest::newRow("XPM: marble") << "marble" << QRect(0, 0, 50, 50) << QByteArray("xpm");
+ QTest::newRow("PNG: kollada") << "kollada" << QRect(0, 0, 50, 50) << QByteArray("png");
+ QTest::newRow("PPM: teapot") << "teapot" << QRect(0, 0, 50, 50) << QByteArray("ppm");
+ QTest::newRow("PPM: runners") << "runners.ppm" << QRect(0, 0, 50, 50) << QByteArray("ppm");
+ QTest::newRow("PPM: test") << "test.ppm" << QRect(0, 0, 50, 50) << QByteArray("ppm");
+ QTest::newRow("XBM: gnus") << "gnus" << QRect(0, 0, 50, 50) << QByteArray("xbm");
#ifdef QTEST_HAVE_JPEG
- QTest::newRow("JPEG: beavis") << "images/beavis" << QRect(0, 0, 50, 50) << QByteArray("jpeg");
+ QTest::newRow("JPEG: beavis") << "beavis" << QRect(0, 0, 50, 50) << QByteArray("jpeg");
#endif // QTEST_HAVE_JPEG
#ifdef QTEST_HAVE_GIF
- QTest::newRow("GIF: earth") << "images/earth" << QRect(0, 0, 50, 50) << QByteArray("gif");
- QTest::newRow("GIF: trolltech") << "images/trolltech" << QRect(0, 0, 50, 50) << QByteArray("gif");
+ QTest::newRow("GIF: earth") << "earth" << QRect(0, 0, 50, 50) << QByteArray("gif");
+ QTest::newRow("GIF: trolltech") << "trolltech" << QRect(0, 0, 50, 50) << QByteArray("gif");
#endif // QTEST_HAVE_GIF
#ifdef QTEST_HAVE_MNG
- QTest::newRow("MNG: ball") << "images/ball" << QRect(0, 0, 50, 50) << QByteArray("mng");
- QTest::newRow("MNG: fire") << "images/fire" << QRect(0, 0, 50, 50) << QByteArray("mng");
+ QTest::newRow("MNG: ball") << "ball" << QRect(0, 0, 50, 50) << QByteArray("mng");
+ QTest::newRow("MNG: fire") << "fire" << QRect(0, 0, 50, 50) << QByteArray("mng");
#endif // QTEST_HAVE_MNG
}
@@ -414,14 +416,14 @@ void tst_QImageReader::setScaledClipRect()
if (!format.isEmpty() && !QImageReader::supportedImageFormats().contains(format))
QSKIP("Qt does not support reading the \"" + format + "\" format", SkipSingle);
- QImageReader reader(fileName);
+ QImageReader reader(prefix + fileName);
reader.setScaledSize(QSize(300, 300));
reader.setScaledClipRect(newRect);
QImage image = reader.read();
QVERIFY(!image.isNull());
QCOMPARE(image.rect(), newRect);
- QImageReader originalReader(fileName);
+ QImageReader originalReader(prefix + fileName);
originalReader.setScaledSize(QSize(300, 300));
QImage originalImage = originalReader.read();
QCOMPARE(originalImage.copy(newRect), image);
@@ -433,29 +435,29 @@ void tst_QImageReader::imageFormat_data()
QTest::addColumn<QByteArray>("format");
QTest::addColumn<QImage::Format>("imageFormat");
- QTest::newRow("pbm") << QString("images/image.pbm") << QByteArray("pbm") << QImage::Format_Mono;
- QTest::newRow("pgm") << QString("images/image.pgm") << QByteArray("pgm") << QImage::Format_Indexed8;
- QTest::newRow("ppm-1") << QString("images/image.ppm") << QByteArray("ppm") << QImage::Format_RGB32;
- QTest::newRow("ppm-2") << QString("images/teapot.ppm") << QByteArray("ppm") << QImage::Format_RGB32;
- QTest::newRow("ppm-3") << QString("images/runners.ppm") << QByteArray("ppm") << QImage::Format_RGB32;
- QTest::newRow("ppm-4") << QString("images/test.ppm") << QByteArray("ppm") << QImage::Format_RGB32;
+ QTest::newRow("pbm") << QString("image.pbm") << QByteArray("pbm") << QImage::Format_Mono;
+ QTest::newRow("pgm") << QString("image.pgm") << QByteArray("pgm") << QImage::Format_Indexed8;
+ QTest::newRow("ppm-1") << QString("image.ppm") << QByteArray("ppm") << QImage::Format_RGB32;
+ QTest::newRow("ppm-2") << QString("teapot.ppm") << QByteArray("ppm") << QImage::Format_RGB32;
+ QTest::newRow("ppm-3") << QString("runners.ppm") << QByteArray("ppm") << QImage::Format_RGB32;
+ QTest::newRow("ppm-4") << QString("test.ppm") << QByteArray("ppm") << QImage::Format_RGB32;
#ifdef QTEST_HAVE_JPEG
- QTest::newRow("jpeg-1") << QString("images/beavis.jpg") << QByteArray("jpeg") << QImage::Format_Indexed8;
- QTest::newRow("jpeg-2") << QString("images/YCbCr_cmyk.jpg") << QByteArray("jpeg") << QImage::Format_RGB32;
- QTest::newRow("jpeg-3") << QString("images/YCbCr_rgb.jpg") << QByteArray("jpeg") << QImage::Format_RGB32;
+ QTest::newRow("jpeg-1") << QString("beavis.jpg") << QByteArray("jpeg") << QImage::Format_Indexed8;
+ QTest::newRow("jpeg-2") << QString("YCbCr_cmyk.jpg") << QByteArray("jpeg") << QImage::Format_RGB32;
+ QTest::newRow("jpeg-3") << QString("YCbCr_rgb.jpg") << QByteArray("jpeg") << QImage::Format_RGB32;
#endif
#if defined QTEST_HAVE_GIF
- QTest::newRow("gif-1") << QString("images/earth.gif") << QByteArray("gif") << QImage::Format_Invalid;
- QTest::newRow("gif-2") << QString("images/trolltech.gif") << QByteArray("gif") << QImage::Format_Invalid;
+ QTest::newRow("gif-1") << QString("earth.gif") << QByteArray("gif") << QImage::Format_Invalid;
+ QTest::newRow("gif-2") << QString("trolltech.gif") << QByteArray("gif") << QImage::Format_Invalid;
#endif
- QTest::newRow("xbm") << QString("images/gnus.xbm") << QByteArray("xbm") << QImage::Format_MonoLSB;
- QTest::newRow("xpm") << QString("images/marble.xpm") << QByteArray("xpm") << QImage::Format_Indexed8;
- QTest::newRow("bmp-1") << QString("images/colorful.bmp") << QByteArray("bmp") << QImage::Format_Indexed8;
- QTest::newRow("bmp-2") << QString("images/font.bmp") << QByteArray("bmp") << QImage::Format_Indexed8;
- QTest::newRow("png") << QString("images/kollada.png") << QByteArray("png") << QImage::Format_ARGB32;
- QTest::newRow("png-2") << QString("images/YCbCr_cmyk.png") << QByteArray("png") << QImage::Format_RGB32;
- QTest::newRow("mng-1") << QString("images/ball.mng") << QByteArray("mng") << QImage::Format_Invalid;
- QTest::newRow("mng-2") << QString("images/fire.mng") << QByteArray("mng") << QImage::Format_Invalid;
+ QTest::newRow("xbm") << QString("gnus.xbm") << QByteArray("xbm") << QImage::Format_MonoLSB;
+ QTest::newRow("xpm") << QString("marble.xpm") << QByteArray("xpm") << QImage::Format_Indexed8;
+ QTest::newRow("bmp-1") << QString("colorful.bmp") << QByteArray("bmp") << QImage::Format_Indexed8;
+ QTest::newRow("bmp-2") << QString("font.bmp") << QByteArray("bmp") << QImage::Format_Indexed8;
+ QTest::newRow("png") << QString("kollada.png") << QByteArray("png") << QImage::Format_ARGB32;
+ QTest::newRow("png-2") << QString("YCbCr_cmyk.png") << QByteArray("png") << QImage::Format_RGB32;
+ QTest::newRow("mng-1") << QString("ball.mng") << QByteArray("mng") << QImage::Format_Invalid;
+ QTest::newRow("mng-2") << QString("fire.mng") << QByteArray("mng") << QImage::Format_Invalid;
}
void tst_QImageReader::imageFormat()
@@ -463,7 +465,8 @@ void tst_QImageReader::imageFormat()
QFETCH(QString, fileName);
QFETCH(QByteArray, format);
QFETCH(QImage::Format, imageFormat);
- if (QImageReader::imageFormat(fileName).isEmpty()) {
+
+ if (QImageReader::imageFormat(prefix + fileName).isEmpty()) {
if (QByteArray("jpeg") == format)
#ifndef QTEST_HAVE_JPEG
return;
@@ -478,31 +481,31 @@ void tst_QImageReader::imageFormat()
#endif // !QTEST_HAVE_MNG
QSKIP(("Qt does not support the " + format + " format.").constData(), SkipSingle);
} else {
- QCOMPARE(QImageReader::imageFormat(fileName), format);
+ QCOMPARE(QImageReader::imageFormat(prefix + fileName), format);
}
- QImageReader reader(fileName);
+ QImageReader reader(prefix + fileName);
QCOMPARE(reader.imageFormat(), imageFormat);
}
void tst_QImageReader::blackXPM()
{
- QImage image(QLatin1String("images/black.xpm"));
- QImage image2(QLatin1String("images/black.png"));
+ QImage image(prefix + QLatin1String("black.xpm"));
+ QImage image2(prefix + QLatin1String("black.png"));
QCOMPARE(image.pixel(25, 25), qRgb(190, 190, 190));
QCOMPARE(image.pixel(25, 25), image2.pixel(25, 25));
}
void tst_QImageReader::transparentXPM()
{
- QImage image(QLatin1String("images/nontransparent.xpm"));
- QImage image2(QLatin1String("images/transparent.xpm"));
+ QImage image(prefix + QLatin1String("nontransparent.xpm"));
+ QImage image2(prefix + QLatin1String("transparent.xpm"));
QCOMPARE(image.format(), QImage::Format_RGB32);
QCOMPARE(image2.format(), QImage::Format_ARGB32);
}
void tst_QImageReader::multiWordNamedColorXPM()
{
- QImage image(QLatin1String("images/namedcolors.xpm"));
+ QImage image(prefix + QLatin1String("namedcolors.xpm"));
QCOMPARE(image.pixel(0, 0), qRgb(102, 139, 139)); // pale turquoise 4
QCOMPARE(image.pixel(0, 1), qRgb(250, 250, 210)); // light golden rod yellow
QCOMPARE(image.pixel(0, 2), qRgb(255, 250, 205)); // lemon chiffon
@@ -593,7 +596,7 @@ void tst_QImageReader::supportsAnimation()
{
QFETCH(QString, fileName);
QFETCH(bool, success);
- QImageReader io("images/" + fileName);
+ QImageReader io(prefix + fileName);
QCOMPARE(io.supportsAnimation(), success);
}
@@ -606,7 +609,7 @@ void tst_QImageReader::sizeBeforeRead()
{
QFETCH(QString, fileName);
QFETCH(QByteArray, format);
- QImageReader reader(fileName);
+ QImageReader reader(prefix + fileName);
QVERIFY(reader.canRead());
if (format == "mng") {
QCOMPARE(reader.size(), QSize());
@@ -644,7 +647,7 @@ void tst_QImageReader::imageFormatBeforeRead()
void tst_QImageReader::gifHandlerBugs()
{
{
- QImageReader io("images/trolltech.gif");
+ QImageReader io(prefix + "trolltech.gif");
QVERIFY(io.loopCount() != 1);
int count=0;
for (; io.canRead(); io.read(), ++count) ;
@@ -653,8 +656,8 @@ void tst_QImageReader::gifHandlerBugs()
// Task 95166
{
- QImageReader io1("images/bat1.gif");
- QImageReader io2("images/bat2.gif");
+ QImageReader io1(prefix + "bat1.gif");
+ QImageReader io2(prefix + "bat2.gif");
QVERIFY(io1.canRead());
QVERIFY(io2.canRead());
QImage im1 = io1.read();
@@ -666,8 +669,8 @@ void tst_QImageReader::gifHandlerBugs()
// Task 9994
{
- QImageReader io1("images/noclearcode.gif");
- QImageReader io2("images/noclearcode.bmp");
+ QImageReader io1(prefix + "noclearcode.gif");
+ QImageReader io2(prefix + "noclearcode.bmp");
QVERIFY(io1.canRead()); QVERIFY(io2.canRead());
QImage im1 = io1.read(); QImage im2 = io2.read();
QVERIFY(!im1.isNull()); QVERIFY(!im2.isNull());
@@ -731,29 +734,29 @@ void tst_QImageReader::readFromDevice_data()
QTest::addColumn<QString>("fileName");
QTest::addColumn<QByteArray>("format");
- QTest::newRow("pbm") << QString("images/image.pbm") << QByteArray("pbm");
- QTest::newRow("pgm") << QString("images/image.pgm") << QByteArray("pgm");
- QTest::newRow("ppm-1") << QString("images/image.ppm") << QByteArray("ppm");
- QTest::newRow("ppm-2") << QString("images/teapot.ppm") << QByteArray("ppm");
- QTest::newRow("ppm-3") << QString("images/teapot.ppm") << QByteArray("ppm");
- QTest::newRow("ppm-4") << QString("images/runners.ppm") << QByteArray("ppm");
+ QTest::newRow("pbm") << QString("image.pbm") << QByteArray("pbm");
+ QTest::newRow("pgm") << QString("image.pgm") << QByteArray("pgm");
+ QTest::newRow("ppm-1") << QString("image.ppm") << QByteArray("ppm");
+ QTest::newRow("ppm-2") << QString("teapot.ppm") << QByteArray("ppm");
+ QTest::newRow("ppm-3") << QString("teapot.ppm") << QByteArray("ppm");
+ QTest::newRow("ppm-4") << QString("runners.ppm") << QByteArray("ppm");
#ifdef QTEST_HAVE_JPEG
- QTest::newRow("jpeg-1") << QString("images/beavis.jpg") << QByteArray("jpeg");
- QTest::newRow("jpeg-2") << QString("images/YCbCr_cmyk.jpg") << QByteArray("jpeg");
- QTest::newRow("jpeg-3") << QString("images/YCbCr_rgb.jpg") << QByteArray("jpeg");
+ QTest::newRow("jpeg-1") << QString("beavis.jpg") << QByteArray("jpeg");
+ QTest::newRow("jpeg-2") << QString("YCbCr_cmyk.jpg") << QByteArray("jpeg");
+ QTest::newRow("jpeg-3") << QString("YCbCr_rgb.jpg") << QByteArray("jpeg");
#endif // QTEST_HAVE_JPEG
#ifdef QTEST_HAVE_GIF
- QTest::newRow("gif-1") << QString("images/earth.gif") << QByteArray("gif");
- QTest::newRow("gif-2") << QString("images/trolltech.gif") << QByteArray("gif");
+ QTest::newRow("gif-1") << QString("earth.gif") << QByteArray("gif");
+ QTest::newRow("gif-2") << QString("trolltech.gif") << QByteArray("gif");
#endif // QTEST_HAVE_GIF
- QTest::newRow("xbm") << QString("images/gnus.xbm") << QByteArray("xbm");
- QTest::newRow("xpm") << QString("images/marble.xpm") << QByteArray("xpm");
- QTest::newRow("bmp-1") << QString("images/colorful.bmp") << QByteArray("bmp");
- QTest::newRow("bmp-2") << QString("images/font.bmp") << QByteArray("bmp");
- QTest::newRow("png") << QString("images/kollada.png") << QByteArray("png");
+ QTest::newRow("xbm") << QString("gnus.xbm") << QByteArray("xbm");
+ QTest::newRow("xpm") << QString("marble.xpm") << QByteArray("xpm");
+ QTest::newRow("bmp-1") << QString("colorful.bmp") << QByteArray("bmp");
+ QTest::newRow("bmp-2") << QString("font.bmp") << QByteArray("bmp");
+ QTest::newRow("png") << QString("kollada.png") << QByteArray("png");
#ifdef QTEST_HAVE_MNG
- QTest::newRow("mng-1") << QString("images/ball.mng") << QByteArray("mng");
- QTest::newRow("mng-2") << QString("images/fire.mng") << QByteArray("mng");
+ QTest::newRow("mng-1") << QString("ball.mng") << QByteArray("mng");
+ QTest::newRow("mng-2") << QString("fire.mng") << QByteArray("mng");
#endif // QTEST_HAVE_MNG
}
@@ -762,9 +765,9 @@ void tst_QImageReader::readFromDevice()
QFETCH(QString, fileName);
QFETCH(QByteArray, format);
- QImage expectedImage(fileName, format);
+ QImage expectedImage(prefix + fileName, format);
- QFile file(fileName);
+ QFile file(prefix + fileName);
QVERIFY(file.open(QFile::ReadOnly));
QByteArray imageData = file.readAll();
QVERIFY(!imageData.isEmpty());
@@ -813,26 +816,26 @@ void tst_QImageReader::readFromFileAfterJunk_data()
QTest::addColumn<QString>("fileName");
QTest::addColumn<QByteArray>("format");
- QTest::newRow("pbm") << QString("images/image.pbm") << QByteArray("pbm");
- QTest::newRow("pgm") << QString("images/image.pgm") << QByteArray("pgm");
- QTest::newRow("ppm-1") << QString("images/image.ppm") << QByteArray("ppm");
- QTest::newRow("ppm-2") << QString("images/teapot.ppm") << QByteArray("ppm");
- QTest::newRow("ppm-3") << QString("images/teapot.ppm") << QByteArray("ppm");
- QTest::newRow("ppm-4") << QString("images/runners.ppm") << QByteArray("ppm");
+ QTest::newRow("pbm") << QString("image.pbm") << QByteArray("pbm");
+ QTest::newRow("pgm") << QString("image.pgm") << QByteArray("pgm");
+ QTest::newRow("ppm-1") << QString("image.ppm") << QByteArray("ppm");
+ QTest::newRow("ppm-2") << QString("teapot.ppm") << QByteArray("ppm");
+ QTest::newRow("ppm-3") << QString("teapot.ppm") << QByteArray("ppm");
+ QTest::newRow("ppm-4") << QString("runners.ppm") << QByteArray("ppm");
#ifdef QTEST_HAVE_JPEG
- QTest::newRow("jpeg-1") << QString("images/beavis.jpg") << QByteArray("jpeg");
- QTest::newRow("jpeg-2") << QString("images/YCbCr_cmyk.jpg") << QByteArray("jpeg");
- QTest::newRow("jpeg-3") << QString("images/YCbCr_rgb.jpg") << QByteArray("jpeg");
+ QTest::newRow("jpeg-1") << QString("beavis.jpg") << QByteArray("jpeg");
+ QTest::newRow("jpeg-2") << QString("YCbCr_cmyk.jpg") << QByteArray("jpeg");
+ QTest::newRow("jpeg-3") << QString("YCbCr_rgb.jpg") << QByteArray("jpeg");
#endif
#if defined QTEST_HAVE_GIF
// QTest::newRow("gif-1") << QString("images/earth.gif") << QByteArray("gif");
// QTest::newRow("gif-2") << QString("images/trolltech.gif") << QByteArray("gif");
#endif
- QTest::newRow("xbm") << QString("images/gnus.xbm") << QByteArray("xbm");
- QTest::newRow("xpm") << QString("images/marble.xpm") << QByteArray("xpm");
- QTest::newRow("bmp-1") << QString("images/colorful.bmp") << QByteArray("bmp");
- QTest::newRow("bmp-2") << QString("images/font.bmp") << QByteArray("bmp");
- QTest::newRow("png") << QString("images/kollada.png") << QByteArray("png");
+ QTest::newRow("xbm") << QString("gnus.xbm") << QByteArray("xbm");
+ QTest::newRow("xpm") << QString("marble.xpm") << QByteArray("xpm");
+ QTest::newRow("bmp-1") << QString("colorful.bmp") << QByteArray("bmp");
+ QTest::newRow("bmp-2") << QString("font.bmp") << QByteArray("bmp");
+ QTest::newRow("png") << QString("kollada.png") << QByteArray("png");
// QTest::newRow("mng-1") << QString("images/ball.mng") << QByteArray("mng");
// QTest::newRow("mng-2") << QString("images/fire.mng") << QByteArray("mng");
}
@@ -851,7 +854,7 @@ void tst_QImageReader::readFromFileAfterJunk()
QFile junkFile("junk");
QVERIFY(junkFile.open(QFile::WriteOnly));
- QFile imageFile(fileName);
+ QFile imageFile(prefix + fileName);
QVERIFY(imageFile.open(QFile::ReadOnly));
QByteArray imageData = imageFile.readAll();
QVERIFY(!imageData.isNull());
@@ -869,7 +872,7 @@ void tst_QImageReader::readFromFileAfterJunk()
for (int i = 0; i < iterations; ++i) {
QImageWriter writer(&junkFile, format);
junkFile.write("deadbeef", 9);
- QVERIFY(writer.write(QImage(fileName)));
+ QVERIFY(writer.write(QImage(prefix + fileName)));
}
}
junkFile.close();
@@ -903,8 +906,8 @@ void tst_QImageReader::description_data()
willem["Software"] = "Created on a NeXTstation color using \"pnmtopng\".";
willem["Disclaimer"] = "Freeware.";
- QTest::newRow("PNG") << QString("images/pngwithtext.png") << willem;
- QTest::newRow("PNG Compressed") << QString("images/pngwithcompressedtext.png") << willem;
+ QTest::newRow("PNG") << QString("pngwithtext.png") << willem;
+ QTest::newRow("PNG Compressed") << QString("pngwithcompressedtext.png") << willem;
}
void tst_QImageReader::description()
@@ -913,9 +916,9 @@ void tst_QImageReader::description()
QFETCH(QStringMap, description);
// Sanity check
- QVERIFY(!QImage(fileName).isNull());
+ QVERIFY(!QImage(prefix + fileName).isNull());
- QImageReader reader(fileName);
+ QImageReader reader(prefix + fileName);
foreach (QString key, description.keys())
QCOMPARE(reader.text(key), description.value(key));
@@ -940,143 +943,143 @@ void tst_QImageReader::readFromResources_data()
QTest::addColumn<QSize>("size");
QTest::addColumn<QString>("message");
- QTest::newRow("images/corrupt.bmp") << QString("images/corrupt.bmp")
+ QTest::newRow("corrupt.bmp") << QString("corrupt.bmp")
<< QByteArray("bmp") << QSize(0, 0)
<< QString("");
- QTest::newRow("images/negativeheight.bmp") << QString("images/negativeheight.bmp")
+ QTest::newRow("negativeheight.bmp") << QString("negativeheight.bmp")
<< QByteArray("bmp") << QSize(127, 64)
<< QString("");
- QTest::newRow("images/font.bmp") << QString("images/font.bmp")
+ QTest::newRow("font.bmp") << QString("font.bmp")
<< QByteArray("bmp") << QSize(240, 8)
<< QString("");
- QTest::newRow("images/noclearcode.bmp") << QString("images/noclearcode.bmp")
+ QTest::newRow("noclearcode.bmp") << QString("noclearcode.bmp")
<< QByteArray("bmp") << QSize(29, 18)
<< QString("");
- QTest::newRow("images/colorful.bmp") << QString("images/colorful.bmp")
+ QTest::newRow("colorful.bmp") << QString("colorful.bmp")
<< QByteArray("bmp") << QSize(320, 200)
<< QString("");
- QTest::newRow("images/16bpp.bmp") << QString("images/16bpp.bmp")
+ QTest::newRow("16bpp.bmp") << QString("16bpp.bmp")
<< QByteArray("bmp") << QSize(320, 240)
<< QString("");
- QTest::newRow("images/crash-signed-char.bmp") << QString("images/crash-signed-char.bmp")
+ QTest::newRow("crash-signed-char.bmp") << QString("crash-signed-char.bmp")
<< QByteArray("bmp") << QSize(360, 280)
<< QString("");
- QTest::newRow("images/4bpp-rle.bmp") << QString("images/4bpp-rle.bmp")
+ QTest::newRow("4bpp-rle.bmp") << QString("4bpp-rle.bmp")
<< QByteArray("bmp") << QSize(640, 480)
<< QString("");
#ifdef QTEST_HAVE_GIF
- QTest::newRow("images/corrupt.gif") << QString("images/corrupt.gif")
+ QTest::newRow("corrupt.gif") << QString("corrupt.gif")
<< QByteArray("gif") << QSize(0, 0)
<< QString("");
- QTest::newRow("images/trolltech.gif") << QString("images/trolltech.gif")
+ QTest::newRow("trolltech.gif") << QString("trolltech.gif")
<< QByteArray("gif") << QSize(128, 64)
<< QString("");
- QTest::newRow("images/noclearcode.gif") << QString("images/noclearcode.gif")
+ QTest::newRow("noclearcode.gif") << QString("noclearcode.gif")
<< QByteArray("gif") << QSize(29, 18)
<< QString("");
- QTest::newRow("images/earth.gif") << QString("images/earth.gif")
+ QTest::newRow("earth.gif") << QString("earth.gif")
<< QByteArray("gif") << QSize(320, 200)
<< QString("");
- QTest::newRow("images/bat1.gif") << QString("images/bat1.gif")
+ QTest::newRow("bat1.gif") << QString("bat1.gif")
<< QByteArray("gif") << QSize(32, 32)
<< QString("");
- QTest::newRow("images/bat2.gif") << QString("images/bat2.gif")
+ QTest::newRow("bat2.gif") << QString("bat2.gif")
<< QByteArray("gif") << QSize(32, 32)
<< QString("");
#endif
#ifdef QTEST_HAVE_JPEG
- QTest::newRow("images/corrupt.jpg") << QString("images/corrupt.jpg")
+ QTest::newRow("corrupt.jpg") << QString("corrupt.jpg")
<< QByteArray("jpg") << QSize(0, 0)
<< QString("JPEG datastream contains no image");
- QTest::newRow("images/beavis.jpg") << QString("images/beavis.jpg")
+ QTest::newRow("beavis.jpg") << QString("beavis.jpg")
<< QByteArray("jpg") << QSize(350, 350)
<< QString("");
- QTest::newRow("images/YCbCr_cmyk.jpg") << QString("images/YCbCr_cmyk.jpg")
+ QTest::newRow("YCbCr_cmyk.jpg") << QString("YCbCr_cmyk.jpg")
<< QByteArray("jpg") << QSize(75, 50)
<< QString("");
- QTest::newRow("images/YCbCr_rgb.jpg") << QString("images/YCbCr_rgb.jpg")
+ QTest::newRow("YCbCr_rgb.jpg") << QString("YCbCr_rgb.jpg")
<< QByteArray("jpg") << QSize(75, 50)
<< QString("");
#endif
#ifdef QTEST_HAVE_MNG
- QTest::newRow("images/corrupt.mng") << QString("images/corrupt.mng")
+ QTest::newRow("corrupt.mng") << QString("corrupt.mng")
<< QByteArray("mng") << QSize(0, 0)
<< QString("MNG error 901: Application signalled I/O error; chunk IHDR; subcode 0:0");
- QTest::newRow("images/fire.mng") << QString("images/fire.mng")
+ QTest::newRow("fire.mng") << QString("fire.mng")
<< QByteArray("mng") << QSize(30, 60)
<< QString("");
- QTest::newRow("images/ball.mng") << QString("images/ball.mng")
+ QTest::newRow("ball.mng") << QString("ball.mng")
<< QByteArray("mng") << QSize(32, 32)
<< QString("");
#endif
- QTest::newRow("images/image.pbm") << QString("images/image.pbm")
+ QTest::newRow("image.pbm") << QString("image.pbm")
<< QByteArray("pbm") << QSize(16, 6)
<< QString("");
- QTest::newRow("images/image.pgm") << QString("images/image.pgm")
+ QTest::newRow("image.pgm") << QString("image.pgm")
<< QByteArray("pgm") << QSize(24, 7)
<< QString("");
- QTest::newRow("images/corrupt.png") << QString("images/corrupt.png")
+ QTest::newRow("corrupt.png") << QString("corrupt.png")
<< QByteArray("png") << QSize(0, 0)
<< QString("");
- QTest::newRow("images/away.png") << QString("images/away.png")
+ QTest::newRow("away.png") << QString("away.png")
<< QByteArray("png") << QSize(16, 16)
<< QString("");
- QTest::newRow("images/image.png") << QString("images/image.png")
+ QTest::newRow("image.png") << QString("image.png")
<< QByteArray("png") << QSize(22, 22)
<< QString("");
- QTest::newRow("images/pngwithcompressedtext.png") << QString("images/pngwithcompressedtext.png")
+ QTest::newRow("pngwithcompressedtext.png") << QString("pngwithcompressedtext.png")
<< QByteArray("png") << QSize(32, 32)
<< QString("");
- QTest::newRow("images/pngwithtext.png") << QString("images/pngwithtext.png")
+ QTest::newRow("pngwithtext.png") << QString("pngwithtext.png")
<< QByteArray("png") << QSize(32, 32)
<< QString("");
- QTest::newRow("images/kollada.png") << QString("images/kollada.png")
+ QTest::newRow("kollada.png") << QString("kollada.png")
<< QByteArray("png") << QSize(436, 160)
<< QString("");
- QTest::newRow("images/black.png") << QString("images/black.png")
+ QTest::newRow("black.png") << QString("black.png")
<< QByteArray("png") << QSize(48, 48)
<< QString("");
- QTest::newRow("images/YCbCr_cmyk.png") << QString("images/YCbCr_cmyk.png")
+ QTest::newRow("YCbCr_cmyk.png") << QString("YCbCr_cmyk.png")
<< QByteArray("png") << QSize(75, 50)
<< QString("");
- QTest::newRow("images/teapot.ppm") << QString("images/teapot.ppm")
+ QTest::newRow("teapot.ppm") << QString("teapot.ppm")
<< QByteArray("ppm") << QSize(256, 256)
<< QString("");
- QTest::newRow("images/image.ppm") << QString("images/image.ppm")
+ QTest::newRow("image.ppm") << QString("image.ppm")
<< QByteArray("ppm") << QSize(4, 4)
<< QString("");
- QTest::newRow("images/runners.ppm") << QString("images/runners.ppm")
+ QTest::newRow("runners.ppm") << QString("runners.ppm")
<< QByteArray("ppm") << QSize(400, 400)
<< QString("");
- QTest::newRow("images/test.ppm") << QString("images/test.ppm")
+ QTest::newRow("test.ppm") << QString("test.ppm")
<< QByteArray("ppm") << QSize(10, 10)
<< QString("");
-// QTest::newRow("images/corrupt.xbm") << QString("images/corrupt.xbm") << QByteArray("xbm") << QSize(0, 0);
- QTest::newRow("images/gnus.xbm") << QString("images/gnus.xbm")
+// QTest::newRow("corrupt.xbm") << QString("corrupt.xbm") << QByteArray("xbm") << QSize(0, 0);
+ QTest::newRow("gnus.xbm") << QString("gnus.xbm")
<< QByteArray("xbm") << QSize(271, 273)
<< QString("");
- QTest::newRow("images/corrupt-colors.xpm") << QString("images/corrupt-colors.xpm")
+ QTest::newRow("corrupt-colors.xpm") << QString("corrupt-colors.xpm")
<< QByteArray("xpm") << QSize(0, 0)
<< QString("QImage: XPM color specification is missing: bla9an.n#x");
- QTest::newRow("images/corrupt-pixels.xpm") << QString("images/corrupt-pixels.xpm")
+ QTest::newRow("corrupt-pixels.xpm") << QString("corrupt-pixels.xpm")
<< QByteArray("xpm") << QSize(0, 0)
<< QString("QImage: XPM pixels missing on image line 3");
- QTest::newRow("images/marble.xpm") << QString("images/marble.xpm")
+ QTest::newRow("marble.xpm") << QString("marble.xpm")
<< QByteArray("xpm") << QSize(240, 240)
<< QString("");
- QTest::newRow("images/test.xpm") << QString("images/test.xpm")
+ QTest::newRow("test.xpm") << QString("test.xpm")
<< QByteArray("xpm") << QSize(256, 256)
<< QString("");
- QTest::newRow("images/black.xpm") << QString("images/black.xpm")
+ QTest::newRow("black.xpm") << QString("black.xpm")
<< QByteArray("xpm") << QSize(48, 48)
<< QString("");
- QTest::newRow("images/namedcolors.xpm") << QString("images/namedcolors.xpm")
+ QTest::newRow("namedcolors.xpm") << QString("namedcolors.xpm")
<< QByteArray("xpm") << QSize(8, 8)
<< QString("");
- QTest::newRow("images/nontransparent.xpm") << QString("images/nontransparent.xpm")
+ QTest::newRow("nontransparent.xpm") << QString("nontransparent.xpm")
<< QByteArray("xpm") << QSize(8, 8)
<< QString("");
- QTest::newRow("images/transparent.xpm") << QString("images/transparent.xpm")
+ QTest::newRow("transparent.xpm") << QString("transparent.xpm")
<< QByteArray("xpm") << QSize(8, 8)
<< QString("");
}
@@ -1087,9 +1090,8 @@ void tst_QImageReader::readFromResources()
QFETCH(QByteArray, format);
QFETCH(QSize, size);
QFETCH(QString, message);
-
for (int i = 0; i < 2; ++i) {
- QString file = i ? (":/" + fileName) : fileName;
+ QString file = i ? (":/images/" + fileName) : (prefix + fileName);
{
// suppress warnings if we expect them
if (!message.isEmpty()) {
@@ -1153,7 +1155,7 @@ void tst_QImageReader::readFromResources()
QTest::ignoreMessage(QtWarningMsg, message.toLatin1());
QTest::ignoreMessage(QtWarningMsg, message.toLatin1());
}
- QCOMPARE(QImageReader(fileName).read(), QImageReader(":/" + fileName).read());
+ QCOMPARE(QImageReader(prefix + fileName).read(), QImageReader(":/images/" + fileName).read());
}
void tst_QImageReader::readCorruptImage_data()
@@ -1162,25 +1164,25 @@ void tst_QImageReader::readCorruptImage_data()
QTest::addColumn<bool>("shouldFail");
QTest::addColumn<QString>("message");
#if defined QTEST_HAVE_JPEG
- QTest::newRow("corrupt jpeg") << QString("images/corrupt.jpg") << true
+ QTest::newRow("corrupt jpeg") << QString("corrupt.jpg") << true
<< QString("JPEG datastream contains no image");
#endif
#if defined QTEST_HAVE_GIF
- QTest::newRow("corrupt gif") << QString("images/corrupt.gif") << true << QString("");
+ QTest::newRow("corrupt gif") << QString("corrupt.gif") << true << QString("");
#endif
#ifdef QTEST_HAVE_MNG
- QTest::newRow("corrupt mng") << QString("images/corrupt.mng") << true
+ QTest::newRow("corrupt mng") << QString("corrupt.mng") << true
<< QString("MNG error 901: Application signalled I/O error; chunk IHDR; subcode 0:0");
#endif
- QTest::newRow("corrupt png") << QString("images/corrupt.png") << true << QString("");
- QTest::newRow("corrupt bmp") << QString("images/corrupt.bmp") << true << QString("");
- QTest::newRow("corrupt xpm (colors)") << QString("images/corrupt-colors.xpm") << true
+ QTest::newRow("corrupt png") << QString("corrupt.png") << true << QString("");
+ QTest::newRow("corrupt bmp") << QString("corrupt.bmp") << true << QString("");
+ QTest::newRow("corrupt xpm (colors)") << QString("corrupt-colors.xpm") << true
<< QString("QImage: XPM color specification is missing: bla9an.n#x");
- QTest::newRow("corrupt xpm (pixels)") << QString("images/corrupt-pixels.xpm") << true
+ QTest::newRow("corrupt xpm (pixels)") << QString("corrupt-pixels.xpm") << true
<< QString("QImage: XPM pixels missing on image line 3");
- QTest::newRow("corrupt xbm") << QString("images/corrupt.xbm") << false << QString("");
+ QTest::newRow("corrupt xbm") << QString("corrupt.xbm") << false << QString("");
#if defined QTEST_HAVE_TIFF
- QTest::newRow("corrupt tiff") << QString("images/corrupt-data.tif") << true << QString("");
+ QTest::newRow("corrupt tiff") << QString("corrupt-data.tif") << true << QString("");
#endif
}
@@ -1189,16 +1191,17 @@ void tst_QImageReader::readCorruptImage()
QFETCH(QString, fileName);
QFETCH(bool, shouldFail);
QFETCH(QString, message);
+
if (!message.isEmpty())
QTest::ignoreMessage(QtWarningMsg, message.toLatin1());
- QImageReader reader(fileName);
+ QImageReader reader(prefix + fileName);
QVERIFY(reader.canRead());
QCOMPARE(reader.read().isNull(), shouldFail);
}
void tst_QImageReader::readCorruptBmp()
{
- QCOMPARE(QImage("images/tst7.bmp").convertToFormat(QImage::Format_ARGB32_Premultiplied), QImage("images/tst7.png").convertToFormat(QImage::Format_ARGB32_Premultiplied));
+ QCOMPARE(QImage("tst7.bmp").convertToFormat(QImage::Format_ARGB32_Premultiplied), QImage("images/tst7.png").convertToFormat(QImage::Format_ARGB32_Premultiplied));
}
void tst_QImageReader::supportsOption_data()
@@ -1206,7 +1209,7 @@ void tst_QImageReader::supportsOption_data()
QTest::addColumn<QString>("fileName");
QTest::addColumn<QIntList>("options");
- QTest::newRow("png") << QString("images/black.png")
+ QTest::newRow("png") << QString("black.png")
<< (QIntList() << QImageIOHandler::Gamma
<< QImageIOHandler::Description
<< QImageIOHandler::Quality
@@ -1234,7 +1237,7 @@ void tst_QImageReader::supportsOption()
<< QImageIOHandler::Animation
<< QImageIOHandler::BackgroundColor;
- QImageReader reader(fileName);
+ QImageReader reader(prefix + fileName);
for (int i = 0; i < options.size(); ++i) {
QVERIFY(reader.supportsOption(QImageIOHandler::ImageOption(options.at(i))));
allOptions.remove(QImageIOHandler::ImageOption(options.at(i)));
@@ -1250,14 +1253,14 @@ void tst_QImageReader::tiffCompression_data()
QTest::addColumn<QString>("uncompressedFile");
QTest::addColumn<QString>("compressedFile");
- QTest::newRow("TIFF: adobedeflate") << "images/rgba_nocompression_littleendian.tif"
- << "images/rgba_adobedeflate_littleendian.tif";
- QTest::newRow("TIFF: lzw") << "images/rgba_nocompression_littleendian.tif"
- << "images/rgba_lzw_littleendian.tif";
- QTest::newRow("TIFF: packbits") << "images/rgba_nocompression_littleendian.tif"
- << "images/rgba_packbits_littleendian.tif";
- QTest::newRow("TIFF: zipdeflate") << "images/rgba_nocompression_littleendian.tif"
- << "images/rgba_zipdeflate_littleendian.tif";
+ QTest::newRow("TIFF: adobedeflate") << "rgba_nocompression_littleendian.tif"
+ << "rgba_adobedeflate_littleendian.tif";
+ QTest::newRow("TIFF: lzw") << "rgba_nocompression_littleendian.tif"
+ << "rgba_lzw_littleendian.tif";
+ QTest::newRow("TIFF: packbits") << "rgba_nocompression_littleendian.tif"
+ << "rgba_packbits_littleendian.tif";
+ QTest::newRow("TIFF: zipdeflate") << "rgba_nocompression_littleendian.tif"
+ << "rgba_zipdeflate_littleendian.tif";
}
void tst_QImageReader::tiffCompression()
@@ -1265,16 +1268,16 @@ void tst_QImageReader::tiffCompression()
QFETCH(QString, uncompressedFile);
QFETCH(QString, compressedFile);
- QImage uncompressedImage(uncompressedFile);
- QImage compressedImage(compressedFile);
+ QImage uncompressedImage(prefix + uncompressedFile);
+ QImage compressedImage(prefix + compressedFile);
QCOMPARE(uncompressedImage, compressedImage);
}
void tst_QImageReader::tiffEndianness()
{
- QImage littleEndian("images/rgba_nocompression_littleendian.tif");
- QImage bigEndian("images/rgba_nocompression_bigendian.tif");
+ QImage littleEndian(prefix + "rgba_nocompression_littleendian.tif");
+ QImage bigEndian(prefix + "rgba_nocompression_bigendian.tif");
QCOMPARE(littleEndian, bigEndian);
}
@@ -1286,8 +1289,10 @@ void tst_QImageReader::dotsPerMeter_data()
QTest::addColumn<QString>("fileName");
QTest::addColumn<int>("expectedDotsPerMeterX");
QTest::addColumn<int>("expectedDotsPerMeterY");
-
- QTest::newRow("TIFF: 72 dpi") << "images/rgba_nocompression_littleendian.tif" << qRound(72 * (100 / 2.54)) << qRound(72 * (100 / 2.54));
+#if defined QTEST_HAVE_TIFF
+ QTest::newRow("TIFF: 72 dpi") << ("rgba_nocompression_littleendian.tif") << qRound(72 * (100 / 2.54)) << qRound(72 * (100 / 2.54));
+ QTest::newRow("TIFF: 100 dpi") << ("image_100dpi.tif") << qRound(100 * (100 / 2.54)) << qRound(100 * (100 / 2.54));
+#endif
}
void tst_QImageReader::dotsPerMeter()
@@ -1296,7 +1301,7 @@ void tst_QImageReader::dotsPerMeter()
QFETCH(int, expectedDotsPerMeterX);
QFETCH(int, expectedDotsPerMeterY);
- QImage image(fileName);
+ QImage image(prefix + fileName);
QCOMPARE(image.dotsPerMeterX(), expectedDotsPerMeterX);
QCOMPARE(image.dotsPerMeterY(), expectedDotsPerMeterY);
@@ -1307,8 +1312,10 @@ void tst_QImageReader::physicalDpi_data()
QTest::addColumn<QString>("fileName");
QTest::addColumn<int>("expectedPhysicalDpiX");
QTest::addColumn<int>("expectedPhysicalDpiY");
-
- QTest::newRow("TIFF: 72 dpi") << "images/rgba_nocompression_littleendian.tif" << 72 << 72;
+#if defined QTEST_HAVE_TIFF
+ QTest::newRow("TIFF: 72 dpi") << "rgba_nocompression_littleendian.tif" << 72 << 72;
+ QTest::newRow("TIFF: 100 dpi") << "image_100dpi.tif" << 100 << 100;
+#endif
}
void tst_QImageReader::physicalDpi()
@@ -1317,7 +1324,7 @@ void tst_QImageReader::physicalDpi()
QFETCH(int, expectedPhysicalDpiX);
QFETCH(int, expectedPhysicalDpiY);
- QImage image(fileName);
+ QImage image(prefix + fileName);
QCOMPARE(image.physicalDpiX(), expectedPhysicalDpiX);
QCOMPARE(image.physicalDpiY(), expectedPhysicalDpiY);
@@ -1328,7 +1335,7 @@ void tst_QImageReader::autoDetectImageFormat()
// Assume PNG is supported :-)
{
// Disables file name extension probing
- QImageReader reader("images/kollada");
+ QImageReader reader(prefix + "kollada");
reader.setAutoDetectImageFormat(false);
QVERIFY(!reader.canRead());
QVERIFY(reader.read().isNull());
@@ -1338,7 +1345,7 @@ void tst_QImageReader::autoDetectImageFormat()
}
{
// Disables detection based on suffix
- QImageReader reader("images/kollada.png");
+ QImageReader reader(prefix + "kollada.png");
reader.setAutoDetectImageFormat(false);
QVERIFY(!reader.canRead());
QVERIFY(reader.read().isNull());
@@ -1348,7 +1355,7 @@ void tst_QImageReader::autoDetectImageFormat()
}
{
// Disables detection based on content
- QImageReader reader("images/kollada-noext");
+ QImageReader reader(prefix + "kollada-noext");
reader.setAutoDetectImageFormat(false);
QVERIFY(!reader.canRead());
QVERIFY(reader.read().isNull());
diff --git a/tests/auto/qimagewriter/tst_qimagewriter.cpp b/tests/auto/qimagewriter/tst_qimagewriter.cpp
index 878d398..349afa5 100644
--- a/tests/auto/qimagewriter/tst_qimagewriter.cpp
+++ b/tests/auto/qimagewriter/tst_qimagewriter.cpp
@@ -97,6 +97,9 @@ private slots:
void saveWithNoFormat_data();
void saveWithNoFormat();
+ void resolution_data();
+ void resolution();
+
void saveToTemporaryFile();
};
@@ -162,7 +165,7 @@ tst_QImageWriter::tst_QImageWriter()
tst_QImageWriter::~tst_QImageWriter()
{
- QDir dir("images");
+ QDir dir(prefix);
QStringList filesToDelete = dir.entryList(QStringList() << "gen-*" , QDir::NoDotAndDotDot | QDir::Files);
foreach( QString file, filesToDelete) {
QFile::remove(dir.absoluteFilePath(file));
@@ -442,13 +445,13 @@ void tst_QImageWriter::supportsOption_data()
QTest::addColumn<QString>("fileName");
QTest::addColumn<QIntList>("options");
- QTest::newRow("png") << QString(prefix + "gen-black.png")
+ QTest::newRow("png") << QString("gen-black.png")
<< (QIntList() << QImageIOHandler::Gamma
<< QImageIOHandler::Description
<< QImageIOHandler::Quality
<< QImageIOHandler::Size);
#if defined QTEST_HAVE_TIFF
- QTest::newRow("tiff") << QString("images/gen-black.tiff")
+ QTest::newRow("tiff") << QString("gen-black.tiff")
<< (QIntList() << QImageIOHandler::Size
<< QImageIOHandler::CompressionRatio);
#endif
@@ -475,7 +478,7 @@ void tst_QImageWriter::supportsOption()
<< QImageIOHandler::Animation
<< QImageIOHandler::BackgroundColor;
- QImageWriter writer(fileName);
+ QImageWriter writer(prefix + fileName);
for (int i = 0; i < options.size(); ++i) {
QVERIFY(writer.supportsOption(QImageIOHandler::ImageOption(options.at(i))));
allOptions.remove(QImageIOHandler::ImageOption(options.at(i)));
@@ -530,6 +533,39 @@ void tst_QImageWriter::saveWithNoFormat()
QVERIFY2(!outImage.isNull(), qPrintable(reader.errorString()));
}
+void tst_QImageWriter::resolution_data()
+{
+ QTest::addColumn<QString>("filename");
+ QTest::addColumn<int>("expectedDotsPerMeterX");
+ QTest::addColumn<int>("expectedDotsPerMeterY");
+#if defined QTEST_HAVE_TIFF
+ QTest::newRow("TIFF: 100 dpi") << ("image_100dpi.tif") << qRound(100 * (100 / 2.54)) << qRound(100 * (100 / 2.54));
+ QTest::newRow("TIFF: 50 dpi") << ("image_50dpi.tif") << qRound(50 * (100 / 2.54)) << qRound(50 * (100 / 2.54));
+ QTest::newRow("TIFF: 300 dot per meter") << ("image_300dpm.tif") << 300 << 300;
+#endif
+}
+
+void tst_QImageWriter::resolution()
+{
+ QFETCH(QString, filename);
+ QFETCH(int, expectedDotsPerMeterX);
+ QFETCH(int, expectedDotsPerMeterY);
+
+ QImage image(prefix + QLatin1String("colorful.bmp"));
+ image.setDotsPerMeterX(expectedDotsPerMeterX);
+ image.setDotsPerMeterY(expectedDotsPerMeterY);
+ const QString generatedFilepath = prefix + "gen-" + filename;
+ {
+ QImageWriter writer(generatedFilepath);
+ QVERIFY(writer.write(image));
+ }
+ QImageReader reader(generatedFilepath);
+ const QImage generatedImage = reader.read();
+
+ QCOMPARE(expectedDotsPerMeterX, generatedImage.dotsPerMeterX());
+ QCOMPARE(expectedDotsPerMeterY, generatedImage.dotsPerMeterY());
+}
+
void tst_QImageWriter::saveToTemporaryFile()
{
QImage image(prefix + "kollada.png");
diff --git a/tests/auto/qiodevice/tst_qiodevice.cpp b/tests/auto/qiodevice/tst_qiodevice.cpp
index 03a0665..367a2e0 100644
--- a/tests/auto/qiodevice/tst_qiodevice.cpp
+++ b/tests/auto/qiodevice/tst_qiodevice.cpp
@@ -120,7 +120,7 @@ void tst_QIODevice::constructing_QTcpSocket()
QVERIFY(!device->isOpen());
- socket.connectToHost("imap.troll.no", 143);
+ socket.connectToHost(QtNetworkSettings::serverName(), 143);
QVERIFY(socket.waitForConnected(5000));
QVERIFY(device->isOpen());
@@ -134,7 +134,7 @@ void tst_QIODevice::constructing_QTcpSocket()
QCOMPARE(socket.pos(), qlonglong(0));
socket.close();
- socket.connectToHost("imap.troll.no", 143);
+ socket.connectToHost(QtNetworkSettings::serverName(), 143);
QVERIFY(socket.waitForConnected(5000));
while (!device->canReadLine())
diff --git a/tests/auto/qitemmodel/tst_qitemmodel.cpp b/tests/auto/qitemmodel/tst_qitemmodel.cpp
index ea1972e..d29a3e3 100644
--- a/tests/auto/qitemmodel/tst_qitemmodel.cpp
+++ b/tests/auto/qitemmodel/tst_qitemmodel.cpp
@@ -54,7 +54,7 @@
#include <QtTest/QtTest>
#include <QtCore>
#include <qdebug.h>
-#include <modelstotest.cpp>
+#include "modelstotest.cpp"
#include <QMetaType>
Q_DECLARE_METATYPE(QModelIndex)
diff --git a/tests/auto/qitemview/tst_qitemview.cpp b/tests/auto/qitemview/tst_qitemview.cpp
index 748bd50..3317c1d 100644
--- a/tests/auto/qitemview/tst_qitemview.cpp
+++ b/tests/auto/qitemview/tst_qitemview.cpp
@@ -42,7 +42,7 @@
#include <QtTest/QtTest>
#include <QtCore/QtCore>
-#include <viewstotest.cpp>
+#include "viewstotest.cpp"
#include <stdlib.h>
#if defined(Q_OS_WIN)
diff --git a/tests/auto/qmake/testcompiler.cpp b/tests/auto/qmake/testcompiler.cpp
index 122a2b8..7255d93 100644
--- a/tests/auto/qmake/testcompiler.cpp
+++ b/tests/auto/qmake/testcompiler.cpp
@@ -56,10 +56,8 @@ static QString targetName( BuildType buildMode, const QString& target, const QSt
targetName.append(".exe");
break;
case Dll: // dll
- if (version != "") {
- QStringList ver = QStringList::split(".", version);
- targetName.append(ver.first());
- }
+ if (!version.empty())
+ targetName.append(version.section(".", 0, 0));
targetName.append(".dll");
break;
case Lib: // lib
diff --git a/tests/auto/qmap/tst_qmap.cpp b/tests/auto/qmap/tst_qmap.cpp
index 99efc80..68ac8d6 100644
--- a/tests/auto/qmap/tst_qmap.cpp
+++ b/tests/auto/qmap/tst_qmap.cpp
@@ -39,6 +39,7 @@
**
****************************************************************************/
+#define QT_STRICT_ITERATORS
#include <QtTest/QtTest>
#include <QDebug>
@@ -400,7 +401,7 @@ void tst_QMap::operator_eq()
QVERIFY(a == b);
QVERIFY(!(a != b));
-
+
a.insert(1,1);
b.insert(1,1);
QVERIFY(a == b);
@@ -422,7 +423,7 @@ void tst_QMap::operator_eq()
b.insert(-1, -1);
QVERIFY(a != b);
- QVERIFY(!(a == b));
+ QVERIFY(!(a == b));
}
{
@@ -468,7 +469,7 @@ void tst_QMap::operator_eq()
b.insert("willy", 1);
QVERIFY(a != b);
QVERIFY(!(a == b));
- }
+ }
}
void tst_QMap::empty()
@@ -523,9 +524,9 @@ void tst_QMap::find()
map1.insertMulti(4, compareString);
}
- QMap<int, QString>::const_iterator it=map1.find(4);
+ QMap<int, QString>::const_iterator it=map1.constFind(4);
- for(i = 9; i > 2 && it != map1.end() && it.key() == 4; --i) {
+ for(i = 9; i > 2 && it != map1.constEnd() && it.key() == 4; --i) {
compareString = testString.arg(i);
QVERIFY(it.value() == compareString);
++it;
@@ -546,9 +547,9 @@ void tst_QMap::constFind()
map1.insert(1,"Mensch");
map1.insert(1,"Mayer");
map1.insert(2,"Hej");
-
+
QVERIFY(map1.constFind(4) == map1.constEnd());
-
+
QVERIFY(map1.constFind(1).value() == "Mayer");
QVERIFY(map1.constFind(2).value() == "Hej");
@@ -677,7 +678,7 @@ void tst_QMap::iterators()
cstlIt--;
QVERIFY(cstlIt.value() == "Teststring 3");
- for(cstlIt = map.begin(), i = 1; cstlIt != map.constEnd(), i < 100; ++cstlIt, ++i)
+ for(cstlIt = map.constBegin(), i = 1; cstlIt != map.constEnd(), i < 100; ++cstlIt, ++i)
QVERIFY(cstlIt.value() == testString.arg(i));
//Java-Style iterators
diff --git a/tests/auto/qnativesocketengine/tst_qnativesocketengine.cpp b/tests/auto/qnativesocketengine/tst_qnativesocketengine.cpp
index 68ec414..90276f2 100644
--- a/tests/auto/qnativesocketengine/tst_qnativesocketengine.cpp
+++ b/tests/auto/qnativesocketengine/tst_qnativesocketengine.cpp
@@ -100,8 +100,6 @@ private slots:
void receiveUrgentData();
};
-static const char *IMAP_IP = "62.70.27.18";
-
tst_QNativeSocketEngine::tst_QNativeSocketEngine()
{
}
@@ -155,15 +153,14 @@ void tst_QNativeSocketEngine::simpleConnectToIMAP()
QVERIFY(socketDevice.initialize(QAbstractSocket::TcpSocket, QAbstractSocket::IPv4Protocol));
QVERIFY(socketDevice.state() == QAbstractSocket::UnconnectedState);
- // Connect to imap.trolltech.com's IP
- bool connected = socketDevice.connectToHost(QHostAddress(IMAP_IP), 143);
- if (!connected) {
+ const bool isConnected = socketDevice.connectToHost(QtNetworkSettings::serverIP(), 143);
+ if (!isConnected) {
QVERIFY(socketDevice.state() == QAbstractSocket::ConnectingState);
QVERIFY(socketDevice.waitForWrite());
QVERIFY(socketDevice.state() == QAbstractSocket::ConnectedState);
}
QVERIFY(socketDevice.state() == QAbstractSocket::ConnectedState);
- QVERIFY(socketDevice.peerAddress() == QHostAddress(IMAP_IP));
+ QVERIFY(socketDevice.peerAddress() == QtNetworkSettings::serverIP());
// Wait for the greeting
QVERIFY(socketDevice.waitForRead());
@@ -176,7 +173,7 @@ void tst_QNativeSocketEngine::simpleConnectToIMAP()
QVERIFY(socketDevice.read(array.data(), array.size()) == available);
// Check that the greeting is what we expect it to be
- QCOMPARE(array.constData(), "* OK esparsett Cyrus IMAP4 v2.2.8 server ready\r\n");
+ QCOMPARE(array.constData(), "* OK [CAPABILITY IMAP4 IMAP4rev1 LITERAL+ ID STARTTLS LOGINDISABLED] qt-test-server.qt-test-net Cyrus IMAP4 v2.3.11-Mandriva-RPM-2.3.11-6mdv2008.1 server ready\r\n");
// Write a logout message
QByteArray array2 = "ZZZ LOGOUT\r\n";
@@ -580,9 +577,8 @@ void tst_QNativeSocketEngine::networkError()
QVERIFY(client.initialize(QAbstractSocket::TcpSocket, QAbstractSocket::IPv4Protocol));
- // Connect to imap.trolltech.com's IP
- bool connected = client.connectToHost(QHostAddress(IMAP_IP), 143);
- if (!connected) {
+ const bool isConnected = client.connectToHost(QHostAddress(QtNetworkSettings::serverIP()), 143);
+ if (!isConnected) {
QVERIFY(client.state() == QAbstractSocket::ConnectingState);
QVERIFY(client.waitForWrite());
QVERIFY(client.state() == QAbstractSocket::ConnectedState);
diff --git a/tests/auto/qnetworkdiskcache/tst_qnetworkdiskcache.cpp b/tests/auto/qnetworkdiskcache/tst_qnetworkdiskcache.cpp
index fc15437..2383767 100644
--- a/tests/auto/qnetworkdiskcache/tst_qnetworkdiskcache.cpp
+++ b/tests/auto/qnetworkdiskcache/tst_qnetworkdiskcache.cpp
@@ -389,7 +389,8 @@ void tst_QNetworkDiskCache::expire()
qint64 max = cache.maximumCacheSize();
QCOMPARE(max, limit);
for (int i = 0; i < 10; ++i) {
- QTest::qWait(2000);
+ if (i % 3 == 0)
+ QTest::qWait(2000);
QNetworkCacheMetaData m;
m.setUrl(QUrl("http://www.foo.com/" + QString::number(i)));
QIODevice *d = cache.prepare(m);
diff --git a/tests/auto/qnetworkreply/tst_qnetworkreply.cpp b/tests/auto/qnetworkreply/tst_qnetworkreply.cpp
index 6c622f7..b76a4e6 100644
--- a/tests/auto/qnetworkreply/tst_qnetworkreply.cpp
+++ b/tests/auto/qnetworkreply/tst_qnetworkreply.cpp
@@ -237,6 +237,8 @@ private Q_SLOTS:
void httpProxyCommands_data();
void httpProxyCommands();
void proxyChange();
+ void authorizationError_data();
+ void authorizationError();
};
QT_BEGIN_NAMESPACE
@@ -3134,7 +3136,8 @@ void tst_QNetworkReply::downloadProgress()
QVERIFY(spy.isValid());
QCoreApplication::instance()->processEvents();
- server.waitForNewConnection(0); // ignore result, since processEvents may have got it
+ if (!server.hasPendingConnections())
+ server.waitForNewConnection(1000);
QVERIFY(server.hasPendingConnections());
QCOMPARE(spy.count(), 0);
@@ -3189,7 +3192,8 @@ void tst_QNetworkReply::uploadProgress()
QVERIFY(finished.isValid());
QCoreApplication::instance()->processEvents();
- server.waitForNewConnection(0); // ignore result, since processEvents may have got it
+ if (!server.hasPendingConnections())
+ server.waitForNewConnection(1000);
QVERIFY(server.hasPendingConnections());
QTcpSocket *receiver = server.nextPendingConnection();
@@ -3512,5 +3516,55 @@ void tst_QNetworkReply::proxyChange()
QVERIFY(int(reply3->error()) > 0);
}
+void tst_QNetworkReply::authorizationError_data()
+{
+
+ QTest::addColumn<QString>("url");
+ QTest::addColumn<int>("errorSignalCount");
+ QTest::addColumn<int>("finishedSignalCount");
+ QTest::addColumn<int>("error");
+ QTest::addColumn<int>("httpStatusCode");
+ QTest::addColumn<QString>("httpBody");
+
+ QTest::newRow("unknown-authorization-method") << "http://" + QtNetworkSettings::serverName() +
+ "/cgi-bin/http-unknown-authentication-method.cgi?401-authorization-required" << 1 << 1
+ << int(QNetworkReply::AuthenticationRequiredError) << 401 << "authorization required";
+ QTest::newRow("unknown-proxy-authorization-method") << "http://" + QtNetworkSettings::serverName() +
+ "/cgi-bin/http-unknown-authentication-method.cgi?407-proxy-authorization-required" << 1 << 1
+ << int(QNetworkReply::ProxyAuthenticationRequiredError) << 407
+ << "authorization required";
+}
+
+void tst_QNetworkReply::authorizationError()
+{
+ QFETCH(QString, url);
+ QNetworkRequest request(url);
+ QNetworkReplyPtr reply = manager.get(request);
+
+ QCOMPARE(reply->error(), QNetworkReply::NoError);
+
+ qRegisterMetaType<QNetworkReply::NetworkError>("QNetworkReply::NetworkError");
+ QSignalSpy errorSpy(reply, SIGNAL(error(QNetworkReply::NetworkError)));
+ QSignalSpy finishedSpy(reply, SIGNAL(finished()));
+ // now run the request:
+ connect(reply, SIGNAL(finished()),
+ &QTestEventLoop::instance(), SLOT(exitLoop()));
+ QTestEventLoop::instance().enterLoop(10);
+ QVERIFY(!QTestEventLoop::instance().timeout());
+
+ QFETCH(int, errorSignalCount);
+ QCOMPARE(errorSpy.count(), errorSignalCount);
+ QFETCH(int, finishedSignalCount);
+ QCOMPARE(finishedSpy.count(), finishedSignalCount);
+ QFETCH(int, error);
+ QCOMPARE(reply->error(), QNetworkReply::NetworkError(error));
+
+ QFETCH(int, httpStatusCode);
+ QCOMPARE(reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt(), httpStatusCode);
+
+ QFETCH(QString, httpBody);
+ QCOMPARE(QString(reply->readAll()), httpBody);
+}
+
QTEST_MAIN(tst_QNetworkReply)
#include "tst_qnetworkreply.moc"
diff --git a/tests/auto/qobjectrace/tst_qobjectrace.cpp b/tests/auto/qobjectrace/tst_qobjectrace.cpp
index 0c88f29..aa80534 100644
--- a/tests/auto/qobjectrace/tst_qobjectrace.cpp
+++ b/tests/auto/qobjectrace/tst_qobjectrace.cpp
@@ -43,6 +43,7 @@
#include <QtCore>
#include <QtTest/QtTest>
+
enum { OneMinute = 60 * 1000, TwoMinutes = OneMinute * 2 };
class tst_QObjectRace: public QObject
@@ -50,6 +51,7 @@ class tst_QObjectRace: public QObject
Q_OBJECT
private slots:
void moveToThreadRace();
+ void destroyRace();
};
class RaceObject : public QObject
@@ -69,12 +71,18 @@ public:
public slots:
void theSlot()
{
- enum { step = 1000 };
+ enum { step = 35 };
if ((++count % step) == 0) {
QThread *nextThread = threads.at((count / step) % threads.size());
moveToThread(nextThread);
}
}
+
+ void destroSlot() {
+ emit theSignal();
+ }
+signals:
+ void theSignal();
};
class RaceThread : public QThread
@@ -119,6 +127,10 @@ private slots:
if (stopWatch.elapsed() >= OneMinute / 2)
#endif
quit();
+
+ QObject o;
+ connect(&o, SIGNAL(destroyed()) , object, SLOT(destroSlot()));
+ connect(object, SIGNAL(destroyed()) , &o, SLOT(deleteLater()));
}
};
@@ -137,15 +149,110 @@ void tst_QObjectRace::moveToThreadRace()
for (int i = 0; i < ThreadCount; ++i)
threads[i]->start();
- QVERIFY(threads[0]->wait(TwoMinutes));
+
+ while(!threads[0]->isFinished()) {
+ QPointer<RaceObject> foo (object);
+ QObject o;
+ connect(&o, SIGNAL(destroyed()) , object, SLOT(destroSlot()));
+ connect(object, SIGNAL(destroyed()) , &o, SLOT(deleteLater()));
+ QTest::qWait(10);
+ }
// the other threads should finish pretty quickly now
for (int i = 1; i < ThreadCount; ++i)
- QVERIFY(threads[i]->wait(30000));
+ QVERIFY(threads[i]->wait(300));
for (int i = 0; i < ThreadCount; ++i)
delete threads[i];
delete object;
}
+
+class MyObject : public QObject
+{ Q_OBJECT
+ public slots:
+ void slot1() { emit signal1(); }
+ void slot2() { emit signal2(); }
+ void slot3() { emit signal3(); }
+ void slot4() { emit signal4(); }
+ void slot5() { emit signal5(); }
+ void slot6() { emit signal6(); }
+ void slot7() { emit signal7(); }
+ signals:
+ void signal1();
+ void signal2();
+ void signal3();
+ void signal4();
+ void signal5();
+ void signal6();
+ void signal7();
+};
+
+
+
+class DestroyThread : public QThread
+{
+ Q_OBJECT
+ QObject **objects;
+ int number;
+
+public:
+ void setObjects(QObject **o, int n)
+ {
+ objects = o;
+ number = n;
+ for(int i = 0; i < number; i++)
+ objects[i]->moveToThread(this);
+ }
+
+ void run() {
+ for(int i = 0; i < number; i++)
+ delete objects[i];
+ }
+};
+
+void tst_QObjectRace::destroyRace()
+{
+ enum { ThreadCount = 10, ObjectCountPerThread = 733,
+ ObjectCount = ThreadCount * ObjectCountPerThread };
+
+ const char *_slots[] = { SLOT(slot1()) , SLOT(slot2()) , SLOT(slot3()),
+ SLOT(slot4()) , SLOT(slot5()) , SLOT(slot6()),
+ SLOT(slot7()) };
+
+ const char *_signals[] = { SIGNAL(signal1()), SIGNAL(signal2()), SIGNAL(signal3()),
+ SIGNAL(signal4()), SIGNAL(signal5()), SIGNAL(signal6()),
+ SIGNAL(signal7()) };
+
+ QObject *objects[ObjectCount];
+ for (int i = 0; i < ObjectCount; ++i)
+ objects[i] = new MyObject;
+
+
+ for (int i = 0; i < ObjectCount * 11; ++i) {
+ connect(objects[(i*13) % ObjectCount], _signals[(2*i)%7],
+ objects[((i+2)*17) % ObjectCount], _slots[(3*i+2)%7] );
+ connect(objects[((i+6)*23) % ObjectCount], _signals[(5*i+4)%7],
+ objects[((i+8)*41) % ObjectCount], _slots[(i+6)%7] );
+ }
+
+ DestroyThread *threads[ThreadCount];
+ for (int i = 0; i < ThreadCount; ++i) {
+ threads[i] = new DestroyThread;
+ threads[i]->setObjects(objects + i*ObjectCountPerThread, ObjectCountPerThread);
+ }
+
+ for (int i = 0; i < ThreadCount; ++i)
+ threads[i]->start();
+
+ QVERIFY(threads[0]->wait(TwoMinutes));
+ // the other threads should finish pretty quickly now
+ for (int i = 1; i < ThreadCount; ++i)
+ QVERIFY(threads[i]->wait(3000));
+
+ for (int i = 0; i < ThreadCount; ++i)
+ delete threads[i];
+}
+
+
QTEST_MAIN(tst_QObjectRace)
#include "tst_qobjectrace.moc"
diff --git a/tests/auto/qpixmapcache/tst_qpixmapcache.cpp b/tests/auto/qpixmapcache/tst_qpixmapcache.cpp
index 1f515ff..405ac34 100644
--- a/tests/auto/qpixmapcache/tst_qpixmapcache.cpp
+++ b/tests/auto/qpixmapcache/tst_qpixmapcache.cpp
@@ -44,9 +44,7 @@
#include <qpixmapcache.h>
-
-
-
+#include "../../../src/gui/image/qpixmapcache_p.h"
//TESTED_CLASS=
@@ -68,10 +66,21 @@ private slots:
void setCacheLimit();
void find();
void insert();
+ void replace();
void remove();
void clear();
+ void pixmapKey();
};
+static QPixmapCache::KeyData* getPrivate(QPixmapCache::Key &key)
+{
+ return (*reinterpret_cast<QPixmapCache::KeyData**>(&key));
+}
+
+static QPixmapCache::KeyData** getPrivateRef(QPixmapCache::Key &key)
+{
+ return (reinterpret_cast<QPixmapCache::KeyData**>(&key));
+}
static int originalCacheLimit;
@@ -119,6 +128,72 @@ void tst_QPixmapCache::setCacheLimit()
QVERIFY(QPixmapCache::find("P1") != 0);
delete p1;
+
+ //The int part of the API
+ p1 = new QPixmap(2, 3);
+ QPixmapCache::Key key = QPixmapCache::insert(*p1);
+ QVERIFY(QPixmapCache::find(key, p1) != 0);
+ delete p1;
+
+ QPixmapCache::setCacheLimit(0);
+ QVERIFY(QPixmapCache::find(key, p1) == 0);
+
+ p1 = new QPixmap(2, 3);
+ QPixmapCache::setCacheLimit(1000);
+ QPixmapCache::replace(key, *p1);
+ QVERIFY(QPixmapCache::find(key, p1) == 0);
+
+ delete p1;
+
+ //Let check if keys are released when the pixmap cache is
+ //full or has been flushed.
+ QPixmapCache::clear();
+ p1 = new QPixmap(2, 3);
+ key = QPixmapCache::insert(*p1);
+ QVERIFY(QPixmapCache::find(key, p1) != 0);
+ QPixmapCache::setCacheLimit(0);
+ QVERIFY(QPixmapCache::find(key, p1) == 0);
+ QPixmapCache::setCacheLimit(1000);
+ key = QPixmapCache::insert(*p1);
+ QCOMPARE(getPrivate(key)->isValid, true);
+ QCOMPARE(getPrivate(key)->key, 1);
+
+ delete p1;
+
+ //Let check if removing old entries doesn't let you get
+ // wrong pixmaps
+ QPixmapCache::clear();
+ QPixmap p2;
+ p1 = new QPixmap(2, 3);
+ key = QPixmapCache::insert(*p1);
+ QVERIFY(QPixmapCache::find(key, &p2) != 0);
+ //we flush the cache
+ QPixmapCache::setCacheLimit(0);
+ QPixmapCache::setCacheLimit(1000);
+ QPixmapCache::Key key2 = QPixmapCache::insert(*p1);
+ QCOMPARE(getPrivate(key2)->key, 2);
+ QVERIFY(QPixmapCache::find(key, &p2) == 0);
+ QVERIFY(QPixmapCache::find(key2, &p2) != 0);
+ QCOMPARE(p2, *p1);
+
+ delete p1;
+
+ //Here we simulate the flushing when the app is idle
+ /*QPixmapCache::clear();
+ QPixmapCache::setCacheLimit(originalCacheLimit);
+ p1 = new QPixmap(300, 300);
+ key = QPixmapCache::insert(*p1);
+ QCOMPARE(getPrivate(key)->key, 1);
+ key2 = QPixmapCache::insert(*p1);
+ key2 = QPixmapCache::insert(*p1);
+ QPixmapCache::Key key3 = QPixmapCache::insert(*p1);
+ QTest::qWait(32000);
+ key2 = QPixmapCache::insert(*p1);
+ QCOMPARE(getPrivate(key2)->key, 1);
+ //This old key is not valid anymore after the flush
+ QCOMPARE(getPrivate(key)->isValid, false);
+ QVERIFY(QPixmapCache::find(key, &p2) == 0);
+ delete p1;*/
}
void tst_QPixmapCache::find()
@@ -137,6 +212,28 @@ void tst_QPixmapCache::find()
QPixmap *p3 = QPixmapCache::find("P1");
QVERIFY(p3);
QCOMPARE(p1, *p3);
+
+ //The int part of the API
+ QPixmapCache::Key key = QPixmapCache::insert(p1);
+
+ QVERIFY(QPixmapCache::find(key, &p2));
+ QCOMPARE(p2.width(), 10);
+ QCOMPARE(p2.height(), 10);
+ QCOMPARE(p1, p2);
+
+ QPixmapCache::clear();
+
+ key = QPixmapCache::insert(p1);
+
+ //The int part of the API
+ // make sure it doesn't explode
+ QList<QPixmapCache::Key> keys;
+ for (int i = 0; i < 40000; ++i)
+ QPixmapCache::insert(p1);
+
+ //at that time the first key has been erase because no more place in the cache
+ QVERIFY(QPixmapCache::find(key, &p1) == 0);
+ QCOMPARE(getPrivate(key)->isValid, false);
}
void tst_QPixmapCache::insert()
@@ -152,18 +249,22 @@ void tst_QPixmapCache::insert()
QPixmapCache::insert("0", p1);
// ditto
- for (int j = 0; j < 20000; ++j)
+ for (int j = 0; j < 40000; ++j)
QPixmapCache::insert(QString::number(j), p1);
int num = 0;
- for (int k = 0; k < 20000; ++k) {
+ for (int k = 0; k < 40000; ++k) {
if (QPixmapCache::find(QString::number(k)))
++num;
}
+ if (QPixmapCache::find("0"))
+ ++num;
+
int estimatedNum = (1024 * QPixmapCache::cacheLimit())
/ ((p1.width() * p1.height() * p1.depth()) / 8);
- QVERIFY(estimatedNum - 1 <= num <= estimatedNum + 1);
+
+ QVERIFY(num <= estimatedNum);
QPixmap p3;
QPixmapCache::insert("null", p3);
@@ -176,6 +277,50 @@ void tst_QPixmapCache::insert()
QPixmapCache::insert("custom", c2);
//We have deleted the old pixmap in the cache for the same key
QVERIFY(c1.isDetached());
+
+ //The int part of the API
+ // make sure it doesn't explode
+ QList<QPixmapCache::Key> keys;
+ for (int i = 0; i < 40000; ++i)
+ keys.append(QPixmapCache::insert(p1));
+
+ num = 0;
+ for (int k = 0; k < 40000; ++k) {
+ if (QPixmapCache::find(keys.at(k), &p2))
+ ++num;
+ }
+
+ estimatedNum = (1024 * QPixmapCache::cacheLimit())
+ / ((p1.width() * p1.height() * p1.depth()) / 8);
+ QVERIFY(num <= estimatedNum);
+ QPixmapCache::insert(p3);
+
+}
+
+void tst_QPixmapCache::replace()
+{
+ //The int part of the API
+ QPixmap p1(10, 10);
+ p1.fill(Qt::red);
+
+ QPixmap p2(10, 10);
+ p2.fill(Qt::yellow);
+
+ QPixmapCache::Key key = QPixmapCache::insert(p1);
+
+ QPixmap p3;
+ QVERIFY(QPixmapCache::find(key, &p3) == 1);
+
+ QPixmapCache::replace(key,p2);
+
+ QVERIFY(QPixmapCache::find(key, &p3) == 1);
+
+ QCOMPARE(p3.width(), 10);
+ QCOMPARE(p3.height(), 10);
+ QCOMPARE(p3, p2);
+
+ //Broken keys
+ QCOMPARE(QPixmapCache::replace(QPixmapCache::Key(), p2), false);
}
void tst_QPixmapCache::remove()
@@ -198,6 +343,40 @@ void tst_QPixmapCache::remove()
QPixmapCache::remove("green");
QVERIFY(QPixmapCache::find("green") == 0);
+
+ //The int part of the API
+ QPixmapCache::clear();
+ p1.fill(Qt::red);
+ QPixmapCache::Key key = QPixmapCache::insert(p1);
+ p1.fill(Qt::yellow);
+
+ QVERIFY(QPixmapCache::find(key, &p2));
+ QVERIFY(p1.toImage() != p2.toImage());
+ QVERIFY(p1.toImage() == p1.toImage()); // sanity check
+
+ QPixmapCache::remove(key);
+ QVERIFY(QPixmapCache::find(key, &p1) == 0);
+
+ //Broken key
+ QPixmapCache::remove(QPixmapCache::Key());
+ QVERIFY(QPixmapCache::find(QPixmapCache::Key(), &p1) == 0);
+
+ //Test if keys are release
+ QPixmapCache::clear();
+ key = QPixmapCache::insert(p1);
+ QCOMPARE(getPrivate(key)->key, 1);
+ QPixmapCache::remove(key);
+ key = QPixmapCache::insert(p1);
+ QCOMPARE(getPrivate(key)->key, 1);
+
+ //We mix both part of the API
+ QPixmapCache::clear();
+ p1.fill(Qt::red);
+ QPixmapCache::insert("red", p1);
+ key = QPixmapCache::insert(p1);
+ QPixmapCache::remove(key);
+ QVERIFY(QPixmapCache::find(key, &p1) == 0);
+ QVERIFY(QPixmapCache::find("red") != 0);
}
void tst_QPixmapCache::clear()
@@ -205,12 +384,11 @@ void tst_QPixmapCache::clear()
QPixmap p1(10, 10);
p1.fill(Qt::red);
- for (int i = 0; i < 20000; ++i) {
+ for (int i = 0; i < 20000; ++i)
QVERIFY(QPixmapCache::find("x" + QString::number(i)) == 0);
- }
- for (int j = 0; j < 20000; ++j) {
+
+ for (int j = 0; j < 20000; ++j)
QPixmapCache::insert(QString::number(j), p1);
- }
int num = 0;
for (int k = 0; k < 20000; ++k) {
@@ -221,10 +399,68 @@ void tst_QPixmapCache::clear()
QPixmapCache::clear();
- for (int k = 0; k < 20000; ++k) {
+ for (int k = 0; k < 20000; ++k)
QVERIFY(QPixmapCache::find(QString::number(k)) == 0);
+
+ //The int part of the API
+ QPixmap p2(10, 10);
+ p2.fill(Qt::red);
+
+ QList<QPixmapCache::Key> keys;
+ for (int k = 0; k < 20000; ++k)
+ keys.append(QPixmapCache::insert(p2));
+
+ QPixmapCache::clear();
+
+ for (int k = 0; k < 20000; ++k) {
+ QVERIFY(QPixmapCache::find(keys.at(k), &p1) == 0);
+ QCOMPARE(getPrivate(keys[k])->isValid, false);
}
}
+void tst_QPixmapCache::pixmapKey()
+{
+ QPixmapCache::Key key;
+ //Default constructed keys have no d pointer unless
+ //we use them
+ QVERIFY(!getPrivate(key));
+ //Let's put a d pointer
+ QPixmapCache::KeyData** keyd = getPrivateRef(key);
+ *keyd = new QPixmapCache::KeyData;
+ QCOMPARE(getPrivate(key)->ref, 1);
+ QPixmapCache::Key key2;
+ //Let's put a d pointer
+ QPixmapCache::KeyData** key2d = getPrivateRef(key2);
+ *key2d = new QPixmapCache::KeyData;
+ QCOMPARE(getPrivate(key2)->ref, 1);
+ key = key2;
+ QCOMPARE(getPrivate(key2)->ref, 2);
+ QCOMPARE(getPrivate(key)->ref, 2);
+ QPixmapCache::Key key3;
+ //Let's put a d pointer
+ QPixmapCache::KeyData** key3d = getPrivateRef(key3);
+ *key3d = new QPixmapCache::KeyData;
+ QPixmapCache::Key key4 = key3;
+ QCOMPARE(getPrivate(key3)->ref, 2);
+ QCOMPARE(getPrivate(key4)->ref, 2);
+ key4 = key;
+ QCOMPARE(getPrivate(key4)->ref, 3);
+ QCOMPARE(getPrivate(key3)->ref, 1);
+ QPixmapCache::Key key5(key3);
+ QCOMPARE(getPrivate(key3)->ref, 2);
+ QCOMPARE(getPrivate(key5)->ref, 2);
+
+ //let test default constructed keys
+ QPixmapCache::Key key6;
+ QVERIFY(!getPrivate(key6));
+ QPixmapCache::Key key7;
+ QVERIFY(!getPrivate(key7));
+ key6 = key7;
+ QVERIFY(!getPrivate(key6));
+ QVERIFY(!getPrivate(key7));
+ QPixmapCache::Key key8(key7);
+ QVERIFY(!getPrivate(key8));
+}
+
QTEST_MAIN(tst_QPixmapCache)
#include "tst_qpixmapcache.moc"
diff --git a/tests/auto/qprinter/tst_qprinter.cpp b/tests/auto/qprinter/tst_qprinter.cpp
index cde4ae5..221e3b0 100644
--- a/tests/auto/qprinter/tst_qprinter.cpp
+++ b/tests/auto/qprinter/tst_qprinter.cpp
@@ -953,8 +953,9 @@ void tst_QPrinter::printDialogCompleter()
QTest::qWait(100);
- QTest::keyClick(0, Qt::Key_Tab);
- QTest::keyClick(0, 'P');
+ QTest::keyClick(&dialog, Qt::Key_Tab);
+ QTest::keyClick(&dialog, 'P');
+ // The test passes if it doesn't crash.
#endif
}
diff --git a/tests/auto/qsharedpointer/tst_qsharedpointer.cpp b/tests/auto/qsharedpointer/tst_qsharedpointer.cpp
index 64439fb..a52bb3e 100644
--- a/tests/auto/qsharedpointer/tst_qsharedpointer.cpp
+++ b/tests/auto/qsharedpointer/tst_qsharedpointer.cpp
@@ -57,8 +57,11 @@ private slots:
void downCast();
void upCast();
void differentPointers();
+ void virtualBaseDifferentPointers();
#ifndef QTEST_NO_RTTI
void dynamicCast();
+ void dynamicCastDifferentPointers();
+ void dynamicCastVirtualBase();
void dynamicCastFailure();
#endif
void customDeleter();
@@ -321,6 +324,10 @@ class DiffPtrDerivedData: public Stuffing, public Data
{
};
+class VirtualDerived: virtual public Data
+{
+};
+
void tst_QSharedPointer::downCast()
{
{
@@ -439,7 +446,7 @@ void tst_QSharedPointer::differentPointers()
DiffPtrDerivedData *aData = new DiffPtrDerivedData;
Data *aBase = aData;
Q_ASSERT(aData == aBase);
- Q_ASSERT(quintptr(&aData) != quintptr(&aBase));
+ Q_ASSERT(*reinterpret_cast<quintptr *>(&aData) != *reinterpret_cast<quintptr *>(&aBase));
QSharedPointer<Data> baseptr = QSharedPointer<Data>(aData);
QSharedPointer<DiffPtrDerivedData> ptr = qSharedPointerCast<DiffPtrDerivedData>(baseptr);
@@ -453,7 +460,7 @@ void tst_QSharedPointer::differentPointers()
DiffPtrDerivedData *aData = new DiffPtrDerivedData;
Data *aBase = aData;
Q_ASSERT(aData == aBase);
- Q_ASSERT(quintptr(&aData) != quintptr(&aBase));
+ Q_ASSERT(*reinterpret_cast<quintptr *>(&aData) != *reinterpret_cast<quintptr *>(&aBase));
QSharedPointer<DiffPtrDerivedData> ptr = QSharedPointer<DiffPtrDerivedData>(aData);
QSharedPointer<Data> baseptr = ptr;
@@ -464,23 +471,53 @@ void tst_QSharedPointer::differentPointers()
QVERIFY(baseptr == aData);
QVERIFY(baseptr == aBase);
}
+}
+
+void tst_QSharedPointer::virtualBaseDifferentPointers()
+{
+ {
+ VirtualDerived *aData = new VirtualDerived;
+ Data *aBase = aData;
+ Q_ASSERT(aData == aBase);
+ Q_ASSERT(*reinterpret_cast<quintptr *>(&aData) != *reinterpret_cast<quintptr *>(&aBase));
+
+ QSharedPointer<VirtualDerived> ptr = QSharedPointer<VirtualDerived>(aData);
+ QSharedPointer<Data> baseptr = qSharedPointerCast<Data>(ptr);
+ QVERIFY(ptr == baseptr);
+ QVERIFY(ptr.data() == baseptr.data());
+ QVERIFY(ptr == aBase);
+ QVERIFY(ptr == aData);
+ QVERIFY(baseptr == aData);
+ QVERIFY(baseptr == aBase);
+ }
+
+ {
+ VirtualDerived *aData = new VirtualDerived;
+ Data *aBase = aData;
+ Q_ASSERT(aData == aBase);
+ Q_ASSERT(*reinterpret_cast<quintptr *>(&aData) != *reinterpret_cast<quintptr *>(&aBase));
- // there is no possibility for different pointers in
- // internal reference counting right now
- //
- // to do that, it's necessary to first implement the ability to
- // call (virtual) functions, so that the two differing bases have
- // the same reference counter
+ QSharedPointer<VirtualDerived> ptr = QSharedPointer<VirtualDerived>(aData);
+ QSharedPointer<Data> baseptr = ptr;
+ QVERIFY(ptr == baseptr);
+ QVERIFY(ptr.data() == baseptr.data());
+ QVERIFY(ptr == aBase);
+ QVERIFY(ptr == aData);
+ QVERIFY(baseptr == aData);
+ QVERIFY(baseptr == aBase);
+ }
}
#ifndef QTEST_NO_RTTI
void tst_QSharedPointer::dynamicCast()
{
- QSharedPointer<Data> baseptr = QSharedPointer<Data>(new DerivedData);
+ DerivedData *aData = new DerivedData;
+ QSharedPointer<Data> baseptr = QSharedPointer<Data>(aData);
{
QSharedPointer<DerivedData> derivedptr = qSharedPointerDynamicCast<DerivedData>(baseptr);
QVERIFY(baseptr == derivedptr);
+ QCOMPARE(derivedptr.data(), aData);
QCOMPARE(static_cast<Data *>(derivedptr.data()), baseptr.data());
}
QCOMPARE(int(baseptr.d->weakref), 1);
@@ -490,6 +527,7 @@ void tst_QSharedPointer::dynamicCast()
QWeakPointer<Data> weakptr = baseptr;
QSharedPointer<DerivedData> derivedptr = qSharedPointerDynamicCast<DerivedData>(weakptr);
QVERIFY(baseptr == derivedptr);
+ QCOMPARE(derivedptr.data(), aData);
QCOMPARE(static_cast<Data *>(derivedptr.data()), baseptr.data());
}
QCOMPARE(int(baseptr.d->weakref), 1);
@@ -498,6 +536,87 @@ void tst_QSharedPointer::dynamicCast()
{
QSharedPointer<DerivedData> derivedptr = baseptr.dynamicCast<DerivedData>();
QVERIFY(baseptr == derivedptr);
+ QCOMPARE(derivedptr.data(), aData);
+ QCOMPARE(static_cast<Data *>(derivedptr.data()), baseptr.data());
+ }
+ QCOMPARE(int(baseptr.d->weakref), 1);
+ QCOMPARE(int(baseptr.d->strongref), 1);
+}
+
+void tst_QSharedPointer::dynamicCastDifferentPointers()
+{
+ // DiffPtrDerivedData derives from both Data and Stuffing
+ DiffPtrDerivedData *aData = new DiffPtrDerivedData;
+ QSharedPointer<Data> baseptr = QSharedPointer<Data>(aData);
+
+ {
+ QSharedPointer<DiffPtrDerivedData> derivedptr = qSharedPointerDynamicCast<DiffPtrDerivedData>(baseptr);
+ QVERIFY(baseptr == derivedptr);
+ QCOMPARE(derivedptr.data(), aData);
+ QCOMPARE(static_cast<Data *>(derivedptr.data()), baseptr.data());
+ }
+ QCOMPARE(int(baseptr.d->weakref), 1);
+ QCOMPARE(int(baseptr.d->strongref), 1);
+
+ {
+ QWeakPointer<Data> weakptr = baseptr;
+ QSharedPointer<DiffPtrDerivedData> derivedptr = qSharedPointerDynamicCast<DiffPtrDerivedData>(weakptr);
+ QVERIFY(baseptr == derivedptr);
+ QCOMPARE(derivedptr.data(), aData);
+ QCOMPARE(static_cast<Data *>(derivedptr.data()), baseptr.data());
+ }
+ QCOMPARE(int(baseptr.d->weakref), 1);
+ QCOMPARE(int(baseptr.d->strongref), 1);
+
+ {
+ QSharedPointer<DiffPtrDerivedData> derivedptr = baseptr.dynamicCast<DiffPtrDerivedData>();
+ QVERIFY(baseptr == derivedptr);
+ QCOMPARE(derivedptr.data(), aData);
+ QCOMPARE(static_cast<Data *>(derivedptr.data()), baseptr.data());
+ }
+ QCOMPARE(int(baseptr.d->weakref), 1);
+ QCOMPARE(int(baseptr.d->strongref), 1);
+
+ {
+ Stuffing *nakedptr = dynamic_cast<Stuffing *>(baseptr.data());
+ QVERIFY(nakedptr);
+
+ QSharedPointer<Stuffing> otherbaseptr = qSharedPointerDynamicCast<Stuffing>(baseptr);
+ QVERIFY(!otherbaseptr.isNull());
+ QVERIFY(otherbaseptr == nakedptr);
+ QCOMPARE(otherbaseptr.data(), nakedptr);
+ QCOMPARE(static_cast<DiffPtrDerivedData*>(otherbaseptr.data()), aData);
+ }
+}
+
+void tst_QSharedPointer::dynamicCastVirtualBase()
+{
+ VirtualDerived *aData = new VirtualDerived;
+ QSharedPointer<Data> baseptr = QSharedPointer<Data>(aData);
+
+ {
+ QSharedPointer<VirtualDerived> derivedptr = qSharedPointerDynamicCast<VirtualDerived>(baseptr);
+ QVERIFY(baseptr == derivedptr);
+ QCOMPARE(derivedptr.data(), aData);
+ QCOMPARE(static_cast<Data *>(derivedptr.data()), baseptr.data());
+ }
+ QCOMPARE(int(baseptr.d->weakref), 1);
+ QCOMPARE(int(baseptr.d->strongref), 1);
+
+ {
+ QWeakPointer<Data> weakptr = baseptr;
+ QSharedPointer<VirtualDerived> derivedptr = qSharedPointerDynamicCast<VirtualDerived>(weakptr);
+ QVERIFY(baseptr == derivedptr);
+ QCOMPARE(derivedptr.data(), aData);
+ QCOMPARE(static_cast<Data *>(derivedptr.data()), baseptr.data());
+ }
+ QCOMPARE(int(baseptr.d->weakref), 1);
+ QCOMPARE(int(baseptr.d->strongref), 1);
+
+ {
+ QSharedPointer<VirtualDerived> derivedptr = baseptr.dynamicCast<VirtualDerived>();
+ QVERIFY(baseptr == derivedptr);
+ QCOMPARE(derivedptr.data(), aData);
QCOMPARE(static_cast<Data *>(derivedptr.data()), baseptr.data());
}
QCOMPARE(int(baseptr.d->weakref), 1);
diff --git a/tests/auto/qsocks5socketengine/tst_qsocks5socketengine.cpp b/tests/auto/qsocks5socketengine/tst_qsocks5socketengine.cpp
index 86333e0..5ab5064 100644
--- a/tests/auto/qsocks5socketengine/tst_qsocks5socketengine.cpp
+++ b/tests/auto/qsocks5socketengine/tst_qsocks5socketengine.cpp
@@ -145,8 +145,6 @@ private slots:
}
};
-static const char *IMAP_IP = "62.70.27.18";
-
tst_QSocks5SocketEngine::tst_QSocks5SocketEngine()
{
}
@@ -321,12 +319,11 @@ void tst_QSocks5SocketEngine::simpleConnectToIMAP()
socketDevice.setProxy(QNetworkProxy(QNetworkProxy::Socks5Proxy, QtNetworkSettings::serverName(), 1080));
- // Connect to imap.trolltech.com's IP
- QVERIFY(!socketDevice.connectToHost(QHostAddress(IMAP_IP), 143));
+ QVERIFY(!socketDevice.connectToHost(QtNetworkSettings::serverIP(), 143));
QVERIFY(socketDevice.state() == QAbstractSocket::ConnectingState);
QVERIFY(socketDevice.waitForWrite());
QVERIFY(socketDevice.state() == QAbstractSocket::ConnectedState);
- QVERIFY(socketDevice.peerAddress() == QHostAddress(IMAP_IP));
+ QVERIFY(socketDevice.peerAddress() == QtNetworkSettings::serverIP());
// Wait for the greeting
QVERIFY(socketDevice.waitForRead());
@@ -340,7 +337,7 @@ void tst_QSocks5SocketEngine::simpleConnectToIMAP()
// Check that the greeting is what we expect it to be
QCOMPARE(array.constData(),
- "* OK esparsett Cyrus IMAP4 v2.2.8 server ready\r\n");
+ "* OK [CAPABILITY IMAP4 IMAP4rev1 LITERAL+ ID STARTTLS LOGINDISABLED] qt-test-server.qt-test-net Cyrus IMAP4 v2.3.11-Mandriva-RPM-2.3.11-6mdv2008.1 server ready\r\n");
// Write a logout message
QByteArray array2 = "XXXX LOGOUT\r\n";
@@ -589,14 +586,14 @@ void tst_QSocks5SocketEngine::tcpSocketBlockingTest()
QTcpSocket socket;
// Connect
- socket.connectToHost("imap.troll.no", 143);
+ socket.connectToHost(QtNetworkSettings::serverName(), 143);
QVERIFY(socket.waitForConnected());
QCOMPARE(socket.state(), QTcpSocket::ConnectedState);
// Read greeting
QVERIFY(socket.waitForReadyRead(5000));
QString s = socket.readLine();
- QCOMPARE(s.toLatin1().constData(), "* OK esparsett Cyrus IMAP4 v2.2.8 server ready\r\n");
+ QCOMPARE(s.toLatin1().constData(), "* OK [CAPABILITY IMAP4 IMAP4rev1 LITERAL+ ID STARTTLS LOGINDISABLED] qt-test-server.qt-test-net Cyrus IMAP4 v2.3.11-Mandriva-RPM-2.3.11-6mdv2008.1 server ready\r\n");
// Write NOOP
QCOMPARE((int) socket.write("1 NOOP\r\n", 8), 8);
@@ -646,7 +643,7 @@ void tst_QSocks5SocketEngine::tcpSocketNonBlockingTest()
tcpSocketNonBlocking_socket = &socket;
// Connect
- socket.connectToHost("imap.troll.no", 143);
+ socket.connectToHost(QtNetworkSettings::serverName(), 143);
QCOMPARE(socket.state(), QTcpSocket::HostLookupState);
QTestEventLoop::instance().enterLoop(30);
@@ -671,7 +668,7 @@ void tst_QSocks5SocketEngine::tcpSocketNonBlockingTest()
// Read greeting
QVERIFY(!tcpSocketNonBlocking_data.isEmpty());
QCOMPARE(tcpSocketNonBlocking_data.at(0).toLatin1().constData(),
- "* OK esparsett Cyrus IMAP4 v2.2.8 server ready\r\n");
+ "* OK [CAPABILITY IMAP4 IMAP4rev1 LITERAL+ ID STARTTLS LOGINDISABLED] qt-test-server.qt-test-net Cyrus IMAP4 v2.3.11-Mandriva-RPM-2.3.11-6mdv2008.1 server ready\r\n");
tcpSocketNonBlocking_data.clear();
tcpSocketNonBlocking_totalWritten = 0;
@@ -798,14 +795,14 @@ void tst_QSocks5SocketEngine::downloadBigFile()
if (QTestEventLoop::instance().timeout())
QFAIL("Network operation timed out");
- QCOMPARE(bytesAvailable, qint64(10000309));
+ QCOMPARE(bytesAvailable, qint64(10000000));
QVERIFY(tmpSocket->state() == QAbstractSocket::ConnectedState);
- qDebug("\t\t%.1fMB/%.1fs: %.1fMB/s",
+ /*qDebug("\t\t%.1fMB/%.1fs: %.1fMB/s",
bytesAvailable / (1024.0 * 1024.0),
stopWatch.elapsed() / 1024.0,
- (bytesAvailable / (stopWatch.elapsed() / 1000.0)) / (1024 * 1024));
+ (bytesAvailable / (stopWatch.elapsed() / 1000.0)) / (1024 * 1024));*/
delete tmpSocket;
tmpSocket = 0;
@@ -819,7 +816,10 @@ void tst_QSocks5SocketEngine::exitLoopSlot()
void tst_QSocks5SocketEngine::downloadBigFileSlot()
{
- bytesAvailable += tmpSocket->readAll().size();
+ QByteArray tmp=tmpSocket->readAll();
+ int correction=tmp.indexOf((char)0,0); //skip header
+ if (correction==-1) correction=0;
+ bytesAvailable += (tmp.size()-correction);
if (bytesAvailable >= 10000000)
QTestEventLoop::instance().exitLoop();
}
@@ -834,15 +834,14 @@ void tst_QSocks5SocketEngine::passwordAuth()
socketDevice.setProxy(QNetworkProxy(QNetworkProxy::Socks5Proxy, QtNetworkSettings::serverName(), 1080, "qsockstest", "password"));
- // Connect to imap.trolltech.com's IP
- QVERIFY(!socketDevice.connectToHost(QHostAddress(IMAP_IP), 143));
+ QVERIFY(!socketDevice.connectToHost(QtNetworkSettings::serverIP(), 143));
QVERIFY(socketDevice.state() == QAbstractSocket::ConnectingState);
QVERIFY(socketDevice.waitForWrite());
- if (!socketDevice.connectToHost(QHostAddress(IMAP_IP), 143)) {
+ if (!socketDevice.connectToHost(QtNetworkSettings::serverIP(), 143)) {
qDebug("%d, %s", socketDevice.error(), socketDevice.errorString().toLatin1().constData());
}
QVERIFY(socketDevice.state() == QAbstractSocket::ConnectedState);
- QVERIFY(socketDevice.peerAddress() == QHostAddress(IMAP_IP));
+ QVERIFY(socketDevice.peerAddress() == QtNetworkSettings::serverIP());
// Wait for the greeting
QVERIFY(socketDevice.waitForRead());
@@ -856,7 +855,7 @@ void tst_QSocks5SocketEngine::passwordAuth()
// Check that the greeting is what we expect it to be
QCOMPARE(array.constData(),
- "* OK esparsett Cyrus IMAP4 v2.2.8 server ready\r\n");
+ "* OK [CAPABILITY IMAP4 IMAP4rev1 LITERAL+ ID STARTTLS LOGINDISABLED] qt-test-server.qt-test-net Cyrus IMAP4 v2.3.11-Mandriva-RPM-2.3.11-6mdv2008.1 server ready\r\n");
// Write a logout message
QByteArray array2 = "XXXX LOGOUT\r\n";
@@ -902,17 +901,16 @@ void tst_QSocks5SocketEngine::passwordAuth2()
socketDevice.setProxy(QNetworkProxy(QNetworkProxy::Socks5Proxy, QtNetworkSettings::serverName(), 1081));
socketDevice.setReceiver(this);
- // Connect to imap.trolltech.com's IP
- QVERIFY(!socketDevice.connectToHost(QHostAddress(IMAP_IP), 143));
+ QVERIFY(!socketDevice.connectToHost(QtNetworkSettings::serverIP(), 143));
QVERIFY(socketDevice.state() == QAbstractSocket::ConnectingState);
while (socketDevice.state() == QAbstractSocket::ConnectingState) {
QVERIFY(socketDevice.waitForWrite());
- socketDevice.connectToHost(QHostAddress(IMAP_IP), 143);
+ socketDevice.connectToHost(QtNetworkSettings::serverIP(), 143);
}
if (socketDevice.state() != QAbstractSocket::ConnectedState)
qDebug("%d, %s", socketDevice.error(), socketDevice.errorString().toLatin1().constData());
QVERIFY(socketDevice.state() == QAbstractSocket::ConnectedState);
- QVERIFY(socketDevice.peerAddress() == QHostAddress(IMAP_IP));
+ QVERIFY(socketDevice.peerAddress() == QtNetworkSettings::serverIP());
// Wait for the greeting
QVERIFY(socketDevice.waitForRead());
@@ -926,7 +924,7 @@ void tst_QSocks5SocketEngine::passwordAuth2()
// Check that the greeting is what we expect it to be
QCOMPARE(array.constData(),
- "* OK esparsett Cyrus IMAP4 v2.2.8 server ready\r\n");
+ "* OK [CAPABILITY IMAP4 IMAP4rev1 LITERAL+ ID STARTTLS LOGINDISABLED] qt-test-server.qt-test-net Cyrus IMAP4 v2.3.11-Mandriva-RPM-2.3.11-6mdv2008.1 server ready\r\n");
// Write a logout message
QByteArray array2 = "XXXX LOGOUT\r\n";
diff --git a/tests/auto/qsplitter/tst_qsplitter.cpp b/tests/auto/qsplitter/tst_qsplitter.cpp
index 33404e4..5fa0286 100644
--- a/tests/auto/qsplitter/tst_qsplitter.cpp
+++ b/tests/auto/qsplitter/tst_qsplitter.cpp
@@ -55,6 +55,7 @@
#include <qtreeview.h>
#include <qlabel.h>
#include <qdebug.h> // for file error messages
+#include "../../shared/util.h"
//TESTED_CLASS=
//TESTED_FILES=
@@ -1341,9 +1342,7 @@ void tst_QSplitter::task187373_addAbstractScrollAreas()
if (addOutsideConstructor)
splitter->addWidget(w);
- qApp->processEvents();
-
- QVERIFY(w->isVisible());
+ QTRY_VERIFY(w->isVisible());
QVERIFY(!w->isHidden());
QVERIFY(w->viewport()->isVisible());
QVERIFY(!w->viewport()->isHidden());
diff --git a/tests/auto/qsslsocket/qsslsocket.pro b/tests/auto/qsslsocket/qsslsocket.pro
index 147b40d..c29fc68 100644
--- a/tests/auto/qsslsocket/qsslsocket.pro
+++ b/tests/auto/qsslsocket/qsslsocket.pro
@@ -7,6 +7,12 @@ QT -= gui
TARGET = tst_qsslsocket
+!wince* {
+DEFINES += SRCDIR=\\\"$$PWD/\\\"
+} else {
+DEFINES += SRCDIR=\\\"./\\\"
+}
+
win32 {
CONFIG(debug, debug|release) {
DESTDIR = debug
diff --git a/tests/auto/qsslsocket/tst_qsslsocket.cpp b/tests/auto/qsslsocket/tst_qsslsocket.cpp
index 432092a..40840bd 100644
--- a/tests/auto/qsslsocket/tst_qsslsocket.cpp
+++ b/tests/auto/qsslsocket/tst_qsslsocket.cpp
@@ -416,7 +416,7 @@ void tst_QSslSocket::simpleConnect()
connect(&socket, SIGNAL(sslErrors(const QList<QSslError> &)), this, SLOT(exitLoop()));
// Start connecting
- socket.connectToHost("imap.troll.no", 993);
+ socket.connectToHost(QtNetworkSettings::serverName(), 993);
QCOMPARE(socket.state(), QAbstractSocket::HostLookupState);
enterLoop(10);
@@ -471,7 +471,7 @@ void tst_QSslSocket::simpleConnectWithIgnore()
connect(&socket, SIGNAL(sslErrors(const QList<QSslError> &)), this, SLOT(exitLoop()));
// Start connecting
- socket.connectToHost("imap.troll.no", 993);
+ socket.connectToHost(QtNetworkSettings::serverName(), 993);
QCOMPARE(socket.state(), QAbstractSocket::HostLookupState);
enterLoop(10);
@@ -490,7 +490,7 @@ void tst_QSslSocket::simpleConnectWithIgnore()
if (!socket.canReadLine())
enterLoop(10);
- QCOMPARE(socket.readAll(), QByteArray("* OK esparsett Cyrus IMAP4 v2.2.8 server ready\r\n"));
+ QCOMPARE(socket.readAll(), QByteArray("* OK [CAPABILITY IMAP4 IMAP4rev1 LITERAL+ ID AUTH=PLAIN SASL-IR] qt-test-server.qt-test-net Cyrus IMAP4 v2.3.11-Mandriva-RPM-2.3.11-6mdv2008.1 server ready\r\n"));
socket.disconnectFromHost();
}
@@ -499,36 +499,39 @@ void tst_QSslSocket::sslErrors_data()
{
QTest::addColumn<QString>("host");
QTest::addColumn<int>("port");
- QTest::addColumn<SslErrorList>("errors");
-
- QTest::newRow("imap.troll.no") << "imap.troll.no" << 993
- << (SslErrorList()
- << QSslError::HostNameMismatch
- << QSslError::SelfSignedCertificateInChain);
- QTest::newRow("imap.trolltech.com") << "imap.trolltech.com" << 993
- << (SslErrorList()
- << QSslError::SelfSignedCertificateInChain);
+ QTest::addColumn<SslErrorList>("expected");
+
+ QTest::newRow(qPrintable(QtNetworkSettings::serverLocalName()))
+ << QtNetworkSettings::serverLocalName()
+ << 993
+ << (SslErrorList() << QSslError::HostNameMismatch
+ << QSslError::SelfSignedCertificate);
+
+ QTest::newRow("imap.trolltech.com")
+ << "imap.trolltech.com"
+ << 993
+ << (SslErrorList() << QSslError::SelfSignedCertificateInChain);
}
void tst_QSslSocket::sslErrors()
{
QFETCH(QString, host);
QFETCH(int, port);
- QFETCH(SslErrorList, errors);
+ QFETCH(SslErrorList, expected);
QSslSocketPtr socket = newSocket();
socket->connectToHostEncrypted(host, port);
socket->waitForEncrypted(5000);
- SslErrorList list;
+ SslErrorList output;
foreach (QSslError error, socket->sslErrors())
- list << error.error();
+ output << error.error();
#ifdef QSSLSOCKET_CERTUNTRUSTED_WORKAROUND
- if (list.last() == QSslError::CertificateUntrusted)
- list.takeLast();
+ if (output.last() == QSslError::CertificateUntrusted)
+ output.takeLast();
#endif
- QCOMPARE(list, errors);
+ QCOMPARE(output, expected);
}
void tst_QSslSocket::addCaCertificate()
@@ -575,7 +578,7 @@ void tst_QSslSocket::connectToHostEncrypted()
QSslSocketPtr socket = newSocket();
this->socket = socket;
- socket->addCaCertificates(QLatin1String("certs/qt-test-server-cacert.pem"));
+ QVERIFY(socket->addCaCertificates(QLatin1String(SRCDIR "certs/qt-test-server-cacert.pem")));
#ifdef QSSLSOCKET_CERTUNTRUSTED_WORKAROUND
connect(&socket, SIGNAL(sslErrors(QList<QSslError>)),
this, SLOT(untrustedWorkaroundSlot(QList<QSslError>)));
@@ -672,7 +675,7 @@ void tst_QSslSocket::peerCertificateChain()
QSslSocketPtr socket = newSocket();
this->socket = socket;
- QList<QSslCertificate> caCertificates = QSslCertificate::fromPath(QLatin1String("certs/qt-test-server-cacert.pem"));
+ QList<QSslCertificate> caCertificates = QSslCertificate::fromPath(QLatin1String(SRCDIR "certs/qt-test-server-cacert.pem"));
QVERIFY(caCertificates.count() == 1);
socket->addCaCertificates(caCertificates);
@@ -733,7 +736,7 @@ void tst_QSslSocket::protocol()
QSslSocketPtr socket = newSocket();
this->socket = socket;
- QList<QSslCertificate> certs = QSslCertificate::fromPath("certs/qt-test-server-cacert.pem");
+ QList<QSslCertificate> certs = QSslCertificate::fromPath(SRCDIR "certs/qt-test-server-cacert.pem");
// qDebug() << "certs:" << certs.at(0).issuerInfo(QSslCertificate::CommonName);
socket->setCaCertificates(certs);
@@ -816,7 +819,7 @@ void tst_QSslSocket::setCaCertificates()
QSslSocket socket;
QCOMPARE(socket.caCertificates(), QSslSocket::defaultCaCertificates());
- socket.setCaCertificates(QSslCertificate::fromPath("certs/qt-test-server-cacert.pem"));
+ socket.setCaCertificates(QSslCertificate::fromPath(SRCDIR "certs/qt-test-server-cacert.pem"));
QCOMPARE(socket.caCertificates().size(), 1);
socket.setCaCertificates(socket.defaultCaCertificates());
QCOMPARE(socket.caCertificates(), QSslSocket::defaultCaCertificates());
@@ -847,13 +850,13 @@ protected:
socket = new QSslSocket(this);
connect(socket, SIGNAL(sslErrors(const QList<QSslError> &)), this, SLOT(ignoreErrorSlot()));
- QFile file("certs/fluke.key");
+ QFile file(SRCDIR "certs/fluke.key");
QVERIFY(file.open(QIODevice::ReadOnly));
QSslKey key(file.readAll(), QSsl::Rsa, QSsl::Pem, QSsl::PrivateKey);
QVERIFY(!key.isNull());
socket->setPrivateKey(key);
- QList<QSslCertificate> localCert = QSslCertificate::fromPath("certs/fluke.cert");
+ QList<QSslCertificate> localCert = QSslCertificate::fromPath(SRCDIR "certs/fluke.cert");
QVERIFY(!localCert.isEmpty());
QVERIFY(localCert.first().handle());
socket->setLocalCertificate(localCert.first());
@@ -954,7 +957,7 @@ void tst_QSslSocket::addDefaultCaCertificate()
// Reset the global CA chain
QSslSocket::setDefaultCaCertificates(QSslSocket::systemCaCertificates());
- QList<QSslCertificate> flukeCerts = QSslCertificate::fromPath("certs/qt-test-server-cacert.pem");
+ QList<QSslCertificate> flukeCerts = QSslCertificate::fromPath(SRCDIR "certs/qt-test-server-cacert.pem");
QCOMPARE(flukeCerts.size(), 1);
QList<QSslCertificate> globalCerts = QSslSocket::defaultCaCertificates();
QVERIFY(!globalCerts.contains(flukeCerts.first()));
@@ -1038,7 +1041,7 @@ void tst_QSslSocket::wildcard()
// responds with the wildcard, and QSslSocket should accept that as a
// valid connection. This was broken in 4.3.0.
QSslSocketPtr socket = newSocket();
- socket->addCaCertificates(QLatin1String("certs/qt-test-server-cacert.pem"));
+ socket->addCaCertificates(QLatin1String(SRCDIR "certs/qt-test-server-cacert.pem"));
this->socket = socket;
#ifdef QSSLSOCKET_CERTUNTRUSTED_WORKAROUND
connect(socket, SIGNAL(sslErrors(QList<QSslError>)),
@@ -1064,7 +1067,7 @@ protected:
socket->ignoreSslErrors();
// Only set the certificate
- QList<QSslCertificate> localCert = QSslCertificate::fromPath("certs/fluke.cert");
+ QList<QSslCertificate> localCert = QSslCertificate::fromPath(SRCDIR "certs/fluke.cert");
QVERIFY(!localCert.isEmpty());
QVERIFY(localCert.first().handle());
socket->setLocalCertificate(localCert.first());
@@ -1223,13 +1226,13 @@ protected:
socket = new QSslSocket(this);
connect(socket, SIGNAL(sslErrors(const QList<QSslError> &)), this, SLOT(ignoreErrorSlot()));
- QFile file("certs/fluke.key");
+ QFile file(SRCDIR "certs/fluke.key");
QVERIFY(file.open(QIODevice::ReadOnly));
QSslKey key(file.readAll(), QSsl::Rsa, QSsl::Pem, QSsl::PrivateKey);
QVERIFY(!key.isNull());
socket->setPrivateKey(key);
- QList<QSslCertificate> localCert = QSslCertificate::fromPath("certs/fluke.cert");
+ QList<QSslCertificate> localCert = QSslCertificate::fromPath(SRCDIR "certs/fluke.cert");
QVERIFY(!localCert.isEmpty());
QVERIFY(localCert.first().handle());
socket->setLocalCertificate(localCert.first());
@@ -1389,8 +1392,8 @@ protected:
{
socket = new QSslSocket(this);
- socket->setPrivateKey("certs/fluke.key");
- socket->setLocalCertificate("certs/fluke.cert");
+ socket->setPrivateKey(SRCDIR "certs/fluke.key");
+ socket->setLocalCertificate(SRCDIR "certs/fluke.cert");
socket->setSocketDescriptor(socketDescriptor);
socket->startServerEncryption();
}
@@ -1513,7 +1516,7 @@ void tst_QSslSocket::resetProxy()
// make sure the connection works, and then set a nonsense proxy, and then
// make sure it does not work anymore
QSslSocket socket;
- socket.addCaCertificates(QLatin1String("certs/qt-test-server-cacert.pem"));
+ socket.addCaCertificates(QLatin1String(SRCDIR "certs/qt-test-server-cacert.pem"));
socket.setProxy(goodProxy);
socket.connectToHostEncrypted(QtNetworkSettings::serverName(), 443);
QVERIFY2(socket.waitForConnected(10000), qPrintable(socket.errorString()));
@@ -1526,7 +1529,7 @@ void tst_QSslSocket::resetProxy()
// set the nonsense proxy and make sure the connection does not work,
// and then set the right proxy and make sure it works
QSslSocket socket2;
- socket2.addCaCertificates(QLatin1String("certs/qt-test-server-cacert.pem"));
+ socket2.addCaCertificates(QLatin1String(SRCDIR "certs/qt-test-server-cacert.pem"));
socket2.setProxy(badProxy);
socket2.connectToHostEncrypted(QtNetworkSettings::serverName(), 443);
QVERIFY(! socket2.waitForConnected(10000));
diff --git a/tests/auto/qtcpserver/tst_qtcpserver.cpp b/tests/auto/qtcpserver/tst_qtcpserver.cpp
index 50b293d..4fd1827 100644
--- a/tests/auto/qtcpserver/tst_qtcpserver.cpp
+++ b/tests/auto/qtcpserver/tst_qtcpserver.cpp
@@ -364,7 +364,7 @@ void tst_QTcpServer::ipv6LoopbackPerformanceTest()
void tst_QTcpServer::ipv4PerformanceTest()
{
QTcpSocket probeSocket;
- probeSocket.connectToHost("imap.troll.no", 143);
+ probeSocket.connectToHost(QtNetworkSettings::serverName(), 143);
QVERIFY(probeSocket.waitForConnected(5000));
QTcpServer server;
diff --git a/tests/auto/qtessellator/testtessellator.cpp b/tests/auto/qtessellator/testtessellator.cpp
index bd2795c..423c1e8 100644
--- a/tests/auto/qtessellator/testtessellator.cpp
+++ b/tests/auto/qtessellator/testtessellator.cpp
@@ -38,7 +38,7 @@
** $QT_END_LICENSE$
**
****************************************************************************/
-#include <testtessellator.h>
+#include "testtessellator.h"
#include <private/qtessellator_p.h>
#include "math.h"
diff --git a/tests/auto/qtessellator/tst_tessellator.cpp b/tests/auto/qtessellator/tst_tessellator.cpp
index 8958ac3..8899285 100644
--- a/tests/auto/qtessellator/tst_tessellator.cpp
+++ b/tests/auto/qtessellator/tst_tessellator.cpp
@@ -218,8 +218,8 @@ void tst_QTessellator::testArc()
const int stop = 1000;
#endif
for (int i = 0; i < stop; ++i) {
- mat.rotate(.01);
- mat.scale(.99, .99);
+ mat.rotate(qreal(.01));
+ mat.scale(qreal(.99), qreal(.99));
QPolygonF poly = arc.at(0);
QPolygonF vec = poly * mat;
QVERIFY(test_arc(vec, true));
@@ -361,11 +361,11 @@ void tst_QTessellator::testRects()
QVector<QPointF> v(5);
for (int i = 0; i < 5; ++i)
v[i] = vec[5 * rect + i];
- if (!test(v.data(), v.size(), false, test_tessellate_polygon_rect, 0.05)) {
+ if (!test(v.data(), v.size(), false, test_tessellate_polygon_rect, qreal(0.05))) {
simplifyTestFailure(v, false);
++failures;
}
- if (!test(v.data(), v.size(), true, test_tessellate_polygon_rect, 0.05)) {
+ if (!test(v.data(), v.size(), true, test_tessellate_polygon_rect, qreal(0.05))) {
simplifyTestFailure(v, true);
++failures;
}
diff --git a/tests/auto/qtessellator/utils.cpp b/tests/auto/qtessellator/utils.cpp
index 8a9dc1e..d408193 100644
--- a/tests/auto/qtessellator/utils.cpp
+++ b/tests/auto/qtessellator/utils.cpp
@@ -43,7 +43,7 @@
#include <assert.h>
#include <qglobal.h>
-#include <qnum.h>
+#include "qnum.h"
#define FloatToXFixed(i) (int)((i) * 65536)
#define IntToXFixed(i) ((i) << 16)
diff --git a/tests/auto/qthreadonce/tst_qthreadonce.cpp b/tests/auto/qthreadonce/tst_qthreadonce.cpp
index 7e67dc3..f20788a 100644
--- a/tests/auto/qthreadonce/tst_qthreadonce.cpp
+++ b/tests/auto/qthreadonce/tst_qthreadonce.cpp
@@ -46,7 +46,7 @@
#include <qmutex.h>
#include <qthread.h>
#include <qwaitcondition.h>
-#include <qthreadonce.h>
+#include "qthreadonce.h"
//TESTED_CLASS=
//TESTED_FILES=corelib/thread/qthreadonce.h corelib/thread/qthreadonce.cpp
diff --git a/tests/auto/qwidget/tst_qwidget.cpp b/tests/auto/qwidget/tst_qwidget.cpp
index efdaaec..23ead01 100644
--- a/tests/auto/qwidget/tst_qwidget.cpp
+++ b/tests/auto/qwidget/tst_qwidget.cpp
@@ -8412,6 +8412,7 @@ void tst_QWidget::translucentWidget()
ColorRedWidget label;
label.setFixedSize(16,16);
label.setAttribute(Qt::WA_TranslucentBackground);
+ label.move(qApp->desktop()->availableGeometry().topLeft());
label.show();
#ifdef Q_WS_X11
qt_x11_wait_for_window_manager(&label);
diff --git a/tests/auto/selftests/expected_xunit.txt b/tests/auto/selftests/expected_xunit.txt
index 875dda6..cb74491 100644
--- a/tests/auto/selftests/expected_xunit.txt
+++ b/tests/auto/selftests/expected_xunit.txt
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" ?>
-<testsuite errors="3" failures="2" tests="6" name="tst_Xunit">
+<testsuite errors="5" failures="3" tests="9" name="tst_Xunit">
<properties>
<property value="4.6.0" name="QTestVersion"/>
<property value="4.6.0" name="QtVersion"/>
@@ -20,10 +20,21 @@
<testcase result="fail" name="testFunc4">
<failure message="a forced failure!" result="fail"/>
</testcase>
+ <testcase result="xfail" name="testFunc5">
+ <!-- message="this failure is expected" type="info" -->
+ </testcase>
+ <testcase result="xfail" name="testFunc6">
+ <!-- message="this failure is also expected" type="info" -->
+ </testcase>
+ <testcase result="xpass" name="testFunc7">
+ <failure message="&apos;true&apos; returned FALSE. ()" result="xpass"/>
+ </testcase>
<testcase result="pass" name="cleanupTestCase"/>
<system-err>
<![CDATA[just a QWARN() !]]>
<![CDATA[a qDebug() call with comment-ending stuff -->]]>
<![CDATA[skipping this function!]]>
+<![CDATA[this failure is expected]]>
+<![CDATA[this failure is also expected]]>
</system-err>
</testsuite>
diff --git a/tests/auto/selftests/xunit/tst_xunit.cpp b/tests/auto/selftests/xunit/tst_xunit.cpp
index dbe9fec..c3c90ab 100644
--- a/tests/auto/selftests/xunit/tst_xunit.cpp
+++ b/tests/auto/selftests/xunit/tst_xunit.cpp
@@ -53,6 +53,9 @@ private slots:
void testFunc2();
void testFunc3();
void testFunc4();
+ void testFunc5();
+ void testFunc6();
+ void testFunc7();
};
tst_Xunit::tst_Xunit()
@@ -81,6 +84,32 @@ void tst_Xunit::testFunc4()
QFAIL("a forced failure!");
}
+/*
+ Note there are two testfunctions which give expected failures.
+ This is so we can test that expected failures don't add to failure
+ counts and unexpected passes do. If we had one xfail and one xpass
+ testfunction, we couldn't test which one of them adds to the failure
+ count.
+*/
+
+void tst_Xunit::testFunc5()
+{
+ QEXPECT_FAIL("", "this failure is expected", Abort);
+ QVERIFY(false);
+}
+
+void tst_Xunit::testFunc6()
+{
+ QEXPECT_FAIL("", "this failure is also expected", Abort);
+ QVERIFY(false);
+}
+
+void tst_Xunit::testFunc7()
+{
+ QEXPECT_FAIL("", "this pass is unexpected", Abort);
+ QVERIFY(true);
+}
+
QTEST_APPLESS_MAIN(tst_Xunit)
#include "tst_xunit.moc"
diff --git a/tests/auto/uic/baseline/languagesdialog.ui.h b/tests/auto/uic/baseline/languagesdialog.ui.h
index a0b9cae..fbe57ca 100644
--- a/tests/auto/uic/baseline/languagesdialog.ui.h
+++ b/tests/auto/uic/baseline/languagesdialog.ui.h
@@ -1,8 +1,8 @@
/********************************************************************************
** Form generated from reading ui file 'languagesdialog.ui'
**
-** Created: Mon Jun 16 17:57:32 2008
-** by: Qt User Interface Compiler version 4.5.0
+** Created: Fri May 15 16:58:03 2009
+** by: Qt User Interface Compiler version 4.5.2
**
** WARNING! All changes made in this file will be lost when recompiling ui file!
********************************************************************************/
@@ -57,7 +57,7 @@ public:
upButton->setObjectName(QString::fromUtf8("upButton"));
upButton->setEnabled(false);
QIcon icon;
- icon.addPixmap(QPixmap(QString::fromUtf8(":/images/up.png")), QIcon::Normal, QIcon::Off);
+ icon.addFile(QString::fromUtf8(":/images/up.png"), QSize(), QIcon::Normal, QIcon::Off);
upButton->setIcon(icon);
hboxLayout->addWidget(upButton);
@@ -66,7 +66,7 @@ public:
downButton->setObjectName(QString::fromUtf8("downButton"));
downButton->setEnabled(false);
QIcon icon1;
- icon1.addPixmap(QPixmap(QString::fromUtf8(":/images/down.png")), QIcon::Normal, QIcon::Off);
+ icon1.addFile(QString::fromUtf8(":/images/down.png"), QSize(), QIcon::Normal, QIcon::Off);
downButton->setIcon(icon1);
hboxLayout->addWidget(downButton);
@@ -75,7 +75,7 @@ public:
removeButton->setObjectName(QString::fromUtf8("removeButton"));
removeButton->setEnabled(false);
QIcon icon2;
- icon2.addPixmap(QPixmap(QString::fromUtf8(":/images/editdelete.png")), QIcon::Normal, QIcon::Off);
+ icon2.addFile(QString::fromUtf8(":/images/editdelete.png"), QSize(), QIcon::Normal, QIcon::Off);
removeButton->setIcon(icon2);
hboxLayout->addWidget(removeButton);
@@ -84,7 +84,7 @@ public:
openFileButton->setObjectName(QString::fromUtf8("openFileButton"));
openFileButton->setEnabled(true);
QIcon icon3;
- icon3.addPixmap(QPixmap(QString::fromUtf8(":/images/mac/fileopen.png")), QIcon::Normal, QIcon::Off);
+ icon3.addFile(QString::fromUtf8(":/images/mac/fileopen.png"), QSize(), QIcon::Normal, QIcon::Off);
openFileButton->setIcon(icon3);
hboxLayout->addWidget(openFileButton);
diff --git a/tests/auto/utf8/tst_utf8.cpp b/tests/auto/utf8/tst_utf8.cpp
index 3aef69f..e21e5a3 100644
--- a/tests/auto/utf8/tst_utf8.cpp
+++ b/tests/auto/utf8/tst_utf8.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
** Contact: Qt Software Information (qt-info@nokia.com)
**
** This file is part of the test suite of the Qt Toolkit.
diff --git a/tests/benchmarks/qgraphicsview/tst_qgraphicsview.cpp b/tests/benchmarks/qgraphicsview/tst_qgraphicsview.cpp
index a293de4..a06e033 100644
--- a/tests/benchmarks/qgraphicsview/tst_qgraphicsview.cpp
+++ b/tests/benchmarks/qgraphicsview/tst_qgraphicsview.cpp
@@ -705,7 +705,6 @@ public:
QGraphicsPixmapItem::paint(painter,option,widget);
//We just want to wait, and we don't want to process the event loop with qWait
QTest::qSleep(3);
-
}
protected:
void advance(int i)
diff --git a/tests/benchmarks/qpixmapcache/qpixmapcache.pro b/tests/benchmarks/qpixmapcache/qpixmapcache.pro
new file mode 100644
index 0000000..e0d7543
--- /dev/null
+++ b/tests/benchmarks/qpixmapcache/qpixmapcache.pro
@@ -0,0 +1,6 @@
+load(qttest_p4)
+TEMPLATE = app
+TARGET = tst_qpixmapcache
+TEMPLATE = app
+# Input
+SOURCES += tst_qpixmapcache.cpp
diff --git a/tests/benchmarks/qpixmapcache/tst_qpixmapcache.cpp b/tests/benchmarks/qpixmapcache/tst_qpixmapcache.cpp
new file mode 100644
index 0000000..f3c1134
--- /dev/null
+++ b/tests/benchmarks/qpixmapcache/tst_qpixmapcache.cpp
@@ -0,0 +1,226 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Qt Software Information (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 either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@nokia.com.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <qtest.h>
+#include <QPixmapCache>
+//TESTED_FILES=
+
+class tst_QPixmapCache : public QObject
+{
+ Q_OBJECT
+
+public:
+ tst_QPixmapCache();
+ virtual ~tst_QPixmapCache();
+
+public slots:
+ void init();
+ void cleanup();
+
+private slots:
+ void insert_data();
+ void insert();
+ void find_data();
+ void find();
+ void styleUseCaseComplexKey();
+ void styleUseCaseComplexKey_data();
+};
+
+tst_QPixmapCache::tst_QPixmapCache()
+{
+}
+
+tst_QPixmapCache::~tst_QPixmapCache()
+{
+}
+
+void tst_QPixmapCache::init()
+{
+}
+
+void tst_QPixmapCache::cleanup()
+{
+}
+
+void tst_QPixmapCache::insert_data()
+{
+ QTest::addColumn<bool>("cacheType");
+ QTest::newRow("QPixmapCache") << true;
+ QTest::newRow("QPixmapCache (int API)") << false;
+}
+
+QList<QPixmapCache::Key> keys;
+
+void tst_QPixmapCache::insert()
+{
+ QFETCH(bool, cacheType);
+ QPixmap p;
+ if (cacheType) {
+ QBENCHMARK {
+ for (int i = 0 ; i <= 10000 ; i++)
+ {
+ QString tmp;
+ tmp.sprintf("my-key-%d", i);
+ QPixmapCache::insert(tmp, p);
+ }
+ }
+ } else {
+ QBENCHMARK {
+ for (int i = 0 ; i <= 10000 ; i++)
+ keys.append(QPixmapCache::insert(p));
+ }
+ }
+}
+
+void tst_QPixmapCache::find_data()
+{
+ QTest::addColumn<bool>("cacheType");
+ QTest::newRow("QPixmapCache") << true;
+ QTest::newRow("QPixmapCache (int API)") << false;
+}
+
+void tst_QPixmapCache::find()
+{
+ QFETCH(bool, cacheType);
+ QPixmap p;
+ if (cacheType) {
+ QBENCHMARK {
+ QString tmp;
+ for (int i = 0 ; i <= 10000 ; i++)
+ {
+ tmp.sprintf("my-key-%d", i);
+ QPixmapCache::find(tmp, p);
+ }
+ }
+ } else {
+ QBENCHMARK {
+ for (int i = 0 ; i <= 10000 ; i++)
+ QPixmapCache::find(keys.at(i), &p);
+ }
+ }
+
+}
+
+void tst_QPixmapCache::styleUseCaseComplexKey_data()
+{
+ QTest::addColumn<bool>("cacheType");
+ QTest::newRow("QPixmapCache") << true;
+ QTest::newRow("QPixmapCache (int API)") << false;
+}
+
+struct styleStruct {
+ QString key;
+ uint state;
+ uint direction;
+ uint complex;
+ uint palette;
+ int width;
+ int height;
+ bool operator==(const styleStruct &str) const
+ {
+ return str.key == key && str.state == state && str.direction == direction
+ && str.complex == complex && str.palette == palette && str.width == width
+ && str.height == height;
+ }
+};
+
+uint qHash(const styleStruct &myStruct)
+{
+ return qHash(myStruct.state);
+}
+
+void tst_QPixmapCache::styleUseCaseComplexKey()
+{
+ QFETCH(bool, cacheType);
+ QPixmap p;
+ if (cacheType) {
+ QBENCHMARK {
+ for (int i = 0 ; i <= 10000 ; i++)
+ {
+ QString tmp;
+ tmp.sprintf("%s-%d-%d-%d-%d-%d-%d", QString("my-progressbar-%1").arg(i).toLatin1().constData(), 5, 3, 0, 358, 100, 200);
+ QPixmapCache::insert(tmp, p);
+ }
+
+ for (int i = 0 ; i <= 10000 ; i++)
+ {
+ QString tmp;
+ tmp.sprintf("%s-%d-%d-%d-%d-%d-%d", QString("my-progressbar-%1").arg(i).toLatin1().constData(), 5, 3, 0, 358, 100, 200);
+ QPixmapCache::find(tmp, p);
+ }
+ }
+ } else {
+ QHash<styleStruct, QPixmapCache::Key> hash;
+ QBENCHMARK {
+ for (int i = 0 ; i <= 10000 ; i++)
+ {
+ styleStruct myStruct;
+ myStruct.key = QString("my-progressbar-%1").arg(i);
+ myStruct.key = 5;
+ myStruct.key = 4;
+ myStruct.key = 3;
+ myStruct.palette = 358;
+ myStruct.width = 100;
+ myStruct.key = 200;
+ QPixmapCache::Key key = QPixmapCache::insert(p);
+ hash.insert(myStruct, key);
+ }
+ for (int i = 0 ; i <= 10000 ; i++)
+ {
+ styleStruct myStruct;
+ myStruct.key = QString("my-progressbar-%1").arg(i);
+ myStruct.key = 5;
+ myStruct.key = 4;
+ myStruct.key = 3;
+ myStruct.palette = 358;
+ myStruct.width = 100;
+ myStruct.key = 200;
+ QPixmapCache::Key key = hash.value(myStruct);
+ QPixmapCache::find(key, &p);
+ }
+ }
+ }
+
+}
+
+
+QTEST_MAIN(tst_QPixmapCache)
+#include "tst_qpixmapcache.moc"