diff options
author | Laszlo Agocs <laszlo.agocs@qt.io> | 2017-03-01 11:54:30 +0100 |
---|---|---|
committer | Laszlo Agocs <laszlo.agocs@qt.io> | 2017-03-01 11:54:35 +0100 |
commit | 87aebe39ae80c0752695b21b5b7508d220035b85 (patch) | |
tree | a60bd61dd81b5e79532762ae014cb7612d619da2 /tests | |
parent | a48244d5aa1d14c286b7cd39afebcfff9c9dcb60 (diff) | |
parent | afec9016d0fd51345ea93a1bbadb99b5c3fdf629 (diff) |
Merge remote-tracking branch 'origin/dev' into wip/scenegraphng
Change-Id: Iba540adaeffb0098fc4e1923050eb611bf47287b
Diffstat (limited to 'tests')
41 files changed, 1045 insertions, 42 deletions
diff --git a/tests/auto/auto.pro b/tests/auto/auto.pro index f25742fb14..1e80f1bf65 100644 --- a/tests/auto/auto.pro +++ b/tests/auto/auto.pro @@ -18,6 +18,4 @@ qtHaveModule(gui):qtConfig(opengl(es1|es2)?) { # console applications not supported uikit: SUBDIRS -= qmltest -qmldevtools.CONFIG = host_build - installed_cmake.depends = cmake diff --git a/tests/auto/qml/animation/qpauseanimationjob/tst_qpauseanimationjob.cpp b/tests/auto/qml/animation/qpauseanimationjob/tst_qpauseanimationjob.cpp index 1791407934..ff295c5409 100644 --- a/tests/auto/qml/animation/qpauseanimationjob/tst_qpauseanimationjob.cpp +++ b/tests/auto/qml/animation/qpauseanimationjob/tst_qpauseanimationjob.cpp @@ -392,8 +392,10 @@ void tst_QPauseAnimationJob::multipleSequentialGroups() #ifdef Q_OS_WIN if (group.state() != QAbstractAnimationJob::Stopped) QEXPECT_FAIL("", winTimerError, Abort); -#endif + QCOMPARE(group.state(), QAbstractAnimationJob::Stopped); +#else QTRY_COMPARE(group.state(), QAbstractAnimationJob::Stopped); +#endif #ifdef Q_OS_WIN if (subgroup1.state() != QAbstractAnimationJob::Stopped) diff --git a/tests/auto/qml/qjsengine/tst_qjsengine.cpp b/tests/auto/qml/qjsengine/tst_qjsengine.cpp index 82bc3d0c59..39f6d80fa0 100644 --- a/tests/auto/qml/qjsengine/tst_qjsengine.cpp +++ b/tests/auto/qml/qjsengine/tst_qjsengine.cpp @@ -566,10 +566,6 @@ void tst_QJSEngine::newDate() QCOMPARE(date.isDate(), true); QCOMPARE(date.isObject(), true); QVERIFY(!date.isCallable()); - // prototype should be Date.prototype - QVERIFY(!date.prototype().isUndefined()); - QCOMPARE(date.prototype().isDate(), true); - QCOMPARE(date.prototype().strictlyEquals(eng.evaluate("Date.prototype")), true); } { @@ -578,10 +574,6 @@ void tst_QJSEngine::newDate() QVERIFY(!date.isUndefined()); QCOMPARE(date.isDate(), true); QCOMPARE(date.isObject(), true); - // prototype should be Date.prototype - QVERIFY(!date.prototype().isUndefined()); - QCOMPARE(date.prototype().isDate(), true); - QCOMPARE(date.prototype().strictlyEquals(eng.evaluate("Date.prototype")), true); QCOMPARE(date.toDateTime(), dt); } @@ -1099,7 +1091,7 @@ void tst_QJSEngine::builtinFunctionNames_data() QTest::newRow("Date.prototype.setFullYear") << QString("Date.prototype.setFullYear") << QString("setFullYear"); QTest::newRow("Date.prototype.setUTCFullYear") << QString("Date.prototype.setUTCFullYear") << QString("setUTCFullYear"); QTest::newRow("Date.prototype.toUTCString") << QString("Date.prototype.toUTCString") << QString("toUTCString"); - QTest::newRow("Date.prototype.toGMTString") << QString("Date.prototype.toGMTString") << QString("toGMTString"); + QTest::newRow("Date.prototype.toGMTString") << QString("Date.prototype.toGMTString") << QString("toUTCString"); // yes, this is per spec QTest::newRow("Error") << QString("Error") << QString("Error"); // QTest::newRow("Error.prototype.backtrace") << QString("Error.prototype.backtrace") << QString("backtrace"); @@ -1177,6 +1169,7 @@ void tst_QJSEngine::builtinFunctionNames_data() QTest::newRow("String.prototype.lastIndexOf") << QString("String.prototype.lastIndexOf") << QString("lastIndexOf"); QTest::newRow("String.prototype.localeCompare") << QString("String.prototype.localeCompare") << QString("localeCompare"); QTest::newRow("String.prototype.match") << QString("String.prototype.match") << QString("match"); + QTest::newRow("String.prototype.repeat") << QString("String.prototype.repeat") << QString("repeat"); QTest::newRow("String.prototype.replace") << QString("String.prototype.replace") << QString("replace"); QTest::newRow("String.prototype.search") << QString("String.prototype.search") << QString("search"); QTest::newRow("String.prototype.slice") << QString("String.prototype.slice") << QString("slice"); diff --git a/tests/auto/qml/qml.pro b/tests/auto/qml/qml.pro index 68a2eace19..04e4b04114 100644 --- a/tests/auto/qml/qml.pro +++ b/tests/auto/qml/qml.pro @@ -73,7 +73,7 @@ qtHaveModule(widgets) { SUBDIRS += $$PUBLICTESTS \ qqmlextensionplugin SUBDIRS += $$METATYPETESTS -!uikit:!winrt { # no QProcess on uikit/winrt +!qtConfig(process) { !contains(QT_CONFIG, no-qml-debug): SUBDIRS += debugger SUBDIRS += qmllint qmlplugindump } diff --git a/tests/auto/qml/qqmlecmascript/data/signalParameterTypes.qml b/tests/auto/qml/qqmlecmascript/data/signalParameterTypes.qml index 676593096c..54d29dfc94 100644 --- a/tests/auto/qml/qqmlecmascript/data/signalParameterTypes.qml +++ b/tests/auto/qml/qqmlecmascript/data/signalParameterTypes.qml @@ -16,5 +16,11 @@ MyQmlObject onBasicSignal: root.mySignal(10, 19.2, Qt.rgba(1, 1, 0, 1), Qt.rgba(1, 0, 1, 1), MyQmlObject.EnumValue3, Qt.LeftButton) - onQjsValueEmittingSignal: {} + property bool emittedQjsValueWasUndefined + property int emittedQjsValueAsInt + + onQjsValueEmittingSignal: { + emittedQjsValueWasUndefined = value === undefined; + emittedQjsValueAsInt = value + } } diff --git a/tests/auto/qml/qqmlecmascript/testtypes.cpp b/tests/auto/qml/qqmlecmascript/testtypes.cpp index d9ddcd71a7..63c2918325 100644 --- a/tests/auto/qml/qqmlecmascript/testtypes.cpp +++ b/tests/auto/qml/qqmlecmascript/testtypes.cpp @@ -515,6 +515,8 @@ void registerTypes() qmlRegisterType<QObjectContainer>("Qt.test", 1, 0, "QObjectContainer"); qmlRegisterType<QObjectContainerWithGCOnAppend>("Qt.test", 1, 0, "QObjectContainerWithGCOnAppend"); qmlRegisterType<FloatingQObject>("Qt.test", 1, 0, "FloatingQObject"); + + qmlRegisterType<ClashingNames>("Qt.test", 1, 0, "ClashingNames"); } #include "testtypes.moc" diff --git a/tests/auto/qml/qqmlecmascript/testtypes.h b/tests/auto/qml/qqmlecmascript/testtypes.h index 1f7f3344ef..eedeb66647 100644 --- a/tests/auto/qml/qqmlecmascript/testtypes.h +++ b/tests/auto/qml/qqmlecmascript/testtypes.h @@ -1714,6 +1714,14 @@ public: virtual void componentComplete(); }; +class ClashingNames : public QObject +{ + Q_OBJECT + Q_PROPERTY(bool clashes READ clashes CONSTANT) +public: + Q_INVOKABLE bool clashes() const { return true; } +}; + void registerTypes(); #endif // TESTTYPES_H diff --git a/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp b/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp index 8c0b0601fc..91ceed7697 100644 --- a/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp +++ b/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp @@ -1,5 +1,6 @@ /**************************************************************************** ** +** Copyright (C) 2017 Crimson AS <info@crimson.no> ** Copyright (C) 2016 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** @@ -46,6 +47,7 @@ #include <private/qv4runtime_p.h> #include <private/qv4object_p.h> #include <private/qqmlcomponentattached_p.h> +#include <private/qv4objectiterator_p.h> #ifdef Q_CC_MSVC #define NO_INLINE __declspec(noinline) @@ -260,6 +262,7 @@ private slots: void nonNotifyable(); void deleteWhileBindingRunning(); void callQtInvokables(); + void resolveClashingProperties(); void invokableObjectArg(); void invokableObjectRet(); void invokableEnumRet(); @@ -333,6 +336,10 @@ private slots: void stringify_qtbug_50592(); void instanceof_data(); void instanceof(); + void constkw_data(); + void constkw(); + void redefineGlobalProp(); + void freeze_empty_object(); private: // static void propertyVarWeakRefCallback(v8::Persistent<v8::Value> object, void* parameter); @@ -1412,7 +1419,6 @@ void tst_qqmlecmascript::signalParameterTypes() QVERIFY(object != 0); emit object->basicSignal(); - emit object->qjsValueEmittingSignal(QJSValue()); QCOMPARE(object->property("intProperty").toInt(), 10); QCOMPARE(object->property("realProperty").toReal(), 19.2); @@ -1421,6 +1427,12 @@ void tst_qqmlecmascript::signalParameterTypes() QVERIFY(object->property("enumProperty") == MyQmlObject::EnumValue3); QVERIFY(object->property("qtEnumProperty") == Qt::LeftButton); + emit object->qjsValueEmittingSignal(QJSValue()); + QVERIFY(object->property("emittedQjsValueWasUndefined").toBool()); + emit object->qjsValueEmittingSignal(QJSValue(42)); + QVERIFY(!object->property("emittedQjsValueWasUndefined").toBool()); + QCOMPARE(object->property("emittedQjsValueAsInt").value<int>(), 42); + delete object; } @@ -2981,6 +2993,48 @@ void tst_qqmlecmascript::callQtInvokables() QVERIFY(callback.isCallable()); } +void tst_qqmlecmascript::resolveClashingProperties() +{ + ClashingNames *o = new ClashingNames(); + QQmlEngine qmlengine; + QQmlEnginePrivate *ep = QQmlEnginePrivate::get(&qmlengine); + + QV4::ExecutionEngine *engine = QV8Engine::getV4(ep->v8engine()); + QV4::Scope scope(engine); + + QV4::ScopedValue object(scope, QV4::QObjectWrapper::wrap(engine, o)); + QV4::ObjectIterator it(scope, object->as<QV4::Object>(), QV4::ObjectIterator::EnumerableOnly); + QV4::ScopedValue name(scope); + QV4::ScopedValue value(scope); + + bool seenProperty = false; + bool seenMethod = false; + while (true) { + QV4::Value v; + name = it.nextPropertyNameAsString(&v); + if (name->isNull()) + break; + QString key = name->toQStringNoThrow(); + if (key == QLatin1String("clashes")) { + value = v; + QV4::ScopedValue typeString(scope, QV4::Runtime::method_typeofValue(engine, value)); + QString type = typeString->toQStringNoThrow(); + if (type == QLatin1String("boolean")) { + QVERIFY(!seenProperty); + seenProperty = true; + } else if (type == QLatin1String("function")) { + QVERIFY(!seenMethod); + seenMethod = true; + } else { + QFAIL(qPrintable(QString::fromLatin1("found 'clashes' property of type %1") + .arg(type))); + } + } + } + QVERIFY(seenProperty); + QVERIFY(seenMethod); +} + // QTBUG-13047 (check that you can pass registered object types as args) void tst_qqmlecmascript::invokableObjectArg() { @@ -8178,6 +8232,121 @@ void tst_qqmlecmascript::instanceof() } } +void tst_qqmlecmascript::constkw_data() +{ + QTest::addColumn<QString>("sourceCode"); + QTest::addColumn<bool>("exceptionExpected"); + QTest::addColumn<QVariant>("expectedValue"); + + QTest::newRow("simpleconst") + << "const v = 5\n" + "v\n" + << false + << QVariant(5); + QTest::newRow("twoconst") + << "const v = 5, i = 10\n" + "v + i\n" + << false + << QVariant(15); + QTest::newRow("constandvar") + << "const v = 5\n" + "var i = 20\n" + "v + i\n" + << false + << QVariant(25); + QTest::newRow("const-multiple-scopes-same-var") + << "const v = 3\n" + "function f() { const v = 1; return v; }\n" + "v + f()\n" + << false + << QVariant(4); + + // error cases + QTest::newRow("const-no-initializer") + << "const v\n" + << true + << QVariant("SyntaxError: Missing initializer in const declaration"); + QTest::newRow("const-no-initializer-comma") + << "const v = 1, i\n" + << true + << QVariant("SyntaxError: Missing initializer in const declaration"); + QTest::newRow("const-no-duplicate") + << "const v = 1, v = 2\n" + << true + << QVariant("SyntaxError: Identifier v has already been declared"); + QTest::newRow("const-no-duplicate-2") + << "const v = 1\n" + "const v = 2\n" + << true + << QVariant("SyntaxError: Identifier v has already been declared"); + QTest::newRow("const-no-duplicate-var") + << "const v = 1\n" + "var v = 1\n" + << true + << QVariant("SyntaxError: Identifier v has already been declared"); + QTest::newRow("var-no-duplicate-const") + << "var v = 1\n" + "const v = 1\n" + << true + << QVariant("SyntaxError: Identifier v has already been declared"); + QTest::newRow("const-no-duplicate-let") + << "const v = 1\n" + "let v = 1\n" + << true + << QVariant("SyntaxError: Identifier v has already been declared"); + QTest::newRow("let-no-duplicate-const") + << "let v = 1\n" + "const v = 1\n" + << true + << QVariant("SyntaxError: Identifier v has already been declared"); +} + +void tst_qqmlecmascript::constkw() +{ + QFETCH(QString, sourceCode); + QFETCH(bool, exceptionExpected); + QFETCH(QVariant, expectedValue); + + QJSEngine engine; + QJSValue ret = engine.evaluate(sourceCode); + + if (!exceptionExpected) { + QVERIFY2(!ret.isError(), qPrintable(ret.toString())); + QCOMPARE(ret.toVariant(), expectedValue); + } else { + QVERIFY2(ret.isError(), qPrintable(ret.toString())); + QCOMPARE(ret.toString(), expectedValue.toString()); + } +} + +// Redefine a property found on the global object. It shouldn't throw. +void tst_qqmlecmascript::redefineGlobalProp() +{ + { + QJSEngine engine; + QJSValue ret = engine.evaluate("\"use strict\"\n var toString = 1;"); + QVERIFY2(!ret.isError(), qPrintable(ret.toString())); + } + { + QJSEngine engine; + QJSValue ret = engine.evaluate("var toString = 1;"); + QVERIFY2(!ret.isError(), qPrintable(ret.toString())); + } +} + +void tst_qqmlecmascript::freeze_empty_object() +{ + // this shouldn't crash + QJSEngine engine; + QJSValue v = engine.evaluate(QString::fromLatin1( + "var obj = {};\n" + "Object.freeze(obj);\n" + )); + QVERIFY(!v.isError()); + QCOMPARE(v.toBool(), true); +} + + QTEST_MAIN(tst_qqmlecmascript) #include "tst_qqmlecmascript.moc" diff --git a/tests/auto/qml/qqmlengine/tst_qqmlengine.cpp b/tests/auto/qml/qqmlengine/tst_qqmlengine.cpp index 9c155eda5b..e170920486 100644 --- a/tests/auto/qml/qqmlengine/tst_qqmlengine.cpp +++ b/tests/auto/qml/qqmlengine/tst_qqmlengine.cpp @@ -56,6 +56,7 @@ private slots: void baseUrl(); void contextForObject(); void offlineStoragePath(); + void offlineDatabaseStoragePath(); void clearComponentCache(); void trimComponentCache(); void trimComponentCache_data(); @@ -252,6 +253,34 @@ void tst_qqmlengine::offlineStoragePath() QCOMPARE(engine.offlineStoragePath(), QDir::homePath()); } +void tst_qqmlengine::offlineDatabaseStoragePath() +{ + // Without these set, QDesktopServices::storageLocation returns + // strings with extra "//" at the end. We set them to ignore this problem. + qApp->setApplicationName("tst_qqmlengine"); + qApp->setOrganizationName("QtProject"); + qApp->setOrganizationDomain("www.qt-project.org"); + + QQmlEngine engine; + QString dataLocation = QStandardPaths::writableLocation(QStandardPaths::DataLocation); + const QString databaseName = QLatin1String("foo"); + QString databaseLocation = engine.offlineStorageDatabaseFilePath(databaseName); + QCOMPARE(dataLocation.isEmpty(), databaseLocation.isEmpty()); + + QDir dir(dataLocation); + dir.mkpath("QML"); + dir.cd("QML"); + dir.mkpath("OfflineStorage"); + dir.cd("OfflineStorage"); + dir.mkpath("Databases"); + dir.cd("Databases"); + QCOMPARE(QFileInfo(databaseLocation).dir().path(), dir.path()); + + QCryptographicHash md5(QCryptographicHash::Md5); + md5.addData(databaseName.toUtf8()); + QCOMPARE(databaseLocation, QDir::toNativeSeparators(dir.filePath(QLatin1String(md5.result().toHex())))); +} + void tst_qqmlengine::clearComponentCache() { QQmlEngine engine; diff --git a/tests/auto/qml/qqmllanguage/data/compositeTypeByName_anon_qmldir.qml b/tests/auto/qml/qqmllanguage/data/compositeTypeByName_anon_qmldir.qml new file mode 100644 index 0000000000..5ffdc26096 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/compositeTypeByName_anon_qmldir.qml @@ -0,0 +1,9 @@ +import QtQuick 2.6 +import "simpleimportByName" + +Item { + Component.onCompleted: { + console.warn(SimpleType) + } +} + diff --git a/tests/auto/qml/qqmllanguage/data/compositeTypeByName_named_qmldir.qml b/tests/auto/qml/qqmllanguage/data/compositeTypeByName_named_qmldir.qml new file mode 100644 index 0000000000..c446eae84c --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/compositeTypeByName_named_qmldir.qml @@ -0,0 +1,9 @@ +import QtQuick 2.6 +import "simpleimportByName" as ImportName + +Item { + Component.onCompleted: { + console.warn(ImportName.SimpleType) + } +} + diff --git a/tests/auto/qml/qqmllanguage/data/quickTypeByName_anon.qml b/tests/auto/qml/qqmllanguage/data/quickTypeByName_anon.qml new file mode 100644 index 0000000000..abe750db33 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/quickTypeByName_anon.qml @@ -0,0 +1,8 @@ +import QtQuick 2.6 + +Item { + Component.onCompleted: { + console.warn(Item) + } +} + diff --git a/tests/auto/qml/qqmllanguage/data/quickTypeByName_named.qml b/tests/auto/qml/qqmllanguage/data/quickTypeByName_named.qml new file mode 100644 index 0000000000..397d4f42f0 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/quickTypeByName_named.qml @@ -0,0 +1,8 @@ +import QtQuick 2.6 as Quick + +Quick.Item { + Quick.Component.onCompleted: { + console.warn(Quick.Item) + } +} + diff --git a/tests/auto/qml/qqmllanguage/data/simpleimportByName/SimpleType.qml b/tests/auto/qml/qqmllanguage/data/simpleimportByName/SimpleType.qml new file mode 100644 index 0000000000..4772dde8f0 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/simpleimportByName/SimpleType.qml @@ -0,0 +1,4 @@ +import QtQuick 2.6 + +MouseArea { +} diff --git a/tests/auto/qml/qqmllanguage/data/simpleimportByName/qmldir b/tests/auto/qml/qqmllanguage/data/simpleimportByName/qmldir new file mode 100644 index 0000000000..80df37d0e6 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/simpleimportByName/qmldir @@ -0,0 +1 @@ +SimpleType 1.0 SimpleType.qml diff --git a/tests/auto/qml/qqmllanguage/testtypes.cpp b/tests/auto/qml/qqmllanguage/testtypes.cpp index bc8c192a61..bdcdaa8137 100644 --- a/tests/auto/qml/qqmllanguage/testtypes.cpp +++ b/tests/auto/qml/qqmllanguage/testtypes.cpp @@ -87,6 +87,10 @@ void registerTypes() qmlRegisterUncreatableType<MyUncreateableBaseClass,1>("Test", 1, 1, "MyUncreateableBaseClass", "Cannot create MyUncreateableBaseClass"); qmlRegisterType<MyCreateableDerivedClass,1>("Test", 1, 1, "MyCreateableDerivedClass"); + qmlRegisterExtendedUncreatableType<MyExtendedUncreateableBaseClass, MyExtendedUncreateableBaseClassExtension>("Test", 1, 0, "MyExtendedUncreateableBaseClass", "Cannot create MyExtendedUncreateableBaseClass"); + qmlRegisterExtendedUncreatableType<MyExtendedUncreateableBaseClass, MyExtendedUncreateableBaseClassExtension, 1>("Test", 1, 1, "MyExtendedUncreateableBaseClass", "Cannot create MyExtendedUncreateableBaseClass"); + qmlRegisterType<MyExtendedCreateableDerivedClass>("Test", 1, 0, "MyExtendedCreateableDerivedClass"); + qmlRegisterCustomType<CustomBinding>("Test", 1, 0, "CustomBinding", new CustomBindingParser); qmlRegisterCustomType<SimpleObjectWithCustomParser>("Test", 1, 0, "SimpleObjectWithCustomParser", new SimpleObjectCustomParser); diff --git a/tests/auto/qml/qqmllanguage/testtypes.h b/tests/auto/qml/qqmllanguage/testtypes.h index 6c62bcf7b9..7d7a8ac6d3 100644 --- a/tests/auto/qml/qqmllanguage/testtypes.h +++ b/tests/auto/qml/qqmllanguage/testtypes.h @@ -1021,6 +1021,60 @@ public: } }; +class MyExtendedUncreateableBaseClass : public QObject +{ + Q_OBJECT + Q_PROPERTY(bool prop1 READ prop1 WRITE setprop1) + Q_PROPERTY(bool prop2 READ prop2 WRITE setprop2 REVISION 1) + Q_PROPERTY(bool prop3 READ prop3 WRITE setprop3 REVISION 1) +public: + explicit MyExtendedUncreateableBaseClass(QObject *parent = 0) + : QObject(parent), _prop1(false), _prop2(false), _prop3(false) + { + } + + bool _prop1; + bool prop1() const { return _prop1; } + void setprop1(bool p) { _prop1 = p; } + bool _prop2; + bool prop2() const { return _prop2; } + void setprop2(bool p) { _prop2 = p; } + bool _prop3; + bool prop3() const { return _prop3; } + void setprop3(bool p) { _prop3 = p; } +}; + +class MyExtendedUncreateableBaseClassExtension : public QObject +{ + Q_OBJECT + Q_PROPERTY(bool prop4 READ prop4 WRITE setprop4) +public: + explicit MyExtendedUncreateableBaseClassExtension(QObject *parent = 0) + : QObject(parent), _prop4(false) + { + } + + bool _prop4; + bool prop4() const { return _prop4; } + void setprop4(bool p) { _prop4 = p; } +}; + +class MyExtendedCreateableDerivedClass : public MyExtendedUncreateableBaseClass +{ + Q_OBJECT + Q_PROPERTY(bool prop5 READ prop5 WRITE setprop5) + +public: + MyExtendedCreateableDerivedClass(QObject *parent = 0) + : MyExtendedUncreateableBaseClass(parent), _prop5(false) + { + } + + bool _prop5; + bool prop5() const { return _prop5; } + void setprop5(bool p) { _prop5 = p; } +}; + class MyVersion2Class : public QObject { Q_OBJECT diff --git a/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp b/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp index f586f7d429..750c32cc3c 100644 --- a/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp +++ b/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp @@ -189,6 +189,9 @@ private slots: void subclassedUncreateableRevision_data(); void subclassedUncreateableRevision(); + void subclassedExtendedUncreateableRevision_data(); + void subclassedExtendedUncreateableRevision(); + void uncreatableTypesAsProperties(); void propertyInit(); @@ -257,6 +260,9 @@ private slots: void defaultListProperty(); void namespacedPropertyTypes(); + void qmlTypeCanBeResolvedByName_data(); + void qmlTypeCanBeResolvedByName(); + private: QQmlEngine engine; QStringList defaultImportPathList; @@ -3225,6 +3231,62 @@ void tst_qqmllanguage::subclassedUncreateableRevision() delete obj; } +void tst_qqmllanguage::subclassedExtendedUncreateableRevision_data() +{ + QTest::addColumn<QString>("version"); + QTest::addColumn<QString>("prop"); + QTest::addColumn<bool>("shouldWork"); + + QTest::newRow("prop1 exists in 1.0") << "1.0" << "prop1" << true; + QTest::newRow("prop2 does not exist in 1.0") << "1.0" << "prop2" << false; + QTest::newRow("prop3 does not exist in 1.0") << "1.0" << "prop3" << false; + QTest::newRow("prop4 exists in 1.0") << "1.0" << "prop4" << true; + QTest::newRow("prop5 exists in 1.0") << "1.0" << "prop5" << true; + + QTest::newRow("prop1 exists in 1.1") << "1.1" << "prop1" << true; + QTest::newRow("prop2 exists in 1.1") << "1.1" << "prop2" << true; + QTest::newRow("prop3 exists in 1.1") << "1.1" << "prop3" << true; + QTest::newRow("prop4 exists in 1.1") << "1.1" << "prop4" << true; + QTest::newRow("prop5 exists in 1.1") << "1.1" << "prop5" << true; +} + +void tst_qqmllanguage::subclassedExtendedUncreateableRevision() +{ + QFETCH(QString, version); + QFETCH(QString, prop); + QFETCH(bool, shouldWork); + + { + QQmlEngine engine; + QString qml = QString("import QtQuick 2.0\nimport Test %1\nMyExtendedUncreateableBaseClass {}").arg(version); + QQmlComponent c(&engine); + QTest::ignoreMessage(QtWarningMsg, "QQmlComponent: Component is not ready"); + c.setData(qml.toUtf8(), QUrl::fromLocalFile(QDir::currentPath())); + QObject *obj = c.create(); + QCOMPARE(obj, static_cast<QObject*>(0)); + QCOMPARE(c.errors().count(), 1); + QCOMPARE(c.errors().first().description(), QString("Cannot create MyExtendedUncreateableBaseClass")); + } + + QQmlEngine engine; + QString qml = QString("import QtQuick 2.0\nimport Test %1\nMyExtendedCreateableDerivedClass {\n%3: true\n}").arg(version).arg(prop); + QQmlComponent c(&engine); + if (!shouldWork) + QTest::ignoreMessage(QtWarningMsg, "QQmlComponent: Component is not ready"); + c.setData(qml.toUtf8(), QUrl::fromLocalFile(QDir::currentPath())); + QObject *obj = c.create(); + if (!shouldWork) { + QCOMPARE(obj, static_cast<QObject*>(0)); + return; + } + + QVERIFY(obj); + MyExtendedUncreateableBaseClass *base = qobject_cast<MyExtendedUncreateableBaseClass*>(obj); + QVERIFY(base); + QCOMPARE(base->property(prop.toLatin1()).toBool(), true); + delete obj; +} + void tst_qqmllanguage::uncreatableTypesAsProperties() { QQmlEngine engine; @@ -4250,6 +4312,32 @@ void tst_qqmllanguage::namespacedPropertyTypes() QVERIFY(!o.isNull()); } +void tst_qqmllanguage::qmlTypeCanBeResolvedByName_data() +{ + QTest::addColumn<QUrl>("componentUrl"); + + // Built-in C++ types + QTest::newRow("C++ - Anonymous") << testFileUrl("quickTypeByName_anon.qml"); + QTest::newRow("C++ - Named") << testFileUrl("quickTypeByName_named.qml"); + + // Composite types with a qmldir + QTest::newRow("QML - Anonymous - qmldir") << testFileUrl("compositeTypeByName_anon_qmldir.qml"); + QTest::newRow("QML - Named - qmldir") << testFileUrl("compositeTypeByName_named_qmldir.qml"); +} + +void tst_qqmllanguage::qmlTypeCanBeResolvedByName() +{ + QFETCH(QUrl, componentUrl); + + QQmlEngine engine; + QQmlComponent component(&engine, componentUrl); + VERIFY_ERRORS(0); + QTest::ignoreMessage(QtMsgType::QtWarningMsg, "[object Object]"); // a bit crude, but it will do + + QScopedPointer<QObject> o(component.create()); + QVERIFY(!o.isNull()); +} + QTEST_MAIN(tst_qqmllanguage) #include "tst_qqmllanguage.moc" diff --git a/tests/auto/qml/qqmllistreference/data/propertyList.qml b/tests/auto/qml/qqmllistreference/data/propertyList.qml new file mode 100644 index 0000000000..c791c6dcf0 --- /dev/null +++ b/tests/auto/qml/qqmllistreference/data/propertyList.qml @@ -0,0 +1,12 @@ +import QtQuick 2.7 + +Item { + id:root + + Component.onCompleted : { + var st1 = Qt.createQmlObject( "import QtQuick 2.7; State{ name: 'MyState1' }", root, "dynamicState1" ); + var st2 = Qt.createQmlObject( "import QtQuick 2.7; State{ name: 'MyState2' }", root, "dynamicState2" ); + root.states.push( st1, st2 ); + root.state = "MyState2"; + } +} diff --git a/tests/auto/qml/qqmllistreference/qqmllistreference.pro b/tests/auto/qml/qqmllistreference/qqmllistreference.pro index dceb7d1133..110d0d9c81 100644 --- a/tests/auto/qml/qqmllistreference/qqmllistreference.pro +++ b/tests/auto/qml/qqmllistreference/qqmllistreference.pro @@ -8,4 +8,4 @@ include (../../shared/util.pri) TESTDATA = data/* -QT += core-private gui-private qml-private testlib +QT += core-private gui-private quick-private qml-private testlib diff --git a/tests/auto/qml/qqmllistreference/tst_qqmllistreference.cpp b/tests/auto/qml/qqmllistreference/tst_qqmllistreference.cpp index 4d33359eaa..5c16a48378 100644 --- a/tests/auto/qml/qqmllistreference/tst_qqmllistreference.cpp +++ b/tests/auto/qml/qqmllistreference/tst_qqmllistreference.cpp @@ -36,6 +36,7 @@ #include <QtQml/qqmlprivate.h> #include <QtQml/qqmlproperty.h> #include <QDebug> +#include <private/qquickstate_p.h> #include "../../shared/util.h" class tst_qqmllistreference : public QQmlDataTest @@ -65,6 +66,7 @@ private slots: void qmlmetaproperty(); void engineTypes(); void variantToList(); + void listProperty(); }; class TestType : public QObject @@ -618,6 +620,28 @@ void tst_qqmllistreference::variantToList() delete o; } +void tst_qqmllistreference::listProperty() +{ + QQmlEngine engine; + QQmlComponent component(&engine, testFileUrl("propertyList.qml")); + + QScopedPointer<QObject> object( component.create() ); + QVERIFY(object != 0); + + QCOMPARE( object->property("state").toString(), QStringLiteral("MyState2") ); + QQmlListReference list( object.data(), "states"); + QCOMPARE( list.count(), 2 ); + + QQuickState* state1 = dynamic_cast<QQuickState*>( list.at( 0 ) ); + QVERIFY(state1 != 0); + QCOMPARE( state1->name(), QStringLiteral("MyState1") ); + QQuickState* state2 = dynamic_cast<QQuickState*>( list.at( 1 ) ); + QVERIFY(state2 != 0); + + QCOMPARE( state2->name(), QStringLiteral("MyState2") ); +} + + QTEST_MAIN(tst_qqmllistreference) #include "tst_qqmllistreference.moc" diff --git a/tests/auto/qmltest/BLACKLIST b/tests/auto/qmltest/BLACKLIST index fd796fcdb4..c38347b42a 100644 --- a/tests/auto/qmltest/BLACKLIST +++ b/tests/auto/qmltest/BLACKLIST @@ -9,5 +9,3 @@ linux linux [ListView::test_listInteractiveCurrentIndexEnforce] linux -[mouserelease::test_mouseDrag] -rhel-7.2 diff --git a/tests/auto/qmltest/events/tst_drag.qml b/tests/auto/qmltest/events/tst_drag.qml index ffdc94167c..ae77247a41 100644 --- a/tests/auto/qmltest/events/tst_drag.qml +++ b/tests/auto/qmltest/events/tst_drag.qml @@ -117,9 +117,9 @@ Rectangle{ name:"mouserelease" when:windowShown function test_mouseDrag() { - mouseDrag(container, 10, 10, 20, 30); - compare(container.x, 20 - util.dragThreshold - 1); - compare(container.y, 30 - util.dragThreshold - 1); + mouseDrag(container, 10, 10, util.dragThreshold * 2, util.dragThreshold * 3); + compare(container.x, util.dragThreshold - 1); + compare(container.y, util.dragThreshold * 2 - 1); } function test_doSomethingWhileDragging() { diff --git a/tests/auto/qmltest/itemgrabber/tst_itemgrabber.qml b/tests/auto/qmltest/itemgrabber/tst_itemgrabber.qml index 022e98a202..a80814d6de 100644 --- a/tests/auto/qmltest/itemgrabber/tst_itemgrabber.qml +++ b/tests/auto/qmltest/itemgrabber/tst_itemgrabber.qml @@ -37,8 +37,9 @@ Item { TestCase { id: testCase name: "item-grabber" - when: imageOnDisk.ready && imageOnDiskSmall.ready && imageInCache.ready && imageInCacheSmall.ready - function test_endresult() { + when: imageOnDisk.ready && imageOnDiskSmall.ready + + function test_endresult_disk() { var image = grabImage(root); // imageOnDisk at (0, 0) - (100x100) @@ -52,6 +53,40 @@ Item { compare(imageOnDiskSmall.height, 50); verify(image.pixel(100, 0) === Qt.rgba(1, 0, 0, 1)); verify(image.pixel(149, 49) === Qt.rgba(0, 0, 1, 1)); + } + + function test_endresult_cache_data() { + return [ + { cache: true, sourceSize: Qt.size(-1, -1), fillMode: Image.Stretch }, + { cache: true, sourceSize: Qt.size(-1, -1), fillMode: Image.PreserveAspectFit }, + { cache: true, sourceSize: Qt.size(-1, -1), fillMode: Image.PreserveAspectCrop }, + { cache: true, sourceSize: Qt.size(10, 10), fillMode: Image.Stretch }, + { cache: true, sourceSize: Qt.size(10, 10), fillMode: Image.PreserveAspectFit }, + { cache: true, sourceSize: Qt.size(10, 10), fillMode: Image.PreserveAspectCrop }, + { cache: false, sourceSize: Qt.size(-1, -1), fillMode: Image.Stretch }, + { cache: false, sourceSize: Qt.size(-1, -1), fillMode: Image.PreserveAspectFit }, + { cache: false, sourceSize: Qt.size(-1, -1), fillMode: Image.PreserveAspectCrop }, + { cache: false, sourceSize: Qt.size(10, 10), fillMode: Image.Stretch }, + { cache: false, sourceSize: Qt.size(10, 10), fillMode: Image.PreserveAspectFit }, + { cache: false, sourceSize: Qt.size(10, 10), fillMode: Image.PreserveAspectCrop }, + ]; + } + + function test_endresult_cache(data) { + imageInCache.cache = data.cache; + imageInCache.sourceSize = data.sourceSize; + imageInCache.fillMode = data.fillMode; + imageInCacheSmall.cache = data.cache; + imageInCacheSmall.sourceSize = data.sourceSize; + imageInCacheSmall.fillMode = data.fillMode; + + box.grabToImage(imageInCache.handleGrab); + box.grabToImage(imageInCacheSmall.handleGrab, Qt.size(50, 50)); + + tryCompare(imageInCache, "ready", true); + tryCompare(imageInCacheSmall, "ready", true); + + var image = grabImage(root); // imageInCache at (0, 100) - 100x100 compare(imageInCache.width, 100); @@ -72,8 +107,6 @@ Item { onWindowShownChanged: { box.grabToImage(imageOnDisk.handleGrab); box.grabToImage(imageOnDiskSmall.handleGrab, Qt.size(50, 50)); - box.grabToImage(imageInCache.handleGrab); - box.grabToImage(imageInCacheSmall.handleGrab, Qt.size(50, 50)); } } diff --git a/tests/auto/quick/qquickimage/tst_qquickimage.cpp b/tests/auto/quick/qquickimage/tst_qquickimage.cpp index 4699f947a1..2681f1a966 100644 --- a/tests/auto/quick/qquickimage/tst_qquickimage.cpp +++ b/tests/auto/quick/qquickimage/tst_qquickimage.cpp @@ -91,6 +91,8 @@ private slots: void sourceSizeChanges(); void correctStatus(); void highdpi(); + void highDpiFillModesAndSizes_data(); + void highDpiFillModesAndSizes(); void hugeImages(); private: @@ -971,6 +973,65 @@ void tst_qquickimage::highdpi() delete obj; } +void tst_qquickimage::highDpiFillModesAndSizes_data() +{ + QTest::addColumn<QQuickImage::FillMode>("fillMode"); + QTest::addColumn<qreal>("expectedHeightAfterSettingWidthTo100"); + QTest::addColumn<qreal>("expectedImplicitHeightAfterSettingWidthTo100"); + QTest::addColumn<qreal>("expectedPaintedWidthAfterSettingWidthTo100"); + QTest::addColumn<qreal>("expectedPaintedHeightAfterSettingWidthTo100"); + + QTest::addRow("Stretch") << QQuickImage::Stretch << 150.0 << 150.0 << 100.0 << 150.0; + QTest::addRow("PreserveAspectFit") << QQuickImage::PreserveAspectFit << 100.0 << 100.0 << 100.0 << 100.0; + QTest::addRow("PreserveAspectCrop") << QQuickImage::PreserveAspectCrop << 150.0 << 150.0 << 150.0 << 150.0; + QTest::addRow("Tile") << QQuickImage::Tile << 150.0 << 150.0 << 100.0 << 150.0; + QTest::addRow("TileVertically") << QQuickImage::TileVertically << 150.0 << 150.0 << 100.0 << 150.0; + QTest::addRow("TileHorizontally") << QQuickImage::TileHorizontally << 150.0 << 150.0 << 100.0 << 150.0; + QTest::addRow("Pad") << QQuickImage::Pad << 150.0 << 150.0 << 150.0 << 150.0; +} + +void tst_qquickimage::highDpiFillModesAndSizes() +{ + QFETCH(QQuickImage::FillMode, fillMode); + QFETCH(qreal, expectedHeightAfterSettingWidthTo100); + QFETCH(qreal, expectedImplicitHeightAfterSettingWidthTo100); + QFETCH(qreal, expectedPaintedWidthAfterSettingWidthTo100); + QFETCH(qreal, expectedPaintedHeightAfterSettingWidthTo100); + + QString componentStr = "import QtQuick 2.0\nImage { source: srcImage; }"; + QQmlComponent component(&engine); + component.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); + + engine.rootContext()->setContextProperty("srcImage", testFileUrl("heart-highdpi@2x.png")); + + QScopedPointer<QQuickImage> image(qobject_cast<QQuickImage*>(component.create())); + QVERIFY(image); + QCOMPARE(image->width(), 150.0); + QCOMPARE(image->height(), 150.0); + QCOMPARE(image->paintedWidth(), 150.0); + QCOMPARE(image->paintedHeight(), 150.0); + QCOMPARE(image->implicitWidth(), 150.0); + QCOMPARE(image->implicitHeight(), 150.0); + QCOMPARE(image->paintedWidth(), 150.0); + QCOMPARE(image->paintedHeight(), 150.0); + + // The implicit size should not change when setting any fillMode here. + image->setFillMode(fillMode); + QCOMPARE(image->fillMode(), fillMode); + QCOMPARE(image->implicitWidth(), 150.0); + QCOMPARE(image->implicitHeight(), 150.0); + QCOMPARE(image->paintedWidth(), 150.0); + QCOMPARE(image->paintedHeight(), 150.0); + + image->setWidth(100.0); + QCOMPARE(image->width(), 100.0); + QCOMPARE(image->height(), expectedHeightAfterSettingWidthTo100); + QCOMPARE(image->implicitWidth(), 150.0); + QCOMPARE(image->implicitHeight(), expectedImplicitHeightAfterSettingWidthTo100); + QCOMPARE(image->paintedWidth(), expectedPaintedWidthAfterSettingWidthTo100); + QCOMPARE(image->paintedHeight(), expectedPaintedHeightAfterSettingWidthTo100); +} + void tst_qquickimage::hugeImages() { QQuickView view; diff --git a/tests/auto/quick/qquickitem/tst_qquickitem.cpp b/tests/auto/quick/qquickitem/tst_qquickitem.cpp index 8d974f4d17..10a3a0bfa8 100644 --- a/tests/auto/quick/qquickitem/tst_qquickitem.cpp +++ b/tests/auto/quick/qquickitem/tst_qquickitem.cpp @@ -48,7 +48,8 @@ public: TestItem(QQuickItem *parent = 0) : QQuickItem(parent), focused(false), pressCount(0), releaseCount(0) , wheelCount(0), acceptIncomingTouchEvents(true) - , touchEventReached(false), timestamp(0) {} + , touchEventReached(false), timestamp(0) + , lastWheelEventPos(0, 0), lastWheelEventGlobalPos(0, 0) {} bool focused; int pressCount; @@ -57,6 +58,8 @@ public: bool acceptIncomingTouchEvents; bool touchEventReached; ulong timestamp; + QPoint lastWheelEventPos; + QPoint lastWheelEventGlobalPos; protected: virtual void focusInEvent(QFocusEvent *) { Q_ASSERT(!focused); focused = true; } virtual void focusOutEvent(QFocusEvent *) { Q_ASSERT(focused); focused = false; } @@ -66,7 +69,13 @@ protected: touchEventReached = true; event->setAccepted(acceptIncomingTouchEvents); } - virtual void wheelEvent(QWheelEvent *event) { event->accept(); ++wheelCount; timestamp = event->timestamp(); } + virtual void wheelEvent(QWheelEvent *event) { + event->accept(); + ++wheelCount; + timestamp = event->timestamp(); + lastWheelEventPos = event->pos(); + lastWheelEventGlobalPos = event->globalPos(); + } }; class TestWindow: public QQuickWindow @@ -1422,19 +1431,24 @@ void tst_qquickitem::wheelEvent() const bool shouldReceiveWheelEvents = visible && enabled; + const int width = 200; + const int height = 200; + QQuickWindow window; - window.resize(200, 200); + window.resize(width, height); window.show(); QTest::qWaitForWindowExposed(&window); TestItem *item = new TestItem; - item->setSize(QSizeF(200, 100)); + item->setSize(QSizeF(width, height)); item->setParentItem(window.contentItem()); item->setEnabled(enabled); item->setVisible(visible); - QWheelEvent event(QPoint(100, 50), -120, Qt::NoButton, Qt::NoModifier, Qt::Vertical); + QPoint localPoint(width / 2, height / 2); + QPoint globalPoint = window.mapToGlobal(localPoint); + QWheelEvent event(localPoint, globalPoint, -120, Qt::NoButton, Qt::NoModifier, Qt::Vertical); event.setTimestamp(123456UL); event.setAccepted(false); QGuiApplication::sendEvent(&window, &event); @@ -1443,6 +1457,8 @@ void tst_qquickitem::wheelEvent() QVERIFY(event.isAccepted()); QCOMPARE(item->wheelCount, 1); QCOMPARE(item->timestamp, 123456UL); + QCOMPARE(item->lastWheelEventPos, localPoint); + QCOMPARE(item->lastWheelEventGlobalPos, globalPoint); } else { QVERIFY(!event.isAccepted()); QCOMPARE(item->wheelCount, 0); diff --git a/tests/auto/quick/qquicklayouts/data/rowlayout/Container2.qml b/tests/auto/quick/qquicklayouts/data/rowlayout/Container2.qml new file mode 100644 index 0000000000..248652e82b --- /dev/null +++ b/tests/auto/quick/qquicklayouts/data/rowlayout/Container2.qml @@ -0,0 +1,55 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of The Qt Company Ltd nor the names of its +** contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.9 +import QtQuick.Layouts 1.3 + +Item { + objectName: "qtbug51927-container" + visible: true + + default property alias _contents: customContent.data + + ColumnLayout { + id: customContent + objectName: "qtbug51927-columnLayout" + anchors.fill: parent + } +} diff --git a/tests/auto/quick/qquicklayouts/data/rowlayout/ContainerUser2.qml b/tests/auto/quick/qquicklayouts/data/rowlayout/ContainerUser2.qml new file mode 100644 index 0000000000..9def782d4a --- /dev/null +++ b/tests/auto/quick/qquicklayouts/data/rowlayout/ContainerUser2.qml @@ -0,0 +1,46 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of The Qt Company Ltd nor the names of its +** contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.6 + +Container2 { + visible: true + Item {} +} diff --git a/tests/auto/quick/qquicklayouts/data/tst_rowlayout.qml b/tests/auto/quick/qquicklayouts/data/tst_rowlayout.qml index 97860458fe..4346c5283e 100644 --- a/tests/auto/quick/qquicklayouts/data/tst_rowlayout.qml +++ b/tests/auto/quick/qquicklayouts/data/tst_rowlayout.qml @@ -959,5 +959,15 @@ Item { // Shouldn't crash. containerUser.destroy(); } + + function test_defaultPropertyAliasCrashAgain() { + var containerUserComponent = Qt.createComponent("rowlayout/ContainerUser2.qml"); + compare(containerUserComponent.status, Component.Ready); + + var containerUser = createTemporaryObject(containerUserComponent, testCase); + verify(containerUser); + + // Shouldn't crash upon destroying containerUser. + } } } diff --git a/tests/auto/quick/qquicklayouts/data/tst_stacklayout.qml b/tests/auto/quick/qquicklayouts/data/tst_stacklayout.qml new file mode 100644 index 0000000000..8234ac6ef7 --- /dev/null +++ b/tests/auto/quick/qquicklayouts/data/tst_stacklayout.qml @@ -0,0 +1,107 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, you may use this file under the terms of the BSD license +** as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of The Qt Company Ltd nor the names of its +** contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.2 +import QtTest 1.0 +import QtQuick.Layouts 1.3 + +Item { + id: container + width: 200 + height: 200 + TestCase { + id: testCase + name: "Tests_StackLayout" + when: windowShown + width: 200 + height: 200 + + Component { + id: layout_rearrange_Component + + StackLayout { + width: 640 + height: 480 + + property alias testRectangle: testRectangle + + RowLayout { + spacing: 0 + + Rectangle { + Layout.preferredWidth: 100 + Layout.preferredHeight: 100 + } + + Rectangle { + id: testRectangle + Layout.preferredWidth: 100 + Layout.preferredHeight: 100 + visible: false + } + + Item { + Layout.fillWidth: true + } + } + } + } + + function test_rearrange() + { + var layout = layout_rearrange_Component.createObject(container) + compare(layout.testRectangle.x, 0) + layout.testRectangle.visible = true + tryCompare(layout.testRectangle, "x", 100) + + layout.destroy() + } + } +} diff --git a/tests/auto/quick/qquicklayouts/qquicklayouts.pro b/tests/auto/quick/qquicklayouts/qquicklayouts.pro index 9ed3e076be..5079d0a182 100644 --- a/tests/auto/quick/qquicklayouts/qquicklayouts.pro +++ b/tests/auto/quick/qquicklayouts/qquicklayouts.pro @@ -9,5 +9,6 @@ TESTDATA = data/* OTHER_FILES += \ data/tst_rowlayout.qml \ - data/tst_gridlayout.qml + data/tst_gridlayout.qml \ + data/tst_stacklayout.qml diff --git a/tests/auto/quick/qquickloader/tst_qquickloader.cpp b/tests/auto/quick/qquickloader/tst_qquickloader.cpp index 77af4796b6..3e7439f3e9 100644 --- a/tests/auto/quick/qquickloader/tst_qquickloader.cpp +++ b/tests/auto/quick/qquickloader/tst_qquickloader.cpp @@ -469,7 +469,7 @@ void tst_QQuickLoader::networkComponent() // because in the synchronous case we're already done loading. QTRY_COMPARE(component.status(), QQmlComponent::Ready); - QQuickItem *item = qobject_cast<QQuickItem*>(component.create()); + QScopedPointer<QQuickItem> item(qobject_cast<QQuickItem*>(component.create())); QVERIFY(item); QQuickLoader *loader = qobject_cast<QQuickLoader*>(item->children().at(1)); @@ -481,7 +481,6 @@ void tst_QQuickLoader::networkComponent() QCOMPARE(loader->status(), QQuickLoader::Ready); QCOMPARE(static_cast<QQuickItem*>(loader)->children().count(), 1); - delete loader; } void tst_QQuickLoader::failNetworkRequest() diff --git a/tests/auto/quick/qquickpositioners/data/implicitGridOneItem.qml b/tests/auto/quick/qquickpositioners/data/implicitGridOneItem.qml new file mode 100644 index 0000000000..8da9fc270d --- /dev/null +++ b/tests/auto/quick/qquickpositioners/data/implicitGridOneItem.qml @@ -0,0 +1,12 @@ +import QtQuick 2.9 +import PositionerTest 1.0 + +ImplicitGrid { + columns: 2 + rows: 1 + + Text { + text: "Text" + width: parent.width + } +} diff --git a/tests/auto/quick/qquickpositioners/data/implicitRowOneItem.qml b/tests/auto/quick/qquickpositioners/data/implicitRowOneItem.qml new file mode 100644 index 0000000000..25a287cf31 --- /dev/null +++ b/tests/auto/quick/qquickpositioners/data/implicitRowOneItem.qml @@ -0,0 +1,9 @@ +import QtQuick 2.9 +import PositionerTest 1.0 + +ImplicitRow { + Text { + text: "Text" + width: parent.width + } +} diff --git a/tests/auto/quick/qquickpositioners/tst_qquickpositioners.cpp b/tests/auto/quick/qquickpositioners/tst_qquickpositioners.cpp index 1b3939401a..4c4afb7a7b 100644 --- a/tests/auto/quick/qquickpositioners/tst_qquickpositioners.cpp +++ b/tests/auto/quick/qquickpositioners/tst_qquickpositioners.cpp @@ -98,6 +98,8 @@ private slots: void test_attachedproperties(); void test_attachedproperties_data(); void test_attachedproperties_dynamic(); + void test_useImplicitSize_oneItem_data(); + void test_useImplicitSize_oneItem(); void populateTransitions_row(); void populateTransitions_row_data(); @@ -304,6 +306,8 @@ void tst_qquickpositioners::moveTransitions_flow_data() tst_qquickpositioners::tst_qquickpositioners() { + qmlRegisterType<QQuickImplicitRow>("PositionerTest", 1, 0, "ImplicitRow"); + qmlRegisterType<QQuickImplicitGrid>("PositionerTest", 1, 0, "ImplicitGrid"); } void tst_qquickpositioners::test_horizontal() @@ -4004,6 +4008,46 @@ void tst_qquickpositioners::test_attachedproperties_dynamic() } +void tst_qquickpositioners::test_useImplicitSize_oneItem_data() +{ + QTest::addColumn<QString>("positionerType"); + + QTest::newRow("Grid") << "Grid"; + QTest::newRow("Row") << "Row"; +} + +void tst_qquickpositioners::test_useImplicitSize_oneItem() +{ + QFETCH(QString, positionerType); + + QQuickView view; + view.setSource(testFileUrl(QString::fromLatin1("implicit%1OneItem.qml").arg(positionerType))); + QCOMPARE(view.status(), QQuickView::Ready); + view.show(); + QVERIFY(QTest::qWaitForWindowExposed(&view)); + + QQuickItem *positioner = view.rootObject(); + QVERIFY(positioner); + const qreal oldPositionerImplicitWidth = positioner->implicitWidth(); + + QQuickText *text = qobject_cast<QQuickText*>(positioner->childItems().first()); + QVERIFY(text); + const qreal oldTextImplicitWidth = text->implicitWidth(); + QCOMPARE(positioner->implicitWidth(), text->implicitWidth()); + + // Ensure that the implicit size of the positioner changes when the implicit size + // of one of its children changes. + text->setText(QLatin1String("Even More Text")); + const qreal textImplicitWidthIncrease = text->implicitWidth() - oldTextImplicitWidth; + QVERIFY(textImplicitWidthIncrease > 0); + QTRY_COMPARE(positioner->implicitWidth(), oldPositionerImplicitWidth + textImplicitWidthIncrease); + + // Ensure that the implicit size of the positioner does not change when the + // explicit size of one of its children changes. + text->setWidth(10); + QTRY_COMPARE(positioner->implicitWidth(), oldPositionerImplicitWidth + textImplicitWidthIncrease); +} + QQuickView *tst_qquickpositioners::createView(const QString &filename, bool wait) { QQuickView *window = new QQuickView(0); diff --git a/tests/auto/quick/qquicktext/data/fontInfo.qml b/tests/auto/quick/qquicktext/data/fontInfo.qml new file mode 100644 index 0000000000..25f924029f --- /dev/null +++ b/tests/auto/quick/qquicktext/data/fontInfo.qml @@ -0,0 +1,24 @@ +import QtQuick 2.9 + +Item { + Text { + id: main + objectName: "main" + width: 500 + height: 500 + text: "Meaningless text" + font.pixelSize: 1000 + fontSizeMode: Text.Fit + } + + Text { + objectName: "copy" + text: main.text + width: main.width + height: main.height + + font.family: main.fontInfo.family + font.pixelSize: main.fontInfo.pixelSize + } +} + diff --git a/tests/auto/quick/qquicktext/tst_qquicktext.cpp b/tests/auto/quick/qquicktext/tst_qquicktext.cpp index 034ea4aec8..f741062d42 100644 --- a/tests/auto/quick/qquicktext/tst_qquicktext.cpp +++ b/tests/auto/quick/qquicktext/tst_qquicktext.cpp @@ -154,6 +154,8 @@ private slots: void hAlignWidthDependsOnImplicitWidth_data(); void hAlignWidthDependsOnImplicitWidth(); + void fontInfo(); + private: QStringList standard; QStringList richText; @@ -4253,6 +4255,23 @@ void tst_qquicktext::hAlignWidthDependsOnImplicitWidth() QCOMPARE(numberOfNonWhitePixels(0, rectX - 1, image), 0); } +void tst_qquicktext::fontInfo() +{ + QQmlComponent component(&engine, testFile("fontInfo.qml")); + + QScopedPointer<QObject> object(component.create()); + QObject *root = object.data(); + + QQuickText *main = root->findChild<QQuickText *>("main"); + QVERIFY(main); + QCOMPARE(main->font().pixelSize(), 1000); + + QQuickText *copy = root->findChild<QQuickText *>("copy"); + QVERIFY(copy); + QCOMPARE(copy->font().family(), QFontInfo(QFont()).family()); + QVERIFY(copy->font().pixelSize() < 1000); +} + QTEST_MAIN(tst_qquicktext) #include "tst_qquicktext.moc" diff --git a/tests/auto/quick/qquickwindow/data/windowWithScreen.qml b/tests/auto/quick/qquickwindow/data/windowWithScreen.qml index fdc0be3388..2a5a7b7b76 100644 --- a/tests/auto/quick/qquickwindow/data/windowWithScreen.qml +++ b/tests/auto/quick/qquickwindow/data/windowWithScreen.qml @@ -3,7 +3,7 @@ import QtQuick.Window 2.3 as Window Window.Window { color: "#00FF00" - targetScreen: Qt.application.screens[0] + screen: Qt.application.screens[0] Item { objectName: "item" } diff --git a/tests/auto/quick/qquickwindow/tst_qquickwindow.cpp b/tests/auto/quick/qquickwindow/tst_qquickwindow.cpp index dd00154935..cd503a88d4 100644 --- a/tests/auto/quick/qquickwindow/tst_qquickwindow.cpp +++ b/tests/auto/quick/qquickwindow/tst_qquickwindow.cpp @@ -1348,12 +1348,6 @@ void tst_qquickwindow::headless() if (isGL) QVERIFY(!window->isSceneGraphInitialized()); } -#if QT_CONFIG(opengl) - if (QGuiApplication::platformName() == QLatin1String("windows") - && QOpenGLContext::openGLModuleType() == QOpenGLContext::LibGLES) { - QSKIP("Crashes on Windows/ANGLE, QTBUG-42967"); - } -#endif // Destroy the native windowing system buffers window->destroy(); QVERIFY(!window->handle()); diff --git a/tests/benchmarks/qml/creation/tst_creation.cpp b/tests/benchmarks/qml/creation/tst_creation.cpp index 9fc67ada71..c0907b5dd1 100644 --- a/tests/benchmarks/qml/creation/tst_creation.cpp +++ b/tests/benchmarks/qml/creation/tst_creation.cpp @@ -385,7 +385,7 @@ void tst_creation::bindings_qml() return; } - QQuickItem *obj = dynamic_cast<QQuickItem *>(component.create()); + QQuickItem *obj = qobject_cast<QQuickItem *>(component.create()); QVERIFY(obj != nullptr); int height = 0; @@ -407,7 +407,7 @@ void tst_creation::bindings_parent_qml() return; } - QQuickItem *obj = dynamic_cast<QQuickItem *>(component.create()); + QQuickItem *obj = qobject_cast<QQuickItem *>(component.create()); QVERIFY(obj != nullptr); int height = 0; diff --git a/tests/manual/v4/TestExpectations b/tests/manual/v4/TestExpectations index 49f107452a..27498de473 100644 --- a/tests/manual/v4/TestExpectations +++ b/tests/manual/v4/TestExpectations @@ -29,3 +29,150 @@ Sbp_12.5_A9_T3 failing Sbp_12.6.1_A13_T3 failing Sbp_12.6.2_A13_T3 failing Sbp_12.6.4_A13_T3 failing + +# es6: function length attributes are configurable, wasn't in es5 +S15.1.2.2_A9.2 failing +S15.1.3.1_A5.2 failing +S15.1.3.2_A5.2 failing +S15.1.3.3_A5.2 failing +S15.1.2.3_A7.2 failing +S15.1.2.4_A2.2 failing +S15.1.2.5_A2.2 failing +S15.1.3.4_A5.2 failing +15.2.3.3-4-186 failing +S15.2.4.2_A9 failing +S15.2.4.3_A9 failing +S15.2.4.4_A9 failing +S15.2.4.5_A9 failing +S15.2.4.6_A9 failing +S15.2.4.7_A9 failing +15.3.3.2-1 failing +15.4.4.2_A4.2 +S15.3.4.2_A9 failing +S15.3.4.3_A9 failing +S15.3.4.4_A9 failing +15.3.4.5-15-2 failing +S15.4.4.2_A4.2 failing +S15.4.4.3_A4.2 failing +S15.4.4.4_A4.2 failing +S15.4.4.5_A6.2 failing +S15.4.4.6_A5.2 failing +S15.4.4.7_A6.2 failing +S15.4.4.8_A5.2 failing +S15.4.4.9_A5.2 failing +S15.4.4.10_A5.2 failing +S15.4.4.11_A7.2 failing +S15.4.4.12_A5.2 failing +S15.4.4.13_A5.2 failing +S15.5.4.10_A9 failing +S15.5.4.11_A9 failing +S15.5.4.12_A9 failing +S15.5.4.13_A9 failing +S15.5.4.14_A9 failing +S15.5.4.15_A9 failing +S15.5.4.16_A9 failing +S15.5.4.17_A9 failing +S15.5.4.18_A9 failing +S15.5.4.19_A9 failing +S15.5.4.4_A9 failing +S15.5.4.5_A9 failing +S15.5.4.6_A9 failing +S15.5.4.7_A9 failing +S15.5.4.8_A9 failing +S15.5.4.9_A9 failing +S15.9.4.2_A3_T2 failing +S15.9.4.3_A3_T2 failing +S15.9.5.2_A3_T2 failing +S15.9.5.3_A3_T2 failing +S15.9.5.4_A3_T2 failing +S15.9.5.5_A3_T2 failing +S15.9.5.1_A3_T2 failing +S15.9.5.10_A3_T2 failing +S15.9.5.11_A3_T2 failing +S15.9.5.12_A3_T2 failing +S15.9.5.13_A3_T2 failing +S15.9.5.14_A3_T2 failing +S15.9.5.15_A3_T2 failing +S15.9.5.16_A3_T2 failing +S15.9.5.17_A3_T2 failing +S15.9.5.18_A3_T2 failing +S15.9.5.19_A3_T2 failing +S15.9.5.20_A3_T2 failing +S15.9.5.21_A3_T2 failing +S15.9.5.22_A3_T2 failing +S15.9.5.23_A3_T2 failing +S15.9.5.24_A3_T2 failing +S15.9.5.25_A3_T2 failing +S15.9.5.26_A3_T2 failing +S15.9.5.27_A3_T2 failing +S15.9.5.28_A3_T2 failing +S15.9.5.29_A3_T2 failing +S15.9.5.30_A3_T2 failing +S15.9.5.31_A3_T2 failing +S15.9.5.32_A3_T2 failing +S15.9.5.33_A3_T2 failing +S15.9.5.34_A3_T2 failing +S15.9.5.35_A3_T2 failing +S15.9.5.36_A3_T2 failing +S15.9.5.37_A3_T2 failing +S15.9.5.38_A3_T2 failing +S15.9.5.39_A3_T2 failing +S15.9.5.40_A3_T2 failing +S15.9.5.41_A3_T2 failing +S15.9.5.42_A3_T2 failing +S15.9.5.6_A3_T2 failing +S15.9.5.7_A3_T2 failing +S15.9.5.8_A3_T2 failing +S15.9.5.9_A3_T2 failing +S15.10.6.2_A9 failing +S15.10.6.3_A9 failing +S15.10.6.4_A9 failing + +# es6: Object.freeze(v) on a non-object returns v, no longer TypeError +15.2.3.9-1 failing +15.2.3.9-1-1 failing +15.2.3.9-1-2 failing +15.2.3.9-1-3 failing +15.2.3.9-1-4 failing +# es6: Object.preventExtensions(O) on a non-object, no longer TypeError +15.2.3.10-1 failing +15.2.3.10-1-3 failing +15.2.3.10-1-4 failing +# es6: Object.isSealed(O) on a non-object, no longer TypeError +15.2.3.11-1 +# es6: Object.isFrozen(O) on a non-object, no longer TypeError +15.2.3.12-1 +15.2.3.12-1-3 +15.2.3.12-1-4 +# es6: Object.isExtensible(O) on a non-object, no longer TypeError +15.2.3.13-1 +15.2.3.13-1-3 +15.2.3.13-1-4 +# es6: Object.keys(O) on a non-object, no longer TypeError +15.2.3.14-1-1 +15.2.3.14-1-2 +15.2.3.14-1-3 +15.2.3.14-1 +15.2.3.14-2 +15.2.3.14-3 +# es6: Object.getOwnPropertyDescriptor(O) on a non-object, no longer TypeError +15.2.3.3-1 +15.2.3.3-1-3 +15.2.3.3-1-4 +# es6: Object.getPrototypeOf(O) on a non-object, no longer TypeError +15.2.3.2-1 +15.2.3.2-1-3 +15.2.3.2-1-4 +# es6: Object.getOwnPropertyNames(O) on a non-object, no longer TypeError +15.2.3.4-1 +15.2.3.4-1-4 +15.2.3.4-1-5 +# es6: Object.seal(O) on a non-object, no longer TypeError +15.2.3.8-1 +15.2.3.8-1-1 +15.2.3.8-1-2 +15.2.3.8-1-3 +15.2.3.8-1-4 + +# es6: Date.prototype is no longer a DateObject +15.9.5.40_1 failing |