Merge remote-tracking branch 'origin/5.4' into 5.5
authorSimon Hausmann <simon.hausmann@theqtcompany.com>
Mon, 27 Apr 2015 07:52:51 +0000 (09:52 +0200)
committerSimon Hausmann <simon.hausmann@theqtcompany.com>
Mon, 27 Apr 2015 12:40:00 +0000 (14:40 +0200)
Conflicts:
.qmake.conf
tests/auto/qml/qqmlxmlhttprequest/tst_qqmlxmlhttprequest.cpp

Change-Id: I715b8a78b74cbe0dcaf599367fd6e08af4858e11

23 files changed:
1  2 
src/qml/doc/src/qmlfunctions.qdoc
src/qml/jsruntime/qv4engine.cpp
src/qml/types/qqmlinstantiator.cpp
tests/auto/qml/qqmlcomponent/tst_qqmlcomponent.cpp
tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp
tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp
tests/auto/qml/qqmlmoduleplugin/tst_qqmlmoduleplugin.cpp
tests/auto/qml/qqmlxmlhttprequest/data/receive_binary_data.expect
tests/auto/qml/qqmlxmlhttprequest/data/send_data.10.expect
tests/auto/qml/qqmlxmlhttprequest/data/send_data.8.expect
tests/auto/qml/qqmlxmlhttprequest/data/send_data.9.expect
tests/auto/qml/qqmlxmlhttprequest/tst_qqmlxmlhttprequest.cpp
tests/auto/quick/qquickanimatedimage/tst_qquickanimatedimage.cpp
tests/auto/quick/qquickborderimage/tst_qquickborderimage.cpp
tests/auto/quick/qquickfontloader/tst_qquickfontloader.cpp
tests/auto/quick/qquickimage/tst_qquickimage.cpp
tests/auto/quick/qquickloader/tst_qquickloader.cpp
tests/auto/quick/qquickpixmapcache/tst_qquickpixmapcache.cpp
tests/auto/quick/qquicktext/tst_qquicktext.cpp
tests/auto/quick/qquicktextedit/tst_qquicktextedit.cpp
tests/auto/quick/qquicktextinput/tst_qquicktextinput.cpp
tests/auto/shared/testhttpserver.cpp
tests/auto/shared/testhttpserver.h

Simple merge
Simple merge
Simple merge
index 79a6138,0000000..112ac4e
mode 100644,000000..100644
--- /dev/null
@@@ -1,7 -1,0 +1,7 @@@
- Host: 127.0.0.1:14445
 +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: {{ServerHostUrl}}
index b099ed2,0000000..8d83a00
mode 100644,000000..100644
--- /dev/null
@@@ -1,10 -1,0 +1,10 @@@
- Host: 127.0.0.1:14445
 +OPTIONS /testdocument.html HTTP/1.1
 +Accept-Language: en-US,*
 +Content-Type: text/plain;charset=UTF-8
 +Content-Length: 12
 +Connection: Keep-Alive
 +Accept-Encoding: gzip, deflate
 +User-Agent: Mozilla/5.0
++Host: {{ServerHostUrl}}
 +
 +My Sent Data
index 8462c40,0000000..e93c019
mode 100644,000000..100644
--- /dev/null
@@@ -1,7 -1,0 +1,7 @@@
- Host: 127.0.0.1:14445
 +OPTIONS / HTTP/1.1
 +Content-Length: 0
 +Connection: Keep-Alive
 +Accept-Encoding: gzip, deflate
 +Accept-Language: en-US,*
 +User-Agent: Mozilla/5.0
++Host: {{ServerHostUrl}}
index 02af8c9,0000000..da38968
mode 100644,000000..100644
--- /dev/null
@@@ -1,7 -1,0 +1,7 @@@
- Host: 127.0.0.1:14445
 +OPTIONS /testdocument.html HTTP/1.1
 +Content-Length: 0
 +Connection: Keep-Alive
 +Accept-Encoding: gzip, deflate
 +Accept-Language: en-US,*
 +User-Agent: Mozilla/5.0
