diff options
author | Liang Qi <liang.qi@qt.io> | 2018-03-28 08:27:57 +0200 |
---|---|---|
committer | Liang Qi <liang.qi@qt.io> | 2018-03-28 08:27:57 +0200 |
commit | 198409ba76e18587526e9e1ec84fdb432c671937 (patch) | |
tree | 2d06c052272ddfd1c9b34b863e342826a31d20b9 /tests | |
parent | 9a98d16d9e49395a24cd733ca8f65b2f82ebba94 (diff) | |
parent | e696a6b7bff04d1581cf59b4d96ecb5508f54169 (diff) |
Merge remote-tracking branch 'origin/5.11' into dev
Conflicts:
src/plugins/qmltooling/qmldbg_profiler/qqmlprofilerservice.cpp
tests/auto/qml/qjsengine/tst_qjsengine.cpp
Change-Id: I8276669e257f35a76768ef7f8795a8605cf4c9bc
Diffstat (limited to 'tests')
16 files changed, 222 insertions, 77 deletions
diff --git a/tests/auto/cmake/CMakeLists.txt b/tests/auto/cmake/CMakeLists.txt index 4d4d8e3db7..f304a99705 100644 --- a/tests/auto/cmake/CMakeLists.txt +++ b/tests/auto/cmake/CMakeLists.txt @@ -25,4 +25,5 @@ add_test(qtquickcompiler ${CMAKE_CTEST_COMMAND} --build-makeprogram ${CMAKE_MAKE_PROGRAM} --build-project qqc_test --build-options "-DCMAKE_PREFIX_PATH=${CMAKE_PREFIX_PATH}" ${BUILD_OPTIONS_LIST} + --test-command qqc_test ) diff --git a/tests/auto/cmake/qtquickcompiler/CMakeLists.txt b/tests/auto/cmake/qtquickcompiler/CMakeLists.txt index 6dee1e25dc..4e46544767 100644 --- a/tests/auto/cmake/qtquickcompiler/CMakeLists.txt +++ b/tests/auto/cmake/qtquickcompiler/CMakeLists.txt @@ -4,11 +4,14 @@ project(qqc_test) find_package(Qt5Qml 5.0.0 REQUIRED) find_package(Qt5Gui 5.0.0 REQUIRED) +find_package(Qt5Test 5.0.0 REQUIRED) find_package(Qt5QuickCompiler) set(CMAKE_CXXFLAGS "${CMAKE_CXXFLAGS} ${Qt5Core_EXECUTABLE_COMPILE_FLAGS}") -qtquick_compiler_add_resources(RESOURCES qqc_test.qrc) +qtquick_compiler_add_resources(RESOURCES "resources with space/qqc_test.qrc") + +set(CMAKE_AUTOMOC ON) add_executable(qqc_test "${CMAKE_CURRENT_SOURCE_DIR}/main.cpp" ${RESOURCES}) -target_link_libraries(qqc_test Qt5::Gui Qt5::Qml) +target_link_libraries(qqc_test Qt5::Gui Qt5::Qml Qt5::Test) diff --git a/tests/auto/cmake/qtquickcompiler/main.cpp b/tests/auto/cmake/qtquickcompiler/main.cpp index 47fc709c0a..c357ef60e6 100644 --- a/tests/auto/cmake/qtquickcompiler/main.cpp +++ b/tests/auto/cmake/qtquickcompiler/main.cpp @@ -1,9 +1,30 @@ -#include <QtGui> +#include <QtCore> #include <QtQml> +#include <QtTest> -int main(int argc, char **argv) +class tst_QQC : public QObject { - QGuiApplication app(argc, argv); - return app.exec(); + Q_OBJECT +private slots: + void packaging(); +}; + +void tst_QQC::packaging() +{ + QVERIFY(QFile::exists(":/main.qml")); + QCOMPARE(QFileInfo(":/main.qml").size(), 0); + QVERIFY(QFile::exists(":/main.cpp")); + QVERIFY(QFileInfo(":/main.cpp").size() > 0); + + + QQmlEngine engine; + QQmlComponent component(&engine, QUrl("qrc:/main.qml")); + QScopedPointer<QObject> obj(component.create()); + QVERIFY(!obj.isNull()); + QCOMPARE(obj->property("success").toInt(), 42); } + +QTEST_MAIN(tst_QQC) + +#include "main.moc" diff --git a/tests/auto/cmake/qtquickcompiler/main.qml b/tests/auto/cmake/qtquickcompiler/resources with space/main.qml index 1f146d89c3..0836808dc2 100644 --- a/tests/auto/cmake/qtquickcompiler/main.qml +++ b/tests/auto/cmake/qtquickcompiler/resources with space/main.qml @@ -1,4 +1,4 @@ import QtQml 2.0 QtObject { - property bool success: 42 + property int success: 42 } diff --git a/tests/auto/cmake/qtquickcompiler/qqc_test.qrc b/tests/auto/cmake/qtquickcompiler/resources with space/qqc_test.qrc index f128b7004b..63d8d1f37e 100644 --- a/tests/auto/cmake/qtquickcompiler/qqc_test.qrc +++ b/tests/auto/cmake/qtquickcompiler/resources with space/qqc_test.qrc @@ -1,6 +1,6 @@ <!DOCTYPE RCC><RCC version="1.0"> <qresource> <file>./main.qml</file> -<file>./main.cpp</file> +<file alias="main.cpp">../main.cpp</file> </qresource> </RCC> diff --git a/tests/auto/qml/debugger/qqmlprofilerservice/tst_qqmlprofilerservice.cpp b/tests/auto/qml/debugger/qqmlprofilerservice/tst_qqmlprofilerservice.cpp index cd8e4216f3..f2b44a4d95 100644 --- a/tests/auto/qml/debugger/qqmlprofilerservice/tst_qqmlprofilerservice.cpp +++ b/tests/auto/qml/debugger/qqmlprofilerservice/tst_qqmlprofilerservice.cpp @@ -221,6 +221,7 @@ private slots: void flushInterval(); void translationBinding(); void memory(); + void compile(); private: bool m_recordFromStart = true; @@ -525,6 +526,8 @@ void tst_QQmlProfilerService::connect() if (!traceEnabled) m_client->client->setRecording(true); + + QTRY_VERIFY(m_client->numLoadedEventTypes() > 0); m_client->client->setRecording(false); checkTraceReceived(); checkJsHeap(); @@ -643,6 +646,7 @@ void tst_QQmlProfilerService::controlFromJS() { QCOMPARE(connect(true, "controlFromJS.qml", false), ConnectSuccess); + QTRY_VERIFY(m_client->numLoadedEventTypes() > 0); m_client->client->setRecording(false); checkTraceReceived(); checkJsHeap(); @@ -749,6 +753,41 @@ void tst_QQmlProfilerService::memory() QVERIFY(smallItems > 5); } +void tst_QQmlProfilerService::compile() +{ + connect(true, "test.qml"); + + QTRY_VERIFY(m_client->numLoadedEventTypes() > 0); + m_client->client->setRecording(false); + + checkTraceReceived(); + checkJsHeap(); + + QQmlProfilerDefinitions::Message rangeStage = QQmlProfilerDefinitions::MaximumMessage; + for (auto message : m_client->qmlMessages) { + const QQmlProfilerEventType &type = m_client->types[message.typeIndex()]; + if (type.rangeType() == QQmlProfilerDefinitions::Compiling) { + switch (rangeStage) { + case QQmlProfilerDefinitions::MaximumMessage: + QCOMPARE(message.rangeStage(), QQmlProfilerDefinitions::RangeStart); + break; + case QQmlProfilerDefinitions::RangeStart: + QCOMPARE(message.rangeStage(), QQmlProfilerDefinitions::RangeEnd); + break; + default: + QFAIL("Wrong range stage"); + } + rangeStage = message.rangeStage(); + QCOMPARE(type.message(), QQmlProfilerDefinitions::MaximumMessage); + QCOMPARE(type.location().filename(), testFileUrl("test.qml").toString()); + QCOMPARE(type.location().line(), 0); + QCOMPARE(type.location().column(), 0); + } + } + + QCOMPARE(rangeStage, QQmlProfilerDefinitions::RangeEnd); +} + QTEST_MAIN(tst_QQmlProfilerService) #include "tst_qqmlprofilerservice.moc" diff --git a/tests/auto/qml/qjsengine/tst_qjsengine.cpp b/tests/auto/qml/qjsengine/tst_qjsengine.cpp index 1eff5739b8..cc0a1e9a93 100644 --- a/tests/auto/qml/qjsengine/tst_qjsengine.cpp +++ b/tests/auto/qml/qjsengine/tst_qjsengine.cpp @@ -203,7 +203,6 @@ private slots: void malformedExpression(); void scriptScopes(); - void perfMapFile(); void binaryNumbers(); void octalNumbers(); @@ -4180,73 +4179,6 @@ void tst_QJSEngine::octalNumbers() QVERIFY(result.isError()); } -static const char *perfMapKey = "QV4_PROFILE_WRITE_PERF_MAP"; -static const char *jitCallKey = "QV4_JIT_CALL_THRESHOLD"; - -struct EnvironmentModifier { - const bool hasPerfMap = false; - const bool hasJitCall = false; - const QByteArray perfMap; - const QByteArray jitCall; - - EnvironmentModifier() : - hasPerfMap(qEnvironmentVariableIsSet(perfMapKey)), - hasJitCall(qEnvironmentVariableIsSet(jitCallKey)), - perfMap(qgetenv(perfMapKey)), - jitCall(qgetenv(jitCallKey)) - { - qputenv(perfMapKey, "1"); - qputenv(jitCallKey, "0"); - } - - ~EnvironmentModifier() - { - if (hasPerfMap) - qputenv(perfMapKey, perfMap); - else - qunsetenv(perfMapKey); - - if (hasJitCall) - qputenv(jitCallKey, jitCall); - else - qunsetenv(jitCallKey); - } -}; - -void tst_QJSEngine::perfMapFile() -{ -#if !defined(Q_OS_LINUX) - QSKIP("perf map files are only generated on linux"); -#else - EnvironmentModifier modifier; - Q_UNUSED(modifier); - QJSEngine engine; - QJSValue def = engine.evaluate("'use strict'; function foo() { return 42 }"); - QVERIFY(!def.isError()); - QJSValue use = engine.evaluate("'use strict'; foo()"); - QVERIFY(use.isNumber()); - QFile file(QString::fromLatin1("/tmp/perf-%1.map").arg(QCoreApplication::applicationPid())); - QVERIFY(file.exists()); - QVERIFY(file.open(QIODevice::ReadOnly)); - QList<QByteArray> functions; - while (!file.atEnd()) { - const QByteArray contents = file.readLine(); - QVERIFY(contents.endsWith('\n')); - QList<QByteArray> fields = contents.split(' '); - QCOMPARE(fields.length(), 3); - bool ok = false; - const qulonglong address = fields[0].toULongLong(&ok, 16); - QVERIFY(ok); - QVERIFY(address > 0); - const ulong size = fields[1].toULong(&ok, 16); - QVERIFY(ok); - QVERIFY(size > 0); - functions.append(fields[2]); - } - QVERIFY(functions.contains("foo\n")); -#endif -} - QTEST_MAIN(tst_QJSEngine) #include "tst_qjsengine.moc" diff --git a/tests/auto/qml/qml.pro b/tests/auto/qml/qml.pro index 9557393a2e..3433b56864 100644 --- a/tests/auto/qml/qml.pro +++ b/tests/auto/qml/qml.pro @@ -69,6 +69,7 @@ PRIVATETESTS += \ qqmltranslation \ qqmlimport \ qqmlobjectmodel \ + qv4assembler \ qv4mm \ ecmascripttests \ bindingdependencyapi diff --git a/tests/auto/qml/qmlcachegen/qmlcachegen.pro b/tests/auto/qml/qmlcachegen/qmlcachegen.pro index bad912c781..a2f963e8c3 100644 --- a/tests/auto/qml/qmlcachegen/qmlcachegen.pro +++ b/tests/auto/qml/qmlcachegen/qmlcachegen.pro @@ -10,4 +10,6 @@ RESOURCES += workerscripts_test RESOURCES += versionchecks.qml +RESOURCES += trickypaths.qrc + QT += core-private qml-private testlib diff --git a/tests/auto/qml/qmlcachegen/trickypaths.qml b/tests/auto/qml/qmlcachegen/trickypaths.qml new file mode 100644 index 0000000000..0836808dc2 --- /dev/null +++ b/tests/auto/qml/qmlcachegen/trickypaths.qml @@ -0,0 +1,4 @@ +import QtQml 2.0 +QtObject { + property int success: 42 +} diff --git a/tests/auto/qml/qmlcachegen/trickypaths.qrc b/tests/auto/qml/qmlcachegen/trickypaths.qrc new file mode 100644 index 0000000000..271cf6571e --- /dev/null +++ b/tests/auto/qml/qmlcachegen/trickypaths.qrc @@ -0,0 +1,5 @@ +<!DOCTYPE RCC><RCC version="1.0"> +<qresource prefix="/directory with spaces"> +<file alias="file name with spaces.qml">trickypaths.qml</file> +</qresource> +</RCC> diff --git a/tests/auto/qml/qmlcachegen/tst_qmlcachegen.cpp b/tests/auto/qml/qmlcachegen/tst_qmlcachegen.cpp index 1c05005c90..5c1692f086 100644 --- a/tests/auto/qml/qmlcachegen/tst_qmlcachegen.cpp +++ b/tests/auto/qml/qmlcachegen/tst_qmlcachegen.cpp @@ -52,6 +52,8 @@ private slots: void versionChecksForAheadOfTimeUnits(); void workerScripts(); + + void trickyPaths(); }; // A wrapper around QQmlComponent to ensure the temporary reference counts @@ -402,6 +404,18 @@ void tst_qmlcachegen::functionExpressions() QCOMPARE(obj->property("h_connections_handler_called").toBool(), true); } +void tst_qmlcachegen::trickyPaths() +{ + QString pathWithSpaces(QStringLiteral(":/directory with spaces/file name with spaces.qml")); + QVERIFY2(QFile::exists(pathWithSpaces), qPrintable(pathWithSpaces)); + QCOMPARE(QFileInfo(pathWithSpaces).size(), 0); + QQmlEngine engine; + QQmlComponent component(&engine, QUrl("qrc" + pathWithSpaces)); + QScopedPointer<QObject> obj(component.create()); + QVERIFY(!obj.isNull()); + QCOMPARE(obj->property("success").toInt(), 42); +} + QTEST_GUILESS_MAIN(tst_qmlcachegen) #include "tst_qmlcachegen.moc" diff --git a/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp b/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp index 31cf40be16..e0b8127dfb 100644 --- a/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp +++ b/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp @@ -351,6 +351,7 @@ private slots: void shadowedFunctionName(); void anotherNaN(); void callPropertyOnUndefined(); + void jumpStrictNotEqualUndefined(); private: // static void propertyVarWeakRefCallback(v8::Persistent<v8::Value> object, void* parameter); @@ -8479,6 +8480,26 @@ void tst_qqmlecmascript::callPropertyOnUndefined() QVERIFY(!v.isError()); // well, more importantly: this shouldn't fail on an assert. } +void tst_qqmlecmascript::jumpStrictNotEqualUndefined() +{ + QJSEngine engine; + QJSValue v = engine.evaluate(QString::fromLatin1( + "var ok = 0\n" + "var foo = 0\n" + "if (foo !== void 1)\n" + " ++ok;\n" + "else\n" + " --ok;\n" + "if (foo === void 1)\n" + " --ok;\n" + "else\n" + " ++ok;\n" + "ok\n" + )); + QVERIFY(!v.isError()); + QCOMPARE(v.toInt(), 2); +} + QTEST_MAIN(tst_qqmlecmascript) #include "tst_qqmlecmascript.moc" diff --git a/tests/auto/qml/qqmlexpression/tst_qqmlexpression.cpp b/tests/auto/qml/qqmlexpression/tst_qqmlexpression.cpp index e1ad1e8c5f..1decc04ad2 100644 --- a/tests/auto/qml/qqmlexpression/tst_qqmlexpression.cpp +++ b/tests/auto/qml/qqmlexpression/tst_qqmlexpression.cpp @@ -101,8 +101,12 @@ void tst_qqmlexpression::syntaxError() { QQmlEngine engine; QQmlExpression expression(engine.rootContext(), nullptr, "asd asd"); - QVariant v = expression.evaluate(); + bool isUndefined = false; + QVariant v = expression.evaluate(&isUndefined); QCOMPARE(v, QVariant()); + QVERIFY(expression.hasError()); + QCOMPARE(expression.error().description(), "SyntaxError: Expected token `;'"); + QVERIFY(isUndefined); } void tst_qqmlexpression::exception() diff --git a/tests/auto/qml/qv4assembler/qv4assembler.pro b/tests/auto/qml/qv4assembler/qv4assembler.pro new file mode 100644 index 0000000000..afd7586ac7 --- /dev/null +++ b/tests/auto/qml/qv4assembler/qv4assembler.pro @@ -0,0 +1,7 @@ +CONFIG += testcase +TARGET = tst_qv4assembler +macos:CONFIG -= app_bundle + +SOURCES += tst_qv4assembler.cpp + +QT += qml-private testlib diff --git a/tests/auto/qml/qv4assembler/tst_qv4assembler.cpp b/tests/auto/qml/qv4assembler/tst_qv4assembler.cpp new file mode 100644 index 0000000000..9bd1afa256 --- /dev/null +++ b/tests/auto/qml/qv4assembler/tst_qv4assembler.cpp @@ -0,0 +1,91 @@ +/**************************************************************************** +** +** Copyright (C) 2018 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:GPL-EXCEPT$ +** 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. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include <QtTest/QtTest> +#include <QtCore/qprocess.h> +#include <QtCore/qtemporaryfile.h> + +class tst_QV4Assembler : public QObject +{ + Q_OBJECT + +private slots: + void perfMapFile(); +}; + +void tst_QV4Assembler::perfMapFile() +{ +#if !defined(Q_OS_LINUX) + QSKIP("perf map files are only generated on linux"); +#else + const QString qmljs = QLibraryInfo::location(QLibraryInfo::BinariesPath) + "/qmljs"; + QProcess process; + + QTemporaryFile infile; + QVERIFY(infile.open()); + infile.write("'use strict'; function foo() { return 42 }; foo();"); + infile.close(); + + QProcessEnvironment environment = QProcessEnvironment::systemEnvironment(); + environment.insert("QV4_PROFILE_WRITE_PERF_MAP", "1"); + environment.insert("QV4_JIT_CALL_THRESHOLD", "0"); + + process.setProcessEnvironment(environment); + process.start(qmljs, QStringList({infile.fileName()})); + QVERIFY(process.waitForStarted()); + const qint64 pid = process.processId(); + QVERIFY(pid != 0); + QVERIFY(process.waitForFinished()); + QCOMPARE(process.exitCode(), 0); + + QFile file(QString::fromLatin1("/tmp/perf-%1.map").arg(pid)); + QVERIFY(file.exists()); + QVERIFY(file.open(QIODevice::ReadOnly)); + QList<QByteArray> functions; + while (!file.atEnd()) { + const QByteArray contents = file.readLine(); + QVERIFY(contents.endsWith('\n')); + QList<QByteArray> fields = contents.split(' '); + QCOMPARE(fields.length(), 3); + bool ok = false; + const qulonglong address = fields[0].toULongLong(&ok, 16); + QVERIFY(ok); + QVERIFY(address > 0); + const ulong size = fields[1].toULong(&ok, 16); + QVERIFY(ok); + QVERIFY(size > 0); + functions.append(fields[2]); + } + QVERIFY(functions.contains("foo\n")); +#endif +} + +QTEST_MAIN(tst_QV4Assembler) + +#include "tst_qv4assembler.moc" + |