summaryrefslogtreecommitdiffstats
path: root/tests/auto
diff options
context:
space:
mode:
authorTarja Sundqvist <tarja.sundqvist@qt.io>2024-01-04 21:21:43 +0200
committerTarja Sundqvist <tarja.sundqvist@qt.io>2024-01-04 21:21:43 +0200
commit4e158f6bfa7d0747d8da70b3b15a44b52e35bb8a (patch)
tree84e20982138de5c9b6d319bf83ac79bd672f918f /tests/auto
parente4391422574aa9aa89fece74f16c07c609cbbae2 (diff)
parenta13fd415d689be046c13cc562cbbbb5df0e6506a (diff)
Merge remote-tracking branch 'origin/tqtc/lts-5.15.13' into tqtc/lts-5.15-opensourcev5.15.13-lts-lgpl5.15
Diffstat (limited to 'tests/auto')
-rw-r--r--tests/auto/corelib/io/qbuffer/tst_qbuffer.cpp24
-rw-r--r--tests/auto/corelib/serialization/qxmlstream/tst_qxmlstream.cpp5
-rw-r--r--tests/auto/corelib/text/qlocale/tst_qlocale.cpp3
-rw-r--r--tests/auto/corelib/text/qstring/tst_qstring.cpp3
-rw-r--r--tests/auto/corelib/time/qtimezone/tst_qtimezone.cpp28
-rw-r--r--tests/auto/corelib/tools/qvarlengtharray/tst_qvarlengtharray.cpp34
-rw-r--r--tests/auto/gui/math3d/qquaternion/tst_qquaternion.cpp29
-rw-r--r--tests/auto/other/android/testdata/top_level_dir/file_in_top_dir.txt1
-rw-r--r--tests/auto/other/android/testdata/top_level_dir/sub_dir/file_in_sub_dir.txt1
-rw-r--r--tests/auto/other/android/testdata/top_level_dir/sub_dir/sub_dir2/sub_dir3/file_in_sub_dir_3.txt1
-rw-r--r--tests/auto/other/android/tst_android.cpp21
-rw-r--r--tests/auto/other/gestures/BLACKLIST13
12 files changed, 159 insertions, 4 deletions
diff --git a/tests/auto/corelib/io/qbuffer/tst_qbuffer.cpp b/tests/auto/corelib/io/qbuffer/tst_qbuffer.cpp
index 6f37f85230..b02400e349 100644
--- a/tests/auto/corelib/io/qbuffer/tst_qbuffer.cpp
+++ b/tests/auto/corelib/io/qbuffer/tst_qbuffer.cpp
@@ -36,6 +36,7 @@ class tst_QBuffer : public QObject
Q_OBJECT
private slots:
void open();
+ void openWriteOnlyDoesNotTruncate();
void getSetCheck();
void readBlock();
void readBlockPastEnd();
@@ -131,6 +132,29 @@ void tst_QBuffer::open()
b.close();
}
+void tst_QBuffer::openWriteOnlyDoesNotTruncate()
+{
+ QBuffer b;
+ const auto data = QByteArrayLiteral("Hey, presto!");
+
+ {
+ QVERIFY(b.open(QIODevice::WriteOnly));
+ b.write(data);
+ b.close();
+ }
+ {
+ QVERIFY(b.open(QIODevice::ReadOnly));
+ QCOMPARE(b.readAll(), data);
+ b.close();
+ }
+ {
+ QVERIFY(b.open(QIODevice::WriteOnly));
+ QCOMPARE(b.size(), data.size());
+ QCOMPARE(b.pos(), 0);
+ b.close();
+ }
+}
+
// some status() tests, too
void tst_QBuffer::readBlock()
{
diff --git a/tests/auto/corelib/serialization/qxmlstream/tst_qxmlstream.cpp b/tests/auto/corelib/serialization/qxmlstream/tst_qxmlstream.cpp
index 533fcd96f5..a2349a5846 100644
--- a/tests/auto/corelib/serialization/qxmlstream/tst_qxmlstream.cpp
+++ b/tests/auto/corelib/serialization/qxmlstream/tst_qxmlstream.cpp
@@ -1748,10 +1748,11 @@ static bool isValidSingleTextChar(const ushort c)
void tst_QXmlStream::readBack() const
{
+ QBuffer buffer;
+
for (ushort c = 0; c < std::numeric_limits<ushort>::max(); ++c) {
- QBuffer buffer;
- QVERIFY(buffer.open(QIODevice::WriteOnly));
+ QVERIFY(buffer.open(QIODevice::WriteOnly|QIODevice::Truncate));
QXmlStreamWriter writer(&buffer);
writer.writeStartDocument();
writer.writeTextElement("a", QString(QChar(c)));
diff --git a/tests/auto/corelib/text/qlocale/tst_qlocale.cpp b/tests/auto/corelib/text/qlocale/tst_qlocale.cpp
index 4ee6c6df75..6bd9e5c25a 100644
--- a/tests/auto/corelib/text/qlocale/tst_qlocale.cpp
+++ b/tests/auto/corelib/text/qlocale/tst_qlocale.cpp
@@ -2108,8 +2108,7 @@ void tst_QLocale::windowsDefaultLocale()
QCOMPARE(locale.toString(QDate(1974, 12, 1), QLocale::NarrowFormat),
locale.toString(QDate(1974, 12, 1), QLocale::ShortFormat));
QCOMPARE(locale.toString(QDate(1974, 12, 1), QLocale::LongFormat), QString("1@12@1974"));
- const QString expectedFormattedShortTimeSeconds = QStringLiteral("1^2^3");
- const QString expectedFormattedShortTime = QStringLiteral("1^2");
+ const QString expectedFormattedShortTime = QStringLiteral("1^2^3");
QCOMPARE(locale.toString(QTime(1,2,3), QLocale::ShortFormat), expectedFormattedShortTime);
QCOMPARE(locale.toString(QTime(1,2,3), QLocale::NarrowFormat),
locale.toString(QTime(1,2,3), QLocale::ShortFormat));
diff --git a/tests/auto/corelib/text/qstring/tst_qstring.cpp b/tests/auto/corelib/text/qstring/tst_qstring.cpp
index 878988d425..90f7f63192 100644
--- a/tests/auto/corelib/text/qstring/tst_qstring.cpp
+++ b/tests/auto/corelib/text/qstring/tst_qstring.cpp
@@ -4876,6 +4876,9 @@ void tst_QString::arg()
QCOMPARE( s4.arg("foo", 10), QLatin1String("[ foo]") );
QCOMPARE( s4.arg("foo", -10), QLatin1String("[foo ]") );
+ // QStringRef argument in multi-arg:
+ QCOMPARE(QString("%1;%2").arg(QStringRef(), QString()), ";");
+
QString firstName( "James" );
QString lastName( "Bond" );
QString fullName = QString( "My name is %2, %1 %2" )
diff --git a/tests/auto/corelib/time/qtimezone/tst_qtimezone.cpp b/tests/auto/corelib/time/qtimezone/tst_qtimezone.cpp
index 412f092377..59b94179f4 100644
--- a/tests/auto/corelib/time/qtimezone/tst_qtimezone.cpp
+++ b/tests/auto/corelib/time/qtimezone/tst_qtimezone.cpp
@@ -65,6 +65,7 @@ private slots:
void isValidId_data();
void isValidId();
void malformed();
+ void serialize();
// Backend tests
void utcTest();
void icuTest();
@@ -951,6 +952,33 @@ void tst_QTimeZone::malformed()
barf.offsetFromUtc(now);
}
+void tst_QTimeZone::serialize()
+{
+ int parts = 0;
+#ifndef QT_NO_DEBUG_STREAM
+ qDebug() << QTimeZone(); // to verify no crash
+ parts++;
+#endif
+#ifndef QT_NO_DATASTREAM
+ QByteArray blob;
+ {
+ QDataStream stream(&blob, QIODevice::WriteOnly);
+ stream << QTimeZone("Europe/Oslo") << QTimeZone(420) << QTimeZone() << qint64(-1);
+ }
+ QDataStream stream(&blob, QIODevice::ReadOnly);
+ QTimeZone invalid, offset, oslo;
+ qint64 minusone;
+ stream >> oslo >> offset >> invalid >> minusone;
+ QCOMPARE(oslo, QTimeZone("Europe/Oslo"));
+ QCOMPARE(offset, QTimeZone(420));
+ QVERIFY(!invalid.isValid());
+ QCOMPARE(minusone, qint64(-1));
+ parts++;
+#endif
+ if (!parts)
+ QSKIP("No serialization enabled");
+}
+
void tst_QTimeZone::utcTest()
{
#ifdef QT_BUILD_INTERNAL
diff --git a/tests/auto/corelib/tools/qvarlengtharray/tst_qvarlengtharray.cpp b/tests/auto/corelib/tools/qvarlengtharray/tst_qvarlengtharray.cpp
index 0174885cf3..d2f032ddcd 100644
--- a/tests/auto/corelib/tools/qvarlengtharray/tst_qvarlengtharray.cpp
+++ b/tests/auto/corelib/tools/qvarlengtharray/tst_qvarlengtharray.cpp
@@ -412,6 +412,12 @@ struct MyBase
bool hasMoved() const { return !wasConstructedAt(this); }
protected:
+ void swap(MyBase &other) {
+ using std::swap;
+ swap(data, other.data);
+ swap(isCopy, other.isCopy);
+ }
+
MyBase(const MyBase *data, bool isCopy)
: data(data), isCopy(isCopy) {}
@@ -486,6 +492,14 @@ struct MyMovable
return *this;
}
+ void swap(MyMovable &other) noexcept
+ {
+ MyBase::swap(other);
+ std::swap(i, other.i);
+ }
+
+ friend void swap(MyMovable &lhs, MyMovable &rhs) noexcept { lhs.swap(rhs); }
+
bool operator==(const MyMovable &other) const
{
return i == other.i;
@@ -501,6 +515,15 @@ struct MyComplex
{
return i == other.i;
}
+
+ void swap(MyComplex &other) noexcept
+ {
+ MyBase::swap(other);
+ std::swap(i, other.i);
+ }
+
+ friend void swap(MyComplex &lhs, MyComplex &rhs) noexcept { lhs.swap(rhs); }
+
char i;
};
@@ -1066,6 +1089,17 @@ void tst_QVarLengthArray::insertMove()
QCOMPARE(MyBase::copyCount, 0);
{
+ MyMovable m1, m2;
+ QCOMPARE(MyBase::liveCount, 2);
+ QCOMPARE(MyBase::copyCount, 0);
+ using std::swap;
+ swap(m1, m2);
+ QCOMPARE(MyBase::liveCount, 2);
+ QCOMPARE(MyBase::movedCount, 0);
+ QCOMPARE(MyBase::copyCount, 0);
+ }
+
+ {
QVarLengthArray<MyMovable, 6> vec;
MyMovable m1;
MyMovable m2;
diff --git a/tests/auto/gui/math3d/qquaternion/tst_qquaternion.cpp b/tests/auto/gui/math3d/qquaternion/tst_qquaternion.cpp
index 7dbd587451..ed7a6a4d5d 100644
--- a/tests/auto/gui/math3d/qquaternion/tst_qquaternion.cpp
+++ b/tests/auto/gui/math3d/qquaternion/tst_qquaternion.cpp
@@ -1113,6 +1113,35 @@ void tst_QQuaternion::fromEulerAngles_data()
QTest::newRow("complex")
<< 30.0f << 240.0f << -45.0f << QQuaternion(-0.531976f, -0.43968f, 0.723317f, -0.02226f);
+
+ // Three gimbal_lock cases are not unique for the conversions from quaternion
+ // to euler, Qt will use only XY rotations for these cases.
+ // For example, QQuaternion(0.5f, 0.5f, -0.5f, 0.5f) can be EulerXYZ(90.0f, 0.0f, 90.0f), too.
+ // But Qt will always convert it to EulerXYZ(90.0f, -90.0f, 0.0f) without Z-rotation.
+ QTest::newRow("gimbal_lock_1")
+ << 90.0f << -90.0f << 0.0f << QQuaternion(0.5f, 0.5f, -0.5f, 0.5f);
+
+ QTest::newRow("gimbal_lock_2")
+ << 90.0f << 40.0f << 0.0f << QQuaternion(0.664463f, 0.664463f, 0.241845f, -0.241845f);
+
+ QTest::newRow("gimbal_lock_3") << 90.0f << 170.0f << 0.0f
+ << QQuaternion(0.0616285f, 0.0616285f, 0.704416f, -0.704416f);
+
+ // These four examples have a fraction of errors that would bypass normalize() threshold
+ // and could make Gimbal lock detection fail.
+ QTest::newRow("gimbal_lock_fraction_1")
+ << -90.0f << 90.001152f << 0.0f << QQuaternion(0.499989986f, -0.5f, 0.5f, 0.5f);
+
+ QTest::newRow("gimbal_lock_fraction_2")
+ << -90.0f << -179.999985f << 0.0f
+ << QQuaternion(1.00000001e-07f, 1.00000001e-10f, -0.707106769f, -0.707105756f);
+
+ QTest::newRow("gimbal_lock_fraction_3")
+ << -90.0f << 90.0011597f << 0.0f << QQuaternion(0.499989986f, -0.49999994f, 0.5f, 0.5f);
+
+ QTest::newRow("gimbal_lock_fraction_4")
+ << -90.0f << -180.0f << 0.0f
+ << QQuaternion(9.99999996e-12f, 9.99999996e-12f, -0.707106769f, -0.707096756f);
}
void tst_QQuaternion::fromEulerAngles()
{
diff --git a/tests/auto/other/android/testdata/top_level_dir/file_in_top_dir.txt b/tests/auto/other/android/testdata/top_level_dir/file_in_top_dir.txt
new file mode 100644
index 0000000000..87b10bd8e6
--- /dev/null
+++ b/tests/auto/other/android/testdata/top_level_dir/file_in_top_dir.txt
@@ -0,0 +1 @@
+FooBar
diff --git a/tests/auto/other/android/testdata/top_level_dir/sub_dir/file_in_sub_dir.txt b/tests/auto/other/android/testdata/top_level_dir/sub_dir/file_in_sub_dir.txt
new file mode 100644
index 0000000000..87b10bd8e6
--- /dev/null
+++ b/tests/auto/other/android/testdata/top_level_dir/sub_dir/file_in_sub_dir.txt
@@ -0,0 +1 @@
+FooBar
diff --git a/tests/auto/other/android/testdata/top_level_dir/sub_dir/sub_dir2/sub_dir3/file_in_sub_dir_3.txt b/tests/auto/other/android/testdata/top_level_dir/sub_dir/sub_dir2/sub_dir3/file_in_sub_dir_3.txt
new file mode 100644
index 0000000000..87b10bd8e6
--- /dev/null
+++ b/tests/auto/other/android/testdata/top_level_dir/sub_dir/sub_dir2/sub_dir3/file_in_sub_dir_3.txt
@@ -0,0 +1 @@
+FooBar
diff --git a/tests/auto/other/android/tst_android.cpp b/tests/auto/other/android/tst_android.cpp
index 57d592d45f..389d465427 100644
--- a/tests/auto/other/android/tst_android.cpp
+++ b/tests/auto/other/android/tst_android.cpp
@@ -27,6 +27,7 @@
****************************************************************************/
#include <QtTest/QtTest>
+#include <QtCore/qdiriterator.h>
class tst_Android : public QObject
{
@@ -34,6 +35,7 @@ Q_OBJECT
private slots:
void assetsRead();
void assetsNotWritable();
+ void assetsIterating();
};
void tst_Android::assetsRead()
@@ -59,6 +61,25 @@ void tst_Android::assetsNotWritable()
QVERIFY(!file.open(QIODevice::Append));
}
+void tst_Android::assetsIterating()
+{
+ QStringList assets = {"assets:/top_level_dir/file_in_top_dir.txt",
+ "assets:/top_level_dir/sub_dir",
+ "assets:/top_level_dir/sub_dir/file_in_sub_dir.txt",
+ "assets:/top_level_dir/sub_dir/sub_dir_2",
+ "assets:/top_level_dir/sub_dir/sub_dir_2/sub_dir_3",
+ "assets:/top_level_dir/sub_dir/sub_dir_2/sub_dir_3/file_in_sub_dir_3.txt"};
+ // Note that we have an "assets:/top_level_dir/sub_dir/empty_sub_dir" in the test's
+ // assets physical directory, but empty folders are not packaged in the built apk,
+ // so it's expected to not have such folder be listed in the assets on runtime
+ QDirIterator it("assets:/top_level_dir", QDirIterator::Subdirectories);
+ QStringList iteratorAssets;
+ while (it.hasNext())
+ iteratorAssets.append(it.next());
+ QVERIFY(assets == iteratorAssets);
+}
+
+
QTEST_MAIN(tst_Android)
#include "tst_android.moc"
diff --git a/tests/auto/other/gestures/BLACKLIST b/tests/auto/other/gestures/BLACKLIST
index 0e35fb374b..04574f90d3 100644
--- a/tests/auto/other/gestures/BLACKLIST
+++ b/tests/auto/other/gestures/BLACKLIST
@@ -9,29 +9,42 @@ opensuse-leap
# QTBUG-67254
opensuse-42.3
[graphicsItemGesture]
+# QTBUG-103054
+ubuntu-20
ubuntu-18.04
rhel-7.4
rhel-7.6
sles-15
rhel-8.4
[graphicsItemTreeGesture]
+# QTBUG-103054
+ubuntu-20
ubuntu-18.04
[graphicsView]
+# QTBUG-103054
+ubuntu-20
ubuntu-18.04
rhel-7.4
rhel-7.6
sles-15
rhel-8.4
[explicitGraphicsObjectTarget]
+# QTBUG-103054
+ubuntu-20
ubuntu-18.04
rhel-7.4
rhel-7.6
sles-15
rhel-8.4
[autoCancelGestures2]
+# QTBUG-103054
+ubuntu-20
ubuntu-18.04
rhel-7.4
rhel-7.6
sles-15
rhel-8.4
+#QTBUG-103054
+[testReuseCanceledGestures]
+ubuntu-20