diff options
author | Qt Forward Merge Bot <qt_forward_merge_bot@qt-project.org> | 2019-02-16 01:03:22 +0100 |
---|---|---|
committer | Qt Forward Merge Bot <qt_forward_merge_bot@qt-project.org> | 2019-02-16 01:03:22 +0100 |
commit | 7d80264fa7fc71bc68ed091ff8ba97bdd7970dc4 (patch) | |
tree | e3d6878189a6079dd61cde0b20f7f10cc4d1ffb0 /tests/auto/qml | |
parent | 27c0e9d709aba97bd522fd3e53a53c4ff3c4d71b (diff) | |
parent | fee0fcfef08a05ed4ba9369d2352c876b514d69c (diff) |
Merge remote-tracking branch 'origin/5.13' into dev
Change-Id: I51cb42d253a83c0e6a76946c37cf1ff7c7cac150
Diffstat (limited to 'tests/auto/qml')
m--------- | tests/auto/qml/ecmascripttests/test262 | 0 | ||||
-rw-r--r-- | tests/auto/qml/qqmlapplicationengine/testapp/delayedExit.qml | 11 | ||||
-rw-r--r-- | tests/auto/qml/qqmlapplicationengine/testapp/delayedQuit.qml (renamed from tests/auto/qml/qqmlapplicationengine/testapp/main.qml) | 0 | ||||
-rw-r--r-- | tests/auto/qml/qqmlapplicationengine/testapp/immediateExit.qml | 8 | ||||
-rw-r--r-- | tests/auto/qml/qqmlapplicationengine/testapp/immediateQuit.qml | 8 | ||||
-rw-r--r-- | tests/auto/qml/qqmlapplicationengine/testapp/main.cpp | 2 | ||||
-rw-r--r-- | tests/auto/qml/qqmlapplicationengine/testapp/main.qrc | 5 | ||||
-rw-r--r-- | tests/auto/qml/qqmlapplicationengine/tst_qqmlapplicationengine.cpp | 44 | ||||
-rw-r--r-- | tests/auto/qml/qqmlconnections/data/override-proxy-type.qml | 13 | ||||
-rw-r--r-- | tests/auto/qml/qqmlconnections/tst_qqmlconnections.cpp | 25 | ||||
-rw-r--r-- | tests/auto/qml/qqmlpropertycache/data/passQGadget.qml | 12 | ||||
-rw-r--r-- | tests/auto/qml/qqmlpropertycache/tst_qqmlpropertycache.cpp | 39 |
12 files changed, 154 insertions, 13 deletions
diff --git a/tests/auto/qml/ecmascripttests/test262 b/tests/auto/qml/ecmascripttests/test262 -Subproject 3c69133cc419840c1be34638039cd8c48a7ef58 +Subproject 6b0c42c63c2492bd0a7a96d3179d122b5f71793 diff --git a/tests/auto/qml/qqmlapplicationengine/testapp/delayedExit.qml b/tests/auto/qml/qqmlapplicationengine/testapp/delayedExit.qml new file mode 100644 index 0000000000..3d67c958bb --- /dev/null +++ b/tests/auto/qml/qqmlapplicationengine/testapp/delayedExit.qml @@ -0,0 +1,11 @@ +import QtQml 2.0 + +QtObject { + id: root + property Timer t: Timer { interval: 1; running: true; onTriggered: Qt.exit(0); } + property Connections c: Connections { + target: Qt.application + onAboutToQuit: console.log("End"); + } + Component.onCompleted: console.log("Start: " + Qt.application.arguments[1]); +} diff --git a/tests/auto/qml/qqmlapplicationengine/testapp/main.qml b/tests/auto/qml/qqmlapplicationengine/testapp/delayedQuit.qml index c75485a7f7..c75485a7f7 100644 --- a/tests/auto/qml/qqmlapplicationengine/testapp/main.qml +++ b/tests/auto/qml/qqmlapplicationengine/testapp/delayedQuit.qml diff --git a/tests/auto/qml/qqmlapplicationengine/testapp/immediateExit.qml b/tests/auto/qml/qqmlapplicationengine/testapp/immediateExit.qml new file mode 100644 index 0000000000..46634f3f51 --- /dev/null +++ b/tests/auto/qml/qqmlapplicationengine/testapp/immediateExit.qml @@ -0,0 +1,8 @@ +import QtQml 2.0 + +QtObject { + Component.onCompleted: { + console.log("End: " + Qt.application.arguments[1]); + Qt.exit(0) + } +} diff --git a/tests/auto/qml/qqmlapplicationengine/testapp/immediateQuit.qml b/tests/auto/qml/qqmlapplicationengine/testapp/immediateQuit.qml new file mode 100644 index 0000000000..1da9d1201a --- /dev/null +++ b/tests/auto/qml/qqmlapplicationengine/testapp/immediateQuit.qml @@ -0,0 +1,8 @@ +import QtQml 2.0 + +QtObject { + Component.onCompleted: { + console.log("End: " + Qt.application.arguments[1]); + Qt.quit() + } +} diff --git a/tests/auto/qml/qqmlapplicationengine/testapp/main.cpp b/tests/auto/qml/qqmlapplicationengine/testapp/main.cpp index a57889fe86..be0d98a2df 100644 --- a/tests/auto/qml/qqmlapplicationengine/testapp/main.cpp +++ b/tests/auto/qml/qqmlapplicationengine/testapp/main.cpp @@ -32,6 +32,6 @@ int main (int argc, char *argv[]) { QCoreApplication app(argc, argv); - QQmlApplicationEngine e(QUrl("qrc:///main.qml")); + QQmlApplicationEngine e(QUrl(QString("qrc:///") + argv[1])); return app.exec(); } diff --git a/tests/auto/qml/qqmlapplicationengine/testapp/main.qrc b/tests/auto/qml/qqmlapplicationengine/testapp/main.qrc index 5f6483ac33..82b695bbd8 100644 --- a/tests/auto/qml/qqmlapplicationengine/testapp/main.qrc +++ b/tests/auto/qml/qqmlapplicationengine/testapp/main.qrc @@ -1,5 +1,8 @@ <RCC> <qresource prefix="/"> - <file>main.qml</file> + <file>immediateQuit.qml</file> + <file>immediateExit.qml</file> + <file>delayedQuit.qml</file> + <file>delayedExit.qml</file> </qresource> </RCC> diff --git a/tests/auto/qml/qqmlapplicationengine/tst_qqmlapplicationengine.cpp b/tests/auto/qml/qqmlapplicationengine/tst_qqmlapplicationengine.cpp index daeb9b5455..ce654dc45e 100644 --- a/tests/auto/qml/qqmlapplicationengine/tst_qqmlapplicationengine.cpp +++ b/tests/auto/qml/qqmlapplicationengine/tst_qqmlapplicationengine.cpp @@ -46,6 +46,7 @@ private slots: void initTestCase(); void basicLoading(); void testNonResolvedPath(); + void application_data(); void application(); void applicationProperties(); void removeObjectsWhenDestroyed(); @@ -111,35 +112,56 @@ void tst_qqmlapplicationengine::testNonResolvedPath() } } +void tst_qqmlapplicationengine::application_data() +{ + QTest::addColumn<QByteArray>("qmlFile"); + QTest::addColumn<QByteArray>("expectedStdErr"); + + QTest::newRow("delayed quit") << QByteArray("delayedQuit.qml") + << QByteArray("qml: Start: delayedQuit.qml\nqml: End\n"); + QTest::newRow("delayed exit") << QByteArray("delayedExit.qml") + << QByteArray("qml: Start: delayedExit.qml\nqml: End\n"); + QTest::newRow("immediate quit") << QByteArray("immediateQuit.qml") + << QByteArray("qml: End: immediateQuit.qml\n"); + QTest::newRow("immediate exit") << QByteArray("immediateExit.qml") + << QByteArray("qml: End: immediateExit.qml\n"); +} + void tst_qqmlapplicationengine::application() { /* This test batches together some tests about running an external application written with QQmlApplicationEngine. The application tests the following functionality which is easier to do by watching a separate process: - -Loads relative paths from the working directory - -quits when quit is called - -emits aboutToQuit after quit is called - -has access to application command line arguments + - Loads relative paths from the working directory + - Quits when quit is called + - Exits when exit is called + - Emits aboutToQuit after quit is called + - Has access to application command line arguments Note that checking the output means that on builds with extra debugging, this might fail with a false positive. Also the testapp is automatically built and installed in shadow builds, so it does NOT use testData */ + + QFETCH(QByteArray, qmlFile); + QFETCH(QByteArray, expectedStdErr); + #if QT_CONFIG(process) QDir::setCurrent(buildDir); QProcess *testProcess = new QProcess(this); QStringList args; - args << QLatin1String("testData"); + args << qmlFile; // QML file passed as an argument is going to be run by testapp. testProcess->start(QLatin1String("testapp/testapp"), args); QVERIFY(testProcess->waitForFinished(5000)); QCOMPARE(testProcess->exitCode(), 0); - QByteArray test_stdout = testProcess->readAllStandardOutput(); - QByteArray test_stderr = testProcess->readAllStandardError(); - QByteArray test_stderr_target("qml: Start: testData\nqml: End\n"); + QByteArray testStdOut = testProcess->readAllStandardOutput(); + QByteArray testStdErr = testProcess->readAllStandardError(); #ifdef Q_OS_WIN - test_stderr_target.replace('\n', QByteArray("\r\n")); + expectedStdErr.replace('\n', QByteArray("\r\n")); #endif - QCOMPARE(test_stdout, QByteArray("")); - QVERIFY(QString(test_stderr).endsWith(QString(test_stderr_target))); + QCOMPARE(testStdOut, QByteArray("")); + QVERIFY2(QString(testStdErr).endsWith(QString(expectedStdErr)), + QByteArray("\nExpected ending:\n") + expectedStdErr + + QByteArray("\nActual output:\n") + testStdErr); delete testProcess; QDir::setCurrent(srcDir); #else // process diff --git a/tests/auto/qml/qqmlconnections/data/override-proxy-type.qml b/tests/auto/qml/qqmlconnections/data/override-proxy-type.qml new file mode 100644 index 0000000000..80e459966b --- /dev/null +++ b/tests/auto/qml/qqmlconnections/data/override-proxy-type.qml @@ -0,0 +1,13 @@ +import QtQml 2.12 +import test.proxy 1.0 + +Proxy { + property int testEnum: 0; + id: proxy + property Connections connections: Connections { + target: proxy + onSomeSignal: testEnum = Proxy.EnumValue; + } + + Component.onCompleted: someSignal() +} diff --git a/tests/auto/qml/qqmlconnections/tst_qqmlconnections.cpp b/tests/auto/qml/qqmlconnections/tst_qqmlconnections.cpp index 8ef00f8080..dc29363fcf 100644 --- a/tests/auto/qml/qqmlconnections/tst_qqmlconnections.cpp +++ b/tests/auto/qml/qqmlconnections/tst_qqmlconnections.cpp @@ -55,6 +55,7 @@ private slots: void disabledAtStart(); void clearImplicitTarget(); void onWithoutASignal(); + void noAcceleratedGlobalLookup(); private: QQmlEngine engine; @@ -407,6 +408,30 @@ void tst_qqmlconnections::onWithoutASignal() QVERIFY(item == nullptr); // should parse error, and not give us an item (or crash). } +class Proxy : public QObject +{ + Q_OBJECT +public: + enum MyEnum { EnumValue = 20, AnotherEnumValue }; + Q_ENUM(MyEnum) + +signals: + void someSignal(); +}; + +void tst_qqmlconnections::noAcceleratedGlobalLookup() +{ + qRegisterMetaType<Proxy::MyEnum>(); + qmlRegisterType<Proxy>("test.proxy", 1, 0, "Proxy"); + QQmlEngine engine; + QQmlComponent c(&engine, testFileUrl("override-proxy-type.qml")); + QVERIFY(c.isReady()); + QScopedPointer<QObject> object(c.create()); + const QVariant val = object->property("testEnum"); + QCOMPARE(val.type(), QMetaType::Int); + QCOMPARE(val.toInt(), int(Proxy::EnumValue)); +} + QTEST_MAIN(tst_qqmlconnections) #include "tst_qqmlconnections.moc" diff --git a/tests/auto/qml/qqmlpropertycache/data/passQGadget.qml b/tests/auto/qml/qqmlpropertycache/data/passQGadget.qml new file mode 100644 index 0000000000..86fdd920ed --- /dev/null +++ b/tests/auto/qml/qqmlpropertycache/data/passQGadget.qml @@ -0,0 +1,12 @@ +import QtQml 2.2 + +QtObject { + property var result; + + property Connections connections: Connections { + target: emitter + onEmitGadget: function(gadget) { + result = gadget.someProperty; + } + } +} diff --git a/tests/auto/qml/qqmlpropertycache/tst_qqmlpropertycache.cpp b/tests/auto/qml/qqmlpropertycache/tst_qqmlpropertycache.cpp index 5abda7b854..07237c9157 100644 --- a/tests/auto/qml/qqmlpropertycache/tst_qqmlpropertycache.cpp +++ b/tests/auto/qml/qqmlpropertycache/tst_qqmlpropertycache.cpp @@ -50,6 +50,7 @@ private slots: void signalHandlers(); void signalHandlersDerived(); void passForeignEnums(); + void passQGadget(); void metaObjectSize_data(); void metaObjectSize(); void metaObjectChecksum(); @@ -362,6 +363,44 @@ void tst_qqmlpropertycache::passForeignEnums() Q_DECLARE_METATYPE(MyEnum::Option1) Q_DECLARE_METATYPE(MyEnum::ShortEnum) +QT_BEGIN_NAMESPACE +class SimpleGadget +{ + Q_GADGET + Q_PROPERTY(bool someProperty READ someProperty) +public: + bool someProperty() const { return true; } +}; + +// Avoids NeedsCreation and NeedsDestruction flags +Q_DECLARE_TYPEINFO(SimpleGadget, Q_PRIMITIVE_TYPE); +QT_END_NAMESPACE + +class GadgetEmitter : public QObject +{ + Q_OBJECT +signals: + void emitGadget(SimpleGadget); +}; + +void tst_qqmlpropertycache::passQGadget() +{ + qRegisterMetaType<SimpleGadget>(); + + GadgetEmitter emitter; + engine.rootContext()->setContextProperty("emitter", &emitter); + QQmlComponent component(&engine, testFile("passQGadget.qml")); + QVERIFY(component.isReady()); + + QScopedPointer<QObject> obj(component.create(engine.rootContext())); + QVariant before = obj->property("result"); + QVERIFY(before.isNull()); + emit emitter.emitGadget(SimpleGadget()); + QVariant after = obj->property("result"); + QCOMPARE(QMetaType::Type(after.type()), QMetaType::Bool); + QVERIFY(after.toBool()); +} + class TestClass : public QObject { Q_OBJECT |