diff options
Diffstat (limited to 'tests/auto/qml')
103 files changed, 1443 insertions, 780 deletions
diff --git a/tests/auto/qml/animation/qpauseanimationjob/tst_qpauseanimationjob.cpp b/tests/auto/qml/animation/qpauseanimationjob/tst_qpauseanimationjob.cpp index a832c58ae3..5a1148e92e 100644 --- a/tests/auto/qml/animation/qpauseanimationjob/tst_qpauseanimationjob.cpp +++ b/tests/auto/qml/animation/qpauseanimationjob/tst_qpauseanimationjob.cpp @@ -211,19 +211,8 @@ void tst_QPauseAnimationJob::multiplePauseAnimations() #endif QCOMPARE(animation2.m_updateCurrentTimeCount, 2); - QTest::qWait(550); - -#ifdef Q_OS_WIN - if (animation2.state() != QAbstractAnimationJob::Stopped) - QEXPECT_FAIL("", winTimerError, Abort); -#endif - QVERIFY(animation2.state() == QAbstractAnimationJob::Stopped); - -#ifdef Q_OS_WIN - if (animation2.m_updateCurrentTimeCount != 3) - QEXPECT_FAIL("", winTimerError, Abort); -#endif - QCOMPARE(animation2.m_updateCurrentTimeCount, 3); + QTRY_COMPARE(animation2.state(), QAbstractAnimationJob::Stopped); + QVERIFY(animation2.m_updateCurrentTimeCount >= 3); } void tst_QPauseAnimationJob::pauseAndPropertyAnimations() @@ -240,19 +229,17 @@ void tst_QPauseAnimationJob::pauseAndPropertyAnimations() QTest::qWait(100); animation.start(); - QVERIFY(animation.state() == QAbstractAnimationJob::Running); - QVERIFY(pause.state() == QAbstractAnimationJob::Running); - QCOMPARE(pause.m_updateCurrentTimeCount, 2); + QCOMPARE(animation.state(), QAbstractAnimationJob::Running); - QTest::qWait(animation.totalDuration() + 100); + QTRY_COMPARE(animation.state(), QAbstractAnimationJob::Running); + QVERIFY(pause.state() == QAbstractAnimationJob::Running); + QVERIFY2(pause.m_updateCurrentTimeCount >= 2, + QByteArrayLiteral("pause.m_updateCurrentTimeCount=") + QByteArray::number(pause.m_updateCurrentTimeCount)); -#ifdef Q_OS_WIN - if (animation.state() != QAbstractAnimationJob::Stopped) - QEXPECT_FAIL("", winTimerError, Abort); -#endif - QVERIFY(animation.state() == QAbstractAnimationJob::Stopped); - QVERIFY(pause.state() == QAbstractAnimationJob::Stopped); - QVERIFY(pause.m_updateCurrentTimeCount > 3); + QTRY_COMPARE(animation.state(), QAbstractAnimationJob::Stopped); + QCOMPARE(pause.state(), QAbstractAnimationJob::Stopped); + QVERIFY2(pause.m_updateCurrentTimeCount > 3, + QByteArrayLiteral("pause.m_updateCurrentTimeCount=") + QByteArray::number(pause.m_updateCurrentTimeCount)); } void tst_QPauseAnimationJob::pauseResume() @@ -260,19 +247,15 @@ void tst_QPauseAnimationJob::pauseResume() TestablePauseAnimation animation; animation.setDuration(400); animation.start(); - QVERIFY(animation.state() == QAbstractAnimationJob::Running); + QCOMPARE(animation.state(), QAbstractAnimationJob::Running); QTest::qWait(200); animation.pause(); - QVERIFY(animation.state() == QAbstractAnimationJob::Paused); + QCOMPARE(animation.state(), QAbstractAnimationJob::Paused); animation.start(); QTest::qWait(300); - QVERIFY(animation.state() == QAbstractAnimationJob::Stopped); - -#ifdef Q_OS_WIN - if (animation.m_updateCurrentTimeCount != 3) - QEXPECT_FAIL("", winTimerError, Abort); -#endif - QCOMPARE(animation.m_updateCurrentTimeCount, 3); + QTRY_VERIFY(animation.state() == QAbstractAnimationJob::Stopped); + QVERIFY2(animation.m_updateCurrentTimeCount >= 3, + QByteArrayLiteral("animation.m_updateCurrentTimeCount=") + QByteArray::number(animation.m_updateCurrentTimeCount)); } void tst_QPauseAnimationJob::sequentialPauseGroup() @@ -423,7 +406,7 @@ void tst_QPauseAnimationJob::multipleSequentialGroups() if (group.state() != QAbstractAnimationJob::Stopped) QEXPECT_FAIL("", winTimerError, Abort); #endif - QVERIFY(group.state() == QAbstractAnimationJob::Stopped); + QTRY_VERIFY(group.state() == QAbstractAnimationJob::Stopped); #ifdef Q_OS_WIN if (subgroup1.state() != QAbstractAnimationJob::Stopped) diff --git a/tests/auto/qml/debugger/debugger.pro b/tests/auto/qml/debugger/debugger.pro index 15abbcc7ab..aa3ad6a3a3 100644 --- a/tests/auto/qml/debugger/debugger.pro +++ b/tests/auto/qml/debugger/debugger.pro @@ -2,7 +2,7 @@ TEMPLATE = subdirs PUBLICTESTS += \ qqmlenginedebugservice \ -# qqmldebugjs \ + qqmldebugjs \ qpacketprotocol \ # qv8profilerservice \ # qdebugmessageservice \ diff --git a/tests/auto/qml/debugger/qdebugmessageservice/tst_qdebugmessageservice.cpp b/tests/auto/qml/debugger/qdebugmessageservice/tst_qdebugmessageservice.cpp index 9318372e2c..2fee7cfc92 100644 --- a/tests/auto/qml/debugger/qdebugmessageservice/tst_qdebugmessageservice.cpp +++ b/tests/auto/qml/debugger/qdebugmessageservice/tst_qdebugmessageservice.cpp @@ -48,7 +48,6 @@ #include <QtCore/QString> #include <QtTest/QtTest> -const char *ENABLE_DEBUG= "-enable-debugger"; const char *NORMALMODE = "-qmljsdebugger=port:3777,3787,block"; const char *QMLFILE = "test.qml"; @@ -183,7 +182,7 @@ void tst_QDebugMessageService::init() m_process = new QQmlDebugProcess(QLibraryInfo::location(QLibraryInfo::BinariesPath) + "/qml", this); m_client = new QQmlDebugMsgClient(m_connection); - m_process->start(QStringList() << QLatin1String(ENABLE_DEBUG) << QLatin1String(NORMALMODE) << QQmlDataTest::instance()->testFile(QMLFILE)); + m_process->start(QStringList() << QLatin1String(NORMALMODE) << QQmlDataTest::instance()->testFile(QMLFILE)); QVERIFY2(m_process->waitForSessionStart(), "Could not launch application, or did not get 'Waiting for connection'."); diff --git a/tests/auto/qml/debugger/qqmldebugjs/tst_qqmldebugjs.cpp b/tests/auto/qml/debugger/qqmldebugjs/tst_qqmldebugjs.cpp index 9bf2d8849e..2cf6ee958a 100644 --- a/tests/auto/qml/debugger/qqmldebugjs/tst_qqmldebugjs.cpp +++ b/tests/auto/qml/debugger/qqmldebugjs/tst_qqmldebugjs.cpp @@ -100,13 +100,10 @@ const char *SCOPES = "scopes"; const char *SCRIPTS = "scripts"; const char *SOURCE = "source"; const char *SETBREAKPOINT = "setbreakpoint"; -const char *CHANGEBREAKPOINT = "changebreakpoint"; const char *CLEARBREAKPOINT = "clearbreakpoint"; const char *SETEXCEPTIONBREAK = "setexceptionbreak"; -const char *V8FLAGS = "v8flags"; const char *VERSION = "version"; const char *DISCONNECT = "disconnect"; -const char *LISTBREAKPOINTS = "listbreakpoints"; const char *GARBAGECOLLECTOR = "gc"; //const char *PROFILE = "profile"; @@ -129,7 +126,6 @@ const char *UNCAUGHT = "uncaught"; //const char *PAUSE = "pause"; //const char *RESUME = "resume"; -const char *ENABLE_DEBUG= "-enable-debugger";//flag needed for debugger with qml binary const char *BLOCKMODE = "-qmljsdebugger=port:3771,3800,block"; const char *NORMALMODE = "-qmljsdebugger=port:3771,3800"; const char *TEST_QMLFILE = "test.qml"; @@ -182,14 +178,8 @@ private slots: void getVersion(); // void getVersionWhenAttaching(); - void applyV8Flags(); - void disconnect(); - void gc(); - - void listBreakpoints(); - void setBreakpointInScriptOnCompleted(); void setBreakpointInScriptOnComponentCreated(); void setBreakpointInScriptOnTimerCallback(); @@ -197,21 +187,17 @@ private slots: void setBreakpointInScriptOnComment(); void setBreakpointInScriptOnEmptyLine(); void setBreakpointInScriptOnOptimizedBinding(); - void setBreakpointInScriptWithCondition(); +// void setBreakpointInScriptWithCondition(); // Not supported yet. void setBreakpointInScriptThatQuits(); //void setBreakpointInFunction(); //NOT SUPPORTED - void setBreakpointOnEvent(); +// void setBreakpointOnEvent(); // void setBreakpointWhenAttaching(); - void changeBreakpoint(); - void changeBreakpointOnCondition(); - void clearBreakpoint(); void setExceptionBreak(); void stepNext(); - void stepNextWithCount(); void stepIn(); void stepOut(); void continueDebugging(); @@ -222,15 +208,11 @@ private slots: void getScopeDetails(); - void evaluateInGlobalScope(); - void evaluateInLocalScope(); - - void getScopes(); +// void evaluateInGlobalScope(); // Not supported yet. +// void evaluateInLocalScope(); // Not supported yet. void getScripts(); - void getSource(); - // void profile(); //NOT SUPPORTED // void verifyQMLOptimizerDisabled(); @@ -277,25 +259,19 @@ public: void connect(); void interrupt(); - void continueDebugging(StepAction stepAction, int stepCount = 1); + void continueDebugging(StepAction stepAction); void evaluate(QString expr, bool global = false, bool disableBreak = false, int frame = -1, const QVariantMap &addContext = QVariantMap()); void lookup(QList<int> handles, bool includeSource = false); void backtrace(int fromFrame = -1, int toFrame = -1, bool bottom = false); void frame(int number = -1); void scope(int number = -1, int frameNumber = -1); - void scopes(int frameNumber = -1); void scripts(int types = 4, QList<int> ids = QList<int>(), bool includeSource = false, QVariant filter = QVariant()); - void source(int frame = -1, int fromLine = -1, int toLine = -1); void setBreakpoint(QString type, QString target, int line = -1, int column = -1, bool enabled = true, QString condition = QString(), int ignoreCount = -1); - void changeBreakpoint(int breakpoint, bool enabled = true, QString condition = QString(), int ignoreCount = -1); void clearBreakpoint(int breakpoint); void setExceptionBreak(Exception type, bool enabled = false); - void v8flags(QString flags); void version(); //void profile(ProfileCommand command); //NOT SUPPORTED void disconnect(); - void gc(); - void listBreakpoints(); protected: //inherited from QQmlDebugClient @@ -338,7 +314,7 @@ void QJSDebugClient::interrupt() sendMessage(packMessage(INTERRUPT)); } -void QJSDebugClient::continueDebugging(StepAction action, int count) +void QJSDebugClient::continueDebugging(StepAction action) { // { "seq" : <number>, // "type" : "request", @@ -362,8 +338,6 @@ void QJSDebugClient::continueDebugging(StepAction action, int count) default:break; } if (!args.isUndefined()) { - if (count != 1) - args.setProperty(QLatin1String(STEPCOUNT),QJSValue(count)); jsonVal.setProperty(QLatin1String(ARGUMENTS),args); } } @@ -527,30 +501,6 @@ void QJSDebugClient::scope(int number, int frameNumber) sendMessage(packMessage(V8REQUEST, json.toString().toUtf8())); } -void QJSDebugClient::scopes(int frameNumber) -{ - // { "seq" : <number>, - // "type" : "request", - // "command" : "scopes", - // "arguments" : { "frameNumber" : <frame number, optional uses selected frame if missing> - // } - // } - VARIANTMAPINIT; - jsonVal.setProperty(QLatin1String(COMMAND),QJSValue(QLatin1String(SCOPES))); - - if (frameNumber != -1) { - QJSValue args = parser.call(QJSValueList() << obj); - args.setProperty(QLatin1String(FRAMENUMBER),QJSValue(frameNumber)); - - if (!args.isUndefined()) { - jsonVal.setProperty(QLatin1String(ARGUMENTS),args); - } - } - - QJSValue json = stringify.call(QJSValueList() << jsonVal); - sendMessage(packMessage(V8REQUEST, json.toString().toUtf8())); -} - void QJSDebugClient::scripts(int types, QList<int> ids, bool includeSource, QVariant /*filter*/) { // { "seq" : <number>, @@ -595,39 +545,6 @@ void QJSDebugClient::scripts(int types, QList<int> ids, bool includeSource, QVar sendMessage(packMessage(V8REQUEST, json.toString().toUtf8())); } -void QJSDebugClient::source(int frame, int fromLine, int toLine) -{ - // { "seq" : <number>, - // "type" : "request", - // "command" : "source", - // "arguments" : { "frame" : <frame number (default selected frame)> - // "fromLine" : <from line within the source default is line 0> - // "toLine" : <to line within the source this line is not included in - // the result default is the number of lines in the script> - // } - // } - VARIANTMAPINIT; - jsonVal.setProperty(QLatin1String(COMMAND),QJSValue(QLatin1String(SOURCE))); - - QJSValue args = parser.call(QJSValueList() << obj); - - if (frame != -1) - args.setProperty(QLatin1String(FRAME),QJSValue(frame)); - - if (fromLine != -1) - args.setProperty(QLatin1String(FROMLINE),QJSValue(fromLine)); - - if (toLine != -1) - args.setProperty(QLatin1String(TOLINE),QJSValue(toLine)); - - if (!args.isUndefined()) { - jsonVal.setProperty(QLatin1String(ARGUMENTS),args); - } - - QJSValue json = stringify.call(QJSValueList() << jsonVal); - sendMessage(packMessage(V8REQUEST, json.toString().toUtf8())); -} - void QJSDebugClient::setBreakpoint(QString type, QString target, int line, int column, bool enabled, QString condition, int ignoreCount) { // { "seq" : <number>, @@ -681,39 +598,6 @@ void QJSDebugClient::setBreakpoint(QString type, QString target, int line, int c } } -void QJSDebugClient::changeBreakpoint(int breakpoint, bool enabled, QString condition, int ignoreCount) -{ - // { "seq" : <number>, - // "type" : "request", - // "command" : "changebreakpoint", - // "arguments" : { "breakpoint" : <number of the break point to clear> - // "enabled" : <initial enabled state. True or false, default is true> - // "condition" : <string with break point condition> - // "ignoreCount" : <number specifying the number of break point hits } - // } - VARIANTMAPINIT; - jsonVal.setProperty(QLatin1String(COMMAND),QJSValue(QLatin1String(CHANGEBREAKPOINT))); - - QJSValue args = parser.call(QJSValueList() << obj); - - args.setProperty(QLatin1String(BREAKPOINT),QJSValue(breakpoint)); - - args.setProperty(QLatin1String(ENABLED),QJSValue(enabled)); - - if (!condition.isEmpty()) - args.setProperty(QLatin1String(CONDITION),QJSValue(condition)); - - if (ignoreCount != -1) - args.setProperty(QLatin1String(IGNORECOUNT),QJSValue(ignoreCount)); - - if (!args.isUndefined()) { - jsonVal.setProperty(QLatin1String(ARGUMENTS),args); - } - - QJSValue json = stringify.call(QJSValueList() << jsonVal); - sendMessage(packMessage(V8REQUEST, json.toString().toUtf8())); -} - void QJSDebugClient::clearBreakpoint(int breakpoint) { // { "seq" : <number>, @@ -767,29 +651,6 @@ void QJSDebugClient::setExceptionBreak(Exception type, bool enabled) sendMessage(packMessage(V8REQUEST, json.toString().toUtf8())); } -void QJSDebugClient::v8flags(QString flags) -{ - // { "seq" : <number>, - // "type" : "request", - // "command" : "v8flags", - // "arguments" : { "flags" : <string: a sequence of v8 flags just like those used on the command line> - // } - // } - VARIANTMAPINIT; - jsonVal.setProperty(QLatin1String(COMMAND),QJSValue(QLatin1String(V8FLAGS))); - - QJSValue args = parser.call(QJSValueList() << obj); - - args.setProperty(QLatin1String(FLAGS),QJSValue(flags)); - - if (!args.isUndefined()) { - jsonVal.setProperty(QLatin1String(ARGUMENTS),args); - } - - QJSValue json = stringify.call(QJSValueList() << jsonVal); - sendMessage(packMessage(V8REQUEST, json.toString().toUtf8())); -} - void QJSDebugClient::version() { // { "seq" : <number>, @@ -842,42 +703,6 @@ void QJSDebugClient::disconnect() sendMessage(packMessage(DISCONNECT, json.toString().toUtf8())); } -void QJSDebugClient::gc() -{ - // { "seq" : <number>, - // "type" : "request", - // "command" : "gc", - // "arguments" : { "type" : <string: "all">, - // } - // } - VARIANTMAPINIT; - jsonVal.setProperty(QLatin1String(COMMAND),QJSValue(QLatin1String(GARBAGECOLLECTOR))); - - QJSValue args = parser.call(QJSValueList() << obj); - - args.setProperty(QLatin1String(TYPE),QJSValue(QLatin1String(ALL))); - - if (!args.isUndefined()) { - jsonVal.setProperty(QLatin1String(ARGUMENTS),args); - } - - QJSValue json = stringify.call(QJSValueList() << jsonVal); - sendMessage(packMessage(V8REQUEST, json.toString().toUtf8())); -} - -void QJSDebugClient::listBreakpoints() -{ - // { "seq" : <number>, - // "type" : "request", - // "command" : "listbreakpoints", - // } - VARIANTMAPINIT; - jsonVal.setProperty(QLatin1String(COMMAND),QJSValue(QLatin1String(LISTBREAKPOINTS))); - - QJSValue json = stringify.call(QJSValueList() << jsonVal); - sendMessage(packMessage(V8REQUEST, json.toString().toUtf8())); -} - void QJSDebugClient::stateChanged(State state) { if (state == Enabled) { @@ -919,9 +744,7 @@ void QJSDebugClient::messageReceived(const QByteArray &data) debugCommand == "lookup" || debugCommand == "setbreakpoint" || debugCommand == "evaluate" || - debugCommand == "listbreakpoints" || debugCommand == "version" || - debugCommand == "v8flags" || debugCommand == "disconnect" || debugCommand == "gc" || debugCommand == "changebreakpoint" || @@ -1010,13 +833,13 @@ void tst_QQmlDebugJS::cleanupTestCase() bool tst_QQmlDebugJS::init(const QString &qmlFile, bool blockMode) { connection = new QQmlDebugConnection(); - process = new QQmlDebugProcess(QLibraryInfo::location(QLibraryInfo::BinariesPath) + "/qml", this); + process = new QQmlDebugProcess(QLibraryInfo::location(QLibraryInfo::BinariesPath) + "/qmlscene", this); client = new QJSDebugClient(connection); if (blockMode) - process->start(QStringList() << QLatin1String(ENABLE_DEBUG) << QLatin1String(BLOCKMODE) << testFile(qmlFile)); + process->start(QStringList() << QLatin1String(BLOCKMODE) << testFile(qmlFile)); else - process->start(QStringList() << QLatin1String(ENABLE_DEBUG) << QLatin1String(NORMALMODE) << testFile(qmlFile)); + process->start(QStringList() << QLatin1String(NORMALMODE) << testFile(qmlFile)); if (!process->waitForSessionStart()) { qDebug() << "could not launch application, or did not get 'Waiting for connection'."; @@ -1104,17 +927,6 @@ void tst_QQmlDebugJS::getVersionWhenAttaching() } */ -void tst_QQmlDebugJS::applyV8Flags() -{ - //void v8flags(QString flags) - - QVERIFY(init()); - client->connect(); - - client->v8flags(QString()); - QVERIFY(QQmlDebugTest::waitForSignal(client, SIGNAL(result()))); -} - void tst_QQmlDebugJS::disconnect() { //void disconnect() @@ -1126,45 +938,6 @@ void tst_QQmlDebugJS::disconnect() QVERIFY(QQmlDebugTest::waitForSignal(client, SIGNAL(result()))); } -void tst_QQmlDebugJS::gc() -{ - //void gc() - - QVERIFY(init()); - client->connect(); - - client->gc(); - QVERIFY(QQmlDebugTest::waitForSignal(client, SIGNAL(result()))); -} - -void tst_QQmlDebugJS::listBreakpoints() -{ - //void listBreakpoints() - - int sourceLine1 = 53; - int sourceLine2 = 54; - int sourceLine3 = 55; - - QVERIFY(init()); - client->connect(); - - client->setBreakpoint(QLatin1String(SCRIPTREGEXP), QLatin1String(TEST_QMLFILE), sourceLine1, -1, true); - QVERIFY(QQmlDebugTest::waitForSignal(client, SIGNAL(result()))); - client->setBreakpoint(QLatin1String(SCRIPTREGEXP), QLatin1String(TEST_QMLFILE), sourceLine2, -1, true); - QVERIFY(QQmlDebugTest::waitForSignal(client, SIGNAL(result()))); - client->setBreakpoint(QLatin1String(SCRIPTREGEXP), QLatin1String(TEST_QMLFILE), sourceLine3, -1, true); - QVERIFY(QQmlDebugTest::waitForSignal(client, SIGNAL(result()))); - client->listBreakpoints(); - QVERIFY(QQmlDebugTest::waitForSignal(client, SIGNAL(result()))); - - QString jsonString(client->response); - QVariantMap value = client->parser.call(QJSValueList() << QJSValue(jsonString)).toVariant().toMap(); - - QList<QVariant> breakpoints = value.value("body").toMap().value("breakpoints").toList(); - - QCOMPARE(breakpoints.count(), 3); -} - void tst_QQmlDebugJS::setBreakpointInScriptOnCompleted() { //void setBreakpoint(QString type, QString target, int line = -1, int column = -1, bool enabled = false, QString condition = QString(), int ignoreCount = -1) @@ -1308,8 +1081,11 @@ void tst_QQmlDebugJS::setBreakpointInScriptOnOptimizedBinding() QCOMPARE(QFileInfo(body.value("script").toMap().value("name").toString()).fileName(), QLatin1String(BREAKPOINTRELOCATION_QMLFILE)); } +#if 0 void tst_QQmlDebugJS::setBreakpointInScriptWithCondition() { + QFAIL("conditional breakpoints are not yet supported"); + //void setBreakpoint(QString type, QString target, int line = -1, int column = -1, bool enabled = false, QString condition = QString(), int ignoreCount = -1) int out = 10; @@ -1340,6 +1116,7 @@ void tst_QQmlDebugJS::setBreakpointInScriptWithCondition() QVERIFY(body.value("value").toInt() > out); } +#endif void tst_QQmlDebugJS::setBreakpointInScriptThatQuits() { @@ -1396,8 +1173,11 @@ void tst_QQmlDebugJS::setBreakpointWhenAttaching() // QCOMPARE(QFileInfo(body.value("script").toMap().value("name").toString()).fileName(), QLatin1String(QMLFILE)); //} +#if 0 void tst_QQmlDebugJS::setBreakpointOnEvent() { + QFAIL("Not implemented in V4."); + //void setBreakpoint(QString type, QString target, int line = -1, int column = -1, bool enabled = false, QString condition = QString(), int ignoreCount = -1) QVERIFY(init(TIMER_QMLFILE)); @@ -1414,97 +1194,7 @@ void tst_QQmlDebugJS::setBreakpointOnEvent() QCOMPARE(QFileInfo(body.value("script").toMap().value("name").toString()).fileName(), QLatin1String(TIMER_QMLFILE)); } - - -void tst_QQmlDebugJS::changeBreakpoint() -{ - //void changeBreakpoint(int breakpoint, bool enabled = false, QString condition = QString(), int ignoreCount = -1) - - int sourceLine1 = 50; - int sourceLine2 = 51; - QVERIFY(init(CHANGEBREAKPOINT_QMLFILE)); - - client->connect(); - client->setBreakpoint(QLatin1String(SCRIPTREGEXP), QLatin1String(CHANGEBREAKPOINT_QMLFILE), sourceLine2, -1, true); - client->setBreakpoint(QLatin1String(SCRIPTREGEXP), QLatin1String(CHANGEBREAKPOINT_QMLFILE), sourceLine1, -1, true); - - QVERIFY(QQmlDebugTest::waitForSignal(client, SIGNAL(stopped()))); - - //Will hit 1st brakpoint, change this breakpoint enable = false - QString jsonString(client->response); - QVariantMap value = client->parser.call(QJSValueList() << QJSValue(jsonString)).toVariant().toMap(); - - QVariantMap body = value.value("body").toMap(); - QList<QVariant> breakpointsHit = body.value("breakpoints").toList(); - - int breakpoint = breakpointsHit.at(0).toInt(); - client->changeBreakpoint(breakpoint,false); - - QVERIFY(QQmlDebugTest::waitForSignal(client, SIGNAL(result()))); - - //Continue with debugging - client->continueDebugging(QJSDebugClient::Continue); - //Hit 2nd breakpoint - QVERIFY(QQmlDebugTest::waitForSignal(client, SIGNAL(stopped()))); - - //Continue with debugging - client->continueDebugging(QJSDebugClient::Continue); - //Should stop at 2nd breakpoint - QVERIFY(QQmlDebugTest::waitForSignal(client, SIGNAL(stopped()))); - - jsonString = client->response; - value = client->parser.call(QJSValueList() << QJSValue(jsonString)).toVariant().toMap(); - - body = value.value("body").toMap(); - - QCOMPARE(body.value("sourceLine").toInt(), sourceLine2); -} - -void tst_QQmlDebugJS::changeBreakpointOnCondition() -{ - //void changeBreakpoint(int breakpoint, bool enabled = false, QString condition = QString(), int ignoreCount = -1) - - int sourceLine1 = 50; - int sourceLine2 = 51; - - QVERIFY(init(CHANGEBREAKPOINT_QMLFILE)); - - client->connect(); - client->setBreakpoint(QLatin1String(SCRIPTREGEXP), QLatin1String(CHANGEBREAKPOINT_QMLFILE), sourceLine1, -1, true); - client->setBreakpoint(QLatin1String(SCRIPTREGEXP), QLatin1String(CHANGEBREAKPOINT_QMLFILE), sourceLine2, -1, true); - - QVERIFY(QQmlDebugTest::waitForSignal(client, SIGNAL(stopped()))); - - //Will hit 1st brakpoint, change this breakpoint enable = false - QString jsonString(client->response); - QVariantMap value = client->parser.call(QJSValueList() << QJSValue(jsonString)).toVariant().toMap(); - - QVariantMap body = value.value("body").toMap(); - QList<QVariant> breakpointsHit = body.value("breakpoints").toList(); - - int breakpoint = breakpointsHit.at(0).toInt(); - client->changeBreakpoint(breakpoint, false, QLatin1String("d == 0")); - - QVERIFY(QQmlDebugTest::waitForSignal(client, SIGNAL(result()))); - - //Continue with debugging - client->continueDebugging(QJSDebugClient::Continue); - //Hit 2nd breakpoint - QVERIFY(QQmlDebugTest::waitForSignal(client, SIGNAL(stopped()))); - - //Continue with debugging - client->continueDebugging(QJSDebugClient::Continue); - //Should stop at 2nd breakpoint - QVERIFY(QQmlDebugTest::waitForSignal(client, SIGNAL(stopped()))); - - jsonString = client->response; - value = client->parser.call(QJSValueList() << QJSValue(jsonString)).toVariant().toMap(); - - body = value.value("body").toMap(); - - QCOMPARE(body.value("sourceLine").toInt(), sourceLine2); - -} +#endif void tst_QQmlDebugJS::clearBreakpoint() { @@ -1583,29 +1273,6 @@ void tst_QQmlDebugJS::stepNext() QCOMPARE(QFileInfo(body.value("script").toMap().value("name").toString()).fileName(), QLatin1String(STEPACTION_QMLFILE)); } -void tst_QQmlDebugJS::stepNextWithCount() -{ - //void continueDebugging(StepAction stepAction, int stepCount = 1); - - int sourceLine = 50; - QVERIFY(init(STEPACTION_QMLFILE)); - - client->connect(); - client->setBreakpoint(QLatin1String(SCRIPTREGEXP), QLatin1String(STEPACTION_QMLFILE), sourceLine, -1, true); - QVERIFY(QQmlDebugTest::waitForSignal(client, SIGNAL(stopped()))); - - client->continueDebugging(QJSDebugClient::Next, 2); - QVERIFY(QQmlDebugTest::waitForSignal(client, SIGNAL(stopped()))); - - QString jsonString(client->response); - QVariantMap value = client->parser.call(QJSValueList() << QJSValue(jsonString)).toVariant().toMap(); - - QVariantMap body = value.value("body").toMap(); - - QCOMPARE(body.value("sourceLine").toInt(), sourceLine + 2); - QCOMPARE(QFileInfo(body.value("script").toMap().value("name").toString()).fileName(), QLatin1String(STEPACTION_QMLFILE)); -} - void tst_QQmlDebugJS::stepIn() { //void continueDebugging(StepAction stepAction, int stepCount = 1); @@ -1724,6 +1391,7 @@ void tst_QQmlDebugJS::getScopeDetails() QVERIFY(QQmlDebugTest::waitForSignal(client, SIGNAL(result()))); } +#if 0 void tst_QQmlDebugJS::evaluateInGlobalScope() { //void evaluate(QString expr, bool global = false, bool disableBreak = false, int frame = -1, const QVariantMap &addContext = QVariantMap()); @@ -1742,7 +1410,9 @@ void tst_QQmlDebugJS::evaluateInGlobalScope() QCOMPARE(body.value("text").toString(),QLatin1String("undefined")); } +#endif +#if 0 void tst_QQmlDebugJS::evaluateInLocalScope() { //void evaluate(QString expr, bool global = false, bool disableBreak = false, int frame = -1, const QVariantMap &addContext = QVariantMap()); @@ -1776,21 +1446,7 @@ void tst_QQmlDebugJS::evaluateInLocalScope() QCOMPARE(body.value("value").toInt(),10); } - -void tst_QQmlDebugJS::getScopes() -{ - //void scopes(int frameNumber = -1); - - int sourceLine = 47; - QVERIFY(init(ONCOMPLETED_QMLFILE)); - - client->setBreakpoint(QLatin1String(SCRIPTREGEXP), QLatin1String(ONCOMPLETED_QMLFILE), sourceLine, -1, true); - client->connect(); - QVERIFY(QQmlDebugTest::waitForSignal(client, SIGNAL(stopped()))); - - client->scopes(); - QVERIFY(QQmlDebugTest::waitForSignal(client, SIGNAL(result()))); -} +#endif void tst_QQmlDebugJS::getScripts() { @@ -1798,7 +1454,9 @@ void tst_QQmlDebugJS::getScripts() QVERIFY(init()); + client->setBreakpoint(QLatin1String(SCRIPTREGEXP), QString(TEST_QMLFILE), 48, -1, true); client->connect(); + QVERIFY(QQmlDebugTest::waitForSignal(client, SIGNAL(stopped()))); client->scripts(); QVERIFY(QQmlDebugTest::waitForSignal(client, SIGNAL(scriptsResult()))); @@ -1808,22 +1466,8 @@ void tst_QQmlDebugJS::getScripts() QList<QVariant> scripts = value.value("body").toList(); - QCOMPARE(scripts.count(), 3); -} - -void tst_QQmlDebugJS::getSource() -{ - //void source(int frame = -1, int fromLine = -1, int toLine = -1); - - int sourceLine = 47; - QVERIFY(init(ONCOMPLETED_QMLFILE)); - - client->setBreakpoint(QLatin1String(SCRIPTREGEXP), QLatin1String(ONCOMPLETED_QMLFILE), sourceLine, -1, true); - client->connect(); - QVERIFY(QQmlDebugTest::waitForSignal(client, SIGNAL(stopped()))); - - client->source(); - QVERIFY(QQmlDebugTest::waitForSignal(client, SIGNAL(result()))); + QCOMPARE(scripts.count(), 1); + QVERIFY(scripts.first().toMap()[QStringLiteral("name")].toString().endsWith(QStringLiteral("data/test.qml"))); } QTEST_MAIN(tst_QQmlDebugJS) diff --git a/tests/auto/qml/debugger/qqmlenginedebuginspectorintegrationtest/tst_qqmlenginedebuginspectorintegration.cpp b/tests/auto/qml/debugger/qqmlenginedebuginspectorintegrationtest/tst_qqmlenginedebuginspectorintegration.cpp index 231e37c6fb..efb130d789 100644 --- a/tests/auto/qml/debugger/qqmlenginedebuginspectorintegrationtest/tst_qqmlenginedebuginspectorintegration.cpp +++ b/tests/auto/qml/debugger/qqmlenginedebuginspectorintegrationtest/tst_qqmlenginedebuginspectorintegration.cpp @@ -110,7 +110,7 @@ void tst_QQmlEngineDebugInspectorIntegration::init() // ### Still using qmlscene because of QTBUG-33376 m_process = new QQmlDebugProcess(QLibraryInfo::location(QLibraryInfo::BinariesPath) + "/qmlscene", this); - m_process->start(QStringList() << QLatin1String("-enable-debugger") << argument << testFile("qtquick2.qml")); + m_process->start(QStringList() << argument << testFile("qtquick2.qml")); QVERIFY2(m_process->waitForSessionStart(), "Could not launch application, or did not get 'Waiting for connection'."); diff --git a/tests/auto/qml/debugger/qqmlinspector/tst_qqmlinspector.cpp b/tests/auto/qml/debugger/qqmlinspector/tst_qqmlinspector.cpp index 2eeb4ce5b2..6a9ecdfa73 100644 --- a/tests/auto/qml/debugger/qqmlinspector/tst_qqmlinspector.cpp +++ b/tests/auto/qml/debugger/qqmlinspector/tst_qqmlinspector.cpp @@ -91,7 +91,7 @@ void tst_QQmlInspector::startQmlsceneProcess(const char * /* qmlFile */) // ### This should be using qml instead of qmlscene, but can't because of QTBUG-33376 (same as the XFAIL testcase) m_process = new QQmlDebugProcess(QLibraryInfo::location(QLibraryInfo::BinariesPath) + "/qmlscene", this); - m_process->start(QStringList() << QLatin1String("-enable-debugger") << argument << testFile("qtquick2.qml")); + m_process->start(QStringList() << argument << testFile("qtquick2.qml")); QVERIFY2(m_process->waitForSessionStart(), "Could not launch application, or did not get 'Waiting for connection'."); diff --git a/tests/auto/qml/debugger/qqmlprofilerservice/tst_qqmlprofilerservice.cpp b/tests/auto/qml/debugger/qqmlprofilerservice/tst_qqmlprofilerservice.cpp index 902e525dd6..f2b82db630 100644 --- a/tests/auto/qml/debugger/qqmlprofilerservice/tst_qqmlprofilerservice.cpp +++ b/tests/auto/qml/debugger/qqmlprofilerservice/tst_qqmlprofilerservice.cpp @@ -300,8 +300,6 @@ void tst_QQmlProfilerService::connect(bool block, const QString &testFile) // ### Still using qmlscene due to QTBUG-33377 const QString executable = QLibraryInfo::location(QLibraryInfo::BinariesPath) + "/qmlscene"; QStringList arguments; - arguments << QLatin1String("-enable-debugger"); - if (block) arguments << QString("-qmljsdebugger=port:" STR_PORT_FROM "," STR_PORT_TO ",block"); else @@ -450,8 +448,9 @@ void tst_QQmlProfilerService::scenegraphData() QTRY_COMPARE(m_client->state(), QQmlDebugClient::Enabled); m_client->setTraceState(true); - QVERIFY(QQmlDebugTest::waitForSignal(m_process, SIGNAL(readyReadStandardOutput()))); - QVERIFY(m_process->output().indexOf(QLatin1String("tick")) != -1); + + while (!m_process->output().contains(QLatin1String("tick"))) + QVERIFY(QQmlDebugTest::waitForSignal(m_process, SIGNAL(readyReadStandardOutput()))); m_client->setTraceState(false); QVERIFY2(QQmlDebugTest::waitForSignal(m_client, SIGNAL(complete())), "No trace received in time."); diff --git a/tests/auto/qml/debugger/qv8profilerservice/tst_qv8profilerservice.cpp b/tests/auto/qml/debugger/qv8profilerservice/tst_qv8profilerservice.cpp index f0485fb68a..a461519c75 100644 --- a/tests/auto/qml/debugger/qv8profilerservice/tst_qv8profilerservice.cpp +++ b/tests/auto/qml/debugger/qv8profilerservice/tst_qv8profilerservice.cpp @@ -206,7 +206,6 @@ bool tst_QV8ProfilerService::connect(bool block, const QString &testFile, { const QString executable = QLibraryInfo::location(QLibraryInfo::BinariesPath) + "/qml"; QStringList arguments; - arguments << QLatin1String("-enable-debugger"); if (block) arguments << QString("-qmljsdebugger=port:" STR_PORT_FROM "," STR_PORT_TO ",block"); diff --git a/tests/auto/qml/debugger/shared/qqmldebugclient.cpp b/tests/auto/qml/debugger/shared/qqmldebugclient.cpp index 95674ce6d7..6474a04796 100644 --- a/tests/auto/qml/debugger/shared/qqmldebugclient.cpp +++ b/tests/auto/qml/debugger/shared/qqmldebugclient.cpp @@ -449,6 +449,7 @@ QString QQmlDebugClient::stateString() const case Unavailable: return QLatin1String("Unavailable"); case Enabled: return QLatin1String("Enabled"); } + return QLatin1String("Invalid"); } void QQmlDebugClient::sendMessage(const QByteArray &message) diff --git a/tests/auto/qml/qjsvalue/tst_qjsvalue.cpp b/tests/auto/qml/qjsvalue/tst_qjsvalue.cpp index 2b8da26dc9..e73edc812a 100644 --- a/tests/auto/qml/qjsvalue/tst_qjsvalue.cpp +++ b/tests/auto/qml/qjsvalue/tst_qjsvalue.cpp @@ -2206,7 +2206,7 @@ void tst_QJSValue::strictlyEquals() { QJSValue var1 = eng.toScriptValue(QVariant(QPoint(1, 2))); QJSValue var2 = eng.toScriptValue(QVariant(QPoint(1, 2))); - QVERIFY(!var1.strictlyEquals(var2)); + QVERIFY(var1.strictlyEquals(var2)); } { QJSValue var1 = eng.toScriptValue(QVariant(QPoint(1, 2))); diff --git a/tests/auto/qml/qqmlecmascript/data/idAsLValue.qml b/tests/auto/qml/qqmlecmascript/data/idAsLValue.qml new file mode 100644 index 0000000000..1035f844b4 --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/idAsLValue.qml @@ -0,0 +1,7 @@ +import QtQml 2.0 +QtObject { + id: root + Component.onCompleted: { + root = "hello" + } +} diff --git a/tests/auto/qml/qqmlecmascript/data/misctypetest.qml b/tests/auto/qml/qqmlecmascript/data/misctypetest.qml new file mode 100644 index 0000000000..60ff53a2b4 --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/misctypetest.qml @@ -0,0 +1,28 @@ +import QtQuick 2.0 +import Qt.test 1.0 + +Item { + MiscTypeTest { + id: mtt + } + + function test_invalid_url_equal() + { + return mtt.invalidUrl() == mtt.invalidUrl(); + } + + function test_invalid_url_refequal() + { + return mtt.invalidUrl() === mtt.invalidUrl(); + } + + function test_valid_url_equal() + { + return mtt.validUrl() == mtt.validUrl(); + } + + function test_valid_url_refequal() + { + return mtt.validUrl() === mtt.validUrl(); + } +} diff --git a/tests/auto/qml/qqmlecmascript/data/qtbug34792.qml b/tests/auto/qml/qqmlecmascript/data/qtbug34792.qml new file mode 100644 index 0000000000..37c551b587 --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/qtbug34792.qml @@ -0,0 +1,14 @@ +import QtQuick 2.1 +Rectangle { + function foo() + { + for (var i = 0; i < 1; i++) + { + if (i >= 0) + break + + return + } + + } +} diff --git a/tests/auto/qml/qqmlecmascript/data/qtbug_33754.qml b/tests/auto/qml/qqmlecmascript/data/qtbug_33754.qml new file mode 100644 index 0000000000..705334fbfa --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/qtbug_33754.qml @@ -0,0 +1,12 @@ +import QtQuick 2.0 + +Item { + property int a: 0 + property int b: 0 + + Component.onCompleted: { + for (var i = ((a > b) ? b : a); i < ((a > b) ? a : b); i++) + { + } + } +} diff --git a/tests/auto/qml/qqmlecmascript/data/qtbug_34493.qml b/tests/auto/qml/qqmlecmascript/data/qtbug_34493.qml new file mode 100644 index 0000000000..7e7d350aae --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/qtbug_34493.qml @@ -0,0 +1,19 @@ +import Qt.test 1.0 +import QtQuick 2.0 + +MyQmlObject { + function doIt() { + d.hello("World") + } + + property QtObject subobject: QtObject { + id: d + function hello(input) { + var temp = "Hello " + input; + var input = temp + "!"; + prop = input + } + } + + property string prop +} diff --git a/tests/auto/qml/qqmlecmascript/data/sequenceConversion.indexes.qml b/tests/auto/qml/qqmlecmascript/data/sequenceConversion.indexes.qml index 962e8dd474..a3f306f717 100644 --- a/tests/auto/qml/qqmlecmascript/data/sequenceConversion.indexes.qml +++ b/tests/auto/qml/qqmlecmascript/data/sequenceConversion.indexes.qml @@ -72,4 +72,17 @@ Item { if (!verifyExpected(msco.intListProperty, 4)) success = false; } + + function indexOf() { + if (msco.qstringListProperty.length != 4) + success = false; + if (msco.qstringListProperty.indexOf("first") != 0) + success = false; + if (msco.qstringListProperty.indexOf("second") != 1) + success = false; + if (msco.qstringListProperty.indexOf("third") != 2) + success = false; + if (msco.qstringListProperty.indexOf("fourth") != 3) + success = false; + } } diff --git a/tests/auto/qml/qqmlecmascript/data/setPropertyOnNull.qml b/tests/auto/qml/qqmlecmascript/data/setPropertyOnNull.qml new file mode 100644 index 0000000000..a3288f47d7 --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/setPropertyOnNull.qml @@ -0,0 +1,5 @@ +import QtQuick 2.2 + +QtObject { + Component.onCompleted: null.bug = 0 +} diff --git a/tests/auto/qml/qqmlecmascript/data/setPropertyOnUndefined.qml b/tests/auto/qml/qqmlecmascript/data/setPropertyOnUndefined.qml new file mode 100644 index 0000000000..6655c47e5f --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/setPropertyOnUndefined.qml @@ -0,0 +1,5 @@ +import QtQuick 2.2 + +QtObject { + Component.onCompleted: undefined.bug = 0 +} diff --git a/tests/auto/qml/qqmlecmascript/data/singletonTest.qml b/tests/auto/qml/qqmlecmascript/data/singletonTest.qml new file mode 100644 index 0000000000..6d296cd613 --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/singletonTest.qml @@ -0,0 +1,48 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Canonical Limited and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the examples 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 Digia Plc and its Subsidiary(-ies) 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.0 +import Test 1.0 + +Item { + property bool qobjectTest: MyInheritedQmlObjectSingleton.isItYouQObject(MyInheritedQmlObjectSingleton) + property bool myQmlObjectTest: MyInheritedQmlObjectSingleton.isItYouMyQmlObject(MyInheritedQmlObjectSingleton) + property bool myInheritedQmlObjectTest: MyInheritedQmlObjectSingleton.isItYouMyInheritedQmlObject(MyInheritedQmlObjectSingleton) +} diff --git a/tests/auto/qml/qqmlecmascript/data/singletonTest2.qml b/tests/auto/qml/qqmlecmascript/data/singletonTest2.qml new file mode 100644 index 0000000000..ec457589de --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/singletonTest2.qml @@ -0,0 +1,74 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Canonical Limited and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the examples 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 Digia Plc and its Subsidiary(-ies) 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.0 +import Test 1.0 + +Item { + property bool myInheritedQmlObjectTest1: false + property bool myInheritedQmlObjectTest2: false + property bool myInheritedQmlObjectTest3: false + property bool myQmlObjectTest1: false + property bool myQmlObjectTest2: false + property bool myQmlObjectTest3: false + property bool qobjectTest1: false + property bool qobjectTest2: false + property bool qobjectTest3: false + property bool singletonEqualToItself: true + + Component.onCompleted: { + MyInheritedQmlObjectSingleton.myInheritedQmlObjectProperty = MyInheritedQmlObjectSingleton; + myInheritedQmlObjectTest1 = MyInheritedQmlObjectSingleton.myInheritedQmlObjectProperty == MyInheritedQmlObjectSingleton; + myInheritedQmlObjectTest2 = MyInheritedQmlObjectSingleton.myInheritedQmlObjectProperty == MyInheritedQmlObjectSingleton.myInheritedQmlObjectProperty; + myInheritedQmlObjectTest3 = MyInheritedQmlObjectSingleton == MyInheritedQmlObjectSingleton.myInheritedQmlObjectProperty; + + MyInheritedQmlObjectSingleton.myQmlObjectProperty = MyInheritedQmlObjectSingleton; + myQmlObjectTest1 = MyInheritedQmlObjectSingleton.myQmlObjectProperty == MyInheritedQmlObjectSingleton; + myQmlObjectTest2 = MyInheritedQmlObjectSingleton.myQmlObjectProperty == MyInheritedQmlObjectSingleton.myQmlObjectProperty; + myQmlObjectTest3 = MyInheritedQmlObjectSingleton == MyInheritedQmlObjectSingleton.myQmlObjectProperty; + + MyInheritedQmlObjectSingleton.qobjectProperty = MyInheritedQmlObjectSingleton; + qobjectTest1 = MyInheritedQmlObjectSingleton.qobjectProperty == MyInheritedQmlObjectSingleton; + qobjectTest2 = MyInheritedQmlObjectSingleton.qobjectProperty == MyInheritedQmlObjectSingleton.qobjectProperty; + qobjectTest3 = MyInheritedQmlObjectSingleton == MyInheritedQmlObjectSingleton.qobjectProperty; + + singletonEqualToItself = MyInheritedQmlObjectSingleton == MyInheritedQmlObjectSingleton; + } +} diff --git a/tests/auto/qml/qqmlecmascript/data/thisObject.qml b/tests/auto/qml/qqmlecmascript/data/thisObject.qml new file mode 100644 index 0000000000..c93d0302cf --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/thisObject.qml @@ -0,0 +1,10 @@ +import QtQml 2.0 +QtObject { + property int value: 1 + property QtObject subObject: QtObject { + property int value: 2 + property int test: { + return this.value; + } + } +} diff --git a/tests/auto/qml/qqmlecmascript/data/updateCall.qml b/tests/auto/qml/qqmlecmascript/data/updateCall.qml new file mode 100644 index 0000000000..341a360d25 --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/updateCall.qml @@ -0,0 +1,10 @@ +import QtQuick 2.1
+
+Rectangle {
+ MouseArea {
+ anchors.fill: parent;
+ Component.onCompleted: {
+ update();
+ }
+ }
+}
diff --git a/tests/auto/qml/qqmlecmascript/testtypes.cpp b/tests/auto/qml/qqmlecmascript/testtypes.cpp index a09bd9f3c6..41fa3672bd 100644 --- a/tests/auto/qml/qqmlecmascript/testtypes.cpp +++ b/tests/auto/qml/qqmlecmascript/testtypes.cpp @@ -235,6 +235,21 @@ public: } }; +class MiscTypeTestClass : public QObject +{ + Q_OBJECT +public: + Q_INVOKABLE QUrl invalidUrl() + { + return QUrl(); + } + + Q_INVOKABLE QUrl validUrl() + { + return QUrl("http://wwww.qt-project.org"); + } +}; + class MyStringClass : public QObject { Q_OBJECT @@ -257,10 +272,34 @@ public: } }; +static MyInheritedQmlObject *theSingletonObject = 0; + +static QObject *inheritedQmlObject_provider(QQmlEngine* /* engine */, QJSEngine* /* scriptEngine */) +{ + theSingletonObject = new MyInheritedQmlObject(); + return theSingletonObject; +} + +bool MyInheritedQmlObject::isItYouQObject(QObject *o) +{ + return o && o == theSingletonObject; +} + +bool MyInheritedQmlObject::isItYouMyQmlObject(MyQmlObject *o) +{ + return o && o == theSingletonObject; +} + +bool MyInheritedQmlObject::isItYouMyInheritedQmlObject(MyInheritedQmlObject *o) +{ + return o && o == theSingletonObject; +} + void registerTypes() { qmlRegisterType<MyQmlObject>("Qt.test", 1,0, "MyQmlObjectAlias"); qmlRegisterType<MyQmlObject>("Qt.test", 1,0, "MyQmlObject"); + qmlRegisterSingletonType<MyInheritedQmlObject>("Test", 1, 0, "MyInheritedQmlObjectSingleton", inheritedQmlObject_provider); qmlRegisterType<MyDeferredObject>("Qt.test", 1,0, "MyDeferredObject"); qmlRegisterType<MyVeryDeferredObject>("Qt.test", 1,0, "MyVeryDeferredObject"); qmlRegisterType<MyQmlContainer>("Qt.test", 1,0, "MyQmlContainer"); @@ -329,6 +368,7 @@ void registerTypes() qmlRegisterType<MyDateClass>("Qt.test", 1, 0, "MyDateClass"); qmlRegisterType<MyStringClass>("Qt.test", 1, 0, "MyStringClass"); + qmlRegisterType<MiscTypeTestClass>("Qt.test", 1, 0, "MiscTypeTest"); qmlRegisterSingletonType<testImportOrderApi>("Qt.test.importOrderApi",1,0,"Data",testImportOrder_api); qmlRegisterSingletonType<testImportOrderApi>("NamespaceAndType",1,0,"NamespaceAndType",testImportOrder_api); diff --git a/tests/auto/qml/qqmlecmascript/testtypes.h b/tests/auto/qml/qqmlecmascript/testtypes.h index 0fdcdafb95..556cc32fd3 100644 --- a/tests/auto/qml/qqmlecmascript/testtypes.h +++ b/tests/auto/qml/qqmlecmascript/testtypes.h @@ -291,6 +291,34 @@ Q_DECLARE_METATYPE(QQmlListProperty<MyQmlObject>) QML_DECLARE_TYPEINFO(MyQmlObject, QML_HAS_ATTACHED_PROPERTIES) +class MyInheritedQmlObject : public MyQmlObject +{ + Q_OBJECT + Q_PROPERTY(MyInheritedQmlObject *myInheritedQmlObjectProperty READ myInheritedQmlObject WRITE setMyInheritedQmlObject) + Q_PROPERTY(MyQmlObject *myQmlObjectProperty READ myQmlObject WRITE setMyQmlObject) + Q_PROPERTY(QObject *qobjectProperty READ qobject WRITE setQObject) +public: + MyInheritedQmlObject() : m_myInheritedQmlObject(0), m_myQmlObject(0), m_qobject(0) {} + + MyInheritedQmlObject *myInheritedQmlObject() const { return m_myInheritedQmlObject; } + void setMyInheritedQmlObject(MyInheritedQmlObject * o) { m_myInheritedQmlObject = o; } + + MyQmlObject *myQmlObject() const { return m_myQmlObject; } + void setMyQmlObject(MyQmlObject * o) { m_myQmlObject = o; } + + QObject *qobject() const { return m_qobject; } + void setQObject(QObject * o) { m_qobject = o; } + + Q_INVOKABLE bool isItYouQObject(QObject *o); + Q_INVOKABLE bool isItYouMyQmlObject(MyQmlObject *o); + Q_INVOKABLE bool isItYouMyInheritedQmlObject(MyInheritedQmlObject *o); +private: + MyInheritedQmlObject *m_myInheritedQmlObject; + MyQmlObject *m_myQmlObject; + QObject *m_qobject; +}; +QML_DECLARE_TYPE(MyInheritedQmlObject) + class MyQmlContainer : public QObject { Q_OBJECT @@ -993,7 +1021,7 @@ class MyRevisionedClass : public MyRevisionedBaseClassUnregistered Q_PROPERTY(qreal prop2 READ prop2 WRITE setProp2 NOTIFY prop2Changed REVISION 1) public: - MyRevisionedClass() {} + MyRevisionedClass() : m_p1(0), m_p2(0) {} qreal prop1() const { return m_p1; } void setProp1(qreal p) { diff --git a/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp b/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp index e764ae783c..6b19c13109 100644 --- a/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp +++ b/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp @@ -304,9 +304,21 @@ private slots: void propertyOverride(); void concatenatedStringPropertyAccess(); void jsOwnedObjectsDeletedOnEngineDestroy(); + void updateCall(); void numberParsing(); void stringParsing(); + void push_and_shift(); void qtbug_32801(); + void thisObject(); + void qtbug_33754(); + void qtbug_34493(); + void singletonFromQMLToCpp(); + void singletonFromQMLAndBackAndCompare(); + void setPropertyOnInvalid(); + void miscTypeTest(); + void stackLimits(); + void idsAsLValues(); + void qtbug_34792(); private: // static void propertyVarWeakRefCallback(v8::Persistent<v8::Value> object, void* parameter); @@ -1304,6 +1316,7 @@ void tst_qqmlecmascript::scope() QVERIFY(object != 0); QCOMPARE(object->property("test1").toBool(), true); + QEXPECT_FAIL("", "Properties resolvable at compile time come before the global object, which is not 100% compatible with older QML versions", Continue); QCOMPARE(object->property("test2").toBool(), true); QCOMPARE(object->property("test3").toBool(), true); @@ -2257,15 +2270,16 @@ static inline bool evaluate_error(QV8Engine *engine, const QV4::ValueRef o, cons QV4::ExecutionContext *ctx = QV8Engine::getV4(engine)->current; QV4::Scope scope(ctx); - try { - QV4::Scoped<QV4::FunctionObject> function(scope, program.run()); - if (!function) - return false; - QV4::ScopedCallData d(scope, 1); - d->args[0] = o; - d->thisObject = engine->global(); - function->call(d); - } catch (...) { + QV4::Scoped<QV4::FunctionObject> function(scope, program.run()); + if (scope.engine->hasException) { + ctx->catchException(); + return true; + } + QV4::ScopedCallData d(scope, 1); + d->args[0] = o; + d->thisObject = engine->global(); + function->call(d); + if (scope.engine->hasException) { ctx->catchException(); return true; } @@ -2284,21 +2298,24 @@ static inline bool evaluate_value(QV8Engine *engine, const QV4::ValueRef o, QV4::ExecutionContext *ctx = QV8Engine::getV4(engine)->current; QV4::Scope scope(ctx); - try { - QV4::Scoped<QV4::FunctionObject> function(scope, program.run()); - if (!function) - return false; - - QV4::ScopedValue value(scope); - QV4::ScopedCallData d(scope, 1); - d->args[0] = o; - d->thisObject = engine->global(); - value = function->call(d); - return __qmljs_strict_equal(value, result); - } catch (...) { + QV4::Scoped<QV4::FunctionObject> function(scope, program.run()); + if (scope.engine->hasException) { ctx->catchException(); + return false; } - return false; + if (!function) + return false; + + QV4::ScopedValue value(scope); + QV4::ScopedCallData d(scope, 1); + d->args[0] = o; + d->thisObject = engine->global(); + value = function->call(d); + if (scope.engine->hasException) { + ctx->catchException(); + return false; + } + return __qmljs_strict_equal(value, result); } static inline QV4::ReturnedValue evaluate(QV8Engine *engine, const QV4::ValueRef o, @@ -2312,18 +2329,23 @@ static inline QV4::ReturnedValue evaluate(QV8Engine *engine, const QV4::ValueRef QV4::Script program(QV8Engine::getV4(engine)->rootContext, functionSource); program.inheritContext = true; - try { - QV4::Scoped<QV4::FunctionObject> function(scope, program.run()); - if (!function) - return QV4::Encode::undefined(); - QV4::ScopedCallData d(scope, 1); - d->args[0] = o; - d->thisObject = engine->global(); - return function->call(d); - } catch (...) { + + QV4::Scoped<QV4::FunctionObject> function(scope, program.run()); + if (scope.engine->hasException) { + ctx->catchException(); + return QV4::Encode::undefined(); + } + if (!function) + return QV4::Encode::undefined(); + QV4::ScopedCallData d(scope, 1); + d->args[0] = o; + d->thisObject = engine->global(); + QV4::ScopedValue result(scope, function->call(d)); + if (scope.engine->hasException) { ctx->catchException(); + return QV4::Encode::undefined(); } - return QV4::Encode::undefined(); + return result.asReturnedValue(); } #define EVALUATE_ERROR(source) evaluate_error(engine, object, source) @@ -3479,9 +3501,9 @@ void tst_qqmlecmascript::compiled() QCOMPARE(object->property("test15").toBool(), false); QCOMPARE(object->property("test16").toBool(), true); - QCOMPARE(object->property("test17").toInt(), 5); + QCOMPARE(object->property("test17").toInt(), 4); QCOMPARE(object->property("test18").toReal(), qreal(176)); - QCOMPARE(object->property("test19").toInt(), 7); + QCOMPARE(object->property("test19").toInt(), 6); QCOMPARE(object->property("test20").toReal(), qreal(6.7)); QCOMPARE(object->property("test21").toString(), QLatin1String("6.7")); QCOMPARE(object->property("test22").toString(), QLatin1String("!")); @@ -3506,7 +3528,7 @@ void tst_qqmlecmascript::numberAssignment() QCOMPARE(object->property("test3"), QVariant((qreal)6)); QCOMPARE(object->property("test4"), QVariant((qreal)6)); - QCOMPARE(object->property("test5"), QVariant((int)7)); + QCOMPARE(object->property("test5"), QVariant((int)6)); QCOMPARE(object->property("test6"), QVariant((int)7)); QCOMPARE(object->property("test7"), QVariant((int)6)); QCOMPARE(object->property("test8"), QVariant((int)6)); @@ -3880,15 +3902,15 @@ void tst_qqmlecmascript::singletonTypeResolution() void tst_qqmlecmascript::verifyContextLifetime(QQmlContextData *ctxt) { QQmlContextData *childCtxt = ctxt->childContexts; - if (!ctxt->importedScripts.isEmpty()) { + if (!ctxt->importedScripts.isNullOrUndefined()) { QV8Engine *engine = QV8Engine::get(ctxt->engine); - foreach (const QV4::PersistentValue& qmlglobal, ctxt->importedScripts) { + QV4::ExecutionEngine *v4 = QV8Engine::getV4(engine); + QV4::Scope scope(v4); + QV4::ScopedArrayObject scripts(scope, ctxt->importedScripts); + QV4::ScopedValue qml(scope); + for (quint32 i = 0; i < scripts->arrayLength(); ++i) { QQmlContextData *scriptContext, *newContext; - - if (qmlglobal.isUndefined()) - continue; - QV4::Scope scope(QV8Engine::getV4((engine))); - QV4::ScopedValue qml(scope, qmlglobal.value()); + qml = scripts->getIndexed(i); scriptContext = QV4::QmlContextWrapper::getContext(qml); qml = QV4::Encode::undefined(); @@ -3900,7 +3922,7 @@ void tst_qqmlecmascript::verifyContextLifetime(QQmlContextData *ctxt) { } engine->gc(); - qml = qmlglobal.value(); + qml = scripts->getIndexed(i); newContext = QV4::QmlContextWrapper::getContext(qml); QVERIFY(scriptContext == newContext); } @@ -5411,6 +5433,8 @@ void tst_qqmlecmascript::sequenceConversionIndexes() QTest::ignoreMessage(QtWarningMsg, qPrintable(w3)); QMetaObject::invokeMethod(object, "indexedAccess"); QVERIFY(object->property("success").toBool()); + QMetaObject::invokeMethod(object, "indexOf"); + QVERIFY(object->property("success").toBool()); delete object; } @@ -6435,7 +6459,7 @@ void tst_qqmlecmascript::realToInt() QMetaObject::invokeMethod(object, "test1"); QCOMPARE(object->value(), int(4)); QMetaObject::invokeMethod(object, "test2"); - QCOMPARE(object->value(), int(8)); + QCOMPARE(object->value(), int(7)); } void tst_qqmlecmascript::urlProperty() @@ -7261,6 +7285,17 @@ void tst_qqmlecmascript::jsOwnedObjectsDeletedOnEngineDestroy() delete object; } +void tst_qqmlecmascript::updateCall() +{ + // update is a slot on QQuickItem. Even though it's not + // documented it can be called from within QML. Make sure + // we don't crash when calling it. + QString file("updateCall.qml"); + QQmlComponent component(&engine, testFileUrl(file)); + QObject *object = component.create(); + QVERIFY(object != 0); +} + void tst_qqmlecmascript::numberParsing() { for (int i = 1; i < 8; ++i) { @@ -7289,6 +7324,18 @@ void tst_qqmlecmascript::stringParsing() } } +void tst_qqmlecmascript::push_and_shift() +{ + QJSEngine e; + const QString program = + "var array = []; " + "for (var i = 0; i < 10000; i++) {" + " array.push(5); array.unshift(5); array.push(5);" + "}" + "array.length;"; + QVERIFY(e.evaluate(program).toNumber() == 30000); +} + void tst_qqmlecmascript::qtbug_32801() { QQmlComponent component(&engine, testFileUrl("qtbug_32801.qml")); @@ -7301,6 +7348,149 @@ void tst_qqmlecmascript::qtbug_32801() QVERIFY(QMetaObject::invokeMethod(obj.data(), "emitTestSignal")); } +void tst_qqmlecmascript::thisObject() +{ + QQmlComponent component(&engine, testFileUrl("thisObject.qml")); + QObject *object = component.create(); + QVERIFY(object); + QCOMPARE(qvariant_cast<QObject*>(object->property("subObject"))->property("test").toInt(), 2); + delete object; +} + +void tst_qqmlecmascript::qtbug_33754() +{ + QQmlComponent component(&engine, testFileUrl("qtbug_33754.qml")); + + QScopedPointer<QObject> obj(component.create()); + QVERIFY(obj != 0); +} + +void tst_qqmlecmascript::qtbug_34493() +{ + QQmlComponent component(&engine, testFileUrl("qtbug_34493.qml")); + + QScopedPointer<QObject> obj(component.create()); + if (component.errors().size()) + qDebug() << component.errors(); + QVERIFY(component.errors().isEmpty()); + QVERIFY(obj != 0); + QVERIFY(QMetaObject::invokeMethod(obj.data(), "doIt")); + QTRY_VERIFY(obj->property("prop").toString() == QLatin1String("Hello World!")); +} + +// Check that a Singleton can be passed from QML to C++ +// as its type*, it's parent type* and as QObject* +void tst_qqmlecmascript::singletonFromQMLToCpp() +{ + QQmlComponent component(&engine, testFile("singletonTest.qml")); + QScopedPointer<QObject> obj(component.create()); + if (component.errors().size()) + qDebug() << component.errors(); + QVERIFY(component.errors().isEmpty()); + QVERIFY(obj != 0); + + QCOMPARE(obj->property("qobjectTest"), QVariant(true)); + QCOMPARE(obj->property("myQmlObjectTest"), QVariant(true)); + QCOMPARE(obj->property("myInheritedQmlObjectTest"), QVariant(true)); +} + +// Check that a Singleton can be passed from QML to C++ +// as its type*, it's parent type* and as QObject* +// and correctly compares to itself +void tst_qqmlecmascript::singletonFromQMLAndBackAndCompare() +{ + QQmlComponent component(&engine, testFile("singletonTest2.qml")); + QScopedPointer<QObject> o(component.create()); + if (component.errors().size()) + qDebug() << component.errors(); + QVERIFY(component.errors().isEmpty()); + QVERIFY(o != 0); + + QCOMPARE(o->property("myInheritedQmlObjectTest1"), QVariant(true)); + QCOMPARE(o->property("myInheritedQmlObjectTest2"), QVariant(true)); + QCOMPARE(o->property("myInheritedQmlObjectTest3"), QVariant(true)); + + QCOMPARE(o->property("myQmlObjectTest1"), QVariant(true)); + QCOMPARE(o->property("myQmlObjectTest2"), QVariant(true)); + QCOMPARE(o->property("myQmlObjectTest3"), QVariant(true)); + + QCOMPARE(o->property("qobjectTest1"), QVariant(true)); + QCOMPARE(o->property("qobjectTest2"), QVariant(true)); + QCOMPARE(o->property("qobjectTest3"), QVariant(true)); + + QCOMPARE(o->property("singletonEqualToItself"), QVariant(true)); +} + +void tst_qqmlecmascript::setPropertyOnInvalid() +{ + { + QQmlComponent component(&engine, testFileUrl("setPropertyOnNull.qml")); + QString warning = component.url().toString() + ":4: TypeError: Type error"; + QTest::ignoreMessage(QtWarningMsg, qPrintable(warning)); + QObject *object = component.create(); + QVERIFY(object); + delete object; + } + + { + QQmlComponent component(&engine, testFileUrl("setPropertyOnUndefined.qml")); + QString warning = component.url().toString() + ":4: TypeError: Type error"; + QTest::ignoreMessage(QtWarningMsg, qPrintable(warning)); + QObject *object = component.create(); + QVERIFY(object); + delete object; + } +} + +void tst_qqmlecmascript::miscTypeTest() +{ + QQmlComponent component(&engine, testFileUrl("misctypetest.qml")); + + QObject *object = component.create(); + if (object == 0) + qDebug() << component.errorString(); + QVERIFY(object != 0); + + QVariant q; + QMetaObject::invokeMethod(object, "test_invalid_url_equal", Q_RETURN_ARG(QVariant, q)); + QVERIFY(q.toBool() == true); + QMetaObject::invokeMethod(object, "test_invalid_url_strictequal", Q_RETURN_ARG(QVariant, q)); + QVERIFY(q.toBool() == true); + QMetaObject::invokeMethod(object, "test_valid_url_equal", Q_RETURN_ARG(QVariant, q)); + QVERIFY(q.toBool() == true); + QMetaObject::invokeMethod(object, "test_valid_url_strictequal", Q_RETURN_ARG(QVariant, q)); + QVERIFY(q.toBool() == true); + + delete object; +} + +void tst_qqmlecmascript::stackLimits() +{ + QJSEngine engine; + engine.evaluate(QStringLiteral("function foo() {foo();} try {foo()} catch(e) { }")); +} + +void tst_qqmlecmascript::idsAsLValues() +{ + QString err = QString(QLatin1String("%1:5 left-hand side of assignment operator is not an lvalue\n")).arg(testFileUrl("idAsLValue.qml").toString()); + QQmlComponent component(&engine, testFileUrl("idAsLValue.qml")); + QTest::ignoreMessage(QtWarningMsg, "QQmlComponent: Component is not ready"); + MyQmlObject *object = qobject_cast<MyQmlObject*>(component.create()); + QVERIFY(!object); + QCOMPARE(component.errorString(), err); +} + +void tst_qqmlecmascript::qtbug_34792() +{ + QQmlComponent component(&engine, testFileUrl("qtbug34792.qml")); + + QObject *object = component.create(); + if (object == 0) + qDebug() << component.errorString(); + QVERIFY(object != 0); + delete object; +} + QTEST_MAIN(tst_qqmlecmascript) #include "tst_qqmlecmascript.moc" diff --git a/tests/auto/qml/qqmlengine/data/interception/imports/Test.2/qmldir b/tests/auto/qml/qqmlengine/data/interception/imports/Test.2/qmldir new file mode 100644 index 0000000000..971812c162 --- /dev/null +++ b/tests/auto/qml/qqmlengine/data/interception/imports/Test.2/qmldir @@ -0,0 +1 @@ +This qmldir file is intentionally invalid, as the URL interception should prevent it being accessed. diff --git a/tests/auto/qml/qqmlengine/data/interception/module/intercepted/Intercepted.qml b/tests/auto/qml/qqmlengine/data/interception/module/intercepted/Intercepted.qml new file mode 100644 index 0000000000..5416ef5dcc --- /dev/null +++ b/tests/auto/qml/qqmlengine/data/interception/module/intercepted/Intercepted.qml @@ -0,0 +1,9 @@ +import QtQml 2.0 + +QtObject { + property url filePath: "doesNotExist.file" + property url resolvedUrl: Qt.resolvedUrl("doesNotExist.file"); + property url absoluteUrl: Qt.resolvedUrl("file:///doesNotExist.file"); + property string childString: "intercepted" + property string scriptString: "intercepted" +} diff --git a/tests/auto/qml/qqmlengine/data/interception/module/intercepted/comment b/tests/auto/qml/qqmlengine/data/interception/module/intercepted/comment new file mode 100644 index 0000000000..b10233e48d --- /dev/null +++ b/tests/auto/qml/qqmlengine/data/interception/module/intercepted/comment @@ -0,0 +1 @@ +Note that the paths are relative the the qmldir file in the actual module path, not the intercepted qmldir file diff --git a/tests/auto/qml/qqmlengine/data/interception/module/intercepted/qmldir b/tests/auto/qml/qqmlengine/data/interception/module/intercepted/qmldir new file mode 100644 index 0000000000..c5457b232a --- /dev/null +++ b/tests/auto/qml/qqmlengine/data/interception/module/intercepted/qmldir @@ -0,0 +1 @@ +TestObject 2.0 ../../module/intercepted/Intercepted.qml diff --git a/tests/auto/qml/qqmlengine/data/interception/module/urlInterceptor.qml b/tests/auto/qml/qqmlengine/data/interception/module/urlInterceptor.qml new file mode 100644 index 0000000000..b79a783582 --- /dev/null +++ b/tests/auto/qml/qqmlengine/data/interception/module/urlInterceptor.qml @@ -0,0 +1,3 @@ +import Test 2.0 //This import will be intercepted to make this file valid + +TestObject {} diff --git a/tests/auto/qml/qqmlengine/tst_qqmlengine.cpp b/tests/auto/qml/qqmlengine/tst_qqmlengine.cpp index 42e17d5624..382bfe4b73 100644 --- a/tests/auto/qml/qqmlengine/tst_qqmlengine.cpp +++ b/tests/auto/qml/qqmlengine/tst_qqmlengine.cpp @@ -54,7 +54,7 @@ #include <QQmlExpression> #include <QQmlIncubationController> #include <private/qqmlengine_p.h> -#include <QQmlAbstractUrlInterceptor> +#include <private/qqmlabstracturlinterceptor_p.h> class tst_qqmlengine : public QQmlDataTest { @@ -680,6 +680,7 @@ void tst_qqmlengine::qtqmlModule() class CustomSelector : public QQmlAbstractUrlInterceptor { public: + CustomSelector(const QUrl &base):m_base(base){} virtual QUrl intercept(const QUrl &url, QQmlAbstractUrlInterceptor::DataType d) { if (url.scheme() != QStringLiteral("file")) @@ -687,6 +688,9 @@ public: if (!m_interceptionPoints.contains(d)) return url; + if (url.path().endsWith("Test.2/qmldir"))//Special case + return QUrl::fromLocalFile(m_base.path() + "interception/module/intercepted/qmldir"); + QString alteredPath = url.path(); int a = alteredPath.lastIndexOf('/'); if (a < 0) @@ -698,6 +702,7 @@ public: return ret; } QList<QQmlAbstractUrlInterceptor::DataType> m_interceptionPoints; + QUrl m_base; }; Q_DECLARE_METATYPE(QList<QQmlAbstractUrlInterceptor::DataType>); @@ -729,6 +734,15 @@ void tst_qqmlengine::urlInterceptor_data() << testFileUrl("interception/qmldir/intercepted/doesNotExist.file").toString() << QStringLiteral("file:///intercepted/doesNotExist.file"); + QTest::newRow("InterceptModule")//just a Test{}, needs to intercept the module import for it to work + << testFileUrl("interception/module/urlInterceptor.qml") + << (QList<QQmlAbstractUrlInterceptor::DataType>() << QQmlAbstractUrlInterceptor::QmldirFile ) + << testFileUrl("interception/module/intercepted/doesNotExist.file").toString() + << QStringLiteral("intercepted") + << QStringLiteral("intercepted") + << testFileUrl("interception/module/intercepted/doesNotExist.file").toString() + << QStringLiteral("file:///doesNotExist.file"); + QTest::newRow("InterceptStrings") << testFileUrl("interception/strings/urlInterceptor.qml") << (QList<QQmlAbstractUrlInterceptor::DataType>() << QQmlAbstractUrlInterceptor::UrlString) @@ -751,7 +765,8 @@ void tst_qqmlengine::urlInterceptor() QFETCH(QString, expectedAbsoluteUrl); QQmlEngine e; - CustomSelector cs; + e.setImportPathList(QStringList() << testFileUrl("interception/imports").toLocalFile()); + CustomSelector cs(testFileUrl("")); cs.m_interceptionPoints = interceptionPoint; e.setUrlInterceptor(&cs); QQmlComponent c(&e, testFile); //Note that this can get intercepted too diff --git a/tests/auto/qml/qqmlfileselector/tst_qqmlfileselector.cpp b/tests/auto/qml/qqmlfileselector/tst_qqmlfileselector.cpp index a583fd0c4c..a9c1c11549 100644 --- a/tests/auto/qml/qqmlfileselector/tst_qqmlfileselector.cpp +++ b/tests/auto/qml/qqmlfileselector/tst_qqmlfileselector.cpp @@ -43,6 +43,7 @@ #include <QQmlEngine> #include <QQmlComponent> #include <QQmlFileSelector> +#include <QQmlApplicationEngine> #include <QFileSelector> #include <QQmlContext> #include <qqmlinfo.h> @@ -56,17 +57,30 @@ public: private slots: void basicTest(); + void applicationEngineTest(); }; void tst_qqmlfileselector::basicTest() { QQmlEngine engine; - QFileSelector selector; + QQmlFileSelector selector(&engine); selector.setExtraSelectors(QStringList() << "basic"); - QQmlFileSelector qmlSelector; - qmlSelector.setSelector(&selector); - engine.setUrlInterceptor(&qmlSelector); + + QQmlComponent component(&engine, testFileUrl("basicTest.qml")); + QObject *object = component.create(); + QVERIFY(object != 0); + QCOMPARE(object->property("value").toString(), QString("selected")); + + delete object; +} + +void tst_qqmlfileselector::applicationEngineTest() +{ + QQmlApplicationEngine engine; + QQmlFileSelector* selector = QQmlFileSelector::get(&engine); + QVERIFY(selector != 0); + selector->setExtraSelectors(QStringList() << "basic"); QQmlComponent component(&engine, testFileUrl("basicTest.qml")); QObject *object = component.create(); diff --git a/tests/auto/qml/qqmlinstantiator/data/createAndRemove.qml b/tests/auto/qml/qqmlinstantiator/data/createAndRemove.qml new file mode 100644 index 0000000000..5dd322b5f5 --- /dev/null +++ b/tests/auto/qml/qqmlinstantiator/data/createAndRemove.qml @@ -0,0 +1,18 @@ +import QtQml 2.1 +import QtQuick 2.1 + +Rectangle { + Instantiator { + objectName: "instantiator1" + model: model1 + delegate: QtObject { + property string datum: model.text + } + } + Component.onCompleted: { + model1.add("Delta"); + model1.add("Gamma"); + model1.add("Beta"); + model1.add("Alpha"); + } +} diff --git a/tests/auto/qml/qqmlinstantiator/qqmlinstantiator.pro b/tests/auto/qml/qqmlinstantiator/qqmlinstantiator.pro index aa83da1509..719fd6c350 100644 --- a/tests/auto/qml/qqmlinstantiator/qqmlinstantiator.pro +++ b/tests/auto/qml/qqmlinstantiator/qqmlinstantiator.pro @@ -4,6 +4,7 @@ macx:CONFIG -= app_bundle INCLUDEPATH += ../../shared/ SOURCES += tst_qqmlinstantiator.cpp +HEADERS += stringmodel.h include (../../shared/util.pri) diff --git a/tests/auto/qml/qqmlinstantiator/stringmodel.h b/tests/auto/qml/qqmlinstantiator/stringmodel.h new file mode 100644 index 0000000000..c66aa5886a --- /dev/null +++ b/tests/auto/qml/qqmlinstantiator/stringmodel.h @@ -0,0 +1,126 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Dmitrii Kosarev aka Kakadu <kakadu.hafanana@gmail.com> +** Contact: http://www.qt-project.org/legal +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** 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 Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#ifndef STRINGMODEL_H +#define STRINGMODEL_H + +#include <QtCore/QObject> +#include <QtCore/QAbstractItemModel> +#include <QtCore/QDebug> + +class StringModel : public QAbstractItemModel +{ + Q_OBJECT + QVector<QString> items; + QHash<int, QByteArray> roles; + QString name; + +public: + explicit StringModel(const QString& name) : QAbstractItemModel(), name(name) + { + roles.insert(555, "text"); + } + + void drop(int count) + { + beginRemoveRows(QModelIndex(), 0, count-1); + for (int i=0; i<count; i++) + items.pop_front(); + endRemoveRows(); + } + + Q_INVOKABLE void add(QString s) + { + beginInsertRows(QModelIndex(), 0, 0); + items.push_front(s); + endInsertRows(); + } + + int rowCount(const QModelIndex &) const + { + return items.count(); + } + + virtual QHash<int, QByteArray> roleNames() const Q_DECL_OVERRIDE + { + return roles; + } + + virtual int columnCount(const QModelIndex &) const + { + return 1; + } + + virtual bool hasChildren(const QModelIndex &) const Q_DECL_OVERRIDE + { + return rowCount(QModelIndex()) > 0; + } + + virtual QModelIndex index(int row, int column, const QModelIndex &parent) const + { + Q_UNUSED(column); + if (row>=0 && row<rowCount(parent)) + return createIndex(row,0); + else + return QModelIndex(); + } + + virtual QModelIndex parent(const QModelIndex &) const + { + return QModelIndex(); + } + + QVariant data (const QModelIndex & index, int role) const + { + int row = index.row(); + if ((row<0) || (row>=items.count())) + return QVariant::Invalid; + + switch (role) { + case Qt::DisplayRole: + case 555: + return QVariant::fromValue(items.at(row)); + default: + return QVariant(); + } + } +}; + +#endif // STRINGMODEL_H diff --git a/tests/auto/qml/qqmlinstantiator/tst_qqmlinstantiator.cpp b/tests/auto/qml/qqmlinstantiator/tst_qqmlinstantiator.cpp index 3e90eb2cbe..1b31e55e2d 100644 --- a/tests/auto/qml/qqmlinstantiator/tst_qqmlinstantiator.cpp +++ b/tests/auto/qml/qqmlinstantiator/tst_qqmlinstantiator.cpp @@ -45,7 +45,9 @@ #include <QtQml/qqmlengine.h> #include <QtQml/qqmlcomponent.h> #include <QtQml/private/qqmlinstantiator_p.h> +#include <QtQml/qqmlcontext.h> #include "../../shared/util.h" +#include "stringmodel.h" class tst_qqmlinstantiator: public QQmlDataTest { @@ -58,6 +60,7 @@ private slots: void stringModel(); void activeProperty(); void intModelChange(); + void createAndRemove(); }; void tst_qqmlinstantiator::createNone() @@ -193,6 +196,27 @@ void tst_qqmlinstantiator::intModelChange() } } +void tst_qqmlinstantiator::createAndRemove() +{ + QQmlEngine engine; + QQmlComponent component(&engine, testFileUrl("createAndRemove.qml")); + StringModel *model = new StringModel("model1"); + engine.rootContext()->setContextProperty("model1", model); + QObject *rootObject = component.create(); + QVERIFY(rootObject != 0); + + QQmlInstantiator *instantiator = + qobject_cast<QQmlInstantiator*>(rootObject->findChild<QObject*>("instantiator1")); + QVERIFY(instantiator != 0); + model->drop(1); + QVector<QString> names; + names << "Beta" << "Gamma" << "Delta"; + for (int i=0; i<3; i++) { + QObject *object = instantiator->objectAt(i); + QVERIFY(object); + QCOMPARE(object->property("datum").toString(), names[i]); + } +} QTEST_MAIN(tst_qqmlinstantiator) #include "tst_qqmlinstantiator.moc" diff --git a/tests/auto/qml/qqmlinstruction/tst_qqmlinstruction.cpp b/tests/auto/qml/qqmlinstruction/tst_qqmlinstruction.cpp index a119607769..0cd4360e67 100644 --- a/tests/auto/qml/qqmlinstruction/tst_qqmlinstruction.cpp +++ b/tests/auto/qml/qqmlinstruction/tst_qqmlinstruction.cpp @@ -63,7 +63,6 @@ private slots: void rectf(); void vector3d(); void vector4d(); - void time(); }; void tst_qqmlinstruction::dump() @@ -688,12 +687,6 @@ void tst_qqmlinstruction::vector4d() QCOMPARE(vector.w(), (qreal)(float)121.1); } -void tst_qqmlinstruction::time() -{ - QCOMPARE(sizeof(QQmlInstruction::instr_storeTime::QTime), sizeof(QTime)); - QCOMPARE(Q_ALIGNOF(QQmlInstruction::instr_storeTime::QTime), Q_ALIGNOF(QTime)); -} - QTEST_MAIN(tst_qqmlinstruction) #include "tst_qqmlinstruction.moc" diff --git a/tests/auto/qml/qqmllanguage/data/singleton/+basicSelector/SingletonType.qml b/tests/auto/qml/qqmllanguage/data/singleton/+basicSelector/SingletonType.qml new file mode 100644 index 0000000000..3e289aed1a --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/singleton/+basicSelector/SingletonType.qml @@ -0,0 +1,10 @@ +import QtQuick 2.0 +pragma Singleton + +Item { + id: singletonId + + property int testProp1: 625 + property int testProp2: 525 + property int testProp3: 455 +} diff --git a/tests/auto/qml/qqmllanguage/data/singleton/RegisteredCompositeSingletonType.qml b/tests/auto/qml/qqmllanguage/data/singleton/RegisteredCompositeSingletonType.qml new file mode 100644 index 0000000000..cdc531ef0d --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/singleton/RegisteredCompositeSingletonType.qml @@ -0,0 +1,58 @@ +/**************************************************************************** +** +** Copyright (C) 2013 BlackBerry Limited. All rights reserved. +** Contact: http://www.qt-project.org/legal +** +** This file is part of the examples 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 Digia Plc and its Subsidiary(-ies) 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.0 +pragma Singleton + +Item { + id: singletonId + + property int testProp1: 925 + property int testProp2: 825 + property int testProp3: 755 + + width: 25; height: 25 + + Rectangle { + id: rectangle + border.color: "white" + anchors.fill: parent + } +}
\ No newline at end of file diff --git a/tests/auto/qml/qqmllanguage/data/singletonTest17.qml b/tests/auto/qml/qqmllanguage/data/singletonTest17.qml new file mode 100644 index 0000000000..655e9d5a78 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/singletonTest17.qml @@ -0,0 +1,49 @@ +/**************************************************************************** +** +** Copyright (C) 2013 BlackBerry Limited. All rights reserved. +** Contact: http://www.qt-project.org/legal +** +** This file is part of the examples 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 Digia Plc and its Subsidiary(-ies) 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.0 +import org.qtproject.Test 1.0 + +Item { + id: test + + property int value1: RegisteredSingleton.testProp1; + property string value2: "Test value: " + RegisteredSingleton.testProp3; +} diff --git a/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp b/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp index 65afdb06d2..621061ab6a 100644 --- a/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp +++ b/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp @@ -49,6 +49,8 @@ #include <QtCore/qdir.h> #include <QSignalSpy> #include <QFont> +#include <QQmlFileSelector> +#include <QFileSelector> #include <private/qqmlproperty_p.h> #include <private/qqmlmetatype_p.h> @@ -209,6 +211,8 @@ private slots: void compositeSingletonQmlDirError(); void compositeSingletonRemote(); void compositeSingletonJavaScriptPragma(); + void compositeSingletonSelectors(); + void compositeSingletonRegistered(); private: QQmlEngine engine; @@ -2844,6 +2848,9 @@ void tst_qqmllanguage::initTestCase() QFile out(testFileUrl(QString::fromUtf8("I18nType\303\201\303\242\303\243\303\244\303\245.qml")).toLocalFile()); QVERIFY2(out.open(QIODevice::WriteOnly), qPrintable(QString::fromLatin1("Cannot open '%1': %2").arg(out.fileName(), out.errorString()))); out.write(in.readAll()); + + // Register a Composite Singleton. + qmlRegisterSingletonType(testFileUrl("singleton/RegisteredCompositeSingletonType.qml"), "org.qtproject.Test", 1, 0, "RegisteredSingleton"); } void tst_qqmllanguage::aliasPropertyChangeSignals() @@ -3501,6 +3508,32 @@ void tst_qqmllanguage::compositeSingletonJavaScriptPragma() verifyCompositeSingletonPropertyValues(o, "value1", 99, "value2", 333); } +// Reads values from a Singleton accessed through selectors. +void tst_qqmllanguage::compositeSingletonSelectors() +{ + QQmlEngine e2; + QQmlFileSelector qmlSelector(&e2); + qmlSelector.setExtraSelectors(QStringList() << "basicSelector"); + QQmlComponent component(&e2, testFile("singletonTest1.qml")); + VERIFY_ERRORS(0); + QObject *o = component.create(); + QVERIFY(o != 0); + + verifyCompositeSingletonPropertyValues(o, "value1", 625, "value2", 455); +} + +// Reads values from a Singleton that was registered through the C++ API: +// qmlRegisterSingletonType. +void tst_qqmllanguage::compositeSingletonRegistered() +{ + QQmlComponent component(&engine, testFile("singletonTest17.qml")); + VERIFY_ERRORS(0); + QObject *o = component.create(); + QVERIFY(o != 0); + + verifyCompositeSingletonPropertyValues(o, "value1", 925, "value2", 755); +} + QTEST_MAIN(tst_qqmllanguage) #include "tst_qqmllanguage.moc" diff --git a/tests/auto/qml/qqmllocale/tst_qqmllocale.cpp b/tests/auto/qml/qqmllocale/tst_qqmllocale.cpp index 8e3626ddf2..d565ad557c 100644 --- a/tests/auto/qml/qqmllocale/tst_qqmllocale.cpp +++ b/tests/auto/qml/qqmllocale/tst_qqmllocale.cpp @@ -910,7 +910,7 @@ void tst_qqmllocale::dateToLocaleTimeStringFormatted() Q_ARG(QVariant, QVariant(format))); QLocale l(locale); - QCOMPARE(val.toString(), l.toString(dt.time(), format)); + QCOMPARE(val.toString(), l.toString(dt, format)); } void tst_qqmllocale::dateFromLocaleString_data() diff --git a/tests/auto/qml/qqmlmoduleplugin/.gitignore b/tests/auto/qml/qqmlmoduleplugin/.gitignore index b458285566..040a48c25f 100644 --- a/tests/auto/qml/qqmlmoduleplugin/.gitignore +++ b/tests/auto/qml/qqmlmoduleplugin/.gitignore @@ -1,2 +1,2 @@ imports/*/*/* -!imports/com/nokia/PureQmlModule/* +!imports/org/qtproject/PureQmlModule/* diff --git a/tests/auto/qml/qqmlmoduleplugin/data/importsMixedQmlCppPlugin.2.qml b/tests/auto/qml/qqmlmoduleplugin/data/importsMixedQmlCppPlugin.2.qml index a0ac0c72c7..97732d35d8 100644 --- a/tests/auto/qml/qqmlmoduleplugin/data/importsMixedQmlCppPlugin.2.qml +++ b/tests/auto/qml/qqmlmoduleplugin/data/importsMixedQmlCppPlugin.2.qml @@ -1,4 +1,4 @@ -import com.nokia.AutoTestQmlMixedPluginType 1.5 +import org.qtproject.AutoTestQmlMixedPluginType 1.5 import QtQuick 2.0 Item { diff --git a/tests/auto/qml/qqmlmoduleplugin/data/importsMixedQmlCppPlugin.qml b/tests/auto/qml/qqmlmoduleplugin/data/importsMixedQmlCppPlugin.qml index 1346cbdb7b..f09c29b5a8 100644 --- a/tests/auto/qml/qqmlmoduleplugin/data/importsMixedQmlCppPlugin.qml +++ b/tests/auto/qml/qqmlmoduleplugin/data/importsMixedQmlCppPlugin.qml @@ -1,4 +1,4 @@ -import com.nokia.AutoTestQmlMixedPluginType 1.0 +import org.qtproject.AutoTestQmlMixedPluginType 1.0 import QtQuick 2.0 Item { diff --git a/tests/auto/qml/qqmlmoduleplugin/data/importsNested.1.errors.txt b/tests/auto/qml/qqmlmoduleplugin/data/importsNested.1.errors.txt index 262193788b..de75f47c03 100644 --- a/tests/auto/qml/qqmlmoduleplugin/data/importsNested.1.errors.txt +++ b/tests/auto/qml/qqmlmoduleplugin/data/importsNested.1.errors.txt @@ -1 +1 @@ -1:1:module "com.nokia.AutoTestQmlNestedPluginType.Nested" is not installed +1:1:module "org.qtproject.AutoTestQmlNestedPluginType.Nested" is not installed diff --git a/tests/auto/qml/qqmlmoduleplugin/data/importsNested.1.qml b/tests/auto/qml/qqmlmoduleplugin/data/importsNested.1.qml index b3f9ac6c3f..35fff29a69 100644 --- a/tests/auto/qml/qqmlmoduleplugin/data/importsNested.1.qml +++ b/tests/auto/qml/qqmlmoduleplugin/data/importsNested.1.qml @@ -1,5 +1,5 @@ -import com.nokia.AutoTestQmlNestedPluginType.Nested 1.0 -import com.nokia.AutoTestQmlNestedPluginType 1.0 +import org.qtproject.AutoTestQmlNestedPluginType.Nested 1.0 +import org.qtproject.AutoTestQmlNestedPluginType 1.0 MyNestedPluginType { } diff --git a/tests/auto/qml/qqmlmoduleplugin/data/importsNested.2.qml b/tests/auto/qml/qqmlmoduleplugin/data/importsNested.2.qml index cb8e0e33d1..ed4ddf2a1a 100644 --- a/tests/auto/qml/qqmlmoduleplugin/data/importsNested.2.qml +++ b/tests/auto/qml/qqmlmoduleplugin/data/importsNested.2.qml @@ -1,5 +1,5 @@ -import com.nokia.AutoTestQmlNestedPluginType 1.0 -import com.nokia.AutoTestQmlNestedPluginType.Nested 1.0 +import org.qtproject.AutoTestQmlNestedPluginType 1.0 +import org.qtproject.AutoTestQmlNestedPluginType.Nested 1.0 MyNestedPluginType { } diff --git a/tests/auto/qml/qqmlmoduleplugin/data/importsNested.3.qml b/tests/auto/qml/qqmlmoduleplugin/data/importsNested.3.qml index 69c6a34f46..b3dbf1741e 100644 --- a/tests/auto/qml/qqmlmoduleplugin/data/importsNested.3.qml +++ b/tests/auto/qml/qqmlmoduleplugin/data/importsNested.3.qml @@ -1,4 +1,4 @@ -import com.nokia.AutoTestQmlNestedPluginType 1.0 +import org.qtproject.AutoTestQmlNestedPluginType 1.0 MyNestedPluginType { } diff --git a/tests/auto/qml/qqmlmoduleplugin/data/importsNested.4.errors.txt b/tests/auto/qml/qqmlmoduleplugin/data/importsNested.4.errors.txt index 9743ae4f68..0e92fce154 100644 --- a/tests/auto/qml/qqmlmoduleplugin/data/importsNested.4.errors.txt +++ b/tests/auto/qml/qqmlmoduleplugin/data/importsNested.4.errors.txt @@ -1 +1 @@ -2:1:module "com.nokia.AutoTestQmlNestedPluginType.Nested" version 6.66 is not installed +2:1:module "org.qtproject.AutoTestQmlNestedPluginType.Nested" version 6.66 is not installed diff --git a/tests/auto/qml/qqmlmoduleplugin/data/importsNested.4.qml b/tests/auto/qml/qqmlmoduleplugin/data/importsNested.4.qml index dce8b7564a..32a4385fbf 100644 --- a/tests/auto/qml/qqmlmoduleplugin/data/importsNested.4.qml +++ b/tests/auto/qml/qqmlmoduleplugin/data/importsNested.4.qml @@ -1,5 +1,5 @@ -import com.nokia.AutoTestQmlNestedPluginType 1.0 -import com.nokia.AutoTestQmlNestedPluginType.Nested 6.66 +import org.qtproject.AutoTestQmlNestedPluginType 1.0 +import org.qtproject.AutoTestQmlNestedPluginType.Nested 6.66 MyNestedPluginType { } diff --git a/tests/auto/qml/qqmlmoduleplugin/data/incorrectCase.qml b/tests/auto/qml/qqmlmoduleplugin/data/incorrectCase.qml index a21ece7058..86504269fa 100644 --- a/tests/auto/qml/qqmlmoduleplugin/data/incorrectCase.qml +++ b/tests/auto/qml/qqmlmoduleplugin/data/incorrectCase.qml @@ -1,4 +1,4 @@ -import com.nokia.WrongCase 1.0 +import org.qtproject.WrongCase 1.0 MyPluginType { value: 123 } diff --git a/tests/auto/qml/qqmlmoduleplugin/data/pluginWithQmlFile.qml b/tests/auto/qml/qqmlmoduleplugin/data/pluginWithQmlFile.qml index a9e28e5d8b..237c49d8eb 100644 --- a/tests/auto/qml/qqmlmoduleplugin/data/pluginWithQmlFile.qml +++ b/tests/auto/qml/qqmlmoduleplugin/data/pluginWithQmlFile.qml @@ -1,3 +1,3 @@ -import com.nokia.AutoTestPluginWithQmlFile 1.0 +import org.qtproject.AutoTestPluginWithQmlFile 1.0 MyQmlFile {} diff --git a/tests/auto/qml/qqmlmoduleplugin/data/versionNotInstalled.2.errors.txt b/tests/auto/qml/qqmlmoduleplugin/data/versionNotInstalled.2.errors.txt index a40c1c8211..8790d4e545 100644 --- a/tests/auto/qml/qqmlmoduleplugin/data/versionNotInstalled.2.errors.txt +++ b/tests/auto/qml/qqmlmoduleplugin/data/versionNotInstalled.2.errors.txt @@ -1 +1 @@ -1:1:module "com.nokia.AutoTestQmlVersionPluginType" version 1.9 is not installed +1:1:module "org.qtproject.AutoTestQmlVersionPluginType" version 1.9 is not installed diff --git a/tests/auto/qml/qqmlmoduleplugin/data/versionNotInstalled.2.qml b/tests/auto/qml/qqmlmoduleplugin/data/versionNotInstalled.2.qml index bda59f0a32..28351cf7f9 100644 --- a/tests/auto/qml/qqmlmoduleplugin/data/versionNotInstalled.2.qml +++ b/tests/auto/qml/qqmlmoduleplugin/data/versionNotInstalled.2.qml @@ -1,4 +1,4 @@ -import com.nokia.AutoTestQmlVersionPluginType 1.9 +import org.qtproject.AutoTestQmlVersionPluginType 1.9 import QtQuick 2.0 QtObject { diff --git a/tests/auto/qml/qqmlmoduleplugin/data/versionNotInstalled.errors.txt b/tests/auto/qml/qqmlmoduleplugin/data/versionNotInstalled.errors.txt index 2634223de7..f6b502e99c 100644 --- a/tests/auto/qml/qqmlmoduleplugin/data/versionNotInstalled.errors.txt +++ b/tests/auto/qml/qqmlmoduleplugin/data/versionNotInstalled.errors.txt @@ -1 +1 @@ -1:1:module "com.nokia.AutoTestQmlVersionPluginType" version 1.1 is not installed +1:1:module "org.qtproject.AutoTestQmlVersionPluginType" version 1.1 is not installed diff --git a/tests/auto/qml/qqmlmoduleplugin/data/versionNotInstalled.qml b/tests/auto/qml/qqmlmoduleplugin/data/versionNotInstalled.qml index 2e556e76d6..9f599c5c15 100644 --- a/tests/auto/qml/qqmlmoduleplugin/data/versionNotInstalled.qml +++ b/tests/auto/qml/qqmlmoduleplugin/data/versionNotInstalled.qml @@ -1,4 +1,4 @@ -import com.nokia.AutoTestQmlVersionPluginType 1.1 +import org.qtproject.AutoTestQmlVersionPluginType 1.1 import QtQuick 2.0 QtObject { diff --git a/tests/auto/qml/qqmlmoduleplugin/data/works.qml b/tests/auto/qml/qqmlmoduleplugin/data/works.qml index f29ae24ea2..58f5212b90 100644 --- a/tests/auto/qml/qqmlmoduleplugin/data/works.qml +++ b/tests/auto/qml/qqmlmoduleplugin/data/works.qml @@ -1,3 +1,3 @@ -import com.nokia.AutoTestQmlPluginType 1.0 +import org.qtproject.AutoTestQmlPluginType 1.0 MyPluginType { value: 123 } diff --git a/tests/auto/qml/qqmlmoduleplugin/data/works2.qml b/tests/auto/qml/qqmlmoduleplugin/data/works2.qml index cc322bf26b..c3a21e0d16 100644 --- a/tests/auto/qml/qqmlmoduleplugin/data/works2.qml +++ b/tests/auto/qml/qqmlmoduleplugin/data/works2.qml @@ -1,3 +1,3 @@ -import com.nokia.AutoTestQmlPluginType 2.0 +import org.qtproject.AutoTestQmlPluginType 2.0 MyPluginType { valueOnlyIn2: 123 } diff --git a/tests/auto/qml/qqmlmoduleplugin/data/works21.qml b/tests/auto/qml/qqmlmoduleplugin/data/works21.qml index c08160ac5a..939cea8bc7 100644 --- a/tests/auto/qml/qqmlmoduleplugin/data/works21.qml +++ b/tests/auto/qml/qqmlmoduleplugin/data/works21.qml @@ -1,3 +1,3 @@ -import com.nokia.AutoTestQmlPluginType 2.1 +import org.qtproject.AutoTestQmlPluginType 2.1 MyPluginType { valueOnlyIn2: 123 } diff --git a/tests/auto/qml/qqmlmoduleplugin/imports/com/nokia/PureQmlModule/ComponentA.qml b/tests/auto/qml/qqmlmoduleplugin/imports/org/qtproject/PureQmlModule/ComponentA.qml index 617bdaaf67..617bdaaf67 100644 --- a/tests/auto/qml/qqmlmoduleplugin/imports/com/nokia/PureQmlModule/ComponentA.qml +++ b/tests/auto/qml/qqmlmoduleplugin/imports/org/qtproject/PureQmlModule/ComponentA.qml diff --git a/tests/auto/qml/qqmlmoduleplugin/imports/com/nokia/PureQmlModule/ComponentB.qml b/tests/auto/qml/qqmlmoduleplugin/imports/org/qtproject/PureQmlModule/ComponentB.qml index fac5d8f4b9..fac5d8f4b9 100644 --- a/tests/auto/qml/qqmlmoduleplugin/imports/com/nokia/PureQmlModule/ComponentB.qml +++ b/tests/auto/qml/qqmlmoduleplugin/imports/org/qtproject/PureQmlModule/ComponentB.qml diff --git a/tests/auto/qml/qqmlmoduleplugin/imports/com/nokia/PureQmlModule/qmldir b/tests/auto/qml/qqmlmoduleplugin/imports/org/qtproject/PureQmlModule/qmldir index 167bb10c21..167bb10c21 100644 --- a/tests/auto/qml/qqmlmoduleplugin/imports/com/nokia/PureQmlModule/qmldir +++ b/tests/auto/qml/qqmlmoduleplugin/imports/org/qtproject/PureQmlModule/qmldir diff --git a/tests/auto/qml/qqmlmoduleplugin/invalidFirstCommandModule/invalidFirstCommandModule.pro b/tests/auto/qml/qqmlmoduleplugin/invalidFirstCommandModule/invalidFirstCommandModule.pro index 8e37a2d16b..9a6ee63b88 100644 --- a/tests/auto/qml/qqmlmoduleplugin/invalidFirstCommandModule/invalidFirstCommandModule.pro +++ b/tests/auto/qml/qqmlmoduleplugin/invalidFirstCommandModule/invalidFirstCommandModule.pro @@ -2,7 +2,7 @@ TEMPLATE = lib CONFIG += plugin SOURCES = plugin.cpp QT = core qml -DESTDIR = ../imports/com/nokia/InvalidFirstCommandModule +DESTDIR = ../imports/org/qtproject/InvalidFirstCommandModule QT += core-private gui-private qml-private diff --git a/tests/auto/qml/qqmlmoduleplugin/invalidFirstCommandModule/plugin.cpp b/tests/auto/qml/qqmlmoduleplugin/invalidFirstCommandModule/plugin.cpp index 925f3cdf86..f8f1386e84 100644 --- a/tests/auto/qml/qqmlmoduleplugin/invalidFirstCommandModule/plugin.cpp +++ b/tests/auto/qml/qqmlmoduleplugin/invalidFirstCommandModule/plugin.cpp @@ -61,8 +61,8 @@ public: void registerTypes(const char *uri) { - Q_ASSERT(QLatin1String(uri) == "com.nokia.InvalidFirstCommandModule"); - qmlRegisterType<MyPluginType>("com.nokia.InvalidFirstCommandModule", 1, 0, "MyPluginType"); + Q_ASSERT(QLatin1String(uri) == "org.qtproject.InvalidFirstCommandModule"); + qmlRegisterType<MyPluginType>("org.qtproject.InvalidFirstCommandModule", 1, 0, "MyPluginType"); } }; diff --git a/tests/auto/qml/qqmlmoduleplugin/invalidFirstCommandModule/qmldir b/tests/auto/qml/qqmlmoduleplugin/invalidFirstCommandModule/qmldir index 90b607e793..9ecbf14516 100644 --- a/tests/auto/qml/qqmlmoduleplugin/invalidFirstCommandModule/qmldir +++ b/tests/auto/qml/qqmlmoduleplugin/invalidFirstCommandModule/qmldir @@ -1,3 +1,3 @@ plugin invalidNamespaceModule -module com.nokia.InvalidFirstCommandModule +module org.qtproject.InvalidFirstCommandModule # comment. diff --git a/tests/auto/qml/qqmlmoduleplugin/invalidNamespaceModule/invalidNamespaceModule.pro b/tests/auto/qml/qqmlmoduleplugin/invalidNamespaceModule/invalidNamespaceModule.pro index b53ae1f9c3..002f177cfd 100644 --- a/tests/auto/qml/qqmlmoduleplugin/invalidNamespaceModule/invalidNamespaceModule.pro +++ b/tests/auto/qml/qqmlmoduleplugin/invalidNamespaceModule/invalidNamespaceModule.pro @@ -2,7 +2,7 @@ TEMPLATE = lib CONFIG += plugin SOURCES = plugin.cpp QT = core qml -DESTDIR = ../imports/com/nokia/InvalidNamespaceModule +DESTDIR = ../imports/org/qtproject/InvalidNamespaceModule QT += core-private gui-private qml-private diff --git a/tests/auto/qml/qqmlmoduleplugin/invalidNamespaceModule/plugin.cpp b/tests/auto/qml/qqmlmoduleplugin/invalidNamespaceModule/plugin.cpp index 0ed1b20446..edf524a240 100644 --- a/tests/auto/qml/qqmlmoduleplugin/invalidNamespaceModule/plugin.cpp +++ b/tests/auto/qml/qqmlmoduleplugin/invalidNamespaceModule/plugin.cpp @@ -61,8 +61,8 @@ public: void registerTypes(const char *uri) { - Q_ASSERT(QLatin1String(uri) == "com.nokia.InvalidStrictModule"); - qmlRegisterType<MyPluginType>("com.nokia.SomeOtherModule", 1, 0, "MyPluginType"); + Q_ASSERT(QLatin1String(uri) == "org.qtproject.InvalidStrictModule"); + qmlRegisterType<MyPluginType>("org.qtproject.SomeOtherModule", 1, 0, "MyPluginType"); } }; diff --git a/tests/auto/qml/qqmlmoduleplugin/invalidNamespaceModule/qmldir b/tests/auto/qml/qqmlmoduleplugin/invalidNamespaceModule/qmldir index 5f349709f2..051e88d46e 100644 --- a/tests/auto/qml/qqmlmoduleplugin/invalidNamespaceModule/qmldir +++ b/tests/auto/qml/qqmlmoduleplugin/invalidNamespaceModule/qmldir @@ -1,2 +1,2 @@ -module com.nokia.AwesomeModule +module org.qtproject.AwesomeModule plugin invalidNamespaceModule diff --git a/tests/auto/qml/qqmlmoduleplugin/invalidStrictModule/invalidStrictModule.pro b/tests/auto/qml/qqmlmoduleplugin/invalidStrictModule/invalidStrictModule.pro index a348d5d6a6..562d109179 100644 --- a/tests/auto/qml/qqmlmoduleplugin/invalidStrictModule/invalidStrictModule.pro +++ b/tests/auto/qml/qqmlmoduleplugin/invalidStrictModule/invalidStrictModule.pro @@ -2,7 +2,7 @@ TEMPLATE = lib CONFIG += plugin SOURCES = plugin.cpp QT = core qml -DESTDIR = ../imports/com/nokia/InvalidStrictModule +DESTDIR = ../imports/org/qtproject/InvalidStrictModule QT += core-private gui-private qml-private diff --git a/tests/auto/qml/qqmlmoduleplugin/invalidStrictModule/plugin.cpp b/tests/auto/qml/qqmlmoduleplugin/invalidStrictModule/plugin.cpp index 0ed1b20446..edf524a240 100644 --- a/tests/auto/qml/qqmlmoduleplugin/invalidStrictModule/plugin.cpp +++ b/tests/auto/qml/qqmlmoduleplugin/invalidStrictModule/plugin.cpp @@ -61,8 +61,8 @@ public: void registerTypes(const char *uri) { - Q_ASSERT(QLatin1String(uri) == "com.nokia.InvalidStrictModule"); - qmlRegisterType<MyPluginType>("com.nokia.SomeOtherModule", 1, 0, "MyPluginType"); + Q_ASSERT(QLatin1String(uri) == "org.qtproject.InvalidStrictModule"); + qmlRegisterType<MyPluginType>("org.qtproject.SomeOtherModule", 1, 0, "MyPluginType"); } }; diff --git a/tests/auto/qml/qqmlmoduleplugin/invalidStrictModule/qmldir b/tests/auto/qml/qqmlmoduleplugin/invalidStrictModule/qmldir index 45752a9bca..20716dc9f9 100644 --- a/tests/auto/qml/qqmlmoduleplugin/invalidStrictModule/qmldir +++ b/tests/auto/qml/qqmlmoduleplugin/invalidStrictModule/qmldir @@ -1,2 +1,2 @@ -module com.nokia.InvalidStrictModule +module org.qtproject.InvalidStrictModule plugin invalidStrictModule diff --git a/tests/auto/qml/qqmlmoduleplugin/nestedPlugin/nestedPlugin.cpp b/tests/auto/qml/qqmlmoduleplugin/nestedPlugin/nestedPlugin.cpp index 8b434dfb12..edd5577335 100644 --- a/tests/auto/qml/qqmlmoduleplugin/nestedPlugin/nestedPlugin.cpp +++ b/tests/auto/qml/qqmlmoduleplugin/nestedPlugin/nestedPlugin.cpp @@ -76,7 +76,7 @@ public: void registerTypes(const char *uri) { - Q_ASSERT(QLatin1String(uri) == "com.nokia.AutoTestQmlNestedPluginType"); + Q_ASSERT(QLatin1String(uri) == "org.qtproject.AutoTestQmlNestedPluginType"); qmlRegisterType<MyPluginType>(uri, 1, 0, "MyPluginType"); QString nestedUri(uri); diff --git a/tests/auto/qml/qqmlmoduleplugin/nestedPlugin/nestedPlugin.pro b/tests/auto/qml/qqmlmoduleplugin/nestedPlugin/nestedPlugin.pro index a2e582a604..5636941951 100644 --- a/tests/auto/qml/qqmlmoduleplugin/nestedPlugin/nestedPlugin.pro +++ b/tests/auto/qml/qqmlmoduleplugin/nestedPlugin/nestedPlugin.pro @@ -2,7 +2,7 @@ TEMPLATE = lib CONFIG += nestedPlugin SOURCES = nestedPlugin.cpp QT = core qml -DESTDIR = ../imports/com/nokia/AutoTestQmlNestedPluginType +DESTDIR = ../imports/org/qtproject/AutoTestQmlNestedPluginType QT += core-private gui-private qml-private diff --git a/tests/auto/qml/qqmlmoduleplugin/nonstrictModule/nonstrictModule.pro b/tests/auto/qml/qqmlmoduleplugin/nonstrictModule/nonstrictModule.pro index 5ad1bd5eca..0d900eb707 100644 --- a/tests/auto/qml/qqmlmoduleplugin/nonstrictModule/nonstrictModule.pro +++ b/tests/auto/qml/qqmlmoduleplugin/nonstrictModule/nonstrictModule.pro @@ -2,7 +2,7 @@ TEMPLATE = lib CONFIG += plugin SOURCES = plugin.cpp QT = core qml -DESTDIR = ../imports/com/nokia/NonstrictModule +DESTDIR = ../imports/org/qtproject/NonstrictModule QT += core-private gui-private qml-private diff --git a/tests/auto/qml/qqmlmoduleplugin/nonstrictModule/plugin.cpp b/tests/auto/qml/qqmlmoduleplugin/nonstrictModule/plugin.cpp index 1cdd0f7754..f6db5bf9ea 100644 --- a/tests/auto/qml/qqmlmoduleplugin/nonstrictModule/plugin.cpp +++ b/tests/auto/qml/qqmlmoduleplugin/nonstrictModule/plugin.cpp @@ -61,10 +61,10 @@ public: void registerTypes(const char *uri) { - Q_ASSERT(QLatin1String(uri) == "com.nokia.NonstrictModule"); + Q_ASSERT(QLatin1String(uri) == "org.qtproject.NonstrictModule"); // Install into a namespace that should be protected - qmlRegisterType<MyPluginType>("com.nokia.StrictModule", 1, 0, "MyPluginType"); + qmlRegisterType<MyPluginType>("org.qtproject.StrictModule", 1, 0, "MyPluginType"); } }; diff --git a/tests/auto/qml/qqmlmoduleplugin/plugin.2.1/plugin.2.1.pro b/tests/auto/qml/qqmlmoduleplugin/plugin.2.1/plugin.2.1.pro index 560450832c..445b98d647 100644 --- a/tests/auto/qml/qqmlmoduleplugin/plugin.2.1/plugin.2.1.pro +++ b/tests/auto/qml/qqmlmoduleplugin/plugin.2.1/plugin.2.1.pro @@ -2,7 +2,7 @@ TEMPLATE = lib CONFIG += plugin SOURCES = plugin.cpp QT = core qml -DESTDIR = ../imports/com/nokia/AutoTestQmlPluginType.2.1 +DESTDIR = ../imports/org/qtproject/AutoTestQmlPluginType.2.1 QT += core-private gui-private qml-private diff --git a/tests/auto/qml/qqmlmoduleplugin/plugin.2.1/plugin.cpp b/tests/auto/qml/qqmlmoduleplugin/plugin.2.1/plugin.cpp index 6b5c38f29a..360f387310 100644 --- a/tests/auto/qml/qqmlmoduleplugin/plugin.2.1/plugin.cpp +++ b/tests/auto/qml/qqmlmoduleplugin/plugin.2.1/plugin.cpp @@ -76,7 +76,7 @@ public: void registerTypes(const char *uri) { - Q_ASSERT(QLatin1String(uri) == "com.nokia.AutoTestQmlPluginType"); + Q_ASSERT(QLatin1String(uri) == "org.qtproject.AutoTestQmlPluginType"); qmlRegisterType<MyPluginType>(uri, 2, 1, "MyPluginType"); } }; diff --git a/tests/auto/qml/qqmlmoduleplugin/plugin.2/plugin.2.pro b/tests/auto/qml/qqmlmoduleplugin/plugin.2/plugin.2.pro index ed70708e1d..00c076d9cf 100644 --- a/tests/auto/qml/qqmlmoduleplugin/plugin.2/plugin.2.pro +++ b/tests/auto/qml/qqmlmoduleplugin/plugin.2/plugin.2.pro @@ -2,7 +2,7 @@ TEMPLATE = lib CONFIG += plugin SOURCES = plugin.cpp QT = core qml -DESTDIR = ../imports/com/nokia/AutoTestQmlPluginType.2 +DESTDIR = ../imports/org/qtproject/AutoTestQmlPluginType.2 QT += core-private gui-private qml-private diff --git a/tests/auto/qml/qqmlmoduleplugin/plugin.2/plugin.cpp b/tests/auto/qml/qqmlmoduleplugin/plugin.2/plugin.cpp index 12e31a4cb8..41c6987462 100644 --- a/tests/auto/qml/qqmlmoduleplugin/plugin.2/plugin.cpp +++ b/tests/auto/qml/qqmlmoduleplugin/plugin.2/plugin.cpp @@ -76,7 +76,7 @@ public: void registerTypes(const char *uri) { - Q_ASSERT(QLatin1String(uri) == "com.nokia.AutoTestQmlPluginType"); + Q_ASSERT(QLatin1String(uri) == "org.qtproject.AutoTestQmlPluginType"); qmlRegisterType<MyPluginType>(uri, 2, 0, "MyPluginType"); } }; diff --git a/tests/auto/qml/qqmlmoduleplugin/plugin/plugin.cpp b/tests/auto/qml/qqmlmoduleplugin/plugin/plugin.cpp index ee07c77e2f..59f7fa1082 100644 --- a/tests/auto/qml/qqmlmoduleplugin/plugin/plugin.cpp +++ b/tests/auto/qml/qqmlmoduleplugin/plugin/plugin.cpp @@ -75,7 +75,7 @@ public: void registerTypes(const char *uri) { - Q_ASSERT(QLatin1String(uri) == "com.nokia.AutoTestQmlPluginType"); + Q_ASSERT(QLatin1String(uri) == "org.qtproject.AutoTestQmlPluginType"); qmlRegisterType<MyPluginType>(uri, 1, 0, "MyPluginType"); } }; diff --git a/tests/auto/qml/qqmlmoduleplugin/plugin/plugin.pro b/tests/auto/qml/qqmlmoduleplugin/plugin/plugin.pro index b78e85c86b..3a0455569e 100644 --- a/tests/auto/qml/qqmlmoduleplugin/plugin/plugin.pro +++ b/tests/auto/qml/qqmlmoduleplugin/plugin/plugin.pro @@ -2,7 +2,7 @@ TEMPLATE = lib CONFIG += plugin SOURCES = plugin.cpp QT = core qml -DESTDIR = ../imports/com/nokia/AutoTestQmlPluginType +DESTDIR = ../imports/org/qtproject/AutoTestQmlPluginType QT += core-private gui-private qml-private diff --git a/tests/auto/qml/qqmlmoduleplugin/pluginMixed/plugin.cpp b/tests/auto/qml/qqmlmoduleplugin/pluginMixed/plugin.cpp index 4512f9a642..bce746afd4 100644 --- a/tests/auto/qml/qqmlmoduleplugin/pluginMixed/plugin.cpp +++ b/tests/auto/qml/qqmlmoduleplugin/pluginMixed/plugin.cpp @@ -65,7 +65,7 @@ public: void registerTypes(const char *uri) { - Q_ASSERT(QLatin1String(uri) == "com.nokia.AutoTestQmlMixedPluginType"); + Q_ASSERT(QLatin1String(uri) == "org.qtproject.AutoTestQmlMixedPluginType"); qmlRegisterType<BarPluginType>(uri, 1, 0, "Bar"); } }; diff --git a/tests/auto/qml/qqmlmoduleplugin/pluginMixed/pluginMixed.pro b/tests/auto/qml/qqmlmoduleplugin/pluginMixed/pluginMixed.pro index 9076c3ebab..d3b237b0f7 100644 --- a/tests/auto/qml/qqmlmoduleplugin/pluginMixed/pluginMixed.pro +++ b/tests/auto/qml/qqmlmoduleplugin/pluginMixed/pluginMixed.pro @@ -2,7 +2,7 @@ TEMPLATE = lib CONFIG += plugin SOURCES = plugin.cpp QT = core qml -DESTDIR = ../imports/com/nokia/AutoTestQmlMixedPluginType +DESTDIR = ../imports/org/qtproject/AutoTestQmlMixedPluginType QT += core-private gui-private qml-private diff --git a/tests/auto/qml/qqmlmoduleplugin/pluginVersion/plugin.cpp b/tests/auto/qml/qqmlmoduleplugin/pluginVersion/plugin.cpp index dfe2262e36..1ac546c39f 100644 --- a/tests/auto/qml/qqmlmoduleplugin/pluginVersion/plugin.cpp +++ b/tests/auto/qml/qqmlmoduleplugin/pluginVersion/plugin.cpp @@ -65,7 +65,7 @@ public: void registerTypes(const char *uri) { - Q_ASSERT(QLatin1String(uri) == "com.nokia.AutoTestQmlVersionPluginType"); + Q_ASSERT(QLatin1String(uri) == "org.qtproject.AutoTestQmlVersionPluginType"); qmlRegisterType<FloorPluginType>(uri, 1, 4, "Floor"); } }; diff --git a/tests/auto/qml/qqmlmoduleplugin/pluginVersion/pluginVersion.pro b/tests/auto/qml/qqmlmoduleplugin/pluginVersion/pluginVersion.pro index ba07180953..5cec9b8ebd 100644 --- a/tests/auto/qml/qqmlmoduleplugin/pluginVersion/pluginVersion.pro +++ b/tests/auto/qml/qqmlmoduleplugin/pluginVersion/pluginVersion.pro @@ -2,7 +2,7 @@ TEMPLATE = lib CONFIG += plugin SOURCES = plugin.cpp QT = core qml -DESTDIR = ../imports/com/nokia/AutoTestQmlVersionPluginType +DESTDIR = ../imports/org/qtproject/AutoTestQmlVersionPluginType QT += core-private gui-private qml-private diff --git a/tests/auto/qml/qqmlmoduleplugin/pluginWithQmlFile/plugin.cpp b/tests/auto/qml/qqmlmoduleplugin/pluginWithQmlFile/plugin.cpp index 34cf311b6b..9f8af9e5fa 100644 --- a/tests/auto/qml/qqmlmoduleplugin/pluginWithQmlFile/plugin.cpp +++ b/tests/auto/qml/qqmlmoduleplugin/pluginWithQmlFile/plugin.cpp @@ -51,7 +51,7 @@ class MyPlugin : public QQmlExtensionPlugin public: void registerTypes(const char *uri) { - Q_ASSERT(QLatin1String(uri) == "com.nokia.AutoTestPluginWithQmlFile"); + Q_ASSERT(QLatin1String(uri) == "org.qtproject.AutoTestPluginWithQmlFile"); } }; diff --git a/tests/auto/qml/qqmlmoduleplugin/pluginWithQmlFile/pluginWithQmlFile.pro b/tests/auto/qml/qqmlmoduleplugin/pluginWithQmlFile/pluginWithQmlFile.pro index 8cb40456cf..ba66d60f18 100644 --- a/tests/auto/qml/qqmlmoduleplugin/pluginWithQmlFile/pluginWithQmlFile.pro +++ b/tests/auto/qml/qqmlmoduleplugin/pluginWithQmlFile/pluginWithQmlFile.pro @@ -2,7 +2,7 @@ TEMPLATE = lib CONFIG += plugin SOURCES = plugin.cpp QT = core qml -DESTDIR = ../imports/com/nokia/AutoTestPluginWithQmlFile +DESTDIR = ../imports/org/qtproject/AutoTestPluginWithQmlFile QT += core-private gui-private qml-private diff --git a/tests/auto/qml/qqmlmoduleplugin/pluginWrongCase/plugin.cpp b/tests/auto/qml/qqmlmoduleplugin/pluginWrongCase/plugin.cpp index 3daba28b3d..96a61fa8c4 100644 --- a/tests/auto/qml/qqmlmoduleplugin/pluginWrongCase/plugin.cpp +++ b/tests/auto/qml/qqmlmoduleplugin/pluginWrongCase/plugin.cpp @@ -75,7 +75,7 @@ public: void registerTypes(const char *uri) { - Q_ASSERT(QLatin1String(uri) == "com.nokia.WrongCase"); + Q_ASSERT(QLatin1String(uri) == "org.qtproject.WrongCase"); qmlRegisterType<MyPluginType>(uri, 1, 0, "MyPluginType"); } }; diff --git a/tests/auto/qml/qqmlmoduleplugin/pluginWrongCase/pluginWrongCase.pro b/tests/auto/qml/qqmlmoduleplugin/pluginWrongCase/pluginWrongCase.pro index 0e3757b6ca..99bac141de 100644 --- a/tests/auto/qml/qqmlmoduleplugin/pluginWrongCase/pluginWrongCase.pro +++ b/tests/auto/qml/qqmlmoduleplugin/pluginWrongCase/pluginWrongCase.pro @@ -3,7 +3,7 @@ CONFIG += plugin SOURCES = plugin.cpp QT = core qml TARGET = Plugin -DESTDIR = ../imports/com/nokia/WrongCase +DESTDIR = ../imports/org/qtproject/WrongCase QT += core-private gui-private qml-private diff --git a/tests/auto/qml/qqmlmoduleplugin/preemptedStrictModule/plugin.cpp b/tests/auto/qml/qqmlmoduleplugin/preemptedStrictModule/plugin.cpp index 1b73f02934..11c75a8dd5 100644 --- a/tests/auto/qml/qqmlmoduleplugin/preemptedStrictModule/plugin.cpp +++ b/tests/auto/qml/qqmlmoduleplugin/preemptedStrictModule/plugin.cpp @@ -61,7 +61,7 @@ public: void registerTypes(const char *uri) { - Q_ASSERT(QLatin1String(uri) == "com.nokia.PreemptedStrictModule"); + Q_ASSERT(QLatin1String(uri) == "org.qtproject.PreemptedStrictModule"); qmlRegisterType<MyPluginType>(uri, 1, 0, "MyPluginType"); } }; diff --git a/tests/auto/qml/qqmlmoduleplugin/preemptedStrictModule/preemptedStrictModule.pro b/tests/auto/qml/qqmlmoduleplugin/preemptedStrictModule/preemptedStrictModule.pro index 0aab522d04..22926bf1ca 100644 --- a/tests/auto/qml/qqmlmoduleplugin/preemptedStrictModule/preemptedStrictModule.pro +++ b/tests/auto/qml/qqmlmoduleplugin/preemptedStrictModule/preemptedStrictModule.pro @@ -2,7 +2,7 @@ TEMPLATE = lib CONFIG += plugin SOURCES = plugin.cpp QT = core qml -DESTDIR = ../imports/com/nokia/PreemptedStrictModule +DESTDIR = ../imports/org/qtproject/PreemptedStrictModule QT += core-private gui-private qml-private diff --git a/tests/auto/qml/qqmlmoduleplugin/preemptedStrictModule/qmldir b/tests/auto/qml/qqmlmoduleplugin/preemptedStrictModule/qmldir index c82acd2fd3..28deed1561 100644 --- a/tests/auto/qml/qqmlmoduleplugin/preemptedStrictModule/qmldir +++ b/tests/auto/qml/qqmlmoduleplugin/preemptedStrictModule/qmldir @@ -1,2 +1,2 @@ -module com.nokia.PreemptedStrictModule +module org.qtproject.PreemptedStrictModule plugin preemptedStrictModule diff --git a/tests/auto/qml/qqmlmoduleplugin/preemptiveModule/plugin.cpp b/tests/auto/qml/qqmlmoduleplugin/preemptiveModule/plugin.cpp index 3a62650b13..35e8670509 100644 --- a/tests/auto/qml/qqmlmoduleplugin/preemptiveModule/plugin.cpp +++ b/tests/auto/qml/qqmlmoduleplugin/preemptiveModule/plugin.cpp @@ -61,11 +61,11 @@ public: void registerTypes(const char *uri) { - Q_ASSERT(QLatin1String(uri) == "com.nokia.PreemptiveModule"); - qmlRegisterType<MyPluginType>("com.nokia.PreemptiveModule", 1, 0, "MyPluginType"); + Q_ASSERT(QLatin1String(uri) == "org.qtproject.PreemptiveModule"); + qmlRegisterType<MyPluginType>("org.qtproject.PreemptiveModule", 1, 0, "MyPluginType"); // Install into another namespace that should be protected - qmlRegisterType<MyPluginType>("com.nokia.PreemptedStrictModule", 1, 0, "MyPluginType"); + qmlRegisterType<MyPluginType>("org.qtproject.PreemptedStrictModule", 1, 0, "MyPluginType"); } }; diff --git a/tests/auto/qml/qqmlmoduleplugin/preemptiveModule/preemptiveModule.pro b/tests/auto/qml/qqmlmoduleplugin/preemptiveModule/preemptiveModule.pro index 5bb6520b80..c07f0621f7 100644 --- a/tests/auto/qml/qqmlmoduleplugin/preemptiveModule/preemptiveModule.pro +++ b/tests/auto/qml/qqmlmoduleplugin/preemptiveModule/preemptiveModule.pro @@ -2,7 +2,7 @@ TEMPLATE = lib CONFIG += plugin SOURCES = plugin.cpp QT = core qml -DESTDIR = ../imports/com/nokia/PreemptiveModule +DESTDIR = ../imports/org/qtproject/PreemptiveModule QT += core-private gui-private qml-private diff --git a/tests/auto/qml/qqmlmoduleplugin/strictModule/plugin.cpp b/tests/auto/qml/qqmlmoduleplugin/strictModule/plugin.cpp index 8353c6b012..e2849f8b64 100644 --- a/tests/auto/qml/qqmlmoduleplugin/strictModule/plugin.cpp +++ b/tests/auto/qml/qqmlmoduleplugin/strictModule/plugin.cpp @@ -61,7 +61,7 @@ public: void registerTypes(const char *uri) { - Q_ASSERT(QLatin1String(uri) == "com.nokia.StrictModule"); + Q_ASSERT(QLatin1String(uri) == "org.qtproject.StrictModule"); qmlRegisterType<MyPluginType>(uri, 1, 0, "MyPluginType"); } }; diff --git a/tests/auto/qml/qqmlmoduleplugin/strictModule/qmldir b/tests/auto/qml/qqmlmoduleplugin/strictModule/qmldir index ff06446fbd..26c408587d 100644 --- a/tests/auto/qml/qqmlmoduleplugin/strictModule/qmldir +++ b/tests/auto/qml/qqmlmoduleplugin/strictModule/qmldir @@ -1,2 +1,2 @@ -module com.nokia.StrictModule +module org.qtproject.StrictModule plugin strictModule diff --git a/tests/auto/qml/qqmlmoduleplugin/strictModule/strictModule.pro b/tests/auto/qml/qqmlmoduleplugin/strictModule/strictModule.pro index 7b818c0481..bf1c5df1a7 100644 --- a/tests/auto/qml/qqmlmoduleplugin/strictModule/strictModule.pro +++ b/tests/auto/qml/qqmlmoduleplugin/strictModule/strictModule.pro @@ -2,7 +2,7 @@ TEMPLATE = lib CONFIG += plugin SOURCES = plugin.cpp QT = core qml -DESTDIR = ../imports/com/nokia/StrictModule +DESTDIR = ../imports/org/qtproject/StrictModule QT += core-private gui-private qml-private diff --git a/tests/auto/qml/qqmlmoduleplugin/tst_qqmlmoduleplugin.cpp b/tests/auto/qml/qqmlmoduleplugin/tst_qqmlmoduleplugin.cpp index 147bdb6ffb..a6d9fb5601 100644 --- a/tests/auto/qml/qqmlmoduleplugin/tst_qqmlmoduleplugin.cpp +++ b/tests/auto/qml/qqmlmoduleplugin/tst_qqmlmoduleplugin.cpp @@ -142,7 +142,7 @@ void tst_qqmlmoduleplugin::importsPlugin() engine.addImportPath(m_importsDirectory); QTest::ignoreMessage(QtWarningMsg, "plugin created"); QTest::ignoreMessage(QtWarningMsg, "import worked"); - QTest::ignoreMessage(QtWarningMsg, "Module 'com.nokia.AutoTestQmlPluginType' does not contain a module identifier directive - it cannot be protected from external registrations."); + QTest::ignoreMessage(QtWarningMsg, "Module 'org.qtproject.AutoTestQmlPluginType' does not contain a module identifier directive - it cannot be protected from external registrations."); QQmlComponent component(&engine, testFileUrl(QStringLiteral("works.qml"))); foreach (QQmlError err, component.errors()) qWarning() << err; @@ -159,7 +159,7 @@ void tst_qqmlmoduleplugin::importsPlugin2() engine.addImportPath(m_importsDirectory); QTest::ignoreMessage(QtWarningMsg, "plugin2 created"); QTest::ignoreMessage(QtWarningMsg, "import2 worked"); - QTest::ignoreMessage(QtWarningMsg, "Module 'com.nokia.AutoTestQmlPluginType' does not contain a module identifier directive - it cannot be protected from external registrations."); + QTest::ignoreMessage(QtWarningMsg, "Module 'org.qtproject.AutoTestQmlPluginType' does not contain a module identifier directive - it cannot be protected from external registrations."); QQmlComponent component(&engine, testFileUrl(QStringLiteral("works2.qml"))); foreach (QQmlError err, component.errors()) qWarning() << err; @@ -176,7 +176,7 @@ void tst_qqmlmoduleplugin::importsPlugin21() engine.addImportPath(m_importsDirectory); QTest::ignoreMessage(QtWarningMsg, "plugin2.1 created"); QTest::ignoreMessage(QtWarningMsg, "import2.1 worked"); - QTest::ignoreMessage(QtWarningMsg, "Module 'com.nokia.AutoTestQmlPluginType' does not contain a module identifier directive - it cannot be protected from external registrations."); + QTest::ignoreMessage(QtWarningMsg, "Module 'org.qtproject.AutoTestQmlPluginType' does not contain a module identifier directive - it cannot be protected from external registrations."); QQmlComponent component(&engine, testFileUrl(QStringLiteral("works21.qml"))); foreach (QQmlError err, component.errors()) qWarning() << err; @@ -197,21 +197,21 @@ void tst_qqmlmoduleplugin::incorrectPluginCase() QList<QQmlError> errors = component.errors(); QCOMPARE(errors.count(), 1); + QString expectedError = QLatin1String("module \"org.qtproject.WrongCase\" plugin \"PluGin\" not found"); + #if defined(Q_OS_MAC) || defined(Q_OS_WIN32) + bool caseSensitive = true; #if defined(Q_OS_MAC) + caseSensitive = pathconf(QDir::currentPath().toLatin1().constData(), _PC_CASE_SENSITIVE); QString libname = "libPluGin.dylib"; #elif defined(Q_OS_WIN32) + caseSensitive = false; QString libname = "PluGin.dll"; #endif - QString expectedError = QLatin1String("plugin cannot be loaded for module \"com.nokia.WrongCase\": File name case mismatch for \"") + QDir(m_importsDirectory).filePath("com/nokia/WrongCase/" + libname) + QLatin1String("\""); -#else - QString expectedError = QLatin1String("module \"com.nokia.WrongCase\" plugin \"PluGin\" not found"); + if (!caseSensitive) + expectedError = QLatin1String("plugin cannot be loaded for module \"org.qtproject.WrongCase\": File name case mismatch for \"") + QDir(m_importsDirectory).filePath("org/qtproject/WrongCase/" + libname) + QLatin1String("\""); #endif -#ifdef Q_OS_OSX - if (QSysInfo::MacintoshVersion == QSysInfo::MV_10_8) - QEXPECT_FAIL("", "See QTBUG-32652", Continue); -#endif QCOMPARE(errors.at(0).description(), expectedError); } @@ -229,7 +229,7 @@ void tst_qqmlmoduleplugin::importPluginWithQmlFile() QQmlEngine engine; engine.addImportPath(path); - QTest::ignoreMessage(QtWarningMsg, "Module 'com.nokia.AutoTestPluginWithQmlFile' does not contain a module identifier directive - it cannot be protected from external registrations."); + QTest::ignoreMessage(QtWarningMsg, "Module 'org.qtproject.AutoTestPluginWithQmlFile' does not contain a module identifier directive - it cannot be protected from external registrations."); QQmlComponent component(&engine, testFileUrl(QStringLiteral("pluginWithQmlFile.qml"))); foreach (QQmlError err, component.errors()) @@ -248,7 +248,7 @@ void tst_qqmlmoduleplugin::remoteImportWithQuotedUrl() QQmlEngine engine; QQmlComponent component(&engine); - component.setData("import \"" SERVER_ADDR "/com/nokia/PureQmlModule\" \nComponentA { width: 300; ComponentB{} }", QUrl()); + component.setData("import \"" SERVER_ADDR "/org/qtproject/PureQmlModule\" \nComponentA { width: 300; ComponentB{} }", QUrl()); QTRY_COMPARE(component.status(), QQmlComponent::Ready); QObject *object = component.create(); @@ -270,7 +270,7 @@ void tst_qqmlmoduleplugin::remoteImportWithUnquotedUri() QQmlEngine engine; engine.addImportPath(m_dataImportsDirectory); QQmlComponent component(&engine); - component.setData("import com.nokia.PureQmlModule 1.0 \nComponentA { width: 300; ComponentB{} }", QUrl()); + component.setData("import org.qtproject.PureQmlModule 1.0 \nComponentA { width: 300; ComponentB{} }", QUrl()); QTRY_COMPARE(component.status(), QQmlComponent::Ready); @@ -291,7 +291,7 @@ void tst_qqmlmoduleplugin::importsMixedQmlCppPlugin() QQmlEngine engine; engine.addImportPath(m_importsDirectory); - QTest::ignoreMessage(QtWarningMsg, "Module 'com.nokia.AutoTestQmlMixedPluginType' does not contain a module identifier directive - it cannot be protected from external registrations."); + QTest::ignoreMessage(QtWarningMsg, "Module 'org.qtproject.AutoTestQmlMixedPluginType' does not contain a module identifier directive - it cannot be protected from external registrations."); { QQmlComponent component(&engine, testFileUrl(QStringLiteral("importsMixedQmlCppPlugin.qml"))); @@ -334,7 +334,7 @@ void tst_qqmlmoduleplugin::versionNotInstalled() static int count = 0; if (++count == 1) - QTest::ignoreMessage(QtWarningMsg, "Module 'com.nokia.AutoTestQmlVersionPluginType' does not contain a module identifier directive - it cannot be protected from external registrations."); + QTest::ignoreMessage(QtWarningMsg, "Module 'org.qtproject.AutoTestQmlVersionPluginType' does not contain a module identifier directive - it cannot be protected from external registrations."); QQmlComponent component(&engine, testFileUrl(file)); VERIFY_ERRORS(errorFile.toLatin1().constData()); @@ -406,7 +406,7 @@ void tst_qqmlmoduleplugin::importsNested() static int count = 0; if (++count == 1) - QTest::ignoreMessage(QtWarningMsg, "Module 'com.nokia.AutoTestQmlNestedPluginType' does not contain a module identifier directive - it cannot be protected from external registrations."); + QTest::ignoreMessage(QtWarningMsg, "Module 'org.qtproject.AutoTestQmlNestedPluginType' does not contain a module identifier directive - it cannot be protected from external registrations."); QQmlComponent component(&engine, testFile(file)); QObject *obj = component.create(); @@ -506,38 +506,38 @@ void tst_qqmlmoduleplugin::importStrictModule_data() QTest::addColumn<QString>("error"); QTest::newRow("success") - << "import com.nokia.StrictModule 1.0\n" + << "import org.qtproject.StrictModule 1.0\n" "MyPluginType {}" << QString() << QString(); QTest::newRow("wrong target") - << "import com.nokia.InvalidStrictModule 1.0\n" + << "import org.qtproject.InvalidStrictModule 1.0\n" "MyPluginType {}" << QString() - << ":1:1: plugin cannot be loaded for module \"com.nokia.InvalidStrictModule\": Cannot install element 'MyPluginType' into unregistered namespace 'com.nokia.SomeOtherModule'"; + << ":1:1: plugin cannot be loaded for module \"org.qtproject.InvalidStrictModule\": Cannot install element 'MyPluginType' into unregistered namespace 'org.qtproject.SomeOtherModule'"; QTest::newRow("non-strict clash") - << "import com.nokia.NonstrictModule 1.0\n" + << "import org.qtproject.NonstrictModule 1.0\n" "MyPluginType {}" - << "Module 'com.nokia.NonstrictModule' does not contain a module identifier directive - it cannot be protected from external registrations." - << ":1:1: plugin cannot be loaded for module \"com.nokia.NonstrictModule\": Cannot install element 'MyPluginType' into protected namespace 'com.nokia.StrictModule'"; + << "Module 'org.qtproject.NonstrictModule' does not contain a module identifier directive - it cannot be protected from external registrations." + << ":1:1: plugin cannot be loaded for module \"org.qtproject.NonstrictModule\": Cannot install element 'MyPluginType' into protected namespace 'org.qtproject.StrictModule'"; QTest::newRow("non-strict preemption") - << "import com.nokia.PreemptiveModule 1.0\n" - "import com.nokia.PreemptedStrictModule 1.0\n" + << "import org.qtproject.PreemptiveModule 1.0\n" + "import org.qtproject.PreemptedStrictModule 1.0\n" "MyPluginType {}" - << "Module 'com.nokia.PreemptiveModule' does not contain a module identifier directive - it cannot be protected from external registrations." - << ":2:1: plugin cannot be loaded for module \"com.nokia.PreemptedStrictModule\": Namespace 'com.nokia.PreemptedStrictModule' has already been used for type registration"; + << "Module 'org.qtproject.PreemptiveModule' does not contain a module identifier directive - it cannot be protected from external registrations." + << ":2:1: plugin cannot be loaded for module \"org.qtproject.PreemptedStrictModule\": Namespace 'org.qtproject.PreemptedStrictModule' has already been used for type registration"; QTest::newRow("invalid namespace") - << "import com.nokia.InvalidNamespaceModule 1.0\n" + << "import org.qtproject.InvalidNamespaceModule 1.0\n" "MyPluginType {}" << QString() - << ":1:1: plugin cannot be loaded for module \"com.nokia.InvalidNamespaceModule\": Module namespace 'com.nokia.AwesomeModule' does not match import URI 'com.nokia.InvalidNamespaceModule'"; + << ":1:1: plugin cannot be loaded for module \"org.qtproject.InvalidNamespaceModule\": Module namespace 'org.qtproject.AwesomeModule' does not match import URI 'org.qtproject.InvalidNamespaceModule'"; QTest::newRow("module directive must be first") - << "import com.nokia.InvalidFirstCommandModule 1.0\n" + << "import org.qtproject.InvalidFirstCommandModule 1.0\n" "MyPluginType {}" << QString() << ":1:1: module identifier directive must be the first directive in a qmldir file"; diff --git a/tests/auto/qml/qqmlnotifier/tst_qqmlnotifier.cpp b/tests/auto/qml/qqmlnotifier/tst_qqmlnotifier.cpp index fa3b190826..f1b48df437 100644 --- a/tests/auto/qml/qqmlnotifier/tst_qqmlnotifier.cpp +++ b/tests/auto/qml/qqmlnotifier/tst_qqmlnotifier.cpp @@ -98,6 +98,7 @@ public: void verifyReceiverCount() { + //Note: QTBUG-34829 means we can't call this from within disconnectNotify or it can lock QCOMPARE(receivers(SIGNAL(qmlObjectPropChanged())), qmlObjectPropConnections); QCOMPARE(receivers(SIGNAL(cppObjectPropChanged())), cppObjectPropConnections); QCOMPARE(receivers(SIGNAL(unboundPropChanged())), unboundPropConnections); @@ -134,7 +135,6 @@ protected: if (signal.name() == "scriptBindingPropChanged") scriptBindingPropConnections--; if (signal.name() == "boundSignal") boundSignalConnections--; if (signal.name() == "unusedSignal") unusedSignalConnections--; - verifyReceiverCount(); //qDebug() << Q_FUNC_INFO << this << signal.methodSignature(); } @@ -205,6 +205,7 @@ void tst_qqmlnotifier::createObjects() exportedClass = qobject_cast<ExportedClass *>( root->findChild<ExportedClass*>("exportedClass")); QVERIFY(exportedClass != 0); + exportedClass->verifyReceiverCount(); } void tst_qqmlnotifier::cleanupTestCase() diff --git a/tests/auto/qml/qqmlsettings/tst_qqmlsettings.cpp b/tests/auto/qml/qqmlsettings/tst_qqmlsettings.cpp index 897450823c..7b5ed5e236 100644 --- a/tests/auto/qml/qqmlsettings/tst_qqmlsettings.cpp +++ b/tests/auto/qml/qqmlsettings/tst_qqmlsettings.cpp @@ -65,6 +65,7 @@ private slots: void aliases(); void categories(); void siblings(); + void initial(); }; class CppObject : public QObject @@ -579,6 +580,23 @@ void tst_QQmlSettings::siblings() QCOMPARE(settings.value("alias2").toString(), QStringLiteral("value2")); } +void tst_QQmlSettings::initial() +{ + QSettings qs; + qs.setValue("value", QStringLiteral("initial")); + qs.sync(); + + QQmlEngine engine; + QQmlComponent component(&engine); + component.setData("import Qt.labs.settings 1.0; Settings { property var value }", QUrl()); + QScopedPointer<QObject> settings(component.create()); + QVERIFY(settings.data()); + + // verify that the initial value from QSettings gets properly loaded + // even if no initial value is set in QML + QCOMPARE(settings->property("value").toString(), QStringLiteral("initial")); +} + QTEST_MAIN(tst_QQmlSettings) #include "tst_qqmlsettings.moc" diff --git a/tests/auto/qml/qqmlxmlhttprequest/tst_qqmlxmlhttprequest.cpp b/tests/auto/qml/qqmlxmlhttprequest/tst_qqmlxmlhttprequest.cpp index 3ae27fe9c3..9c67e6e2e9 100644 --- a/tests/auto/qml/qqmlxmlhttprequest/tst_qqmlxmlhttprequest.cpp +++ b/tests/auto/qml/qqmlxmlhttprequest/tst_qqmlxmlhttprequest.cpp @@ -127,8 +127,8 @@ private: void tst_qqmlxmlhttprequest::domExceptionCodes() { QQmlComponent component(&engine, testFileUrl("domExceptionCodes.qml")); - QObject *object = component.create(); - QVERIFY(object != 0); + QScopedPointer<QObject> object(component.create()); + QVERIFY(!object.isNull()); QCOMPARE(object->property("index_size_err").toInt(), 1); QCOMPARE(object->property("domstring_size_err").toInt(), 2); @@ -147,8 +147,6 @@ void tst_qqmlxmlhttprequest::domExceptionCodes() QCOMPARE(object->property("invalid_access_err").toInt(), 15); QCOMPARE(object->property("validation_err").toInt(), 16); QCOMPARE(object->property("type_mismatch_err").toInt(), 17); - - delete object; } void tst_qqmlxmlhttprequest::callbackException_data() @@ -172,15 +170,13 @@ void tst_qqmlxmlhttprequest::callbackException() QTest::ignoreMessage(QtWarningMsg, expect.toLatin1()); QQmlComponent component(&engine, testFileUrl("callbackException.qml")); - QObject *object = component.beginCreate(engine.rootContext()); - QVERIFY(object != 0); + QScopedPointer<QObject> object(component.beginCreate(engine.rootContext())); + QVERIFY(!object.isNull()); object->setProperty("url", "testdocument.html"); object->setProperty("which", which); component.completeCreate(); QTRY_VERIFY(object->property("threw").toBool() == true); - - delete object; } // Test that the state value properties on the XMLHttpRequest constructor have the correct values. @@ -188,61 +184,53 @@ void tst_qqmlxmlhttprequest::callbackException() void tst_qqmlxmlhttprequest::staticStateValues() { QQmlComponent component(&engine, testFileUrl("staticStateValues.qml")); - QObject *object = component.create(); - QVERIFY(object != 0); + QScopedPointer<QObject> object(component.create()); + QVERIFY(!object.isNull()); QCOMPARE(object->property("unsent").toInt(), 0); QCOMPARE(object->property("opened").toInt(), 1); QCOMPARE(object->property("headers_received").toInt(), 2); QCOMPARE(object->property("loading").toInt(), 3); QCOMPARE(object->property("done").toInt(), 4); - - delete object; } // Test that the state value properties on instances have the correct values. void tst_qqmlxmlhttprequest::instanceStateValues() { QQmlComponent component(&engine, testFileUrl("instanceStateValues.qml")); - QObject *object = component.create(); - QVERIFY(object != 0); + QScopedPointer<QObject> object(component.create()); + QVERIFY(!object.isNull()); QCOMPARE(object->property("unsent").toInt(), 0); QCOMPARE(object->property("opened").toInt(), 1); QCOMPARE(object->property("headers_received").toInt(), 2); QCOMPARE(object->property("loading").toInt(), 3); QCOMPARE(object->property("done").toInt(), 4); - - delete object; } // Test calling constructor void tst_qqmlxmlhttprequest::constructor() { QQmlComponent component(&engine, testFileUrl("constructor.qml")); - QObject *object = component.create(); - QVERIFY(object != 0); + QScopedPointer<QObject> object(component.create()); + QVERIFY(!object.isNull()); QCOMPARE(object->property("calledAsConstructor").toBool(), true); QCOMPARE(object->property("calledAsFunction").toBool(), true); - - delete object; } // Test that all the properties are set correctly before any request is sent void tst_qqmlxmlhttprequest::defaultState() { QQmlComponent component(&engine, testFileUrl("defaultState.qml")); - QObject *object = component.create(); - QVERIFY(object != 0); + QScopedPointer<QObject> object(component.create()); + QVERIFY(!object.isNull()); QCOMPARE(object->property("readState").toInt(), 0); QCOMPARE(object->property("statusIsException").toBool(), true); QCOMPARE(object->property("statusTextIsException").toBool(), true); QCOMPARE(object->property("responseText").toString(), QString()); QCOMPARE(object->property("responseXMLIsNull").toBool(), true); - - delete object; } // Test valid XMLHttpRequest.open() calls @@ -262,8 +250,8 @@ void tst_qqmlxmlhttprequest::open() } QQmlComponent component(&engine, qmlFile); - QObject *object = component.beginCreate(engine.rootContext()); - QVERIFY(object != 0); + QScopedPointer<QObject> object(component.beginCreate(engine.rootContext())); + QVERIFY(!object.isNull()); object->setProperty("url", url); component.completeCreate(); @@ -275,8 +263,6 @@ void tst_qqmlxmlhttprequest::open() QCOMPARE(object->property("responseXML").toBool(), true); QTRY_VERIFY(object->property("dataOK").toBool() == true); - - delete object; } void tst_qqmlxmlhttprequest::open_data() @@ -297,24 +283,20 @@ void tst_qqmlxmlhttprequest::open_data() void tst_qqmlxmlhttprequest::open_invalid_method() { QQmlComponent component(&engine, testFileUrl("open_invalid_method.qml")); - QObject *object = component.create(); - QVERIFY(object != 0); + QScopedPointer<QObject> object(component.create()); + QVERIFY(!object.isNull()); QCOMPARE(object->property("exceptionThrown").toBool(), true); - - delete object; } // Test that calling XMLHttpRequest.open() with sync raises an exception void tst_qqmlxmlhttprequest::open_sync() { QQmlComponent component(&engine, testFileUrl("open_sync.qml")); - QObject *object = component.create(); - QVERIFY(object != 0); + QScopedPointer<QObject> object(component.create()); + QVERIFY(!object.isNull()); QCOMPARE(object->property("exceptionThrown").toBool(), true); - - delete object; } // Calling with incorrect arg count raises an exception @@ -322,22 +304,18 @@ void tst_qqmlxmlhttprequest::open_arg_count() { { QQmlComponent component(&engine, testFileUrl("open_arg_count.1.qml")); - QObject *object = component.create(); - QVERIFY(object != 0); + QScopedPointer<QObject> object(component.create()); + QVERIFY(!object.isNull()); QCOMPARE(object->property("exceptionThrown").toBool(), true); - - delete object; } { QQmlComponent component(&engine, testFileUrl("open_arg_count.2.qml")); - QObject *object = component.create(); - QVERIFY(object != 0); + QScopedPointer<QObject> object(component.create()); + QVERIFY(!object.isNull()); QCOMPARE(object->property("exceptionThrown").toBool(), true); - - delete object; } } @@ -351,14 +329,12 @@ void tst_qqmlxmlhttprequest::setRequestHeader() testFileUrl("testdocument.html"))); QQmlComponent component(&engine, testFileUrl("setRequestHeader.qml")); - QObject *object = component.beginCreate(engine.rootContext()); - QVERIFY(object != 0); + QScopedPointer<QObject> object(component.beginCreate(engine.rootContext())); + QVERIFY(!object.isNull()); object->setProperty("url", "http://127.0.0.1:14445/testdocument.html"); component.completeCreate(); QTRY_VERIFY(object->property("dataOK").toBool() == true); - - delete object; } // Test valid setRequestHeader() calls with different header cases @@ -371,25 +347,21 @@ void tst_qqmlxmlhttprequest::setRequestHeader_caseInsensitive() testFileUrl("testdocument.html"))); QQmlComponent component(&engine, testFileUrl("setRequestHeader_caseInsensitive.qml")); - QObject *object = component.beginCreate(engine.rootContext()); - QVERIFY(object != 0); + QScopedPointer<QObject> object(component.beginCreate(engine.rootContext())); + QVERIFY(!object.isNull()); object->setProperty("url", "http://127.0.0.1:14445/testdocument.html"); component.completeCreate(); QTRY_VERIFY(object->property("dataOK").toBool() == true); - - delete object; } // Test setting headers before open() throws exception void tst_qqmlxmlhttprequest::setRequestHeader_unsent() { QQmlComponent component(&engine, testFileUrl("setRequestHeader_unsent.qml")); - QObject *object = component.create(); - QVERIFY(object != 0); + QScopedPointer<QObject> object(component.create()); + QVERIFY(!object.isNull()); QCOMPARE(object->property("test").toBool(), true); - - delete object; } void tst_qqmlxmlhttprequest::setRequestHeader_illegalName_data() @@ -432,8 +404,8 @@ void tst_qqmlxmlhttprequest::setRequestHeader_illegalName() testFileUrl("testdocument.html"))); QQmlComponent component(&engine, testFileUrl("setRequestHeader_illegalName.qml")); - QObject *object = component.beginCreate(engine.rootContext()); - QVERIFY(object != 0); + QScopedPointer<QObject> object(component.beginCreate(engine.rootContext())); + QVERIFY(!object.isNull()); object->setProperty("url", "http://127.0.0.1:14445/testdocument.html"); object->setProperty("header", name); component.completeCreate(); @@ -446,8 +418,6 @@ void tst_qqmlxmlhttprequest::setRequestHeader_illegalName() QCOMPARE(object->property("responseXML").toBool(), true); QTRY_VERIFY(object->property("dataOK").toBool() == true); - - delete object; } // Test that attempting to set a header after a request is sent throws an exception @@ -460,53 +430,45 @@ void tst_qqmlxmlhttprequest::setRequestHeader_sent() testFileUrl("testdocument.html"))); QQmlComponent component(&engine, testFileUrl("setRequestHeader_sent.qml")); - QObject *object = component.beginCreate(engine.rootContext()); - QVERIFY(object != 0); + QScopedPointer<QObject> object(component.beginCreate(engine.rootContext())); + QVERIFY(!object.isNull()); object->setProperty("url", "http://127.0.0.1:14445/testdocument.html"); component.completeCreate(); QCOMPARE(object->property("test").toBool(), true); QTRY_VERIFY(object->property("dataOK").toBool() == true); - - delete object; } // Invalid arg count throws exception void tst_qqmlxmlhttprequest::setRequestHeader_args() { QQmlComponent component(&engine, testFileUrl("setRequestHeader_args.qml")); - QObject *object = component.create(); - QVERIFY(object != 0); + QScopedPointer<QObject> object(component.create()); + QVERIFY(!object.isNull()); QCOMPARE(object->property("exceptionThrown").toBool(), true); - - delete object; } // Test that calling send() in UNSENT state throws an exception void tst_qqmlxmlhttprequest::send_unsent() { QQmlComponent component(&engine, testFileUrl("send_unsent.qml")); - QObject *object = component.create(); - QVERIFY(object != 0); + QScopedPointer<QObject> object(component.create()); + QVERIFY(!object.isNull()); QCOMPARE(object->property("test").toBool(), true); - - delete object; } // Test attempting to resend a sent request throws an exception void tst_qqmlxmlhttprequest::send_alreadySent() { QQmlComponent component(&engine, testFileUrl("send_alreadySent.qml")); - QObject *object = component.create(); - QVERIFY(object != 0); + QScopedPointer<QObject> object(component.create()); + QVERIFY(!object.isNull()); QCOMPARE(object->property("test").toBool(), true); QTRY_VERIFY(object->property("dataOK").toBool() == true); - - delete object; } // Test that sends for GET, HEAD and DELETE ignore data @@ -520,15 +482,13 @@ void tst_qqmlxmlhttprequest::send_ignoreData() testFileUrl("testdocument.html"))); QQmlComponent component(&engine, testFileUrl("send_ignoreData.qml")); - QObject *object = component.beginCreate(engine.rootContext()); - QVERIFY(object != 0); + QScopedPointer<QObject> object(component.beginCreate(engine.rootContext())); + QVERIFY(!object.isNull()); object->setProperty("reqType", "GET"); object->setProperty("url", "http://127.0.0.1:14445/testdocument.html"); component.completeCreate(); QTRY_VERIFY(object->property("dataOK").toBool() == true); - - delete object; } { @@ -539,15 +499,13 @@ void tst_qqmlxmlhttprequest::send_ignoreData() QUrl())); QQmlComponent component(&engine, testFileUrl("send_ignoreData.qml")); - QObject *object = component.beginCreate(engine.rootContext()); - QVERIFY(object != 0); + QScopedPointer<QObject> object(component.beginCreate(engine.rootContext())); + QVERIFY(!object.isNull()); object->setProperty("reqType", "HEAD"); object->setProperty("url", "http://127.0.0.1:14445/testdocument.html"); component.completeCreate(); QTRY_VERIFY(object->property("dataOK").toBool() == true); - - delete object; } { @@ -558,15 +516,13 @@ void tst_qqmlxmlhttprequest::send_ignoreData() QUrl())); QQmlComponent component(&engine, testFileUrl("send_ignoreData.qml")); - QObject *object = component.beginCreate(engine.rootContext()); - QVERIFY(object != 0); + QScopedPointer<QObject> object(component.beginCreate(engine.rootContext())); + QVERIFY(!object.isNull()); object->setProperty("reqType", "DELETE"); object->setProperty("url", "http://127.0.0.1:14445/testdocument.html"); component.completeCreate(); QTRY_VERIFY(object->property("dataOK").toBool() == true); - - delete object; } } @@ -583,14 +539,12 @@ void tst_qqmlxmlhttprequest::send_withdata() testFileUrl("testdocument.html"))); QQmlComponent component(&engine, testFileUrl(file_qml)); - QObject *object = component.beginCreate(engine.rootContext()); - QVERIFY(object != 0); + QScopedPointer<QObject> object(component.beginCreate(engine.rootContext())); + QVERIFY(!object.isNull()); object->setProperty("url", "http://127.0.0.1:14445/testdocument.html"); component.completeCreate(); QTRY_VERIFY(object->property("dataOK").toBool() == true); - - delete object; } void tst_qqmlxmlhttprequest::send_withdata_data() @@ -611,8 +565,8 @@ void tst_qqmlxmlhttprequest::send_withdata_data() void tst_qqmlxmlhttprequest::abort_unsent() { QQmlComponent component(&engine, testFileUrl("abort_unsent.qml")); - QObject *object = component.beginCreate(engine.rootContext()); - QVERIFY(object != 0); + QScopedPointer<QObject> object(component.beginCreate(engine.rootContext())); + QVERIFY(!object.isNull()); object->setProperty("url", "testdocument.html"); component.completeCreate(); @@ -624,16 +578,14 @@ void tst_qqmlxmlhttprequest::abort_unsent() QCOMPARE(object->property("responseXML").toBool(), true); QTRY_VERIFY(object->property("dataOK").toBool() == true); - - delete object; } // Test abort() cancels an open (but unsent) request void tst_qqmlxmlhttprequest::abort_opened() { QQmlComponent component(&engine, testFileUrl("abort_opened.qml")); - QObject *object = component.beginCreate(engine.rootContext()); - QVERIFY(object != 0); + QScopedPointer<QObject> object(component.beginCreate(engine.rootContext())); + QVERIFY(!object.isNull()); object->setProperty("url", "testdocument.html"); component.completeCreate(); @@ -645,8 +597,6 @@ void tst_qqmlxmlhttprequest::abort_opened() QCOMPARE(object->property("responseXML").toBool(), true); QTRY_VERIFY(object->property("dataOK").toBool() == true); - - delete object; } // Test abort() aborts in progress send @@ -659,8 +609,8 @@ void tst_qqmlxmlhttprequest::abort() testFileUrl("testdocument.html"))); QQmlComponent component(&engine, testFileUrl("abort.qml")); - QObject *object = component.beginCreate(engine.rootContext()); - QVERIFY(object != 0); + QScopedPointer<QObject> object(component.beginCreate(engine.rootContext())); + QVERIFY(!object.isNull()); object->setProperty("urlDummy", "http://127.0.0.1:14449/testdocument.html"); object->setProperty("url", "http://127.0.0.1:14445/testdocument.html"); component.completeCreate(); @@ -670,8 +620,6 @@ void tst_qqmlxmlhttprequest::abort() QCOMPARE(object->property("endStateUnsent").toBool(), true); QTRY_VERIFY(object->property("dataOK").toBool() == true); - - delete object; } void tst_qqmlxmlhttprequest::getResponseHeader() @@ -686,8 +634,8 @@ void tst_qqmlxmlhttprequest::getResponseHeader() QQmlComponent component(&engine, testFileUrl("getResponseHeader.qml")); - QObject *object = component.beginCreate(engine.rootContext()); - QVERIFY(object != 0); + QScopedPointer<QObject> object(component.beginCreate(engine.rootContext())); + QVERIFY(!object.isNull()); object->setProperty("url", "http://127.0.0.1:14445/testdocument.html"); component.completeCreate(); @@ -709,44 +657,36 @@ void tst_qqmlxmlhttprequest::getResponseHeader() QCOMPARE(object->property("doneValidHeader").toBool(), true); QCOMPARE(object->property("doneMultiValidHeader").toBool(), true); QCOMPARE(object->property("doneCookieHeader").toBool(), true); - - delete object; } // Test getResponseHeader throws an exception in an invalid state void tst_qqmlxmlhttprequest::getResponseHeader_unsent() { QQmlComponent component(&engine, testFileUrl("getResponseHeader_unsent.qml")); - QObject *object = component.create(); - QVERIFY(object != 0); + QScopedPointer<QObject> object(component.create()); + QVERIFY(!object.isNull()); QCOMPARE(object->property("test").toBool(), true); - - delete object; } // Test getResponseHeader throws an exception in an invalid state void tst_qqmlxmlhttprequest::getResponseHeader_sent() { QQmlComponent component(&engine, testFileUrl("getResponseHeader_sent.qml")); - QObject *object = component.create(); - QVERIFY(object != 0); + QScopedPointer<QObject> object(component.create()); + QVERIFY(!object.isNull()); QCOMPARE(object->property("test").toBool(), true); - - delete object; } // Invalid arg count throws exception void tst_qqmlxmlhttprequest::getResponseHeader_args() { QQmlComponent component(&engine, testFileUrl("getResponseHeader_args.qml")); - QObject *object = component.create(); - QVERIFY(object != 0); + QScopedPointer<QObject> object(component.create()); + QVERIFY(!object.isNull()); QTRY_VERIFY(object->property("exceptionThrown").toBool() == true); - - delete object; } void tst_qqmlxmlhttprequest::getAllResponseHeaders() @@ -760,8 +700,8 @@ void tst_qqmlxmlhttprequest::getAllResponseHeaders() testFileUrl("testdocument.html"))); QQmlComponent component(&engine, testFileUrl("getAllResponseHeaders.qml")); - QObject *object = component.beginCreate(engine.rootContext()); - QVERIFY(object != 0); + QScopedPointer<QObject> object(component.beginCreate(engine.rootContext())); + QVERIFY(!object.isNull()); object->setProperty("url", "http://127.0.0.1:14445/testdocument.html"); component.completeCreate(); @@ -777,44 +717,36 @@ void tst_qqmlxmlhttprequest::getAllResponseHeaders() QCOMPARE(object->property("doneState").toBool(), true); QCOMPARE(object->property("doneHeader").toBool(), true); - - delete object; } // Test getAllResponseHeaders throws an exception in an invalid state void tst_qqmlxmlhttprequest::getAllResponseHeaders_unsent() { QQmlComponent component(&engine, testFileUrl("getAllResponseHeaders_unsent.qml")); - QObject *object = component.create(); - QVERIFY(object != 0); + QScopedPointer<QObject> object(component.create()); + QVERIFY(!object.isNull()); QCOMPARE(object->property("test").toBool(), true); - - delete object; } // Test getAllResponseHeaders throws an exception in an invalid state void tst_qqmlxmlhttprequest::getAllResponseHeaders_sent() { QQmlComponent component(&engine, testFileUrl("getAllResponseHeaders_sent.qml")); - QObject *object = component.create(); - QVERIFY(object != 0); + QScopedPointer<QObject> object(component.create()); + QVERIFY(!object.isNull()); QCOMPARE(object->property("test").toBool(), true); - - delete object; } // Invalid arg count throws exception void tst_qqmlxmlhttprequest::getAllResponseHeaders_args() { QQmlComponent component(&engine, testFileUrl("getAllResponseHeaders_args.qml")); - QObject *object = component.create(); - QVERIFY(object != 0); + QScopedPointer<QObject> object(component.create()); + QVERIFY(!object.isNull()); QTRY_VERIFY(object->property("exceptionThrown").toBool() == true); - - delete object; } void tst_qqmlxmlhttprequest::status() @@ -829,8 +761,8 @@ void tst_qqmlxmlhttprequest::status() testFileUrl("testdocument.html"))); QQmlComponent component(&engine, testFileUrl("status.qml")); - QObject *object = component.beginCreate(engine.rootContext()); - QVERIFY(object != 0); + QScopedPointer<QObject> object(component.beginCreate(engine.rootContext())); + QVERIFY(!object.isNull()); object->setProperty("url", "http://127.0.0.1:14445/testdocument.html"); object->setProperty("expectedStatus", status); component.completeCreate(); @@ -844,8 +776,6 @@ void tst_qqmlxmlhttprequest::status() QCOMPARE(object->property("loading").toBool(), true); QCOMPARE(object->property("done").toBool(), true); QCOMPARE(object->property("resetException").toBool(), true); - - delete object; } void tst_qqmlxmlhttprequest::status_data() @@ -870,8 +800,8 @@ void tst_qqmlxmlhttprequest::statusText() testFileUrl("testdocument.html"))); QQmlComponent component(&engine, testFileUrl("statusText.qml")); - QObject *object = component.beginCreate(engine.rootContext()); - QVERIFY(object != 0); + QScopedPointer<QObject> object(component.beginCreate(engine.rootContext())); + QVERIFY(!object.isNull()); object->setProperty("url", "http://127.0.0.1:14445/testdocument.html"); object->setProperty("expectedStatus", statusText); component.completeCreate(); @@ -885,8 +815,6 @@ void tst_qqmlxmlhttprequest::statusText() QCOMPARE(object->property("loading").toBool(), true); QCOMPARE(object->property("done").toBool(), true); QCOMPARE(object->property("resetException").toBool(), true); - - delete object; } void tst_qqmlxmlhttprequest::statusText_data() @@ -912,8 +840,8 @@ void tst_qqmlxmlhttprequest::responseText() bodyUrl)); QQmlComponent component(&engine, testFileUrl("responseText.qml")); - QObject *object = component.beginCreate(engine.rootContext()); - QVERIFY(object != 0); + QScopedPointer<QObject> object(component.beginCreate(engine.rootContext())); + QVERIFY(!object.isNull()); object->setProperty("url", "http://127.0.0.1:14445/testdocument.html"); object->setProperty("expectedText", responseText); component.completeCreate(); @@ -927,8 +855,6 @@ void tst_qqmlxmlhttprequest::responseText() QCOMPARE(object->property("loading").toBool(), true); QCOMPARE(object->property("done").toBool(), true); QCOMPARE(object->property("reset").toBool(), true); - - delete object; } void tst_qqmlxmlhttprequest::responseText_data() @@ -950,11 +876,11 @@ void tst_qqmlxmlhttprequest::nonUtf8() QFETCH(QString, xmlRootNodeValue); QQmlComponent component(&engine, testFileUrl("utf16.qml")); - QObject *object = component.create(); - QVERIFY(object != 0); + QScopedPointer<QObject> object(component.create()); + QVERIFY(!object.isNull()); object->setProperty("fileName", fileName); - QMetaObject::invokeMethod(object, "startRequest"); + QMetaObject::invokeMethod(object.data(), "startRequest"); QTRY_VERIFY(object->property("dataOK").toBool() == true); @@ -964,8 +890,6 @@ void tst_qqmlxmlhttprequest::nonUtf8() QString rootNodeValue = object->property("responseXmlRootNodeValue").toString(); QCOMPARE(rootNodeValue, xmlRootNodeValue); } - - delete object; } void tst_qqmlxmlhttprequest::nonUtf8_data() @@ -989,8 +913,8 @@ void tst_qqmlxmlhttprequest::nonUtf8_data() void tst_qqmlxmlhttprequest::invalidMethodUsage() { QQmlComponent component(&engine, testFileUrl("invalidMethodUsage.qml")); - QObject *object = component.create(); - QVERIFY(object != 0); + QScopedPointer<QObject> object(component.create()); + QVERIFY(!object.isNull()); QCOMPARE(object->property("readyState").toBool(), true); QCOMPARE(object->property("status").toBool(), true); @@ -1004,8 +928,6 @@ void tst_qqmlxmlhttprequest::invalidMethodUsage() QCOMPARE(object->property("abort").toBool(), true); QCOMPARE(object->property("getResponseHeader").toBool(), true); QCOMPARE(object->property("getAllResponseHeaders").toBool(), true); - - delete object; } // Test that XMLHttpRequest transparently redirects @@ -1018,16 +940,14 @@ void tst_qqmlxmlhttprequest::redirects() server.serveDirectory(dataDirectory()); QQmlComponent component(&engine, testFileUrl("redirects.qml")); - QObject *object = component.beginCreate(engine.rootContext()); - QVERIFY(object != 0); + QScopedPointer<QObject> object(component.beginCreate(engine.rootContext())); + QVERIFY(!object.isNull()); object->setProperty("url", "http://127.0.0.1:14445/redirect.html"); object->setProperty("expectedText", ""); component.completeCreate(); QTRY_VERIFY(object->property("done").toBool() == true); QCOMPARE(object->property("dataOK").toBool(), true); - - delete object; } { @@ -1037,16 +957,14 @@ void tst_qqmlxmlhttprequest::redirects() server.serveDirectory(dataDirectory()); QQmlComponent component(&engine, testFileUrl("redirectError.qml")); - QObject *object = component.beginCreate(engine.rootContext()); - QVERIFY(object != 0); + QScopedPointer<QObject> object(component.beginCreate(engine.rootContext())); + QVERIFY(!object.isNull()); object->setProperty("url", "http://127.0.0.1:14445/redirect.html"); object->setProperty("expectedText", ""); component.completeCreate(); QTRY_VERIFY(object->property("done").toBool() == true); QCOMPARE(object->property("dataOK").toBool(), true); - - delete object; } { @@ -1056,8 +974,8 @@ void tst_qqmlxmlhttprequest::redirects() server.serveDirectory(dataDirectory()); QQmlComponent component(&engine, testFileUrl("redirectRecur.qml")); - QObject *object = component.beginCreate(engine.rootContext()); - QVERIFY(object != 0); + QScopedPointer<QObject> object(component.beginCreate(engine.rootContext())); + QVERIFY(!object.isNull()); object->setProperty("url", "http://127.0.0.1:14445/redirect.html"); object->setProperty("expectedText", ""); component.completeCreate(); @@ -1069,92 +987,78 @@ void tst_qqmlxmlhttprequest::redirects() QVERIFY(object->property("done").toBool() == true); QCOMPARE(object->property("dataOK").toBool(), true); - - delete object; } } void tst_qqmlxmlhttprequest::responseXML_invalid() { QQmlComponent component(&engine, testFileUrl("responseXML_invalid.qml")); - QObject *object = component.create(); - QVERIFY(object != 0); + QScopedPointer<QObject> object(component.create()); + QVERIFY(!object.isNull()); QTRY_VERIFY(object->property("dataOK").toBool() == true); QCOMPARE(object->property("xmlNull").toBool(), true); - - delete object; } // Test the Document DOM element void tst_qqmlxmlhttprequest::document() { QQmlComponent component(&engine, testFileUrl("document.qml")); - QObject *object = component.create(); - QVERIFY(object != 0); + QScopedPointer<QObject> object(component.create()); + QVERIFY(!object.isNull()); QTRY_VERIFY(object->property("dataOK").toBool() == true); QCOMPARE(object->property("xmlTest").toBool(), true); - - delete object; } // Test the Element DOM element void tst_qqmlxmlhttprequest::element() { QQmlComponent component(&engine, testFileUrl("element.qml")); - QObject *object = component.create(); - QVERIFY(object != 0); + QScopedPointer<QObject> object(component.create()); + QVERIFY(!object.isNull()); QTRY_VERIFY(object->property("dataOK").toBool() == true); QCOMPARE(object->property("xmlTest").toBool(), true); - - delete object; } // Test the Attr DOM element void tst_qqmlxmlhttprequest::attr() { QQmlComponent component(&engine, testFileUrl("attr.qml")); - QObject *object = component.create(); - QVERIFY(object != 0); + QScopedPointer<QObject> object(component.create()); + QVERIFY(!object.isNull()); QTRY_VERIFY(object->property("dataOK").toBool() == true); QCOMPARE(object->property("xmlTest").toBool(), true); - - delete object; } // Test the Text DOM element void tst_qqmlxmlhttprequest::text() { QQmlComponent component(&engine, testFileUrl("text.qml")); - QObject *object = component.create(); - QVERIFY(object != 0); + QScopedPointer<QObject> object(component.create()); + QVERIFY(!object.isNull()); QTRY_VERIFY(object->property("dataOK").toBool() == true); QCOMPARE(object->property("xmlTest").toBool(), true); - - delete object; } // Test the CDataSection DOM element void tst_qqmlxmlhttprequest::cdata() { QQmlComponent component(&engine, testFileUrl("cdata.qml")); - QObject *object = component.create(); - QVERIFY(object != 0); + QScopedPointer<QObject> object(component.create()); + QVERIFY(!object.isNull()); QTRY_VERIFY(object->property("dataOK").toBool() == true); QCOMPARE(object->property("xmlTest").toBool(), true); - - delete object; } void tst_qqmlxmlhttprequest::stateChangeCallingContext() @@ -1171,11 +1075,10 @@ void tst_qqmlxmlhttprequest::stateChangeCallingContext() server.serveDirectory(dataDirectory(), TestHTTPServer::Delay); QQmlComponent component(&engine, testFileUrl("stateChangeCallingContext.qml")); - QObject *object = component.create(); - QVERIFY(object != 0); + QScopedPointer<QObject> object(component.create()); + QVERIFY(!object.isNull()); server.sendDelayedItem(); QTRY_VERIFY(object->property("success").toBool() == true); - delete object; } QTEST_MAIN(tst_qqmlxmlhttprequest) diff --git a/tests/auto/qml/qv4debugger/tst_qv4debugger.cpp b/tests/auto/qml/qv4debugger/tst_qv4debugger.cpp index 9fbcb4a118..15a6acc272 100644 --- a/tests/auto/qml/qv4debugger/tst_qv4debugger.cpp +++ b/tests/auto/qml/qv4debugger/tst_qv4debugger.cpp @@ -45,6 +45,9 @@ #include <private/qv4debugging_p.h> #include <private/qv8engine_p.h> +using namespace QV4; +using namespace QV4::Debugging; + static bool waitForSignal(QObject* obj, const char* signal, int timeout = 10000) { QEventLoop loop; @@ -77,7 +80,7 @@ public: QV4::ExecutionEngine *v4Engine() { return QV8Engine::getV4(this); } - typedef QV4::ReturnedValue (*InjectedFunction)(QV4::SimpleCallContext*); + typedef QV4::ReturnedValue (*InjectedFunction)(QV4::CallContext*); Q_INVOKABLE void injectFunction(const QString &functionName, TestEngine::InjectedFunction injectedFunction) { @@ -95,26 +98,109 @@ signals: Q_DECLARE_METATYPE(TestEngine::InjectedFunction) +namespace { +class TestCollector: public QV4::Debugging::Debugger::Collector +{ +public: + TestCollector(QV4::ExecutionEngine *engine) + : Collector(engine) + , destination(0) + {} + + virtual ~TestCollector() {} + + void setDestination(QVariantMap *dest) + { destination = dest; } + +protected: + virtual void addUndefined(const QString &name) + { + destination->insert(name, QStringLiteral("undefined")); // TODO: add a user-defined type for this + } + + virtual void addNull(const QString &name) + { + destination->insert(name, QStringLiteral("null")); // TODO: add a user-defined type for this + } + + virtual void addBoolean(const QString &name, bool value) + { + destination->insert(name, value); + } + + virtual void addString(const QString &name, const QString &value) + { + destination->insert(name, value); + } + + virtual void addObject(const QString &name, QV4::ValueRef value) + { + QV4::Scope scope(engine()); + QV4::ScopedObject obj(scope, value->asObject()); + + QVariantMap props, *prev = &props; + qSwap(destination, prev); + collect(obj); + qSwap(destination, prev); + + destination->insert(name, props); + } + + virtual void addInteger(const QString &name, int value) + { + destination->insert(name, QVariant::fromValue<double>(static_cast<double>(value))); + } + + virtual void addDouble(const QString &name, double value) + { + destination->insert(name, QVariant::fromValue<double>(value)); + } + +private: + QVariantMap *destination; +}; +} + class TestAgent : public QV4::Debugging::DebuggerAgent { Q_OBJECT public: TestAgent() : m_wasPaused(false) + , m_captureContextInfo(false) { } - virtual void debuggerPaused(QV4::Debugging::Debugger *debugger) + virtual void debuggerPaused(Debugger *debugger, PauseReason reason) { Q_ASSERT(m_debuggers.count() == 1 && m_debuggers.first() == debugger); m_wasPaused = true; + m_pauseReason = reason; m_statesWhenPaused << debugger->currentExecutionState(); + TestCollector collector(debugger->engine()); + QVariantMap tmp; + collector.setDestination(&tmp); + debugger->collectThrownValue(&collector); + m_thrownValue = tmp["exception"]; + foreach (const TestBreakPoint &bp, m_breakPointsToAddWhenPaused) debugger->addBreakPoint(bp.fileName, bp.lineNumber); m_breakPointsToAddWhenPaused.clear(); - debugger->resume(); + m_stackTrace = debugger->stackTrace(); + + if (m_captureContextInfo) + captureContextInfo(debugger); + + debugger->resume(Debugger::FullThrottle); + } + + virtual void sourcesCollected(Debugger *debugger, QStringList sources, int requestSequenceNr) + { + Q_UNUSED(debugger); + Q_UNUSED(sources); + Q_UNUSED(requestSequenceNr); } int debuggerCount() const { return m_debuggers.count(); } @@ -128,18 +214,52 @@ public: int lineNumber; }; + void captureContextInfo(Debugger *debugger) + { + TestCollector collector(debugger->engine()); + + for (int i = 0, ei = m_stackTrace.size(); i != ei; ++i) { + QVariantMap args; + collector.setDestination(&args); + debugger->collectArgumentsInContext(&collector, i); + m_capturedArguments.append(args); + + QVariantMap locals; + collector.setDestination(&locals); + debugger->collectLocalsInContext(&collector, i); + m_capturedLocals.append(locals); + } + } + bool m_wasPaused; - QList<QV4::Debugging::Debugger::ExecutionState> m_statesWhenPaused; + PauseReason m_pauseReason; + bool m_captureContextInfo; + QList<Debugger::ExecutionState> m_statesWhenPaused; QList<TestBreakPoint> m_breakPointsToAddWhenPaused; + QVector<QV4::StackFrame> m_stackTrace; + QList<QVariantMap> m_capturedArguments; + QList<QVariantMap> m_capturedLocals; + QVariant m_thrownValue; + + // Utility methods: + void dumpStackTrace() const + { + qDebug() << "Stack depth:" << m_stackTrace.size(); + foreach (const QV4::StackFrame &frame, m_stackTrace) + qDebug("\t%s (%s:%d:%d)", qPrintable(frame.function), qPrintable(frame.source), + frame.line, frame.column); + } }; class tst_qv4debugger : public QObject { Q_OBJECT + private slots: void init(); void cleanup(); + // breakpoints: void breakAnywhere(); void pendingBreakpoint(); void liveBreakPoint(); @@ -147,6 +267,15 @@ private slots: void addBreakPointWhilePaused(); void removeBreakPointForNextInstruction(); + // context access: + void readArguments(); + void readLocals(); + void readObject(); + void readContextInAllFrames(); + + // exceptions: + void pauseOnThrow(); + private: void evaluateJavaScript(const QString &script, const QString &fileName, int lineNumber = 1) { @@ -235,8 +364,8 @@ void tst_qv4debugger::removePendingBreakPoint() "var i = 42;\n" "var j = i + 1\n" "var k = i\n"; - m_debuggerAgent->addBreakPoint("removePendingBreakPoint", 2); - m_debuggerAgent->removeBreakPoint("removePendingBreakPoint", 2); + int id = m_debuggerAgent->addBreakPoint("removePendingBreakPoint", 2); + m_debuggerAgent->removeBreakPoint(id); evaluateJavaScript(script, "removePendingBreakPoint"); QVERIFY(!m_debuggerAgent->m_wasPaused); } @@ -262,7 +391,7 @@ void tst_qv4debugger::addBreakPointWhilePaused() QCOMPARE(state.lineNumber, 2); } -static QV4::ReturnedValue someCall(QV4::SimpleCallContext *ctx) +static QV4::ReturnedValue someCall(QV4::CallContext *ctx) { ctx->engine->debugger->removeBreakPoint("removeBreakPointForNextInstruction", 2); return QV4::Encode::undefined(); @@ -283,6 +412,134 @@ void tst_qv4debugger::removeBreakPointForNextInstruction() QVERIFY(!m_debuggerAgent->m_wasPaused); } +void tst_qv4debugger::readArguments() +{ + m_debuggerAgent->m_captureContextInfo = true; + QString script = + "function f(a, b, c, d) {\n" + " return a === b\n" + "}\n" + "var four;\n" + "f(1, 'two', null, four);\n"; + m_debuggerAgent->addBreakPoint("readArguments", 2); + evaluateJavaScript(script, "readArguments"); + QVERIFY(m_debuggerAgent->m_wasPaused); + QCOMPARE(m_debuggerAgent->m_capturedArguments[0].size(), 4); + QVERIFY(m_debuggerAgent->m_capturedArguments[0].contains(QStringLiteral("a"))); + QCOMPARE(m_debuggerAgent->m_capturedArguments[0]["a"].type(), QVariant::Double); + QCOMPARE(m_debuggerAgent->m_capturedArguments[0]["a"].toDouble(), 1.0); + QVERIFY(m_debuggerAgent->m_capturedArguments[0].contains("b")); + QCOMPARE(m_debuggerAgent->m_capturedArguments[0]["b"].type(), QVariant::String); + QCOMPARE(m_debuggerAgent->m_capturedArguments[0]["b"].toString(), QLatin1String("two")); +} + +void tst_qv4debugger::readLocals() +{ + m_debuggerAgent->m_captureContextInfo = true; + QString script = + "function f(a, b) {\n" + " var c = a + b\n" + " var d = a - b\n" // breakpoint, c should be set, d should be undefined + " return c === d\n" + "}\n" + "f(1, 2, 3);\n"; + m_debuggerAgent->addBreakPoint("readLocals", 3); + evaluateJavaScript(script, "readLocals"); + QVERIFY(m_debuggerAgent->m_wasPaused); + QCOMPARE(m_debuggerAgent->m_capturedLocals[0].size(), 2); + QVERIFY(m_debuggerAgent->m_capturedLocals[0].contains("c")); + QCOMPARE(m_debuggerAgent->m_capturedLocals[0]["c"].type(), QVariant::Double); + QCOMPARE(m_debuggerAgent->m_capturedLocals[0]["c"].toDouble(), 3.0); + QVERIFY(m_debuggerAgent->m_capturedLocals[0].contains("d")); + QCOMPARE(m_debuggerAgent->m_capturedLocals[0]["d"].toString(), QString("undefined")); +} + +void tst_qv4debugger::readObject() +{ + m_debuggerAgent->m_captureContextInfo = true; + QString script = + "function f(a) {\n" + " var b = a\n" + " return b\n" + "}\n" + "f({head: 1, tail: { head: 'asdf', tail: null }});\n"; + m_debuggerAgent->addBreakPoint("readObject", 3); + evaluateJavaScript(script, "readObject"); + QVERIFY(m_debuggerAgent->m_wasPaused); + QCOMPARE(m_debuggerAgent->m_capturedLocals[0].size(), 1); + QVERIFY(m_debuggerAgent->m_capturedLocals[0].contains("b")); + QCOMPARE(m_debuggerAgent->m_capturedLocals[0]["b"].type(), QVariant::Map); + + QVariantMap b = m_debuggerAgent->m_capturedLocals[0]["b"].toMap(); + QCOMPARE(b.size(), 2); + QVERIFY(b.contains("head")); + QCOMPARE(b["head"].type(), QVariant::Double); + QCOMPARE(b["head"].toDouble(), 1.0); + QVERIFY(b.contains("tail")); + QCOMPARE(b["tail"].type(), QVariant::Map); + + QVariantMap b_tail = b["tail"].toMap(); + QCOMPARE(b_tail.size(), 2); + QVERIFY(b_tail.contains("head")); + QCOMPARE(b_tail["head"].type(), QVariant::String); + QCOMPARE(b_tail["head"].toString(), QString("asdf")); +} + +void tst_qv4debugger::readContextInAllFrames() +{ + m_debuggerAgent->m_captureContextInfo = true; + QString script = + "function fact(n) {\n" + " if (n > 1) {\n" + " var n_1 = n - 1;\n" + " n_1 = fact(n_1);\n" + " return n * n_1;\n" + " } else\n" + " return 1;\n" // breakpoint + "}\n" + "fact(12);\n"; + m_debuggerAgent->addBreakPoint("readFormalsInAllFrames", 7); + evaluateJavaScript(script, "readFormalsInAllFrames"); + QVERIFY(m_debuggerAgent->m_wasPaused); + QCOMPARE(m_debuggerAgent->m_stackTrace.size(), 13); + QCOMPARE(m_debuggerAgent->m_capturedArguments.size(), 13); + QCOMPARE(m_debuggerAgent->m_capturedLocals.size(), 13); + + for (int i = 0; i < 12; ++i) { + QCOMPARE(m_debuggerAgent->m_capturedArguments[i].size(), 1); + QVERIFY(m_debuggerAgent->m_capturedArguments[i].contains("n")); + QCOMPARE(m_debuggerAgent->m_capturedArguments[i]["n"].type(), QVariant::Double); + QCOMPARE(m_debuggerAgent->m_capturedArguments[i]["n"].toDouble(), i + 1.0); + + QCOMPARE(m_debuggerAgent->m_capturedLocals[i].size(), 1); + QVERIFY(m_debuggerAgent->m_capturedLocals[i].contains("n_1")); + if (i == 0) { + QCOMPARE(m_debuggerAgent->m_capturedLocals[i]["n_1"].toString(), QString("undefined")); + } else { + QCOMPARE(m_debuggerAgent->m_capturedLocals[i]["n_1"].type(), QVariant::Double); + QCOMPARE(m_debuggerAgent->m_capturedLocals[i]["n_1"].toInt(), i); + } + } + QCOMPARE(m_debuggerAgent->m_capturedArguments[12].size(), 0); + QCOMPARE(m_debuggerAgent->m_capturedLocals[12].size(), 0); +} + +void tst_qv4debugger::pauseOnThrow() +{ + QString script = + "function die(n) {\n" + " throw n\n" + "}\n" + "die('hard');\n"; + m_debuggerAgent->setBreakOnThrow(true); + evaluateJavaScript(script, "pauseOnThrow"); + QVERIFY(m_debuggerAgent->m_wasPaused); + QCOMPARE(m_debuggerAgent->m_pauseReason, Throwing); + QCOMPARE(m_debuggerAgent->m_stackTrace.size(), 2); + QCOMPARE(m_debuggerAgent->m_thrownValue.type(), QVariant::String); + QCOMPARE(m_debuggerAgent->m_thrownValue.toString(), QString("hard")); +} + QTEST_MAIN(tst_qv4debugger) #include "tst_qv4debugger.moc" |