diff options
author | Qt Forward Merge Bot <qt_forward_merge_bot@qt-project.org> | 2018-11-20 01:00:07 +0100 |
---|---|---|
committer | Qt Forward Merge Bot <qt_forward_merge_bot@qt-project.org> | 2018-11-20 01:00:08 +0100 |
commit | 6fb7a51ab4cd38622b0f6a11bca0300782e7f09c (patch) | |
tree | 0e9d86289b179a0a4bcd818d0c906fb71ed24dd7 /tests | |
parent | 722fd8b86e7c3b5d6e4c3382f2710e4d3bfed3ec (diff) | |
parent | a54e15bc7968a546fc939fc2d166261fd6513d5a (diff) |
Merge remote-tracking branch 'origin/5.12' into dev
Change-Id: I57de61b259423a8351ad146a2ff42488ba11d607
Diffstat (limited to 'tests')
5 files changed, 89 insertions, 5 deletions
diff --git a/tests/auto/qml/qqmlpropertycache/data/foreignEnums.qml b/tests/auto/qml/qqmlpropertycache/data/foreignEnums.qml new file mode 100644 index 0000000000..7ceb231c8d --- /dev/null +++ b/tests/auto/qml/qqmlpropertycache/data/foreignEnums.qml @@ -0,0 +1,11 @@ +import QtQml 2.2 +import example 1.0 + +QtObject { + Component.onCompleted: { + var opt1 = MyEnum.Option1A | MyEnum.Option1D // 0x09 + mydata.opt1 = opt1; + mydata.setOpt1(opt1); + mydata.setOption1(opt1); + } +} diff --git a/tests/auto/qml/qqmlpropertycache/qqmlpropertycache.pro b/tests/auto/qml/qqmlpropertycache/qqmlpropertycache.pro index 9a04c899fe..26d41bbdbf 100644 --- a/tests/auto/qml/qqmlpropertycache/qqmlpropertycache.pro +++ b/tests/auto/qml/qqmlpropertycache/qqmlpropertycache.pro @@ -4,4 +4,8 @@ macx:CONFIG -= app_bundle SOURCES += tst_qqmlpropertycache.cpp +include (../../shared/util.pri) + +TESTDATA = data/* + QT += core-private gui-private qml-private testlib diff --git a/tests/auto/qml/qqmlpropertycache/tst_qqmlpropertycache.cpp b/tests/auto/qml/qqmlpropertycache/tst_qqmlpropertycache.cpp index 29f70c4e46..1c8e3c50ab 100644 --- a/tests/auto/qml/qqmlpropertycache/tst_qqmlpropertycache.cpp +++ b/tests/auto/qml/qqmlpropertycache/tst_qqmlpropertycache.cpp @@ -29,12 +29,14 @@ #include <qtest.h> #include <private/qqmlpropertycache_p.h> #include <QtQml/qqmlengine.h> +#include <QtQml/qqmlcontext.h> +#include <QtQml/qqmlcomponent.h> #include <private/qv8engine_p.h> #include <private/qmetaobjectbuilder_p.h> #include <QCryptographicHash> #include "../../shared/util.h" -class tst_qqmlpropertycache : public QObject +class tst_qqmlpropertycache : public QQmlDataTest { Q_OBJECT public: @@ -47,6 +49,7 @@ private slots: void methodsDerived(); void signalHandlers(); void signalHandlersDerived(); + void passForeignEnums(); void metaObjectSize_data(); void metaObjectSize(); void metaObjectChecksum(); @@ -271,6 +274,70 @@ void tst_qqmlpropertycache::signalHandlersDerived() QCOMPARE(data->coreIndex(), metaObject->indexOfMethod("propertyDChanged()")); } +class MyEnum : public QObject + { + Q_OBJECT + public: + enum Option1Flag { + Option10 = 0, + Option1A = 1, + Option1B = 2, + Option1C = 4, + Option1D = 8, + Option1E = 16, + Option1F = 32, + Option1AD = Option1A | Option1D, + }; + Q_DECLARE_FLAGS(Option1, Option1Flag) + Q_FLAG(Option1) +}; + +class MyData : public QObject +{ + Q_OBJECT + Q_PROPERTY(MyEnum::Option1 opt1 READ opt1 WRITE setOpt1 NOTIFY opt1Changed) +public: + MyEnum::Option1 opt1() const { return m_opt1; } + +signals: + void opt1Changed(MyEnum::Option1 opt1); + +public slots: + void setOpt1(MyEnum::Option1 opt1) + { + QCOMPARE(opt1, MyEnum::Option1AD); + if (opt1 != m_opt1) { + m_opt1 = opt1; + emit opt1Changed(opt1); + } + } + + void setOption1(MyEnum::Option1 opt1) { setOpt1(opt1); } + +private: + MyEnum::Option1 m_opt1 = MyEnum::Option10; +}; + +void tst_qqmlpropertycache::passForeignEnums() +{ + qmlRegisterType<MyEnum>("example", 1, 0, "MyEnum"); + qmlRegisterType<MyData>("example", 1, 0, "MyData"); + + MyEnum myenum; + MyData data; + + engine.rootContext()->setContextProperty("myenum", &myenum); + engine.rootContext()->setContextProperty("mydata", &data); + + QQmlComponent component(&engine, testFile("foreignEnums.qml")); + QVERIFY(component.isReady()); + + QObject *obj = component.create(engine.rootContext()); + QCOMPARE(data.opt1(), MyEnum::Option1AD); +} + +Q_DECLARE_METATYPE(MyEnum::Option1) + class TestClass : public QObject { Q_OBJECT diff --git a/tests/auto/qml/v4misc/tst_v4misc.cpp b/tests/auto/qml/v4misc/tst_v4misc.cpp index c35f412870..5aac91aae9 100644 --- a/tests/auto/qml/v4misc/tst_v4misc.cpp +++ b/tests/auto/qml/v4misc/tst_v4misc.cpp @@ -116,6 +116,8 @@ void tst_v4misc::parserMisc_data() QTest::newRow("[1]=7[A=8=9]") << QString("ReferenceError: left-hand side of assignment operator is not an lvalue"); QTest::newRow("var asmvalsLen = asmvals{{{{{ngth}}}}};") << QString("SyntaxError: Expected token `;'"); QTest::newRow("T||9[---L6i]") << QString("ReferenceError: Prefix ++ operator applied to value that is not a reference."); + QTest::newRow("a?b:[---Hi]") << QString("ReferenceError: Prefix ++ operator applied to value that is not a reference."); + QTest::newRow("[``]=1") << QString("ReferenceError: Binding target is not a reference."); } void tst_v4misc::parserMisc() diff --git a/tests/auto/qmltest/itemgrabber/tst_itemgrabber.qml b/tests/auto/qmltest/itemgrabber/tst_itemgrabber.qml index af1b4db0e0..f7e708e7aa 100644 --- a/tests/auto/qmltest/itemgrabber/tst_itemgrabber.qml +++ b/tests/auto/qmltest/itemgrabber/tst_itemgrabber.qml @@ -49,8 +49,8 @@ Item { // imageOnDisk at (0, 0) - (100x100) compare(imageOnDisk.width, 100); compare(imageOnDisk.height, 100); - verify(image.pixel(0, 0) === Qt.rgba(1, 0, 0, 1)); // Use verify because compare doesn't support colors (QTBUG-34878) - verify(image.pixel(99, 99) === Qt.rgba(0, 0, 1, 1)); + compare(image.pixel(0, 0), Qt.rgba(1, 0, 0, 1)); + compare(image.pixel(99, 99), Qt.rgba(0, 0, 1, 1)); // imageOnDiskSmall at (100, 0) - 50x50 compare(imageOnDiskSmall.width, 50); @@ -99,8 +99,8 @@ Item { // imageInCache at (0, 100) - 100x100 compare(imageInCache.width, 100); compare(imageInCache.height, 100); - verify(image.pixel(0, 100) === Qt.rgba(1, 0, 0, 1)); - verify(image.pixel(99, 199) === Qt.rgba(0, 0, 1, 1)); + compare(image.pixel(0, 100), Qt.rgba(1, 0, 0, 1)); + compare(image.pixel(99, 199), Qt.rgba(0, 0, 1, 1)); // imageInCacheSmall at (100, 100) - 50x50 compare(imageInCacheSmall.width, 50); |