diff options
Diffstat (limited to 'tests/auto')
22 files changed, 307 insertions, 1052 deletions
diff --git a/tests/auto/corelib/io/qsettings/tst_qsettings.cpp b/tests/auto/corelib/io/qsettings/tst_qsettings.cpp index 2f039cbcd8..0e8a784423 100644 --- a/tests/auto/corelib/io/qsettings/tst_qsettings.cpp +++ b/tests/auto/corelib/io/qsettings/tst_qsettings.cpp @@ -159,6 +159,7 @@ private slots: void iniCodec(); void bom(); + void testXdg(); private: void cleanupTestFiles(); @@ -3397,5 +3398,77 @@ void tst_QSettings::consistentRegistryStorage() } #endif +#if defined(QT_BUILD_INTERNAL) && defined(Q_OS_UNIX) && !defined(Q_OS_DARWIN) && !defined(Q_OS_ANDROID) && !defined(QT_NO_STANDARDPATHS) +QT_BEGIN_NAMESPACE +extern void clearDefaultPaths(); +QT_END_NAMESPACE +#endif +void tst_QSettings::testXdg() +{ +#if defined(QT_BUILD_INTERNAL) && defined(Q_OS_UNIX) && !defined(Q_OS_DARWIN) && !defined(Q_OS_ANDROID) && !defined(QT_NO_STANDARDPATHS) + // Note: The XDG_CONFIG_DIRS test must be done before overriding the system path + // by QSettings::setPath/setSystemIniPath (used in cleanupTestFiles()). + clearDefaultPaths(); + + // Initialize the env. variable & populate testing files. + const QStringList config_dirs = { settingsPath("xdg_1st"), settingsPath("xdg_2nd"), settingsPath("xdg_3rd") }; + qputenv("XDG_CONFIG_DIRS", config_dirs.join(':').toUtf8()); + QList<QSettings *> xdg_orgs, xdg_apps; + for (const auto & dir : config_dirs) { + xdg_orgs << new QSettings{dir + "/software.org.conf", QSettings::NativeFormat}; + xdg_apps << new QSettings{dir + "/software.org/KillerAPP.conf", QSettings::NativeFormat}; + } + Q_ASSERT(config_dirs.size() == 3 && xdg_orgs.size() == 3 && xdg_apps.size() == 3); + for (int i = 0; i < 3; ++i) { + xdg_orgs[i]->setValue("all", QString{"all_org%1"}.arg(i)); + xdg_apps[i]->setValue("all", QString{"all_app%1"}.arg(i)); + xdg_orgs[i]->setValue("all_only_org", QString{"all_only_org%1"}.arg(i)); + xdg_apps[i]->setValue("all_only_app", QString{"all_only_app%1"}.arg(i)); + + if (i > 0) { + xdg_orgs[i]->setValue("from2nd", QString{"from2nd_org%1"}.arg(i)); + xdg_apps[i]->setValue("from2nd", QString{"from2nd_app%1"}.arg(i)); + xdg_orgs[i]->setValue("from2nd_only_org", QString{"from2nd_only_org%1"}.arg(i)); + xdg_apps[i]->setValue("from2nd_only_app", QString{"from2nd_only_app%1"}.arg(i)); + } + + if (i > 1) { + xdg_orgs[i]->setValue("from3rd", QString{"from3rd_org%1"}.arg(i)); + xdg_apps[i]->setValue("from3rd", QString{"from3rd_app%1"}.arg(i)); + xdg_orgs[i]->setValue("from3rd_only_org", QString{"from3rd_only_org%1"}.arg(i)); + xdg_apps[i]->setValue("from3rd_only_app", QString{"from3rd_only_app%1"}.arg(i)); + } + } + qDeleteAll(xdg_apps); + qDeleteAll(xdg_orgs); + + // Do the test. + QSettings app{QSettings::SystemScope, "software.org", "KillerAPP"}, org{QSettings::SystemScope, "software.org"}; + + QVERIFY(app.value("all").toString() == "all_app0"); + QVERIFY(org.value("all").toString() == "all_org0"); + QVERIFY(app.value("all_only_org").toString() == "all_only_org0"); + QVERIFY(org.value("all_only_org").toString() == "all_only_org0"); + QVERIFY(app.value("all_only_app").toString() == "all_only_app0"); + QVERIFY(org.value("all_only_app").toString() == QString{}); + + QVERIFY(app.value("from2nd").toString() == "from2nd_app1"); + QVERIFY(org.value("from2nd").toString() == "from2nd_org1"); + QVERIFY(app.value("from2nd_only_org").toString() == "from2nd_only_org1"); + QVERIFY(org.value("from2nd_only_org").toString() == "from2nd_only_org1"); + QVERIFY(app.value("from2nd_only_app").toString() == "from2nd_only_app1"); + QVERIFY(org.value("from2nd_only_app").toString() == QString{}); + + QVERIFY(app.value("from3rd").toString() == "from3rd_app2"); + QVERIFY(org.value("from3rd").toString() == "from3rd_org2"); + QVERIFY(app.value("from3rd_only_org").toString() == "from3rd_only_org2"); + QVERIFY(org.value("from3rd_only_org").toString() == "from3rd_only_org2"); + QVERIFY(app.value("from3rd_only_app").toString() == "from3rd_only_app2"); + QVERIFY(org.value("from3rd_only_app").toString() == QString{}); +#else + QSKIP("This test is performed in QT_BUILD_INTERNAL on Q_XDG_PLATFORM with use of standard paths only."); +#endif +} + QTEST_MAIN(tst_QSettings) #include "tst_qsettings.moc" diff --git a/tests/auto/corelib/io/qstandardpaths/tst_qstandardpaths.cpp b/tests/auto/corelib/io/qstandardpaths/tst_qstandardpaths.cpp index 5b18ab9d68..0b536f26de 100644 --- a/tests/auto/corelib/io/qstandardpaths/tst_qstandardpaths.cpp +++ b/tests/auto/corelib/io/qstandardpaths/tst_qstandardpaths.cpp @@ -372,7 +372,7 @@ void tst_qstandardpaths::testFindExecutable_data() QTest::newRow("win-cmd-nosuffix") << QString() << QString::fromLatin1("cmd") << cmdPath; - if (QSysInfo::windowsVersion() >= QSysInfo::WV_WINDOWS8) { + if (QOperatingSystemVersion::current() >= QOperatingSystemVersion::Windows8) { // The logo executable on Windows 8 is perfectly suited for testing that the // suffix mechanism is not thrown off by dots in the name. const QString logo = QLatin1String("microsoft.windows.softwarelogo.showdesktop"); diff --git a/tests/auto/corelib/io/qtemporarydir/tst_qtemporarydir.cpp b/tests/auto/corelib/io/qtemporarydir/tst_qtemporarydir.cpp index 487c13be94..758bbead84 100644 --- a/tests/auto/corelib/io/qtemporarydir/tst_qtemporarydir.cpp +++ b/tests/auto/corelib/io/qtemporarydir/tst_qtemporarydir.cpp @@ -57,6 +57,8 @@ private slots: void fileTemplate_data(); void getSetCheck(); void fileName(); + void filePath_data(); + void filePath(); void autoRemove(); void nonWritableCurrentDir(); void openOnRootDrives(); @@ -204,6 +206,29 @@ void tst_QTemporaryDir::fileName() QCOMPARE(absoluteFilePath, absoluteTempPath); } +void tst_QTemporaryDir::filePath_data() +{ + QTest::addColumn<QString>("templatePath"); + QTest::addColumn<QString>("fileName"); + + QTest::newRow("0") << QString() << "/tmpfile"; + QTest::newRow("1") << QString() << "tmpfile"; + QTest::newRow("2") << "XXXXX" << "tmpfile"; + QTest::newRow("3") << "YYYYY" << "subdir/file"; +} + +void tst_QTemporaryDir::filePath() +{ + QFETCH(QString, templatePath); + QFETCH(QString, fileName); + + QTemporaryDir dir(templatePath); + const QString filePath = dir.filePath(fileName); + const QString expectedFilePath = QDir::isAbsolutePath(fileName) ? + QString() : dir.path() + QLatin1Char('/') + fileName; + QCOMPARE(filePath, expectedFilePath); +} + void tst_QTemporaryDir::autoRemove() { // Test auto remove diff --git a/tests/auto/corelib/kernel/qobject/tst_qobject.cpp b/tests/auto/corelib/kernel/qobject/tst_qobject.cpp index 0f7f75fb2e..fea185c48f 100644 --- a/tests/auto/corelib/kernel/qobject/tst_qobject.cpp +++ b/tests/auto/corelib/kernel/qobject/tst_qobject.cpp @@ -3401,14 +3401,12 @@ void tst_QObject::dumpObjectInfo() QObject a, b; QObject::connect(&a, SIGNAL(destroyed(QObject*)), &b, SLOT(deleteLater())); a.disconnect(&b); -#ifdef QT_DEBUG QTest::ignoreMessage(QtDebugMsg, "OBJECT QObject::unnamed"); QTest::ignoreMessage(QtDebugMsg, " SIGNALS OUT"); QTest::ignoreMessage(QtDebugMsg, " signal: destroyed(QObject*)"); QTest::ignoreMessage(QtDebugMsg, " <Disconnected receiver>"); QTest::ignoreMessage(QtDebugMsg, " SIGNALS IN"); QTest::ignoreMessage(QtDebugMsg, " <None>"); -#endif a.dumpObjectInfo(); // should not crash } diff --git a/tests/auto/corelib/tools/qarraydata/tst_qarraydata.cpp b/tests/auto/corelib/tools/qarraydata/tst_qarraydata.cpp index 0c41f66357..65887e50d3 100644 --- a/tests/auto/corelib/tools/qarraydata/tst_qarraydata.cpp +++ b/tests/auto/corelib/tools/qarraydata/tst_qarraydata.cpp @@ -65,6 +65,8 @@ private slots: void simpleVectorReserve(); void allocate_data(); void allocate(); + void reallocate_data() { allocate_data(); } + void reallocate(); void alignment_data(); void alignment(); void typedData(); @@ -742,6 +744,54 @@ void tst_QArrayData::allocate() } } +void tst_QArrayData::reallocate() +{ + QFETCH(size_t, objectSize); + QFETCH(size_t, alignment); + QFETCH(QArrayData::AllocationOptions, allocateOptions); + QFETCH(bool, isCapacityReserved); + QFETCH(const QArrayData *, commonEmpty); + + // Maximum alignment that can be requested is that of QArrayData, + // otherwise, we can't use reallocate(). + Q_ASSERT(alignment <= Q_ALIGNOF(QArrayData)); + + // Minimum alignment that can be requested is that of QArrayData. + // Typically, this alignment is sizeof(void *) and ensured by malloc. + size_t minAlignment = qMax(alignment, Q_ALIGNOF(QArrayData)); + + int capacity = 10; + Deallocator keeper(objectSize, minAlignment); + QArrayData *data = QArrayData::allocate(objectSize, minAlignment, capacity, + QArrayData::AllocationOptions(allocateOptions) & ~QArrayData::Grow); + keeper.headers.append(data); + + memset(data->data(), 'A', objectSize * capacity); + data->size = capacity; + + // now try to reallocate + int newCapacity = 40; + data = QArrayData::reallocateUnaligned(data, objectSize, newCapacity, + QArrayData::AllocationOptions(allocateOptions)); + QVERIFY(data); + keeper.headers.clear(); + keeper.headers.append(data); + + QCOMPARE(data->size, capacity); + if (allocateOptions & QArrayData::Grow) + QVERIFY(data->alloc > uint(newCapacity)); + else + QCOMPARE(data->alloc, uint(newCapacity)); + QCOMPARE(data->capacityReserved, uint(isCapacityReserved)); +#if !defined(QT_NO_UNSHARABLE_CONTAINERS) + QFETCH(bool, isSharable); + QCOMPARE(data->ref.isSharable(), isSharable); +#endif + + for (int i = 0; i < capacity; ++i) + QCOMPARE(static_cast<char *>(data->data())[i], 'A'); +} + class Unaligned { char dummy[8]; diff --git a/tests/auto/corelib/tools/qlocale/tst_qlocale.cpp b/tests/auto/corelib/tools/qlocale/tst_qlocale.cpp index 8d9a789507..7681f4755c 100644 --- a/tests/auto/corelib/tools/qlocale/tst_qlocale.cpp +++ b/tests/auto/corelib/tools/qlocale/tst_qlocale.cpp @@ -1754,6 +1754,30 @@ void tst_QLocale::numberOptions() QVERIFY(ok); locale.toDouble(QString("1.24e+01"), &ok); QVERIFY(!ok); + + QCOMPARE(locale.toString(12.4, 'g', 5), QString("12.4")); + locale.setNumberOptions(QLocale::IncludeTrailingZeroesAfterDot); + QCOMPARE(locale.numberOptions(), QLocale::IncludeTrailingZeroesAfterDot); + QCOMPARE(locale.toString(12.4, 'g', 5), QString("12.400")); + + locale.toDouble(QString("1.24e+01"), &ok); + QVERIFY(ok); + locale.toDouble(QString("1.2400e+01"), &ok); + QVERIFY(ok); + locale.toDouble(QString("12.4"), &ok); + QVERIFY(ok); + locale.toDouble(QString("12.400"), &ok); + QVERIFY(ok); + locale.setNumberOptions(QLocale::RejectTrailingZeroesAfterDot); + QCOMPARE(locale.numberOptions(), QLocale::RejectTrailingZeroesAfterDot); + locale.toDouble(QString("1.24e+01"), &ok); + QVERIFY(ok); + locale.toDouble(QString("1.2400e+01"), &ok); + QVERIFY(!ok); + locale.toDouble(QString("12.4"), &ok); + QVERIFY(ok); + locale.toDouble(QString("12.400"), &ok); + QVERIFY(!ok); } void tst_QLocale::negativeNumbers() diff --git a/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp b/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp index 43e05c95f9..61927862f7 100644 --- a/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp +++ b/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp @@ -104,10 +104,10 @@ class tst_QNetworkReply: public QObject Q_OBJECT #ifndef QT_NO_NETWORKPROXY - struct ProxyData { + struct ProxyData + { ProxyData(const QNetworkProxy &p, const QByteArray &t, bool auth) - : tag(t), proxy(p), requiresAuthentication(auth) - { } + : tag(t), proxy(p), requiresAuthentication(auth) {} QByteArray tag; QNetworkProxy proxy; bool requiresAuthentication; @@ -115,7 +115,8 @@ class tst_QNetworkReply: public QObject #endif // !QT_NO_NETWORKPROXY static bool seedCreated; - static QString createUniqueExtension() { + static QString createUniqueExtension() + { if (!seedCreated) { qsrand(QTime(0,0,0).msecsTo(QTime::currentTime()) + QCoreApplication::applicationPid()); seedCreated = true; // not thread-safe, but who cares @@ -534,7 +535,7 @@ QT_END_NAMESPACE QString errorMsg = call; \ if (!errorMsg.isEmpty()) \ QFAIL(qPrintable(errorMsg)); \ - } while (0); + } while (0) #ifndef QT_NO_SSL static void setupSslServer(QSslSocket* serverSocket) @@ -546,6 +547,7 @@ static void setupSslServer(QSslSocket* serverSocket) serverSocket->setProtocol(QSsl::AnyProtocol); serverSocket->setLocalCertificate(testDataDir + "/certs/server.pem"); serverSocket->setPrivateKey(testDataDir + "/certs/server.key"); + serverSocket->startServerEncryption(); } #endif @@ -592,31 +594,30 @@ protected: void incomingConnection(qintptr socketDescriptor) { //qDebug() << "incomingConnection" << socketDescriptor << "doSsl:" << doSsl << "ipv6:" << ipv6; - if (!doSsl) { - client = new QTcpSocket; - client->setSocketDescriptor(socketDescriptor); - connectSocketSignals(); - } else { #ifndef QT_NO_SSL - QSslSocket *serverSocket = new QSslSocket; - serverSocket->setParent(this); - if (serverSocket->setSocketDescriptor(socketDescriptor)) { - connect(serverSocket, SIGNAL(sslErrors(QList<QSslError>)), this, SLOT(slotSslErrors(QList<QSslError>))); - setupSslServer(serverSocket); - serverSocket->startServerEncryption(); - client = serverSocket; - connectSocketSignals(); - } else { + if (doSsl) { + QSslSocket *serverSocket = new QSslSocket(this); + if (!serverSocket->setSocketDescriptor(socketDescriptor)) { delete serverSocket; return; } + connect(serverSocket, SIGNAL(sslErrors(QList<QSslError>)), this, SLOT(slotSslErrors(QList<QSslError>))); + // connect(serverSocket, &QSslSocket::encrypted, this, &SslServer::ready); ? + setupSslServer(serverSocket); + client = serverSocket; + } else #endif + { + client = new QTcpSocket; + client->setSocketDescriptor(socketDescriptor); } + connectSocketSignals(); client->setParent(this); ++totalConnections; } - virtual void reply() { + virtual void reply() + { Q_ASSERT(!client.isNull()); // we need to emulate the bytesWrittenSlot call if the data is empty. if (dataToTransmit.size() == 0) { @@ -673,7 +674,8 @@ public slots: } } - void bytesWrittenSlot() { + void bytesWrittenSlot() + { Q_ASSERT(!client.isNull()); // Disconnect and delete in next cycle (else Windows clients will fail with RemoteHostClosedError). if (doClose && client->bytesToWrite() == 0) { @@ -918,7 +920,8 @@ class BlockingTcpServer : public QTcpServer public: BlockingTcpServer(bool ssl) : doSsl(ssl), sslSocket(0) {} - QTcpSocket* waitForNextConnectionSocket() { + QTcpSocket* waitForNextConnectionSocket() + { waitForNewConnection(-1); if (doSsl) { if (!sslSocket) @@ -939,7 +942,6 @@ public: serverSocket->setSocketDescriptor(socketDescriptor); connect(serverSocket, SIGNAL(sslErrors(QList<QSslError>)), this, SLOT(slotSslErrors(QList<QSslError>))); setupSslServer(serverSocket); - serverSocket->startServerEncryption(); sslSocket = serverSocket; } else #endif @@ -1420,14 +1422,12 @@ static QByteArray msgWaitForFinished(QNetworkReplyPtr &reply) QString result; QDebug debug(&result); debug << reply->url(); - if (reply->isFinished()) { - if (reply->error() == QNetworkReply::NoError) - debug << "finished."; - else - debug << "failed: #" << reply->error() << reply->errorString(); - } else { + if (!reply->isFinished()) debug << "timed out."; - } + else if (reply->error() == QNetworkReply::NoError) + debug << "finished."; + else + debug << "failed: #" << reply->error() << reply->errorString(); return result.toLocal8Bit(); } @@ -1442,7 +1442,7 @@ int tst_QNetworkReply::waitForFinish(QNetworkReplyPtr &reply) QSignalSpy spy(reply.data(), SIGNAL(downloadProgress(qint64,qint64))); while (!reply->isFinished()) { QTimer::singleShot(5000, loop, SLOT(quit())); - if ( loop->exec() == Timeout && count == spy.count() && !reply->isFinished()) { + if (loop->exec() == Timeout && count == spy.count() && !reply->isFinished()) { returnCode = Timeout; break; } @@ -1456,12 +1456,14 @@ int tst_QNetworkReply::waitForFinish(QNetworkReplyPtr &reply) void tst_QNetworkReply::finished() { - loop->exit(returnCode = Success); + if (loop) + loop->exit(returnCode = Success); } void tst_QNetworkReply::gotError() { - loop->exit(returnCode = Failure); + if (loop) + loop->exit(returnCode = Failure); disconnect(QObject::sender(), SIGNAL(finished()), this, 0); } @@ -4764,11 +4766,13 @@ void tst_QNetworkReply::ioPostToHttpNoBufferFlag() } #ifndef QT_NO_SSL -class SslServer : public QTcpServer { +class SslServer : public QTcpServer +{ Q_OBJECT public: SslServer() : socket(0), m_ssl(true) {} - void incomingConnection(qintptr socketDescriptor) { + void incomingConnection(qintptr socketDescriptor) + { QSslSocket *serverSocket = new QSslSocket; serverSocket->setParent(this); @@ -4778,16 +4782,9 @@ public: emit newPlainConnection(serverSocket); return; } - QString testDataDir = QFileInfo(QFINDTESTDATA("rfc3252.txt")).absolutePath(); - if (testDataDir.isEmpty()) - testDataDir = QCoreApplication::applicationDirPath(); - connect(serverSocket, SIGNAL(encrypted()), this, SLOT(encryptedSlot())); - serverSocket->setProtocol(QSsl::AnyProtocol); connect(serverSocket, SIGNAL(sslErrors(QList<QSslError>)), serverSocket, SLOT(ignoreSslErrors())); - serverSocket->setLocalCertificate(testDataDir + "/certs/server.pem"); - serverSocket->setPrivateKey(testDataDir + "/certs/server.key"); - serverSocket->startServerEncryption(); + setupSslServer(serverSocket); } else { delete serverSocket; } @@ -4796,11 +4793,13 @@ signals: void newEncryptedConnection(QSslSocket *s); void newPlainConnection(QSslSocket *s); public slots: - void encryptedSlot() { + void encryptedSlot() + { socket = (QSslSocket*) sender(); emit newEncryptedConnection(socket); } - void readyReadSlot() { + void readyReadSlot() + { // for the incoming sockets, not the server socket //qDebug() << static_cast<QSslSocket*>(sender())->bytesAvailable() << static_cast<QSslSocket*>(sender())->encryptedBytesAvailable(); } @@ -4846,7 +4845,7 @@ void tst_QNetworkReply::ioPostToHttpsUploadProgress() disconnect(&server, SIGNAL(newEncryptedConnection(QSslSocket*)), &QTestEventLoop::instance(), SLOT(exitLoop())); - incomingSocket->setReadBufferSize(1*1024); + incomingSocket->setReadBufferSize(1024); // some progress should have been made QTRY_VERIFY(!spy.isEmpty()); QList<QVariant> args = spy.last(); @@ -4950,7 +4949,7 @@ void tst_QNetworkReply::ioGetFromBuiltinHttp() QCOMPARE(reply->header(QNetworkRequest::ContentLengthHeader).toLongLong(), (qint64)testData.size()); if (reader.data.size() < testData.size()) { // oops? - QCOMPARE(reader.data, testData.mid(0, reader.data.size())); + QCOMPARE(reader.data, testData.left(reader.data.size())); qDebug() << "The data is incomplete, the last" << testData.size() - reader.data.size() << "bytes are missing"; } QCOMPARE(reader.data.size(), testData.size()); @@ -4997,7 +4996,7 @@ void tst_QNetworkReply::ioPostToHttpUploadProgress() QVERIFY(incomingSocket); disconnect(&server, SIGNAL(newConnection()), &QTestEventLoop::instance(), SLOT(exitLoop())); - incomingSocket->setReadBufferSize(1*1024); + incomingSocket->setReadBufferSize(1024); QTestEventLoop::instance().enterLoop(5); // some progress should have been made QVERIFY(!spy.isEmpty()); @@ -5699,12 +5698,14 @@ void tst_QNetworkReply::httpProxyCommands() QCOMPARE(uaheader, QByteArray("User-Agent: QNetworkReplyAutoTest/1.0")); } -class ProxyChangeHelper : public QObject { +class ProxyChangeHelper : public QObject +{ Q_OBJECT public: ProxyChangeHelper() : QObject(), signalCount(0) {}; public slots: - void finishedSlot() { + void finishedSlot() + { signalCount++; if (signalCount == 2) QMetaObject::invokeMethod(&QTestEventLoop::instance(), "exitLoop", Qt::QueuedConnection); @@ -5950,7 +5951,8 @@ void tst_QNetworkReply::httpReUsingConnectionSequential() reply2->deleteLater(); } -class HttpReUsingConnectionFromFinishedSlot : public QObject { +class HttpReUsingConnectionFromFinishedSlot : public QObject +{ Q_OBJECT public: QNetworkReply* reply1; @@ -5958,7 +5960,8 @@ public: QUrl url; QNetworkAccessManager manager; public slots: - void finishedSlot() { + void finishedSlot() + { QVERIFY(!reply1->error()); QFETCH(bool, doDeleteLater); @@ -6006,7 +6009,8 @@ void tst_QNetworkReply::httpReUsingConnectionFromFinishedSlot() QCOMPARE(server.totalConnections, 1); } -class HttpRecursiveCreationHelper : public QObject { +class HttpRecursiveCreationHelper : public QObject +{ Q_OBJECT public: @@ -6022,7 +6026,8 @@ public: int requestsStartedCount_readyRead; int requestsFinishedCount; public slots: - void finishedSlot() { + void finishedSlot() + { requestsFinishedCount++; QNetworkReply *reply = qobject_cast<QNetworkReply*>(sender()); @@ -6041,7 +6046,8 @@ public slots: reply->deleteLater(); } - void readyReadSlot() { + void readyReadSlot() + { QNetworkReply *reply = qobject_cast<QNetworkReply*>(sender()); QVERIFY(!reply->error()); @@ -6050,7 +6056,8 @@ public slots: requestsStartedCount_readyRead++; } } - void startOne() { + void startOne() + { QUrl url = "http://" + QtNetworkSettings::serverName() + "/qtest/fluke.gif"; QNetworkRequest request(url); QNetworkReply *reply = manager.get(request); @@ -6419,7 +6426,8 @@ void tst_QNetworkReply::getFromHttpIntoBuffer() } // FIXME we really need to consolidate all those server implementations -class GetFromHttpIntoBuffer2Server : QObject { +class GetFromHttpIntoBuffer2Server : QObject +{ Q_OBJECT qint64 dataSize; qint64 dataSent; @@ -6429,26 +6437,28 @@ class GetFromHttpIntoBuffer2Server : QObject { bool chunkedEncoding; public: - GetFromHttpIntoBuffer2Server (qint64 ds, bool sscl, bool ce) : dataSize(ds), dataSent(0), - client(0), serverSendsContentLength(sscl), chunkedEncoding(ce) { + GetFromHttpIntoBuffer2Server (qint64 ds, bool sscl, bool ce) + : dataSize(ds), dataSent(0), client(0), + serverSendsContentLength(sscl), chunkedEncoding(ce) + { server.listen(); connect(&server, SIGNAL(newConnection()), this, SLOT(newConnectionSlot())); } - int serverPort() { - return server.serverPort(); - } + int serverPort() { return server.serverPort(); } public slots: - void newConnectionSlot() { + void newConnectionSlot() + { client = server.nextPendingConnection(); client->setParent(this); connect(client, SIGNAL(readyRead()), this, SLOT(readyReadSlot())); connect(client, SIGNAL(bytesWritten(qint64)), this, SLOT(bytesWrittenSlot(qint64))); } - void readyReadSlot() { + void readyReadSlot() + { client->readAll(); client->write("HTTP/1.0 200 OK\n"); if (serverSendsContentLength) @@ -6458,7 +6468,8 @@ public slots: client->write("Connection: close\n\n"); } - void bytesWrittenSlot(qint64 amount) { + void bytesWrittenSlot(qint64 amount) + { Q_UNUSED(amount); if (dataSent == dataSize && client) { // close eventually @@ -6492,7 +6503,8 @@ public slots: } }; -class GetFromHttpIntoBuffer2Client : QObject { +class GetFromHttpIntoBuffer2Client : QObject +{ Q_OBJECT private: bool useDownloadBuffer; @@ -6509,7 +6521,8 @@ public: } public slots: - void metaDataChangedSlot() { + void metaDataChangedSlot() + { if (useDownloadBuffer) { QSharedPointer<char> sharedPointer = qvariant_cast<QSharedPointer<char> >(reply->attribute(QNetworkRequest::DownloadBufferAttribute)); QVERIFY(!sharedPointer.isNull()); // It will be 0 if it failed @@ -6519,7 +6532,8 @@ public: QVERIFY(bytesAvailableList.isEmpty()); } - void readyReadSlot() { + void readyReadSlot() + { QVERIFY(!reply->isFinished()); qint64 bytesAvailable = reply->bytesAvailable(); @@ -6541,7 +6555,8 @@ public: // Add bytesAvailable to a list an parse } - void finishedSlot() { + void finishedSlot() + { // We should have already received all readyRead QVERIFY(!bytesAvailableList.isEmpty()); QCOMPARE(bytesAvailableList.last(), uploadSize); @@ -6947,17 +6962,17 @@ void tst_QNetworkReply::authenticationWithDifferentRealm() } #endif // !QT_NO_NETWORKPROXY -class QtBug13431Helper : public QObject { +class QtBug13431Helper : public QObject +{ Q_OBJECT public: QNetworkReply* m_reply; QTimer m_dlTimer; public slots: - void replyFinished(QNetworkReply*) { - QTestEventLoop::instance().exitLoop(); - } + void replyFinished(QNetworkReply*) { QTestEventLoop::instance().exitLoop(); } - void onReadAndReschedule() { + void onReadAndReschedule() + { const qint64 bytesReceived = m_reply->bytesAvailable(); if (bytesReceived && m_reply->readBufferSize()) { QByteArray data = m_reply->read(bytesReceived); @@ -7105,7 +7120,8 @@ void tst_QNetworkReply::qtbug22660gzipNoContentLengthEmptyContent() QCOMPARE(reply->readAll(), QByteArray()); } -class QtBug27161Helper : public QObject { +class QtBug27161Helper : public QObject +{ Q_OBJECT public: QtBug27161Helper(MiniHttpServer & server, const QByteArray & data): @@ -7115,16 +7131,19 @@ public: connect(&m_server, SIGNAL(newConnection()), this, SLOT(newConnectionSlot())); } public slots: - void newConnectionSlot(){ + void newConnectionSlot() + { connect(m_server.client, SIGNAL(bytesWritten(qint64)), this, SLOT(bytesWrittenSlot())); } - void bytesWrittenSlot(){ + void bytesWrittenSlot() + { disconnect(m_server.client, SIGNAL(bytesWritten(qint64)), this, SLOT(bytesWrittenSlot())); m_Timer.singleShot(100, this, SLOT(timeoutSlot())); } - void timeoutSlot(){ + void timeoutSlot() + { m_server.doClose = true; // we need to emulate the bytesWrittenSlot call if the data is empty. if (m_data.size() == 0) @@ -7553,10 +7572,12 @@ void tst_QNetworkReply::httpUserAgent() void tst_QNetworkReply::synchronousAuthenticationCache() { - class MiniAuthServer : public MiniHttpServer { + class MiniAuthServer : public MiniHttpServer + { public: - MiniAuthServer(QThread *thread) : MiniHttpServer(QByteArray(), false, thread) {}; - virtual void reply() { + MiniAuthServer(QThread *thread) : MiniHttpServer(QByteArray(), false, thread) {} + virtual void reply() + { dataToTransmit = "HTTP/1.0 401 Unauthorized\r\n" @@ -7968,7 +7989,8 @@ public: qint64 bandwidthQuota; QTimer timer; - RateLimitedUploadDevice(QByteArray d) : QIODevice(),data(d),read(0),bandwidthQuota(0) { + RateLimitedUploadDevice(QByteArray d) : QIODevice(),data(d),read(0),bandwidthQuota(0) + { buffer.setData(data); buffer.open(QIODevice::ReadOnly); timer.setInterval(200); @@ -7976,12 +7998,14 @@ public: timer.start(); } - virtual qint64 writeData(const char* , qint64 ) { + virtual qint64 writeData(const char* , qint64 ) + { Q_ASSERT(false); return 0; } - virtual qint64 readData(char* data, qint64 maxlen) { + virtual qint64 readData(char* data, qint64 maxlen) + { //qDebug() << Q_FUNC_INFO << maxlen << bandwidthQuota; maxlen = qMin(maxlen, buffer.bytesAvailable()); maxlen = qMin(maxlen, bandwidthQuota); @@ -7998,24 +8022,17 @@ public: //qDebug() << Q_FUNC_INFO << maxlen << bandwidthQuota << read << ret << buffer.bytesAvailable(); return ret; } - virtual bool atEnd() const { - return buffer.atEnd(); - } - virtual qint64 size() const{ - return data.length(); - } + virtual bool atEnd() const { return buffer.atEnd(); } + virtual qint64 size() const { return data.length(); } qint64 bytesAvailable() const { return buffer.bytesAvailable() + QIODevice::bytesAvailable(); } - virtual bool isSequential() const{ // random access, we can seek - return false; - } - virtual bool seek ( qint64 pos ) { - return buffer.seek(pos); - } + virtual bool isSequential() const { return false; } // random access, we can seek + virtual bool seek (qint64 pos) { return buffer.seek(pos); } protected slots: - void timeoutSlot() { + void timeoutSlot() + { //qDebug() << Q_FUNC_INFO; bandwidthQuota = 8*1024; // fill quota emit readyRead(); @@ -8205,9 +8222,7 @@ signals: void corruptFileUploadReceived(); public slots: - void closeDelayed() { - m_socket->close(); - } + void closeDelayed() { m_socket->close(); } void readyReadSlot() { @@ -8232,17 +8247,18 @@ public slots: // We had received some data but it is corrupt! qDebug() << "CORRUPT" << m_receivedData.count(); - // Use this to track down the pattern of the corruption and conclude the source -// QFile a("/tmp/corrupt"); -// a.open(QIODevice::WriteOnly); -// a.write(m_receivedData); -// a.close(); +#if 0 // Use this to track down the pattern of the corruption and conclude the source + QFile a("/tmp/corrupt"); + a.open(QIODevice::WriteOnly); + a.write(m_receivedData); + a.close(); -// QFile b("/tmp/correct"); -// b.open(QIODevice::WriteOnly); -// b.write(m_expectedData); -// b.close(); + QFile b("/tmp/correct"); + b.open(QIODevice::WriteOnly); + b.write(m_expectedData); + b.close(); //exit(1); +#endif emit corruptFileUploadReceived(); } else { emit correctFileUploadReceived(); @@ -8259,26 +8275,26 @@ public: int m_repliesFinished; int m_expectedReplies; QByteArray m_expectedData; - PutWithServerClosingConnectionImmediatelyServer() : SslServer(), m_correctUploads(0), m_corruptUploads(0), m_repliesFinished(0), m_expectedReplies(0) + PutWithServerClosingConnectionImmediatelyServer() + : SslServer(), m_correctUploads(0), m_corruptUploads(0), + m_repliesFinished(0), m_expectedReplies(0) { QObject::connect(this, SIGNAL(newEncryptedConnection(QSslSocket*)), this, SLOT(createHandlerForConnection(QSslSocket*))); QObject::connect(this, SIGNAL(newPlainConnection(QSslSocket*)), this, SLOT(createHandlerForConnection(QSslSocket*))); } public slots: - void createHandlerForConnection(QSslSocket* s) { + void createHandlerForConnection(QSslSocket* s) + { PutWithServerClosingConnectionImmediatelyHandler *handler = new PutWithServerClosingConnectionImmediatelyHandler(s, m_expectedData); handler->setParent(this); QObject::connect(handler, SIGNAL(correctFileUploadReceived()), this, SLOT(increaseCorrect())); QObject::connect(handler, SIGNAL(corruptFileUploadReceived()), this, SLOT(increaseCorrupt())); } - void increaseCorrect() { - m_correctUploads++; - } - void increaseCorrupt() { - m_corruptUploads++; - } - void replyFinished() { + void increaseCorrect() { m_correctUploads++; } + void increaseCorrupt() { m_corruptUploads++; } + void replyFinished() + { m_repliesFinished++; if (m_repliesFinished == m_expectedReplies) { QTestEventLoop::instance().exitLoop(); diff --git a/tests/auto/other/atwrapper/.gitignore b/tests/auto/other/atwrapper/.gitignore deleted file mode 100644 index 162ad53af6..0000000000 --- a/tests/auto/other/atwrapper/.gitignore +++ /dev/null @@ -1 +0,0 @@ -tst_atwrapper diff --git a/tests/auto/other/atwrapper/TODO b/tests/auto/other/atwrapper/TODO deleted file mode 100644 index 23a70c3c9e..0000000000 --- a/tests/auto/other/atwrapper/TODO +++ /dev/null @@ -1,17 +0,0 @@ -* Get rid of "Keep baseline" on test failure page (Lars) !! DONE !! -* Make to autotest (Simon) !! DONE !! -* Add visual diff (Everyone ;)) !! DONE !! -* Add flicker (Simon/Jesper) !! DONE !! -* Add third image -- base-baseline (Lars) !! DONE !! -* Add "view baselines" gallery, including the "base base line" (Lars) !! DONE !! -* Add PS printer driver engine test thingy (Eskil) !! DONE !! -* Add platform by platform comparison perl script. (Morton) -* Fix the QDateTime.fromString() weirdness on win32 in xmldata.cpp (Jesper) -* Have one result per page view (Lars) !! DONE !! -* Have "platform - hostname" on test overview (Lars) !! DONE !! -* Have the links on the overview page only show failures for that host.(All)!! DONE !! -* "onion skin" diff. (Jesper) -* Promote all to baseline -* Switch all to flicker/onion/whatever -* Add javascript confirmation for "make baseline" -* Make "single view" more stable diff --git a/tests/auto/other/atwrapper/atWrapper.cpp b/tests/auto/other/atwrapper/atWrapper.cpp deleted file mode 100644 index 8f623538f9..0000000000 --- a/tests/auto/other/atwrapper/atWrapper.cpp +++ /dev/null @@ -1,636 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - - -#include <atWrapper.h> -#include <datagenerator/datagenerator.h> - -#include <QString> -#include <QHash> -#include <QFile> -#include <QFtp> -#include <QObject> -#include <QHostInfo> -#include <QWidget> -#include <QImage> -#include <QtTest/QSignalSpy> -#include <QLibraryInfo> - -static const char *ArthurDir = "../../arthur"; - -#include <string.h> - -atWrapper::atWrapper() -{ - - // initTests(); - -} - -bool atWrapper::initTests(bool *haveBaseline) -{ - qDebug() << "Running test on buildkey:" << QLibraryInfo::buildKey() << " qt version:" << qVersion(); - - qDebug( "Initializing tests..." ); - - if (!loadConfig( QHostInfo::localHostName().split( "." ).first() + ".ini" )) - return false; - - //Reset the FTP environment where the results are stored - *haveBaseline = setupFTP(); - - // Retrieve the latest test result baseline from the FTP server. - downloadBaseline(); - return true; -} - -void atWrapper::downloadBaseline() -{ - - qDebug() << "Now downloading baseline..."; - - QFtp ftp; - - QObject::connect( &ftp, SIGNAL(listInfo(QUrlInfo)), this, SLOT(ftpMgetAddToList(QUrlInfo)) ); - - //Making sure that the needed local directories exist. - - QHashIterator<QString, QString> j(enginesToTest); - - while ( j.hasNext() ) - { - j.next(); - - QDir dir( output ); - - if ( !dir.cd( j.key() + ".baseline" ) ) - dir.mkdir( j.key() + ".baseline" ); - - } - - //FTP to the host specified in the config file, and retrieve the test result baseline. - ftp.connectToHost( ftpHost ); - ftp.login( ftpUser, ftpPass ); - - ftp.cd( ftpBaseDir ); - - QHashIterator<QString, QString> i(enginesToTest); - while ( i.hasNext() ) - { - i.next(); - mgetDirList.clear(); - mgetDirList << i.key() + ".baseline"; - ftp.cd( i.key() + ".baseline" ); - ftp.list(); - ftp.cd( ".." ); - - while ( ftp.hasPendingCommands() ) - QCoreApplication::instance()->processEvents(); - - ftpMgetDone( true ); - } - - ftp.close(); - ftp.close(); - - while ( ftp.hasPendingCommands() ) - QCoreApplication::instance()->processEvents(); - -} - -void atWrapper::ftpMgetAddToList( const QUrlInfo &urlInfo ) -{ - //Simply adding to the list of files to download. - mgetDirList << urlInfo.name(); - -} - -void atWrapper::ftpMgetDone( bool error) -{ - Q_UNUSED( error ); - - //Downloading the files listed in mgetDirList... - QFtp ftp; - ftp.connectToHost( ftpHost ); - ftp.login( ftpUser, ftpPass ); - - QFile* file; - - if ( mgetDirList.size() > 1 ) - for ( int i = 1; i < mgetDirList.size(); ++i ) - { - file = new QFile( QString( output ) + QLatin1Char('/') + mgetDirList.at( 0 ) - + QLatin1Char('/') + mgetDirList.at( i ) ); - if (file->open(QIODevice::WriteOnly)) { - ftp.get( ftpBaseDir + QLatin1Char('/') + mgetDirList.at( 0 ) + QLatin1Char('/') + mgetDirList.at( i ), file ); - ftp.list(); //Only there to fill up a slot in the pendingCommands queue. - while ( ftp.hasPendingCommands() ) - QCoreApplication::instance()->processEvents(); - file->close(); - } else { - qDebug() << "Couldn't open file for writing: " << file->fileName(); - } - } - - - while ( ftp.hasPendingCommands() ) - QCoreApplication::instance()->processEvents(); -} - -void atWrapper::uploadFailed( QString dir, QString filename, QByteArray filedata ) -{ - //Upload a failed test case image to the FTP server. - QFtp ftp; - ftp.connectToHost( ftpHost ); - ftp.login( ftpUser, ftpPass ); - - ftp.cd( ftpBaseDir ); - ftp.cd( dir ); - - ftp.put( filedata, filename, QFtp::Binary ); - - ftp.close(); - - while ( ftp.hasPendingCommands() ) - QCoreApplication::instance()->processEvents(); -} - -// returns false if no baseline exists -bool atWrapper::setupFTP() -{ - qDebug( "Setting up FTP environment" ); - - QString dir = ""; - ftpMkDir( ftpBaseDir ); - - ftpBaseDir += QLatin1Char('/') + QLibraryInfo::buildKey(); - - ftpMkDir( ftpBaseDir ); - - ftpBaseDir += QLatin1Char('/') + QString( qVersion() ); - - ftpMkDir( ftpBaseDir ); - - QHashIterator<QString, QString> i(enginesToTest); - QHashIterator<QString, QString> j(enginesToTest); - - bool haveBaseline = true; - //Creating the baseline directories for each engine - while ( i.hasNext() ) - { - i.next(); - //qDebug() << "Creating dir with key:" << i.key(); - ftpMkDir( ftpBaseDir + QLatin1Char('/') + QString( i.key() ) + ".failed" ); - ftpMkDir( ftpBaseDir + QLatin1Char('/') + QString( i.key() ) + ".diff" ); - if (!ftpMkDir( ftpBaseDir + QLatin1Char('/') + QString( i.key() ) + ".baseline" )) - haveBaseline = false; - } - - - QFtp ftp; - ftp.connectToHost( ftpHost ); - ftp.login( ftpUser, ftpPass ); - - ftp.cd( ftpBaseDir ); - //Deleting previous failed directory and all the files in it, then recreating it. - while ( j.hasNext() ) - { - j.next(); - rmDirList.clear(); - rmDirList << ftpBaseDir + QLatin1Char('/') + j.key() + ".failed/"; - ftpRmDir( j.key() + ".failed" ); - ftp.rmdir( j.key() + ".failed" ); - ftp.mkdir( j.key() + ".failed" ); - ftp.list(); - - while ( ftp.hasPendingCommands() ) - QCoreApplication::instance()->processEvents(); - - rmDirList.clear(); - rmDirList << ftpBaseDir + QLatin1Char('/') + j.key() + ".diff/"; - ftpRmDir( j.key() + ".diff" ); - ftp.rmdir( j.key() + ".diff" ); - ftp.mkdir( j.key() + ".diff" ); - ftp.list(); - - while ( ftp.hasPendingCommands() ) - QCoreApplication::instance()->processEvents(); - - } - - ftp.close(); - - while ( ftp.hasPendingCommands() ) - QCoreApplication::instance()->processEvents(); - - return haveBaseline; -} - -void atWrapper::ftpRmDir( QString dir ) -{ - //Hack to remove a populated directory. (caveat: containing only files and empty dirs, not recursive!) - qDebug() << "Now removing directory: " << dir; - QFtp ftp; - QObject::connect( &ftp, SIGNAL(listInfo(QUrlInfo)), this, SLOT(ftpRmDirAddToList(QUrlInfo)) ); - QObject::connect( &ftp, SIGNAL(done(bool)), this, SLOT(ftpRmDirDone(bool)) ); - - ftp.connectToHost( ftpHost ); - ftp.login( ftpUser, ftpPass ); - - ftp.list( ftpBaseDir + "/" + dir ); - ftp.close(); - ftp.close(); - - while ( ftp.hasPendingCommands() ) - QCoreApplication::instance()->processEvents(); -} - -void atWrapper::ftpRmDirDone( bool error ) -{ - //Deleting each file in the directory listning, rmDirList. - Q_UNUSED( error ); - - QFtp ftp; - ftp.connectToHost( ftpHost ); - ftp.login( ftpUser, ftpPass ); - - if ( rmDirList.size() > 1 ) - for (int i = 1; i < rmDirList.size(); ++i) - ftp.remove( rmDirList.at(0) + rmDirList.at( i ) ); - - ftp.close(); - - while ( ftp.hasPendingCommands() ) - QCoreApplication::instance()->processEvents(); -} - -// returns false if the directory already exists -bool atWrapper::ftpMkDir( QString dir ) -{ - //Simply used to avoid QFTP from bailing out and loosing a queue of commands. - // IE: conveniance. - QFtp ftp; - - QSignalSpy commandSpy(&ftp, SIGNAL(commandFinished(int,bool))); - - ftp.connectToHost( ftpHost ); - ftp.login( ftpUser, ftpPass ); - const int command = ftp.mkdir( dir ); - ftp.close(); - - while ( ftp.hasPendingCommands() ) - QCoreApplication::instance()->processEvents(); - - for (int i = 0; i < commandSpy.count(); ++i) - if (commandSpy.at(i).at(0) == command) - return commandSpy.at(i).at(1).toBool(); - - return false; -} - - -void atWrapper::ftpRmDirAddToList( const QUrlInfo &urlInfo ) -{ - //Just adding the file to the list for deletion - rmDirList << urlInfo.name(); -} - - -bool atWrapper::executeTests() -{ - qDebug("Executing the tests..."); - - QHashIterator<QString, QString> i(enginesToTest); - - DataGenerator generator; - - //Running datagenerator against all the frameworks specified in the config file. - while ( i.hasNext() ) - { - - i.next(); - - qDebug( "Now testing: " + i.key().toLatin1() ); - - char* params[13]; - //./bin/datagenerator -framework data/framework.ini -engine OpenGL -suite 1.1 -output outtest - - - QByteArray eng = i.key().toLatin1(); - QByteArray fwk = framework.toLatin1(); - QByteArray sut = suite.toLatin1(); - QByteArray out = output.toLatin1(); - QByteArray siz = size.toLatin1(); - QByteArray fill = fillColor.toLatin1(); - - params[1] = "-framework"; - params[2] = fwk.data(); - params[3] = "-engine"; - params[4] = eng.data(); - params[5] = "-suite"; - params[6] = sut.data(); - params[7] = "-output"; - params[8] = out.data(); - params[9] = "-size"; - params[10] = siz.data(); - params[11] = "-fill"; - params[12] = fill.data(); - - generator.run( 13, params ); - } - - return true; -} - -void atWrapper::createBaseline() -{ - qDebug( "Now uploading a baseline of only the latest test values" ); - - QHashIterator<QString, QString> i(enginesToTest); - - QDir dir( output ); - QFtp ftp; - ftp.connectToHost( ftpHost ); - ftp.login( ftpUser, ftpPass ); - ftp.cd( ftpBaseDir ); - //Upload all the latest test results to the FTP server's baseline directory. - while ( i.hasNext() ) - { - - i.next(); - dir.cd( i.key() ); - ftp.cd( i.key() + ".baseline" ); - dir.setFilter(QDir::Files | QDir::Hidden | QDir::NoSymLinks); - dir.setNameFilters( QStringList() << "*.png" ); - QFileInfoList list = dir.entryInfoList(); - dir.cd( ".." ); - for (int n = 0; n < list.size(); n++) - { - QFileInfo fileInfo = list.at( n ); - QFile file( QString( output ) + QLatin1Char('/') + i.key() + QLatin1Char('/') + fileInfo.fileName() ); - file.open( QIODevice::ReadOnly ); - QByteArray fileData = file.readAll(); - //qDebug() << "Sending up:" << fileInfo.fileName() << "with file size" << fileData.size(); - file.close(); - ftp.put( fileData, fileInfo.fileName(), QFtp::Binary ); - } - - ftp.cd( ".." ); - } - - ftp.close(); - - while ( ftp.hasPendingCommands() ) - QCoreApplication::instance()->processEvents(); -} - -bool atWrapper::compare() -{ - qDebug( "Now comparing the results to the baseline" ); - - QHashIterator<QString, QString> i(enginesToTest); - - while ( i.hasNext() ) - { - i.next(); - - compareDirs( output , i.key() ); - - } - - return true; -} - -void atWrapper::compareDirs( QString basedir, QString target ) -{ - - QDir dir( basedir ); - - /* The following should be redundant now. - - if ( !dir.cd( target + ".failed" ) ) - dir.mkdir( target + ".failed" ); - else - dir.cdUp(); - - */ - - if ( !dir.cd( target + ".diff" ) ) - dir.mkdir( target + ".diff" ); - else - dir.cdUp(); - - - - //Perform comparisons between the two directories. - - dir.setFilter(QDir::Files | QDir::Hidden | QDir::NoSymLinks); - dir.setNameFilters( QStringList() << "*.png" ); - dir.cd( target + ".baseline" ); - QFileInfoList list = dir.entryInfoList(); - - for (int i = 0; i < list.size(); ++i) - { - QFileInfo fileInfo = list.at(i); - diff ( basedir, target, fileInfo.fileName() ); - } -} - -bool atWrapper::diff( QString basedir, QString dir, QString target ) -{ - //Comparing the two specified files, and then uploading them to - //the ftp server if they differ - - basedir += QLatin1Char('/') + dir; - QString one = basedir + ".baseline/" + target; - QString two = basedir + QLatin1Char('/') + target; - - QFile file( one ); - - file.open( QIODevice::ReadOnly ); - QByteArray contentsOfOne = file.readAll(); - file.close(); - - file.setFileName( two ); - - file.open( QIODevice::ReadOnly ); - QByteArray contentsOfTwo = file.readAll(); - file.close(); - - if ( contentsOfTwo.size() == 0 ) - { - qDebug() << "No test result found for baseline: " << one; - file.setFileName( one ); - file.open( QIODevice::ReadOnly ); - file.copy( basedir + ".failed/" + target + "_missing" ); - uploadFailed( dir + ".failed", target + "_missing", contentsOfTwo ); - return false; - } - - - if ( ( memcmp( contentsOfOne, contentsOfTwo, contentsOfOne.size() ) ) == 0 ) - return true; - else - { - qDebug() << "Sorry, the result did not match: " << one; - file.setFileName( two ); - file.open( QIODevice::ReadOnly ); - file.copy( basedir + ".failed/" + target ); - file.close(); - uploadFailed( dir + ".failed", target, contentsOfTwo ); - uploadDiff( basedir, dir, target ); - return false; - } -} - -void atWrapper::uploadDiff( QString basedir, QString dir, QString filename ) -{ - - qDebug() << basedir; - QImage im1( basedir + ".baseline/" + filename ); - QImage im2( basedir + QLatin1Char('/') + filename ); - - QImage im3(im1.size(), QImage::Format_ARGB32); - - im1 = im1.convertToFormat(QImage::Format_ARGB32); - im2 = im2.convertToFormat(QImage::Format_ARGB32); - - for ( int y=0; y<im1.height(); ++y ) - { - uint *s = (uint *) im1.scanLine(y); - uint *d = (uint *) im2.scanLine(y); - uint *w = (uint *) im3.scanLine(y); - - for ( int x=0; x<im1.width(); ++x ) - { - if (*s != *d) - *w = 0xff000000; - else - *w = 0xffffffff; - w++; - s++; - d++; - } - } - - im3.save( basedir + ".diff/" + filename ,"PNG"); - - QFile file( basedir + ".diff/" + filename ); - file.open( QIODevice::ReadOnly ); - QByteArray contents = file.readAll(); - file.close(); - - uploadFailed( dir + ".diff", filename, contents ); - -} - -bool atWrapper::loadConfig( QString path ) -{ - qDebug() << "Loading config file from ... " << path; - configPath = path; - //If there is no config file, don't proceed; - if ( !QFile::exists( path ) ) - { - return false; - } - - - QSettings settings( path, QSettings::IniFormat, this ); - - - //FIXME: Switch to QStringList or something, hash is not needed! - int numEngines = settings.beginReadArray("engines"); - - for ( int i = 0; i < numEngines; ++i ) - { - settings.setArrayIndex(i); - enginesToTest.insert( settings.value( "engine" ).toString(), "Info here please :p" ); - } - - settings.endArray(); - - framework = QString(ArthurDir) + QDir::separator() + settings.value( "framework" ).toString(); - suite = settings.value( "suite" ).toString(); - output = settings.value( "output" ).toString(); - size = settings.value( "size", "480,360" ).toString(); - fillColor = settings.value( "fill", "white" ).toString(); - ftpUser = settings.value( "ftpUser" ).toString(); - ftpPass = settings.value( "ftpPass" ).toString(); - ftpHost = settings.value( "ftpHost" ).toString(); - ftpBaseDir = settings.value( "ftpBaseDir" ).toString(); - - - QDir::current().mkdir( output ); - - output += QLatin1Char('/') + QLibraryInfo::buildKey(); - - QDir::current().mkdir( output ); - - output += QLatin1Char('/') + QString( qVersion() ); - - QDir::current().mkdir( output ); - - - ftpBaseDir += QLatin1Char('/') + QHostInfo::localHostName().split( QLatin1Char('.') ).first(); - - -/* - framework = "data/framework.ini"; - suite = "1.1"; - output = "testresults"; - ftpUser = "anonymous"; - ftpPass = "anonymouspass"; - ftpHost = "kramer.troll.no"; - ftpBaseDir = "/arthurtest"; -*/ - return true; -} - -bool atWrapper::runAutoTests() -{ - //SVG needs this widget... - QWidget dummy; - - bool haveBaseline = false; - - if (!initTests(&haveBaseline)) - return false; - executeTests(); - - if ( !haveBaseline ) - { - qDebug( " First run! Creating baseline..." ); - createBaseline(); - } - else - { - qDebug( " Comparing results..." ); - compare(); - } - return true; -} diff --git a/tests/auto/other/atwrapper/atWrapper.h b/tests/auto/other/atwrapper/atWrapper.h deleted file mode 100644 index dab2b579e3..0000000000 --- a/tests/auto/other/atwrapper/atWrapper.h +++ /dev/null @@ -1,80 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#ifndef ATWRAPPER_H -#define ATWRAPPER_H - -#include <QHash> -#include <QString> -#include <QUrlInfo> -#include <QColor> - -class atWrapper : public QObject -{ - Q_OBJECT - - public: - atWrapper(); - bool runAutoTests(); - - private: - bool executeTests(); - bool initTests(bool *haveBaseline); - bool compare(); - void createBaseline(); - bool loadConfig( QString ); - void compareDirs( QString, QString ); - bool diff( QString, QString, QString ); - void downloadBaseline(); - void uploadFailed( QString, QString, QByteArray ); - bool ftpMkDir( QString ); - void ftpRmDir( QString ); - bool setupFTP(); - void uploadDiff( QString, QString, QString ); - - QHash<QString, QString> enginesToTest; - QString framework; - QString suite; - QString output; - QString size; - QString ftpUser; - QString ftpPass; - QString ftpHost; - QString ftpBaseDir; - QList<QString> rmDirList; - QList<QString> mgetDirList; - QString configPath; - QString fillColor; - - private slots: - void ftpRmDirAddToList( const QUrlInfo &urlInfo ); - void ftpRmDirDone( bool ); - void ftpMgetAddToList( const QUrlInfo &urlInfo ); - void ftpMgetDone( bool ); -}; - -#endif diff --git a/tests/auto/other/atwrapper/atWrapper.pro b/tests/auto/other/atwrapper/atWrapper.pro deleted file mode 100644 index 1617ae89d1..0000000000 --- a/tests/auto/other/atwrapper/atWrapper.pro +++ /dev/null @@ -1,21 +0,0 @@ -ARTHUR=$$QT_SOURCE_TREE/tests/arthur -COMMON_FOLDER = $$ARTHUR/common -include($$ARTHUR/arthurtester.pri) -INCLUDEPATH += $$ARTHUR -DEFINES += SRCDIR=\\\"$$PWD\\\" - -QT += xml svg network testlib - -qtHaveModule(opengl): QT += opengl - -include($$ARTHUR/datagenerator/datagenerator.pri) - -CONFIG += testcase - -HEADERS += atWrapper.h -SOURCES += atWrapperAutotest.cpp atWrapper.cpp - -TARGET = tst_atwrapper - -#include($$COMMON_FOLDER/common.pri) -DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0 diff --git a/tests/auto/other/atwrapper/atWrapperAutotest.cpp b/tests/auto/other/atwrapper/atWrapperAutotest.cpp deleted file mode 100644 index ea40cc92b9..0000000000 --- a/tests/auto/other/atwrapper/atWrapperAutotest.cpp +++ /dev/null @@ -1,65 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - - -#include <QtTest/QtTest> -#include "atWrapper.h" -#include <QApplication> - -class atWrapperAutotest: public QObject -{ - -Q_OBJECT - -public slots: - void init(); - -private slots: - void runTest(); -}; - -void atWrapperAutotest::init() -{ -#ifndef Q_OS_IRIX - QDir::setCurrent(SRCDIR); -#endif -} - -void atWrapperAutotest::runTest() -{ - - //QApplication app(argc, argv); - - atWrapper wrapper; - if (!wrapper.runAutoTests()) - QSKIP("Arthur not tested on this machine"); - QVERIFY(true); -} - -QTEST_MAIN(atWrapperAutotest) -#include "atWrapperAutotest.moc" diff --git a/tests/auto/other/atwrapper/desert.ini b/tests/auto/other/atwrapper/desert.ini deleted file mode 100644 index 6d8605252d..0000000000 --- a/tests/auto/other/atwrapper/desert.ini +++ /dev/null @@ -1,14 +0,0 @@ -[General] -framework=data/framework.ini -ftpBaseDir=/arthurtest -ftpHost=kramer.troll.no -ftpPass=anonymouspass -ftpUser=anonymous -output=testresults -suite=1.1 - -[engines] -1\engine=NativeXRender -2\engine=PDF -3\engine=Raster -size=3 diff --git a/tests/auto/other/atwrapper/ephron.ini b/tests/auto/other/atwrapper/ephron.ini deleted file mode 100644 index eeccb3b6ef..0000000000 --- a/tests/auto/other/atwrapper/ephron.ini +++ /dev/null @@ -1,14 +0,0 @@ -[General] -framework=data/framework.ini -ftpBaseDir=/arthurtest -ftpHost=kramer.troll.no -ftpPass=anonymouspass -ftpUser=anonymous -output=testresults -suite=oxygen -size=256 -fill=transparent - -[engines] -1\engine=Raster -size=1 diff --git a/tests/auto/other/atwrapper/gullgubben.ini b/tests/auto/other/atwrapper/gullgubben.ini deleted file mode 100644 index 3a664dddd5..0000000000 --- a/tests/auto/other/atwrapper/gullgubben.ini +++ /dev/null @@ -1,12 +0,0 @@ -[General] -framework=data/framework.ini -ftpBaseDir=/arthurtest -ftpHost=kramer.troll.no -ftpPass=anonymouspass -ftpUser=anonymous -output=testresults -suite=1.1 - -[engines] -1\engine=OpenGL -size=1 diff --git a/tests/auto/other/atwrapper/honshu.ini b/tests/auto/other/atwrapper/honshu.ini deleted file mode 100644 index 3b7751a128..0000000000 --- a/tests/auto/other/atwrapper/honshu.ini +++ /dev/null @@ -1,16 +0,0 @@ -[General] -framework=data/framework.ini -ftpBaseDir=/arthurtest -ftpHost=kramer.troll.no -ftpPass=anonymouspass -ftpUser=anonymous -output=testresults -suite=1.1 - -[engines] -1\engine=NativeWin32 -2\engine=PDF -3\engine=Raster -4\engine=OpenGL -5\engine=WinPrint -size=5 diff --git a/tests/auto/other/atwrapper/kramer.ini b/tests/auto/other/atwrapper/kramer.ini deleted file mode 100644 index 289d8a8b7e..0000000000 --- a/tests/auto/other/atwrapper/kramer.ini +++ /dev/null @@ -1,12 +0,0 @@ -[General] -framework=data/framework.ini -ftpBaseDir=/arthurtest -ftpHost=kramer.troll.no -ftpPass=anonymouspass -ftpUser=anonymous -output=testresults -suite=1.1 - -[engines] -1\engine=Raster -size=1 diff --git a/tests/auto/other/atwrapper/scruffy.ini b/tests/auto/other/atwrapper/scruffy.ini deleted file mode 100644 index 329f537e6f..0000000000 --- a/tests/auto/other/atwrapper/scruffy.ini +++ /dev/null @@ -1,15 +0,0 @@ -[General] -framework=data/framework.ini -ftpBaseDir=/arthurtest -ftpHost=kramer.nokia.troll.no -ftpPass=anonymouspass -ftpUser=anonymous -output=testresults -suite=1.1 - -[engines] -1\engine=NativeMac -2\engine=PDF -3\engine=Raster -4\engine=OpenGL -size=4 diff --git a/tests/auto/other/atwrapper/spareribs.ini b/tests/auto/other/atwrapper/spareribs.ini deleted file mode 100644 index 78ff9e985f..0000000000 --- a/tests/auto/other/atwrapper/spareribs.ini +++ /dev/null @@ -1,14 +0,0 @@ -[General] -framework=data/framework.ini -ftpBaseDir=/arthurtest -ftpHost=kramer.troll.no -ftpPass=anonymouspass -ftpUser=anonymous -output=testresults -suite=1.1 - -[engines] -1\engine=NativeWin32 -2\engine=PDF -3\engine=Raster -size=3 diff --git a/tests/auto/other/atwrapper/titan.ini b/tests/auto/other/atwrapper/titan.ini deleted file mode 100644 index 3a0b0dfd31..0000000000 --- a/tests/auto/other/atwrapper/titan.ini +++ /dev/null @@ -1,13 +0,0 @@ -[General] -framework=data/framework.ini -ftpBaseDir=/arthurtest -ftpHost=kramer.troll.no -ftpPass=anonymouspass -ftpUser=anonymous -output=testresults -suite=1.1 - -[engines] -1\engine=NativeXRender -2\engine=OpenGL -size=2 diff --git a/tests/auto/other/other.pro b/tests/auto/other/other.pro index 0babac4b6f..a12f08488d 100644 --- a/tests/auto/other/other.pro +++ b/tests/auto/other/other.pro @@ -2,7 +2,6 @@ TEMPLATE=subdirs QT_FOR_CONFIG += gui-private SUBDIRS=\ - # atwrapper \ # QTBUG-19452 compiler \ gestures \ lancelot \ |