diff options
author | Kari Oikarinen <kari.oikarinen@qt.io> | 2019-08-27 07:50:48 +0300 |
---|---|---|
committer | Kari Oikarinen <kari.oikarinen@qt.io> | 2019-08-27 07:50:48 +0300 |
commit | 3fbaa2618c0c43a4dd6550666a789327f0d8f2cc (patch) | |
tree | dc48f088144a44e2026f196ad14add4519d4d30a /tests | |
parent | 7919751e999d68d4b4e9dae37493d607e7759105 (diff) | |
parent | 50ccfaa7ad26e0872ac50b92b346bebbd3002838 (diff) |
Merge dev into 5.14
Change-Id: I3ae119563f41fda63ac2b452f2d05fa83e411faa
Diffstat (limited to 'tests')
31 files changed, 481 insertions, 36 deletions
diff --git a/tests/auto/qml/bindingdependencyapi/dummy_imports.qml b/tests/auto/qml/bindingdependencyapi/dummy_imports.qml new file mode 100644 index 0000000000..b9a196e188 --- /dev/null +++ b/tests/auto/qml/bindingdependencyapi/dummy_imports.qml @@ -0,0 +1,8 @@ +// This file exists for the sole purpose for qmlimportscanner to find +// which modules it needs to extract for deployment. +// Otherwise, it fails to find the imports that are expressed in C++ +// code in tst_parserstress.cpp + +import QtQuick 2.0 + +QtObject { } // This is needed in order to keep importscanner happy diff --git a/tests/auto/qml/qjsengine/dummy_imports.qml b/tests/auto/qml/qjsengine/dummy_imports.qml new file mode 100644 index 0000000000..8d86f3583b --- /dev/null +++ b/tests/auto/qml/qjsengine/dummy_imports.qml @@ -0,0 +1,8 @@ +// This file exists for the sole purpose for qmlimportscanner to find +// which modules it needs to extract for deployment. +// Otherwise, it fails to find the imports that are expressed in C++ +// code in tst_parserstress.cpp + +import QtQml 2.0 + +QtObject { } // This is needed in order to keep importscanner happy diff --git a/tests/auto/qml/qjsengine/tst_qjsengine.cpp b/tests/auto/qml/qjsengine/tst_qjsengine.cpp index 0ccb8210bc..1c895eb793 100644 --- a/tests/auto/qml/qjsengine/tst_qjsengine.cpp +++ b/tests/auto/qml/qjsengine/tst_qjsengine.cpp @@ -201,7 +201,9 @@ private slots: void engineForObject(); void intConversion_QTBUG43309(); +#ifdef QT_DEPRECATED void toFixed(); +#endif void argumentEvaluationOrder(); @@ -4323,7 +4325,10 @@ void tst_QJSEngine::engineForObject() QVERIFY(!qjsEngine(&object)); QJSValue wrapper = engine.newQObject(&object); QQmlEngine::setObjectOwnership(&object, QQmlEngine::CppOwnership); + QVERIFY(qjsEngine(&object)); +#ifdef QT_DEPRECATED QCOMPARE(qjsEngine(&object), wrapper.engine()); +#endif } QVERIFY(!qjsEngine(&object)); } @@ -4338,6 +4343,7 @@ void tst_QJSEngine::intConversion_QTBUG43309() QCOMPARE(result.toNumber(), 25.0); } +#ifdef QT_DEPRECATED // QTBUG-44039 and QTBUG-43885: void tst_QJSEngine::toFixed() { @@ -4349,6 +4355,7 @@ void tst_QJSEngine::toFixed() QVERIFY(result.isString()); QCOMPARE(result.toString(), QStringLiteral("12.1")); } +#endif void tst_QJSEngine::argumentEvaluationOrder() { diff --git a/tests/auto/qml/qjsvalue/tst_qjsvalue.cpp b/tests/auto/qml/qjsvalue/tst_qjsvalue.cpp index 4de72ae7a1..37d0ea4dea 100644 --- a/tests/auto/qml/qjsvalue/tst_qjsvalue.cpp +++ b/tests/auto/qml/qjsvalue/tst_qjsvalue.cpp @@ -52,7 +52,9 @@ void tst_QJSValue::ctor_invalid() { QJSValue v; QVERIFY(v.isUndefined()); +#ifdef QT_DEPRECATED QCOMPARE(v.engine(), (QJSEngine *)nullptr); +#endif } } @@ -63,7 +65,9 @@ void tst_QJSValue::ctor_undefinedWithEngine() QJSValue v = eng.toScriptValue(QVariant()); QVERIFY(v.isUndefined()); QCOMPARE(v.isObject(), false); +#ifdef QT_DEPRECATED QCOMPARE(v.engine(), &eng); +#endif } } @@ -75,7 +79,9 @@ void tst_QJSValue::ctor_nullWithEngine() QVERIFY(!v.isUndefined()); QCOMPARE(v.isNull(), true); QCOMPARE(v.isObject(), false); +#ifdef QT_DEPRECATED QCOMPARE(v.engine(), &eng); +#endif } } @@ -88,7 +94,9 @@ void tst_QJSValue::ctor_boolWithEngine() QCOMPARE(v.isBool(), true); QCOMPARE(v.isObject(), false); QCOMPARE(v.toBool(), false); +#ifdef QT_DEPRECATED QCOMPARE(v.engine(), &eng); +#endif } } @@ -101,7 +109,9 @@ void tst_QJSValue::ctor_intWithEngine() QCOMPARE(v.isNumber(), true); QCOMPARE(v.isObject(), false); QCOMPARE(v.toNumber(), 1.0); +#ifdef QT_DEPRECATED QCOMPARE(v.engine(), &eng); +#endif } } @@ -118,7 +128,9 @@ void tst_QJSValue::ctor_int() QCOMPARE(v.isNumber(), true); QCOMPARE(v.isObject(), false); QCOMPARE(v.toNumber(), 1.0); +#ifdef QT_DEPRECATED QCOMPARE(v.engine(), (QJSEngine *)nullptr); +#endif } } @@ -131,7 +143,9 @@ void tst_QJSValue::ctor_uintWithEngine() QCOMPARE(v.isNumber(), true); QCOMPARE(v.isObject(), false); QCOMPARE(v.toNumber(), 1.0); +#ifdef QT_DEPRECATED QCOMPARE(v.engine(), &eng); +#endif } } @@ -148,7 +162,9 @@ void tst_QJSValue::ctor_uint() QCOMPARE(v.isNumber(), true); QCOMPARE(v.isObject(), false); QCOMPARE(v.toNumber(), 1.0); +#ifdef QT_DEPRECATED QCOMPARE(v.engine(), (QJSEngine *)nullptr); +#endif } } @@ -161,7 +177,9 @@ void tst_QJSValue::ctor_floatWithEngine() QCOMPARE(v.isNumber(), true); QCOMPARE(v.isObject(), false); QCOMPARE(v.toNumber(), 1.0); +#ifdef QT_DEPRECATED QCOMPARE(v.engine(), &eng); +#endif } } @@ -178,7 +196,9 @@ void tst_QJSValue::ctor_float() QCOMPARE(v.isNumber(), true); QCOMPARE(v.isObject(), false); QCOMPARE(v.toNumber(), 1.0); +#ifdef QT_DEPRECATED QCOMPARE(v.engine(), (QJSEngine *)nullptr); +#endif } } @@ -191,7 +211,9 @@ void tst_QJSValue::ctor_stringWithEngine() QCOMPARE(v.isString(), true); QCOMPARE(v.isObject(), false); QCOMPARE(v.toString(), QLatin1String("ciao")); +#ifdef QT_DEPRECATED QCOMPARE(v.engine(), &eng); +#endif } } @@ -203,7 +225,9 @@ void tst_QJSValue::ctor_string() QCOMPARE(v.isString(), true); QCOMPARE(v.isObject(), false); QCOMPARE(v.toString(), QLatin1String("ciao")); +#ifdef QT_DEPRECATED QCOMPARE(v.engine(), (QJSEngine *)nullptr); +#endif } { QJSValue v("ciao"); @@ -211,7 +235,9 @@ void tst_QJSValue::ctor_string() QCOMPARE(v.isString(), true); QCOMPARE(v.isObject(), false); QCOMPARE(v.toString(), QLatin1String("ciao")); +#ifdef QT_DEPRECATED QCOMPARE(v.engine(), (QJSEngine *)nullptr); +#endif } } @@ -223,12 +249,16 @@ void tst_QJSValue::ctor_copyAndAssignWithEngine() QJSValue v = eng.toScriptValue(1.0); QJSValue v2(v); QCOMPARE(v2.strictlyEquals(v), true); +#ifdef QT_DEPRECATED QCOMPARE(v2.engine(), &eng); +#endif QJSValue v3(v); QCOMPARE(v3.strictlyEquals(v), true); QCOMPARE(v3.strictlyEquals(v2), true); +#ifdef QT_DEPRECATED QCOMPARE(v3.engine(), &eng); +#endif QJSValue v4 = eng.toScriptValue(2.0); QCOMPARE(v4.strictlyEquals(v), false); @@ -253,7 +283,9 @@ void tst_QJSValue::ctor_undefined() QJSValue v(QJSValue::UndefinedValue); QVERIFY(v.isUndefined()); QCOMPARE(v.isObject(), false); +#ifdef QT_DEPRECATED QCOMPARE(v.engine(), (QJSEngine *)nullptr); +#endif } void tst_QJSValue::ctor_null() @@ -262,7 +294,9 @@ void tst_QJSValue::ctor_null() QVERIFY(!v.isUndefined()); QCOMPARE(v.isNull(), true); QCOMPARE(v.isObject(), false); +#ifdef QT_DEPRECATED QCOMPARE(v.engine(), (QJSEngine *)nullptr); +#endif } void tst_QJSValue::ctor_bool() @@ -273,7 +307,9 @@ void tst_QJSValue::ctor_bool() QCOMPARE(v.isBool(), true); QCOMPARE(v.isObject(), false); QCOMPARE(v.toBool(), false); +#ifdef QT_DEPRECATED QCOMPARE(v.engine(), (QJSEngine *)nullptr); +#endif } void tst_QJSValue::ctor_copyAndAssign() @@ -281,12 +317,16 @@ void tst_QJSValue::ctor_copyAndAssign() QJSValue v(1.0); QJSValue v2(v); QCOMPARE(v2.strictlyEquals(v), true); +#ifdef QT_DEPRECATED QCOMPARE(v2.engine(), (QJSEngine *)nullptr); +#endif QJSValue v3(v); QCOMPARE(v3.strictlyEquals(v), true); QCOMPARE(v3.strictlyEquals(v2), true); +#ifdef QT_DEPRECATED QCOMPARE(v3.engine(), (QJSEngine *)nullptr); +#endif QJSValue v4(2.0); QCOMPARE(v4.strictlyEquals(v), false); @@ -423,7 +463,9 @@ void tst_QJSValue::toString() QCOMPARE(o.toString(), QStringLiteral("[object Object]")); o = createUnboundValue(o); +#ifdef QT_DEPRECATED QVERIFY(!o.engine()); +#endif QCOMPARE(o.toString(), QStringLiteral("[object Object]")); } @@ -435,7 +477,9 @@ void tst_QJSValue::toString() QCOMPARE(o.toString(), QStringLiteral("1,2,3")); o = createUnboundValue(o); +#ifdef QT_DEPRECATED QVERIFY(!o.engine()); +#endif QCOMPARE(o.toString(), QStringLiteral("1,2,3")); } @@ -1641,10 +1685,14 @@ void tst_QJSValue::getSetProperty() QCOMPARE(object.property("baz").toNumber(), num.toNumber()); QJSValue strstr = QJSValue("bar"); +#ifdef QT_DEPRECATED QCOMPARE(strstr.engine(), (QJSEngine *)nullptr); +#endif object.setProperty("foo", strstr); QCOMPARE(object.property("foo").toString(), strstr.toString()); +#ifdef QT_DEPRECATED QCOMPARE(strstr.engine(), &eng); // the value has been bound to the engine +#endif QJSValue numnum = QJSValue(123.0); object.setProperty("baz", numnum); @@ -2536,15 +2584,18 @@ void tst_QJSValue::engineDeleted() delete eng; QVERIFY(v1.isUndefined()); - QVERIFY(!v1.engine()); QVERIFY(v2.isUndefined()); - QVERIFY(!v2.engine()); QVERIFY(v3.isUndefined()); - QVERIFY(!v3.engine()); QVERIFY(v4.isUndefined()); - QVERIFY(!v4.engine()); QVERIFY(v5.isString()); // was not bound to engine + +#ifdef QT_DEPRECATED + QVERIFY(!v1.engine()); + QVERIFY(!v2.engine()); + QVERIFY(!v3.engine()); + QVERIFY(!v4.engine()); QVERIFY(!v5.engine()); +#endif QVERIFY(v3.property("foo").isUndefined()); } diff --git a/tests/auto/qml/qmldiskcache/dummy_imports.qml b/tests/auto/qml/qmldiskcache/dummy_imports.qml new file mode 100644 index 0000000000..b9a196e188 --- /dev/null +++ b/tests/auto/qml/qmldiskcache/dummy_imports.qml @@ -0,0 +1,8 @@ +// This file exists for the sole purpose for qmlimportscanner to find +// which modules it needs to extract for deployment. +// Otherwise, it fails to find the imports that are expressed in C++ +// code in tst_parserstress.cpp + +import QtQuick 2.0 + +QtObject { } // This is needed in order to keep importscanner happy diff --git a/tests/auto/qml/qmllint/qmllint.pro b/tests/auto/qml/qmllint/qmllint.pro index b53a6f6877..95470b4085 100644 --- a/tests/auto/qml/qmllint/qmllint.pro +++ b/tests/auto/qml/qmllint/qmllint.pro @@ -1,6 +1,11 @@ -TEMPLATE = app -TARGET = testqmllint -INCLUDEPATH += . +CONFIG += testcase +TARGET = tst_qmllint +macos:CONFIG -= app_bundle + +SOURCES += tst_qmllint.cpp + +include (../../shared/util.pri) + +TESTDATA = data/* -SOURCES += main.cpp QT += testlib diff --git a/tests/auto/qml/qmllint/main.cpp b/tests/auto/qml/qmllint/tst_qmllint.cpp index 87b34d83bd..582f146dca 100644 --- a/tests/auto/qml/qmllint/main.cpp +++ b/tests/auto/qml/qmllint/tst_qmllint.cpp @@ -30,12 +30,14 @@ #include <QProcess> #include <QString> -class TestQmllint: public QObject +#include <util.h> + +class TestQmllint: public QQmlDataTest { Q_OBJECT private Q_SLOTS: - void initTestCase(); + void initTestCase() override; void test(); void test_data(); void testUnqualified(); @@ -48,6 +50,7 @@ private: void TestQmllint::initTestCase() { + QQmlDataTest::initTestCase(); m_qmllintPath = QLibraryInfo::location(QLibraryInfo::BinariesPath) + QLatin1String("/qmllint"); #ifdef Q_OS_WIN m_qmllintPath += QLatin1String(".exe"); @@ -80,9 +83,8 @@ void TestQmllint::testUnqualified() QFETCH(QString, warningMessage); QFETCH(int, warningLine); QFETCH(int, warningColumn); - filename.prepend(QStringLiteral("data/")); QStringList args; - args << QStringLiteral("-U") << filename << QStringLiteral("-I") << qmlImportDir; + args << QStringLiteral("-U") << testFile(filename) << QStringLiteral("-I") << qmlImportDir; QProcess process; process.start(m_qmllintPath, args); @@ -122,8 +124,7 @@ void TestQmllint::testUnqualifiedNoSpuriousParentWarning() { auto qmlImportDir = QLibraryInfo::location(QLibraryInfo::Qml2ImportsPath); { - QString filename = QLatin1String("spuriousParentWarning.qml"); - filename.prepend(QStringLiteral("data/")); + QString filename = testFile("spuriousParentWarning.qml"); QStringList args; args << QStringLiteral("-U") << filename << QStringLiteral("-I") << qmlImportDir; QProcess process; @@ -133,8 +134,7 @@ void TestQmllint::testUnqualifiedNoSpuriousParentWarning() QVERIFY(process.exitCode() == 0); } { - QString filename = QLatin1String("nonSpuriousParentWarning.qml"); - filename.prepend(QStringLiteral("data/")); + QString filename = testFile("nonSpuriousParentWarning.qml"); QStringList args; args << QStringLiteral("-U") << filename << QStringLiteral("-I") << qmlImportDir; QProcess process; @@ -163,13 +163,12 @@ void TestQmllint::test() { QFETCH(QString, filename); QFETCH(bool, isValid); - filename = QStringLiteral("data/") + filename; QStringList args; - args << QStringLiteral("--silent") << filename; + args << QStringLiteral("--silent") << testFile(filename); bool success = QProcess::execute(m_qmllintPath, args) == 0; QCOMPARE(success, isValid); } QTEST_MAIN(TestQmllint) -#include "main.moc" +#include "tst_qmllint.moc" diff --git a/tests/auto/qml/qqmlapplicationengine/tst_qqmlapplicationengine.cpp b/tests/auto/qml/qqmlapplicationengine/tst_qqmlapplicationengine.cpp index 8787a43884..0f5eea8b95 100644 --- a/tests/auto/qml/qqmlapplicationengine/tst_qqmlapplicationengine.cpp +++ b/tests/auto/qml/qqmlapplicationengine/tst_qqmlapplicationengine.cpp @@ -52,6 +52,7 @@ private slots: void removeObjectsWhenDestroyed(); void loadTranslation_data(); void loadTranslation(); + void setInitialProperties(); private: QString buildDir; @@ -275,6 +276,23 @@ void tst_qqmlapplicationengine::loadTranslation() QCOMPARE(rootObject->property("translation").toString(), translation); } +void tst_qqmlapplicationengine::setInitialProperties() +{ + QQmlApplicationEngine test {}; + { + test.setInitialProperties(QVariantMap{{"success", false}}); + test.load(testFileUrl("basicTest.qml")); + QVERIFY(!test.rootObjects().empty()); + QCOMPARE(test.rootObjects().first()->property("success").toBool(), false); + } + { + test.setInitialProperties({{"success", true}}); + test.load(testFileUrl("basicTest.qml")); + QCOMPARE(test.rootObjects().size(), 2); + QCOMPARE(test.rootObjects().at(1)->property("success").toBool(), true); + } +} + QTEST_MAIN(tst_qqmlapplicationengine) #include "tst_qqmlapplicationengine.moc" diff --git a/tests/auto/qml/qqmlcomponent/data/allJSONTypes.qml b/tests/auto/qml/qqmlcomponent/data/allJSONTypes.qml new file mode 100644 index 0000000000..0541c9b104 --- /dev/null +++ b/tests/auto/qml/qqmlcomponent/data/allJSONTypes.qml @@ -0,0 +1,9 @@ +import QtQuick 2.14 + +Item { + property int i + property bool b + property double d + property string s + property var nothing +} diff --git a/tests/auto/qml/qqmlcomponent/data/variantBasedInitialization.qml b/tests/auto/qml/qqmlcomponent/data/variantBasedInitialization.qml new file mode 100644 index 0000000000..acf08e94d2 --- /dev/null +++ b/tests/auto/qml/qqmlcomponent/data/variantBasedInitialization.qml @@ -0,0 +1,21 @@ +import QtQuick 2.14 + +Item { + property int i + property bool b + property double d + property string s + property var nothing + property url myurl + property color c + property font myfont + property date mydate + property point mypoint + property size mysize + property rect myrect + property matrix4x4 matrix + property quaternion quat + property vector2d vec2 + property vector3d vec3 + property vector4d vec4 +} diff --git a/tests/auto/qml/qqmlcomponent/tst_qqmlcomponent.cpp b/tests/auto/qml/qqmlcomponent/tst_qqmlcomponent.cpp index 71d3e8fe5f..79ec507388 100644 --- a/tests/auto/qml/qqmlcomponent/tst_qqmlcomponent.cpp +++ b/tests/auto/qml/qqmlcomponent/tst_qqmlcomponent.cpp @@ -121,6 +121,7 @@ private slots: void relativeUrl_data(); void relativeUrl(); void setDataNoEngineNoSegfault(); + void testSetInitialProperties(); private: QQmlEngine engine; @@ -667,6 +668,101 @@ void tst_qqmlcomponent::setDataNoEngineNoSegfault() QVERIFY(!c); } +void tst_qqmlcomponent::testSetInitialProperties() +{ + QQmlEngine eng; + { + // JSON based initialization + QQmlComponent comp(&eng); + comp.loadUrl(testFileUrl("allJSONTypes.qml")); + QScopedPointer<QObject> obj { comp.beginCreate(eng.rootContext()) }; + QVERIFY(obj); + comp.setInitialProperties(obj.get(), QVariantMap { + {QLatin1String("i"), 42}, + {QLatin1String("b"), true}, + {QLatin1String("d"), 3.1416}, + {QLatin1String("s"), QLatin1String("hello world")}, + {QLatin1String("nothing"), QVariant::fromValue(nullptr)} + }); + comp.completeCreate(); + if (!comp.errors().empty()) + qDebug() << comp.errorString() << comp.errors(); + QVERIFY(comp.errors().empty()); + QCOMPARE(obj->property("i"), 42); + QCOMPARE(obj->property("b"), true); + QCOMPARE(obj->property("d"), 3.1416); + QCOMPARE(obj->property("s"), QLatin1String("hello world")); + QCOMPARE(obj->property("nothing"), QVariant::fromValue(nullptr)); + } + { + // QVariant + QQmlComponent comp(&eng); + comp.loadUrl(testFileUrl("variantBasedInitialization.qml")); + QScopedPointer<QObject> obj { comp.beginCreate(eng.rootContext()) }; + QVERIFY(obj); + QUrl myurl = comp.url(); + QFont myfont; + QDateTime mydate = QDateTime::currentDateTime(); + QPoint mypoint {1,2}; + QSizeF mysize {0.5, 0.3}; + QMatrix4x4 matrix {}; + QQuaternion quat {5.0f, 0.3f, 0.2f, 0.1f}; + QVector2D vec2 {2.0f, 3.1f}; + QVector3D vec3 {1.0f, 2.0, 3.0f}; + QVector4D vec4 {1.0f, 2.0f, 3.0f, 4.0f}; +#define ASJSON(NAME) {QLatin1String(#NAME), NAME} + comp.setInitialProperties(obj.get(), QVariantMap { + {QLatin1String("i"), 42}, + {QLatin1String("b"), true}, + {QLatin1String("d"), 3.1416}, + {QLatin1String("s"), QLatin1String("hello world")}, + {QLatin1String("nothing"), QVariant::fromValue( nullptr)}, + ASJSON(myurl), + ASJSON(myfont), + ASJSON(mydate), + ASJSON(mypoint), + ASJSON(mysize), + ASJSON(matrix), + ASJSON(quat), + ASJSON(vec2), ASJSON(vec3), ASJSON(vec4) + }); +#undef ASJSON + comp.completeCreate(); + if (!comp.errors().empty()) + qDebug() << comp.errorString() << comp.errors(); + QVERIFY(comp.errors().empty()); + QCOMPARE(obj->property("i"), 42); + QCOMPARE(obj->property("b"), true); + QCOMPARE(obj->property("d"), 3.1416); + QCOMPARE(obj->property("s"), QLatin1String("hello world")); + QCOMPARE(obj->property("nothing"), QVariant::fromValue(nullptr)); +#define COMPARE(NAME) QCOMPARE(obj->property(#NAME), NAME) + COMPARE(myurl); + COMPARE(myfont); + COMPARE(mydate); + COMPARE(mypoint); + COMPARE(mysize); + COMPARE(matrix); + COMPARE(quat); + COMPARE(vec2); + COMPARE(vec3); + COMPARE(vec4); +#undef COMPARE + + } + { + // createWithInitialProperties: setting a nonexistent property + QQmlComponent comp(&eng); + comp.loadUrl(testFileUrl("allJSONTypes.qml")); + QScopedPointer<QObject> obj { + comp.createWithInitialProperties(QVariantMap { {"notThePropertiesYoureLookingFor", 42} }) + }; + qDebug() << comp.errorString(); + QVERIFY(obj); + QVERIFY(comp.errorString().contains("Could not set property notThePropertiesYoureLookingFor")); + } +} + QTEST_MAIN(tst_qqmlcomponent) #include "tst_qqmlcomponent.moc" diff --git a/tests/auto/qml/qv4mm/tst_qv4mm.cpp b/tests/auto/qml/qv4mm/tst_qv4mm.cpp index 1e34b79954..5d635aa63b 100644 --- a/tests/auto/qml/qv4mm/tst_qv4mm.cpp +++ b/tests/auto/qml/qv4mm/tst_qv4mm.cpp @@ -136,7 +136,7 @@ void tst_qv4mm::clearICParent() // to change this test. for (uint i = 0; i < 16 * 1024; ++i) { QV4::Scope scope(&engine); - QV4::ScopedString s(scope, identifiers->getIndexed(i)); + QV4::ScopedString s(scope, identifiers->get(i)); QV4::Scoped<QV4::InternalClass> ic(scope, object->internalClass()); QVERIFY(ic->d()->parent != nullptr); object->deleteProperty(s->toPropertyKey()); diff --git a/tests/auto/quick/qquickborderimage/data/multi.ico b/tests/auto/quick/qquickborderimage/data/multi.ico Binary files differnew file mode 100644 index 0000000000..b748ceaa29 --- /dev/null +++ b/tests/auto/quick/qquickborderimage/data/multi.ico diff --git a/tests/auto/quick/qquickborderimage/data/multiframe.qml b/tests/auto/quick/qquickborderimage/data/multiframe.qml new file mode 100644 index 0000000000..8bd32da5a6 --- /dev/null +++ b/tests/auto/quick/qquickborderimage/data/multiframe.qml @@ -0,0 +1,8 @@ +import QtQuick 2.14 + +BorderImage { + source: "multi.ico" + border { left: 19; top: 19; right: 19; bottom: 19 } + width: 160; height: 160 + horizontalTileMode: BorderImage.Stretch +} diff --git a/tests/auto/quick/qquickborderimage/data/multiframeAsync.qml b/tests/auto/quick/qquickborderimage/data/multiframeAsync.qml new file mode 100644 index 0000000000..059e4becf3 --- /dev/null +++ b/tests/auto/quick/qquickborderimage/data/multiframeAsync.qml @@ -0,0 +1,9 @@ +import QtQuick 2.14 + +BorderImage { + source: "multi.ico" + asynchronous: true + border { left: 19; top: 19; right: 19; bottom: 19 } + width: 160; height: 160 + horizontalTileMode: BorderImage.Stretch +} diff --git a/tests/auto/quick/qquickborderimage/tst_qquickborderimage.cpp b/tests/auto/quick/qquickborderimage/tst_qquickborderimage.cpp index 9292e1886a..dc3a783600 100644 --- a/tests/auto/quick/qquickborderimage/tst_qquickborderimage.cpp +++ b/tests/auto/quick/qquickborderimage/tst_qquickborderimage.cpp @@ -46,6 +46,8 @@ #include "../../shared/util.h" #include "../shared/visualtestutil.h" +Q_LOGGING_CATEGORY(lcTests, "qt.quick.tests") + Q_DECLARE_METATYPE(QQuickImageBase::Status) class tst_qquickborderimage : public QQmlDataTest @@ -79,6 +81,8 @@ private slots: #if QT_CONFIG(opengl) void borderImageMesh(); #endif + void multiFrame_data(); + void multiFrame(); private: QQmlEngine engine; @@ -601,6 +605,67 @@ void tst_qquickborderimage::borderImageMesh() qPrintable(errorMessage)); } #endif + +void tst_qquickborderimage::multiFrame_data() +{ + QTest::addColumn<QString>("qmlfile"); + QTest::addColumn<bool>("asynchronous"); + + QTest::addRow("default") << "multiframe.qml" << false; + QTest::addRow("async") << "multiframeAsync.qml" << true; +} + +void tst_qquickborderimage::multiFrame() +{ + if ((QGuiApplication::platformName() == QLatin1String("offscreen")) + || (QGuiApplication::platformName() == QLatin1String("minimal"))) + QSKIP("Skipping due to grabWindow not functional on offscreen/minimimal platforms"); + + QFETCH(QString, qmlfile); + QFETCH(bool, asynchronous); + Q_UNUSED(asynchronous) + + QQuickView view(testFileUrl(qmlfile)); + QQuickBorderImage *image = qobject_cast<QQuickBorderImage*>(view.rootObject()); + QVERIFY(image); + QSignalSpy countSpy(image, SIGNAL(frameCountChanged())); + QSignalSpy currentSpy(image, SIGNAL(currentFrameChanged())); + if (asynchronous) { + QCOMPARE(image->frameCount(), 0); + QTRY_COMPARE(image->frameCount(), 4); + QCOMPARE(countSpy.count(), 1); + } else { + QCOMPARE(image->frameCount(), 4); + } + QCOMPARE(image->currentFrame(), 0); + view.show(); + QVERIFY(QTest::qWaitForWindowExposed(&view)); + QCoreApplication::processEvents(); // Process all queued events + + QImage contents = view.grabWindow(); + if (contents.width() < 160) + QSKIP("Skipping due to grabWindow not functional"); + + // The middle of the first frame looks blue, approximately qRgba(0x43, 0x7e, 0xd6, 0xff) + QColor color = contents.pixelColor(60, 60); + qCDebug(lcTests) << "expected bluish color, got" << color; + QVERIFY(color.redF() < 0.75); + QVERIFY(color.greenF() < 0.75); + QVERIFY(color.blueF() > 0.75); + + image->setCurrentFrame(1); + QTRY_COMPARE(image->status(), QQuickImageBase::Ready); + QCOMPARE(currentSpy.count(), 1); + QCOMPARE(image->currentFrame(), 1); + contents = view.grabWindow(); + // The middle of the second frame looks green, approximately qRgba(0x3a, 0xd2, 0x31, 0xff) + color = contents.pixelColor(60, 60); + qCDebug(lcTests) << "expected greenish color, got" << color; + QVERIFY(color.redF() < 0.75); + QVERIFY(color.green() > 0.75); + QVERIFY(color.blueF() < 0.75); +} + QTEST_MAIN(tst_qquickborderimage) #include "tst_qquickborderimage.moc" diff --git a/tests/auto/quick/qquickflickable/tst_qquickflickable.cpp b/tests/auto/quick/qquickflickable/tst_qquickflickable.cpp index 2314b82e8c..c104eecbcd 100644 --- a/tests/auto/quick/qquickflickable/tst_qquickflickable.cpp +++ b/tests/auto/quick/qquickflickable/tst_qquickflickable.cpp @@ -874,7 +874,8 @@ void tst_qquickflickable::wheel() // test a vertical flick { QPoint pos(200, 200); - QWheelEvent event(pos, window->mapToGlobal(pos), QPoint(), QPoint(0,-120), -120, Qt::Vertical, Qt::NoButton, Qt::NoModifier); + QWheelEvent event(pos, window->mapToGlobal(pos), QPoint(), QPoint(0,-120), + Qt::NoButton, Qt::NoModifier, Qt::NoScrollPhase, false); event.setAccepted(false); QGuiApplication::sendEvent(window.data(), &event); } @@ -897,7 +898,8 @@ void tst_qquickflickable::wheel() // test a horizontal flick { QPoint pos(200, 200); - QWheelEvent event(pos, window->mapToGlobal(pos), QPoint(), QPoint(-120,0), -120, Qt::Horizontal, Qt::NoButton, Qt::NoModifier); + QWheelEvent event(pos, window->mapToGlobal(pos), QPoint(), QPoint(-120,0), + Qt::NoButton, Qt::NoModifier, Qt::NoScrollPhase, false); event.setAccepted(false); QGuiApplication::sendEvent(window.data(), &event); @@ -926,7 +928,8 @@ void tst_qquickflickable::trackpad() QPoint pos(200, 200); { - QWheelEvent event(pos, window->mapToGlobal(pos), QPoint(0,-100), QPoint(0,-120), -120, Qt::Vertical, Qt::NoButton, Qt::NoModifier, Qt::ScrollBegin); + QWheelEvent event(pos, window->mapToGlobal(pos), QPoint(0,-100), QPoint(0,-120), + Qt::NoButton, Qt::NoModifier, Qt::ScrollBegin, false); event.setAccepted(false); QGuiApplication::sendEvent(window.data(), &event); } @@ -938,7 +941,8 @@ void tst_qquickflickable::trackpad() QCOMPARE(flick->contentY(), qreal(0)); { - QWheelEvent event(pos, window->mapToGlobal(pos), QPoint(-100,0), QPoint(-120,0), -120, Qt::Horizontal, Qt::NoButton, Qt::NoModifier, Qt::ScrollUpdate); + QWheelEvent event(pos, window->mapToGlobal(pos), QPoint(-100,0), QPoint(-120,0), + Qt::NoButton, Qt::NoModifier, Qt::ScrollUpdate, false); event.setAccepted(false); QGuiApplication::sendEvent(window.data(), &event); } @@ -947,7 +951,8 @@ void tst_qquickflickable::trackpad() QCOMPARE(flick->contentY(), qreal(0)); { - QWheelEvent event(pos, window->mapToGlobal(pos), QPoint(0,0), QPoint(0,0), 0, Qt::Horizontal, Qt::NoButton, Qt::NoModifier, Qt::ScrollEnd); + QWheelEvent event(pos, window->mapToGlobal(pos), QPoint(0,0), QPoint(0,0), + Qt::NoButton, Qt::NoModifier, Qt::ScrollEnd, false); event.setAccepted(false); QGuiApplication::sendEvent(window.data(), &event); } diff --git a/tests/auto/quick/qquickimage/data/multi.ico b/tests/auto/quick/qquickimage/data/multi.ico Binary files differnew file mode 100644 index 0000000000..b748ceaa29 --- /dev/null +++ b/tests/auto/quick/qquickimage/data/multi.ico diff --git a/tests/auto/quick/qquickimage/data/multiframe.qml b/tests/auto/quick/qquickimage/data/multiframe.qml new file mode 100644 index 0000000000..df70bc784c --- /dev/null +++ b/tests/auto/quick/qquickimage/data/multiframe.qml @@ -0,0 +1,5 @@ +import QtQuick 2.14 + +Image { + source: "multi.ico" +} diff --git a/tests/auto/quick/qquickimage/data/multiframeAsync.qml b/tests/auto/quick/qquickimage/data/multiframeAsync.qml new file mode 100644 index 0000000000..167b4a3e57 --- /dev/null +++ b/tests/auto/quick/qquickimage/data/multiframeAsync.qml @@ -0,0 +1,6 @@ +import QtQuick 2.14 + +Image { + source: "multi.ico" + asynchronous: true +} diff --git a/tests/auto/quick/qquickimage/tst_qquickimage.cpp b/tests/auto/quick/qquickimage/tst_qquickimage.cpp index 34c18aa64b..abc7cd86bd 100644 --- a/tests/auto/quick/qquickimage/tst_qquickimage.cpp +++ b/tests/auto/quick/qquickimage/tst_qquickimage.cpp @@ -97,6 +97,8 @@ private slots: void highDpiFillModesAndSizes(); void hugeImages(); void urlInterceptor(); + void multiFrame_data(); + void multiFrame(); private: QQmlEngine engine; @@ -1132,6 +1134,62 @@ void tst_qquickimage::urlInterceptor() QTRY_COMPARE(object->progress(), 1.0); } +void tst_qquickimage::multiFrame_data() +{ + QTest::addColumn<QString>("qmlfile"); + QTest::addColumn<bool>("asynchronous"); + + QTest::addRow("default") << "multiframe.qml" << false; + QTest::addRow("async") << "multiframeAsync.qml" << true; +} + +void tst_qquickimage::multiFrame() +{ + if ((QGuiApplication::platformName() == QLatin1String("offscreen")) + || (QGuiApplication::platformName() == QLatin1String("minimal"))) + QSKIP("Skipping due to grabWindow not functional on offscreen/minimimal platforms"); + + QFETCH(QString, qmlfile); + QFETCH(bool, asynchronous); + Q_UNUSED(asynchronous) + + QQuickView view(testFileUrl(qmlfile)); + QQuickImage *image = qobject_cast<QQuickImage*>(view.rootObject()); + QVERIFY(image); + QSignalSpy countSpy(image, SIGNAL(frameCountChanged())); + QSignalSpy currentSpy(image, SIGNAL(currentFrameChanged())); + if (asynchronous) { + QCOMPARE(image->frameCount(), 0); + QTRY_COMPARE(image->frameCount(), 4); + QCOMPARE(countSpy.count(), 1); + } else { + QCOMPARE(image->frameCount(), 4); + } + QCOMPARE(image->currentFrame(), 0); + view.show(); + QVERIFY(QTest::qWaitForWindowExposed(&view)); + + QImage contents = view.grabWindow(); + if (contents.width() < 40) + QSKIP("Skipping due to grabWindow not functional"); + // The first frame is a blue ball, approximately qRgba(0x33, 0x6d, 0xcc, 0xff) + QRgb color = contents.pixel(16, 16); + QVERIFY(qRed(color) < 0xc0); + QVERIFY(qGreen(color) < 0xc0); + QVERIFY(qBlue(color) > 0xc0); + + image->setCurrentFrame(1); + QTRY_COMPARE(image->status(), QQuickImageBase::Ready); + QCOMPARE(currentSpy.count(), 1); + QCOMPARE(image->currentFrame(), 1); + contents = view.grabWindow(); + // The second frame is a green ball, approximately qRgba(0x27, 0xc8, 0x22, 0xff) + color = contents.pixel(16, 16); + QVERIFY(qRed(color) < 0xc0); + QVERIFY(qGreen(color) > 0xc0); + QVERIFY(qBlue(color) < 0xc0); +} + QTEST_MAIN(tst_qquickimage) #include "tst_qquickimage.moc" diff --git a/tests/auto/quick/qquickitem/tst_qquickitem.cpp b/tests/auto/quick/qquickitem/tst_qquickitem.cpp index 7e132f97b6..b6e40d5117 100644 --- a/tests/auto/quick/qquickitem/tst_qquickitem.cpp +++ b/tests/auto/quick/qquickitem/tst_qquickitem.cpp @@ -83,8 +83,8 @@ protected: event->accept(); ++wheelCount; timestamp = event->timestamp(); - lastWheelEventPos = event->pos(); - lastWheelEventGlobalPos = event->globalPos(); + lastWheelEventPos = event->position().toPoint(); + lastWheelEventGlobalPos = event->globalPosition().toPoint(); } }; @@ -1462,7 +1462,8 @@ void tst_qquickitem::wheelEvent() QPoint localPoint(width / 2, height / 2); QPoint globalPoint = window.mapToGlobal(localPoint); - QWheelEvent event(localPoint, globalPoint, -120, Qt::NoButton, Qt::NoModifier, Qt::Vertical); + QWheelEvent event(localPoint, globalPoint, QPoint(0, 0), QPoint(0, -120), + Qt::NoButton, Qt::NoModifier, Qt::NoScrollPhase, false); event.setTimestamp(123456UL); event.setAccepted(false); QGuiApplication::sendEvent(&window, &event); diff --git a/tests/auto/quick/qquicklistview/data/addoncompleted.qml b/tests/auto/quick/qquicklistview/data/addoncompleted.qml index 57265cb2c0..2341295868 100644 --- a/tests/auto/quick/qquicklistview/data/addoncompleted.qml +++ b/tests/auto/quick/qquicklistview/data/addoncompleted.qml @@ -73,6 +73,9 @@ Rectangle { anchors.fill: parent model: listModel objectName: "view" + // buffered delegates are created asynchronously + // therefore we disable buffering + cacheBuffer: 0 delegate: Rectangle { height: 15 diff --git a/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp b/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp index bab2ec34f8..08149a1786 100644 --- a/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp +++ b/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp @@ -8958,6 +8958,7 @@ void tst_QQuickListView::addOnCompleted() y = 9999999; } else { const qreal newY = item->y(); + QVERIFY(newY != 9999999); // once we could not find an item, we shouldn' find any further ones QVERIFY2(newY > y, objName.toUtf8().constData()); y = newY; } diff --git a/tests/auto/quick/qquickmousearea/tst_qquickmousearea.cpp b/tests/auto/quick/qquickmousearea/tst_qquickmousearea.cpp index 4215017db3..5844720aa4 100644 --- a/tests/auto/quick/qquickmousearea/tst_qquickmousearea.cpp +++ b/tests/auto/quick/qquickmousearea/tst_qquickmousearea.cpp @@ -1519,7 +1519,7 @@ void tst_QQuickMouseArea::onWheel() QVERIFY(root != nullptr); QWheelEvent wheelEvent(QPoint(10, 32), QPoint(10, 32), QPoint(60, 20), QPoint(0, 120), - 0, Qt::Vertical,Qt::NoButton, Qt::ControlModifier); + Qt::NoButton, Qt::ControlModifier, Qt::NoScrollPhase, false); QGuiApplication::sendEvent(&window, &wheelEvent); QCOMPARE(root->property("angleDeltaY").toInt(), 120); diff --git a/tests/auto/quick/qquicktext/data/verticallyAlignedImageInTable.qml b/tests/auto/quick/qquicktext/data/verticallyAlignedImageInTable.qml new file mode 100644 index 0000000000..4c00362d15 --- /dev/null +++ b/tests/auto/quick/qquicktext/data/verticallyAlignedImageInTable.qml @@ -0,0 +1,14 @@ +import QtQuick 2.0 + +Item { + width: 320 + height: 480 + + Text { + anchors.centerIn: parent + font.family: "Arial" + font.pixelSize: 16 + textFormat: Text.RichText + text: "<table><tr><td/><td valign=\"top\"><img src=\"images/face-sad.png\"></td></tr></table>" + } +} diff --git a/tests/auto/quick/qquicktext/tst_qquicktext.cpp b/tests/auto/quick/qquicktext/tst_qquicktext.cpp index fd0ba0f49b..97107694bd 100644 --- a/tests/auto/quick/qquicktext/tst_qquicktext.cpp +++ b/tests/auto/quick/qquicktext/tst_qquicktext.cpp @@ -162,6 +162,8 @@ private slots: void initialContentHeight(); + void verticallyAlignedImageInTable(); + private: QStringList standard; QStringList richText; @@ -4415,6 +4417,18 @@ void tst_qquicktext::implicitSizeChangeRewrap() QVERIFY(text->contentWidth() < window->width()); } +void tst_qquicktext::verticallyAlignedImageInTable() +{ + QScopedPointer<QQuickView> window(new QQuickView); + window->setSource(testFileUrl("verticallyAlignedImageInTable.qml")); + QTRY_COMPARE(window->status(), QQuickView::Ready); + + window->show(); + QVERIFY(QTest::qWaitForWindowExposed(window.data())); + + // Don't crash +} + QTEST_MAIN(tst_qquicktext) #include "tst_qquicktext.moc" diff --git a/tests/auto/quick/qquickview/tst_qquickview.cpp b/tests/auto/quick/qquickview/tst_qquickview.cpp index e259ed1ae7..dbce0d308c 100644 --- a/tests/auto/quick/qquickview/tst_qquickview.cpp +++ b/tests/auto/quick/qquickview/tst_qquickview.cpp @@ -49,6 +49,7 @@ private slots: void errors(); void engine(); void findChild(); + void setInitialProperties(); }; @@ -283,6 +284,17 @@ void tst_QQuickView::findChild() QVERIFY(!view.rootObject()->findChild<QObject *>("rootObject")); // self } +void tst_QQuickView::setInitialProperties() +{ + QQuickView view; + view.setInitialProperties({{"z", 4}, {"width", 100}}); + view.setSource(testFileUrl("resizemodeitem.qml")); + QObject *rootObject = view.rootObject(); + QVERIFY(rootObject); + QCOMPARE(rootObject->property("z").toInt(), 4); + QCOMPARE(rootObject->property("width").toInt(), 100); +} + QTEST_MAIN(tst_QQuickView) #include "tst_qquickview.moc" diff --git a/tests/benchmarks/qml/js/qjsengine/tst_qjsengine.cpp b/tests/benchmarks/qml/js/qjsengine/tst_qjsengine.cpp index d13751385c..cb23d6edbd 100644 --- a/tests/benchmarks/qml/js/qjsengine/tst_qjsengine.cpp +++ b/tests/benchmarks/qml/js/qjsengine/tst_qjsengine.cpp @@ -452,7 +452,7 @@ void tst_QJSEngine::installTranslatorFunctions() { newEngine(); QBENCHMARK { - m_engine->installTranslatorFunctions(); + m_engine->installExtensions(QJSEngine::TranslationExtension); } } @@ -471,7 +471,7 @@ void tst_QJSEngine::translation() QFETCH(QString, text); QFETCH(QString, fileName); newEngine(); - m_engine->installTranslatorFunctions(); + m_engine->installExtensions(QJSEngine::TranslationExtension); QBENCHMARK { (void)m_engine->evaluate(text, fileName); diff --git a/tests/benchmarks/qml/painting/paintbenchmark.cpp b/tests/benchmarks/qml/painting/paintbenchmark.cpp index d195675ab8..1500f39c9a 100644 --- a/tests/benchmarks/qml/painting/paintbenchmark.cpp +++ b/tests/benchmarks/qml/painting/paintbenchmark.cpp @@ -34,7 +34,7 @@ #include <QGLWidget> #include <QTextLayout> #include <QVBoxLayout> -#include <QTime> +#include <QElapsedTimer> #include <QDebug> #include <QRandomGenerator> #include <QStaticText> @@ -328,20 +328,20 @@ public: } void paintEvent(QPaintEvent *) { - static int last = 0; + static qint64 last = 0; static bool firstRun = true; if (firstRun) { timer.start(); firstRun = false; } else { - int elapsed = timer.elapsed(); + qint64 elapsed = timer.elapsed(); qDebug() << "frame elapsed:" << elapsed - last; last = elapsed; } QPainter p(this); p.fillRect(rect(), Qt::white); p.setPen(Qt::black); - QTime drawTimer; + QElapsedTimer drawTimer; drawTimer.start(); testFunc(p); qDebug() << "draw time" << drawTimer.elapsed(); @@ -351,7 +351,7 @@ public: qApp->quit(); } - QTime timer; + QElapsedTimer timer; int frames; }; diff --git a/tests/manual/scenegraph_lancelot/data/text/text_table_vertically_aligned_image.qml b/tests/manual/scenegraph_lancelot/data/text/text_table_vertically_aligned_image.qml new file mode 100644 index 0000000000..d712f94572 --- /dev/null +++ b/tests/manual/scenegraph_lancelot/data/text/text_table_vertically_aligned_image.qml @@ -0,0 +1,14 @@ +import QtQuick 2.0 + +Item { + width: 320 + height: 480 + + Text { + anchors.centerIn: parent + font.family: "Arial" + font.pixelSize: 16 + textFormat: Text.RichText + text: "<table><tr><td/><td valign=\"top\"><img src=\"data/logo.png\"></td></tr></table>" + } +} |