aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/qml
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/qml')
-rw-r--r--tests/auto/qml/ecmascripttests/test262runner.cpp18
-rw-r--r--tests/auto/qml/linebylinelex/BLACKLIST5
-rw-r--r--tests/auto/qml/linebylinelex/CMakeLists.txt22
-rw-r--r--tests/auto/qml/linebylinelex/tst_linebylinelex.cpp15
-rw-r--r--tests/auto/qml/qjsengine/tst_qjsengine.cpp2
-rw-r--r--tests/auto/qml/qmllint/data/Qtbug111015/qmldir3
-rw-r--r--tests/auto/qml/qmllint/data/Qtbug111015/qtbug111015.qmltypes12
-rw-r--r--tests/auto/qml/qmllint/data/jsonObjectIsRecognized.qml8
-rw-r--r--tests/auto/qml/qmllint/data/something.qml2
-rw-r--r--tests/auto/qml/qmllint/tst_qmllint.cpp12
-rw-r--r--tests/auto/qml/qqmlparser/tst_qqmlparser.cpp72
-rw-r--r--tests/auto/qml/qqmlvaluetypes/data/matrix4x4_invokables.qml4
-rw-r--r--tests/auto/qml/qqmlxmllistmodel/tst_qqmlxmllistmodel.cpp12
-rw-r--r--tests/auto/qml/qv4estable/tst_qv4estable.cpp6
14 files changed, 144 insertions, 49 deletions
diff --git a/tests/auto/qml/ecmascripttests/test262runner.cpp b/tests/auto/qml/ecmascripttests/test262runner.cpp
index 90ac10a38b..d87a8a9552 100644
--- a/tests/auto/qml/ecmascripttests/test262runner.cpp
+++ b/tests/auto/qml/ecmascripttests/test262runner.cpp
@@ -222,10 +222,20 @@ void Test262Runner::createProcesses()
}
});
- QObject::connect(&p, &QProcess::finished, this, [&, i](int, QProcess::ExitStatus status) {
- if (status != QProcess::NormalExit) {
- qDebug() << QStringLiteral("Process %1 of %2 exited with a non-normal status")
- .arg(i).arg(processCount - 1);
+ QObject::connect(&p, &QProcess::finished, this,
+ [this, processCount, i](int exitCode, QProcess::ExitStatus status) {
+ if (status != QProcess::NormalExit || exitCode != 0) {
+ TestData &testData(currentTasks[i]);
+
+ auto &result = testData.stillNeedStrictRun
+ ? testData.sloppyResult
+ : testData.strictResult;
+ result = TestCase::Result(
+ TestCase::Crashes,
+ QStringLiteral("Process %1 of %2 exited with a non-normal status")
+ .arg(i).arg(processCount - 1));
+
+ addResult(testData);
}
--runningCount;
diff --git a/tests/auto/qml/linebylinelex/BLACKLIST b/tests/auto/qml/linebylinelex/BLACKLIST
deleted file mode 100644
index 0fd7f604e3..0000000000
--- a/tests/auto/qml/linebylinelex/BLACKLIST
+++ /dev/null
@@ -1,5 +0,0 @@
-# QTBUG-105697
-[testFormatter]
-android
-[testLineByLineLex]
-android
diff --git a/tests/auto/qml/linebylinelex/CMakeLists.txt b/tests/auto/qml/linebylinelex/CMakeLists.txt
index 8b05ca0527..92d956a972 100644
--- a/tests/auto/qml/linebylinelex/CMakeLists.txt
+++ b/tests/auto/qml/linebylinelex/CMakeLists.txt
@@ -10,12 +10,12 @@ endif()
# Collect linebyline test data
file(GLOB_RECURSE test_data_glob
- RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}/..
- linebylinelex/data/*)
+ RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}
+ data/*)
# Collect qmlformat test data
file(GLOB_RECURSE test_data_glob2
- RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}/..
- qmlformat/data/*)
+ RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}
+ ../qmlformat/data/*)
list(APPEND test_data ${test_data_glob} ${test_data_glob2})
qt_internal_add_test(tst_linebylinelex
@@ -25,17 +25,5 @@ qt_internal_add_test(tst_linebylinelex
Qt::Qml
Qt::QuickTestUtilsPrivate
TESTDATA ${test_data}
-)
-
-## Scopes:
-#####################################################################
-
-qt_internal_extend_target(tst_linebylinelex CONDITION ANDROID OR IOS
- DEFINES
- QT_QMLTEST_DATADIR=":/"
-)
-
-qt_internal_extend_target(tst_linebylinelex CONDITION NOT ANDROID AND NOT IOS
- DEFINES
- QT_QMLTEST_DATADIR="${CMAKE_CURRENT_SOURCE_DIR}/.."
+ BUILTIN_TESTDATA
)
diff --git a/tests/auto/qml/linebylinelex/tst_linebylinelex.cpp b/tests/auto/qml/linebylinelex/tst_linebylinelex.cpp
index d94f325020..040ccfa9a6 100644
--- a/tests/auto/qml/linebylinelex/tst_linebylinelex.cpp
+++ b/tests/auto/qml/linebylinelex/tst_linebylinelex.cpp
@@ -13,7 +13,7 @@ QT_USE_NAMESPACE
using namespace Qt::StringLiterals;
using namespace QQmlJS;
-class TestLineByLineLex : public QQmlDataTest
+class TestLineByLineLex : public QObject
{
Q_OBJECT
@@ -21,7 +21,7 @@ public:
TestLineByLineLex();
private Q_SLOTS:
- void initTestCase() override;
+ void initTestCase();
void testLineByLineLex_data();
void testLineByLineLex();
@@ -34,17 +34,14 @@ private:
QString m_qmljsrootgenPath;
QString m_qmltyperegistrarPath;
- QString m_baseDir;
};
TestLineByLineLex::TestLineByLineLex()
- : QQmlDataTest(QT_QMLTEST_DATADIR), m_baseDir(QString::fromLocal8Bit(QT_QMLTEST_DATADIR))
{
}
void TestLineByLineLex::initTestCase()
{
- QQmlDataTest::initTestCase();
}
void TestLineByLineLex::testLineByLineLex_data()
@@ -59,22 +56,18 @@ void TestLineByLineLex::testLineByLineLex()
{
QFETCH(QString, filename);
- QString filePath = m_baseDir + u"/linebylinelex/data/"_s + filename;
+ QString filePath = QFINDTESTDATA("data/" + filename);
runLex(filePath);
}
void TestLineByLineLex::testFormatter_data()
{
QTest::addColumn<QString>("filename");
- QDir formatData(m_baseDir + u"/qmlformat/data"_s);
- bool hasTestData = false; // ### TODO: fix test to always have data
+ QDir formatData(QFINDTESTDATA("qmlformat/data"));
for (const QFileInfo &fInfo :
formatData.entryInfoList(QStringList({ u"*.qml"_s, u"*.js"_s }), QDir::Files)) {
QTest::newRow(qPrintable(fInfo.fileName())) << fInfo.absoluteFilePath();
- hasTestData = true;
}
- if (!hasTestData)
- QSKIP("No test data found!");
}
void TestLineByLineLex::testFormatter()
diff --git a/tests/auto/qml/qjsengine/tst_qjsengine.cpp b/tests/auto/qml/qjsengine/tst_qjsengine.cpp
index daa16eba72..7bf3b34f86 100644
--- a/tests/auto/qml/qjsengine/tst_qjsengine.cpp
+++ b/tests/auto/qml/qjsengine/tst_qjsengine.cpp
@@ -5948,7 +5948,7 @@ void tst_QJSEngine::functionCtorGeneratedCUIsNotCollectedByGc()
const QString program = "new Function('a', 'b', 'let x = \"Hello\"; return a + b');";
auto sumFunc = engine.evaluate(program);
QVERIFY(sumFunc.isCallable());
- auto *function = QJSValuePrivate::asManagedType<QV4::FunctionObject>(&sumFunc);
+ auto *function = QJSValuePrivate::asManagedType<QV4::JavaScriptFunctionObject>(&sumFunc);
auto *cu = function->d()->function->executableCompilationUnit();
QVERIFY(cu->runtimeStrings); // should exist for "Hello"
QVERIFY(cu->runtimeStrings[0]->isMarked());
diff --git a/tests/auto/qml/qmllint/data/Qtbug111015/qmldir b/tests/auto/qml/qmllint/data/Qtbug111015/qmldir
new file mode 100644
index 0000000000..3bf1d48e13
--- /dev/null
+++ b/tests/auto/qml/qmllint/data/Qtbug111015/qmldir
@@ -0,0 +1,3 @@
+module Qtbug111015
+typeinfo qtbug111015.qmltypes
+import QtQml
diff --git a/tests/auto/qml/qmllint/data/Qtbug111015/qtbug111015.qmltypes b/tests/auto/qml/qmllint/data/Qtbug111015/qtbug111015.qmltypes
new file mode 100644
index 0000000000..cad6d88cc3
--- /dev/null
+++ b/tests/auto/qml/qmllint/data/Qtbug111015/qtbug111015.qmltypes
@@ -0,0 +1,12 @@
+import QtQuick.tooling 1.2
+
+Module {
+ Component {
+ file: "typewithjsonobjectlist.h"
+ name: "TypeWithJsonObjectList"
+ exports: ["QmlLintTestLib/TypeWithJsonObjectList 1.0"]
+ accessSemantics: "reference"
+ prototype: "QObject"
+ Property { name: "jsonObjectList"; type: "QJsonObject"; isList: true; read: "getJsonObjectList"; index: 0; isReadonly: true }
+ }
+}
diff --git a/tests/auto/qml/qmllint/data/jsonObjectIsRecognized.qml b/tests/auto/qml/qmllint/data/jsonObjectIsRecognized.qml
new file mode 100644
index 0000000000..0a96fa9f92
--- /dev/null
+++ b/tests/auto/qml/qmllint/data/jsonObjectIsRecognized.qml
@@ -0,0 +1,8 @@
+import QtQuick
+import Qtbug111015 1.0
+
+Item {
+ TypeWithJsonObjectList {
+ jsonObjectList: []
+ }
+}
diff --git a/tests/auto/qml/qmllint/data/something.qml b/tests/auto/qml/qmllint/data/something.qml
new file mode 100644
index 0000000000..38998f606d
--- /dev/null
+++ b/tests/auto/qml/qmllint/data/something.qml
@@ -0,0 +1,2 @@
+import ModuleInImportPath
+A {}
diff --git a/tests/auto/qml/qmllint/tst_qmllint.cpp b/tests/auto/qml/qmllint/tst_qmllint.cpp
index 57cb7228d8..bcccd5f1f0 100644
--- a/tests/auto/qml/qmllint/tst_qmllint.cpp
+++ b/tests/auto/qml/qmllint/tst_qmllint.cpp
@@ -105,6 +105,7 @@ private Q_SLOTS:
void valueTypesFromString();
void ignoreSettingsNotCommandLineOptions();
+ void backslashedQmldirPath();
void environment_data();
void environment();
@@ -113,6 +114,7 @@ private Q_SLOTS:
void testPlugin();
void quickPlugin();
#endif
+
private:
enum DefaultImportOption { NoDefaultImports, UseDefaultImports };
enum ContainOption { StringNotContained, StringContained };
@@ -1345,6 +1347,7 @@ void TestQmllint::cleanQmlCode_data()
QTest::newRow("locale") << QStringLiteral("locale.qml");
QTest::newRow("constInvokable") << QStringLiteral("useConstInvokable.qml");
QTest::newRow("dontCheckJSTypes") << QStringLiteral("dontCheckJSTypes.qml");
+ QTest::newRow("jsonObjectIsRecognized") << QStringLiteral("jsonObjectIsRecognized.qml");
}
void TestQmllint::cleanQmlCode()
@@ -2252,5 +2255,14 @@ void TestQmllint::ignoreSettingsNotCommandLineOptions()
QCOMPARE(output, QString());
}
+void TestQmllint::backslashedQmldirPath()
+{
+ const QString qmldirPath
+ = testFile(u"ImportPath/ModuleInImportPath/qmldir"_s).replace('/', QDir::separator());
+ const QString output = runQmllint(
+ testFile(u"something.qml"_s), true, QStringList{ u"-i"_s, qmldirPath });
+ QVERIFY(output.isEmpty());
+}
+
QTEST_GUILESS_MAIN(TestQmllint)
#include "tst_qmllint.moc"
diff --git a/tests/auto/qml/qqmlparser/tst_qqmlparser.cpp b/tests/auto/qml/qqmlparser/tst_qqmlparser.cpp
index eb8c6c260f..0a8411ddcf 100644
--- a/tests/auto/qml/qqmlparser/tst_qqmlparser.cpp
+++ b/tests/auto/qml/qqmlparser/tst_qqmlparser.cpp
@@ -34,6 +34,10 @@ private slots:
void codeLocationsWithContinuationStringLiteral_data();
void noSubstitutionTemplateLiteral();
void templateLiteral();
+ void numericSeparator_data();
+ void numericSeparator();
+ void invalidNumericSeparator_data();
+ void invalidNumericSeparator();
void leadingSemicolonInClass();
void templatedReadonlyProperty();
void qmlImportInJS();
@@ -496,6 +500,74 @@ void tst_qqmlparser::templateLiteral()
QVERIFY(e);
}
+void tst_qqmlparser::numericSeparator_data() {
+ QTest::addColumn<QString>("code");
+ QTest::addColumn<double>("expected_value");
+
+ QTest::newRow("Separator in decimal literal") << "1_000_000_000" << 1000000000.0;
+ QTest::newRow("Separator in fractional part") << "1000.22_33" << 1000.2233;
+ QTest::newRow("Separator in exponent part") << "1e1_0_0" << std::pow(10, 100);
+ QTest::newRow("Separator in positive exponent part") << "1e+1_0_0" << 1e100;
+ QTest::newRow("Separator in negative exponent part") << "1e-1_0_0" << 1e-100;
+ QTest::newRow("Separator in binary literal with b prefix") << "0b1010_0001_1000_0101" << static_cast<double>(0b1010000110000101);
+ QTest::newRow("Separator in binary literal with B prefix") << "0B01_10_01_10" << static_cast<double>(0b01100110);
+ QTest::newRow("Separator in octal literal with o prefix") << "0o1234_5670" << static_cast<double>(012345670);
+ QTest::newRow("Separator in octal literal with O prefix") << "0O7777_0000" << static_cast<double>(077770000);
+ QTest::newRow("Separator in hex literal with x prefix") << "0xA0_B0_C0" << static_cast<double>(0xA0B0C0);
+ QTest::newRow("Separator in hex literal with X prefix") << "0X1000_AAAA" << static_cast<double>(0x1000AAAA);
+}
+
+void tst_qqmlparser::numericSeparator() {
+ using namespace QQmlJS;
+
+ QFETCH(QString, code);
+ QFETCH(double, expected_value);
+
+ QQmlJS::Engine engine;
+
+ QQmlJS::Lexer lexer(&engine);
+ lexer.setCode(code, 1);
+
+ QQmlJS::Parser parser(&engine);
+ QVERIFY(parser.parseExpression());
+
+ AST::ExpressionNode *expression = parser.expression();
+ QVERIFY(expression);
+
+ auto *literal = QQmlJS::AST::cast<QQmlJS::AST::NumericLiteral *>(expression);
+ QVERIFY(literal);
+
+ QCOMPARE(literal->value, expected_value);
+ QCOMPARE(literal->firstSourceLocation().begin(), 0u);
+ QCOMPARE(literal->lastSourceLocation().end(), quint32(code.size()));
+}
+
+void tst_qqmlparser::invalidNumericSeparator_data() {
+ QTest::addColumn<QString>("code");
+ QTest::addColumn<QString>("error");
+
+ QTest::newRow("Trailing numeric separator") << "1_" << "A trailing numeric separator is not allowed in numeric literals";
+ QTest::newRow("Multiple numeric separators") << "1__2" << "There can be at most one numeric separator beetwen digits";
+}
+
+void tst_qqmlparser::invalidNumericSeparator() {
+ using namespace QQmlJS;
+
+ QFETCH(QString, code);
+ QFETCH(QString, error);
+
+ QQmlJS::Engine engine;
+
+ QQmlJS::Lexer lexer(&engine);
+ lexer.setCode(code, 1);
+
+ QQmlJS::Parser parser(&engine);
+ QVERIFY(!parser.parseExpression());
+
+ QVERIFY(lexer.errorCode() != Lexer::NoError);
+ QCOMPARE(lexer.errorMessage(), error);
+}
+
void tst_qqmlparser::leadingSemicolonInClass()
{
QQmlJS::Engine engine;
diff --git a/tests/auto/qml/qqmlvaluetypes/data/matrix4x4_invokables.qml b/tests/auto/qml/qqmlvaluetypes/data/matrix4x4_invokables.qml
index c28901956d..1827b57ca9 100644
--- a/tests/auto/qml/qqmlvaluetypes/data/matrix4x4_invokables.qml
+++ b/tests/auto/qml/qqmlvaluetypes/data/matrix4x4_invokables.qml
@@ -1,4 +1,4 @@
-import QtQuick 2.0
+import QtQuick
Item {
property bool success: false
@@ -6,6 +6,7 @@ Item {
property variant m1: Qt.matrix4x4(1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4)
property variant m2: Qt.matrix4x4(5,5,5,5,6,6,6,6,7,7,7,7,8,8,8,8)
property variant m3: Qt.matrix4x4(123,22,6,42,55,54,67,77,777,1,112,22,55,6696,77,777)
+ property matrix4x4 m4: PlanarTransform.fromAffineMatrix(1, 2, 3, 4, 5, 6)
property variant v1: Qt.vector4d(1,2,3,4)
property variant v2: Qt.vector3d(1,2,3)
property real factor: 2.23
@@ -101,6 +102,7 @@ Item {
if (m1.transposed() != Qt.matrix4x4(1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4)) success = false;
if (m1.fuzzyEquals(m2)) success = false;
if (!m1.fuzzyEquals(m2, 10)) success = false;
+ if (m4 != Qt.matrix4x4(1, 3, 0, 5, 2, 4, 0, 6, 0, 0, 1, 0, 0, 0, 0, 1)) success = false;
if (!testTransformation()) success = false;
if (!testMatrixMapping()) success = false;
}
diff --git a/tests/auto/qml/qqmlxmllistmodel/tst_qqmlxmllistmodel.cpp b/tests/auto/qml/qqmlxmllistmodel/tst_qqmlxmllistmodel.cpp
index eebe4a6c05..bb6e59cb17 100644
--- a/tests/auto/qml/qqmlxmllistmodel/tst_qqmlxmllistmodel.cpp
+++ b/tests/auto/qml/qqmlxmllistmodel/tst_qqmlxmllistmodel.cpp
@@ -321,14 +321,12 @@ void tst_QQmlXmlListModel::headers()
QTRY_COMPARE_WITH_TIMEOUT(qvariant_cast<QQmlXmlListModel::Status>(model->property("status")),
QQmlXmlListModel::Error, 10000);
- QVariantMap expectedHeaders;
- expectedHeaders["Accept"] = "application/xml,*/*";
+ QLatin1String expectedAcceptHeader = "application/xml,*/*"_L1;
- QCOMPARE(factory.lastSentHeaders.size(), expectedHeaders.size());
- for (auto it = expectedHeaders.cbegin(), end = expectedHeaders.cend(); it != end; ++it) {
- QVERIFY(factory.lastSentHeaders.contains(it.key()));
- QCOMPARE(factory.lastSentHeaders[it.key()].toString(), it.value().toString());
- }
+ QCOMPARE(factory.lastSentHeaders.size(), 1);
+ QVariant acceptHeader = factory.lastSentHeaders["accept"];
+ QVERIFY(acceptHeader.isValid());
+ QCOMPARE(acceptHeader.toString(), expectedAcceptHeader);
}
void tst_QQmlXmlListModel::source()
diff --git a/tests/auto/qml/qv4estable/tst_qv4estable.cpp b/tests/auto/qml/qv4estable/tst_qv4estable.cpp
index 45df62b23e..7d137ae7d2 100644
--- a/tests/auto/qml/qv4estable/tst_qv4estable.cpp
+++ b/tests/auto/qml/qv4estable/tst_qv4estable.cpp
@@ -18,7 +18,7 @@ void tst_qv4estable::checkRemoveAvoidsHeapBufferOverflow()
QV4::ESTable estable;
// Fill the ESTable with values so it is at max capacity.
- QCOMPARE_EQ(estable.m_capacity, 8);
+ QCOMPARE_EQ(estable.m_capacity, 8U);
for (uint i = 0; i < estable.m_capacity; ++i) {
estable.set(QV4::Value::fromUInt32(i), QV4::Value::fromUInt32(i));
}
@@ -27,8 +27,8 @@ void tst_qv4estable::checkRemoveAvoidsHeapBufferOverflow()
for (uint i = 0; i < estable.m_capacity; ++i) {
QVERIFY(estable.m_keys[i].sameValueZero(QV4::Value::fromUInt32(i)));
}
- QCOMPARE_EQ(estable.m_capacity, 8);
- QCOMPARE_EQ(estable.m_size, 8);
+ QCOMPARE_EQ(estable.m_capacity, 8U);
+ QCOMPARE_EQ(estable.m_size, 8U);
// Remove the first item from the set to verify that asan does not trip.
// Relies on the CI platform propagating asan flag to all tests.