aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/imports/dialogs/plugin.cpp3
-rw-r--r--src/qml/debugger/qv8debugservice.cpp8
-rw-r--r--src/qml/debugger/qv8debugservice_p.h3
-rw-r--r--src/qml/jsapi/qjsvalueiterator.h6
-rw-r--r--src/qml/qml/qqmlcompiler.cpp4
-rw-r--r--src/qml/qml/qqmlengine.cpp3
-rw-r--r--src/qml/qml/qqmlimport.cpp54
-rw-r--r--src/quick/items/qquickitem.cpp6
-rw-r--r--src/quick/items/qquickitemsmodule.cpp5
-rw-r--r--src/quick/items/qquickmousearea.cpp6
-rw-r--r--src/quick/items/qquickshadereffectsource.cpp4
-rw-r--r--src/quick/scenegraph/qsgadaptationlayer.cpp10
-rw-r--r--src/quick/scenegraph/qsgadaptationlayer_p.h2
-rw-r--r--src/quick/scenegraph/qsgdefaultdistancefieldglyphcache.cpp37
-rw-r--r--src/quick/scenegraph/qsgdefaultdistancefieldglyphcache_p.h4
-rw-r--r--src/quick/scenegraph/qsgdefaultglyphnode_p.cpp81
-rw-r--r--src/quick/scenegraph/qsgdefaultglyphnode_p_p.h6
-rw-r--r--src/quick/scenegraph/qsgshareddistancefieldglyphcache.cpp16
-rw-r--r--src/quick/scenegraph/qsgshareddistancefieldglyphcache_p.h2
-rw-r--r--tests/auto/qml/debugger/qqmldebugjs/data/quit.qml53
-rw-r--r--tests/auto/qml/debugger/qqmldebugjs/tst_qqmldebugjs.cpp25
-rw-r--r--tests/auto/qml/debugger/shared/debugutil.cpp10
-rw-r--r--tests/auto/qml/debugger/shared/debugutil_p.h3
-rw-r--r--tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp1
-rw-r--r--tests/auto/quick/qquickflickable/tst_qquickflickable.cpp51
-rw-r--r--tests/auto/quick/qquickgridview/tst_qquickgridview.cpp2
-rw-r--r--tests/auto/quick/qquickitem/tst_qquickitem.cpp3
-rw-r--r--tests/auto/quick/qquickitemlayer/data/SourceRect.qml4
-rw-r--r--tests/auto/quick/qquicklistview/tst_qquicklistview.cpp6
-rw-r--r--tests/auto/quick/qquickmousearea/qquickmousearea.pro2
-rw-r--r--tests/auto/quick/qquickmousearea/tst_qquickmousearea.cpp796
-rw-r--r--tests/auto/quick/qquickpathview/tst_qquickpathview.cpp5
-rw-r--r--tests/auto/quick/qquickpositioners/tst_qquickpositioners.cpp6
-rw-r--r--tests/auto/quick/qquickwindow/tst_qquickwindow.cpp31
-rw-r--r--tests/auto/quick/rendernode/tst_rendernode.cpp41
-rw-r--r--tests/auto/quick/shared/viewtestutil.cpp28
-rw-r--r--tests/auto/quick/shared/viewtestutil.h3
37 files changed, 771 insertions, 559 deletions
diff --git a/src/imports/dialogs/plugin.cpp b/src/imports/dialogs/plugin.cpp
index eab273ed1c..249152c48c 100644
--- a/src/imports/dialogs/plugin.cpp
+++ b/src/imports/dialogs/plugin.cpp
@@ -77,9 +77,8 @@ class QtQuick2DialogsPlugin : public QQmlExtensionPlugin
public:
QtQuick2DialogsPlugin() : QQmlExtensionPlugin() { }
- virtual void initializeEngine(QQmlEngine *engine, const char *uri) {
+ virtual void initializeEngine(QQmlEngine *engine, const char * /*uri*/) {
//qDebug() << Q_FUNC_INFO << uri << m_decorationComponentUrl;
- Q_UNUSED(uri);
QQuickAbstractDialog::m_decorationComponent =
new QQmlComponent(engine, m_decorationComponentUrl, QQmlComponent::Asynchronous);
}
diff --git a/src/qml/debugger/qv8debugservice.cpp b/src/qml/debugger/qv8debugservice.cpp
index eeab21d6ab..2195dad089 100644
--- a/src/qml/debugger/qv8debugservice.cpp
+++ b/src/qml/debugger/qv8debugservice.cpp
@@ -146,12 +146,18 @@ QV8DebugService *QV8DebugService::instance()
return v8ServiceInstance();
}
-void QV8DebugService::initialize(const QV8Engine *engine)
+void QV8DebugService::addEngine(const QV8Engine *engine)
{
// just make sure that the service is properly registered
v8ServiceInstance()->setEngine(engine);
}
+void QV8DebugService::removeEngine(const QV8Engine *engine)
+{
+ if (v8ServiceInstance()->d_func()->engine == engine)
+ v8ServiceInstance()->setEngine(0);
+}
+
void QV8DebugService::setEngine(const QV8Engine *engine)
{
Q_D(QV8DebugService);
diff --git a/src/qml/debugger/qv8debugservice_p.h b/src/qml/debugger/qv8debugservice_p.h
index e6f05a2397..75fd69290c 100644
--- a/src/qml/debugger/qv8debugservice_p.h
+++ b/src/qml/debugger/qv8debugservice_p.h
@@ -75,7 +75,8 @@ public:
~QV8DebugService();
static QV8DebugService *instance();
- static void initialize(const QV8Engine *engine);
+ static void addEngine(const QV8Engine *engine);
+ static void removeEngine(const QV8Engine *engine);
void debugMessageHandler(const QString &message);
diff --git a/src/qml/jsapi/qjsvalueiterator.h b/src/qml/jsapi/qjsvalueiterator.h
index e204558e90..9bbcc7bc3e 100644
--- a/src/qml/jsapi/qjsvalueiterator.h
+++ b/src/qml/jsapi/qjsvalueiterator.h
@@ -39,8 +39,8 @@
**
****************************************************************************/
-#ifndef QSCRIPTVALUEITERATOR_H
-#define QSCRIPTVALUEITERATOR_H
+#ifndef QJSVALUEITERATOR_H
+#define QJSVALUEITERATOR_H
#include <QtQml/qjsvalue.h>
#include <QtQml/qtqmlglobal.h>
@@ -75,4 +75,4 @@ private:
QT_END_NAMESPACE
-#endif // QSCRIPTVALUEITERATOR_H
+#endif // QJSVALUEITERATOR_H
diff --git a/src/qml/qml/qqmlcompiler.cpp b/src/qml/qml/qqmlcompiler.cpp
index ddefffe8e2..6bc9128730 100644
--- a/src/qml/qml/qqmlcompiler.cpp
+++ b/src/qml/qml/qqmlcompiler.cpp
@@ -1747,7 +1747,9 @@ bool QQmlCompiler::buildProperty(QQmlScript::Property *prop,
if (d == 0 && notInRevision) {
const QList<QQmlTypeData::TypeReference> &resolvedTypes = unit->resolvedTypes();
- const QQmlTypeData::TypeReference &type = resolvedTypes.at(obj->type);
+ QQmlTypeData::TypeReference type;
+ if (obj->type != -1)
+ type = resolvedTypes.at(obj->type);
if (type.type) {
COMPILE_EXCEPTION(prop, tr("\"%1.%2\" is not available in %3 %4.%5.").arg(elementName(obj)).arg(prop->name().toString()).arg(type.type->module()).arg(type.majorVersion).arg(type.minorVersion));
} else {
diff --git a/src/qml/qml/qqmlengine.cpp b/src/qml/qml/qqmlengine.cpp
index 5c59cc3383..39c3399917 100644
--- a/src/qml/qml/qqmlengine.cpp
+++ b/src/qml/qml/qqmlengine.cpp
@@ -757,7 +757,7 @@ void QQmlEnginePrivate::init()
QQmlEngineDebugService::isDebuggingEnabled()) {
isDebugging = true;
QQmlEngineDebugService::instance()->addEngine(q);
- QV8DebugService::initialize(v8engine());
+ QV8DebugService::addEngine(v8engine());
QV8ProfilerService::initialize();
QQmlProfilerService::initialize();
QDebugMessageService::instance();
@@ -846,6 +846,7 @@ QQmlEngine::~QQmlEngine()
Q_D(QQmlEngine);
if (d->isDebugging) {
QQmlEngineDebugService::instance()->remEngine(this);
+ QV8DebugService::removeEngine(handle());
}
// Emit onDestruction signals for the root context before
diff --git a/src/qml/qml/qqmlimport.cpp b/src/qml/qml/qqmlimport.cpp
index 816f9cec0f..85c6a4246a 100644
--- a/src/qml/qml/qqmlimport.cpp
+++ b/src/qml/qml/qqmlimport.cpp
@@ -161,13 +161,20 @@ QQmlType *getTypeForUrl(const QString &urlString, const QHashedStringRef& typeNa
}
-typedef QMap<QString, QString> StringStringMap;
-Q_GLOBAL_STATIC(StringStringMap, qmlEnginePluginsWithRegisteredTypes); // stores the uri
+struct RegisteredPlugin {
+ QString uri;
+ QPluginLoader* loader;
+};
+
+typedef QMap<QString, RegisteredPlugin> StringRegisteredPluginMap;
+Q_GLOBAL_STATIC(StringRegisteredPluginMap, qmlEnginePluginsWithRegisteredTypes); // stores the uri and the PluginLoaders
void qmlClearEnginePlugins()
{
- foreach (const QString &s, qmlEnginePluginsWithRegisteredTypes()->values()) {
- QPluginLoader loader(s);
- loader.unload(); // ### Always returns false, worth doing?
+ foreach (RegisteredPlugin plugin, qmlEnginePluginsWithRegisteredTypes()->values()) {
+ QPluginLoader* loader = plugin.loader;
+ if (!loader->unload())
+ qWarning("Unloading %s failed: %s", qPrintable(plugin.uri), qPrintable(loader->errorString()));
+ delete loader;
}
qmlEnginePluginsWithRegisteredTypes()->clear();
}
@@ -1634,7 +1641,7 @@ bool QQmlImportDatabase::importPlugin(const QString &filePath, const QString &ur
bool typesRegistered = qmlEnginePluginsWithRegisteredTypes()->contains(absoluteFilePath);
if (typesRegistered) {
- Q_ASSERT_X(qmlEnginePluginsWithRegisteredTypes()->value(absoluteFilePath) == uri,
+ Q_ASSERT_X(qmlEnginePluginsWithRegisteredTypes()->value(absoluteFilePath).uri == uri,
"QQmlImportDatabase::importPlugin",
"Internal error: Plugin imported previously with different uri");
}
@@ -1648,25 +1655,37 @@ bool QQmlImportDatabase::importPlugin(const QString &filePath, const QString &ur
}
return false;
}
- QPluginLoader loader(absoluteFilePath);
- if (!loader.load()) {
- if (errors) {
- QQmlError error;
- error.setDescription(loader.errorString());
- errors->prepend(error);
+ QPluginLoader* loader = 0;
+ if (!typesRegistered) {
+ loader = new QPluginLoader(absoluteFilePath);
+
+ if (!loader->load()) {
+ if (errors) {
+ QQmlError error;
+ error.setDescription(loader->errorString());
+ errors->prepend(error);
+
+ delete loader;
+ }
+ return false;
}
- return false;
+ } else {
+ loader = qmlEnginePluginsWithRegisteredTypes()->value(absoluteFilePath).loader;
}
- QObject *instance = loader.instance();
+ QObject *instance = loader->instance();
if (QQmlTypesExtensionInterface *iface = qobject_cast<QQmlExtensionInterface *>(instance)) {
const QByteArray bytes = uri.toUtf8();
const char *moduleId = bytes.constData();
if (!typesRegistered) {
- qmlEnginePluginsWithRegisteredTypes()->insert(absoluteFilePath, uri);
+ RegisteredPlugin plugin;
+ plugin.uri = uri;
+ plugin.loader = loader;
+
+ qmlEnginePluginsWithRegisteredTypes()->insert(absoluteFilePath, plugin);
QStringList registrationFailures;
@@ -1734,8 +1753,11 @@ bool QQmlImportDatabase::importPlugin(const QString &filePath, const QString &ur
} else {
if (errors) {
QQmlError error;
- error.setDescription(loader.errorString());
+ error.setDescription(loader->errorString());
errors->prepend(error);
+
+ if (!typesRegistered)
+ delete loader;
}
return false;
}
diff --git a/src/quick/items/qquickitem.cpp b/src/quick/items/qquickitem.cpp
index b6a3ae1ea5..01625756cd 100644
--- a/src/quick/items/qquickitem.cpp
+++ b/src/quick/items/qquickitem.cpp
@@ -4403,12 +4403,12 @@ void QQuickItemPrivate::deliverKeyEvent(QKeyEvent *e)
extra->keyHandler->keyReleased(e, true);
}
- if (e->isAccepted())
+ if (e->isAccepted() || !q->window())
return;
//only care about KeyPress now
- if ((q == q->window()->contentItem() || q->activeFocusOnTab())
- && e->type() == QEvent::KeyPress) {
+ if (e->type() == QEvent::KeyPress &&
+ (q == q->window()->contentItem() || q->activeFocusOnTab())) {
bool res = false;
if (!(e->modifiers() & (Qt::ControlModifier | Qt::AltModifier))) { //### Add MetaModifier?
if (e->key() == Qt::Key_Backtab
diff --git a/src/quick/items/qquickitemsmodule.cpp b/src/quick/items/qquickitemsmodule.cpp
index 6f1edc718a..04eb28343a 100644
--- a/src/quick/items/qquickitemsmodule.cpp
+++ b/src/quick/items/qquickitemsmodule.cpp
@@ -242,11 +242,6 @@ static void qt_quickitems_defineModule(const char *uri, int major, int minor)
void QQuickItemsModule::defineModule()
{
- static bool initialized = false;
- if (initialized)
- return;
- initialized = true;
-
QByteArray name = "QtQuick";
int majorVersion = 2;
int minorVersion = 0;
diff --git a/src/quick/items/qquickmousearea.cpp b/src/quick/items/qquickmousearea.cpp
index a8786585da..1970a03bee 100644
--- a/src/quick/items/qquickmousearea.cpp
+++ b/src/quick/items/qquickmousearea.cpp
@@ -547,6 +547,12 @@ QQuickMouseArea::QQuickMouseArea(QQuickItem *parent)
{
Q_D(QQuickMouseArea);
d->init();
+#ifndef QT_NO_CURSOR
+ // Explcitly call setCursor on QQuickItem since
+ // it internally keeps a boolean hasCursor that doesn't
+ // get set to true unless you call setCursor
+ setCursor(Qt::ArrowCursor);
+#endif
}
QQuickMouseArea::~QQuickMouseArea()
diff --git a/src/quick/items/qquickshadereffectsource.cpp b/src/quick/items/qquickshadereffectsource.cpp
index 9debfe35b3..e48cedaf26 100644
--- a/src/quick/items/qquickshadereffectsource.cpp
+++ b/src/quick/items/qquickshadereffectsource.cpp
@@ -96,6 +96,10 @@ class QQuickShaderEffectSourceTextureProvider : public QSGTextureProvider
public:
QQuickShaderEffectSourceTextureProvider()
: sourceTexture(0)
+ , mipmapFiltering(QSGTexture::None)
+ , filtering(QSGTexture::Nearest)
+ , horizontalWrap(QSGTexture::ClampToEdge)
+ , verticalWrap(QSGTexture::ClampToEdge)
{
}
diff --git a/src/quick/scenegraph/qsgadaptationlayer.cpp b/src/quick/scenegraph/qsgadaptationlayer.cpp
index 3536975e94..3c8772252c 100644
--- a/src/quick/scenegraph/qsgadaptationlayer.cpp
+++ b/src/quick/scenegraph/qsgadaptationlayer.cpp
@@ -168,13 +168,11 @@ void QSGDistanceFieldGlyphCache::update()
qsg_render_timer.start();
#endif
- QHash<glyph_t, QImage> distanceFields;
-
+ QList<QDistanceField> distanceFields;
for (int i = 0; i < m_pendingGlyphs.size(); ++i) {
- glyph_t glyphIndex = m_pendingGlyphs.at(i);
-
- QImage distanceField = qt_renderDistanceFieldGlyph(m_referenceFont, glyphIndex, m_doubleGlyphResolution);
- distanceFields.insert(glyphIndex, distanceField);
+ distanceFields.append(QDistanceField(m_referenceFont,
+ m_pendingGlyphs.at(i),
+ m_doubleGlyphResolution));
}
#ifndef QSG_NO_RENDER_TIMING
diff --git a/src/quick/scenegraph/qsgadaptationlayer_p.h b/src/quick/scenegraph/qsgadaptationlayer_p.h
index cc22bfa61f..9e173101ba 100644
--- a/src/quick/scenegraph/qsgadaptationlayer_p.h
+++ b/src/quick/scenegraph/qsgadaptationlayer_p.h
@@ -230,7 +230,7 @@ protected:
};
virtual void requestGlyphs(const QSet<glyph_t> &glyphs) = 0;
- virtual void storeGlyphs(const QHash<glyph_t, QImage> &glyphs) = 0;
+ virtual void storeGlyphs(const QList<QDistanceField> &glyphs) = 0;
virtual void referenceGlyphs(const QSet<glyph_t> &glyphs) = 0;
virtual void releaseGlyphs(const QSet<glyph_t> &glyphs) = 0;
diff --git a/src/quick/scenegraph/qsgdefaultdistancefieldglyphcache.cpp b/src/quick/scenegraph/qsgdefaultdistancefieldglyphcache.cpp
index 4652a2241e..884abd3edc 100644
--- a/src/quick/scenegraph/qsgdefaultdistancefieldglyphcache.cpp
+++ b/src/quick/scenegraph/qsgdefaultdistancefieldglyphcache.cpp
@@ -142,13 +142,19 @@ void QSGDefaultDistanceFieldGlyphCache::requestGlyphs(const QSet<glyph_t> &glyph
markGlyphsToRender(glyphsToRender);
}
-void QSGDefaultDistanceFieldGlyphCache::storeGlyphs(const QHash<glyph_t, QImage> &glyphs)
+void QSGDefaultDistanceFieldGlyphCache::storeGlyphs(const QList<QDistanceField> &glyphs)
{
QHash<TextureInfo *, QVector<glyph_t> > glyphTextures;
- QHash<glyph_t, QImage>::const_iterator it;
- for (it = glyphs.constBegin(); it != glyphs.constEnd(); ++it) {
- glyph_t glyphIndex = it.key();
+ GLint alignment = 4; // default value
+ glGetIntegerv(GL_UNPACK_ALIGNMENT, &alignment);
+
+ // Distance field data is always tightly packed
+ glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
+
+ for (int i = 0; i < glyphs.size(); ++i) {
+ QDistanceField glyph = glyphs.at(i);
+ glyph_t glyphIndex = glyph.glyph();
TexCoord c = glyphTexCoord(glyphIndex);
TextureInfo *texInfo = m_glyphsTexture.value(glyphIndex);
@@ -157,7 +163,6 @@ void QSGDefaultDistanceFieldGlyphCache::storeGlyphs(const QHash<glyph_t, QImage>
glyphTextures[texInfo].append(glyphIndex);
- QImage glyph = it.value();
int expectedWidth = qCeil(c.width + c.xMargin * 2);
if (glyph.width() != expectedWidth)
glyph = glyph.copy(0, 0, expectedWidth, glyph.height());
@@ -167,15 +172,17 @@ void QSGDefaultDistanceFieldGlyphCache::storeGlyphs(const QHash<glyph_t, QImage>
uchar *outBits = texInfo->image.scanLine(int(c.y)) + int(c.x);
for (int y = 0; y < glyph.height(); ++y) {
memcpy(outBits, inBits, glyph.width());
- inBits += glyph.bytesPerLine();
- outBits += texInfo->image.bytesPerLine();
+ inBits += glyph.width();
+ outBits += texInfo->image.width();
}
}
- for (int i = 0; i < glyph.height(); ++i)
- glTexSubImage2D(GL_TEXTURE_2D, 0, c.x, c.y + i, glyph.width(), 1, GL_ALPHA, GL_UNSIGNED_BYTE, glyph.scanLine(i));
+ glTexSubImage2D(GL_TEXTURE_2D, 0, c.x, c.y, glyph.width(), glyph.height(), GL_ALPHA, GL_UNSIGNED_BYTE, glyph.constBits());
}
+ // restore to previous alignment
+ glPixelStorei(GL_UNPACK_ALIGNMENT, alignment);
+
QHash<TextureInfo *, QVector<glyph_t> >::const_iterator i;
for (i = glyphTextures.constBegin(); i != glyphTextures.constEnd(); ++i) {
Texture t;
@@ -198,7 +205,7 @@ void QSGDefaultDistanceFieldGlyphCache::releaseGlyphs(const QSet<glyph_t> &glyph
void QSGDefaultDistanceFieldGlyphCache::createTexture(TextureInfo *texInfo, int width, int height)
{
if (useWorkaround() && texInfo->image.isNull())
- texInfo->image = QImage(width, height, QImage::Format_Indexed8);
+ texInfo->image = QDistanceField(width, height);
while (glGetError() != GL_NO_ERROR) { }
@@ -243,8 +250,14 @@ void QSGDefaultDistanceFieldGlyphCache::resizeTexture(TextureInfo *texInfo, int
updateTexture(oldTexture, texInfo->texture, texInfo->size);
if (useWorkaround()) {
- for (int i = 0; i < oldHeight; ++i)
- glTexSubImage2D(GL_TEXTURE_2D, 0, 0, i, oldWidth, 1, GL_ALPHA, GL_UNSIGNED_BYTE, texInfo->image.scanLine(i));
+ GLint alignment = 4; // default value
+ glGetIntegerv(GL_UNPACK_ALIGNMENT, &alignment);
+ glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
+
+ glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, oldWidth, oldHeight, GL_ALPHA, GL_UNSIGNED_BYTE, texInfo->image.constBits());
+
+ glPixelStorei(GL_UNPACK_ALIGNMENT, alignment); // restore to previous value
+
texInfo->image = texInfo->image.copy(0, 0, width, height);
glDeleteTextures(1, &oldTexture);
return;
diff --git a/src/quick/scenegraph/qsgdefaultdistancefieldglyphcache_p.h b/src/quick/scenegraph/qsgdefaultdistancefieldglyphcache_p.h
index ef722d85df..4ce3a50d1b 100644
--- a/src/quick/scenegraph/qsgdefaultdistancefieldglyphcache_p.h
+++ b/src/quick/scenegraph/qsgdefaultdistancefieldglyphcache_p.h
@@ -58,7 +58,7 @@ public:
virtual ~QSGDefaultDistanceFieldGlyphCache();
void requestGlyphs(const QSet<glyph_t> &glyphs);
- void storeGlyphs(const QHash<glyph_t, QImage> &glyphs);
+ void storeGlyphs(const QList<QDistanceField> &glyphs);
void referenceGlyphs(const QSet<glyph_t> &glyphs);
void releaseGlyphs(const QSet<glyph_t> &glyphs);
@@ -73,7 +73,7 @@ private:
GLuint texture;
QSize size;
QRect allocatedArea;
- QImage image;
+ QDistanceField image;
TextureInfo() : texture(0)
{ }
diff --git a/src/quick/scenegraph/qsgdefaultglyphnode_p.cpp b/src/quick/scenegraph/qsgdefaultglyphnode_p.cpp
index f5a461f19e..c62bee097b 100644
--- a/src/quick/scenegraph/qsgdefaultglyphnode_p.cpp
+++ b/src/quick/scenegraph/qsgdefaultglyphnode_p.cpp
@@ -58,7 +58,7 @@ QT_BEGIN_NAMESPACE
class QSGTextMaskMaterialData : public QSGMaterialShader
{
public:
- QSGTextMaskMaterialData();
+ QSGTextMaskMaterialData(QFontEngineGlyphCache::Type cacheType);
virtual void updateState(const RenderState &state, QSGMaterial *newEffect, QSGMaterial *oldEffect);
virtual char const *const *attributeNames() const;
@@ -74,6 +74,8 @@ protected:
int m_matrix_id;
int m_color_id;
int m_textureScale_id;
+
+ QFontEngineGlyphCache::Type m_cacheType;
};
const char *QSGTextMaskMaterialData::vertexShader() const {
@@ -106,7 +108,8 @@ char const *const *QSGTextMaskMaterialData::attributeNames() const
return attr;
}
-QSGTextMaskMaterialData::QSGTextMaskMaterialData()
+QSGTextMaskMaterialData::QSGTextMaskMaterialData(QFontEngineGlyphCache::Type cacheType)
+ : m_cacheType(cacheType)
{
}
@@ -126,24 +129,31 @@ static inline qreal fontSmoothingGamma()
void QSGTextMaskMaterialData::activate()
{
QSGMaterialShader::activate();
- glBlendFunc(GL_CONSTANT_COLOR, GL_ONE_MINUS_SRC_COLOR);
+
+ if (m_cacheType == QFontEngineGlyphCache::Raster_RGBMask)
+ glBlendFunc(GL_CONSTANT_COLOR, GL_ONE_MINUS_SRC_COLOR);
#if !defined(QT_OPENGL_ES_2) && defined(GL_ARB_framebuffer_sRGB)
// 0.25 was found to be acceptable error margin by experimentation. On Mac, the gamma is 2.0,
// but using sRGB looks okay.
- if (qAbs(fontSmoothingGamma() - 2.2) < 0.25)
+ if (m_cacheType == QFontEngineGlyphCache::Raster_RGBMask
+ && qAbs(fontSmoothingGamma() - 2.2) < 0.25) {
glEnable(GL_FRAMEBUFFER_SRGB);
+ }
#endif
}
void QSGTextMaskMaterialData::deactivate()
{
QSGMaterialShader::deactivate();
- glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
+ if (m_cacheType == QFontEngineGlyphCache::Raster_RGBMask)
+ glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
#if !defined(QT_OPENGL_ES_2) && defined(GL_ARB_framebuffer_sRGB)
- if (qAbs(fontSmoothingGamma() - 2.2) < 0.25)
+ if (m_cacheType == QFontEngineGlyphCache::Raster_RGBMask
+ && qAbs(fontSmoothingGamma() - 2.2) < 0.25) {
glDisable(GL_FRAMEBUFFER_SRGB);
+ }
#endif
}
@@ -213,11 +223,11 @@ void QSGTextMaskMaterialData::updateState(const RenderState &state, QSGMaterial
class QSGStyledTextMaterialData : public QSGTextMaskMaterialData
{
public:
- QSGStyledTextMaterialData() { }
+ QSGStyledTextMaterialData(QFontEngineGlyphCache::Type cacheType)
+ : QSGTextMaskMaterialData(cacheType)
+ { }
virtual void updateState(const RenderState &state, QSGMaterial *newEffect, QSGMaterial *oldEffect);
- virtual void activate();
- virtual void deactivate();
private:
virtual void initialize();
@@ -284,28 +294,6 @@ void QSGStyledTextMaterialData::updateState(const RenderState &state,
program()->setUniformValue(m_matrix_id, state.combinedMatrix());
}
-void QSGStyledTextMaterialData::activate()
-{
- QSGMaterialShader::activate();
-
-#if !defined(QT_OPENGL_ES_2) && defined(GL_ARB_framebuffer_sRGB)
- // 0.25 was found to be acceptable error margin by experimentation. On Mac, the gamma is 2.0,
- // but using sRGB looks okay.
- if (qAbs(fontSmoothingGamma() - 2.2) < 0.25)
- glEnable(GL_FRAMEBUFFER_SRGB);
-#endif
-}
-
-void QSGStyledTextMaterialData::deactivate()
-{
- QSGMaterialShader::deactivate();
-
-#if !defined(QT_OPENGL_ES_2) && defined(GL_ARB_framebuffer_sRGB)
- if (qAbs(fontSmoothingGamma() - 2.2) < 0.25)
- glDisable(GL_FRAMEBUFFER_SRGB);
-#endif
-}
-
const char *QSGStyledTextMaterialData::vertexShader() const
{
return
@@ -343,7 +331,9 @@ const char *QSGStyledTextMaterialData::fragmentShader() const
class QSGOutlinedTextMaterialData : public QSGStyledTextMaterialData
{
public:
- QSGOutlinedTextMaterialData() { }
+ QSGOutlinedTextMaterialData(QFontEngineGlyphCache::Type cacheType)
+ : QSGStyledTextMaterialData(cacheType)
+ { }
private:
const char *vertexShader() const;
@@ -396,20 +386,19 @@ const char *QSGOutlinedTextMaterialData::fragmentShader() const
"}";
}
-QSGTextMaskMaterial::QSGTextMaskMaterial(const QRawFont &font, QFontEngineGlyphCache::Type cacheType)
+QSGTextMaskMaterial::QSGTextMaskMaterial(const QRawFont &font, int cacheType)
: m_texture(0)
- , m_cacheType(cacheType)
, m_glyphCache(0)
, m_font(font)
{
- init();
+ init(cacheType);
}
QSGTextMaskMaterial::~QSGTextMaskMaterial()
{
}
-void QSGTextMaskMaterial::init()
+void QSGTextMaskMaterial::init(int cacheType)
{
Q_ASSERT(m_font.isValid());
@@ -420,9 +409,17 @@ void QSGTextMaskMaterial::init()
QRawFontPrivate *fontD = QRawFontPrivate::get(m_font);
if (fontD->fontEngine != 0) {
- m_glyphCache = fontD->fontEngine->glyphCache(ctx, m_cacheType, QTransform());
- if (!m_glyphCache || m_glyphCache->cacheType() != m_cacheType) {
- m_glyphCache = new QOpenGLTextureGlyphCache(m_cacheType, QTransform());
+ if (cacheType < 0) {
+ cacheType = fontD->fontEngine->glyphFormat < 0
+ ? QFontEngineGlyphCache::Raster_RGBMask
+ : fontD->fontEngine->glyphFormat;
+ }
+ m_glyphCache = fontD->fontEngine->glyphCache(ctx,
+ QFontEngineGlyphCache::Type(cacheType),
+ QTransform());
+ if (!m_glyphCache || int(m_glyphCache->cacheType()) != cacheType) {
+ m_glyphCache = new QOpenGLTextureGlyphCache(QFontEngineGlyphCache::Type(cacheType),
+ QTransform());
fontD->fontEngine->setGlyphCache(ctx, m_glyphCache.data());
}
}
@@ -513,7 +510,7 @@ QOpenGLTextureGlyphCache *QSGTextMaskMaterial::glyphCache() const
QSGMaterialShader *QSGTextMaskMaterial::createShader() const
{
- return new QSGTextMaskMaterialData;
+ return new QSGTextMaskMaterialData(glyphCache()->cacheType());
}
int QSGTextMaskMaterial::compare(const QSGMaterial *o) const
@@ -570,7 +567,7 @@ QSGMaterialType *QSGStyledTextMaterial::type() const
QSGMaterialShader *QSGStyledTextMaterial::createShader() const
{
- return new QSGStyledTextMaterialData;
+ return new QSGStyledTextMaterialData(glyphCache()->cacheType());
}
int QSGStyledTextMaterial::compare(const QSGMaterial *o) const
@@ -602,7 +599,7 @@ QSGMaterialType *QSGOutlinedTextMaterial::type() const
QSGMaterialShader *QSGOutlinedTextMaterial::createShader() const
{
- return new QSGOutlinedTextMaterialData;
+ return new QSGOutlinedTextMaterialData(glyphCache()->cacheType());
}
QT_END_NAMESPACE
diff --git a/src/quick/scenegraph/qsgdefaultglyphnode_p_p.h b/src/quick/scenegraph/qsgdefaultglyphnode_p_p.h
index d1a739de88..ddfc72a4e6 100644
--- a/src/quick/scenegraph/qsgdefaultglyphnode_p_p.h
+++ b/src/quick/scenegraph/qsgdefaultglyphnode_p_p.h
@@ -59,8 +59,7 @@ class Geometry;
class QSGTextMaskMaterial: public QSGMaterial
{
public:
- QSGTextMaskMaterial(const QRawFont &font,
- QFontEngineGlyphCache::Type cacheType = QFontEngineGlyphCache::Raster_RGBMask);
+ QSGTextMaskMaterial(const QRawFont &font, int cacheType = -1);
virtual ~QSGTextMaskMaterial();
virtual QSGMaterialType *type() const;
@@ -84,10 +83,9 @@ public:
const QMargins &margins = QMargins(0, 0, 0, 0));
private:
- void init();
+ void init(int cacheType);
QSGPlainTexture *m_texture;
- QFontEngineGlyphCache::Type m_cacheType;
QExplicitlySharedDataPointer<QFontEngineGlyphCache> m_glyphCache;
QRawFont m_font;
QColor m_color;
diff --git a/src/quick/scenegraph/qsgshareddistancefieldglyphcache.cpp b/src/quick/scenegraph/qsgshareddistancefieldglyphcache.cpp
index 97bb4295f7..c15263f53f 100644
--- a/src/quick/scenegraph/qsgshareddistancefieldglyphcache.cpp
+++ b/src/quick/scenegraph/qsgshareddistancefieldglyphcache.cpp
@@ -300,7 +300,7 @@ void QSGSharedDistanceFieldGlyphCache::waitForGlyphs()
}
}
-void QSGSharedDistanceFieldGlyphCache::storeGlyphs(const QHash<glyph_t, QImage> &glyphs)
+void QSGSharedDistanceFieldGlyphCache::storeGlyphs(const QList<QDistanceField> &glyphs)
{
{
QMutexLocker locker(&m_pendingGlyphsMutex);
@@ -312,14 +312,12 @@ void QSGSharedDistanceFieldGlyphCache::storeGlyphs(const QHash<glyph_t, QImage>
int glyphCount = glyphs.size();
QVector<quint32> glyphIds(glyphCount);
QVector<QImage> images(glyphCount);
- QHash<glyph_t, QImage>::const_iterator it = glyphs.constBegin();
- int i=0;
- while (it != glyphs.constEnd()) {
- m_requestedGlyphsThatHaveNotBeenReturned.insert(it.key());
- glyphIds[i] = it.key();
- images[i] = it.value();
-
- ++it; ++i;
+ for (int i = 0; i < glyphs.size(); ++i) {
+ const QDistanceField &df = glyphs.at(i);
+ m_requestedGlyphsThatHaveNotBeenReturned.insert(df.glyph());
+ glyphIds[i] = df.glyph();
+ // ### TODO: Handle QDistanceField in QPlatformSharedGraphicsCache
+ images[i] = df.toImage(QImage::Format_Indexed8);
}
m_hasPostedEvents = true;
diff --git a/src/quick/scenegraph/qsgshareddistancefieldglyphcache_p.h b/src/quick/scenegraph/qsgshareddistancefieldglyphcache_p.h
index 3ca5485be3..7587d948ad 100644
--- a/src/quick/scenegraph/qsgshareddistancefieldglyphcache_p.h
+++ b/src/quick/scenegraph/qsgshareddistancefieldglyphcache_p.h
@@ -65,7 +65,7 @@ public:
void requestGlyphs(const QSet<glyph_t> &glyphs);
void referenceGlyphs(const QSet<glyph_t> &glyphs);
- void storeGlyphs(const QHash<glyph_t, QImage> &glyphs);
+ void storeGlyphs(const QList<QDistanceField> &glyphs);
void releaseGlyphs(const QSet<glyph_t> &glyphs);
Q_SIGNALS:
diff --git a/tests/auto/qml/debugger/qqmldebugjs/data/quit.qml b/tests/auto/qml/debugger/qqmldebugjs/data/quit.qml
new file mode 100644
index 0000000000..47acceba2a
--- /dev/null
+++ b/tests/auto/qml/debugger/qqmldebugjs/data/quit.qml
@@ -0,0 +1,53 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+//DO NOT CHANGE
+
+Item {
+ Timer {
+ running: true
+ triggeredOnStart: true
+ onTriggered: Qt.quit();
+ }
+}
+
diff --git a/tests/auto/qml/debugger/qqmldebugjs/tst_qqmldebugjs.cpp b/tests/auto/qml/debugger/qqmldebugjs/tst_qqmldebugjs.cpp
index 424a3b36ac..e5a7af630a 100644
--- a/tests/auto/qml/debugger/qqmldebugjs/tst_qqmldebugjs.cpp
+++ b/tests/auto/qml/debugger/qqmldebugjs/tst_qqmldebugjs.cpp
@@ -139,6 +139,7 @@ const char *EXCEPTION_QMLFILE = "exception.qml";
const char *ONCOMPLETED_QMLFILE = "oncompleted.qml";
const char *CREATECOMPONENT_QMLFILE = "createComponent.qml";
const char *CONDITION_QMLFILE = "condition.qml";
+const char *QUIT_QMLFILE = "quit.qml";
const char *CHANGEBREAKPOINT_QMLFILE = "changeBreakpoint.qml";
const char *STEPACTION_QMLFILE = "stepAction.qml";
const char *BREAKPOINTRELOCATION_QMLFILE = "breakpointRelocation.qml";
@@ -196,6 +197,7 @@ private slots:
void setBreakpointInScriptOnEmptyLine();
void setBreakpointInScriptOnOptimizedBinding();
void setBreakpointInScriptWithCondition();
+ void setBreakpointInScriptThatQuits();
//void setBreakpointInFunction(); //NOT SUPPORTED
void setBreakpointOnEvent();
// void setBreakpointWhenAttaching();
@@ -1338,6 +1340,29 @@ void tst_QQmlDebugJS::setBreakpointInScriptWithCondition()
QVERIFY(body.value("value").toInt() > out);
}
+void tst_QQmlDebugJS::setBreakpointInScriptThatQuits()
+{
+ QVERIFY(init(QUIT_QMLFILE));
+
+ int sourceLine = 49;
+
+ client->setBreakpoint(QLatin1String(SCRIPTREGEXP), QLatin1String(QUIT_QMLFILE), sourceLine, -1, true);
+ client->connect();
+ QVERIFY(QQmlDebugTest::waitForSignal(client, SIGNAL(stopped())));
+
+ QString jsonString(client->response);
+ QVariantMap value = client->parser.call(QJSValueList() << QJSValue(jsonString)).toVariant().toMap();
+
+ QVariantMap body = value.value("body").toMap();
+
+ QCOMPARE(body.value("sourceLine").toInt(), sourceLine);
+ QCOMPARE(QFileInfo(body.value("script").toMap().value("name").toString()).fileName(), QLatin1String(QUIT_QMLFILE));
+
+ client->continueDebugging(QJSDebugClient::Continue);
+ QVERIFY(process->waitForFinished());
+ QCOMPARE(process->exitStatus(), QProcess::NormalExit);
+}
+
/* TODO fails because of a race condition when starting up the engine before the view
void tst_QQmlDebugJS::setBreakpointWhenAttaching()
{
diff --git a/tests/auto/qml/debugger/shared/debugutil.cpp b/tests/auto/qml/debugger/shared/debugutil.cpp
index ff3140f520..ab27337d41 100644
--- a/tests/auto/qml/debugger/shared/debugutil.cpp
+++ b/tests/auto/qml/debugger/shared/debugutil.cpp
@@ -168,6 +168,16 @@ int QQmlDebugProcess::debugPort() const
return m_port;
}
+bool QQmlDebugProcess::waitForFinished()
+{
+ return m_process.waitForFinished();
+}
+
+QProcess::ExitStatus QQmlDebugProcess::exitStatus() const
+{
+ return m_process.exitStatus();
+}
+
void QQmlDebugProcess::setEnvironment(const QStringList &environment)
{
m_environment = environment;
diff --git a/tests/auto/qml/debugger/shared/debugutil_p.h b/tests/auto/qml/debugger/shared/debugutil_p.h
index 11b16a1fb8..9f9a852fb6 100644
--- a/tests/auto/qml/debugger/shared/debugutil_p.h
+++ b/tests/auto/qml/debugger/shared/debugutil_p.h
@@ -95,6 +95,9 @@ public:
bool waitForSessionStart();
int debugPort() const;
+ bool waitForFinished();
+ QProcess::ExitStatus exitStatus() const;
+
QString output() const;
void stop();
diff --git a/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp b/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp
index ec5eaf2017..b5c8edf5f3 100644
--- a/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp
+++ b/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp
@@ -245,7 +245,6 @@ private:
void tst_qqmllanguage::cleanupTestCase()
{
QVERIFY(QFile::remove(testFile(QString::fromUtf8("I18nType\303\201\303\242\303\243\303\244\303\245.qml"))));
- qmlClearTypeRegistrations(); // Should not crash
}
void tst_qqmllanguage::insertedSemicolon_data()
diff --git a/tests/auto/quick/qquickflickable/tst_qquickflickable.cpp b/tests/auto/quick/qquickflickable/tst_qquickflickable.cpp
index dd9fa47d81..4392055dde 100644
--- a/tests/auto/quick/qquickflickable/tst_qquickflickable.cpp
+++ b/tests/auto/quick/qquickflickable/tst_qquickflickable.cpp
@@ -236,6 +236,10 @@ void tst_qquickflickable::rebound()
{
QScopedPointer<QQuickView> window(new QQuickView);
window->setSource(testFileUrl("rebound.qml"));
+ QTRY_COMPARE(window->status(), QQuickView::Ready);
+ QQuickViewTestUtil::centerOnScreen(window.data());
+ QQuickViewTestUtil::moveMouseAway(window.data());
+
window->show();
QVERIFY(QTest::qWaitForWindowExposed(window.data()));
QVERIFY(window->rootObject() != 0);
@@ -375,6 +379,9 @@ void tst_qquickflickable::pressDelay()
{
QScopedPointer<QQuickView> window(new QQuickView);
window->setSource(testFileUrl("pressDelay.qml"));
+ QTRY_COMPARE(window->status(), QQuickView::Ready);
+ QQuickViewTestUtil::centerOnScreen(window.data());
+ QQuickViewTestUtil::moveMouseAway(window.data());
window->show();
QVERIFY(QTest::qWaitForWindowExposed(window.data()));
QVERIFY(window->rootObject() != 0);
@@ -414,6 +421,9 @@ void tst_qquickflickable::nestedPressDelay()
{
QScopedPointer<QQuickView> window(new QQuickView);
window->setSource(testFileUrl("nestedPressDelay.qml"));
+ QTRY_COMPARE(window->status(), QQuickView::Ready);
+ QQuickViewTestUtil::centerOnScreen(window.data());
+ QQuickViewTestUtil::moveMouseAway(window.data());
window->show();
QVERIFY(QTest::qWaitForWindowExposed(window.data()));
QVERIFY(window->rootObject() != 0);
@@ -636,6 +646,9 @@ void tst_qquickflickable::movingAndFlicking()
QScopedPointer<QQuickView> window(new QQuickView);
window->setSource(testFileUrl("flickable03.qml"));
+ QTRY_COMPARE(window->status(), QQuickView::Ready);
+ QQuickViewTestUtil::centerOnScreen(window.data());
+ QQuickViewTestUtil::moveMouseAway(window.data());
window->show();
QVERIFY(QTest::qWaitForWindowExposed(window.data()));
QVERIFY(window->rootObject() != 0);
@@ -796,6 +809,9 @@ void tst_qquickflickable::movingAndDragging()
QScopedPointer<QQuickView> window(new QQuickView);
window->setSource(testFileUrl("flickable03.qml"));
+ QTRY_COMPARE(window->status(), QQuickView::Ready);
+ QQuickViewTestUtil::centerOnScreen(window.data());
+ QQuickViewTestUtil::moveMouseAway(window.data());
window->show();
QVERIFY(QTest::qWaitForWindowExposed(window.data()));
QVERIFY(window->rootObject() != 0);
@@ -999,6 +1015,9 @@ void tst_qquickflickable::pressWhileFlicking()
{
QScopedPointer<QQuickView> window(new QQuickView);
window->setSource(testFileUrl("flickable03.qml"));
+ QTRY_COMPARE(window->status(), QQuickView::Ready);
+ QQuickViewTestUtil::centerOnScreen(window.data());
+ QQuickViewTestUtil::moveMouseAway(window.data());
window->show();
QVERIFY(QTest::qWaitForWindowExposed(window.data()));
QVERIFY(window->rootObject() != 0);
@@ -1077,6 +1096,9 @@ void tst_qquickflickable::flickVelocity()
{
QScopedPointer<QQuickView> window(new QQuickView);
window->setSource(testFileUrl("flickable03.qml"));
+ QTRY_COMPARE(window->status(), QQuickView::Ready);
+ QQuickViewTestUtil::centerOnScreen(window.data());
+ QQuickViewTestUtil::moveMouseAway(window.data());
window->show();
QVERIFY(QTest::qWaitForWindowExposed(window.data()));
QVERIFY(window->rootObject() != 0);
@@ -1177,6 +1199,9 @@ void tst_qquickflickable::cancelOnMouseGrab()
{
QScopedPointer<QQuickView> window(new QQuickView);
window->setSource(testFileUrl("cancel.qml"));
+ QTRY_COMPARE(window->status(), QQuickView::Ready);
+ QQuickViewTestUtil::centerOnScreen(window.data());
+ QQuickViewTestUtil::moveMouseAway(window.data());
window->show();
QVERIFY(QTest::qWaitForWindowExposed(window.data()));
QVERIFY(window->rootObject() != 0);
@@ -1212,6 +1237,9 @@ void tst_qquickflickable::clickAndDragWhenTransformed()
{
QScopedPointer<QQuickView> view(new QQuickView);
view->setSource(testFileUrl("transformedFlickable.qml"));
+ QTRY_COMPARE(view->status(), QQuickView::Ready);
+ QQuickViewTestUtil::centerOnScreen(view.data());
+ QQuickViewTestUtil::moveMouseAway(view.data());
view->show();
QVERIFY(QTest::qWaitForWindowExposed(view.data()));
QVERIFY(view->rootObject() != 0);
@@ -1260,8 +1288,11 @@ void tst_qquickflickable::flickTwiceUsingTouches()
touchDevice->setCapabilities(QTouchDevice::Position);
QWindowSystemInterface::registerTouchDevice(touchDevice);
- QQuickView *window = new QQuickView;
+ QScopedPointer<QQuickView> window(new QQuickView);
window->setSource(testFileUrl("longList.qml"));
+ QTRY_COMPARE(window->status(), QQuickView::Ready);
+ QQuickViewTestUtil::centerOnScreen(window.data());
+ QQuickViewTestUtil::moveMouseAway(window.data());
window->show();
QVERIFY(window->rootObject() != 0);
@@ -1269,20 +1300,18 @@ void tst_qquickflickable::flickTwiceUsingTouches()
QVERIFY(flickable != 0);
QCOMPARE(flickable->contentY(), 0.0f);
- flickWithTouch(window, touchDevice, QPoint(100, 400), QPoint(100, 240));
+ flickWithTouch(window.data(), touchDevice, QPoint(100, 400), QPoint(100, 240));
qreal contentYAfterFirstFlick = flickable->contentY();
qDebug() << "contentYAfterFirstFlick " << contentYAfterFirstFlick;
QVERIFY(contentYAfterFirstFlick > 50.0f);
- flickWithTouch(window, touchDevice, QPoint(100, 400), QPoint(100, 240));
+ flickWithTouch(window.data(), touchDevice, QPoint(100, 400), QPoint(100, 240));
// In the original bug, that second flick would cause Flickable to halt immediately
qreal contentYAfterSecondFlick = flickable->contentY();
qDebug() << "contentYAfterSecondFlick " << contentYAfterSecondFlick;
QVERIFY(contentYAfterSecondFlick > (contentYAfterFirstFlick + 80.0f));
-
- delete window;
}
void tst_qquickflickable::flickWithTouch(QWindow *window, QTouchDevice *touchDevice, const QPoint &from, const QPoint &to)
@@ -1319,6 +1348,9 @@ void tst_qquickflickable::nestedStopAtBounds()
QQuickView view;
view.setSource(testFileUrl("nestedStopAtBounds.qml"));
+ QTRY_COMPARE(view.status(), QQuickView::Ready);
+ QQuickViewTestUtil::centerOnScreen(&view);
+ QQuickViewTestUtil::moveMouseAway(&view);
view.show();
view.requestActivate();
QVERIFY(QTest::qWaitForWindowExposed(&view));
@@ -1378,8 +1410,11 @@ void tst_qquickflickable::nestedMouseAreaUsingTouch()
touchDevice->setCapabilities(QTouchDevice::Position);
QWindowSystemInterface::registerTouchDevice(touchDevice);
- QQuickView *window = new QQuickView;
+ QScopedPointer<QQuickView> window(new QQuickView);
window->setSource(testFileUrl("nestedmousearea.qml"));
+ QTRY_COMPARE(window->status(), QQuickView::Ready);
+ QQuickViewTestUtil::centerOnScreen(window.data());
+ QQuickViewTestUtil::moveMouseAway(window.data());
window->show();
QVERIFY(window->rootObject() != 0);
@@ -1387,7 +1422,7 @@ void tst_qquickflickable::nestedMouseAreaUsingTouch()
QVERIFY(flickable != 0);
QCOMPARE(flickable->contentY(), 50.0f);
- flickWithTouch(window, touchDevice, QPoint(100, 300), QPoint(100, 200));
+ flickWithTouch(window.data(), touchDevice, QPoint(100, 300), QPoint(100, 200));
// flickable should not have moved
QCOMPARE(flickable->contentY(), 50.0);
@@ -1395,8 +1430,6 @@ void tst_qquickflickable::nestedMouseAreaUsingTouch()
// draggable item should have moved up
QQuickItem *nested = window->rootObject()->findChild<QQuickItem*>("nested");
QVERIFY(nested->y() < 100.0);
-
- delete window;
}
QTEST_MAIN(tst_qquickflickable)
diff --git a/tests/auto/quick/qquickgridview/tst_qquickgridview.cpp b/tests/auto/quick/qquickgridview/tst_qquickgridview.cpp
index d0ffba9435..f1adb7858f 100644
--- a/tests/auto/quick/qquickgridview/tst_qquickgridview.cpp
+++ b/tests/auto/quick/qquickgridview/tst_qquickgridview.cpp
@@ -4253,6 +4253,7 @@ void tst_QQuickGridView::snapToRow()
QQuickView *window = getView();
+ QQuickViewTestUtil::moveMouseAway(window);
window->setSource(testFileUrl("snapToRow.qml"));
window->show();
qApp->processEvents();
@@ -4347,6 +4348,7 @@ void tst_QQuickGridView::snapOneRow()
QFETCH(qreal, startExtent);
QQuickView *window = getView();
+ QQuickViewTestUtil::moveMouseAway(window);
window->setSource(testFileUrl("snapOneRow.qml"));
window->show();
diff --git a/tests/auto/quick/qquickitem/tst_qquickitem.cpp b/tests/auto/quick/qquickitem/tst_qquickitem.cpp
index 79f08d5147..97e002361b 100644
--- a/tests/auto/quick/qquickitem/tst_qquickitem.cpp
+++ b/tests/auto/quick/qquickitem/tst_qquickitem.cpp
@@ -1162,6 +1162,9 @@ static inline QByteArray msgItem(const QQuickItem *item)
void tst_qquickitem::mouseGrab()
{
+#if defined(Q_OS_WIN) && defined(QT_OPENGL_ES_2)
+ QSKIP("Fails in the CI for ANGLE builds on Windows, QTBUG-32664");
+#endif
QQuickWindow window;
window.setFramePosition(QPoint(100, 100));
window.resize(200, 200);
diff --git a/tests/auto/quick/qquickitemlayer/data/SourceRect.qml b/tests/auto/quick/qquickitemlayer/data/SourceRect.qml
index a161760028..76ad61bd14 100644
--- a/tests/auto/quick/qquickitemlayer/data/SourceRect.qml
+++ b/tests/auto/quick/qquickitemlayer/data/SourceRect.qml
@@ -22,8 +22,8 @@ Item
uniform lowp float qt_Opacity;
varying highp vec2 qt_TexCoord0;
void main() {
- vec4 c = texture2D(source, qt_TexCoord0);
- if (c.a == 0.)
+ mediump vec4 c = texture2D(source, qt_TexCoord0);
+ if (c.a == 0.0)
c = vec4(0, 0, 1, 1);
gl_FragColor = c * qt_Opacity;
}
diff --git a/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp b/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp
index cd8cc53b40..41f193cdb7 100644
--- a/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp
+++ b/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp
@@ -2127,6 +2127,7 @@ void tst_QQuickListView::sectionsDragOutsideBounds()
QFETCH(int, cacheBuffer);
QQuickView *window = getView();
+ QQuickViewTestUtil::moveMouseAway(window);
QaimModel model;
for (int i = 0; i < 10; i++)
@@ -4819,6 +4820,7 @@ void tst_QQuickListView::marginsResize()
QQuickView *window = getView();
window->setSource(testFileUrl("margins2.qml"));
+ QQuickViewTestUtil::moveMouseAway(window);
window->show();
qApp->processEvents();
@@ -4954,6 +4956,7 @@ void tst_QQuickListView::snapToItem()
QFETCH(qreal, startExtent);
QQuickView *window = getView();
+ QQuickViewTestUtil::moveMouseAway(window);
window->setSource(testFileUrl("snapToItem.qml"));
window->show();
@@ -5282,6 +5285,7 @@ void tst_QQuickListView::snapOneItem()
QFETCH(qreal, startExtent);
QQuickView *window = getView();
+ QQuickViewTestUtil::moveMouseAway(window);
window->setSource(testFileUrl("snapOneItem.qml"));
window->show();
@@ -6754,6 +6758,7 @@ void tst_QQuickListView::matchItemLists(const QVariantList &itemLists, const QLi
void tst_QQuickListView::flickBeyondBounds()
{
QQuickView *window = createView();
+ QQuickViewTestUtil::moveMouseAway(window);
window->setSource(testFileUrl("flickBeyondBoundsBug.qml"));
window->show();
@@ -6889,6 +6894,7 @@ void tst_QQuickListView::delayedChanges_QTBUG_30555()
void tst_QQuickListView::outsideViewportChangeNotAffectingView()
{
QQuickView *window = createView();
+ QQuickViewTestUtil::moveMouseAway(window);
window->setSource(testFileUrl("outsideViewportChangeNotAffectingView.qml"));
QQuickListView *listview = window->rootObject()->findChild<QQuickListView*>();
diff --git a/tests/auto/quick/qquickmousearea/qquickmousearea.pro b/tests/auto/quick/qquickmousearea/qquickmousearea.pro
index e9b06fd1df..dd7b434898 100644
--- a/tests/auto/quick/qquickmousearea/qquickmousearea.pro
+++ b/tests/auto/quick/qquickmousearea/qquickmousearea.pro
@@ -10,7 +10,5 @@ include (../../shared/util.pri)
TESTDATA = data/*
-win32:CONFIG += insignificant_test # QTBUG-33006
-
QT += core-private gui-private qml-private quick-private network testlib
DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0
diff --git a/tests/auto/quick/qquickmousearea/tst_qquickmousearea.cpp b/tests/auto/quick/qquickmousearea/tst_qquickmousearea.cpp
index f92612e411..5e7370f8a5 100644
--- a/tests/auto/quick/qquickmousearea/tst_qquickmousearea.cpp
+++ b/tests/auto/quick/qquickmousearea/tst_qquickmousearea.cpp
@@ -49,6 +49,33 @@
#include <QtQml/qqmlengine.h>
#include "../../shared/util.h"
#include <QtGui/qstylehints.h>
+#include <QtGui/QCursor>
+#include <QtGui/QScreen>
+
+// Initialize view, set Url, center in available geometry, move mouse away if desired
+static bool initView(QQuickView &v, const QUrl &url, bool moveMouseOut, QByteArray *errorMessage)
+{
+ v.setBaseSize(QSize(240,320));
+ v.setSource(url);
+ while (v.status() == QQuickView::Loading)
+ QTest::qWait(10);
+ if (v.status() != QQuickView::Ready) {
+ foreach (const QQmlError &e, v.errors())
+ errorMessage->append(e.toString().toLocal8Bit() + '\n');
+ return false;
+ }
+ const QRect screenGeometry = v.screen()->availableGeometry();
+ const QSize size = v.size();
+ const QPoint offset = QPoint(size.width() / 2, size.height() / 2);
+ v.setFramePosition(screenGeometry.center() - offset);
+#ifndef QT_NO_CURSOR // Get the cursor out of the way.
+ if (moveMouseOut)
+ QCursor::setPos(v.geometry().topRight() + QPoint(100, 100));
+#else
+ Q_UNUSED(moveMouseOut)
+#endif
+ return true;
+}
class tst_QQuickMouseArea: public QQmlDataTest
{
@@ -96,8 +123,6 @@ private slots:
private:
void acceptedButton_data();
void rejectedButton_data();
-
- QQuickView *createView();
};
Q_DECLARE_METATYPE(Qt::MouseButton)
@@ -129,23 +154,24 @@ void tst_QQuickMouseArea::rejectedButton_data()
void tst_QQuickMouseArea::dragProperties()
{
- QQuickView *window = createView();
- window->setSource(testFileUrl("dragproperties.qml"));
- window->show();
- QTest::qWaitForWindowExposed(window);
- QVERIFY(window->rootObject() != 0);
+ QQuickView window;
+ QByteArray errorMessage;
+ QVERIFY2(initView(window, testFileUrl("dragproperties.qml"), true, &errorMessage), errorMessage.constData());
+ window.show();
+ QTest::qWaitForWindowExposed(&window);
+ QVERIFY(window.rootObject() != 0);
- QQuickMouseArea *mouseRegion = window->rootObject()->findChild<QQuickMouseArea*>("mouseregion");
+ QQuickMouseArea *mouseRegion = window.rootObject()->findChild<QQuickMouseArea*>("mouseregion");
QQuickDrag *drag = mouseRegion->drag();
QVERIFY(mouseRegion != 0);
QVERIFY(drag != 0);
// target
- QQuickItem *blackRect = window->rootObject()->findChild<QQuickItem*>("blackrect");
+ QQuickItem *blackRect = window.rootObject()->findChild<QQuickItem*>("blackrect");
QVERIFY(blackRect != 0);
QVERIFY(blackRect == drag->target());
- QQuickItem *rootItem = qobject_cast<QQuickItem*>(window->rootObject());
+ QQuickItem *rootItem = qobject_cast<QQuickItem*>(window.rootObject());
QVERIFY(rootItem != 0);
QSignalSpy targetSpy(drag, SIGNAL(targetChanged()));
drag->setTarget(rootItem);
@@ -208,38 +234,34 @@ void tst_QQuickMouseArea::dragProperties()
drag->setFilterChildren(true);
QCOMPARE(filterChildrenSpy.count(), 1);
-
- delete window;
}
void tst_QQuickMouseArea::resetDrag()
{
- QQuickView *window = createView();
-
- window->rootContext()->setContextProperty("haveTarget", QVariant(true));
- window->setSource(testFileUrl("dragreset.qml"));
- window->show();
- QTest::qWaitForWindowExposed(window);
- QVERIFY(window->rootObject() != 0);
-
- QQuickMouseArea *mouseRegion = window->rootObject()->findChild<QQuickMouseArea*>("mouseregion");
+ QQuickView window;
+ QByteArray errorMessage;
+ window.rootContext()->setContextProperty("haveTarget", QVariant(true));
+ QVERIFY2(initView(window, testFileUrl("dragreset.qml"), true, &errorMessage), errorMessage.constData());
+ window.show();
+ QTest::qWaitForWindowExposed(&window);
+ QVERIFY(window.rootObject() != 0);
+
+ QQuickMouseArea *mouseRegion = window.rootObject()->findChild<QQuickMouseArea*>("mouseregion");
QQuickDrag *drag = mouseRegion->drag();
QVERIFY(mouseRegion != 0);
QVERIFY(drag != 0);
// target
- QQuickItem *blackRect = window->rootObject()->findChild<QQuickItem*>("blackrect");
+ QQuickItem *blackRect = window.rootObject()->findChild<QQuickItem*>("blackrect");
QVERIFY(blackRect != 0);
QVERIFY(blackRect == drag->target());
- QQuickItem *rootItem = qobject_cast<QQuickItem*>(window->rootObject());
+ QQuickItem *rootItem = qobject_cast<QQuickItem*>(window.rootObject());
QVERIFY(rootItem != 0);
QSignalSpy targetSpy(drag, SIGNAL(targetChanged()));
QVERIFY(drag->target() != 0);
- window->rootContext()->setContextProperty("haveTarget", QVariant(false));
+ window.rootContext()->setContextProperty("haveTarget", QVariant(false));
QCOMPARE(targetSpy.count(),1);
QVERIFY(drag->target() == 0);
-
- delete window;
}
void tst_QQuickMouseArea::dragging()
@@ -247,15 +269,15 @@ void tst_QQuickMouseArea::dragging()
QFETCH(Qt::MouseButtons, acceptedButtons);
QFETCH(Qt::MouseButton, button);
- QQuickView *window = createView();
+ QQuickView window;
+ QByteArray errorMessage;
+ QVERIFY2(initView(window, testFileUrl("dragging.qml"), true, &errorMessage), errorMessage.constData());
- window->setSource(testFileUrl("dragging.qml"));
- window->show();
- QTest::qWaitForWindowExposed(window);
- QVERIFY(QTest::qWaitForWindowExposed(window));
- QVERIFY(window->rootObject() != 0);
+ window.show();
+ QVERIFY(QTest::qWaitForWindowExposed(&window));
+ QVERIFY(window.rootObject() != 0);
- QQuickMouseArea *mouseRegion = window->rootObject()->findChild<QQuickMouseArea*>("mouseregion");
+ QQuickMouseArea *mouseRegion = window.rootObject()->findChild<QQuickMouseArea*>("mouseregion");
QQuickDrag *drag = mouseRegion->drag();
QVERIFY(mouseRegion != 0);
QVERIFY(drag != 0);
@@ -263,13 +285,13 @@ void tst_QQuickMouseArea::dragging()
mouseRegion->setAcceptedButtons(acceptedButtons);
// target
- QQuickItem *blackRect = window->rootObject()->findChild<QQuickItem*>("blackrect");
+ QQuickItem *blackRect = window.rootObject()->findChild<QQuickItem*>("blackrect");
QVERIFY(blackRect != 0);
QVERIFY(blackRect == drag->target());
QVERIFY(!drag->active());
- QTest::mousePress(window, button, 0, QPoint(100,100));
+ QTest::mousePress(&window, button, 0, QPoint(100,100));
QVERIFY(!drag->active());
QCOMPARE(blackRect->x(), 50.0);
@@ -280,21 +302,19 @@ void tst_QQuickMouseArea::dragging()
// The item is moved relative to the position of the mouse when the drag
// was triggered, this prevents a sudden change in position when the drag
// threshold is exceeded.
- QTest::mouseMove(window, QPoint(111,111), 50);
- QTest::mouseMove(window, QPoint(116,116), 50);
- QTest::mouseMove(window, QPoint(122,122), 50);
+ QTest::mouseMove(&window, QPoint(111,111), 50);
+ QTest::mouseMove(&window, QPoint(116,116), 50);
+ QTest::mouseMove(&window, QPoint(122,122), 50);
QTRY_VERIFY(drag->active());
QTRY_COMPARE(blackRect->x(), 61.0);
QCOMPARE(blackRect->y(), 61.0);
- QTest::mouseRelease(window, button, 0, QPoint(122,122));
+ QTest::mouseRelease(&window, button, 0, QPoint(122,122));
QTRY_VERIFY(!drag->active());
QCOMPARE(blackRect->x(), 61.0);
QCOMPARE(blackRect->y(), 61.0);
-
- delete window;
}
void tst_QQuickMouseArea::invalidDrag()
@@ -302,14 +322,14 @@ void tst_QQuickMouseArea::invalidDrag()
QFETCH(Qt::MouseButtons, acceptedButtons);
QFETCH(Qt::MouseButton, button);
- QQuickView *window = createView();
+ QQuickView window;
+ QByteArray errorMessage;
+ QVERIFY2(initView(window, testFileUrl("dragging.qml"), true, &errorMessage), errorMessage.constData());
+ window.show();
+ QTest::qWaitForWindowExposed(&window);
+ QVERIFY(window.rootObject() != 0);
- window->setSource(testFileUrl("dragging.qml"));
- window->show();
- QTest::qWaitForWindowExposed(window);
- QVERIFY(window->rootObject() != 0);
-
- QQuickMouseArea *mouseRegion = window->rootObject()->findChild<QQuickMouseArea*>("mouseregion");
+ QQuickMouseArea *mouseRegion = window.rootObject()->findChild<QQuickMouseArea*>("mouseregion");
QQuickDrag *drag = mouseRegion->drag();
QVERIFY(mouseRegion != 0);
QVERIFY(drag != 0);
@@ -317,13 +337,13 @@ void tst_QQuickMouseArea::invalidDrag()
mouseRegion->setAcceptedButtons(acceptedButtons);
// target
- QQuickItem *blackRect = window->rootObject()->findChild<QQuickItem*>("blackrect");
+ QQuickItem *blackRect = window.rootObject()->findChild<QQuickItem*>("blackrect");
QVERIFY(blackRect != 0);
QVERIFY(blackRect == drag->target());
QVERIFY(!drag->active());
- QTest::mousePress(window, button, 0, QPoint(100,100));
+ QTest::mousePress(&window, button, 0, QPoint(100,100));
QVERIFY(!drag->active());
QCOMPARE(blackRect->x(), 50.0);
@@ -332,42 +352,40 @@ void tst_QQuickMouseArea::invalidDrag()
// First move event triggers drag, second is acted upon.
// This is due to possibility of higher stacked area taking precedence.
- QTest::mouseMove(window, QPoint(111,111));
+ QTest::mouseMove(&window, QPoint(111,111));
QTest::qWait(50);
- QTest::mouseMove(window, QPoint(122,122));
+ QTest::mouseMove(&window, QPoint(122,122));
QTest::qWait(50);
QVERIFY(!drag->active());
QCOMPARE(blackRect->x(), 50.0);
QCOMPARE(blackRect->y(), 50.0);
- QTest::mouseRelease(window, button, 0, QPoint(122,122));
+ QTest::mouseRelease(&window, button, 0, QPoint(122,122));
QTest::qWait(50);
QVERIFY(!drag->active());
QCOMPARE(blackRect->x(), 50.0);
QCOMPARE(blackRect->y(), 50.0);
-
- delete window;
}
void tst_QQuickMouseArea::setDragOnPressed()
{
- QQuickView *window = createView();
-
- window->setSource(testFileUrl("setDragOnPressed.qml"));
- window->show();
- QTest::qWaitForWindowExposed(window);
- QVERIFY(window->rootObject() != 0);
-
- QQuickMouseArea *mouseArea = qobject_cast<QQuickMouseArea *>(window->rootObject());
+ QQuickView window;
+ QByteArray errorMessage;
+ QVERIFY2(initView(window, testFileUrl("setDragOnPressed.qml"), true, &errorMessage), errorMessage.constData());
+ window.show();
+ QTest::qWaitForWindowExposed(&window);
+ QVERIFY(window.rootObject() != 0);
+
+ QQuickMouseArea *mouseArea = qobject_cast<QQuickMouseArea *>(window.rootObject());
QVERIFY(mouseArea);
// target
QQuickItem *target = mouseArea->findChild<QQuickItem*>("target");
QVERIFY(target);
- QTest::mousePress(window, Qt::LeftButton, 0, QPoint(100,100));
+ QTest::mousePress(&window, Qt::LeftButton, 0, QPoint(100,100));
QQuickDrag *drag = mouseArea->drag();
QVERIFY(drag);
@@ -379,81 +397,71 @@ void tst_QQuickMouseArea::setDragOnPressed()
// First move event triggers drag, second is acted upon.
// This is due to possibility of higher stacked area taking precedence.
- QTest::mouseMove(window, QPoint(111,102));
+ QTest::mouseMove(&window, QPoint(111,102));
QTest::qWait(50);
- QTest::mouseMove(window, QPoint(122,122));
+ QTest::mouseMove(&window, QPoint(122,122));
QTest::qWait(50);
QVERIFY(drag->active());
QCOMPARE(target->x(), 61.0);
QCOMPARE(target->y(), 50.0);
- QTest::mouseRelease(window, Qt::LeftButton, 0, QPoint(122,122));
+ QTest::mouseRelease(&window, Qt::LeftButton, 0, QPoint(122,122));
QTest::qWait(50);
QVERIFY(!drag->active());
QCOMPARE(target->x(), 61.0);
QCOMPARE(target->y(), 50.0);
-
- delete window;
-}
-
-QQuickView *tst_QQuickMouseArea::createView()
-{
- QQuickView *window = new QQuickView(0);
- window->setBaseSize(QSize(240,320));
-
- return window;
}
void tst_QQuickMouseArea::updateMouseAreaPosOnClick()
{
- QQuickView *window = createView();
- window->setSource(testFileUrl("updateMousePosOnClick.qml"));
- window->show();
- QTest::qWaitForWindowExposed(window);
- QVERIFY(window->rootObject() != 0);
-
- QQuickMouseArea *mouseRegion = window->rootObject()->findChild<QQuickMouseArea*>("mouseregion");
+ QQuickView window;
+ QByteArray errorMessage;
+ QVERIFY2(initView(window, testFileUrl("updateMousePosOnClick.qml"), true, &errorMessage), errorMessage.constData());
+ window.show();
+ QVERIFY(QTest::qWaitForWindowExposed(&window));
+ QVERIFY(window.rootObject() != 0);
+
+ QQuickMouseArea *mouseRegion = window.rootObject()->findChild<QQuickMouseArea*>("mouseregion");
QVERIFY(mouseRegion != 0);
- QQuickRectangle *rect = window->rootObject()->findChild<QQuickRectangle*>("ball");
+ QQuickRectangle *rect = window.rootObject()->findChild<QQuickRectangle*>("ball");
QVERIFY(rect != 0);
QCOMPARE(mouseRegion->mouseX(), rect->x());
QCOMPARE(mouseRegion->mouseY(), rect->y());
QMouseEvent event(QEvent::MouseButtonPress, QPoint(100, 100), Qt::LeftButton, Qt::LeftButton, 0);
- QGuiApplication::sendEvent(window, &event);
+ QGuiApplication::sendEvent(&window, &event);
QCOMPARE(mouseRegion->mouseX(), 100.0);
QCOMPARE(mouseRegion->mouseY(), 100.0);
QCOMPARE(mouseRegion->mouseX(), rect->x());
QCOMPARE(mouseRegion->mouseY(), rect->y());
-
- delete window;
}
void tst_QQuickMouseArea::updateMouseAreaPosOnResize()
{
- QQuickView *window = createView();
- window->setSource(testFileUrl("updateMousePosOnResize.qml"));
- window->show();
- QTest::qWaitForWindowExposed(window);
- QVERIFY(window->rootObject() != 0);
-
- QQuickMouseArea *mouseRegion = window->rootObject()->findChild<QQuickMouseArea*>("mouseregion");
+ QQuickView window;
+ QByteArray errorMessage;
+ QVERIFY2(initView(window, testFileUrl("updateMousePosOnResize.qml"), true, &errorMessage), errorMessage.constData());
+ window.show();
+ QVERIFY(QTest::qWaitForWindowExposed(&window));
+ QVERIFY(window.rootObject() != 0);
+
+ QQuickMouseArea *mouseRegion = window.rootObject()->findChild<QQuickMouseArea*>("mouseregion");
QVERIFY(mouseRegion != 0);
- QQuickRectangle *rect = window->rootObject()->findChild<QQuickRectangle*>("brother");
+ QQuickRectangle *rect = window.rootObject()->findChild<QQuickRectangle*>("brother");
QVERIFY(rect != 0);
QCOMPARE(mouseRegion->mouseX(), 0.0);
QCOMPARE(mouseRegion->mouseY(), 0.0);
QMouseEvent event(QEvent::MouseButtonPress, rect->position().toPoint(), Qt::LeftButton, Qt::LeftButton, 0);
- QGuiApplication::sendEvent(window, &event);
+ QGuiApplication::sendEvent(&window, &event);
QVERIFY(!mouseRegion->property("emitPositionChanged").toBool());
QVERIFY(mouseRegion->property("mouseMatchesPos").toBool());
@@ -466,148 +474,142 @@ void tst_QQuickMouseArea::updateMouseAreaPosOnResize()
QCOMPARE(mouseRegion->mouseX(), rect->x());
QCOMPARE(mouseRegion->mouseY(), rect->y());
-
- delete window;
}
void tst_QQuickMouseArea::noOnClickedWithPressAndHold()
{
{
// We handle onPressAndHold, therefore no onClicked
- QQuickView *window = createView();
- window->setSource(testFileUrl("clickandhold.qml"));
- window->show();
- QTest::qWaitForWindowExposed(window);
- QVERIFY(window->rootObject() != 0);
- QQuickMouseArea *mouseArea = qobject_cast<QQuickMouseArea*>(window->rootObject()->children().first());
+ QQuickView window;
+ QByteArray errorMessage;
+ QVERIFY2(initView(window, testFileUrl("clickandhold.qml"), true, &errorMessage), errorMessage.constData());
+ window.show();
+ QVERIFY(QTest::qWaitForWindowExposed(&window));
+ QVERIFY(window.rootObject() != 0);
+ QQuickMouseArea *mouseArea = qobject_cast<QQuickMouseArea*>(window.rootObject()->children().first());
QVERIFY(mouseArea);
QMouseEvent pressEvent(QEvent::MouseButtonPress, QPoint(100, 100), Qt::LeftButton, Qt::LeftButton, 0);
- QGuiApplication::sendEvent(window, &pressEvent);
+ QGuiApplication::sendEvent(&window, &pressEvent);
QVERIFY(mouseArea->pressedButtons() == Qt::LeftButton);
- QVERIFY(!window->rootObject()->property("clicked").toBool());
- QVERIFY(!window->rootObject()->property("held").toBool());
+ QVERIFY(!window.rootObject()->property("clicked").toBool());
+ QVERIFY(!window.rootObject()->property("held").toBool());
// timeout is 800 (in qquickmousearea.cpp)
QTest::qWait(1000);
QCoreApplication::processEvents();
- QVERIFY(!window->rootObject()->property("clicked").toBool());
- QVERIFY(window->rootObject()->property("held").toBool());
+ QVERIFY(!window.rootObject()->property("clicked").toBool());
+ QVERIFY(window.rootObject()->property("held").toBool());
QMouseEvent releaseEvent(QEvent::MouseButtonRelease, QPoint(100, 100), Qt::LeftButton, Qt::LeftButton, 0);
- QGuiApplication::sendEvent(window, &releaseEvent);
+ QGuiApplication::sendEvent(&window, &releaseEvent);
- QTRY_VERIFY(window->rootObject()->property("held").toBool());
- QVERIFY(!window->rootObject()->property("clicked").toBool());
-
- delete window;
+ QTRY_VERIFY(window.rootObject()->property("held").toBool());
+ QVERIFY(!window.rootObject()->property("clicked").toBool());
}
{
// We do not handle onPressAndHold, therefore we get onClicked
- QQuickView *window = createView();
- window->setSource(testFileUrl("noclickandhold.qml"));
- window->show();
- QTest::qWaitForWindowExposed(window);
- QVERIFY(window->rootObject() != 0);
+ QQuickView window;
+ QByteArray errorMessage;
+ QVERIFY2(initView(window, testFileUrl("noclickandhold.qml"), true, &errorMessage), errorMessage.constData());
+ window.show();
+ QVERIFY(QTest::qWaitForWindowExposed(&window));
+ QVERIFY(window.rootObject() != 0);
QMouseEvent pressEvent(QEvent::MouseButtonPress, QPoint(100, 100), Qt::LeftButton, Qt::LeftButton, 0);
- QGuiApplication::sendEvent(window, &pressEvent);
+ QGuiApplication::sendEvent(&window, &pressEvent);
- QVERIFY(!window->rootObject()->property("clicked").toBool());
+ QVERIFY(!window.rootObject()->property("clicked").toBool());
QTest::qWait(1000);
QMouseEvent releaseEvent(QEvent::MouseButtonRelease, QPoint(100, 100), Qt::LeftButton, Qt::LeftButton, 0);
- QGuiApplication::sendEvent(window, &releaseEvent);
-
- QVERIFY(window->rootObject()->property("clicked").toBool());
+ QGuiApplication::sendEvent(&window, &releaseEvent);
- delete window;
+ QVERIFY(window.rootObject()->property("clicked").toBool());
}
}
void tst_QQuickMouseArea::onMousePressRejected()
{
- QQuickView *window = createView();
- window->setSource(testFileUrl("rejectEvent.qml"));
- window->show();
- QTest::qWaitForWindowExposed(window);
- QVERIFY(window->rootObject() != 0);
- QVERIFY(window->rootObject()->property("enabled").toBool());
-
- QVERIFY(!window->rootObject()->property("mr1_pressed").toBool());
- QVERIFY(!window->rootObject()->property("mr1_released").toBool());
- QVERIFY(!window->rootObject()->property("mr1_canceled").toBool());
- QVERIFY(!window->rootObject()->property("mr2_pressed").toBool());
- QVERIFY(!window->rootObject()->property("mr2_released").toBool());
- QVERIFY(!window->rootObject()->property("mr2_canceled").toBool());
+ QQuickView window;
+ QByteArray errorMessage;
+ QVERIFY2(initView(window, testFileUrl("rejectEvent.qml"), true, &errorMessage), errorMessage.constData());
+ window.show();
+ QVERIFY(QTest::qWaitForWindowExposed(&window));
+ QVERIFY(window.rootObject() != 0);
+ QVERIFY(window.rootObject()->property("enabled").toBool());
+
+ QVERIFY(!window.rootObject()->property("mr1_pressed").toBool());
+ QVERIFY(!window.rootObject()->property("mr1_released").toBool());
+ QVERIFY(!window.rootObject()->property("mr1_canceled").toBool());
+ QVERIFY(!window.rootObject()->property("mr2_pressed").toBool());
+ QVERIFY(!window.rootObject()->property("mr2_released").toBool());
+ QVERIFY(!window.rootObject()->property("mr2_canceled").toBool());
QMouseEvent pressEvent(QEvent::MouseButtonPress, QPoint(100, 100), Qt::LeftButton, Qt::LeftButton, 0);
- QGuiApplication::sendEvent(window, &pressEvent);
+ QGuiApplication::sendEvent(&window, &pressEvent);
- QVERIFY(window->rootObject()->property("mr1_pressed").toBool());
- QVERIFY(!window->rootObject()->property("mr1_released").toBool());
- QVERIFY(!window->rootObject()->property("mr1_canceled").toBool());
- QVERIFY(window->rootObject()->property("mr2_pressed").toBool());
- QVERIFY(!window->rootObject()->property("mr2_released").toBool());
- QVERIFY(window->rootObject()->property("mr2_canceled").toBool());
+ QVERIFY(window.rootObject()->property("mr1_pressed").toBool());
+ QVERIFY(!window.rootObject()->property("mr1_released").toBool());
+ QVERIFY(!window.rootObject()->property("mr1_canceled").toBool());
+ QVERIFY(window.rootObject()->property("mr2_pressed").toBool());
+ QVERIFY(!window.rootObject()->property("mr2_released").toBool());
+ QVERIFY(window.rootObject()->property("mr2_canceled").toBool());
QTest::qWait(200);
QMouseEvent releaseEvent(QEvent::MouseButtonRelease, QPoint(100, 100), Qt::LeftButton, Qt::LeftButton, 0);
- QGuiApplication::sendEvent(window, &releaseEvent);
-
- QVERIFY(window->rootObject()->property("mr1_released").toBool());
- QVERIFY(!window->rootObject()->property("mr1_canceled").toBool());
- QVERIFY(!window->rootObject()->property("mr2_released").toBool());
+ QGuiApplication::sendEvent(&window, &releaseEvent);
- delete window;
+ QVERIFY(window.rootObject()->property("mr1_released").toBool());
+ QVERIFY(!window.rootObject()->property("mr1_canceled").toBool());
+ QVERIFY(!window.rootObject()->property("mr2_released").toBool());
}
void tst_QQuickMouseArea::pressedCanceledOnWindowDeactivate()
{
- QQuickView *window = createView();
- window->setSource(testFileUrl("pressedCanceled.qml"));
- window->show();
- QTest::qWaitForWindowExposed(window);
- QVERIFY(window->rootObject() != 0);
- QVERIFY(!window->rootObject()->property("pressed").toBool());
- QVERIFY(!window->rootObject()->property("canceled").toBool());
- QVERIFY(!window->rootObject()->property("released").toBool());
+ QQuickView window;
+ QByteArray errorMessage;
+ QVERIFY2(initView(window, testFileUrl("pressedCanceled.qml"), true, &errorMessage), errorMessage.constData());
+ window.show();
+ QVERIFY(QTest::qWaitForWindowExposed(&window));
+ QVERIFY(window.rootObject() != 0);
+ QVERIFY(!window.rootObject()->property("pressed").toBool());
+ QVERIFY(!window.rootObject()->property("canceled").toBool());
+ QVERIFY(!window.rootObject()->property("released").toBool());
QMouseEvent pressEvent(QEvent::MouseButtonPress, QPoint(100, 100), Qt::LeftButton, Qt::LeftButton, 0);
- QGuiApplication::sendEvent(window, &pressEvent);
+ QGuiApplication::sendEvent(&window, &pressEvent);
- QVERIFY(window->rootObject()->property("pressed").toBool());
- QVERIFY(!window->rootObject()->property("canceled").toBool());
- QVERIFY(!window->rootObject()->property("released").toBool());
+ QVERIFY(window.rootObject()->property("pressed").toBool());
+ QVERIFY(!window.rootObject()->property("canceled").toBool());
+ QVERIFY(!window.rootObject()->property("released").toBool());
- QWindow *secondWindow = qvariant_cast<QWindow*>(window->rootObject()->property("secondWindow"));
+ QWindow *secondWindow = qvariant_cast<QWindow*>(window.rootObject()->property("secondWindow"));
secondWindow->setProperty("visible", true);
QTest::qWaitForWindowExposed(secondWindow);
- QVERIFY(!window->rootObject()->property("pressed").toBool());
- QVERIFY(window->rootObject()->property("canceled").toBool());
- QVERIFY(!window->rootObject()->property("released").toBool());
+ QVERIFY(!window.rootObject()->property("pressed").toBool());
+ QVERIFY(window.rootObject()->property("canceled").toBool());
+ QVERIFY(!window.rootObject()->property("released").toBool());
//press again
- QGuiApplication::sendEvent(window, &pressEvent);
- QVERIFY(window->rootObject()->property("pressed").toBool());
- QVERIFY(!window->rootObject()->property("canceled").toBool());
- QVERIFY(!window->rootObject()->property("released").toBool());
+ QGuiApplication::sendEvent(&window, &pressEvent);
+ QVERIFY(window.rootObject()->property("pressed").toBool());
+ QVERIFY(!window.rootObject()->property("canceled").toBool());
+ QVERIFY(!window.rootObject()->property("released").toBool());
QTest::qWait(200);
//release
QMouseEvent releaseEvent(QEvent::MouseButtonRelease, QPoint(100, 100), Qt::LeftButton, Qt::LeftButton, 0);
- QGuiApplication::sendEvent(window, &releaseEvent);
- QVERIFY(!window->rootObject()->property("pressed").toBool());
- QVERIFY(!window->rootObject()->property("canceled").toBool());
- QVERIFY(window->rootObject()->property("released").toBool());
-
- delete window;
+ QGuiApplication::sendEvent(&window, &releaseEvent);
+ QVERIFY(!window.rootObject()->property("pressed").toBool());
+ QVERIFY(!window.rootObject()->property("canceled").toBool());
+ QVERIFY(window.rootObject()->property("released").toBool());
}
void tst_QQuickMouseArea::doubleClick()
@@ -615,36 +617,35 @@ void tst_QQuickMouseArea::doubleClick()
QFETCH(Qt::MouseButtons, acceptedButtons);
QFETCH(Qt::MouseButton, button);
- QQuickView *window = createView();
- window->setSource(testFileUrl("doubleclick.qml"));
- window->show();
- QTest::qWaitForWindowExposed(window);
- QVERIFY(window->rootObject() != 0);
+ QQuickView window;
+ QByteArray errorMessage;
+ QVERIFY2(initView(window, testFileUrl("doubleclick.qml"), true, &errorMessage), errorMessage.constData());
+ window.show();
+ QVERIFY(QTest::qWaitForWindowExposed(&window));
+ QVERIFY(window.rootObject() != 0);
- QQuickMouseArea *mouseArea = window->rootObject()->findChild<QQuickMouseArea *>("mousearea");
+ QQuickMouseArea *mouseArea = window.rootObject()->findChild<QQuickMouseArea *>("mousearea");
QVERIFY(mouseArea);
mouseArea->setAcceptedButtons(acceptedButtons);
// The sequence for a double click is:
// press, release, (click), press, double click, release
QMouseEvent pressEvent(QEvent::MouseButtonPress, QPoint(100, 100), button, button, 0);
- QGuiApplication::sendEvent(window, &pressEvent);
+ QGuiApplication::sendEvent(&window, &pressEvent);
QMouseEvent releaseEvent(QEvent::MouseButtonRelease, QPoint(100, 100), button, button, 0);
- QGuiApplication::sendEvent(window, &releaseEvent);
+ QGuiApplication::sendEvent(&window, &releaseEvent);
- QCOMPARE(window->rootObject()->property("released").toInt(), 1);
+ QCOMPARE(window.rootObject()->property("released").toInt(), 1);
- QGuiApplication::sendEvent(window, &pressEvent);
+ QGuiApplication::sendEvent(&window, &pressEvent);
pressEvent = QMouseEvent(QEvent::MouseButtonDblClick, QPoint(100, 100), button, button, 0);
- QGuiApplication::sendEvent(window, &pressEvent);
- QGuiApplication::sendEvent(window, &releaseEvent);
+ QGuiApplication::sendEvent(&window, &pressEvent);
+ QGuiApplication::sendEvent(&window, &releaseEvent);
- QCOMPARE(window->rootObject()->property("clicked").toInt(), 1);
- QCOMPARE(window->rootObject()->property("doubleClicked").toInt(), 1);
- QCOMPARE(window->rootObject()->property("released").toInt(), 2);
-
- delete window;
+ QCOMPARE(window.rootObject()->property("clicked").toInt(), 1);
+ QCOMPARE(window.rootObject()->property("doubleClicked").toInt(), 1);
+ QCOMPARE(window.rootObject()->property("released").toInt(), 2);
}
// QTBUG-14832
@@ -653,36 +654,35 @@ void tst_QQuickMouseArea::clickTwice()
QFETCH(Qt::MouseButtons, acceptedButtons);
QFETCH(Qt::MouseButton, button);
- QQuickView *window = createView();
- window->setSource(testFileUrl("clicktwice.qml"));
- window->show();
- QTest::qWaitForWindowExposed(window);
- QVERIFY(window->rootObject() != 0);
+ QQuickView window;
+ QByteArray errorMessage;
+ QVERIFY2(initView(window, testFileUrl("clicktwice.qml"), true, &errorMessage), errorMessage.constData());
+ window.show();
+ QVERIFY(QTest::qWaitForWindowExposed(&window));
+ QVERIFY(window.rootObject() != 0);
- QQuickMouseArea *mouseArea = window->rootObject()->findChild<QQuickMouseArea *>("mousearea");
+ QQuickMouseArea *mouseArea = window.rootObject()->findChild<QQuickMouseArea *>("mousearea");
QVERIFY(mouseArea);
mouseArea->setAcceptedButtons(acceptedButtons);
QMouseEvent pressEvent(QEvent::MouseButtonPress, QPoint(100, 100), button, button, 0);
- QGuiApplication::sendEvent(window, &pressEvent);
+ QGuiApplication::sendEvent(&window, &pressEvent);
QMouseEvent releaseEvent(QEvent::MouseButtonRelease, QPoint(100, 100), button, button, 0);
- QGuiApplication::sendEvent(window, &releaseEvent);
+ QGuiApplication::sendEvent(&window, &releaseEvent);
- QCOMPARE(window->rootObject()->property("pressed").toInt(), 1);
- QCOMPARE(window->rootObject()->property("released").toInt(), 1);
- QCOMPARE(window->rootObject()->property("clicked").toInt(), 1);
+ QCOMPARE(window.rootObject()->property("pressed").toInt(), 1);
+ QCOMPARE(window.rootObject()->property("released").toInt(), 1);
+ QCOMPARE(window.rootObject()->property("clicked").toInt(), 1);
- QGuiApplication::sendEvent(window, &pressEvent);
+ QGuiApplication::sendEvent(&window, &pressEvent);
pressEvent = QMouseEvent(QEvent::MouseButtonDblClick, QPoint(100, 100), button, button, 0);
- QGuiApplication::sendEvent(window, &pressEvent);
- QGuiApplication::sendEvent(window, &releaseEvent);
+ QGuiApplication::sendEvent(&window, &pressEvent);
+ QGuiApplication::sendEvent(&window, &releaseEvent);
- QCOMPARE(window->rootObject()->property("pressed").toInt(), 2);
- QCOMPARE(window->rootObject()->property("released").toInt(), 2);
- QCOMPARE(window->rootObject()->property("clicked").toInt(), 2);
-
- delete window;
+ QCOMPARE(window.rootObject()->property("pressed").toInt(), 2);
+ QCOMPARE(window.rootObject()->property("released").toInt(), 2);
+ QCOMPARE(window.rootObject()->property("clicked").toInt(), 2);
}
void tst_QQuickMouseArea::invalidClick()
@@ -690,90 +690,88 @@ void tst_QQuickMouseArea::invalidClick()
QFETCH(Qt::MouseButtons, acceptedButtons);
QFETCH(Qt::MouseButton, button);
- QQuickView *window = createView();
- window->setSource(testFileUrl("doubleclick.qml"));
- window->show();
- QTest::qWaitForWindowExposed(window);
- QVERIFY(window->rootObject() != 0);
+ QQuickView window;
+ QByteArray errorMessage;
+ QVERIFY2(initView(window, testFileUrl("doubleclick.qml"), true, &errorMessage), errorMessage.constData());
+ window.show();
+ QVERIFY(QTest::qWaitForWindowExposed(&window));
+ QVERIFY(window.rootObject() != 0);
- QQuickMouseArea *mouseArea = window->rootObject()->findChild<QQuickMouseArea *>("mousearea");
+ QQuickMouseArea *mouseArea = window.rootObject()->findChild<QQuickMouseArea *>("mousearea");
QVERIFY(mouseArea);
mouseArea->setAcceptedButtons(acceptedButtons);
// The sequence for a double click is:
// press, release, (click), press, double click, release
QMouseEvent pressEvent(QEvent::MouseButtonPress, QPoint(100, 100), button, button, 0);
- QGuiApplication::sendEvent(window, &pressEvent);
+ QGuiApplication::sendEvent(&window, &pressEvent);
QMouseEvent releaseEvent(QEvent::MouseButtonRelease, QPoint(100, 100), button, button, 0);
- QGuiApplication::sendEvent(window, &releaseEvent);
+ QGuiApplication::sendEvent(&window, &releaseEvent);
- QCOMPARE(window->rootObject()->property("released").toInt(), 0);
+ QCOMPARE(window.rootObject()->property("released").toInt(), 0);
- QGuiApplication::sendEvent(window, &pressEvent);
+ QGuiApplication::sendEvent(&window, &pressEvent);
pressEvent = QMouseEvent(QEvent::MouseButtonDblClick, QPoint(100, 100), button, button, 0);
- QGuiApplication::sendEvent(window, &pressEvent);
- QGuiApplication::sendEvent(window, &releaseEvent);
+ QGuiApplication::sendEvent(&window, &pressEvent);
+ QGuiApplication::sendEvent(&window, &releaseEvent);
- QCOMPARE(window->rootObject()->property("clicked").toInt(), 0);
- QCOMPARE(window->rootObject()->property("doubleClicked").toInt(), 0);
- QCOMPARE(window->rootObject()->property("released").toInt(), 0);
-
- delete window;
+ QCOMPARE(window.rootObject()->property("clicked").toInt(), 0);
+ QCOMPARE(window.rootObject()->property("doubleClicked").toInt(), 0);
+ QCOMPARE(window.rootObject()->property("released").toInt(), 0);
}
void tst_QQuickMouseArea::pressedOrdering()
{
- QQuickView *window = createView();
- window->setSource(testFileUrl("pressedOrdering.qml"));
- window->show();
- QTest::qWaitForWindowExposed(window);
- QVERIFY(window->rootObject() != 0);
+ QQuickView window;
+ QByteArray errorMessage;
+ QVERIFY2(initView(window, testFileUrl("pressedOrdering.qml"), true, &errorMessage), errorMessage.constData());
+ window.show();
+ QVERIFY(QTest::qWaitForWindowExposed(&window));
+ QVERIFY(window.rootObject() != 0);
- QCOMPARE(window->rootObject()->property("value").toString(), QLatin1String("base"));
+ QCOMPARE(window.rootObject()->property("value").toString(), QLatin1String("base"));
QMouseEvent pressEvent(QEvent::MouseButtonPress, QPoint(100, 100), Qt::LeftButton, Qt::LeftButton, 0);
- QGuiApplication::sendEvent(window, &pressEvent);
+ QGuiApplication::sendEvent(&window, &pressEvent);
- QCOMPARE(window->rootObject()->property("value").toString(), QLatin1String("pressed"));
+ QCOMPARE(window.rootObject()->property("value").toString(), QLatin1String("pressed"));
QMouseEvent releaseEvent(QEvent::MouseButtonRelease, QPoint(100, 100), Qt::LeftButton, Qt::LeftButton, 0);
- QGuiApplication::sendEvent(window, &releaseEvent);
+ QGuiApplication::sendEvent(&window, &releaseEvent);
- QCOMPARE(window->rootObject()->property("value").toString(), QLatin1String("toggled"));
+ QCOMPARE(window.rootObject()->property("value").toString(), QLatin1String("toggled"));
- QGuiApplication::sendEvent(window, &pressEvent);
+ QGuiApplication::sendEvent(&window, &pressEvent);
- QCOMPARE(window->rootObject()->property("value").toString(), QLatin1String("pressed"));
-
- delete window;
+ QCOMPARE(window.rootObject()->property("value").toString(), QLatin1String("pressed"));
}
void tst_QQuickMouseArea::preventStealing()
{
- QQuickView *window = createView();
-
- window->setSource(testFileUrl("preventstealing.qml"));
- window->show();
- QTest::qWaitForWindowExposed(window);
- QVERIFY(window->rootObject() != 0);
-
- QQuickFlickable *flickable = qobject_cast<QQuickFlickable*>(window->rootObject());
+ QQuickView window;
+ QByteArray errorMessage;
+ QVERIFY2(initView(window, testFileUrl("preventstealing.qml"), true, &errorMessage), errorMessage.constData());
+ window.show();
+ QVERIFY(QTest::qWaitForWindowExposed(&window));
+ QVERIFY(window.rootObject() != 0);
+
+ QQuickFlickable *flickable = qobject_cast<QQuickFlickable*>(window.rootObject());
QVERIFY(flickable != 0);
- QQuickMouseArea *mouseArea = window->rootObject()->findChild<QQuickMouseArea*>("mousearea");
+ QQuickMouseArea *mouseArea = window.rootObject()->findChild<QQuickMouseArea*>("mousearea");
QVERIFY(mouseArea != 0);
QSignalSpy mousePositionSpy(mouseArea, SIGNAL(positionChanged(QQuickMouseEvent*)));
- QTest::mousePress(window, Qt::LeftButton, 0, QPoint(80, 80));
+ QTest::mousePress(&window, Qt::LeftButton, 0, QPoint(80, 80));
// Without preventStealing, mouse movement over MouseArea would
// cause the Flickable to steal mouse and trigger content movement.
- QTest::mouseMove(window,QPoint(69,69));
- QTest::mouseMove(window,QPoint(58,58));
- QTest::mouseMove(window,QPoint(47,47));
+ QTest::mouseMove(&window,QPoint(69,69));
+ QTest::mouseMove(&window,QPoint(58,58));
+ QTest::mouseMove(&window,QPoint(47,47));
// We should have received all three move events
QCOMPARE(mousePositionSpy.count(), 3);
@@ -783,19 +781,19 @@ void tst_QQuickMouseArea::preventStealing()
QCOMPARE(flickable->contentX(), 0.);
QCOMPARE(flickable->contentY(), 0.);
- QTest::mouseRelease(window, Qt::LeftButton, 0, QPoint(47, 47));
+ QTest::mouseRelease(&window, Qt::LeftButton, 0, QPoint(47, 47));
// Now allow stealing and confirm Flickable does its thing.
- window->rootObject()->setProperty("stealing", false);
+ window.rootObject()->setProperty("stealing", false);
- QTest::mousePress(window, Qt::LeftButton, 0, QPoint(80, 80));
+ QTest::mousePress(&window, Qt::LeftButton, 0, QPoint(80, 80));
// Without preventStealing, mouse movement over MouseArea would
// cause the Flickable to steal mouse and trigger content movement.
- QTest::mouseMove(window,QPoint(69,69));
- QTest::mouseMove(window,QPoint(58,58));
- QTest::mouseMove(window,QPoint(47,47));
+ QTest::mouseMove(&window,QPoint(69,69));
+ QTest::mouseMove(&window,QPoint(58,58));
+ QTest::mouseMove(&window,QPoint(47,47));
// We should only have received the first move event
QCOMPARE(mousePositionSpy.count(), 4);
@@ -807,23 +805,22 @@ void tst_QQuickMouseArea::preventStealing()
QCOMPARE(flickable->contentX(), 11.);
QCOMPARE(flickable->contentY(), 11.);
- QTest::mouseRelease(window, Qt::LeftButton, 0, QPoint(50, 50));
-
- delete window;
+ QTest::mouseRelease(&window, Qt::LeftButton, 0, QPoint(50, 50));
}
void tst_QQuickMouseArea::clickThrough()
{
QSKIP("QTBUG-23976 Unstable");
//With no handlers defined click, doubleClick and PressAndHold should propagate to those with handlers
- QQuickView *window = createView();
- window->setSource(testFileUrl("clickThrough.qml"));
+ QScopedPointer<QQuickView> window(new QQuickView);
+ QByteArray errorMessage;
+ QVERIFY2(initView(*window.data(), testFileUrl("clickThrough.qml"), true, &errorMessage), errorMessage.constData());
window->show();
- QTest::qWaitForWindowExposed(window);
+ QVERIFY(QTest::qWaitForWindowExposed(window.data()));
QVERIFY(window->rootObject() != 0);
- QTest::mousePress(window, Qt::LeftButton, 0, QPoint(100,100));
- QTest::mouseRelease(window, Qt::LeftButton, 0, QPoint(100,100));
+ QTest::mousePress(window.data(), Qt::LeftButton, 0, QPoint(100,100));
+ QTest::mouseRelease(window.data(), Qt::LeftButton, 0, QPoint(100,100));
QTRY_COMPARE(window->rootObject()->property("presses").toInt(), 0);
QTRY_COMPARE(window->rootObject()->property("clicks").toInt(), 1);
@@ -832,15 +829,15 @@ void tst_QQuickMouseArea::clickThrough()
int doubleClickInterval = qApp->styleHints()->mouseDoubleClickInterval() + 10;
QTest::qWait(doubleClickInterval);
- QTest::mousePress(window, Qt::LeftButton, 0, QPoint(100,100));
+ QTest::mousePress(window.data(), Qt::LeftButton, 0, QPoint(100,100));
QTest::qWait(1000);
- QTest::mouseRelease(window, Qt::LeftButton, 0, QPoint(100,100));
+ QTest::mouseRelease(window.data(), Qt::LeftButton, 0, QPoint(100,100));
QTRY_COMPARE(window->rootObject()->property("presses").toInt(), 0);
QTRY_COMPARE(window->rootObject()->property("clicks").toInt(), 1);
QTRY_COMPARE(window->rootObject()->property("pressAndHolds").toInt(), 1);
- QTest::mouseDClick(window, Qt::LeftButton, 0, QPoint(100,100));
+ QTest::mouseDClick(window.data(), Qt::LeftButton, 0, QPoint(100,100));
QTest::qWait(100);
QCOMPARE(window->rootObject()->property("presses").toInt(), 0);
@@ -848,33 +845,32 @@ void tst_QQuickMouseArea::clickThrough()
QTRY_COMPARE(window->rootObject()->property("doubleClicks").toInt(), 1);
QCOMPARE(window->rootObject()->property("pressAndHolds").toInt(), 1);
- delete window;
+ window.reset(new QQuickView);
//With handlers defined click, doubleClick and PressAndHold should propagate only when explicitly ignored
- window = createView();
- window->setSource(testFileUrl("clickThrough2.qml"));
+ QVERIFY2(initView(*window.data(), testFileUrl("clickThrough2.qml"), true, &errorMessage), errorMessage.constData());
window->show();
- QTest::qWaitForWindowExposed(window);
+ QVERIFY(QTest::qWaitForWindowExposed(window.data()));
QVERIFY(window->rootObject() != 0);
- QTest::mousePress(window, Qt::LeftButton, 0, QPoint(100,100));
- QTest::mouseRelease(window, Qt::LeftButton, 0, QPoint(100,100));
+ QTest::mousePress(window.data(), Qt::LeftButton, 0, QPoint(100,100));
+ QTest::mouseRelease(window.data(), Qt::LeftButton, 0, QPoint(100,100));
QCOMPARE(window->rootObject()->property("presses").toInt(), 0);
QCOMPARE(window->rootObject()->property("clicks").toInt(), 0);
QTest::qWait(doubleClickInterval); // to avoid generating a double click.
- QTest::mousePress(window, Qt::LeftButton, 0, QPoint(100,100));
+ QTest::mousePress(window.data(), Qt::LeftButton, 0, QPoint(100,100));
QTest::qWait(1000);
- QTest::mouseRelease(window, Qt::LeftButton, 0, QPoint(100,100));
+ QTest::mouseRelease(window.data(), Qt::LeftButton, 0, QPoint(100,100));
QTest::qWait(100);
QCOMPARE(window->rootObject()->property("presses").toInt(), 0);
QCOMPARE(window->rootObject()->property("clicks").toInt(), 0);
QCOMPARE(window->rootObject()->property("pressAndHolds").toInt(), 0);
- QTest::mouseDClick(window, Qt::LeftButton, 0, QPoint(100,100));
+ QTest::mouseDClick(window.data(), Qt::LeftButton, 0, QPoint(100,100));
QTest::qWait(100);
QCOMPARE(window->rootObject()->property("presses").toInt(), 0);
@@ -885,23 +881,23 @@ void tst_QQuickMouseArea::clickThrough()
window->rootObject()->setProperty("letThrough", QVariant(true));
QTest::qWait(doubleClickInterval); // to avoid generating a double click.
- QTest::mousePress(window, Qt::LeftButton, 0, QPoint(100,100));
- QTest::mouseRelease(window, Qt::LeftButton, 0, QPoint(100,100));
+ QTest::mousePress(window.data(), Qt::LeftButton, 0, QPoint(100,100));
+ QTest::mouseRelease(window.data(), Qt::LeftButton, 0, QPoint(100,100));
QCOMPARE(window->rootObject()->property("presses").toInt(), 0);
QTRY_COMPARE(window->rootObject()->property("clicks").toInt(), 1);
QTest::qWait(doubleClickInterval); // to avoid generating a double click.
- QTest::mousePress(window, Qt::LeftButton, 0, QPoint(100,100));
+ QTest::mousePress(window.data(), Qt::LeftButton, 0, QPoint(100,100));
QTest::qWait(1000);
- QTest::mouseRelease(window, Qt::LeftButton, 0, QPoint(100,100));
+ QTest::mouseRelease(window.data(), Qt::LeftButton, 0, QPoint(100,100));
QTest::qWait(100);
QCOMPARE(window->rootObject()->property("presses").toInt(), 0);
QCOMPARE(window->rootObject()->property("clicks").toInt(), 1);
QCOMPARE(window->rootObject()->property("pressAndHolds").toInt(), 1);
- QTest::mouseDClick(window, Qt::LeftButton, 0, QPoint(100,100));
+ QTest::mouseDClick(window.data(), Qt::LeftButton, 0, QPoint(100,100));
QTest::qWait(100);
QCOMPARE(window->rootObject()->property("presses").toInt(), 0);
@@ -912,88 +908,82 @@ void tst_QQuickMouseArea::clickThrough()
window->rootObject()->setProperty("noPropagation", QVariant(true));
QTest::qWait(doubleClickInterval); // to avoid generating a double click.
- QTest::mousePress(window, Qt::LeftButton, 0, QPoint(100,100));
- QTest::mouseRelease(window, Qt::LeftButton, 0, QPoint(100,100));
+ QTest::mousePress(window.data(), Qt::LeftButton, 0, QPoint(100,100));
+ QTest::mouseRelease(window.data(), Qt::LeftButton, 0, QPoint(100,100));
QTest::qWait(doubleClickInterval); // to avoid generating a double click.
- QTest::mousePress(window, Qt::LeftButton, 0, QPoint(100,100));
+ QTest::mousePress(window.data(), Qt::LeftButton, 0, QPoint(100,100));
QTest::qWait(1000);
- QTest::mouseRelease(window, Qt::LeftButton, 0, QPoint(100,100));
+ QTest::mouseRelease(window.data(), Qt::LeftButton, 0, QPoint(100,100));
QTest::qWait(100);
- QTest::mouseDClick(window, Qt::LeftButton, 0, QPoint(100,100));
+ QTest::mouseDClick(window.data(), Qt::LeftButton, 0, QPoint(100,100));
QTest::qWait(100);
QCOMPARE(window->rootObject()->property("presses").toInt(), 0);
QTRY_COMPARE(window->rootObject()->property("clicks").toInt(), 2);
QCOMPARE(window->rootObject()->property("doubleClicks").toInt(), 1);
QCOMPARE(window->rootObject()->property("pressAndHolds").toInt(), 1);
-
- delete window;
}
void tst_QQuickMouseArea::hoverPosition()
{
- QQuickView *window = createView();
- window->setSource(testFileUrl("hoverPosition.qml"));
-
- QQuickItem *root = window->rootObject();
+ QQuickView window;
+ QByteArray errorMessage;
+ QVERIFY2(initView(window, testFileUrl("hoverPosition.qml"), true, &errorMessage), errorMessage.constData());
+ QQuickItem *root = window.rootObject();
QVERIFY(root != 0);
QCOMPARE(root->property("mouseX").toReal(), qreal(0));
QCOMPARE(root->property("mouseY").toReal(), qreal(0));
- QTest::mouseMove(window,QPoint(10,32));
+ QTest::mouseMove(&window,QPoint(10,32));
QCOMPARE(root->property("mouseX").toReal(), qreal(10));
QCOMPARE(root->property("mouseY").toReal(), qreal(32));
-
- delete window;
}
void tst_QQuickMouseArea::hoverPropagation()
{
//QTBUG-18175, to behave like GV did.
- QQuickView *window = createView();
- window->setSource(testFileUrl("hoverPropagation.qml"));
-
- QQuickItem *root = window->rootObject();
+ QQuickView window;
+ QByteArray errorMessage;
+ QVERIFY2(initView(window, testFileUrl("hoverPropagation.qml"), true, &errorMessage), errorMessage.constData());
+ QQuickItem *root = window.rootObject();
QVERIFY(root != 0);
QCOMPARE(root->property("point1").toBool(), false);
QCOMPARE(root->property("point2").toBool(), false);
QMouseEvent moveEvent(QEvent::MouseMove, QPoint(32, 32), Qt::NoButton, Qt::NoButton, 0);
- QGuiApplication::sendEvent(window, &moveEvent);
+ QGuiApplication::sendEvent(&window, &moveEvent);
QCOMPARE(root->property("point1").toBool(), true);
QCOMPARE(root->property("point2").toBool(), false);
QMouseEvent moveEvent2(QEvent::MouseMove, QPoint(232, 32), Qt::NoButton, Qt::NoButton, 0);
- QGuiApplication::sendEvent(window, &moveEvent2);
+ QGuiApplication::sendEvent(&window, &moveEvent2);
QCOMPARE(root->property("point1").toBool(), false);
QCOMPARE(root->property("point2").toBool(), true);
-
- delete window;
}
void tst_QQuickMouseArea::hoverVisible()
{
- QQuickView *window = createView();
- window->setSource(testFileUrl("hoverVisible.qml"));
-
- QQuickItem *root = window->rootObject();
+ QQuickView window;
+ QByteArray errorMessage;
+ QVERIFY2(initView(window, testFileUrl("hoverVisible.qml"), true, &errorMessage), errorMessage.constData());
+ QQuickItem *root = window.rootObject();
QVERIFY(root != 0);
- QQuickMouseArea *mouseTracker = window->rootObject()->findChild<QQuickMouseArea*>("mousetracker");
+ QQuickMouseArea *mouseTracker = window.rootObject()->findChild<QQuickMouseArea*>("mousetracker");
QVERIFY(mouseTracker != 0);
QSignalSpy enteredSpy(mouseTracker, SIGNAL(entered()));
// Note: We need to use a position that is different from the position in the last event
// generated in the previous test case. Otherwise it is not interpreted as a move.
- QTest::mouseMove(window,QPoint(11,33));
+ QTest::mouseMove(&window,QPoint(11,33));
QCOMPARE(mouseTracker->hovered(), false);
QCOMPARE(enteredSpy.count(), 0);
@@ -1004,46 +994,44 @@ void tst_QQuickMouseArea::hoverVisible()
QCOMPARE(enteredSpy.count(), 1);
QCOMPARE(QPointF(mouseTracker->mouseX(), mouseTracker->mouseY()), QPointF(11,33));
-
- delete window;
}
void tst_QQuickMouseArea::hoverAfterPress()
{
- QQuickView *window = createView();
- window->setSource(testFileUrl("hoverAfterPress.qml"));
-
- QQuickItem *root = window->rootObject();
+ QQuickView window;
+ QByteArray errorMessage;
+ QVERIFY2(initView(window, testFileUrl("hoverAfterPress.qml"), true, &errorMessage), errorMessage.constData());
+ QQuickItem *root = window.rootObject();
QVERIFY(root != 0);
- QQuickMouseArea *mouseArea = window->rootObject()->findChild<QQuickMouseArea*>("mouseArea");
+ QQuickMouseArea *mouseArea = window.rootObject()->findChild<QQuickMouseArea*>("mouseArea");
QVERIFY(mouseArea != 0);
- QTest::mouseMove(window, QPoint(22,33));
+ QTest::mouseMove(&window, QPoint(22,33));
QCOMPARE(mouseArea->hovered(), false);
- QTest::mouseMove(window, QPoint(200,200));
+ QTest::mouseMove(&window, QPoint(200,200));
QCOMPARE(mouseArea->hovered(), true);
- QTest::mouseMove(window, QPoint(22,33));
+ QTest::mouseMove(&window, QPoint(22,33));
QCOMPARE(mouseArea->hovered(), false);
- QTest::mouseMove(window, QPoint(200,200));
+ QTest::mouseMove(&window, QPoint(200,200));
QCOMPARE(mouseArea->hovered(), true);
- QTest::mousePress(window, Qt::LeftButton, Qt::NoModifier, QPoint(200,200));
+ QTest::mousePress(&window, Qt::LeftButton, Qt::NoModifier, QPoint(200,200));
QCOMPARE(mouseArea->hovered(), true);
- QTest::mouseRelease(window, Qt::LeftButton, Qt::NoModifier, QPoint(200,200));
+ QTest::mouseRelease(&window, Qt::LeftButton, Qt::NoModifier, QPoint(200,200));
QCOMPARE(mouseArea->hovered(), true);
- QTest::mouseMove(window, QPoint(22,33));
+ QTest::mouseMove(&window, QPoint(22,33));
QCOMPARE(mouseArea->hovered(), false);
- delete window;
}
void tst_QQuickMouseArea::disableAfterPress()
{
- QQuickView *window = createView();
- window->setSource(testFileUrl("dragging.qml"));
- window->show();
- QTest::qWaitForWindowExposed(window);
- QVERIFY(window->rootObject() != 0);
-
- QQuickMouseArea *mouseArea = window->rootObject()->findChild<QQuickMouseArea*>("mouseregion");
+ QQuickView window;
+ QByteArray errorMessage;
+ QVERIFY2(initView(window, testFileUrl("dragging.qml"), true, &errorMessage), errorMessage.constData());
+ window.show();
+ QVERIFY(QTest::qWaitForWindowExposed(&window));
+ QVERIFY(window.rootObject() != 0);
+
+ QQuickMouseArea *mouseArea = window.rootObject()->findChild<QQuickMouseArea*>("mouseregion");
QQuickDrag *drag = mouseArea->drag();
QVERIFY(mouseArea != 0);
QVERIFY(drag != 0);
@@ -1053,13 +1041,13 @@ void tst_QQuickMouseArea::disableAfterPress()
QSignalSpy mouseReleaseSpy(mouseArea, SIGNAL(released(QQuickMouseEvent*)));
// target
- QQuickItem *blackRect = window->rootObject()->findChild<QQuickItem*>("blackrect");
+ QQuickItem *blackRect = window.rootObject()->findChild<QQuickItem*>("blackrect");
QVERIFY(blackRect != 0);
QVERIFY(blackRect == drag->target());
QVERIFY(!drag->active());
- QTest::mousePress(window, Qt::LeftButton, 0, QPoint(100,100));
+ QTest::mousePress(&window, Qt::LeftButton, 0, QPoint(100,100));
QTRY_COMPARE(mousePressSpy.count(), 1);
@@ -1070,9 +1058,9 @@ void tst_QQuickMouseArea::disableAfterPress()
// First move event triggers drag, second is acted upon.
// This is due to possibility of higher stacked area taking precedence.
- QTest::mouseMove(window, QPoint(111,111));
+ QTest::mouseMove(&window, QPoint(111,111));
QTest::qWait(50);
- QTest::mouseMove(window, QPoint(122,122));
+ QTest::mouseMove(&window, QPoint(122,122));
QTRY_COMPARE(mousePositionSpy.count(), 2);
@@ -1083,9 +1071,9 @@ void tst_QQuickMouseArea::disableAfterPress()
mouseArea->setEnabled(false);
// move should still be acted upon
- QTest::mouseMove(window, QPoint(133,133));
+ QTest::mouseMove(&window, QPoint(133,133));
QTest::qWait(50);
- QTest::mouseMove(window, QPoint(144,144));
+ QTest::mouseMove(&window, QPoint(144,144));
QTRY_COMPARE(mousePositionSpy.count(), 4);
@@ -1096,7 +1084,7 @@ void tst_QQuickMouseArea::disableAfterPress()
QVERIFY(mouseArea->pressed());
QVERIFY(mouseArea->hovered());
- QTest::mouseRelease(window, Qt::LeftButton, 0, QPoint(144,144));
+ QTest::mouseRelease(&window, Qt::LeftButton, 0, QPoint(144,144));
QTRY_COMPARE(mouseReleaseSpy.count(), 1);
@@ -1115,13 +1103,13 @@ void tst_QQuickMouseArea::disableAfterPress()
mousePositionSpy.clear();
mouseReleaseSpy.clear();
- QTest::mousePress(window, Qt::LeftButton, 0, QPoint(100,100));
+ QTest::mousePress(&window, Qt::LeftButton, 0, QPoint(100,100));
QTest::qWait(50);
QCOMPARE(mousePressSpy.count(), 0);
- QTest::mouseMove(window, QPoint(111,111));
+ QTest::mouseMove(&window, QPoint(111,111));
QTest::qWait(50);
- QTest::mouseMove(window, QPoint(122,122));
+ QTest::mouseMove(&window, QPoint(122,122));
QTest::qWait(50);
QCOMPARE(mousePositionSpy.count(), 0);
@@ -1130,32 +1118,28 @@ void tst_QQuickMouseArea::disableAfterPress()
QCOMPARE(blackRect->x(), 50.0);
QCOMPARE(blackRect->y(), 50.0);
- QTest::mouseRelease(window, Qt::LeftButton, 0, QPoint(122,122));
+ QTest::mouseRelease(&window, Qt::LeftButton, 0, QPoint(122,122));
QTest::qWait(50);
QCOMPARE(mouseReleaseSpy.count(), 0);
-
- delete window;
}
void tst_QQuickMouseArea::onWheel()
{
- QQuickView *window = createView();
- window->setSource(testFileUrl("wheel.qml"));
-
- QQuickItem *root = window->rootObject();
+ QQuickView window;
+ QByteArray errorMessage;
+ QVERIFY2(initView(window, testFileUrl("wheel.qml"), true, &errorMessage), errorMessage.constData());
+ QQuickItem *root = window.rootObject();
QVERIFY(root != 0);
QWheelEvent wheelEvent(QPoint(10, 32), QPoint(10, 32), QPoint(60, 20), QPoint(0, 120),
0, Qt::Vertical,Qt::NoButton, Qt::ControlModifier);
- QGuiApplication::sendEvent(window, &wheelEvent);
+ QGuiApplication::sendEvent(&window, &wheelEvent);
QCOMPARE(root->property("angleDeltaY").toInt(), 120);
QCOMPARE(root->property("mouseX").toReal(), qreal(10));
QCOMPARE(root->property("mouseY").toReal(), qreal(32));
QCOMPARE(root->property("controlPressed").toBool(), true);
-
- delete window;
}
void tst_QQuickMouseArea::transformedMouseArea_data()
@@ -1186,30 +1170,29 @@ void tst_QQuickMouseArea::transformedMouseArea()
QFETCH(bool, insideTarget);
QFETCH(QList<QPoint>, points);
- QQuickView *window = createView();
- window->setSource(testFileUrl("transformedMouseArea.qml"));
- window->show();
- QTest::qWaitForWindowExposed(window);
- QVERIFY(window->rootObject() != 0);
+ QQuickView window;
+ QByteArray errorMessage;
+ QVERIFY2(initView(window, testFileUrl("transformedMouseArea.qml"), true, &errorMessage), errorMessage.constData());
+ window.show();
+ QVERIFY(QTest::qWaitForWindowExposed(&window));
+ QVERIFY(window.rootObject() != 0);
- QQuickMouseArea *mouseArea = window->rootObject()->findChild<QQuickMouseArea *>("mouseArea");
+ QQuickMouseArea *mouseArea = window.rootObject()->findChild<QQuickMouseArea *>("mouseArea");
QVERIFY(mouseArea != 0);
foreach (const QPoint &point, points) {
// check hover
- QTest::mouseMove(window, point);
+ QTest::mouseMove(&window, point);
QTRY_COMPARE(mouseArea->property("containsMouse").toBool(), insideTarget);
// check mouse press
- QTest::mousePress(window, Qt::LeftButton, 0, point);
+ QTest::mousePress(&window, Qt::LeftButton, 0, point);
QTRY_COMPARE(mouseArea->property("pressed").toBool(), insideTarget);
// check mouse release
- QTest::mouseRelease(window, Qt::LeftButton, 0, point);
+ QTest::mouseRelease(&window, Qt::LeftButton, 0, point);
QTRY_COMPARE(mouseArea->property("pressed").toBool(), false);
}
-
- delete window;
}
void tst_QQuickMouseArea::pressedMultipleButtons_data()
@@ -1301,13 +1284,14 @@ void tst_QQuickMouseArea::pressedMultipleButtons()
QFETCH(QList<Qt::MouseButtons>, pressedButtons);
QFETCH(int, changeCount);
- QQuickView *view = createView();
- view->setSource(testFileUrl("simple.qml"));
- view->show();
- QTest::qWaitForWindowExposed(view);
- QVERIFY(view->rootObject() != 0);
+ QQuickView view;
+ QByteArray errorMessage;
+ QVERIFY2(initView(view, testFileUrl("simple.qml"), true, &errorMessage), errorMessage.constData());
+ view.show();
+ QTest::qWaitForWindowExposed(&view);
+ QVERIFY(view.rootObject() != 0);
- QQuickMouseArea *mouseArea = view->rootObject()->findChild<QQuickMouseArea *>("mousearea");
+ QQuickMouseArea *mouseArea = view.rootObject()->findChild<QQuickMouseArea *>("mousearea");
QVERIFY(mouseArea != 0);
QSignalSpy pressedSpy(mouseArea, SIGNAL(pressedChanged()));
@@ -1320,31 +1304,29 @@ void tst_QQuickMouseArea::pressedMultipleButtons()
int btns = buttons.at(i);
// The windowsysteminterface takes care of sending releases
- QTest::mousePress(view, (Qt::MouseButton)btns, 0, point);
+ QTest::mousePress(&view, (Qt::MouseButton)btns, 0, point);
QCOMPARE(mouseArea->pressed(), pressed.at(i));
QCOMPARE(mouseArea->pressedButtons(), pressedButtons.at(i));
}
- QTest::mousePress(view, Qt::NoButton, 0, point);
+ QTest::mousePress(&view, Qt::NoButton, 0, point);
QCOMPARE(mouseArea->pressed(), false);
QCOMPARE(pressedSpy.count(), 2);
QCOMPARE(pressedButtonsSpy.count(), changeCount);
-
- delete view;
}
void tst_QQuickMouseArea::changeAxis()
{
- QQuickView *view = createView();
-
- view->setSource(testFileUrl("changeAxis.qml"));
- view->show();
- QTest::qWaitForWindowExposed(view);
- QTRY_VERIFY(view->rootObject() != 0);
+ QQuickView view;
+ QByteArray errorMessage;
+ QVERIFY2(initView(view, testFileUrl("changeAxis.qml"), true, &errorMessage), errorMessage.constData());
+ view.show();
+ QVERIFY(QTest::qWaitForWindowExposed(&view));
+ QTRY_VERIFY(view.rootObject() != 0);
- QQuickMouseArea *mouseRegion = view->rootObject()->findChild<QQuickMouseArea*>("mouseregion");
+ QQuickMouseArea *mouseRegion = view.rootObject()->findChild<QQuickMouseArea*>("mouseregion");
QQuickDrag *drag = mouseRegion->drag();
QVERIFY(mouseRegion != 0);
QVERIFY(drag != 0);
@@ -1352,22 +1334,22 @@ void tst_QQuickMouseArea::changeAxis()
mouseRegion->setAcceptedButtons(Qt::LeftButton);
// target
- QQuickItem *blackRect = view->rootObject()->findChild<QQuickItem*>("blackrect");
+ QQuickItem *blackRect = view.rootObject()->findChild<QQuickItem*>("blackrect");
QVERIFY(blackRect != 0);
QVERIFY(blackRect == drag->target());
QVERIFY(!drag->active());
// Start a diagonal drag
- QTest::mousePress(view, Qt::LeftButton, 0, QPoint(100, 100));
+ QTest::mousePress(&view, Qt::LeftButton, 0, QPoint(100, 100));
QVERIFY(!drag->active());
QCOMPARE(blackRect->x(), 50.0);
QCOMPARE(blackRect->y(), 50.0);
- QTest::mouseMove(view, QPoint(111, 111));
+ QTest::mouseMove(&view, QPoint(111, 111));
QTest::qWait(50);
- QTest::mouseMove(view, QPoint(122, 122));
+ QTest::mouseMove(&view, QPoint(122, 122));
QTRY_VERIFY(drag->active());
QCOMPARE(blackRect->x(), 61.0);
@@ -1377,24 +1359,22 @@ void tst_QQuickMouseArea::changeAxis()
/* When blackRect.x becomes bigger than 75, the drag axis is changed to
* Drag.YAxis by the QML code. Verify that this happens, and that the drag
* movement is effectively constrained to the Y axis. */
- QTest::mouseMove(view, QPoint(144, 144));
+ QTest::mouseMove(&view, QPoint(144, 144));
QTRY_COMPARE(blackRect->x(), 83.0);
QTRY_COMPARE(blackRect->y(), 83.0);
QTRY_COMPARE(drag->axis(), QQuickDrag::YAxis);
- QTest::mouseMove(view, QPoint(155, 155));
+ QTest::mouseMove(&view, QPoint(155, 155));
QTRY_COMPARE(blackRect->y(), 94.0);
QCOMPARE(blackRect->x(), 83.0);
- QTest::mouseRelease(view, Qt::LeftButton, 0, QPoint(155, 155));
+ QTest::mouseRelease(&view, Qt::LeftButton, 0, QPoint(155, 155));
QTRY_VERIFY(!drag->active());
QCOMPARE(blackRect->x(), 83.0);
QCOMPARE(blackRect->y(), 94.0);
-
- delete view;
}
#ifndef QT_NO_CURSOR
@@ -1429,25 +1409,22 @@ void tst_QQuickMouseArea::cursorShape()
void tst_QQuickMouseArea::moveAndReleaseWithoutPress()
{
- QQuickView *window = createView();
+ QQuickView window;
+ QByteArray errorMessage;
+ QVERIFY2(initView(window, testFileUrl("moveAndReleaseWithoutPress.qml"), true, &errorMessage), errorMessage.constData());
+ window.show();
+ QVERIFY(QTest::qWaitForWindowExposed(&window));
- window->setSource(testFileUrl("moveAndReleaseWithoutPress.qml"));
- window->show();
- QTest::qWaitForWindowExposed(window);
- QVERIFY(QTest::qWaitForWindowExposed(window));
-
- QObject *root = window->rootObject();
+ QObject *root = window.rootObject();
QVERIFY(root);
- QTest::mousePress(window, Qt::LeftButton, 0, QPoint(100,100));
+ QTest::mousePress(&window, Qt::LeftButton, 0, QPoint(100,100));
- QTest::mouseMove(window, QPoint(110,110), 50);
+ QTest::mouseMove(&window, QPoint(110,110), 50);
QTRY_COMPARE(root->property("hadMove").toBool(), false);
- QTest::mouseRelease(window, Qt::LeftButton, 0, QPoint(110,110));
+ QTest::mouseRelease(&window, Qt::LeftButton, 0, QPoint(110,110));
QTRY_COMPARE(root->property("hadRelease").toBool(), false);
-
- delete window;
}
void tst_QQuickMouseArea::nestedStopAtBounds_data()
@@ -1467,7 +1444,8 @@ void tst_QQuickMouseArea::nestedStopAtBounds()
QFETCH(bool, invert);
QQuickView view;
- view.setSource(testFileUrl("nestedStopAtBounds.qml"));
+ QByteArray errorMessage;
+ QVERIFY2(initView(view, testFileUrl("nestedStopAtBounds.qml"), true, &errorMessage), errorMessage.constData());
view.show();
view.requestActivate();
QVERIFY(QTest::qWaitForWindowExposed(&view));
diff --git a/tests/auto/quick/qquickpathview/tst_qquickpathview.cpp b/tests/auto/quick/qquickpathview/tst_qquickpathview.cpp
index e4ad7b9c40..083497750d 100644
--- a/tests/auto/quick/qquickpathview/tst_qquickpathview.cpp
+++ b/tests/auto/quick/qquickpathview/tst_qquickpathview.cpp
@@ -1444,6 +1444,7 @@ void tst_QQuickPathView::undefinedPath()
void tst_QQuickPathView::mouseDrag()
{
QScopedPointer<QQuickView> window(createView());
+ QQuickViewTestUtil::moveMouseAway(window.data());
window->setSource(testFileUrl("dragpath.qml"));
window->show();
window->requestActivate();
@@ -1737,6 +1738,7 @@ void tst_QQuickPathView::cancelDrag()
{
QScopedPointer<QQuickView> window(createView());
window->setSource(testFileUrl("dragpath.qml"));
+ QQuickViewTestUtil::moveMouseAway(window.data());
window->show();
window->requestActivate();
QVERIFY(QTest::qWaitForWindowActive(window.data()));
@@ -1782,6 +1784,7 @@ void tst_QQuickPathView::maximumFlickVelocity()
{
QScopedPointer<QQuickView> window(createView());
window->setSource(testFileUrl("dragpath.qml"));
+ QQuickViewTestUtil::moveMouseAway(window.data());
window->show();
window->requestActivate();
QVERIFY(QTest::qWaitForWindowActive(window.data()));
@@ -1827,6 +1830,7 @@ void tst_QQuickPathView::snapToItem()
QFETCH(bool, enforceRange);
QScopedPointer<QQuickView> window(createView());
+ QQuickViewTestUtil::moveMouseAway(window.data());
window->setSource(testFileUrl("panels.qml"));
QQuickPathView *pathview = window->rootObject()->findChild<QQuickPathView*>("view");
QVERIFY(pathview != 0);
@@ -1865,6 +1869,7 @@ void tst_QQuickPathView::snapOneItem()
QFETCH(bool, enforceRange);
QScopedPointer<QQuickView> window(createView());
+ QQuickViewTestUtil::moveMouseAway(window.data());
window->setSource(testFileUrl("panels.qml"));
window->show();
window->requestActivate();
diff --git a/tests/auto/quick/qquickpositioners/tst_qquickpositioners.cpp b/tests/auto/quick/qquickpositioners/tst_qquickpositioners.cpp
index 1f472a3f46..69008486c4 100644
--- a/tests/auto/quick/qquickpositioners/tst_qquickpositioners.cpp
+++ b/tests/auto/quick/qquickpositioners/tst_qquickpositioners.cpp
@@ -655,10 +655,13 @@ void tst_qquickpositioners::addTransitions(const QString &positionerObjectName)
QQmlContext *ctxt = window->rootContext();
ctxt->setContextProperty("usePopulateTransition", QVariant(false));
ctxt->setContextProperty("enableAddTransition", QVariant(true));
+ ctxt->setContextProperty("dynamicallyPopulate", QVariant(false));
+ ctxt->setContextProperty("testModel", &model);
ctxt->setContextProperty("model_targetItems_transitionFrom", &model_targetItems_transitionFrom);
ctxt->setContextProperty("model_displacedItems_transitionVia", &model_displacedItems_transitionVia);
ctxt->setContextProperty("targetItems_transitionFrom", targetItems_transitionFrom);
ctxt->setContextProperty("displacedItems_transitionVia", displacedItems_transitionVia);
+ ctxt->setContextProperty("testedPositioner", QString());
window->setSource(testFileUrl("transitions.qml"));
window->show();
QTest::qWaitForWindowExposed(window.data());
@@ -767,10 +770,13 @@ void tst_qquickpositioners::moveTransitions(const QString &positionerObjectName)
QQmlContext *ctxt = window->rootContext();
ctxt->setContextProperty("usePopulateTransition", QVariant(false));
ctxt->setContextProperty("enableAddTransition", QVariant(false));
+ ctxt->setContextProperty("dynamicallyPopulate", QVariant(false));
+ ctxt->setContextProperty("testModel", &model);
ctxt->setContextProperty("model_targetItems_transitionFrom", &model_targetItems_transitionFrom);
ctxt->setContextProperty("model_displacedItems_transitionVia", &model_displacedItems_transitionVia);
ctxt->setContextProperty("targetItems_transitionFrom", targetItems_transitionFrom);
ctxt->setContextProperty("displacedItems_transitionVia", displacedItems_transitionVia);
+ ctxt->setContextProperty("testedPositioner", QString());
window->setSource(testFileUrl("transitions.qml"));
window->show();
QTest::qWaitForWindowExposed(window.data());
diff --git a/tests/auto/quick/qquickwindow/tst_qquickwindow.cpp b/tests/auto/quick/qquickwindow/tst_qquickwindow.cpp
index 17999ed588..55f91db603 100644
--- a/tests/auto/quick/qquickwindow/tst_qquickwindow.cpp
+++ b/tests/auto/quick/qquickwindow/tst_qquickwindow.cpp
@@ -911,15 +911,15 @@ void tst_qquickwindow::qmlCreation()
QQmlEngine engine;
QQmlComponent component(&engine);
component.loadUrl(testFileUrl("window.qml"));
- QObject* created = component.create();
+ QObject *created = component.create();
QScopedPointer<QObject> cleanup(created);
QVERIFY(created);
- QQuickWindow* window = qobject_cast<QQuickWindow*>(created);
+ QQuickWindow *window = qobject_cast<QQuickWindow*>(created);
QVERIFY(window);
QCOMPARE(window->color(), QColor(Qt::green));
- QQuickItem* item = window->findChild<QQuickItem*>("item");
+ QQuickItem *item = window->findChild<QQuickItem*>("item");
QVERIFY(item);
QCOMPARE(item->window(), window);
}
@@ -1000,10 +1000,10 @@ void tst_qquickwindow::animationsWhileHidden()
QQmlEngine engine;
QQmlComponent component(&engine);
component.loadUrl(testFileUrl("AnimationsWhileHidden.qml"));
- QObject* created = component.create();
+ QObject *created = component.create();
QScopedPointer<QObject> cleanup(created);
- QQuickWindow* window = qobject_cast<QQuickWindow*>(created);
+ QQuickWindow *window = qobject_cast<QQuickWindow*>(created);
QVERIFY(window);
QVERIFY(window->isVisible());
@@ -1022,10 +1022,10 @@ void tst_qquickwindow::headless()
QQmlEngine engine;
QQmlComponent component(&engine);
component.loadUrl(testFileUrl("Headless.qml"));
- QObject* created = component.create();
+ QObject *created = component.create();
QScopedPointer<QObject> cleanup(created);
- QQuickWindow* window = qobject_cast<QQuickWindow*>(created);
+ QQuickWindow *window = qobject_cast<QQuickWindow*>(created);
window->setPersistentOpenGLContext(false);
window->setPersistentSceneGraph(false);
QVERIFY(window);
@@ -1120,13 +1120,13 @@ void tst_qquickwindow::focusObject()
void tst_qquickwindow::ignoreUnhandledMouseEvents()
{
- QQuickWindow* window = new QQuickWindow;
+ QQuickWindow *window = new QQuickWindow;
QScopedPointer<QQuickWindow> cleanup(window);
window->resize(100, 100);
window->show();
QVERIFY(QTest::qWaitForWindowExposed(window));
- QQuickItem* item = new QQuickItem;
+ QQuickItem *item = new QQuickItem;
item->setSize(QSizeF(100, 100));
item->setParentItem(window->contentItem());
@@ -1163,10 +1163,10 @@ void tst_qquickwindow::ownershipRootItem()
QQmlEngine engine;
QQmlComponent component(&engine);
component.loadUrl(testFileUrl("ownershipRootItem.qml"));
- QObject* created = component.create();
+ QObject *created = component.create();
QScopedPointer<QObject> cleanup(created);
- QQuickWindow* window = qobject_cast<QQuickWindow*>(created);
+ QQuickWindow *window = qobject_cast<QQuickWindow*>(created);
QVERIFY(window);
window->show();
QVERIFY(QTest::qWaitForWindowExposed(window));
@@ -1426,7 +1426,7 @@ void tst_qquickwindow::requestActivate()
QQmlEngine engine;
QQmlComponent component(&engine);
component.loadUrl(testFileUrl("active.qml"));
- QQuickWindow* window1 = qobject_cast<QQuickWindow *>(component.create());
+ QQuickWindow *window1 = qobject_cast<QQuickWindow *>(component.create());
QVERIFY(window1);
QWindowList windows = QGuiApplication::topLevelWindows();
@@ -1475,7 +1475,7 @@ void tst_qquickwindow::blockClosing()
QQmlEngine engine;
QQmlComponent component(&engine);
component.loadUrl(testFileUrl("ucantclosethis.qml"));
- QQuickWindow* window = qobject_cast<QQuickWindow *>(component.create());
+ QQuickWindow *window = qobject_cast<QQuickWindow *>(component.create());
QVERIFY(window);
window->show();
QTest::qWaitForWindowExposed(window);
@@ -1495,15 +1495,14 @@ void tst_qquickwindow::crashWhenHoverItemDeleted()
QQmlEngine engine;
QQmlComponent component(&engine);
component.loadUrl(testFileUrl("hoverCrash.qml"));
- QQuickWindow* window = qobject_cast<QQuickWindow *>(component.create());
+ QQuickWindow *window = qobject_cast<QQuickWindow *>(component.create());
QVERIFY(window);
window->show();
QTest::qWaitForWindowExposed(window);
// Simulate a move from the first rectangle to the second. Crash will happen in here
// Moving instantaneously from (0, 99) to (0, 102) does not cause the crash
- for (int i = 99; i < 102; ++i)
- {
+ for (int i = 99; i < 102; ++i) {
QTest::mouseMove(window, QPoint(0, i));
}
}
diff --git a/tests/auto/quick/rendernode/tst_rendernode.cpp b/tests/auto/quick/rendernode/tst_rendernode.cpp
index 04b32499ff..90a9488047 100644
--- a/tests/auto/quick/rendernode/tst_rendernode.cpp
+++ b/tests/auto/quick/rendernode/tst_rendernode.cpp
@@ -44,6 +44,7 @@
#include <QtQuick/qquickitem.h>
#include <QtQuick/qquickview.h>
#include <QtGui/qopenglcontext.h>
+#include <QtGui/qscreen.h>
#include <private/qsgrendernode_p.h>
#include "../../shared/util.h"
@@ -59,6 +60,10 @@ public:
QQuickView view;
view.setSource(testFileUrl(fileName));
+ const QRect screenGeometry = view.screen()->availableGeometry();
+ const QSize size = view.size();
+ const QPoint offset = QPoint(size.width() / 2, size.height() / 2);
+ view.setFramePosition(screenGeometry.center() - offset);
view.showNormal();
QTest::qWaitForWindowExposed(&view);
@@ -185,15 +190,27 @@ tst_rendernode::tst_rendernode()
qmlRegisterType<MessUpItem>("Test", 1, 0, "MessUpItem");
}
-static void fuzzyCompareColor(QRgb x, QRgb y)
+static bool fuzzyCompareColor(QRgb x, QRgb y, QByteArray *errorMessage)
{
- QVERIFY(qAbs(qRed(x) - qRed(y)) < 4);
- QVERIFY(qAbs(qGreen(x) - qGreen(y)) < 4);
- QVERIFY(qAbs(qBlue(x) - qBlue(y)) < 4);
+ enum { fuzz = 4 };
+ if (qAbs(qRed(x) - qRed(y)) >= fuzz || qAbs(qGreen(x) - qGreen(y)) >= fuzz || qAbs(qBlue(x) - qBlue(y)) >= fuzz) {
+ QString s;
+ QDebug(&s).nospace() << hex << "Color mismatch 0x" << x << " 0x" << y << dec << " (fuzz=" << fuzz << ").";
+ *errorMessage = s.toLocal8Bit();
+ return false;
+ }
+ return true;
+}
+
+static inline QByteArray msgColorMismatchAt(const QByteArray &colorMsg, int x, int y)
+{
+ return colorMsg + QByteArrayLiteral(" at ") + QByteArray::number(x) +',' + QByteArray::number(y);
}
void tst_rendernode::renderOrder()
{
+ if (QGuiApplication::primaryScreen()->depth() < 24)
+ QSKIP("This test does not work at display depths < 24");
QImage fb = runTest("RenderOrder.qml");
int x1 = fb.width() / 8;
int x2 = fb.width() * 3 / 8;
@@ -204,18 +221,24 @@ void tst_rendernode::renderOrder()
int y3 = fb.height() * 5 / 8;
int y4 = fb.height() * 7 / 8;
- fuzzyCompareColor(fb.pixel(x1, y1), qRgb(0x7f, 0x00, 0x00));
+ QByteArray errorMessage;
+ QVERIFY2(fuzzyCompareColor(fb.pixel(x1, y1), qRgb(0x7f, 0x00, 0x00), &errorMessage),
+ msgColorMismatchAt(errorMessage, x1, y1).constData());
QCOMPARE(fb.pixel(x2, y2), qRgb(0xff, 0xff, 0xff));
QCOMPARE(fb.pixel(x3, y2), qRgb(0x00, 0x00, 0xff));
QCOMPARE(fb.pixel(x4, y1), qRgb(0x00, 0x00, 0xff));
QCOMPARE(fb.pixel(x1, y4), qRgb(0xff, 0x00, 0x00));
QCOMPARE(fb.pixel(x2, y3), qRgb(0xff, 0xff, 0xff));
- fuzzyCompareColor(fb.pixel(x3, y3), qRgb(0x7f, 0x7f, 0xff));
- fuzzyCompareColor(fb.pixel(x4, y4), qRgb(0x00, 0x00, 0x7f));
+ QVERIFY2(fuzzyCompareColor(fb.pixel(x3, y3), qRgb(0x7f, 0x7f, 0xff), &errorMessage),
+ msgColorMismatchAt(errorMessage, x3, y3).constData());
+ QVERIFY2(fuzzyCompareColor(fb.pixel(x4, y4), qRgb(0x00, 0x00, 0x7f), &errorMessage),
+ msgColorMismatchAt(errorMessage, x4, y4).constData());
}
void tst_rendernode::messUpState()
{
+ if (QGuiApplication::primaryScreen()->depth() < 24)
+ QSKIP("This test does not work at display depths < 24");
QImage fb = runTest("MessUpState.qml");
int x1 = 0;
int x2 = fb.width() / 2;
@@ -231,7 +254,9 @@ void tst_rendernode::messUpState()
QCOMPARE(fb.pixel(x2, y1), qRgb(0x00, 0x00, 0x00));
QCOMPARE(fb.pixel(x2, y2), qRgb(0x00, 0x00, 0x00));
- fuzzyCompareColor(fb.pixel(x2, y3), qRgb(0x7f, 0x00, 0x7f));
+ QByteArray errorMessage;
+ QVERIFY2(fuzzyCompareColor(fb.pixel(x2, y3), qRgb(0x7f, 0x00, 0x7f), &errorMessage),
+ msgColorMismatchAt(errorMessage, x2, y3).constData());
QCOMPARE(fb.pixel(x2, y4), qRgb(0x00, 0x00, 0x00));
QCOMPARE(fb.pixel(x2, y5), qRgb(0x00, 0x00, 0x00));
}
diff --git a/tests/auto/quick/shared/viewtestutil.cpp b/tests/auto/quick/shared/viewtestutil.cpp
index 29b82072c9..0e3964d52d 100644
--- a/tests/auto/quick/shared/viewtestutil.cpp
+++ b/tests/auto/quick/shared/viewtestutil.cpp
@@ -42,17 +42,41 @@
#include "viewtestutil.h"
#include <QtQuick/QQuickView>
+#include <QtQuick/QQuickView>
+#include <QtGui/QScreen>
#include <QtTest/QTest>
QQuickView *QQuickViewTestUtil::createView()
{
QQuickView *window = new QQuickView(0);
- window->setGeometry(0,0,240,320);
-
+ const QSize size(240, 320);
+ window->resize(size);
+ QQuickViewTestUtil::centerOnScreen(window, size);
return window;
}
+void QQuickViewTestUtil::centerOnScreen(QQuickView *window, const QSize &size)
+{
+ const QRect screenGeometry = window->screen()->availableGeometry();
+ const QPoint offset = QPoint(size.width() / 2, size.height() / 2);
+ window->setFramePosition(screenGeometry.center() - offset);
+}
+
+void QQuickViewTestUtil::centerOnScreen(QQuickView *window)
+{
+ QQuickViewTestUtil::centerOnScreen(window, window->size());
+}
+
+void QQuickViewTestUtil::moveMouseAway(QQuickView *window)
+{
+#ifndef QT_NO_CURSOR // Get the cursor out of the way.
+ QCursor::setPos(window->geometry().topRight() + QPoint(100, 100));
+#else
+ Q_UNUSED(window)
+#endif
+}
+
void QQuickViewTestUtil::flick(QQuickView *window, const QPoint &from, const QPoint &to, int duration)
{
const int pointCount = 5;
diff --git a/tests/auto/quick/shared/viewtestutil.h b/tests/auto/quick/shared/viewtestutil.h
index 67906114f6..5b0b10b69c 100644
--- a/tests/auto/quick/shared/viewtestutil.h
+++ b/tests/auto/quick/shared/viewtestutil.h
@@ -53,6 +53,9 @@ namespace QQuickViewTestUtil
QQuickView *createView();
void flick(QQuickView *window, const QPoint &from, const QPoint &to, int duration);
+ void centerOnScreen(QQuickView *window, const QSize &size);
+ void centerOnScreen(QQuickView *window);
+ void moveMouseAway(QQuickView *window);
QList<int> adjustIndexesForAddDisplaced(const QList<int> &indexes, int index, int count);
QList<int> adjustIndexesForMove(const QList<int> &indexes, int from, int to, int count);