summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorLiang Qi <liang.qi@theqtcompany.com>2015-08-26 20:06:57 +0200
committerLiang Qi <liang.qi@theqtcompany.com>2015-08-26 20:06:57 +0200
commitafab1546a7665bac2a8d7a6452e6aea46bfd2127 (patch)
treed616a7559c54a40e35a12b464f606774c9b0475b /tests
parent06b457c693f207e392d3021d77a0ab18cd78da92 (diff)
parent53ecaade10319ecc1d8115521ae6d8eba1ee55c1 (diff)
Merge remote-tracking branch 'origin/5.5' into 5.6
Conflicts: qmake/doc/snippets/code/doc_src_qmake-manual.pro qmake/doc/src/qmake-manual.qdoc src/corelib/io/qstorageinfo_unix.cpp src/corelib/tools/qbytearray.cpp src/widgets/kernel/qwidgetwindow.cpp tests/auto/corelib/io/qprocess/tst_qprocess.cpp tests/auto/corelib/mimetypes/qmimedatabase/tst_qmimedatabase.cpp tests/auto/network/access/qnetworkreply/BLACKLIST Change-Id: I9efcd7e1cce1c394eed425c43aa6fce7d2edf31c
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/corelib/io/qprocess/qprocess.pri1
-rw-r--r--tests/auto/corelib/io/qprocess/testProcessHang/main.cpp62
-rw-r--r--tests/auto/corelib/io/qprocess/testProcessHang/testProcessHang.pro4
-rw-r--r--tests/auto/corelib/io/qprocess/tst_qprocess.cpp165
-rw-r--r--tests/auto/corelib/mimetypes/qmimedatabase/qmimedatabase-cache/qmimedatabase-cache.pro2
-rw-r--r--tests/auto/corelib/mimetypes/qmimedatabase/qmimedatabase-cache/tst_qmimedatabase-cache.cpp2
-rw-r--r--tests/auto/corelib/mimetypes/qmimedatabase/qmimedatabase-xml/qmimedatabase-xml.pro2
-rw-r--r--tests/auto/corelib/mimetypes/qmimedatabase/qmimedatabase-xml/tst_qmimedatabase-xml.cpp2
-rw-r--r--tests/auto/corelib/mimetypes/qmimedatabase/testdata.qrc1
-rw-r--r--tests/auto/corelib/mimetypes/qmimedatabase/text-x-objcsrc.xml7
-rw-r--r--tests/auto/corelib/mimetypes/qmimedatabase/tst_qmimedatabase.cpp87
-rw-r--r--tests/auto/corelib/mimetypes/qmimedatabase/tst_qmimedatabase.h8
-rw-r--r--tests/auto/corelib/mimetypes/qmimedatabase/yast2-metapackage-handler-mimetypes.xml2
-rw-r--r--tests/auto/corelib/tools/qregularexpression/tst_qregularexpression.cpp386
-rw-r--r--tests/auto/corelib/tools/qregularexpression/tst_qregularexpression.h1
-rw-r--r--tests/auto/corelib/tools/qtime/tst_qtime.cpp2
-rw-r--r--tests/auto/network/access/qnetworkreply/BLACKLIST8
-rw-r--r--tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp9
-rw-r--r--tests/auto/network/socket/qudpsocket/tst_qudpsocket.cpp34
-rw-r--r--tests/auto/other/qaccessibility/tst_qaccessibility.cpp2
-rw-r--r--tests/auto/widgets/widgets/qlineedit/tst_qlineedit.cpp44
-rw-r--r--tests/auto/widgets/widgets/qmenubar/tst_qmenubar.cpp11
22 files changed, 753 insertions, 89 deletions
diff --git a/tests/auto/corelib/io/qprocess/qprocess.pri b/tests/auto/corelib/io/qprocess/qprocess.pri
index 430251fbf1..a43c823846 100644
--- a/tests/auto/corelib/io/qprocess/qprocess.pri
+++ b/tests/auto/corelib/io/qprocess/qprocess.pri
@@ -4,6 +4,7 @@ SUBPROGRAMS = \
testProcessEcho2 \
testProcessEcho3 \
testProcessEnvironment \
+ testProcessHang \
testProcessNormal \
testProcessOutput \
testProcessDeadWhileReading \
diff --git a/tests/auto/corelib/io/qprocess/testProcessHang/main.cpp b/tests/auto/corelib/io/qprocess/testProcessHang/main.cpp
new file mode 100644
index 0000000000..e06502f738
--- /dev/null
+++ b/tests/auto/corelib/io/qprocess/testProcessHang/main.cpp
@@ -0,0 +1,62 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 Intel Corporation.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL21$
+** 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 http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 or version 3 as published by the Free
+** Software Foundation and appearing in the file LICENSE.LGPLv21 and
+** LICENSE.LGPLv3 included in the packaging of this file. Please review the
+** following information to ensure the GNU Lesser General Public License
+** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <stdio.h>
+
+#if defined(WIN32) || defined(_WIN32) || defined(__WIN32__)
+# include <windows.h>
+
+void sleepForever()
+{
+ ::Sleep(INFINITE);
+}
+#else
+# include <unistd.h>
+
+void sleepForever()
+{
+ ::pause();
+}
+#endif
+
+int main()
+{
+ puts("ready.");
+ fflush(stdout);
+ fprintf(stderr, "ready.\n");
+ fflush(stderr);
+
+ // sleep forever, simulating a hung application
+ sleepForever();
+ return 0;
+}
diff --git a/tests/auto/corelib/io/qprocess/testProcessHang/testProcessHang.pro b/tests/auto/corelib/io/qprocess/testProcessHang/testProcessHang.pro
new file mode 100644
index 0000000000..e236e05c7d
--- /dev/null
+++ b/tests/auto/corelib/io/qprocess/testProcessHang/testProcessHang.pro
@@ -0,0 +1,4 @@
+SOURCES = main.cpp
+CONFIG -= qt app_bundle
+CONFIG += console
+DESTDIR = ./
diff --git a/tests/auto/corelib/io/qprocess/tst_qprocess.cpp b/tests/auto/corelib/io/qprocess/tst_qprocess.cpp
index 0d4c53a7a9..caefc3fc21 100644
--- a/tests/auto/corelib/io/qprocess/tst_qprocess.cpp
+++ b/tests/auto/corelib/io/qprocess/tst_qprocess.cpp
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2015 The Qt Company Ltd.
+** Copyright (C) 2015 Intel Corporation.
** Contact: http://www.qt.io/licensing/
**
** This file is part of the test suite of the Qt Toolkit.
@@ -116,7 +117,8 @@ private slots:
void setStandardInputFile();
void setStandardOutputFile_data();
void setStandardOutputFile();
- void setStandardOutputFile2();
+ void setStandardOutputFileNullDevice();
+ void setStandardOutputFileAndWaitForBytesWritten();
void setStandardOutputProcess_data();
void setStandardOutputProcess();
void removeFileWhileProcessIsRunning();
@@ -150,6 +152,9 @@ private slots:
void onlyOneStartedSignal();
void finishProcessBeforeReadingDone();
void waitForStartedWithoutStart();
+ void startStopStartStop();
+ void startStopStartStopBuffers_data();
+ void startStopStartStopBuffers();
// keep these at the end, since they use lots of processes and sometimes
// caused obscure failures to occur in tests that followed them (esp. on the Mac)
@@ -1970,22 +1975,6 @@ void tst_QProcess::setStandardOutputFile_data()
<< true;
}
-#ifndef Q_OS_WINCE
-void tst_QProcess::setStandardOutputFile2()
-{
- static const char testdata[] = "Test data.";
-
- QProcess process;
- process.setStandardOutputFile(QProcess::nullDevice());
- process.start("testProcessEcho2/testProcessEcho2");
- process.write(testdata, sizeof testdata);
- QPROCESS_VERIFY(process,waitForFinished());
- QCOMPARE(process.bytesAvailable(), Q_INT64_C(0));
-
- QVERIFY(!QFileInfo(QProcess::nullDevice()).isFile());
-}
-#endif
-
void tst_QProcess::setStandardOutputFile()
{
static const char data[] = "Original data. ";
@@ -2034,6 +2023,40 @@ void tst_QProcess::setStandardOutputFile()
QCOMPARE(all.size(), expectedsize);
}
+
+void tst_QProcess::setStandardOutputFileNullDevice()
+{
+ static const char testdata[] = "Test data.";
+
+ QProcess process;
+ process.setStandardOutputFile(QProcess::nullDevice());
+ process.start("testProcessEcho2/testProcessEcho2");
+ process.write(testdata, sizeof testdata);
+ QPROCESS_VERIFY(process,waitForFinished());
+ QCOMPARE(process.bytesAvailable(), Q_INT64_C(0));
+
+ QVERIFY(!QFileInfo(QProcess::nullDevice()).isFile());
+}
+
+void tst_QProcess::setStandardOutputFileAndWaitForBytesWritten()
+{
+ static const char testdata[] = "Test data.";
+
+ QFile file("data");
+ QProcess process;
+ process.setStandardOutputFile(file.fileName());
+ process.start("testProcessEcho2/testProcessEcho2");
+ process.write(testdata, sizeof testdata);
+ process.waitForBytesWritten();
+ QPROCESS_VERIFY(process, waitForFinished());
+
+ // open the file again and verify the data
+ QVERIFY(file.open(QIODevice::ReadOnly));
+ QByteArray all = file.readAll();
+ file.close();
+
+ QCOMPARE(all, QByteArray::fromRawData(testdata, sizeof testdata - 1));
+}
#endif
#ifndef Q_OS_WINCE
@@ -2041,17 +2064,19 @@ void tst_QProcess::setStandardOutputFile()
void tst_QProcess::setStandardOutputProcess_data()
{
QTest::addColumn<bool>("merged");
- QTest::newRow("separate") << false;
- QTest::newRow("merged") << true;
+ QTest::addColumn<bool>("waitForBytesWritten");
+ QTest::newRow("separate") << false << false;
+ QTest::newRow("separate with waitForBytesWritten") << false << true;
+ QTest::newRow("merged") << true << false;
}
void tst_QProcess::setStandardOutputProcess()
{
-
QProcess source;
QProcess sink;
QFETCH(bool, merged);
+ QFETCH(bool, waitForBytesWritten);
source.setReadChannelMode(merged ? QProcess::MergedChannels : QProcess::SeparateChannels);
source.setStandardOutputProcess(&sink);
@@ -2060,6 +2085,8 @@ void tst_QProcess::setStandardOutputProcess()
QByteArray data("Hello, World");
source.write(data);
+ if (waitForBytesWritten)
+ source.waitForBytesWritten();
source.closeWriteChannel();
QPROCESS_VERIFY(source, waitForFinished());
QPROCESS_VERIFY(sink, waitForFinished());
@@ -2333,12 +2360,110 @@ void tst_QProcess::finishProcessBeforeReadingDone()
QCOMPARE(lines.last(), QStringLiteral("10239 -this is a number"));
}
+//-----------------------------------------------------------------------------
void tst_QProcess::waitForStartedWithoutStart()
{
QProcess process;
QVERIFY(!process.waitForStarted(5000));
}
+//-----------------------------------------------------------------------------
+void tst_QProcess::startStopStartStop()
+{
+ // we actually do start-stop x 3 :-)
+ QProcess process;
+ process.start("testProcessNormal/testProcessNormal");
+ QVERIFY(process.waitForFinished());
+ QCOMPARE(process.exitCode(), 0);
+
+ process.start("testExitCodes/testExitCodes", QStringList() << "1");
+ QVERIFY(process.waitForFinished());
+ QCOMPARE(process.exitCode(), 1);
+
+ process.start("testProcessNormal/testProcessNormal");
+ QVERIFY(process.waitForFinished());
+ QCOMPARE(process.exitCode(), 0);
+}
+
+//-----------------------------------------------------------------------------
+void tst_QProcess::startStopStartStopBuffers_data()
+{
+ QTest::addColumn<int>("channelMode1");
+ QTest::addColumn<int>("channelMode2");
+
+ QTest::newRow("separate-separate") << int(QProcess::SeparateChannels) << int(QProcess::SeparateChannels);
+ QTest::newRow("separate-merged") << int(QProcess::SeparateChannels) << int(QProcess::MergedChannels);
+ QTest::newRow("merged-separate") << int(QProcess::MergedChannels) << int(QProcess::SeparateChannels);
+ QTest::newRow("merged-merged") << int(QProcess::MergedChannels) << int(QProcess::MergedChannels);
+ QTest::newRow("merged-forwarded") << int(QProcess::MergedChannels) << int(QProcess::ForwardedChannels);
+}
+
+void tst_QProcess::startStopStartStopBuffers()
+{
+ QFETCH(int, channelMode1);
+ QFETCH(int, channelMode2);
+
+ QProcess process;
+ process.setProcessChannelMode(QProcess::ProcessChannelMode(channelMode1));
+ process.start("testProcessHang/testProcessHang");
+ QVERIFY2(process.waitForReadyRead(), process.errorString().toLocal8Bit());
+ if (channelMode1 == QProcess::SeparateChannels || channelMode1 == QProcess::ForwardedOutputChannel) {
+ process.setReadChannel(QProcess::StandardError);
+ if (process.bytesAvailable() == 0)
+ QVERIFY(process.waitForReadyRead());
+ process.setReadChannel(QProcess::StandardOutput);
+ }
+
+ // We want to test that the write buffer still has bytes after the child
+ // exiting. We do that by writing to a child process that never reads. We
+ // just have to write more data than a pipe can hold, so that even if
+ // QProcess finds the pipe writable (during waitForFinished() or in the
+ // QWindowsPipeWriter thread), some data will remain. The worst case I know
+ // of is Linux, which defaults to 64 kB of buffer.
+
+ process.write(QByteArray(128 * 1024, 'a'));
+ QVERIFY(process.bytesToWrite() > 0);
+ process.kill();
+
+ QVERIFY(process.waitForFinished());
+
+#ifndef Q_OS_WIN
+ // confirm that our buffers are still full
+ // Note: this doesn't work on Windows because our buffers are drained into
+ // QWindowsPipeWriter before being sent to the child process.
+ QVERIFY(process.bytesToWrite() > 0);
+ QVERIFY(process.bytesAvailable() > 0); // channelMode1 is not ForwardedChannels
+ if (channelMode1 == QProcess::SeparateChannels || channelMode1 == QProcess::ForwardedOutputChannel) {
+ process.setReadChannel(QProcess::StandardError);
+ QVERIFY(process.bytesAvailable() > 0);
+ process.setReadChannel(QProcess::StandardOutput);
+ }
+#endif
+
+ process.setProcessChannelMode(QProcess::ProcessChannelMode(channelMode2));
+ process.start("testProcessEcho2/testProcessEcho2", QIODevice::ReadWrite | QIODevice::Text);
+
+ // the buffers should now be empty
+ QCOMPARE(process.bytesToWrite(), qint64(0));
+ QCOMPARE(process.bytesAvailable(), qint64(0));
+ process.setReadChannel(QProcess::StandardError);
+ QCOMPARE(process.bytesAvailable(), qint64(0));
+ process.setReadChannel(QProcess::StandardOutput);
+
+ process.write("line3\n");
+ process.closeWriteChannel();
+ QVERIFY(process.waitForFinished());
+ QCOMPARE(process.exitCode(), 0);
+
+ if (channelMode2 == QProcess::MergedChannels) {
+ QCOMPARE(process.readAll(), QByteArray("lliinnee33\n\n"));
+ } else if (channelMode2 != QProcess::ForwardedChannels) {
+ QCOMPARE(process.readAllStandardOutput(), QByteArray("line3\n"));
+ if (channelMode2 == QProcess::SeparateChannels)
+ QCOMPARE(process.readAllStandardError(), QByteArray("line3\n"));
+ }
+}
+
#endif //QT_NO_PROCESS
QTEST_MAIN(tst_QProcess)
diff --git a/tests/auto/corelib/mimetypes/qmimedatabase/qmimedatabase-cache/qmimedatabase-cache.pro b/tests/auto/corelib/mimetypes/qmimedatabase/qmimedatabase-cache/qmimedatabase-cache.pro
index d0dbf077c8..d0b834824a 100644
--- a/tests/auto/corelib/mimetypes/qmimedatabase/qmimedatabase-cache/qmimedatabase-cache.pro
+++ b/tests/auto/corelib/mimetypes/qmimedatabase/qmimedatabase-cache/qmimedatabase-cache.pro
@@ -11,3 +11,5 @@ RESOURCES += ../testdata.qrc
*-g++*:QMAKE_CXXFLAGS += -W -Wall -Wextra -Wshadow -Wno-long-long -Wnon-virtual-dtor
DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0
+
+unix:!mac:!qnx: DEFINES += USE_XDG_DATA_DIRS
diff --git a/tests/auto/corelib/mimetypes/qmimedatabase/qmimedatabase-cache/tst_qmimedatabase-cache.cpp b/tests/auto/corelib/mimetypes/qmimedatabase/qmimedatabase-cache/tst_qmimedatabase-cache.cpp
index 7f78312582..2113672821 100644
--- a/tests/auto/corelib/mimetypes/qmimedatabase/qmimedatabase-cache/tst_qmimedatabase-cache.cpp
+++ b/tests/auto/corelib/mimetypes/qmimedatabase/qmimedatabase-cache/tst_qmimedatabase-cache.cpp
@@ -39,7 +39,7 @@
#include "../tst_qmimedatabase.cpp"
-void tst_QMimeDatabase::init()
+void tst_QMimeDatabase::initTestCaseInternal()
{
#ifdef QT_NO_PROCESS
QSKIP("No qprocess support", SkipAll);
diff --git a/tests/auto/corelib/mimetypes/qmimedatabase/qmimedatabase-xml/qmimedatabase-xml.pro b/tests/auto/corelib/mimetypes/qmimedatabase/qmimedatabase-xml/qmimedatabase-xml.pro
index 6d7cbc6016..4add6c2bcd 100644
--- a/tests/auto/corelib/mimetypes/qmimedatabase/qmimedatabase-xml/qmimedatabase-xml.pro
+++ b/tests/auto/corelib/mimetypes/qmimedatabase/qmimedatabase-xml/qmimedatabase-xml.pro
@@ -12,3 +12,5 @@ RESOURCES += ../testdata.qrc
*-g++*:QMAKE_CXXFLAGS += -W -Wall -Wextra -Wshadow -Wno-long-long -Wnon-virtual-dtor
DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0
+
+unix:!mac:!qnx: DEFINES += USE_XDG_DATA_DIRS
diff --git a/tests/auto/corelib/mimetypes/qmimedatabase/qmimedatabase-xml/tst_qmimedatabase-xml.cpp b/tests/auto/corelib/mimetypes/qmimedatabase/qmimedatabase-xml/tst_qmimedatabase-xml.cpp
index e24b1b1249..c4a1dab697 100644
--- a/tests/auto/corelib/mimetypes/qmimedatabase/qmimedatabase-xml/tst_qmimedatabase-xml.cpp
+++ b/tests/auto/corelib/mimetypes/qmimedatabase/qmimedatabase-xml/tst_qmimedatabase-xml.cpp
@@ -33,7 +33,7 @@
#include "../tst_qmimedatabase.h"
-void tst_QMimeDatabase::init()
+void tst_QMimeDatabase::initTestCaseInternal()
{
qputenv("QT_NO_MIME_CACHE", "1");
}
diff --git a/tests/auto/corelib/mimetypes/qmimedatabase/testdata.qrc b/tests/auto/corelib/mimetypes/qmimedatabase/testdata.qrc
index 48d3204473..4654a61660 100644
--- a/tests/auto/corelib/mimetypes/qmimedatabase/testdata.qrc
+++ b/tests/auto/corelib/mimetypes/qmimedatabase/testdata.qrc
@@ -2,6 +2,7 @@
<qresource prefix="/qt-project.org/qmime">
<file alias="yast2-metapackage-handler-mimetypes.xml">yast2-metapackage-handler-mimetypes.xml</file>
<file alias="qml-again.xml">qml-again.xml</file>
+ <file alias="text-x-objcsrc.xml">text-x-objcsrc.xml</file>
<file alias="test.qml">test.qml</file>
</qresource>
</RCC>
diff --git a/tests/auto/corelib/mimetypes/qmimedatabase/text-x-objcsrc.xml b/tests/auto/corelib/mimetypes/qmimedatabase/text-x-objcsrc.xml
new file mode 100644
index 0000000000..e262dc634d
--- /dev/null
+++ b/tests/auto/corelib/mimetypes/qmimedatabase/text-x-objcsrc.xml
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<mime-info xmlns="http://www.freedesktop.org/standards/shared-mime-info">
+ <mime-type type="text/x-objcsrc">
+ <comment>Objective-C source code</comment>
+ <glob-deleteall/>
+ </mime-type>
+</mime-info>
diff --git a/tests/auto/corelib/mimetypes/qmimedatabase/tst_qmimedatabase.cpp b/tests/auto/corelib/mimetypes/qmimedatabase/tst_qmimedatabase.cpp
index 12abaf47c5..dd04849f87 100644
--- a/tests/auto/corelib/mimetypes/qmimedatabase/tst_qmimedatabase.cpp
+++ b/tests/auto/corelib/mimetypes/qmimedatabase/tst_qmimedatabase.cpp
@@ -38,6 +38,8 @@
#include <QtCore/QElapsedTimer>
#include <QtCore/QFile>
#include <QtCore/QFileInfo>
+#include <QtCore/QStandardPaths>
+#include <QtCore/QTemporaryDir>
#include <QtCore/QTextStream>
#include <QFutureSynchronizer>
#include <QtConcurrent/QtConcurrentRun>
@@ -46,6 +48,7 @@
static const char yastFileName[] ="yast2-metapackage-handler-mimetypes.xml";
static const char qmlAgainFileName[] ="qml-again.xml";
+static const char textXObjCSrcFileName[] ="text-x-objcsrc.xml";
#define RESOURCE_PREFIX ":/qt-project.org/qmime/"
void initializeLang()
@@ -117,30 +120,31 @@ tst_QMimeDatabase::tst_QMimeDatabase()
void tst_QMimeDatabase::initTestCase()
{
+ QStandardPaths::setTestModeEnabled(true);
+ m_localMimeDir = QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation) + "/mime";
+ if (QDir(m_localMimeDir).exists()) {
+ QVERIFY2(QDir(m_localMimeDir).removeRecursively(), qPrintable(m_localMimeDir + ": " + qt_error_string()));
+ }
+ QString errorMessage;
+
+#ifdef USE_XDG_DATA_DIRS
+ // Create a temporary "global" XDG data dir for later use
+ // It will initially contain a copy of freedesktop.org.xml
QVERIFY2(m_temporaryDir.isValid(),
("Could not create temporary subdir: " + m_temporaryDir.errorString()).toUtf8());
-
- // Create a "global" and a "local" XDG data dir, right here.
- // The local dir will be empty initially, while the global dir will contain a copy of freedesktop.org.xml
-
const QDir here = QDir(m_temporaryDir.path());
-
m_globalXdgDir = m_temporaryDir.path() + QStringLiteral("/global");
- m_localXdgDir = m_temporaryDir.path() + QStringLiteral("/local");
-
const QString globalPackageDir = m_globalXdgDir + QStringLiteral("/mime/packages");
- QVERIFY(here.mkpath(globalPackageDir) && here.mkpath(m_localXdgDir));
+ QVERIFY(here.mkpath(globalPackageDir));
qputenv("XDG_DATA_DIRS", QFile::encodeName(m_globalXdgDir));
- qputenv("XDG_DATA_HOME", QFile::encodeName(m_localXdgDir));
- qDebug() << "\nLocal XDG_DATA_HOME: " << m_localXdgDir
- << "\nGlobal XDG_DATA_DIRS: " << m_globalXdgDir;
+ qDebug() << "\nGlobal XDG_DATA_DIRS: " << m_globalXdgDir;
const QString freeDesktopXml = QStringLiteral("freedesktop.org.xml");
const QString xmlFileName = QLatin1String(RESOURCE_PREFIX) + freeDesktopXml;
const QString xmlTargetFileName = globalPackageDir + QLatin1Char('/') + freeDesktopXml;
- QString errorMessage;
QVERIFY2(copyResourceFile(xmlFileName, xmlTargetFileName, &errorMessage), qPrintable(errorMessage));
+#endif
m_testSuite = QFINDTESTDATA("testfiles");
if (m_testSuite.isEmpty())
@@ -151,8 +155,22 @@ void tst_QMimeDatabase::initTestCase()
QVERIFY2(QFile::exists(m_yastMimeTypes), qPrintable(errorMessage.arg(yastFileName)));
m_qmlAgainFileName = QLatin1String(RESOURCE_PREFIX) + qmlAgainFileName;
QVERIFY2(QFile::exists(m_qmlAgainFileName), qPrintable(errorMessage.arg(qmlAgainFileName)));
+ m_textXObjCSrcFileName = QLatin1String(RESOURCE_PREFIX) + textXObjCSrcFileName;
+ QVERIFY2(QFile::exists(m_textXObjCSrcFileName), qPrintable(errorMessage.arg(textXObjCSrcFileName)));
+
+ initTestCaseInternal();
+ m_isUsingCacheProvider = !qEnvironmentVariableIsSet("QT_NO_MIME_CACHE");
+}
- init();
+void tst_QMimeDatabase::init()
+{
+ // clean up local data from previous runs
+ QDir(m_localMimeDir).removeRecursively();
+}
+
+void tst_QMimeDatabase::cleanupTestCase()
+{
+ QDir(m_localMimeDir).removeRecursively();
}
void tst_QMimeDatabase::mimeTypeForName()
@@ -853,6 +871,10 @@ QT_END_NAMESPACE
void tst_QMimeDatabase::installNewGlobalMimeType()
{
+#if !defined(USE_XDG_DATA_DIRS)
+ QSKIP("This test requires XDG_DATA_DIRS");
+#endif
+
#ifdef QT_NO_PROCESS
QSKIP("This test requires QProcess support");
#else
@@ -867,6 +889,8 @@ void tst_QMimeDatabase::installNewGlobalMimeType()
QFile::remove(destFile);
const QString destQmlFile = destDir + QLatin1String(qmlAgainFileName);
QFile::remove(destQmlFile);
+ const QString destTextXObjCSrcFile = destDir + QLatin1String(textXObjCSrcFileName);
+ QFile::remove(destTextXObjCSrcFile);
//qDebug() << destFile;
if (!QFileInfo(destDir).isDir())
@@ -874,11 +898,12 @@ void tst_QMimeDatabase::installNewGlobalMimeType()
QString errorMessage;
QVERIFY2(copyResourceFile(m_yastMimeTypes, destFile, &errorMessage), qPrintable(errorMessage));
QVERIFY2(copyResourceFile(m_qmlAgainFileName, destQmlFile, &errorMessage), qPrintable(errorMessage));
- if (!waitAndRunUpdateMimeDatabase(mimeDir))
+ QVERIFY2(copyResourceFile(m_textXObjCSrcFileName, destTextXObjCSrcFile, &errorMessage), qPrintable(errorMessage));
+ if (m_isUsingCacheProvider && !waitAndRunUpdateMimeDatabase(mimeDir))
QSKIP("shared-mime-info not found, skipping mime.cache test");
QCOMPARE(db.mimeTypeForFile(QLatin1String("foo.ymu"), QMimeDatabase::MatchExtension).name(),
- QString::fromLatin1("text/x-suse-ymu"));
+ QString::fromLatin1("text/x-SuSE-ymu"));
QVERIFY(db.mimeTypeForName(QLatin1String("text/x-suse-ymp")).isValid());
checkHasMimeType("text/x-suse-ymp");
@@ -890,10 +915,18 @@ void tst_QMimeDatabase::installNewGlobalMimeType()
QCOMPARE(db.mimeTypeForFile(qmlTestFile).name(),
QString::fromLatin1("text/x-qml"));
+ // ensure we can access the empty glob list
+ {
+ QMimeType objcsrc = db.mimeTypeForName(QStringLiteral("text/x-objcsrc"));
+ QVERIFY(objcsrc.isValid());
+ qDebug() << objcsrc.globPatterns();
+ }
+
// Now test removing it again
- QFile::remove(destFile);
- QFile::remove(destQmlFile);
- if (!waitAndRunUpdateMimeDatabase(mimeDir))
+ QVERIFY(QFile::remove(destFile));
+ QVERIFY(QFile::remove(destQmlFile));
+ QVERIFY(QFile::remove(destTextXObjCSrcFile));
+ if (m_isUsingCacheProvider && !waitAndRunUpdateMimeDatabase(mimeDir))
QSKIP("shared-mime-info not found, skipping mime.cache test");
QCOMPARE(db.mimeTypeForFile(QLatin1String("foo.ymu"), QMimeDatabase::MatchExtension).name(),
QString::fromLatin1("application/octet-stream"));
@@ -911,8 +944,7 @@ void tst_QMimeDatabase::installNewLocalMimeType()
QMimeDatabase db;
QVERIFY(!db.mimeTypeForName(QLatin1String("text/x-suse-ymp")).isValid());
- const QString mimeDir = m_localXdgDir + QLatin1String("/mime");
- const QString destDir = mimeDir + QLatin1String("/packages/");
+ const QString destDir = m_localMimeDir + QLatin1String("/packages/");
QDir().mkpath(destDir);
const QString destFile = destDir + QLatin1String(yastFileName);
QFile::remove(destFile);
@@ -921,15 +953,16 @@ void tst_QMimeDatabase::installNewLocalMimeType()
QString errorMessage;
QVERIFY2(copyResourceFile(m_yastMimeTypes, destFile, &errorMessage), qPrintable(errorMessage));
QVERIFY2(copyResourceFile(m_qmlAgainFileName, destQmlFile, &errorMessage), qPrintable(errorMessage));
- if (!runUpdateMimeDatabase(mimeDir)) {
+ if (m_isUsingCacheProvider && !runUpdateMimeDatabase(m_localMimeDir)) {
const QString skipWarning = QStringLiteral("shared-mime-info not found, skipping mime.cache test (")
- + QDir::toNativeSeparators(mimeDir) + QLatin1Char(')');
+ + QDir::toNativeSeparators(m_localMimeDir) + QLatin1Char(')');
QSKIP(qPrintable(skipWarning));
}
QCOMPARE(db.mimeTypeForFile(QLatin1String("foo.ymu"), QMimeDatabase::MatchExtension).name(),
- QString::fromLatin1("text/x-suse-ymu"));
+ QString::fromLatin1("text/x-SuSE-ymu"));
QVERIFY(db.mimeTypeForName(QLatin1String("text/x-suse-ymp")).isValid());
+ QCOMPARE(db.mimeTypeForName(QLatin1String("text/x-SuSE-ymu")).comment(), QString("URL of a YaST Meta Package"));
checkHasMimeType("text/x-suse-ymp");
// Test that a double-definition of a mimetype doesn't lead to sniffing ("conflicting globs").
@@ -941,16 +974,16 @@ void tst_QMimeDatabase::installNewLocalMimeType()
QString::fromLatin1("text/x-qml"));
// Now test removing the local mimetypes again (note, this leaves a mostly-empty mime.cache file)
- QFile::remove(destFile);
- QFile::remove(destQmlFile);
- if (!waitAndRunUpdateMimeDatabase(mimeDir))
+ QVERIFY(QFile::remove(destFile));
+ QVERIFY(QFile::remove(destQmlFile));
+ if (m_isUsingCacheProvider && !waitAndRunUpdateMimeDatabase(m_localMimeDir))
QSKIP("shared-mime-info not found, skipping mime.cache test");
QCOMPARE(db.mimeTypeForFile(QLatin1String("foo.ymu"), QMimeDatabase::MatchExtension).name(),
QString::fromLatin1("application/octet-stream"));
QVERIFY(!db.mimeTypeForName(QLatin1String("text/x-suse-ymp")).isValid());
// And now the user goes wild and uses rm -rf
- QFile::remove(mimeDir + QString::fromLatin1("/mime.cache"));
+ QFile::remove(m_localMimeDir + QString::fromLatin1("/mime.cache"));
QCOMPARE(db.mimeTypeForFile(QLatin1String("foo.ymu"), QMimeDatabase::MatchExtension).name(),
QString::fromLatin1("application/octet-stream"));
QVERIFY(!db.mimeTypeForName(QLatin1String("text/x-suse-ymp")).isValid());
diff --git a/tests/auto/corelib/mimetypes/qmimedatabase/tst_qmimedatabase.h b/tests/auto/corelib/mimetypes/qmimedatabase/tst_qmimedatabase.h
index 26def8f290..f12beafe86 100644
--- a/tests/auto/corelib/mimetypes/qmimedatabase/tst_qmimedatabase.h
+++ b/tests/auto/corelib/mimetypes/qmimedatabase/tst_qmimedatabase.h
@@ -46,6 +46,8 @@ public:
private slots:
void initTestCase();
+ void init();
+ void cleanupTestCase();
void mimeTypeForName();
void mimeTypeForFileName_data();
@@ -86,14 +88,16 @@ private slots:
void installNewLocalMimeType();
private:
- void init(); // test-specific
+ void initTestCaseInternal(); // test-specific
QString m_globalXdgDir;
- QString m_localXdgDir;
+ QString m_localMimeDir;
QString m_yastMimeTypes;
QString m_qmlAgainFileName;
+ QString m_textXObjCSrcFileName;
QTemporaryDir m_temporaryDir;
QString m_testSuite;
+ bool m_isUsingCacheProvider;
};
#endif // TST_QMIMEDATABASE_H
diff --git a/tests/auto/corelib/mimetypes/qmimedatabase/yast2-metapackage-handler-mimetypes.xml b/tests/auto/corelib/mimetypes/qmimedatabase/yast2-metapackage-handler-mimetypes.xml
index ef3035ef4a..bb352b7ba2 100644
--- a/tests/auto/corelib/mimetypes/qmimedatabase/yast2-metapackage-handler-mimetypes.xml
+++ b/tests/auto/corelib/mimetypes/qmimedatabase/yast2-metapackage-handler-mimetypes.xml
@@ -7,7 +7,7 @@
<glob pattern="*.ymp"/>
</mime-type>
- <mime-type type="text/x-suse-ymu">
+ <mime-type type="text/x-SuSE-ymu">
<comment>URL of a YaST Meta Package</comment>
<glob pattern="*.ymu"/>
</mime-type>
diff --git a/tests/auto/corelib/tools/qregularexpression/tst_qregularexpression.cpp b/tests/auto/corelib/tools/qregularexpression/tst_qregularexpression.cpp
index 6b7614b7b9..8ddd4979b6 100644
--- a/tests/auto/corelib/tools/qregularexpression/tst_qregularexpression.cpp
+++ b/tests/auto/corelib/tools/qregularexpression/tst_qregularexpression.cpp
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2012 Giuseppe D'Angelo <dangelog@gmail.com>.
-** Copyright (C) 2013 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
+** Copyright (C) 2015 Giuseppe D'Angelo <dangelog@gmail.com>.
+** Copyright (C) 2015 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
** Contact: http://www.qt.io/licensing/
**
** This file is part of the test suite of the Qt Toolkit.
@@ -306,19 +306,6 @@ static void testMatch(const QRegularExpression &regexp,
matchType,
matchOptions,
result);
-
- // offset <= 0 tested above; now also test stringrefs not spanning over
- // the entire subject. Note that the offset can be negative, hence the above
- // tests can't be merged into this one
- for (int i = 1; i <= offset; ++i) {
- testMatchImpl<QREMatch>(regexp,
- matchingMethodForStringRef,
- QStringRef(&subject, i, subject.length() - i),
- offset - i,
- matchType,
- matchOptions,
- result);
- }
}
typedef QRegularExpressionMatch (QRegularExpression::*QREMatchStringPMF)(const QString &, int, QRegularExpression::MatchType, QRegularExpression::MatchOptions) const;
@@ -737,6 +724,18 @@ void tst_QRegularExpression::normalMatch_data()
// ***
m.clear();
+ m.isValid = true; m.hasMatch = true;
+ m.captured << "bcd";
+ QTest::newRow("match12")
+ << QRegularExpression("\\Bbcd\\B")
+ << "abcde"
+ << 1
+ << QRegularExpression::MatchOptions(QRegularExpression::NoMatchOption)
+ << m;
+
+ // ***
+
+ m.clear();
m.isValid = true;
QTest::newRow("nomatch01") << QRegularExpression("\\d+")
<< "a string"
@@ -1710,3 +1709,360 @@ void tst_QRegularExpression::JOptionUsage()
re.optimize();
QCOMPARE(re.isValid(), isValid);
}
+
+void tst_QRegularExpression::QStringAndQStringRefEquivalence()
+{
+ const QString subject = QStringLiteral("Mississippi");
+ {
+ const QRegularExpression re("\\Biss\\B");
+ QVERIFY(re.isValid());
+ {
+ const QRegularExpressionMatch match = re.match(subject);
+ consistencyCheck(match);
+ QVERIFY(match.isValid());
+ QVERIFY(match.hasMatch());
+ QCOMPARE(match.captured(), QStringLiteral("iss"));
+ QCOMPARE(match.capturedStart(), 1);
+ QCOMPARE(match.capturedEnd(), 4);
+ }
+ {
+ const QRegularExpressionMatch match = re.match(QStringRef(&subject));
+ consistencyCheck(match);
+ QVERIFY(match.isValid());
+ QVERIFY(match.hasMatch());
+ QCOMPARE(match.captured(), QStringLiteral("iss"));
+ QCOMPARE(match.capturedStart(), 1);
+ QCOMPARE(match.capturedEnd(), 4);
+ }
+ {
+ const QRegularExpressionMatch match = re.match(subject, 1);
+ consistencyCheck(match);
+ QVERIFY(match.isValid());
+ QVERIFY(match.hasMatch());
+ QCOMPARE(match.captured(), QStringLiteral("iss"));
+ QCOMPARE(match.capturedStart(), 1);
+ QCOMPARE(match.capturedEnd(), 4);
+ }
+ {
+ const QRegularExpressionMatch match = re.match(QStringRef(&subject), 1);
+ consistencyCheck(match);
+ QVERIFY(match.isValid());
+ QVERIFY(match.hasMatch());
+ QCOMPARE(match.captured(), QStringLiteral("iss"));
+ QCOMPARE(match.capturedStart(), 1);
+ QCOMPARE(match.capturedEnd(), 4);
+ }
+ {
+ const QRegularExpressionMatch match = re.match(subject.mid(1));
+ consistencyCheck(match);
+ QVERIFY(match.isValid());
+ QVERIFY(match.hasMatch());
+ QCOMPARE(match.captured(), QStringLiteral("iss"));
+ QCOMPARE(match.capturedStart(), 3);
+ QCOMPARE(match.capturedEnd(), 6);
+ }
+ {
+ const QRegularExpressionMatch match = re.match(subject.midRef(1));
+ consistencyCheck(match);
+ QVERIFY(match.isValid());
+ QVERIFY(match.hasMatch());
+ QCOMPARE(match.captured(), QStringLiteral("iss"));
+ QCOMPARE(match.capturedStart(), 3);
+ QCOMPARE(match.capturedEnd(), 6);
+ }
+ {
+ const QRegularExpressionMatch match = re.match(subject.mid(1), 1);
+ consistencyCheck(match);
+ QVERIFY(match.isValid());
+ QVERIFY(match.hasMatch());
+ QCOMPARE(match.captured(), QStringLiteral("iss"));
+ QCOMPARE(match.capturedStart(), 3);
+ QCOMPARE(match.capturedEnd(), 6);
+ }
+ {
+ const QRegularExpressionMatch match = re.match(subject.midRef(1), 1);
+ consistencyCheck(match);
+ QVERIFY(match.isValid());
+ QVERIFY(match.hasMatch());
+ QCOMPARE(match.captured(), QStringLiteral("iss"));
+ QCOMPARE(match.capturedStart(), 3);
+ QCOMPARE(match.capturedEnd(), 6);
+ }
+ {
+ const QRegularExpressionMatch match = re.match(subject, 4);
+ consistencyCheck(match);
+ QVERIFY(match.isValid());
+ QVERIFY(match.hasMatch());
+ QCOMPARE(match.captured(), QStringLiteral("iss"));
+ QCOMPARE(match.capturedStart(), 4);
+ QCOMPARE(match.capturedEnd(), 7);
+ }
+ {
+ const QRegularExpressionMatch match = re.match(QStringRef(&subject), 4);
+ consistencyCheck(match);
+ QVERIFY(match.isValid());
+ QVERIFY(match.hasMatch());
+ QCOMPARE(match.captured(), QStringLiteral("iss"));
+ QCOMPARE(match.capturedStart(), 4);
+ QCOMPARE(match.capturedEnd(), 7);
+ }
+ {
+ const QRegularExpressionMatch match = re.match(subject.mid(4));
+ consistencyCheck(match);
+ QVERIFY(match.isValid());
+ QVERIFY(!match.hasMatch());
+ }
+ {
+ const QRegularExpressionMatch match = re.match(subject.midRef(4));
+ consistencyCheck(match);
+ QVERIFY(match.isValid());
+ QVERIFY(!match.hasMatch());
+ }
+
+ {
+ QRegularExpressionMatchIterator i = re.globalMatch(subject);
+ QVERIFY(i.isValid());
+
+ consistencyCheck(i);
+ QVERIFY(i.hasNext());
+ const QRegularExpressionMatch match1 = i.next();
+ consistencyCheck(match1);
+ QVERIFY(match1.isValid());
+ QVERIFY(match1.hasMatch());
+ QCOMPARE(match1.captured(), QStringLiteral("iss"));
+ QCOMPARE(match1.capturedStart(), 1);
+ QCOMPARE(match1.capturedEnd(), 4);
+
+ consistencyCheck(i);
+ QVERIFY(i.hasNext());
+ const QRegularExpressionMatch match2 = i.next();
+ consistencyCheck(match2);
+ QVERIFY(match2.isValid());
+ QVERIFY(match2.hasMatch());
+ QCOMPARE(match2.captured(), QStringLiteral("iss"));
+ QCOMPARE(match2.capturedStart(), 4);
+ QCOMPARE(match2.capturedEnd(), 7);
+
+ QVERIFY(!i.hasNext());
+ }
+ {
+ QRegularExpressionMatchIterator i = re.globalMatch(QStringRef(&subject));
+ QVERIFY(i.isValid());
+
+ consistencyCheck(i);
+ QVERIFY(i.hasNext());
+ const QRegularExpressionMatch match1 = i.next();
+ consistencyCheck(match1);
+ QVERIFY(match1.isValid());
+ QVERIFY(match1.hasMatch());
+ QCOMPARE(match1.captured(), QStringLiteral("iss"));
+ QCOMPARE(match1.capturedStart(), 1);
+ QCOMPARE(match1.capturedEnd(), 4);
+
+ consistencyCheck(i);
+ QVERIFY(i.hasNext());
+ const QRegularExpressionMatch match2 = i.next();
+ consistencyCheck(match2);
+ QVERIFY(match2.isValid());
+ QVERIFY(match2.hasMatch());
+ QCOMPARE(match2.captured(), QStringLiteral("iss"));
+ QCOMPARE(match2.capturedStart(), 4);
+ QCOMPARE(match2.capturedEnd(), 7);
+
+ QVERIFY(!i.hasNext());
+ }
+ {
+ QRegularExpressionMatchIterator i = re.globalMatch(subject, 1);
+ QVERIFY(i.isValid());
+
+ consistencyCheck(i);
+ QVERIFY(i.hasNext());
+ const QRegularExpressionMatch match1 = i.next();
+ consistencyCheck(match1);
+ QVERIFY(match1.isValid());
+ QVERIFY(match1.hasMatch());
+ QCOMPARE(match1.captured(), QStringLiteral("iss"));
+ QCOMPARE(match1.capturedStart(), 1);
+ QCOMPARE(match1.capturedEnd(), 4);
+
+ consistencyCheck(i);
+ QVERIFY(i.hasNext());
+ const QRegularExpressionMatch match2 = i.next();
+ consistencyCheck(match2);
+ QVERIFY(match2.isValid());
+ QVERIFY(match2.hasMatch());
+ QCOMPARE(match2.captured(), QStringLiteral("iss"));
+ QCOMPARE(match2.capturedStart(), 4);
+ QCOMPARE(match2.capturedEnd(), 7);
+
+ QVERIFY(!i.hasNext());
+ }
+ {
+ QRegularExpressionMatchIterator i = re.globalMatch(QStringRef(&subject), 1);
+ QVERIFY(i.isValid());
+
+ consistencyCheck(i);
+ QVERIFY(i.hasNext());
+ const QRegularExpressionMatch match1 = i.next();
+ consistencyCheck(match1);
+ QVERIFY(match1.isValid());
+ QVERIFY(match1.hasMatch());
+ QCOMPARE(match1.captured(), QStringLiteral("iss"));
+ QCOMPARE(match1.capturedStart(), 1);
+ QCOMPARE(match1.capturedEnd(), 4);
+
+ consistencyCheck(i);
+ QVERIFY(i.hasNext());
+ const QRegularExpressionMatch match2 = i.next();
+ consistencyCheck(match2);
+ QVERIFY(match2.isValid());
+ QVERIFY(match2.hasMatch());
+ QCOMPARE(match2.captured(), QStringLiteral("iss"));
+ QCOMPARE(match2.capturedStart(), 4);
+ QCOMPARE(match2.capturedEnd(), 7);
+
+ QVERIFY(!i.hasNext());
+ }
+ {
+ QRegularExpressionMatchIterator i = re.globalMatch(subject.mid(1));
+ QVERIFY(i.isValid());
+
+ consistencyCheck(i);
+ QVERIFY(i.hasNext());
+ const QRegularExpressionMatch match = i.next();
+ consistencyCheck(match);
+ QVERIFY(match.isValid());
+ QVERIFY(match.hasMatch());
+ QCOMPARE(match.captured(), QStringLiteral("iss"));
+ QCOMPARE(match.capturedStart(), 3);
+ QCOMPARE(match.capturedEnd(), 6);
+
+ QVERIFY(!i.hasNext());
+ }
+ {
+ QRegularExpressionMatchIterator i = re.globalMatch(subject.midRef(1));
+ QVERIFY(i.isValid());
+
+ consistencyCheck(i);
+ QVERIFY(i.hasNext());
+ const QRegularExpressionMatch match = i.next();
+ consistencyCheck(match);
+ QVERIFY(match.isValid());
+ QVERIFY(match.hasMatch());
+ QCOMPARE(match.captured(), QStringLiteral("iss"));
+ QCOMPARE(match.capturedStart(), 3);
+ QCOMPARE(match.capturedEnd(), 6);
+
+ QVERIFY(!i.hasNext());
+ }
+ {
+ QRegularExpressionMatchIterator i = re.globalMatch(subject.mid(1), 1);
+ QVERIFY(i.isValid());
+
+ consistencyCheck(i);
+ QVERIFY(i.hasNext());
+ const QRegularExpressionMatch match = i.next();
+ consistencyCheck(match);
+ QVERIFY(match.isValid());
+ QVERIFY(match.hasMatch());
+ QCOMPARE(match.captured(), QStringLiteral("iss"));
+ QCOMPARE(match.capturedStart(), 3);
+ QCOMPARE(match.capturedEnd(), 6);
+
+ QVERIFY(!i.hasNext());
+ }
+ {
+ QRegularExpressionMatchIterator i = re.globalMatch(subject.midRef(1), 1);
+ QVERIFY(i.isValid());
+
+ consistencyCheck(i);
+ QVERIFY(i.hasNext());
+ const QRegularExpressionMatch match = i.next();
+ consistencyCheck(match);
+ QVERIFY(match.isValid());
+ QVERIFY(match.hasMatch());
+ QCOMPARE(match.captured(), QStringLiteral("iss"));
+ QCOMPARE(match.capturedStart(), 3);
+ QCOMPARE(match.capturedEnd(), 6);
+
+ QVERIFY(!i.hasNext());
+ }
+ {
+ QRegularExpressionMatchIterator i = re.globalMatch(subject.mid(1), 1);
+ QVERIFY(i.isValid());
+
+ consistencyCheck(i);
+ QVERIFY(i.hasNext());
+ const QRegularExpressionMatch match = i.next();
+ consistencyCheck(match);
+ QVERIFY(match.isValid());
+ QVERIFY(match.hasMatch());
+ QCOMPARE(match.captured(), QStringLiteral("iss"));
+ QCOMPARE(match.capturedStart(), 3);
+ QCOMPARE(match.capturedEnd(), 6);
+
+ QVERIFY(!i.hasNext());
+ }
+ {
+ QRegularExpressionMatchIterator i = re.globalMatch(subject.midRef(1), 1);
+ QVERIFY(i.isValid());
+
+ consistencyCheck(i);
+ QVERIFY(i.hasNext());
+ const QRegularExpressionMatch match = i.next();
+ consistencyCheck(match);
+ QVERIFY(match.isValid());
+ QVERIFY(match.hasMatch());
+ QCOMPARE(match.captured(), QStringLiteral("iss"));
+ QCOMPARE(match.capturedStart(), 3);
+ QCOMPARE(match.capturedEnd(), 6);
+
+ QVERIFY(!i.hasNext());
+ }
+
+ {
+ QRegularExpressionMatchIterator i = re.globalMatch(subject, 4);
+ QVERIFY(i.isValid());
+
+ consistencyCheck(i);
+ QVERIFY(i.hasNext());
+ const QRegularExpressionMatch match = i.next();
+ consistencyCheck(match);
+ QVERIFY(match.isValid());
+ QVERIFY(match.hasMatch());
+ QCOMPARE(match.captured(), QStringLiteral("iss"));
+ QCOMPARE(match.capturedStart(), 4);
+ QCOMPARE(match.capturedEnd(), 7);
+
+ QVERIFY(!i.hasNext());
+ }
+ {
+ QRegularExpressionMatchIterator i = re.globalMatch(QStringRef(&subject), 4);
+ QVERIFY(i.isValid());
+
+ consistencyCheck(i);
+ QVERIFY(i.hasNext());
+ const QRegularExpressionMatch match = i.next();
+ consistencyCheck(match);
+ QVERIFY(match.isValid());
+ QVERIFY(match.hasMatch());
+ QCOMPARE(match.captured(), QStringLiteral("iss"));
+ QCOMPARE(match.capturedStart(), 4);
+ QCOMPARE(match.capturedEnd(), 7);
+
+ QVERIFY(!i.hasNext());
+ }
+ {
+ QRegularExpressionMatchIterator i = re.globalMatch(subject.mid(4));
+ consistencyCheck(i);
+ QVERIFY(i.isValid());
+ QVERIFY(!i.hasNext());
+ }
+ {
+ QRegularExpressionMatchIterator i = re.globalMatch(subject.midRef(4));
+ consistencyCheck(i);
+ QVERIFY(i.isValid());
+ QVERIFY(!i.hasNext());
+ }
+ }
+}
diff --git a/tests/auto/corelib/tools/qregularexpression/tst_qregularexpression.h b/tests/auto/corelib/tools/qregularexpression/tst_qregularexpression.h
index 578a4129ec..aed262d15d 100644
--- a/tests/auto/corelib/tools/qregularexpression/tst_qregularexpression.h
+++ b/tests/auto/corelib/tools/qregularexpression/tst_qregularexpression.h
@@ -72,6 +72,7 @@ private slots:
void regularExpressionMatch();
void JOptionUsage_data();
void JOptionUsage();
+ void QStringAndQStringRefEquivalence();
private:
void provideRegularExpressions();
diff --git a/tests/auto/corelib/tools/qtime/tst_qtime.cpp b/tests/auto/corelib/tools/qtime/tst_qtime.cpp
index 9a9101b7e9..213b817c3d 100644
--- a/tests/auto/corelib/tools/qtime/tst_qtime.cpp
+++ b/tests/auto/corelib/tools/qtime/tst_qtime.cpp
@@ -84,6 +84,8 @@ void tst_QTime::addSecs_data()
QTest::newRow("Data0") << QTime(0,0,0) << 200 << QTime(0,3,20);
QTest::newRow("Data1") << QTime(0,0,0) << 20 << QTime(0,0,20);
+ QTest::newRow("overflow") << QTime(0,0,0) << (INT_MAX / 1000 + 1)
+ << QTime(0,0,0).addSecs((INT_MAX / 1000 + 1) % 86400);
}
void tst_QTime::addSecs()
diff --git a/tests/auto/network/access/qnetworkreply/BLACKLIST b/tests/auto/network/access/qnetworkreply/BLACKLIST
index 7c9b8db3c3..3ec580ddde 100644
--- a/tests/auto/network/access/qnetworkreply/BLACKLIST
+++ b/tests/auto/network/access/qnetworkreply/BLACKLIST
@@ -1,16 +1,8 @@
osx
[ioGetFromBuiltinHttp:http+limited]
-osx
ubuntu-14.04
[ioGetFromBuiltinHttp:https+limited]
-osx
ubuntu-14.04
-[ioGetFromHttpBrokenServer:no-newline]
-osx
-[synchronousRequest:https]
-osx
-[SslHandshakeFailedError]
-osx
[httpAbort]
*
[backgroundRequestInterruption:ftp, bg, nobg]
diff --git a/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp b/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp
index 4d41d4beb1..debdc6bcb3 100644
--- a/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp
+++ b/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp
@@ -1078,7 +1078,7 @@ protected:
// clean up QAbstractSocket's residue:
while (client->bytesToWrite() > 0) {
qDebug() << "Still having" << client->bytesToWrite() << "bytes to write, doing that now";
- if (!client->waitForBytesWritten(2000)) {
+ if (!client->waitForBytesWritten(10000)) {
qDebug() << "ERROR: FastSender:" << client->error() << "cleaning up residue";
return;
}
@@ -1098,7 +1098,7 @@ protected:
measuredSentBytes += writeNextData(client, bytesToWrite);
while (client->bytesToWrite() > 0) {
- if (!client->waitForBytesWritten(2000)) {
+ if (!client->waitForBytesWritten(10000)) {
qDebug() << "ERROR: FastSender:" << client->error() << "during blocking write";
return;
}
@@ -8203,7 +8203,7 @@ public slots:
m_receivedData += data;
if (!m_parsedHeaders && m_receivedData.contains("\r\n\r\n")) {
m_parsedHeaders = true;
- QTimer::singleShot(qrand()%10, this, SLOT(closeDelayed())); // simulate random network latency
+ QTimer::singleShot(qrand()%60, this, SLOT(closeDelayed())); // simulate random network latency
// This server simulates a web server connection closing, e.g. because of Apaches MaxKeepAliveRequests or KeepAliveTimeout
// In this case QNAM needs to re-send the upload data but it had a bug which then corrupts the upload
// This test catches that.
@@ -8309,11 +8309,12 @@ void tst_QNetworkReply::putWithServerClosingConnectionImmediately()
// get the request started and the incoming socket connected
QTestEventLoop::instance().enterLoop(10);
+ QVERIFY(!QTestEventLoop::instance().timeout());
//qDebug() << "correct=" << server.m_correctUploads << "corrupt=" << server.m_corruptUploads << "expected=" <<numUploads;
// Sanity check because ecause of 9c2ecf89 most replies will error out but we want to make sure at least some of them worked
- QVERIFY(server.m_correctUploads > 5);
+ QVERIFY(server.m_correctUploads > 2);
// Because actually important is that we don't get any corruption:
QCOMPARE(server.m_corruptUploads, 0);
diff --git a/tests/auto/network/socket/qudpsocket/tst_qudpsocket.cpp b/tests/auto/network/socket/qudpsocket/tst_qudpsocket.cpp
index dc41a93906..2331bc19aa 100644
--- a/tests/auto/network/socket/qudpsocket/tst_qudpsocket.cpp
+++ b/tests/auto/network/socket/qudpsocket/tst_qudpsocket.cpp
@@ -848,7 +848,11 @@ void tst_QUdpSocket::writeDatagramToNonExistingPeer_data()
QTest::addColumn<bool>("bind");
QTest::addColumn<QHostAddress>("peerAddress");
QHostAddress localhost(QHostAddress::LocalHost);
- QHostAddress remote = QHostInfo::fromName(QtNetworkSettings::serverName()).addresses().first();
+ QList<QHostAddress> serverAddresses(QHostInfo::fromName(QtNetworkSettings::serverName()).addresses());
+ if (serverAddresses.isEmpty())
+ return;
+
+ QHostAddress remote = serverAddresses.first();
QTest::newRow("localhost-unbound") << false << localhost;
QTest::newRow("localhost-bound") << true << localhost;
@@ -858,6 +862,8 @@ void tst_QUdpSocket::writeDatagramToNonExistingPeer_data()
void tst_QUdpSocket::writeDatagramToNonExistingPeer()
{
+ if (QHostInfo::fromName(QtNetworkSettings::serverName()).addresses().isEmpty())
+ QFAIL("Could not find test server address");
QFETCH(bool, bind);
QFETCH(QHostAddress, peerAddress);
@@ -879,7 +885,11 @@ void tst_QUdpSocket::writeToNonExistingPeer_data()
{
QTest::addColumn<QHostAddress>("peerAddress");
QHostAddress localhost(QHostAddress::LocalHost);
- QHostAddress remote = QHostInfo::fromName(QtNetworkSettings::serverName()).addresses().first();
+ QList<QHostAddress> serverAddresses(QHostInfo::fromName(QtNetworkSettings::serverName()).addresses());
+ if (serverAddresses.isEmpty())
+ return;
+
+ QHostAddress remote = serverAddresses.first();
// write (required to be connected)
QTest::newRow("localhost") << localhost;
QTest::newRow("remote") << remote;
@@ -888,6 +898,8 @@ void tst_QUdpSocket::writeToNonExistingPeer_data()
void tst_QUdpSocket::writeToNonExistingPeer()
{
QSKIP("Connected-mode UDP sockets and their behaviour are erratic");
+ if (QHostInfo::fromName(QtNetworkSettings::serverName()).addresses().isEmpty())
+ QFAIL("Could not find test server address");
QFETCH(QHostAddress, peerAddress);
quint16 peerPort = 34534;
qRegisterMetaType<QAbstractSocket::SocketError>("QAbstractSocket::SocketError");
@@ -1114,6 +1126,9 @@ void tst_QUdpSocket::multicastTtlOption_data()
void tst_QUdpSocket::multicastTtlOption()
{
+#ifdef Q_OS_WINRT
+ QSKIP("WinRT does not support multicast.");
+#endif
QFETCH_GLOBAL(bool, setProxy);
QFETCH(QHostAddress, bindAddress);
QFETCH(int, ttl);
@@ -1156,6 +1171,9 @@ void tst_QUdpSocket::multicastLoopbackOption_data()
void tst_QUdpSocket::multicastLoopbackOption()
{
+#ifdef Q_OS_WINRT
+ QSKIP("WinRT does not support multicast.");
+#endif
QFETCH_GLOBAL(bool, setProxy);
QFETCH(QHostAddress, bindAddress);
QFETCH(int, loopback);
@@ -1186,6 +1204,9 @@ void tst_QUdpSocket::multicastJoinBeforeBind_data()
void tst_QUdpSocket::multicastJoinBeforeBind()
{
+#ifdef Q_OS_WINRT
+ QSKIP("WinRT does not support multicast.");
+#endif
QFETCH(QHostAddress, groupAddress);
QUdpSocket udpSocket;
@@ -1206,6 +1227,9 @@ void tst_QUdpSocket::multicastLeaveAfterClose_data()
void tst_QUdpSocket::multicastLeaveAfterClose()
{
+#ifdef Q_OS_WINRT
+ QSKIP("WinRT does not support multicast.");
+#endif
QFETCH_GLOBAL(bool, setProxy);
QFETCH(QHostAddress, groupAddress);
if (setProxy)
@@ -1247,6 +1271,9 @@ void tst_QUdpSocket::setMulticastInterface_data()
void tst_QUdpSocket::setMulticastInterface()
{
+#ifdef Q_OS_WINRT
+ QSKIP("WinRT does not support multicast.");
+#endif
QFETCH_GLOBAL(bool, setProxy);
QFETCH(QNetworkInterface, iface);
QFETCH(QHostAddress, address);
@@ -1295,6 +1322,9 @@ void tst_QUdpSocket::multicast_data()
void tst_QUdpSocket::multicast()
{
+#ifdef Q_OS_WINRT
+ QSKIP("WinRT does not support multicast.");
+#endif
QFETCH_GLOBAL(bool, setProxy);
QFETCH(QHostAddress, bindAddress);
QFETCH(bool, bindResult);
diff --git a/tests/auto/other/qaccessibility/tst_qaccessibility.cpp b/tests/auto/other/qaccessibility/tst_qaccessibility.cpp
index 69007bd250..62c2c0a916 100644
--- a/tests/auto/other/qaccessibility/tst_qaccessibility.cpp
+++ b/tests/auto/other/qaccessibility/tst_qaccessibility.cpp
@@ -1715,7 +1715,7 @@ static QRect characterRect(const QTextEdit &edit, int offset)
int h = fm.height();
qreal x = line.cursorToX(relativeOffset);
- QRect r(layoutPosition.x() + x, layoutPosition.y() + line.y(), w, h);
+ QRect r(layoutPosition.x() + x, layoutPosition.y() + line.y() + line.ascent() + fm.descent() - h, w, h);
r.moveTo(edit.viewport()->mapToGlobal(r.topLeft()));
return r;
diff --git a/tests/auto/widgets/widgets/qlineedit/tst_qlineedit.cpp b/tests/auto/widgets/widgets/qlineedit/tst_qlineedit.cpp
index 5c8f6eeeb8..a41d80d7dd 100644
--- a/tests/auto/widgets/widgets/qlineedit/tst_qlineedit.cpp
+++ b/tests/auto/widgets/widgets/qlineedit/tst_qlineedit.cpp
@@ -306,6 +306,7 @@ private slots:
void clearButton();
void clearButtonVisibleAfterSettingText_QTBUG_45518();
void sideWidgets();
+ void sideWidgetsActionEvents();
void shouldShowPlaceholderText_data();
void shouldShowPlaceholderText();
@@ -4318,6 +4319,13 @@ void tst_QLineEdit::clearButtonVisibleAfterSettingText_QTBUG_45518()
#endif // QT_BUILD_INTERNAL
}
+static inline QIcon sideWidgetTestIcon()
+{
+ QImage image(QSize(20, 20), QImage::Format_ARGB32);
+ image.fill(Qt::yellow);
+ return QIcon(QPixmap::fromImage(image));
+}
+
void tst_QLineEdit::sideWidgets()
{
QWidget testWidget;
@@ -4325,9 +4333,7 @@ void tst_QLineEdit::sideWidgets()
QLineEdit *lineEdit = new QLineEdit(&testWidget);
l->addWidget(lineEdit);
l->addSpacerItem(new QSpacerItem(0, 50, QSizePolicy::Ignored, QSizePolicy::Fixed));
- QImage image(QSize(20, 20), QImage::Format_ARGB32);
- image.fill(Qt::yellow);
- QAction *iconAction = new QAction(QIcon(QPixmap::fromImage(image)), QString(), lineEdit);
+ QAction *iconAction = new QAction(sideWidgetTestIcon(), QString(), lineEdit);
QWidgetAction *label1Action = new QWidgetAction(lineEdit);
label1Action->setDefaultWidget(new QLabel(QStringLiteral("l1")));
QWidgetAction *label2Action = new QWidgetAction(lineEdit);
@@ -4354,6 +4360,38 @@ void tst_QLineEdit::sideWidgets()
lineEdit->addAction(iconAction);
}
+void tst_QLineEdit::sideWidgetsActionEvents()
+{
+ // QTBUG-39660, verify whether action events are handled by the widget.
+ QWidget testWidget;
+ QVBoxLayout *l = new QVBoxLayout(&testWidget);
+ QLineEdit *lineEdit = new QLineEdit(&testWidget);
+ l->addWidget(lineEdit);
+ l->addSpacerItem(new QSpacerItem(0, 50, QSizePolicy::Ignored, QSizePolicy::Fixed));
+ QAction *iconAction = lineEdit->addAction(sideWidgetTestIcon(), QLineEdit::LeadingPosition);
+ testWidget.move(300, 300);
+ testWidget.show();
+ QVERIFY(QTest::qWaitForWindowExposed(&testWidget));
+
+ QWidget *toolButton = Q_NULLPTR;
+ foreach (QWidget *w, iconAction->associatedWidgets()) {
+ if (qobject_cast<QToolButton *>(w)) {
+ toolButton = w;
+ break;
+ }
+ }
+ QVERIFY(toolButton);
+
+ QVERIFY(toolButton->isVisible());
+ QVERIFY(toolButton->isEnabled());
+
+ iconAction->setEnabled(false);
+ QVERIFY(!toolButton->isEnabled());
+
+ iconAction->setVisible(false);
+ QVERIFY(!toolButton->isVisible());
+}
+
Q_DECLARE_METATYPE(Qt::AlignmentFlag)
void tst_QLineEdit::shouldShowPlaceholderText_data()
{
diff --git a/tests/auto/widgets/widgets/qmenubar/tst_qmenubar.cpp b/tests/auto/widgets/widgets/qmenubar/tst_qmenubar.cpp
index 9e24f373eb..baf60551c4 100644
--- a/tests/auto/widgets/widgets/qmenubar/tst_qmenubar.cpp
+++ b/tests/auto/widgets/widgets/qmenubar/tst_qmenubar.cpp
@@ -128,7 +128,7 @@ private slots:
void taskQTBUG4965_escapeEaten();
#endif
void taskQTBUG11823_crashwithInvisibleActions();
- void closeOnSecondClick();
+ void closeOnSecondClickAndOpenOnThirdClick();
void cornerWidgets_data();
void cornerWidgets();
@@ -1312,7 +1312,7 @@ void tst_QMenuBar::taskQTBUG11823_crashwithInvisibleActions()
QCOMPARE(menubar.activeAction(), m); //the active action shouldn't have changed
}
-void tst_QMenuBar::closeOnSecondClick() // QTBUG-32807, menu should close on 2nd click.
+void tst_QMenuBar::closeOnSecondClickAndOpenOnThirdClick() // QTBUG-32807, menu should close on 2nd click.
{
QMainWindow mainWindow;
mainWindow.resize(300, 200);
@@ -1322,17 +1322,20 @@ void tst_QMenuBar::closeOnSecondClick() // QTBUG-32807, menu should close on 2nd
#endif
QMenuBar *menuBar = mainWindow.menuBar();
menuBar->setNativeMenuBar(false);
- QMenu *fileMenu = menuBar->addMenu(QStringLiteral("closeOnSecondClick"));
+ QMenu *fileMenu = menuBar->addMenu(QStringLiteral("OpenCloseOpen"));
fileMenu->addAction(QStringLiteral("Quit"));
mainWindow.show();
QApplication::setActiveWindow(&mainWindow);
QVERIFY(QTest::qWaitForWindowActive(&mainWindow));
const QPoint center = menuBar->actionGeometry(fileMenu->menuAction()).center();
+ const QPoint globalPos = menuBar->mapToGlobal(center);
QTest::mouseMove(menuBar, center);
QTest::mouseClick(menuBar, Qt::LeftButton, 0, center);
QTRY_VERIFY(fileMenu->isVisible());
- QTest::mouseClick(menuBar, Qt::LeftButton, 0, center);
+ QTest::mouseClick(fileMenu, Qt::LeftButton, 0, fileMenu->mapFromGlobal(globalPos));
QTRY_VERIFY(!fileMenu->isVisible());
+ QTest::mouseClick(menuBar, Qt::LeftButton, 0, center);
+ QTRY_VERIFY(fileMenu->isVisible());
}
Q_DECLARE_METATYPE(Qt::Corner)