summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/corelib/global/qglobal/qglobal.c2
-rw-r--r--tests/auto/corelib/kernel/qdeadlinetimer/tst_qdeadlinetimer.cpp4
-rw-r--r--tests/auto/corelib/kernel/qeventdispatcher/tst_qeventdispatcher.cpp45
-rw-r--r--tests/auto/corelib/kernel/qtimer/tst_qtimer.cpp6
-rw-r--r--tests/auto/corelib/kernel/qvariant/tst_qvariant.cpp4
-rw-r--r--tests/auto/corelib/serialization/qcborvalue/tst_qcborvalue.cpp30
-rw-r--r--tests/auto/corelib/thread/qmutex/tst_qmutex.cpp14
-rw-r--r--tests/auto/corelib/time/qdatetime/tst_qdatetime.cpp65
-rw-r--r--tests/auto/corelib/tools/containerapisymmetry/tst_containerapisymmetry.cpp2
-rw-r--r--tests/auto/gui/text/qtextdocument/tst_qtextdocument.cpp27
-rw-r--r--tests/auto/network/kernel/qnetworkinterface/BLACKLIST3
-rw-r--r--tests/auto/network/kernel/qnetworkinterface/tst_qnetworkinterface.cpp48
-rw-r--r--tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp76
-rw-r--r--tests/auto/widgets/dialogs/qfiledialog/tst_qfiledialog.cpp1
-rw-r--r--tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp54
-rw-r--r--tests/auto/widgets/widgets/qlineedit/tst_qlineedit.cpp3
-rw-r--r--tests/auto/widgets/widgets/qplaintextedit/tst_qplaintextedit.cpp46
-rw-r--r--tests/benchmarks/corelib/thread/qreadwritelock/tst_qreadwritelock.cpp2
-rw-r--r--tests/manual/highdpi/main.cpp137
-rw-r--r--tests/testserver/docker-compose-bridge-network.yml37
-rw-r--r--tests/testserver/docker-compose-host-network.yml21
21 files changed, 497 insertions, 130 deletions
diff --git a/tests/auto/corelib/global/qglobal/qglobal.c b/tests/auto/corelib/global/qglobal/qglobal.c
index c7124454d0..7a2266ae94 100644
--- a/tests/auto/corelib/global/qglobal/qglobal.c
+++ b/tests/auto/corelib/global/qglobal/qglobal.c
@@ -28,7 +28,7 @@
#include <QtCore/qglobal.h>
-#if QT_HAS_INCLUDE(<stdbool.h>) || __STDC_VERSION__ >= 199901L
+#if __has_include(<stdbool.h>) || __STDC_VERSION__ >= 199901L
# include <stdbool.h>
#else
# undef true
diff --git a/tests/auto/corelib/kernel/qdeadlinetimer/tst_qdeadlinetimer.cpp b/tests/auto/corelib/kernel/qdeadlinetimer/tst_qdeadlinetimer.cpp
index 4ca68550b9..4e105d7dc7 100644
--- a/tests/auto/corelib/kernel/qdeadlinetimer/tst_qdeadlinetimer.cpp
+++ b/tests/auto/corelib/kernel/qdeadlinetimer/tst_qdeadlinetimer.cpp
@@ -32,7 +32,7 @@
#include <QtCore/QElapsedTimer>
#include <QtTest/QtTest>
-#if QT_HAS_INCLUDE(<chrono>)
+#if __has_include(<chrono>)
# include <chrono>
#endif
@@ -519,7 +519,7 @@ void tst_QDeadlineTimer::expire()
void tst_QDeadlineTimer::stdchrono()
{
-#if !QT_HAS_INCLUDE(<chrono>)
+#if !__has_include(<chrono>)
QSKIP("std::chrono not found on this system");
#else
using namespace std::chrono;
diff --git a/tests/auto/corelib/kernel/qeventdispatcher/tst_qeventdispatcher.cpp b/tests/auto/corelib/kernel/qeventdispatcher/tst_qeventdispatcher.cpp
index 49c10c6a24..365508024b 100644
--- a/tests/auto/corelib/kernel/qeventdispatcher/tst_qeventdispatcher.cpp
+++ b/tests/auto/corelib/kernel/qeventdispatcher/tst_qeventdispatcher.cpp
@@ -67,6 +67,7 @@ private slots:
void sendPostedEvents_data();
void sendPostedEvents();
void processEventsOnlySendsQueuedEvents();
+ void eventLoopExit();
};
bool tst_QEventDispatcher::event(QEvent *e)
@@ -314,5 +315,49 @@ void tst_QEventDispatcher::processEventsOnlySendsQueuedEvents()
QCOMPARE(object.eventsReceived, 4);
}
+void tst_QEventDispatcher::eventLoopExit()
+{
+ // This test was inspired by QTBUG-79477. A particular
+ // implementation detail in QCocoaEventDispatcher allowed
+ // QEventLoop::exit() to fail to really exit the event loop.
+ // Thus this test is a part of the dispatcher auto-test.
+
+ // Imitates QApplication::exec():
+ QEventLoop mainLoop;
+ // The test itself is a lambda:
+ QTimer::singleShot(0, [&mainLoop]() {
+ // Two more single shots, both will be posted as events
+ // (zero timeout) and supposed to be processes by the
+ // mainLoop:
+
+ QTimer::singleShot(0, [&mainLoop]() {
+ // wakeUp triggers QCocoaEventDispatcher into incrementing
+ // its 'serialNumber':
+ mainLoop.wakeUp();
+ // QCocoaEventDispatcher::processEvents() will process
+ // posted events and execute the second lambda defined below:
+ QCoreApplication::processEvents();
+ });
+
+ QTimer::singleShot(0, [&mainLoop]() {
+ // With QCocoaEventDispatcher this is executed while in the
+ // processEvents (see above) and would fail to actually
+ // interrupt the loop.
+ mainLoop.exit();
+ });
+ });
+
+ bool timeoutObserved = false;
+ QTimer::singleShot(500, [&timeoutObserved, &mainLoop]() {
+ // In case the QEventLoop::exit above failed, we have to bail out
+ // early, not wasting time:
+ mainLoop.exit();
+ timeoutObserved = true;
+ });
+
+ mainLoop.exec();
+ QVERIFY(!timeoutObserved);
+}
+
QTEST_MAIN(tst_QEventDispatcher)
#include "tst_qeventdispatcher.moc"
diff --git a/tests/auto/corelib/kernel/qtimer/tst_qtimer.cpp b/tests/auto/corelib/kernel/qtimer/tst_qtimer.cpp
index 8e0bdac520..1bd27cd0ce 100644
--- a/tests/auto/corelib/kernel/qtimer/tst_qtimer.cpp
+++ b/tests/auto/corelib/kernel/qtimer/tst_qtimer.cpp
@@ -223,7 +223,7 @@ void tst_QTimer::remainingTimeDuringActivation()
namespace {
-#if QT_HAS_INCLUDE(<chrono>)
+#if __has_include(<chrono>)
template <typename T>
std::chrono::milliseconds to_ms(T t)
{ return std::chrono::duration_cast<std::chrono::milliseconds>(t); }
@@ -233,7 +233,7 @@ namespace {
void tst_QTimer::basic_chrono()
{
-#if !QT_HAS_INCLUDE(<chrono>)
+#if !__has_include(<chrono>)
QSKIP("This test requires C++11 <chrono> support");
#else
// duplicates zeroTimer, singleShotTimeout, interval and remainingTime
@@ -871,7 +871,7 @@ void tst_QTimer::singleShotToFunctors()
void tst_QTimer::singleShot_chrono()
{
-#if !QT_HAS_INCLUDE(<chrono>)
+#if !__has_include(<chrono>)
QSKIP("This test requires C++11 <chrono> support");
#else
// duplicates singleShotStaticFunctionZeroTimeout and singleShotToFunctors
diff --git a/tests/auto/corelib/kernel/qvariant/tst_qvariant.cpp b/tests/auto/corelib/kernel/qvariant/tst_qvariant.cpp
index c4af2267a8..8db28c7c71 100644
--- a/tests/auto/corelib/kernel/qvariant/tst_qvariant.cpp
+++ b/tests/auto/corelib/kernel/qvariant/tst_qvariant.cpp
@@ -45,7 +45,7 @@
#include <limits.h>
#include <float.h>
#include <cmath>
-#if QT_HAS_INCLUDE(<variant>) && __cplusplus >= 201703L
+#if __has_include(<variant>) && __cplusplus >= 201703L
#include <variant>
#endif
#include <QLinkedList>
@@ -4568,7 +4568,7 @@ void tst_QVariant::accessSequentialContainerKey()
void tst_QVariant::fromStdVariant()
{
-#if QT_HAS_INCLUDE(<variant>) && __cplusplus >= 201703L
+#if __has_include(<variant>) && __cplusplus >= 201703L
{
typedef std::variant<int, bool> intorbool_t;
intorbool_t stdvar = 5;
diff --git a/tests/auto/corelib/serialization/qcborvalue/tst_qcborvalue.cpp b/tests/auto/corelib/serialization/qcborvalue/tst_qcborvalue.cpp
index 47ad328d64..d5a9012f9f 100644
--- a/tests/auto/corelib/serialization/qcborvalue/tst_qcborvalue.cpp
+++ b/tests/auto/corelib/serialization/qcborvalue/tst_qcborvalue.cpp
@@ -384,7 +384,7 @@ void tst_QCborValue::copyCompare()
QCOMPARE(v, other);
QVERIFY(!(v != other));
QVERIFY(!(v < other));
-#if 0 && QT_HAS_INCLUDE(<compare>)
+#if 0 && __has_include(<compare>)
QVERIFY(v <= other);
QVERIFY(v >= other);
QVERIFY(!(v > other));
@@ -821,9 +821,37 @@ void tst_QCborValue::mapMutation()
QVERIFY(v.isUndefined());
// now mutate the list
+ // simple -> HasByteData
+ const QString strValue = QStringLiteral("value");
+ v = strValue;
+ QVERIFY(v.isString());
+ QCOMPARE(v, QCborValue(strValue));
+ QCOMPARE(m, QCborMap({{42, strValue}}));
+
+ // HasByteData -> HasByteData
+ const QLatin1String otherStrValue("othervalue");
+ v = otherStrValue;
+ QVERIFY(v.isString());
+ QCOMPARE(v, QCborValue(otherStrValue));
+ QCOMPARE(m, QCborMap({{42, otherStrValue}}));
+
+ // HasByteData -> simple
+ v = 42;
+ QVERIFY(v.isInteger());
+ QCOMPARE(v, QCborValue(42));
+ QCOMPARE(m, QCborMap({{42, 42}}));
+
+ // simple -> container
+ v = QCborArray{1, 2, 3};
+ QVERIFY(v.isArray());
+ QCOMPARE(v, QCborArray({1, 2, 3}));
+ QCOMPARE(m, QCborMap({{42, QCborArray{1, 2, 3}}}));
+
+ // container -> simple
v = true;
QVERIFY(v.isBool());
QVERIFY(v.isTrue());
+ QCOMPARE(m, QCborMap({{42, true}}));
QVERIFY(m.begin()->isTrue());
QVERIFY(m.begin().value() == v);
QVERIFY(v == m.begin().value());
diff --git a/tests/auto/corelib/thread/qmutex/tst_qmutex.cpp b/tests/auto/corelib/thread/qmutex/tst_qmutex.cpp
index 749aa45916..11f34343ab 100644
--- a/tests/auto/corelib/thread/qmutex/tst_qmutex.cpp
+++ b/tests/auto/corelib/thread/qmutex/tst_qmutex.cpp
@@ -89,7 +89,7 @@ enum {
waitTime = 100
};
-#if QT_HAS_INCLUDE(<chrono>)
+#if __has_include(<chrono>)
static Q_CONSTEXPR std::chrono::milliseconds waitTimeAsDuration(waitTime);
#endif
@@ -100,7 +100,7 @@ void tst_QMutex::convertToMilliseconds_data()
QTest::addColumn<qint64>("intValue");
QTest::addColumn<qint64>("expected");
-#if !QT_HAS_INCLUDE(<chrono>)
+#if !__has_include(<chrono>)
QSKIP("This test requires <chrono>");
#endif
@@ -156,7 +156,7 @@ void tst_QMutex::convertToMilliseconds_data()
void tst_QMutex::convertToMilliseconds()
{
-#if !QT_HAS_INCLUDE(<chrono>)
+#if !__has_include(<chrono>)
QSKIP("This test requires <chrono>");
#else
QFETCH(TimeUnit, unit);
@@ -325,7 +325,7 @@ void tst_QMutex::tryLock_non_recursive()
}
void tst_QMutex::try_lock_for_non_recursive() {
-#if !QT_HAS_INCLUDE(<chrono>)
+#if !__has_include(<chrono>)
QSKIP("This test requires <chrono>");
#else
class Thread : public QThread
@@ -454,7 +454,7 @@ void tst_QMutex::try_lock_for_non_recursive() {
void tst_QMutex::try_lock_until_non_recursive()
{
-#if !QT_HAS_INCLUDE(<chrono>)
+#if !__has_include(<chrono>)
QSKIP("This test requires <chrono>");
#else
class Thread : public QThread
@@ -707,7 +707,7 @@ void tst_QMutex::tryLock_recursive()
void tst_QMutex::try_lock_for_recursive()
{
-#if !QT_HAS_INCLUDE(<chrono>)
+#if !__has_include(<chrono>)
QSKIP("This test requires <chrono>");
#else
class Thread : public QThread
@@ -836,7 +836,7 @@ void tst_QMutex::try_lock_for_recursive()
void tst_QMutex::try_lock_until_recursive()
{
-#if !QT_HAS_INCLUDE(<chrono>)
+#if !__has_include(<chrono>)
QSKIP("This test requires <chrono>");
#else
class Thread : public QThread
diff --git a/tests/auto/corelib/time/qdatetime/tst_qdatetime.cpp b/tests/auto/corelib/time/qdatetime/tst_qdatetime.cpp
index 7f13fd0aa5..7778542736 100644
--- a/tests/auto/corelib/time/qdatetime/tst_qdatetime.cpp
+++ b/tests/auto/corelib/time/qdatetime/tst_qdatetime.cpp
@@ -150,6 +150,7 @@ private slots:
void timeZones() const;
void systemTimeZoneChange() const;
+ void invalid_data() const;
void invalid() const;
void range() const;
@@ -2209,6 +2210,13 @@ void tst_QDateTime::fromStringDateFormat_data()
<< Qt::TextDate << QDateTime(QDate(2013, 5, 6), QTime(1, 2, 3, 456));
// Test Qt::ISODate format.
+ QTest::newRow("trailing space") // QTBUG-80445
+ << QString("2000-01-02 03:04:05.678 ")
+ << Qt::ISODate << QDateTime(QDate(2000, 1, 2), QTime(3, 4, 5, 678));
+ QTest::newRow("space before millis")
+ << QString("2000-01-02 03:04:05. 678") << Qt::ISODate << QDateTime();
+
+ // Normal usage:
QTest::newRow("ISO +01:00") << QString::fromLatin1("1987-02-13T13:24:51+01:00")
<< Qt::ISODate << QDateTime(QDate(1987, 2, 13), QTime(12, 24, 51), Qt::UTC);
QTest::newRow("ISO +00:01") << QString::fromLatin1("1987-02-13T13:24:51+00:01")
@@ -2229,11 +2237,17 @@ void tst_QDateTime::fromStringDateFormat_data()
<< Qt::ISODate << QDateTime(QDate(2014, 12, 15), QTime(15, 37, 9), Qt::UTC);
QTest::newRow("ISO zzz-3") << QString::fromLatin1("2014-12-15T12:37:09.745-3")
<< Qt::ISODate << QDateTime(QDate(2014, 12, 15), QTime(15, 37, 9, 745), Qt::UTC);
+ QTest::newRow("ISO lower-case") << QString::fromLatin1("2005-06-28T07:57:30.002z")
+ << Qt::ISODate << QDateTime(QDate(2005, 6, 28), QTime(7, 57, 30, 2), Qt::UTC);
// No time specified - defaults to Qt::LocalTime.
QTest::newRow("ISO data3") << QString::fromLatin1("2002-10-01")
<< Qt::ISODate << QDateTime(QDate(2002, 10, 1), QTime(0, 0, 0, 0), Qt::LocalTime);
+ // Excess digits in milliseconds, round correctly:
QTest::newRow("ISO") << QString::fromLatin1("2005-06-28T07:57:30.0010000000Z")
<< Qt::ISODate << QDateTime(QDate(2005, 6, 28), QTime(7, 57, 30, 1), Qt::UTC);
+ QTest::newRow("ISO rounding") << QString::fromLatin1("2005-06-28T07:57:30.0015Z")
+ << Qt::ISODate << QDateTime(QDate(2005, 6, 28), QTime(7, 57, 30, 2), Qt::UTC);
+ // ... and accept comma as separator:
QTest::newRow("ISO with comma 1") << QString::fromLatin1("2005-06-28T07:57:30,0040000000Z")
<< Qt::ISODate << QDateTime(QDate(2005, 6, 28), QTime(7, 57, 30, 4), Qt::UTC);
QTest::newRow("ISO with comma 2") << QString::fromLatin1("2005-06-28T07:57:30,0015Z")
@@ -2458,6 +2472,7 @@ void tst_QDateTime::fromStringStringFormat_data()
if (southBrazil.isValid()) {
QTest::newRow("spring-forward-midnight")
<< QString("2008-10-19 23:45.678 America/Sao_Paulo") << QString("yyyy-MM-dd mm:ss.zzz t")
+ // That's in the hour skipped - expect the matching time after the spring-forward, in DST:
<< QDateTime(QDate(2008, 10, 19), QTime(1, 23, 45, 678), southBrazil);
}
#endif
@@ -3359,6 +3374,9 @@ void tst_QDateTime::timeZones() const
QCOMPARE(utc.date(), utcDst.date());
QCOMPARE(utc.time(), utcDst.time());
+ // Crash test, QTBUG-80146:
+ QVERIFY(!nzStd.toTimeZone(QTimeZone()).isValid());
+
// Sydney is 2 hours behind New Zealand
QTimeZone ausTz = QTimeZone("Australia/Sydney");
QDateTime aus = nzStd.toTimeZone(ausTz);
@@ -3528,23 +3546,42 @@ void tst_QDateTime::systemTimeZoneChange() const
QCOMPARE(tzDate.toMSecsSinceEpoch(), tzMsecs);
}
-void tst_QDateTime::invalid() const
+void tst_QDateTime::invalid_data() const
{
- QDateTime invalidDate = QDateTime(QDate(0, 0, 0), QTime(-1, -1, -1));
- QCOMPARE(invalidDate.isValid(), false);
- QCOMPARE(invalidDate.timeSpec(), Qt::LocalTime);
+ QTest::addColumn<QDateTime>("when");
+ QTest::addColumn<Qt::TimeSpec>("spec");
+ QTest::addColumn<bool>("goodZone");
+ QTest::newRow("default") << QDateTime() << Qt::LocalTime << true;
- QDateTime utcDate = invalidDate.toUTC();
- QCOMPARE(utcDate.isValid(), false);
- QCOMPARE(utcDate.timeSpec(), Qt::UTC);
-
- QDateTime offsetDate = invalidDate.toOffsetFromUtc(3600);
- QCOMPARE(offsetDate.isValid(), false);
- QCOMPARE(offsetDate.timeSpec(), Qt::OffsetFromUTC);
+ QDateTime invalidDate = QDateTime(QDate(0, 0, 0), QTime(-1, -1, -1));
+ QTest::newRow("simple") << invalidDate << Qt::LocalTime << true;
+ QTest::newRow("UTC") << invalidDate.toUTC() << Qt::UTC << true;
+ QTest::newRow("offset")
+ << invalidDate.toOffsetFromUtc(3600) << Qt::OffsetFromUTC << true;
+ QTest::newRow("CET")
+ << invalidDate.toTimeZone(QTimeZone("Europe/Oslo")) << Qt::TimeZone << true;
+
+ // Crash tests, QTBUG-80146:
+ QTest::newRow("nozone+construct")
+ << QDateTime(QDate(1970, 1, 1), QTime(12, 0), QTimeZone()) << Qt::TimeZone << false;
+ QTest::newRow("nozone+fromMSecs")
+ << QDateTime::fromMSecsSinceEpoch(42, QTimeZone()) << Qt::TimeZone << false;
+ QDateTime valid(QDate(1970, 1, 1), QTime(12, 0), Qt::UTC);
+ QTest::newRow("tonozone") << valid.toTimeZone(QTimeZone()) << Qt::TimeZone << false;
+}
- QDateTime tzDate = invalidDate.toTimeZone(QTimeZone("Europe/Oslo"));
- QCOMPARE(tzDate.isValid(), false);
- QCOMPARE(tzDate.timeSpec(), Qt::TimeZone);
+void tst_QDateTime::invalid() const
+{
+ QFETCH(QDateTime, when);
+ QFETCH(Qt::TimeSpec, spec);
+ QFETCH(bool, goodZone);
+ QVERIFY(!when.isValid());
+ QCOMPARE(when.timeSpec(), spec);
+ QCOMPARE(when.timeZoneAbbreviation(), QString());
+ if (!goodZone)
+ QCOMPARE(when.toMSecsSinceEpoch(), 0);
+ QVERIFY(!when.isDaylightTime());
+ QCOMPARE(when.timeZone().isValid(), goodZone);
}
void tst_QDateTime::range() const
diff --git a/tests/auto/corelib/tools/containerapisymmetry/tst_containerapisymmetry.cpp b/tests/auto/corelib/tools/containerapisymmetry/tst_containerapisymmetry.cpp
index f6f10e9642..0e4517e740 100644
--- a/tests/auto/corelib/tools/containerapisymmetry/tst_containerapisymmetry.cpp
+++ b/tests/auto/corelib/tools/containerapisymmetry/tst_containerapisymmetry.cpp
@@ -51,7 +51,7 @@
#ifdef Q_CC_MSVC
#define COMPILER_HAS_STDLIB_INCLUDE(x) 1
#else
-#define COMPILER_HAS_STDLIB_INCLUDE(x) QT_HAS_INCLUDE(x)
+#define COMPILER_HAS_STDLIB_INCLUDE(x) __has_include(x)
#endif
#if COMPILER_HAS_STDLIB_INCLUDE(<forward_list>)
diff --git a/tests/auto/gui/text/qtextdocument/tst_qtextdocument.cpp b/tests/auto/gui/text/qtextdocument/tst_qtextdocument.cpp
index 0e9f94ab2b..3917c859cc 100644
--- a/tests/auto/gui/text/qtextdocument/tst_qtextdocument.cpp
+++ b/tests/auto/gui/text/qtextdocument/tst_qtextdocument.cpp
@@ -125,6 +125,7 @@ private slots:
void clonePreservesResources();
void clonePreservesUserStates();
void clonePreservesIndentWidth();
+ void clonePreservesFormatsWhenEmpty();
void blockCount();
void defaultStyleSheet();
@@ -2348,6 +2349,32 @@ void tst_QTextDocument::clonePreservesIndentWidth()
delete clone;
}
+void tst_QTextDocument::clonePreservesFormatsWhenEmpty()
+{
+ QTextDocument document;
+ QTextCursor cursor(&document);
+
+ // Change a few char format attributes
+ QTextCharFormat charFormat;
+ charFormat.setFontPointSize(charFormat.fontPointSize() + 1);
+ charFormat.setFontWeight(charFormat.fontWeight() + 1);
+ cursor.setBlockCharFormat(charFormat);
+
+ // Change a few block format attributes
+ QTextBlockFormat blockFormat;
+ blockFormat.setAlignment(Qt::AlignRight); // The default is Qt::AlignLeft
+ blockFormat.setIndent(blockFormat.indent() + 1);
+ cursor.setBlockFormat(blockFormat);
+
+ auto clone = document.clone();
+ QTextCursor cloneCursor(clone);
+
+ QCOMPARE(cloneCursor.blockCharFormat().fontPointSize(), charFormat.fontPointSize());
+ QCOMPARE(cloneCursor.blockCharFormat().fontWeight(), charFormat.fontWeight());
+ QCOMPARE(cloneCursor.blockFormat().alignment(), blockFormat.alignment());
+ QCOMPARE(cloneCursor.blockFormat().indent(), blockFormat.indent());
+}
+
void tst_QTextDocument::blockCount()
{
QCOMPARE(doc->blockCount(), 1);
diff --git a/tests/auto/network/kernel/qnetworkinterface/BLACKLIST b/tests/auto/network/kernel/qnetworkinterface/BLACKLIST
deleted file mode 100644
index e28cc38ee0..0000000000
--- a/tests/auto/network/kernel/qnetworkinterface/BLACKLIST
+++ /dev/null
@@ -1,3 +0,0 @@
-# QTBUG-65667
-[localAddress:linklocal-ipv4]
-windows ci
diff --git a/tests/auto/network/kernel/qnetworkinterface/tst_qnetworkinterface.cpp b/tests/auto/network/kernel/qnetworkinterface/tst_qnetworkinterface.cpp
index 0c7ba99be5..bc6e5435df 100644
--- a/tests/auto/network/kernel/qnetworkinterface/tst_qnetworkinterface.cpp
+++ b/tests/auto/network/kernel/qnetworkinterface/tst_qnetworkinterface.cpp
@@ -215,31 +215,45 @@ void tst_QNetworkInterface::loopbackIPv6()
}
void tst_QNetworkInterface::localAddress_data()
{
+ bool ipv6 = isIPv6Working();
QTest::addColumn<QHostAddress>("target");
QTest::newRow("localhost-ipv4") << QHostAddress(QHostAddress::LocalHost);
- if (isIPv6Working())
+ if (ipv6)
QTest::newRow("localhost-ipv6") << QHostAddress(QHostAddress::LocalHostIPv6);
QTest::newRow("test-server") << QtNetworkSettings::serverIP();
- // Since we don't actually transmit anything, we can list any IPv4 address
- // and it should work. But we're using a linklocal address so that this
- // test can pass even machines that failed to reach a DHCP server.
- QTest::newRow("linklocal-ipv4") << QHostAddress("169.254.0.1");
-
- if (isIPv6Working()) {
- // On the other hand, we can't list just any IPv6 here. It's very
- // likely that this machine has not received a route via ICMPv6-RA or
- // DHCPv6, so it won't have a global route. On some OSes, IPv6 may be
- // enabled per interface, so we need to know which ones work.
- const QList<QHostAddress> addrs = QNetworkInterface::allAddresses();
- for (const QHostAddress &addr : addrs) {
- QString scope = addr.scopeId();
- if (scope.isEmpty())
+ QSet<QHostAddress> added;
+ const QList<QNetworkInterface> ifaces = QNetworkInterface::allInterfaces();
+ for (const QNetworkInterface &iface : ifaces) {
+ if ((iface.flags() & QNetworkInterface::IsUp) == 0)
+ continue;
+ const QList<QNetworkAddressEntry> addrs = iface.addressEntries();
+ for (const QNetworkAddressEntry &entry : addrs) {
+ QHostAddress addr = entry.ip();
+ if (addr.isLoopback())
+ continue; // added above
+
+ if (addr.protocol() == QAbstractSocket::IPv4Protocol) {
+ // add an IPv4 address with bits in the host portion of the address flipped
+ quint32 ip4 = entry.ip().toIPv4Address();
+ addr.setAddress(ip4 ^ ~entry.netmask().toIPv4Address());
+ } else if (!ipv6 || entry.prefixLength() != 64) {
+ continue;
+ } else {
+ // add a random node in this IPv6 network
+ quint64 randomid = qFromBigEndian(Q_UINT64_C(0x8f41f072e5733caa));
+ QIPv6Address ip6 = addr.toIPv6Address();
+ memcpy(&ip6[8], &randomid, sizeof(randomid));
+ addr.setAddress(ip6);
+ }
+
+ if (added.contains(addr))
continue;
- QTest::addRow("linklocal-ipv6-%s", qPrintable(scope))
- << QHostAddress("fe80::1234%" + scope);
+ added.insert(addr);
+
+ QTest::addRow("%s-%s", qPrintable(iface.name()), qPrintable(addr.toString())) << addr;
}
}
}
diff --git a/tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp b/tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp
index 4c3749eaee..4533284a0f 100644
--- a/tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp
+++ b/tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp
@@ -965,9 +965,7 @@ void tst_QSqlQuery::blob()
//don' make it too big otherwise sybase and mysql will complain
QByteArray ba( BLOBSIZE, 0 );
- int i;
-
- for ( i = 0; i < ( int )ba.size(); ++i )
+ for (int i = 0; i < ba.size(); ++i)
ba[i] = i % 256;
QSqlQuery q( db );
@@ -980,7 +978,7 @@ void tst_QSqlQuery::blob()
QVERIFY_SQL(q, prepare("insert into " + qTableName("qtest_blob", __FILE__, db) + " (id, t_blob) values (?, ?)"));
- for ( i = 0; i < BLOBCOUNT; ++i ) {
+ for (int i = 0; i < BLOBCOUNT; ++i) {
q.addBindValue( i );
q.addBindValue( ba );
QVERIFY_SQL( q, exec() );
@@ -988,13 +986,13 @@ void tst_QSqlQuery::blob()
QVERIFY_SQL(q, exec("select * from " + qTableName("qtest_blob", __FILE__, db)));
- for ( i = 0; i < BLOBCOUNT; ++i ) {
+ for (int i = 0; i < BLOBCOUNT; ++i) {
QVERIFY( q.next() );
QByteArray res = q.value( 1 ).toByteArray();
QVERIFY2( res.size() >= ba.size(),
QString( "array sizes differ, expected %1, got %2" ).arg( ba.size() ).arg( res.size() ).toLatin1() );
- for ( int i2 = 0; i2 < ( int )ba.size(); ++i2 ) {
+ for (int i2 = 0; i2 < ba.size(); ++i2) {
if ( res[i2] != ba[i2] )
QFAIL( QString( "ByteArrays differ at position %1, expected %2, got %3" ).arg(
i2 ).arg(( int )( unsigned char )ba[i2] ).arg(( int )( unsigned char )res[i2] ).toLatin1() );
@@ -1834,7 +1832,7 @@ void tst_QSqlQuery::oci_rawField()
}
// test whether we can fetch values with more than DOUBLE precision
-// note that MySQL's 3.x highest precision is that of a double, although
+// note that SQLite highest precision is that of a double, although
// you can define field with higher precision
void tst_QSqlQuery::precision()
{
@@ -1845,46 +1843,41 @@ void tst_QSqlQuery::precision()
if (dbType == QSqlDriver::Interbase)
QSKIP("DB unable to store high precision");
+ const auto oldPrecision = db.driver()->numericalPrecisionPolicy();
+ db.driver()->setNumericalPrecisionPolicy(QSql::HighPrecision);
const QString qtest_precision(qTableName("qtest_precision", __FILE__, db));
- static const char precStr[] = "1.2345678901234567891";
- const int precStrLen = sizeof(precStr);
+ static const QLatin1String precStr("1.2345678901234567891");
{
// need a new scope for SQLITE
QSqlQuery q( db );
q.exec("drop table " + qtest_precision);
- if ( tst_Databases::isMSAccess( db ) )
- QVERIFY_SQL( q, exec( "create table " + qtest_precision + " (col1 number)" ) );
+ if (tst_Databases::isMSAccess(db))
+ QVERIFY_SQL(q, exec("CREATE TABLE " + qtest_precision + " (col1 number)"));
else
- QVERIFY_SQL( q, exec( "create table " + qtest_precision + " (col1 numeric(21, 20))" ) );
-
- QVERIFY_SQL( q, exec( "insert into " + qtest_precision + " (col1) values (1.2345678901234567891)" ) );
-
- QVERIFY_SQL( q, exec( "select * from " + qtest_precision ) );
- QVERIFY( q.next() );
+ QVERIFY_SQL(q, exec("CREATE TABLE " + qtest_precision + " (col1 numeric(21, 20))"));
- QString val = q.value( 0 ).toString();
-
- if ( !val.startsWith( "1.2345678901234567891" ) ) {
+ QVERIFY_SQL(q, exec("INSERT INTO " + qtest_precision + " (col1) VALUES (" + precStr + ")"));
+ QVERIFY_SQL(q, exec("SELECT * FROM " + qtest_precision));
+ QVERIFY(q.next());
+ const QString val = q.value(0).toString();
+ if (!val.startsWith(precStr)) {
int i = 0;
-
- while ( i < precStrLen && i < val.size() && precStr[i] != 0 && *( precStr + i ) == val[i].toLatin1() )
+ while (i < val.size() && precStr[i] != 0 && precStr[i] == val[i].toLatin1())
i++;
- // MySQL and TDS have crappy precisions by default
- if (dbType == QSqlDriver::MySqlServer) {
- if ( i < 17 )
- QWARN( "MySQL didn't return the right precision" );
- } else if (dbType == QSqlDriver::Sybase) {
- if ( i < 18 )
- QWARN( "TDS didn't return the right precision" );
+ // TDS has crappy precisions by default
+ if (dbType == QSqlDriver::Sybase) {
+ if (i < 18)
+ QWARN("TDS didn't return the right precision");
} else {
- QWARN( QString( tst_Databases::dbToString( db ) + " didn't return the right precision (" +
- QString::number( i ) + " out of 21), " + val ).toLatin1() );
+ QWARN(QString(tst_Databases::dbToString(db) + " didn't return the right precision (" +
+ QString::number(i) + " out of 21), " + val).toUtf8());
}
}
} // SQLITE scope
+ db.driver()->setNumericalPrecisionPolicy(oldPrecision);
}
void tst_QSqlQuery::nullResult()
@@ -2840,10 +2833,11 @@ void tst_QSqlQuery::psql_bindWithDoubleColonCastOperator()
QVERIFY_SQL( q, exec() );
QVERIFY_SQL( q, next() );
- if ( db.driver()->hasFeature( QSqlDriver::PreparedQueries ) )
- QCOMPARE( q.executedQuery(), QString( "select sum((fld1 - fld2)::int) from " + tablename + " where id1 = ? and id2 =? and id3=?" ) );
+ // the positional placeholders are converted to named placeholders in executedQuery()
+ if (db.driver()->hasFeature(QSqlDriver::PreparedQueries))
+ QCOMPARE(q.executedQuery(), QString("select sum((fld1 - fld2)::int) from " + tablename + " where id1 = :myid1 and id2 =:myid2 and id3=:myid3"));
else
- QCOMPARE( q.executedQuery(), QString( "select sum((fld1 - fld2)::int) from " + tablename + " where id1 = 1 and id2 =2 and id3=3" ) );
+ QCOMPARE(q.executedQuery(), QString("select sum((fld1 - fld2)::int) from " + tablename + " where id1 = 1 and id2 =2 and id3=3"));
}
void tst_QSqlQuery::psql_specialFloatValues()
@@ -4003,8 +3997,8 @@ void tst_QSqlQuery::QTBUG_2192()
// Check if retrieved value preserves reported precision
int precision = qMax(0, q.record().field("dt").precision());
- int diff = qAbs(q.value(0).toDateTime().msecsTo(dt));
- int keep = qMin(1000, (int)qPow(10.0, precision));
+ qint64 diff = qAbs(q.value(0).toDateTime().msecsTo(dt));
+ qint64 keep = qMin(1000LL, qRound64(qPow(10.0, precision)));
QVERIFY(diff <= 1000 - keep);
}
}
@@ -4021,8 +4015,10 @@ void tst_QSqlQuery::QTBUG_36211()
QSqlQuery q(db);
QVERIFY_SQL(q, exec(QString("CREATE TABLE %1 (dtwtz timestamptz, dtwotz timestamp)").arg(tableName)));
- QTimeZone l_tzBrazil("BRT");
- QTimeZone l_tzChina("CST");
+ QTimeZone l_tzBrazil("America/Sao_Paulo");
+ QTimeZone l_tzChina("Asia/Shanghai");
+ QVERIFY(l_tzBrazil.isValid());
+ QVERIFY(l_tzChina.isValid());
QDateTime dt = QDateTime(QDate(2014, 10, 30), QTime(14, 12, 02, 357));
QVERIFY_SQL(q, prepare("INSERT INTO " + tableName + " (dtwtz, dtwotz) VALUES (:dt, :dt)"));
q.bindValue(":dt", dt);
@@ -4040,8 +4036,8 @@ void tst_QSqlQuery::QTBUG_36211()
for (int j = 0; j < 2; ++j) {
// Check if retrieved value preserves reported precision
int precision = qMax(0, q.record().field(j).precision());
- int diff = qAbs(q.value(j).toDateTime().msecsTo(dt));
- int keep = qMin(1000, (int)qPow(10.0, precision));
+ qint64 diff = qAbs(q.value(j).toDateTime().msecsTo(dt));
+ qint64 keep = qMin(1000LL, qRound64(qPow(10.0, precision)));
QVERIFY(diff <= 1000 - keep);
}
}
diff --git a/tests/auto/widgets/dialogs/qfiledialog/tst_qfiledialog.cpp b/tests/auto/widgets/dialogs/qfiledialog/tst_qfiledialog.cpp
index 029738652e..afb24bc528 100644
--- a/tests/auto/widgets/dialogs/qfiledialog/tst_qfiledialog.cpp
+++ b/tests/auto/widgets/dialogs/qfiledialog/tst_qfiledialog.cpp
@@ -1380,6 +1380,7 @@ void tst_QFiledialog::clearLineEdit()
fd.setFileMode(QFileDialog::AnyFile);
fd.show();
+ QVERIFY(QTest::qWaitForWindowExposed(&fd));
QLineEdit *lineEdit = fd.findChild<QLineEdit*>("fileNameEdit");
QVERIFY(lineEdit);
QCOMPARE(lineEdit->text(), QLatin1String("foo"));
diff --git a/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp b/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp
index 6f8fd5dcbe..dd747a8616 100644
--- a/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp
+++ b/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp
@@ -60,6 +60,7 @@
#include <QtGui/qpaintengine.h>
#include <QtGui/qbackingstore.h>
#include <QtGui/qguiapplication.h>
+#include <QtGui/qpa/qplatformwindow.h>
#include <QtGui/qscreen.h>
#include <qmenubar.h>
#include <qcompleter.h>
@@ -227,6 +228,7 @@ private slots:
void setFixedSize();
void ensureCreated();
+ void createAndDestroy();
void winIdChangeEvent();
void persistentWinId();
void showNativeChild();
@@ -4250,6 +4252,58 @@ public:
int winIdChangeEventCount() const { return m_winIdList.count(); }
};
+class CreateDestroyWidget : public WinIdChangeWidget
+{
+public:
+ void create() { QWidget::create(); }
+ void destroy() { QWidget::destroy(); }
+};
+
+void tst_QWidget::createAndDestroy()
+{
+ CreateDestroyWidget widget;
+
+ // Create and destroy via QWidget
+ widget.create();
+ QVERIFY(widget.testAttribute(Qt::WA_WState_Created));
+ QCOMPARE(widget.winIdChangeEventCount(), 1);
+ QVERIFY(widget.internalWinId());
+
+ widget.destroy();
+ QVERIFY(!widget.testAttribute(Qt::WA_WState_Created));
+ QCOMPARE(widget.winIdChangeEventCount(), 2);
+ QVERIFY(!widget.internalWinId());
+
+ // Create via QWidget, destroy via QWindow
+ widget.create();
+ QVERIFY(widget.testAttribute(Qt::WA_WState_Created));
+ QCOMPARE(widget.winIdChangeEventCount(), 3);
+ QVERIFY(widget.internalWinId());
+
+ widget.windowHandle()->destroy();
+ QVERIFY(!widget.testAttribute(Qt::WA_WState_Created));
+ QCOMPARE(widget.winIdChangeEventCount(), 4);
+ QVERIFY(!widget.internalWinId());
+
+ // Create via QWidget again
+ widget.create();
+ QVERIFY(widget.testAttribute(Qt::WA_WState_Created));
+ QCOMPARE(widget.winIdChangeEventCount(), 5);
+ QVERIFY(widget.internalWinId());
+
+ // Destroy via QWindow, create via QWindow
+ widget.windowHandle()->destroy();
+ QVERIFY(widget.windowHandle());
+ QVERIFY(!widget.testAttribute(Qt::WA_WState_Created));
+ QCOMPARE(widget.winIdChangeEventCount(), 6);
+ QVERIFY(!widget.internalWinId());
+
+ widget.windowHandle()->create();
+ QVERIFY(widget.testAttribute(Qt::WA_WState_Created));
+ QCOMPARE(widget.winIdChangeEventCount(), 7);
+ QVERIFY(widget.internalWinId());
+}
+
void tst_QWidget::winIdChangeEvent()
{
{
diff --git a/tests/auto/widgets/widgets/qlineedit/tst_qlineedit.cpp b/tests/auto/widgets/widgets/qlineedit/tst_qlineedit.cpp
index c2475be8b4..bf31f12958 100644
--- a/tests/auto/widgets/widgets/qlineedit/tst_qlineedit.cpp
+++ b/tests/auto/widgets/widgets/qlineedit/tst_qlineedit.cpp
@@ -885,9 +885,6 @@ void tst_QLineEdit::hasAcceptableInputMask()
qApp->sendEvent(testWidget, &lostFocus);
QVERIFY(validInput);
- // at the moment we don't strip the blank character if it is valid input, this makes the test between x vs X useless
- QEXPECT_FAIL( "Any optional and required", "To eat blanks or not? Known issue. Task 43172", Abort);
-
// test requiredMask
testWidget->setInputMask(requiredMask);
validInput = true;
diff --git a/tests/auto/widgets/widgets/qplaintextedit/tst_qplaintextedit.cpp b/tests/auto/widgets/widgets/qplaintextedit/tst_qplaintextedit.cpp
index 336b6ebfd5..a86784f2ec 100644
--- a/tests/auto/widgets/widgets/qplaintextedit/tst_qplaintextedit.cpp
+++ b/tests/auto/widgets/widgets/qplaintextedit/tst_qplaintextedit.cpp
@@ -155,6 +155,7 @@ private slots:
#if QT_CONFIG(scrollbar)
void updateAfterChangeCenterOnScroll();
#endif
+ void updateCursorPositionAfterEdit();
private:
void createSelection();
@@ -1802,5 +1803,50 @@ void tst_QPlainTextEdit::updateAfterChangeCenterOnScroll()
#endif
+void tst_QPlainTextEdit::updateCursorPositionAfterEdit()
+{
+ QPlainTextEdit plaintextEdit;
+ plaintextEdit.setPlainText("some text some text\nsome text some text");
+
+ const auto initialPosition = 1;
+
+ // select some text
+ auto cursor = plaintextEdit.textCursor();
+ cursor.setPosition(initialPosition, QTextCursor::MoveAnchor);
+ cursor.setPosition(initialPosition + 3, QTextCursor::KeepAnchor);
+ plaintextEdit.setTextCursor(cursor);
+ QVERIFY(plaintextEdit.textCursor().hasSelection());
+
+ QTest::keyClick(&plaintextEdit, Qt::Key_Delete);
+ QTest::keyClick(&plaintextEdit, Qt::Key_Down);
+ QTest::keyClick(&plaintextEdit, Qt::Key_Up);
+
+ // Moving the cursor down and up should bring it to the initial position
+ QCOMPARE(plaintextEdit.textCursor().position(), initialPosition);
+
+ // Test the same with backspace
+ cursor = plaintextEdit.textCursor();
+ cursor.setPosition(initialPosition + 3, QTextCursor::KeepAnchor);
+ plaintextEdit.setTextCursor(cursor);
+ QVERIFY(plaintextEdit.textCursor().hasSelection());
+
+ QTest::keyClick(&plaintextEdit, Qt::Key_Backspace);
+ QTest::keyClick(&plaintextEdit, Qt::Key_Down);
+ QTest::keyClick(&plaintextEdit, Qt::Key_Up);
+
+ // Moving the cursor down and up should bring it to the initial position
+ QCOMPARE(plaintextEdit.textCursor().position(), initialPosition);
+
+ // Test insertion
+ const QString txt("txt");
+ QApplication::clipboard()->setText(txt);
+ plaintextEdit.paste();
+ QTest::keyClick(&plaintextEdit, Qt::Key_Down);
+ QTest::keyClick(&plaintextEdit, Qt::Key_Up);
+
+ // The curser should move back to the end of the copied text
+ QCOMPARE(plaintextEdit.textCursor().position(), initialPosition + txt.length());
+}
+
QTEST_MAIN(tst_QPlainTextEdit)
#include "tst_qplaintextedit.moc"
diff --git a/tests/benchmarks/corelib/thread/qreadwritelock/tst_qreadwritelock.cpp b/tests/benchmarks/corelib/thread/qreadwritelock/tst_qreadwritelock.cpp
index 1d47d98657..8f8e8300a1 100644
--- a/tests/benchmarks/corelib/thread/qreadwritelock/tst_qreadwritelock.cpp
+++ b/tests/benchmarks/corelib/thread/qreadwritelock/tst_qreadwritelock.cpp
@@ -30,7 +30,7 @@
#include <QtTest/QtTest>
#include <QtCore/private/qmemory_p.h>
#include <mutex>
-#if QT_HAS_INCLUDE(<shared_mutex>)
+#if __has_include(<shared_mutex>)
#if __cplusplus > 201103L
#include <shared_mutex>
#endif
diff --git a/tests/manual/highdpi/main.cpp b/tests/manual/highdpi/main.cpp
index c025f251a2..2a9fb6aa0c 100644
--- a/tests/manual/highdpi/main.cpp
+++ b/tests/manual/highdpi/main.cpp
@@ -39,6 +39,7 @@
#include <QButtonGroup>
#include <QLineEdit>
#include <QPlainTextEdit>
+#include <QTabWidget>
#include <QScrollBar>
#include <QSlider>
#include <QSpinBox>
@@ -51,12 +52,14 @@
#include <QGraphicsView>
#include <QGraphicsTextItem>
#include <QFile>
+#include <QFontMetrics>
#include <QMouseEvent>
#include <QTemporaryDir>
#include <QTimer>
#include <QCommandLineParser>
#include <QCommandLineOption>
#include <QDebug>
+#include <QElapsedTimer>
#include <private/qhighdpiscaling_p.h>
#include <qpa/qplatformscreen.h>
@@ -64,6 +67,12 @@
#include <utility>
+static QTextStream &operator<<(QTextStream &str, const QSizeF &s)
+{
+ str << s.width() << 'x' << s.height();
+ return str;
+}
+
static QTextStream &operator<<(QTextStream &str, const QRect &r)
{
str << r.width() << 'x' << r.height() << Qt::forcesign << r.x() << r.y() << Qt::noforcesign;
@@ -1241,7 +1250,7 @@ public:
}
};
-class MetricsTest : public QWidget
+class MetricsTest : public QTabWidget
{
Q_OBJECT
public:
@@ -1258,14 +1267,25 @@ QT_SCREEN_SCALE_FACTORS=N;N;N or QT_SCREEN_SCALE_FACTORS=name:N
QT_SCALE_FACTOR_ROUNDING_POLICY=Round|Ceil|Floor|RoundPreferFloor|PassThrough
QT_DPI_ADJUSTMENT_POLICY=AdjustDpi|DontAdjustDpi|AdjustUpOnly)";
- resize(480, 360);
+ m_textEdit = addTextPage("Parameters");
+ m_logEdit = addTextPage("Screen Change Log");
- auto layout = new QVBoxLayout(this);
+ const auto screens = QGuiApplication::screens();
+ for (auto screen : screens)
+ connectScreenChangeSignals(screen);
+ connect(qApp, &QGuiApplication::screenAdded, this, &MetricsTest::slotScreenAdded);
+ connect(qApp, &QGuiApplication::primaryScreenChanged, this, &MetricsTest::slotPrimaryScreenChanged);
+ connect(qApp, &QGuiApplication::screenRemoved, this, &MetricsTest::slotScreenRemoved);
- m_textEdit = new QPlainTextEdit;
- m_textEdit->setReadOnly(true);
- layout->addWidget(m_textEdit);
setWindowTitle(formatWindowTitle("Screens"));
+ m_logTimer.start();
+ logMessage(briefFormatScreens());
+
+ // Resize to roughly match the metrics text.
+ const auto metrics = QFontMetrics(m_textEdit->font(), m_textEdit);
+ const int width = 10 + metrics.horizontalAdvance(QStringLiteral("X")) * 50;
+ const int height = 40 + metrics.height() * (10 + 8 * screens.size());
+ resize(width, height);
}
void setVisible(bool visible) override
@@ -1323,15 +1343,118 @@ QT_DPI_ADJUSTMENT_POLICY=AdjustDpi|DontAdjustDpi|AdjustUpOnly)";
private slots:
void screenChanged()
{
- qDebug().noquote() << __FUNCTION__ << windowHandle()->screen()->name();
+ const QString message = QLatin1String("screenChanged ") + windowHandle()->screen()->name();
+ qInfo("%s", qPrintable(message));
+ logMessage(message);
updateMetrics();
}
+ void slotScreenAdded(QScreen *);
+ void slotScreenRemoved(QScreen *);
+ void slotPrimaryScreenChanged(QScreen *);
+ void slotScreenGeometryChanged(const QRect &geometry)
+ { logScreenChangeSignal(sender(), "geometry", geometry); }
+ void slotScreenAvailableGeometryChanged(const QRect &geometry)
+ { logScreenChangeSignal(sender(), "availableGeometry", geometry); }
+ void slotScreenPhysicalSizeChanged(const QSizeF &size)
+ { logScreenChangeSignal(sender(), "physicalSize", size); }
+ void slotScreenPhysicalDotsPerInchChanged(qreal dpi)
+ { logScreenChangeSignal(sender(), "physicalDotsPerInch", dpi); }
+ void slotScreenLogicalDotsPerInchChanged(qreal dpi)
+ { logScreenChangeSignal(sender(), "logicalDotsPerInch", dpi); }
+ void slotScreenVirtualGeometryChanged(const QRect &rect)
+ { logScreenChangeSignal(sender(), "virtualGeometry", rect); }
+ void slotScreenPrimaryOrientationChanged(Qt::ScreenOrientation orientation)
+ { logScreenChangeSignal(sender(), "primaryOrientation", orientation); }
+ void slotScreenOrientationChanged(Qt::ScreenOrientation orientation)
+ { logScreenChangeSignal(sender(), "orientation", orientation); }
+ void slotScreenRefreshRateChanged(qreal refreshRate)
+ { logScreenChangeSignal(sender(), "refreshRate", refreshRate); }
+
private:
+ QPlainTextEdit *addTextPage(const QString &title);
+ void logMessage(const QString &);
+ void connectScreenChangeSignals(QScreen *s);
+ static QString briefFormatScreens();
+ template <class T>
+ void logScreenChangeSignal(const QObject *o, const char *name, const T &value);
+
QPlainTextEdit *m_textEdit;
+ QPlainTextEdit *m_logEdit;
+ QElapsedTimer m_logTimer;
bool m_screenChangedConnected = false;
};
+void MetricsTest::slotScreenAdded(QScreen *screen)
+{
+ logMessage(QLatin1String("Added ") + screen->name() + QLatin1Char(' ')
+ + briefFormatScreens());
+ connectScreenChangeSignals(screen);
+}
+
+void MetricsTest::slotScreenRemoved(QScreen *screen)
+{
+ logMessage(QLatin1String("Removed ") + screen->name() + QLatin1Char(' ')
+ + briefFormatScreens());
+}
+
+void MetricsTest::slotPrimaryScreenChanged(QScreen *screen)
+{
+ logMessage(QLatin1String("PrimaryScreenChanged ") + screen->name() + QLatin1Char(' ')
+ + briefFormatScreens());
+}
+
+QPlainTextEdit *MetricsTest::addTextPage(const QString &title)
+{
+ auto result = new QPlainTextEdit(this);
+ result->setReadOnly(true);
+ result->setFont(QFontDatabase::systemFont(QFontDatabase::FixedFont));
+ addTab(result, title);
+ return result;
+}
+
+void MetricsTest::logMessage(const QString &m)
+{
+ const QString timeStamp =
+ QStringLiteral("%1ms: %2").arg(m_logTimer.elapsed(), 6, 10, QLatin1Char('0')).arg(m);
+ m_logEdit->appendPlainText(timeStamp);
+}
+
+void MetricsTest::connectScreenChangeSignals(QScreen *s)
+{
+ connect(s, &QScreen::geometryChanged, this, &MetricsTest::slotScreenGeometryChanged);
+ connect(s, &QScreen::availableGeometryChanged, this, &MetricsTest::slotScreenAvailableGeometryChanged);
+ connect(s, &QScreen::physicalSizeChanged, this, &MetricsTest::slotScreenPhysicalSizeChanged);
+ connect(s, &QScreen::physicalDotsPerInchChanged, this, &MetricsTest::slotScreenPhysicalDotsPerInchChanged);
+ connect(s, &QScreen::logicalDotsPerInchChanged, this, &MetricsTest::slotScreenLogicalDotsPerInchChanged);
+ connect(s, &QScreen::virtualGeometryChanged, this, &MetricsTest::slotScreenVirtualGeometryChanged);
+ connect(s, &QScreen::primaryOrientationChanged, this, &MetricsTest::slotScreenPrimaryOrientationChanged);
+ connect(s, &QScreen::orientationChanged, this, &MetricsTest::slotScreenOrientationChanged);
+ connect(s, &QScreen::refreshRateChanged, this, &MetricsTest::slotScreenRefreshRateChanged);
+}
+
+QString MetricsTest::briefFormatScreens()
+{
+ QString message;
+ QTextStream str(&message);
+ const auto screens = QGuiApplication::screens();
+ for (int i = 0, size = screens.size(); i < size; ++i) {
+ str << (i ? ", " : "(");
+ str << screens.at(i)->name() << " " << screens.at(i)->geometry();
+ }
+ str << ')';
+ return message;
+}
+
+template <class T>
+void MetricsTest::logScreenChangeSignal(const QObject *o, const char *name, const T &value)
+{
+ auto screen = qobject_cast<const QScreen *>(o);
+ QString message;
+ QTextStream(&message) << (screen ? screen->name() : QString()) << ' ' << name << " changed: " << value;
+ logMessage(message);
+}
+
int main(int argc, char **argv)
{
#define NOSCALINGOPTION "noscaling"
diff --git a/tests/testserver/docker-compose-bridge-network.yml b/tests/testserver/docker-compose-bridge-network.yml
index 2cabeee1dc..8054d631f8 100644
--- a/tests/testserver/docker-compose-bridge-network.yml
+++ b/tests/testserver/docker-compose-bridge-network.yml
@@ -1,11 +1,20 @@
version: '2.1'
-# The tag of images is used by docker compose file to launch the corresponding
-# docker containers. The value of tag comes from the provisioning script
-# (coin/provisioning/.../testserver/docker_testserver.sh). The script gets SHA-1
-# of each server context as the tag of docker images. If one of the server
-# contexts gets changes, please make sure to update this compose file as well.
-# You can run command 'docker images' to list all the tags of test server images.
+# The tag of images is used by docker compose file to launch the correct
+# docker containers. By default we always launch the "latest" tag.
+#
+# But in the "docker build" phase, we also tag the images with a unique tag,
+# the SHA1 hash of all files used for "docker build" - see sha1tree() in
+# provisioning.
+#
+# So if you want to update the docker image at a specific time, make sure that
+# 1. you modify this file to run the specific image's SHA1 tag, instead of
+# "latest"
+# 2. you build two docker images in provisioning, the currently used one,
+# plus the new one that you tag as "latest"
+# 3. you switch this file to the "latest" tag when ready
+
+# You can run `docker images` to list all the tags of available images:
# For example:
# REPOSITORY TAG
# qt-test-server-apache2 537fe302f61851d1663f41495230d8e3554a4a13
@@ -20,7 +29,7 @@ services:
build:
context: .
args:
- provisioningImage: qt-test-server-apache2:537fe302f61851d1663f41495230d8e3554a4a13
+ provisioningImage: qt-test-server-apache2:latest
shareDir: ./common
serviceDir: ./apache2
entrypoint: service/startup.sh
@@ -43,7 +52,7 @@ services:
build:
context: .
args:
- provisioningImage: qt-test-server-squid:9c32f41b19aca3d778733c4d8fb0ecc5955e893c
+ provisioningImage: qt-test-server-squid:latest
shareDir: ./common
serviceDir: ./squid
entrypoint: service/startup.sh
@@ -58,7 +67,7 @@ services:
build:
context: .
args:
- provisioningImage: qt-test-server-vsftpd:f3a9c8d793a77cc007c0e4e481bec01f9e3eeb7e
+ provisioningImage: qt-test-server-vsftpd:latest
shareDir: ./common
serviceDir: ./vsftpd
entrypoint: service/startup.sh
@@ -77,7 +86,7 @@ services:
build:
context: .
args:
- provisioningImage: qt-test-server-ftp-proxy:d7de8b28392d173db512a558ccc84ead8bece2ae
+ provisioningImage: qt-test-server-ftp-proxy:latest
shareDir: ./common
serviceDir: ./ftp-proxy
entrypoint: service/startup.sh
@@ -102,7 +111,7 @@ services:
build:
context: .
args:
- provisioningImage: qt-test-server-danted:35607f9b790524cf9690c7d12a9a401696b7b6b5
+ provisioningImage: qt-test-server-danted:latest
shareDir: ./common
serviceDir: ./danted
entrypoint: service/startup.sh
@@ -117,7 +126,7 @@ services:
build:
context: .
args:
- provisioningImage: qt-test-server-cyrus:c8d72754abc0e501afd624ce838e4df35505abc9
+ provisioningImage: qt-test-server-cyrus:latest
shareDir: ./common
serviceDir: ./cyrus
entrypoint: service/startup.sh
@@ -132,7 +141,7 @@ services:
build:
context: .
args:
- provisioningImage: qt-test-server-iptables:cb7a8bd6d28602085a88c8ced7d67e28e75781e2
+ provisioningImage: qt-test-server-iptables:latest
shareDir: ./common
serviceDir: ./iptables
entrypoint: service/startup.sh
@@ -150,7 +159,7 @@ services:
build:
context: .
args:
- provisioningImage: qt-test-server-echo:b29ad409e746a834c1055fd0f7a55fd5056da6ea
+ provisioningImage: qt-test-server-echo:latest
shareDir: ./common
serviceDir: ./echo
entrypoint: service/startup.sh
diff --git a/tests/testserver/docker-compose-host-network.yml b/tests/testserver/docker-compose-host-network.yml
index 4b2e1ebdab..aedd94cf73 100644
--- a/tests/testserver/docker-compose-host-network.yml
+++ b/tests/testserver/docker-compose-host-network.yml
@@ -1,14 +1,7 @@
version: '2.1'
-# The tag of images is used by docker compose file to launch the corresponding
-# docker containers. The value of tag comes from the provisioning script
-# (coin/provisioning/.../testserver/docker_testserver.sh). The script gets SHA-1
-# of each server context as the tag of docker images. If one of the server
-# contexts gets changes, please make sure to update this compose file as well.
-# You can run command 'docker images' to list all the tags of test server images.
-# For example:
-# REPOSITORY TAG
-# qt-test-server-apache2 537fe302f61851d1663f41495230d8e3554a4a13
+# For details about the "latest" tag used in the images here, see comments in
+# docker-compose-bridge-network.yml
services:
apache2:
@@ -20,7 +13,7 @@ services:
build:
context: .
args:
- provisioningImage: qt-test-server-apache2:537fe302f61851d1663f41495230d8e3554a4a13
+ provisioningImage: qt-test-server-apache2:latest
shareDir: ./common
serviceDir: ./apache2
entrypoint: service/startup.sh
@@ -39,7 +32,7 @@ services:
build:
context: .
args:
- provisioningImage: qt-test-server-squid:9c32f41b19aca3d778733c4d8fb0ecc5955e893c
+ provisioningImage: qt-test-server-squid:latest
shareDir: ./common
serviceDir: ./squid
entrypoint: service/startup.sh
@@ -54,7 +47,7 @@ services:
build:
context: .
args:
- provisioningImage: qt-test-server-vsftpd:f3a9c8d793a77cc007c0e4e481bec01f9e3eeb7e
+ provisioningImage: qt-test-server-vsftpd:latest
shareDir: ./common
serviceDir: ./vsftpd
entrypoint: service/startup.sh
@@ -71,7 +64,7 @@ services:
build:
context: .
args:
- provisioningImage: qt-test-server-ftp-proxy:d7de8b28392d173db512a558ccc84ead8bece2ae
+ provisioningImage: qt-test-server-ftp-proxy:latest
shareDir: ./common
serviceDir: ./ftp-proxy
entrypoint: service/startup.sh
@@ -90,7 +83,7 @@ services:
build:
context: .
args:
- provisioningImage: qt-test-server-danted:35607f9b790524cf9690c7d12a9a401696b7b6b5
+ provisioningImage: qt-test-server-danted:latest
shareDir: ./common
serviceDir: ./danted
entrypoint: service/startup.sh