summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorAllan Sandfeld Jensen <allan.jensen@theqtcompany.com>2015-05-08 13:22:49 +0200
committerAllan Sandfeld Jensen <allan.jensen@theqtcompany.com>2015-05-08 13:26:44 +0200
commit1fce111809f216383e60f56b57a9f68ccd2b766f (patch)
tree521d560ae28354ec495ee49e2abf4cfd28303c3f /tests
parente6ffb36b5517d1d4025718b56423db9bdf0a63f8 (diff)
parent3545ef41217e3ce4d1bea2b07793fa7a8c1058a6 (diff)
Merge remote-tracking branch 'origin/5.4' into merge5.5
Conflicts: src/corelib/global/qglobal.h src/corelib/io/qnoncontiguousbytedevice_p.h src/gui/image/qjpeghandler.cpp src/network/access/qhttpthreaddelegate_p.h tests/auto/corelib/io/qlockfile/tst_qlockfile.cpp tests/auto/widgets/widgets/qmenubar/BLACKLIST Change-Id: I01de8c1c28efcedfd7953d05025f54802dc08ab3
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/corelib/io/qlockfile/tst_qlockfile.cpp17
-rw-r--r--tests/auto/dbus/qdbustype/tst_qdbustype.cpp13
-rw-r--r--tests/auto/gui/image/qimage/images/jpeg_exif_orientation_value_1.jpgbin910 -> 0 bytes
-rw-r--r--tests/auto/gui/image/qimage/images/jpeg_exif_orientation_value_2.jpgbin910 -> 0 bytes
-rw-r--r--tests/auto/gui/image/qimage/images/jpeg_exif_orientation_value_3.jpgbin988 -> 0 bytes
-rw-r--r--tests/auto/gui/image/qimage/images/jpeg_exif_orientation_value_4.jpgbin995 -> 0 bytes
-rw-r--r--tests/auto/gui/image/qimage/images/jpeg_exif_orientation_value_5.jpgbin912 -> 0 bytes
-rw-r--r--tests/auto/gui/image/qimage/images/jpeg_exif_orientation_value_6.jpgbin911 -> 0 bytes
-rw-r--r--tests/auto/gui/image/qimage/images/jpeg_exif_orientation_value_6_motorola.jpgbin911 -> 0 bytes
-rw-r--r--tests/auto/gui/image/qimage/images/jpeg_exif_orientation_value_7.jpgbin987 -> 0 bytes
-rw-r--r--tests/auto/gui/image/qimage/images/jpeg_exif_orientation_value_8.jpgbin991 -> 0 bytes
-rw-r--r--tests/auto/gui/image/qimage/tst_qimage.cpp33
-rw-r--r--tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp175
-rw-r--r--tests/auto/tools/moc/tst_moc.cpp6
-rw-r--r--tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp53
-rw-r--r--tests/auto/widgets/widgets/qmenu/BLACKLIST2
-rw-r--r--tests/auto/widgets/widgets/qmenubar/BLACKLIST2
17 files changed, 258 insertions, 43 deletions
diff --git a/tests/auto/corelib/io/qlockfile/tst_qlockfile.cpp b/tests/auto/corelib/io/qlockfile/tst_qlockfile.cpp
index bef3d3a012..8d890e81fa 100644
--- a/tests/auto/corelib/io/qlockfile/tst_qlockfile.cpp
+++ b/tests/auto/corelib/io/qlockfile/tst_qlockfile.cpp
@@ -62,6 +62,7 @@ private slots:
void staleLockRace();
void noPermissions();
void noPermissionsWindows();
+ void corruptedLockFile();
public:
QString m_helperApp;
@@ -480,5 +481,21 @@ void tst_QLockFile::noPermissionsWindows()
QCOMPARE(int(lockFile.error()), int(QLockFile::PermissionError));
}
+void tst_QLockFile::corruptedLockFile()
+{
+ const QString fileName = dir.path() + "/corruptedLockFile";
+
+ {
+ // Create a empty file. Typically the result of a computer crash or hard disk full.
+ QFile file(fileName);
+ QVERIFY(file.open(QFile::WriteOnly));
+ }
+
+ QLockFile secondLock(fileName);
+ secondLock.setStaleLockTime(100);
+ QVERIFY(secondLock.tryLock(10000));
+ QCOMPARE(int(secondLock.error()), int(QLockFile::NoError));
+}
+
QTEST_MAIN(tst_QLockFile)
#include "tst_qlockfile.moc"
diff --git a/tests/auto/dbus/qdbustype/tst_qdbustype.cpp b/tests/auto/dbus/qdbustype/tst_qdbustype.cpp
index ced73dbf3b..63444b61ad 100644
--- a/tests/auto/dbus/qdbustype/tst_qdbustype.cpp
+++ b/tests/auto/dbus/qdbustype/tst_qdbustype.cpp
@@ -87,8 +87,19 @@ static void addFixedTypes()
QTest::newRow("int64") << DBUS_TYPE_INT64_AS_STRING << true << true;
QTest::newRow("uint64") << DBUS_TYPE_UINT64_AS_STRING << true << true;
QTest::newRow("double") << DBUS_TYPE_DOUBLE_AS_STRING << true << true;
+
#ifdef DBUS_TYPE_UNIX_FD_AS_STRING
- QTest::newRow("unixfd") << DBUS_TYPE_UNIX_FD_AS_STRING << true << true;
+# ifndef QT_LINKED_LIBDBUS
+ // We have got the macro from dbus_minimal_p.h, so we need to check if
+ // the library recognizes this as valid type first.
+ // The following function was added for Unix FD support, so if it is
+ // present, so is support for Unix FDs.
+ bool supportsUnixFds = qdbus_resolve_conditionally("dbus_connection_can_send_type");
+# else
+ bool supportsUnixFds = true;
+# endif
+ if (supportsUnixFds)
+ QTest::newRow("unixfd") << DBUS_TYPE_UNIX_FD_AS_STRING << true << true;
#endif
}
diff --git a/tests/auto/gui/image/qimage/images/jpeg_exif_orientation_value_1.jpg b/tests/auto/gui/image/qimage/images/jpeg_exif_orientation_value_1.jpg
deleted file mode 100644
index aaa4ac4e10..0000000000
--- a/tests/auto/gui/image/qimage/images/jpeg_exif_orientation_value_1.jpg
+++ /dev/null
Binary files differ
diff --git a/tests/auto/gui/image/qimage/images/jpeg_exif_orientation_value_2.jpg b/tests/auto/gui/image/qimage/images/jpeg_exif_orientation_value_2.jpg
deleted file mode 100644
index a61d2723d7..0000000000
--- a/tests/auto/gui/image/qimage/images/jpeg_exif_orientation_value_2.jpg
+++ /dev/null
Binary files differ
diff --git a/tests/auto/gui/image/qimage/images/jpeg_exif_orientation_value_3.jpg b/tests/auto/gui/image/qimage/images/jpeg_exif_orientation_value_3.jpg
deleted file mode 100644
index 43e56dcef7..0000000000
--- a/tests/auto/gui/image/qimage/images/jpeg_exif_orientation_value_3.jpg
+++ /dev/null
Binary files differ
diff --git a/tests/auto/gui/image/qimage/images/jpeg_exif_orientation_value_4.jpg b/tests/auto/gui/image/qimage/images/jpeg_exif_orientation_value_4.jpg
deleted file mode 100644
index d5d06f7409..0000000000
--- a/tests/auto/gui/image/qimage/images/jpeg_exif_orientation_value_4.jpg
+++ /dev/null
Binary files differ
diff --git a/tests/auto/gui/image/qimage/images/jpeg_exif_orientation_value_5.jpg b/tests/auto/gui/image/qimage/images/jpeg_exif_orientation_value_5.jpg
deleted file mode 100644
index 1886f3775e..0000000000
--- a/tests/auto/gui/image/qimage/images/jpeg_exif_orientation_value_5.jpg
+++ /dev/null
Binary files differ
diff --git a/tests/auto/gui/image/qimage/images/jpeg_exif_orientation_value_6.jpg b/tests/auto/gui/image/qimage/images/jpeg_exif_orientation_value_6.jpg
deleted file mode 100644
index 5cec757354..0000000000
--- a/tests/auto/gui/image/qimage/images/jpeg_exif_orientation_value_6.jpg
+++ /dev/null
Binary files differ
diff --git a/tests/auto/gui/image/qimage/images/jpeg_exif_orientation_value_6_motorola.jpg b/tests/auto/gui/image/qimage/images/jpeg_exif_orientation_value_6_motorola.jpg
deleted file mode 100644
index 0aa164b78b..0000000000
--- a/tests/auto/gui/image/qimage/images/jpeg_exif_orientation_value_6_motorola.jpg
+++ /dev/null
Binary files differ
diff --git a/tests/auto/gui/image/qimage/images/jpeg_exif_orientation_value_7.jpg b/tests/auto/gui/image/qimage/images/jpeg_exif_orientation_value_7.jpg
deleted file mode 100644
index b3dcc466a9..0000000000
--- a/tests/auto/gui/image/qimage/images/jpeg_exif_orientation_value_7.jpg
+++ /dev/null
Binary files differ
diff --git a/tests/auto/gui/image/qimage/images/jpeg_exif_orientation_value_8.jpg b/tests/auto/gui/image/qimage/images/jpeg_exif_orientation_value_8.jpg
deleted file mode 100644
index 8bc390e2b9..0000000000
--- a/tests/auto/gui/image/qimage/images/jpeg_exif_orientation_value_8.jpg
+++ /dev/null
Binary files differ
diff --git a/tests/auto/gui/image/qimage/tst_qimage.cpp b/tests/auto/gui/image/qimage/tst_qimage.cpp
index 2931185c8b..62a9f19f36 100644
--- a/tests/auto/gui/image/qimage/tst_qimage.cpp
+++ b/tests/auto/gui/image/qimage/tst_qimage.cpp
@@ -181,9 +181,6 @@ private slots:
void invertPixelsRGB_data();
void invertPixelsRGB();
- void exifOrientation_data();
- void exifOrientation();
-
void cleanupFunctions();
void devicePixelRatio();
@@ -2813,36 +2810,6 @@ void tst_QImage::invertPixelsRGB()
QCOMPARE(qBlue(pixel) >> 4, (255 - 96) >> 4);
}
-void tst_QImage::exifOrientation_data()
-{
- QTest::addColumn<QString>("fileName");
- QTest::newRow("Orientation 1, Intel format") << m_prefix + "jpeg_exif_orientation_value_1.jpg";
- QTest::newRow("Orientation 2, Intel format") << m_prefix + "jpeg_exif_orientation_value_2.jpg";
- QTest::newRow("Orientation 3, Intel format") << m_prefix + "jpeg_exif_orientation_value_3.jpg";
- QTest::newRow("Orientation 4, Intel format") << m_prefix + "jpeg_exif_orientation_value_4.jpg";
- QTest::newRow("Orientation 5, Intel format") << m_prefix + "jpeg_exif_orientation_value_5.jpg";
- QTest::newRow("Orientation 6, Intel format") << m_prefix + "jpeg_exif_orientation_value_6.jpg";
- QTest::newRow("Orientation 6, Motorola format") << m_prefix + "jpeg_exif_orientation_value_6_motorola.jpg";
- QTest::newRow("Orientation 7, Intel format") << m_prefix + "jpeg_exif_orientation_value_7.jpg";
- QTest::newRow("Orientation 8, Intel format") << m_prefix + "jpeg_exif_orientation_value_8.jpg";
-}
-
-void tst_QImage::exifOrientation()
-{
- QFETCH(QString, fileName);
-
- QImage img;
- QRgb px;
-
- QVERIFY(img.load(fileName));
-
- px = img.pixel(0, 0);
- QVERIFY(qRed(px) > 250 && qGreen(px) < 5 && qBlue(px) < 5);
-
- px = img.pixel(img.width() - 1, 0);
- QVERIFY(qRed(px) < 5 && qGreen(px) < 5 && qBlue(px) > 250);
-}
-
static void cleanupFunction(void* info)
{
bool *called = static_cast<bool*>(info);
diff --git a/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp b/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp
index c63cfaf6b6..262b380446 100644
--- a/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp
+++ b/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp
@@ -456,6 +456,10 @@ private Q_SLOTS:
void putWithRateLimiting();
+#ifndef QT_NO_SSL
+ void putWithServerClosingConnectionImmediately();
+#endif
+
// NOTE: This test must be last!
void parentingRepliesToTheApp();
private:
@@ -4723,18 +4727,22 @@ void tst_QNetworkReply::ioPostToHttpNoBufferFlag()
class SslServer : public QTcpServer {
Q_OBJECT
public:
- SslServer() : socket(0) {};
+ SslServer() : socket(0), m_ssl(true) {}
void incomingConnection(qintptr socketDescriptor) {
QSslSocket *serverSocket = new QSslSocket;
serverSocket->setParent(this);
if (serverSocket->setSocketDescriptor(socketDescriptor)) {
+ connect(serverSocket, SIGNAL(readyRead()), this, SLOT(readyReadSlot()));
+ if (!m_ssl) {
+ emit newPlainConnection(serverSocket);
+ return;
+ }
QString testDataDir = QFileInfo(QFINDTESTDATA("rfc3252.txt")).absolutePath();
if (testDataDir.isEmpty())
testDataDir = QCoreApplication::applicationDirPath();
connect(serverSocket, SIGNAL(encrypted()), this, SLOT(encryptedSlot()));
- connect(serverSocket, SIGNAL(readyRead()), this, SLOT(readyReadSlot()));
serverSocket->setProtocol(QSsl::AnyProtocol);
connect(serverSocket, SIGNAL(sslErrors(QList<QSslError>)), serverSocket, SLOT(ignoreSslErrors()));
serverSocket->setLocalCertificate(testDataDir + "/certs/server.pem");
@@ -4745,11 +4753,12 @@ public:
}
}
signals:
- void newEncryptedConnection();
+ void newEncryptedConnection(QSslSocket *s);
+ void newPlainConnection(QSslSocket *s);
public slots:
void encryptedSlot() {
socket = (QSslSocket*) sender();
- emit newEncryptedConnection();
+ emit newEncryptedConnection(socket);
}
void readyReadSlot() {
// for the incoming sockets, not the server socket
@@ -4758,6 +4767,7 @@ public slots:
public:
QSslSocket *socket;
+ bool m_ssl;
};
// very similar to ioPostToHttpUploadProgress but for SSL
@@ -4785,7 +4795,7 @@ void tst_QNetworkReply::ioPostToHttpsUploadProgress()
QNetworkReplyPtr reply(manager.post(request, sourceFile));
QSignalSpy spy(reply.data(), SIGNAL(uploadProgress(qint64,qint64)));
- connect(&server, SIGNAL(newEncryptedConnection()), &QTestEventLoop::instance(), SLOT(exitLoop()));
+ connect(&server, SIGNAL(newEncryptedConnection(QSslSocket*)), &QTestEventLoop::instance(), SLOT(exitLoop()));
connect(reply, SIGNAL(sslErrors(QList<QSslError>)), reply.data(), SLOT(ignoreSslErrors()));
// get the request started and the incoming socket connected
@@ -4793,7 +4803,7 @@ void tst_QNetworkReply::ioPostToHttpsUploadProgress()
QVERIFY(!QTestEventLoop::instance().timeout());
QTcpSocket *incomingSocket = server.socket;
QVERIFY(incomingSocket);
- disconnect(&server, SIGNAL(newEncryptedConnection()), &QTestEventLoop::instance(), SLOT(exitLoop()));
+ disconnect(&server, SIGNAL(newEncryptedConnection(QSslSocket*)), &QTestEventLoop::instance(), SLOT(exitLoop()));
incomingSocket->setReadBufferSize(1*1024);
@@ -7963,6 +7973,159 @@ void tst_QNetworkReply::putWithRateLimiting()
}
+#ifndef QT_NO_SSL
+
+class PutWithServerClosingConnectionImmediatelyHandler: public QObject
+{
+ Q_OBJECT
+public:
+ bool m_parsedHeaders;
+ QByteArray m_receivedData;
+ QByteArray m_expectedData;
+ QSslSocket *m_socket;
+ PutWithServerClosingConnectionImmediatelyHandler(QSslSocket *s, QByteArray expected) :m_parsedHeaders(false), m_expectedData(expected), m_socket(s)
+ {
+ m_socket->setParent(this);
+ connect(m_socket, SIGNAL(readyRead()), SLOT(readyReadSlot()));
+ connect(m_socket, SIGNAL(disconnected()), SLOT(disconnectedSlot()));
+ }
+signals:
+ void correctFileUploadReceived();
+ void corruptFileUploadReceived();
+
+public slots:
+ void closeDelayed() {
+ m_socket->close();
+ }
+
+ void readyReadSlot()
+ {
+ QByteArray data = m_socket->readAll();
+ 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
+ // 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.
+ }
+
+ }
+ void disconnectedSlot()
+ {
+ if (m_parsedHeaders) {
+ //qDebug() << m_receivedData.left(m_receivedData.indexOf("\r\n\r\n"));
+ m_receivedData = m_receivedData.mid(m_receivedData.indexOf("\r\n\r\n")+4); // check only actual data
+ }
+ if (m_receivedData.length() > 0 && !m_expectedData.startsWith(m_receivedData)) {
+ // We had received some data but it is corrupt!
+ qDebug() << "CORRUPT" << m_receivedData.count();
+
+ // Use this to track down the pattern of the corruption and conclude the source
+// QFile a("/tmp/corrupt");
+// a.open(QIODevice::WriteOnly);
+// a.write(m_receivedData);
+// a.close();
+
+// QFile b("/tmp/correct");
+// b.open(QIODevice::WriteOnly);
+// b.write(m_expectedData);
+// b.close();
+ //exit(1);
+ emit corruptFileUploadReceived();
+ } else {
+ emit correctFileUploadReceived();
+ }
+ }
+};
+
+class PutWithServerClosingConnectionImmediatelyServer: public SslServer
+{
+ Q_OBJECT
+public:
+ int m_correctUploads;
+ int m_corruptUploads;
+ int m_repliesFinished;
+ int m_expectedReplies;
+ QByteArray m_expectedData;
+ PutWithServerClosingConnectionImmediatelyServer() : SslServer(), m_correctUploads(0), m_corruptUploads(0), m_repliesFinished(0), m_expectedReplies(0)
+ {
+ QObject::connect(this, SIGNAL(newEncryptedConnection(QSslSocket*)), this, SLOT(createHandlerForConnection(QSslSocket*)));
+ QObject::connect(this, SIGNAL(newPlainConnection(QSslSocket*)), this, SLOT(createHandlerForConnection(QSslSocket*)));
+ }
+
+public slots:
+ void createHandlerForConnection(QSslSocket* s) {
+ PutWithServerClosingConnectionImmediatelyHandler *handler = new PutWithServerClosingConnectionImmediatelyHandler(s, m_expectedData);
+ handler->setParent(this);
+ QObject::connect(handler, SIGNAL(correctFileUploadReceived()), this, SLOT(increaseCorrect()));
+ QObject::connect(handler, SIGNAL(corruptFileUploadReceived()), this, SLOT(increaseCorrupt()));
+ }
+ void increaseCorrect() {
+ m_correctUploads++;
+ }
+ void increaseCorrupt() {
+ m_corruptUploads++;
+ }
+ void replyFinished() {
+ m_repliesFinished++;
+ if (m_repliesFinished == m_expectedReplies) {
+ QTestEventLoop::instance().exitLoop();
+ }
+ }
+};
+
+
+
+void tst_QNetworkReply::putWithServerClosingConnectionImmediately()
+{
+ const int numUploads = 40;
+ qint64 wantedSize = 512*1024; // 512 kB
+ QByteArray sourceFile;
+ for (int i = 0; i < wantedSize; ++i) {
+ sourceFile += (char)'a' +(i%26);
+ }
+ bool withSsl = false;
+
+ for (int s = 0; s <= 1; s++) {
+ withSsl = (s == 1);
+ // Test also needs to run several times because of 9c2ecf89
+ for (int j = 0; j < 20; j++) {
+ // emulate a minimal https server
+ PutWithServerClosingConnectionImmediatelyServer server;
+ server.m_ssl = withSsl;
+ server.m_expectedData = sourceFile;
+ server.m_expectedReplies = numUploads;
+ server.listen(QHostAddress(QHostAddress::LocalHost), 0);
+
+ for (int i = 0; i < numUploads; i++) {
+ // create the request
+ QUrl url = QUrl(QString("http%1://127.0.0.1:%2/file=%3").arg(withSsl ? "s" : "").arg(server.serverPort()).arg(i));
+ QNetworkRequest request(url);
+ QNetworkReply *reply = manager.put(request, sourceFile);
+ connect(reply, SIGNAL(sslErrors(QList<QSslError>)), reply, SLOT(ignoreSslErrors()));
+ connect(reply, SIGNAL(finished()), &server, SLOT(replyFinished()));
+ reply->setParent(&server);
+ }
+
+ // get the request started and the incoming socket connected
+ QTestEventLoop::instance().enterLoop(10);
+
+ //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);
+ // Because actually important is that we don't get any corruption:
+ QCOMPARE(server.m_corruptUploads, 0);
+
+ server.close();
+ }
+ }
+
+
+}
+
+#endif
// NOTE: This test must be last testcase in tst_qnetworkreply!
void tst_QNetworkReply::parentingRepliesToTheApp()
diff --git a/tests/auto/tools/moc/tst_moc.cpp b/tests/auto/tools/moc/tst_moc.cpp
index 00e5c60b29..405d273f4b 100644
--- a/tests/auto/tools/moc/tst_moc.cpp
+++ b/tests/auto/tools/moc/tst_moc.cpp
@@ -680,7 +680,7 @@ void tst_Moc::oldStyleCasts()
QStringList args;
args << "-c" << "-x" << "c++" << "-Wold-style-cast" << "-I" << "."
- << "-I" << qtIncludePath << "-o" << "/dev/null" << "-fPIE" << "-";
+ << "-I" << qtIncludePath << "-o" << "/dev/null" << "-fPIC" << "-";
proc.start("gcc", args);
QVERIFY(proc.waitForStarted());
proc.write(mocOut);
@@ -750,7 +750,7 @@ void tst_Moc::inputFileNameWithDotsButNoExtension()
QStringList args;
args << "-c" << "-x" << "c++" << "-I" << ".."
- << "-I" << qtIncludePath << "-o" << "/dev/null" << "-fPIE" << "-";
+ << "-I" << qtIncludePath << "-o" << "/dev/null" << "-fPIC" << "-";
proc.start("gcc", args);
QVERIFY(proc.waitForStarted());
proc.write(mocOut);
@@ -1029,7 +1029,7 @@ void tst_Moc::ignoreOptionClashes()
// If -pthread wasn't ignored, it was parsed as a prefix of "thread/", which breaks compilation.
QStringList gccArgs;
gccArgs << "-c" << "-x" << "c++" << "-I" << ".."
- << "-I" << qtIncludePath << "-I" << includeDir << "-o" << "/dev/null" << "-fPIE" << "-";
+ << "-I" << qtIncludePath << "-I" << includeDir << "-o" << "/dev/null" << "-fPIC" << "-";
proc.start("gcc", gccArgs);
QVERIFY(proc.waitForStarted());
proc.write(mocOut);
diff --git a/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp b/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp
index f623c0ab00..085677315d 100644
--- a/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp
+++ b/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp
@@ -436,6 +436,7 @@ private slots:
void grabKeyboard();
void touchEventSynthesizedMouseEvent();
+ void touchUpdateOnNewTouch();
void styleSheetPropagation();
@@ -9757,6 +9758,9 @@ class TouchMouseWidget : public QWidget {
public:
explicit TouchMouseWidget(QWidget *parent = 0)
: QWidget(parent),
+ m_touchBeginCount(0),
+ m_touchUpdateCount(0),
+ m_touchEndCount(0),
m_touchEventCount(0),
m_acceptTouch(false),
m_mouseEventCount(0),
@@ -9783,6 +9787,12 @@ protected:
case QEvent::TouchBegin:
case QEvent::TouchUpdate:
case QEvent::TouchEnd:
+ if (e->type() == QEvent::TouchBegin)
+ ++m_touchBeginCount;
+ else if (e->type() == QEvent::TouchUpdate)
+ ++m_touchUpdateCount;
+ else if (e->type() == QEvent::TouchEnd)
+ ++m_touchEndCount;
++m_touchEventCount;
if (m_acceptTouch)
e->accept();
@@ -9807,6 +9817,9 @@ protected:
}
public:
+ int m_touchBeginCount;
+ int m_touchUpdateCount;
+ int m_touchEndCount;
int m_touchEventCount;
bool m_acceptTouch;
int m_mouseEventCount;
@@ -9923,6 +9936,46 @@ void tst_QWidget::touchEventSynthesizedMouseEvent()
}
}
+void tst_QWidget::touchUpdateOnNewTouch()
+{
+ QTouchDevice *device = new QTouchDevice;
+ device->setType(QTouchDevice::TouchScreen);
+ QWindowSystemInterface::registerTouchDevice(device);
+
+ TouchMouseWidget widget;
+ widget.setAcceptTouch(true);
+ QVBoxLayout *layout = new QVBoxLayout;
+ layout->addWidget(new QWidget);
+ widget.setLayout(layout);
+ widget.show();
+
+ QWindow* window = widget.windowHandle();
+ QVERIFY(QTest::qWaitForWindowExposed(window));
+ QCOMPARE(widget.m_touchBeginCount, 0);
+ QCOMPARE(widget.m_touchUpdateCount, 0);
+ QCOMPARE(widget.m_touchEndCount, 0);
+ QTest::touchEvent(window, device).press(0, QPoint(20, 20), window);
+ QCOMPARE(widget.m_touchBeginCount, 1);
+ QCOMPARE(widget.m_touchUpdateCount, 0);
+ QCOMPARE(widget.m_touchEndCount, 0);
+ QTest::touchEvent(window, device).move(0, QPoint(25, 25), window);
+ QCOMPARE(widget.m_touchBeginCount, 1);
+ QCOMPARE(widget.m_touchUpdateCount, 1);
+ QCOMPARE(widget.m_touchEndCount, 0);
+ QTest::touchEvent(window, device).stationary(0).press(1, QPoint(40, 40), window);
+ QCOMPARE(widget.m_touchBeginCount, 1);
+ QCOMPARE(widget.m_touchUpdateCount, 2);
+ QCOMPARE(widget.m_touchEndCount, 0);
+ QTest::touchEvent(window, device).stationary(1).release(0, QPoint(25, 25), window);
+ QCOMPARE(widget.m_touchBeginCount, 1);
+ QCOMPARE(widget.m_touchUpdateCount, 3);
+ QCOMPARE(widget.m_touchEndCount, 0);
+ QTest::touchEvent(window, device).release(1, QPoint(40, 40), window);
+ QCOMPARE(widget.m_touchBeginCount, 1);
+ QCOMPARE(widget.m_touchUpdateCount, 3);
+ QCOMPARE(widget.m_touchEndCount, 1);
+}
+
void tst_QWidget::styleSheetPropagation()
{
QTableView tw;
diff --git a/tests/auto/widgets/widgets/qmenu/BLACKLIST b/tests/auto/widgets/widgets/qmenu/BLACKLIST
new file mode 100644
index 0000000000..de49d5ff45
--- /dev/null
+++ b/tests/auto/widgets/widgets/qmenu/BLACKLIST
@@ -0,0 +1,2 @@
+[task258920_mouseBorder]
+osx
diff --git a/tests/auto/widgets/widgets/qmenubar/BLACKLIST b/tests/auto/widgets/widgets/qmenubar/BLACKLIST
index 53ea4a9148..424ab2ceed 100644
--- a/tests/auto/widgets/widgets/qmenubar/BLACKLIST
+++ b/tests/auto/widgets/widgets/qmenubar/BLACKLIST
@@ -2,3 +2,5 @@
ubuntu-14.04
[taskQTBUG4965_escapeEaten]
ubuntu-14.04
+[task256322_highlight]
+osx