summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorTobias Koenig <tokoe@kde.org>2009-06-10 15:11:59 (GMT)
committerTobias Koenig <tokoe@kde.org>2009-06-10 15:11:59 (GMT)
commitf1e6e89f7ee452af0e4404af537f5fed2a2b2dc5 (patch)
tree045fbf67a4806e4e217ef23cdf4f363ac359bef1 /tests
parent5d87f2542bbcb0877f4a9a9b5be4df80cd6aa4cd (diff)
parent5b24c5793607c809b1bac82c7cc3696001ee9217 (diff)
downloadQt-f1e6e89f7ee452af0e4404af537f5fed2a2b2dc5.zip
Qt-f1e6e89f7ee452af0e4404af537f5fed2a2b2dc5.tar.gz
Qt-f1e6e89f7ee452af0e4404af537f5fed2a2b2dc5.tar.bz2
Merge branch 'master' of git://gitorious.org/qt/qt
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/_networkselftest/tst_networkselftest.cpp8
-rw-r--r--tests/auto/bic/bic.pro6
-rw-r--r--tests/auto/bic/tst_bic.cpp33
-rw-r--r--tests/auto/headers/tst_headers.cpp3
-rw-r--r--tests/auto/qcssparser/tst_cssparser.cpp45
-rw-r--r--tests/auto/qdbusmarshall/tst_qdbusmarshall.cpp25
-rw-r--r--tests/auto/qimagereader/qimagereader.qrc2
-rw-r--r--tests/auto/qimagereader/tst_qimagereader.cpp26
-rw-r--r--tests/auto/qimagewriter/tst_qimagewriter.cpp26
-rw-r--r--tests/auto/qlistview/tst_qlistview.cpp51
-rw-r--r--tests/auto/qlocalsocket/tst_qlocalsocket.cpp14
-rw-r--r--tests/auto/qnetworkdiskcache/tst_qnetworkdiskcache.cpp4
-rw-r--r--tests/auto/qnetworkreply/tst_qnetworkreply.cpp99
-rw-r--r--tests/auto/qobject/tst_qobject.cpp27
-rw-r--r--tests/auto/qpainter/tst_qpainter.cpp26
-rw-r--r--tests/auto/qprogressbar/tst_qprogressbar.cpp20
-rw-r--r--tests/auto/qscriptqobject/tst_qscriptqobject.cpp29
-rw-r--r--tests/auto/qscriptvalue/tst_qscriptvalue.cpp21
-rw-r--r--tests/auto/qstringbuilder/qstringbuilder.pro5
-rw-r--r--tests/auto/qstringbuilder/scenario1.cpp1
-rw-r--r--tests/auto/qstringbuilder/scenario1.pro8
-rw-r--r--tests/auto/qstringbuilder/scenario2.cpp1
-rw-r--r--tests/auto/qstringbuilder/scenario2.pro7
-rw-r--r--tests/auto/qstringbuilder/scenario3.cpp1
-rw-r--r--tests/auto/qstringbuilder/scenario3.pro7
-rw-r--r--tests/auto/qstringbuilder/scenario4.cpp1
-rw-r--r--tests/auto/qstringbuilder/scenario4.pro7
-rw-r--r--tests/auto/qstringbuilder/tst_qstringbuilder.cpp147
-rw-r--r--tests/auto/qtextcodec/tst_qtextcodec.cpp15
-rw-r--r--tests/auto/qtextdocument/tst_qtextdocument.cpp32
-rw-r--r--tests/auto/qtreewidget/tst_qtreewidget.cpp4
-rw-r--r--tests/auto/qwidget/tst_qwidget.cpp18
-rw-r--r--tests/benchmarks/qpixmapcache/tst_qpixmapcache.cpp4
-rw-r--r--tests/benchmarks/qstringbuilder/main.cpp86
34 files changed, 733 insertions, 76 deletions
diff --git a/tests/auto/_networkselftest/tst_networkselftest.cpp b/tests/auto/_networkselftest/tst_networkselftest.cpp
index dab4433..eac603f 100644
--- a/tests/auto/_networkselftest/tst_networkselftest.cpp
+++ b/tests/auto/_networkselftest/tst_networkselftest.cpp
@@ -190,12 +190,6 @@ static void netChat(int port, const QList<Chat> &chat)
// now start the chat
QList<Chat>::ConstIterator it = chat.constBegin();
for (int i = 1; it != chat.constEnd(); ++it, ++i) {
- if (it->type != Chat::Reconnect
- && socket.state() != QAbstractSocket::ConnectedState
- && socket.state() != QAbstractSocket::ClosingState)
- QFAIL(QString("Internal error: socket is in invalid state %1 in step %2")
- .arg(socket.state()).arg(i).toLocal8Bit());
-
switch (it->type) {
case Chat::Expect: {
qDebug() << i << "Expecting" << prettyByteArray(it->data);
@@ -463,7 +457,7 @@ void tst_NetworkSelfTest::httpsServer()
<< Chat::expect("200 ")
<< Chat::DiscardUntilDisconnect);
#else
- QSKIP("SSL not enabled, cannot test");
+ QSKIP("SSL not enabled, cannot test", SkipAll);
#endif
}
diff --git a/tests/auto/bic/bic.pro b/tests/auto/bic/bic.pro
index a168d77..82711c9 100644
--- a/tests/auto/bic/bic.pro
+++ b/tests/auto/bic/bic.pro
@@ -2,3 +2,9 @@ load(qttest_p4)
SOURCES += tst_bic.cpp qbic.cpp
QT = core
+wince*:{
+ DEFINES += SRCDIR=\\\"\\\"
+} else {
+ DEFINES += SRCDIR=\\\"$$PWD/\\\"
+}
+
diff --git a/tests/auto/bic/tst_bic.cpp b/tests/auto/bic/tst_bic.cpp
index 181c275..8bc8d4f 100644
--- a/tests/auto/bic/tst_bic.cpp
+++ b/tests/auto/bic/tst_bic.cpp
@@ -165,30 +165,30 @@ void tst_Bic::sizesAndVTables_data()
#if defined Q_OS_LINUX && defined Q_WS_X11
# if defined(__powerpc__) && !defined(__powerpc64__)
- archFileName400 = "data/%1.4.0.0.linux-gcc-ppc32.txt";
- archFileName410 = "data/%1.4.1.0.linux-gcc-ppc32.txt";
- archFileName420 = "data/%1.4.2.0.linux-gcc-ppc32.txt";
+ archFileName400 = SRCDIR "data/%1.4.0.0.linux-gcc-ppc32.txt";
+ archFileName410 = SRCDIR "data/%1.4.1.0.linux-gcc-ppc32.txt";
+ archFileName420 = SRCDIR "data/%1.4.2.0.linux-gcc-ppc32.txt";
# elif defined(__amd64__)
- archFileName400 = "data/%1.4.0.0.linux-gcc-amd64.txt";
+ archFileName400 = SRCDIR "data/%1.4.0.0.linux-gcc-amd64.txt";
# elif defined(__i386__)
- archFileName400 = "data/%1.4.0.0.linux-gcc-ia32.txt";
- archFileName410 = "data/%1.4.1.0.linux-gcc-ia32.txt";
- archFileName420 = "data/%1.4.2.0.linux-gcc-ia32.txt";
- archFileName430 = "data/%1.4.3.0.linux-gcc-ia32.txt";
+ archFileName400 = SRCDIR "data/%1.4.0.0.linux-gcc-ia32.txt";
+ archFileName410 = SRCDIR "data/%1.4.1.0.linux-gcc-ia32.txt";
+ archFileName420 = SRCDIR "data/%1.4.2.0.linux-gcc-ia32.txt";
+ archFileName430 = SRCDIR "data/%1.4.3.0.linux-gcc-ia32.txt";
# endif
#elif defined Q_OS_AIX
if (sizeof(void*) == 4)
- archFileName400 = "data/%1.4.0.0.aix-gcc-power32.txt";
+ archFileName400 = SRCDIR "data/%1.4.0.0.aix-gcc-power32.txt";
#elif defined Q_OS_MAC && defined(__powerpc__)
- archFileName400 = "data/%1.4.0.0.macx-gcc-ppc32.txt";
- archFileName410 = "data/%1.4.1.0.macx-gcc-ppc32.txt";
- archFileName420 = "data/%1.4.2.0.macx-gcc-ppc32.txt";
+ archFileName400 = SRCDIR "data/%1.4.0.0.macx-gcc-ppc32.txt";
+ archFileName410 = SRCDIR "data/%1.4.1.0.macx-gcc-ppc32.txt";
+ archFileName420 = SRCDIR "data/%1.4.2.0.macx-gcc-ppc32.txt";
#elif defined Q_OS_MAC && defined(__i386__)
- archFileName410 = "data/%1.4.1.0.macx-gcc-ia32.txt";
- archFileName420 = "data/%1.4.2.0.macx-gcc-ia32.txt";
+ archFileName410 = SRCDIR "data/%1.4.1.0.macx-gcc-ia32.txt";
+ archFileName420 = SRCDIR "data/%1.4.2.0.macx-gcc-ia32.txt";
#elif defined Q_OS_WIN && defined Q_CC_GNU
- archFileName410 = "data/%1.4.1.0.win32-gcc-ia32.txt";
- archFileName420 = "data/%1.4.2.0.win32-gcc-ia32.txt";
+ archFileName410 = SRCDIR "data/%1.4.1.0.win32-gcc-ia32.txt";
+ archFileName420 = SRCDIR "data/%1.4.2.0.win32-gcc-ia32.txt";
#endif
if (archFileName400.isEmpty() && archFileName410.isEmpty()
@@ -293,6 +293,7 @@ void tst_Bic::sizesAndVTables()
bool isFailed = false;
+ qDebug() << oldLib.arg(libName);
if (oldLib.isEmpty() || !QFile::exists(oldLib.arg(libName)))
QSKIP("No platform spec found for this platform/version.", SkipSingle);
diff --git a/tests/auto/headers/tst_headers.cpp b/tests/auto/headers/tst_headers.cpp
index 607d655..7e32deb 100644
--- a/tests/auto/headers/tst_headers.cpp
+++ b/tests/auto/headers/tst_headers.cpp
@@ -135,6 +135,9 @@ void tst_Headers::licenseCheck()
QByteArray data = f.readAll();
QStringList content = QString::fromLocal8Bit(data.replace('\r',"")).split("\n");
+ if (content.first().contains("generated"))
+ content.takeFirst();
+
QVERIFY(licensePattern.exactMatch(content.at(7)) ||
licensePattern.exactMatch(content.at(4)));
QString licenseType = licensePattern.cap(1);
diff --git a/tests/auto/qcssparser/tst_cssparser.cpp b/tests/auto/qcssparser/tst_cssparser.cpp
index b41a745..27258b7 100644
--- a/tests/auto/qcssparser/tst_cssparser.cpp
+++ b/tests/auto/qcssparser/tst_cssparser.cpp
@@ -114,11 +114,52 @@ void tst_CssParser::scanner_data()
}
}
+
+static char *tokenName(QCss::TokenType t)
+{
+ switch (t) {
+ case QCss::NONE: return "NONE";
+ case QCss::S: return "S";
+ case QCss::CDO: return "CDO";
+ case QCss::CDC: return "CDC";
+ case QCss::INCLUDES: return "INCLUDES";
+ case QCss::DASHMATCH: return "DASHMATCH";
+ case QCss::LBRACE: return "LBRACE";
+ case QCss::PLUS: return "PLUS";
+ case QCss::GREATER: return "GREATER";
+ case QCss::COMMA: return "COMMA";
+ case QCss::STRING: return "STRING";
+ case QCss::INVALID: return "INVALID";
+ case QCss::IDENT: return "IDENT";
+ case QCss::HASH: return "HASH";
+ case QCss::ATKEYWORD_SYM: return "ATKEYWORD_SYM";
+ case QCss::EXCLAMATION_SYM: return "EXCLAMATION_SYM";
+ case QCss::LENGTH: return "LENGTH";
+ case QCss::PERCENTAGE: return "PERCENTAGE";
+ case QCss::NUMBER: return "NUMBER";
+ case QCss::FUNCTION: return "FUNCTION";
+ case QCss::COLON: return "COLON";
+ case QCss::SEMICOLON: return "SEMICOLON";
+ case QCss::RBRACE: return "RBRACE";
+ case QCss::SLASH: return "SLASH";
+ case QCss::MINUS: return "MINUS";
+ case QCss::DOT: return "DOT";
+ case QCss::STAR: return "STAR";
+ case QCss::LBRACKET: return "LBRACKET";
+ case QCss::RBRACKET: return "RBRACKET";
+ case QCss::EQUAL: return "EQUAL";
+ case QCss::LPAREN: return "LPAREN";
+ case QCss::RPAREN: return "RPAREN";
+ case QCss::OR: return "OR";
+ }
+ return "";
+}
+
static void debug(const QVector<QCss::Symbol> &symbols, int index = -1)
{
qDebug() << "all symbols:";
for (int i = 0; i < symbols.count(); ++i)
- qDebug() << "(" << i << "); Token:" << QCss::Scanner::tokenName(symbols.at(i).token) << "; Lexem:" << symbols.at(i).lexem();
+ qDebug() << "(" << i << "); Token:" << tokenName(symbols.at(i).token) << "; Lexem:" << symbols.at(i).lexem();
if (index != -1)
qDebug() << "failure at index" << index;
}
@@ -160,7 +201,7 @@ void tst_CssParser::scanner()
QCOMPARE(l.count(), 2);
const QString expectedToken = l.at(0);
const QString expectedLexem = l.at(1);
- QString actualToken = QString::fromLatin1(QCss::Scanner::tokenName(symbols.at(i).token));
+ QString actualToken = QString::fromLatin1(tokenName(symbols.at(i).token));
if (actualToken != expectedToken) {
debug(symbols, i);
QCOMPARE(actualToken, expectedToken);
diff --git a/tests/auto/qdbusmarshall/tst_qdbusmarshall.cpp b/tests/auto/qdbusmarshall/tst_qdbusmarshall.cpp
index ad1a1b8..58bfabc 100644
--- a/tests/auto/qdbusmarshall/tst_qdbusmarshall.cpp
+++ b/tests/auto/qdbusmarshall/tst_qdbusmarshall.cpp
@@ -84,6 +84,8 @@ private slots:
void sendArgument_data();
void sendArgument();
+ void sendErrors();
+
private:
QProcess proc;
};
@@ -782,5 +784,28 @@ void tst_QDBusMarshall::sendArgument()
QCOMPARE(extracted, value);
}
+void tst_QDBusMarshall::sendErrors()
+{
+ QDBusConnection con = QDBusConnection::sessionBus();
+
+ QVERIFY(con.isConnected());
+ QDBusMessage msg = QDBusMessage::createSignal("/foo", "local.interfaceName",
+ "signalName");
+ msg << qVariantFromValue(QDBusObjectPath());
+
+ QTest::ignoreMessage(QtWarningMsg, "QDBusConnection: error: could not send signal path \"/foo\" interface \"local.interfaceName\" member \"signalName\"");
+ QVERIFY(!con.send(msg));
+
+ msg.setArguments(QVariantList());
+ QDBusObjectPath path;
+
+ QTest::ignoreMessage(QtWarningMsg, "QDBusObjectPath: invalid path \"abc\"");
+ path.setPath("abc");
+ msg << qVariantFromValue(path);
+
+ QTest::ignoreMessage(QtWarningMsg, "QDBusConnection: error: could not send signal path \"/foo\" interface \"local.interfaceName\" member \"signalName\"");
+ QVERIFY(!con.send(msg));
+}
+
QTEST_MAIN(tst_QDBusMarshall)
#include "tst_qdbusmarshall.moc"
diff --git a/tests/auto/qimagereader/qimagereader.qrc b/tests/auto/qimagereader/qimagereader.qrc
index 3c674ad..c6b963b 100644
--- a/tests/auto/qimagereader/qimagereader.qrc
+++ b/tests/auto/qimagereader/qimagereader.qrc
@@ -30,7 +30,7 @@
<file>images/image.pgm</file>
<file>images/image.png</file>
<file>images/image.ppm</file>
- <file>images/image.tif</file>
+ <file>images/image_100dpi.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 f5313eb..0b32f0a 100644
--- a/tests/auto/qimagereader/tst_qimagereader.cpp
+++ b/tests/auto/qimagereader/tst_qimagereader.cpp
@@ -156,6 +156,9 @@ private slots:
void pixelCompareWithBaseline_data();
void pixelCompareWithBaseline();
+
+ void task255627_setNullScaledSize_data();
+ void task255627_setNullScaledSize();
};
static const QLatin1String prefix(SRCDIR "/images/");
@@ -333,6 +336,29 @@ void tst_QImageReader::setScaledSize()
QCOMPARE(image.size(), newSize);
}
+void tst_QImageReader::task255627_setNullScaledSize_data()
+{
+ setScaledSize_data();
+}
+
+void tst_QImageReader::task255627_setNullScaledSize()
+{
+ QFETCH(QString, fileName);
+ QFETCH(QByteArray, format);
+
+ if (!format.isEmpty() && !QImageReader::supportedImageFormats().contains(format))
+ QSKIP("Qt does not support reading the \"" + format + "\" format", SkipSingle);
+
+ QImageReader reader(prefix + fileName);
+
+ // set a null size
+ reader.setScaledSize(QSize(0, 0));
+ reader.setQuality(0);
+ QImage image = reader.read();
+ QVERIFY(image.isNull());
+ QCOMPARE(image.size(), QSize(0, 0));
+}
+
void tst_QImageReader::setClipRect_data()
{
QTest::addColumn<QString>("fileName");
diff --git a/tests/auto/qimagewriter/tst_qimagewriter.cpp b/tests/auto/qimagewriter/tst_qimagewriter.cpp
index 349afa5..3ceb2c2 100644
--- a/tests/auto/qimagewriter/tst_qimagewriter.cpp
+++ b/tests/auto/qimagewriter/tst_qimagewriter.cpp
@@ -59,6 +59,7 @@ Q_DECLARE_METATYPE(QStringMap)
Q_DECLARE_METATYPE(QIntList)
Q_DECLARE_METATYPE(QImageWriter::ImageWriterError)
Q_DECLARE_METATYPE(QIODevice *)
+Q_DECLARE_METATYPE(QImage::Format)
//TESTED_FILES=
@@ -82,6 +83,9 @@ private slots:
void writeImage2();
void supportedFormats();
+ void readWriteNonDestructive_data();
+ void readWriteNonDestructive();
+
#if defined QTEST_HAVE_TIFF
void largeTiff();
#endif
@@ -376,6 +380,28 @@ void tst_QImageWriter::supportedFormats()
QCOMPARE(formatSet.size(), formats.size());
}
+void tst_QImageWriter::readWriteNonDestructive_data()
+{
+ QTest::addColumn<QImage::Format>("format");
+ QTest::addColumn<QImage::Format>("expectedFormat");
+ QTest::newRow("tiff mono") << QImage::Format_Mono << QImage::Format_Mono;
+ QTest::newRow("tiff indexed") << QImage::Format_Indexed8 << QImage::Format_Indexed8;
+ QTest::newRow("tiff rgb32") << QImage::Format_ARGB32 << QImage::Format_ARGB32;
+}
+
+void tst_QImageWriter::readWriteNonDestructive()
+{
+ QFETCH(QImage::Format, format);
+ QFETCH(QImage::Format, expectedFormat);
+ QImage image = QImage(prefix + "colorful.bmp").convertToFormat(format);
+ QVERIFY(image.save(prefix + "gen-readWriteNonDestructive.tiff"));
+
+ QImage image2 = QImage(prefix + "gen-readWriteNonDestructive.tiff");
+ QImage::Format readFormat = image2.format();
+ QCOMPARE(readFormat, expectedFormat);
+ QCOMPARE(image, image2);
+}
+
void tst_QImageWriter::setDescription_data()
{
QTest::addColumn<QString>("fileName");
diff --git a/tests/auto/qlistview/tst_qlistview.cpp b/tests/auto/qlistview/tst_qlistview.cpp
index f70db14..8338ffa 100644
--- a/tests/auto/qlistview/tst_qlistview.cpp
+++ b/tests/auto/qlistview/tst_qlistview.cpp
@@ -52,6 +52,7 @@
#include <math.h>
#include <QtGui/QScrollBar>
#include <QtGui/QDialog>
+#include <QtGui/QStyledItemDelegate>
#if defined(Q_OS_WIN) || defined(Q_OS_WINCE)
#include <windows.h>
#endif
@@ -107,6 +108,7 @@ private slots:
void task248430_crashWith0SizedItem();
void task250446_scrollChanged();
void task196118_visualRegionForSelection();
+ void task254449_draggingItemToNegativeCoordinates();
void keyboardSearch();
};
@@ -1580,6 +1582,55 @@ void tst_QListView::task196118_visualRegionForSelection()
QVERIFY(view.visualRegionForSelection().isEmpty());
}
+void tst_QListView::task254449_draggingItemToNegativeCoordinates()
+{
+ //we'll check that the items are painted correctly
+ class MyListView : public QListView
+ {
+ public:
+ void setPositionForIndex(const QPoint &position, const QModelIndex &index)
+ { QListView::setPositionForIndex(position, index); }
+
+ } list;
+
+ QStandardItemModel model(1,1);
+ QModelIndex index = model.index(0,0);
+ model.setData(index, QLatin1String("foo"));
+ list.setModel(&model);
+ list.setViewMode(QListView::IconMode);
+ list.show();
+ QTest::qWait(200); //makes sure the layout is done
+
+ const QPoint topLeft(-6, 0);
+
+
+ list.setPositionForIndex(topLeft, index);
+
+ class MyItemDelegate : public QStyledItemDelegate
+ {
+ public:
+ MyItemDelegate() : numPaints(0) { }
+ void paint(QPainter *painter,
+ const QStyleOptionViewItem &option, const QModelIndex &index) const
+ {
+ numPaints++;
+ QStyledItemDelegate::paint(painter, option, index);
+ }
+
+ mutable int numPaints;
+ } delegate;
+
+ list.setItemDelegate(&delegate);
+
+ //we'll make sure the item is repainted
+ delegate.numPaints = 0;
+ list.viewport()->repaint();
+
+ QCOMPARE(list.visualRect(index).topLeft(), topLeft);
+ QCOMPARE(delegate.numPaints, 1);
+}
+
+
void tst_QListView::keyboardSearch()
{
QStringList items;
diff --git a/tests/auto/qlocalsocket/tst_qlocalsocket.cpp b/tests/auto/qlocalsocket/tst_qlocalsocket.cpp
index 785eab0..ac26075 100644
--- a/tests/auto/qlocalsocket/tst_qlocalsocket.cpp
+++ b/tests/auto/qlocalsocket/tst_qlocalsocket.cpp
@@ -115,8 +115,6 @@ tst_QLocalSocket::tst_QLocalSocket()
#endif
))
qWarning() << "lackey executable doesn't exists!";
-
- QLocalServer::removeServer("tst_localsocket");
}
tst_QLocalSocket::~tst_QLocalSocket()
@@ -141,7 +139,13 @@ public:
LocalServer() : QLocalServer()
{
connect(this, SIGNAL(newConnection()), this, SLOT(slotNewConnection()));
- };
+ }
+
+ bool listen(const QString &name)
+ {
+ removeServer(name);
+ return QLocalServer::listen(name);
+ }
QList<int> hits;
@@ -530,7 +534,7 @@ void tst_QLocalSocket::sendData()
// QLocalSocket/Server can take a name or path, check that it works as expected
void tst_QLocalSocket::fullPath()
{
- QLocalServer server;
+ LocalServer server;
QString name = "qlocalsocket_pathtest";
#if defined(QT_LOCALSOCKET_TCP)
QString path = "QLocalServer";
@@ -824,7 +828,7 @@ void tst_QLocalSocket::removeServer()
void tst_QLocalSocket::recycleServer()
{
- QLocalServer server;
+ LocalServer server;
QLocalSocket client;
QVERIFY(server.listen("recycletest1"));
diff --git a/tests/auto/qnetworkdiskcache/tst_qnetworkdiskcache.cpp b/tests/auto/qnetworkdiskcache/tst_qnetworkdiskcache.cpp
index 2383767..2f6180f 100644
--- a/tests/auto/qnetworkdiskcache/tst_qnetworkdiskcache.cpp
+++ b/tests/auto/qnetworkdiskcache/tst_qnetworkdiskcache.cpp
@@ -76,7 +76,7 @@ private slots:
void oldCacheVersionFile_data();
void oldCacheVersionFile();
-
+
void sync();
};
@@ -486,7 +486,7 @@ public:
void run()
{
QByteArray longString = "Hello World, this is some long string, well not really that long";
- for (int i = 0; i < 10; ++i)
+ for (int j = 0; j < 10; ++j)
longString += longString;
QByteArray longString2 = "Help, I am stuck in an autotest!";
QUrl url(EXAMPLE_URL);
diff --git a/tests/auto/qnetworkreply/tst_qnetworkreply.cpp b/tests/auto/qnetworkreply/tst_qnetworkreply.cpp
index b76a4e6..43b4ea9 100644
--- a/tests/auto/qnetworkreply/tst_qnetworkreply.cpp
+++ b/tests/auto/qnetworkreply/tst_qnetworkreply.cpp
@@ -161,6 +161,10 @@ private Q_SLOTS:
void putToHttp();
void postToHttp_data();
void postToHttp();
+ void deleteFromHttp_data();
+ void deleteFromHttp();
+ void putGetDeleteGetFromHttp_data();
+ void putGetDeleteGetFromHttp();
void ioGetFromData_data();
void ioGetFromData();
@@ -903,6 +907,10 @@ QString tst_QNetworkReply::runSimpleRequest(QNetworkAccessManager::Operation op,
reply = manager.post(request, data);
break;
+ case QNetworkAccessManager::DeleteOperation:
+ reply = manager.deleteResource(request);
+ break;
+
default:
Q_ASSERT_X(false, "tst_QNetworkReply", "Invalid/unknown operation requested");
}
@@ -1478,6 +1486,97 @@ void tst_QNetworkReply::postToHttp()
QCOMPARE(uploadedData, md5sum.toHex());
}
+void tst_QNetworkReply::deleteFromHttp_data()
+{
+ QTest::addColumn<QUrl>("url");
+ QTest::addColumn<int>("resultCode");
+ QTest::addColumn<QNetworkReply::NetworkError>("error");
+
+ // for status codes to expect, see http://www.w3.org/Protocols/rfc2616/rfc2616-sec9.html
+
+ QTest::newRow("405-method-not-allowed") << QUrl("http://" + QtNetworkSettings::serverName() + "/index.html") << 405 << QNetworkReply::ContentOperationNotPermittedError;
+ QTest::newRow("200-ok") << QUrl("http://" + QtNetworkSettings::serverName() + "/cgi-bin/http-delete.cgi?200-ok") << 200 << QNetworkReply::NoError;
+ QTest::newRow("202-accepted") << QUrl("http://" + QtNetworkSettings::serverName() + "/cgi-bin/http-delete.cgi?202-accepted") << 202 << QNetworkReply::NoError;
+ QTest::newRow("204-no-content") << QUrl("http://" + QtNetworkSettings::serverName() + "/cgi-bin/http-delete.cgi?204-no-content") << 204 << QNetworkReply::NoError;
+ QTest::newRow("404-not-found") << QUrl("http://" + QtNetworkSettings::serverName() + "/cgi-bin/http-delete.cgi?404-not-found") << 404 << QNetworkReply::ContentNotFoundError;
+}
+
+void tst_QNetworkReply::deleteFromHttp()
+{
+ QFETCH(QUrl, url);
+ QFETCH(int, resultCode);
+ QFETCH(QNetworkReply::NetworkError, error);
+ QNetworkRequest request(url);
+ QNetworkReplyPtr reply;
+ runSimpleRequest(QNetworkAccessManager::DeleteOperation, request, reply, 0);
+ QCOMPARE(reply->url(), url);
+ QCOMPARE(reply->error(), error);
+ QCOMPARE(reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt(), resultCode);
+}
+
+void tst_QNetworkReply::putGetDeleteGetFromHttp_data()
+{
+ QTest::addColumn<QUrl>("putUrl");
+ QTest::addColumn<int>("putResultCode");
+ QTest::addColumn<QNetworkReply::NetworkError>("putError");
+ QTest::addColumn<QUrl>("deleteUrl");
+ QTest::addColumn<int>("deleteResultCode");
+ QTest::addColumn<QNetworkReply::NetworkError>("deleteError");
+ QTest::addColumn<QUrl>("get2Url");
+ QTest::addColumn<int>("get2ResultCode");
+ QTest::addColumn<QNetworkReply::NetworkError>("get2Error");
+
+ QUrl url("http://" + QtNetworkSettings::serverName());
+ url.setPath(QString("/dav/qnetworkaccess-putToHttp-%1-%2")
+ .arg(QTest::currentDataTag())
+ .arg(uniqueExtension));
+
+ // first use case: put, get (to check it is there), delete, get (to check it is not there anymore)
+ QTest::newRow("success") << url << 201 << QNetworkReply::NoError << url << 204 << QNetworkReply::NoError << url << 404 << QNetworkReply::ContentNotFoundError;
+
+ QUrl wrongUrl("http://" + QtNetworkSettings::serverName());
+ wrongUrl.setPath(QString("/dav/qnetworkaccess-thisURLisNotAvailable"));
+
+ // second use case: put, get (to check it is there), delete wrong URL, get (to check it is still there)
+ QTest::newRow("delete-error") << url << 201 << QNetworkReply::NoError << wrongUrl << 404 << QNetworkReply::ContentNotFoundError << url << 200 << QNetworkReply::NoError;
+
+}
+
+void tst_QNetworkReply::putGetDeleteGetFromHttp()
+{
+ QFETCH(QUrl, putUrl);
+ QFETCH(int, putResultCode);
+ QFETCH(QNetworkReply::NetworkError, putError);
+ QFETCH(QUrl, deleteUrl);
+ QFETCH(int, deleteResultCode);
+ QFETCH(QNetworkReply::NetworkError, deleteError);
+ QFETCH(QUrl, get2Url);
+ QFETCH(int, get2ResultCode);
+ QFETCH(QNetworkReply::NetworkError, get2Error);
+
+ QNetworkRequest putRequest(putUrl);
+ QNetworkRequest deleteRequest(deleteUrl);
+ QNetworkRequest get2Request(get2Url);
+ QNetworkReplyPtr reply;
+
+ RUN_REQUEST(runSimpleRequest(QNetworkAccessManager::PutOperation, putRequest, reply, 0));
+ QCOMPARE(reply->error(), putError);
+ QCOMPARE(reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt(), putResultCode);
+
+ runSimpleRequest(QNetworkAccessManager::GetOperation, putRequest, reply, 0);
+ QCOMPARE(reply->error(), QNetworkReply::NoError);
+ QCOMPARE(reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt(), 200);
+
+ runSimpleRequest(QNetworkAccessManager::DeleteOperation, deleteRequest, reply, 0);
+ QCOMPARE(reply->error(), deleteError);
+ QCOMPARE(reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt(), deleteResultCode);
+
+ runSimpleRequest(QNetworkAccessManager::GetOperation, get2Request, reply, 0);
+ QCOMPARE(reply->error(), get2Error);
+ QCOMPARE(reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt(), get2ResultCode);
+
+}
+
void tst_QNetworkReply::ioGetFromData_data()
{
QTest::addColumn<QString>("urlStr");
diff --git a/tests/auto/qobject/tst_qobject.cpp b/tests/auto/qobject/tst_qobject.cpp
index 399d021..d76c7d4 100644
--- a/tests/auto/qobject/tst_qobject.cpp
+++ b/tests/auto/qobject/tst_qobject.cpp
@@ -106,6 +106,7 @@ private slots:
void childDeletesItsSibling();
void dynamicProperties();
void floatProperty();
+ void qrealProperty();
void property();
void recursiveSignalEmission();
void blockingQueuedConnection();
@@ -1113,6 +1114,7 @@ class PropertyObject : public QObject
Q_PROPERTY(QVariant variant READ variant WRITE setVariant)
Q_PROPERTY(CustomType* custom READ custom WRITE setCustom)
Q_PROPERTY(float myFloat READ myFloat WRITE setMyFloat)
+ Q_PROPERTY(qreal myQReal READ myQReal WRITE setMyQReal)
public:
enum Alpha {
@@ -1148,6 +1150,9 @@ public:
void setMyFloat(float value) { m_float = value; }
inline float myFloat() const { return m_float; }
+ void setMyQReal(qreal value) { m_qreal = value; }
+ qreal myQReal() const { return m_qreal; }
+
private:
Alpha m_alpha;
Priority m_priority;
@@ -1156,6 +1161,7 @@ private:
QVariant m_variant;
CustomType *m_custom;
float m_float;
+ qreal m_qreal;
};
Q_DECLARE_METATYPE(PropertyObject::Priority)
@@ -2348,6 +2354,27 @@ void tst_QObject::floatProperty()
QVERIFY(qVariantValue<float>(v) == 128.0f);
}
+void tst_QObject::qrealProperty()
+{
+ PropertyObject obj;
+ const int idx = obj.metaObject()->indexOfProperty("myQReal");
+ QVERIFY(idx > 0);
+ QMetaProperty prop = obj.metaObject()->property(idx);
+ QVERIFY(prop.isValid());
+ QVERIFY(prop.type() == uint(QMetaType::type("qreal")));
+ QVERIFY(!prop.write(&obj, QVariant("Hello")));
+
+ QVERIFY(prop.write(&obj, qVariantFromValue(128.0f)));
+ QVariant v = prop.read(&obj);
+ QCOMPARE(v.userType(), qMetaTypeId<qreal>());
+ QVERIFY(qVariantValue<qreal>(v) == 128.0);
+
+ QVERIFY(prop.write(&obj, qVariantFromValue(double(127))));
+ v = prop.read(&obj);
+ QCOMPARE(v.userType(), qMetaTypeId<qreal>());
+ QVERIFY(qVariantValue<qreal>(v) == 127.0);
+}
+
class DynamicPropertyObject : public PropertyObject
{
public:
diff --git a/tests/auto/qpainter/tst_qpainter.cpp b/tests/auto/qpainter/tst_qpainter.cpp
index af0f6cf..c0f9935 100644
--- a/tests/auto/qpainter/tst_qpainter.cpp
+++ b/tests/auto/qpainter/tst_qpainter.cpp
@@ -215,6 +215,7 @@ private slots:
void imageCoordinateLimit();
void imageBlending_data();
void imageBlending();
+ void imageBlending_clipped();
void paintOnNullPixmap();
void checkCompositionMode();
@@ -3793,6 +3794,31 @@ void tst_QPainter::imageBlending()
}
}
+void tst_QPainter::imageBlending_clipped()
+{
+ QImage src(20, 20, QImage::Format_RGB16);
+ QPainter p(&src);
+ p.fillRect(src.rect(), Qt::red);
+ p.end();
+
+ QImage dst(40, 20, QImage::Format_RGB16);
+ p.begin(&dst);
+ p.fillRect(dst.rect(), Qt::white);
+ p.end();
+
+ QImage expected = dst;
+
+ p.begin(&dst);
+ p.setClipRect(QRect(23, 0, 20, 20));
+
+ // should be completely clipped
+ p.drawImage(QRectF(3, 0, 20, 20), src);
+ p.end();
+
+ // dst should be left unchanged
+ QCOMPARE(dst, expected);
+}
+
void tst_QPainter::paintOnNullPixmap()
{
QPixmap pix(16, 16);
diff --git a/tests/auto/qprogressbar/tst_qprogressbar.cpp b/tests/auto/qprogressbar/tst_qprogressbar.cpp
index d6379d3..cb037e0 100644
--- a/tests/auto/qprogressbar/tst_qprogressbar.cpp
+++ b/tests/auto/qprogressbar/tst_qprogressbar.cpp
@@ -63,6 +63,7 @@ private slots:
void setValueRepaint();
void sizeHint();
+ void task245201_testChangeStyleAndDelete_data();
void task245201_testChangeStyleAndDelete();
};
@@ -224,15 +225,30 @@ void tst_QProgressBar::sizeHint()
QCOMPARE(barSize.height(), size.height());
}
+void tst_QProgressBar::task245201_testChangeStyleAndDelete_data()
+{
+ QTest::addColumn<QString>("style1_str");
+ QTest::addColumn<QString>("style2_str");
+
+ QTest::newRow("plastique-windows") << QString::fromLatin1("plastique") << QString::fromLatin1("windows");
+ QTest::newRow("mlotif-windows") << QString::fromLatin1("motif") << QString::fromLatin1("windows");
+ QTest::newRow("cleanlooks-cde") << QString::fromLatin1("cleanlooks") << QString::fromLatin1("cde");
+ QTest::newRow("gtk-plastique") << QString::fromLatin1("gtk") << QString::fromLatin1("plastique");
+}
+
void tst_QProgressBar::task245201_testChangeStyleAndDelete()
{
+ QFETCH(QString, style1_str);
+ QFETCH(QString, style2_str);
+
QProgressBar *bar = new QProgressBar;
- QStyle *style = QStyleFactory::create("plastique");
+ QStyle *style = QStyleFactory::create(style1_str);
bar->setStyle(style);
bar->show();
- QStyle *style2 = QStyleFactory::create("windows");
+ QStyle *style2 = QStyleFactory::create(style2_str);
bar->setStyle(style2);
+ QTest::qWait(10);
delete bar;
QTest::qWait(100); //should not crash
diff --git a/tests/auto/qscriptqobject/tst_qscriptqobject.cpp b/tests/auto/qscriptqobject/tst_qscriptqobject.cpp
index 1025d2a..2c47c49 100644
--- a/tests/auto/qscriptqobject/tst_qscriptqobject.cpp
+++ b/tests/auto/qscriptqobject/tst_qscriptqobject.cpp
@@ -333,6 +333,10 @@ public:
{ emit mySignalWithDefaultArg(arg); }
void emitMySignalWithDefaultArg()
{ emit mySignalWithDefaultArg(); }
+ void emitMySignalWithVariantArg(const QVariant &arg)
+ { emit mySignalWithVariantArg(arg); }
+ void emitMySignalWithScriptEngineArg(QScriptEngine *arg)
+ { emit mySignalWithScriptEngineArg(arg); }
public Q_SLOTS:
void mySlot()
@@ -395,6 +399,8 @@ Q_SIGNALS:
void myOtherOverloadedSignal(const QString &arg);
void myOtherOverloadedSignal(int arg);
void mySignalWithDefaultArg(int arg = 123);
+ void mySignalWithVariantArg(const QVariant &arg);
+ void mySignalWithScriptEngineArg(QScriptEngine *arg);
protected:
void connectNotify(const char *signal) {
@@ -1553,6 +1559,29 @@ void tst_QScriptExtQObject::connectAndDisconnect()
m_myObject->emitMyOtherOverloadedSignal(123);
QVERIFY(!m_engine->evaluate("gotSignal").toBoolean());
+ // signal with QVariant arg: argument conversion should work
+ m_myObject->clearConnectedSignal();
+ QVERIFY(m_engine->evaluate("myObject.mySignalWithVariantArg.connect(myHandler)").isUndefined());
+ QCOMPARE(m_myObject->connectedSignal().constData(), SIGNAL(mySignalWithVariantArg(QVariant)));
+ m_engine->evaluate("gotSignal = false");
+ m_myObject->emitMySignalWithVariantArg(123);
+ QCOMPARE(m_engine->evaluate("gotSignal").toBoolean(), true);
+ QCOMPARE(m_engine->evaluate("signalArgs.length").toNumber(), 1.0);
+ QCOMPARE(m_engine->evaluate("signalArgs[0]").toNumber(), 123.0);
+ QVERIFY(m_engine->evaluate("myObject.mySignalWithVariantArg.disconnect(myHandler)").isUndefined());
+
+ // signal with argument type that's unknown to the meta-type system
+ m_myObject->clearConnectedSignal();
+ QVERIFY(m_engine->evaluate("myObject.mySignalWithScriptEngineArg.connect(myHandler)").isUndefined());
+ QCOMPARE(m_myObject->connectedSignal().constData(), SIGNAL(mySignalWithScriptEngineArg(QScriptEngine*)));
+ m_engine->evaluate("gotSignal = false");
+ QTest::ignoreMessage(QtWarningMsg, "QScriptEngine: Unable to handle unregistered datatype 'QScriptEngine*' when invoking handler of signal MyQObject::mySignalWithScriptEngineArg(QScriptEngine*)");
+ m_myObject->emitMySignalWithScriptEngineArg(m_engine);
+ QCOMPARE(m_engine->evaluate("gotSignal").toBoolean(), true);
+ QCOMPARE(m_engine->evaluate("signalArgs.length").toNumber(), 1.0);
+ QVERIFY(m_engine->evaluate("signalArgs[0]").isUndefined());
+ QVERIFY(m_engine->evaluate("myObject.mySignalWithScriptEngineArg.disconnect(myHandler)").isUndefined());
+
// connect(object, function)
m_engine->evaluate("otherObject = { name:'foo' }");
QVERIFY(m_engine->evaluate("myObject.mySignal.connect(otherObject, myHandler)").isUndefined());
diff --git a/tests/auto/qscriptvalue/tst_qscriptvalue.cpp b/tests/auto/qscriptvalue/tst_qscriptvalue.cpp
index bf91001..ad1080a 100644
--- a/tests/auto/qscriptvalue/tst_qscriptvalue.cpp
+++ b/tests/auto/qscriptvalue/tst_qscriptvalue.cpp
@@ -1301,6 +1301,27 @@ void tst_QScriptValue::toVariant()
QCOMPARE(str.toVariant(), QVariant(QString("ciao")));
QCOMPARE(qscriptvalue_cast<QVariant>(str), QVariant(QString("ciao")));
}
+
+ // array
+ {
+ QVariantList listIn;
+ listIn << 123 << "hello";
+ QScriptValue array = qScriptValueFromValue(&eng, listIn);
+ QVERIFY(array.isArray());
+ QCOMPARE(array.property("length").toInt32(), 2);
+ QVariant ret = array.toVariant();
+ QCOMPARE(ret.type(), QVariant::List);
+ QVariantList listOut = ret.toList();
+ QCOMPARE(listOut.size(), listIn.size());
+ for (int i = 0; i < listIn.size(); ++i)
+ QVERIFY(listOut.at(i) == listIn.at(i));
+ // round-trip conversion
+ QScriptValue array2 = qScriptValueFromValue(&eng, ret);
+ QVERIFY(array2.isArray());
+ QCOMPARE(array2.property("length").toInt32(), array.property("length").toInt32());
+ for (int i = 0; i < array.property("length").toInt32(); ++i)
+ QVERIFY(array2.property(i).strictlyEquals(array.property(i)));
+ }
}
// unfortunately, this is necessary in order to do qscriptvalue_cast<QPushButton*>(...)
diff --git a/tests/auto/qstringbuilder/qstringbuilder.pro b/tests/auto/qstringbuilder/qstringbuilder.pro
new file mode 100644
index 0000000..c5a26d3
--- /dev/null
+++ b/tests/auto/qstringbuilder/qstringbuilder.pro
@@ -0,0 +1,5 @@
+
+TEMPLATE = subdirs
+SUBDIRS = scenario1.pro scenario2.pro scenario3.pro scenario4.pro
+
+
diff --git a/tests/auto/qstringbuilder/scenario1.cpp b/tests/auto/qstringbuilder/scenario1.cpp
new file mode 100644
index 0000000..26b4ed3
--- /dev/null
+++ b/tests/auto/qstringbuilder/scenario1.cpp
@@ -0,0 +1 @@
+#include "tst_qstringbuilder.cpp"
diff --git a/tests/auto/qstringbuilder/scenario1.pro b/tests/auto/qstringbuilder/scenario1.pro
new file mode 100644
index 0000000..4ce7156
--- /dev/null
+++ b/tests/auto/qstringbuilder/scenario1.pro
@@ -0,0 +1,8 @@
+load(qttest_p4)
+
+QT = core
+
+SOURCES += scenario1.cpp
+
+DEFINES += SCENARIO=1
+
diff --git a/tests/auto/qstringbuilder/scenario2.cpp b/tests/auto/qstringbuilder/scenario2.cpp
new file mode 100644
index 0000000..26b4ed3
--- /dev/null
+++ b/tests/auto/qstringbuilder/scenario2.cpp
@@ -0,0 +1 @@
+#include "tst_qstringbuilder.cpp"
diff --git a/tests/auto/qstringbuilder/scenario2.pro b/tests/auto/qstringbuilder/scenario2.pro
new file mode 100644
index 0000000..64c46e2
--- /dev/null
+++ b/tests/auto/qstringbuilder/scenario2.pro
@@ -0,0 +1,7 @@
+load(qttest_p4)
+
+QT = core
+
+SOURCES += scenario2.cpp
+
+DEFINES += SCENARIO=2
diff --git a/tests/auto/qstringbuilder/scenario3.cpp b/tests/auto/qstringbuilder/scenario3.cpp
new file mode 100644
index 0000000..26b4ed3
--- /dev/null
+++ b/tests/auto/qstringbuilder/scenario3.cpp
@@ -0,0 +1 @@
+#include "tst_qstringbuilder.cpp"
diff --git a/tests/auto/qstringbuilder/scenario3.pro b/tests/auto/qstringbuilder/scenario3.pro
new file mode 100644
index 0000000..beedffd
--- /dev/null
+++ b/tests/auto/qstringbuilder/scenario3.pro
@@ -0,0 +1,7 @@
+load(qttest_p4)
+
+QT = core
+
+SOURCES += scenario3.cpp
+
+DEFINES += SCENARIO=3
diff --git a/tests/auto/qstringbuilder/scenario4.cpp b/tests/auto/qstringbuilder/scenario4.cpp
new file mode 100644
index 0000000..26b4ed3
--- /dev/null
+++ b/tests/auto/qstringbuilder/scenario4.cpp
@@ -0,0 +1 @@
+#include "tst_qstringbuilder.cpp"
diff --git a/tests/auto/qstringbuilder/scenario4.pro b/tests/auto/qstringbuilder/scenario4.pro
new file mode 100644
index 0000000..1c45a70
--- /dev/null
+++ b/tests/auto/qstringbuilder/scenario4.pro
@@ -0,0 +1,7 @@
+load(qttest_p4)
+
+QT = core
+
+SOURCES += scenario4.cpp
+
+DEFINES += SCENARIO=4
diff --git a/tests/auto/qstringbuilder/tst_qstringbuilder.cpp b/tests/auto/qstringbuilder/tst_qstringbuilder.cpp
new file mode 100644
index 0000000..5501204
--- /dev/null
+++ b/tests/auto/qstringbuilder/tst_qstringbuilder.cpp
@@ -0,0 +1,147 @@
+/****************************************************************************
+**
+** 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$
+**
+****************************************************************************/
+
+// This is included in various .cpp files as a compile test for various scenarios
+// depending on NO_CAST_* and QT_USE_FAST_OPERATOR_PLUS and QT_USE_FAST_CONCATENATION
+
+#if SCENARIO == 1
+// this is the "no harm done" version. Only operator% is active,
+// with NO_CAST * defined
+#define P %
+#undef QT_USE_FAST_OPERATOR_PLUS
+#undef QT_USE_FAST_CONCATENATION
+#define QT_NO_CAST_FROM_ASCII
+#define QT_NO_CAST_TO_ASCII
+#endif
+
+
+#if SCENARIO == 2
+// this is the "full" version. Operator+ is replaced by a QStringBuilder
+// based version
+// with NO_CAST * defined
+#define P +
+#define QT_USE_FAST_OPERATOR_PLUS
+#define QT_USE_FAST_CONCATENATION
+#define QT_NO_CAST_FROM_ASCII
+#define QT_NO_CAST_TO_ASCII
+#endif
+
+#if SCENARIO == 3
+// this is the "no harm done" version. Only operator% is active,
+// with NO_CAST * _not_ defined
+#define P %
+#undef QT_USE_FAST_OPERATOR_PLUS
+#undef QT_USE_FAST_CONCATENATION
+#undef QT_NO_CAST_FROM_ASCII
+#undef QT_NO_CAST_TO_ASCII
+#endif
+
+#if SCENARIO == 4
+// this is the "full" version. Operator+ is replaced by a QStringBuilder
+// based version
+// with NO_CAST * _not_ defined
+#define P +
+#define QT_USE_FAST_OPERATOR_PLUS
+#define QT_USE_FAST_CONCATENATION
+#undef QT_NO_CAST_FROM_ASCII
+#undef QT_NO_CAST_TO_ASCII
+#endif
+
+
+#include <QtTest/QtTest>
+
+//TESTED_CLASS=QStringBuilder
+//TESTED_FILES=qstringbuilder.cpp
+
+#include <qtest.h>
+
+#define LITERAL "some literal"
+
+class tst_QStringBuilder : public QObject
+{
+ Q_OBJECT
+
+public:
+ tst_QStringBuilder() {}
+ ~tst_QStringBuilder() {}
+
+public slots:
+ void init() {}
+ void cleanup() {}
+
+ void scenario();
+};
+
+void tst_QStringBuilder::scenario()
+{
+ QLatin1Literal l1literal(LITERAL);
+ QLatin1String l1string(LITERAL);
+ QString string(l1string);
+ QStringRef stringref(&string, 2, 10);
+ QLatin1Char achar('c');
+ QString r2(QLatin1String(LITERAL LITERAL));
+ QString r;
+
+ r = l1literal P l1literal;
+ QCOMPARE(r, r2);
+ r = string P string;
+ QCOMPARE(r, r2);
+ r = stringref P stringref;
+ QCOMPARE(r, QString(stringref.toString() + stringref.toString()));
+ r = string P l1literal;
+ QCOMPARE(r, r2);
+ r = string P l1string;
+ QCOMPARE(r, r2);
+ r = string + achar;
+ QCOMPARE(r, QString(string P achar));
+ r = achar + string;
+ QCOMPARE(r, QString(achar P string));
+#ifndef QT_NO_CAST_FROM_ASCII
+ r = string P LITERAL;
+ QCOMPARE(r, r2);
+ r = LITERAL P string;
+ QCOMPARE(r, r2);
+#endif
+}
+
+QTEST_APPLESS_MAIN(tst_QStringBuilder)
+
+#include "tst_qstringbuilder.moc"
diff --git a/tests/auto/qtextcodec/tst_qtextcodec.cpp b/tests/auto/qtextcodec/tst_qtextcodec.cpp
index 22f9557..97c409b 100644
--- a/tests/auto/qtextcodec/tst_qtextcodec.cpp
+++ b/tests/auto/qtextcodec/tst_qtextcodec.cpp
@@ -1540,7 +1540,7 @@ void tst_QTextCodec::utfHeaders_data()
<< QByteArray("\xef\xbb\xbfhello")
<< (QString(QChar(0xfeff)) + QString::fromLatin1("hello"))
<< true;
- QTest::newRow("utf8 nobom")
+ QTest::newRow("utf8 nobom ignore header")
<< QByteArray("UTF-8")
<< (int)QTextCodec::IgnoreHeader
<< QByteArray("hello")
@@ -1721,14 +1721,23 @@ void tst_QTextCodec::utfHeaders()
QFETCH(bool, toUnicode);
+ QLatin1String ignoreReverseTestOn = (QSysInfo::ByteOrder == QSysInfo::BigEndian) ? QLatin1String(" le") : QLatin1String(" be");
+ QString rowName(QTest::currentDataTag());
+
for (int i = 0; i < encoded.length(); ++i)
qDebug() << hex << " " << (uint)(uchar)encoded.at(i);
if (toUnicode) {
QString result = codec->toUnicode(encoded.constData(), encoded.length(), &state);
- for (int i = 0; i < result.length(); ++i)
- qDebug() << hex << " " << (uint)result.at(i).unicode();
+ for (int i = 0; i < result.length(); ++i)
+ qDebug() << hex << " " << (uint)result.at(i).unicode();
QCOMPARE(result.length(), unicode.length());
QCOMPARE(result, unicode);
+
+ if (!rowName.endsWith("nobom") && !rowName.contains(ignoreReverseTestOn)) {
+ QTextCodec::ConverterState state2(cFlags);
+ QByteArray reencoded = codec->fromUnicode(unicode.unicode(), unicode.length(), &state2);
+ QCOMPARE(reencoded, encoded);
+ }
} else {
QByteArray result = codec->fromUnicode(unicode.unicode(), unicode.length(), &state);
QCOMPARE(result, encoded);
diff --git a/tests/auto/qtextdocument/tst_qtextdocument.cpp b/tests/auto/qtextdocument/tst_qtextdocument.cpp
index 63a172b..27be372 100644
--- a/tests/auto/qtextdocument/tst_qtextdocument.cpp
+++ b/tests/auto/qtextdocument/tst_qtextdocument.cpp
@@ -163,6 +163,8 @@ private slots:
void testUndoBlocks();
+ void receiveCursorPositionChangedAfterContentsChange();
+
private:
void backgroundImage_checkExpectedHtml(const QTextDocument &doc);
@@ -2453,5 +2455,35 @@ void tst_QTextDocument::testUndoBlocks()
QCOMPARE(doc->toPlainText(), QString(""));
}
+class Receiver : public QObject
+{
+ Q_OBJECT
+ public:
+ QString first;
+ public slots:
+ void cursorPositionChanged() {
+ if (first.isEmpty())
+ first = QLatin1String("cursorPositionChanged");
+ }
+
+ void contentsChange() {
+ if (first.isEmpty())
+ first = QLatin1String("contentsChanged");
+ }
+};
+
+void tst_QTextDocument::receiveCursorPositionChangedAfterContentsChange()
+{
+ QVERIFY(doc);
+ doc->setDocumentLayout(new MyAbstractTextDocumentLayout(doc));
+ Receiver rec;
+ connect(doc, SIGNAL(cursorPositionChanged(QTextCursor)),
+ &rec, SLOT(cursorPositionChanged()));
+ connect(doc, SIGNAL(contentsChange(int,int,int)),
+ &rec, SLOT(contentsChange()));
+ cursor.insertText("Hello World");
+ QCOMPARE(rec.first, QString("contentsChanged"));
+}
+
QTEST_MAIN(tst_QTextDocument)
#include "tst_qtextdocument.moc"
diff --git a/tests/auto/qtreewidget/tst_qtreewidget.cpp b/tests/auto/qtreewidget/tst_qtreewidget.cpp
index 906332c..32a2c40 100644
--- a/tests/auto/qtreewidget/tst_qtreewidget.cpp
+++ b/tests/auto/qtreewidget/tst_qtreewidget.cpp
@@ -2434,6 +2434,10 @@ void tst_QTreeWidget::itemOperatorLessThan()
item1.setText(0, "b");
item2.setText(0, "a");
QCOMPARE(item1 < item2, true);
+ tw.sortItems(0, Qt::AscendingOrder);
+ item1.setData(0, Qt::DisplayRole, 11);
+ item2.setData(0, Qt::DisplayRole, 2);
+ QCOMPARE(item1 < item2, false);
}
}
diff --git a/tests/auto/qwidget/tst_qwidget.cpp b/tests/auto/qwidget/tst_qwidget.cpp
index 3fad366..041aa7a 100644
--- a/tests/auto/qwidget/tst_qwidget.cpp
+++ b/tests/auto/qwidget/tst_qwidget.cpp
@@ -351,7 +351,6 @@ private slots:
void toplevelLineEditFocus();
void focusWidget_task254563();
- void focusWidget_mixed_widget_hierarchy();
private:
bool ensureScreenSize(int width, int height);
@@ -8995,22 +8994,5 @@ void tst_QWidget::focusWidget_task254563()
QVERIFY(top.focusWidget() != widget); //dangling pointer
}
-void tst_QWidget::focusWidget_mixed_widget_hierarchy()
-{
- QWidget top;
- top.show();
- QWidget notvisible(&top);
- QWidget *visible = new QWidget(&notvisible);
- visible->show();
-
- visible->setFocus();
- notvisible.setFocus();
- notvisible.show();
- QCOMPARE(top.focusWidget(), visible);
- QCOMPARE(notvisible.focusWidget(), visible);
- QCOMPARE(visible->focusWidget(), visible);
-}
-
-
QTEST_MAIN(tst_QWidget)
#include "tst_qwidget.moc"
diff --git a/tests/benchmarks/qpixmapcache/tst_qpixmapcache.cpp b/tests/benchmarks/qpixmapcache/tst_qpixmapcache.cpp
index f3c1134..9dafff5 100644
--- a/tests/benchmarks/qpixmapcache/tst_qpixmapcache.cpp
+++ b/tests/benchmarks/qpixmapcache/tst_qpixmapcache.cpp
@@ -156,9 +156,9 @@ struct styleStruct {
int height;
bool operator==(const styleStruct &str) const
{
- return str.key == key && str.state == state && str.direction == direction
+ return str.state == state && str.direction == direction
&& str.complex == complex && str.palette == palette && str.width == width
- && str.height == height;
+ && str.height == height && str.key == key;
}
};
diff --git a/tests/benchmarks/qstringbuilder/main.cpp b/tests/benchmarks/qstringbuilder/main.cpp
index d4e2fa0..8b769a6 100644
--- a/tests/benchmarks/qstringbuilder/main.cpp
+++ b/tests/benchmarks/qstringbuilder/main.cpp
@@ -1,6 +1,6 @@
// Select one of the scenarios below
-#define SCENARIO 3
+#define SCENARIO 1
#if SCENARIO == 1
// this is the "no harm done" version. Only operator% is active,
@@ -17,7 +17,7 @@
// this is the "full" version. Operator+ is replaced by a QStringBuilder
// based version
// with NO_CAST * defined
-#define P %
+#define P +
#define QT_USE_FAST_OPERATOR_PLUS
#define QT_USE_FAST_CONCATENATION
#define QT_NO_CAST_FROM_ASCII
@@ -38,7 +38,7 @@
// this is the "full" version. Operator+ is replaced by a QStringBuilder
// based version
// with NO_CAST * _not_ defined
-#define P %
+#define P +
#define QT_USE_FAST_OPERATOR_PLUS
#define QT_USE_FAST_CONCATENATION
#undef QT_NO_CAST_FROM_ASCII
@@ -53,6 +53,8 @@
#include <qtest.h>
+#include <string>
+
#define COMPARE(a, b) QCOMPARE(a, b)
//#define COMPARE(a, b)
@@ -70,6 +72,7 @@ public:
l1string(LITERAL),
ba(LITERAL),
string(l1string),
+ stdstring(LITERAL),
stringref(&string, 2, 10),
achar('c'),
r2(QLatin1String(LITERAL LITERAL)),
@@ -115,8 +118,9 @@ public:
private slots:
void separator_0() {
- qDebug() << "\nIn each block the QStringBuilder based result appear first, "
- "QStringBased second.\n";
+ qDebug() << "\nIn each block the QStringBuilder based result appear first "
+ "(with a 'b_' prefix), QStringBased second ('q_' prefix), std::string "
+ "last ('s_' prefix)\n";
}
void separator_1() { SEP("literal + literal (builder first)"); }
@@ -131,7 +135,7 @@ private slots:
COMPARE(r, r2);
}
#endif
- void s_2_l1string() {
+ void q_2_l1string() {
QBENCHMARK { r = l1string + l1string; }
COMPARE(r, r2);
}
@@ -143,10 +147,14 @@ private slots:
QBENCHMARK { r = string P string; }
COMPARE(r, r2);
}
- void s_2_string() {
+ void q_2_string() {
QBENCHMARK { r = string + string; }
COMPARE(r, r2);
}
+ void s_2_string() {
+ QBENCHMARK { stdr = stdstring + stdstring; }
+ COMPARE(stdr, stdstring + stdstring);
+ }
void separator_2c() { SEP("2 string refs"); }
@@ -155,7 +163,7 @@ private slots:
QBENCHMARK { r = stringref % stringref; }
COMPARE(r, QString(stringref.toString() + stringref.toString()));
}
- void s_2_stringref() {
+ void q_2_stringref() {
QBENCHMARK { r = stringref.toString() + stringref.toString(); }
COMPARE(r, QString(stringref % stringref));
}
@@ -167,10 +175,30 @@ private slots:
QBENCHMARK { r = string P string P string; }
COMPARE(r, r3);
}
- void s_3_string() {
+ void q_3_string() {
QBENCHMARK { r = string + string + string; }
COMPARE(r, r3);
}
+ void s_3_string() {
+ QBENCHMARK { stdr = stdstring + stdstring + stdstring; }
+ COMPARE(stdr, stdstring + stdstring + stdstring);
+ }
+
+ void separator_2e() { SEP("4 strings"); }
+
+ void b_4_string() {
+ QBENCHMARK { r = string P string P string P string; }
+ COMPARE(r, r4);
+ }
+ void q_4_string() {
+ QBENCHMARK { r = string + string + string + string; }
+ COMPARE(r, r4);
+ }
+ void s_4_string() {
+ QBENCHMARK { stdr = stdstring + stdstring + stdstring + stdstring; }
+ COMPARE(stdr, stdstring + stdstring + stdstring + stdstring);
+ }
+
void separator_2a() { SEP("string + literal (builder first)"); }
@@ -193,14 +221,18 @@ private slots:
QBENCHMARK { r = string P l1string; }
COMPARE(r, r2);
}
- void s_string_l1literal() {
+ void q_string_l1literal() {
QBENCHMARK { r = string + l1string; }
COMPARE(r, r2);
}
- void s_string_l1string() {
+ void q_string_l1string() {
QBENCHMARK { r = string + l1string; }
COMPARE(r, r2);
}
+ void s_LITERAL_string() {
+ QBENCHMARK { stdr = LITERAL + stdstring; }
+ COMPARE(stdr, stdstring + stdstring);
+ }
void separator_3() { SEP("3 literals"); }
@@ -209,10 +241,14 @@ private slots:
QBENCHMARK { r = l1literal P l1literal P l1literal; }
COMPARE(r, r3);
}
- void s_3_l1string() {
+ void q_3_l1string() {
QBENCHMARK { r = l1string + l1string + l1string; }
COMPARE(r, r3);
}
+ void s_3_l1string() {
+ QBENCHMARK { stdr = stdstring + LITERAL + LITERAL; }
+ COMPARE(stdr, stdstring + stdstring + stdstring);
+ }
void separator_4() { SEP("4 literals"); }
@@ -221,7 +257,7 @@ private slots:
QBENCHMARK { r = l1literal P l1literal P l1literal P l1literal; }
COMPARE(r, r4);
}
- void s_4_l1string() {
+ void q_4_l1string() {
QBENCHMARK { r = l1string + l1string + l1string + l1string; }
COMPARE(r, r4);
}
@@ -234,7 +270,7 @@ private slots:
COMPARE(r, r5);
}
- void s_5_l1string() {
+ void q_5_l1string() {
QBENCHMARK { r = l1string + l1string + l1string + l1string + l1string; }
COMPARE(r, r5);
}
@@ -247,11 +283,16 @@ private slots:
COMPARE(r, QString(string P achar P achar P achar P achar));
}
- void s_string_4_char() {
+ void q_string_4_char() {
QBENCHMARK { r = string + achar + achar + achar + achar; }
COMPARE(r, QString(string P achar P achar P achar P achar));
}
+ void s_string_4_char() {
+ QBENCHMARK { stdr = stdstring + 'c' + 'c' + 'c' + 'c'; }
+ COMPARE(stdr, stdstring + 'c' + 'c' + 'c' + 'c');
+ }
+
void separator_7() { SEP("char + string + char"); }
@@ -260,11 +301,17 @@ private slots:
COMPARE(r, QString(achar P string P achar));
}
- void s_char_string_char() {
+ void q_char_string_char() {
QBENCHMARK { r = achar + string + achar; }
COMPARE(r, QString(achar P string P achar));
}
+ void s_char_string_char() {
+ QBENCHMARK { stdr = 'c' + stdstring + 'c'; }
+ COMPARE(stdr, 'c' + stdstring + 'c');
+ }
+
+
void separator_8() { SEP("string.arg"); }
void b_string_arg() {
@@ -273,13 +320,13 @@ private slots:
COMPARE(r, r3);
}
- void s_string_arg() {
+ void q_string_arg() {
const QString pattern = l1string + QLatin1String("%1") + l1string;
QBENCHMARK { r = pattern.arg(string); }
COMPARE(r, r3);
}
- void s_bytearray_arg() {
+ void q_bytearray_arg() {
QByteArray result;
QBENCHMARK { result = ba + ba + ba; }
}
@@ -331,11 +378,14 @@ private:
const QLatin1String l1string;
const QByteArray ba;
const QString string;
+ const std::string stdstring;
const QStringRef stringref;
const QLatin1Char achar;
const QString r2, r3, r4, r5;
+ // short cuts for results
QString r;
+ std::string stdr;
};