++Host: {{ServerHostUrl}}
@@@ -284,46 -282,14 +285,55 @@@ void tst_qqmlxmlhttprequest::open_inval
      QCOMPARE(object->property("exceptionThrown").toBool(), true);
  }
  
 -// Test that calling XMLHttpRequest.open() with sync raises an exception
 +class TestThreadedHTTPServer : public QObject
 +{
 +    Q_OBJECT
 +public:
 +    TestThreadedHTTPServer(const QUrl &expectUrl, const QUrl &replyUrl, const QUrl &bodyUrl)
 +        : m_server(Q_NULLPTR) {
++        QMutexLocker locker(&m_lock);
 +        moveToThread(&m_thread);
 +        m_thread.start();
 +        QMetaObject::invokeMethod(this, "start", Qt::QueuedConnection, Q_ARG(QUrl, expectUrl), Q_ARG(QUrl, replyUrl), Q_ARG(QUrl, bodyUrl));
++        m_startupCondition.wait(&m_lock);
 +    }
 +    ~TestThreadedHTTPServer() {
 +        m_server->deleteLater();
 +        m_thread.exit();
 +        m_thread.wait();
 +    }
 +
++    QUrl serverBaseUrl;
++
 +private slots:
 +    void start(const QUrl &expectUrl, const QUrl &replyUrl, const QUrl &bodyUrl) {
++        QMutexLocker locker(&m_lock);
 +        m_server = new TestHTTPServer;
-         QVERIFY2(m_server->listen(SERVER_PORT), qPrintable(m_server->errorString()));
++        QVERIFY2(m_server->listen(), qPrintable(m_server->errorString()));
++        serverBaseUrl = m_server->baseUrl();
 +        QVERIFY(m_server->wait(expectUrl, replyUrl, bodyUrl));
++        m_startupCondition.wakeAll();
 +    }
 +
 +private:
 +    TestHTTPServer *m_server;
 +    QThread m_thread;
++    QMutex m_lock;
++    QWaitCondition m_startupCondition;
 +};
 +
 +// Test that calling XMLHttpRequest.open() with sync
  void tst_qqmlxmlhttprequest::open_sync()
  {
 +    TestThreadedHTTPServer server(testFileUrl("open_network.expect"), testFileUrl("open_network.reply"), testFileUrl("testdocument.html"));
 +
      QQmlComponent component(&engine, testFileUrl("open_sync.qml"));
 -    QScopedPointer<QObject> object(component.create());
 +    QScopedPointer<QObject> object(component.beginCreate(engine.rootContext()));
      QVERIFY(!object.isNull());
-     object->setProperty("url", "http://127.0.0.1:14445/testdocument.html");
++    object->setProperty("url", server.serverBaseUrl.resolved(QStringLiteral("/testdocument.html")).toString());
 +    component.completeCreate();
  
 -    QCOMPARE(object->property("exceptionThrown").toBool(), true);
 +    QCOMPARE(object->property("responseText").toString(), QStringLiteral("QML Rocks!\n"));
  }
  
  // Calling with incorrect arg count raises an exception
@@@ -588,47 -554,6 +598,47 @@@ void tst_qqmlxmlhttprequest::send_withd
      QTest::newRow("Correct content-type - no charset") << "send_data.1.expect" << "send_data.7.qml";
  }
  
-     QVERIFY2(server.listen(SERVER_PORT), qPrintable(server.errorString()));
 +void tst_qqmlxmlhttprequest::send_options()
 +{
 +    QFETCH(QString, url_suffix);
 +    QFETCH(QString, file_expected);
 +    QFETCH(QString, file_qml);
 +    QFETCH(QString, file_reply);
 +
 +    TestHTTPServer server;
-     QString url = "http://127.0.0.1:14445";
++    QVERIFY2(server.listen(), qPrintable(server.errorString()));
 +    QVERIFY(server.wait(testFileUrl(file_expected),
 +                        testFileUrl(file_reply),
 +                        testFileUrl("testdocument.html")));
 +
 +    QQmlComponent component(&engine, testFileUrl(file_qml));
 +    QScopedPointer<QObject> object(component.beginCreate(engine.rootContext()));
 +    QVERIFY(!object.isNull());
++    QString url = server.baseUrl().toString();
 +    if (url_suffix != "/")
 +        url.append("/");
 +    if (!url_suffix.isEmpty())
 +        url.append(url_suffix);
 +    object->setProperty("url", url);
 +    component.completeCreate();
 +
 +    QTRY_VERIFY(object->property("dataOK").toBool());
 +    QTRY_VERIFY(object->property("headerOK").toBool());
 +}
 +
 +void tst_qqmlxmlhttprequest::send_options_data()
 +{
 +    QTest::addColumn<QString>("url_suffix");
 +    QTest::addColumn<QString>("file_expected");
 +    QTest::addColumn<QString>("file_qml");
 +    QTest::addColumn<QString>("file_reply");
 +
 +    QTest::newRow("OPTIONS (no data, no resource, no path)") << "" << "send_data.8.expect" << "send_data.8.qml" << "send_data.2.reply";
 +    QTest::newRow("OPTIONS (no data, no resource, path- \"/\")") << "/" << "send_data.8.expect" << "send_data.8.qml" << "send_data.2.reply";
 +    QTest::newRow("OPTIONS (no data, with resource)") << "testdocument.html" << "send_data.9.expect" << "send_data.8.qml" << "send_data.2.reply";
 +    QTest::newRow("OPTIONS (with data)") << "testdocument.html" << "send_data.10.expect" << "send_data.9.qml" << "send_data.2.reply";
 +}
 +
  // Test abort() has no effect in unsent state
  void tst_qqmlxmlhttprequest::abort_unsent()
  {
@@@ -817,24 -745,6 +830,24 @@@ void tst_qqmlxmlhttprequest::getAllResp
      QTRY_VERIFY(object->property("exceptionThrown").toBool() == true);
  }
  
-     QVERIFY2(server.listen(SERVER_PORT), qPrintable(server.errorString()));
 +void tst_qqmlxmlhttprequest::getBinaryData()
 +{
 +    TestHTTPServer server;
-     object->setProperty("url", "http://127.0.0.1:14445/gml_logo.png");
++    QVERIFY2(server.listen(), 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", server.urlString("/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);
Simple merge
Simple merge