summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorLiang Qi <liang.qi@theqtcompany.com>2016-04-13 06:55:37 +0200
committerLiang Qi <liang.qi@theqtcompany.com>2016-04-13 06:55:37 +0200
commitb94773c9c838a0b3db1bced0bc8daf5b04aefc29 (patch)
tree4afe809fa3ac8a83f5eaf98d0b40d4bbf7b5fca4 /tests
parentc327fb79e1a50c825a945e97f2c66d07a1c6d225 (diff)
parent541c9d4d2acd045459c3e75eee80c63b36af9ed0 (diff)
Merge remote-tracking branch 'origin/5.6' into 5.7
Conflicts: config.tests/unix/compile.test src/android/jar/src/org/qtproject/qt5/android/QtActivityDelegate.java src/testlib/qtestcase.cpp src/testlib/qtestcase.qdoc Change-Id: Ied3c471dbc9a076c8de33d673bd557e88575609d
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/corelib/io/qfile/tst_qfile.cpp4
-rw-r--r--tests/auto/corelib/io/qipaddress/tst_qipaddress.cpp8
-rw-r--r--tests/auto/corelib/io/qlockfile/tst_qlockfile.cpp10
-rw-r--r--tests/auto/corelib/tools/qstringbuilder/qstringbuilder1/stringbuilder.cpp5
-rw-r--r--tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp10
-rw-r--r--tests/auto/network/kernel/qhostaddress/tst_qhostaddress.cpp17
-rw-r--r--tests/auto/network/socket/qlocalsocket/tst_qlocalsocket.cpp3
-rw-r--r--tests/auto/widgets/widgets/qfontcombobox/BLACKLIST6
-rw-r--r--tests/auto/widgets/widgets/qfontcombobox/tst_qfontcombobox.cpp20
-rw-r--r--tests/manual/network_remote_stresstest/tst_network_remote_stresstest.cpp2
-rw-r--r--tests/manual/network_stresstest/tst_network_stresstest.cpp2
-rw-r--r--tests/manual/qscreen/main.cpp67
12 files changed, 131 insertions, 23 deletions
diff --git a/tests/auto/corelib/io/qfile/tst_qfile.cpp b/tests/auto/corelib/io/qfile/tst_qfile.cpp
index 0d912d7b3c..411c73fb90 100644
--- a/tests/auto/corelib/io/qfile/tst_qfile.cpp
+++ b/tests/auto/corelib/io/qfile/tst_qfile.cpp
@@ -539,6 +539,10 @@ void tst_QFile::open_data()
<< false << QFile::OpenError;
QTest::newRow("noreadfile") << QString::fromLatin1(noReadFile) << int(QIODevice::ReadOnly)
<< false << QFile::OpenError;
+ QTest::newRow("resource_file") << QString::fromLatin1(":/does/not/exist")
+ << int(QIODevice::ReadOnly)
+ << false
+ << QFile::OpenError;
#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) && !defined(Q_OS_WINRT)
//opening devices requires administrative privileges (and elevation).
HANDLE hTest = CreateFile(_T("\\\\.\\PhysicalDrive0"), GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0, NULL);
diff --git a/tests/auto/corelib/io/qipaddress/tst_qipaddress.cpp b/tests/auto/corelib/io/qipaddress/tst_qipaddress.cpp
index 5ecd1723c0..ba5e9eaaa1 100644
--- a/tests/auto/corelib/io/qipaddress/tst_qipaddress.cpp
+++ b/tests/auto/corelib/io/qipaddress/tst_qipaddress.cpp
@@ -181,6 +181,7 @@ void tst_QIpAddress::invalidParseIp4_data()
QTest::newRow("..") << "..";
QTest::newRow("...") << "...";
QTest::newRow("....") << "....";
+ QTest::newRow(".1.2.3") << ".1.2.3";
QTest::newRow("1.") << "1.";
QTest::newRow("1.2.") << "1.2.";
QTest::newRow("1.2.3.") << "1.2.3.";
@@ -209,9 +210,15 @@ void tst_QIpAddress::invalidParseIp4_data()
QTest::newRow("-1.1") << "-1.1";
QTest::newRow("1.-1") << "1.-1";
QTest::newRow("1.1.1.-1") << "1.1.1.-1";
+ QTest::newRow("300-05") << "300-05";
+ QTest::newRow("127.-1") << "127.-1";
+ QTest::newRow("-127-10") << "-127-10";
+ QTest::newRow("198.-16") << "198-16";
+ QTest::newRow("-127.-0.") << "-127.-0.";
// letters
QTest::newRow("abc") << "abc";
+ QTest::newRow("localhost") << "localhost";
QTest::newRow("1.2.3a.4") << "1.2.3a.4";
QTest::newRow("a.2.3.4") << "a.2.3.4";
QTest::newRow("1.2.3.4a") << "1.2.3.4a";
@@ -244,6 +251,7 @@ void tst_QIpAddress::ip4ToString_data()
QTest::newRow("0.0.0.0") << 0u << "0.0.0.0";
QTest::newRow("1.2.3.4") << 0x01020304u << "1.2.3.4";
+ QTest::newRow("127.0.0.1") << 0x7f000001u << "127.0.0.1";
QTest::newRow("111.222.33.44") << 0x6fde212cu << "111.222.33.44";
QTest::newRow("255.255.255.255") << 0xffffffffu << "255.255.255.255";
}
diff --git a/tests/auto/corelib/io/qlockfile/tst_qlockfile.cpp b/tests/auto/corelib/io/qlockfile/tst_qlockfile.cpp
index 00b82cb377..2e5cfb1053 100644
--- a/tests/auto/corelib/io/qlockfile/tst_qlockfile.cpp
+++ b/tests/auto/corelib/io/qlockfile/tst_qlockfile.cpp
@@ -541,5 +541,15 @@ bool tst_QLockFile::overwritePidInLockFile(const QString &filePath, qint64 pid)
return f.write(buf) == buf.size();
}
+struct LockFileUsageInGlobalDtor
+{
+ ~LockFileUsageInGlobalDtor() {
+ QLockFile lockFile(QDir::currentPath() + "/lastlock");
+ QVERIFY(lockFile.lock());
+ QVERIFY(lockFile.isLocked());
+ }
+};
+LockFileUsageInGlobalDtor s_instance;
+
QTEST_MAIN(tst_QLockFile)
#include "tst_qlockfile.moc"
diff --git a/tests/auto/corelib/tools/qstringbuilder/qstringbuilder1/stringbuilder.cpp b/tests/auto/corelib/tools/qstringbuilder/qstringbuilder1/stringbuilder.cpp
index 4ccc903e32..7a361c0693 100644
--- a/tests/auto/corelib/tools/qstringbuilder/qstringbuilder1/stringbuilder.cpp
+++ b/tests/auto/corelib/tools/qstringbuilder/qstringbuilder1/stringbuilder.cpp
@@ -88,6 +88,11 @@ void runScenario()
r = special + string;
QCOMPARE(r, QString(special P string));
+ // self-assignment:
+ r = stringref.toString();
+ r = achar + r;
+ QCOMPARE(r, QString(achar P stringref));
+
#ifdef Q_COMPILER_UNICODE_STRINGS
r = QStringLiteral(UNICODE_LITERAL);
r = r Q QStringLiteral(UNICODE_LITERAL);
diff --git a/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp b/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp
index bd9f3a5b72..21a84dfbb2 100644
--- a/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp
+++ b/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp
@@ -6829,19 +6829,19 @@ void tst_QNetworkReply::authenticationCacheAfterCancel()
QTestEventLoop::instance().enterLoop(10);
QVERIFY(!QTestEventLoop::instance().timeout());
- if (reply->error() == QNetworkReply::HostNotFoundError)
- QSKIP("skip because of quirk in the old test server");
- QCOMPARE(reply->error(), QNetworkReply::ProxyAuthenticationRequiredError);
+ // Work round known quirk in the old test server (danted -v < v1.1.19):
+ if (reply->error() != QNetworkReply::HostNotFoundError)
+ QCOMPARE(reply->error(), QNetworkReply::ProxyAuthenticationRequiredError);
QCOMPARE(authSpy.count(), 0);
QVERIFY(proxyAuthSpy.count() > 0);
proxyAuthSpy.clear();
- //QTBUG-23136 workaround
+ // QTBUG-23136 workaround (needed even with danted v1.1.19):
if (proxy.port() == 1081) {
#ifdef QT_BUILD_INTERNAL
QNetworkAccessManagerPrivate::clearCache(&manager);
#else
- return; //XFAIL result above
+ return;
#endif
}
diff --git a/tests/auto/network/kernel/qhostaddress/tst_qhostaddress.cpp b/tests/auto/network/kernel/qhostaddress/tst_qhostaddress.cpp
index a418e59ba4..4fb97fe1f2 100644
--- a/tests/auto/network/kernel/qhostaddress/tst_qhostaddress.cpp
+++ b/tests/auto/network/kernel/qhostaddress/tst_qhostaddress.cpp
@@ -136,8 +136,16 @@ void tst_QHostAddress::setAddress_QString_data()
QTest::newRow("ip4_06") << QString("123.0.0") << true << QString("123.0.0.0") << 4;
// for the format of IPv6 addresses see also RFC 5952
- QTest::newRow("ip6_00") << QString("FEDC:BA98:7654:3210:FEDC:BA98:7654:3210") << true << QString("fedc:ba98:7654:3210:fedc:ba98:7654:3210") << 6;
- QTest::newRow("ip6_01") << QString("1080:0000:0000:0000:0008:0800:200C:417A") << true << QString("1080::8:800:200c:417a") << 6;
+ // rule 4.1: Leading zeros MUST be suppressed
+ // rule 4.2.1: Shorten as Much as Possible
+ // rule 4.2.2: The symbol "::" MUST NOT be used to shorten just one 16-bit 0 field.
+ // rule 4.2.3: the longest run of consecutive 16-bit 0 fields MUST be shortened
+ // When the length of the consecutive 16-bit 0 fields, the first sequence
+ // of zero bits MUST be shortened
+ // rule 4.3: The characters "a", "b", "c", "d", "e", and "f" in an IPv6 address
+ // MUST be represented in lowercase
+ QTest::newRow("ip6_00") << QString("FEDC:BA98:7654:3210:FEDC:BA98:7654:3210") << true << QString("fedc:ba98:7654:3210:fedc:ba98:7654:3210") << 6; // 4.3
+ QTest::newRow("ip6_01") << QString("1080:0000:0000:0000:0008:0800:200C:417A") << true << QString("1080::8:800:200c:417a") << 6; // 4.1, 4.2.1
QTest::newRow("ip6_02") << QString("1080:0:0:0:8:800:200C:417A") << true << QString("1080::8:800:200c:417a") << 6;
QTest::newRow("ip6_03") << QString("1080::8:800:200C:417A") << true << QString("1080::8:800:200c:417a") << 6;
QTest::newRow("ip6_04") << QString("FF01::43") << true << QString("ff01::43") << 6;
@@ -150,10 +158,11 @@ void tst_QHostAddress::setAddress_QString_data()
QTest::newRow("ip6_11") << QString("::FFFF:129.144.52.38") << true << QString("::ffff:129.144.52.38") << 6;
QTest::newRow("ip6_12") << QString("1::FFFF:129.144.52.38") << true << QString("1::ffff:8190:3426") << 6;
QTest::newRow("ip6_13") << QString("A:B::D:E") << true << QString("a:b::d:e") << 6;
- QTest::newRow("ip6_14") << QString("1080:0:1:0:8:800:200C:417A") << true << QString("1080:0:1:0:8:800:200c:417a") << 6;
+ QTest::newRow("ip6_14") << QString("1080:0:1:0:8:800:200C:417A") << true << QString("1080:0:1:0:8:800:200c:417a") << 6; // 4.2.2
QTest::newRow("ip6_15") << QString("1080:0:1:0:8:800:200C:0") << true << QString("1080:0:1:0:8:800:200c:0") << 6;
QTest::newRow("ip6_16") << QString("1080:0:1:0:8:800:0:0") << true << QString("1080:0:1:0:8:800::") << 6;
- QTest::newRow("ip6_17") << QString("1080:0:0:0:8:800:0:0") << true << QString("1080::8:800:0:0") << 6;
+ QTest::newRow("ip6_17a") << QString("1080:0:0:8:800:0:0:0") << true << QString("1080:0:0:8:800::") << 6; // 4.2.3a
+ QTest::newRow("ip6_17b") << QString("1080:0:0:0:8:0:0:0") << true << QString("1080::8:0:0:0") << 6; // 4.2.3b
QTest::newRow("ip6_18") << QString("0:1:1:1:8:800:0:0") << true << QString("0:1:1:1:8:800::") << 6;
QTest::newRow("ip6_19") << QString("0:1:1:1:8:800:0:1") << true << QString("0:1:1:1:8:800:0:1") << 6;
diff --git a/tests/auto/network/socket/qlocalsocket/tst_qlocalsocket.cpp b/tests/auto/network/socket/qlocalsocket/tst_qlocalsocket.cpp
index b5032c8c35..d0baa62e29 100644
--- a/tests/auto/network/socket/qlocalsocket/tst_qlocalsocket.cpp
+++ b/tests/auto/network/socket/qlocalsocket/tst_qlocalsocket.cpp
@@ -839,7 +839,8 @@ void tst_QLocalSocket::processConnection()
const QString exeSuffix;
#endif
- QString socketProcess = QStringLiteral("socketprocess/socketprocess") + exeSuffix;
+ const QString socketProcess
+ = QFINDTESTDATA(QStringLiteral("socketprocess/socketprocess") + exeSuffix);
QVERIFY(QFile::exists(socketProcess));
QFETCH(int, processes);
diff --git a/tests/auto/widgets/widgets/qfontcombobox/BLACKLIST b/tests/auto/widgets/widgets/qfontcombobox/BLACKLIST
deleted file mode 100644
index 8bd4caad31..0000000000
--- a/tests/auto/widgets/widgets/qfontcombobox/BLACKLIST
+++ /dev/null
@@ -1,6 +0,0 @@
-[currentFont]
-osx
-[fontFilters]
-osx
-[writingSystem]
-osx
diff --git a/tests/auto/widgets/widgets/qfontcombobox/tst_qfontcombobox.cpp b/tests/auto/widgets/widgets/qfontcombobox/tst_qfontcombobox.cpp
index cda24a19d3..9e6b16d4ce 100644
--- a/tests/auto/widgets/widgets/qfontcombobox/tst_qfontcombobox.cpp
+++ b/tests/auto/widgets/widgets/qfontcombobox/tst_qfontcombobox.cpp
@@ -80,18 +80,21 @@ void tst_QFontComboBox::qfontcombobox()
void tst_QFontComboBox::currentFont_data()
{
QTest::addColumn<QFont>("currentFont");
+ QFontDatabase db;
// Normalize the names
QFont defaultFont;
QFontInfo fi(defaultFont);
defaultFont = QFont(fi.family()); // make sure we have a real font name and not something like 'Sans Serif'.
- QTest::newRow("default") << defaultFont;
+ if (!db.isPrivateFamily(defaultFont.family()))
+ QTest::newRow("default") << defaultFont;
defaultFont.setPointSize(defaultFont.pointSize() + 10);
- QTest::newRow("default2") << defaultFont;
- QFontDatabase db;
+ if (!db.isPrivateFamily(defaultFont.family()))
+ QTest::newRow("default2") << defaultFont;
QStringList list = db.families();
for (int i = 0; i < list.count(); ++i) {
QFont f = QFont(QFontInfo(QFont(list.at(i))).family());
- QTest::newRow(qPrintable(list.at(i))) << f;
+ if (!db.isPrivateFamily(f.family()))
+ QTest::newRow(qPrintable(list.at(i))) << f;
}
}
@@ -168,6 +171,8 @@ void tst_QFontComboBox::fontFilters()
fontFilters &= ~spacingMask;
for (int i = 0; i < list.count(); ++i) {
+ if (db.isPrivateFamily(list[i]))
+ continue;
if (fontFilters & QFontComboBox::ScalableFonts) {
if (!db.isSmoothlyScalable(list[i]))
continue;
@@ -232,7 +237,12 @@ void tst_QFontComboBox::writingSystem()
QFontDatabase db;
QStringList list = db.families(writingSystem);
- QCOMPARE(box.model()->rowCount(), list.count());
+ int c = list.count();
+ for (int i = 0; i < list.count(); ++i) {
+ if (db.isPrivateFamily(list[i]))
+ c--;
+ }
+ QCOMPARE(box.model()->rowCount(), c);
if (list.count() == 0)
QCOMPARE(box.currentFont(), QFont());
diff --git a/tests/manual/network_remote_stresstest/tst_network_remote_stresstest.cpp b/tests/manual/network_remote_stresstest/tst_network_remote_stresstest.cpp
index 0035d47c88..05ede9da99 100644
--- a/tests/manual/network_remote_stresstest/tst_network_remote_stresstest.cpp
+++ b/tests/manual/network_remote_stresstest/tst_network_remote_stresstest.cpp
@@ -139,7 +139,7 @@ void tst_NetworkRemoteStressTest::init()
{
// clear the internal cache
#ifndef QT_BUILD_INTERNAL
- if (strncmp(QTest::currentTestFunction(), "nam") == 0)
+ if (strncmp(QTest::currentTestFunction(), "nam", 3) == 0)
QSKIP("QNetworkAccessManager tests disabled");
#endif
}
diff --git a/tests/manual/network_stresstest/tst_network_stresstest.cpp b/tests/manual/network_stresstest/tst_network_stresstest.cpp
index 9e04d52c4a..e3c76ea11b 100644
--- a/tests/manual/network_stresstest/tst_network_stresstest.cpp
+++ b/tests/manual/network_stresstest/tst_network_stresstest.cpp
@@ -130,7 +130,7 @@ void tst_NetworkStressTest::init()
{
// clear the internal cache
#ifndef QT_BUILD_INTERNAL
- if (strncmp(QTest::currentTestFunction(), "nam") == 0)
+ if (strncmp(QTest::currentTestFunction(), "nam", 3) == 0)
QSKIP("QNetworkAccessManager tests disabled");
#endif
}
diff --git a/tests/manual/qscreen/main.cpp b/tests/manual/qscreen/main.cpp
index f9f93fd525..445af82e09 100644
--- a/tests/manual/qscreen/main.cpp
+++ b/tests/manual/qscreen/main.cpp
@@ -40,6 +40,61 @@
#include <QStatusBar>
#include <QLineEdit>
#include <QDesktopWidget>
+#include <QPushButton>
+#include <QLabel>
+#include <QMouseEvent>
+
+
+class MouseMonitor : public QLabel {
+ Q_OBJECT
+public:
+ MouseMonitor() : m_grabbed(false) {
+ setMinimumSize(540, 240);
+ setAlignment(Qt::AlignCenter);
+ setMouseTracking(true);
+ setWindowTitle(QLatin1String("Mouse Monitor"));
+ updateText();
+ }
+
+ void updateText() {
+ QString txt = m_grabbed ?
+ QLatin1String("Left-click to test QGuiApplication::topLevelAt(click pos)\nRight-click to ungrab\n") :
+ QLatin1String("Left-click to grab mouse\n");
+ if (!m_cursorPos.isNull()) {
+ txt += QString(QLatin1String("Current mouse position: %1, %2 on screen %3\n"))
+ .arg(m_cursorPos.x()).arg(m_cursorPos.y()).arg(QApplication::desktop()->screenNumber(m_cursorPos));
+ if (QGuiApplication::mouseButtons() & Qt::LeftButton) {
+ QWindow *win = QGuiApplication::topLevelAt(m_cursorPos);
+ txt += QString(QLatin1String("Top-level window found? %1\n"))
+ .arg(win ? (win->title().isEmpty() ? "no title" : win->title()) : "none");
+ }
+ }
+ setText(txt);
+ }
+
+protected:
+ void mouseMoveEvent(QMouseEvent *ev) Q_DECL_OVERRIDE {
+ m_cursorPos = ev->screenPos().toPoint();
+ updateText();
+ }
+
+ void mousePressEvent(QMouseEvent *ev) Q_DECL_OVERRIDE {
+ m_cursorPos = ev->screenPos().toPoint();
+ qDebug() << "top level @" << m_cursorPos << ":" << QGuiApplication::topLevelAt(m_cursorPos);
+ updateText();
+ if (!m_grabbed) {
+ grabMouse(Qt::CrossCursor);
+ m_grabbed = true;
+ } else if (ev->button() == Qt::RightButton) {
+ setVisible(false);
+ deleteLater();
+ }
+ }
+
+private:
+ QPoint m_cursorPos;
+ bool m_grabbed;
+};
class ScreenPropertyWatcher : public PropertyWatcher
{
@@ -96,6 +151,7 @@ public:
protected:
bool event(QEvent *event) Q_DECL_OVERRIDE;
+ void startMouseMonitor();
private:
const QString m_annotation;
@@ -119,6 +175,11 @@ ScreenWatcherMainWindow::ScreenWatcherMainWindow(QScreen *screen)
a = fileMenu->addAction(QLatin1String("Quit"));
a->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_Q));
connect(a, SIGNAL(triggered()), qApp, SLOT(quit()));
+
+ QMenu *toolsMenu = menuBar()->addMenu(QLatin1String("&Tools"));
+ a = toolsMenu->addAction(QLatin1String("Mouse Monitor"));
+ a->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_M));
+ connect(a, &QAction::triggered, this, &ScreenWatcherMainWindow::startMouseMonitor);
}
static inline QString msgScreenChange(const QWidget *w, const QScreen *oldScreen, const QScreen *newScreen)
@@ -154,6 +215,12 @@ bool ScreenWatcherMainWindow::event(QEvent *event)
return QMainWindow::event(event);
}
+void ScreenWatcherMainWindow::startMouseMonitor()
+{
+ MouseMonitor *mm = new MouseMonitor();
+ mm->show();
+}
+
void screenAdded(QScreen* screen)
{
screen->setOrientationUpdateMask((Qt::ScreenOrientations)0x0F);