summaryrefslogtreecommitdiffstats
path: root/tests/auto
diff options
context:
space:
mode:
authorLiang Qi <liang.qi@qt.io>2017-10-30 08:43:14 +0100
committerLiang Qi <liang.qi@qt.io>2017-10-30 08:54:05 +0100
commit17d51411132edef53e79dcbaf1046f06f79bed5d (patch)
tree38398d448b30313f91960c70a3a28cce91293da9 /tests/auto
parentea0e868c4881944207e9b3a77011e05a505ff3b7 (diff)
parent9f0dda29d5d070f63b7f098139f01f07ec91ffdf (diff)
Merge remote-tracking branch 'origin/5.9' into 5.10
Conflicts: src/plugins/platforms/windows/qwindowswindow.cpp tests/auto/widgets/kernel/qaction/tst_qaction.cpp Change-Id: Ia017a825ed2ca2d53ac586f4ae48df6f65818d40
Diffstat (limited to 'tests/auto')
-rw-r--r--tests/auto/corelib/io/qfile/tst_qfile.cpp92
-rw-r--r--tests/auto/corelib/io/qfileselector/platforms/+qnx/test0
-rw-r--r--tests/auto/corelib/io/qfileselector/platforms/+qnx/test20
-rw-r--r--tests/auto/corelib/io/qfileselector/platforms/+unix/+qnx/test0
-rw-r--r--tests/auto/corelib/io/qfileselector/qfileselector.qrc3
-rw-r--r--tests/auto/corelib/io/qfileselector/tst_qfileselector.cpp2
-rw-r--r--tests/auto/corelib/io/qurl/tst_qurl.cpp35
-rw-r--r--tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp83
-rw-r--r--tests/auto/other/qaccessibility/tst_qaccessibility.cpp27
-rw-r--r--tests/auto/sql/kernel/qsqldatabase/tst_qsqldatabase.cpp2
-rw-r--r--tests/auto/widgets/dialogs/qwizard/tst_qwizard.cpp20
-rw-r--r--tests/auto/widgets/kernel/qaction/tst_qaction.cpp16
-rw-r--r--tests/auto/widgets/widgets/qmenubar/tst_qmenubar.cpp10
13 files changed, 232 insertions, 58 deletions
diff --git a/tests/auto/corelib/io/qfile/tst_qfile.cpp b/tests/auto/corelib/io/qfile/tst_qfile.cpp
index 7bf45be58c..9026864b12 100644
--- a/tests/auto/corelib/io/qfile/tst_qfile.cpp
+++ b/tests/auto/corelib/io/qfile/tst_qfile.cpp
@@ -109,6 +109,30 @@ QT_END_NAMESPACE
Q_DECLARE_METATYPE(QFile::FileError)
+
+class StdioFileGuard
+{
+ Q_DISABLE_COPY(StdioFileGuard)
+public:
+ explicit StdioFileGuard(FILE *f = nullptr) : m_file(f) {}
+ ~StdioFileGuard() { close(); }
+
+ operator FILE *() const { return m_file; }
+
+ void close();
+
+private:
+ FILE * m_file;
+};
+
+void StdioFileGuard::close()
+{
+ if (m_file != nullptr) {
+ fclose(m_file);
+ m_file = nullptr;
+ }
+}
+
class tst_QFile : public QObject
{
Q_OBJECT
@@ -660,14 +684,13 @@ void tst_QFile::size()
}
{
- QFile f;
- FILE* stream = QT_FOPEN(filename.toLocal8Bit().constData(), "rb");
+ StdioFileGuard stream(QT_FOPEN(filename.toLocal8Bit().constData(), "rb"));
QVERIFY( stream );
+ QFile f;
QVERIFY( f.open(stream, QIODevice::ReadOnly) );
QCOMPARE( f.size(), size );
f.close();
- fclose(stream);
}
{
@@ -1592,12 +1615,34 @@ void tst_QFile::writeTextFile()
}
#if defined(Q_OS_WIN) && !defined(Q_OS_WINRT)
+// Helper for executing QFile::open() with warning in QTRY_VERIFY(), which evaluates the condition
+// multiple times
+static bool qFileOpen(QFile &file, QIODevice::OpenMode ioFlags)
+{
+ const bool result = file.isOpen() || file.open(ioFlags);
+ if (!result)
+ qWarning() << "Cannot open" << file.fileName() << ':' << file.errorString();
+ return result;
+}
+
+// Helper for executing fopen() with warning in QTRY_VERIFY(), which evaluates the condition
+// multiple times
+static bool fOpen(const QByteArray &fileName, const char *mode, FILE **file)
+{
+ if (*file == nullptr)
+ *file = fopen(fileName.constData(), mode);
+ if (*file == nullptr)
+ qWarning("Cannot open %s: %s", fileName.constData(), strerror(errno));
+ return *file != nullptr;
+}
+
void tst_QFile::largeUncFileSupport()
{
qint64 size = Q_INT64_C(8589934592);
qint64 dataOffset = Q_INT64_C(8589914592);
QByteArray knownData("LargeFile content at offset 8589914592");
QString largeFile("//" + QtNetworkSettings::winServerName() + "/testsharelargefile/file.bin");
+ const QByteArray largeFileEncoded = QFile::encodeName(largeFile);
{
// 1) Native file handling.
@@ -1605,31 +1650,36 @@ void tst_QFile::largeUncFileSupport()
QVERIFY2(file.exists(), msgFileDoesNotExist(largeFile));
QCOMPARE(file.size(), size);
- QVERIFY2(file.open(QIODevice::ReadOnly), msgOpenFailed(file).constData());
+ // Retry in case of sharing violation
+ QTRY_VERIFY2(qFileOpen(file, QIODevice::ReadOnly), msgOpenFailed(file).constData());
QCOMPARE(file.size(), size);
QVERIFY(file.seek(dataOffset));
QCOMPARE(file.read(knownData.size()), knownData);
}
{
// 2) stdlib file handling.
+ FILE *fhF = nullptr;
+ // Retry in case of sharing violation
+ QTRY_VERIFY(fOpen(largeFileEncoded, "rb", &fhF));
+ StdioFileGuard fh(fhF);
QFile file;
- FILE *fh = fopen(QFile::encodeName(largeFile).data(), "rb");
QVERIFY(file.open(fh, QIODevice::ReadOnly));
QCOMPARE(file.size(), size);
QVERIFY(file.seek(dataOffset));
QCOMPARE(file.read(knownData.size()), knownData);
- fclose(fh);
}
{
// 3) stdio file handling.
- QFile file;
- FILE *fh = fopen(QFile::encodeName(largeFile).data(), "rb");
+ FILE *fhF = nullptr;
+ // Retry in case of sharing violation
+ QTRY_VERIFY(fOpen(largeFileEncoded, "rb", &fhF));
+ StdioFileGuard fh(fhF);
int fd = int(_fileno(fh));
+ QFile file;
QVERIFY(file.open(fd, QIODevice::ReadOnly));
QCOMPARE(file.size(), size);
QVERIFY(file.seek(dataOffset));
QCOMPARE(file.read(knownData.size()), knownData);
- fclose(fh);
}
}
#endif
@@ -1670,7 +1720,7 @@ void tst_QFile::bufferedRead()
file.write("abcdef");
file.close();
- FILE *stdFile = fopen("stdfile.txt", "r");
+ StdioFileGuard stdFile(fopen("stdfile.txt", "r"));
QVERIFY(stdFile);
char c;
QCOMPARE(int(fread(&c, 1, 1, stdFile)), 1);
@@ -1685,8 +1735,6 @@ void tst_QFile::bufferedRead()
QCOMPARE(c, 'b');
QCOMPARE(file.pos(), qlonglong(2));
}
-
- fclose(stdFile);
}
#ifdef Q_OS_UNIX
@@ -1815,7 +1863,7 @@ void tst_QFile::FILEReadWrite()
f.close();
}
- FILE *fp = fopen("FILEReadWrite.txt", "r+b");
+ StdioFileGuard fp(fopen("FILEReadWrite.txt", "r+b"));
QVERIFY(fp);
QFile file;
QVERIFY2(file.open(fp, QFile::ReadWrite), msgOpenFailed(file).constData());
@@ -1850,7 +1898,7 @@ void tst_QFile::FILEReadWrite()
}
file.close();
- fclose(fp);
+ fp.close();
// check modified file
{
@@ -2436,11 +2484,10 @@ void tst_QFile::virtualFile()
void tst_QFile::textFile()
{
-#if defined(Q_OS_WIN)
- FILE *fs = ::fopen("writeabletextfile", "wt");
-#else
- FILE *fs = ::fopen("writeabletextfile", "w");
-#endif
+ const char *openMode = QOperatingSystemVersion::current().type() != QOperatingSystemVersion::Windows
+ ? "w" : "wt";
+ StdioFileGuard fs(fopen("writeabletextfile", openMode));
+ QVERIFY(fs);
QFile f;
QByteArray part1("This\nis\na\nfile\nwith\nnewlines\n");
QByteArray part2("Add\nsome\nmore\nnewlines\n");
@@ -2449,7 +2496,7 @@ void tst_QFile::textFile()
f.write(part1);
f.write(part2);
f.close();
- ::fclose(fs);
+ fs.close();
QFile file("writeabletextfile");
QVERIFY2(file.open(QIODevice::ReadOnly), msgOpenFailed(file).constData());
@@ -2705,11 +2752,12 @@ void tst_QFile::handle()
//test round trip of adopted stdio file handle
QFile file2;
- FILE *fp = fopen(qPrintable(m_testSourceFile), "r");
+ StdioFileGuard fp(fopen(qPrintable(m_testSourceFile), "r"));
+ QVERIFY(fp);
file2.open(fp, QIODevice::ReadOnly);
QCOMPARE(int(file2.handle()), int(fileno(fp)));
QCOMPARE(int(file2.handle()), int(fileno(fp)));
- fclose(fp);
+ fp.close();
//test round trip of adopted posix file handle
#ifdef Q_OS_UNIX
diff --git a/tests/auto/corelib/io/qfileselector/platforms/+qnx/test b/tests/auto/corelib/io/qfileselector/platforms/+qnx/test
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/tests/auto/corelib/io/qfileselector/platforms/+qnx/test
diff --git a/tests/auto/corelib/io/qfileselector/platforms/+qnx/test2 b/tests/auto/corelib/io/qfileselector/platforms/+qnx/test2
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/tests/auto/corelib/io/qfileselector/platforms/+qnx/test2
diff --git a/tests/auto/corelib/io/qfileselector/platforms/+unix/+qnx/test b/tests/auto/corelib/io/qfileselector/platforms/+unix/+qnx/test
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/tests/auto/corelib/io/qfileselector/platforms/+unix/+qnx/test
diff --git a/tests/auto/corelib/io/qfileselector/qfileselector.qrc b/tests/auto/corelib/io/qfileselector/qfileselector.qrc
index ea9b8270e0..54b2e0a0e2 100644
--- a/tests/auto/corelib/io/qfileselector/qfileselector.qrc
+++ b/tests/auto/corelib/io/qfileselector/qfileselector.qrc
@@ -21,6 +21,7 @@
<file>platforms/+unix/+darwin/test</file>
<file>platforms/+unix/+haiku/test</file>
<file>platforms/+unix/+linux/test</file>
+ <file>platforms/+unix/+qnx/test</file>
<file>platforms/+unix/test</file>
<file>platforms/+windows/+wince/test</file>
<file>platforms/+windows/+winnt/test</file>
@@ -34,6 +35,7 @@
<file>platforms/+mac/test</file>
<file>platforms/+haiku/test</file>
<file>platforms/+linux/test</file>
+ <file>platforms/+qnx/test</file>
<file>platforms/+wince/test</file>
<file>platforms/+winrt/test</file>
@@ -44,6 +46,7 @@
<file>platforms/+macos/test2</file>
<file>platforms/+haiku/test2</file>
<file>platforms/+linux/test2</file>
+ <file>platforms/+qnx/test2</file>
<file>platforms/+wince/test2</file>
<file>platforms/+winnt/test2</file>
<file>platforms/+winrt/test2</file>
diff --git a/tests/auto/corelib/io/qfileselector/tst_qfileselector.cpp b/tests/auto/corelib/io/qfileselector/tst_qfileselector.cpp
index c537e43802..c9f1e3d9f6 100644
--- a/tests/auto/corelib/io/qfileselector/tst_qfileselector.cpp
+++ b/tests/auto/corelib/io/qfileselector/tst_qfileselector.cpp
@@ -86,7 +86,7 @@ void tst_QFileSelector::basicTest_data()
QString expectedPlatform2File(""); //Only the last selector
QString expectedPlatform3File; // Only the first selector (the family)
#if defined(Q_OS_UNIX) && !defined(Q_OS_ANDROID) && \
- !defined(Q_OS_DARWIN) && !defined(Q_OS_LINUX) && !defined(Q_OS_HAIKU)
+ !defined(Q_OS_DARWIN) && !defined(Q_OS_LINUX) && !defined(Q_OS_HAIKU) && !defined(Q_OS_QNX)
/* We are only aware of specific unixes, and do not have test files for any of the others.
However those unixes can get a selector added from the result of a uname call, so this will
lead to a case where we don't have that file so we can't expect the concatenation of platform
diff --git a/tests/auto/corelib/io/qurl/tst_qurl.cpp b/tests/auto/corelib/io/qurl/tst_qurl.cpp
index 400a89c03f..20282068cb 100644
--- a/tests/auto/corelib/io/qurl/tst_qurl.cpp
+++ b/tests/auto/corelib/io/qurl/tst_qurl.cpp
@@ -2063,6 +2063,11 @@ void tst_QUrl::isValid()
QVERIFY(!url.isValid());
QVERIFY(url.toString().isEmpty());
QVERIFY(url.errorString().contains("Path component starts with '//' and authority is absent"));
+
+ // should disappear if we set a port
+ url.setPort(80);
+ QVERIFY(url.isValid());
+ QCOMPARE(url.toString(), QString("http://:80//example.com"));
}
{
@@ -2071,6 +2076,13 @@ void tst_QUrl::isValid()
QVERIFY(!url.isValid());
QVERIFY(url.toString().isEmpty());
QVERIFY(url.errorString().contains("':' before any '/'"));
+
+ // this specific error disappears if we set anything in the authority,
+ // but then we run into another error
+ url.setPort(80);
+ QVERIFY(!url.isValid());
+ QVERIFY(url.toString().isEmpty());
+ QVERIFY(url.errorString().contains("Path component is relative and authority is present"));
}
{
@@ -2810,6 +2822,29 @@ void tst_QUrl::setPort()
QCOMPARE(url.port(), -1);
QVERIFY(url.errorString().contains("out of range"));
}
+
+ {
+ QUrl reference("//:80");
+ QUrl piecewise;
+ piecewise.setPort(80);
+ QCOMPARE(piecewise, reference);
+ }
+
+ {
+ // setAuthority must clear the port
+ QUrl url("http://example.com:80");
+ url.setAuthority("example.org");
+ QCOMPARE(url.port(), -1);
+ QCOMPARE(url.toString(), QString("http://example.org"));
+ }
+
+ {
+ // setAuthority must clear the port
+ QUrl url("http://example.com:80");
+ url.setAuthority(QString());
+ QCOMPARE(url.port(), -1);
+ QCOMPARE(url.toString(), QString("http:"));
+ }
}
void tst_QUrl::port_data()
diff --git a/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp b/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp
index d22850ba4e..93afca3d48 100644
--- a/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp
+++ b/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp
@@ -491,10 +491,12 @@ private Q_SLOTS:
void ioHttpRedirect_data();
void ioHttpRedirect();
void ioHttpRedirectFromLocalToRemote();
- void ioHttpRedirectPost_data();
- void ioHttpRedirectPost();
+ void ioHttpRedirectPostPut_data();
+ void ioHttpRedirectPostPut();
void ioHttpRedirectMultipartPost_data();
void ioHttpRedirectMultipartPost();
+ void ioHttpRedirectDelete();
+ void ioHttpRedirectCustom();
#ifndef QT_NO_SSL
void putWithServerClosingConnectionImmediately();
#endif
@@ -546,7 +548,7 @@ static void setupSslServer(QSslSocket* serverSocket)
}
#endif
-// Does not work for PUT! Limited support for POST.
+// Limited support for POST and PUT.
class MiniHttpServer: public QTcpServer
{
Q_OBJECT
@@ -678,7 +680,7 @@ public slots:
if (doubleEndlPos != -1) {
const int endOfHeader = doubleEndlPos + 4;
- hasContent = receivedData.startsWith("POST");
+ hasContent = receivedData.startsWith("POST") || receivedData.startsWith("PUT");
if (hasContent && contentLength == 0)
parseContentLength();
contentRead = receivedData.length() - endOfHeader;
@@ -8546,37 +8548,46 @@ void tst_QNetworkReply::ioHttpRedirectFromLocalToRemote()
QCOMPARE(reply->readAll(), reference.readAll());
}
-void tst_QNetworkReply::ioHttpRedirectPost_data()
+void tst_QNetworkReply::ioHttpRedirectPostPut_data()
{
+ QTest::addColumn<bool>("usePost");
QTest::addColumn<QString>("status");
QTest::addColumn<QByteArray>("data");
QTest::addColumn<QString>("contentType");
QByteArray data;
data = "hello world";
- QTest::addRow("307") << "307 Temporary Redirect" << data << "text/plain";
+ QTest::addRow("post-307") << true << "307 Temporary Redirect" << data << "text/plain";
+ QTest::addRow("put-307") << false << "307 Temporary Redirect" << data << "text/plain";
QString permanentRedirect = "308 Permanent Redirect";
- QTest::addRow("308") << permanentRedirect << data << "text/plain";
+ QTest::addRow("post-308") << true << permanentRedirect << data << "text/plain";
+ QTest::addRow("put-308") << false << permanentRedirect << data << "text/plain";
// Some data from ::putToFile_data
data = "";
- QTest::newRow("empty") << permanentRedirect << data << "application/octet-stream";
+ QTest::newRow("post-empty") << true << permanentRedirect << data << "application/octet-stream";
+ QTest::newRow("put-empty") << false << permanentRedirect << data << "application/octet-stream";
data = QByteArray("abcd\0\1\2\abcd",12);
- QTest::newRow("with-nul") << permanentRedirect << data << "application/octet-stream";
+ QTest::newRow("post-with-nul") << true << permanentRedirect << data << "application/octet-stream";
+ QTest::newRow("put-with-nul") << false << permanentRedirect << data << "application/octet-stream";
data = QByteArray(4097, '\4');
- QTest::newRow("4k+1") << permanentRedirect << data << "application/octet-stream";
+ QTest::newRow("post-4k+1") << true << permanentRedirect << data << "application/octet-stream";
+ QTest::newRow("put-4k+1") << false << permanentRedirect << data << "application/octet-stream";
data = QByteArray(128*1024+1, '\177');
- QTest::newRow("128k+1") << permanentRedirect << data << "application/octet-stream";
+ QTest::newRow("post-128k+1") << true << permanentRedirect << data << "application/octet-stream";
+ QTest::newRow("put-128k+1") << false << permanentRedirect << data << "application/octet-stream";
data = QByteArray(2*1024*1024+1, '\177');
- QTest::newRow("2MB+1") << permanentRedirect << data << "application/octet-stream";
+ QTest::newRow("post-2MB+1") << true << permanentRedirect << data << "application/octet-stream";
+ QTest::newRow("put-2MB+1") << false << permanentRedirect << data << "application/octet-stream";
}
-void tst_QNetworkReply::ioHttpRedirectPost()
+void tst_QNetworkReply::ioHttpRedirectPostPut()
{
+ QFETCH(bool, usePost);
QFETCH(QString, status);
QFETCH(QByteArray, data);
QFETCH(QString, contentType);
@@ -8595,7 +8606,7 @@ void tst_QNetworkReply::ioHttpRedirectPost()
auto oldRedirectPolicy = manager.redirectPolicy();
manager.setRedirectPolicy(QNetworkRequest::RedirectPolicy::NoLessSafeRedirectPolicy);
- QNetworkReplyPtr reply(manager.post(request, data));
+ QNetworkReplyPtr reply(usePost ? manager.post(request, data) : manager.put(request, data));
// Restore previous policy:
manager.setRedirectPolicy(oldRedirectPolicy);
@@ -8664,6 +8675,50 @@ void tst_QNetworkReply::ioHttpRedirectMultipartPost()
QCOMPARE(replyData, expectedReplyData);
}
+void tst_QNetworkReply::ioHttpRedirectDelete()
+{
+ MiniHttpServer target(httpEmpty200Response, false);
+ QUrl targetUrl("http://localhost/");
+ targetUrl.setPort(target.serverPort());
+
+ QString redirectReply = tempRedirectReplyStr().arg(targetUrl.toString());
+ MiniHttpServer redirectServer(redirectReply.toLatin1());
+ QUrl url("http://localhost/");
+ url.setPort(redirectServer.serverPort());
+ QNetworkRequest request(url);
+ auto oldRedirectPolicy = manager.redirectPolicy();
+ manager.setRedirectPolicy(QNetworkRequest::RedirectPolicy::NoLessSafeRedirectPolicy);
+
+ QNetworkReplyPtr reply(manager.deleteResource(request));
+ // Restore previous policy:
+ manager.setRedirectPolicy(oldRedirectPolicy);
+
+ QCOMPARE(waitForFinish(reply), int(Success));
+ QVERIFY2(target.receivedData.startsWith("DELETE"), "Target server called with the wrong method");
+}
+
+void tst_QNetworkReply::ioHttpRedirectCustom()
+{
+ MiniHttpServer target(httpEmpty200Response, false);
+ QUrl targetUrl("http://localhost/");
+ targetUrl.setPort(target.serverPort());
+
+ QString redirectReply = tempRedirectReplyStr().arg(targetUrl.toString());
+ MiniHttpServer redirectServer(redirectReply.toLatin1());
+ QUrl url("http://localhost/");
+ url.setPort(redirectServer.serverPort());
+ QNetworkRequest request(url);
+ auto oldRedirectPolicy = manager.redirectPolicy();
+ manager.setRedirectPolicy(QNetworkRequest::RedirectPolicy::NoLessSafeRedirectPolicy);
+
+ QNetworkReplyPtr reply(manager.sendCustomRequest(request, QByteArrayLiteral("CUSTOM")));
+ // Restore previous policy:
+ manager.setRedirectPolicy(oldRedirectPolicy);
+
+ QCOMPARE(waitForFinish(reply), int(Success));
+ QVERIFY2(target.receivedData.startsWith("CUSTOM"), "Target server called with the wrong method");
+}
+
#ifndef QT_NO_SSL
class PutWithServerClosingConnectionImmediatelyHandler: public QObject
diff --git a/tests/auto/other/qaccessibility/tst_qaccessibility.cpp b/tests/auto/other/qaccessibility/tst_qaccessibility.cpp
index e73af60e74..dc8de72b2a 100644
--- a/tests/auto/other/qaccessibility/tst_qaccessibility.cpp
+++ b/tests/auto/other/qaccessibility/tst_qaccessibility.cpp
@@ -47,6 +47,7 @@
#include <qpa/qplatformintegration.h>
#include <qpa/qplatformaccessibility.h>
#include <QtGui/private/qguiapplication_p.h>
+#include <QtGui/private/qhighdpiscaling_p.h>
#if defined(Q_OS_WIN) && defined(interface)
# undef interface
@@ -301,6 +302,7 @@ void tst_QAccessibility::cleanup()
qAccessibleEventString(list.at(i)->type()), list.at(i)->child());
}
QTestAccessibility::clearEvents();
+ QTRY_VERIFY(QApplication::topLevelWidgets().isEmpty());
}
void tst_QAccessibility::eventTest()
@@ -3743,14 +3745,14 @@ void tst_QAccessibility::bridgeTest()
// Ideally it should be extended to test all aspects of the bridge.
#if defined(Q_OS_WIN) && !defined(Q_OS_WINRT)
// First, test MSAA part of bridge
- QWidget *window = new QWidget;
- QVBoxLayout *lay = new QVBoxLayout(window);
- QPushButton *button = new QPushButton(tr("Push me"), window);
- QTextEdit *te = new QTextEdit(window);
+ QWidget window;
+ QVBoxLayout *lay = new QVBoxLayout(&window);
+ QPushButton *button = new QPushButton(tr("Push me"), &window);
+ QTextEdit *te = new QTextEdit(&window);
te->setText(QLatin1String("hello world\nhow are you today?\n"));
// Add QTableWidget
- QTableWidget *tableWidget = new QTableWidget(3, 3, window);
+ QTableWidget *tableWidget = new QTableWidget(3, 3, &window);
tableWidget->setColumnCount(3);
QStringList hHeader;
hHeader << "h1" << "h2" << "h3";
@@ -3776,8 +3778,8 @@ void tst_QAccessibility::bridgeTest()
lay->addWidget(tableWidget);
lay->addWidget(label);
- window->show();
- QVERIFY(QTest::qWaitForWindowExposed(window));
+ window.show();
+ QVERIFY(QTest::qWaitForWindowExposed(&window));
/**************************************************
@@ -3789,9 +3791,8 @@ void tst_QAccessibility::bridgeTest()
QCOMPARE(buttonRect.topLeft(), buttonPos);
// All set, now test the bridge.
- POINT pt;
- pt.x = buttonRect.center().x();
- pt.y = buttonRect.center().y();
+ const QPoint nativePos = QHighDpi::toNativePixels(buttonRect.center(), window.windowHandle());
+ POINT pt{nativePos.x(), nativePos.y()};
IAccessible *iaccButton;
VARIANT varChild;
@@ -3817,7 +3818,7 @@ void tst_QAccessibility::bridgeTest()
QCOMPARE(SUCCEEDED(hr), false);
hr = iaccButton->accLocation(&x, &y, &w, &h, varSELF);
- QCOMPARE(buttonRect, QRect(x, y, w, h));
+ QCOMPARE(buttonRect, QHighDpi::fromNativePixels(QRect(x, y, w, h), window.windowHandle()));
#ifdef QT_SUPPORTS_IACCESSIBLE2
// Test IAccessible2 part of bridge
@@ -3832,7 +3833,7 @@ void tst_QAccessibility::bridgeTest()
long x, y;
hr = ia2Component->get_locationInParent(&x, &y);
QVERIFY(SUCCEEDED(hr));
- QCOMPARE(button->pos(), QPoint(x, y));
+ QCOMPARE(button->pos(), QHighDpi::fromNativePixels(QPoint(x, y), window.windowHandle()));
ia2Component->Release();
/***** Test IAccessibleAction *****/
@@ -3897,7 +3898,7 @@ void tst_QAccessibility::bridgeTest()
/**************************************************
* QWidget
**************************************************/
- QWindow *windowHandle = window->windowHandle();
+ QWindow *windowHandle = window.windowHandle();
QPlatformNativeInterface *platform = QGuiApplication::platformNativeInterface();
HWND hWnd = (HWND)platform->nativeResourceForWindow("handle", windowHandle);
diff --git a/tests/auto/sql/kernel/qsqldatabase/tst_qsqldatabase.cpp b/tests/auto/sql/kernel/qsqldatabase/tst_qsqldatabase.cpp
index 9b0d5b6920..4395a04976 100644
--- a/tests/auto/sql/kernel/qsqldatabase/tst_qsqldatabase.cpp
+++ b/tests/auto/sql/kernel/qsqldatabase/tst_qsqldatabase.cpp
@@ -1252,7 +1252,7 @@ void tst_QSqlDatabase::psql_schemas()
QString table = schemaName + '.' + qTableName("qtesttable", __FILE__, db);
QVERIFY_SQL(q, exec("CREATE TABLE " + table + " (id int primary key, name varchar(20))"));
- QVERIFY(db.tables().contains(table));
+ QVERIFY(db.tables().contains(table, Qt::CaseInsensitive));
QSqlRecord rec = db.record(table);
QCOMPARE(rec.count(), 2);
diff --git a/tests/auto/widgets/dialogs/qwizard/tst_qwizard.cpp b/tests/auto/widgets/dialogs/qwizard/tst_qwizard.cpp
index db86fba59c..6ad93b2666 100644
--- a/tests/auto/widgets/dialogs/qwizard/tst_qwizard.cpp
+++ b/tests/auto/widgets/dialogs/qwizard/tst_qwizard.cpp
@@ -96,6 +96,7 @@ private slots:
void task248107_backButton();
void task255350_fieldObjectDestroyed();
void taskQTBUG_25691_fieldObjectDestroyed2();
+ void taskQTBUG_46894_nextButtonShortcut();
/*
Things that could be added:
@@ -2700,5 +2701,24 @@ void tst_QWizard::taskQTBUG_25691_fieldObjectDestroyed2()
::taskQTBUG_25691_fieldObjectDestroyed2();
}
+void tst_QWizard::taskQTBUG_46894_nextButtonShortcut()
+{
+ for (int i = 0; i < QWizard::NStyles; ++i) {
+ QWizard wizard;
+ QWizard::WizardStyle style = static_cast<QWizard::WizardStyle>(i);
+ wizard.setWizardStyle(style);
+ wizard.show();
+ QVERIFY(QTest::qWaitForWindowExposed(&wizard));
+
+ if (wizard.button(QWizard::NextButton)->text() == "&Next") {
+ QCOMPARE(wizard.button(QWizard::NextButton)->shortcut(),
+ QKeySequence(Qt::ALT | Qt::Key_Right));
+ } else {
+ QCOMPARE(wizard.button(QWizard::NextButton)->shortcut(),
+ QKeySequence::mnemonic(wizard.button(QWizard::NextButton)->text()));
+ }
+ }
+}
+
QTEST_MAIN(tst_QWizard)
#include "tst_qwizard.moc"
diff --git a/tests/auto/widgets/kernel/qaction/tst_qaction.cpp b/tests/auto/widgets/kernel/qaction/tst_qaction.cpp
index ac6362168e..4b3db6bd9c 100644
--- a/tests/auto/widgets/kernel/qaction/tst_qaction.cpp
+++ b/tests/auto/widgets/kernel/qaction/tst_qaction.cpp
@@ -62,6 +62,7 @@ private slots:
void task229128TriggeredSignalWithoutActiongroup();
void task229128TriggeredSignalWhenInActiongroup();
void repeat();
+ void setData();
void keysequence(); // QTBUG-53381
private:
@@ -443,5 +444,20 @@ void tst_QAction::repeat()
QCOMPARE(spy.count(), 2);
}
+void tst_QAction::setData() // QTBUG-62006
+{
+ QAction act(nullptr);
+ QSignalSpy spy(&act, &QAction::changed);
+ QCOMPARE(act.data(), QVariant());
+ QCOMPARE(spy.count(), 0);
+ act.setData(QVariant());
+ QCOMPARE(spy.count(), 0);
+
+ act.setData(-1);
+ QCOMPARE(spy.count(), 1);
+ act.setData(-1);
+ QCOMPARE(spy.count(), 1);
+}
+
QTEST_MAIN(tst_QAction)
#include "tst_qaction.moc"
diff --git a/tests/auto/widgets/widgets/qmenubar/tst_qmenubar.cpp b/tests/auto/widgets/widgets/qmenubar/tst_qmenubar.cpp
index 9a70208b94..bc50e4f1d8 100644
--- a/tests/auto/widgets/widgets/qmenubar/tst_qmenubar.cpp
+++ b/tests/auto/widgets/widgets/qmenubar/tst_qmenubar.cpp
@@ -719,9 +719,7 @@ void tst_QMenuBar::taskQTBUG56860_focus()
#endif
QMainWindow w;
QMenuBar *mb = w.menuBar();
-
- if (mb->platformMenuBar())
- QSKIP("This test requires the Qt menubar.");
+ mb->setNativeMenuBar(false);
QMenu *em = mb->addMenu("&Edit");
em->setObjectName("EditMenu");
@@ -765,8 +763,7 @@ void tst_QMenuBar::check_homeKey()
{
// I'm temporarily shutting up this testcase.
// Seems like the behaviour i'm expecting isn't ok.
- QVERIFY( true );
- return;
+ QSKIP("This test has been \"temporarily\" disabled at least since 2009 :)");
QEXPECT_FAIL( "0", "Popupmenu should respond to a Home key", Abort );
@@ -807,8 +804,7 @@ void tst_QMenuBar::check_endKey()
{
// I'm temporarily silenting this testcase.
// Seems like the behaviour i'm expecting isn't ok.
- QVERIFY( true );
- return;
+ QSKIP("This test has been \"temporarily\" disabled at least since 2009 :)");
QEXPECT_FAIL( "0", "Popupmenu should respond to an End key", Abort );