diff options
Diffstat (limited to 'tests/auto/qml')
9 files changed, 94 insertions, 69 deletions
diff --git a/tests/auto/qml/debugger/qqmldebuggingenabler/qqmldebuggingenabler.pro b/tests/auto/qml/debugger/qqmldebuggingenabler/qqmldebuggingenabler.pro index 1fa5913138..330c8bcdbf 100644 --- a/tests/auto/qml/debugger/qqmldebuggingenabler/qqmldebuggingenabler.pro +++ b/tests/auto/qml/debugger/qqmldebuggingenabler/qqmldebuggingenabler.pro @@ -10,4 +10,4 @@ include(../../../shared/util.pri) include(../shared/debugutil.pri) OTHER_FILES += data/test.qml -DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0 +DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0 QT_QML_DEBUG_NO_WARNING diff --git a/tests/auto/qml/debugger/qqmldebuggingenabler/tst_qqmldebuggingenabler.cpp b/tests/auto/qml/debugger/qqmldebuggingenabler/tst_qqmldebuggingenabler.cpp index 7f8ded51ba..73abc03e28 100644 --- a/tests/auto/qml/debugger/qqmldebuggingenabler/tst_qqmldebuggingenabler.cpp +++ b/tests/auto/qml/debugger/qqmldebuggingenabler/tst_qqmldebuggingenabler.cpp @@ -55,17 +55,9 @@ private slots: void cleanup(); void qmlscene(); void qmlsceneBlock(); - void qmlsceneInvalidPorts(); - void qmlsceneBlockInvalidPorts(); - void qmlsceneMixedPorts(); - void qmlsceneBlockMixedPorts(); void custom(); void customBlock(); - void customInvalidPorts(); - void customBlockInvalidPorts(); - void customMixedPorts(); - void customBlockMixedPorts(); private: QQmlDebugProcess *process; @@ -161,30 +153,6 @@ void tst_QQmlDebuggingEnabler::qmlsceneBlock() QVERIFY(init(true, true, 5555, 5565)); } -void tst_QQmlDebuggingEnabler::qmlsceneInvalidPorts() -{ - QVERIFY(!init(false, true, 10, 20)); - QVERIFY(process->output().contains( - QLatin1String("QML Debugger: Unable to listen to ports 10 - 20."))); -} - -void tst_QQmlDebuggingEnabler::qmlsceneBlockInvalidPorts() -{ - QVERIFY(!init(true, true, 10, 20)); - QVERIFY(process->output().contains( - QLatin1String("QML Debugger: Unable to listen to ports 10 - 20."))); -} - -void tst_QQmlDebuggingEnabler::qmlsceneMixedPorts() -{ - QVERIFY(init(false, true, 1020, 1030)); -} - -void tst_QQmlDebuggingEnabler::qmlsceneBlockMixedPorts() -{ - QVERIFY(init(true, true, 1020, 1030)); -} - void tst_QQmlDebuggingEnabler::custom() { QVERIFY(init(false, false, 5555, 5565)); @@ -195,42 +163,6 @@ void tst_QQmlDebuggingEnabler::customBlock() QVERIFY(init(true, false, 5555, 5565)); } -void tst_QQmlDebuggingEnabler::customInvalidPorts() -{ - QVERIFY(!init(false, false, 10, 20)); - for (int i = 10; i < 20; ++i) { - QVERIFY(process->output().contains( - QString(QLatin1String("QML Debugger: Unable to listen to port %1.")).arg(i))); - } -} - -void tst_QQmlDebuggingEnabler::customBlockInvalidPorts() -{ - QVERIFY(!init(true, false, 10, 20)); - for (int i = 10; i < 20; ++i) { - QVERIFY(process->output().contains( - QString(QLatin1String("QML Debugger: Unable to listen to port %1.")).arg(i))); - } -} - -void tst_QQmlDebuggingEnabler::customMixedPorts() -{ - QVERIFY(init(false, false, 1020, 1030)); - for (int i = 1020; i < 1024; ++i) { - QVERIFY(process->output().contains( - QString(QLatin1String("QML Debugger: Unable to listen to port %1.")).arg(i))); - } -} - -void tst_QQmlDebuggingEnabler::customBlockMixedPorts() -{ - QVERIFY(init(true, false, 1020, 1030)); - for (int i = 1020; i < 1024; ++i) { - QVERIFY(process->output().contains( - QString(QLatin1String("QML Debugger: Unable to listen to port %1.")).arg(i))); - } -} - namespace QQmlDebuggingEnablerTest { QTEST_MAIN(tst_QQmlDebuggingEnabler) } diff --git a/tests/auto/qml/qjsengine/tst_qjsengine.cpp b/tests/auto/qml/qjsengine/tst_qjsengine.cpp index c938e19a77..61816b6cc0 100644 --- a/tests/auto/qml/qjsengine/tst_qjsengine.cpp +++ b/tests/auto/qml/qjsengine/tst_qjsengine.cpp @@ -176,6 +176,7 @@ private slots: void engineForObject(); void intConversion_QTBUG43309(); + void toFixed(); signals: void testSignal(); @@ -3652,6 +3653,18 @@ void tst_QJSEngine::intConversion_QTBUG43309() QCOMPARE(result.toNumber(), 25.0); } +// QTBUG-44039 and QTBUG-43885: +void tst_QJSEngine::toFixed() +{ + QJSEngine engine; + QJSValue result = engine.evaluate(QStringLiteral("(12.5).toFixed()")); + QVERIFY(result.isString()); + QCOMPARE(result.toString(), QStringLiteral("13")); + result = engine.evaluate(QStringLiteral("(12.05).toFixed(1)")); + QVERIFY(result.isString()); + QCOMPARE(result.toString(), QStringLiteral("12.1")); +} + QTEST_MAIN(tst_QJSEngine) #include "tst_qjsengine.moc" diff --git a/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp b/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp index 722fd19af6..def04765a0 100644 --- a/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp +++ b/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp @@ -325,6 +325,7 @@ private slots: void qtbug_39520(); void readUnregisteredQObjectProperty(); void writeUnregisteredQObjectProperty(); + void switchExpression(); private: // static void propertyVarWeakRefCallback(v8::Persistent<v8::Value> object, void* parameter); @@ -7843,6 +7844,29 @@ void tst_qqmlecmascript::writeUnregisteredQObjectProperty() QCOMPARE(root->property("container").value<ObjectContainer*>()->mSetterCalled, true); } +void tst_qqmlecmascript::switchExpression() +{ + // verify that we evaluate the expression inside switch() exactly once + QJSEngine engine; + QJSValue v = engine.evaluate(QString::fromLatin1( + "var num = 0\n" + "var x = 0\n" + "function f() { ++num; return (Math.random() > 0.5) ? 0 : 1; }\n" + "for (var i = 0; i < 1000; ++i) {\n" + " switch (f()) {\n" + " case 0:\n" + " case 1:\n" + " break;\n" + " default:\n" + " ++x;\n" + " }\n" + "}\n" + "(x == 0 && num == 1000) ? true : false\n" + )); + QVERIFY(!v.isError()); + QCOMPARE(v.toBool(), true); +} + QTEST_MAIN(tst_qqmlecmascript) #include "tst_qqmlecmascript.moc" diff --git a/tests/auto/qml/qqmlxmlhttprequest/data/qml_logo.png b/tests/auto/qml/qqmlxmlhttprequest/data/qml_logo.png Binary files differnew file mode 100644 index 0000000000..681aef8aa2 --- /dev/null +++ b/tests/auto/qml/qqmlxmlhttprequest/data/qml_logo.png diff --git a/tests/auto/qml/qqmlxmlhttprequest/data/receiveBinaryData.qml b/tests/auto/qml/qqmlxmlhttprequest/data/receiveBinaryData.qml new file mode 100644 index 0000000000..234d759284 --- /dev/null +++ b/tests/auto/qml/qqmlxmlhttprequest/data/receiveBinaryData.qml @@ -0,0 +1,27 @@ +import QtQuick 2.0 + +QtObject { + property string url + property int readSize: 0 + + Component.onCompleted: { + + var request = new XMLHttpRequest(); + request.open("GET", url); + request.responseType = "arraybuffer"; + + request.onreadystatechange = function() { + if (request.readyState == XMLHttpRequest.DONE) { + var arrayBuffer = request.response; + if (arrayBuffer) { + var byteArray = new Uint8Array(arrayBuffer); + readSize = byteArray.byteLength; + } + } + } + + request.send(null); + + } +} + diff --git a/tests/auto/qml/qqmlxmlhttprequest/data/receive_binary_data.expect b/tests/auto/qml/qqmlxmlhttprequest/data/receive_binary_data.expect new file mode 100644 index 0000000000..79a61383e3 --- /dev/null +++ b/tests/auto/qml/qqmlxmlhttprequest/data/receive_binary_data.expect @@ -0,0 +1,7 @@ +GET /gml_logo.png HTTP/1.1 +Accept-Language: en-US,* +Content-Type: image/png +Connection: Keep-Alive +Accept-Encoding: gzip, deflate +User-Agent: Mozilla/5.0 +Host: 127.0.0.1:14445 diff --git a/tests/auto/qml/qqmlxmlhttprequest/data/receive_binary_data.reply b/tests/auto/qml/qqmlxmlhttprequest/data/receive_binary_data.reply new file mode 100644 index 0000000000..44ba138213 --- /dev/null +++ b/tests/auto/qml/qqmlxmlhttprequest/data/receive_binary_data.reply @@ -0,0 +1,3 @@ +HTTP/1.1 200 OK +Connection: close +Content-Type: image/png diff --git a/tests/auto/qml/qqmlxmlhttprequest/tst_qqmlxmlhttprequest.cpp b/tests/auto/qml/qqmlxmlhttprequest/tst_qqmlxmlhttprequest.cpp index fe1b8b1505..dd70f81d5e 100644 --- a/tests/auto/qml/qqmlxmlhttprequest/tst_qqmlxmlhttprequest.cpp +++ b/tests/auto/qml/qqmlxmlhttprequest/tst_qqmlxmlhttprequest.cpp @@ -87,6 +87,7 @@ private slots: void getAllResponseHeaders_unsent(); void getAllResponseHeaders_sent(); void getAllResponseHeaders_args(); + void getBinaryData(); void status(); void status_data(); void statusText(); @@ -816,6 +817,24 @@ void tst_qqmlxmlhttprequest::getAllResponseHeaders_args() QTRY_VERIFY(object->property("exceptionThrown").toBool() == true); } +void tst_qqmlxmlhttprequest::getBinaryData() +{ + TestHTTPServer server; + QVERIFY2(server.listen(SERVER_PORT), qPrintable(server.errorString())); + QVERIFY(server.wait(testFileUrl("receive_binary_data.expect"), + testFileUrl("receive_binary_data.reply"), + testFileUrl("qml_logo.png"))); + + QQmlComponent component(&engine, testFileUrl("receiveBinaryData.qml")); + QScopedPointer<QObject> object(component.beginCreate(engine.rootContext())); + QVERIFY(!object.isNull()); + object->setProperty("url", "http://127.0.0.1:14445/gml_logo.png"); + component.completeCreate(); + + QFileInfo fileInfo("data/qml_logo.png"); + QTRY_VERIFY(object->property("readSize").toInt() == fileInfo.size()); +} + void tst_qqmlxmlhttprequest::status() { QFETCH(QUrl, replyUrl); |