Merge remote-tracking branch 'origin/5.5' into dev
Conflicts: tests/auto/quick/qquicktext/tst_qquicktext.cpp Change-Id: I075e742da8396a268d97d3ab34bcd9e0c0cf001f
This commit is contained in:
commit
94db5de2ac
|
@ -0,0 +1,49 @@
|
|||
Qt 5.4.2 is a bug-fix release. It maintains both forward and backward
|
||||
compatibility (source and binary) with Qt 5.4.1.
|
||||
|
||||
For more details, refer to the online documentation included in this
|
||||
distribution. The documentation is also available online:
|
||||
|
||||
http://doc.qt.io/qt-5.4
|
||||
|
||||
The Qt version 5.4 series is binary compatible with the 5.3.x series.
|
||||
Applications compiled for 5.3 will continue to run with 5.4.
|
||||
|
||||
Some of the changes listed in this file include issue tracking numbers
|
||||
corresponding to tasks in the Qt Bug Tracker:
|
||||
|
||||
http://bugreports.qt.io/
|
||||
|
||||
Each of these identifiers can be entered in the bug tracker to obtain more
|
||||
information about a particular change.
|
||||
|
||||
****************************************************************************
|
||||
* Library *
|
||||
****************************************************************************
|
||||
|
||||
|
||||
Qt Quick
|
||||
--------
|
||||
|
||||
- [QTBUG-40920] Fix crash due to embedded QQuickView with WA_DeleteOnClose
|
||||
- [QTBUG-43376] Fix crash due to deleted items in the dirty list
|
||||
- [QTBUG-43129] Fix crash in overdraw and change visualizers
|
||||
- [QTBUG-42913] Fix crash in QQuickWindow::updatePolish()
|
||||
- [QTBUG-34351] Fix crash when removing items from QQmlDelegateModel
|
||||
- [QTBUG-38528] Fix vertical positioning of the first image in Text
|
||||
- [QTBUG-42878] Ensure that Canvas has correct size with complex bindings
|
||||
- [QTBUG-42222] Fix crash in Canvas destructor
|
||||
- [QTBUG-42861] Better text rendering in QQuickWidget on OS X
|
||||
- [QTBUG-44049] Use @2x HiDPI images from QRC without a file extension
|
||||
- [QTBUG-43847][QTBUG-40789] Scale mipmapped npot images when not supported
|
||||
- Fix width/height property assignment during animations
|
||||
- TextInput: update the baseline offset when vertical alignment changes
|
||||
|
||||
QtQml
|
||||
-----
|
||||
|
||||
- [QTBUG-42759] Fix compilation on x32 ABI (don't use JIT)
|
||||
- [QTBUG-43885][QTBUG-44039] Correct ToFixed rounding for 0 fraction digits
|
||||
- [QTBUG-44026] Update Timer running property at the same time the
|
||||
triggered signal is emitted
|
||||
- Fix crash on FreeBSD when computing stack limits
|
|
@ -1,7 +1,7 @@
|
|||
CXX_MODULE = qml
|
||||
TARGET = modelsplugin
|
||||
TARGETPATH = QtQml/Models.2
|
||||
IMPORT_VERSION = 2.1
|
||||
IMPORT_VERSION = 2.2
|
||||
|
||||
SOURCES += \
|
||||
plugin.cpp
|
||||
|
|
|
@ -38,7 +38,7 @@
|
|||
QT_BEGIN_NAMESPACE
|
||||
|
||||
/*!
|
||||
\qmlmodule QtQml.Models 2.1
|
||||
\qmlmodule QtQml.Models 2.2
|
||||
\title Qt QML Models QML Types
|
||||
\ingroup qmlmodules
|
||||
\brief Provides QML types for data models
|
||||
|
@ -49,7 +49,7 @@ QT_BEGIN_NAMESPACE
|
|||
To use the types in this module, import the module with the following line:
|
||||
|
||||
\code
|
||||
import QtQml.Models 2.1
|
||||
import QtQml.Models 2.2
|
||||
\endcode
|
||||
|
||||
Note that QtQml.Models module started at version 2.1 to match the version
|
||||
|
|
|
@ -315,14 +315,15 @@ void QQmlSettingsPrivate::load()
|
|||
|
||||
void QQmlSettingsPrivate::store()
|
||||
{
|
||||
QHash<const char *, QVariant>::iterator it = changedProperties.begin();
|
||||
while (it != changedProperties.end()) {
|
||||
QHash<const char *, QVariant>::const_iterator it = changedProperties.constBegin();
|
||||
while (it != changedProperties.constEnd()) {
|
||||
instance()->setValue(it.key(), it.value());
|
||||
#ifdef SETTINGS_DEBUG
|
||||
qDebug() << "QQmlSettings: store" << it.key() << ":" << it.value();
|
||||
#endif
|
||||
it = changedProperties.erase(it);
|
||||
++it;
|
||||
}
|
||||
changedProperties.clear();
|
||||
}
|
||||
|
||||
void QQmlSettingsPrivate::_q_propertyChanged()
|
||||
|
@ -394,12 +395,10 @@ void QQmlSettings::timerEvent(QTimerEvent *event)
|
|||
{
|
||||
Q_D(QQmlSettings);
|
||||
if (event->timerId() == d->timerId) {
|
||||
if (d->changedProperties.isEmpty()) {
|
||||
killTimer(d->timerId);
|
||||
d->timerId = 0;
|
||||
} else {
|
||||
d->store();
|
||||
}
|
||||
killTimer(d->timerId);
|
||||
d->timerId = 0;
|
||||
|
||||
d->store();
|
||||
}
|
||||
QObject::timerEvent(event);
|
||||
}
|
||||
|
|
|
@ -1891,7 +1891,7 @@ bool QQmlPropertyValidator::validateObject(int objectIndex, const QV4::CompiledD
|
|||
|
||||
bool seenSubObjectWithId = false;
|
||||
|
||||
if (binding->type >= QV4::CompiledData::Binding::Type_Object && (!customParser || binding->type == QV4::CompiledData::Binding::Type_AttachedProperty)) {
|
||||
if (binding->type >= QV4::CompiledData::Binding::Type_Object && (pd || binding->isAttachedProperty())) {
|
||||
qSwap(_seenObjectWithId, seenSubObjectWithId);
|
||||
const bool subObjectValid = validateObject(binding->value.objectIndex, binding, pd && QQmlValueTypeFactory::metaObjectForMetaType(pd->propType));
|
||||
qSwap(_seenObjectWithId, seenSubObjectWithId);
|
||||
|
|
|
@ -516,7 +516,7 @@
|
|||
|
||||
#include <QtQml> to use this function.
|
||||
|
||||
Returns non-zero if the registration was sucessful.
|
||||
Returns -1 if the registration was not successful.
|
||||
*/
|
||||
|
||||
/*!
|
||||
|
|
|
@ -124,8 +124,14 @@ quintptr getStackLimit()
|
|||
} else
|
||||
size = pthread_get_stacksize_np(thread_self);
|
||||
stackLimit -= size;
|
||||
# elif defined(__hppa)
|
||||
// On some architectures the stack grows upwards. All of these are rather exotic, so simply assume
|
||||
// everything is fine there.
|
||||
// Known examples:
|
||||
// -HP PA-RISC
|
||||
stackLimit = 0;
|
||||
|
||||
# else
|
||||
void* stackBottom = 0;
|
||||
pthread_attr_t attr;
|
||||
#if HAVE(PTHREAD_NP_H) && OS(FREEBSD)
|
||||
// on FreeBSD pthread_attr_init() must be called otherwise getting the attrs crashes
|
||||
|
@ -133,7 +139,9 @@ quintptr getStackLimit()
|
|||
#else
|
||||
if (pthread_getattr_np(pthread_self(), &attr) == 0) {
|
||||
#endif
|
||||
void *stackBottom = Q_NULLPTR;
|
||||
size_t stackSize = 0;
|
||||
|
||||
pthread_attr_getstack(&attr, &stackBottom, &stackSize);
|
||||
pthread_attr_destroy(&attr);
|
||||
|
||||
|
|
|
@ -44,6 +44,7 @@
|
|||
#include <private/qv4functionobject_p.h>
|
||||
#include <private/qv4variantobject_p.h>
|
||||
#include <private/qv4qmlextensions_p.h>
|
||||
#include <private/qv4alloca_p.h>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
|
|
|
@ -48,6 +48,7 @@ QQmlInstantiatorPrivate::QQmlInstantiatorPrivate()
|
|||
, active(true)
|
||||
, async(false)
|
||||
, ownModel(false)
|
||||
, requestedIndex(-1)
|
||||
, model(QVariant(1))
|
||||
, instanceModel(0)
|
||||
, delegate(0)
|
||||
|
@ -75,6 +76,15 @@ void QQmlInstantiatorPrivate::clear()
|
|||
q->objectChanged();
|
||||
}
|
||||
|
||||
QObject *QQmlInstantiatorPrivate::modelObject(int index, bool async)
|
||||
{
|
||||
requestedIndex = index;
|
||||
QObject *o = instanceModel->object(index, async);
|
||||
requestedIndex = -1;
|
||||
return o;
|
||||
}
|
||||
|
||||
|
||||
void QQmlInstantiatorPrivate::regenerate()
|
||||
{
|
||||
Q_Q(QQmlInstantiator);
|
||||
|
@ -92,7 +102,7 @@ void QQmlInstantiatorPrivate::regenerate()
|
|||
}
|
||||
|
||||
for (int i = 0; i < instanceModel->count(); i++) {
|
||||
QObject *object = instanceModel->object(i, async);
|
||||
QObject *object = modelObject(i, async);
|
||||
// If the item was already created we won't get a createdItem
|
||||
if (object)
|
||||
_q_createdItem(i, object);
|
||||
|
@ -106,8 +116,18 @@ void QQmlInstantiatorPrivate::_q_createdItem(int idx, QObject* item)
|
|||
Q_Q(QQmlInstantiator);
|
||||
if (objects.contains(item)) //Case when it was created synchronously in regenerate
|
||||
return;
|
||||
if (requestedIndex != idx) // Asynchronous creation, reference the object
|
||||
(void)instanceModel->object(idx, false);
|
||||
item->setParent(q);
|
||||
objects.insert(idx, item);
|
||||
if (objects.size() < idx + 1) {
|
||||
int modelCount = instanceModel->count();
|
||||
if (objects.capacity() < modelCount)
|
||||
objects.reserve(modelCount);
|
||||
objects.resize(idx + 1);
|
||||
}
|
||||
if (QObject *o = objects.at(idx))
|
||||
instanceModel->release(o);
|
||||
objects.replace(idx, item);
|
||||
if (objects.count() == 1)
|
||||
q->objectChanged();
|
||||
q->objectAdded(idx, item);
|
||||
|
@ -153,11 +173,15 @@ void QQmlInstantiatorPrivate::_q_modelUpdated(const QQmlChangeSet &changeSet, bo
|
|||
if (insert.isMove()) {
|
||||
QVector<QPointer<QObject> > movedObjects = moved.value(insert.moveId);
|
||||
objects = objects.mid(0, index) + movedObjects + objects.mid(index);
|
||||
} else for (int i = 0; i < insert.count; ++i) {
|
||||
int modelIndex = index + i;
|
||||
QObject* obj = instanceModel->object(modelIndex, async);
|
||||
if (obj)
|
||||
_q_createdItem(modelIndex, obj);
|
||||
} else {
|
||||
if (insert.index <= objects.size())
|
||||
objects.insert(insert.index, insert.count, 0);
|
||||
for (int i = 0; i < insert.count; ++i) {
|
||||
int modelIndex = index + i;
|
||||
QObject* obj = modelObject(modelIndex, async);
|
||||
if (obj)
|
||||
_q_createdItem(modelIndex, obj);
|
||||
}
|
||||
}
|
||||
difference += insert.count;
|
||||
}
|
||||
|
@ -169,7 +193,7 @@ void QQmlInstantiatorPrivate::_q_modelUpdated(const QQmlChangeSet &changeSet, bo
|
|||
void QQmlInstantiatorPrivate::makeModel()
|
||||
{
|
||||
Q_Q(QQmlInstantiator);
|
||||
QQmlDelegateModel* delegateModel = new QQmlDelegateModel(qmlContext(q));
|
||||
QQmlDelegateModel* delegateModel = new QQmlDelegateModel(qmlContext(q), q);
|
||||
instanceModel = delegateModel;
|
||||
ownModel = true;
|
||||
delegateModel->setDelegate(delegate);
|
||||
|
|
|
@ -66,12 +66,14 @@ public:
|
|||
void makeModel();
|
||||
void _q_createdItem(int, QObject *);
|
||||
void _q_modelUpdated(const QQmlChangeSet &, bool);
|
||||
QObject *modelObject(int index, bool async);
|
||||
|
||||
bool componentComplete:1;
|
||||
bool effectiveReset:1;
|
||||
bool active:1;
|
||||
bool async:1;
|
||||
bool ownModel:1;
|
||||
int requestedIndex;
|
||||
QVariant model;
|
||||
QQmlInstanceModel *instanceModel;
|
||||
QQmlComponent *delegate;
|
||||
|
|
|
@ -38,6 +38,7 @@
|
|||
#include <QtQuick/private/qsgrenderer_p.h>
|
||||
#include <QtQuick/private/qsgshadersourcebuilder_p.h>
|
||||
#include <QtQuick/private/qsgtexture_p.h>
|
||||
#include <QtCore/qmutex.h>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
|
@ -348,7 +349,10 @@ uint qHash(const QQuickShaderEffectMaterialKey &key)
|
|||
}
|
||||
|
||||
|
||||
QHash<QQuickShaderEffectMaterialKey, QSharedPointer<QSGMaterialType> > QQuickShaderEffectMaterial::materialMap;
|
||||
typedef QHash<QQuickShaderEffectMaterialKey, QWeakPointer<QSGMaterialType> > MaterialHash;
|
||||
|
||||
Q_GLOBAL_STATIC(MaterialHash, materialHash)
|
||||
Q_GLOBAL_STATIC(QMutex, materialHashMutex)
|
||||
|
||||
QQuickShaderEffectMaterial::QQuickShaderEffectMaterial(QQuickShaderEffectNode *node)
|
||||
: cullMode(NoCulling)
|
||||
|
@ -403,12 +407,30 @@ int QQuickShaderEffectMaterial::compare(const QSGMaterial *o) const
|
|||
|
||||
void QQuickShaderEffectMaterial::setProgramSource(const QQuickShaderEffectMaterialKey &source)
|
||||
{
|
||||
QMutexLocker locker(materialHashMutex);
|
||||
Q_UNUSED(locker);
|
||||
|
||||
m_source = source;
|
||||
m_emittedLogChanged = false;
|
||||
m_type = materialMap.value(m_source);
|
||||
QWeakPointer<QSGMaterialType> weakPtr = materialHash->value(m_source);
|
||||
m_type = weakPtr.toStrongRef();
|
||||
|
||||
if (m_type.isNull()) {
|
||||
m_type = QSharedPointer<QSGMaterialType>(new QSGMaterialType);
|
||||
materialMap.insert(m_source, m_type);
|
||||
materialHash->insert(m_source, m_type.toWeakRef());
|
||||
}
|
||||
}
|
||||
|
||||
void QQuickShaderEffectMaterial::cleanupMaterialCache()
|
||||
{
|
||||
QMutexLocker locker(materialHashMutex);
|
||||
Q_UNUSED(locker);
|
||||
|
||||
for (MaterialHash::iterator it = materialHash->begin(); it != materialHash->end(); ) {
|
||||
if (!it.value().toStrongRef())
|
||||
it = materialHash->erase(it);
|
||||
else
|
||||
++it;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -101,6 +101,8 @@ public:
|
|||
void updateTextures() const;
|
||||
void invalidateTextureProvider(QSGTextureProvider *provider);
|
||||
|
||||
static void cleanupMaterialCache();
|
||||
|
||||
protected:
|
||||
friend class QQuickCustomMaterialShader;
|
||||
|
||||
|
@ -115,8 +117,6 @@ protected:
|
|||
|
||||
QQuickShaderEffectNode *m_node;
|
||||
bool m_emittedLogChanged;
|
||||
|
||||
static QHash<QQuickShaderEffectMaterialKey, QSharedPointer<QSGMaterialType> > materialMap;
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -52,6 +52,8 @@
|
|||
#include <QtQuick/private/qsgcontext_p.h>
|
||||
#include <private/qquickprofiler_p.h>
|
||||
|
||||
#include <private/qquickshadereffectnode_p.h>
|
||||
|
||||
#ifdef Q_OS_WIN
|
||||
# include <QtCore/qt_windows.h>
|
||||
#endif
|
||||
|
@ -309,6 +311,8 @@ void QSGGuiThreadRenderLoop::windowDestroyed(QQuickWindow *window)
|
|||
if (Q_UNLIKELY(!current))
|
||||
qCDebug(QSG_LOG_RENDERLOOP) << "cleanup without an OpenGL context";
|
||||
|
||||
QQuickShaderEffectMaterial::cleanupMaterialCache();
|
||||
|
||||
d->cleanupNodesOnShutdown();
|
||||
if (m_windows.size() == 0) {
|
||||
rc->invalidate();
|
||||
|
|
|
@ -56,6 +56,8 @@
|
|||
#include <private/qquickprofiler_p.h>
|
||||
#include <private/qqmldebugservice_p.h>
|
||||
|
||||
#include <private/qquickshadereffectnode_p.h>
|
||||
|
||||
/*
|
||||
Overall design:
|
||||
|
||||
|
@ -474,6 +476,8 @@ void QSGRenderThread::invalidateOpenGL(QQuickWindow *window, bool inDestructor,
|
|||
qCDebug(QSG_LOG_RENDERLOOP) << QSG_RT_PAD << "- cleanup without an OpenGL context";
|
||||
}
|
||||
|
||||
QQuickShaderEffectMaterial::cleanupMaterialCache();
|
||||
|
||||
// The canvas nodes must be cleaned up regardless if we are in the destructor..
|
||||
if (wipeSG) {
|
||||
QQuickWindowPrivate *dd = QQuickWindowPrivate::get(window);
|
||||
|
|
|
@ -48,6 +48,8 @@
|
|||
|
||||
#include <private/qquickprofiler_p.h>
|
||||
|
||||
#include <private/qquickshadereffectnode_p.h>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
extern Q_GUI_EXPORT QImage qt_gl_read_framebuffer(const QSize &size, bool alpha_format, bool include_alpha);
|
||||
|
@ -232,6 +234,8 @@ void QSGWindowsRenderLoop::windowDestroyed(QQuickWindow *window)
|
|||
if (Q_UNLIKELY(!current))
|
||||
qCDebug(QSG_LOG_RENDERLOOP) << "cleanup without an OpenGL context";
|
||||
|
||||
QQuickShaderEffectMaterial::cleanupMaterialCache();
|
||||
|
||||
d->cleanupNodesOnShutdown();
|
||||
if (m_windows.size() == 0) {
|
||||
d->context->invalidate();
|
||||
|
|
|
@ -44,8 +44,6 @@
|
|||
#include "../../shared/util.h"
|
||||
#include "testhttpserver.h"
|
||||
|
||||
#define SERVER_PORT 14450
|
||||
|
||||
class MyIC : public QObject, public QQmlIncubationController
|
||||
{
|
||||
Q_OBJECT
|
||||
|
@ -313,12 +311,12 @@ void tst_qqmlcomponent::qmlCreateParentReference()
|
|||
void tst_qqmlcomponent::async()
|
||||
{
|
||||
TestHTTPServer server;
|
||||
QVERIFY2(server.listen(SERVER_PORT), qPrintable(server.errorString()));
|
||||
QVERIFY2(server.listen(), qPrintable(server.errorString()));
|
||||
server.serveDirectory(dataDirectory());
|
||||
|
||||
QQmlComponent component(&engine);
|
||||
ComponentWatcher watcher(&component);
|
||||
component.loadUrl(QUrl("http://127.0.0.1:14450/TestComponent.qml"), QQmlComponent::Asynchronous);
|
||||
component.loadUrl(server.url("/TestComponent.qml"), QQmlComponent::Asynchronous);
|
||||
QCOMPARE(watcher.loading, 1);
|
||||
QTRY_VERIFY(component.isReady());
|
||||
QCOMPARE(watcher.ready, 1);
|
||||
|
@ -333,13 +331,13 @@ void tst_qqmlcomponent::async()
|
|||
void tst_qqmlcomponent::asyncHierarchy()
|
||||
{
|
||||
TestHTTPServer server;
|
||||
QVERIFY2(server.listen(SERVER_PORT), qPrintable(server.errorString()));
|
||||
QVERIFY2(server.listen(), qPrintable(server.errorString()));
|
||||
server.serveDirectory(dataDirectory());
|
||||
|
||||
// ensure that the item hierarchy is compiled correctly.
|
||||
QQmlComponent component(&engine);
|
||||
ComponentWatcher watcher(&component);
|
||||
component.loadUrl(QUrl("http://127.0.0.1:14450/TestComponent.2.qml"), QQmlComponent::Asynchronous);
|
||||
component.loadUrl(server.url("/TestComponent.2.qml"), QQmlComponent::Asynchronous);
|
||||
QCOMPARE(watcher.loading, 1);
|
||||
QTRY_VERIFY(component.isReady());
|
||||
QCOMPARE(watcher.ready, 1);
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
var myvar = 10;
|
||||
|
||||
function go()
|
||||
function go(serverBaseUrl)
|
||||
{
|
||||
var a = Qt.include("http://127.0.0.1:8111/remote_file.js",
|
||||
var a = Qt.include(serverBaseUrl + "/remote_file.js",
|
||||
function(o) {
|
||||
test2 = o.status == o.OK
|
||||
test3 = a.status == a.OK
|
||||
|
@ -13,7 +13,7 @@ function go()
|
|||
test1 = a.status == a.LOADING
|
||||
|
||||
|
||||
var b = Qt.include("http://127.0.0.1:8111/exception.js",
|
||||
var b = Qt.include(serverBaseUrl + "/exception.js",
|
||||
function(o) {
|
||||
test7 = o.status == o.EXCEPTION
|
||||
test8 = b.status == a.EXCEPTION
|
||||
|
|
|
@ -17,5 +17,7 @@ QtObject {
|
|||
property bool test9: false
|
||||
property bool test10: false
|
||||
|
||||
Component.onCompleted: IncludeTest.go();
|
||||
property string serverBaseUrl;
|
||||
|
||||
Component.onCompleted: IncludeTest.go(serverBaseUrl);
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
function go()
|
||||
function go(serverBaseUrl)
|
||||
{
|
||||
var a = Qt.include("http://127.0.0.1:8111/missing.js",
|
||||
var a = Qt.include(serverBaseUrl + "/missing.js",
|
||||
function(o) {
|
||||
test2 = o.status == o.NETWORK_ERROR
|
||||
test3 = a.status == a.NETWORK_ERROR
|
||||
|
|
|
@ -8,5 +8,7 @@ QtObject {
|
|||
property bool test2: false
|
||||
property bool test3: false
|
||||
|
||||
Component.onCompleted: IncludeTest.go();
|
||||
property string serverBaseUrl;
|
||||
|
||||
Component.onCompleted: IncludeTest.go(serverBaseUrl);
|
||||
}
|
||||
|
|
|
@ -4203,12 +4203,12 @@ void tst_qqmlecmascript::importScripts()
|
|||
QFETCH(QVariantList, propertyValues);
|
||||
|
||||
TestHTTPServer server;
|
||||
QVERIFY2(server.listen(8111), qPrintable(server.errorString()));
|
||||
QVERIFY2(server.listen(), qPrintable(server.errorString()));
|
||||
server.serveDirectory(dataDirectory() + "/remote");
|
||||
|
||||
QStringList importPathList = engine.importPathList();
|
||||
|
||||
QString remotePath(QLatin1String("http://127.0.0.1:8111/"));
|
||||
QString remotePath(server.urlString("/"));
|
||||
engine.addImportPath(remotePath);
|
||||
|
||||
QQmlComponent component(&engine, testfile);
|
||||
|
@ -6055,12 +6055,14 @@ void tst_qqmlecmascript::include()
|
|||
// Remote - error
|
||||
{
|
||||
TestHTTPServer server;
|
||||
QVERIFY2(server.listen(8111), qPrintable(server.errorString()));
|
||||
QVERIFY2(server.listen(), qPrintable(server.errorString()));
|
||||
server.serveDirectory(dataDirectory());
|
||||
|
||||
QQmlComponent component(&engine, testFileUrl("include_remote_missing.qml"));
|
||||
QObject *o = component.create();
|
||||
QObject *o = component.beginCreate(engine.rootContext());
|
||||
QVERIFY(o != 0);
|
||||
o->setProperty("serverBaseUrl", server.baseUrl().toString());
|
||||
component.completeCreate();
|
||||
|
||||
QTRY_VERIFY(o->property("done").toBool() == true);
|
||||
|
||||
|
@ -6097,12 +6099,14 @@ void tst_qqmlecmascript::includeRemoteSuccess()
|
|||
|
||||
// Remote - success
|
||||
TestHTTPServer server;
|
||||
QVERIFY2(server.listen(8111), qPrintable(server.errorString()));
|
||||
QVERIFY2(server.listen(), qPrintable(server.errorString()));
|
||||
server.serveDirectory(dataDirectory());
|
||||
|
||||
QQmlComponent component(&engine, testFileUrl("include_remote.qml"));
|
||||
QObject *o = component.create();
|
||||
QObject *o = component.beginCreate(engine.rootContext());
|
||||
QVERIFY(o != 0);
|
||||
o->setProperty("serverBaseUrl", server.baseUrl().toString());
|
||||
component.completeCreate();
|
||||
|
||||
QTRY_VERIFY(o->property("done").toBool() == true);
|
||||
QTRY_VERIFY(o->property("done2").toBool() == true);
|
||||
|
|
|
@ -0,0 +1,10 @@
|
|||
import QtQml 2.1
|
||||
|
||||
Instantiator {
|
||||
model: 10
|
||||
asynchronous: true
|
||||
delegate: QtObject {
|
||||
property bool success: true
|
||||
property int idx: index
|
||||
}
|
||||
}
|
|
@ -38,6 +38,7 @@
|
|||
#include <QtQml/qqmlcomponent.h>
|
||||
#include <QtQml/private/qqmlinstantiator_p.h>
|
||||
#include <QtQml/qqmlcontext.h>
|
||||
#include <QtQml/qqmlincubator.h>
|
||||
#include "../../shared/util.h"
|
||||
#include "stringmodel.h"
|
||||
|
||||
|
@ -53,6 +54,9 @@ private slots:
|
|||
void activeProperty();
|
||||
void intModelChange();
|
||||
void createAndRemove();
|
||||
|
||||
void asynchronous_data();
|
||||
void asynchronous();
|
||||
};
|
||||
|
||||
void tst_qqmlinstantiator::createNone()
|
||||
|
@ -209,6 +213,45 @@ void tst_qqmlinstantiator::createAndRemove()
|
|||
QCOMPARE(object->property("datum").toString(), names[i]);
|
||||
}
|
||||
}
|
||||
|
||||
void tst_qqmlinstantiator::asynchronous_data()
|
||||
{
|
||||
QTest::addColumn<bool>("asyncIncubator");
|
||||
QTest::addColumn<QString>("fileName");
|
||||
|
||||
QTest::newRow("Asynchronous Instantiator") << false << "createMultipleAsync.qml";
|
||||
QTest::newRow("Nested-asynchronous Instantiator") << true << "createMultiple.qml";
|
||||
}
|
||||
|
||||
void tst_qqmlinstantiator::asynchronous()
|
||||
{
|
||||
QFETCH(bool, asyncIncubator);
|
||||
QFETCH(QString, fileName);
|
||||
|
||||
QQmlEngine engine;
|
||||
QQmlIncubationController incubationController;
|
||||
engine.setIncubationController(&incubationController);
|
||||
QQmlComponent component(&engine, testFileUrl(fileName));
|
||||
QQmlIncubator incubator(asyncIncubator ? QQmlIncubator::Asynchronous : QQmlIncubator::Synchronous);
|
||||
component.create(incubator);
|
||||
while (!incubator.isReady())
|
||||
incubationController.incubateFor(10);
|
||||
QQmlInstantiator *instantiator = qobject_cast<QQmlInstantiator *>(incubator.object());
|
||||
while (incubationController.incubatingObjectCount() > 0)
|
||||
incubationController.incubateFor(10);
|
||||
QVERIFY(instantiator != 0);
|
||||
QCOMPARE(instantiator->isActive(), true);
|
||||
QCOMPARE(instantiator->count(), 10);
|
||||
|
||||
for (int i=0; i<10; i++) {
|
||||
QObject *object = instantiator->objectAt(i);
|
||||
QVERIFY(object);
|
||||
QCOMPARE(object->parent(), instantiator);
|
||||
QCOMPARE(object->property("success").toBool(), true);
|
||||
QCOMPARE(object->property("idx").toInt(), i);
|
||||
}
|
||||
}
|
||||
|
||||
QTEST_MAIN(tst_qqmlinstantiator)
|
||||
|
||||
#include "tst_qqmlinstantiator.moc"
|
||||
|
|
|
@ -0,0 +1,8 @@
|
|||
import Test 1.0
|
||||
import QtQml 2.0
|
||||
SimpleObjectWithCustomParser {
|
||||
customProperty: 42
|
||||
property var nested: SimpleObjectWithCustomParser {
|
||||
customNestedProperty: 42
|
||||
}
|
||||
}
|
|
@ -1,5 +1,5 @@
|
|||
import QtQuick 2.0
|
||||
import "http://127.0.0.1:14447/singleton/remote"
|
||||
import "{{ServerBaseUrl}}/singleton/remote"
|
||||
|
||||
Item {
|
||||
property int value1: RemoteSingletonType2.testProp1;
|
||||
|
|
|
@ -229,6 +229,7 @@ private slots:
|
|||
void customParserEvaluateEnum();
|
||||
void customParserProperties();
|
||||
void customParserWithExtendedObject();
|
||||
void nestedCustomParsers();
|
||||
|
||||
void preservePropertyCacheOnGroupObjects();
|
||||
void propertyCacheInSync();
|
||||
|
@ -2511,7 +2512,7 @@ void tst_qqmllanguage::basicRemote_data()
|
|||
QTest::addColumn<QString>("type");
|
||||
QTest::addColumn<QString>("error");
|
||||
|
||||
QString serverdir = "http://127.0.0.1:14447/qtest/qml/qqmllanguage/";
|
||||
QString serverdir = "/qtest/qml/qqmllanguage/";
|
||||
|
||||
QTest::newRow("no need for qmldir") << QUrl(serverdir+"Test.qml") << "" << "";
|
||||
QTest::newRow("absent qmldir") << QUrl(serverdir+"/noqmldir/Test.qml") << "" << "";
|
||||
|
@ -2525,9 +2526,11 @@ void tst_qqmllanguage::basicRemote()
|
|||
QFETCH(QString, error);
|
||||
|
||||
TestHTTPServer server;
|
||||
QVERIFY2(server.listen(14447), qPrintable(server.errorString()));
|
||||
QVERIFY2(server.listen(), qPrintable(server.errorString()));
|
||||
server.serveDirectory(dataDirectory());
|
||||
|
||||
url = server.baseUrl().resolved(url);
|
||||
|
||||
QQmlComponent component(&engine, url);
|
||||
|
||||
QTRY_VERIFY(!component.isLoading());
|
||||
|
@ -2547,7 +2550,7 @@ void tst_qqmllanguage::importsRemote_data()
|
|||
QTest::addColumn<QString>("type");
|
||||
QTest::addColumn<QString>("error");
|
||||
|
||||
QString serverdir = "http://127.0.0.1:14447/qtest/qml/qqmllanguage";
|
||||
QString serverdir = "{{ServerBaseUrl}}/qtest/qml/qqmllanguage";
|
||||
|
||||
QTest::newRow("remote import") << "import \""+serverdir+"\"\nTest {}" << "QQuickRectangle"
|
||||
<< "";
|
||||
|
@ -2570,9 +2573,11 @@ void tst_qqmllanguage::importsRemote()
|
|||
QFETCH(QString, error);
|
||||
|
||||
TestHTTPServer server;
|
||||
QVERIFY2(server.listen(14447), qPrintable(server.errorString()));
|
||||
QVERIFY2(server.listen(), qPrintable(server.errorString()));
|
||||
server.serveDirectory(dataDirectory());
|
||||
|
||||
qml.replace(QStringLiteral("{{ServerBaseUrl}}"), server.baseUrl().toString());
|
||||
|
||||
testType(qml,type,error);
|
||||
}
|
||||
|
||||
|
@ -2663,10 +2668,10 @@ void tst_qqmllanguage::importsInstalledRemote()
|
|||
QFETCH(QString, error);
|
||||
|
||||
TestHTTPServer server;
|
||||
QVERIFY2(server.listen(14447), qPrintable(server.errorString()));
|
||||
QVERIFY2(server.listen(), qPrintable(server.errorString()));
|
||||
server.serveDirectory(dataDirectory());
|
||||
|
||||
QString serverdir = "http://127.0.0.1:14447/lib/";
|
||||
QString serverdir = server.urlString("/lib/");
|
||||
engine.setImportPathList(QStringList(defaultImportPathList) << serverdir);
|
||||
|
||||
testType(qml,type,error);
|
||||
|
@ -2681,43 +2686,43 @@ void tst_qqmllanguage::importsPath_data()
|
|||
QTest::addColumn<QString>("value");
|
||||
|
||||
QTest::newRow("local takes priority normal")
|
||||
<< (QStringList() << testFile("lib") << "http://127.0.0.1:14447/lib2/")
|
||||
<< (QStringList() << testFile("lib") << "{{ServerBaseUrl}}/lib2/")
|
||||
<< "import testModule 1.0\n"
|
||||
"Test {}"
|
||||
<< "foo";
|
||||
|
||||
QTest::newRow("local takes priority reversed")
|
||||
<< (QStringList() << "http://127.0.0.1:14447/lib/" << testFile("lib2"))
|
||||
<< (QStringList() << "{{ServerBaseUrl}}/lib/" << testFile("lib2"))
|
||||
<< "import testModule 1.0\n"
|
||||
"Test {}"
|
||||
<< "bar";
|
||||
|
||||
QTest::newRow("earlier takes priority 1")
|
||||
<< (QStringList() << "http://127.0.0.1:14447/lib/" << "http://127.0.0.1:14447/lib2/")
|
||||
<< (QStringList() << "{{ServerBaseUrl}}/lib/" << "{{ServerBaseUrl}}/lib2/")
|
||||
<< "import testModule 1.0\n"
|
||||
"Test {}"
|
||||
<< "foo";
|
||||
|
||||
QTest::newRow("earlier takes priority 2")
|
||||
<< (QStringList() << "http://127.0.0.1:14447/lib2/" << "http://127.0.0.1:14447/lib/")
|
||||
<< (QStringList() << "{{ServerBaseUrl}}/lib2/" << "{{ServerBaseUrl}}/lib/")
|
||||
<< "import testModule 1.0\n"
|
||||
"Test {}"
|
||||
<< "bar";
|
||||
|
||||
QTest::newRow("major version takes priority over unversioned")
|
||||
<< (QStringList() << "http://127.0.0.1:14447/lib/" << "http://127.0.0.1:14447/lib3/")
|
||||
<< (QStringList() << "{{ServerBaseUrl}}/lib/" << "{{ServerBaseUrl}}/lib3/")
|
||||
<< "import testModule 1.0\n"
|
||||
"Test {}"
|
||||
<< "baz";
|
||||
|
||||
QTest::newRow("major version takes priority over minor")
|
||||
<< (QStringList() << "http://127.0.0.1:14447/lib4/" << "http://127.0.0.1:14447/lib3/")
|
||||
<< (QStringList() << "{{ServerBaseUrl}}/lib4/" << "{{ServerBaseUrl}}/lib3/")
|
||||
<< "import testModule 1.0\n"
|
||||
"Test {}"
|
||||
<< "baz";
|
||||
|
||||
QTest::newRow("minor version takes priority over unversioned")
|
||||
<< (QStringList() << "http://127.0.0.1:14447/lib/" << "http://127.0.0.1:14447/lib4/")
|
||||
<< (QStringList() << "{{ServerBaseUrl}}/lib/" << "{{ServerBaseUrl}}/lib4/")
|
||||
<< "import testModule 1.0\n"
|
||||
"Test {}"
|
||||
<< "qux";
|
||||
|
@ -2730,9 +2735,12 @@ void tst_qqmllanguage::importsPath()
|
|||
QFETCH(QString, value);
|
||||
|
||||
TestHTTPServer server;
|
||||
QVERIFY2(server.listen(14447), qPrintable(server.errorString()));
|
||||
QVERIFY2(server.listen(), qPrintable(server.errorString()));
|
||||
server.serveDirectory(dataDirectory());
|
||||
|
||||
for (int i = 0; i < importPath.count(); ++i)
|
||||
importPath[i].replace(QStringLiteral("{{ServerBaseUrl}}"), server.baseUrl().toString());
|
||||
|
||||
engine.setImportPathList(QStringList(defaultImportPathList) << importPath);
|
||||
|
||||
QQmlComponent component(&engine);
|
||||
|
@ -3330,11 +3338,11 @@ void tst_qqmllanguage::registeredCompositeType()
|
|||
void tst_qqmllanguage::remoteLoadCrash()
|
||||
{
|
||||
TestHTTPServer server;
|
||||
QVERIFY2(server.listen(14448), qPrintable(server.errorString()));
|
||||
QVERIFY2(server.listen(), qPrintable(server.errorString()));
|
||||
server.serveDirectory(dataDirectory());
|
||||
|
||||
QQmlComponent component(&engine);
|
||||
component.setData("import QtQuick 2.0; Text {}", QUrl("http://127.0.0.1:14448/remoteLoadCrash.qml"));
|
||||
component.setData("import QtQuick 2.0; Text {}", server.url("/remoteLoadCrash.qml"));
|
||||
while (component.isLoading())
|
||||
QCoreApplication::processEvents( QEventLoop::ExcludeUserInputEvents | QEventLoop::WaitForMoreEvents, 50);
|
||||
|
||||
|
@ -3821,10 +3829,18 @@ void tst_qqmllanguage::compositeSingletonQmlDirError()
|
|||
void tst_qqmllanguage::compositeSingletonRemote()
|
||||
{
|
||||
TestHTTPServer server;
|
||||
QVERIFY2(server.listen(14447), qPrintable(server.errorString()));
|
||||
QVERIFY2(server.listen(), qPrintable(server.errorString()));
|
||||
server.serveDirectory(dataDirectory());
|
||||
|
||||
QQmlComponent component(&engine, testFile("singletonTest15.qml"));
|
||||
QFile f(testFile("singletonTest15.qml"));
|
||||
QVERIFY(f.open(QIODevice::ReadOnly));
|
||||
QByteArray contents = f.readAll();
|
||||
f.close();
|
||||
|
||||
contents.replace(QByteArrayLiteral("{{ServerBaseUrl}}"), server.baseUrl().toString().toUtf8());
|
||||
|
||||
QQmlComponent component(&engine);
|
||||
component.setData(contents, testFileUrl("singletonTest15.qml"));
|
||||
|
||||
while (component.isLoading())
|
||||
QCoreApplication::processEvents( QEventLoop::ExcludeUserInputEvents | QEventLoop::WaitForMoreEvents, 50);
|
||||
|
@ -3930,6 +3946,20 @@ void tst_qqmllanguage::customParserWithExtendedObject()
|
|||
QCOMPARE(returnValue.toInt(), 1584);
|
||||
}
|
||||
|
||||
void tst_qqmllanguage::nestedCustomParsers()
|
||||
{
|
||||
QQmlComponent component(&engine, testFile("nestedCustomParsers.qml"));
|
||||
VERIFY_ERRORS(0);
|
||||
QScopedPointer<QObject> o(component.create());
|
||||
QVERIFY(!o.isNull());
|
||||
SimpleObjectWithCustomParser *testObject = qobject_cast<SimpleObjectWithCustomParser*>(o.data());
|
||||
QVERIFY(testObject);
|
||||
QCOMPARE(testObject->customBindingsCount(), 1);
|
||||
SimpleObjectWithCustomParser *nestedObject = qobject_cast<SimpleObjectWithCustomParser*>(testObject->property("nested").value<QObject*>());
|
||||
QVERIFY(nestedObject);
|
||||
QCOMPARE(nestedObject->customBindingsCount(), 1);
|
||||
}
|
||||
|
||||
void tst_qqmllanguage::preservePropertyCacheOnGroupObjects()
|
||||
{
|
||||
QQmlComponent component(&engine, testFile("preservePropertyCacheOnGroupObjects.qml"));
|
||||
|
|
|
@ -44,9 +44,6 @@
|
|||
#include "../../shared/testhttpserver.h"
|
||||
#include "../../shared/util.h"
|
||||
|
||||
#define SERVER_ADDR "http://127.0.0.1:14456"
|
||||
#define SERVER_PORT 14456
|
||||
|
||||
// Note: this test does not use module identifier directives in the qmldir files, because
|
||||
// it would result in repeated attempts to insert types into the same namespace.
|
||||
// This occurs because type registration is process-global, while the test
|
||||
|
@ -240,12 +237,13 @@ void tst_qqmlmoduleplugin::importPluginWithQmlFile()
|
|||
void tst_qqmlmoduleplugin::remoteImportWithQuotedUrl()
|
||||
{
|
||||
TestHTTPServer server;
|
||||
QVERIFY2(server.listen(SERVER_PORT), qPrintable(server.errorString()));
|
||||
QVERIFY2(server.listen(), qPrintable(server.errorString()));
|
||||
server.serveDirectory(m_dataImportsDirectory);
|
||||
|
||||
QQmlEngine engine;
|
||||
QQmlComponent component(&engine);
|
||||
component.setData("import \"" SERVER_ADDR "/org/qtproject/PureQmlModule\" \nComponentA { width: 300; ComponentB{} }", QUrl());
|
||||
const QString qml = "import \"" + server.urlString("/org/qtproject/PureQmlModule") + "\" \nComponentA { width: 300; ComponentB{} }";
|
||||
component.setData(qml.toUtf8(), QUrl());
|
||||
|
||||
QTRY_COMPARE(component.status(), QQmlComponent::Ready);
|
||||
QObject *object = component.create();
|
||||
|
@ -261,7 +259,7 @@ void tst_qqmlmoduleplugin::remoteImportWithQuotedUrl()
|
|||
void tst_qqmlmoduleplugin::remoteImportWithUnquotedUri()
|
||||
{
|
||||
TestHTTPServer server;
|
||||
QVERIFY2(server.listen(SERVER_PORT), qPrintable(server.errorString()));
|
||||
QVERIFY2(server.listen(), qPrintable(server.errorString()));
|
||||
server.serveDirectory(m_dataImportsDirectory);
|
||||
|
||||
QQmlEngine engine;
|
||||
|
|
|
@ -17,7 +17,7 @@ Item {
|
|||
var o = Qt.createQmlObject(seqComponent,root);
|
||||
}
|
||||
}
|
||||
doc.open("GET", "http://127.0.0.1:14445/TestComponent3.qml");
|
||||
doc.open("GET", serverBaseUrl + "/TestComponent3.qml");
|
||||
doc.send();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,6 +5,6 @@ Content-Length: 9
|
|||
Connection: Keep-Alive
|
||||
Accept-Encoding: gzip, deflate
|
||||
User-Agent: Mozilla/5.0
|
||||
Host: 127.0.0.1:14445
|
||||
Host: {{ServerHostUrl}}
|
||||
|
||||
Test Data
|
|
@ -3,5 +3,5 @@ Accept-Language: en-US
|
|||
Connection: Keep-Alive
|
||||
Accept-Encoding: gzip, deflate
|
||||
User-Agent: Mozilla/5.0
|
||||
Host: 127.0.0.1:14445
|
||||
Host: {{ServerHostUrl}}
|
||||
|
||||
|
|
|
@ -3,5 +3,5 @@ Accept-Language: en-US
|
|||
Connection: Keep-Alive
|
||||
Accept-Encoding: gzip, deflate
|
||||
User-Agent: Mozilla/5.0
|
||||
Host: 127.0.0.1:14445
|
||||
Host: {{ServerHostUrl}}
|
||||
|
||||
|
|
|
@ -4,4 +4,4 @@ Content-Type: image/png
|
|||
Connection: Keep-Alive
|
||||
Accept-Encoding: gzip, deflate
|
||||
User-Agent: Mozilla/5.0
|
||||
Host: 127.0.0.1:14445
|
||||
Host: {{ServerHostUrl}}
|
||||
|
|
|
@ -4,4 +4,4 @@ Content-Type: application/jsonrequest
|
|||
Connection: Keep-Alive
|
||||
Accept-Encoding: gzip, deflate
|
||||
User-Agent: Mozilla/5.0
|
||||
Host: 127.0.0.1:14445
|
||||
Host: {{ServerHostUrl}}
|
||||
|
|
|
@ -5,6 +5,6 @@ Content-Length: 12
|
|||
Connection: Keep-Alive
|
||||
Accept-Encoding: gzip, deflate
|
||||
User-Agent: Mozilla/5.0
|
||||
Host: 127.0.0.1:14445
|
||||
Host: {{ServerHostUrl}}
|
||||
|
||||
My Sent Data
|
|
@ -5,6 +5,6 @@ Content-Length: 12
|
|||
Connection: Keep-Alive
|
||||
Accept-Encoding: gzip, deflate
|
||||
User-Agent: Mozilla/5.0
|
||||
Host: 127.0.0.1:14445
|
||||
Host: {{ServerHostUrl}}
|
||||
|
||||
My Sent Data
|
|
@ -5,6 +5,6 @@ Content-Length: 12
|
|||
Connection: Keep-Alive
|
||||
Accept-Encoding: gzip, deflate
|
||||
User-Agent: Mozilla/5.0
|
||||
Host: 127.0.0.1:14445
|
||||
Host: {{ServerHostUrl}}
|
||||
|
||||
My Sent Data
|
|
@ -5,6 +5,6 @@ Content-Length: 12
|
|||
Connection: Keep-Alive
|
||||
Accept-Encoding: gzip, deflate
|
||||
User-Agent: Mozilla/5.0
|
||||
Host: 127.0.0.1:14445
|
||||
Host: {{ServerHostUrl}}
|
||||
|
||||
My Sent Data
|
|
@ -4,4 +4,4 @@ Connection: Keep-Alive
|
|||
Accept-Encoding: gzip, deflate
|
||||
Accept-Language: en-US,*
|
||||
User-Agent: Mozilla/5.0
|
||||
Host: 127.0.0.1:14445
|
||||
Host: {{ServerHostUrl}}
|
||||
|
|
|
@ -4,4 +4,4 @@ Connection: Keep-Alive
|
|||
Accept-Encoding: gzip, deflate
|
||||
Accept-Language: en-US,*
|
||||
User-Agent: Mozilla/5.0
|
||||
Host: 127.0.0.1:14445
|
||||
Host: {{ServerHostUrl}}
|
||||
|
|
|
@ -3,5 +3,5 @@ Accept-Language: en-US
|
|||
Connection: Keep-Alive
|
||||
Accept-Encoding: gzip, deflate
|
||||
User-Agent: Mozilla/5.0
|
||||
Host: 127.0.0.1:14445
|
||||
Host: {{ServerHostUrl}}
|
||||
|
||||
|
|
|
@ -3,5 +3,5 @@ Accept-Language: en-US
|
|||
Connection: Keep-Alive
|
||||
Accept-Encoding: gzip, deflate
|
||||
User-Agent: Mozilla/5.0
|
||||
Host: 127.0.0.1:14445
|
||||
Host: {{ServerHostUrl}}
|
||||
|
||||
|
|
|
@ -3,5 +3,5 @@ Accept-Language: en-US
|
|||
Connection: Keep-Alive
|
||||
Accept-Encoding: gzip, deflate
|
||||
User-Agent: Mozilla/5.0
|
||||
Host: 127.0.0.1:14445
|
||||
Host: {{ServerHostUrl}}
|
||||
|
||||
|
|
|
@ -5,5 +5,5 @@ Test-header2: value,value2
|
|||
Connection: Keep-Alive
|
||||
Accept-Encoding: gzip, deflate
|
||||
User-Agent: Mozilla/5.0
|
||||
Host: 127.0.0.1:14445
|
||||
Host: {{ServerHostUrl}}
|
||||
|
||||
|
|
|
@ -5,6 +5,7 @@ Item {
|
|||
|
||||
property int whichCount: 0
|
||||
property bool success: false
|
||||
property string serverBaseUrl;
|
||||
|
||||
SequentialAnimation {
|
||||
id: anim
|
||||
|
@ -23,7 +24,7 @@ Item {
|
|||
|
||||
function updateList() {
|
||||
var xhr = new XMLHttpRequest();
|
||||
xhr.open("GET","http://127.0.0.1:14445/testlist"); // list of components
|
||||
xhr.open("GET",serverBaseUrl + "/testlist"); // list of components
|
||||
xhr.onreadystatechange = function () {
|
||||
if (xhr.readyState == XMLHttpRequest.DONE) {
|
||||
var components = xhr.responseText.split('\n');
|
||||
|
|
|
@ -3,5 +3,5 @@ Accept-Language: en-US
|
|||
Connection: Keep-Alive
|
||||
Accept-Encoding: gzip, deflate
|
||||
User-Agent: Mozilla/5.0
|
||||
Host: 127.0.0.1:14445
|
||||
Host: {{ServerHostUrl}}
|
||||
|
||||
|
|
|
@ -38,11 +38,11 @@
|
|||
#include <QScopedPointer>
|
||||
#include <QNetworkCookieJar>
|
||||
#include <QThread>
|
||||
#include <QMutex>
|
||||
#include <QWaitCondition>
|
||||
#include "testhttpserver.h"
|
||||
#include "../../shared/util.h"
|
||||
|
||||
#define SERVER_PORT 14445
|
||||
|
||||
class tst_qqmlxmlhttprequest : public QQmlDataTest
|
||||
{
|
||||
Q_OBJECT
|
||||
|
@ -239,10 +239,11 @@ void tst_qqmlxmlhttprequest::open()
|
|||
|
||||
TestHTTPServer server;
|
||||
if (remote) {
|
||||
QVERIFY2(server.listen(SERVER_PORT), qPrintable(server.errorString()));
|
||||
QVERIFY2(server.listen(), qPrintable(server.errorString()));
|
||||
QVERIFY(server.wait(testFileUrl("open_network.expect"),
|
||||
testFileUrl("open_network.reply"),
|
||||
testFileUrl("testdocument.html")));
|
||||
url = server.urlString(url);
|
||||
}
|
||||
|
||||
QQmlComponent component(&engine, qmlFile);
|
||||
|
@ -269,10 +270,10 @@ void tst_qqmlxmlhttprequest::open_data()
|
|||
|
||||
QTest::newRow("Relative url)") << testFileUrl("open.qml") << "testdocument.html" << false;
|
||||
QTest::newRow("Absolute url)") << testFileUrl("open.qml") << testFileUrl("testdocument.html").toString() << false;
|
||||
QTest::newRow("Absolute network url)") << testFileUrl("open.qml") << "http://127.0.0.1:14445/testdocument.html" << true;
|
||||
QTest::newRow("Absolute network url)") << testFileUrl("open.qml") << "/testdocument.html" << true;
|
||||
|
||||
// ### Check that the username/password were sent to the server
|
||||
QTest::newRow("User/pass") << testFileUrl("open_user.qml") << "http://127.0.0.1:14445/testdocument.html" << true;
|
||||
QTest::newRow("User/pass") << testFileUrl("open_user.qml") << "/testdocument.html" << true;
|
||||
}
|
||||
|
||||
// Test that calling XMLHttpRequest.open() with an invalid method raises an exception
|
||||
|
@ -291,9 +292,11 @@ class TestThreadedHTTPServer : public QObject
|
|||
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();
|
||||
|
@ -301,16 +304,23 @@ public:
|
|||
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
|
||||
|
@ -321,7 +331,7 @@ void tst_qqmlxmlhttprequest::open_sync()
|
|||
QQmlComponent component(&engine, testFileUrl("open_sync.qml"));
|
||||
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("responseText").toString(), QStringLiteral("QML Rocks!\n"));
|
||||
|
@ -351,7 +361,7 @@ void tst_qqmlxmlhttprequest::open_arg_count()
|
|||
void tst_qqmlxmlhttprequest::setRequestHeader()
|
||||
{
|
||||
TestHTTPServer server;
|
||||
QVERIFY2(server.listen(SERVER_PORT), qPrintable(server.errorString()));
|
||||
QVERIFY2(server.listen(), qPrintable(server.errorString()));
|
||||
QVERIFY(server.wait(testFileUrl("setRequestHeader.expect"),
|
||||
testFileUrl("setRequestHeader.reply"),
|
||||
testFileUrl("testdocument.html")));
|
||||
|
@ -359,7 +369,7 @@ void tst_qqmlxmlhttprequest::setRequestHeader()
|
|||
QQmlComponent component(&engine, testFileUrl("setRequestHeader.qml"));
|
||||
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.urlString("/testdocument.html"));
|
||||
component.completeCreate();
|
||||
|
||||
QTRY_VERIFY(object->property("dataOK").toBool() == true);
|
||||
|
@ -369,7 +379,7 @@ void tst_qqmlxmlhttprequest::setRequestHeader()
|
|||
void tst_qqmlxmlhttprequest::setRequestHeader_caseInsensitive()
|
||||
{
|
||||
TestHTTPServer server;
|
||||
QVERIFY2(server.listen(SERVER_PORT), qPrintable(server.errorString()));
|
||||
QVERIFY2(server.listen(), qPrintable(server.errorString()));
|
||||
QVERIFY(server.wait(testFileUrl("setRequestHeader.expect"),
|
||||
testFileUrl("setRequestHeader.reply"),
|
||||
testFileUrl("testdocument.html")));
|
||||
|
@ -377,7 +387,7 @@ void tst_qqmlxmlhttprequest::setRequestHeader_caseInsensitive()
|
|||
QQmlComponent component(&engine, testFileUrl("setRequestHeader_caseInsensitive.qml"));
|
||||
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.urlString("/testdocument.html"));
|
||||
component.completeCreate();
|
||||
|
||||
QTRY_VERIFY(object->property("dataOK").toBool() == true);
|
||||
|
@ -426,7 +436,7 @@ void tst_qqmlxmlhttprequest::setRequestHeader_illegalName()
|
|||
QFETCH(QString, name);
|
||||
|
||||
TestHTTPServer server;
|
||||
QVERIFY2(server.listen(SERVER_PORT), qPrintable(server.errorString()));
|
||||
QVERIFY2(server.listen(), qPrintable(server.errorString()));
|
||||
QVERIFY(server.wait(testFileUrl("open_network.expect"),
|
||||
testFileUrl("open_network.reply"),
|
||||
testFileUrl("testdocument.html")));
|
||||
|
@ -434,7 +444,7 @@ void tst_qqmlxmlhttprequest::setRequestHeader_illegalName()
|
|||
QQmlComponent component(&engine, testFileUrl("setRequestHeader_illegalName.qml"));
|
||||
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.urlString("/testdocument.html"));
|
||||
object->setProperty("header", name);
|
||||
component.completeCreate();
|
||||
|
||||
|
@ -452,7 +462,7 @@ void tst_qqmlxmlhttprequest::setRequestHeader_illegalName()
|
|||
void tst_qqmlxmlhttprequest::setRequestHeader_sent()
|
||||
{
|
||||
TestHTTPServer server;
|
||||
QVERIFY2(server.listen(SERVER_PORT), qPrintable(server.errorString()));
|
||||
QVERIFY2(server.listen(), qPrintable(server.errorString()));
|
||||
QVERIFY(server.wait(testFileUrl("open_network.expect"),
|
||||
testFileUrl("open_network.reply"),
|
||||
testFileUrl("testdocument.html")));
|
||||
|
@ -460,7 +470,7 @@ void tst_qqmlxmlhttprequest::setRequestHeader_sent()
|
|||
QQmlComponent component(&engine, testFileUrl("setRequestHeader_sent.qml"));
|
||||
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.urlString("/testdocument.html"));
|
||||
component.completeCreate();
|
||||
|
||||
QCOMPARE(object->property("test").toBool(), true);
|
||||
|
@ -504,7 +514,7 @@ void tst_qqmlxmlhttprequest::send_ignoreData()
|
|||
{
|
||||
{
|
||||
TestHTTPServer server;
|
||||
QVERIFY2(server.listen(SERVER_PORT), qPrintable(server.errorString()));
|
||||
QVERIFY2(server.listen(), qPrintable(server.errorString()));
|
||||
QVERIFY(server.wait(testFileUrl("send_ignoreData_GET.expect"),
|
||||
testFileUrl("send_ignoreData.reply"),
|
||||
testFileUrl("testdocument.html")));
|
||||
|
@ -513,7 +523,7 @@ void tst_qqmlxmlhttprequest::send_ignoreData()
|
|||
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");
|
||||
object->setProperty("url", server.urlString("/testdocument.html"));
|
||||
component.completeCreate();
|
||||
|
||||
QTRY_VERIFY(object->property("dataOK").toBool() == true);
|
||||
|
@ -521,7 +531,7 @@ void tst_qqmlxmlhttprequest::send_ignoreData()
|
|||
|
||||
{
|
||||
TestHTTPServer server;
|
||||
QVERIFY2(server.listen(SERVER_PORT), qPrintable(server.errorString()));
|
||||
QVERIFY2(server.listen(), qPrintable(server.errorString()));
|
||||
QVERIFY(server.wait(testFileUrl("send_ignoreData_HEAD.expect"),
|
||||
testFileUrl("send_ignoreData.reply"),
|
||||
QUrl()));
|
||||
|
@ -530,7 +540,7 @@ void tst_qqmlxmlhttprequest::send_ignoreData()
|
|||
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");
|
||||
object->setProperty("url", server.urlString("/testdocument.html"));
|
||||
component.completeCreate();
|
||||
|
||||
QTRY_VERIFY(object->property("dataOK").toBool() == true);
|
||||
|
@ -538,7 +548,7 @@ void tst_qqmlxmlhttprequest::send_ignoreData()
|
|||
|
||||
{
|
||||
TestHTTPServer server;
|
||||
QVERIFY2(server.listen(SERVER_PORT), qPrintable(server.errorString()));
|
||||
QVERIFY2(server.listen(), qPrintable(server.errorString()));
|
||||
QVERIFY(server.wait(testFileUrl("send_ignoreData_DELETE.expect"),
|
||||
testFileUrl("send_ignoreData.reply"),
|
||||
QUrl()));
|
||||
|
@ -547,7 +557,7 @@ void tst_qqmlxmlhttprequest::send_ignoreData()
|
|||
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");
|
||||
object->setProperty("url", server.urlString("/testdocument.html"));
|
||||
component.completeCreate();
|
||||
|
||||
QTRY_VERIFY(object->property("dataOK").toBool() == true);
|
||||
|
@ -561,7 +571,7 @@ void tst_qqmlxmlhttprequest::send_withdata()
|
|||
QFETCH(QString, file_qml);
|
||||
|
||||
TestHTTPServer server;
|
||||
QVERIFY2(server.listen(SERVER_PORT), qPrintable(server.errorString()));
|
||||
QVERIFY2(server.listen(), qPrintable(server.errorString()));
|
||||
QVERIFY(server.wait(testFileUrl(file_expected),
|
||||
testFileUrl("send_data.reply"),
|
||||
testFileUrl("testdocument.html")));
|
||||
|
@ -569,7 +579,7 @@ void tst_qqmlxmlhttprequest::send_withdata()
|
|||
QQmlComponent component(&engine, testFileUrl(file_qml));
|
||||
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.urlString("/testdocument.html"));
|
||||
component.completeCreate();
|
||||
|
||||
QTRY_VERIFY(object->property("dataOK").toBool() == true);
|
||||
|
@ -597,7 +607,7 @@ void tst_qqmlxmlhttprequest::send_options()
|
|||
QFETCH(QString, file_reply);
|
||||
|
||||
TestHTTPServer server;
|
||||
QVERIFY2(server.listen(SERVER_PORT), qPrintable(server.errorString()));
|
||||
QVERIFY2(server.listen(), qPrintable(server.errorString()));
|
||||
QVERIFY(server.wait(testFileUrl(file_expected),
|
||||
testFileUrl(file_reply),
|
||||
testFileUrl("testdocument.html")));
|
||||
|
@ -605,7 +615,7 @@ void tst_qqmlxmlhttprequest::send_options()
|
|||
QQmlComponent component(&engine, testFileUrl(file_qml));
|
||||
QScopedPointer<QObject> object(component.beginCreate(engine.rootContext()));
|
||||
QVERIFY(!object.isNull());
|
||||
QString url = "http://127.0.0.1:14445";
|
||||
QString url = server.baseUrl().toString();
|
||||
if (url_suffix != "/")
|
||||
url.append("/");
|
||||
if (!url_suffix.isEmpty())
|
||||
|
@ -672,7 +682,7 @@ void tst_qqmlxmlhttprequest::abort_opened()
|
|||
void tst_qqmlxmlhttprequest::abort()
|
||||
{
|
||||
TestHTTPServer server;
|
||||
QVERIFY2(server.listen(SERVER_PORT), qPrintable(server.errorString()));
|
||||
QVERIFY2(server.listen(), qPrintable(server.errorString()));
|
||||
QVERIFY(server.wait(testFileUrl("abort.expect"),
|
||||
testFileUrl("abort.reply"),
|
||||
testFileUrl("testdocument.html")));
|
||||
|
@ -680,8 +690,11 @@ void tst_qqmlxmlhttprequest::abort()
|
|||
QQmlComponent component(&engine, testFileUrl("abort.qml"));
|
||||
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");
|
||||
const QUrl url = server.url("/testdocument.html");
|
||||
QUrl dummyUrl = url;
|
||||
dummyUrl.setPort(dummyUrl.port() - 1);
|
||||
object->setProperty("urlDummy", dummyUrl.toString());
|
||||
object->setProperty("url", url.toString());
|
||||
component.completeCreate();
|
||||
|
||||
QCOMPARE(object->property("seenDone").toBool(), true);
|
||||
|
@ -696,7 +709,7 @@ void tst_qqmlxmlhttprequest::getResponseHeader()
|
|||
QQmlEngine engine; // Avoid cookie contamination
|
||||
|
||||
TestHTTPServer server;
|
||||
QVERIFY2(server.listen(SERVER_PORT), qPrintable(server.errorString()));
|
||||
QVERIFY2(server.listen(), qPrintable(server.errorString()));
|
||||
QVERIFY(server.wait(testFileUrl("getResponseHeader.expect"),
|
||||
testFileUrl("getResponseHeader.reply"),
|
||||
testFileUrl("testdocument.html")));
|
||||
|
@ -705,7 +718,7 @@ void tst_qqmlxmlhttprequest::getResponseHeader()
|
|||
QQmlComponent component(&engine, testFileUrl("getResponseHeader.qml"));
|
||||
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.urlString("/testdocument.html"));
|
||||
component.completeCreate();
|
||||
|
||||
QCOMPARE(object->property("unsentException").toBool(), true);
|
||||
|
@ -763,7 +776,7 @@ void tst_qqmlxmlhttprequest::getAllResponseHeaders()
|
|||
QQmlEngine engine; // Avoid cookie contamination
|
||||
|
||||
TestHTTPServer server;
|
||||
QVERIFY2(server.listen(SERVER_PORT), qPrintable(server.errorString()));
|
||||
QVERIFY2(server.listen(), qPrintable(server.errorString()));
|
||||
QVERIFY(server.wait(testFileUrl("getResponseHeader.expect"),
|
||||
testFileUrl("getResponseHeader.reply"),
|
||||
testFileUrl("testdocument.html")));
|
||||
|
@ -771,7 +784,7 @@ void tst_qqmlxmlhttprequest::getAllResponseHeaders()
|
|||
QQmlComponent component(&engine, testFileUrl("getAllResponseHeaders.qml"));
|
||||
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.urlString("/testdocument.html"));
|
||||
component.completeCreate();
|
||||
|
||||
QCOMPARE(object->property("unsentException").toBool(), true);
|
||||
|
@ -821,7 +834,7 @@ void tst_qqmlxmlhttprequest::getAllResponseHeaders_args()
|
|||
void tst_qqmlxmlhttprequest::getBinaryData()
|
||||
{
|
||||
TestHTTPServer server;
|
||||
QVERIFY2(server.listen(SERVER_PORT), qPrintable(server.errorString()));
|
||||
QVERIFY2(server.listen(), qPrintable(server.errorString()));
|
||||
QVERIFY(server.wait(testFileUrl("receive_binary_data.expect"),
|
||||
testFileUrl("receive_binary_data.reply"),
|
||||
testFileUrl("qml_logo.png")));
|
||||
|
@ -829,7 +842,7 @@ void tst_qqmlxmlhttprequest::getBinaryData()
|
|||
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");
|
||||
object->setProperty("url", server.urlString("/gml_logo.png"));
|
||||
component.completeCreate();
|
||||
|
||||
QFileInfo fileInfo("data/qml_logo.png");
|
||||
|
@ -839,7 +852,7 @@ void tst_qqmlxmlhttprequest::getBinaryData()
|
|||
void tst_qqmlxmlhttprequest::getJsonData()
|
||||
{
|
||||
TestHTTPServer server;
|
||||
QVERIFY2(server.listen(SERVER_PORT), qPrintable(server.errorString()));
|
||||
QVERIFY2(server.listen(), qPrintable(server.errorString()));
|
||||
QVERIFY(server.wait(testFileUrl("receive_json_data.expect"),
|
||||
testFileUrl("receive_binary_data.reply"),
|
||||
testFileUrl("json.data")));
|
||||
|
@ -847,7 +860,7 @@ void tst_qqmlxmlhttprequest::getJsonData()
|
|||
QQmlComponent component(&engine, testFileUrl("receiveJsonData.qml"));
|
||||
QScopedPointer<QObject> object(component.beginCreate(engine.rootContext()));
|
||||
QVERIFY(!object.isNull());
|
||||
object->setProperty("url", "http://127.0.0.1:14445/json.data");
|
||||
object->setProperty("url", server.urlString("/json.data"));
|
||||
component.completeCreate();
|
||||
|
||||
QTRY_VERIFY(object->property("result").toBool());
|
||||
|
@ -859,7 +872,7 @@ void tst_qqmlxmlhttprequest::status()
|
|||
QFETCH(int, status);
|
||||
|
||||
TestHTTPServer server;
|
||||
QVERIFY2(server.listen(SERVER_PORT), qPrintable(server.errorString()));
|
||||
QVERIFY2(server.listen(), qPrintable(server.errorString()));
|
||||
QVERIFY(server.wait(testFileUrl("status.expect"),
|
||||
replyUrl,
|
||||
testFileUrl("testdocument.html")));
|
||||
|
@ -867,7 +880,7 @@ void tst_qqmlxmlhttprequest::status()
|
|||
QQmlComponent component(&engine, testFileUrl("status.qml"));
|
||||
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.urlString("/testdocument.html"));
|
||||
object->setProperty("expectedStatus", status);
|
||||
component.completeCreate();
|
||||
|
||||
|
@ -898,7 +911,7 @@ void tst_qqmlxmlhttprequest::statusText()
|
|||
QFETCH(QString, statusText);
|
||||
|
||||
TestHTTPServer server;
|
||||
QVERIFY2(server.listen(SERVER_PORT), qPrintable(server.errorString()));
|
||||
QVERIFY2(server.listen(), qPrintable(server.errorString()));
|
||||
QVERIFY(server.wait(testFileUrl("status.expect"),
|
||||
replyUrl,
|
||||
testFileUrl("testdocument.html")));
|
||||
|
@ -906,7 +919,7 @@ void tst_qqmlxmlhttprequest::statusText()
|
|||
QQmlComponent component(&engine, testFileUrl("statusText.qml"));
|
||||
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.urlString("/testdocument.html"));
|
||||
object->setProperty("expectedStatus", statusText);
|
||||
component.completeCreate();
|
||||
|
||||
|
@ -938,7 +951,7 @@ void tst_qqmlxmlhttprequest::responseText()
|
|||
QFETCH(QString, responseText);
|
||||
|
||||
TestHTTPServer server;
|
||||
QVERIFY2(server.listen(SERVER_PORT), qPrintable(server.errorString()));
|
||||
QVERIFY2(server.listen(), qPrintable(server.errorString()));
|
||||
QVERIFY(server.wait(testFileUrl("status.expect"),
|
||||
replyUrl,
|
||||
bodyUrl));
|
||||
|
@ -946,7 +959,7 @@ void tst_qqmlxmlhttprequest::responseText()
|
|||
QQmlComponent component(&engine, testFileUrl("responseText.qml"));
|
||||
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.urlString("/testdocument.html"));
|
||||
object->setProperty("expectedText", responseText);
|
||||
component.completeCreate();
|
||||
|
||||
|
@ -1039,14 +1052,14 @@ void tst_qqmlxmlhttprequest::redirects()
|
|||
{
|
||||
{
|
||||
TestHTTPServer server;
|
||||
QVERIFY2(server.listen(SERVER_PORT), qPrintable(server.errorString()));
|
||||
server.addRedirect("redirect.html", "http://127.0.0.1:14445/redirecttarget.html");
|
||||
QVERIFY2(server.listen(), qPrintable(server.errorString()));
|
||||
server.addRedirect("redirect.html", server.urlString("/redirecttarget.html"));
|
||||
server.serveDirectory(dataDirectory());
|
||||
|
||||
QQmlComponent component(&engine, testFileUrl("redirects.qml"));
|
||||
QScopedPointer<QObject> object(component.beginCreate(engine.rootContext()));
|
||||
QVERIFY(!object.isNull());
|
||||
object->setProperty("url", "http://127.0.0.1:14445/redirect.html");
|
||||
object->setProperty("url", server.urlString("/redirect.html"));
|
||||
object->setProperty("expectedText", "");
|
||||
component.completeCreate();
|
||||
|
||||
|
@ -1056,14 +1069,14 @@ void tst_qqmlxmlhttprequest::redirects()
|
|||
|
||||
{
|
||||
TestHTTPServer server;
|
||||
QVERIFY2(server.listen(SERVER_PORT), qPrintable(server.errorString()));
|
||||
server.addRedirect("redirect.html", "http://127.0.0.1:14445/redirectmissing.html");
|
||||
QVERIFY2(server.listen(), qPrintable(server.errorString()));
|
||||
server.addRedirect("redirect.html", server.urlString("/redirectmissing.html"));
|
||||
server.serveDirectory(dataDirectory());
|
||||
|
||||
QQmlComponent component(&engine, testFileUrl("redirectError.qml"));
|
||||
QScopedPointer<QObject> object(component.beginCreate(engine.rootContext()));
|
||||
QVERIFY(!object.isNull());
|
||||
object->setProperty("url", "http://127.0.0.1:14445/redirect.html");
|
||||
object->setProperty("url", server.urlString("/redirect.html"));
|
||||
object->setProperty("expectedText", "");
|
||||
component.completeCreate();
|
||||
|
||||
|
@ -1073,14 +1086,14 @@ void tst_qqmlxmlhttprequest::redirects()
|
|||
|
||||
{
|
||||
TestHTTPServer server;
|
||||
QVERIFY2(server.listen(SERVER_PORT), qPrintable(server.errorString()));
|
||||
server.addRedirect("redirect.html", "http://127.0.0.1:14445/redirect.html");
|
||||
QVERIFY2(server.listen(), qPrintable(server.errorString()));
|
||||
server.addRedirect("redirect.html", server.urlString("/redirect.html"));
|
||||
server.serveDirectory(dataDirectory());
|
||||
|
||||
QQmlComponent component(&engine, testFileUrl("redirectRecur.qml"));
|
||||
QScopedPointer<QObject> object(component.beginCreate(engine.rootContext()));
|
||||
QVERIFY(!object.isNull());
|
||||
object->setProperty("url", "http://127.0.0.1:14445/redirect.html");
|
||||
object->setProperty("url", server.urlString("/redirect.html"));
|
||||
object->setProperty("expectedText", "");
|
||||
component.completeCreate();
|
||||
|
||||
|
@ -1175,12 +1188,14 @@ void tst_qqmlxmlhttprequest::stateChangeCallingContext()
|
|||
// without a valid calling context.
|
||||
|
||||
TestHTTPServer server;
|
||||
QVERIFY2(server.listen(SERVER_PORT), qPrintable(server.errorString()));
|
||||
QVERIFY2(server.listen(), qPrintable(server.errorString()));
|
||||
server.serveDirectory(dataDirectory(), TestHTTPServer::Delay);
|
||||
|
||||
QQmlComponent component(&engine, testFileUrl("stateChangeCallingContext.qml"));
|
||||
QScopedPointer<QObject> object(component.create());
|
||||
QScopedPointer<QObject> object(component.beginCreate(engine.rootContext()));
|
||||
QVERIFY(!object.isNull());
|
||||
object->setProperty("serverBaseUrl", server.baseUrl().toString());
|
||||
component.completeCreate();
|
||||
server.sendDelayedItem();
|
||||
QTRY_VERIFY(object->property("success").toBool() == true);
|
||||
}
|
||||
|
|
|
@ -253,11 +253,11 @@ void tst_qquickanimatedimage::remote()
|
|||
QFETCH(bool, paused);
|
||||
|
||||
TestHTTPServer server;
|
||||
QVERIFY2(server.listen(14449), qPrintable(server.errorString()));
|
||||
QVERIFY2(server.listen(), qPrintable(server.errorString()));
|
||||
server.serveDirectory(dataDirectory());
|
||||
|
||||
QQmlEngine engine;
|
||||
QQmlComponent component(&engine, QUrl("http://127.0.0.1:14449/" + fileName));
|
||||
QQmlComponent component(&engine, server.url(fileName));
|
||||
QTRY_VERIFY(component.isReady());
|
||||
|
||||
QQuickAnimatedImage *anim = qobject_cast<QQuickAnimatedImage *>(component.create());
|
||||
|
@ -318,7 +318,7 @@ void tst_qquickanimatedimage::invalidSource()
|
|||
void tst_qquickanimatedimage::sourceSizeChanges()
|
||||
{
|
||||
TestHTTPServer server;
|
||||
QVERIFY2(server.listen(14449), qPrintable(server.errorString()));
|
||||
QVERIFY2(server.listen(), qPrintable(server.errorString()));
|
||||
server.serveDirectory(dataDirectory());
|
||||
|
||||
QQmlEngine engine;
|
||||
|
@ -358,19 +358,19 @@ void tst_qquickanimatedimage::sourceSizeChanges()
|
|||
QTRY_VERIFY(sourceSizeSpy.count() == 3);
|
||||
|
||||
// Remote
|
||||
ctxt->setContextProperty("srcImage", QUrl("http://127.0.0.1:14449/hearts.gif"));
|
||||
ctxt->setContextProperty("srcImage", server.url("/hearts.gif"));
|
||||
QTRY_COMPARE(anim->status(), QQuickAnimatedImage::Ready);
|
||||
QTRY_VERIFY(sourceSizeSpy.count() == 4);
|
||||
|
||||
ctxt->setContextProperty("srcImage", QUrl("http://127.0.0.1:14449/hearts.gif"));
|
||||
ctxt->setContextProperty("srcImage", server.url("/hearts.gif"));
|
||||
QTRY_COMPARE(anim->status(), QQuickAnimatedImage::Ready);
|
||||
QTRY_VERIFY(sourceSizeSpy.count() == 4);
|
||||
|
||||
ctxt->setContextProperty("srcImage", QUrl("http://127.0.0.1:14449/hearts_copy.gif"));
|
||||
ctxt->setContextProperty("srcImage", server.url("/hearts_copy.gif"));
|
||||
QTRY_COMPARE(anim->status(), QQuickAnimatedImage::Ready);
|
||||
QTRY_VERIFY(sourceSizeSpy.count() == 4);
|
||||
|
||||
ctxt->setContextProperty("srcImage", QUrl("http://127.0.0.1:14449/colors.gif"));
|
||||
ctxt->setContextProperty("srcImage", server.url("/colors.gif"));
|
||||
QTRY_COMPARE(anim->status(), QQuickAnimatedImage::Ready);
|
||||
QTRY_VERIFY(sourceSizeSpy.count() == 5);
|
||||
|
||||
|
@ -384,7 +384,7 @@ void tst_qquickanimatedimage::sourceSizeChanges()
|
|||
void tst_qquickanimatedimage::qtbug_16520()
|
||||
{
|
||||
TestHTTPServer server;
|
||||
QVERIFY2(server.listen(14449), qPrintable(server.errorString()));
|
||||
QVERIFY2(server.listen(), qPrintable(server.errorString()));
|
||||
server.serveDirectory(dataDirectory());
|
||||
|
||||
QQmlEngine engine;
|
||||
|
@ -396,7 +396,7 @@ void tst_qquickanimatedimage::qtbug_16520()
|
|||
QQuickAnimatedImage *anim = root->findChild<QQuickAnimatedImage*>("anim");
|
||||
QVERIFY(anim != 0);
|
||||
|
||||
anim->setProperty("source", "http://127.0.0.1:14449/stickman.gif");
|
||||
anim->setProperty("source", server.urlString("/stickman.gif"));
|
||||
QTRY_VERIFY(anim->opacity() == 0);
|
||||
QTRY_VERIFY(anim->opacity() == 1);
|
||||
|
||||
|
@ -407,7 +407,7 @@ void tst_qquickanimatedimage::qtbug_16520()
|
|||
void tst_qquickanimatedimage::progressAndStatusChanges()
|
||||
{
|
||||
TestHTTPServer server;
|
||||
QVERIFY2(server.listen(14449), qPrintable(server.errorString()));
|
||||
QVERIFY2(server.listen(), qPrintable(server.errorString()));
|
||||
server.serveDirectory(dataDirectory());
|
||||
|
||||
QQmlEngine engine;
|
||||
|
@ -443,7 +443,7 @@ void tst_qquickanimatedimage::progressAndStatusChanges()
|
|||
QTRY_COMPARE(statusSpy.count(), 1);
|
||||
|
||||
// Loading remote file
|
||||
ctxt->setContextProperty("srcImage", "http://127.0.0.1:14449/stickman.gif");
|
||||
ctxt->setContextProperty("srcImage", server.url("/stickman.gif"));
|
||||
QTRY_VERIFY(obj->status() == QQuickImage::Loading);
|
||||
QTRY_VERIFY(obj->progress() == 0.0);
|
||||
QTRY_VERIFY(obj->status() == QQuickImage::Ready);
|
||||
|
|
|
@ -4,4 +4,4 @@ border.right:30
|
|||
border.bottom:40
|
||||
horizontalTileRule:Round
|
||||
verticalTileRule:Repeat
|
||||
source:http://127.0.0.1:14446/colors.png
|
||||
source:{{ServerBaseUrl}}/colors.png
|
||||
|
|
|
@ -50,9 +50,6 @@
|
|||
#include "../../shared/testhttpserver.h"
|
||||
#include "../../shared/util.h"
|
||||
|
||||
#define SERVER_PORT 14446
|
||||
#define SERVER_ADDR "http://127.0.0.1:14446"
|
||||
|
||||
Q_DECLARE_METATYPE(QQuickImageBase::Status)
|
||||
|
||||
class tst_qquickborderimage : public QQmlDataTest
|
||||
|
@ -124,9 +121,9 @@ void tst_qquickborderimage::imageSource_data()
|
|||
QTest::newRow("local") << testFileUrl("colors.png").toString() << false << "";
|
||||
QTest::newRow("local not found") << testFileUrl("no-such-file.png").toString() << false
|
||||
<< "<Unknown File>:2:1: QML BorderImage: Cannot open: " + testFileUrl("no-such-file.png").toString();
|
||||
QTest::newRow("remote") << SERVER_ADDR "/colors.png" << true << "";
|
||||
QTest::newRow("remote not found") << SERVER_ADDR "/no-such-file.png" << true
|
||||
<< "<Unknown File>:2:1: QML BorderImage: Error downloading " SERVER_ADDR "/no-such-file.png - server replied: Not found";
|
||||
QTest::newRow("remote") << "/colors.png" << true << "";
|
||||
QTest::newRow("remote not found") << "/no-such-file.png" << true
|
||||
<< "<Unknown File>:2:1: QML BorderImage: Error downloading {{ServerBaseUrl}}/no-such-file.png - server replied: Not found";
|
||||
}
|
||||
|
||||
void tst_qquickborderimage::imageSource()
|
||||
|
@ -144,8 +141,10 @@ void tst_qquickborderimage::imageSource()
|
|||
|
||||
TestHTTPServer server;
|
||||
if (remote) {
|
||||
QVERIFY2(server.listen(SERVER_PORT), qPrintable(server.errorString()));
|
||||
QVERIFY2(server.listen(), qPrintable(server.errorString()));
|
||||
server.serveDirectory(dataDirectory());
|
||||
source = server.urlString(source);
|
||||
error.replace(QStringLiteral("{{ServerBaseUrl}}"), server.baseUrl().toString());
|
||||
}
|
||||
|
||||
if (!error.isEmpty())
|
||||
|
@ -287,13 +286,14 @@ void tst_qquickborderimage::sciSource()
|
|||
{
|
||||
QFETCH(QString, source);
|
||||
QFETCH(bool, valid);
|
||||
|
||||
bool remote = source.startsWith("http");
|
||||
QFETCH(bool, remote);
|
||||
|
||||
TestHTTPServer server;
|
||||
if (remote) {
|
||||
QVERIFY2(server.listen(SERVER_PORT), qPrintable(server.errorString()));
|
||||
QVERIFY2(server.listen(), qPrintable(server.errorString()));
|
||||
server.serveDirectory(dataDirectory());
|
||||
source = server.urlString(source);
|
||||
server.registerFileNameForContentSubstitution(QUrl(source).path());
|
||||
}
|
||||
|
||||
QString componentStr = "import QtQuick 2.0\nBorderImage { source: \"" + source + "\"; width: 300; height: 300 }";
|
||||
|
@ -328,14 +328,15 @@ void tst_qquickborderimage::sciSource_data()
|
|||
{
|
||||
QTest::addColumn<QString>("source");
|
||||
QTest::addColumn<bool>("valid");
|
||||
QTest::addColumn<bool>("remote");
|
||||
|
||||
QTest::newRow("local") << testFileUrl("colors-round.sci").toString() << true;
|
||||
QTest::newRow("local quoted filename") << testFileUrl("colors-round-quotes.sci").toString() << true;
|
||||
QTest::newRow("local not found") << testFileUrl("no-such-file.sci").toString() << false;
|
||||
QTest::newRow("remote") << SERVER_ADDR "/colors-round.sci" << true;
|
||||
QTest::newRow("remote filename quoted") << SERVER_ADDR "/colors-round-quotes.sci" << true;
|
||||
QTest::newRow("remote image") << SERVER_ADDR "/colors-round-remote.sci" << true;
|
||||
QTest::newRow("remote not found") << SERVER_ADDR "/no-such-file.sci" << false;
|
||||
QTest::newRow("local") << testFileUrl("colors-round.sci").toString() << true << /*remote*/false;
|
||||
QTest::newRow("local quoted filename") << testFileUrl("colors-round-quotes.sci").toString() << true << /*remote*/false;
|
||||
QTest::newRow("local not found") << testFileUrl("no-such-file.sci").toString() << false << /*remote*/false;
|
||||
QTest::newRow("remote") << "/colors-round.sci" << true << /*remote*/true;
|
||||
QTest::newRow("remote filename quoted") << "/colors-round-quotes.sci" << true << /*remote*/true;
|
||||
QTest::newRow("remote image") << "/colors-round-remote.sci" << true << /*remote*/true;
|
||||
QTest::newRow("remote not found") << "/no-such-file.sci" << false << /*remote*/true;
|
||||
}
|
||||
|
||||
void tst_qquickborderimage::invalidSciFile()
|
||||
|
@ -421,7 +422,7 @@ void tst_qquickborderimage::statusChanges_data()
|
|||
QTest::newRow("nofile") << "" << 0 << false << QQuickImageBase::Null;
|
||||
QTest::newRow("nonexistent") << testFileUrl("thisfiledoesnotexist.png").toString() << 1 << false << QQuickImageBase::Error;
|
||||
QTest::newRow("noprotocol") << QString("thisfiledoesnotexisteither.png") << 2 << false << QQuickImageBase::Error;
|
||||
QTest::newRow("remote") << "http://localhost:14446/colors.png" << 2 << true << QQuickImageBase::Ready;
|
||||
QTest::newRow("remote") << "/colors.png" << 2 << true << QQuickImageBase::Ready;
|
||||
}
|
||||
|
||||
void tst_qquickborderimage::statusChanges()
|
||||
|
@ -433,8 +434,9 @@ void tst_qquickborderimage::statusChanges()
|
|||
|
||||
TestHTTPServer server;
|
||||
if (remote) {
|
||||
QVERIFY2(server.listen(SERVER_PORT), qPrintable(server.errorString()));
|
||||
QVERIFY2(server.listen(), qPrintable(server.errorString()));
|
||||
server.serveDirectory(dataDirectory());
|
||||
source = server.urlString(source);
|
||||
}
|
||||
|
||||
QString componentStr = "import QtQuick 2.0\nBorderImage { width: 300; height: 300 }";
|
||||
|
@ -457,7 +459,7 @@ void tst_qquickborderimage::statusChanges()
|
|||
void tst_qquickborderimage::sourceSizeChanges()
|
||||
{
|
||||
TestHTTPServer server;
|
||||
QVERIFY2(server.listen(14449), qPrintable(server.errorString()));
|
||||
QVERIFY2(server.listen(), qPrintable(server.errorString()));
|
||||
server.serveDirectory(dataDirectory());
|
||||
|
||||
QQmlEngine engine;
|
||||
|
@ -497,19 +499,19 @@ void tst_qquickborderimage::sourceSizeChanges()
|
|||
QTRY_COMPARE(sourceSizeSpy.count(), 3);
|
||||
|
||||
// Remote
|
||||
ctxt->setContextProperty("srcImage", QUrl("http://127.0.0.1:14449/heart200.png"));
|
||||
ctxt->setContextProperty("srcImage", server.url("/heart200.png"));
|
||||
QTRY_COMPARE(obj->status(), QQuickBorderImage::Ready);
|
||||
QTRY_COMPARE(sourceSizeSpy.count(), 4);
|
||||
|
||||
ctxt->setContextProperty("srcImage", QUrl("http://127.0.0.1:14449/heart200.png"));
|
||||
ctxt->setContextProperty("srcImage", server.url("/heart200.png"));
|
||||
QTRY_COMPARE(obj->status(), QQuickBorderImage::Ready);
|
||||
QTRY_COMPARE(sourceSizeSpy.count(), 4);
|
||||
|
||||
ctxt->setContextProperty("srcImage", QUrl("http://127.0.0.1:14449/heart200_copy.png"));
|
||||
ctxt->setContextProperty("srcImage", server.url("/heart200_copy.png"));
|
||||
QTRY_COMPARE(obj->status(), QQuickBorderImage::Ready);
|
||||
QTRY_COMPARE(sourceSizeSpy.count(), 4);
|
||||
|
||||
ctxt->setContextProperty("srcImage", QUrl("http://127.0.0.1:14449/colors.png"));
|
||||
ctxt->setContextProperty("srcImage", server.url("/colors.png"));
|
||||
QTRY_COMPARE(obj->status(), QQuickBorderImage::Ready);
|
||||
QTRY_COMPARE(sourceSizeSpy.count(), 5);
|
||||
|
||||
|
@ -523,7 +525,7 @@ void tst_qquickborderimage::sourceSizeChanges()
|
|||
void tst_qquickborderimage::progressAndStatusChanges()
|
||||
{
|
||||
TestHTTPServer server;
|
||||
QVERIFY2(server.listen(14449), qPrintable(server.errorString()));
|
||||
QVERIFY2(server.listen(), qPrintable(server.errorString()));
|
||||
server.serveDirectory(dataDirectory());
|
||||
|
||||
QQmlEngine engine;
|
||||
|
@ -559,7 +561,7 @@ void tst_qquickborderimage::progressAndStatusChanges()
|
|||
QTRY_COMPARE(statusSpy.count(), 1);
|
||||
|
||||
// Loading remote file
|
||||
ctxt->setContextProperty("srcImage", "http://127.0.0.1:14449/heart200.png");
|
||||
ctxt->setContextProperty("srcImage", server.url("/heart200.png"));
|
||||
QTRY_VERIFY(obj->status() == QQuickBorderImage::Loading);
|
||||
QTRY_VERIFY(obj->progress() == 0.0);
|
||||
QTRY_VERIFY(obj->status() == QQuickBorderImage::Ready);
|
||||
|
|
|
@ -41,9 +41,6 @@
|
|||
#include <QtQuick/QQuickView>
|
||||
#include <QtQuick/QQuickItem>
|
||||
|
||||
#define SERVER_PORT 14457
|
||||
#define SERVER_ADDR "http://localhost:14457"
|
||||
|
||||
class tst_qquickfontloader : public QQmlDataTest
|
||||
{
|
||||
Q_OBJECT
|
||||
|
@ -75,7 +72,7 @@ void tst_qquickfontloader::initTestCase()
|
|||
{
|
||||
QQmlDataTest::initTestCase();
|
||||
server.serveDirectory(dataDirectory());
|
||||
QVERIFY2(server.listen(SERVER_PORT), qPrintable(server.errorString()));
|
||||
QVERIFY2(server.listen(), qPrintable(server.errorString()));
|
||||
}
|
||||
|
||||
void tst_qquickfontloader::noFont()
|
||||
|
@ -135,7 +132,7 @@ void tst_qquickfontloader::failLocalFont()
|
|||
|
||||
void tst_qquickfontloader::webFont()
|
||||
{
|
||||
QString componentStr = "import QtQuick 2.0\nFontLoader { source: \"" SERVER_ADDR "/tarzeau_ocr_a.ttf\" }";
|
||||
QString componentStr = "import QtQuick 2.0\nFontLoader { source: \"" + server.baseUrl().toString() + "/tarzeau_ocr_a.ttf\" }";
|
||||
QQmlComponent component(&engine);
|
||||
|
||||
component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
|
||||
|
@ -151,7 +148,7 @@ void tst_qquickfontloader::redirWebFont()
|
|||
{
|
||||
server.addRedirect("olddir/oldname.ttf","../tarzeau_ocr_a.ttf");
|
||||
|
||||
QString componentStr = "import QtQuick 2.0\nFontLoader { source: \"" SERVER_ADDR "/olddir/oldname.ttf\" }";
|
||||
QString componentStr = "import QtQuick 2.0\nFontLoader { source: \"" + server.baseUrl().toString() + "/olddir/oldname.ttf\" }";
|
||||
QQmlComponent component(&engine);
|
||||
|
||||
component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
|
||||
|
@ -165,8 +162,9 @@ void tst_qquickfontloader::redirWebFont()
|
|||
|
||||
void tst_qquickfontloader::failWebFont()
|
||||
{
|
||||
QString componentStr = "import QtQuick 2.0\nFontLoader { source: \"" SERVER_ADDR "/nonexist.ttf\" }";
|
||||
QTest::ignoreMessage(QtWarningMsg, "<Unknown File>:2:1: QML FontLoader: Cannot load font: \"" SERVER_ADDR "/nonexist.ttf\"");
|
||||
QString componentStr = "import QtQuick 2.0\nFontLoader { source: \"" + server.baseUrl().toString() + "/nonexist.ttf\" }";
|
||||
const QString expectedError = "<Unknown File>:2:1: QML FontLoader: Cannot load font: \"" + server.baseUrl().toString() + "/nonexist.ttf\"";
|
||||
QTest::ignoreMessage(QtWarningMsg, expectedError.toUtf8());
|
||||
QQmlComponent component(&engine);
|
||||
component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
|
||||
QQuickFontLoader *fontObject = qobject_cast<QQuickFontLoader*>(component.create());
|
||||
|
@ -196,7 +194,7 @@ void tst_qquickfontloader::changeFont()
|
|||
QCOMPARE(statusSpy.count(), 0);
|
||||
QTRY_COMPARE(fontObject->name(), QString("OCRA"));
|
||||
|
||||
ctxt->setContextProperty("font", SERVER_ADDR "/daniel.ttf");
|
||||
ctxt->setContextProperty("font", server.urlString("/daniel.ttf"));
|
||||
QTRY_VERIFY(fontObject->status() == QQuickFontLoader::Loading);
|
||||
QTRY_VERIFY(fontObject->status() == QQuickFontLoader::Ready);
|
||||
QCOMPARE(nameSpy.count(), 1);
|
||||
|
@ -209,7 +207,7 @@ void tst_qquickfontloader::changeFont()
|
|||
QCOMPARE(statusSpy.count(), 2);
|
||||
QTRY_COMPARE(fontObject->name(), QString("OCRA"));
|
||||
|
||||
ctxt->setContextProperty("font", SERVER_ADDR "/daniel.ttf");
|
||||
ctxt->setContextProperty("font", server.urlString("/daniel.ttf"));
|
||||
QTRY_VERIFY(fontObject->status() == QQuickFontLoader::Ready);
|
||||
QCOMPARE(nameSpy.count(), 3);
|
||||
QCOMPARE(statusSpy.count(), 2);
|
||||
|
|
|
@ -8,7 +8,7 @@ Item {
|
|||
GridView {
|
||||
anchors.fill: parent
|
||||
delegate: Image {
|
||||
source: imagePath;
|
||||
source: serverBaseUrl + imagePath;
|
||||
asynchronous: true
|
||||
smooth: true
|
||||
width: 200
|
||||
|
@ -16,28 +16,28 @@ Item {
|
|||
}
|
||||
model: ListModel {
|
||||
ListElement {
|
||||
imagePath: "http://127.0.0.1:14451/big256.png"
|
||||
imagePath: "/big256.png"
|
||||
}
|
||||
ListElement {
|
||||
imagePath: "http://127.0.0.1:14451/big256.png"
|
||||
imagePath: "/big256.png"
|
||||
}
|
||||
ListElement {
|
||||
imagePath: "http://127.0.0.1:14451/big256.png"
|
||||
imagePath: "/big256.png"
|
||||
}
|
||||
ListElement {
|
||||
imagePath: "http://127.0.0.1:14451/colors.png"
|
||||
imagePath: "/colors.png"
|
||||
}
|
||||
ListElement {
|
||||
imagePath: "http://127.0.0.1:14451/colors1.png"
|
||||
imagePath: "/colors1.png"
|
||||
}
|
||||
ListElement {
|
||||
imagePath: "http://127.0.0.1:14451/big.jpeg"
|
||||
imagePath: "/big.jpeg"
|
||||
}
|
||||
ListElement {
|
||||
imagePath: "http://127.0.0.1:14451/heart.png"
|
||||
imagePath: "/heart.png"
|
||||
}
|
||||
ListElement {
|
||||
imagePath: "http://127.0.0.1:14451/green.png"
|
||||
imagePath: "/green.png"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -55,9 +55,6 @@
|
|||
#include "../../shared/testhttpserver.h"
|
||||
#include "../shared/visualtestutil.h"
|
||||
|
||||
#define SERVER_PORT 14451
|
||||
#define SERVER_ADDR "http://127.0.0.1:14451"
|
||||
|
||||
|
||||
using namespace QQuickVisualTestUtil;
|
||||
|
||||
|
@ -150,14 +147,14 @@ void tst_qquickimage::imageSource_data()
|
|||
<< false << true << "<Unknown File>:2:1: QML Image: Cannot open: " + testFileUrl("no-such-file.png").toString();
|
||||
QTest::newRow("local async not found") << testFileUrl("no-such-file-1.png").toString() << 0.0 << 0.0 << false
|
||||
<< true << true << "<Unknown File>:2:1: QML Image: Cannot open: " + testFileUrl("no-such-file-1.png").toString();
|
||||
QTest::newRow("remote") << SERVER_ADDR "/colors.png" << 120.0 << 120.0 << true << false << true << "";
|
||||
QTest::newRow("remote redirected") << SERVER_ADDR "/oldcolors.png" << 120.0 << 120.0 << true << false << false << "";
|
||||
QTest::newRow("remote") << "/colors.png" << 120.0 << 120.0 << true << false << true << "";
|
||||
QTest::newRow("remote redirected") << "/oldcolors.png" << 120.0 << 120.0 << true << false << false << "";
|
||||
if (QImageReader::supportedImageFormats().contains("svg"))
|
||||
QTest::newRow("remote svg") << SERVER_ADDR "/heart.svg" << 550.0 << 500.0 << true << false << false << "";
|
||||
QTest::newRow("remote svg") << "/heart.svg" << 550.0 << 500.0 << true << false << false << "";
|
||||
if (QImageReader::supportedImageFormats().contains("svgz"))
|
||||
QTest::newRow("remote svgz") << SERVER_ADDR "/heart.svgz" << 550.0 << 500.0 << true << false << false << "";
|
||||
QTest::newRow("remote not found") << SERVER_ADDR "/no-such-file.png" << 0.0 << 0.0 << true
|
||||
<< false << true << "<Unknown File>:2:1: QML Image: Error downloading " SERVER_ADDR "/no-such-file.png - server replied: Not found";
|
||||
QTest::newRow("remote svgz") << "/heart.svgz" << 550.0 << 500.0 << true << false << false << "";
|
||||
QTest::newRow("remote not found") << "/no-such-file.png" << 0.0 << 0.0 << true
|
||||
<< false << true << "<Unknown File>:2:1: QML Image: Error downloading {{ServerBaseUrl}}/no-such-file.png - server replied: Not found";
|
||||
|
||||
}
|
||||
|
||||
|
@ -185,9 +182,11 @@ void tst_qquickimage::imageSource()
|
|||
|
||||
TestHTTPServer server;
|
||||
if (remote) {
|
||||
QVERIFY2(server.listen(SERVER_PORT), qPrintable(server.errorString()));
|
||||
QVERIFY2(server.listen(), qPrintable(server.errorString()));
|
||||
server.serveDirectory(dataDirectory());
|
||||
server.addRedirect("oldcolors.png", SERVER_ADDR "/colors.png");
|
||||
server.addRedirect("oldcolors.png", server.urlString("/colors.png"));
|
||||
source = server.urlString(source);
|
||||
error.replace(QStringLiteral("{{ServerBaseUrl}}"), server.baseUrl().toString());
|
||||
}
|
||||
|
||||
if (!error.isEmpty())
|
||||
|
@ -535,9 +534,9 @@ void tst_qquickimage::noLoading()
|
|||
qRegisterMetaType<QQuickImageBase::Status>();
|
||||
|
||||
TestHTTPServer server;
|
||||
QVERIFY2(server.listen(SERVER_PORT), qPrintable(server.errorString()));
|
||||
QVERIFY2(server.listen(), qPrintable(server.errorString()));
|
||||
server.serveDirectory(dataDirectory());
|
||||
server.addRedirect("oldcolors.png", SERVER_ADDR "/colors.png");
|
||||
server.addRedirect("oldcolors.png", server.urlString("/colors.png"));
|
||||
|
||||
QString componentStr = "import QtQuick 2.0\nImage { source: srcImage; cache: true }";
|
||||
QQmlContext *ctxt = engine.rootContext();
|
||||
|
@ -561,7 +560,7 @@ void tst_qquickimage::noLoading()
|
|||
QTRY_COMPARE(statusSpy.count(), 1);
|
||||
|
||||
// Loading remote file
|
||||
ctxt->setContextProperty("srcImage", QString(SERVER_ADDR) + "/rect.png");
|
||||
ctxt->setContextProperty("srcImage", server.url("/rect.png"));
|
||||
QTRY_VERIFY(obj->status() == QQuickImage::Loading);
|
||||
QTRY_VERIFY(obj->progress() == 0.0);
|
||||
QTRY_VERIFY(obj->status() == QQuickImage::Ready);
|
||||
|
@ -573,7 +572,7 @@ void tst_qquickimage::noLoading()
|
|||
// Loading remote file again - should not go through 'Loading' state.
|
||||
progressSpy.clear();
|
||||
ctxt->setContextProperty("srcImage", testFileUrl("green.png"));
|
||||
ctxt->setContextProperty("srcImage", QString(SERVER_ADDR) + "/rect.png");
|
||||
ctxt->setContextProperty("srcImage", server.url("/rect.png"));
|
||||
QTRY_VERIFY(obj->status() == QQuickImage::Ready);
|
||||
QTRY_VERIFY(obj->progress() == 1.0);
|
||||
QTRY_COMPARE(sourceSpy.count(), 4);
|
||||
|
@ -679,9 +678,13 @@ void tst_qquickimage::nullPixmapPaint()
|
|||
window->show();
|
||||
QVERIFY(QTest::qWaitForWindowExposed(window.data()));
|
||||
|
||||
TestHTTPServer server;
|
||||
QVERIFY2(server.listen(), qPrintable(server.errorString()));
|
||||
server.serveDirectory(dataDirectory(), TestHTTPServer::Delay);
|
||||
|
||||
QQuickImage *image = qobject_cast<QQuickImage*>(window->rootObject());
|
||||
QTRY_VERIFY(image != 0);
|
||||
image->setSource(SERVER_ADDR + QString("/no-such-file.png"));
|
||||
image->setSource(server.url("/no-such-file.png"));
|
||||
|
||||
QQmlTestMessageHandler messageHandler;
|
||||
// used to print "QTransform::translate with NaN called"
|
||||
|
@ -693,11 +696,13 @@ void tst_qquickimage::nullPixmapPaint()
|
|||
void tst_qquickimage::imageCrash_QTBUG_22125()
|
||||
{
|
||||
TestHTTPServer server;
|
||||
QVERIFY2(server.listen(SERVER_PORT), qPrintable(server.errorString()));
|
||||
QVERIFY2(server.listen(), qPrintable(server.errorString()));
|
||||
server.serveDirectory(dataDirectory(), TestHTTPServer::Delay);
|
||||
|
||||
{
|
||||
QQuickView view(testFileUrl("qtbug_22125.qml"));
|
||||
QQuickView view;
|
||||
view.rootContext()->setContextProperty(QStringLiteral("serverBaseUrl"), server.baseUrl());
|
||||
view.setSource(testFileUrl("qtbug_22125.qml"));
|
||||
view.show();
|
||||
QVERIFY(QTest::qWaitForWindowExposed(&view));
|
||||
qApp->processEvents();
|
||||
|
@ -762,7 +767,7 @@ void tst_qquickimage::sourceSize()
|
|||
void tst_qquickimage::sourceSizeChanges()
|
||||
{
|
||||
TestHTTPServer server;
|
||||
QVERIFY2(server.listen(14449), qPrintable(server.errorString()));
|
||||
QVERIFY2(server.listen(), qPrintable(server.errorString()));
|
||||
server.serveDirectory(dataDirectory());
|
||||
|
||||
QQmlEngine engine;
|
||||
|
@ -802,19 +807,19 @@ void tst_qquickimage::sourceSizeChanges()
|
|||
QTRY_COMPARE(sourceSizeSpy.count(), 3);
|
||||
|
||||
// Remote
|
||||
ctxt->setContextProperty("srcImage", QUrl("http://127.0.0.1:14449/heart.png"));
|
||||
ctxt->setContextProperty("srcImage", server.url("/heart.png"));
|
||||
QTRY_COMPARE(img->status(), QQuickImage::Ready);
|
||||
QTRY_COMPARE(sourceSizeSpy.count(), 4);
|
||||
|
||||
ctxt->setContextProperty("srcImage", QUrl("http://127.0.0.1:14449/heart.png"));
|
||||
ctxt->setContextProperty("srcImage", server.url("/heart.png"));
|
||||
QTRY_COMPARE(img->status(), QQuickImage::Ready);
|
||||
QTRY_COMPARE(sourceSizeSpy.count(), 4);
|
||||
|
||||
ctxt->setContextProperty("srcImage", QUrl("http://127.0.0.1:14449/heart_copy.png"));
|
||||
ctxt->setContextProperty("srcImage", server.url("/heart_copy.png"));
|
||||
QTRY_COMPARE(img->status(), QQuickImage::Ready);
|
||||
QTRY_COMPARE(sourceSizeSpy.count(), 4);
|
||||
|
||||
ctxt->setContextProperty("srcImage", QUrl("http://127.0.0.1:14449/colors.png"));
|
||||
ctxt->setContextProperty("srcImage", server.url("/colors.png"));
|
||||
QTRY_COMPARE(img->status(), QQuickImage::Ready);
|
||||
QTRY_COMPARE(sourceSizeSpy.count(), 5);
|
||||
|
||||
|
@ -828,7 +833,7 @@ void tst_qquickimage::sourceSizeChanges()
|
|||
void tst_qquickimage::progressAndStatusChanges()
|
||||
{
|
||||
TestHTTPServer server;
|
||||
QVERIFY2(server.listen(14449), qPrintable(server.errorString()));
|
||||
QVERIFY2(server.listen(), qPrintable(server.errorString()));
|
||||
server.serveDirectory(dataDirectory());
|
||||
|
||||
QQmlEngine engine;
|
||||
|
@ -864,7 +869,7 @@ void tst_qquickimage::progressAndStatusChanges()
|
|||
QTRY_COMPARE(statusSpy.count(), 1);
|
||||
|
||||
// Loading remote file
|
||||
ctxt->setContextProperty("srcImage", "http://127.0.0.1:14449/heart.png");
|
||||
ctxt->setContextProperty("srcImage", server.url("/heart.png"));
|
||||
QTRY_VERIFY(obj->status() == QQuickImage::Loading);
|
||||
QTRY_VERIFY(obj->progress() == 0.0);
|
||||
QTRY_VERIFY(obj->status() == QQuickImage::Ready);
|
||||
|
@ -935,10 +940,6 @@ void tst_qquickimage::correctStatus()
|
|||
|
||||
void tst_qquickimage::highdpi()
|
||||
{
|
||||
TestHTTPServer server;
|
||||
QVERIFY2(server.listen(SERVER_PORT), qPrintable(server.errorString()));
|
||||
server.serveDirectory(dataDirectory());
|
||||
|
||||
QString componentStr = "import QtQuick 2.0\nImage { source: srcImage ; }";
|
||||
QQmlComponent component(&engine);
|
||||
component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
|
||||
|
|
|
@ -3,6 +3,7 @@ import QtQuick 2.0
|
|||
Item {
|
||||
id: root
|
||||
property int initialValue: 0
|
||||
property string serverBaseUrl;
|
||||
|
||||
Loader {
|
||||
id: loader
|
||||
|
@ -14,7 +15,7 @@ Item {
|
|||
}
|
||||
|
||||
Component.onCompleted: {
|
||||
loader.setSource("http://127.0.0.1:14458/InitialPropertyValuesComponent.qml", {"canary": 6});
|
||||
loader.setSource(serverBaseUrl + "/InitialPropertyValuesComponent.qml", {"canary": 6});
|
||||
loader.active = true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -41,9 +41,6 @@
|
|||
#include "testhttpserver.h"
|
||||
#include "../../shared/util.h"
|
||||
|
||||
#define SERVER_PORT 14458
|
||||
#define SERVER_ADDR "http://localhost:14458"
|
||||
|
||||
class SlowComponent : public QQmlComponent
|
||||
{
|
||||
Q_OBJECT
|
||||
|
@ -439,11 +436,12 @@ void tst_QQuickLoader::noResize()
|
|||
void tst_QQuickLoader::networkRequestUrl()
|
||||
{
|
||||
TestHTTPServer server;
|
||||
QVERIFY2(server.listen(SERVER_PORT), qPrintable(server.errorString()));
|
||||
QVERIFY2(server.listen(), qPrintable(server.errorString()));
|
||||
server.serveDirectory(dataDirectory());
|
||||
|
||||
QQmlComponent component(&engine);
|
||||
component.setData(QByteArray("import QtQuick 2.0\nLoader { property int signalCount : 0; source: \"" SERVER_ADDR "/Rect120x60.qml\"; onLoaded: signalCount += 1 }"), testFileUrl("../dummy.qml"));
|
||||
const QString qml = "import QtQuick 2.0\nLoader { property int signalCount : 0; source: \"" + server.baseUrl().toString() + "/Rect120x60.qml\"; onLoaded: signalCount += 1 }";
|
||||
component.setData(qml.toUtf8(), testFileUrl("../dummy.qml"));
|
||||
if (component.isError())
|
||||
qDebug() << component.errors();
|
||||
QQuickLoader *loader = qobject_cast<QQuickLoader*>(component.create());
|
||||
|
@ -463,17 +461,16 @@ void tst_QQuickLoader::networkRequestUrl()
|
|||
void tst_QQuickLoader::networkComponent()
|
||||
{
|
||||
TestHTTPServer server;
|
||||
QVERIFY2(server.listen(SERVER_PORT), qPrintable(server.errorString()));
|
||||
QVERIFY2(server.listen(), qPrintable(server.errorString()));
|
||||
server.serveDirectory(dataDirectory(), TestHTTPServer::Delay);
|
||||
|
||||
QQmlComponent component(&engine);
|
||||
component.setData(QByteArray(
|
||||
"import QtQuick 2.0\n"
|
||||
"import \"" SERVER_ADDR "/\" as NW\n"
|
||||
"Item {\n"
|
||||
" Component { id: comp; NW.Rect120x60 {} }\n"
|
||||
" Loader { sourceComponent: comp } }")
|
||||
, dataDirectory());
|
||||
const QString qml = "import QtQuick 2.0\n"
|
||||
"import \"" + server.baseUrl().toString() + "/\" as NW\n"
|
||||
"Item {\n"
|
||||
" Component { id: comp; NW.Rect120x60 {} }\n"
|
||||
" Loader { sourceComponent: comp } }";
|
||||
component.setData(qml.toUtf8(), dataDirectory());
|
||||
QCOMPARE(component.status(), QQmlComponent::Loading);
|
||||
server.sendDelayedItem();
|
||||
QTRY_COMPARE(component.status(), QQmlComponent::Ready);
|
||||
|
@ -496,13 +493,14 @@ void tst_QQuickLoader::networkComponent()
|
|||
void tst_QQuickLoader::failNetworkRequest()
|
||||
{
|
||||
TestHTTPServer server;
|
||||
QVERIFY2(server.listen(SERVER_PORT), qPrintable(server.errorString()));
|
||||
QVERIFY2(server.listen(), qPrintable(server.errorString()));
|
||||
server.serveDirectory(dataDirectory());
|
||||
|
||||
QTest::ignoreMessage(QtWarningMsg, SERVER_ADDR "/IDontExist.qml: File not found");
|
||||
QTest::ignoreMessage(QtWarningMsg, QString(server.baseUrl().toString() + "/IDontExist.qml: File not found").toUtf8());
|
||||
|
||||
QQmlComponent component(&engine);
|
||||
component.setData(QByteArray("import QtQuick 2.0\nLoader { property int did_load: 123; source: \"" SERVER_ADDR "/IDontExist.qml\"; onLoaded: did_load=456 }"), QUrl(QString(SERVER_ADDR "/dummy.qml")));
|
||||
const QString qml = "import QtQuick 2.0\nLoader { property int did_load: 123; source: \"" + server.baseUrl().toString() + "/IDontExist.qml\"; onLoaded: did_load=456 }";
|
||||
component.setData(qml.toUtf8(), server.url("/dummy.qml"));
|
||||
QTRY_COMPARE(component.status(), QQmlComponent::Ready);
|
||||
QQuickLoader *loader = qobject_cast<QQuickLoader*>(component.create());
|
||||
QVERIFY(loader != 0);
|
||||
|
@ -711,15 +709,23 @@ void tst_QQuickLoader::initialPropertyValues()
|
|||
QFETCH(QVariantList, propertyValues);
|
||||
|
||||
TestHTTPServer server;
|
||||
QVERIFY2(server.listen(SERVER_PORT), qPrintable(server.errorString()));
|
||||
QVERIFY2(server.listen(), qPrintable(server.errorString()));
|
||||
server.serveDirectory(dataDirectory());
|
||||
|
||||
foreach (const QString &warning, expectedWarnings)
|
||||
QTest::ignoreMessage(QtWarningMsg, warning.toLatin1().constData());
|
||||
|
||||
QQmlComponent component(&engine, qmlFile);
|
||||
QObject *object = component.create();
|
||||
QObject *object = component.beginCreate(engine.rootContext());
|
||||
QVERIFY(object != 0);
|
||||
|
||||
const int serverBaseUrlPropertyIndex = object->metaObject()->indexOfProperty("serverBaseUrl");
|
||||
if (serverBaseUrlPropertyIndex != -1) {
|
||||
QMetaProperty prop = object->metaObject()->property(serverBaseUrlPropertyIndex);
|
||||
QVERIFY(prop.write(object, server.baseUrl().toString()));
|
||||
}
|
||||
|
||||
component.completeCreate();
|
||||
if (expectedWarnings.isEmpty()) {
|
||||
QQuickLoader *loader = object->findChild<QQuickLoader*>("loader");
|
||||
QTRY_VERIFY(loader->item());
|
||||
|
|
|
@ -108,7 +108,7 @@ void tst_qquickpixmapcache::initTestCase()
|
|||
{
|
||||
QQmlDataTest::initTestCase();
|
||||
|
||||
QVERIFY2(server.listen(14452), qPrintable(server.errorString()));
|
||||
QVERIFY2(server.listen(), qPrintable(server.errorString()));
|
||||
|
||||
// This avoids a race condition/deadlock bug in network config
|
||||
// manager when it is accessed by the HTTP server thread before
|
||||
|
@ -133,8 +133,8 @@ void tst_qquickpixmapcache::single_data()
|
|||
// File URLs are optimized
|
||||
QTest::newRow("local") << testFileUrl("exists.png") << localfile_optimized << true << false;
|
||||
QTest::newRow("local") << testFileUrl("notexists.png") << localfile_optimized << false << false;
|
||||
QTest::newRow("remote") << QUrl("http://127.0.0.1:14452/exists.png") << false << true << false;
|
||||
QTest::newRow("remote") << QUrl("http://127.0.0.1:14452/notexists.png") << false << false << true;
|
||||
QTest::newRow("remote") << server.url("/exists.png") << false << true << false;
|
||||
QTest::newRow("remote") << server.url("/notexists.png") << false << false << true;
|
||||
}
|
||||
|
||||
void tst_qquickpixmapcache::single()
|
||||
|
@ -201,26 +201,26 @@ void tst_qquickpixmapcache::parallel_data()
|
|||
<< -1;
|
||||
|
||||
QTest::newRow("remote")
|
||||
<< QUrl("http://127.0.0.1:14452/exists2.png")
|
||||
<< QUrl("http://127.0.0.1:14452/exists3.png")
|
||||
<< server.url("/exists2.png")
|
||||
<< server.url("/exists3.png")
|
||||
<< 0
|
||||
<< -1;
|
||||
|
||||
QTest::newRow("remoteagain")
|
||||
<< QUrl("http://127.0.0.1:14452/exists2.png")
|
||||
<< QUrl("http://127.0.0.1:14452/exists3.png")
|
||||
<< server.url("/exists2.png")
|
||||
<< server.url("/exists3.png")
|
||||
<< 2
|
||||
<< -1;
|
||||
|
||||
QTest::newRow("remotecopy")
|
||||
<< QUrl("http://127.0.0.1:14452/exists4.png")
|
||||
<< QUrl("http://127.0.0.1:14452/exists4.png")
|
||||
<< server.url("/exists4.png")
|
||||
<< server.url("/exists4.png")
|
||||
<< 0
|
||||
<< -1;
|
||||
|
||||
QTest::newRow("remotecopycancel")
|
||||
<< QUrl("http://127.0.0.1:14452/exists5.png")
|
||||
<< QUrl("http://127.0.0.1:14452/exists5.png")
|
||||
<< server.url("/exists5.png")
|
||||
<< server.url("/exists5.png")
|
||||
<< 0
|
||||
<< 0;
|
||||
}
|
||||
|
@ -332,7 +332,7 @@ void tst_qquickpixmapcache::massive()
|
|||
// QTBUG-12729
|
||||
void tst_qquickpixmapcache::cancelcrash()
|
||||
{
|
||||
QUrl url("http://127.0.0.1:14452/cancelcrash_notexist.png");
|
||||
QUrl url = server.url("/cancelcrash_notexist.png");
|
||||
for (int ii = 0; ii < 1000; ++ii) {
|
||||
QQuickPixmap pix(&engine, url);
|
||||
}
|
||||
|
@ -370,12 +370,10 @@ void tst_qquickpixmapcache::shrinkcache()
|
|||
|
||||
#ifndef QT_NO_CONCURRENT
|
||||
|
||||
void createNetworkServer()
|
||||
void createNetworkServer(TestHTTPServer *server)
|
||||
{
|
||||
QEventLoop eventLoop;
|
||||
TestHTTPServer server;
|
||||
QVERIFY2(server.listen(14453), qPrintable(server.errorString()));
|
||||
server.serveDirectory(QQmlDataTest::instance()->testFile("http"));
|
||||
server->serveDirectory(QQmlDataTest::instance()->testFile("http"));
|
||||
QTimer::singleShot(100, &eventLoop, SLOT(quit()));
|
||||
eventLoop.exec();
|
||||
}
|
||||
|
@ -384,11 +382,13 @@ void createNetworkServer()
|
|||
// QT-3957
|
||||
void tst_qquickpixmapcache::networkCrash()
|
||||
{
|
||||
QFuture<void> future = QtConcurrent::run(createNetworkServer);
|
||||
TestHTTPServer server;
|
||||
QVERIFY2(server.listen(), qPrintable(server.errorString()));
|
||||
QFuture<void> future = QtConcurrent::run(createNetworkServer, &server);
|
||||
QQmlEngine engine;
|
||||
for (int ii = 0; ii < 100 ; ++ii) {
|
||||
QQuickPixmap* pixmap = new QQuickPixmap;
|
||||
pixmap->load(&engine, QUrl(QString("http://127.0.0.1:14453/exists.png")));
|
||||
pixmap->load(&engine, server.url("/exists.png"));
|
||||
QTest::qSleep(1);
|
||||
pixmap->clear();
|
||||
delete pixmap;
|
||||
|
@ -403,14 +403,14 @@ void tst_qquickpixmapcache::networkCrash()
|
|||
void tst_qquickpixmapcache::lockingCrash()
|
||||
{
|
||||
TestHTTPServer server;
|
||||
QVERIFY2(server.listen(14453), qPrintable(server.errorString()));
|
||||
QVERIFY2(server.listen(), qPrintable(server.errorString()));
|
||||
server.serveDirectory(testFile("http"), TestHTTPServer::Delay);
|
||||
|
||||
{
|
||||
QQuickPixmap* p = new QQuickPixmap;
|
||||
{
|
||||
QQmlEngine e;
|
||||
p->load(&e, QUrl(QString("http://127.0.0.1:14453/exists6.png")));
|
||||
p->load(&e, server.url("/exists6.png"));
|
||||
}
|
||||
p->clear();
|
||||
QVERIFY(p->isNull());
|
||||
|
|
|
@ -2,5 +2,5 @@ import QtQuick 2.0
|
|||
|
||||
Text {
|
||||
textFormat: Text.RichText
|
||||
text: "<img src='http://127.0.0.1:14459/exists.png'>"
|
||||
text: "<img src='" + serverBaseUrl + "/exists.png'>"
|
||||
}
|
||||
|
|
|
@ -2,5 +2,5 @@ import QtQuick 2.0
|
|||
|
||||
Text {
|
||||
textFormat: Text.RichText
|
||||
text: "<img src='http://127.0.0.1:14459/notexists.png'>"
|
||||
text: "<img src='" + serverBaseUrl + "/notexists.png'>"
|
||||
}
|
||||
|
|
|
@ -3,5 +3,5 @@ import QtQuick 2.0
|
|||
Text {
|
||||
textFormat: Text.RichText
|
||||
text: "<img src='exists.png'>"
|
||||
baseUrl: "http://127.0.0.1:14459/text.html"
|
||||
baseUrl: serverBaseUrl + "/text.html"
|
||||
}
|
||||
|
|
|
@ -50,9 +50,6 @@
|
|||
|
||||
DEFINE_BOOL_CONFIG_OPTION(qmlDisableDistanceField, QML_DISABLE_DISTANCEFIELD)
|
||||
|
||||
#define SERVER_PORT 14459
|
||||
#define SERVER_ADDR "http://127.0.0.1:14459"
|
||||
|
||||
Q_DECLARE_METATYPE(QQuickText::TextFormat)
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
@ -2051,7 +2048,7 @@ void tst_qquicktext::embeddedImages_data()
|
|||
QTest::newRow("local") << testFileUrl("embeddedImagesLocalRelative.qml") << "";
|
||||
QTest::newRow("remote") << testFileUrl("embeddedImagesRemote.qml") << "";
|
||||
QTest::newRow("remote-error") << testFileUrl("embeddedImagesRemoteError.qml")
|
||||
<< testFileUrl("embeddedImagesRemoteError.qml").toString()+":3:1: QML Text: Error downloading " SERVER_ADDR "/notexists.png - server replied: Not found";
|
||||
<< testFileUrl("embeddedImagesRemoteError.qml").toString()+":3:1: QML Text: Error downloading {{ServerBaseUrl}}/notexists.png - server replied: Not found";
|
||||
QTest::newRow("remote-relative") << testFileUrl("embeddedImagesRemoteRelative.qml") << "";
|
||||
}
|
||||
|
||||
|
@ -2071,13 +2068,16 @@ void tst_qquicktext::embeddedImages()
|
|||
#endif
|
||||
|
||||
TestHTTPServer server;
|
||||
QVERIFY2(server.listen(SERVER_PORT), qPrintable(server.errorString()));
|
||||
QVERIFY2(server.listen(), qPrintable(server.errorString()));
|
||||
server.serveDirectory(testFile("http"));
|
||||
error.replace(QStringLiteral("{{ServerBaseUrl}}"), server.baseUrl().toString());
|
||||
|
||||
if (!error.isEmpty())
|
||||
QTest::ignoreMessage(QtWarningMsg, error.toLatin1());
|
||||
|
||||
QQuickView *view = new QQuickView(qmlfile);
|
||||
QQuickView *view = new QQuickView;
|
||||
view->rootContext()->setContextProperty(QStringLiteral("serverBaseUrl"), server.baseUrl());
|
||||
view->setSource(qmlfile);
|
||||
view->show();
|
||||
view->requestActivate();
|
||||
QVERIFY(QTest::qWaitForWindowActive(view));
|
||||
|
@ -2787,22 +2787,33 @@ void tst_qquicktext::imgTagsBaseUrl_data()
|
|||
<< 181.;
|
||||
|
||||
QTest::newRow("absolute remote")
|
||||
<< QUrl(SERVER_ADDR "/images/heart200.png")
|
||||
<< QUrl("http://testserver/images/heart200.png")
|
||||
<< QUrl()
|
||||
<< QUrl()
|
||||
<< 181.;
|
||||
QTest::newRow("relative remote base 1")
|
||||
<< QUrl("images/heart200.png")
|
||||
<< QUrl(SERVER_ADDR "/")
|
||||
<< QUrl("http://testserver/")
|
||||
<< testFileUrl("nonexistant/app.qml")
|
||||
<< 181.;
|
||||
QTest::newRow("relative remote base 2")
|
||||
<< QUrl("heart200.png")
|
||||
<< QUrl(SERVER_ADDR "/images/")
|
||||
<< QUrl("http://testserver/images/")
|
||||
<< testFileUrl("nonexistant/app.qml")
|
||||
<< 181.;
|
||||
}
|
||||
|
||||
static QUrl substituteTestServerUrl(const QUrl &serverUrl, const QUrl &testUrl)
|
||||
{
|
||||
QUrl result = testUrl;
|
||||
if (result.host() == QStringLiteral("testserver")) {
|
||||
result.setScheme(serverUrl.scheme());
|
||||
result.setHost(serverUrl.host());
|
||||
result.setPort(serverUrl.port());
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
void tst_qquicktext::imgTagsBaseUrl()
|
||||
{
|
||||
QFETCH(QUrl, src);
|
||||
|
@ -2811,9 +2822,13 @@ void tst_qquicktext::imgTagsBaseUrl()
|
|||
QFETCH(qreal, imgHeight);
|
||||
|
||||
TestHTTPServer server;
|
||||
QVERIFY2(server.listen(SERVER_PORT), qPrintable(server.errorString()));
|
||||
QVERIFY2(server.listen(), qPrintable(server.errorString()));
|
||||
server.serveDirectory(testFile(""));
|
||||
|
||||
src = substituteTestServerUrl(server.baseUrl(), src);
|
||||
baseUrl = substituteTestServerUrl(server.baseUrl(), baseUrl);
|
||||
contextUrl = substituteTestServerUrl(server.baseUrl(), contextUrl);
|
||||
|
||||
QByteArray baseUrlFragment;
|
||||
if (!baseUrl.isEmpty())
|
||||
baseUrlFragment = "; baseUrl: \"" + baseUrl.toEncoded() + "\"";
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
import QtQuick 2.0
|
||||
|
||||
TextEdit {
|
||||
property string serverBaseUrl;
|
||||
textFormat: TextEdit.RichText
|
||||
text: "<img src='http://127.0.0.1:42332/exists.png'>"
|
||||
text: "<img src='" + serverBaseUrl + "/exists.png'>"
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
import QtQuick 2.0
|
||||
|
||||
TextEdit {
|
||||
property string serverBaseUrl;
|
||||
textFormat: TextEdit.RichText
|
||||
text: "<img src='http://127.0.0.1:42332/notexists.png'>"
|
||||
text: "<img src='" + serverBaseUrl + "/notexists.png'>"
|
||||
}
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
import QtQuick 2.0
|
||||
|
||||
TextEdit {
|
||||
property string serverBaseUrl;
|
||||
textFormat: TextEdit.RichText
|
||||
text: "<img src='exists.png'>"
|
||||
baseUrl: "http://127.0.0.1:42332/text.html"
|
||||
baseUrl: serverBaseUrl + "/text.html"
|
||||
}
|
||||
|
|
|
@ -62,9 +62,6 @@
|
|||
#include <Carbon/Carbon.h>
|
||||
#endif
|
||||
|
||||
#define SERVER_PORT 42332
|
||||
#define SERVER_ADDR "http://localhost:42332"
|
||||
|
||||
Q_DECLARE_METATYPE(QQuickTextEdit::SelectionMode)
|
||||
Q_DECLARE_METATYPE(Qt::Key)
|
||||
DEFINE_BOOL_CONFIG_OPTION(qmlDisableDistanceField, QML_DISABLE_DISTANCEFIELD)
|
||||
|
@ -2602,12 +2599,12 @@ void tst_qquicktextedit::cursorDelegate()
|
|||
void tst_qquicktextedit::remoteCursorDelegate()
|
||||
{
|
||||
TestHTTPServer server;
|
||||
QVERIFY2(server.listen(SERVER_PORT), qPrintable(server.errorString()));
|
||||
QVERIFY2(server.listen(), qPrintable(server.errorString()));
|
||||
server.serveDirectory(dataDirectory(), TestHTTPServer::Delay);
|
||||
|
||||
QQuickView view;
|
||||
|
||||
QQmlComponent component(view.engine(), QUrl(SERVER_ADDR "/RemoteCursor.qml"));
|
||||
QQmlComponent component(view.engine(), server.url("/RemoteCursor.qml"));
|
||||
|
||||
view.rootContext()->setContextProperty("contextDelegate", &component);
|
||||
view.setSource(testFileUrl("cursorTestRemote.qml"));
|
||||
|
@ -2730,8 +2727,8 @@ void tst_qquicktextedit::delegateLoading_data()
|
|||
|
||||
// import installed
|
||||
QTest::newRow("pass") << "cursorHttpTestPass.qml" << "";
|
||||
QTest::newRow("fail1") << "cursorHttpTestFail1.qml" << "http://localhost:42332/FailItem.qml: Remote host closed the connection";
|
||||
QTest::newRow("fail2") << "cursorHttpTestFail2.qml" << "http://localhost:42332/ErrItem.qml:4:5: Fungus is not a type";
|
||||
QTest::newRow("fail1") << "cursorHttpTestFail1.qml" << "{{ServerBaseUrl}}/FailItem.qml: Remote host closed the connection";
|
||||
QTest::newRow("fail2") << "cursorHttpTestFail2.qml" << "{{ServerBaseUrl}}/ErrItem.qml:4:5: Fungus is not a type";
|
||||
}
|
||||
|
||||
void tst_qquicktextedit::delegateLoading()
|
||||
|
@ -2740,12 +2737,14 @@ void tst_qquicktextedit::delegateLoading()
|
|||
QFETCH(QString, error);
|
||||
|
||||
TestHTTPServer server;
|
||||
QVERIFY2(server.listen(SERVER_PORT), qPrintable(server.errorString()));
|
||||
QVERIFY2(server.listen(), qPrintable(server.errorString()));
|
||||
server.serveDirectory(testFile("httpfail"), TestHTTPServer::Disconnect);
|
||||
server.serveDirectory(testFile("httpslow"), TestHTTPServer::Delay);
|
||||
server.serveDirectory(testFile("http"));
|
||||
|
||||
QQuickView view(QUrl(QLatin1String(SERVER_ADDR "/") + qmlfile));
|
||||
error.replace(QStringLiteral("{{ServerBaseUrl}}"), server.baseUrl().toString());
|
||||
|
||||
QQuickView view(server.url(qmlfile));
|
||||
view.show();
|
||||
view.requestActivate();
|
||||
|
||||
|
@ -5272,8 +5271,8 @@ void tst_qquicktextedit::embeddedImages_data()
|
|||
QTest::newRow("local") << testFileUrl("embeddedImagesLocalRelative.qml") << "";
|
||||
QTest::newRow("remote") << testFileUrl("embeddedImagesRemote.qml") << "";
|
||||
QTest::newRow("remote-error") << testFileUrl("embeddedImagesRemoteError.qml")
|
||||
<< testFileUrl("embeddedImagesRemoteError.qml").toString()+":3:1: QML TextEdit: Error downloading http://127.0.0.1:42332/notexists.png - server replied: Not found";
|
||||
QTest::newRow("remote") << testFileUrl("embeddedImagesRemoteRelative.qml") << "";
|
||||
<< testFileUrl("embeddedImagesRemoteError.qml").toString()+":3:1: QML TextEdit: Error downloading {{ServerBaseUrl}}/notexists.png - server replied: Not found";
|
||||
QTest::newRow("remote-relative") << testFileUrl("embeddedImagesRemoteRelative.qml") << "";
|
||||
}
|
||||
|
||||
void tst_qquicktextedit::embeddedImages()
|
||||
|
@ -5282,16 +5281,26 @@ void tst_qquicktextedit::embeddedImages()
|
|||
QFETCH(QString, error);
|
||||
|
||||
TestHTTPServer server;
|
||||
QVERIFY2(server.listen(SERVER_PORT), qPrintable(server.errorString()));
|
||||
QVERIFY2(server.listen(), qPrintable(server.errorString()));
|
||||
server.serveDirectory(testFile("http"));
|
||||
|
||||
error.replace(QStringLiteral("{{ServerBaseUrl}}"), server.baseUrl().toString());
|
||||
|
||||
if (!error.isEmpty())
|
||||
QTest::ignoreMessage(QtWarningMsg, error.toLatin1());
|
||||
|
||||
QQmlComponent textComponent(&engine, qmlfile);
|
||||
QQuickTextEdit *textObject = qobject_cast<QQuickTextEdit*>(textComponent.create());
|
||||
|
||||
QQuickTextEdit *textObject = qobject_cast<QQuickTextEdit*>(textComponent.beginCreate(engine.rootContext()));
|
||||
QVERIFY(textObject != 0);
|
||||
|
||||
const int baseUrlPropertyIndex = textObject->metaObject()->indexOfProperty("serverBaseUrl");
|
||||
if (baseUrlPropertyIndex != -1) {
|
||||
QMetaProperty prop = textObject->metaObject()->property(baseUrlPropertyIndex);
|
||||
QVERIFY(prop.write(textObject, server.baseUrl().toString()));
|
||||
}
|
||||
|
||||
textComponent.completeCreate();
|
||||
|
||||
QTRY_COMPARE(QQuickTextEditPrivate::get(textObject)->document->resourcesLoading(), 0);
|
||||
|
||||
QPixmap pm(testFile("http/exists.png"));
|
||||
|
|
|
@ -59,9 +59,6 @@
|
|||
#include "../../shared/platformquirks.h"
|
||||
#include "../../shared/platforminputcontext.h"
|
||||
|
||||
#define SERVER_PORT 14460
|
||||
#define SERVER_ADDR "http://localhost:14460"
|
||||
|
||||
Q_DECLARE_METATYPE(QQuickTextInput::SelectionMode)
|
||||
Q_DECLARE_METATYPE(QQuickTextInput::EchoMode)
|
||||
Q_DECLARE_METATYPE(Qt::Key)
|
||||
|
@ -2861,12 +2858,12 @@ void tst_qquicktextinput::cursorDelegate()
|
|||
void tst_qquicktextinput::remoteCursorDelegate()
|
||||
{
|
||||
TestHTTPServer server;
|
||||
QVERIFY2(server.listen(SERVER_PORT), qPrintable(server.errorString()));
|
||||
QVERIFY2(server.listen(), qPrintable(server.errorString()));
|
||||
server.serveDirectory(dataDirectory(), TestHTTPServer::Delay);
|
||||
|
||||
QQuickView view;
|
||||
|
||||
QQmlComponent component(view.engine(), QUrl(SERVER_ADDR "/RemoteCursor.qml"));
|
||||
QQmlComponent component(view.engine(), server.url("/RemoteCursor.qml"));
|
||||
|
||||
view.rootContext()->setContextProperty("contextDelegate", &component);
|
||||
view.setSource(testFileUrl("cursorTestRemote.qml"));
|
||||
|
|
|
@ -87,9 +87,28 @@ TestHTTPServer::TestHTTPServer()
|
|||
|
||||
}
|
||||
|
||||
bool TestHTTPServer::listen(quint16 port)
|
||||
bool TestHTTPServer::listen()
|
||||
{
|
||||
return server.listen(QHostAddress::LocalHost, port);
|
||||
return server.listen(QHostAddress::LocalHost, 0);
|
||||
}
|
||||
|
||||
QUrl TestHTTPServer::baseUrl() const
|
||||
{
|
||||
QUrl url;
|
||||
url.setScheme(QStringLiteral("http"));
|
||||
url.setHost(QStringLiteral("127.0.0.1"));
|
||||
url.setPort(server.serverPort());
|
||||
return url;
|
||||
}
|
||||
|
||||
QUrl TestHTTPServer::url(const QString &documentPath) const
|
||||
{
|
||||
return baseUrl().resolved(documentPath);
|
||||
}
|
||||
|
||||
QString TestHTTPServer::urlString(const QString &documentPath) const
|
||||
{
|
||||
return url(documentPath).toString();
|
||||
}
|
||||
|
||||
QString TestHTTPServer::errorString() const
|
||||
|
@ -117,6 +136,11 @@ void TestHTTPServer::addRedirect(const QString &filename, const QString &redirec
|
|||
redirects.insert(filename, redirectName);
|
||||
}
|
||||
|
||||
void TestHTTPServer::registerFileNameForContentSubstitution(const QString &fileName)
|
||||
{
|
||||
contentSubstitutedFileNames.insert(fileName);
|
||||
}
|
||||
|
||||
bool TestHTTPServer::wait(const QUrl &expect, const QUrl &reply, const QUrl &body)
|
||||
{
|
||||
m_state = AwaitingHeader;
|
||||
|
@ -135,6 +159,8 @@ bool TestHTTPServer::wait(const QUrl &expect, const QUrl &reply, const QUrl &bod
|
|||
bodyData = bodyFile.readAll();
|
||||
}
|
||||
|
||||
const QByteArray serverHostUrl = QByteArrayLiteral("127.0.0.1:") + QByteArray::number(server.serverPort());
|
||||
|
||||
QByteArray line;
|
||||
bool headers_done = false;
|
||||
while (!(line = expectFile.readLine()).isEmpty()) {
|
||||
|
@ -143,10 +169,12 @@ bool TestHTTPServer::wait(const QUrl &expect, const QUrl &reply, const QUrl &bod
|
|||
headers_done = true;
|
||||
continue;
|
||||
}
|
||||
if (headers_done)
|
||||
if (headers_done) {
|
||||
waitData.body.append(line);
|
||||
else
|
||||
} else {
|
||||
line.replace("{{ServerHostUrl}}", serverHostUrl);
|
||||
waitData.headers.append(line);
|
||||
}
|
||||
}
|
||||
/*
|
||||
while (waitData.endsWith('\n'))
|
||||
|
@ -277,6 +305,9 @@ bool TestHTTPServer::reply(QTcpSocket *socket, const QByteArray &fileName)
|
|||
return true;
|
||||
|
||||
QByteArray data = file.readAll();
|
||||
if (contentSubstitutedFileNames.contains("/" + fileName)) {
|
||||
data.replace(QByteArrayLiteral("{{ServerBaseUrl}}"), baseUrl().toString().toUtf8());
|
||||
}
|
||||
|
||||
QByteArray response = "HTTP/1.0 200 OK\r\nContent-type: text/html; charset=UTF-8\r\nContent-length: ";
|
||||
response += QByteArray::number(data.count());
|
||||
|
|
|
@ -45,7 +45,10 @@ class TestHTTPServer : public QObject
|
|||
public:
|
||||
TestHTTPServer();
|
||||
|
||||
bool listen(quint16 port);
|
||||
bool listen();
|
||||
QUrl baseUrl() const;
|
||||
QUrl url(const QString &documentPath) const;
|
||||
QString urlString(const QString &documentPath) const;
|
||||
QString errorString() const;
|
||||
|
||||
enum Mode { Normal, Delay, Disconnect };
|
||||
|
@ -57,6 +60,8 @@ public:
|
|||
void addAlias(const QString &filename, const QString &aliasName);
|
||||
void addRedirect(const QString &filename, const QString &redirectName);
|
||||
|
||||
void registerFileNameForContentSubstitution(const QString &fileName);
|
||||
|
||||
// In Delay mode, each item needs one call to this function to be sent
|
||||
void sendDelayedItem();
|
||||
|
||||
|
@ -79,6 +84,7 @@ private:
|
|||
QList<QPair<QString, Mode> > dirs;
|
||||
QHash<QTcpSocket *, QByteArray> dataCache;
|
||||
QList<QPair<QTcpSocket *, QByteArray> > toSend;
|
||||
QSet<QString> contentSubstitutedFileNames;
|
||||
|
||||
struct WaitData {
|
||||
QList <QByteArray>headers;
|
||||
|
|
|
@ -45,15 +45,14 @@ printProperty ()
|
|||
|
||||
# printEnvVar(): prints a key-value pair from given environment variable name.
|
||||
# key is printed as "Env_<varname>".
|
||||
# If the variable is undefined, value is printed as UNDEFINED.
|
||||
# If the variable is undefined, nothing is printed.
|
||||
# Arguments: $1: varname
|
||||
|
||||
printEnvVar ()
|
||||
{
|
||||
key=Env_$1
|
||||
val=`eval 'echo $'$1`
|
||||
[ -z "$val" ] && val='[undefined]'
|
||||
echo $key: $val
|
||||
[ -n "$val" ] && echo $key: $val
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -43,12 +43,11 @@
|
|||
// Timeout values:
|
||||
|
||||
// A valid screen grab requires the scene to not change
|
||||
// for SCENE_STABLE_TIME ms (default 500)
|
||||
#define SCENE_STABLE_TIME 500
|
||||
// for SCENE_STABLE_TIME ms
|
||||
#define SCENE_STABLE_TIME 200
|
||||
|
||||
// Give up after SCENE_TIMEOUT ms
|
||||
#define SCENE_TIMEOUT 16000
|
||||
|
||||
#define SCENE_TIMEOUT 6000
|
||||
|
||||
//#define GRABBERDEBUG
|
||||
|
||||
|
@ -58,30 +57,44 @@ class GrabbingView : public QQuickView
|
|||
|
||||
public:
|
||||
GrabbingView(const QString &outputFile)
|
||||
: ofile(outputFile), frames(0), isGrabbing(false)
|
||||
: ofile(outputFile), grabNo(0), isGrabbing(false), initDone(false)
|
||||
{
|
||||
connect(this, SIGNAL(afterRendering()), SLOT(renderingDone()));
|
||||
grabTimer = new QTimer(this);
|
||||
grabTimer->setSingleShot(true);
|
||||
grabTimer->setInterval(SCENE_STABLE_TIME);
|
||||
connect(grabTimer, SIGNAL(timeout()), SLOT(grab()));
|
||||
|
||||
connect(this, SIGNAL(afterRendering()), SLOT(startGrabbing()));
|
||||
|
||||
QTimer::singleShot(SCENE_TIMEOUT, this, SLOT(timedOut()));
|
||||
stableSceneTimer.setSingleShot(true);
|
||||
connect(&stableSceneTimer, SIGNAL(timeout()), SLOT(sceneStabilized()));
|
||||
}
|
||||
|
||||
private slots:
|
||||
void renderingDone()
|
||||
void startGrabbing()
|
||||
{
|
||||
if (!initDone) {
|
||||
initDone = true;
|
||||
grabTimer->start();
|
||||
}
|
||||
}
|
||||
|
||||
void grab()
|
||||
{
|
||||
if (isGrabbing)
|
||||
return;
|
||||
isGrabbing = true;
|
||||
frames++;
|
||||
grabNo++;
|
||||
#ifdef GRABBERDEBUG
|
||||
printf("...frame %i\n", frames);
|
||||
printf("grab no. %i\n", grabNo);
|
||||
#endif
|
||||
QImage img = grabWindow();
|
||||
//qDebug() << "Rendering done, grab is" << !img.isNull() << "timer valid:" << stableSceneTimer.isActive() << "same as last:" << (img == lastGrab);
|
||||
if (!img.isNull() && img != lastGrab) {
|
||||
if (!img.isNull() && img == lastGrab) {
|
||||
sceneStabilized();
|
||||
} else {
|
||||
lastGrab = img;
|
||||
stableSceneTimer.start(SCENE_STABLE_TIME);
|
||||
grabTimer->start();
|
||||
}
|
||||
|
||||
isGrabbing = false;
|
||||
}
|
||||
|
||||
|
@ -104,7 +117,6 @@ private slots:
|
|||
return;
|
||||
}
|
||||
}
|
||||
|
||||
QGuiApplication::exit(0);
|
||||
#ifdef GRABBERDEBUG
|
||||
printf("...sceneStabilized OUT\n");
|
||||
|
@ -113,16 +125,17 @@ private slots:
|
|||
|
||||
void timedOut()
|
||||
{
|
||||
qWarning() << "Error: timed out waiting for scene to stabilize." << frames << "frame(s) received. Last grab was" << (lastGrab.isNull() ? "invalid." : "valid.");
|
||||
qWarning() << "Error: timed out waiting for scene to stabilize." << grabNo << "grab(s) done. Last grab was" << (lastGrab.isNull() ? "invalid." : "valid.");
|
||||
QGuiApplication::exit(3);
|
||||
}
|
||||
|
||||
private:
|
||||
QImage lastGrab;
|
||||
QTimer stableSceneTimer;
|
||||
QTimer *grabTimer;
|
||||
QString ofile;
|
||||
int frames;
|
||||
int grabNo;
|
||||
bool isGrabbing;
|
||||
bool initDone;
|
||||
};
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue