diff options
Diffstat (limited to 'tests/auto')
8 files changed, 68 insertions, 40 deletions
diff --git a/tests/auto/corelib/io/qdir/tst_qdir.cpp b/tests/auto/corelib/io/qdir/tst_qdir.cpp index d44ef167b5..fbb21e4e9a 100644 --- a/tests/auto/corelib/io/qdir/tst_qdir.cpp +++ b/tests/auto/corelib/io/qdir/tst_qdir.cpp @@ -311,12 +311,28 @@ void tst_QDir::mkdir() void tst_QDir::makedirReturnCode() { QString dirName = QString::fromLatin1("makedirReturnCode"); - QDir::current().rmdir(dirName); // cleanup a previous run. + QFile f(QDir::current().filePath(dirName)); + + // cleanup a previous run. + f.remove(); + QDir::current().rmdir(dirName); + QDir dir(dirName); QVERIFY(!dir.exists()); QVERIFY(QDir::current().mkdir(dirName)); QVERIFY(!QDir::current().mkdir(dirName)); // calling mkdir on an existing dir will fail. QVERIFY(QDir::current().mkpath(dirName)); // calling mkpath on an existing dir will pass + + // Remove the directory and create a file with the same path + QDir::current().rmdir(dirName); + QVERIFY(!f.exists()); + f.open(QIODevice::WriteOnly); + f.write("test"); + f.close(); + QVERIFY(f.exists()); + QVERIFY(!QDir::current().mkdir(dirName)); // calling mkdir on an existing file will fail. + QVERIFY(!QDir::current().mkpath(dirName)); // calling mkpath on an existing file will fail. + f.remove(); } void tst_QDir::rmdir_data() diff --git a/tests/auto/corelib/io/qtemporarydir/tst_qtemporarydir.cpp b/tests/auto/corelib/io/qtemporarydir/tst_qtemporarydir.cpp index 8515f8a698..713d0c5c17 100644 --- a/tests/auto/corelib/io/qtemporarydir/tst_qtemporarydir.cpp +++ b/tests/auto/corelib/io/qtemporarydir/tst_qtemporarydir.cpp @@ -279,17 +279,18 @@ void tst_QTemporaryDir::openOnRootDrives() void tst_QTemporaryDir::stressTest() { const int iterations = 1000; + QTemporaryDir rootDir; + QVERIFY(rootDir.isValid()); QSet<QString> names; + const QString pattern = rootDir.path() + QStringLiteral("/XXXXXX"); for (int i = 0; i < iterations; ++i) { - QTemporaryDir dir; + QTemporaryDir dir(pattern); dir.setAutoRemove(false); - QVERIFY2(dir.isValid(), qPrintable(QString::number(i))); + QVERIFY2(dir.isValid(), qPrintable(QString::fromLatin1("Failed to create #%1 under %2.").arg(i).arg(QDir::toNativeSeparators(pattern)))); QVERIFY(!names.contains(dir.path())); names.insert(dir.path()); } - for (QSet<QString>::const_iterator it = names.constBegin(); it != names.constEnd(); ++it) - QDir(*it).removeRecursively(); } void tst_QTemporaryDir::rename() diff --git a/tests/auto/gui/kernel/qguimetatype/tst_qguimetatype.cpp b/tests/auto/gui/kernel/qguimetatype/tst_qguimetatype.cpp index da2c961558..1839b0670c 100644 --- a/tests/auto/gui/kernel/qguimetatype/tst_qguimetatype.cpp +++ b/tests/auto/gui/kernel/qguimetatype/tst_qguimetatype.cpp @@ -66,7 +66,7 @@ private slots: void constructCopy(); }; -#define FOR_EACH_GUI_METATYPE(F) \ +#define FOR_EACH_GUI_METATYPE_BASE(F) \ F(QFont, QFont) \ F(QPixmap, QPixmap) \ F(QBrush, QBrush) \ @@ -76,7 +76,6 @@ private slots: F(QPolygon, QPolygon) \ F(QRegion, QRegion) \ F(QBitmap, QBitmap) \ - F(QCursor, QCursor) \ F(QKeySequence, QKeySequence) \ F(QPen, QPen) \ F(QTextLength, QTextLength) \ @@ -89,6 +88,16 @@ private slots: F(QVector4D, QVector4D) \ F(QQuaternion, QQuaternion) +#ifndef QTEST_NO_CURSOR +# define FOR_EACH_GUI_METATYPE(F) \ + FOR_EACH_GUI_METATYPE_BASE(F) \ + F(QCursor, QCursor) +#else // !QTEST_NO_CURSOR +# define FOR_EACH_GUI_METATYPE(F) \ + FOR_EACH_GUI_METATYPE_BASE(F) +#endif // !QTEST_NO_CURSOR + + namespace { template <typename T> struct static_assert_trigger { diff --git a/tests/auto/gui/text/qrawfont/tst_qrawfont.cpp b/tests/auto/gui/text/qrawfont/tst_qrawfont.cpp index fb5bb18f87..ae6e450301 100644 --- a/tests/auto/gui/text/qrawfont/tst_qrawfont.cpp +++ b/tests/auto/gui/text/qrawfont/tst_qrawfont.cpp @@ -215,8 +215,8 @@ void tst_QRawFont::correctFontData_data() << QFont::StyleNormal << QFont::Normal << QFont::HintingPreference(*hintingPreference) - << 1000.0 - << 10.0; + << qreal(1000.0) + << qreal(10.0); fileName = testFontBoldItalic; title = fileName @@ -229,8 +229,8 @@ void tst_QRawFont::correctFontData_data() << QFont::StyleItalic << QFont::Bold << QFont::HintingPreference(*hintingPreference) - << 1000.0 - << 10.0; + << qreal(1000.0) + << qreal(10.0); ++hintingPreference; } diff --git a/tests/auto/network/kernel/qnetworkproxyfactory/tst_qnetworkproxyfactory.cpp b/tests/auto/network/kernel/qnetworkproxyfactory/tst_qnetworkproxyfactory.cpp index dd24f6757e..9e03884e4e 100644 --- a/tests/auto/network/kernel/qnetworkproxyfactory/tst_qnetworkproxyfactory.cpp +++ b/tests/auto/network/kernel/qnetworkproxyfactory/tst_qnetworkproxyfactory.cpp @@ -380,7 +380,7 @@ void tst_QNetworkProxyFactory::genericSystemProxy() QFETCH(int, port); // The generic system proxy is only available on the following platforms -#if (!defined Q_OS_BLACKBERRY) && (!defined Q_OS_WIN) && ((!defined Q_OS_MAC) || defined Q_OS_IOS) +#if (!defined Q_OS_BLACKBERRY) && (!defined Q_OS_WIN) && (!defined Q_OS_MACX) qputenv(envVar, url); const QList<QNetworkProxy> systemProxy = QNetworkProxyFactory::systemProxyForQuery(); QCOMPARE(systemProxy.size(), 1); diff --git a/tests/auto/tools/qmake/tst_qmake.cpp b/tests/auto/tools/qmake/tst_qmake.cpp index 0935b1bca4..4d3b5983f0 100644 --- a/tests/auto/tools/qmake/tst_qmake.cpp +++ b/tests/auto/tools/qmake/tst_qmake.cpp @@ -314,6 +314,9 @@ void tst_qmake::export_across_file_boundaries() void tst_qmake::include_dir() { +#ifdef QT_NO_WIDGETS + QSKIP("This test depends on QtWidgets"); +#else QString workDir = base_path + "/testdata/include_dir"; QVERIFY( test_compiler.qmake( workDir, "foo" )); QVERIFY( test_compiler.make( workDir )); @@ -325,6 +328,7 @@ void tst_qmake::include_dir() QVERIFY( test_compiler.make( buildDir )); QVERIFY( test_compiler.exists( buildDir, "foo", Exe, "1.0.0" )); QVERIFY( test_compiler.makeDistClean( buildDir )); +#endif } void tst_qmake::include_pwd() diff --git a/tests/auto/widgets/dialogs/qfiledialog/tst_qfiledialog.cpp b/tests/auto/widgets/dialogs/qfiledialog/tst_qfiledialog.cpp index 4176fef631..81b69f6b89 100644 --- a/tests/auto/widgets/dialogs/qfiledialog/tst_qfiledialog.cpp +++ b/tests/auto/widgets/dialogs/qfiledialog/tst_qfiledialog.cpp @@ -44,6 +44,7 @@ #include <qcoreapplication.h> #include <qdebug.h> +#include <qsharedpointer.h> #include <qfiledialog.h> #include <qabstractitemdelegate.h> #include <qdirmodel.h> @@ -441,33 +442,25 @@ void tst_QFiledialog::completer_data() void tst_QFiledialog::completer() { + typedef QSharedPointer<QTemporaryFile> TemporaryFilePtr; + QFETCH(QString, input); QFETCH(QString, startPath); QFETCH(int, expected); - QString tempPath = QDir::tempPath() + '/' + "QFileDialogTestDir"; - if (startPath.isEmpty()) - startPath = tempPath; + QTemporaryDir tempDir; + QVERIFY(tempDir.isValid()); - startPath = QDir::cleanPath(startPath); + const QString tempPath = tempDir.path(); + startPath = startPath.isEmpty() ? tempPath : QDir::cleanPath(startPath); // make temp dir and files - { - QDir cleanup(tempPath); - QStringList x = cleanup.entryList(); - for (int i = 0; i < x.count(); ++i) - QFile::remove(tempPath + '/' + x[i]); - cleanup.rmdir(tempPath); - } - QDir tmp(QDir::tempPath()); - if (!tmp.exists(tempPath)) - QVERIFY(tmp.mkdir("QFileDialogTestDir")); - QList<QTemporaryFile*> files; + QList<TemporaryFilePtr> files; QT_TRY { for (int i = 0; i < 10; ++i) { - QScopedPointer<QTemporaryFile> file(new QTemporaryFile(tempPath + "/rXXXXXX")); - file->open(); - files.append(file.take()); + TemporaryFilePtr file(new QTemporaryFile(tempPath + QStringLiteral("/rXXXXXX"))); + QVERIFY(file->open()); + files.append(file); } // ### flesh this out more @@ -515,7 +508,7 @@ void tst_QFiledialog::completer() QStringList expectedFiles; if (expected == -1) { - QString fullPath = startPath.isEmpty() ? tempPath : startPath; + QString fullPath = startPath; if (!fullPath.endsWith(QLatin1Char('/'))) fullPath.append(QLatin1Char('/')); fullPath.append(input); @@ -551,10 +544,8 @@ void tst_QFiledialog::completer() QTRY_COMPARE(cModel->rowCount(), expected); } QT_CATCH(...) { - qDeleteAll(files); QT_RETHROW; } - qDeleteAll(files); } void tst_QFiledialog::completer_up() @@ -890,9 +881,9 @@ void tst_QFiledialog::selectFiles() { QNonNativeFileDialog fd; fd.setViewMode(QFileDialog::List); - QString tempPath = QDir::tempPath() + '/' + "QFileDialogTestDir4SelectFiles"; - QDir dir; - QVERIFY(dir.mkpath(tempPath)); + QTemporaryDir tempDir; + QVERIFY(tempDir.isValid()); + const QString tempPath = tempDir.path(); fd.setDirectory(tempPath); QSignalSpy spyCurrentChanged(&fd, SIGNAL(currentChanged(QString))); QSignalSpy spyDirectoryEntered(&fd, SIGNAL(directoryEntered(QString))); @@ -936,15 +927,12 @@ void tst_QFiledialog::selectFiles() QCOMPARE(spyDirectoryEntered.count(), 0); QCOMPARE(spyFilesSelected.count(), 0); QCOMPARE(spyFilterSelected.count(), 0); - for (int i=0; i < 5; ++i) - QFile::remove(filesPath + QString::fromLatin1("/qfiledialog_auto_test_not_pres_%1").arg(i)); //If the selection is invalid then we fill the line edit but without the / QNonNativeFileDialog * dialog = new QNonNativeFileDialog( 0, "Save" ); dialog->setFileMode( QFileDialog::AnyFile ); dialog->setAcceptMode( QFileDialog::AcceptSave ); - QString temporary = QDir::tempPath() + QLatin1String("/blah"); - dialog->selectFile(temporary); + dialog->selectFile(tempPath + QStringLiteral("/blah")); dialog->show(); QVERIFY(QTest::qWaitForWindowExposed(dialog)); QLineEdit *lineEdit = dialog->findChild<QLineEdit*>("fileNameEdit"); diff --git a/tests/auto/widgets/kernel/qwindowcontainer/tst_qwindowcontainer.cpp b/tests/auto/widgets/kernel/qwindowcontainer/tst_qwindowcontainer.cpp index 440639cd49..2d9cb98e27 100644 --- a/tests/auto/widgets/kernel/qwindowcontainer/tst_qwindowcontainer.cpp +++ b/tests/auto/widgets/kernel/qwindowcontainer/tst_qwindowcontainer.cpp @@ -192,6 +192,11 @@ void tst_QWindowContainer::testActivation() QVERIFY(QTest::qWaitForWindowActive(root.windowHandle())); QVERIFY(QGuiApplication::focusWindow() == root.windowHandle()); + // Verify that all states in the root widget indicate it is active + QVERIFY(root.windowHandle()->isActive()); + QVERIFY(root.isActiveWindow()); + QCOMPARE(root.palette().currentColorGroup(), QPalette::Active); + // Under KDE (ubuntu 12.10), we experience that doing two activateWindow in a row // does not work. The second gets ignored by the window manager, even though the // timestamp in the xcb connection is unique for both. @@ -201,6 +206,11 @@ void tst_QWindowContainer::testActivation() window->requestActivate(); QVERIFY(QTest::qWaitForWindowActive(window)); QVERIFY(QGuiApplication::focusWindow() == window); + + // Verify that all states in the root widget still indicate it is active + QVERIFY(root.windowHandle()->isActive()); + QVERIFY(root.isActiveWindow()); + QCOMPARE(root.palette().currentColorGroup(), QPalette::Active); } |