diff options
author | Liang Qi <liang.qi@theqtcompany.com> | 2015-04-27 21:36:32 +0200 |
---|---|---|
committer | Liang Qi <liang.qi@theqtcompany.com> | 2015-04-27 21:36:32 +0200 |
commit | 1c8451bdbbd6ca909dfc5b96a24be909810522fc (patch) | |
tree | 9cc69a4794e23f7224d75fc2323fc70e294a9454 /tests | |
parent | 7ebec0fa848de299d4cdee06ccc611ee46494fbf (diff) | |
parent | 0635b1a69dd666f5eed4b096895bd80b1a9420ff (diff) |
Merge remote-tracking branch 'origin/5.5' into dev
Conflicts:
src/tools/qdoc/tree.cpp
tests/auto/gui/painting/qcolor/tst_qcolor.cpp
Change-Id: Iaa78f601a63191fa643aabf853520f913f2f0fdc
Diffstat (limited to 'tests')
21 files changed, 370 insertions, 64 deletions
diff --git a/tests/auto/corelib/io/qfilesystemwatcher/tst_qfilesystemwatcher.cpp b/tests/auto/corelib/io/qfilesystemwatcher/tst_qfilesystemwatcher.cpp index 458dbc532d..0ebfd2ae35 100644 --- a/tests/auto/corelib/io/qfilesystemwatcher/tst_qfilesystemwatcher.cpp +++ b/tests/auto/corelib/io/qfilesystemwatcher/tst_qfilesystemwatcher.cpp @@ -36,6 +36,9 @@ #include <QTemporaryDir> #include <QFileSystemWatcher> +#include <QElapsedTimer> +#include <QTextStream> +#include <QDir> /* All tests need to run in temporary directories not used * by the application to avoid non-deterministic failures on Windows @@ -387,6 +390,60 @@ void tst_QFileSystemWatcher::addPaths() QCOMPARE(watcher.addPaths(paths), QStringList()); } +// A signal spy that records the paths and times received for better diagnostics. +class FileSystemWatcherSpy : public QObject { + Q_OBJECT +public: + enum Mode { + SpyOnDirectoryChanged, + SpyOnFileChanged + }; + + explicit FileSystemWatcherSpy(QFileSystemWatcher *watcher, Mode mode) + { + connect(watcher, mode == SpyOnDirectoryChanged ? + &QFileSystemWatcher::directoryChanged : &QFileSystemWatcher::fileChanged, + this, &FileSystemWatcherSpy::spySlot); + m_elapsedTimer.start(); + } + + int count() const { return m_entries.size(); } + void clear() + { + m_entries.clear(); + m_elapsedTimer.restart(); + } + + QByteArray receivedFilesMessage() const + { + QString result; + QTextStream str(&result); + str << "At " << m_elapsedTimer.elapsed() << "ms, received " + << count() << " changes: "; + for (int i =0, e = m_entries.size(); i < e; ++i) { + if (i) + str << ", "; + str << m_entries.at(i).timeStamp << "ms: " << QDir::toNativeSeparators(m_entries.at(i).path); + } + return result.toLocal8Bit(); + } + +private slots: + void spySlot(const QString &p) { m_entries.append(Entry(m_elapsedTimer.elapsed(), p)); } + +private: + struct Entry { + Entry() : timeStamp(0) {} + Entry(qint64 t, const QString &p) : timeStamp(t), path(p) {} + + qint64 timeStamp; + QString path; + }; + + QElapsedTimer m_elapsedTimer; + QList<Entry> m_entries; +}; + void tst_QFileSystemWatcher::removePaths() { QFileSystemWatcher watcher; @@ -438,9 +495,8 @@ void tst_QFileSystemWatcher::watchFileAndItsDirectory() QVERIFY(watcher.addPath(testFileName)); QSignalSpy fileChangedSpy(&watcher, &QFileSystemWatcher::fileChanged); - QSignalSpy dirChangedSpy(&watcher, &QFileSystemWatcher::directoryChanged); + FileSystemWatcherSpy dirChangedSpy(&watcher, FileSystemWatcherSpy::SpyOnDirectoryChanged); QVERIFY(fileChangedSpy.isValid()); - QVERIFY(dirChangedSpy.isValid()); QEventLoop eventLoop; QTimer timer; connect(&timer, SIGNAL(timeout()), &eventLoop, SLOT(quit())); @@ -460,7 +516,7 @@ void tst_QFileSystemWatcher::watchFileAndItsDirectory() #endif QTRY_VERIFY(fileChangedSpy.count() > 0); - QCOMPARE(dirChangedSpy.count(), 0); + QVERIFY2(dirChangedSpy.count() == 0, dirChangedSpy.receivedFilesMessage()); fileChangedSpy.clear(); QFile secondFile(secondFileName); @@ -640,13 +696,14 @@ private: // emitted with the destination path instead of the starting path void tst_QFileSystemWatcher::signalsEmittedAfterFileMoved() { + const int fileCount = 10; QTemporaryDir temporaryDirectory(m_tempDirPattern); QVERIFY(temporaryDirectory.isValid()); QDir testDir(temporaryDirectory.path()); QVERIFY(testDir.mkdir("movehere")); QString movePath = testDir.filePath("movehere"); - for (int i = 0; i < 10; i++) { + for (int i = 0; i < fileCount; ++i) { QFile f(testDir.filePath(QString("test%1.txt").arg(i))); QVERIFY(f.open(QIODevice::WriteOnly)); f.write(QByteArray("i am ") + QByteArray::number(i)); @@ -659,6 +716,7 @@ void tst_QFileSystemWatcher::signalsEmittedAfterFileMoved() // add files to watcher QFileInfoList files = testDir.entryInfoList(QDir::Files | QDir::NoSymLinks); + QCOMPARE(files.size(), fileCount); foreach (const QFileInfo &finfo, files) QVERIFY(watcher.addPath(finfo.absoluteFilePath())); @@ -667,14 +725,16 @@ void tst_QFileSystemWatcher::signalsEmittedAfterFileMoved() connect(&watcher, SIGNAL(fileChanged(QString)), &signalReceiver, SLOT(fileChanged(QString))); // watch signals - QSignalSpy changedSpy(&watcher, &QFileSystemWatcher::fileChanged); - QVERIFY(changedSpy.isValid()); + FileSystemWatcherSpy changedSpy(&watcher, FileSystemWatcherSpy::SpyOnFileChanged); + QCOMPARE(changedSpy.count(), 0); // move files to second directory foreach (const QFileInfo &finfo, files) QVERIFY(testDir.rename(finfo.fileName(), QString("movehere/%2").arg(finfo.fileName()))); - QTRY_COMPARE(changedSpy.count(), 10); + QCoreApplication::processEvents(); + QVERIFY2(changedSpy.count() <= fileCount, changedSpy.receivedFilesMessage()); + QTRY_COMPARE(changedSpy.count(), fileCount); } #endif // QT_NO_FILESYSTEMWATCHER diff --git a/tests/auto/corelib/io/qlockfile/tst_qlockfile.cpp b/tests/auto/corelib/io/qlockfile/tst_qlockfile.cpp index 90f65e9dbc..bef3d3a012 100644 --- a/tests/auto/corelib/io/qlockfile/tst_qlockfile.cpp +++ b/tests/auto/corelib/io/qlockfile/tst_qlockfile.cpp @@ -36,8 +36,11 @@ #include <QtConcurrentRun> #include <qlockfile.h> #include <qtemporarydir.h> +#include <qsysinfo.h> #if defined(Q_OS_UNIX) && !defined(Q_OS_VXWORKS) #include <unistd.h> +#elif defined(Q_OS_WIN) && !defined(Q_OS_WINCE) && !defined(Q_OS_WINRT) +# include <qt_windows.h> #endif class tst_QLockFile : public QObject @@ -58,6 +61,7 @@ private slots: void staleLongLockFromBusyProcess(); void staleLockRace(); void noPermissions(); + void noPermissionsWindows(); public: QString m_helperApp; @@ -415,5 +419,66 @@ void tst_QLockFile::noPermissions() QCOMPARE(int(lockFile.error()), int(QLockFile::PermissionError)); } +enum ProcessProperty { + ElevatedProcess = 0x1, + VirtualStore = 0x2 +}; + +Q_DECLARE_FLAGS(ProcessProperties, ProcessProperty) +Q_DECLARE_OPERATORS_FOR_FLAGS(ProcessProperties) + +static inline ProcessProperties processProperties() +{ + ProcessProperties result; +#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) && !defined(Q_OS_WINRT) + HANDLE processToken = NULL; + if (OpenProcessToken(GetCurrentProcess(), TOKEN_QUERY, &processToken)) { + DWORD elevation; // struct containing a DWORD, not present in some MinGW headers. + DWORD cbSize = sizeof(elevation); + if (GetTokenInformation(processToken, TokenElevation, &elevation, cbSize, &cbSize) + && elevation) { + result |= ElevatedProcess; + } + // Check for UAC virtualization (compatibility mode for old software + // allowing it to write to system folders by mirroring them under + // "\Users\...\AppData\Local\VirtualStore\", which is typically the case + // for MinGW). + DWORD virtualStoreEnabled = 0; + cbSize = sizeof(virtualStoreEnabled); + if (GetTokenInformation(processToken, TokenVirtualizationEnabled, &virtualStoreEnabled, cbSize, &cbSize) + && virtualStoreEnabled) { + result |= VirtualStore; + } + CloseHandle(processToken); + } +#endif + return result; +} + +void tst_QLockFile::noPermissionsWindows() +{ + // Windows: Do the permissions test in a system directory in which + // files cannot be created. +#if !defined(Q_OS_WIN) || defined(Q_OS_WINCE) || defined(Q_OS_WINRT) + QSKIP("This test is for desktop Windows only"); +#endif +#ifdef Q_OS_WIN + if (QSysInfo::windowsVersion() < QSysInfo::WV_WINDOWS7) + QSKIP("This test requires at least Windows 7"); +#endif + if (const int p = processProperties()) { + const QByteArray message = "This test cannot be run (properties=0x" + + QByteArray::number(p, 16) + ')'; + QSKIP(message.constData()); + } + + const QString fileName = QFile::decodeName(qgetenv("ProgramFiles")) + + QLatin1Char('/') + QCoreApplication::applicationName() + + QDateTime::currentDateTime().toString(QStringLiteral("yyMMddhhmm")); + QLockFile lockFile(fileName); + QVERIFY(!lockFile.lock()); + QCOMPARE(int(lockFile.error()), int(QLockFile::PermissionError)); +} + QTEST_MAIN(tst_QLockFile) #include "tst_qlockfile.moc" diff --git a/tests/auto/corelib/io/qlockfile/tst_qlockfile.pro b/tests/auto/corelib/io/qlockfile/tst_qlockfile.pro index 2f7009b736..6eb72343bc 100644 --- a/tests/auto/corelib/io/qlockfile/tst_qlockfile.pro +++ b/tests/auto/corelib/io/qlockfile/tst_qlockfile.pro @@ -4,3 +4,4 @@ TARGET = tst_qlockfile SOURCES += tst_qlockfile.cpp QT = core testlib concurrent +win32:!wince:!winrt:LIBS += -ladvapi32 diff --git a/tests/auto/corelib/io/qresourceengine/qresourceengine.pro b/tests/auto/corelib/io/qresourceengine/qresourceengine.pro index 92d0952b89..64f5cb46e0 100644 --- a/tests/auto/corelib/io/qresourceengine/qresourceengine.pro +++ b/tests/auto/corelib/io/qresourceengine/qresourceengine.pro @@ -10,6 +10,7 @@ runtime_resource.depends = $$PWD/testqrc/test.qrc runtime_resource.commands = $$QMAKE_RCC -root /runtime_resource/ -binary $${runtime_resource.depends} -o $${runtime_resource.target} QMAKE_EXTRA_TARGETS = runtime_resource PRE_TARGETDEPS += $${runtime_resource.target} +QMAKE_DISTCLEAN += $${runtime_resource.target} TESTDATA += \ parentdir.txt \ diff --git a/tests/auto/corelib/statemachine/qstate/tst_qstate.cpp b/tests/auto/corelib/statemachine/qstate/tst_qstate.cpp index 1e885ddf92..ac3374b6a3 100644 --- a/tests/auto/corelib/statemachine/qstate/tst_qstate.cpp +++ b/tests/auto/corelib/statemachine/qstate/tst_qstate.cpp @@ -41,24 +41,14 @@ class tst_QState : public QObject { Q_OBJECT -public: - tst_QState(); - private slots: void assignProperty(); void assignPropertyTwice(); void historyInitialState(); void transitions(); void privateSignals(); - -private: - bool functionCalled; }; -tst_QState::tst_QState() : functionCalled(false) -{ -} - class TestClass: public QObject { Q_OBJECT diff --git a/tests/auto/gui/image/qimage/tst_qimage.cpp b/tests/auto/gui/image/qimage/tst_qimage.cpp index 525d5b33a0..5691a654d7 100644 --- a/tests/auto/gui/image/qimage/tst_qimage.cpp +++ b/tests/auto/gui/image/qimage/tst_qimage.cpp @@ -155,6 +155,9 @@ private slots: void inplaceMirrored_data(); void inplaceMirrored(); + void inplaceMirroredOdd_data(); + void inplaceMirroredOdd(); + void inplaceRgbMirrored(); void inplaceConversion_data(); @@ -2471,6 +2474,54 @@ void tst_QImage::inplaceMirrored() #endif } +void tst_QImage::inplaceMirroredOdd_data() +{ + QTest::addColumn<QImage::Format>("format"); + QTest::addColumn<bool>("swap_vertical"); + QTest::addColumn<bool>("swap_horizontal"); + + QTest::newRow("Format_ARGB32, vertical") << QImage::Format_ARGB32 << true << false; + QTest::newRow("Format_RGB888, vertical") << QImage::Format_RGB888 << true << false; + QTest::newRow("Format_RGB16, vertical") << QImage::Format_RGB16 << true << false; + + QTest::newRow("Format_ARGB32, horizontal") << QImage::Format_ARGB32 << false << true; + QTest::newRow("Format_RGB888, horizontal") << QImage::Format_RGB888 << false << true; + QTest::newRow("Format_RGB16, horizontal") << QImage::Format_RGB16 << false << true; + + QTest::newRow("Format_ARGB32, horizontal+vertical") << QImage::Format_ARGB32 << true << true; + QTest::newRow("Format_RGB888, horizontal+vertical") << QImage::Format_RGB888 << true << true; + QTest::newRow("Format_RGB16, horizontal+vertical") << QImage::Format_RGB16 << true << true; +} + +void tst_QImage::inplaceMirroredOdd() +{ +#if defined(Q_COMPILER_REF_QUALIFIERS) + QFETCH(QImage::Format, format); + QFETCH(bool, swap_vertical); + QFETCH(bool, swap_horizontal); + + QImage image(15, 15, format); + + for (int i = 0; i < image.height(); ++i) + for (int j = 0; j < image.width(); ++j) + image.setPixel(j, i, qRgb(j*16, i*16, 0)); + + const uchar* originalPtr = image.constScanLine(0); + + QImage imageMirrored = std::move(image).mirrored(swap_horizontal, swap_vertical); + for (int i = 0; i < imageMirrored.height(); ++i) { + int mirroredI = swap_vertical ? (imageMirrored.height() - i - 1) : i; + for (int j = 0; j < imageMirrored.width(); ++j) { + int mirroredJ = swap_horizontal ? (imageMirrored.width() - j - 1) : j; + QRgb mirroredColor = imageMirrored.pixel(mirroredJ, mirroredI); + QCOMPARE(qRed(mirroredColor) & 0xF8, j * 16); + QCOMPARE(qGreen(mirroredColor) & 0xF8, i * 16); + } + } + QCOMPARE(imageMirrored.constScanLine(0), originalPtr); +#endif +} + void tst_QImage::inplaceRgbMirrored() { #if defined(Q_COMPILER_REF_QUALIFIERS) diff --git a/tests/auto/gui/painting/qcolor/tst_qcolor.cpp b/tests/auto/gui/painting/qcolor/tst_qcolor.cpp index ca9f6cb9f4..cf0d82f3f7 100644 --- a/tests/auto/gui/painting/qcolor/tst_qcolor.cpp +++ b/tests/auto/gui/painting/qcolor/tst_qcolor.cpp @@ -38,6 +38,7 @@ #include <qcolor.h> #include <qdebug.h> +#include <private/qdrawingprimitive_sse2_p.h> #include <qrgba64.h> class tst_QColor : public QObject @@ -104,6 +105,7 @@ private slots: void achromaticHslHue(); void premultiply(); + void unpremultiply_sse4(); void qrgba64(); void qrgba64Premultiply(); void qrgba64Equivalence(); @@ -1449,6 +1451,23 @@ void tst_QColor::premultiply() } } +void tst_QColor::unpremultiply_sse4() +{ + // Tests that qUnpremultiply_sse4 returns the same as qUnpremultiply. +#if QT_COMPILER_SUPPORTS_HERE(SSE4_1) + if (qCpuHasFeature(SSE4_1)) { + for (uint a = 0; a < 256; a++) { + for (uint c = 0; c <= a; c++) { + QRgb p = qRgba(c, a-c, c, a); + QCOMPARE(qUnpremultiply(p), qUnpremultiply_sse4(p)); + } + } + return; + } +#endif + QSKIP("SSE4 not supported on this CPU."); +} + void tst_QColor::qrgba64() { QRgba64 rgb64 = QRgba64::fromRgba(0x22, 0x33, 0x44, 0xff); diff --git a/tests/auto/network/kernel/qhostinfo/BLACKLIST b/tests/auto/network/kernel/qhostinfo/BLACKLIST new file mode 100644 index 0000000000..ea4b64d7c2 --- /dev/null +++ b/tests/auto/network/kernel/qhostinfo/BLACKLIST @@ -0,0 +1,3 @@ +# QTBUG-23837 +[abortHostLookupInDifferentThread] +opensuse-13.1 64bit diff --git a/tests/auto/network/kernel/qhostinfo/qhostinfo.pro b/tests/auto/network/kernel/qhostinfo/qhostinfo.pro index a95a6bc2d6..4fca7950dd 100644 --- a/tests/auto/network/kernel/qhostinfo/qhostinfo.pro +++ b/tests/auto/network/kernel/qhostinfo/qhostinfo.pro @@ -14,5 +14,3 @@ wince*: { # needed for getaddrinfo with official MinGW mingw:DEFINES += _WIN32_WINNT=0x0501 - -linux-*:CONFIG+=insignificant_test # QTBUG-23837 - test is unstable diff --git a/tests/auto/tools/moc/tst_moc.cpp b/tests/auto/tools/moc/tst_moc.cpp index 08dc9581e1..00e5c60b29 100644 --- a/tests/auto/tools/moc/tst_moc.cpp +++ b/tests/auto/tools/moc/tst_moc.cpp @@ -83,6 +83,10 @@ QT_USE_NAMESPACE template <bool b> struct QTBUG_31218 {}; struct QTBUG_31218_Derived : QTBUG_31218<-1<0> {}; +#if defined(Q_MOC_RUN) + class QTBUG_45790 : Bug() { }; +#endif + struct MyStruct {}; struct MyStruct2 {}; diff --git a/tests/auto/tools/uic/baseline/addtorrentform.ui.h b/tests/auto/tools/uic/baseline/addtorrentform.ui.h index 29bae9735c..5aca0c4e47 100644 --- a/tests/auto/tools/uic/baseline/addtorrentform.ui.h +++ b/tests/auto/tools/uic/baseline/addtorrentform.ui.h @@ -97,7 +97,6 @@ public: browseTorrents = new QPushButton(groupBox); browseTorrents->setObjectName(QStringLiteral("browseTorrents")); - browseTorrents->setDefault(true); gridLayout->addWidget(browseTorrents, 0, 3, 1, 1); @@ -205,6 +204,9 @@ public: QObject::connect(okButton, SIGNAL(clicked()), AddTorrentFile, SLOT(accept())); QObject::connect(cancelButton, SIGNAL(clicked()), AddTorrentFile, SLOT(reject())); + browseTorrents->setDefault(true); + + QMetaObject::connectSlotsByName(AddTorrentFile); } // setupUi diff --git a/tests/auto/tools/uic/baseline/config.ui.h b/tests/auto/tools/uic/baseline/config.ui.h index 0775c02346..2d9003b4b9 100644 --- a/tests/auto/tools/uic/baseline/config.ui.h +++ b/tests/auto/tools/uic/baseline/config.ui.h @@ -688,7 +688,6 @@ public: buttonOk = new QPushButton(Config); buttonOk->setObjectName(QStringLiteral("buttonOk")); buttonOk->setAutoDefault(true); - buttonOk->setDefault(true); hboxLayout3->addWidget(buttonOk); @@ -706,6 +705,9 @@ public: QObject::connect(size_width, SIGNAL(valueChanged(int)), size_custom, SLOT(click())); QObject::connect(size_height, SIGNAL(valueChanged(int)), size_custom, SLOT(click())); + buttonOk->setDefault(true); + + QMetaObject::connectSlotsByName(Config); } // setupUi diff --git a/tests/auto/tools/uic/baseline/finddialog.ui.h b/tests/auto/tools/uic/baseline/finddialog.ui.h index 50595edc8a..259d36569f 100644 --- a/tests/auto/tools/uic/baseline/finddialog.ui.h +++ b/tests/auto/tools/uic/baseline/finddialog.ui.h @@ -164,7 +164,6 @@ public: vboxLayout1->setObjectName(QStringLiteral("vboxLayout1")); findNxt = new QPushButton(FindDialog); findNxt->setObjectName(QStringLiteral("findNxt")); - findNxt->setDefault(true); findNxt->setFlat(false); vboxLayout1->addWidget(findNxt); @@ -194,6 +193,9 @@ public: retranslateUi(FindDialog); QObject::connect(cancel, SIGNAL(clicked()), FindDialog, SLOT(reject())); + findNxt->setDefault(true); + + QMetaObject::connectSlotsByName(FindDialog); } // setupUi diff --git a/tests/auto/tools/uic/baseline/qsqlconnectiondialog.ui.h b/tests/auto/tools/uic/baseline/qsqlconnectiondialog.ui.h index 484c0877bc..31edb426fe 100644 --- a/tests/auto/tools/uic/baseline/qsqlconnectiondialog.ui.h +++ b/tests/auto/tools/uic/baseline/qsqlconnectiondialog.ui.h @@ -171,7 +171,6 @@ public: okButton = new QPushButton(QSqlConnectionDialogUi); okButton->setObjectName(QStringLiteral("okButton")); - okButton->setDefault(true); hboxLayout1->addWidget(okButton); @@ -202,6 +201,9 @@ public: retranslateUi(QSqlConnectionDialogUi); + okButton->setDefault(true); + + QMetaObject::connectSlotsByName(QSqlConnectionDialogUi); } // setupUi diff --git a/tests/auto/tools/uic/baseline/sslclient.ui.h b/tests/auto/tools/uic/baseline/sslclient.ui.h index a74a465955..f2071d8780 100644 --- a/tests/auto/tools/uic/baseline/sslclient.ui.h +++ b/tests/auto/tools/uic/baseline/sslclient.ui.h @@ -86,7 +86,6 @@ public: connectButton = new QPushButton(Form); connectButton->setObjectName(QStringLiteral("connectButton")); connectButton->setEnabled(true); - connectButton->setDefault(true); vboxLayout->addWidget(connectButton); @@ -136,7 +135,6 @@ public: sendButton->setObjectName(QStringLiteral("sendButton")); sendButton->setEnabled(false); sendButton->setFocusPolicy(Qt::TabFocus); - sendButton->setDefault(true); hboxLayout1->addWidget(sendButton); @@ -151,6 +149,10 @@ public: QObject::connect(hostNameEdit, SIGNAL(returnPressed()), connectButton, SLOT(animateClick())); QObject::connect(sessionInput, SIGNAL(returnPressed()), sendButton, SLOT(animateClick())); + connectButton->setDefault(true); + sendButton->setDefault(true); + + QMetaObject::connectSlotsByName(Form); } // setupUi diff --git a/tests/auto/tools/uic/baseline/topicchooser.ui.h b/tests/auto/tools/uic/baseline/topicchooser.ui.h index 06d34e9c63..3935a7a87b 100644 --- a/tests/auto/tools/uic/baseline/topicchooser.ui.h +++ b/tests/auto/tools/uic/baseline/topicchooser.ui.h @@ -77,7 +77,6 @@ public: buttonDisplay = new QPushButton(Layout16); buttonDisplay->setObjectName(QStringLiteral("buttonDisplay")); buttonDisplay->setAutoDefault(true); - buttonDisplay->setDefault(true); hboxLayout->addWidget(buttonDisplay); @@ -96,6 +95,9 @@ public: retranslateUi(TopicChooser); + buttonDisplay->setDefault(true); + + QMetaObject::connectSlotsByName(TopicChooser); } // setupUi diff --git a/tests/auto/tools/uic/baseline/translatedialog.ui.h b/tests/auto/tools/uic/baseline/translatedialog.ui.h index 72a2b48f2e..c494ca77c3 100644 --- a/tests/auto/tools/uic/baseline/translatedialog.ui.h +++ b/tests/auto/tools/uic/baseline/translatedialog.ui.h @@ -164,7 +164,6 @@ public: vboxLayout2->setContentsMargins(0, 0, 0, 0); findNxt = new QPushButton(TranslateDialog); findNxt->setObjectName(QStringLiteral("findNxt")); - findNxt->setDefault(true); findNxt->setFlat(false); vboxLayout2->addWidget(findNxt); @@ -206,6 +205,9 @@ public: retranslateUi(TranslateDialog); QObject::connect(cancel, SIGNAL(clicked()), TranslateDialog, SLOT(reject())); + findNxt->setDefault(true); + + QMetaObject::connectSlotsByName(TranslateDialog); } // setupUi diff --git a/tests/auto/tools/uic/tst_uic.cpp b/tests/auto/tools/uic/tst_uic.cpp index 1d1e327641..eac80bed7a 100644 --- a/tests/auto/tools/uic/tst_uic.cpp +++ b/tests/auto/tools/uic/tst_uic.cpp @@ -39,6 +39,7 @@ #include <QtCore/QByteArray> #include <QtCore/QLibraryInfo> #include <QtCore/QTemporaryDir> +#include <QtCore/QStandardPaths> class tst_uic : public QObject { @@ -67,10 +68,12 @@ private: const QString m_command; QString m_baseline; QTemporaryDir m_generated; + QRegExp m_versionRegexp; }; tst_uic::tst_uic() : m_command(QLibraryInfo::location(QLibraryInfo::BinariesPath) + QLatin1String("/uic")) + , m_versionRegexp(QLatin1String("Created by: Qt User Interface Compiler version [.\\d]{5,5}")) { } @@ -83,6 +86,7 @@ static QByteArray msgProcessStartFailed(const QString &command, const QString &w void tst_uic::initTestCase() { + QVERIFY(m_versionRegexp.isValid()); m_baseline = QFINDTESTDATA("baseline"); QVERIFY2(!m_baseline.isEmpty(), "Could not find 'baseline'."); QProcess process; @@ -171,6 +175,37 @@ void tst_uic::run_data() const } } +// Helpers to generate a diff using the standard diff tool if present for failures. +static inline QString diffBinary() +{ + QString binary = QLatin1String("diff"); +#ifdef Q_OS_WIN + binary += QLatin1String(".exe"); +#endif + return QStandardPaths::findExecutable(binary); +} + +static QString generateDiff(const QString &originalFile, const QString &generatedFile) +{ + static const QString diff = diffBinary(); + if (diff.isEmpty()) + return QString(); + const QStringList args = QStringList() << QLatin1String("-u") + << QDir::toNativeSeparators(originalFile) + << QDir::toNativeSeparators(generatedFile); + QProcess diffProcess; + diffProcess.start(diff, args); + return diffProcess.waitForStarted() && diffProcess.waitForFinished() + ? QString::fromLocal8Bit(diffProcess.readAllStandardOutput()) : QString(); +} + +static QByteArray msgCannotReadFile(const QFile &file) +{ + const QString result = QLatin1String("Could not read file: ") + + QDir::toNativeSeparators(file.fileName()) + + QLatin1String(": ") + file.errorString(); + return result.toLocal8Bit(); +} void tst_uic::compare() { @@ -180,23 +215,23 @@ void tst_uic::compare() QFile orgFile(originalFile); QFile genFile(generatedFile); - if (!orgFile.open(QIODevice::ReadOnly | QIODevice::Text)) { - QString err(QLatin1String("Could not read file: %1...")); - QFAIL(err.arg(orgFile.fileName()).toUtf8()); - } + QVERIFY2(orgFile.open(QIODevice::ReadOnly | QIODevice::Text), msgCannotReadFile(orgFile)); - if (!genFile.open(QIODevice::ReadOnly | QIODevice::Text)) { - QString err(QLatin1String("Could not read file: %1...")); - QFAIL(err.arg(genFile.fileName()).toUtf8()); - } + QVERIFY2(genFile.open(QIODevice::ReadOnly | QIODevice::Text), msgCannotReadFile(genFile)); - originalFile = orgFile.readAll(); - originalFile.replace(QRegExp(QLatin1String("Created by: Qt User Interface Compiler version [.\\d]{5,5}")), ""); + QString originalFileContents = orgFile.readAll(); + originalFileContents.replace(m_versionRegexp, QString()); - generatedFile = genFile.readAll(); - generatedFile.replace(QRegExp(QLatin1String("Created by: Qt User Interface Compiler version [.\\d]{5,5}")), ""); + QString generatedFileContents = genFile.readAll(); + generatedFileContents.replace(m_versionRegexp, QString()); - QCOMPARE(generatedFile, originalFile); + if (generatedFileContents != originalFileContents) { + const QString diff = generateDiff(originalFile, generatedFile); + if (!diff.isEmpty()) + qWarning().noquote().nospace() << "Difference:\n" << diff; + } + + QCOMPARE(generatedFileContents, originalFileContents); } void tst_uic::compare_data() const @@ -240,28 +275,31 @@ void tst_uic::runTranslation() void tst_uic::runCompare() { - QFile orgFile(m_baseline + QLatin1String("/translation/Dialog_without_Buttons_tr.h")); + const QString dialogFile = QLatin1String("/translation/Dialog_without_Buttons_tr.h"); + const QString originalFile = m_baseline + dialogFile; + QFile orgFile(originalFile); QDir generated(m_generated.path()); - QFile genFile(generated.absolutePath() + QLatin1String("/translation/Dialog_without_Buttons_tr.h")); + const QString generatedFile = generated.absolutePath() + dialogFile; + QFile genFile(generatedFile); - if (!orgFile.open(QIODevice::ReadOnly | QIODevice::Text)) { - QString err(QLatin1String("Could not read file: %1...")); - QFAIL(err.arg(orgFile.fileName()).toUtf8()); - } + QVERIFY2(orgFile.open(QIODevice::ReadOnly | QIODevice::Text), msgCannotReadFile(orgFile)); - if (!genFile.open(QIODevice::ReadOnly | QIODevice::Text)) { - QString err(QLatin1String("Could not read file: %1...")); - QFAIL(err.arg(genFile.fileName()).toUtf8()); - } + QVERIFY2(genFile.open(QIODevice::ReadOnly | QIODevice::Text), msgCannotReadFile(genFile)); - QString originalFile = orgFile.readAll(); - originalFile.replace(QRegExp(QLatin1String("Created by: Qt User Interface Compiler version [.\\d]{5,5}")), ""); + QString originalFileContents = orgFile.readAll(); + originalFileContents.replace(m_versionRegexp, QString()); - QString generatedFile = genFile.readAll(); - generatedFile.replace(QRegExp(QLatin1String("Created by: Qt User Interface Compiler version [.\\d]{5,5}")), ""); + QString generatedFileContents = genFile.readAll(); + generatedFileContents.replace(m_versionRegexp, QString()); + + if (generatedFileContents != originalFileContents) { + const QString diff = generateDiff(originalFile, generatedFile); + if (!diff.isEmpty()) + qWarning().noquote().nospace() << "Difference:\n" << diff; + } - QCOMPARE(generatedFile, originalFile); + QCOMPARE(generatedFileContents, originalFileContents); } QTEST_MAIN(tst_uic) diff --git a/tests/auto/widgets/graphicsview/qgraphicsitem/BLACKLIST b/tests/auto/widgets/graphicsview/qgraphicsitem/BLACKLIST index edaa450731..abfa7a3329 100644 --- a/tests/auto/widgets/graphicsview/qgraphicsitem/BLACKLIST +++ b/tests/auto/widgets/graphicsview/qgraphicsitem/BLACKLIST @@ -1,2 +1,2 @@ -[sorting] -osx +[ensureUpdateOnTextItem] +osx-10.10 diff --git a/tests/auto/widgets/widgets/qcombobox/BLACKLIST b/tests/auto/widgets/widgets/qcombobox/BLACKLIST new file mode 100644 index 0000000000..4a270c085b --- /dev/null +++ b/tests/auto/widgets/widgets/qcombobox/BLACKLIST @@ -0,0 +1,3 @@ +QTBUG-45531 +[task260974_menuItemRectangleForComboBoxPopup] +osx-10.10 diff --git a/tests/auto/widgets/widgets/qdockwidget/tst_qdockwidget.cpp b/tests/auto/widgets/widgets/qdockwidget/tst_qdockwidget.cpp index 0521a9bd99..ade9f72543 100644 --- a/tests/auto/widgets/widgets/qdockwidget/tst_qdockwidget.cpp +++ b/tests/auto/widgets/widgets/qdockwidget/tst_qdockwidget.cpp @@ -72,6 +72,7 @@ private slots: void setTitleBarWidget(); void titleBarDoubleClick(); void restoreStateOfFloating(); + void restoreDockWidget(); // task specific tests: void task165177_deleteFocusWidget(); void task169808_setFloating(); @@ -694,20 +695,78 @@ void tst_QDockWidget::titleBarDoubleClick() QCOMPARE(win.dockWidgetArea(&dock), Qt::TopDockWidgetArea); } +static QDockWidget *createTestDock(QMainWindow &parent) +{ + const QString title = QStringLiteral("dock1"); + QDockWidget *dock = new QDockWidget(title, &parent); + dock->setObjectName(title); + dock->setAllowedAreas(Qt::AllDockWidgetAreas); + return dock; +} + void tst_QDockWidget::restoreStateOfFloating() { QMainWindow mw; - QDockWidget dock; - dock.setObjectName("dock1"); - mw.addDockWidget(Qt::TopDockWidgetArea, &dock); - QVERIFY(!dock.isFloating()); + QDockWidget *dock = createTestDock(mw); + mw.addDockWidget(Qt::TopDockWidgetArea, dock); + QVERIFY(!dock->isFloating()); QByteArray ba = mw.saveState(); - dock.setFloating(true); - QVERIFY(dock.isFloating()); + dock->setFloating(true); + QVERIFY(dock->isFloating()); QVERIFY(mw.restoreState(ba)); - QVERIFY(!dock.isFloating()); + QVERIFY(!dock->isFloating()); } +void tst_QDockWidget::restoreDockWidget() +{ + QByteArray geometry; + QByteArray state; + const QString name = QStringLiteral("main"); + const QRect availableGeometry = QApplication::desktop()->availableGeometry(); + const QSize size = availableGeometry.size() / 5; + const QPoint mainWindowPos = availableGeometry.bottomRight() - QPoint(size.width(), size.height()) - QPoint(100, 100); + const QPoint dockPos = availableGeometry.center(); + + { + QMainWindow saveWindow; + saveWindow.setObjectName(name); + saveWindow.setWindowTitle(QTest::currentTestFunction() + QStringLiteral(" save")); + saveWindow.resize(size); + saveWindow.move(mainWindowPos); + saveWindow.restoreState(QByteArray()); + QDockWidget *dock = createTestDock(saveWindow); + QVERIFY(!saveWindow.restoreDockWidget(dock)); // Not added, no placeholder + saveWindow.addDockWidget(Qt::TopDockWidgetArea, dock); + dock->setFloating(true); + dock->resize(size); + dock->move(dockPos); + saveWindow.show(); + QVERIFY(QTest::qWaitForWindowExposed(&saveWindow)); + QVERIFY(dock->isFloating()); + state = saveWindow.saveState(); + geometry = saveWindow.saveGeometry(); + } + + QVERIFY(!geometry.isEmpty()); + QVERIFY(!state.isEmpty()); + + { + QMainWindow restoreWindow; + restoreWindow.setObjectName(name); + restoreWindow.setWindowTitle(QTest::currentTestFunction() + QStringLiteral(" restore")); + QVERIFY(restoreWindow.restoreState(state)); + QVERIFY(restoreWindow.restoreGeometry(geometry)); + + // QMainWindow::restoreDockWidget() restores the state when adding the dock + // after restoreState(). + QDockWidget *dock = createTestDock(restoreWindow); + QVERIFY(restoreWindow.restoreDockWidget(dock)); + restoreWindow.show(); + QVERIFY(QTest::qWaitForWindowExposed(&restoreWindow)); + QTRY_VERIFY(dock->isFloating()); + QTRY_COMPARE(dock->pos(), dockPos); + } +} void tst_QDockWidget::task165177_deleteFocusWidget() { |