summaryrefslogtreecommitdiffstats
path: root/tests/auto
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto')
-rw-r--r--tests/auto/corelib/kernel/qdeadlinetimer/tst_qdeadlinetimer.cpp79
-rw-r--r--tests/auto/corelib/tools/qlocale/tst_qlocale.cpp12
-rw-r--r--tests/auto/gui/text/qfontdatabase/BLACKLIST3
-rw-r--r--tests/auto/gui/text/qfontdatabase/tst_qfontdatabase.cpp13
-rw-r--r--tests/auto/other/qaccessibility/tst_qaccessibility.cpp15
-rw-r--r--tests/auto/other/qaccessibilitylinux/qaccessibilitylinux.pro1
-rw-r--r--tests/auto/other/qaccessibilitylinux/tst_qaccessibilitylinux.cpp15
-rw-r--r--tests/auto/testlib/selftests/expected_sleep.lightxml4
-rw-r--r--tests/auto/testlib/selftests/expected_sleep.tap9
-rw-r--r--tests/auto/testlib/selftests/expected_sleep.teamcity2
-rw-r--r--tests/auto/testlib/selftests/expected_sleep.txt3
-rw-r--r--tests/auto/testlib/selftests/expected_sleep.xml4
-rw-r--r--tests/auto/testlib/selftests/expected_sleep.xunitxml3
-rw-r--r--tests/auto/testlib/selftests/sleep/tst_sleep.cpp19
14 files changed, 166 insertions, 16 deletions
diff --git a/tests/auto/corelib/kernel/qdeadlinetimer/tst_qdeadlinetimer.cpp b/tests/auto/corelib/kernel/qdeadlinetimer/tst_qdeadlinetimer.cpp
index 6ab24d2480..4ca68550b9 100644
--- a/tests/auto/corelib/kernel/qdeadlinetimer/tst_qdeadlinetimer.cpp
+++ b/tests/auto/corelib/kernel/qdeadlinetimer/tst_qdeadlinetimer.cpp
@@ -29,6 +29,7 @@
#include <QtCore/QString>
#include <QtCore/QTime>
#include <QtCore/QDeadlineTimer>
+#include <QtCore/QElapsedTimer>
#include <QtTest/QtTest>
#if QT_HAS_INCLUDE(<chrono>)
@@ -50,6 +51,7 @@ private Q_SLOTS:
void current();
void deadlines();
void setDeadline();
+ void overflow();
void expire();
void stdchrono();
};
@@ -417,6 +419,83 @@ void tst_QDeadlineTimer::setDeadline()
QCOMPARE(deadline.deadlineNSecs(), nsec);
}
+void tst_QDeadlineTimer::overflow()
+{
+ QFETCH_GLOBAL(Qt::TimerType, timerType);
+ // Check the constructor for overflows (should also cover saturating the result of the deadline() method if overflowing)
+ QDeadlineTimer now = QDeadlineTimer::current(timerType), deadline(std::numeric_limits<qint64>::max() - 1, timerType);
+ QVERIFY(deadline.isForever() || deadline.deadline() >= now.deadline());
+
+ // Check the setDeadline with milliseconds (should also cover implicitly setting the nanoseconds as qint64 max)
+ deadline.setDeadline(std::numeric_limits<qint64>::max() - 1, timerType);
+ QVERIFY(deadline.isForever() || deadline.deadline() >= now.deadline());
+
+ // Check the setRemainingTime with milliseconds (should also cover implicitly setting the nanoseconds as qint64 max)
+ deadline.setRemainingTime(std::numeric_limits<qint64>::max() - 1, timerType);
+ QVERIFY(deadline.isForever() || deadline.deadline() >= now.deadline());
+
+ // Check that the deadline gets saturated when the arguments of setPreciseDeadline are large
+ deadline.setPreciseDeadline(std::numeric_limits<qint64>::max() - 1, std::numeric_limits<qint64>::max() - 1, timerType);
+ QCOMPARE(deadline.deadline(), std::numeric_limits<qint64>::max());
+ QVERIFY(deadline.isForever());
+
+ // Check that remainingTime gets saturated if we overflow
+ deadline.setPreciseRemainingTime(std::numeric_limits<qint64>::max() - 1, std::numeric_limits<qint64>::max() - 1, timerType);
+ QCOMPARE(deadline.remainingTime(), qint64(-1));
+ QVERIFY(deadline.isForever());
+
+ // Check that we saturate the getter for nanoseconds
+ deadline.setPreciseDeadline(std::numeric_limits<qint64>::max() - 1, 0, timerType);
+ QCOMPARE(deadline.deadlineNSecs(), std::numeric_limits<qint64>::max());
+
+ // Check that adding nanoseconds and overflowing is consistent and saturates the timer
+ deadline = QDeadlineTimer::addNSecs(deadline, std::numeric_limits<qint64>::max() - 1);
+ QVERIFY(deadline.isForever());
+
+ // Make sure forever is forever, regardless of us subtracting time from it
+ deadline = QDeadlineTimer(QDeadlineTimer::Forever, timerType);
+ deadline = QDeadlineTimer::addNSecs(deadline, -10000);
+ QVERIFY(deadline.isForever());
+
+ // Make sure we get the correct result when moving the deadline back and forth in time
+ QDeadlineTimer current = QDeadlineTimer::current(timerType);
+ QDeadlineTimer takenNSecs = QDeadlineTimer::addNSecs(current, -1000);
+ QVERIFY(takenNSecs.deadlineNSecs() - current.deadlineNSecs() == -1000);
+ QDeadlineTimer addedNSecs = QDeadlineTimer::addNSecs(current, 1000);
+ QVERIFY(addedNSecs.deadlineNSecs() - current.deadlineNSecs() == 1000);
+
+ // Make sure the calculation goes as expected when we need to subtract nanoseconds
+ // We make use of an additional timer to be certain that
+ // even when the environment is under load we can track the
+ // time needed to do the calls
+ static constexpr qint64 nsExpected = 1000 * 1000 * 1000 - 1000; // 1s - 1000ns, what we pass to setPreciseRemainingTime() later
+
+ QElapsedTimer callTimer;
+ callTimer.start();
+
+ deadline = QDeadlineTimer::current(timerType);
+ qint64 nsDeadline = deadline.deadlineNSecs();
+ // We adjust in relation to current() here, so we expect the difference to be a tad over the exact number.
+ // However we are tracking the elapsed time, so it shouldn't be a problem.
+ deadline.setPreciseRemainingTime(1, -1000, timerType);
+ qint64 difference = (deadline.deadlineNSecs() - nsDeadline) - nsExpected;
+ QVERIFY(difference >= 0); // Should always be true, but just in case
+ QVERIFY(difference <= callTimer.nsecsElapsed()); // Ideally difference should be 0 exactly
+
+ // Make sure setRemainingTime underflows gracefully
+ deadline.setPreciseRemainingTime(std::numeric_limits<qint64>::min() / 10, 0, timerType);
+ QVERIFY(!deadline.isForever()); // On Win/macOS the above underflows, make sure we don't saturate to Forever
+ QVERIFY(deadline.remainingTime() == 0);
+ // If the timer is saturated we don't want to get a valid number of milliseconds
+ QVERIFY(deadline.deadline() == std::numeric_limits<qint64>::min());
+
+ // Check that the conversion to milliseconds and nanoseconds underflows gracefully
+ deadline.setPreciseDeadline(std::numeric_limits<qint64>::min() / 10, 0, timerType);
+ QVERIFY(!deadline.isForever()); // On Win/macOS the above underflows, make sure we don't saturate to Forever
+ QVERIFY(deadline.deadline() == std::numeric_limits<qint64>::min());
+ QVERIFY(deadline.deadlineNSecs() == std::numeric_limits<qint64>::min());
+}
+
void tst_QDeadlineTimer::expire()
{
QFETCH_GLOBAL(Qt::TimerType, timerType);
diff --git a/tests/auto/corelib/tools/qlocale/tst_qlocale.cpp b/tests/auto/corelib/tools/qlocale/tst_qlocale.cpp
index 0b41af3371..be2e2a2e08 100644
--- a/tests/auto/corelib/tools/qlocale/tst_qlocale.cpp
+++ b/tests/auto/corelib/tools/qlocale/tst_qlocale.cpp
@@ -2458,9 +2458,9 @@ void tst_QLocale::timeFormat()
QCOMPARE(c.timeFormat(QLocale::NarrowFormat), c.timeFormat(QLocale::ShortFormat));
const QLocale no("no_NO");
- QCOMPARE(no.timeFormat(QLocale::NarrowFormat), QLatin1String("HH:mm"));
- QCOMPARE(no.timeFormat(QLocale::ShortFormat), QLatin1String("HH:mm"));
- QCOMPARE(no.timeFormat(QLocale::LongFormat), QLatin1String("HH:mm:ss t"));
+ QCOMPARE(no.timeFormat(QLocale::NarrowFormat), QLatin1String("HH.mm"));
+ QCOMPARE(no.timeFormat(QLocale::ShortFormat), QLatin1String("HH.mm"));
+ QCOMPARE(no.timeFormat(QLocale::LongFormat), QLatin1String("HH.mm.ss t"));
const QLocale id("id_ID");
QCOMPARE(id.timeFormat(QLocale::ShortFormat), QLatin1String("HH.mm"));
@@ -2482,9 +2482,9 @@ void tst_QLocale::dateTimeFormat()
QCOMPARE(c.dateTimeFormat(QLocale::NarrowFormat), c.dateTimeFormat(QLocale::ShortFormat));
const QLocale no("no_NO");
- QCOMPARE(no.dateTimeFormat(QLocale::NarrowFormat), QLatin1String("dd.MM.yyyy HH:mm"));
- QCOMPARE(no.dateTimeFormat(QLocale::ShortFormat), QLatin1String("dd.MM.yyyy HH:mm"));
- QCOMPARE(no.dateTimeFormat(QLocale::LongFormat), QLatin1String("dddd d. MMMM yyyy HH:mm:ss t"));
+ QCOMPARE(no.dateTimeFormat(QLocale::NarrowFormat), QLatin1String("dd.MM.yyyy HH.mm"));
+ QCOMPARE(no.dateTimeFormat(QLocale::ShortFormat), QLatin1String("dd.MM.yyyy HH.mm"));
+ QCOMPARE(no.dateTimeFormat(QLocale::LongFormat), QLatin1String("dddd d. MMMM yyyy HH.mm.ss t"));
}
void tst_QLocale::monthName()
diff --git a/tests/auto/gui/text/qfontdatabase/BLACKLIST b/tests/auto/gui/text/qfontdatabase/BLACKLIST
new file mode 100644
index 0000000000..7f479e4b0e
--- /dev/null
+++ b/tests/auto/gui/text/qfontdatabase/BLACKLIST
@@ -0,0 +1,3 @@
+[systemFixedFont] # QTBUG-54623
+winrt
+b2qt
diff --git a/tests/auto/gui/text/qfontdatabase/tst_qfontdatabase.cpp b/tests/auto/gui/text/qfontdatabase/tst_qfontdatabase.cpp
index 68664cdd2f..064e37f73c 100644
--- a/tests/auto/gui/text/qfontdatabase/tst_qfontdatabase.cpp
+++ b/tests/auto/gui/text/qfontdatabase/tst_qfontdatabase.cpp
@@ -35,6 +35,8 @@
#include <private/qrawfont_p.h>
#include <qpa/qplatformfontdatabase.h>
+Q_LOGGING_CATEGORY(lcTests, "qt.text.tests")
+
class tst_QFontDatabase : public QObject
{
Q_OBJECT
@@ -49,6 +51,7 @@ private slots:
void fixedPitch_data();
void fixedPitch();
+ void systemFixedFont();
#ifdef Q_OS_MAC
void trickyFonts_data();
@@ -156,6 +159,16 @@ void tst_QFontDatabase::fixedPitch()
QCOMPARE(fi.fixedPitch(), fixedPitch);
}
+void tst_QFontDatabase::systemFixedFont() // QTBUG-54623
+{
+ QFont font = QFontDatabase::systemFont(QFontDatabase::FixedFont);
+ QFontInfo fontInfo(font);
+ bool fdbSaysFixed = QFontDatabase().isFixedPitch(fontInfo.family(), fontInfo.styleName());
+ qCDebug(lcTests) << "system fixed font is" << font << "really fixed?" << fdbSaysFixed << fontInfo.fixedPitch();
+ QVERIFY(fdbSaysFixed);
+ QVERIFY(fontInfo.fixedPitch());
+}
+
#ifdef Q_OS_MAC
void tst_QFontDatabase::trickyFonts_data()
{
diff --git a/tests/auto/other/qaccessibility/tst_qaccessibility.cpp b/tests/auto/other/qaccessibility/tst_qaccessibility.cpp
index 8b24937079..bc45487599 100644
--- a/tests/auto/other/qaccessibility/tst_qaccessibility.cpp
+++ b/tests/auto/other/qaccessibility/tst_qaccessibility.cpp
@@ -2045,6 +2045,15 @@ void tst_QAccessibility::lineEditTest()
QVERIFY(!iface->state().selectable);
QVERIFY(iface->state().selectableText);
QVERIFY(!iface->state().hasPopup);
+ QVERIFY(!iface->state().readOnly);
+ QVERIFY(iface->state().editable);
+
+ le->setReadOnly(true);
+ QVERIFY(iface->state().editable);
+ QVERIFY(iface->state().readOnly);
+ le->setReadOnly(false);
+ QVERIFY(!iface->state().readOnly);
+
QCOMPARE(bool(iface->state().focused), le->hasFocus());
QString secret(QLatin1String("secret"));
@@ -3640,6 +3649,12 @@ void tst_QAccessibility::labelTest()
QVERIFY(acc_label);
QCOMPARE(acc_label->text(QAccessible::Name), text);
+ QCOMPARE(acc_label->state().editable, false);
+ QCOMPARE(acc_label->state().passwordEdit, false);
+ QCOMPARE(acc_label->state().disabled, false);
+ QCOMPARE(acc_label->state().focused, false);
+ QCOMPARE(acc_label->state().focusable, false);
+ QCOMPARE(acc_label->state().readOnly, true);
QVector<QPair<QAccessibleInterface *, QAccessible::Relation> > rels = acc_label->relations();
QCOMPARE(rels.count(), 1);
diff --git a/tests/auto/other/qaccessibilitylinux/qaccessibilitylinux.pro b/tests/auto/other/qaccessibilitylinux/qaccessibilitylinux.pro
index 5cb3f5902a..a964df0e24 100644
--- a/tests/auto/other/qaccessibilitylinux/qaccessibilitylinux.pro
+++ b/tests/auto/other/qaccessibilitylinux/qaccessibilitylinux.pro
@@ -5,3 +5,4 @@ SOURCES += tst_qaccessibilitylinux.cpp
QT += gui-private widgets dbus testlib accessibility_support-private linuxaccessibility_support-private
+DBUS_INTERFACES = $$PWD/../../../../src/platformsupport/linuxaccessibility/dbusxml/Bus.xml
diff --git a/tests/auto/other/qaccessibilitylinux/tst_qaccessibilitylinux.cpp b/tests/auto/other/qaccessibilitylinux/tst_qaccessibilitylinux.cpp
index 48594b2fa1..7ba3715e13 100644
--- a/tests/auto/other/qaccessibilitylinux/tst_qaccessibilitylinux.cpp
+++ b/tests/auto/other/qaccessibilitylinux/tst_qaccessibilitylinux.cpp
@@ -42,12 +42,11 @@
#include <QDBusInterface>
#include <QDBusReply>
-#include "atspi/atspi-constants.h"
+#include <atspi/atspi-constants.h>
+#include <private/dbusconnection_p.h>
+#include <private/struct_marshallers_p.h>
#include "bus_interface.h"
-#include "dbusconnection_p.h"
-#include "struct_marshallers_p.h"
-
#define COMPARE3(v1, v2, v3) QCOMPARE(v1, v3); QCOMPARE(v2, v3);
class AccessibleTestWindow : public QWidget
@@ -251,6 +250,8 @@ void tst_QAccessibilityLinux::testLabel()
QCOMPARE(labelInterface->call(QDBus::Block, "GetRoleName").arguments().first().toString(), QLatin1String("label"));
QCOMPARE(labelInterface->call(QDBus::Block, "GetRole").arguments().first().toUInt(), 29u);
QCOMPARE(getParent(labelInterface), mainWindow->path());
+ QVERIFY(!hasState(labelInterface, ATSPI_STATE_EDITABLE));
+ QVERIFY(hasState(labelInterface, ATSPI_STATE_READ_ONLY));
l->setText("New text");
QCOMPARE(labelInterface->property("Name").toString(), l->text());
@@ -303,6 +304,12 @@ void tst_QAccessibilityLinux::testLineEdit()
QCOMPARE(lineEdit->selectionStart(), -1);
QCOMPARE(textInterface->call(QDBus::Block, "GetNSelections").arguments().first().toInt(), 0);
+ QVERIFY(hasState(accessibleInterface, ATSPI_STATE_EDITABLE));
+ QVERIFY(!hasState(accessibleInterface, ATSPI_STATE_READ_ONLY));
+ lineEdit->setReadOnly(true);
+ QVERIFY(hasState(accessibleInterface, ATSPI_STATE_EDITABLE));
+ QVERIFY(hasState(accessibleInterface, ATSPI_STATE_READ_ONLY));
+
m_window->clearChildren();
delete accessibleInterface;
delete textInterface;
diff --git a/tests/auto/testlib/selftests/expected_sleep.lightxml b/tests/auto/testlib/selftests/expected_sleep.lightxml
index 97b65d1259..78e1c44cf2 100644
--- a/tests/auto/testlib/selftests/expected_sleep.lightxml
+++ b/tests/auto/testlib/selftests/expected_sleep.lightxml
@@ -11,6 +11,10 @@
<Incident type="pass" file="" line="0" />
<Duration msecs="0"/>
</TestFunction>
+<TestFunction name="wait">
+<Incident type="pass" file="" line="0" />
+ <Duration msecs="0"/>
+</TestFunction>
<TestFunction name="cleanupTestCase">
<Incident type="pass" file="" line="0" />
<Duration msecs="0"/>
diff --git a/tests/auto/testlib/selftests/expected_sleep.tap b/tests/auto/testlib/selftests/expected_sleep.tap
index 7caef214d2..65edefb9ba 100644
--- a/tests/auto/testlib/selftests/expected_sleep.tap
+++ b/tests/auto/testlib/selftests/expected_sleep.tap
@@ -2,8 +2,9 @@ TAP version 13
# tst_Sleep
ok 1 - initTestCase()
ok 2 - sleep()
-ok 3 - cleanupTestCase()
-1..3
-# tests 3
-# pass 3
+ok 3 - wait()
+ok 4 - cleanupTestCase()
+1..4
+# tests 4
+# pass 4
# fail 0
diff --git a/tests/auto/testlib/selftests/expected_sleep.teamcity b/tests/auto/testlib/selftests/expected_sleep.teamcity
index 36b2445ccc..45a503bb54 100644
--- a/tests/auto/testlib/selftests/expected_sleep.teamcity
+++ b/tests/auto/testlib/selftests/expected_sleep.teamcity
@@ -3,6 +3,8 @@
##teamcity[testFinished name='initTestCase()' flowId='tst_Sleep']
##teamcity[testStarted name='sleep()' flowId='tst_Sleep']
##teamcity[testFinished name='sleep()' flowId='tst_Sleep']
+##teamcity[testStarted name='wait()' flowId='tst_Sleep']
+##teamcity[testFinished name='wait()' flowId='tst_Sleep']
##teamcity[testStarted name='cleanupTestCase()' flowId='tst_Sleep']
##teamcity[testFinished name='cleanupTestCase()' flowId='tst_Sleep']
##teamcity[testSuiteFinished name='tst_Sleep' flowId='tst_Sleep']
diff --git a/tests/auto/testlib/selftests/expected_sleep.txt b/tests/auto/testlib/selftests/expected_sleep.txt
index d18c3212bb..d1701d2bed 100644
--- a/tests/auto/testlib/selftests/expected_sleep.txt
+++ b/tests/auto/testlib/selftests/expected_sleep.txt
@@ -2,6 +2,7 @@
Config: Using QtTest library
PASS : tst_Sleep::initTestCase()
PASS : tst_Sleep::sleep()
+PASS : tst_Sleep::wait()
PASS : tst_Sleep::cleanupTestCase()
-Totals: 3 passed, 0 failed, 0 skipped, 0 blacklisted, 0ms
+Totals: 4 passed, 0 failed, 0 skipped, 0 blacklisted, 0ms
********* Finished testing of tst_Sleep *********
diff --git a/tests/auto/testlib/selftests/expected_sleep.xml b/tests/auto/testlib/selftests/expected_sleep.xml
index 5729c0ac9d..94bb25ba8d 100644
--- a/tests/auto/testlib/selftests/expected_sleep.xml
+++ b/tests/auto/testlib/selftests/expected_sleep.xml
@@ -13,6 +13,10 @@
<Incident type="pass" file="" line="0" />
<Duration msecs="0"/>
</TestFunction>
+<TestFunction name="wait">
+<Incident type="pass" file="" line="0" />
+ <Duration msecs="0"/>
+</TestFunction>
<TestFunction name="cleanupTestCase">
<Incident type="pass" file="" line="0" />
<Duration msecs="0"/>
diff --git a/tests/auto/testlib/selftests/expected_sleep.xunitxml b/tests/auto/testlib/selftests/expected_sleep.xunitxml
index 138486fc02..e4ed66bcb8 100644
--- a/tests/auto/testlib/selftests/expected_sleep.xunitxml
+++ b/tests/auto/testlib/selftests/expected_sleep.xunitxml
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" ?>
-<testsuite errors="0" failures="0" tests="3" name="tst_Sleep">
+<testsuite errors="0" failures="0" tests="4" name="tst_Sleep">
<properties>
<property value="@INSERT_QT_VERSION_HERE@" name="QTestVersion"/>
<property value="@INSERT_QT_VERSION_HERE@" name="QtVersion"/>
@@ -7,6 +7,7 @@
</properties>
<testcase result="pass" name="initTestCase"/>
<testcase result="pass" name="sleep"/>
+ <testcase result="pass" name="wait"/>
<testcase result="pass" name="cleanupTestCase"/>
<system-err/>
</testsuite>
diff --git a/tests/auto/testlib/selftests/sleep/tst_sleep.cpp b/tests/auto/testlib/selftests/sleep/tst_sleep.cpp
index afe6e22120..b7b141afd0 100644
--- a/tests/auto/testlib/selftests/sleep/tst_sleep.cpp
+++ b/tests/auto/testlib/selftests/sleep/tst_sleep.cpp
@@ -36,6 +36,7 @@ class tst_Sleep: public QObject
private slots:
void sleep();
+ void wait();
};
void tst_Sleep::sleep()
@@ -53,6 +54,24 @@ void tst_Sleep::sleep()
QVERIFY(t.elapsed() > 1000 * 10);
}
+void tst_Sleep::wait()
+{
+ QElapsedTimer t;
+ t.start();
+
+ QTest::qWait(1);
+ QVERIFY(t.elapsed() >= 1);
+
+ QTest::qWait(10);
+ QVERIFY(t.elapsed() >= 11);
+
+ QTest::qWait(100);
+ QVERIFY(t.elapsed() >= 111);
+
+ QTest::qWait(1000);
+ QVERIFY(t.elapsed() >= 1111);
+}
+
QTEST_MAIN(tst_Sleep)
#include "tst_sleep.moc"