aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/quick
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/quick')
-rw-r--r--tests/auto/quick/geometry/tst_geometry.cpp6
-rw-r--r--tests/auto/quick/nokeywords/tst_nokeywords.cpp1
-rw-r--r--tests/auto/quick/qquickanchors/tst_qquickanchors.cpp8
-rw-r--r--tests/auto/quick/qquickanimatedimage/tst_qquickanimatedimage.cpp56
-rw-r--r--[-rwxr-xr-x]tests/auto/quick/qquickanimationcontroller/data/tst_coloranimation.qml0
-rw-r--r--[-rwxr-xr-x]tests/auto/quick/qquickanimationcontroller/data/tst_completion.qml0
-rw-r--r--tests/auto/quick/qquickanimations/data/animatorInvalidTargetCrash.qml63
-rw-r--r--tests/auto/quick/qquickanimations/data/defaultRotationAnimation.qml14
-rw-r--r--tests/auto/quick/qquickanimations/tst_qquickanimations.cpp99
-rw-r--r--tests/auto/quick/qquickapplication/tst_qquickapplication.cpp4
-rw-r--r--tests/auto/quick/qquickbehaviors/BLACKLIST2
-rw-r--r--tests/auto/quick/qquickbehaviors/data/Accelerator.qml18
-rw-r--r--tests/auto/quick/qquickbehaviors/data/aliased.qml39
-rw-r--r--tests/auto/quick/qquickbehaviors/tst_qquickbehaviors.cpp210
-rw-r--r--tests/auto/quick/qquickborderimage/tst_qquickborderimage.cpp51
-rw-r--r--tests/auto/quick/qquickdesignersupport/data/TestComponent.qml9
-rw-r--r--tests/auto/quick/qquickdesignersupport/data/test.qml39
-rw-r--r--tests/auto/quick/qquickdesignersupport/qquickdesignersupport.pro16
-rw-r--r--tests/auto/quick/qquickdesignersupport/tst_qquickdesignersupport.cpp501
-rw-r--r--tests/auto/quick/qquickdynamicpropertyanimation/tst_qquickdynamicpropertyanimation.cpp8
-rw-r--r--tests/auto/quick/qquickflickable/BLACKLIST2
-rw-r--r--tests/auto/quick/qquickflickable/data/movementSignals.qml26
-rw-r--r--tests/auto/quick/qquickflickable/data/nestedPressDelay.qml10
-rw-r--r--tests/auto/quick/qquickflickable/tst_qquickflickable.cpp276
-rw-r--r--tests/auto/quick/qquickflipable/tst_qquickflipable.cpp8
-rw-r--r--tests/auto/quick/qquickfocusscope/tst_qquickfocusscope.cpp160
-rw-r--r--tests/auto/quick/qquickfontloader/tst_qquickfontloader.cpp30
-rw-r--r--tests/auto/quick/qquickfontloader_static/data/font.ttfbin0 -> 51984 bytes
-rw-r--r--tests/auto/quick/qquickfontloader_static/qquickfontloader_static.pro12
-rw-r--r--tests/auto/quick/qquickfontloader_static/tst_qquickfontloader_static.cpp69
-rw-r--r--tests/auto/quick/qquickgridview/BLACKLIST2
-rw-r--r--tests/auto/quick/qquickgridview/data/contentHeightWithDelayRemove.qml47
-rw-r--r--tests/auto/quick/qquickgridview/data/gridview-initCurrent.qml3
-rw-r--r--tests/auto/quick/qquickgridview/data/qtbug45640.qml24
-rw-r--r--tests/auto/quick/qquickgridview/tst_qquickgridview.cpp194
-rw-r--r--tests/auto/quick/qquickimage/tst_qquickimage.cpp83
-rw-r--r--tests/auto/quick/qquickimageprovider/tst_qquickimageprovider.cpp110
-rw-r--r--tests/auto/quick/qquickitem/BLACKLIST2
-rw-r--r--tests/auto/quick/qquickitem/tst_qquickitem.cpp78
-rw-r--r--tests/auto/quick/qquickitem2/data/childrenRectBottomRightCorner.qml47
-rw-r--r--tests/auto/quick/qquickitem2/data/mapCoordinates.qml16
-rw-r--r--tests/auto/quick/qquickitem2/data/mapCoordinatesRect.qml16
-rw-r--r--tests/auto/quick/qquickitem2/data/tabFence.qml49
-rw-r--r--tests/auto/quick/qquickitem2/tst_qquickitem.cpp190
-rw-r--r--tests/auto/quick/qquickitemlayer/data/TextureMirroring.qml159
-rw-r--r--tests/auto/quick/qquickitemlayer/qquickitemlayer.pro3
-rw-r--r--tests/auto/quick/qquickitemlayer/tst_qquickitemlayer.cpp93
-rw-r--r--tests/auto/quick/qquicklistview/BLACKLIST4
-rw-r--r--tests/auto/quick/qquicklistview/data/contentHeightWithDelayRemove.qml46
-rw-r--r--tests/auto/quick/qquicklistview/data/listview-initCurrent.qml3
-rw-r--r--tests/auto/quick/qquicklistview/data/objectmodel.qml24
-rw-r--r--tests/auto/quick/qquicklistview/data/qtbug48044.qml144
-rw-r--r--tests/auto/quick/qquicklistview/data/qtbug48870.qml24
-rw-r--r--tests/auto/quick/qquicklistview/data/qtbug50097.qml47
-rw-r--r--tests/auto/quick/qquicklistview/data/qtbug50105.qml130
-rw-r--r--tests/auto/quick/qquicklistview/data/snapOneItemCurrentIndexRemoveAnimation.qml39
-rw-r--r--tests/auto/quick/qquicklistview/data/snapOneItemResize.qml16
-rw-r--r--tests/auto/quick/qquicklistview/tst_qquicklistview.cpp529
-rw-r--r--tests/auto/quick/qquickloader/tst_qquickloader.cpp51
-rw-r--r--tests/auto/quick/qquickmousearea/tst_qquickmousearea.cpp22
-rw-r--r--tests/auto/quick/qquickmultipointtoucharea/BLACKLIST2
-rw-r--r--tests/auto/quick/qquickmultipointtoucharea/tst_qquickmultipointtoucharea.cpp8
-rw-r--r--tests/auto/quick/qquickpathview/data/customAttribute.qml58
-rw-r--r--tests/auto/quick/qquickpathview/data/qtbug42716.qml111
-rw-r--r--tests/auto/quick/qquickpathview/tst_qquickpathview.cpp82
-rw-r--r--tests/auto/quick/qquickpincharea/tst_qquickpincharea.cpp2
-rw-r--r--tests/auto/quick/qquickpixmapcache/tst_qquickpixmapcache.cpp25
-rw-r--r--tests/auto/quick/qquickpositioners/data/allInvisible.qml40
-rw-r--r--tests/auto/quick/qquickpositioners/data/flowtest-padding.qml44
-rw-r--r--tests/auto/quick/qquickpositioners/data/gridtest-padding.qml47
-rw-r--r--tests/auto/quick/qquickpositioners/data/horizontal-padding.qml30
-rw-r--r--tests/auto/quick/qquickpositioners/data/repeatertest-padding.qml53
-rw-r--r--tests/auto/quick/qquickpositioners/data/repeatertest.qml18
-rw-r--r--tests/auto/quick/qquickpositioners/data/transitions-padding.qml239
-rw-r--r--tests/auto/quick/qquickpositioners/tst_qquickpositioners.cpp2060
-rw-r--r--tests/auto/quick/qquickrepeater/data/modelCleared.qml17
-rw-r--r--tests/auto/quick/qquickrepeater/data/objectmodel.qml28
-rw-r--r--tests/auto/quick/qquickrepeater/data/stackingorder.qml38
-rw-r--r--tests/auto/quick/qquickrepeater/tst_qquickrepeater.cpp122
-rw-r--r--tests/auto/quick/qquicksmoothedanimation/tst_qquicksmoothedanimation.cpp8
-rw-r--r--tests/auto/quick/qquickstates/tst_qquickstates.cpp12
-rw-r--r--tests/auto/quick/qquickstyledtext/tst_qquickstyledtext.cpp8
-rw-r--r--tests/auto/quick/qquicksystempalette/tst_qquicksystempalette.cpp4
-rw-r--r--tests/auto/quick/qquicktext/BLACKLIST4
-rw-r--r--tests/auto/quick/qquicktext/data/fontSizeMode.qml4
-rw-r--r--tests/auto/quick/qquicktext/data/hAlignImplicitWidth.qml2
-rw-r--r--tests/auto/quick/qquicktext/data/padding.qml12
-rw-r--r--tests/auto/quick/qquicktext/tst_qquicktext.cpp265
-rw-r--r--tests/auto/quick/qquicktextdocument/tst_qquicktextdocument.cpp2
-rw-r--r--tests/auto/quick/qquicktextedit/BLACKLIST2
-rw-r--r--tests/auto/quick/qquicktextedit/data/hAlignVisual.qml1
-rw-r--r--tests/auto/quick/qquicktextedit/data/padding.qml12
-rw-r--r--tests/auto/quick/qquicktextedit/data/signal_editingfinished.qml13
-rw-r--r--tests/auto/quick/qquicktextedit/qquicktextedit.pro2
-rw-r--r--tests/auto/quick/qquicktextedit/tst_qquicktextedit.cpp296
-rw-r--r--tests/auto/quick/qquicktextinput/data/padding.qml12
-rw-r--r--tests/auto/quick/qquicktextinput/qquicktextinput.pro2
-rw-r--r--tests/auto/quick/qquicktextinput/tst_qquicktextinput.cpp302
-rw-r--r--tests/auto/quick/qquickview/data/error2.qml4
-rw-r--r--tests/auto/quick/qquickview/tst_qquickview.cpp23
-rw-r--r--tests/auto/quick/qquickvisualdatamodel/tst_qquickvisualdatamodel.cpp10
-rw-r--r--tests/auto/quick/qquickwindow/tst_qquickwindow.cpp161
-rw-r--r--tests/auto/quick/qquickxmllistmodel/tst_qquickxmllistmodel.cpp28
-rw-r--r--tests/auto/quick/quick.pro5
-rw-r--r--tests/auto/quick/scenegraph/data/mipmap_large.pngbin4465 -> 6536 bytes
-rw-r--r--tests/auto/quick/scenegraph/data/mipmap_small.pngbin170 -> 124 bytes
-rw-r--r--tests/auto/quick/scenegraph/data/render_Mipmap.qml9
-rw-r--r--tests/auto/quick/scenegraph/tst_scenegraph.cpp103
-rw-r--r--tests/auto/quick/shared/viewtestutil.cpp20
-rw-r--r--tests/auto/quick/shared/viewtestutil.h2
-rw-r--r--tests/auto/quick/touchmouse/data/hoverMouseAreas.qml39
-rw-r--r--tests/auto/quick/touchmouse/tst_touchmouse.cpp95
112 files changed, 7303 insertions, 1115 deletions
diff --git a/tests/auto/quick/geometry/tst_geometry.cpp b/tests/auto/quick/geometry/tst_geometry.cpp
index 1cc9b112cc..bdd6f1a394 100644
--- a/tests/auto/quick/geometry/tst_geometry.cpp
+++ b/tests/auto/quick/geometry/tst_geometry.cpp
@@ -58,7 +58,7 @@ void GeometryTest::testPoint2D()
QCOMPARE(geometry.sizeOfVertex(), (int) sizeof(float) * 2);
QCOMPARE(geometry.vertexCount(), 4);
QCOMPARE(geometry.indexCount(), 0);
- QVERIFY(geometry.indexData() == 0);
+ QVERIFY(!geometry.indexData());
QSGGeometry::updateRectGeometry(&geometry, QRectF(1, 2, 3, 4));
@@ -91,7 +91,7 @@ void GeometryTest::testTexturedPoint2D()
QCOMPARE(geometry.sizeOfVertex(), (int) sizeof(float) * 4);
QCOMPARE(geometry.vertexCount(), 4);
QCOMPARE(geometry.indexCount(), 0);
- QVERIFY(geometry.indexData() == 0);
+ QVERIFY(!geometry.indexData());
QSGGeometry::updateTexturedRectGeometry(&geometry, QRectF(1, 2, 3, 4), QRectF(5, 6, 7, 8));
@@ -163,7 +163,7 @@ void GeometryTest::testCustomGeometry()
for (int i=0; i<4000; ++i)
QCOMPARE(ii[i], (quint16) i);
for (int i=0; i<1000; ++i)
- QVERIFY(v[i].v1 == 6);
+ QCOMPARE(v[i].v1, float(6));
}
diff --git a/tests/auto/quick/nokeywords/tst_nokeywords.cpp b/tests/auto/quick/nokeywords/tst_nokeywords.cpp
index 378af7ea90..58746447f0 100644
--- a/tests/auto/quick/nokeywords/tst_nokeywords.cpp
+++ b/tests/auto/quick/nokeywords/tst_nokeywords.cpp
@@ -67,7 +67,6 @@
#include <QtQuick/private/qsgrenderer_p.h>
#include <QtQuick/private/qsgrenderloop_p.h>
#include <QtQuick/private/qsgrendernode_p.h>
-#include <QtQuick/private/qsgshareddistancefieldglyphcache_p.h>
#include <QtQuick/private/qsgtexturematerial_p.h>
#include <QtQuick/private/qsgtexture_p.h>
#include <QtQuick/private/qsgthreadedrenderloop_p.h>
diff --git a/tests/auto/quick/qquickanchors/tst_qquickanchors.cpp b/tests/auto/quick/qquickanchors/tst_qquickanchors.cpp
index 6591d84504..597ea87feb 100644
--- a/tests/auto/quick/qquickanchors/tst_qquickanchors.cpp
+++ b/tests/auto/quick/qquickanchors/tst_qquickanchors.cpp
@@ -405,15 +405,15 @@ void tst_qquickanchors::resetConvenience()
//fill
itemPrivate->anchors()->setFill(baseItem);
- QVERIFY(itemPrivate->anchors()->fill() == baseItem);
+ QCOMPARE(itemPrivate->anchors()->fill(), baseItem);
itemPrivate->anchors()->resetFill();
- QVERIFY(itemPrivate->anchors()->fill() == 0);
+ QVERIFY(!itemPrivate->anchors()->fill());
//centerIn
itemPrivate->anchors()->setCenterIn(baseItem);
- QVERIFY(itemPrivate->anchors()->centerIn() == baseItem);
+ QCOMPARE(itemPrivate->anchors()->centerIn(), baseItem);
itemPrivate->anchors()->resetCenterIn();
- QVERIFY(itemPrivate->anchors()->centerIn() == 0);
+ QVERIFY(!itemPrivate->anchors()->centerIn());
delete item;
delete baseItem;
diff --git a/tests/auto/quick/qquickanimatedimage/tst_qquickanimatedimage.cpp b/tests/auto/quick/qquickanimatedimage/tst_qquickanimatedimage.cpp
index a0accfcd58..f4c37b4d66 100644
--- a/tests/auto/quick/qquickanimatedimage/tst_qquickanimatedimage.cpp
+++ b/tests/auto/quick/qquickanimatedimage/tst_qquickanimatedimage.cpp
@@ -252,9 +252,7 @@ void tst_qquickanimatedimage::remote()
QFETCH(QString, fileName);
QFETCH(bool, paused);
- TestHTTPServer server;
- QVERIFY2(server.listen(), qPrintable(server.errorString()));
- server.serveDirectory(dataDirectory());
+ ThreadedTestHTTPServer server(dataDirectory());
QQmlEngine engine;
QQmlComponent component(&engine, server.url(fileName));
@@ -335,48 +333,48 @@ void tst_qquickanimatedimage::sourceSizeChanges()
// Local
ctxt->setContextProperty("srcImage", QUrl(""));
QTRY_COMPARE(anim->status(), QQuickAnimatedImage::Null);
- QTRY_VERIFY(sourceSizeSpy.count() == 0);
+ QTRY_COMPARE(sourceSizeSpy.count(), 0);
ctxt->setContextProperty("srcImage", testFileUrl("hearts.gif"));
QTRY_COMPARE(anim->status(), QQuickAnimatedImage::Ready);
- QTRY_VERIFY(sourceSizeSpy.count() == 1);
+ QTRY_COMPARE(sourceSizeSpy.count(), 1);
ctxt->setContextProperty("srcImage", testFileUrl("hearts.gif"));
QTRY_COMPARE(anim->status(), QQuickAnimatedImage::Ready);
- QTRY_VERIFY(sourceSizeSpy.count() == 1);
+ QTRY_COMPARE(sourceSizeSpy.count(), 1);
ctxt->setContextProperty("srcImage", testFileUrl("hearts_copy.gif"));
QTRY_COMPARE(anim->status(), QQuickAnimatedImage::Ready);
- QTRY_VERIFY(sourceSizeSpy.count() == 1);
+ QTRY_COMPARE(sourceSizeSpy.count(), 1);
ctxt->setContextProperty("srcImage", testFileUrl("colors.gif"));
QTRY_COMPARE(anim->status(), QQuickAnimatedImage::Ready);
- QTRY_VERIFY(sourceSizeSpy.count() == 2);
+ QTRY_COMPARE(sourceSizeSpy.count(), 2);
ctxt->setContextProperty("srcImage", QUrl(""));
QTRY_COMPARE(anim->status(), QQuickAnimatedImage::Null);
- QTRY_VERIFY(sourceSizeSpy.count() == 3);
+ QTRY_COMPARE(sourceSizeSpy.count(), 3);
// Remote
ctxt->setContextProperty("srcImage", server.url("/hearts.gif"));
QTRY_COMPARE(anim->status(), QQuickAnimatedImage::Ready);
- QTRY_VERIFY(sourceSizeSpy.count() == 4);
+ QTRY_COMPARE(sourceSizeSpy.count(), 4);
ctxt->setContextProperty("srcImage", server.url("/hearts.gif"));
QTRY_COMPARE(anim->status(), QQuickAnimatedImage::Ready);
- QTRY_VERIFY(sourceSizeSpy.count() == 4);
+ QTRY_COMPARE(sourceSizeSpy.count(), 4);
ctxt->setContextProperty("srcImage", server.url("/hearts_copy.gif"));
QTRY_COMPARE(anim->status(), QQuickAnimatedImage::Ready);
- QTRY_VERIFY(sourceSizeSpy.count() == 4);
+ QTRY_COMPARE(sourceSizeSpy.count(), 4);
ctxt->setContextProperty("srcImage", server.url("/colors.gif"));
QTRY_COMPARE(anim->status(), QQuickAnimatedImage::Ready);
- QTRY_VERIFY(sourceSizeSpy.count() == 5);
+ QTRY_COMPARE(sourceSizeSpy.count(), 5);
ctxt->setContextProperty("srcImage", QUrl(""));
QTRY_COMPARE(anim->status(), QQuickAnimatedImage::Null);
- QTRY_VERIFY(sourceSizeSpy.count() == 6);
+ QTRY_COMPARE(sourceSizeSpy.count(), 6);
delete anim;
}
@@ -397,8 +395,8 @@ void tst_qquickanimatedimage::qtbug_16520()
QVERIFY(anim != 0);
anim->setProperty("source", server.urlString("/stickman.gif"));
- QTRY_VERIFY(anim->opacity() == 0);
- QTRY_VERIFY(anim->opacity() == 1);
+ QTRY_COMPARE(anim->opacity(), qreal(0));
+ QTRY_COMPARE(anim->opacity(), qreal(1));
delete anim;
delete root;
@@ -418,8 +416,8 @@ void tst_qquickanimatedimage::progressAndStatusChanges()
component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
QQuickImage *obj = qobject_cast<QQuickImage*>(component.create());
QVERIFY(obj != 0);
- QVERIFY(obj->status() == QQuickImage::Ready);
- QTRY_VERIFY(obj->progress() == 1.0);
+ QCOMPARE(obj->status(), QQuickImage::Ready);
+ QTRY_COMPARE(obj->progress(), 1.0);
qRegisterMetaType<QQuickImageBase::Status>();
QSignalSpy sourceSpy(obj, SIGNAL(sourceChanged(QUrl)));
@@ -428,33 +426,33 @@ void tst_qquickanimatedimage::progressAndStatusChanges()
// Same image
ctxt->setContextProperty("srcImage", testFileUrl("stickman.gif"));
- QTRY_VERIFY(obj->status() == QQuickImage::Ready);
- QTRY_VERIFY(obj->progress() == 1.0);
+ QTRY_COMPARE(obj->status(), QQuickImage::Ready);
+ QTRY_COMPARE(obj->progress(), 1.0);
QTRY_COMPARE(sourceSpy.count(), 0);
QTRY_COMPARE(progressSpy.count(), 0);
QTRY_COMPARE(statusSpy.count(), 0);
// Loading local file
ctxt->setContextProperty("srcImage", testFileUrl("colors.gif"));
- QTRY_VERIFY(obj->status() == QQuickImage::Ready);
- QTRY_VERIFY(obj->progress() == 1.0);
+ QTRY_COMPARE(obj->status(), QQuickImage::Ready);
+ QTRY_COMPARE(obj->progress(), 1.0);
QTRY_COMPARE(sourceSpy.count(), 1);
QTRY_COMPARE(progressSpy.count(), 0);
QTRY_COMPARE(statusSpy.count(), 1);
// Loading remote file
ctxt->setContextProperty("srcImage", server.url("/stickman.gif"));
- QTRY_VERIFY(obj->status() == QQuickImage::Loading);
- QTRY_VERIFY(obj->progress() == 0.0);
- QTRY_VERIFY(obj->status() == QQuickImage::Ready);
- QTRY_VERIFY(obj->progress() == 1.0);
+ QTRY_COMPARE(obj->status(), QQuickImage::Loading);
+ QTRY_COMPARE(obj->progress(), 0.0);
+ QTRY_COMPARE(obj->status(), QQuickImage::Ready);
+ QTRY_COMPARE(obj->progress(), 1.0);
QTRY_COMPARE(sourceSpy.count(), 2);
QTRY_VERIFY(progressSpy.count() > 1);
QTRY_COMPARE(statusSpy.count(), 3);
ctxt->setContextProperty("srcImage", "");
- QTRY_VERIFY(obj->status() == QQuickImage::Null);
- QTRY_VERIFY(obj->progress() == 0.0);
+ QTRY_COMPARE(obj->status(), QQuickImage::Null);
+ QTRY_COMPARE(obj->progress(), 0.0);
QTRY_COMPARE(sourceSpy.count(), 3);
QTRY_VERIFY(progressSpy.count() > 2);
QTRY_COMPARE(statusSpy.count(), 4);
@@ -472,7 +470,7 @@ void tst_qquickanimatedimage::playingAndPausedChanges()
component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
QQuickAnimatedImage *obj = qobject_cast<QQuickAnimatedImage*>(component.create());
QVERIFY(obj != 0);
- QVERIFY(obj->status() == QQuickAnimatedImage::Null);
+ QCOMPARE(obj->status(), QQuickAnimatedImage::Null);
QTRY_VERIFY(obj->isPlaying());
QTRY_VERIFY(!obj->isPaused());
QSignalSpy playingSpy(obj, SIGNAL(playingChanged()));
diff --git a/tests/auto/quick/qquickanimationcontroller/data/tst_coloranimation.qml b/tests/auto/quick/qquickanimationcontroller/data/tst_coloranimation.qml
index 8374552974..8374552974 100755..100644
--- a/tests/auto/quick/qquickanimationcontroller/data/tst_coloranimation.qml
+++ b/tests/auto/quick/qquickanimationcontroller/data/tst_coloranimation.qml
diff --git a/tests/auto/quick/qquickanimationcontroller/data/tst_completion.qml b/tests/auto/quick/qquickanimationcontroller/data/tst_completion.qml
index 1a8ca81ba0..1a8ca81ba0 100755..100644
--- a/tests/auto/quick/qquickanimationcontroller/data/tst_completion.qml
+++ b/tests/auto/quick/qquickanimationcontroller/data/tst_completion.qml
diff --git a/tests/auto/quick/qquickanimations/data/animatorInvalidTargetCrash.qml b/tests/auto/quick/qquickanimations/data/animatorInvalidTargetCrash.qml
new file mode 100644
index 0000000000..f2c378e4b5
--- /dev/null
+++ b/tests/auto/quick/qquickanimations/data/animatorInvalidTargetCrash.qml
@@ -0,0 +1,63 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 Klaralvdalens Datakonsult AB (KDAB).
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the QtQuick module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL21$
+** 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 The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/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 or version 3 as published by the Free
+** Software Foundation and appearing in the file LICENSE.LGPLv21 and
+** LICENSE.LGPLv3 included in the packaging of this file. Please review the
+** following information to ensure the GNU Lesser General Public License
+** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.3
+import QtQuick.Window 2.2
+
+Window {
+ visible: true
+ width: 100
+ height: 100
+
+ OpacityAnimator {
+ id: anim
+ from: 1
+ to:0
+ duration: 5000
+ running: false
+ }
+
+ Loader {
+ id: loader
+ sourceComponent: Text {
+ text: "Hello World"
+ anchors.centerIn: parent
+ }
+ }
+
+ Component.onCompleted: {
+ anim.target = loader.item;
+ anim.start();
+ loader.active = false;
+ }
+}
diff --git a/tests/auto/quick/qquickanimations/data/defaultRotationAnimation.qml b/tests/auto/quick/qquickanimations/data/defaultRotationAnimation.qml
new file mode 100644
index 0000000000..94692add60
--- /dev/null
+++ b/tests/auto/quick/qquickanimations/data/defaultRotationAnimation.qml
@@ -0,0 +1,14 @@
+import QtQuick 2.0
+
+Rectangle {
+ id: rect
+
+ RotationAnimation {
+ target: rect
+ from: 0
+ to: 360
+ running: true
+ duration: 1000
+ loops: Animation.Infinite
+ }
+}
diff --git a/tests/auto/quick/qquickanimations/tst_qquickanimations.cpp b/tests/auto/quick/qquickanimations/tst_qquickanimations.cpp
index 45cfe4f334..5cad68b275 100644
--- a/tests/auto/quick/qquickanimations/tst_qquickanimations.cpp
+++ b/tests/auto/quick/qquickanimations/tst_qquickanimations.cpp
@@ -104,6 +104,8 @@ private slots:
void scriptActionBug();
void groupAnimationNullChildBug();
void scriptActionCrash();
+ void animatorInvalidTargetCrash();
+ void defaultPropertyWarning();
};
#define QTIMED_COMPARE(lhs, rhs) do { \
@@ -122,9 +124,9 @@ void tst_qquickanimations::simpleProperty()
animation.setTargetObject(&rect);
animation.setProperty("x");
animation.setTo(200);
- QVERIFY(animation.target() == &rect);
- QVERIFY(animation.property() == "x");
- QVERIFY(animation.to().toReal() == 200.0);
+ QCOMPARE(animation.target(), &rect);
+ QCOMPARE(animation.property(), QLatin1String("x"));
+ QCOMPARE(animation.to().toReal(), 200.0);
animation.start();
QVERIFY(animation.isRunning());
QTest::qWait(animation.duration());
@@ -136,7 +138,7 @@ void tst_qquickanimations::simpleProperty()
animation.pause();
QVERIFY(animation.isPaused());
animation.setCurrentTime(125);
- QVERIFY(animation.currentTime() == 125);
+ QCOMPARE(animation.currentTime(), 125);
QCOMPARE(rect.x(),100.0);
}
@@ -147,9 +149,9 @@ void tst_qquickanimations::simpleNumber()
animation.setTargetObject(&rect);
animation.setProperty("x");
animation.setTo(200);
- QVERIFY(animation.target() == &rect);
- QVERIFY(animation.property() == "x");
- QVERIFY(animation.to() == 200);
+ QCOMPARE(animation.target(), &rect);
+ QCOMPARE(animation.property(), QLatin1String("x"));
+ QCOMPARE(animation.to(), qreal(200));
animation.start();
QVERIFY(animation.isRunning());
QTest::qWait(animation.duration());
@@ -161,7 +163,7 @@ void tst_qquickanimations::simpleNumber()
QVERIFY(animation.isRunning());
QVERIFY(animation.isPaused());
animation.setCurrentTime(125);
- QVERIFY(animation.currentTime() == 125);
+ QCOMPARE(animation.currentTime(), 125);
QCOMPARE(rect.x(), qreal(100));
}
@@ -172,9 +174,9 @@ void tst_qquickanimations::simpleColor()
animation.setTargetObject(&rect);
animation.setProperty("color");
animation.setTo(QColor("red"));
- QVERIFY(animation.target() == &rect);
- QVERIFY(animation.property() == "color");
- QVERIFY(animation.to() == QColor("red"));
+ QCOMPARE(animation.target(), &rect);
+ QCOMPARE(animation.property(), QLatin1String("color"));
+ QCOMPARE(animation.to(), QColor("red"));
animation.start();
QVERIFY(animation.isRunning());
QTest::qWait(animation.duration());
@@ -186,12 +188,12 @@ void tst_qquickanimations::simpleColor()
QVERIFY(animation.isRunning());
QVERIFY(animation.isPaused());
animation.setCurrentTime(125);
- QVERIFY(animation.currentTime() == 125);
+ QCOMPARE(animation.currentTime(), 125);
QCOMPARE(rect.color(), QColor::fromRgbF(0.498039, 0, 0.498039, 1));
rect.setColor(QColor("green"));
animation.setFrom(QColor("blue"));
- QVERIFY(animation.from() == QColor("blue"));
+ QCOMPARE(animation.from(), QColor("blue"));
animation.restart();
QCOMPARE(rect.color(), QColor("blue"));
QVERIFY(animation.isRunning());
@@ -206,10 +208,10 @@ void tst_qquickanimations::simpleRotation()
animation.setTargetObject(&rect);
animation.setProperty("rotation");
animation.setTo(270);
- QVERIFY(animation.target() == &rect);
- QVERIFY(animation.property() == "rotation");
- QVERIFY(animation.to() == 270);
- QVERIFY(animation.direction() == QQuickRotationAnimation::Numerical);
+ QCOMPARE(animation.target(), &rect);
+ QCOMPARE(animation.property(), QLatin1String("rotation"));
+ QCOMPARE(animation.to(), qreal(270));
+ QCOMPARE(animation.direction(), QQuickRotationAnimation::Numerical);
animation.start();
QVERIFY(animation.isRunning());
QTest::qWait(animation.duration());
@@ -221,7 +223,7 @@ void tst_qquickanimations::simpleRotation()
QVERIFY(animation.isRunning());
QVERIFY(animation.isPaused());
animation.setCurrentTime(125);
- QVERIFY(animation.currentTime() == 125);
+ QCOMPARE(animation.currentTime(), 125);
QCOMPARE(rect.rotation(), qreal(135));
}
@@ -567,8 +569,8 @@ void tst_qquickanimations::alwaysRunToEnd()
animation.setDuration(1000);
animation.setLoops(-1);
animation.setAlwaysRunToEnd(true);
- QVERIFY(animation.loops() == -1);
- QVERIFY(animation.alwaysRunToEnd() == true);
+ QCOMPARE(animation.loops(), -1);
+ QVERIFY(animation.alwaysRunToEnd());
QElapsedTimer timer;
timer.start();
@@ -600,7 +602,7 @@ void tst_qquickanimations::complete()
animation.setFrom(1);
animation.setTo(200);
animation.setDuration(500);
- QVERIFY(animation.from() == 1);
+ QCOMPARE(animation.from().toInt(), 1);
animation.start();
QTest::qWait(50);
animation.stop();
@@ -620,7 +622,7 @@ void tst_qquickanimations::resume()
animation.setFrom(10);
animation.setTo(200);
animation.setDuration(1000);
- QVERIFY(animation.from() == 10);
+ QCOMPARE(animation.from().toInt(), 10);
animation.start();
QTest::qWait(400);
@@ -685,7 +687,7 @@ void tst_qquickanimations::dotProperty()
animation.start();
animation.pause();
animation.setCurrentTime(125);
- QVERIFY(animation.currentTime() == 125);
+ QCOMPARE(animation.currentTime(), 125);
QCOMPARE(rect.border()->width(), 5.0);
}
@@ -708,7 +710,7 @@ void tst_qquickanimations::badTypes()
QTest::ignoreMessage(QtWarningMsg, "QQmlComponent: Component is not ready");
c.create();
- QVERIFY(c.errors().count() == 1);
+ QCOMPARE(c.errors().count(), 1);
QCOMPARE(c.errors().at(0).description(), QLatin1String("Invalid property assignment: number expected"));
}
@@ -719,7 +721,7 @@ void tst_qquickanimations::badTypes()
QTest::ignoreMessage(QtWarningMsg, "QQmlComponent: Component is not ready");
c.create();
- QVERIFY(c.errors().count() == 1);
+ QCOMPARE(c.errors().count(), 1);
QCOMPARE(c.errors().at(0).description(), QLatin1String("Invalid property assignment: color expected"));
}
@@ -1065,7 +1067,7 @@ void tst_qquickanimations::propertyValueSourceDefaultStart()
QQuickAbstractAnimation *myAnim = rect->findChild<QQuickAbstractAnimation*>("MyAnim");
QVERIFY(myAnim);
- QVERIFY(myAnim->isRunning() == false);
+ QVERIFY(!myAnim->isRunning());
}
{
@@ -1078,7 +1080,7 @@ void tst_qquickanimations::propertyValueSourceDefaultStart()
QQuickAbstractAnimation *myAnim = rect->findChild<QQuickAbstractAnimation*>("MyAnim");
QVERIFY(myAnim && !myAnim->qtAnimation());
- //QVERIFY(myAnim->qtAnimation()->state() == QAbstractAnimationJob::Stopped);
+ //QCOMPARE(myAnim->qtAnimation()->state(), QAbstractAnimationJob::Stopped);
}
}
@@ -1097,7 +1099,7 @@ void tst_qquickanimations::dontStart()
QQuickAbstractAnimation *myAnim = rect->findChild<QQuickAbstractAnimation*>("MyAnim");
QVERIFY(myAnim && !myAnim->qtAnimation());
- //QVERIFY(myAnim->qtAnimation()->state() == QAbstractAnimationJob::Stopped);
+ //QCOMPARE(myAnim->qtAnimation()->state(), QAbstractAnimationJob::Stopped);
}
{
@@ -1112,7 +1114,7 @@ void tst_qquickanimations::dontStart()
QQuickAbstractAnimation *myAnim = rect->findChild<QQuickAbstractAnimation*>("MyAnim");
QVERIFY(myAnim && !myAnim->qtAnimation());
- //QVERIFY(myAnim->qtAnimation()->state() == QAbstractAnimationJob::Stopped);
+ //QCOMPARE(myAnim->qtAnimation()->state(), QAbstractAnimationJob::Stopped);
}
}
@@ -1350,8 +1352,8 @@ void tst_qquickanimations::alwaysRunToEndRestartBug()
animation.setDuration(1000);
animation.setLoops(-1);
animation.setAlwaysRunToEnd(true);
- QVERIFY(animation.loops() == -1);
- QVERIFY(animation.alwaysRunToEnd() == true);
+ QCOMPARE(animation.loops(), -1);
+ QVERIFY(animation.alwaysRunToEnd());
animation.start();
animation.stop();
animation.start();
@@ -1387,7 +1389,7 @@ void tst_qquickanimations::pauseBindingBug()
QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
QVERIFY(rect != 0);
QQuickAbstractAnimation *anim = rect->findChild<QQuickAbstractAnimation*>("animation");
- QVERIFY(anim->qtAnimation()->state() == QAbstractAnimationJob::Paused);
+ QCOMPARE(anim->qtAnimation()->state(), QAbstractAnimationJob::Paused);
delete rect;
}
@@ -1491,7 +1493,40 @@ void tst_qquickanimations::scriptActionCrash()
delete obj;
}
+// QTBUG-49364
+// Test that we don't crash when the target of an Animator becomes
+// invalid between the time the animator is started and the time the
+// animator job is actually started
+void tst_qquickanimations::animatorInvalidTargetCrash()
+{
+ QQmlEngine engine;
+ QQmlComponent c(&engine, testFileUrl("animatorInvalidTargetCrash.qml"));
+ QObject *obj = c.create();
+
+ //just testing that we don't crash
+ QTest::qWait(5000); //animator duration
+
+ delete obj;
+}
+
+Q_DECLARE_METATYPE(QList<QQmlError>)
+
+// QTBUG-22141
+void tst_qquickanimations::defaultPropertyWarning()
+{
+ QQmlEngine engine;
+
+ qRegisterMetaType<QList<QQmlError> >();
+ QSignalSpy warnings(&engine, SIGNAL(warnings(QList<QQmlError>)));
+ QVERIFY(warnings.isValid());
+
+ QQmlComponent component(&engine, testFileUrl("defaultRotationAnimation.qml"));
+ QScopedPointer<QQuickItem> root(qobject_cast<QQuickItem*>(component.create()));
+ QVERIFY(root);
+
+ QVERIFY(warnings.isEmpty());
+}
QTEST_MAIN(tst_qquickanimations)
diff --git a/tests/auto/quick/qquickapplication/tst_qquickapplication.cpp b/tests/auto/quick/qquickapplication/tst_qquickapplication.cpp
index 7df020405f..1d8fc430b8 100644
--- a/tests/auto/quick/qquickapplication/tst_qquickapplication.cpp
+++ b/tests/auto/quick/qquickapplication/tst_qquickapplication.cpp
@@ -97,7 +97,7 @@ void tst_qquickapplication::active()
window.show();
window.requestActivate();
QTest::qWaitForWindowActive(&window);
- QVERIFY(QGuiApplication::focusWindow() == &window);
+ QCOMPARE(QGuiApplication::focusWindow(), &window);
QVERIFY(item->property("active").toBool());
QVERIFY(item->property("active2").toBool());
@@ -167,7 +167,7 @@ void tst_qquickapplication::state()
window.show();
window.requestActivate();
QTest::qWaitForWindowActive(&window);
- QVERIFY(QGuiApplication::focusWindow() == &window);
+ QCOMPARE(QGuiApplication::focusWindow(), &window);
QCOMPARE(Qt::ApplicationState(item->property("state").toInt()), Qt::ApplicationActive);
QCOMPARE(Qt::ApplicationState(item->property("state2").toInt()), Qt::ApplicationActive);
diff --git a/tests/auto/quick/qquickbehaviors/BLACKLIST b/tests/auto/quick/qquickbehaviors/BLACKLIST
new file mode 100644
index 0000000000..9be4da176d
--- /dev/null
+++ b/tests/auto/quick/qquickbehaviors/BLACKLIST
@@ -0,0 +1,2 @@
+[currentValue]
+windows
diff --git a/tests/auto/quick/qquickbehaviors/data/Accelerator.qml b/tests/auto/quick/qquickbehaviors/data/Accelerator.qml
new file mode 100644
index 0000000000..a2b5146c3f
--- /dev/null
+++ b/tests/auto/quick/qquickbehaviors/data/Accelerator.qml
@@ -0,0 +1,18 @@
+import QtQuick 2.3
+
+Rectangle {
+ property alias value: range.width
+ color: "yellow"
+ Text {
+ text: 'value: ' + value
+ }
+
+ Rectangle {
+ id: range
+ objectName: "range"
+ color: "red"
+ width: 0
+ height: 5
+ anchors.bottom: parent.bottom
+ }
+}
diff --git a/tests/auto/quick/qquickbehaviors/data/aliased.qml b/tests/auto/quick/qquickbehaviors/data/aliased.qml
new file mode 100644
index 0000000000..e65e035d83
--- /dev/null
+++ b/tests/auto/quick/qquickbehaviors/data/aliased.qml
@@ -0,0 +1,39 @@
+import QtQuick 2.3
+
+Rectangle {
+ width: 400
+ height: 400
+ id: rect
+ property bool accelerating : false
+
+ Text {
+ anchors.centerIn: parent
+ text: "Press anywere to accelerate"
+ }
+
+ Accelerator {
+ id: acc
+ objectName: "acc"
+ anchors.fill: parent
+ value: accelerating ? 400 : 0
+ Behavior on value {
+ NumberAnimation {
+ duration: 500
+ }
+ }
+ }
+
+ MouseArea {
+ id: clicker
+ anchors.fill: parent
+ }
+
+ states: State {
+ name: "moved"
+ when: clicker.pressed
+ PropertyChanges {
+ target: rect
+ accelerating: true
+ }
+ }
+}
diff --git a/tests/auto/quick/qquickbehaviors/tst_qquickbehaviors.cpp b/tests/auto/quick/qquickbehaviors/tst_qquickbehaviors.cpp
index b96f1de930..635958314f 100644
--- a/tests/auto/quick/qquickbehaviors/tst_qquickbehaviors.cpp
+++ b/tests/auto/quick/qquickbehaviors/tst_qquickbehaviors.cpp
@@ -76,45 +76,42 @@ private slots:
void multipleChangesToValueType();
void currentValue();
void disabledWriteWhileRunning();
+ void aliasedProperty();
};
void tst_qquickbehaviors::simpleBehavior()
{
QQmlEngine engine;
QQmlComponent c(&engine, testFileUrl("simple.qml"));
- QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
- QTRY_VERIFY(rect);
+ QScopedPointer<QQuickRectangle> rect(qobject_cast<QQuickRectangle*>(c.create()));;
+ QVERIFY2(!rect.isNull(), qPrintable(c.errorString()));
QTRY_VERIFY(qobject_cast<QQuickBehavior*>(rect->findChild<QQuickBehavior*>("MyBehavior"))->animation());
- QQuickItemPrivate::get(rect)->setState("moved");
+ QQuickItemPrivate::get(rect.data())->setState("moved");
QTRY_VERIFY(qobject_cast<QQuickRectangle*>(rect->findChild<QQuickRectangle*>("MyRect"))->x() > 0);
QTRY_VERIFY(qobject_cast<QQuickRectangle*>(rect->findChild<QQuickRectangle*>("MyRect"))->x() < 200);
//i.e. the behavior has been triggered
-
- delete rect;
}
void tst_qquickbehaviors::scriptTriggered()
{
QQmlEngine engine;
QQmlComponent c(&engine, testFileUrl("scripttrigger.qml"));
- QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
- QTRY_VERIFY(rect);
+ QScopedPointer<QQuickRectangle> rect(qobject_cast<QQuickRectangle*>(c.create()));;
+ QVERIFY2(!rect.isNull(), qPrintable(c.errorString()));
rect->setColor(QColor("red"));
QTRY_VERIFY(qobject_cast<QQuickRectangle*>(rect->findChild<QQuickRectangle*>("MyRect"))->x() > 0);
QTRY_VERIFY(qobject_cast<QQuickRectangle*>(rect->findChild<QQuickRectangle*>("MyRect"))->x() < 200);
//i.e. the behavior has been triggered
-
- delete rect;
}
void tst_qquickbehaviors::cppTriggered()
{
QQmlEngine engine;
QQmlComponent c(&engine, testFileUrl("cpptrigger.qml"));
- QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
- QTRY_VERIFY(rect);
+ QScopedPointer<QQuickRectangle> rect(qobject_cast<QQuickRectangle*>(c.create()));;
+ QVERIFY2(!rect.isNull(), qPrintable(c.errorString()));
QQuickRectangle *innerRect = qobject_cast<QQuickRectangle*>(rect->findChild<QQuickRectangle*>("MyRect"));
QTRY_VERIFY(innerRect);
@@ -122,60 +119,52 @@ void tst_qquickbehaviors::cppTriggered()
innerRect->setProperty("x", 200);
QTRY_VERIFY(innerRect->x() > 0);
QTRY_VERIFY(innerRect->x() < 200); //i.e. the behavior has been triggered
-
- delete rect;
}
void tst_qquickbehaviors::loop()
{
QQmlEngine engine;
QQmlComponent c(&engine, testFileUrl("loop.qml"));
- QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
- QTRY_VERIFY(rect);
+ QScopedPointer<QQuickRectangle> rect(qobject_cast<QQuickRectangle*>(c.create()));;
+ QVERIFY2(!rect.isNull(), qPrintable(c.errorString()));
//don't crash
- QQuickItemPrivate::get(rect)->setState("moved");
-
- delete rect;
+ QQuickItemPrivate::get(rect.data())->setState("moved");
}
void tst_qquickbehaviors::colorBehavior()
{
QQmlEngine engine;
QQmlComponent c(&engine, testFileUrl("color.qml"));
- QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
- QTRY_VERIFY(rect);
+ QScopedPointer<QQuickRectangle> rect(qobject_cast<QQuickRectangle*>(c.create()));;
+ QVERIFY2(!rect.isNull(), qPrintable(c.errorString()));
- QQuickItemPrivate::get(rect)->setState("red");
+ QQuickItemPrivate::get(rect.data())->setState("red");
QTRY_VERIFY(qobject_cast<QQuickRectangle*>(rect->findChild<QQuickRectangle*>("MyRect"))->color() != QColor("red"));
QTRY_VERIFY(qobject_cast<QQuickRectangle*>(rect->findChild<QQuickRectangle*>("MyRect"))->color() != QColor("green"));
//i.e. the behavior has been triggered
-
- delete rect;
}
void tst_qquickbehaviors::parentBehavior()
{
QQmlEngine engine;
QQmlComponent c(&engine, testFileUrl("parent.qml"));
- QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
- QTRY_VERIFY(rect);
+ QScopedPointer<QQuickRectangle> rect(qobject_cast<QQuickRectangle*>(c.create()));;
+ QVERIFY2(!rect.isNull(), qPrintable(c.errorString()));
- QQuickItemPrivate::get(rect)->setState("reparented");
+ QQuickItemPrivate::get(rect.data())->setState("reparented");
QTRY_VERIFY(rect->findChild<QQuickRectangle*>("MyRect")->parentItem() != rect->findChild<QQuickItem*>("NewParent"));
QTRY_VERIFY(rect->findChild<QQuickRectangle*>("MyRect")->parentItem() == rect->findChild<QQuickItem*>("NewParent"));
-
- delete rect;
}
void tst_qquickbehaviors::replaceBinding()
{
QQmlEngine engine;
QQmlComponent c(&engine, testFileUrl("binding.qml"));
- QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
- QTRY_VERIFY(rect);
+ QScopedPointer<QQuickRectangle> rect(qobject_cast<QQuickRectangle*>(c.create()));;
+ QVERIFY2(!rect.isNull(), qPrintable(c.errorString()));
- QQuickItemPrivate::get(rect)->setState("moved");
+ QQuickItemPrivate::get(rect.data())->setState("moved");
QQuickRectangle *innerRect = qobject_cast<QQuickRectangle*>(rect->findChild<QQuickRectangle*>("MyRect"));
QTRY_VERIFY(innerRect);
QTRY_VERIFY(innerRect->x() > 0);
@@ -187,7 +176,7 @@ void tst_qquickbehaviors::replaceBinding()
rect->setProperty("movedx", 210);
QTRY_COMPARE(innerRect->x(), (qreal)210);
- QQuickItemPrivate::get(rect)->setState("");
+ QQuickItemPrivate::get(rect.data())->setState("");
QTRY_VERIFY(innerRect->x() > 10);
QTRY_VERIFY(innerRect->x() < 210); //i.e. the behavior has been triggered
QTRY_COMPARE(innerRect->x(), (qreal)10);
@@ -195,8 +184,6 @@ void tst_qquickbehaviors::replaceBinding()
QTRY_COMPARE(innerRect->x(), (qreal)10);
rect->setProperty("basex", 20);
QTRY_COMPARE(innerRect->x(), (qreal)20);
-
- delete rect;
}
void tst_qquickbehaviors::group()
@@ -205,32 +192,27 @@ void tst_qquickbehaviors::group()
{
QQmlEngine engine;
QQmlComponent c(&engine, testFileUrl("groupProperty.qml")));
- QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
- qDebug() << c.errorString();
- QTRY_VERIFY(rect);
+ QScopedPointer<QQuickRectangle> rect(qobject_cast<QQuickRectangle*>(c.create()));;
+ QVERIFY2(!rect.isNull(), qPrintable(c.errorString()));
- QQuickItemPrivate::get(rect)->setState("moved");
+ QQuickItemPrivate::get(rect.data())->setState("moved");
//QTest::qWait(200);
QTRY_VERIFY(qobject_cast<QQuickRectangle*>(rect->findChild<QQuickRectangle*>("MyRect"))->x() > 0);
QTRY_VERIFY(qobject_cast<QQuickRectangle*>(rect->findChild<QQuickRectangle*>("MyRect"))->x() < 200);
//i.e. the behavior has been triggered
-
- delete rect;
}
*/
{
QQmlEngine engine;
QQmlComponent c(&engine, testFileUrl("groupProperty2.qml"));
- QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
- QTRY_VERIFY(rect);
+ QScopedPointer<QQuickRectangle> rect(qobject_cast<QQuickRectangle*>(c.create()));;
+ QVERIFY2(!rect.isNull(), qPrintable(c.errorString()));
- QQuickItemPrivate::get(rect)->setState("moved");
+ QQuickItemPrivate::get(rect.data())->setState("moved");
QTRY_VERIFY(qobject_cast<QQuickRectangle*>(rect->findChild<QQuickRectangle*>("MyRect"))->border()->width() > 0);
QTRY_VERIFY(qobject_cast<QQuickRectangle*>(rect->findChild<QQuickRectangle*>("MyRect"))->border()->width() < 4);
//i.e. the behavior has been triggered
-
- delete rect;
}
}
@@ -238,56 +220,48 @@ void tst_qquickbehaviors::valueType()
{
QQmlEngine engine;
QQmlComponent c(&engine, testFileUrl("valueType.qml"));
- QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
- QVERIFY(rect);
+ QScopedPointer<QQuickRectangle> rect(qobject_cast<QQuickRectangle*>(c.create()));;
+ QVERIFY2(!rect.isNull(), qPrintable(c.errorString()));
//QTBUG-20827
QCOMPARE(rect->color(), QColor::fromRgb(255,0,255));
-
- delete rect;
}
void tst_qquickbehaviors::emptyBehavior()
{
QQmlEngine engine;
QQmlComponent c(&engine, testFileUrl("empty.qml"));
- QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
- QVERIFY(rect);
+ QScopedPointer<QQuickRectangle> rect(qobject_cast<QQuickRectangle*>(c.create()));;
+ QVERIFY2(!rect.isNull(), qPrintable(c.errorString()));
- QQuickItemPrivate::get(rect)->setState("moved");
+ QQuickItemPrivate::get(rect.data())->setState("moved");
qreal x = qobject_cast<QQuickRectangle*>(rect->findChild<QQuickRectangle*>("MyRect"))->x();
QCOMPARE(x, qreal(200)); //should change immediately
-
- delete rect;
}
void tst_qquickbehaviors::explicitSelection()
{
QQmlEngine engine;
QQmlComponent c(&engine, testFileUrl("explicit.qml"));
- QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
- QVERIFY(rect);
+ QScopedPointer<QQuickRectangle> rect(qobject_cast<QQuickRectangle*>(c.create()));;
+ QVERIFY2(!rect.isNull(), qPrintable(c.errorString()));
- QQuickItemPrivate::get(rect)->setState("moved");
+ QQuickItemPrivate::get(rect.data())->setState("moved");
QTRY_VERIFY(qobject_cast<QQuickRectangle*>(rect->findChild<QQuickRectangle*>("MyRect"))->x() > 0);
QTRY_VERIFY(qobject_cast<QQuickRectangle*>(rect->findChild<QQuickRectangle*>("MyRect"))->x() < 200);
//i.e. the behavior has been triggered
-
- delete rect;
}
void tst_qquickbehaviors::nonSelectingBehavior()
{
QQmlEngine engine;
QQmlComponent c(&engine, testFileUrl("nonSelecting2.qml"));
- QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
- QVERIFY(rect);
+ QScopedPointer<QQuickRectangle> rect(qobject_cast<QQuickRectangle*>(c.create()));;
+ QVERIFY2(!rect.isNull(), qPrintable(c.errorString()));
- QQuickItemPrivate::get(rect)->setState("moved");
+ QQuickItemPrivate::get(rect.data())->setState("moved");
qreal x = qobject_cast<QQuickRectangle*>(rect->findChild<QQuickRectangle*>("MyRect"))->x();
QCOMPARE(x, qreal(200)); //should change immediately
-
- delete rect;
}
void tst_qquickbehaviors::reassignedAnimation()
@@ -296,27 +270,23 @@ void tst_qquickbehaviors::reassignedAnimation()
QQmlComponent c(&engine, testFileUrl("reassignedAnimation.qml"));
QString warning = testFileUrl("reassignedAnimation.qml").toString() + ":9:9: QML Behavior: Cannot change the animation assigned to a Behavior.";
QTest::ignoreMessage(QtWarningMsg, qPrintable(warning));
- QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
- QVERIFY(rect);
+ QScopedPointer<QQuickRectangle> rect(qobject_cast<QQuickRectangle*>(c.create()));;
+ QVERIFY2(!rect.isNull(), qPrintable(c.errorString()));
QCOMPARE(qobject_cast<QQuickNumberAnimation*>(
rect->findChild<QQuickBehavior*>("MyBehavior")->animation())->duration(), 200);
-
- delete rect;
}
void tst_qquickbehaviors::disabled()
{
QQmlEngine engine;
QQmlComponent c(&engine, testFileUrl("disabled.qml"));
- QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
- QVERIFY(rect);
+ QScopedPointer<QQuickRectangle> rect(qobject_cast<QQuickRectangle*>(c.create()));;
+ QVERIFY2(!rect.isNull(), qPrintable(c.errorString()));
QCOMPARE(rect->findChild<QQuickBehavior*>("MyBehavior")->enabled(), false);
- QQuickItemPrivate::get(rect)->setState("moved");
+ QQuickItemPrivate::get(rect.data())->setState("moved");
qreal x = qobject_cast<QQuickRectangle*>(rect->findChild<QQuickRectangle*>("MyRect"))->x();
QCOMPARE(x, qreal(200)); //should change immediately
-
- delete rect;
}
void tst_qquickbehaviors::dontStart()
@@ -327,13 +297,12 @@ void tst_qquickbehaviors::dontStart()
QString warning = c.url().toString() + ":13:13: QML NumberAnimation: setRunning() cannot be used on non-root animation nodes.";
QTest::ignoreMessage(QtWarningMsg, qPrintable(warning));
- QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
- QVERIFY(rect);
+ QScopedPointer<QQuickRectangle> rect(qobject_cast<QQuickRectangle*>(c.create()));;
+ QVERIFY2(!rect.isNull(), qPrintable(c.errorString()));
QQuickAbstractAnimation *myAnim = rect->findChild<QQuickAbstractAnimation*>("MyAnim");
- QVERIFY(myAnim && !myAnim->qtAnimation());
-
- delete rect;
+ QVERIFY(myAnim);
+ QVERIFY(!myAnim->qtAnimation());
}
void tst_qquickbehaviors::startup()
@@ -341,22 +310,20 @@ void tst_qquickbehaviors::startup()
{
QQmlEngine engine;
QQmlComponent c(&engine, testFileUrl("startup.qml"));
- QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
- QVERIFY(rect);
+ QScopedPointer<QQuickRectangle> rect(qobject_cast<QQuickRectangle*>(c.create()));;
+ QVERIFY2(!rect.isNull(), qPrintable(c.errorString()));
QQuickRectangle *innerRect = rect->findChild<QQuickRectangle*>("innerRect");
QVERIFY(innerRect);
QCOMPARE(innerRect->x(), qreal(100)); //should be set immediately
-
- delete rect;
}
{
QQmlEngine engine;
QQmlComponent c(&engine, testFileUrl("startup2.qml"));
- QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
- QVERIFY(rect);
+ QScopedPointer<QQuickRectangle> rect(qobject_cast<QQuickRectangle*>(c.create()));;
+ QVERIFY2(!rect.isNull(), qPrintable(c.errorString()));
QQuickRectangle *innerRect = rect->findChild<QQuickRectangle*>("innerRect");
QVERIFY(innerRect);
@@ -365,8 +332,6 @@ void tst_qquickbehaviors::startup()
QVERIFY(text);
QCOMPARE(innerRect->x(), text->width()); //should be set immediately
-
- delete rect;
}
}
@@ -375,10 +340,8 @@ void tst_qquickbehaviors::groupedPropertyCrash()
{
QQmlEngine engine;
QQmlComponent c(&engine, testFileUrl("groupedPropertyCrash.qml"));
- QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
- QVERIFY(rect); //don't crash
-
- delete rect;
+ QScopedPointer<QQuickRectangle> rect(qobject_cast<QQuickRectangle*>(c.create()));;
+ QVERIFY2(!rect.isNull(), qPrintable(c.errorString())); //don't crash
}
//QTBUG-5491
@@ -386,8 +349,8 @@ void tst_qquickbehaviors::runningTrue()
{
QQmlEngine engine;
QQmlComponent c(&engine, testFileUrl("runningTrue.qml"));
- QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
- QVERIFY(rect);
+ QScopedPointer<QQuickRectangle> rect(qobject_cast<QQuickRectangle*>(c.create()));;
+ QVERIFY2(!rect.isNull(), qPrintable(c.errorString()));
QQuickAbstractAnimation *animation = rect->findChild<QQuickAbstractAnimation*>("rotAnim");
QVERIFY(animation);
@@ -395,8 +358,6 @@ void tst_qquickbehaviors::runningTrue()
QSignalSpy runningSpy(animation, SIGNAL(runningChanged(bool)));
rect->setProperty("myValue", 180);
QTRY_VERIFY(runningSpy.count() > 0);
-
- delete rect;
}
//QTBUG-12295
@@ -404,8 +365,8 @@ void tst_qquickbehaviors::sameValue()
{
QQmlEngine engine;
QQmlComponent c(&engine, testFileUrl("qtbug12295.qml"));
- QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
- QVERIFY(rect);
+ QScopedPointer<QQuickRectangle> rect(qobject_cast<QQuickRectangle*>(c.create()));;
+ QVERIFY2(!rect.isNull(), qPrintable(c.errorString()));
QQuickRectangle *target = rect->findChild<QQuickRectangle*>("myRect");
QVERIFY(target);
@@ -424,8 +385,6 @@ void tst_qquickbehaviors::sameValue()
//even though we set 0 twice in a row.
target->setProperty("x", 0);
QTRY_VERIFY(target->x() != qreal(0) && target->x() != qreal(100));
-
- delete rect;
}
//QTBUG-18362
@@ -434,8 +393,8 @@ void tst_qquickbehaviors::delayedRegistration()
QQmlEngine engine;
QQmlComponent c(&engine, testFileUrl("delayedRegistration.qml"));
- QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
- QVERIFY(rect != 0);
+ QScopedPointer<QQuickRectangle> rect(qobject_cast<QQuickRectangle*>(c.create()));;
+ QVERIFY2(!rect.isNull(), qPrintable(c.errorString()));
QQuickItem *innerRect = rect->property("myItem").value<QQuickItem*>();
QVERIFY(innerRect != 0);
@@ -451,8 +410,8 @@ void tst_qquickbehaviors::startOnCompleted()
QQmlEngine engine;
QQmlComponent c(&engine, testFileUrl("startOnCompleted.qml"));
- QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
- QVERIFY(rect != 0);
+ QScopedPointer<QQuickRectangle> rect(qobject_cast<QQuickRectangle*>(c.create()));;
+ QVERIFY2(!rect.isNull(), qPrintable(c.errorString()));
QQuickItem *innerRect = rect->findChild<QQuickRectangle*>();
QVERIFY(innerRect != 0);
@@ -460,8 +419,6 @@ void tst_qquickbehaviors::startOnCompleted()
QCOMPARE(innerRect->property("x").toInt(), int(0));
QTRY_COMPARE(innerRect->property("x").toInt(), int(100));
-
- delete rect;
}
//QTBUG-25139
@@ -471,7 +428,7 @@ void tst_qquickbehaviors::multipleChangesToValueType()
QQmlComponent c(&engine, testFileUrl("multipleChangesToValueType.qml"));
QScopedPointer<QQuickRectangle> rect(qobject_cast<QQuickRectangle *>(c.create()));
- QVERIFY(rect != 0);
+ QVERIFY2(!rect.isNull(), qPrintable(c.errorString()));
QQuickText *text = rect->findChild<QQuickText *>();
QVERIFY(text != 0);
@@ -496,8 +453,8 @@ void tst_qquickbehaviors::currentValue()
{
QQmlEngine engine;
QQmlComponent c(&engine, testFileUrl("qtbug21549.qml"));
- QQuickItem *item = qobject_cast<QQuickItem*>(c.create());
- QVERIFY(item);
+ QScopedPointer<QQuickItem> item(qobject_cast<QQuickItem*>(c.create()));
+ QVERIFY2(!item.isNull(), qPrintable(c.errorString()));
QQuickRectangle *target = item->findChild<QQuickRectangle*>("myRect");
QVERIFY(target);
@@ -516,15 +473,13 @@ void tst_qquickbehaviors::currentValue()
target->setProperty("x", 100);
QCOMPARE(item->property("behaviorCount").toInt(), 1);
QCOMPARE(target->x(), qreal(100));
-
- delete item;
}
{
QQmlEngine engine;
QQmlComponent c(&engine, testFileUrl("qtbug21549-2.qml"));
- QQuickItem *item = qobject_cast<QQuickItem*>(c.create());
- QVERIFY(item);
+ QScopedPointer<QQuickItem> item(qobject_cast<QQuickItem*>(c.create()));
+ QVERIFY2(!item.isNull(), qPrintable(c.errorString()));
QQuickRectangle *target = item->findChild<QQuickRectangle*>("myRect");
QVERIFY(target);
@@ -537,9 +492,7 @@ void tst_qquickbehaviors::currentValue()
// in the QML (which should be between 50 and 80);
QTRY_COMPARE(item->property("animRunning").toBool(), true);
QTRY_COMPARE(item->property("animRunning").toBool(), false);
- QVERIFY(target->x() > qreal(50) && target->x() < qreal(80));
-
- delete item;
+ QVERIFY2(target->x() > qreal(50) && target->x() < qreal(80), QByteArray::number(target->x()));
}
}
@@ -548,8 +501,8 @@ void tst_qquickbehaviors::disabledWriteWhileRunning()
{
QQmlEngine engine;
QQmlComponent c(&engine, testFileUrl("disabledWriteWhileRunning.qml"));
- QQuickItem *root = qobject_cast<QQuickItem*>(c.create());
- QVERIFY(root);
+ QScopedPointer<QQuickItem> root(qobject_cast<QQuickItem*>(c.create()));
+ QVERIFY2(!root.isNull(), qPrintable(c.errorString()));
QQuickRectangle *myRect = qobject_cast<QQuickRectangle*>(root->findChild<QQuickRectangle*>("MyRect"));
QQuickBehavior *myBehavior = qobject_cast<QQuickBehavior*>(root->findChild<QQuickBehavior*>("MyBehavior"));
@@ -579,16 +532,14 @@ void tst_qquickbehaviors::disabledWriteWhileRunning()
QCOMPARE(myRect->x(), qreal(100));
QTest::qWait(200);
QCOMPARE(myRect->x(), qreal(100));
-
- delete root;
}
//test additional complications with SmoothedAnimation
{
QQmlEngine engine;
QQmlComponent c(&engine, testFileUrl("disabledWriteWhileRunning2.qml"));
- QQuickItem *root = qobject_cast<QQuickItem*>(c.create());
- QVERIFY(root);
+ QScopedPointer<QQuickItem> root(qobject_cast<QQuickItem*>(c.create()));
+ QVERIFY2(!root.isNull(), qPrintable(c.errorString()));
QQuickRectangle *myRect = qobject_cast<QQuickRectangle*>(root->findChild<QQuickRectangle*>("MyRect"));
QQuickBehavior *myBehavior = qobject_cast<QQuickBehavior*>(root->findChild<QQuickBehavior*>("MyBehavior"));
@@ -623,11 +574,26 @@ void tst_qquickbehaviors::disabledWriteWhileRunning()
QCOMPARE(myRect->x(), qreal(100));
QTest::qWait(200);
QCOMPARE(myRect->x(), qreal(100));
-
- delete root;
}
}
+void tst_qquickbehaviors::aliasedProperty()
+{
+ QQmlEngine engine;
+ QQmlComponent c(&engine, testFileUrl("aliased.qml"));
+ QScopedPointer<QQuickRectangle> rect(qobject_cast<QQuickRectangle*>(c.create()));
+ QVERIFY2(!rect.isNull(), qPrintable(c.errorString()));
+
+ QQuickItemPrivate::get(rect.data())->setState("moved");
+ QScopedPointer<QQuickRectangle> acc(qobject_cast<QQuickRectangle*>(rect->findChild<QQuickRectangle*>("acc")));
+ QScopedPointer<QQuickRectangle> range(qobject_cast<QQuickRectangle*>(acc->findChild<QQuickRectangle*>("range")));
+ QTRY_VERIFY(acc->property("value").toDouble() > 0);
+ QTRY_VERIFY(range->width() > 0);
+ QTRY_VERIFY(acc->property("value").toDouble() < 400);
+ QTRY_VERIFY(range->width() < 400);
+ //i.e. the behavior has been triggered
+}
+
QTEST_MAIN(tst_qquickbehaviors)
#include "tst_qquickbehaviors.moc"
diff --git a/tests/auto/quick/qquickborderimage/tst_qquickborderimage.cpp b/tests/auto/quick/qquickborderimage/tst_qquickborderimage.cpp
index efe2ca8b18..265579ead2 100644
--- a/tests/auto/quick/qquickborderimage/tst_qquickborderimage.cpp
+++ b/tests/auto/quick/qquickborderimage/tst_qquickborderimage.cpp
@@ -123,7 +123,7 @@ void tst_qquickborderimage::imageSource_data()
<< "<Unknown File>:2:1: QML BorderImage: Cannot open: " + testFileUrl("no-such-file.png").toString();
QTest::newRow("remote") << "/colors.png" << true << "";
QTest::newRow("remote not found") << "/no-such-file.png" << true
- << "<Unknown File>:2:1: QML BorderImage: Error downloading {{ServerBaseUrl}}/no-such-file.png - server replied: Not found";
+ << "<Unknown File>:2:1: QML BorderImage: Error transferring {{ServerBaseUrl}}/no-such-file.png - server replied: Not found";
}
void tst_qquickborderimage::imageSource()
@@ -132,6 +132,13 @@ void tst_qquickborderimage::imageSource()
QFETCH(bool, remote);
QFETCH(QString, error);
+#if defined(Q_OS_LINUX) && !defined(Q_OS_ANDROID)
+ if (qstrcmp(QTest::currentDataTag(), "remote") == 0
+ || qstrcmp(QTest::currentDataTag(), "remote not found") == 0) {
+ QSKIP("Remote tests cause occasional hangs in the CI system -- QTBUG-45655");
+ }
+#endif
+
TestHTTPServer server;
if (remote) {
QVERIFY2(server.listen(), qPrintable(server.errorString()));
@@ -150,12 +157,12 @@ void tst_qquickborderimage::imageSource()
QVERIFY(obj != 0);
if (remote)
- QTRY_VERIFY(obj->status() == QQuickBorderImage::Loading);
+ QTRY_COMPARE(obj->status(), QQuickBorderImage::Loading);
QCOMPARE(obj->source(), remote ? source : QUrl(source));
if (error.isEmpty()) {
- QTRY_VERIFY(obj->status() == QQuickBorderImage::Ready);
+ QTRY_COMPARE(obj->status(), QQuickBorderImage::Ready);
QCOMPARE(obj->width(), 120.);
QCOMPARE(obj->height(), 120.);
QCOMPARE(obj->sourceSize().width(), 120);
@@ -163,7 +170,7 @@ void tst_qquickborderimage::imageSource()
QCOMPARE(obj->horizontalTileMode(), QQuickBorderImage::Stretch);
QCOMPARE(obj->verticalTileMode(), QQuickBorderImage::Stretch);
} else {
- QTRY_VERIFY(obj->status() == QQuickBorderImage::Error);
+ QTRY_COMPARE(obj->status(), QQuickBorderImage::Error);
}
delete obj;
@@ -178,13 +185,13 @@ void tst_qquickborderimage::clearSource()
component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
QQuickBorderImage *obj = qobject_cast<QQuickBorderImage*>(component.create());
QVERIFY(obj != 0);
- QVERIFY(obj->status() == QQuickBorderImage::Ready);
+ QCOMPARE(obj->status(), QQuickBorderImage::Ready);
QCOMPARE(obj->width(), 120.);
QCOMPARE(obj->height(), 120.);
ctxt->setContextProperty("srcImage", "");
QVERIFY(obj->source().isEmpty());
- QVERIFY(obj->status() == QQuickBorderImage::Null);
+ QCOMPARE(obj->status(), QQuickBorderImage::Null);
QCOMPARE(obj->width(), 0.);
QCOMPARE(obj->height(), 0.);
@@ -296,14 +303,14 @@ void tst_qquickborderimage::sciSource()
QVERIFY(obj != 0);
if (remote)
- QTRY_VERIFY(obj->status() == QQuickBorderImage::Loading);
+ QTRY_COMPARE(obj->status(), QQuickBorderImage::Loading);
QCOMPARE(obj->source(), remote ? source : QUrl(source));
QCOMPARE(obj->width(), 300.);
QCOMPARE(obj->height(), 300.);
if (valid) {
- QTRY_VERIFY(obj->status() == QQuickBorderImage::Ready);
+ QTRY_COMPARE(obj->status(), QQuickBorderImage::Ready);
QCOMPARE(obj->border()->left(), 10);
QCOMPARE(obj->border()->top(), 20);
QCOMPARE(obj->border()->right(), 30);
@@ -311,7 +318,7 @@ void tst_qquickborderimage::sciSource()
QCOMPARE(obj->horizontalTileMode(), QQuickBorderImage::Round);
QCOMPARE(obj->verticalTileMode(), QQuickBorderImage::Repeat);
} else {
- QTRY_VERIFY(obj->status() == QQuickBorderImage::Error);
+ QTRY_COMPARE(obj->status(), QQuickBorderImage::Error);
}
delete obj;
@@ -443,7 +450,7 @@ void tst_qquickborderimage::statusChanges()
obj->setSource(source);
if (remote)
server.sendDelayedItem();
- QTRY_VERIFY(obj->status() == finalStatus);
+ QTRY_COMPARE(obj->status(), finalStatus);
QCOMPARE(spy.count(), emissions);
delete obj;
@@ -529,8 +536,8 @@ void tst_qquickborderimage::progressAndStatusChanges()
component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
QQuickBorderImage *obj = qobject_cast<QQuickBorderImage*>(component.create());
QVERIFY(obj != 0);
- QVERIFY(obj->status() == QQuickBorderImage::Ready);
- QTRY_VERIFY(obj->progress() == 1.0);
+ QCOMPARE(obj->status(), QQuickBorderImage::Ready);
+ QTRY_COMPARE(obj->progress(), 1.0);
qRegisterMetaType<QQuickBorderImage::Status>();
QSignalSpy sourceSpy(obj, SIGNAL(sourceChanged(QUrl)));
@@ -539,33 +546,33 @@ void tst_qquickborderimage::progressAndStatusChanges()
// Same file
ctxt->setContextProperty("srcImage", testFileUrl("heart200.png"));
- QTRY_VERIFY(obj->status() == QQuickBorderImage::Ready);
- QTRY_VERIFY(obj->progress() == 1.0);
+ QTRY_COMPARE(obj->status(), QQuickBorderImage::Ready);
+ QTRY_COMPARE(obj->progress(), 1.0);
QTRY_COMPARE(sourceSpy.count(), 0);
QTRY_COMPARE(progressSpy.count(), 0);
QTRY_COMPARE(statusSpy.count(), 0);
// Loading local file
ctxt->setContextProperty("srcImage", testFileUrl("colors.png"));
- QTRY_VERIFY(obj->status() == QQuickBorderImage::Ready);
- QTRY_VERIFY(obj->progress() == 1.0);
+ QTRY_COMPARE(obj->status(), QQuickBorderImage::Ready);
+ QTRY_COMPARE(obj->progress(), 1.0);
QTRY_COMPARE(sourceSpy.count(), 1);
QTRY_COMPARE(progressSpy.count(), 0);
QTRY_COMPARE(statusSpy.count(), 1);
// Loading remote file
ctxt->setContextProperty("srcImage", server.url("/heart200.png"));
- QTRY_VERIFY(obj->status() == QQuickBorderImage::Loading);
- QTRY_VERIFY(obj->progress() == 0.0);
- QTRY_VERIFY(obj->status() == QQuickBorderImage::Ready);
- QTRY_VERIFY(obj->progress() == 1.0);
+ QTRY_COMPARE(obj->status(), QQuickBorderImage::Loading);
+ QTRY_COMPARE(obj->progress(), 0.0);
+ QTRY_COMPARE(obj->status(), QQuickBorderImage::Ready);
+ QTRY_COMPARE(obj->progress(), 1.0);
QTRY_COMPARE(sourceSpy.count(), 2);
QTRY_VERIFY(progressSpy.count() > 1);
QTRY_COMPARE(statusSpy.count(), 3);
ctxt->setContextProperty("srcImage", "");
- QTRY_VERIFY(obj->status() == QQuickBorderImage::Null);
- QTRY_VERIFY(obj->progress() == 0.0);
+ QTRY_COMPARE(obj->status(), QQuickBorderImage::Null);
+ QTRY_COMPARE(obj->progress(), 0.0);
QTRY_COMPARE(sourceSpy.count(), 3);
QTRY_VERIFY(progressSpy.count() > 2);
QTRY_COMPARE(statusSpy.count(), 4);
diff --git a/tests/auto/quick/qquickdesignersupport/data/TestComponent.qml b/tests/auto/quick/qquickdesignersupport/data/TestComponent.qml
new file mode 100644
index 0000000000..68f456af99
--- /dev/null
+++ b/tests/auto/quick/qquickdesignersupport/data/TestComponent.qml
@@ -0,0 +1,9 @@
+import QtQuick 2.0
+
+Item {
+ width: 100
+ height: 62
+
+ x: Math.max(0, 200)
+}
+
diff --git a/tests/auto/quick/qquickdesignersupport/data/test.qml b/tests/auto/quick/qquickdesignersupport/data/test.qml
new file mode 100644
index 0000000000..1d43cb3b7e
--- /dev/null
+++ b/tests/auto/quick/qquickdesignersupport/data/test.qml
@@ -0,0 +1,39 @@
+import QtQuick 2.0
+
+Rectangle {
+ objectName: "rootItem"
+ color: "white"
+ width: 800
+ height: 600
+
+ TestComponent {
+ objectName: "testComponent"
+
+ }
+
+ Rectangle {
+ objectName: "rectangleItem"
+ gradient: Gradient {
+
+ }
+ }
+
+ Item {
+ id: item
+ objectName: "simpleItem"
+ property string testProperty: dynamicProperty
+ }
+
+ states: [
+ State {
+ name: "state01"
+ PropertyChanges {
+ target: item
+ width: 10
+ }
+ },
+ State {
+ name: "state02"
+ }
+ ]
+}
diff --git a/tests/auto/quick/qquickdesignersupport/qquickdesignersupport.pro b/tests/auto/quick/qquickdesignersupport/qquickdesignersupport.pro
new file mode 100644
index 0000000000..af932d834b
--- /dev/null
+++ b/tests/auto/quick/qquickdesignersupport/qquickdesignersupport.pro
@@ -0,0 +1,16 @@
+CONFIG += testcase
+TARGET = tst_qquickdesignersupport
+SOURCES += tst_qquickdesignersupport.cpp
+
+include (../../shared/util.pri)
+include (../shared/util.pri)
+
+osx:CONFIG -= app_bundle
+
+TESTDATA = data/*
+
+QT += core-private gui-private qml-private quick-private testlib
+DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0
+
+DISTFILES += \
+ data/TestComponent.qml
diff --git a/tests/auto/quick/qquickdesignersupport/tst_qquickdesignersupport.cpp b/tests/auto/quick/qquickdesignersupport/tst_qquickdesignersupport.cpp
new file mode 100644
index 0000000000..1104ce1d98
--- /dev/null
+++ b/tests/auto/quick/qquickdesignersupport/tst_qquickdesignersupport.cpp
@@ -0,0 +1,501 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL21$
+** 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 The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/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 or version 3 as published by the Free
+** Software Foundation and appearing in the file LICENSE.LGPLv21 and
+** LICENSE.LGPLv3 included in the packaging of this file. Please review the
+** following information to ensure the GNU Lesser General Public License
+** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include <qtest.h>
+#include <QtQml/qqmlengine.h>
+#include <QtQml/qqmlcomponent.h>
+#include <QtQuick/qquickview.h>
+#include <private/qquickdesignersupportitems_p.h>
+#include <private/qquickdesignersupportmetainfo_p.h>
+#include <private/qquickdesignersupportproperties_p.h>
+#include <private/qquickdesignersupportstates_p.h>
+#include <private/qquickdesignersupportpropertychanges_p.h>
+#include <private/qquickitem_p.h>
+#include <private/qquickstate_p.h>
+#include <private/qquickstate_p_p.h>
+#include <private/qquickstategroup_p.h>
+#include <private/qquickpropertychanges_p.h>
+#include <private/qquickrectangle_p.h>
+#include "../../shared/util.h"
+#include "../shared/visualtestutil.h"
+
+using namespace QQuickVisualTestUtil;
+
+class tst_qquickdesignersupport : public QQmlDataTest
+{
+ Q_OBJECT
+public:
+ tst_qquickdesignersupport() {}
+
+private slots:
+ void customData();
+ void customDataBindings();
+ void objectProperties();
+ void dynamicProperty();
+ void createComponent();
+ void basicStates();
+ void statesPropertyChanges();
+ void testNotifyPropertyChangeCallBack();
+ void testFixResourcePathsForObjectCallBack();
+};
+
+void tst_qquickdesignersupport::customData()
+{
+ QScopedPointer<QQuickView> view(new QQuickView);
+ view->engine()->setOutputWarningsToStandardError(false);
+ view->setSource(testFileUrl("test.qml"));
+
+ QVERIFY(view->errors().isEmpty());
+
+ QQuickItem *rootItem = view->rootObject();
+
+ QVERIFY(rootItem);
+
+ QScopedPointer<QObject> newItemScopedPointer(QQuickDesignerSupportItems::createPrimitive(QLatin1String("QtQuick/Item"), 2, 6, view->rootContext()));
+ QObject *newItem = newItemScopedPointer.data();
+
+ QVERIFY(newItem);
+ QVERIFY(qobject_cast<QQuickItem*>(newItem));
+
+ QQuickDesignerSupportProperties::registerCustomData(newItem);
+ QVERIFY(QQuickDesignerSupportProperties::getResetValue(newItem, "width").isValid());
+ int defaultWidth = QQuickDesignerSupportProperties::getResetValue(newItem, "width").toInt();
+ QCOMPARE(defaultWidth, 0);
+
+ newItem->setProperty("width", 200);
+ QCOMPARE(newItem->property("width").toInt(), 200);
+
+ //Check if reseting property does work
+ QQuickDesignerSupportProperties::doResetProperty(newItem, view->rootContext(), "width");
+ QCOMPARE(newItem->property("width").toInt(), 0);
+
+ //Setting a binding on width
+ QQuickDesignerSupportProperties::setPropertyBinding(newItem,
+ view->engine()->contextForObject(newItem),
+ "width",
+ QLatin1String("Math.max(0, 200)"));
+ QCOMPARE(newItem->property("width").toInt(), 200);
+ QVERIFY(QQuickDesignerSupportProperties::hasBindingForProperty(newItem,
+ view->engine()->contextForObject(newItem),
+ "width",
+ 0));
+
+ //Check if reseting property does work after setting binding
+ QQuickDesignerSupportProperties::doResetProperty(newItem, view->rootContext(), "width");
+ QCOMPARE(newItem->property("width").toInt(), 0);
+
+ //No custom data available for the rootItem, because not registered by QQuickDesignerSupportProperties::registerCustomData
+ QVERIFY(!QQuickDesignerSupportProperties::getResetValue(rootItem, "width").isValid());
+
+ newItemScopedPointer.reset(); //Delete the item and check if item gets removed from the hash and an invalid QVariant is returned.
+
+ QVERIFY(!QQuickDesignerSupportProperties::getResetValue(newItem, "width").isValid());
+}
+
+void tst_qquickdesignersupport::customDataBindings()
+{
+ QScopedPointer<QQuickView> view(new QQuickView);
+ view->engine()->setOutputWarningsToStandardError(false);
+ view->setSource(testFileUrl("test.qml"));
+
+ QVERIFY(view->errors().isEmpty());
+
+ QQuickItem *rootItem = view->rootObject();
+
+ QVERIFY(rootItem);
+
+ QQuickItem *testComponent = findItem<QQuickItem>(view->rootObject(), QLatin1String("testComponent"));
+
+ QVERIFY(testComponent);
+ QQuickDesignerSupportProperties::registerCustomData(testComponent);
+ QQuickDesignerSupportProperties::hasValidResetBinding(testComponent, "x");
+ QVERIFY(QQuickDesignerSupportProperties::hasBindingForProperty(testComponent,
+ view->engine()->contextForObject(testComponent),
+ "x",
+ 0));
+
+ QCOMPARE(testComponent->property("x").toInt(), 200);
+
+
+ //Set property to 100 and ovveride the default binding
+ QQmlProperty property(testComponent, "x", view->engine()->contextForObject(testComponent));
+ QVERIFY(property.write(100));
+ QCOMPARE(testComponent->property("x").toInt(), 100);
+
+ QVERIFY(!QQuickDesignerSupportProperties::hasBindingForProperty(testComponent,
+ view->engine()->contextForObject(testComponent),
+ "x",
+ 0));
+
+ //Reset the binding to the default
+ QQuickDesignerSupportProperties::doResetProperty(testComponent,
+ view->engine()->contextForObject(testComponent),
+ "x");
+
+ QVERIFY(QQuickDesignerSupportProperties::hasBindingForProperty(testComponent,
+ view->engine()->contextForObject(testComponent),
+ "x",
+ 0));
+ QCOMPARE(testComponent->property("x").toInt(), 200);
+
+
+
+ //Set a different binding/expression
+ QQuickDesignerSupportProperties::setPropertyBinding(testComponent,
+ view->engine()->contextForObject(testComponent),
+ "x",
+ QLatin1String("Math.max(0, 300)"));
+
+ QVERIFY(QQuickDesignerSupportProperties::hasBindingForProperty(testComponent,
+ view->engine()->contextForObject(testComponent),
+ "x",
+ 0));
+
+ QCOMPARE(testComponent->property("x").toInt(), 300);
+
+
+
+ //Reset the binding to the default
+ QQuickDesignerSupportProperties::doResetProperty(testComponent,
+ view->engine()->contextForObject(testComponent),
+ "x");
+
+
+ QVERIFY(QQuickDesignerSupportProperties::hasBindingForProperty(testComponent,
+ view->engine()->contextForObject(testComponent),
+ "x",
+ 0));
+ QCOMPARE(testComponent->property("x").toInt(), 200);
+}
+
+void tst_qquickdesignersupport::objectProperties()
+{
+ QScopedPointer<QQuickView> view(new QQuickView);
+ view->engine()->setOutputWarningsToStandardError(false);
+ view->setSource(testFileUrl("test.qml"));
+
+ QVERIFY(view->errors().isEmpty());
+
+ QQuickItem *rootItem = view->rootObject();
+
+ QVERIFY(rootItem);
+
+ QQuickItem *rectangleItem = findItem<QQuickItem>(view->rootObject(), QLatin1String("rectangleItem"));
+ QVERIFY(rectangleItem);
+
+
+ //Read gradient property as QObject
+ int propertyIndex = rectangleItem->metaObject()->indexOfProperty("gradient");
+ QVERIFY(propertyIndex > 0);
+ QMetaProperty metaProperty = rectangleItem->metaObject()->property(propertyIndex);
+ QVERIFY(metaProperty.isValid());
+
+ QVERIFY(QQuickDesignerSupportProperties::isPropertyQObject(metaProperty));
+
+ QObject*gradient = QQuickDesignerSupportProperties::readQObjectProperty(metaProperty, rectangleItem);
+ QVERIFY(gradient);
+
+
+ //The width property is not a QObject
+ propertyIndex = rectangleItem->metaObject()->indexOfProperty("width");
+ QVERIFY(propertyIndex > 0);
+ metaProperty = rectangleItem->metaObject()->property(propertyIndex);
+ QVERIFY(metaProperty.isValid());
+ QVERIFY(!QQuickDesignerSupportProperties::isPropertyQObject(metaProperty));
+}
+
+void tst_qquickdesignersupport::dynamicProperty()
+{
+ QScopedPointer<QQuickView> view(new QQuickView);
+ view->engine()->setOutputWarningsToStandardError(false);
+ view->setSource(testFileUrl("test.qml"));
+
+ QVERIFY(view->errors().isEmpty());
+
+ QQuickItem *rootItem = view->rootObject();
+
+ QVERIFY(rootItem);
+
+ QQuickItem *simpleItem = findItem<QQuickItem>(view->rootObject(), QLatin1String("simpleItem"));
+
+ QVERIFY(simpleItem);
+
+ QQuickDesignerSupportProperties::registerNodeInstanceMetaObject(simpleItem, view->engine());
+ QQuickDesignerSupportProperties::getPropertyCache(simpleItem, view->engine());
+
+ QQuickDesignerSupportProperties::createNewDynamicProperty(simpleItem, view->engine(), QLatin1String("dynamicProperty"));
+
+ QQmlProperty property(simpleItem, "dynamicProperty", view->engine()->contextForObject(simpleItem));
+ QVERIFY(property.isValid());
+ QVERIFY(property.write(QLatin1String("test")));
+
+
+ QCOMPARE(property.read().toString(), QLatin1String("test"));
+
+ //Force evalutation of all bindings
+ QQuickDesignerSupport::refreshExpressions(view->rootContext());
+
+ //Check if expression to dynamic property gets properly resolved
+ property = QQmlProperty(simpleItem, "testProperty", view->engine()->contextForObject(simpleItem));
+ QVERIFY(property.isValid());
+ QCOMPARE(property.read().toString(), QLatin1String("test"));
+}
+
+void tst_qquickdesignersupport::createComponent()
+{
+ QScopedPointer<QQuickView> view(new QQuickView);
+ view->engine()->setOutputWarningsToStandardError(false);
+ view->setSource(testFileUrl("test.qml"));
+
+ QVERIFY(view->errors().isEmpty());
+
+ QQuickItem *rootItem = view->rootObject();
+
+ QVERIFY(rootItem);
+
+ QObject *testComponentObject = QQuickDesignerSupportItems::createComponent(testFileUrl("TestComponent.qml"), view->rootContext());
+ QVERIFY(testComponentObject);
+
+ QVERIFY(QQuickDesignerSupportMetaInfo::isSubclassOf(testComponentObject, "QtQuick/Item"));
+}
+
+void tst_qquickdesignersupport::basicStates()
+{
+ QScopedPointer<QQuickView> view(new QQuickView);
+ view->engine()->setOutputWarningsToStandardError(false);
+ view->setSource(testFileUrl("test.qml"));
+
+ QVERIFY(view->errors().isEmpty());
+
+ QQuickItem *rootItem = view->rootObject();
+
+ QVERIFY(rootItem);
+
+ QQuickStateGroup *stateGroup = QQuickItemPrivate::get(rootItem)->_states();
+
+ QVERIFY(stateGroup);
+
+ QCOMPARE(stateGroup->states().count(), 2 );
+
+ QQuickState *state01 = stateGroup->states().first();
+ QQuickState *state02 = stateGroup->states().last();
+
+ QVERIFY(state01);
+ QVERIFY(state02);
+
+ QCOMPARE(state01->property("name").toString(), QLatin1String("state01"));
+ QCOMPARE(state02->property("name").toString(), QLatin1String("state02"));
+
+ QVERIFY(!QQuickDesignerSupportStates::isStateActive(state01, view->rootContext()));
+ QVERIFY(!QQuickDesignerSupportStates::isStateActive(state01, view->rootContext()));
+
+ QQuickDesignerSupportStates::activateState(state01, view->rootContext());
+ QVERIFY(QQuickDesignerSupportStates::isStateActive(state01, view->rootContext()));
+
+ QQuickDesignerSupportStates::activateState(state02, view->rootContext());
+ QVERIFY(QQuickDesignerSupportStates::isStateActive(state02, view->rootContext()));
+ QVERIFY(!QQuickDesignerSupportStates::isStateActive(state01, view->rootContext()));
+
+ QQuickDesignerSupportStates::deactivateState(state02);
+ QVERIFY(!QQuickDesignerSupportStates::isStateActive(state01, view->rootContext()));
+ QVERIFY(!QQuickDesignerSupportStates::isStateActive(state01, view->rootContext()));
+}
+
+void tst_qquickdesignersupport::statesPropertyChanges()
+{
+ QScopedPointer<QQuickView> view(new QQuickView);
+ view->engine()->setOutputWarningsToStandardError(false);
+ view->setSource(testFileUrl("test.qml"));
+
+ QVERIFY(view->errors().isEmpty());
+
+ QQuickItem *rootItem = view->rootObject();
+
+ QVERIFY(rootItem);
+
+ QQuickItem *simpleItem = findItem<QQuickItem>(view->rootObject(), QLatin1String("simpleItem"));
+
+ QVERIFY(simpleItem);
+
+ QQuickStateGroup *stateGroup = QQuickItemPrivate::get(rootItem)->_states();
+
+ QVERIFY(stateGroup);
+
+ QCOMPARE(stateGroup->states().count(), 2 );
+
+ QQuickState *state01 = stateGroup->states().first();
+ QQuickState *state02 = stateGroup->states().last();
+
+ QVERIFY(state01);
+ QVERIFY(state02);
+
+ QCOMPARE(state01->property("name").toString(), QLatin1String("state01"));
+ QCOMPARE(state02->property("name").toString(), QLatin1String("state02"));
+
+ //PropertyChanges are parsed lazily
+ QQuickDesignerSupportStates::activateState(state01, view->rootContext());
+ QQuickDesignerSupportStates::deactivateState(state01);
+
+ QQuickStatePrivate *statePrivate01 = static_cast<QQuickStatePrivate *>(QQuickStatePrivate::get(state01));
+
+ QCOMPARE(state01->operationCount(), 1);
+
+ QCOMPARE(statePrivate01->operations.count(), 1);
+
+ QQuickStateOperation *propertyChange = statePrivate01->operations.at(0).data();
+
+ QCOMPARE(QQuickDesignerSupportPropertyChanges::stateObject(propertyChange), state01);
+
+ QQuickDesignerSupportPropertyChanges::changeValue(propertyChange, "width", 300);
+
+ QCOMPARE(simpleItem->property("width").toInt(), 0);
+ QQuickDesignerSupportStates::activateState(state01, view->rootContext());
+ QCOMPARE(simpleItem->property("width").toInt(), 300);
+ QQuickDesignerSupportStates::deactivateState(state01);
+ QCOMPARE(simpleItem->property("width").toInt(), 0);
+
+ //Set "base state value" in state1 using the revert list
+ QQuickDesignerSupportStates::activateState(state01, view->rootContext());
+ QQuickDesignerSupportStates::changeValueInRevertList(state01, simpleItem, "width", 200);
+ QCOMPARE(simpleItem->property("width").toInt(), 300);
+ QQuickDesignerSupportStates::deactivateState(state01);
+ QCOMPARE(simpleItem->property("width").toInt(), 200);
+
+
+ //Create new PropertyChanges
+ QQuickPropertyChanges *newPropertyChange = new QQuickPropertyChanges();
+ newPropertyChange->setParent(state01);
+ QQmlListProperty<QQuickStateOperation> changes = state01->changes();
+ QQuickStatePrivate::operations_append(&changes, newPropertyChange);
+
+ newPropertyChange->setObject(rootItem);
+
+ QQuickDesignerSupportPropertyChanges::attachToState(newPropertyChange);
+
+ QCOMPARE(rootItem, QQuickDesignerSupportPropertyChanges::targetObject(newPropertyChange));
+
+ QCOMPARE(state01->operationCount(), 2);
+ QCOMPARE(statePrivate01->operations.count(), 2);
+
+ QCOMPARE(QQuickDesignerSupportPropertyChanges::stateObject(newPropertyChange), state01);
+
+ //Set color for rootItem in state1
+ QQuickDesignerSupportPropertyChanges::changeValue(newPropertyChange, "color", QColor(Qt::red));
+
+ QQuickDesignerSupportStates::activateState(state01, view->rootContext());
+ QCOMPARE(rootItem->property("color").value<QColor>(), QColor(Qt::red));
+ QQuickDesignerSupportStates::deactivateState(state01);
+ QCOMPARE(rootItem->property("color").value<QColor>(), QColor(Qt::white));
+
+ QQuickDesignerSupportPropertyChanges::removeProperty(newPropertyChange, "color");
+ QQuickDesignerSupportStates::activateState(state01, view->rootContext());
+ QCOMPARE(rootItem->property("color").value<QColor>(), QColor(Qt::white));
+
+}
+
+static QObject * s_object = 0;
+static QQuickDesignerSupport::PropertyName s_propertyName;
+
+static void notifyPropertyChangeCallBackFunction(QObject *object, const QQuickDesignerSupport::PropertyName &propertyName)
+{
+ s_object = object;
+ s_propertyName = propertyName;
+}
+
+static void (*notifyPropertyChangeCallBackPointer)(QObject *, const QQuickDesignerSupport::PropertyName &) = &notifyPropertyChangeCallBackFunction;
+
+
+void tst_qquickdesignersupport::testNotifyPropertyChangeCallBack()
+{
+ QScopedPointer<QQuickView> view(new QQuickView);
+ view->engine()->setOutputWarningsToStandardError(false);
+ view->setSource(testFileUrl("test.qml"));
+
+ QVERIFY(view->errors().isEmpty());
+
+ QQuickItem *rootItem = view->rootObject();
+
+ QVERIFY(rootItem);
+
+ QQuickRectangle *rectangle = static_cast<QQuickRectangle *>(rootItem);
+ QVERIFY(rectangle);
+
+ QQuickDesignerSupportProperties::registerNodeInstanceMetaObject(rectangle, view->engine());
+
+ QQuickGradient *gradient = new QQuickGradient(rectangle);
+
+ QQuickDesignerSupportMetaInfo::registerNotifyPropertyChangeCallBack(notifyPropertyChangeCallBackPointer);
+
+ rectangle->setProperty("gradient", QVariant::fromValue<QQuickGradient *>(gradient));
+
+ QVERIFY(s_object);
+ QCOMPARE(s_object, rootItem);
+ QCOMPARE(s_propertyName, QQuickDesignerSupport::PropertyName("gradient"));
+}
+
+static void fixResourcePathsForObjectCallBackFunction(QObject *object)
+{
+ s_object = object;
+}
+
+static void (*fixResourcePathsForObjectCallBackPointer)(QObject *) = &fixResourcePathsForObjectCallBackFunction;
+
+void tst_qquickdesignersupport::testFixResourcePathsForObjectCallBack()
+{
+ QScopedPointer<QQuickView> view(new QQuickView);
+ view->engine()->setOutputWarningsToStandardError(false);
+ view->setSource(testFileUrl("test.qml"));
+
+ QVERIFY(view->errors().isEmpty());
+
+ QQuickItem *rootItem = view->rootObject();
+
+ QVERIFY(rootItem);
+
+ s_object = 0;
+
+ QQuickDesignerSupportItems::registerFixResourcePathsForObjectCallBack(fixResourcePathsForObjectCallBackPointer);
+
+ QQuickItem *simpleItem = findItem<QQuickItem>(view->rootObject(), QLatin1String("simpleItem"));
+
+ QVERIFY(simpleItem);
+
+ QQuickDesignerSupportItems::tweakObjects(simpleItem);
+
+ //Check that the fixResourcePathsForObjectCallBack was called on simpleItem
+ QCOMPARE(simpleItem , s_object);
+}
+
+
+QTEST_MAIN(tst_qquickdesignersupport)
+
+#include "tst_qquickdesignersupport.moc"
diff --git a/tests/auto/quick/qquickdynamicpropertyanimation/tst_qquickdynamicpropertyanimation.cpp b/tests/auto/quick/qquickdynamicpropertyanimation/tst_qquickdynamicpropertyanimation.cpp
index 40bd6624f0..3656bb8aab 100644
--- a/tests/auto/quick/qquickdynamicpropertyanimation/tst_qquickdynamicpropertyanimation.cpp
+++ b/tests/auto/quick/qquickdynamicpropertyanimation/tst_qquickdynamicpropertyanimation.cpp
@@ -59,11 +59,11 @@ private:
QQmlProperty testProp(item, propertyName);
QPropertyAnimation animation(item, propertyName, this);
animation.setEndValue(toValue);
- QVERIFY(animation.targetObject() == item);
- QVERIFY(animation.propertyName() == propertyName);
- QVERIFY(animation.endValue().value<T>() == toValue);
+ QCOMPARE(animation.targetObject(), item);
+ QCOMPARE(animation.propertyName(), propertyName);
+ QCOMPARE(animation.endValue().value<T>(), toValue);
animation.start();
- QVERIFY(animation.state() == QAbstractAnimation::Running);
+ QCOMPARE(animation.state(), QAbstractAnimation::Running);
QTest::qWait(animation.duration());
QTRY_COMPARE(testProp.read().value<T>(), toValue);
}
diff --git a/tests/auto/quick/qquickflickable/BLACKLIST b/tests/auto/quick/qquickflickable/BLACKLIST
index 92ed8708de..647bf819a5 100644
--- a/tests/auto/quick/qquickflickable/BLACKLIST
+++ b/tests/auto/quick/qquickflickable/BLACKLIST
@@ -10,7 +10,7 @@ osx-10.10
osx-10.10
[stopAtBounds]
osx-10.10
-windows 32bit developer-build
+windows developer-build
[returnToBounds]
osx
[pressWhileFlicking]
diff --git a/tests/auto/quick/qquickflickable/data/movementSignals.qml b/tests/auto/quick/qquickflickable/data/movementSignals.qml
new file mode 100644
index 0000000000..581e882139
--- /dev/null
+++ b/tests/auto/quick/qquickflickable/data/movementSignals.qml
@@ -0,0 +1,26 @@
+import QtQuick 2.0
+
+Flickable {
+ width: 400; height: 400
+ contentWidth: 400; contentHeight: 1200
+
+ property string signalString
+
+ Rectangle {
+ width: 400; height: 400
+ color: "red"
+ }
+ Rectangle {
+ y: 400; width: 400; height: 400
+ color: "yellow"
+ }
+ Rectangle {
+ y: 800; width: 400; height: 400
+ color: "green"
+ }
+
+ onMovementStarted: signalString += "ms"
+ onMovementEnded: signalString += "me"
+ onFlickStarted: signalString += "fs"
+ onFlickEnded: signalString += "fe"
+}
diff --git a/tests/auto/quick/qquickflickable/data/nestedPressDelay.qml b/tests/auto/quick/qquickflickable/data/nestedPressDelay.qml
index 742656641f..bdb866ce65 100644
--- a/tests/auto/quick/qquickflickable/data/nestedPressDelay.qml
+++ b/tests/auto/quick/qquickflickable/data/nestedPressDelay.qml
@@ -8,12 +8,18 @@ Flickable {
contentHeight: 320
flickableDirection: Flickable.HorizontalFlick
pressDelay: 10000
- Rectangle {
+ MouseArea {
+ objectName: "filteringMouseArea"
x: 20
y: 20
width: 400
height: 300
- color: "yellow"
+ drag.filterChildren: true
+ Rectangle {
+ id: rectangle
+ color: "yellow"
+ anchors.fill: parent
+ }
Flickable {
objectName: "innerFlickable"
anchors.fill: parent
diff --git a/tests/auto/quick/qquickflickable/tst_qquickflickable.cpp b/tests/auto/quick/qquickflickable/tst_qquickflickable.cpp
index 7d08c3c81e..dc7171746c 100644
--- a/tests/auto/quick/qquickflickable/tst_qquickflickable.cpp
+++ b/tests/auto/quick/qquickflickable/tst_qquickflickable.cpp
@@ -67,6 +67,7 @@ private slots:
void flickDeceleration();
void pressDelay();
void nestedPressDelay();
+ void filterReplayedPress();
void nestedClickThenFlick();
void flickableDirection();
void resizeContent();
@@ -91,7 +92,9 @@ private slots:
void stopAtBounds_data();
void nestedMouseAreaUsingTouch();
void pressDelayWithLoader();
+ void movementFromProgrammaticFlick();
void cleanup();
+ void contentSize();
private:
void flickWithTouch(QQuickWindow *window, QTouchDevice *touchDevice, const QPoint &from, const QPoint &to);
@@ -195,9 +198,9 @@ void tst_qquickflickable::properties()
QCOMPARE(obj->pressDelay(), 200);
QCOMPARE(obj->maximumFlickVelocity(), 2000.);
- QVERIFY(obj->property("ok").toBool() == false);
+ QVERIFY(!obj->property("ok").toBool());
QMetaObject::invokeMethod(obj, "check");
- QVERIFY(obj->property("ok").toBool() == true);
+ QVERIFY(obj->property("ok").toBool());
delete obj;
}
@@ -211,28 +214,28 @@ void tst_qquickflickable::boundsBehavior()
QSignalSpy spy(flickable, SIGNAL(boundsBehaviorChanged()));
QVERIFY(flickable);
- QVERIFY(flickable->boundsBehavior() == QQuickFlickable::StopAtBounds);
+ QCOMPARE(flickable->boundsBehavior(), QQuickFlickable::StopAtBounds);
flickable->setBoundsBehavior(QQuickFlickable::DragAndOvershootBounds);
- QVERIFY(flickable->boundsBehavior() == QQuickFlickable::DragAndOvershootBounds);
+ QCOMPARE(flickable->boundsBehavior(), QQuickFlickable::DragAndOvershootBounds);
QCOMPARE(spy.count(),1);
flickable->setBoundsBehavior(QQuickFlickable::DragAndOvershootBounds);
QCOMPARE(spy.count(),1);
flickable->setBoundsBehavior(QQuickFlickable::DragOverBounds);
- QVERIFY(flickable->boundsBehavior() == QQuickFlickable::DragOverBounds);
+ QCOMPARE(flickable->boundsBehavior(), QQuickFlickable::DragOverBounds);
QCOMPARE(spy.count(),2);
flickable->setBoundsBehavior(QQuickFlickable::DragOverBounds);
QCOMPARE(spy.count(),2);
flickable->setBoundsBehavior(QQuickFlickable::StopAtBounds);
- QVERIFY(flickable->boundsBehavior() == QQuickFlickable::StopAtBounds);
+ QCOMPARE(flickable->boundsBehavior(), QQuickFlickable::StopAtBounds);
QCOMPARE(spy.count(),3);
flickable->setBoundsBehavior(QQuickFlickable::StopAtBounds);
QCOMPARE(spy.count(),3);
flickable->setBoundsBehavior(QQuickFlickable::OvershootBounds);
- QVERIFY(flickable->boundsBehavior() == QQuickFlickable::OvershootBounds);
+ QCOMPARE(flickable->boundsBehavior(), QQuickFlickable::OvershootBounds);
QCOMPARE(spy.count(),4);
flickable->setBoundsBehavior(QQuickFlickable::OvershootBounds);
QCOMPARE(spy.count(),4);
@@ -249,7 +252,7 @@ void tst_qquickflickable::rebound()
QQuickViewTestUtil::moveMouseAway(window.data());
window->show();
- QVERIFY(QTest::qWaitForWindowExposed(window.data()));
+ QVERIFY(QTest::qWaitForWindowActive(window.data()));
QVERIFY(window->rootObject() != 0);
QQuickFlickable *flickable = qobject_cast<QQuickFlickable*>(window->rootObject());
@@ -295,11 +298,11 @@ void tst_qquickflickable::rebound()
// flick and trigger the transition multiple times
// (moving signals are emitted as soon as the first transition starts)
- flick(window.data(), QPoint(20,20), QPoint(120,120), 200); // both x and y will bounce back
- flick(window.data(), QPoint(20,120), QPoint(120,20), 200); // only x will bounce back
+ flick(window.data(), QPoint(20,20), QPoint(120,120), 50); // both x and y will bounce back
+ flick(window.data(), QPoint(20,120), QPoint(120,20), 50); // only x will bounce back
QVERIFY(flickable->isMoving());
- QVERIFY(window->rootObject()->property("transitionsStarted").toInt() >= 1);
+ QTRY_VERIFY(window->rootObject()->property("transitionsStarted").toInt() >= 1);
QCOMPARE(hMoveSpy.count(), 1);
QCOMPARE(vMoveSpy.count(), 1);
QCOMPARE(movementStartedSpy.count(), 1);
@@ -388,7 +391,7 @@ void tst_qquickflickable::pressDelay()
QQuickViewTestUtil::centerOnScreen(window.data());
QQuickViewTestUtil::moveMouseAway(window.data());
window->show();
- QVERIFY(QTest::qWaitForWindowExposed(window.data()));
+ QVERIFY(QTest::qWaitForWindowActive(window.data()));
QVERIFY(window->rootObject() != 0);
QQuickFlickable *flickable = qobject_cast<QQuickFlickable*>(window->rootObject());
@@ -406,13 +409,13 @@ void tst_qquickflickable::pressDelay()
QQuickItem *mouseArea = window->rootObject()->findChild<QQuickItem*>("mouseArea");
QSignalSpy clickedSpy(mouseArea, SIGNAL(clicked(QQuickMouseEvent*)));
- QTest::mousePress(window.data(), Qt::LeftButton, 0, QPoint(150, 150));
+ moveAndPress(window.data(), QPoint(150, 150));
// The press should not occur immediately
- QVERIFY(mouseArea->property("pressed").toBool() == false);
+ QVERIFY(!mouseArea->property("pressed").toBool());
// But, it should occur eventually
- QTRY_VERIFY(mouseArea->property("pressed").toBool() == true);
+ QTRY_VERIFY(mouseArea->property("pressed").toBool());
QCOMPARE(clickedSpy.count(),0);
@@ -427,10 +430,10 @@ void tst_qquickflickable::pressDelay()
// Test a quick tap within the pressDelay timeout
clickedSpy.clear();
- QTest::mousePress(window.data(), Qt::LeftButton, 0, QPoint(180, 180));
+ moveAndPress(window.data(), QPoint(180, 180));
// The press should not occur immediately
- QVERIFY(mouseArea->property("pressed").toBool() == false);
+ QVERIFY(!mouseArea->property("pressed").toBool());
QCOMPARE(clickedSpy.count(),0);
@@ -444,16 +447,16 @@ void tst_qquickflickable::pressDelay()
// QTBUG-31168
- QTest::mousePress(window.data(), Qt::LeftButton, 0, QPoint(150, 110));
+ moveAndPress(window.data(), QPoint(150, 110));
// The press should not occur immediately
- QVERIFY(mouseArea->property("pressed").toBool() == false);
+ QVERIFY(!mouseArea->property("pressed").toBool());
QTest::mouseMove(window.data(), QPoint(150, 190));
// As we moved pass the drag threshold, we should never receive the press
- QVERIFY(mouseArea->property("pressed").toBool() == false);
- QTRY_VERIFY(mouseArea->property("pressed").toBool() == false);
+ QVERIFY(!mouseArea->property("pressed").toBool());
+ QTRY_VERIFY(!mouseArea->property("pressed").toBool());
// On release the clicked signal should *not* be emitted
QTest::mouseRelease(window.data(), Qt::LeftButton, 0, QPoint(150, 190));
@@ -469,7 +472,7 @@ void tst_qquickflickable::nestedPressDelay()
QQuickViewTestUtil::centerOnScreen(window.data());
QQuickViewTestUtil::moveMouseAway(window.data());
window->show();
- QVERIFY(QTest::qWaitForWindowExposed(window.data()));
+ QVERIFY(QTest::qWaitForWindowActive(window.data()));
QVERIFY(window->rootObject() != 0);
QQuickFlickable *outer = qobject_cast<QQuickFlickable*>(window->rootObject());
@@ -478,48 +481,90 @@ void tst_qquickflickable::nestedPressDelay()
QQuickFlickable *inner = window->rootObject()->findChild<QQuickFlickable*>("innerFlickable");
QVERIFY(inner != 0);
- QTest::mousePress(window.data(), Qt::LeftButton, 0, QPoint(150, 150));
+ moveAndPress(window.data(), QPoint(150, 150));
// the MouseArea is not pressed immediately
- QVERIFY(outer->property("pressed").toBool() == false);
- QVERIFY(inner->property("pressed").toBool() == false);
+ QVERIFY(!outer->property("pressed").toBool());
+ QVERIFY(!inner->property("pressed").toBool());
// The inner pressDelay will prevail (50ms, vs. 10sec)
// QTRY_VERIFY() has 5sec timeout, so will timeout well within 10sec.
- QTRY_VERIFY(outer->property("pressed").toBool() == true);
+ QTRY_VERIFY(outer->property("pressed").toBool());
QTest::mouseRelease(window.data(), Qt::LeftButton, 0, QPoint(150, 150));
// Dragging inner Flickable should work
- QTest::mousePress(window.data(), Qt::LeftButton, 0, QPoint(80, 150));
+ moveAndPress(window.data(), QPoint(80, 150));
// the MouseArea is not pressed immediately
- QVERIFY(outer->property("pressed").toBool() == false);
- QVERIFY(inner->property("pressed").toBool() == false);
+ QVERIFY(!outer->property("pressed").toBool());
+ QVERIFY(!inner->property("pressed").toBool());
QTest::mouseMove(window.data(), QPoint(60, 150));
QTest::mouseMove(window.data(), QPoint(40, 150));
QTest::mouseMove(window.data(), QPoint(20, 150));
- QVERIFY(inner->property("moving").toBool() == true);
- QVERIFY(outer->property("moving").toBool() == false);
+ QVERIFY(inner->property("moving").toBool());
+ QVERIFY(!outer->property("moving").toBool());
QTest::mouseRelease(window.data(), Qt::LeftButton, 0, QPoint(20, 150));
// Dragging the MouseArea in the inner Flickable should move the inner Flickable
- QTest::mousePress(window.data(), Qt::LeftButton, 0, QPoint(150, 150));
+ moveAndPress(window.data(), QPoint(150, 150));
// the MouseArea is not pressed immediately
- QVERIFY(outer->property("pressed").toBool() == false);
+ QVERIFY(!outer->property("pressed").toBool());
QTest::mouseMove(window.data(), QPoint(130, 150));
QTest::mouseMove(window.data(), QPoint(110, 150));
QTest::mouseMove(window.data(), QPoint(90, 150));
- QVERIFY(outer->property("moving").toBool() == false);
- QVERIFY(inner->property("moving").toBool() == true);
+ QVERIFY(!outer->property("moving").toBool());
+ QVERIFY(inner->property("moving").toBool());
QTest::mouseRelease(window.data(), Qt::LeftButton, 0, QPoint(90, 150));
}
+void tst_qquickflickable::filterReplayedPress()
+{
+ 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::qWaitForWindowActive(window.data()));
+ QVERIFY(window->rootObject() != 0);
+
+ QQuickFlickable *outer = qobject_cast<QQuickFlickable*>(window->rootObject());
+ QVERIFY(outer != 0);
+
+ QQuickFlickable *inner = window->rootObject()->findChild<QQuickFlickable*>("innerFlickable");
+ QVERIFY(inner != 0);
+
+ QQuickItem *filteringMouseArea = outer->findChild<QQuickItem *>("filteringMouseArea");
+ QVERIFY(filteringMouseArea);
+
+ moveAndPress(window.data(), QPoint(150, 150));
+ // the MouseArea filtering the Flickable is pressed immediately.
+ QCOMPARE(filteringMouseArea->property("pressed").toBool(), true);
+
+ // Some event causes the mouse area to set keepMouseGrab.
+ filteringMouseArea->setKeepMouseGrab(true);
+ QCOMPARE(filteringMouseArea->keepMouseGrab(), true);
+
+ // The inner pressDelay will prevail (50ms, vs. 10sec)
+ // QTRY_VERIFY() has 5sec timeout, so will timeout well within 10sec.
+ QTRY_VERIFY(outer->property("pressed").toBool());
+
+ // The replayed press event isn't delivered to parent items of the
+ // flickable with the press delay, and the state of the parent mouse
+ // area is therefore unaffected.
+ QCOMPARE(filteringMouseArea->property("pressed").toBool(), true);
+ QCOMPARE(filteringMouseArea->keepMouseGrab(), true);
+
+ QTest::mouseRelease(window.data(), Qt::LeftButton, 0, QPoint(150, 150));
+}
+
+
// QTBUG-37316
void tst_qquickflickable::nestedClickThenFlick()
{
@@ -529,7 +574,7 @@ void tst_qquickflickable::nestedClickThenFlick()
QQuickViewTestUtil::centerOnScreen(window.data());
QQuickViewTestUtil::moveMouseAway(window.data());
window->show();
- QVERIFY(QTest::qWaitForWindowExposed(window.data()));
+ QVERIFY(QTest::qWaitForWindowActive(window.data()));
QVERIFY(window->rootObject() != 0);
QQuickFlickable *outer = qobject_cast<QQuickFlickable*>(window->rootObject());
@@ -538,29 +583,29 @@ void tst_qquickflickable::nestedClickThenFlick()
QQuickFlickable *inner = window->rootObject()->findChild<QQuickFlickable*>("innerFlickable");
QVERIFY(inner != 0);
- QTest::mousePress(window.data(), Qt::LeftButton, 0, QPoint(150, 150));
+ moveAndPress(window.data(), QPoint(150, 150));
// the MouseArea is not pressed immediately
- QVERIFY(outer->property("pressed").toBool() == false);
- QTRY_VERIFY(outer->property("pressed").toBool() == true);
+ QVERIFY(!outer->property("pressed").toBool());
+ QTRY_VERIFY(outer->property("pressed").toBool());
QTest::mouseRelease(window.data(), Qt::LeftButton, 0, QPoint(150, 150));
- QVERIFY(outer->property("pressed").toBool() == false);
+ QVERIFY(!outer->property("pressed").toBool());
// Dragging inner Flickable should work
- QTest::mousePress(window.data(), Qt::LeftButton, 0, QPoint(80, 150));
+ moveAndPress(window.data(), QPoint(80, 150));
// the MouseArea is not pressed immediately
- QVERIFY(outer->property("pressed").toBool() == false);
+ QVERIFY(!outer->property("pressed").toBool());
QTest::mouseMove(window.data(), QPoint(80, 148));
QTest::mouseMove(window.data(), QPoint(80, 140));
QTest::mouseMove(window.data(), QPoint(80, 120));
QTest::mouseMove(window.data(), QPoint(80, 100));
- QVERIFY(outer->property("moving").toBool() == false);
- QVERIFY(inner->property("moving").toBool() == true);
+ QVERIFY(!outer->property("moving").toBool());
+ QVERIFY(inner->property("moving").toBool());
QTest::mouseRelease(window.data(), Qt::LeftButton, 0, QPoint(80, 100));
}
@@ -628,6 +673,8 @@ void tst_qquickflickable::returnToBounds()
window->rootContext()->setContextProperty("setRebound", setRebound);
window->setSource(testFileUrl("resize.qml"));
+ window->show();
+ QTest::qWaitForWindowActive(window.data());
QVERIFY(window->rootObject() != 0);
QQuickFlickable *obj = findItem<QQuickFlickable>(window->rootObject(), "flick");
@@ -671,7 +718,7 @@ void tst_qquickflickable::wheel()
QScopedPointer<QQuickView> window(new QQuickView);
window->setSource(testFileUrl("wheel.qml"));
window->show();
- QVERIFY(QTest::qWaitForWindowExposed(window.data()));
+ QVERIFY(QTest::qWaitForWindowActive(window.data()));
QVERIFY(window->rootObject() != 0);
QQuickFlickable *flick = window->rootObject()->findChild<QQuickFlickable*>("flick");
@@ -685,10 +732,10 @@ void tst_qquickflickable::wheel()
}
QTRY_VERIFY(flick->contentY() > 0);
- QVERIFY(flick->contentX() == 0);
+ QCOMPARE(flick->contentX(), qreal(0));
flick->setContentY(0);
- QVERIFY(flick->contentY() == 0);
+ QCOMPARE(flick->contentY(), qreal(0));
{
QPoint pos(200, 200);
@@ -699,7 +746,7 @@ void tst_qquickflickable::wheel()
}
QTRY_VERIFY(flick->contentX() > 0);
- QVERIFY(flick->contentY() == 0);
+ QCOMPARE(flick->contentY(), qreal(0));
}
void tst_qquickflickable::movingAndFlicking_data()
@@ -740,7 +787,7 @@ void tst_qquickflickable::movingAndFlicking()
QQuickViewTestUtil::centerOnScreen(window.data());
QQuickViewTestUtil::moveMouseAway(window.data());
window->show();
- QVERIFY(QTest::qWaitForWindowExposed(window.data()));
+ QVERIFY(QTest::qWaitForWindowActive(window.data()));
QVERIFY(window->rootObject() != 0);
QQuickFlickable *flickable = qobject_cast<QQuickFlickable*>(window->rootObject());
@@ -903,7 +950,7 @@ void tst_qquickflickable::movingAndDragging()
QQuickViewTestUtil::centerOnScreen(window.data());
QQuickViewTestUtil::moveMouseAway(window.data());
window->show();
- QVERIFY(QTest::qWaitForWindowExposed(window.data()));
+ QVERIFY(QTest::qWaitForWindowActive(window.data()));
QVERIFY(window->rootObject() != 0);
QQuickFlickable *flickable = qobject_cast<QQuickFlickable*>(window->rootObject());
@@ -922,7 +969,7 @@ void tst_qquickflickable::movingAndDragging()
QSignalSpy moveEndSpy(flickable, SIGNAL(movementEnded()));
// start the drag
- QTest::mousePress(window.data(), Qt::LeftButton, 0, moveFrom);
+ moveAndPress(window.data(), moveFrom);
QTest::mouseMove(window.data(), moveFrom + moveByWithoutSnapBack);
QTest::mouseMove(window.data(), moveFrom + moveByWithoutSnapBack*2);
QTest::mouseMove(window.data(), moveFrom + moveByWithoutSnapBack*3);
@@ -962,7 +1009,7 @@ void tst_qquickflickable::movingAndDragging()
// Don't test whether moving finished because a flick could occur
// wait for any motion to end
- QTRY_VERIFY(flickable->isMoving() == false);
+ QTRY_VERIFY(!flickable->isMoving());
QVERIFY(!flickable->isMovingHorizontally());
QVERIFY(!flickable->isMovingVertically());
@@ -998,7 +1045,7 @@ void tst_qquickflickable::movingAndDragging()
flickable->setContentX(0);
flickable->setContentY(0);
QTRY_VERIFY(!flickable->isMoving());
- QTest::mousePress(window.data(), Qt::LeftButton, 0, moveFrom);
+ moveAndPress(window.data(), moveFrom);
QTest::mouseMove(window.data(), moveFrom + moveByWithSnapBack);
QTest::mouseMove(window.data(), moveFrom + moveByWithSnapBack*2);
QTest::mouseMove(window.data(), moveFrom + moveByWithSnapBack*3);
@@ -1072,7 +1119,7 @@ void tst_qquickflickable::flickOnRelease()
QScopedPointer<QQuickView> window(new QQuickView);
window->setSource(testFileUrl("flickable03.qml"));
window->show();
- QVERIFY(QTest::qWaitForWindowExposed(window.data()));
+ QVERIFY(QTest::qWaitForWindowActive(window.data()));
QVERIFY(window->rootObject() != 0);
QQuickFlickable *flickable = qobject_cast<QQuickFlickable*>(window->rootObject());
@@ -1085,14 +1132,14 @@ void tst_qquickflickable::flickOnRelease()
// underlying drivers will hopefully provide a pre-calculated velocity
// (based on more data than what the UI gets), thus making this use case
// working even with small movements.
- QTest::mousePress(window.data(), Qt::LeftButton, 0, QPoint(50, 300));
+ moveAndPress(window.data(), QPoint(50, 300));
QTest::mouseMove(window.data(), QPoint(50, 10), 10);
QTest::mouseRelease(window.data(), Qt::LeftButton, 0, QPoint(50, 10), 10);
QCOMPARE(vFlickSpy.count(), 1);
// wait for any motion to end
- QTRY_VERIFY(flickable->isMoving() == false);
+ QTRY_VERIFY(!flickable->isMoving());
#ifdef Q_OS_MAC
QEXPECT_FAIL("", "QTBUG-26094 stopping on a full pixel doesn't work on OS X", Continue);
@@ -1109,7 +1156,7 @@ void tst_qquickflickable::pressWhileFlicking()
QQuickViewTestUtil::centerOnScreen(window.data());
QQuickViewTestUtil::moveMouseAway(window.data());
window->show();
- QVERIFY(QTest::qWaitForWindowExposed(window.data()));
+ QVERIFY(QTest::qWaitForWindowActive(window.data()));
QVERIFY(window->rootObject() != 0);
QQuickFlickable *flickable = qobject_cast<QQuickFlickable*>(window->rootObject());
@@ -1159,27 +1206,27 @@ void tst_qquickflickable::disabled()
QScopedPointer<QQuickView> window(new QQuickView);
window->setSource(testFileUrl("disabled.qml"));
window->show();
- QVERIFY(QTest::qWaitForWindowExposed(window.data()));
+ QVERIFY(QTest::qWaitForWindowActive(window.data()));
QVERIFY(window->rootObject() != 0);
QQuickFlickable *flick = window->rootObject()->findChild<QQuickFlickable*>("flickable");
QVERIFY(flick != 0);
- QTest::mousePress(window.data(), Qt::LeftButton, 0, QPoint(50, 90));
+ moveAndPress(window.data(), QPoint(50, 90));
QTest::mouseMove(window.data(), QPoint(50, 80));
QTest::mouseMove(window.data(), QPoint(50, 70));
QTest::mouseMove(window.data(), QPoint(50, 60));
- QVERIFY(flick->isMoving() == false);
+ QVERIFY(!flick->isMoving());
QTest::mouseRelease(window.data(), Qt::LeftButton, 0, QPoint(50, 60));
// verify that mouse clicks on other elements still work (QTBUG-20584)
- QTest::mousePress(window.data(), Qt::LeftButton, 0, QPoint(50, 10));
+ moveAndPress(window.data(), QPoint(50, 10));
QTest::mouseRelease(window.data(), Qt::LeftButton, 0, QPoint(50, 10));
- QTRY_VERIFY(window->rootObject()->property("clicked").toBool() == true);
+ QTRY_VERIFY(window->rootObject()->property("clicked").toBool());
}
void tst_qquickflickable::flickVelocity()
@@ -1190,7 +1237,7 @@ void tst_qquickflickable::flickVelocity()
QQuickViewTestUtil::centerOnScreen(window.data());
QQuickViewTestUtil::moveMouseAway(window.data());
window->show();
- QVERIFY(QTest::qWaitForWindowExposed(window.data()));
+ QVERIFY(QTest::qWaitForWindowActive(window.data()));
QVERIFY(window->rootObject() != 0);
QQuickFlickable *flickable = qobject_cast<QQuickFlickable*>(window->rootObject());
@@ -1199,12 +1246,12 @@ void tst_qquickflickable::flickVelocity()
// flick up
flick(window.data(), QPoint(20,190), QPoint(20, 50), 200);
QVERIFY(flickable->verticalVelocity() > 0.0);
- QTRY_VERIFY(flickable->verticalVelocity() == 0.0);
+ QTRY_COMPARE(flickable->verticalVelocity(), 0.0);
// flick down
flick(window.data(), QPoint(20,10), QPoint(20, 140), 200);
QTRY_VERIFY(flickable->verticalVelocity() < 0.0);
- QTRY_VERIFY(flickable->verticalVelocity() == 0.0);
+ QTRY_COMPARE(flickable->verticalVelocity(), 0.0);
#ifdef Q_OS_MAC
QSKIP("boost doesn't work on OS X");
@@ -1223,7 +1270,7 @@ void tst_qquickflickable::flickVelocity()
// Flick in opposite direction -> boost cancelled.
flick(window.data(), QPoint(20,10), QPoint(20, 340), 200);
QTRY_VERIFY(flickable->verticalVelocity() < 0.0);
- QVERIFY(fp->flickBoost == 1.0);
+ QCOMPARE(fp->flickBoost, 1.0);
}
void tst_qquickflickable::margins()
@@ -1235,7 +1282,7 @@ void tst_qquickflickable::margins()
QQuickViewTestUtil::moveMouseAway(window.data());
window->setTitle(QTest::currentTestFunction());
window->show();
- QVERIFY(QTest::qWaitForWindowExposed(window.data()));
+ QVERIFY(QTest::qWaitForWindowActive(window.data()));
QQuickItem *root = window->rootObject();
QVERIFY(root);
QQuickFlickable *obj = qobject_cast<QQuickFlickable*>(root);
@@ -1298,13 +1345,13 @@ void tst_qquickflickable::cancelOnMouseGrab()
QQuickViewTestUtil::centerOnScreen(window.data());
QQuickViewTestUtil::moveMouseAway(window.data());
window->show();
- QVERIFY(QTest::qWaitForWindowExposed(window.data()));
+ QVERIFY(QTest::qWaitForWindowActive(window.data()));
QVERIFY(window->rootObject() != 0);
QQuickFlickable *flickable = qobject_cast<QQuickFlickable*>(window->rootObject());
QVERIFY(flickable != 0);
- QTest::mousePress(window.data(), Qt::LeftButton, 0, QPoint(10, 10));
+ moveAndPress(window.data(), QPoint(10, 10));
// drag out of bounds
QTest::mouseMove(window.data(), QPoint(50, 50));
QTest::mouseMove(window.data(), QPoint(100, 100));
@@ -1324,7 +1371,7 @@ void tst_qquickflickable::cancelOnMouseGrab()
QTRY_VERIFY(!flickable->isMoving());
QTRY_VERIFY(!flickable->isDragging());
- QTest::mouseRelease(window.data(), Qt::LeftButton, 0, QPoint(50, 10));
+ moveAndRelease(window.data(), QPoint(50, 10));
}
@@ -1336,41 +1383,41 @@ void tst_qquickflickable::clickAndDragWhenTransformed()
QQuickViewTestUtil::centerOnScreen(view.data());
QQuickViewTestUtil::moveMouseAway(view.data());
view->show();
- QVERIFY(QTest::qWaitForWindowExposed(view.data()));
+ QVERIFY(QTest::qWaitForWindowActive(view.data()));
QVERIFY(view->rootObject() != 0);
QQuickFlickable *flickable = view->rootObject()->findChild<QQuickFlickable*>("flickable");
QVERIFY(flickable != 0);
// click outside child rect
- QTest::mousePress(view.data(), Qt::LeftButton, 0, QPoint(190, 190));
+ moveAndPress(view.data(), QPoint(190, 190));
QTRY_COMPARE(flickable->property("itemPressed").toBool(), false);
QTest::mouseRelease(view.data(), Qt::LeftButton, 0, QPoint(190, 190));
// click inside child rect
- QTest::mousePress(view.data(), Qt::LeftButton, 0, QPoint(200, 200));
+ moveAndPress(view.data(), QPoint(200, 200));
QTRY_COMPARE(flickable->property("itemPressed").toBool(), true);
QTest::mouseRelease(view.data(), Qt::LeftButton, 0, QPoint(200, 200));
const int threshold = qApp->styleHints()->startDragDistance();
// drag outside bounds
- QTest::mousePress(view.data(), Qt::LeftButton, 0, QPoint(160, 160));
+ moveAndPress(view.data(), QPoint(160, 160));
QTest::qWait(10);
QTest::mouseMove(view.data(), QPoint(160 + threshold * 2, 160));
QTest::mouseMove(view.data(), QPoint(160 + threshold * 3, 160));
QCOMPARE(flickable->isDragging(), false);
QCOMPARE(flickable->property("itemPressed").toBool(), false);
- QTest::mouseRelease(view.data(), Qt::LeftButton, 0, QPoint(180, 160));
+ moveAndRelease(view.data(), QPoint(180, 160));
// drag inside bounds
- QTest::mousePress(view.data(), Qt::LeftButton, 0, QPoint(200, 140));
+ moveAndPress(view.data(), QPoint(200, 140));
QTest::qWait(10);
QTest::mouseMove(view.data(), QPoint(200 + threshold * 2, 140));
QTest::mouseMove(view.data(), QPoint(200 + threshold * 3, 140));
QCOMPARE(flickable->isDragging(), true);
QCOMPARE(flickable->property("itemPressed").toBool(), false);
- QTest::mouseRelease(view.data(), Qt::LeftButton, 0, QPoint(220, 140));
+ moveAndRelease(view.data(), QPoint(220, 140));
}
void tst_qquickflickable::flickTwiceUsingTouches()
@@ -1459,7 +1506,7 @@ void tst_qquickflickable::nestedStopAtBounds()
QQuickViewTestUtil::moveMouseAway(&view);
view.show();
view.requestActivate();
- QVERIFY(QTest::qWaitForWindowExposed(&view));
+ QVERIFY(QTest::qWaitForWindowActive(&view));
QVERIFY(view.rootObject());
QQuickFlickable *outer = qobject_cast<QQuickFlickable*>(view.rootObject());
@@ -1489,7 +1536,7 @@ void tst_qquickflickable::nestedStopAtBounds()
int &axis = transpose ? position.ry() : position.rx();
// drag toward the aligned boundary. Outer flickable dragged.
- QTest::mousePress(&view, Qt::LeftButton, 0, position);
+ moveAndPress(&view, position);
QTest::qWait(10);
axis += invert ? threshold * 2 : -threshold * 2;
QTest::mouseMove(&view, position);
@@ -1507,7 +1554,7 @@ void tst_qquickflickable::nestedStopAtBounds()
outer->setContentY(50);
// drag away from the aligned boundary. Inner flickable dragged.
- QTest::mousePress(&view, Qt::LeftButton, 0, position);
+ moveAndPress(&view, position);
QTest::qWait(10);
axis += invert ? -threshold * 2 : threshold * 2;
QTest::mouseMove(&view, position);
@@ -1526,7 +1573,7 @@ void tst_qquickflickable::nestedStopAtBounds()
inner->setContentHeight(inner->height() - margin);
// Drag inner with equal size and contentSize
- QTest::mousePress(&view, Qt::LeftButton, 0, position);
+ moveAndPress(&view, position);
QTest::qWait(10);
axis += invert ? -threshold * 2 : threshold * 2;
QTest::mouseMove(&view, position);
@@ -1543,7 +1590,7 @@ void tst_qquickflickable::nestedStopAtBounds()
inner->setContentHeight(inner->height() - 100);
// Drag inner with size greater than contentSize
- QTest::mousePress(&view, Qt::LeftButton, 0, position);
+ moveAndPress(&view, position);
QTest::qWait(10);
axis += invert ? -threshold * 2 : threshold * 2;
QTest::mouseMove(&view, position);
@@ -1583,7 +1630,7 @@ void tst_qquickflickable::stopAtBounds()
QQuickViewTestUtil::moveMouseAway(&view);
view.show();
view.requestActivate();
- QVERIFY(QTest::qWaitForWindowExposed(&view));
+ QVERIFY(QTest::qWaitForWindowActive(&view));
QVERIFY(view.rootObject());
QQuickFlickable *flickable = qobject_cast<QQuickFlickable*>(view.rootObject());
@@ -1601,7 +1648,7 @@ void tst_qquickflickable::stopAtBounds()
int &axis = transpose ? position.ry() : position.rx();
// drag away from the aligned boundary. View should not move
- QTest::mousePress(&view, Qt::LeftButton, 0, position);
+ moveAndPress(&view, position);
QTest::qWait(10);
for (int i = 0; i < 3; ++i) {
axis += invert ? -threshold : threshold;
@@ -1649,12 +1696,14 @@ void tst_qquickflickable::stopAtBounds()
} else {
flickable->setContentX(invert ? 100 : 0);
}
+
+ QSignalSpy flickSignal(flickable, SIGNAL(flickingChanged()));
if (invert)
flick(&view, QPoint(20,20), QPoint(120,120), 100);
else
flick(&view, QPoint(120,120), QPoint(20,20), 100);
- QVERIFY(flickable->isFlicking());
+ QVERIFY(flickSignal.count() > 0);
if (transpose) {
if (invert)
QTRY_COMPARE(flickable->isAtYBeginning(), true);
@@ -1707,14 +1756,67 @@ void tst_qquickflickable::pressDelayWithLoader()
QQuickViewTestUtil::centerOnScreen(window.data());
QQuickViewTestUtil::moveMouseAway(window.data());
window->show();
- QVERIFY(QTest::qWaitForWindowExposed(window.data()));
+ QVERIFY(QTest::qWaitForWindowActive(window.data()));
QVERIFY(window->rootObject() != 0);
// do not crash
- QTest::mousePress(window.data(), Qt::LeftButton, 0, QPoint(150, 150));
+ moveAndPress(window.data(), QPoint(150, 150));
QTest::mouseRelease(window.data(), Qt::LeftButton, 0, QPoint(150, 150));
}
+// QTBUG-34507
+void tst_qquickflickable::movementFromProgrammaticFlick()
+{
+ QScopedPointer<QQuickView> window(new QQuickView);
+ window->setSource(testFileUrl("movementSignals.qml"));
+ QTRY_COMPARE(window->status(), QQuickView::Ready);
+ QQuickViewTestUtil::centerOnScreen(window.data());
+ QQuickViewTestUtil::moveMouseAway(window.data());
+ window->show();
+ QVERIFY(QTest::qWaitForWindowActive(window.data()));
+
+ QQuickFlickable *flickable = qobject_cast<QQuickFlickable*>(window->rootObject());
+ QVERIFY(flickable != 0);
+
+ // verify that the signals for movement and flicking are called in the right order
+ flickable->flick(0, -1000);
+ QTRY_COMPARE(flickable->property("signalString").toString(), QString("msfsfeme"));
+}
+
+// QTBUG_35038
+void tst_qquickflickable::contentSize()
+{
+ QQuickFlickable flickable;
+ QCOMPARE(flickable.contentWidth(), qreal(-1));
+ QCOMPARE(flickable.contentHeight(), qreal(-1));
+
+ QSignalSpy cwspy(&flickable, SIGNAL(contentWidthChanged()));
+ QVERIFY(cwspy.isValid());
+
+ QSignalSpy chspy(&flickable, SIGNAL(contentHeightChanged()));
+ QVERIFY(chspy.isValid());
+
+ flickable.setWidth(100);
+ QCOMPARE(flickable.width(), qreal(100));
+ QCOMPARE(flickable.contentWidth(), qreal(-1.0));
+ QCOMPARE(cwspy.count(), 0);
+
+ flickable.setContentWidth(10);
+ QCOMPARE(flickable.width(), qreal(100));
+ QCOMPARE(flickable.contentWidth(), qreal(10));
+ QCOMPARE(cwspy.count(), 1);
+
+ flickable.setHeight(100);
+ QCOMPARE(flickable.height(), qreal(100));
+ QCOMPARE(flickable.contentHeight(), qreal(-1.0));
+ QCOMPARE(chspy.count(), 0);
+
+ flickable.setContentHeight(10);
+ QCOMPARE(flickable.height(), qreal(100));
+ QCOMPARE(flickable.contentHeight(), qreal(10));
+ QCOMPARE(chspy.count(), 1);
+}
+
QTEST_MAIN(tst_qquickflickable)
#include "tst_qquickflickable.moc"
diff --git a/tests/auto/quick/qquickflipable/tst_qquickflipable.cpp b/tests/auto/quick/qquickflipable/tst_qquickflipable.cpp
index 76bf509cf0..2eb8942eee 100644
--- a/tests/auto/quick/qquickflipable/tst_qquickflipable.cpp
+++ b/tests/auto/quick/qquickflipable/tst_qquickflipable.cpp
@@ -108,11 +108,11 @@ void tst_qquickflipable::flipFlipable()
QQmlComponent c(&engine, testFileUrl("flip-flipable.qml"));
QQuickFlipable *obj = qobject_cast<QQuickFlipable*>(c.create());
QVERIFY(obj != 0);
- QVERIFY(obj->side() == QQuickFlipable::Front);
+ QCOMPARE(obj->side(), QQuickFlipable::Front);
obj->setProperty("flipped", QVariant(true));
- QTRY_VERIFY(obj->side() == QQuickFlipable::Back);
- QTRY_VERIFY(obj->side() == QQuickFlipable::Front);
- QTRY_VERIFY(obj->side() == QQuickFlipable::Back);
+ QTRY_COMPARE(obj->side(), QQuickFlipable::Back);
+ QTRY_COMPARE(obj->side(), QQuickFlipable::Front);
+ QTRY_COMPARE(obj->side(), QQuickFlipable::Back);
delete obj;
}
diff --git a/tests/auto/quick/qquickfocusscope/tst_qquickfocusscope.cpp b/tests/auto/quick/qquickfocusscope/tst_qquickfocusscope.cpp
index 98f85af92e..4b377f92d6 100644
--- a/tests/auto/quick/qquickfocusscope/tst_qquickfocusscope.cpp
+++ b/tests/auto/quick/qquickfocusscope/tst_qquickfocusscope.cpp
@@ -81,27 +81,27 @@ void tst_qquickfocusscope::basic()
view->requestActivate();
QTest::qWaitForWindowActive(view);
- QTRY_VERIFY(view == qGuiApp->focusWindow());
+ QTRY_COMPARE(view, qGuiApp->focusWindow());
QVERIFY(view->isTopLevel());
- QVERIFY(item0->hasActiveFocus() == true);
- QVERIFY(item1->hasActiveFocus() == true);
- QVERIFY(item2->hasActiveFocus() == false);
- QVERIFY(item3->hasActiveFocus() == false);
+ QVERIFY(item0->hasActiveFocus());
+ QVERIFY(item1->hasActiveFocus());
+ QVERIFY(!item2->hasActiveFocus());
+ QVERIFY(!item3->hasActiveFocus());
QTest::keyClick(view, Qt::Key_Right);
QTest::qWait(50);
- QVERIFY(item0->hasActiveFocus() == true);
- QVERIFY(item1->hasActiveFocus() == false);
- QVERIFY(item2->hasActiveFocus() == true);
- QVERIFY(item3->hasActiveFocus() == false);
+ QVERIFY(item0->hasActiveFocus());
+ QVERIFY(!item1->hasActiveFocus());
+ QVERIFY(item2->hasActiveFocus());
+ QVERIFY(!item3->hasActiveFocus());
QTest::keyClick(view, Qt::Key_Down);
QTest::qWait(50);
- QVERIFY(item0->hasActiveFocus() == false);
- QVERIFY(item1->hasActiveFocus() == false);
- QVERIFY(item2->hasActiveFocus() == false);
- QVERIFY(item3->hasActiveFocus() == true);
+ QVERIFY(!item0->hasActiveFocus());
+ QVERIFY(!item1->hasActiveFocus());
+ QVERIFY(!item2->hasActiveFocus());
+ QVERIFY(item3->hasActiveFocus());
delete view;
}
@@ -126,13 +126,13 @@ void tst_qquickfocusscope::nested()
view->requestActivate();
QTest::qWaitForWindowActive(view);
- QTRY_VERIFY(view == qGuiApp->focusWindow());
+ QTRY_COMPARE(view, qGuiApp->focusWindow());
- QVERIFY(item1->hasActiveFocus() == true);
- QVERIFY(item2->hasActiveFocus() == true);
- QVERIFY(item3->hasActiveFocus() == true);
- QVERIFY(item4->hasActiveFocus() == true);
- QVERIFY(item5->hasActiveFocus() == true);
+ QVERIFY(item1->hasActiveFocus());
+ QVERIFY(item2->hasActiveFocus());
+ QVERIFY(item3->hasActiveFocus());
+ QVERIFY(item4->hasActiveFocus());
+ QVERIFY(item5->hasActiveFocus());
delete view;
}
@@ -153,24 +153,24 @@ void tst_qquickfocusscope::noFocus()
view->show();
view->requestActivate();
QVERIFY(QTest::qWaitForWindowActive(view));
- QVERIFY(view == qGuiApp->focusWindow());
+ QCOMPARE(view, qGuiApp->focusWindow());
- QVERIFY(item0->hasActiveFocus() == false);
- QVERIFY(item1->hasActiveFocus() == false);
- QVERIFY(item2->hasActiveFocus() == false);
- QVERIFY(item3->hasActiveFocus() == false);
+ QVERIFY(!item0->hasActiveFocus());
+ QVERIFY(!item1->hasActiveFocus());
+ QVERIFY(!item2->hasActiveFocus());
+ QVERIFY(!item3->hasActiveFocus());
QTest::keyClick(view, Qt::Key_Right);
- QVERIFY(item0->hasActiveFocus() == false);
- QVERIFY(item1->hasActiveFocus() == false);
- QVERIFY(item2->hasActiveFocus() == false);
- QVERIFY(item3->hasActiveFocus() == false);
+ QVERIFY(!item0->hasActiveFocus());
+ QVERIFY(!item1->hasActiveFocus());
+ QVERIFY(!item2->hasActiveFocus());
+ QVERIFY(!item3->hasActiveFocus());
QTest::keyClick(view, Qt::Key_Down);
- QVERIFY(item0->hasActiveFocus() == false);
- QVERIFY(item1->hasActiveFocus() == false);
- QVERIFY(item2->hasActiveFocus() == false);
- QVERIFY(item3->hasActiveFocus() == false);
+ QVERIFY(!item0->hasActiveFocus());
+ QVERIFY(!item1->hasActiveFocus());
+ QVERIFY(!item2->hasActiveFocus());
+ QVERIFY(!item3->hasActiveFocus());
delete view;
}
@@ -194,33 +194,33 @@ void tst_qquickfocusscope::textEdit()
QTest::qWaitForWindowActive(view);
- QTRY_VERIFY(view == qGuiApp->focusWindow());
- QVERIFY(item0->hasActiveFocus() == true);
- QVERIFY(item1->hasActiveFocus() == true);
- QVERIFY(item2->hasActiveFocus() == false);
- QVERIFY(item3->hasActiveFocus() == false);
+ QTRY_COMPARE(view, qGuiApp->focusWindow());
+ QVERIFY(item0->hasActiveFocus());
+ QVERIFY(item1->hasActiveFocus());
+ QVERIFY(!item2->hasActiveFocus());
+ QVERIFY(!item3->hasActiveFocus());
QTest::keyClick(view, Qt::Key_Right);
- QVERIFY(item0->hasActiveFocus() == true);
- QVERIFY(item1->hasActiveFocus() == true);
- QVERIFY(item2->hasActiveFocus() == false);
- QVERIFY(item3->hasActiveFocus() == false);
+ QVERIFY(item0->hasActiveFocus());
+ QVERIFY(item1->hasActiveFocus());
+ QVERIFY(!item2->hasActiveFocus());
+ QVERIFY(!item3->hasActiveFocus());
QTest::keyClick(view, Qt::Key_Right);
QTest::keyClick(view, Qt::Key_Right);
QTest::keyClick(view, Qt::Key_Right);
QTest::keyClick(view, Qt::Key_Right);
QTest::keyClick(view, Qt::Key_Right);
- QVERIFY(item0->hasActiveFocus() == true);
- QVERIFY(item1->hasActiveFocus() == false);
- QVERIFY(item2->hasActiveFocus() == true);
- QVERIFY(item3->hasActiveFocus() == false);
+ QVERIFY(item0->hasActiveFocus());
+ QVERIFY(!item1->hasActiveFocus());
+ QVERIFY(item2->hasActiveFocus());
+ QVERIFY(!item3->hasActiveFocus());
QTest::keyClick(view, Qt::Key_Down);
- QVERIFY(item0->hasActiveFocus() == false);
- QVERIFY(item1->hasActiveFocus() == false);
- QVERIFY(item2->hasActiveFocus() == false);
- QVERIFY(item3->hasActiveFocus() == true);
+ QVERIFY(!item0->hasActiveFocus());
+ QVERIFY(!item1->hasActiveFocus());
+ QVERIFY(!item2->hasActiveFocus());
+ QVERIFY(item3->hasActiveFocus());
delete view;
}
@@ -246,30 +246,30 @@ void tst_qquickfocusscope::forceFocus()
view->show();
view->requestActivate();
QTest::qWaitForWindowActive(view);
- QTRY_VERIFY(view == qGuiApp->focusWindow());
+ QTRY_COMPARE(view, qGuiApp->focusWindow());
- QVERIFY(item0->hasActiveFocus() == true);
- QVERIFY(item1->hasActiveFocus() == true);
- QVERIFY(item2->hasActiveFocus() == false);
- QVERIFY(item3->hasActiveFocus() == false);
- QVERIFY(item4->hasActiveFocus() == false);
- QVERIFY(item5->hasActiveFocus() == false);
+ QVERIFY(item0->hasActiveFocus());
+ QVERIFY(item1->hasActiveFocus());
+ QVERIFY(!item2->hasActiveFocus());
+ QVERIFY(!item3->hasActiveFocus());
+ QVERIFY(!item4->hasActiveFocus());
+ QVERIFY(!item5->hasActiveFocus());
QTest::keyClick(view, Qt::Key_4);
- QVERIFY(item0->hasActiveFocus() == true);
- QVERIFY(item1->hasActiveFocus() == true);
- QVERIFY(item2->hasActiveFocus() == false);
- QVERIFY(item3->hasActiveFocus() == false);
- QVERIFY(item4->hasActiveFocus() == false);
- QVERIFY(item5->hasActiveFocus() == false);
+ QVERIFY(item0->hasActiveFocus());
+ QVERIFY(item1->hasActiveFocus());
+ QVERIFY(!item2->hasActiveFocus());
+ QVERIFY(!item3->hasActiveFocus());
+ QVERIFY(!item4->hasActiveFocus());
+ QVERIFY(!item5->hasActiveFocus());
QTest::keyClick(view, Qt::Key_5);
- QVERIFY(item0->hasActiveFocus() == false);
- QVERIFY(item1->hasActiveFocus() == false);
- QVERIFY(item2->hasActiveFocus() == false);
- QVERIFY(item3->hasActiveFocus() == true);
- QVERIFY(item4->hasActiveFocus() == false);
- QVERIFY(item5->hasActiveFocus() == true);
+ QVERIFY(!item0->hasActiveFocus());
+ QVERIFY(!item1->hasActiveFocus());
+ QVERIFY(!item2->hasActiveFocus());
+ QVERIFY(item3->hasActiveFocus());
+ QVERIFY(!item4->hasActiveFocus());
+ QVERIFY(item5->hasActiveFocus());
delete view;
}
@@ -283,13 +283,13 @@ void tst_qquickfocusscope::noParentFocus()
view->show();
view->requestActivate();
QTest::qWaitForWindowActive(view);
- QTRY_VERIFY(view == qGuiApp->focusWindow());
+ QTRY_COMPARE(view, qGuiApp->focusWindow());
- QVERIFY(view->rootObject()->property("focus1") == false);
- QVERIFY(view->rootObject()->property("focus2") == false);
- QVERIFY(view->rootObject()->property("focus3") == true);
- QVERIFY(view->rootObject()->property("focus4") == true);
- QVERIFY(view->rootObject()->property("focus5") == true);
+ QVERIFY(!view->rootObject()->property("focus1").toBool());
+ QVERIFY(!view->rootObject()->property("focus2").toBool());
+ QVERIFY(view->rootObject()->property("focus3").toBool());
+ QVERIFY(view->rootObject()->property("focus4").toBool());
+ QVERIFY(view->rootObject()->property("focus5").toBool());
delete view;
}
@@ -312,7 +312,7 @@ void tst_qquickfocusscope::signalEmission()
view->requestActivate();
QTest::qWaitForWindowActive(view);
- QTRY_VERIFY(view == qGuiApp->focusWindow());
+ QTRY_COMPARE(view, qGuiApp->focusWindow());
QVariant blue(QColor("blue"));
QVariant red(QColor("red"));
@@ -362,7 +362,7 @@ void tst_qquickfocusscope::qtBug13380()
QVERIFY(QTest::qWaitForWindowExposed(view));
- QTRY_VERIFY(view == qGuiApp->focusWindow());
+ QTRY_COMPARE(view, qGuiApp->focusWindow());
QVERIFY(view->rootObject()->property("noFocus").toBool());
view->rootObject()->setProperty("showRect", true);
@@ -379,7 +379,7 @@ void tst_qquickfocusscope::forceActiveFocus()
view->show();
view->requestActivate();
QVERIFY(QTest::qWaitForWindowExposed(view));
- QTRY_VERIFY(view == qGuiApp->focusWindow());
+ QTRY_COMPARE(view, qGuiApp->focusWindow());
QQuickItem *rootObject = view->rootObject();
QVERIFY(rootObject);
@@ -532,7 +532,7 @@ void tst_qquickfocusscope::canvasFocus()
view->requestActivate();
QVERIFY(QTest::qWaitForWindowActive(view));
- QVERIFY(view == qGuiApp->focusWindow());
+ QCOMPARE(view, qGuiApp->focusWindow());
// Now the window has focus, active focus given to item1
QCOMPARE(rootItem->hasFocus(), true);
@@ -558,7 +558,7 @@ void tst_qquickfocusscope::canvasFocus()
alternateView.show();
alternateView.requestActivate();
QVERIFY(QTest::qWaitForWindowActive(&alternateView));
- QVERIFY(QGuiApplication::focusWindow() == &alternateView);
+ QCOMPARE(QGuiApplication::focusWindow(), &alternateView);
QCOMPARE(rootItem->hasFocus(), false);
QCOMPARE(rootItem->hasActiveFocus(), false);
@@ -604,7 +604,7 @@ void tst_qquickfocusscope::canvasFocus()
view->show();
view->requestActivate();
QVERIFY(QTest::qWaitForWindowActive(view));
- QVERIFY(QGuiApplication::focusWindow() == view);
+ QCOMPARE(QGuiApplication::focusWindow(), view);
QCOMPARE(rootItem->hasFocus(), true);
QCOMPARE(rootItem->hasActiveFocus(), true);
diff --git a/tests/auto/quick/qquickfontloader/tst_qquickfontloader.cpp b/tests/auto/quick/qquickfontloader/tst_qquickfontloader.cpp
index a084c86a95..b16e89dc39 100644
--- a/tests/auto/quick/qquickfontloader/tst_qquickfontloader.cpp
+++ b/tests/auto/quick/qquickfontloader/tst_qquickfontloader.cpp
@@ -85,7 +85,7 @@ void tst_qquickfontloader::noFont()
QVERIFY(fontObject != 0);
QCOMPARE(fontObject->name(), QString(""));
QCOMPARE(fontObject->source(), QUrl(""));
- QTRY_VERIFY(fontObject->status() == QQuickFontLoader::Null);
+ QTRY_COMPARE(fontObject->status(), QQuickFontLoader::Null);
delete fontObject;
}
@@ -100,7 +100,7 @@ void tst_qquickfontloader::namedFont()
QVERIFY(fontObject != 0);
QCOMPARE(fontObject->source(), QUrl(""));
QCOMPARE(fontObject->name(), QString("Helvetica"));
- QTRY_VERIFY(fontObject->status() == QQuickFontLoader::Ready);
+ QTRY_COMPARE(fontObject->status(), QQuickFontLoader::Ready);
}
void tst_qquickfontloader::localFont()
@@ -113,13 +113,13 @@ void tst_qquickfontloader::localFont()
QVERIFY(fontObject != 0);
QVERIFY(fontObject->source() != QUrl(""));
QTRY_COMPARE(fontObject->name(), QString("OCRA"));
- QTRY_VERIFY(fontObject->status() == QQuickFontLoader::Ready);
+ QTRY_COMPARE(fontObject->status(), QQuickFontLoader::Ready);
}
void tst_qquickfontloader::failLocalFont()
{
QString componentStr = "import QtQuick 2.0\nFontLoader { source: \"" + testFileUrl("dummy.ttf").toString() + "\" }";
- QTest::ignoreMessage(QtWarningMsg, QString("<Unknown File>:2:1: QML FontLoader: Cannot load font: \"" + testFileUrl("dummy.ttf").toString() + "\"").toUtf8().constData());
+ QTest::ignoreMessage(QtWarningMsg, QString("<Unknown File>:2:1: QML FontLoader: Cannot load font: \"" + testFileUrl("dummy.ttf").toString() + QLatin1Char('"')).toUtf8().constData());
QQmlComponent component(&engine);
component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
QQuickFontLoader *fontObject = qobject_cast<QQuickFontLoader*>(component.create());
@@ -127,7 +127,7 @@ void tst_qquickfontloader::failLocalFont()
QVERIFY(fontObject != 0);
QVERIFY(fontObject->source() != QUrl(""));
QTRY_COMPARE(fontObject->name(), QString(""));
- QTRY_VERIFY(fontObject->status() == QQuickFontLoader::Error);
+ QTRY_COMPARE(fontObject->status(), QQuickFontLoader::Error);
}
void tst_qquickfontloader::webFont()
@@ -141,7 +141,7 @@ void tst_qquickfontloader::webFont()
QVERIFY(fontObject != 0);
QVERIFY(fontObject->source() != QUrl(""));
QTRY_COMPARE(fontObject->name(), QString("OCRA"));
- QTRY_VERIFY(fontObject->status() == QQuickFontLoader::Ready);
+ QTRY_COMPARE(fontObject->status(), QQuickFontLoader::Ready);
}
void tst_qquickfontloader::redirWebFont()
@@ -157,7 +157,7 @@ void tst_qquickfontloader::redirWebFont()
QVERIFY(fontObject != 0);
QVERIFY(fontObject->source() != QUrl(""));
QTRY_COMPARE(fontObject->name(), QString("OCRA"));
- QTRY_VERIFY(fontObject->status() == QQuickFontLoader::Ready);
+ QTRY_COMPARE(fontObject->status(), QQuickFontLoader::Ready);
}
void tst_qquickfontloader::failWebFont()
@@ -172,7 +172,7 @@ void tst_qquickfontloader::failWebFont()
QVERIFY(fontObject != 0);
QVERIFY(fontObject->source() != QUrl(""));
QTRY_COMPARE(fontObject->name(), QString(""));
- QTRY_VERIFY(fontObject->status() == QQuickFontLoader::Error);
+ QTRY_COMPARE(fontObject->status(), QQuickFontLoader::Error);
}
void tst_qquickfontloader::changeFont()
@@ -189,26 +189,26 @@ void tst_qquickfontloader::changeFont()
QSignalSpy nameSpy(fontObject, SIGNAL(nameChanged()));
QSignalSpy statusSpy(fontObject, SIGNAL(statusChanged()));
- QTRY_VERIFY(fontObject->status() == QQuickFontLoader::Ready);
+ QTRY_COMPARE(fontObject->status(), QQuickFontLoader::Ready);
QCOMPARE(nameSpy.count(), 0);
QCOMPARE(statusSpy.count(), 0);
QTRY_COMPARE(fontObject->name(), QString("OCRA"));
ctxt->setContextProperty("font", server.urlString("/daniel.ttf"));
- QTRY_VERIFY(fontObject->status() == QQuickFontLoader::Loading);
- QTRY_VERIFY(fontObject->status() == QQuickFontLoader::Ready);
+ QTRY_COMPARE(fontObject->status(), QQuickFontLoader::Loading);
+ QTRY_COMPARE(fontObject->status(), QQuickFontLoader::Ready);
QCOMPARE(nameSpy.count(), 1);
QCOMPARE(statusSpy.count(), 2);
QTRY_COMPARE(fontObject->name(), QString("Daniel"));
ctxt->setContextProperty("font", testFileUrl("tarzeau_ocr_a.ttf"));
- QTRY_VERIFY(fontObject->status() == QQuickFontLoader::Ready);
+ QTRY_COMPARE(fontObject->status(), QQuickFontLoader::Ready);
QCOMPARE(nameSpy.count(), 2);
QCOMPARE(statusSpy.count(), 2);
QTRY_COMPARE(fontObject->name(), QString("OCRA"));
ctxt->setContextProperty("font", server.urlString("/daniel.ttf"));
- QTRY_VERIFY(fontObject->status() == QQuickFontLoader::Ready);
+ QTRY_COMPARE(fontObject->status(), QQuickFontLoader::Ready);
QCOMPARE(nameSpy.count(), 3);
QCOMPARE(statusSpy.count(), 2);
QTRY_COMPARE(fontObject->name(), QString("Daniel"));
@@ -224,7 +224,7 @@ void tst_qquickfontloader::changeFontSourceViaState()
QQuickFontLoader *fontObject = qobject_cast<QQuickFontLoader*>(qvariant_cast<QObject *>(window.rootObject()->property("fontloader")));
QVERIFY(fontObject != 0);
- QTRY_VERIFY(fontObject->status() == QQuickFontLoader::Ready);
+ QTRY_COMPARE(fontObject->status(), QQuickFontLoader::Ready);
QVERIFY(fontObject->source() != QUrl(""));
QTRY_COMPARE(fontObject->name(), QString("OCRA"));
@@ -236,7 +236,7 @@ void tst_qquickfontloader::changeFontSourceViaState()
QTest::ignoreMessage(QtWarningMsg, qPrintable(warning));
QEXPECT_FAIL("", "QTBUG-20268", Abort);
- QTRY_VERIFY(fontObject->status() == QQuickFontLoader::Ready);
+ QTRY_COMPARE(fontObject->status(), QQuickFontLoader::Ready);
QCOMPARE(window.rootObject()->property("name").toString(), QString("Tahoma"));
}
diff --git a/tests/auto/quick/qquickfontloader_static/data/font.ttf b/tests/auto/quick/qquickfontloader_static/data/font.ttf
new file mode 100644
index 0000000000..aae50d5035
--- /dev/null
+++ b/tests/auto/quick/qquickfontloader_static/data/font.ttf
Binary files differ
diff --git a/tests/auto/quick/qquickfontloader_static/qquickfontloader_static.pro b/tests/auto/quick/qquickfontloader_static/qquickfontloader_static.pro
new file mode 100644
index 0000000000..f6835c05c0
--- /dev/null
+++ b/tests/auto/quick/qquickfontloader_static/qquickfontloader_static.pro
@@ -0,0 +1,12 @@
+CONFIG += testcase
+TARGET = tst_qquickfontloader_static
+macx:CONFIG -= app_bundle
+
+SOURCES += tst_qquickfontloader_static.cpp
+
+include (../../shared/util.pri)
+
+TESTDATA = data/*
+
+QT += core-private gui-private qml-private quick-private network testlib
+DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0
diff --git a/tests/auto/quick/qquickfontloader_static/tst_qquickfontloader_static.cpp b/tests/auto/quick/qquickfontloader_static/tst_qquickfontloader_static.cpp
new file mode 100644
index 0000000000..f7f00172ba
--- /dev/null
+++ b/tests/auto/quick/qquickfontloader_static/tst_qquickfontloader_static.cpp
@@ -0,0 +1,69 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL21$
+** 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 The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/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 or version 3 as published by the Free
+** Software Foundation and appearing in the file LICENSE.LGPLv21 and
+** LICENSE.LGPLv3 included in the packaging of this file. Please review the
+** following information to ensure the GNU Lesser General Public License
+** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtGui/QGuiApplication>
+#include <QtQuick/QQuickView>
+#include <QtQml/QQmlComponent>
+#include "../../shared/util.h"
+#include <qtest.h>
+
+QByteArray qmltemplate("import QtQuick 2.0\n"
+"\n"
+"Rectangle {\n"
+" width: 400\n"
+" height: 400\n"
+" color: \"red\"\n"
+" FontLoader { id: fixedFont; source: \"%1\" }\n"
+" Text {\n"
+" text: \"hello world\"\n"
+" anchors.centerIn: parent\n"
+" font.family: fixedFont.name\n"
+" }\n"
+"}\n");
+
+int main(int argc, char **argv)
+{
+ for (int i = 0; i < 3; i++) {
+ QGuiApplication app(argc, argv);
+ QQmlDataTest dataTest;
+ dataTest.initTestCase();
+ QQuickView window;
+ QQmlComponent component (window.engine());
+ QUrl current = QUrl::fromLocalFile("");
+ qmltemplate.replace("%1", dataTest.testFileUrl("font.ttf").toString().toLocal8Bit());
+ component.setData(qmltemplate, current);
+ window.setContent(current, &component, component.create());
+ window.show();
+ QTest::qWaitForWindowActive(&window);
+ }
+}
diff --git a/tests/auto/quick/qquickgridview/BLACKLIST b/tests/auto/quick/qquickgridview/BLACKLIST
new file mode 100644
index 0000000000..9eb9940aa5
--- /dev/null
+++ b/tests/auto/quick/qquickgridview/BLACKLIST
@@ -0,0 +1,2 @@
+[snapOneRow:horizontal, right to left]
+windows
diff --git a/tests/auto/quick/qquickgridview/data/contentHeightWithDelayRemove.qml b/tests/auto/quick/qquickgridview/data/contentHeightWithDelayRemove.qml
new file mode 100644
index 0000000000..3f8246bafc
--- /dev/null
+++ b/tests/auto/quick/qquickgridview/data/contentHeightWithDelayRemove.qml
@@ -0,0 +1,47 @@
+import QtQuick 2.1
+
+Item {
+ width: 400
+ height: 600
+ function takeOne()
+ {
+ gridView.model.remove(2)
+ }
+ function takeThree()
+ {
+ gridView.model.remove(4)
+ gridView.model.remove(2)
+ gridView.model.remove(0)
+ }
+ function takeAll()
+ {
+ gridView.model.clear()
+ }
+
+ GridView {
+ id: gridView
+
+ property bool useDelayRemove
+
+ height: parent.height
+ width: 400
+ cellWidth: width/2
+ model: ListModel {
+ ListElement { name: "A" }
+ ListElement { name: "B" }
+ ListElement { name: "C" }
+ ListElement { name: "D" }
+ ListElement { name: "E" }
+ }
+ delegate: Text {
+ id: wrapper
+ height: 100
+ text: index + gridView.count
+ GridView.delayRemove: gridView.useDelayRemove
+ GridView.onRemove: SequentialAnimation {
+ PauseAnimation { duration: wrapper.GridView.delayRemove ? 100 : 0 }
+ PropertyAction { target: wrapper; property: "GridView.delayRemove"; value: false }
+ }
+ }
+ }
+}
diff --git a/tests/auto/quick/qquickgridview/data/gridview-initCurrent.qml b/tests/auto/quick/qquickgridview/data/gridview-initCurrent.qml
index af35d2fa1b..0a6184c9de 100644
--- a/tests/auto/quick/qquickgridview/data/gridview-initCurrent.qml
+++ b/tests/auto/quick/qquickgridview/data/gridview-initCurrent.qml
@@ -6,6 +6,7 @@ Rectangle {
property int current: grid.currentIndex
property bool showHeader: false
property bool showFooter: false
+ property int currentItemChangedCount: 0
width: 240
height: 320
@@ -63,5 +64,7 @@ Rectangle {
model: testModel
header: root.showHeader ? headerFooter : null
footer: root.showFooter ? headerFooter : null
+
+ onCurrentItemChanged: { root.currentItemChangedCount++ }
}
}
diff --git a/tests/auto/quick/qquickgridview/data/qtbug45640.qml b/tests/auto/quick/qquickgridview/data/qtbug45640.qml
new file mode 100644
index 0000000000..6973773432
--- /dev/null
+++ b/tests/auto/quick/qquickgridview/data/qtbug45640.qml
@@ -0,0 +1,24 @@
+import QtQuick 2.0
+
+GridView {
+ id: gridView
+ width: 400; height: 400
+ cellHeight: 100
+ cellWidth: 100
+ model: 32
+
+ topMargin: 50
+ snapMode: GridView.SnapToRow
+ preferredHighlightBegin: 50
+ preferredHighlightEnd: 50
+ highlightRangeMode: GridView.ApplyRange
+
+ delegate: Rectangle {
+ width: 100
+ height: 100
+ color: index % 2 == 0 ? "#FFFF00" : "#0000FF"
+ }
+
+ highlight: Rectangle { color: "red"; z: 2 }
+ highlightMoveDuration: 1000
+}
diff --git a/tests/auto/quick/qquickgridview/tst_qquickgridview.cpp b/tests/auto/quick/qquickgridview/tst_qquickgridview.cpp
index 9472407e01..3699bef56d 100644
--- a/tests/auto/quick/qquickgridview/tst_qquickgridview.cpp
+++ b/tests/auto/quick/qquickgridview/tst_qquickgridview.cpp
@@ -206,6 +206,11 @@ private slots:
void jsArrayChange();
+ void contentHeightWithDelayRemove_data();
+ void contentHeightWithDelayRemove();
+
+ void QTBUG_45640();
+
private:
QList<int> toIntList(const QVariantList &list);
void matchIndexLists(const QVariantList &indexLists, const QList<int> &expectedIndexes);
@@ -373,7 +378,7 @@ void tst_QQuickGridView::items()
ctxt->setContextProperty("testModel", &model2);
int itemCount = findItems<QQuickItem>(contentItem, "wrapper").count();
- QTRY_VERIFY(itemCount == 0);
+ QTRY_COMPARE(itemCount, 0);
delete window;
}
@@ -473,8 +478,8 @@ void tst_QQuickGridView::inserted_basic()
// Confirm items positioned correctly
for (int i = 0; i < model.count(); ++i) {
QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
- QTRY_VERIFY(item->x() == (i%3)*80);
- QTRY_VERIFY(item->y() == (i/3)*60);
+ QTRY_COMPARE(item->x(), qreal((i%3)*80));
+ QTRY_COMPARE(item->y(), qreal((i/3)*60));
}
for (int i = model.count(); i < 30; ++i)
@@ -485,7 +490,7 @@ void tst_QQuickGridView::inserted_basic()
// Insert item outside visible area
model.insertItem(1, "Hello", "1324");
- QTRY_VERIFY(gridview->contentY() == 120);
+ QTRY_COMPARE(gridview->contentY(), qreal(120));
delete window;
}
@@ -815,8 +820,8 @@ void tst_QQuickGridView::removed_basic()
for (int i = 0; i < model.count() && i < itemCount; ++i) {
QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
if (!item) qWarning() << "Item" << i << "not found";
- QTRY_VERIFY(item->x() == (i%3)*80);
- QTRY_VERIFY(item->y() == (i/3)*60);
+ QTRY_COMPARE(item->x(), qreal((i%3)*80));
+ QTRY_COMPARE(item->y(), qreal((i/3)*60));
}
// Remove first item (which is the current item);
@@ -836,8 +841,8 @@ void tst_QQuickGridView::removed_basic()
for (int i = 0; i < model.count() && i < itemCount; ++i) {
QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
if (!item) qWarning() << "Item" << i << "not found";
- QTRY_VERIFY(item->x() == (i%3)*80);
- QTRY_VERIFY(item->y() == (i/3)*60);
+ QTRY_COMPARE(item->x(), qreal((i%3)*80));
+ QTRY_COMPARE(item->y(), qreal((i/3)*60));
}
// Remove items not visible
@@ -849,8 +854,8 @@ void tst_QQuickGridView::removed_basic()
for (int i = 0; i < model.count() && i < itemCount; ++i) {
QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
if (!item) qWarning() << "Item" << i << "not found";
- QTRY_VERIFY(item->x() == (i%3)*80);
- QTRY_VERIFY(item->y() == (i/3)*60);
+ QTRY_COMPARE(item->x(), qreal((i%3)*80));
+ QTRY_COMPARE(item->y(), qreal((i/3)*60));
}
// Remove items before visible
@@ -867,8 +872,8 @@ void tst_QQuickGridView::removed_basic()
for (int i = 6; i < 18; ++i) {
QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
if (!item) qWarning() << "Item" << i << "not found";
- QTRY_VERIFY(item->x() == (i%3)*80);
- QTRY_VERIFY(item->y() == (i/3)*60);
+ QTRY_COMPARE(item->x(), qreal((i%3)*80));
+ QTRY_COMPARE(item->y(), qreal((i/3)*60));
}
// Remove currentIndex
@@ -886,8 +891,8 @@ void tst_QQuickGridView::removed_basic()
itemCount = findItems<QQuickItem>(contentItem, "wrapper").count();
for (int i = 0; i < model.count() && i < itemCount; ++i) {
QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
- QTRY_VERIFY(item->x() == (i%3)*80);
- QTRY_VERIFY(item->y() == (i/3)*60);
+ QTRY_COMPARE(item->x(), qreal((i%3)*80));
+ QTRY_COMPARE(item->y(), qreal((i/3)*60));
}
// remove item outside current view.
@@ -895,7 +900,7 @@ void tst_QQuickGridView::removed_basic()
gridview->setContentY(240);
model.removeItem(30);
- QTRY_VERIFY(gridview->currentIndex() == 31);
+ QTRY_COMPARE(gridview->currentIndex(), 31);
// remove current item beyond visible items.
gridview->setCurrentIndex(20);
@@ -912,7 +917,7 @@ void tst_QQuickGridView::removed_basic()
model.removeItem(6);
QTRY_COMPARE(gridview->currentIndex(), 7);
- QTRY_VERIFY(gridview->currentItem() == oldCurrent);
+ QTRY_COMPARE(gridview->currentItem(), oldCurrent);
delete window;
}
@@ -1211,7 +1216,7 @@ void tst_QQuickGridView::addOrRemoveBeforeVisible()
for (int i = 0; i < model.count() && i < itemCount; ++i) {
QTRY_VERIFY(findItem<QQuickItem>(contentItem, "wrapper", i));
QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
- QTRY_VERIFY(item->x() == (i%3)*80);
+ QTRY_COMPARE(item->x(), qreal((i%3)*80));
QTRY_VERIFY(item->y() == (i/3)*60 + newTopContentY);
}
@@ -1249,10 +1254,10 @@ void tst_QQuickGridView::clear()
model.clear();
gridview->forceLayout();
- QVERIFY(gridview->count() == 0);
- QVERIFY(gridview->currentItem() == 0);
- QVERIFY(gridview->contentY() == 0);
- QVERIFY(gridview->currentIndex() == -1);
+ QCOMPARE(gridview->count(), 0);
+ QVERIFY(!gridview->currentItem());
+ QCOMPARE(gridview->contentY(), qreal(0));
+ QCOMPARE(gridview->currentIndex(), -1);
QCOMPARE(gridview->contentHeight(), 0.0);
// confirm sanity when adding an item to cleared list
@@ -1260,7 +1265,7 @@ void tst_QQuickGridView::clear()
gridview->forceLayout();
QTRY_COMPARE(gridview->count(), 1);
QVERIFY(gridview->currentItem() != 0);
- QVERIFY(gridview->currentIndex() == 0);
+ QCOMPARE(gridview->currentIndex(), 0);
delete window;
}
@@ -1799,7 +1804,7 @@ void tst_QQuickGridView::swapWithFirstItem()
// ensure content position is stable
gridview->setContentY(0);
model.moveItem(10, 0);
- QTRY_VERIFY(gridview->contentY() == 0);
+ QTRY_COMPARE(gridview->contentY(), qreal(0));
delete window;
}
@@ -1849,7 +1854,7 @@ void tst_QQuickGridView::currentIndex()
gridview->setCurrentIndex(35);
QTRY_VERIFY(gridview->verticalVelocity() != 0.0);
gridview->setCurrentIndex(0);
- QTRY_VERIFY(gridview->verticalVelocity() == 0.0);
+ QTRY_COMPARE(gridview->verticalVelocity(), 0.0);
// footer should become visible if it is out of view, and then current index moves to the first row
window->rootObject()->setProperty("showFooter", true);
@@ -1871,7 +1876,7 @@ void tst_QQuickGridView::currentIndex()
// turn off auto highlight
gridview->setHighlightFollowsCurrentItem(false);
- QVERIFY(gridview->highlightFollowsCurrentItem() == false);
+ QVERIFY(!gridview->highlightFollowsCurrentItem());
QVERIFY(gridview->highlightItem());
qreal hlPosX = gridview->highlightItem()->x();
qreal hlPosY = gridview->highlightItem()->y();
@@ -1881,9 +1886,12 @@ void tst_QQuickGridView::currentIndex()
QTRY_COMPARE(gridview->highlightItem()->y(), hlPosY);
// insert item before currentIndex
+ window->rootObject()->setProperty("currentItemChangedCount", QVariant(0));
gridview->setCurrentIndex(28);
+ QTRY_COMPARE(window->rootObject()->property("currentItemChangedCount").toInt(), 1);
model.insertItem(0, "Foo", "1111");
QTRY_COMPARE(window->rootObject()->property("current").toInt(), 29);
+ QCOMPARE(window->rootObject()->property("currentItemChangedCount").toInt(), 1);
// check removing highlight by setting currentIndex to -1;
gridview->setCurrentIndex(-1);
@@ -1971,7 +1979,7 @@ void tst_QQuickGridView::keyNavigation()
window->requestActivate();
QTest::qWaitForWindowActive(window);
- QTRY_VERIFY(qGuiApp->focusWindow() == window);
+ QTRY_COMPARE(qGuiApp->focusWindow(), window);
QCOMPARE(gridview->currentIndex(), 0);
QTest::keyClick(window, forwardsKey);
@@ -2256,15 +2264,15 @@ void tst_QQuickGridView::defaultValues()
QQuickGridView *obj = qobject_cast<QQuickGridView*>(c.create());
QTRY_VERIFY(obj != 0);
- QTRY_VERIFY(obj->model() == QVariant());
- QTRY_VERIFY(obj->delegate() == 0);
+ QTRY_COMPARE(obj->model(), QVariant());
+ QTRY_VERIFY(!obj->delegate());
QTRY_COMPARE(obj->currentIndex(), -1);
- QTRY_VERIFY(obj->currentItem() == 0);
+ QTRY_VERIFY(!obj->currentItem());
QTRY_COMPARE(obj->count(), 0);
- QTRY_VERIFY(obj->highlight() == 0);
- QTRY_VERIFY(obj->highlightItem() == 0);
+ QTRY_VERIFY(!obj->highlight());
+ QTRY_VERIFY(!obj->highlightItem());
QTRY_COMPARE(obj->highlightFollowsCurrentItem(), true);
- QTRY_VERIFY(obj->flow() == 0);
+ QTRY_COMPARE(obj->flow(), QQuickGridView::FlowLeftToRight);
QTRY_COMPARE(obj->isWrapEnabled(), false);
#ifdef QML_VIEW_DEFAULTCACHEBUFFER
QTRY_COMPARE(obj->cacheBuffer(), QML_VIEW_DEFAULTCACHEBUFFER);
@@ -2291,7 +2299,7 @@ void tst_QQuickGridView::properties()
QTRY_VERIFY(obj->highlight() != 0);
QTRY_VERIFY(obj->highlightItem() != 0);
QTRY_COMPARE(obj->highlightFollowsCurrentItem(), false);
- QTRY_VERIFY(obj->flow() == 0);
+ QTRY_COMPARE(obj->flow(), QQuickGridView::FlowLeftToRight);
QTRY_COMPARE(obj->isWrapEnabled(), true);
QTRY_COMPARE(obj->cacheBuffer(), 200);
QTRY_COMPARE(obj->cellWidth(), qreal(100));
@@ -2728,7 +2736,7 @@ void tst_QQuickGridView::mirroring()
foreach (const QString objectName, objectNames)
QCOMPARE(findItem<QQuickItem>(gridviewA, objectName)->x(), findItem<QQuickItem>(gridviewB, objectName)->x());
- QVERIFY(gridviewB->layoutDirection() == gridviewB->effectiveLayoutDirection());
+ QCOMPARE(gridviewB->layoutDirection(), gridviewB->effectiveLayoutDirection());
QQuickItemPrivate::get(gridviewB)->setLayoutMirror(true);
QVERIFY(gridviewB->layoutDirection() != gridviewB->effectiveLayoutDirection());
@@ -3016,7 +3024,7 @@ void tst_QQuickGridView::footer()
QQuickText *footer = findItem<QQuickText>(contentItem, "footer");
QVERIFY(footer);
- QVERIFY(footer == gridview->footerItem());
+ QCOMPARE(footer, gridview->footerItem());
QCOMPARE(footer->position(), initialFooterPos);
QCOMPARE(footer->width(), 100.);
@@ -3082,7 +3090,7 @@ void tst_QQuickGridView::footer()
QVERIFY(!footer);
footer = findItem<QQuickText>(contentItem, "footer2");
QVERIFY(footer);
- QVERIFY(footer == gridview->footerItem());
+ QCOMPARE(footer, gridview->footerItem());
QCOMPARE(footer->position(), changedFooterPos);
QCOMPARE(footer->width(), 50.);
@@ -3265,7 +3273,7 @@ void tst_QQuickGridView::header()
QQuickText *header = findItem<QQuickText>(contentItem, "header");
QVERIFY(header);
- QVERIFY(header == gridview->headerItem());
+ QCOMPARE(header, gridview->headerItem());
QCOMPARE(header->position(), initialHeaderPos);
QCOMPARE(header->width(), 100.);
@@ -3302,7 +3310,7 @@ void tst_QQuickGridView::header()
header = findItem<QQuickText>(contentItem, "header2");
QVERIFY(header);
- QVERIFY(header == gridview->headerItem());
+ QCOMPARE(header, gridview->headerItem());
QCOMPARE(header->position(), changedHeaderPos);
QCOMPARE(header->width(), 50.);
@@ -3609,11 +3617,11 @@ void tst_QQuickGridView::resetModel_headerFooter()
// A reset should not force a new header or footer to be created.
QQuickItem *newHeader = findItem<QQuickItem>(contentItem, "header");
- QVERIFY(newHeader == header);
+ QCOMPARE(newHeader, header);
QCOMPARE(header->y(), -header->height());
QQuickItem *newFooter = findItem<QQuickItem>(contentItem, "footer");
- QVERIFY(newFooter == footer);
+ QCOMPARE(newFooter, footer);
QCOMPARE(footer->y(), 60.*2);
delete window;
@@ -4315,8 +4323,19 @@ void tst_QQuickGridView::snapToRow()
QQuickItem *contentItem = gridview->contentItem();
QTRY_VERIFY(contentItem != 0);
+ qreal origContentY = gridview->contentY();
+ qreal origContentX = gridview->contentX();
// confirm that a flick hits an item boundary
flick(window, flickStart, flickEnd, 180);
+
+ // wait until it's at least one cell further
+ QTRY_VERIFY(qAbs(gridview->contentX() - origContentX) > 80 ||
+ qAbs(gridview->contentY() - origContentY) > 80);
+
+ // click to stop it. Otherwise we wouldn't know how much further it will go. We don't want to it
+ // to hit the endExtent, yet.
+ QTest::mouseClick(window, Qt::LeftButton, 0, flickEnd);
+
QTRY_VERIFY(gridview->isMoving() == false); // wait until it stops
if (flow == QQuickGridView::FlowLeftToRight)
QCOMPARE(qreal(fmod(gridview->contentY(),80.0)), snapAlignment);
@@ -5810,7 +5829,7 @@ void tst_QQuickGridView::cacheBuffer()
window->engine()->setIncubationController(&controller);
window->rootObject()->setProperty("cacheBuffer", 200);
- QTRY_VERIFY(gridview->cacheBuffer() == 200);
+ QTRY_COMPARE(gridview->cacheBuffer(), 200);
// items will be created one at a time
for (int i = itemCount; i < qMin(itemCount+9,model.count()); ++i) {
@@ -5910,8 +5929,8 @@ void tst_QQuickGridView::asynchronous()
for (int i = 0; i < 12; ++i) {
QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
if (!item) qWarning() << "Item" << i << "not found";
- QVERIFY(item->x() == (i%3)*100);
- QVERIFY(item->y() == (i/3)*100);
+ QCOMPARE(item->x(), qreal((i%3)*100));
+ QCOMPARE(item->y(), qreal((i/3)*100));
}
delete window;
@@ -6329,7 +6348,7 @@ void tst_QQuickGridView::matchIndexLists(const QVariantList &indexLists, const Q
void tst_QQuickGridView::matchItemsAndIndexes(const QVariantMap &items, const QaimModel &model, const QList<int> &expectedIndexes)
{
for (QVariantMap::const_iterator it = items.begin(); it != items.end(); ++it) {
- QVERIFY(it.value().type() == QVariant::Int);
+ QCOMPARE(it.value().type(), QVariant::Int);
QString name = it.key();
int itemIndex = it.value().toInt();
QVERIFY2(expectedIndexes.contains(itemIndex), QTest::toString(QString("Index %1 not found in expectedIndexes").arg(itemIndex)));
@@ -6460,6 +6479,93 @@ void tst_QQuickGridView::jsArrayChange()
QCOMPARE(spy.count(), 1);
}
+void tst_QQuickGridView::contentHeightWithDelayRemove_data()
+{
+ QTest::addColumn<bool>("useDelayRemove");
+ QTest::addColumn<QByteArray>("removeFunc");
+ QTest::addColumn<int>("countDelta");
+ QTest::addColumn<qreal>("contentHeightDelta");
+
+ QTest::newRow("remove without delayRemove")
+ << false
+ << QByteArray("takeOne")
+ << -1
+ << qreal(-1 * 100.0);
+
+ QTest::newRow("remove with delayRemove")
+ << true
+ << QByteArray("takeOne")
+ << -1
+ << qreal(-1 * 100.0);
+
+ QTest::newRow("remove with multiple delayRemove")
+ << true
+ << QByteArray("takeThree")
+ << -3
+ << qreal(-2 * 100.0);
+
+ QTest::newRow("clear with delayRemove")
+ << true
+ << QByteArray("takeAll")
+ << -5
+ << qreal(-3 * 100.0);
+}
+
+void tst_QQuickGridView::contentHeightWithDelayRemove()
+{
+ QFETCH(bool, useDelayRemove);
+ QFETCH(QByteArray, removeFunc);
+ QFETCH(int, countDelta);
+ QFETCH(qreal, contentHeightDelta);
+
+ QQuickView *window = createView();
+ window->setSource(testFileUrl("contentHeightWithDelayRemove.qml"));
+ window->show();
+ QVERIFY(QTest::qWaitForWindowExposed(window));
+
+ QQuickGridView *gridview = window->rootObject()->findChild<QQuickGridView*>();
+ QTRY_VERIFY(gridview != 0);
+
+ const int initialCount(gridview->count());
+ const int eventualCount(initialCount + countDelta);
+
+ const qreal initialContentHeight(gridview->contentHeight());
+ const int eventualContentHeight(qRound(initialContentHeight + contentHeightDelta));
+
+ gridview->setProperty("useDelayRemove", useDelayRemove);
+ QMetaObject::invokeMethod(window->rootObject(), removeFunc.constData());
+ QTest::qWait(50);
+ QCOMPARE(gridview->count(), eventualCount);
+
+ if (useDelayRemove) {
+ QCOMPARE(qRound(gridview->contentHeight()), qRound(initialContentHeight));
+ QTRY_COMPARE(qRound(gridview->contentHeight()), eventualContentHeight);
+ } else {
+ QCOMPARE(qRound(gridview->contentHeight()), eventualContentHeight);
+ }
+
+ delete window;
+}
+
+void tst_QQuickGridView::QTBUG_45640()
+{
+ QQuickView *window = createView();
+ window->setSource(testFileUrl("qtbug45640.qml"));
+ window->show();
+ QVERIFY(QTest::qWaitForWindowExposed(window));
+
+ QQuickGridView *gridview = qobject_cast<QQuickGridView*>(window->rootObject());
+ QVERIFY(gridview != 0);
+
+ QCOMPARE(gridview->contentY(), qreal(-50.0));
+
+ gridview->moveCurrentIndexDown();
+
+ QTRY_VERIFY(gridview->contentY() > qreal(-50.0) && gridview->contentY() < qreal(0.0));
+
+ delete window;
+}
+
QTEST_MAIN(tst_QQuickGridView)
#include "tst_qquickgridview.moc"
diff --git a/tests/auto/quick/qquickimage/tst_qquickimage.cpp b/tests/auto/quick/qquickimage/tst_qquickimage.cpp
index ce8b52222d..3975654694 100644
--- a/tests/auto/quick/qquickimage/tst_qquickimage.cpp
+++ b/tests/auto/quick/qquickimage/tst_qquickimage.cpp
@@ -121,7 +121,7 @@ void tst_qquickimage::noSource()
QQuickImage *obj = qobject_cast<QQuickImage*>(component.create());
QVERIFY(obj != 0);
QCOMPARE(obj->source(), QUrl());
- QVERIFY(obj->status() == QQuickImage::Null);
+ QCOMPARE(obj->status(), QQuickImage::Null);
QCOMPARE(obj->width(), 0.);
QCOMPARE(obj->height(), 0.);
QCOMPARE(obj->fillMode(), QQuickImage::Stretch);
@@ -154,7 +154,7 @@ void tst_qquickimage::imageSource_data()
if (QImageReader::supportedImageFormats().contains("svgz"))
QTest::newRow("remote svgz") << "/heart.svgz" << 550.0 << 500.0 << true << false << false << "";
QTest::newRow("remote not found") << "/no-such-file.png" << 0.0 << 0.0 << true
- << false << true << "<Unknown File>:2:1: QML Image: Error downloading {{ServerBaseUrl}}/no-such-file.png - server replied: Not found";
+ << false << true << "<Unknown File>:2:1: QML Image: Error transferring {{ServerBaseUrl}}/no-such-file.png - server replied: Not found";
}
@@ -168,6 +168,18 @@ void tst_qquickimage::imageSource()
QFETCH(bool, cache);
QFETCH(QString, error);
+
+#if defined(Q_OS_LINUX) && !defined(Q_OS_ANDROID)
+ if (qstrcmp(QTest::currentDataTag(), "remote") == 0
+ || qstrcmp(QTest::currentDataTag(), "remote redirected") == 0
+ || qstrcmp(QTest::currentDataTag(), "remote svg") == 0
+ || qstrcmp(QTest::currentDataTag(), "remote svgz") == 0
+ || qstrcmp(QTest::currentDataTag(), "remote not found") == 0
+ ) {
+ QSKIP("Remote tests cause occasional hangs in the CI system -- QTBUG-45655");
+ }
+#endif
+
TestHTTPServer server;
if (remote) {
QVERIFY2(server.listen(), qPrintable(server.errorString()));
@@ -189,28 +201,28 @@ void tst_qquickimage::imageSource()
QVERIFY(obj != 0);
if (async)
- QVERIFY(obj->asynchronous() == true);
+ QVERIFY(obj->asynchronous());
else
- QVERIFY(obj->asynchronous() == false);
+ QVERIFY(!obj->asynchronous());
if (cache)
- QVERIFY(obj->cache() == true);
+ QVERIFY(obj->cache());
else
- QVERIFY(obj->cache() == false);
+ QVERIFY(!obj->cache());
if (remote || async)
- QTRY_VERIFY(obj->status() == QQuickImage::Loading);
+ QTRY_COMPARE(obj->status(), QQuickImage::Loading);
QCOMPARE(obj->source(), remote ? source : QUrl(source));
if (error.isEmpty()) {
- QTRY_VERIFY(obj->status() == QQuickImage::Ready);
+ QTRY_COMPARE(obj->status(), QQuickImage::Ready);
QCOMPARE(obj->width(), qreal(width));
QCOMPARE(obj->height(), qreal(height));
QCOMPARE(obj->fillMode(), QQuickImage::Stretch);
QCOMPARE(obj->progress(), 1.0);
} else {
- QTRY_VERIFY(obj->status() == QQuickImage::Error);
+ QTRY_COMPARE(obj->status(), QQuickImage::Error);
}
delete obj;
@@ -225,14 +237,14 @@ void tst_qquickimage::clearSource()
component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
QQuickImage *obj = qobject_cast<QQuickImage*>(component.create());
QVERIFY(obj != 0);
- QVERIFY(obj->status() == QQuickImage::Ready);
+ QCOMPARE(obj->status(), QQuickImage::Ready);
QCOMPARE(obj->width(), 120.);
QCOMPARE(obj->height(), 120.);
QCOMPARE(obj->progress(), 1.0);
ctxt->setContextProperty("srcImage", "");
QVERIFY(obj->source().isEmpty());
- QVERIFY(obj->status() == QQuickImage::Null);
+ QCOMPARE(obj->status(), QQuickImage::Null);
QCOMPARE(obj->width(), 0.);
QCOMPARE(obj->height(), 0.);
QCOMPARE(obj->progress(), 0.0);
@@ -533,7 +545,7 @@ void tst_qquickimage::noLoading()
component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
QQuickImage *obj = qobject_cast<QQuickImage*>(component.create());
QVERIFY(obj != 0);
- QVERIFY(obj->status() == QQuickImage::Ready);
+ QCOMPARE(obj->status(), QQuickImage::Ready);
QSignalSpy sourceSpy(obj, SIGNAL(sourceChanged(QUrl)));
QSignalSpy progressSpy(obj, SIGNAL(progressChanged(qreal)));
@@ -541,29 +553,30 @@ void tst_qquickimage::noLoading()
// Loading local file
ctxt->setContextProperty("srcImage", testFileUrl("green.png"));
- QTRY_VERIFY(obj->status() == QQuickImage::Ready);
- QTRY_VERIFY(obj->progress() == 1.0);
+ QTRY_COMPARE(obj->status(), QQuickImage::Ready);
+ QTRY_COMPARE(obj->progress(), 1.0);
QTRY_COMPARE(sourceSpy.count(), 1);
QTRY_COMPARE(progressSpy.count(), 0);
QTRY_COMPARE(statusSpy.count(), 1);
// Loading remote file
ctxt->setContextProperty("srcImage", server.url("/rect.png"));
- QTRY_VERIFY(obj->status() == QQuickImage::Loading);
- QTRY_VERIFY(obj->progress() == 0.0);
- QTRY_VERIFY(obj->status() == QQuickImage::Ready);
- QTRY_VERIFY(obj->progress() == 1.0);
+ QTRY_COMPARE(obj->status(), QQuickImage::Loading);
+ QTRY_COMPARE(obj->progress(), 0.0);
+ QTRY_COMPARE(obj->status(), QQuickImage::Ready);
+ QTRY_COMPARE(obj->progress(), 1.0);
QTRY_COMPARE(sourceSpy.count(), 2);
- QTRY_COMPARE(progressSpy.count(), 2);
+ QTRY_VERIFY(progressSpy.count() >= 2);
QTRY_COMPARE(statusSpy.count(), 3);
// Loading remote file again - should not go through 'Loading' state.
+ progressSpy.clear();
ctxt->setContextProperty("srcImage", testFileUrl("green.png"));
ctxt->setContextProperty("srcImage", server.url("/rect.png"));
- QTRY_VERIFY(obj->status() == QQuickImage::Ready);
- QTRY_VERIFY(obj->progress() == 1.0);
+ QTRY_COMPARE(obj->status(), QQuickImage::Ready);
+ QTRY_COMPARE(obj->progress(), 1.0);
QTRY_COMPARE(sourceSpy.count(), 4);
- QTRY_COMPARE(progressSpy.count(), 2);
+ QTRY_COMPARE(progressSpy.count(), 0);
QTRY_COMPARE(statusSpy.count(), 5);
delete obj;
@@ -615,7 +628,7 @@ void tst_qquickimage::sourceSize_QTBUG_14303()
QSignalSpy sourceSizeSpy(obj, SIGNAL(sourceSizeChanged()));
QTRY_VERIFY(obj != 0);
- QTRY_VERIFY(obj->status() == QQuickImage::Ready);
+ QTRY_COMPARE(obj->status(), QQuickImage::Ready);
QTRY_COMPARE(obj->sourceSize().width(), 200);
QTRY_COMPARE(obj->sourceSize().height(), 200);
@@ -831,8 +844,8 @@ void tst_qquickimage::progressAndStatusChanges()
component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
QQuickImage *obj = qobject_cast<QQuickImage*>(component.create());
QVERIFY(obj != 0);
- QVERIFY(obj->status() == QQuickImage::Ready);
- QTRY_VERIFY(obj->progress() == 1.0);
+ QCOMPARE(obj->status(), QQuickImage::Ready);
+ QTRY_COMPARE(obj->progress(), 1.0);
qRegisterMetaType<QQuickImageBase::Status>();
QSignalSpy sourceSpy(obj, SIGNAL(sourceChanged(QUrl)));
@@ -841,33 +854,33 @@ void tst_qquickimage::progressAndStatusChanges()
// Same image
ctxt->setContextProperty("srcImage", testFileUrl("heart.png"));
- QTRY_VERIFY(obj->status() == QQuickImage::Ready);
- QTRY_VERIFY(obj->progress() == 1.0);
+ QTRY_COMPARE(obj->status(), QQuickImage::Ready);
+ QTRY_COMPARE(obj->progress(), 1.0);
QTRY_COMPARE(sourceSpy.count(), 0);
QTRY_COMPARE(progressSpy.count(), 0);
QTRY_COMPARE(statusSpy.count(), 0);
// Loading local file
ctxt->setContextProperty("srcImage", testFileUrl("colors.png"));
- QTRY_VERIFY(obj->status() == QQuickImage::Ready);
- QTRY_VERIFY(obj->progress() == 1.0);
+ QTRY_COMPARE(obj->status(), QQuickImage::Ready);
+ QTRY_COMPARE(obj->progress(), 1.0);
QTRY_COMPARE(sourceSpy.count(), 1);
QTRY_COMPARE(progressSpy.count(), 0);
QTRY_COMPARE(statusSpy.count(), 1);
// Loading remote file
ctxt->setContextProperty("srcImage", server.url("/heart.png"));
- QTRY_VERIFY(obj->status() == QQuickImage::Loading);
- QTRY_VERIFY(obj->progress() == 0.0);
- QTRY_VERIFY(obj->status() == QQuickImage::Ready);
- QTRY_VERIFY(obj->progress() == 1.0);
+ QTRY_COMPARE(obj->status(), QQuickImage::Loading);
+ QTRY_COMPARE(obj->progress(), 0.0);
+ QTRY_COMPARE(obj->status(), QQuickImage::Ready);
+ QTRY_COMPARE(obj->progress(), 1.0);
QTRY_COMPARE(sourceSpy.count(), 2);
QTRY_VERIFY(progressSpy.count() > 1);
QTRY_COMPARE(statusSpy.count(), 3);
ctxt->setContextProperty("srcImage", "");
- QTRY_VERIFY(obj->status() == QQuickImage::Null);
- QTRY_VERIFY(obj->progress() == 0.0);
+ QTRY_COMPARE(obj->status(), QQuickImage::Null);
+ QTRY_COMPARE(obj->progress(), 0.0);
QTRY_COMPARE(sourceSpy.count(), 3);
QTRY_VERIFY(progressSpy.count() > 2);
QTRY_COMPARE(statusSpy.count(), 4);
diff --git a/tests/auto/quick/qquickimageprovider/tst_qquickimageprovider.cpp b/tests/auto/quick/qquickimageprovider/tst_qquickimageprovider.cpp
index dae46b5c3d..644f2be129 100644
--- a/tests/auto/quick/qquickimageprovider/tst_qquickimageprovider.cpp
+++ b/tests/auto/quick/qquickimageprovider/tst_qquickimageprovider.cpp
@@ -37,6 +37,7 @@
#include <private/qquickimage_p.h>
#include <QImageReader>
#include <QWaitCondition>
+#include <QThreadPool>
Q_DECLARE_METATYPE(QQuickImageProvider*);
@@ -68,6 +69,8 @@ private slots:
void threadTest();
+ void asyncTextureTest();
+
private:
QString newImageFileName() const;
void fillRequestTestsData(const QString &id);
@@ -234,15 +237,15 @@ void tst_qquickimageprovider::runTest(bool async, QQuickImageProvider *provider)
async |= (provider->flags() & QQuickImageProvider::ForceAsynchronousImageLoading) != 0;
if (async)
- QTRY_VERIFY(obj->status() == QQuickImage::Loading);
+ QTRY_COMPARE(obj->status(), QQuickImage::Loading);
QCOMPARE(obj->source(), QUrl(source));
if (error.isEmpty()) {
if (async)
- QTRY_VERIFY(obj->status() == QQuickImage::Ready);
+ QTRY_COMPARE(obj->status(), QQuickImage::Ready);
else
- QVERIFY(obj->status() == QQuickImage::Ready);
+ QCOMPARE(obj->status(), QQuickImage::Ready);
if (QByteArray(QTest::currentDataTag()).startsWith("qimage"))
QCOMPARE(static_cast<TestQImageProvider*>(provider)->lastImageId, imageId);
else
@@ -254,9 +257,9 @@ void tst_qquickimageprovider::runTest(bool async, QQuickImageProvider *provider)
QCOMPARE(obj->progress(), 1.0);
} else {
if (async)
- QTRY_VERIFY(obj->status() == QQuickImage::Error);
+ QTRY_COMPARE(obj->status(), QQuickImage::Error);
else
- QVERIFY(obj->status() == QQuickImage::Error);
+ QCOMPARE(obj->status(), QQuickImage::Error);
}
delete obj;
@@ -453,7 +456,102 @@ void tst_qquickimageprovider::threadTest()
provider->cond.wakeAll();
QTest::qWait(250);
foreach (QQuickImage *img, images) {
- QTRY_VERIFY(img->status() == QQuickImage::Ready);
+ QTRY_COMPARE(img->status(), QQuickImage::Ready);
+ }
+}
+
+class TestImageResponse : public QQuickImageResponse, public QRunnable
+{
+ public:
+ TestImageResponse(QMutex *lock, QWaitCondition *condition, bool *ok, const QString &id, const QSize &requestedSize)
+ : m_lock(lock), m_condition(condition), m_ok(ok), m_id(id), m_requestedSize(requestedSize), m_texture(0)
+ {
+ setAutoDelete(false);
+ }
+
+ QQuickTextureFactory *textureFactory() const
+ {
+ return m_texture;
+ }
+
+ void run()
+ {
+ m_lock->lock();
+ if (!(*m_ok)) {
+ m_condition->wait(m_lock);
+ }
+ m_lock->unlock();
+ QImage image(50, 50, QImage::Format_RGB32);
+ image.fill(QColor(m_id).rgb());
+ if (m_requestedSize.isValid())
+ image = image.scaled(m_requestedSize);
+ m_texture = QQuickTextureFactory::textureFactoryForImage(image);
+ emit finished();
+ }
+
+ QMutex *m_lock;
+ QWaitCondition *m_condition;
+ bool *m_ok;
+ QString m_id;
+ QSize m_requestedSize;
+ QQuickTextureFactory *m_texture;
+};
+
+class TestAsyncProvider : public QQuickAsyncImageProvider
+{
+ public:
+ TestAsyncProvider() : ok(false)
+ {
+ pool.setMaxThreadCount(4);
+ }
+
+ ~TestAsyncProvider() {}
+
+ QQuickImageResponse *requestImageResponse(const QString &id, const QSize &requestedSize)
+ {
+ TestImageResponse *response = new TestImageResponse(&lock, &condition, &ok, id, requestedSize);
+ pool.start(response);
+ return response;
+ }
+
+ QThreadPool pool;
+ QMutex lock;
+ QWaitCondition condition;
+ bool ok;
+};
+
+
+void tst_qquickimageprovider::asyncTextureTest()
+{
+ QQmlEngine engine;
+
+ TestAsyncProvider *provider = new TestAsyncProvider;
+
+ engine.addImageProvider("test_async", provider);
+ QVERIFY(engine.imageProvider("test_async") != 0);
+
+ QString componentStr = "import QtQuick 2.0\nItem { \n"
+ "Image { source: \"image://test_async/blue\"; }\n"
+ "Image { source: \"image://test_async/red\"; }\n"
+ "Image { source: \"image://test_async/green\"; }\n"
+ "Image { source: \"image://test_async/yellow\"; }\n"
+ " }";
+ QQmlComponent component(&engine);
+ component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QObject *obj = component.create();
+ //MUST not deadlock
+ QVERIFY(obj != 0);
+ QList<QQuickImage *> images = obj->findChildren<QQuickImage *>();
+ QCOMPARE(images.count(), 4);
+
+ QTRY_COMPARE(provider->pool.activeThreadCount(), 4);
+ foreach (QQuickImage *img, images) {
+ QTRY_COMPARE(img->status(), QQuickImage::Loading);
+ }
+ provider->ok = true;
+ provider->condition.wakeAll();
+ foreach (QQuickImage *img, images) {
+ QTRY_COMPARE(img->status(), QQuickImage::Ready);
}
}
diff --git a/tests/auto/quick/qquickitem/BLACKLIST b/tests/auto/quick/qquickitem/BLACKLIST
new file mode 100644
index 0000000000..d94a3ef102
--- /dev/null
+++ b/tests/auto/quick/qquickitem/BLACKLIST
@@ -0,0 +1,2 @@
+[contains:hollow square: testing points inside]
+xcb
diff --git a/tests/auto/quick/qquickitem/tst_qquickitem.cpp b/tests/auto/quick/qquickitem/tst_qquickitem.cpp
index c79af91747..73e691b08c 100644
--- a/tests/auto/quick/qquickitem/tst_qquickitem.cpp
+++ b/tests/auto/quick/qquickitem/tst_qquickitem.cpp
@@ -276,7 +276,7 @@ void tst_qquickitem::simpleFocus()
QQuickWindow window;
ensureFocus(&window);
- QTRY_VERIFY(QGuiApplication::focusWindow() == &window);
+ QTRY_COMPARE(QGuiApplication::focusWindow(), &window);
QQuickItem *l1c1 = new TestItem(window.contentItem());
QQuickItem *l1c2 = new TestItem(window.contentItem());
@@ -327,7 +327,7 @@ void tst_qquickitem::scopedFocus()
{
QQuickWindow window;
ensureFocus(&window);
- QTRY_VERIFY(QGuiApplication::focusWindow() == &window);
+ QTRY_COMPARE(QGuiApplication::focusWindow(), &window);
QQuickItem *l1c1 = new TestItem(window.contentItem());
QQuickItem *l1c2 = new TestItem(window.contentItem());
@@ -407,7 +407,7 @@ void tst_qquickitem::addedToWindow()
{
QQuickWindow window;
ensureFocus(&window);
- QTRY_VERIFY(QGuiApplication::focusWindow() == &window);
+ QTRY_COMPARE(QGuiApplication::focusWindow(), &window);
QQuickItem *item = new TestItem;
@@ -427,7 +427,7 @@ void tst_qquickitem::addedToWindow()
{
QQuickWindow window;
ensureFocus(&window);
- QTRY_VERIFY(QGuiApplication::focusWindow() == &window);
+ QTRY_COMPARE(QGuiApplication::focusWindow(), &window);
QQuickItem *item = new TestItem(window.contentItem());
@@ -456,7 +456,7 @@ void tst_qquickitem::addedToWindow()
{
QQuickWindow window;
ensureFocus(&window);
- QTRY_VERIFY(QGuiApplication::focusWindow() == &window);
+ QTRY_COMPARE(QGuiApplication::focusWindow(), &window);
QQuickItem *tree = new TestItem;
QQuickItem *c1 = new TestItem(tree);
@@ -480,7 +480,7 @@ void tst_qquickitem::addedToWindow()
{
QQuickWindow window;
ensureFocus(&window);
- QTRY_VERIFY(QGuiApplication::focusWindow() == &window);
+ QTRY_COMPARE(QGuiApplication::focusWindow(), &window);
QQuickItem *tree = new TestFocusScope;
QQuickItem *c1 = new TestItem(tree);
QQuickItem *c2 = new TestItem(tree);
@@ -508,7 +508,7 @@ void tst_qquickitem::addedToWindow()
{
QQuickWindow window;
ensureFocus(&window);
- QTRY_VERIFY(QGuiApplication::focusWindow() == &window);
+ QTRY_COMPARE(QGuiApplication::focusWindow(), &window);
QQuickItem *tree = new TestFocusScope;
QQuickItem *c1 = new TestItem(tree);
QQuickItem *c2 = new TestItem(tree);
@@ -534,7 +534,7 @@ void tst_qquickitem::addedToWindow()
{
QQuickWindow window;
ensureFocus(&window);
- QTRY_VERIFY(QGuiApplication::focusWindow() == &window);
+ QTRY_COMPARE(QGuiApplication::focusWindow(), &window);
QQuickItem *child = new TestItem(window.contentItem());
QQuickItem *tree = new TestFocusScope;
QQuickItem *c1 = new TestItem(tree);
@@ -574,7 +574,7 @@ void tst_qquickitem::changeParent()
{
QQuickWindow window;
ensureFocus(&window);
- QTRY_VERIFY(QGuiApplication::focusWindow() == &window);
+ QTRY_COMPARE(QGuiApplication::focusWindow(), &window);
QQuickItem *child = new TestItem(window.contentItem());
FocusState focusState;
@@ -596,7 +596,7 @@ void tst_qquickitem::changeParent()
{
QQuickWindow window;
ensureFocus(&window);
- QTRY_VERIFY(QGuiApplication::focusWindow() == &window);
+ QTRY_COMPARE(QGuiApplication::focusWindow(), &window);
QQuickItem *child = new TestItem(window.contentItem());
QQuickItem *child2 = new TestItem(window.contentItem());
@@ -617,7 +617,7 @@ void tst_qquickitem::changeParent()
{
QQuickWindow window;
ensureFocus(&window);
- QTRY_VERIFY(QGuiApplication::focusWindow() == &window);
+ QTRY_COMPARE(QGuiApplication::focusWindow(), &window);
QQuickItem *child = new TestItem(window.contentItem());
QQuickItem *child2 = new TestFocusScope(window.contentItem());
QQuickItem *item = new TestItem(child);
@@ -639,7 +639,7 @@ void tst_qquickitem::changeParent()
{
QQuickWindow window;
ensureFocus(&window);
- QTRY_VERIFY(QGuiApplication::focusWindow() == &window);
+ QTRY_COMPARE(QGuiApplication::focusWindow(), &window);
QQuickItem *child = new TestItem(window.contentItem());
QQuickItem *child2 = new TestFocusScope(window.contentItem());
QQuickItem *item = new TestItem(child2);
@@ -661,7 +661,7 @@ void tst_qquickitem::changeParent()
{
QQuickWindow window;
ensureFocus(&window);
- QTRY_VERIFY(QGuiApplication::focusWindow() == &window);
+ QTRY_COMPARE(QGuiApplication::focusWindow(), &window);
QQuickItem *child = new TestItem(window.contentItem());
QQuickItem *child2 = new TestFocusScope(window.contentItem());
QQuickItem *item = new TestItem(child2);
@@ -687,7 +687,7 @@ void tst_qquickitem::changeParent()
{
QQuickWindow window;
ensureFocus(&window);
- QTRY_VERIFY(QGuiApplication::focusWindow() == &window);
+ QTRY_COMPARE(QGuiApplication::focusWindow(), &window);
QQuickItem *item = new TestFocusScope(window.contentItem());
QQuickItem *child = new TestItem(item);
QQuickItem *child2 = new TestItem;
@@ -726,7 +726,7 @@ void tst_qquickitem::multipleFocusClears()
view.setSource(testFileUrl("multipleFocusClears.qml"));
view.show();
ensureFocus(&view);
- QTRY_VERIFY(QGuiApplication::focusWindow() == &view);
+ QTRY_COMPARE(QGuiApplication::focusWindow(), &view);
}
void tst_qquickitem::focusSubItemInNonFocusScope()
@@ -757,7 +757,7 @@ void tst_qquickitem::parentItemWithFocus()
{
QQuickWindow window;
ensureFocus(&window);
- QTRY_VERIFY(QGuiApplication::focusWindow() == &window);
+ QTRY_COMPARE(QGuiApplication::focusWindow(), &window);
{
QQuickItem parent;
QQuickItem child;
@@ -856,7 +856,7 @@ void tst_qquickitem::reparentFocusedItem()
{
QQuickWindow window;
ensureFocus(&window);
- QTRY_VERIFY(QGuiApplication::focusWindow() == &window);
+ QTRY_COMPARE(QGuiApplication::focusWindow(), &window);
QQuickItem parent(window.contentItem());
QQuickItem child(&parent);
@@ -883,18 +883,18 @@ void tst_qquickitem::reparentFocusedItem()
void tst_qquickitem::constructor()
{
QScopedPointer<QQuickItem> root(new QQuickItem);
- QVERIFY(root->parent() == 0);
- QVERIFY(root->parentItem() == 0);
+ QVERIFY(!root->parent());
+ QVERIFY(!root->parentItem());
QQuickItem *child1 = new QQuickItem(root.data());
- QVERIFY(child1->parent() == root.data());
- QVERIFY(child1->parentItem() == root.data());
+ QCOMPARE(child1->parent(), root.data());
+ QCOMPARE(child1->parentItem(), root.data());
QCOMPARE(root->childItems().count(), 1);
QCOMPARE(root->childItems().at(0), child1);
QQuickItem *child2 = new QQuickItem(root.data());
- QVERIFY(child2->parent() == root.data());
- QVERIFY(child2->parentItem() == root.data());
+ QCOMPARE(child2->parent(), root.data());
+ QCOMPARE(child2->parentItem(), root.data());
QCOMPARE(root->childItems().count(), 2);
QCOMPARE(root->childItems().at(0), child1);
QCOMPARE(root->childItems().at(1), child2);
@@ -903,41 +903,41 @@ void tst_qquickitem::constructor()
void tst_qquickitem::setParentItem()
{
QQuickItem *root = new QQuickItem;
- QVERIFY(root->parent() == 0);
- QVERIFY(root->parentItem() == 0);
+ QVERIFY(!root->parent());
+ QVERIFY(!root->parentItem());
QQuickItem *child1 = new QQuickItem;
- QVERIFY(child1->parent() == 0);
- QVERIFY(child1->parentItem() == 0);
+ QVERIFY(!child1->parent());
+ QVERIFY(!child1->parentItem());
child1->setParentItem(root);
- QVERIFY(child1->parent() == 0);
- QVERIFY(child1->parentItem() == root);
+ QVERIFY(!child1->parent());
+ QCOMPARE(child1->parentItem(), root);
QCOMPARE(root->childItems().count(), 1);
QCOMPARE(root->childItems().at(0), child1);
QQuickItem *child2 = new QQuickItem;
- QVERIFY(child2->parent() == 0);
- QVERIFY(child2->parentItem() == 0);
+ QVERIFY(!child2->parent());
+ QVERIFY(!child2->parentItem());
child2->setParentItem(root);
- QVERIFY(child2->parent() == 0);
- QVERIFY(child2->parentItem() == root);
+ QVERIFY(!child2->parent());
+ QCOMPARE(child2->parentItem(), root);
QCOMPARE(root->childItems().count(), 2);
QCOMPARE(root->childItems().at(0), child1);
QCOMPARE(root->childItems().at(1), child2);
child1->setParentItem(0);
- QVERIFY(child1->parent() == 0);
- QVERIFY(child1->parentItem() == 0);
+ QVERIFY(!child1->parent());
+ QVERIFY(!child1->parentItem());
QCOMPARE(root->childItems().count(), 1);
QCOMPARE(root->childItems().at(0), child2);
delete root;
- QVERIFY(child1->parent() == 0);
- QVERIFY(child1->parentItem() == 0);
- QVERIFY(child2->parent() == 0);
- QVERIFY(child2->parentItem() == 0);
+ QVERIFY(!child1->parent());
+ QVERIFY(!child1->parentItem());
+ QVERIFY(!child2->parent());
+ QVERIFY(!child2->parentItem());
delete child1;
delete child2;
diff --git a/tests/auto/quick/qquickitem2/data/childrenRectBottomRightCorner.qml b/tests/auto/quick/qquickitem2/data/childrenRectBottomRightCorner.qml
new file mode 100644
index 0000000000..0b83e20b20
--- /dev/null
+++ b/tests/auto/quick/qquickitem2/data/childrenRectBottomRightCorner.qml
@@ -0,0 +1,47 @@
+import QtQuick 2.0
+
+Item {
+ width: 300
+ height: 300
+
+ Item {
+ anchors.centerIn: parent
+
+ Rectangle {
+ objectName: "childrenRectProxy"
+ x: container.childrenRect.x
+ y: container.childrenRect.y
+ width: container.childrenRect.width
+ height: container.childrenRect.height
+ color: "red"
+ opacity: 0.5
+ }
+
+ Item {
+ id: container
+
+ Rectangle {
+ x: -100
+ y: -100
+ width: 10
+ height: 10
+ color: "red"
+ }
+
+ Rectangle {
+ x: -60
+ y: -60
+ width: 10
+ height: 10
+ color: "red"
+ }
+ }
+
+ Rectangle {
+ id: origin
+ width: 5
+ height: 5
+ color: "black"
+ }
+ }
+}
diff --git a/tests/auto/quick/qquickitem2/data/mapCoordinates.qml b/tests/auto/quick/qquickitem2/data/mapCoordinates.qml
index 0b0b15a767..a9c5030e12 100644
--- a/tests/auto/quick/qquickitem2/data/mapCoordinates.qml
+++ b/tests/auto/quick/qquickitem2/data/mapCoordinates.qml
@@ -65,12 +65,20 @@ Item {
}
function checkMapAToInvalid(x, y) {
- var pos = itemA.mapToItem(1122, x, y)
- return pos == undefined;
+ try {
+ itemA.mapToItem(1122, x, y)
+ } catch (e) {
+ return e instanceof TypeError
+ }
+ return false
}
function checkMapAFromInvalid(x, y) {
- var pos = itemA.mapFromItem(1122, x, y)
- return pos == undefined;
+ try {
+ itemA.mapFromItem(1122, x, y)
+ } catch (e) {
+ return e instanceof TypeError
+ }
+ return false
}
}
diff --git a/tests/auto/quick/qquickitem2/data/mapCoordinatesRect.qml b/tests/auto/quick/qquickitem2/data/mapCoordinatesRect.qml
index e21aab1f01..c127407eae 100644
--- a/tests/auto/quick/qquickitem2/data/mapCoordinatesRect.qml
+++ b/tests/auto/quick/qquickitem2/data/mapCoordinatesRect.qml
@@ -66,12 +66,20 @@ Item {
}
function checkMapAToInvalid(x, y, w, h) {
- var pos = itemA.mapToItem(1122, x, y, w, h)
- return pos == undefined;
+ try {
+ itemA.mapToItem(1122, x, y, w, h)
+ } catch (e) {
+ return e instanceof TypeError
+ }
+ return false;
}
function checkMapAFromInvalid(x, y, w, h) {
- var pos = itemA.mapFromItem(1122, x, y, w, h)
- return pos == undefined;
+ try {
+ itemA.mapFromItem(1122, x, y, w, h)
+ } catch (e) {
+ return e instanceof TypeError
+ }
+ return false;
}
}
diff --git a/tests/auto/quick/qquickitem2/data/tabFence.qml b/tests/auto/quick/qquickitem2/data/tabFence.qml
new file mode 100644
index 0000000000..fcf69b418b
--- /dev/null
+++ b/tests/auto/quick/qquickitem2/data/tabFence.qml
@@ -0,0 +1,49 @@
+import QtQuick 2.1
+import Test 1.0
+
+Item {
+ objectName: "root"
+ focus: true
+ width: 800
+ height: 600
+
+ TabFence {
+ objectName: "fence1"
+
+ TextInput {
+ objectName: "input11"
+ activeFocusOnTab: true
+ }
+ TextInput {
+ objectName: "input12"
+ activeFocusOnTab: true
+ }
+ TextInput {
+ objectName: "input13"
+ activeFocusOnTab: true
+ }
+ }
+
+ TextInput {
+ objectName: "input1"
+ activeFocusOnTab: true
+ }
+
+ TextInput {
+ objectName: "input2"
+ activeFocusOnTab: true
+ }
+
+ TabFence {
+ objectName: "fence2"
+ }
+
+ TextInput {
+ objectName: "input3"
+ activeFocusOnTab: true
+ }
+
+ TabFence {
+ objectName: "fence3"
+ }
+}
diff --git a/tests/auto/quick/qquickitem2/tst_qquickitem.cpp b/tests/auto/quick/qquickitem2/tst_qquickitem.cpp
index f3333df60d..c7717b9cca 100644
--- a/tests/auto/quick/qquickitem2/tst_qquickitem.cpp
+++ b/tests/auto/quick/qquickitem2/tst_qquickitem.cpp
@@ -73,6 +73,8 @@ private slots:
void nextItemInFocusChain2();
void nextItemInFocusChain3();
+ void tabFence();
+
void keys();
void standardKeys_data();
void standardKeys();
@@ -102,6 +104,7 @@ private slots:
void childrenRectBug();
void childrenRectBug2();
void childrenRectBug3();
+ void childrenRectBottomRightCorner();
void childrenProperty();
void resourcesProperty();
@@ -290,6 +293,20 @@ private:
QML_DECLARE_TYPE(HollowTestItem);
+class TabFenceItem : public QQuickItem
+{
+ Q_OBJECT
+
+public:
+ TabFenceItem(QQuickItem *parent = Q_NULLPTR)
+ : QQuickItem(parent)
+ {
+ QQuickItemPrivate *d = QQuickItemPrivate::get(this);
+ d->isTabFence = true;
+ }
+};
+
+QML_DECLARE_TYPE(TabFenceItem);
tst_QQuickItem::tst_QQuickItem()
{
@@ -300,6 +317,7 @@ void tst_QQuickItem::initTestCase()
QQmlDataTest::initTestCase();
qmlRegisterType<KeyTestItem>("Test",1,0,"KeyTestItem");
qmlRegisterType<HollowTestItem>("Test", 1, 0, "HollowTestItem");
+ qmlRegisterType<TabFenceItem>("Test", 1, 0, "TabFence");
}
void tst_QQuickItem::cleanup()
@@ -320,7 +338,7 @@ void tst_QQuickItem::activeFocusOnTab()
window->show();
window->requestActivate();
QVERIFY(QTest::qWaitForWindowActive(window));
- QVERIFY(QGuiApplication::focusWindow() == window);
+ QCOMPARE(QGuiApplication::focusWindow(), window);
// original: button12
QQuickItem *item = findItem<QQuickItem>(window->rootObject(), "button12");
@@ -432,7 +450,7 @@ void tst_QQuickItem::activeFocusOnTab2()
window->show();
window->requestActivate();
QVERIFY(QTest::qWaitForWindowActive(window));
- QVERIFY(QGuiApplication::focusWindow() == window);
+ QCOMPARE(QGuiApplication::focusWindow(), window);
// original: button12
QQuickItem *item = findItem<QQuickItem>(window->rootObject(), "button12");
@@ -472,7 +490,7 @@ void tst_QQuickItem::activeFocusOnTab3()
window->show();
window->requestActivate();
QVERIFY(QTest::qWaitForWindowActive(window));
- QVERIFY(QGuiApplication::focusWindow() == window);
+ QCOMPARE(QGuiApplication::focusWindow(), window);
// original: button1
QQuickItem *item = findItem<QQuickItem>(window->rootObject(), "button1");
@@ -654,7 +672,7 @@ void tst_QQuickItem::activeFocusOnTab4()
window->show();
window->requestActivate();
QVERIFY(QTest::qWaitForWindowActive(window));
- QVERIFY(QGuiApplication::focusWindow() == window);
+ QCOMPARE(QGuiApplication::focusWindow(), window);
// original: button11
QQuickItem *item = findItem<QQuickItem>(window->rootObject(), "button11");
@@ -686,7 +704,7 @@ void tst_QQuickItem::activeFocusOnTab5()
window->show();
window->requestActivate();
QVERIFY(QTest::qWaitForWindowActive(window));
- QVERIFY(QGuiApplication::focusWindow() == window);
+ QCOMPARE(QGuiApplication::focusWindow(), window);
// original: button11 in sub1
QQuickItem *item = findItem<QQuickItem>(window->rootObject(), "button11");
@@ -720,7 +738,7 @@ void tst_QQuickItem::activeFocusOnTab6()
window->show();
window->requestActivate();
QVERIFY(QTest::qWaitForWindowActive(window));
- QVERIFY(QGuiApplication::focusWindow() == window);
+ QCOMPARE(QGuiApplication::focusWindow(), window);
// original: button12
QQuickItem *item = findItem<QQuickItem>(window->rootObject(), "button12");
@@ -778,7 +796,7 @@ void tst_QQuickItem::activeFocusOnTab7()
window->show();
window->requestActivate();
QVERIFY(QTest::qWaitForWindowActive(window));
- QVERIFY(QGuiApplication::focusWindow() == window);
+ QCOMPARE(QGuiApplication::focusWindow(), window);
QQuickItem *item = findItem<QQuickItem>(window->rootObject(), "button1");
QVERIFY(item);
@@ -811,7 +829,7 @@ void tst_QQuickItem::activeFocusOnTab8()
window->show();
window->requestActivate();
QVERIFY(QTest::qWaitForWindowActive(window));
- QVERIFY(QGuiApplication::focusWindow() == window);
+ QCOMPARE(QGuiApplication::focusWindow(), window);
QQuickItem *content = window->contentItem();
QVERIFY(content);
@@ -863,7 +881,7 @@ void tst_QQuickItem::activeFocusOnTab9()
window->show();
window->requestActivate();
QVERIFY(QTest::qWaitForWindowActive(window));
- QVERIFY(QGuiApplication::focusWindow() == window);
+ QCOMPARE(QGuiApplication::focusWindow(), window);
QQuickItem *content = window->contentItem();
QVERIFY(content);
@@ -914,7 +932,7 @@ void tst_QQuickItem::activeFocusOnTab10()
window->show();
window->requestActivate();
QVERIFY(QTest::qWaitForWindowActive(window));
- QVERIFY(QGuiApplication::focusWindow() == window);
+ QCOMPARE(QGuiApplication::focusWindow(), window);
QQuickItem *content = window->contentItem();
QVERIFY(content);
@@ -997,7 +1015,7 @@ void tst_QQuickItem::nextItemInFocusChain()
window->show();
window->requestActivate();
QVERIFY(QTest::qWaitForWindowActive(window));
- QVERIFY(QGuiApplication::focusWindow() == window);
+ QCOMPARE(QGuiApplication::focusWindow(), window);
QQuickItem *button11 = findItem<QQuickItem>(window->rootObject(), "button11");
QVERIFY(button11);
@@ -1073,7 +1091,7 @@ void tst_QQuickItem::nextItemInFocusChain2()
window->show();
window->requestActivate();
QVERIFY(QTest::qWaitForWindowActive(window));
- QVERIFY(QGuiApplication::focusWindow() == window);
+ QCOMPARE(QGuiApplication::focusWindow(), window);
QQuickItem *button11 = findItem<QQuickItem>(window->rootObject(), "button11");
QVERIFY(button11);
@@ -1118,7 +1136,62 @@ void tst_QQuickItem::nextItemInFocusChain3()
window->show();
window->requestActivate();
QVERIFY(QTest::qWaitForWindowActive(window));
+ QCOMPARE(QGuiApplication::focusWindow(), window);
+}
+
+void verifyTabFocusChain(QQuickView *window, const char **focusChain, bool forward)
+{
+ int idx = 0;
+ for (const char **objectName = focusChain; *objectName; ++objectName, ++idx) {
+ const QString &descrStr = QString("idx=%1 objectName=\"%2\"").arg(idx).arg(*objectName);
+ const char *descr = descrStr.toLocal8Bit().data();
+ QKeyEvent key(QEvent::KeyPress, Qt::Key_Tab, forward ? Qt::NoModifier : Qt::ShiftModifier);
+ QGuiApplication::sendEvent(window, &key);
+ QVERIFY2(key.isAccepted(), descr);
+
+ QQuickItem *item = findItem<QQuickItem>(window->rootObject(), *objectName);
+ QVERIFY2(item, descr);
+ QVERIFY2(item->hasActiveFocus(), descr);
+ }
+}
+
+void tst_QQuickItem::tabFence()
+{
+ QQuickView *window = new QQuickView(0);
+ window->setBaseSize(QSize(800,600));
+
+ window->setSource(testFileUrl("tabFence.qml"));
+ window->show();
+ window->requestActivate();
+ QVERIFY(QTest::qWaitForWindowActive(window));
QVERIFY(QGuiApplication::focusWindow() == window);
+ QVERIFY(window->rootObject()->hasActiveFocus());
+
+ const char *rootTabFocusChain[] = {
+ "input1", "input2", "input3", "input1", Q_NULLPTR
+ };
+ verifyTabFocusChain(window, rootTabFocusChain, true /* forward */);
+
+ const char *rootBacktabFocusChain[] = {
+ "input3", "input2", "input1", "input3", Q_NULLPTR
+ };
+ verifyTabFocusChain(window, rootBacktabFocusChain, false /* forward */);
+
+ // Give focus to input11 in fence1
+ QQuickItem *item = findItem<QQuickItem>(window->rootObject(), "input11");
+ item->setFocus(true);
+ QVERIFY(item);
+ QVERIFY(item->hasActiveFocus());
+
+ const char *fence1TabFocusChain[] = {
+ "input12", "input13", "input11", "input12", Q_NULLPTR
+ };
+ verifyTabFocusChain(window, fence1TabFocusChain, true /* forward */);
+
+ const char *fence1BacktabFocusChain[] = {
+ "input11", "input13", "input12", "input11", Q_NULLPTR
+ };
+ verifyTabFocusChain(window, fence1BacktabFocusChain, false /* forward */);
}
void tst_QQuickItem::keys()
@@ -1136,7 +1209,7 @@ void tst_QQuickItem::keys()
window->show();
window->requestActivate();
QVERIFY(QTest::qWaitForWindowActive(window));
- QVERIFY(QGuiApplication::focusWindow() == window);
+ QCOMPARE(QGuiApplication::focusWindow(), window);
QVERIFY(window->rootObject());
QCOMPARE(window->rootObject()->property("isEnabled").toBool(), true);
@@ -1146,7 +1219,7 @@ void tst_QQuickItem::keys()
QCOMPARE(testObject->mKey, int(Qt::Key_A));
QCOMPARE(testObject->mForwardedKey, int(Qt::Key_A));
QCOMPARE(testObject->mText, QLatin1String("A"));
- QVERIFY(testObject->mModifiers == Qt::NoModifier);
+ QCOMPARE(testObject->mModifiers, int(Qt::NoModifier));
QVERIFY(!key.isAccepted());
testObject->reset();
@@ -1156,7 +1229,7 @@ void tst_QQuickItem::keys()
QCOMPARE(testObject->mKey, int(Qt::Key_A));
QCOMPARE(testObject->mForwardedKey, int(Qt::Key_A));
QCOMPARE(testObject->mText, QLatin1String("A"));
- QVERIFY(testObject->mModifiers == Qt::ShiftModifier);
+ QCOMPARE(testObject->mModifiers, int(Qt::ShiftModifier));
QVERIFY(key.isAccepted());
testObject->reset();
@@ -1166,7 +1239,7 @@ void tst_QQuickItem::keys()
QCOMPARE(testObject->mKey, int(Qt::Key_Return));
QCOMPARE(testObject->mForwardedKey, int(Qt::Key_Return));
QCOMPARE(testObject->mText, QLatin1String("Return"));
- QVERIFY(testObject->mModifiers == Qt::NoModifier);
+ QCOMPARE(testObject->mModifiers, int(Qt::NoModifier));
QVERIFY(key.isAccepted());
testObject->reset();
@@ -1176,7 +1249,7 @@ void tst_QQuickItem::keys()
QCOMPARE(testObject->mKey, int(Qt::Key_0));
QCOMPARE(testObject->mForwardedKey, int(Qt::Key_0));
QCOMPARE(testObject->mText, QLatin1String("0"));
- QVERIFY(testObject->mModifiers == Qt::NoModifier);
+ QCOMPARE(testObject->mModifiers, int(Qt::NoModifier));
QVERIFY(key.isAccepted());
testObject->reset();
@@ -1186,7 +1259,7 @@ void tst_QQuickItem::keys()
QCOMPARE(testObject->mKey, int(Qt::Key_9));
QCOMPARE(testObject->mForwardedKey, int(Qt::Key_9));
QCOMPARE(testObject->mText, QLatin1String("9"));
- QVERIFY(testObject->mModifiers == Qt::NoModifier);
+ QCOMPARE(testObject->mModifiers, int(Qt::NoModifier));
QVERIFY(!key.isAccepted());
testObject->reset();
@@ -1196,7 +1269,7 @@ void tst_QQuickItem::keys()
QCOMPARE(testObject->mKey, int(Qt::Key_Tab));
QCOMPARE(testObject->mForwardedKey, int(Qt::Key_Tab));
QCOMPARE(testObject->mText, QLatin1String("Tab"));
- QVERIFY(testObject->mModifiers == Qt::NoModifier);
+ QCOMPARE(testObject->mModifiers, int(Qt::NoModifier));
QVERIFY(key.isAccepted());
testObject->reset();
@@ -1206,7 +1279,7 @@ void tst_QQuickItem::keys()
QCOMPARE(testObject->mKey, int(Qt::Key_Backtab));
QCOMPARE(testObject->mForwardedKey, int(Qt::Key_Backtab));
QCOMPARE(testObject->mText, QLatin1String("Backtab"));
- QVERIFY(testObject->mModifiers == Qt::NoModifier);
+ QCOMPARE(testObject->mModifiers, int(Qt::NoModifier));
QVERIFY(key.isAccepted());
testObject->reset();
@@ -1215,8 +1288,8 @@ void tst_QQuickItem::keys()
QGuiApplication::sendEvent(window, &key);
QCOMPARE(testObject->mKey, int(Qt::Key_VolumeUp));
QCOMPARE(testObject->mForwardedKey, int(Qt::Key_VolumeUp));
- QVERIFY(testObject->mModifiers == Qt::NoModifier);
- QVERIFY(testObject->mNativeScanCode == 1234);
+ QCOMPARE(testObject->mModifiers, int(Qt::NoModifier));
+ QCOMPARE(testObject->mNativeScanCode, quint32(1234));
QVERIFY(key.isAccepted());
testObject->reset();
@@ -1227,7 +1300,7 @@ void tst_QQuickItem::keys()
QCOMPARE(testObject->mKey, int(Qt::Key_A));
QCOMPARE(testObject->mForwardedKey, 0);
QCOMPARE(testObject->mText, QLatin1String("A"));
- QVERIFY(testObject->mModifiers == Qt::NoModifier);
+ QCOMPARE(testObject->mModifiers, int(Qt::NoModifier));
QVERIFY(!key.isAccepted());
testObject->reset();
@@ -1322,7 +1395,7 @@ void tst_QQuickItem::keysProcessingOrder()
window->show();
window->requestActivate();
QVERIFY(QTest::qWaitForWindowActive(window));
- QVERIFY(QGuiApplication::focusWindow() == window);
+ QCOMPARE(QGuiApplication::focusWindow(), window);
KeyTestItem *testItem = qobject_cast<KeyTestItem*>(window->rootObject());
QVERIFY(testItem);
@@ -1333,7 +1406,7 @@ void tst_QQuickItem::keysProcessingOrder()
QGuiApplication::sendEvent(window, &key);
QCOMPARE(testObject->mKey, int(Qt::Key_A));
QCOMPARE(testObject->mText, QLatin1String("A"));
- QVERIFY(testObject->mModifiers == Qt::NoModifier);
+ QCOMPARE(testObject->mModifiers, int(Qt::NoModifier));
QVERIFY(key.isAccepted());
testObject->reset();
@@ -1353,7 +1426,7 @@ void tst_QQuickItem::keysProcessingOrder()
QGuiApplication::sendEvent(window, &key);
QCOMPARE(testObject->mKey, int(Qt::Key_B));
QCOMPARE(testObject->mText, QLatin1String("B"));
- QVERIFY(testObject->mModifiers == Qt::NoModifier);
+ QCOMPARE(testObject->mModifiers, int(Qt::NoModifier));
QVERIFY(!key.isAccepted());
testObject->reset();
@@ -1380,7 +1453,7 @@ void tst_QQuickItem::keysim()
window->show();
window->requestActivate();
QVERIFY(QTest::qWaitForWindowActive(window));
- QVERIFY(QGuiApplication::focusWindow() == window);
+ QCOMPARE(QGuiApplication::focusWindow(), window);
QVERIFY(window->rootObject());
QVERIFY(window->rootObject()->hasFocus() && window->rootObject()->hasActiveFocus());
@@ -1406,7 +1479,7 @@ void tst_QQuickItem::keysForward()
window.show();
window.requestActivate();
QVERIFY(QTest::qWaitForWindowActive(&window));
- QVERIFY(QGuiApplication::focusWindow() == &window);
+ QCOMPARE(QGuiApplication::focusWindow(), &window);
QQuickItem *rootItem = qobject_cast<QQuickItem *>(window.rootObject());
QVERIFY(rootItem);
@@ -1646,7 +1719,7 @@ void tst_QQuickItem::keyNavigation()
window->show();
window->requestActivate();
QVERIFY(QTest::qWaitForWindowActive(window));
- QVERIFY(QGuiApplication::focusWindow() == window);
+ QCOMPARE(QGuiApplication::focusWindow(), window);
QQuickItem *item = findItem<QQuickItem>(window->rootObject(), "item1");
QVERIFY(item);
@@ -1723,7 +1796,7 @@ void tst_QQuickItem::keyNavigation_RightToLeft()
window->show();
window->requestActivate();
QVERIFY(QTest::qWaitForWindowActive(window));
- QVERIFY(QGuiApplication::focusWindow() == window);
+ QCOMPARE(QGuiApplication::focusWindow(), window);
QQuickItem *rootItem = qobject_cast<QQuickItem*>(window->rootObject());
QVERIFY(rootItem);
@@ -1778,7 +1851,7 @@ void tst_QQuickItem::keyNavigation_skipNotVisible()
window->show();
window->requestActivate();
QVERIFY(QTest::qWaitForWindowActive(window));
- QVERIFY(QGuiApplication::focusWindow() == window);
+ QCOMPARE(QGuiApplication::focusWindow(), window);
QQuickItem *item = findItem<QQuickItem>(window->rootObject(), "item1");
QVERIFY(item);
@@ -1853,7 +1926,7 @@ void tst_QQuickItem::keyNavigation_implicitSetting()
window->show();
window->requestActivate();
QVERIFY(QTest::qWaitForWindowActive(window));
- QVERIFY(QGuiApplication::focusWindow() == window);
+ QCOMPARE(QGuiApplication::focusWindow(), window);
QEvent wa(QEvent::WindowActivate);
QGuiApplication::sendEvent(window, &wa);
@@ -1983,7 +2056,7 @@ void tst_QQuickItem::keyNavigation_focusReason()
window->requestActivate();
QVERIFY(QTest::qWaitForWindowActive(window));
- QVERIFY(QGuiApplication::focusWindow() == window);
+ QCOMPARE(QGuiApplication::focusWindow(), window);
// install event filter on first item
QQuickItem *item = findItem<QQuickItem>(window->rootObject(), "item1");
@@ -2018,10 +2091,14 @@ void tst_QQuickItem::keyNavigation_focusReason()
QVERIFY(key.isAccepted());
QCOMPARE(focusEventFilter.lastFocusReason, Qt::BacktabFocusReason);
- // some arbitrary cursor key
+ // right - it's also one kind of key navigation
key = QKeyEvent(QEvent::KeyPress, Qt::Key_Right, Qt::NoModifier, "", false, 1);
QGuiApplication::sendEvent(window, &key);
QVERIFY(key.isAccepted());
+ QCOMPARE(focusEventFilter.lastFocusReason, Qt::TabFocusReason);
+
+ item->setFocus(true, Qt::OtherFocusReason);
+ QVERIFY(item->hasActiveFocus());
QCOMPARE(focusEventFilter.lastFocusReason, Qt::OtherFocusReason);
delete window;
@@ -2066,8 +2143,8 @@ void tst_QQuickItem::smooth()
QVERIFY(item->smooth());
QCOMPARE(spy.count(),1);
QList<QVariant> arguments = spy.first();
- QVERIFY(arguments.count() == 1);
- QVERIFY(arguments.at(0).toBool() == true);
+ QCOMPARE(arguments.count(), 1);
+ QVERIFY(arguments.at(0).toBool());
item->setSmooth(true);
QCOMPARE(spy.count(),1);
@@ -2095,8 +2172,8 @@ void tst_QQuickItem::antialiasing()
QVERIFY(item->antialiasing());
QCOMPARE(spy.count(),1);
QList<QVariant> arguments = spy.first();
- QVERIFY(arguments.count() == 1);
- QVERIFY(arguments.at(0).toBool() == true);
+ QCOMPARE(arguments.count(), 1);
+ QVERIFY(arguments.at(0).toBool());
item->setAntialiasing(true);
QCOMPARE(spy.count(),1);
@@ -2124,8 +2201,8 @@ void tst_QQuickItem::clip()
QVERIFY(item->clip());
QList<QVariant> arguments = spy.first();
- QVERIFY(arguments.count() == 1);
- QVERIFY(arguments.at(0).toBool() == true);
+ QCOMPARE(arguments.count(), 1);
+ QVERIFY(arguments.at(0).toBool());
QCOMPARE(spy.count(),1);
item->setClip(true);
@@ -2351,7 +2428,7 @@ void tst_QQuickItem::propertyChanges()
window->show();
window->requestActivate();
QVERIFY(QTest::qWaitForWindowActive(window));
- QVERIFY(QGuiApplication::focusWindow() == window);
+ QCOMPARE(QGuiApplication::focusWindow(), window);
QQuickItem *item = findItem<QQuickItem>(window->rootObject(), "item");
QQuickItem *parentItem = findItem<QQuickItem>(window->rootObject(), "parentItem");
@@ -2379,7 +2456,7 @@ void tst_QQuickItem::propertyChanges()
QCOMPARE(item->parentItem(), parentItem);
QCOMPARE(parentSpy.count(),1);
QList<QVariant> parentArguments = parentSpy.first();
- QVERIFY(parentArguments.count() == 1);
+ QCOMPARE(parentArguments.count(), 1);
QCOMPARE(item->parentItem(), qvariant_cast<QQuickItem *>(parentArguments.at(0)));
QCOMPARE(childrenChangedSpy.count(),1);
@@ -2395,19 +2472,19 @@ void tst_QQuickItem::propertyChanges()
QCOMPARE(item->baselineOffset(), 10.0);
QCOMPARE(baselineOffsetSpy.count(),1);
QList<QVariant> baselineOffsetArguments = baselineOffsetSpy.first();
- QVERIFY(baselineOffsetArguments.count() == 1);
+ QCOMPARE(baselineOffsetArguments.count(), 1);
QCOMPARE(item->baselineOffset(), baselineOffsetArguments.at(0).toReal());
QCOMPARE(parentItem->childrenRect(), QRectF(0.0,0.0,100.0,200.0));
QCOMPARE(childrenRectSpy.count(),1);
QList<QVariant> childrenRectArguments = childrenRectSpy.at(0);
- QVERIFY(childrenRectArguments.count() == 1);
+ QCOMPARE(childrenRectArguments.count(), 1);
QCOMPARE(parentItem->childrenRect(), childrenRectArguments.at(0).toRectF());
QCOMPARE(item->hasActiveFocus(), true);
QCOMPARE(focusSpy.count(),1);
QList<QVariant> focusArguments = focusSpy.first();
- QVERIFY(focusArguments.count() == 1);
+ QCOMPARE(focusArguments.count(), 1);
QCOMPARE(focusArguments.at(0).toBool(), true);
QCOMPARE(parentItem->hasActiveFocus(), false);
@@ -2519,6 +2596,22 @@ void tst_QQuickItem::childrenRectBug3()
delete window;
}
+// QTBUG-38732
+void tst_QQuickItem::childrenRectBottomRightCorner()
+{
+ QQuickView *window = new QQuickView(0);
+ window->setSource(testFileUrl("childrenRectBottomRightCorner.qml"));
+ window->show();
+
+ QQuickItem *rect = window->rootObject()->findChild<QQuickItem*>("childrenRectProxy");
+ QCOMPARE(rect->x(), qreal(-100));
+ QCOMPARE(rect->y(), qreal(-100));
+ QCOMPARE(rect->width(), qreal(50));
+ QCOMPARE(rect->height(), qreal(50));
+
+ delete window;
+}
+
// QTBUG-13893
void tst_QQuickItem::transformCrash()
{
@@ -2671,7 +2764,10 @@ void tst_QQuickItem::parentLoop()
{
QQuickView *window = new QQuickView(0);
- QTest::ignoreMessage(QtWarningMsg, "QQuickItem::setParentItem: Parent is already part of this items subtree.");
+#ifndef QT_NO_REGULAREXPRESSION
+ QRegularExpression msgRegexp = QRegularExpression("QQuickItem::setParentItem: Parent QQuickItem\\(.*\\) is already part of the subtree of QQuickItem\\(.*\\)");
+ QTest::ignoreMessage(QtWarningMsg, msgRegexp);
+#endif
window->setSource(testFileUrl("parentLoop.qml"));
QQuickItem *root = qobject_cast<QQuickItem*>(window->rootObject());
@@ -2763,7 +2859,7 @@ void tst_QQuickItem::contains()
window->show();
window->requestActivate();
QVERIFY(QTest::qWaitForWindowActive(window));
- QVERIFY(QGuiApplication::focusWindow() == window);
+ QCOMPARE(QGuiApplication::focusWindow(), window);
QQuickItem *root = qobject_cast<QQuickItem *>(window->rootObject());
QVERIFY(root);
diff --git a/tests/auto/quick/qquickitemlayer/data/TextureMirroring.qml b/tests/auto/quick/qquickitemlayer/data/TextureMirroring.qml
new file mode 100644
index 0000000000..2827960153
--- /dev/null
+++ b/tests/auto/quick/qquickitemlayer/data/TextureMirroring.qml
@@ -0,0 +1,159 @@
+import QtQuick 2.6
+
+Item
+{
+ width: 250
+ height: 50
+
+ property int mirroring: 0
+
+ // Layered box without effect. Mirroring should not affect how it looks.
+ Rectangle {
+ x: 0
+ y: 0
+ width: 50
+ height: 50
+ layer.enabled: true
+ layer.textureMirroring: mirroring
+ Rectangle {
+ x: 0
+ y: 0
+ width: 25
+ height: 25
+ color: "#000000"
+ }
+ Rectangle {
+ x: 25
+ y: 0
+ width: 25
+ height: 25
+ color: "#ff0000"
+ }
+ Rectangle {
+ x: 0
+ y: 25
+ width: 25
+ height: 25
+ color: "#00ff00"
+ }
+ Rectangle {
+ x: 25
+ y: 25
+ width: 25
+ height: 25
+ color: "#0000ff"
+ }
+ }
+
+ // Layered box with effect. Mirroring should affect how it looks.
+ Rectangle {
+ id: layeredEffectBox
+ x: 50
+ y: 0
+ width: 50
+ height: 50
+ layer.enabled: true
+ layer.textureMirroring: mirroring
+ layer.samplerName: "source"
+ layer.effect: ShaderEffect {
+ property variant source: layeredEffectBox
+ fragmentShader: "
+ uniform lowp sampler2D source;
+ varying highp vec2 qt_TexCoord0;
+ void main() {
+ gl_FragColor = texture2D(source, qt_TexCoord0);
+ }"
+
+ }
+
+ Rectangle {
+ x: 0
+ y: 0
+ width: 25
+ height: 25
+ color: "#000000"
+ }
+ Rectangle {
+ x: 25
+ y: 0
+ width: 25
+ height: 25
+ color: "#ff0000"
+ }
+ Rectangle {
+ x: 0
+ y: 25
+ width: 25
+ height: 25
+ color: "#00ff00"
+ }
+ Rectangle {
+ x: 25
+ y: 25
+ width: 25
+ height: 25
+ color: "#0000ff"
+ }
+ }
+
+ // Non-layered source item for ShaderEffectSource. Mirroring should not affect how it looks.
+ Rectangle {
+ id: box2
+ x: 100
+ y: 0
+ width: 50
+ height: 50
+ Rectangle {
+ x: 0
+ y: 0
+ width: 25
+ height: 25
+ color: "#000000"
+ }
+ Rectangle {
+ x: 25
+ y: 0
+ width: 25
+ height: 25
+ color: "#ff0000"
+ }
+ Rectangle {
+ x: 0
+ y: 25
+ width: 25
+ height: 25
+ color: "#00ff00"
+ }
+ Rectangle {
+ x: 25
+ y: 25
+ width: 25
+ height: 25
+ color: "#0000ff"
+ }
+ }
+ // ShaderEffectSource item. Mirroring should not affect how it looks.
+ ShaderEffectSource {
+ id: theSource
+ x: 150
+ y: 0
+ width: 50
+ height: 50
+ sourceItem: box2
+ textureMirroring: mirroring
+ }
+ // ShaderEffect item. Mirroring should affect how it looks.
+ ShaderEffect {
+ x: 200
+ y: 0
+ width: 50
+ height: 50
+ property variant source: theSource
+ fragmentShader: "
+ uniform lowp sampler2D source;
+ varying highp vec2 qt_TexCoord0;
+ void main() {
+ gl_FragColor = texture2D(source, qt_TexCoord0);
+ }"
+ }
+}
diff --git a/tests/auto/quick/qquickitemlayer/qquickitemlayer.pro b/tests/auto/quick/qquickitemlayer/qquickitemlayer.pro
index 999f0cf23d..a087948f6d 100644
--- a/tests/auto/quick/qquickitemlayer/qquickitemlayer.pro
+++ b/tests/auto/quick/qquickitemlayer/qquickitemlayer.pro
@@ -25,5 +25,6 @@ OTHER_FILES += \
data/DisableLayer.qml \
data/SamplerNameChange.qml \
data/ItemEffect.qml \
- data/RectangleEffect.qml
+ data/RectangleEffect.qml \
+ data/TextureMirroring.qml
DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0
diff --git a/tests/auto/quick/qquickitemlayer/tst_qquickitemlayer.cpp b/tests/auto/quick/qquickitemlayer/tst_qquickitemlayer.cpp
index 25a75c0580..094b69c07f 100644
--- a/tests/auto/quick/qquickitemlayer/tst_qquickitemlayer.cpp
+++ b/tests/auto/quick/qquickitemlayer/tst_qquickitemlayer.cpp
@@ -87,7 +87,12 @@ private slots:
void itemEffect();
void rectangleEffect();
+ void textureMirroring_data();
+ void textureMirroring();
+
private:
+ void mirroringCheck(int mirroring, int x, bool shouldMirror, const QImage &fb);
+
bool m_isMesaSoftwareRasterizer;
int m_mesaVersion;
};
@@ -434,6 +439,94 @@ void tst_QQuickItemLayer::rectangleEffect()
QCOMPARE(fb.pixel(0, 100), qRgb(0, 0, 0xff));
}
+void tst_QQuickItemLayer::textureMirroring_data()
+{
+ QTest::addColumn<int>("mirroring");
+
+ QTest::newRow("no mirroring") << 0;
+ QTest::newRow("horizontal") << 1;
+ QTest::newRow("vertical") << 2;
+ QTest::newRow("horizontal | vertical") << 3;
+}
+
+void tst_QQuickItemLayer::textureMirroring()
+{
+ QFETCH(int, mirroring);
+
+ QQuickView view;
+ view.setSource(testFileUrl("TextureMirroring.qml"));
+
+ QQuickItem *child = view.contentItem()->childItems().at(0);
+ child->setProperty("mirroring", mirroring);
+
+ view.show();
+
+ QTest::qWaitForWindowExposed(&view);
+
+ QImage fb = view.grabWindow();
+
+ // Mirroring should have no visual effect on layered item without shader effect
+ mirroringCheck(mirroring, 0, false, fb);
+
+ // Mirroring should have visual effect on layered item with shader effect
+ mirroringCheck(mirroring, 50, true, fb);
+
+ // Mirroring should have no visual effect on source item for ShaderEffectSource
+ mirroringCheck(mirroring, 100, false, fb);
+
+ // Mirroring should have no visual effect on ShaderEffectSource item
+ mirroringCheck(mirroring, 150, false, fb);
+
+ // Mirroring should have visual effect on ShaderEffect item itself
+ mirroringCheck(mirroring, 200, true, fb);
+}
+
+void tst_QQuickItemLayer::mirroringCheck(int mirroring, int x, bool shouldMirror, const QImage &fb)
+{
+ int offset = 10;
+ int spacing = 25;
+
+ if (shouldMirror) {
+ switch (mirroring) {
+ case 0: { // No mirroring -> Visually Y gets swapped, X is default
+ QCOMPARE(fb.pixel(x + offset, offset), qRgb(0, 0xff, 0));
+ QCOMPARE(fb.pixel(x + offset + spacing, offset), qRgb(0, 0, 0xff));
+ QCOMPARE(fb.pixel(x + offset, offset + spacing), qRgb(0, 0, 0));
+ QCOMPARE(fb.pixel(x + offset + spacing, offset + spacing), qRgb(0xff, 0, 0));
+ break;
+ }
+ case 1: { // Horizontal mirroring -> Visually both X and Y get swapped, as neither is default
+ QCOMPARE(fb.pixel(x + offset, offset), qRgb(0, 0, 0xff));
+ QCOMPARE(fb.pixel(x + offset + spacing, offset), qRgb(0, 0xff, 0));
+ QCOMPARE(fb.pixel(x + offset, offset + spacing), qRgb(0xff, 0, 0));
+ QCOMPARE(fb.pixel(x + offset + spacing, offset + spacing), qRgb(0, 0, 0));
+ break;
+ }
+ case 2: { // Vertical mirroring -> The default case, nothing gets swapped
+ QCOMPARE(fb.pixel(x + offset, offset), qRgb(0, 0, 0));
+ QCOMPARE(fb.pixel(x + offset + spacing, offset), qRgb(0xff, 0, 0));
+ QCOMPARE(fb.pixel(x + offset, offset + spacing), qRgb(0, 0xff, 0));
+ QCOMPARE(fb.pixel(x + offset + spacing, offset + spacing), qRgb(0, 0, 0xff));
+ break;
+ }
+ case 3: { // Both axes mirrored -> Visually X gets swapped, Y is default
+ QCOMPARE(fb.pixel(x + offset, offset), qRgb(0xff, 0, 0));
+ QCOMPARE(fb.pixel(x + offset + spacing, offset), qRgb(0, 0, 0));
+ QCOMPARE(fb.pixel(x + offset, offset + spacing), qRgb(0, 0, 0xff));
+ QCOMPARE(fb.pixel(x + offset + spacing, offset + spacing), qRgb(0, 0xff, 0));
+ break;
+ }
+ default:
+ qWarning() << "Invalid case!";
+ break;
+ }
+ } else {
+ QCOMPARE(fb.pixel(x + offset, offset), qRgb(0, 0, 0));
+ QCOMPARE(fb.pixel(x + offset + spacing, offset), qRgb(0xff, 0, 0));
+ QCOMPARE(fb.pixel(x + offset, offset + spacing), qRgb(0, 0xff, 0));
+ QCOMPARE(fb.pixel(x + offset + spacing, offset + spacing), qRgb(0, 0, 0xff));
+ }
+}
QTEST_MAIN(tst_QQuickItemLayer)
diff --git a/tests/auto/quick/qquicklistview/BLACKLIST b/tests/auto/quick/qquicklistview/BLACKLIST
new file mode 100644
index 0000000000..269696ce8c
--- /dev/null
+++ b/tests/auto/quick/qquicklistview/BLACKLIST
@@ -0,0 +1,4 @@
+[QTBUG_38209]
+*
+[enforceRange_withoutHighlight]
+osx
diff --git a/tests/auto/quick/qquicklistview/data/contentHeightWithDelayRemove.qml b/tests/auto/quick/qquicklistview/data/contentHeightWithDelayRemove.qml
new file mode 100644
index 0000000000..06011519b2
--- /dev/null
+++ b/tests/auto/quick/qquicklistview/data/contentHeightWithDelayRemove.qml
@@ -0,0 +1,46 @@
+import QtQuick 2.1
+
+Item {
+ width: 400
+ height: 600
+ function takeOne()
+ {
+ listView.model.remove(2)
+ }
+ function takeThree()
+ {
+ listView.model.remove(4)
+ listView.model.remove(2)
+ listView.model.remove(0)
+ }
+ function takeAll()
+ {
+ listView.model.clear()
+ }
+
+ ListView {
+ id: listView
+
+ property bool useDelayRemove
+
+ height: parent.height
+ width: 400
+ model: ListModel {
+ ListElement { name: "A" }
+ ListElement { name: "B" }
+ ListElement { name: "C" }
+ ListElement { name: "D" }
+ ListElement { name: "E" }
+ }
+ delegate: Text {
+ id: wrapper
+ height: 100
+ text: index + listView.count
+ ListView.delayRemove: listView.useDelayRemove
+ ListView.onRemove: SequentialAnimation {
+ PauseAnimation { duration: wrapper.ListView.delayRemove ? 100 : 0 }
+ PropertyAction { target: wrapper; property: "ListView.delayRemove"; value: false }
+ }
+ }
+ }
+}
diff --git a/tests/auto/quick/qquicklistview/data/listview-initCurrent.qml b/tests/auto/quick/qquicklistview/data/listview-initCurrent.qml
index a02b66b8af..8aff649a67 100644
--- a/tests/auto/quick/qquicklistview/data/listview-initCurrent.qml
+++ b/tests/auto/quick/qquicklistview/data/listview-initCurrent.qml
@@ -6,6 +6,7 @@ Rectangle {
property int current: list.currentIndex
property bool showHeader: false
property bool showFooter: false
+ property int currentItemChangedCount: 0
width: 240
height: 320
@@ -60,5 +61,7 @@ Rectangle {
model: testModel
header: root.showHeader ? headerFooter : null
footer: root.showFooter ? headerFooter : null
+
+ onCurrentItemChanged: { root.currentItemChangedCount++ }
}
}
diff --git a/tests/auto/quick/qquicklistview/data/objectmodel.qml b/tests/auto/quick/qquicklistview/data/objectmodel.qml
new file mode 100644
index 0000000000..5c23d64cd3
--- /dev/null
+++ b/tests/auto/quick/qquicklistview/data/objectmodel.qml
@@ -0,0 +1,24 @@
+import QtQuick 2.0
+import QtQml.Models 2.1
+
+ListView {
+ width: 360
+ height: 360
+ model: ObjectModel {
+ Rectangle {
+ width: 20
+ height: 20
+ color: "red"
+ }
+ Rectangle {
+ width: 20
+ height: 20
+ color: "green"
+ }
+ Rectangle {
+ width: 20
+ height: 20
+ color: "blue"
+ }
+ }
+}
diff --git a/tests/auto/quick/qquicklistview/data/qtbug48044.qml b/tests/auto/quick/qquicklistview/data/qtbug48044.qml
new file mode 100644
index 0000000000..d318643c1c
--- /dev/null
+++ b/tests/auto/quick/qquicklistview/data/qtbug48044.qml
@@ -0,0 +1,144 @@
+import QtQuick 2.0
+
+Item {
+ width: 200
+ height: 442
+
+ ListModel {
+ id: listModel
+ ListElement {
+ name: "h1"
+ txt: "Header 1"
+ header: true
+ collapsed: true
+ }
+ ListElement {
+ name: "h2"
+ txt: "Header 2"
+ header: true
+ collapsed: true
+ }
+ ListElement {
+ name: "h3"
+ txt: "Header 3"
+ header: true
+ collapsed: true
+ }
+
+ function indexFromName(name) {
+ for (var i = 0; i < count; i++)
+ if (get(i).name === name)
+ return i
+
+ console.warn("Did not find index for name " + name)
+ return -1
+ }
+ }
+
+ function populateModel(prefix, index, n) {
+ for (var k = 1; k <= n; k++) {
+ var name = prefix + k
+ var data = {
+ "collapsed": false,
+ "name": name,
+ "txt": name,
+ "header": false
+ }
+ listModel.insert(index + k, data)
+ }
+ }
+
+ function h2(open) {
+ var i = listModel.indexFromName("h2")
+ if (listModel.get(i).collapsed === !open)
+ return
+
+ listModel.setProperty(i, "collapsed", !open)
+
+ var n = 15
+ if (open) {
+ h3(false)
+ populateModel("c2_", listModel.indexFromName("h2"), n)
+ } else {
+ listModel.remove(i + 1, n)
+ }
+
+ }
+
+ function h3(open) {
+ var i = listModel.indexFromName("h3")
+ if (listModel.get(i).collapsed === !open)
+ return
+
+ listModel.setProperty(i, "collapsed", !open)
+
+ var n = 6
+ if (open) {
+ h2(false)
+ populateModel("c3_", listModel.indexFromName("h3"), n)
+ } else {
+ listModel.remove(i + 1, n)
+ }
+ }
+
+ ListView {
+ id: listView
+ width: parent.width
+ height: parent.height
+ cacheBuffer: 0
+ model: listModel
+
+ property bool transitionsDone: false
+ property int runningTransitions: 0
+ onRunningTransitionsChanged: {
+ if (runningTransitions === 0)
+ transitionsDone = true
+ }
+
+ displaced: Transition {
+ id: dispTrans
+ SequentialAnimation {
+ ScriptAction {
+ script: listView.runningTransitions++
+ }
+ NumberAnimation {
+ property: "y";
+ duration: 250
+ }
+ ScriptAction {
+ script: listView.runningTransitions--
+ }
+ }
+ }
+
+ delegate: Rectangle {
+ id: rect
+ color: header ? "yellow" : "cyan"
+ border.color: "black"
+ height: 50
+ width: parent.width
+
+ Text {
+ anchors.centerIn: parent
+ font.pixelSize: 20
+ text: txt
+ }
+
+ MouseArea {
+ anchors.fill: parent
+ onClicked: {
+ listView.currentIndex = index
+ var i = listModel.indexFromName("h3")
+ if (i === -1)
+ return;
+ var isCollapsed = listModel.get(i).collapsed
+ if (name === "h2")
+ h2(isCollapsed)
+ else if (name === "h3")
+ h3(isCollapsed)
+ }
+ }
+ }
+ }
+}
+
diff --git a/tests/auto/quick/qquicklistview/data/qtbug48870.qml b/tests/auto/quick/qquicklistview/data/qtbug48870.qml
new file mode 100644
index 0000000000..217f58af48
--- /dev/null
+++ b/tests/auto/quick/qquicklistview/data/qtbug48870.qml
@@ -0,0 +1,24 @@
+import QtQuick 2.6
+
+Rectangle {
+ width: 500
+ height: 500
+ color: "blue"
+
+ ListView {
+ objectName: "list"
+ anchors.fill: parent
+ model: testModel
+
+ delegate: Rectangle {
+ height: 50
+ width: ListView.view ? ListView.view.width : height
+ color: "green"
+
+ Text {
+ anchors.centerIn: parent
+ text: "Item " + index
+ }
+ }
+ }
+}
diff --git a/tests/auto/quick/qquicklistview/data/qtbug50097.qml b/tests/auto/quick/qquicklistview/data/qtbug50097.qml
new file mode 100644
index 0000000000..24d506b804
--- /dev/null
+++ b/tests/auto/quick/qquicklistview/data/qtbug50097.qml
@@ -0,0 +1,47 @@
+import QtQuick 2.6
+
+ListView {
+ id: lv
+
+ // How many rows per page
+ property int pageSize: 5
+
+ // The current page number
+ property int currentPage: 1
+
+ // How large a single item is
+ property int itemSize: 100
+
+ // Arbitrary
+ property int totalPages: 5
+
+ height: itemSize * pageSize // display one full page at a time
+ width: 500 // arbitrary.
+ model: pageSize * totalPages
+ delegate: Text {
+ height: itemSize
+ text: "Item " + (index + 1) + " of " + lv.count
+ }
+
+ // contentY should be < 0 to account for header visibility
+ onContentYChanged: console.log(contentY)
+
+ headerPositioning: ListView.OverlayHeader
+ header: Rectangle {
+ height: itemSize
+ width: 500
+ z: 1000
+ visible: false
+ color: "black"
+
+ Text {
+ anchors.centerIn: parent
+ color: "red"
+ text: "List header"
+ }
+ }
+
+ onCurrentPageChanged: {
+ lv.positionViewAtIndex((currentPage - 1) * pageSize, ListView.Beginning);
+ }
+}
diff --git a/tests/auto/quick/qquicklistview/data/qtbug50105.qml b/tests/auto/quick/qquicklistview/data/qtbug50105.qml
new file mode 100644
index 0000000000..a48a881a21
--- /dev/null
+++ b/tests/auto/quick/qquicklistview/data/qtbug50105.qml
@@ -0,0 +1,130 @@
+import QtQuick 2.4
+import QtQuick.Window 2.2
+
+Window {
+ id : mainWindow
+ visible: true
+ width: 800
+ height: 480
+
+ property real gridListWidth : (width * 0.60)
+ property real gridListHeight : (height * 0.50)
+
+ property real gridCellSpacing : (height * 0.004)
+ property real gridCellHeight : (height * 0.039)
+ property real gridCellWidth : (width * 0.20)
+
+ Rectangle {
+ id : rectBackground
+ anchors.fill: parent
+ color : "white"
+
+ ListView {
+ id : ls
+ width: mainWindow.gridListWidth
+ height: mainWindow.gridListHeight
+ clip : true
+ headerPositioning: ListView.OverlayHeader
+ spacing : mainWindow.gridCellSpacing
+
+ model: ListModel {
+ ListElement {
+ name: "Bill Smith"
+ number: "555 3264"
+ hairColor: "red"
+ }
+ ListElement {
+ name: "John Brown"
+ number: "484 7789"
+ hairColor: "blue"
+ }
+ ListElement {
+ name: "Sam Wise"
+ number: "284 1547"
+ hairColor: "yellow"
+ }
+ }
+
+ header : Row {
+ spacing : mainWindow.gridCellSpacing
+
+ Rectangle {
+ width : mainWindow.gridCellWidth
+ height : mainWindow.gridCellHeight
+ color : "blue"
+
+ Text {
+ anchors.centerIn: parent
+ color : "white"
+ text: "Name"
+ }
+ }
+
+ Rectangle {
+ width : mainWindow.gridCellWidth
+ height : mainWindow.gridCellHeight
+ color : "blue"
+
+ Text {
+ anchors.centerIn: parent
+ color : "white"
+ text: "Number"
+ }
+
+ }
+
+ Rectangle {
+ width : mainWindow.gridCellWidth
+ height : mainWindow.gridCellHeight
+ color : "blue"
+
+ Text {
+ anchors.centerIn: parent
+ color : "white"
+ text: "Hair Color"
+ }
+ }
+ }
+
+ delegate: Row {
+ spacing : mainWindow.gridCellSpacing
+
+ Rectangle {
+ width : mainWindow.gridCellWidth
+ height : mainWindow.gridCellHeight
+ color : "red"
+
+ Text {
+ anchors.centerIn: parent
+ color : "white"
+ text: name
+ }
+ }
+
+ Rectangle {
+ width : mainWindow.gridCellWidth
+ height : mainWindow.gridCellHeight
+ color : "red"
+
+ Text {
+ anchors.centerIn: parent
+ color : "white"
+ text: number
+ }
+ }
+
+ Rectangle {
+ width : mainWindow.gridCellWidth
+ height : mainWindow.gridCellHeight
+ color : "red"
+
+ Text {
+ anchors.centerIn: parent
+ color : "white"
+ text: hairColor
+ }
+ }
+ }
+ }
+ }
+}
diff --git a/tests/auto/quick/qquicklistview/data/snapOneItemCurrentIndexRemoveAnimation.qml b/tests/auto/quick/qquicklistview/data/snapOneItemCurrentIndexRemoveAnimation.qml
new file mode 100644
index 0000000000..215467f0cc
--- /dev/null
+++ b/tests/auto/quick/qquicklistview/data/snapOneItemCurrentIndexRemoveAnimation.qml
@@ -0,0 +1,39 @@
+import QtQuick 2.4
+
+ListView {
+ id: root
+ height: 400
+ width: height
+ model: ListModel {
+ id: lmodel
+ ListElement { dummy: 0 }
+ ListElement { dummy: 0 }
+ ListElement { dummy: 0 }
+ ListElement { dummy: 0 }
+ ListElement { dummy: 0 }
+ ListElement { dummy: 0 }
+ }
+
+ function removeItemZero()
+ {
+ lmodel.remove(0);
+ }
+
+ orientation: ListView.Horizontal
+ snapMode: ListView.SnapOneItem
+ highlightRangeMode: ListView.StrictlyEnforceRange
+
+ property int transitionsRun: 0
+
+ removeDisplaced: Transition {
+ id: transition
+ PropertyAnimation { property: "x"; duration: 500 }
+ onRunningChanged: if (!running) transitionsRun++;
+ }
+
+ delegate: Text {
+ text: index + " of " + lmodel.count
+ width: root.width
+ height: root.height
+ }
+} \ No newline at end of file
diff --git a/tests/auto/quick/qquicklistview/data/snapOneItemResize.qml b/tests/auto/quick/qquicklistview/data/snapOneItemResize.qml
new file mode 100644
index 0000000000..7ecc833a64
--- /dev/null
+++ b/tests/auto/quick/qquicklistview/data/snapOneItemResize.qml
@@ -0,0 +1,16 @@
+import QtQuick 2.0
+
+ListView {
+ id: list
+ currentIndex: 5
+ snapMode: ListView.SnapOneItem
+ orientation: ListView.Horizontal
+ highlightRangeMode: ListView.StrictlyEnforceRange
+ highlightFollowsCurrentItem: true
+ model: 10
+ spacing: 10
+ delegate: Item {
+ width: ListView.view.width
+ height: ListView.view.height
+ }
+}
diff --git a/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp b/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp
index c93aac456d..12405e32c0 100644
--- a/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp
+++ b/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp
@@ -40,6 +40,7 @@
#include <QtQml/qqmlcontext.h>
#include <QtQml/qqmlexpression.h>
#include <QtQml/qqmlincubator.h>
+#include <QtQuick/private/qquickitemview_p_p.h>
#include <QtQuick/private/qquicklistview_p.h>
#include <QtQuick/private/qquicktext_p.h>
#include <QtQml/private/qqmlobjectmodel_p.h>
@@ -179,8 +180,10 @@ private slots:
void creationContext();
void snapToItem_data();
void snapToItem();
+ void snapOneItemResize_QTBUG_43555();
void snapOneItem_data();
void snapOneItem();
+ void snapOneItemCurrentIndexRemoveAnimation();
void QTBUG_9791();
void QTBUG_11105();
@@ -241,6 +244,16 @@ private slots:
void QTBUG_39492();
void jsArrayChange();
+ void objectModel();
+
+ void contentHeightWithDelayRemove();
+ void contentHeightWithDelayRemove_data();
+
+ void QTBUG_48044_currentItemNotVisibleAfterTransition();
+ void QTBUG_48870_fastModelUpdates();
+
+ void QTBUG_50105();
+ void QTBUG_50097_stickyHeader_positionViewAtIndex();
private:
template <class T> void items(const QUrl &source);
@@ -391,7 +404,7 @@ void tst_QQuickListView::items(const QUrl &source)
QTRY_VERIFY(contentItem != 0);
QMetaObject::invokeMethod(window->rootObject(), "checkProperties");
- QTRY_VERIFY(testObject->error() == false);
+ QTRY_VERIFY(!testObject->error());
QTRY_VERIFY(listview->highlightItem() != 0);
QTRY_COMPARE(listview->count(), model.count());
@@ -414,20 +427,20 @@ void tst_QQuickListView::items(const QUrl &source)
// switch to other delegate
testObject->setAnimate(true);
QMetaObject::invokeMethod(window->rootObject(), "checkProperties");
- QTRY_VERIFY(testObject->error() == false);
+ QTRY_VERIFY(!testObject->error());
QTRY_VERIFY(listview->currentItem());
// set invalid highlight
testObject->setInvalidHighlight(true);
QMetaObject::invokeMethod(window->rootObject(), "checkProperties");
- QTRY_VERIFY(testObject->error() == false);
+ QTRY_VERIFY(!testObject->error());
QTRY_VERIFY(listview->currentItem());
- QTRY_VERIFY(listview->highlightItem() == 0);
+ QTRY_VERIFY(!listview->highlightItem());
// back to normal highlight
testObject->setInvalidHighlight(false);
QMetaObject::invokeMethod(window->rootObject(), "checkProperties");
- QTRY_VERIFY(testObject->error() == false);
+ QTRY_VERIFY(!testObject->error());
QTRY_VERIFY(listview->currentItem());
QTRY_VERIFY(listview->highlightItem() != 0);
@@ -439,7 +452,7 @@ void tst_QQuickListView::items(const QUrl &source)
listview->forceLayout();
int itemCount = findItems<QQuickItem>(contentItem, "wrapper").count();
- QTRY_VERIFY(itemCount == 0);
+ QTRY_COMPARE(itemCount, 0);
QTRY_COMPARE(listview->highlightResizeVelocity(), 1000.0);
QTRY_COMPARE(listview->highlightMoveVelocity(), 100000.0);
@@ -563,7 +576,7 @@ void tst_QQuickListView::inserted(const QUrl &source)
// Insert item outside visible area
model.insertItem(1, "Hello", "1324");
- QTRY_VERIFY(listview->contentY() == 80);
+ QTRY_COMPARE(listview->contentY(), qreal(80));
// Confirm items positioned correctly
for (int i = 5; i < 5+15; ++i) {
@@ -582,8 +595,7 @@ void tst_QQuickListView::inserted(const QUrl &source)
QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", 0);
QVERIFY(item);
- QCOMPARE(item->y(), 0.);
- QTRY_VERIFY(listview->contentY() == 0);
+ QTRY_COMPARE(item->y() - listview->contentY(), 0.);
delete window;
delete testObject;
@@ -634,7 +646,8 @@ void tst_QQuickListView::inserted_more(QQuickItemView::VerticalLayoutDirection v
QTRY_COMPARE(listview->property("count").toInt(), model.count());
-
+ // FIXME This is NOT checking anything about visibleItems.first()
+#if 0
// check visibleItems.first() is in correct position
QQuickItem *item0 = findItem<QQuickItem>(contentItem, "wrapper", 0);
QVERIFY(item0);
@@ -642,6 +655,7 @@ void tst_QQuickListView::inserted_more(QQuickItemView::VerticalLayoutDirection v
QCOMPARE(item0->y(), -item0->height() - itemsOffsetAfterMove);
else
QCOMPARE(item0->y(), itemsOffsetAfterMove);
+#endif
QList<QQuickItem*> items = findItems<QQuickItem>(contentItem, "wrapper");
int firstVisibleIndex = -1;
@@ -657,12 +671,21 @@ void tst_QQuickListView::inserted_more(QQuickItemView::VerticalLayoutDirection v
// Confirm items positioned correctly and indexes correct
QQuickText *name;
QQuickText *number;
+ const qreal visibleFromPos = listview->contentY() - listview->displayMarginBeginning() - listview->cacheBuffer();
+ const qreal visibleToPos = listview->contentY() + listview->height() + listview->displayMarginEnd() + listview->cacheBuffer();
for (int i = firstVisibleIndex; i < model.count() && i < items.count(); ++i) {
QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
QVERIFY2(item, QTest::toString(QString("Item %1 not found").arg(i)));
qreal pos = i*20.0 + itemsOffsetAfterMove;
if (verticalLayoutDirection == QQuickItemView::BottomToTop)
- pos = -item0->height() - pos;
+ pos = -item->height() - pos;
+ // Items outside the visible area (including cache buffer) should be skipped
+ if (pos > visibleToPos || pos < visibleFromPos) {
+ QTRY_VERIFY2(QQuickItemPrivate::get(item)->culled || item->y() < visibleFromPos || item->y() > visibleToPos,
+ QTest::toString(QString("index %5, y %1, from %2, to %3, expected pos %4, culled %6").
+ arg(item->y()).arg(visibleFromPos).arg(visibleToPos).arg(pos).arg(i).arg(bool(QQuickItemPrivate::get(item)->culled))));
+ continue;
+ }
QTRY_COMPARE(item->y(), pos);
name = findItem<QQuickText>(contentItem, "textName", i);
QVERIFY(name != 0);
@@ -916,7 +939,7 @@ void tst_QQuickListView::removed(const QUrl &source, bool /* animated */)
QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
if (!item) qWarning() << "Item" << i << "not found";
QTRY_VERIFY(item);
- QTRY_VERIFY(item->y() == i*20);
+ QTRY_COMPARE(item->y(), qreal(i*20));
}
// Remove first item (which is the current item);
@@ -968,7 +991,7 @@ void tst_QQuickListView::removed(const QUrl &source, bool /* animated */)
}
// Remove current index
- QTRY_VERIFY(listview->currentIndex() == 9);
+ QTRY_COMPARE(listview->currentIndex(), 9);
QQuickItem *oldCurrent = listview->currentItem();
model.removeItem(9);
@@ -1004,7 +1027,7 @@ void tst_QQuickListView::removed(const QUrl &source, bool /* animated */)
model.removeItem(6);
QTRY_COMPARE(listview->currentIndex(), 7);
- QTRY_VERIFY(listview->currentItem() == oldCurrent);
+ QTRY_COMPARE(listview->currentItem(), oldCurrent);
listview->setContentY(80);
QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
@@ -1272,22 +1295,22 @@ void tst_QQuickListView::clear(const QUrl &source, QQuickItemView::VerticalLayou
model.clear();
QTRY_COMPARE(findItems<QQuickListView>(contentItem, "wrapper").count(), 0);
- QTRY_VERIFY(listview->count() == 0);
- QTRY_VERIFY(listview->currentItem() == 0);
+ QTRY_COMPARE(listview->count(), 0);
+ QTRY_VERIFY(!listview->currentItem());
if (verticalLayoutDirection == QQuickItemView::TopToBottom)
QTRY_COMPARE(listview->contentY(), 0.0);
else
QTRY_COMPARE(listview->contentY(), -listview->height());
- QVERIFY(listview->currentIndex() == -1);
+ QCOMPARE(listview->currentIndex(), -1);
QCOMPARE(listview->contentHeight(), 0.0);
// confirm sanity when adding an item to cleared list
model.addItem("New", "1");
listview->forceLayout();
- QTRY_VERIFY(listview->count() == 1);
+ QTRY_COMPARE(listview->count(), 1);
QVERIFY(listview->currentItem() != 0);
- QVERIFY(listview->currentIndex() == 0);
+ QCOMPARE(listview->currentIndex(), 0);
delete window;
delete testObject;
@@ -1805,7 +1828,7 @@ void tst_QQuickListView::swapWithFirstItem()
// ensure content position is stable
listview->setContentY(0);
model.moveItem(1, 0);
- QTRY_VERIFY(listview->contentY() == 0);
+ QTRY_COMPARE(listview->contentY(), qreal(0));
delete testObject;
delete window;
@@ -1943,11 +1966,11 @@ void tst_QQuickListView::spacing()
QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
if (!item) qWarning() << "Item" << i << "not found";
QTRY_VERIFY(item);
- QTRY_VERIFY(item->y() == i*20);
+ QTRY_COMPARE(item->y(), qreal(i*20));
}
listview->setSpacing(10);
- QTRY_VERIFY(listview->spacing() == 10);
+ QTRY_COMPARE(listview->spacing(), qreal(10));
// Confirm items positioned correctly
QTRY_VERIFY(findItems<QQuickItem>(contentItem, "wrapper").count() == 11);
@@ -1955,7 +1978,7 @@ void tst_QQuickListView::spacing()
QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
if (!item) qWarning() << "Item" << i << "not found";
QTRY_VERIFY(item);
- QTRY_VERIFY(item->y() == i*30);
+ QTRY_COMPARE(item->y(), qreal(i*30));
}
listview->setSpacing(0);
@@ -2261,7 +2284,7 @@ void tst_QQuickListView::sectionsDelegate_headerVisibility()
listview->setCurrentIndex(20);
QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
QTRY_VERIFY(qFuzzyCompare(listview->contentY(), 200.0));
- QTRY_VERIFY(listview->isMoving() == false);
+ QTRY_VERIFY(!listview->isMoving());
listview->setCurrentIndex(0);
QTRY_VERIFY(qFuzzyIsNull(listview->contentY()));
@@ -2682,7 +2705,7 @@ void tst_QQuickListView::currentIndex()
listview->setCurrentIndex(20);
QTRY_VERIFY(listview->verticalVelocity() != 0.0);
listview->setCurrentIndex(0);
- QTRY_VERIFY(listview->verticalVelocity() == 0.0);
+ QTRY_COMPARE(listview->verticalVelocity(), 0.0);
// footer should become visible if it is out of view, and then current index is set to count-1
window->rootObject()->setProperty("showFooter", true);
@@ -2704,7 +2727,7 @@ void tst_QQuickListView::currentIndex()
// turn off auto highlight
listview->setHighlightFollowsCurrentItem(false);
- QVERIFY(listview->highlightFollowsCurrentItem() == false);
+ QVERIFY(!listview->highlightFollowsCurrentItem());
QVERIFY(listview->highlightItem());
qreal hlPos = listview->highlightItem()->y();
@@ -2713,9 +2736,12 @@ void tst_QQuickListView::currentIndex()
QTRY_COMPARE(listview->highlightItem()->y(), hlPos);
// insert item before currentIndex
+ window->rootObject()->setProperty("currentItemChangedCount", QVariant(0));
listview->setCurrentIndex(28);
+ QTRY_COMPARE(window->rootObject()->property("currentItemChangedCount").toInt(), 1);
model.insertItem(0, "Foo", "1111");
QTRY_COMPARE(window->rootObject()->property("current").toInt(), 29);
+ QCOMPARE(window->rootObject()->property("currentItemChangedCount").toInt(), 1);
// check removing highlight by setting currentIndex to -1;
listview->setCurrentIndex(-1);
@@ -2808,7 +2834,7 @@ void tst_QQuickListView::keyNavigation()
window->requestActivate();
QTest::qWaitForWindowActive(window);
- QTRY_VERIFY(qGuiApp->focusWindow() == window);
+ QTRY_COMPARE(qGuiApp->focusWindow(), window);
QTest::keyClick(window, forwardsKey);
QCOMPARE(listview->currentIndex(), 1);
@@ -2917,7 +2943,7 @@ void tst_QQuickListView::itemList()
QQmlObjectModel *model = window->rootObject()->findChild<QQmlObjectModel*>("itemModel");
QTRY_VERIFY(model != 0);
- QTRY_VERIFY(model->count() == 3);
+ QTRY_COMPARE(model->count(), 3);
QTRY_COMPARE(listview->currentIndex(), 0);
QQuickItem *item = findItem<QQuickItem>(contentItem, "item1");
@@ -2958,7 +2984,7 @@ void tst_QQuickListView::itemListFlicker()
QQmlObjectModel *model = window->rootObject()->findChild<QQmlObjectModel*>("itemModel");
QTRY_VERIFY(model != 0);
- QTRY_VERIFY(model->count() == 3);
+ QTRY_COMPARE(model->count(), 3);
QTRY_COMPARE(listview->currentIndex(), 0);
QQuickItem *item;
@@ -3024,14 +3050,14 @@ void tst_QQuickListView::cacheBuffer()
QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
if (!item) qWarning() << "Item" << i << "not found";
QTRY_VERIFY(item);
- QTRY_VERIFY(item->y() == i*20);
+ QTRY_COMPARE(item->y(), qreal(i*20));
}
QQmlIncubationController controller;
window->engine()->setIncubationController(&controller);
testObject->setCacheBuffer(200);
- QTRY_VERIFY(listview->cacheBuffer() == 200);
+ QTRY_COMPARE(listview->cacheBuffer(), 200);
// items will be created one at a time
for (int i = itemCount; i < qMin(itemCount+10,model.count()); ++i) {
@@ -3057,7 +3083,7 @@ void tst_QQuickListView::cacheBuffer()
QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
if (!item) qWarning() << "Item" << i << "not found";
QTRY_VERIFY(item);
- QTRY_VERIFY(item->y() == i*20);
+ QTRY_COMPARE(item->y(), qreal(i*20));
}
// move view and confirm items in view are visible immediately and outside are created async
@@ -3067,7 +3093,7 @@ void tst_QQuickListView::cacheBuffer()
QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
if (!item) qWarning() << "Item" << i << "not found";
QVERIFY(item);
- QVERIFY(item->y() == i*20);
+ QCOMPARE(item->y(), qreal(i*20));
}
QVERIFY(findItem<QQuickItem>(listview, "wrapper", 32) == 0);
@@ -3528,7 +3554,7 @@ void tst_QQuickListView::QTBUG_11105()
QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
if (!item) qWarning() << "Item" << i << "not found";
QTRY_VERIFY(item);
- QTRY_VERIFY(item->y() == i*20);
+ QTRY_COMPARE(item->y(), qreal(i*20));
}
listview->positionViewAtIndex(20, QQuickListView::Beginning);
@@ -3622,7 +3648,7 @@ void tst_QQuickListView::header()
QQuickText *header = 0;
QTRY_VERIFY(header = findItem<QQuickText>(contentItem, "header"));
- QVERIFY(header == listview->headerItem());
+ QCOMPARE(header, listview->headerItem());
QCOMPARE(header->width(), 100.);
QCOMPARE(header->height(), 30.);
@@ -3660,7 +3686,7 @@ void tst_QQuickListView::header()
header = findItem<QQuickText>(contentItem, "header2");
QVERIFY(header);
- QVERIFY(header == listview->headerItem());
+ QCOMPARE(header, listview->headerItem());
QCOMPARE(header->position(), changedHeaderPos);
QCOMPARE(header->width(), 50.);
@@ -3811,7 +3837,7 @@ void tst_QQuickListView::headerChangesViewport()
QQuickText *header = 0;
QTRY_VERIFY(header = findItem<QQuickText>(contentItem, "header"));
- QVERIFY(header == listview->headerItem());
+ QCOMPARE(header, listview->headerItem());
QCOMPARE(header->height(), 20.);
QCOMPARE(listview->contentHeight(), 20.);
@@ -3862,7 +3888,7 @@ void tst_QQuickListView::footer()
QQuickText *footer = findItem<QQuickText>(contentItem, "footer");
QVERIFY(footer);
- QVERIFY(footer == listview->footerItem());
+ QCOMPARE(footer, listview->footerItem());
QCOMPARE(footer->position(), initialFooterPos);
QCOMPARE(footer->width(), 100.);
@@ -3922,7 +3948,7 @@ void tst_QQuickListView::footer()
footer = findItem<QQuickText>(contentItem, "footer2");
QVERIFY(footer);
- QVERIFY(footer == listview->footerItem());
+ QCOMPARE(footer, listview->footerItem());
QCOMPARE(footer->position(), changedFooterPos);
QCOMPARE(footer->width(), 50.);
@@ -4155,11 +4181,11 @@ void tst_QQuickListView::resetModel_headerFooter()
// A reset should not force a new header or footer to be created.
QQuickItem *newHeader = findItem<QQuickItem>(contentItem, "header");
- QVERIFY(newHeader == header);
+ QCOMPARE(newHeader, header);
QCOMPARE(header->y(), -header->height());
QQuickItem *newFooter = findItem<QQuickItem>(contentItem, "footer");
- QVERIFY(newFooter == footer);
+ QCOMPARE(newFooter, footer);
QCOMPARE(footer->y(), 30.*4);
delete window;
@@ -4664,7 +4690,7 @@ void tst_QQuickListView::indexAt_itemAt()
QVERIFY(item);
}
QCOMPARE(listview->indexAt(x,y), index);
- QVERIFY(listview->itemAt(x,y) == item);
+ QCOMPARE(listview->itemAt(x,y), item);
releaseView(window);
delete testObject;
@@ -4828,7 +4854,7 @@ void tst_QQuickListView::rightToLeft()
QQmlObjectModel *model = window->rootObject()->findChild<QQmlObjectModel*>("itemModel");
QTRY_VERIFY(model != 0);
- QTRY_VERIFY(model->count() == 3);
+ QTRY_COMPARE(model->count(), 3);
QTRY_COMPARE(listview->currentIndex(), 0);
// initial position at first item, right edge aligned
@@ -4893,7 +4919,7 @@ void tst_QQuickListView::test_mirroring()
foreach (const QString objectName, objectNames)
QCOMPARE(findItem<QQuickItem>(listviewA, objectName)->x(), findItem<QQuickItem>(listviewB, objectName)->x());
- QVERIFY(listviewB->layoutDirection() == listviewB->effectiveLayoutDirection());
+ QCOMPARE(listviewB->layoutDirection(), listviewB->effectiveLayoutDirection());
QQuickItemPrivate::get(listviewB)->setLayoutMirror(true);
QVERIFY(listviewB->layoutDirection() != listviewB->effectiveLayoutDirection());
@@ -5034,7 +5060,7 @@ void tst_QQuickListView::marginsResize()
// flick past the end and check content pos still settles on correct extents
flick(window, flickStart, flickEnd, 180);
- QTRY_VERIFY(listview->isMoving() == false);
+ QTRY_VERIFY(!listview->isMoving());
if (orientation == QQuickListView::Vertical)
QTRY_COMPARE(listview->contentY(), end);
else
@@ -5049,7 +5075,7 @@ void tst_QQuickListView::marginsResize()
// flick past the beginning and check content pos still settles on correct extents
flick(window, flickEnd, flickStart, 180);
- QTRY_VERIFY(listview->isMoving() == false);
+ QTRY_VERIFY(!listview->isMoving());
if (orientation == QQuickListView::Vertical)
QTRY_COMPARE(listview->contentY(), start);
else
@@ -5199,6 +5225,37 @@ void tst_QQuickListView::snapToItem()
releaseView(window);
}
+void tst_QQuickListView::snapOneItemResize_QTBUG_43555()
+{
+ QQuickView *window = createView();
+ window->resize(QSize(100, 320));
+ window->setResizeMode(QQuickView::SizeRootObjectToView);
+ QQuickViewTestUtil::moveMouseAway(window);
+
+ window->setSource(testFileUrl("snapOneItemResize.qml"));
+ window->show();
+ QVERIFY(QTest::qWaitForWindowExposed(window));
+
+ QQuickListView *listview = qobject_cast<QQuickListView*>(window->rootObject());
+ QTRY_VERIFY(listview != 0);
+
+ QSignalSpy currentIndexSpy(listview, SIGNAL(currentIndexChanged()));
+
+ QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
+ QTRY_COMPARE(listview->currentIndex(), 5);
+ currentIndexSpy.clear();
+
+ window->resize(QSize(400, 320));
+
+ QTRY_COMPARE(int(listview->width()), 400);
+ QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
+
+ QTRY_COMPARE(listview->currentIndex(), 5);
+ QCOMPARE(currentIndexSpy.count(), 0);
+
+ delete window;
+}
+
void tst_QQuickListView::qAbstractItemModel_package_items()
{
items<QaimModel>(testFileUrl("listviewtest-package.qml"));
@@ -5546,6 +5603,32 @@ void tst_QQuickListView::snapOneItem()
releaseView(window);
}
+void tst_QQuickListView::snapOneItemCurrentIndexRemoveAnimation()
+{
+ QQuickView *window = createView();
+
+ window->setSource(testFileUrl("snapOneItemCurrentIndexRemoveAnimation.qml"));
+ window->show();
+ QVERIFY(QTest::qWaitForWindowExposed(window));
+
+ QQuickListView *listview = qobject_cast<QQuickListView*>(window->rootObject());
+ QTRY_VERIFY(listview != 0);
+
+ QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
+ QTRY_COMPARE(listview->currentIndex(), 0);
+ QSignalSpy currentIndexSpy(listview, SIGNAL(currentIndexChanged()));
+
+ QMetaObject::invokeMethod(window->rootObject(), "removeItemZero");
+ QTRY_COMPARE(listview->property("transitionsRun").toInt(), 1);
+
+ QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
+
+ QCOMPARE(listview->currentIndex(), 0);
+ QCOMPARE(currentIndexSpy.count(), 0);
+
+ delete window;
+}
+
void tst_QQuickListView::attachedProperties_QTBUG_32836()
{
QQuickView *window = createView();
@@ -7006,7 +7089,7 @@ void tst_QQuickListView::matchIndexLists(const QVariantList &indexLists, const Q
void tst_QQuickListView::matchItemsAndIndexes(const QVariantMap &items, const QaimModel &model, const QList<int> &expectedIndexes)
{
for (QVariantMap::const_iterator it = items.begin(); it != items.end(); ++it) {
- QVERIFY(it.value().type() == QVariant::Int);
+ QCOMPARE(it.value().type(), QVariant::Int);
QString name = it.key();
int itemIndex = it.value().toInt();
QVERIFY2(expectedIndexes.contains(itemIndex), QTest::toString(QString("Index %1 not found in expectedIndexes").arg(itemIndex)));
@@ -7020,7 +7103,7 @@ void tst_QQuickListView::matchItemsAndIndexes(const QVariantMap &items, const Qa
void tst_QQuickListView::matchItemLists(const QVariantList &itemLists, const QList<QQuickItem *> &expectedItems)
{
for (int i=0; i<itemLists.count(); i++) {
- QVERIFY(itemLists[i].type() == QVariant::List);
+ QCOMPARE(itemLists[i].type(), QVariant::List);
QVariantList current = itemLists[i].toList();
for (int j=0; j<current.count(); j++) {
QQuickItem *o = qobject_cast<QQuickItem*>(current[j].value<QObject*>());
@@ -7062,7 +7145,7 @@ void tst_QQuickListView::flickBeyondBounds()
QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
if (!item) qWarning() << "Item" << i << "not found";
QTRY_VERIFY(item);
- QTRY_VERIFY(item->y() == i*45);
+ QTRY_COMPARE(item->y(), qreal(i*45));
}
delete window;
@@ -7398,7 +7481,7 @@ void tst_QQuickListView::stickyPositioning()
QFETCH(QPointF, headerPos);
QFETCH(QPointF, footerPos);
- QQuickView *window = createView();
+ QQuickView *window = getView();
QaimModel model;
for (int i = 0; i < 20; i++)
@@ -7441,7 +7524,7 @@ void tst_QQuickListView::stickyPositioning()
QCOMPARE(actualPos, footerPos);
}
- delete window;
+ releaseView(window);
}
void tst_QQuickListView::stickyPositioning_data()
@@ -7468,7 +7551,7 @@ void tst_QQuickListView::stickyPositioning_data()
QTest::newRow("top header") << "stickyPositioning-header.qml"
<< Qt::Vertical << Qt::LeftToRight << QQuickListView::TopToBottom
<< 0 << QQuickItemView::Beginning << QList<QPointF>()
- << QPointF(0,-10) << QPointF();
+ << QPointF(0,0) << QPointF();
QTest::newRow("top header: 1/2 up") << "stickyPositioning-header.qml"
<< Qt::Vertical << Qt::LeftToRight << QQuickListView::TopToBottom
@@ -7495,7 +7578,7 @@ void tst_QQuickListView::stickyPositioning_data()
QTest::newRow("top footer") << "stickyPositioning-footer.qml"
<< Qt::Vertical << Qt::LeftToRight << QQuickListView::BottomToTop
<< 19 << QQuickItemView::End << QList<QPointF>()
- << QPointF() << QPointF(0,-10);
+ << QPointF() << QPointF(0,0);
QTest::newRow("top footer: 1/2 up") << "stickyPositioning-footer.qml"
<< Qt::Vertical << Qt::LeftToRight << QQuickListView::BottomToTop
@@ -7522,7 +7605,7 @@ void tst_QQuickListView::stickyPositioning_data()
QTest::newRow("bottom header") << "stickyPositioning-header.qml"
<< Qt::Vertical << Qt::LeftToRight << QQuickListView::BottomToTop
<< 0 << QQuickItemView::Beginning << QList<QPointF>()
- << QPointF(0,100) << QPointF();
+ << QPointF(0,90) << QPointF();
QTest::newRow("bottom header: 1/2 down") << "stickyPositioning-header.qml"
<< Qt::Vertical << Qt::LeftToRight << QQuickListView::BottomToTop
@@ -7549,7 +7632,7 @@ void tst_QQuickListView::stickyPositioning_data()
QTest::newRow("bottom footer") << "stickyPositioning-footer.qml"
<< Qt::Vertical << Qt::LeftToRight << QQuickListView::TopToBottom
<< 19 << QQuickItemView::End << QList<QPointF>()
- << QPointF() << QPointF(0,100);
+ << QPointF() << QPointF(0,90);
QTest::newRow("bottom footer: 1/2 down") << "stickyPositioning-footer.qml"
<< Qt::Vertical << Qt::LeftToRight << QQuickListView::TopToBottom
@@ -7576,7 +7659,7 @@ void tst_QQuickListView::stickyPositioning_data()
QTest::newRow("top header & bottom footer") << "stickyPositioning-both.qml"
<< Qt::Vertical << Qt::LeftToRight << QQuickListView::TopToBottom
<< 0 << QQuickItemView::Beginning << QList<QPointF>()
- << QPointF(0,-10) << QPointF(0,90);
+ << QPointF(0,0) << QPointF(0,100);
QTest::newRow("top header & bottom footer: 1/2 up") << "stickyPositioning-both.qml"
<< Qt::Vertical << Qt::LeftToRight << QQuickListView::TopToBottom
@@ -7629,7 +7712,7 @@ void tst_QQuickListView::stickyPositioning_data()
QTest::newRow("left header") << "stickyPositioning-header.qml"
<< Qt::Horizontal << Qt::LeftToRight << QQuickListView::TopToBottom
<< 0 << QQuickItemView::Beginning << QList<QPointF>()
- << QPointF(-10,0) << QPointF();
+ << QPointF(0,0) << QPointF();
QTest::newRow("left header: 1/2 left") << "stickyPositioning-header.qml"
<< Qt::Horizontal << Qt::LeftToRight << QQuickListView::TopToBottom
@@ -7656,7 +7739,7 @@ void tst_QQuickListView::stickyPositioning_data()
QTest::newRow("left footer") << "stickyPositioning-footer.qml"
<< Qt::Horizontal << Qt::RightToLeft << QQuickListView::TopToBottom
<< 19 << QQuickItemView::End << QList<QPointF>()
- << QPointF() << QPointF(-10,0);
+ << QPointF() << QPointF(0,0);
QTest::newRow("left footer: 1/2 left") << "stickyPositioning-footer.qml"
<< Qt::Horizontal << Qt::RightToLeft << QQuickListView::TopToBottom
@@ -7683,7 +7766,7 @@ void tst_QQuickListView::stickyPositioning_data()
QTest::newRow("right header") << "stickyPositioning-header.qml"
<< Qt::Horizontal << Qt::RightToLeft << QQuickListView::TopToBottom
<< 0 << QQuickItemView::Beginning << QList<QPointF>()
- << QPointF(100,0) << QPointF();
+ << QPointF(90,0) << QPointF();
QTest::newRow("right header: 1/2 right") << "stickyPositioning-header.qml"
<< Qt::Horizontal << Qt::RightToLeft << QQuickListView::TopToBottom
@@ -7710,7 +7793,7 @@ void tst_QQuickListView::stickyPositioning_data()
QTest::newRow("right footer") << "stickyPositioning-footer.qml"
<< Qt::Horizontal << Qt::LeftToRight << QQuickListView::TopToBottom
<< 19 << QQuickItemView::End << QList<QPointF>()
- << QPointF() << QPointF(100,0);
+ << QPointF() << QPointF(90,0);
QTest::newRow("right footer: 1/2 right") << "stickyPositioning-footer.qml"
<< Qt::Horizontal << Qt::LeftToRight << QQuickListView::TopToBottom
@@ -7737,7 +7820,7 @@ void tst_QQuickListView::stickyPositioning_data()
QTest::newRow("left header & right footer") << "stickyPositioning-both.qml"
<< Qt::Horizontal << Qt::LeftToRight << QQuickListView::TopToBottom
<< 0 << QQuickItemView::Beginning << QList<QPointF>()
- << QPointF(-10,0) << QPointF(90,0);
+ << QPointF(0,0) << QPointF(100,0);
QTest::newRow("left header & right footer: 1/2 left") << "stickyPositioning-both.qml"
<< Qt::Horizontal << Qt::LeftToRight << QQuickListView::TopToBottom
@@ -7856,7 +7939,7 @@ void tst_QQuickListView::QTBUG_38209()
// simulate mouse flick
flick(window.data(), QPoint(200, 200), QPoint(200, 50), 100);
- QTRY_VERIFY(listview->isMoving() == false);
+ QTRY_VERIFY(!listview->isMoving());
qreal contentY = listview->contentY();
// flick down
@@ -8063,6 +8146,328 @@ void tst_QQuickListView::jsArrayChange()
QCOMPARE(spy.count(), 1);
}
+static bool compareObjectModel(QQuickListView *listview, QQmlObjectModel *model)
+{
+ if (listview->count() != model->count())
+ return false;
+ for (int i = 0; i < listview->count(); ++i) {
+ listview->setCurrentIndex(i);
+ if (listview->currentItem() != model->get(i))
+ return false;
+ }
+ return true;
+}
+
+void tst_QQuickListView::objectModel()
+{
+ QQmlEngine engine;
+ QQmlComponent component(&engine, testFileUrl("objectmodel.qml"));
+
+ QQuickListView *listview = qobject_cast<QQuickListView *>(component.create());
+ QVERIFY(listview);
+
+ QQmlObjectModel *model = listview->model().value<QQmlObjectModel *>();
+ QVERIFY(model);
+
+ listview->setCurrentIndex(0);
+ QVERIFY(listview->currentItem());
+ QCOMPARE(listview->currentItem()->property("color").toString(), QColor("red").name());
+
+ listview->setCurrentIndex(1);
+ QVERIFY(listview->currentItem());
+ QCOMPARE(listview->currentItem()->property("color").toString(), QColor("green").name());
+
+ listview->setCurrentIndex(2);
+ QVERIFY(listview->currentItem());
+ QCOMPARE(listview->currentItem()->property("color").toString(), QColor("blue").name());
+
+ QQuickItem *item0 = new QQuickItem(listview);
+ item0->setSize(QSizeF(20, 20));
+ model->append(item0);
+ QCOMPARE(model->count(), 4);
+ QVERIFY(compareObjectModel(listview, model));
+
+ QQuickItem *item1 = new QQuickItem(listview);
+ item1->setSize(QSizeF(20, 20));
+ model->insert(0, item1);
+ QCOMPARE(model->count(), 5);
+ QVERIFY(compareObjectModel(listview, model));
+
+ model->move(1, 2, 3);
+ QVERIFY(compareObjectModel(listview, model));
+
+ model->remove(2, 2);
+ QCOMPARE(model->count(), 3);
+ QVERIFY(compareObjectModel(listview, model));
+
+ model->clear();
+ QCOMPARE(model->count(), 0);
+ QCOMPARE(listview->count(), 0);
+
+ delete listview;
+}
+
+void tst_QQuickListView::contentHeightWithDelayRemove_data()
+{
+ QTest::addColumn<bool>("useDelayRemove");
+ QTest::addColumn<QByteArray>("removeFunc");
+ QTest::addColumn<int>("countDelta");
+ QTest::addColumn<qreal>("contentHeightDelta");
+
+ QTest::newRow("remove without delayRemove")
+ << false
+ << QByteArray("takeOne")
+ << -1
+ << qreal(-1 * 100.0);
+
+ QTest::newRow("remove with delayRemove")
+ << true
+ << QByteArray("takeOne")
+ << -1
+ << qreal(-1 * 100.0);
+
+ QTest::newRow("remove with multiple delayRemove")
+ << true
+ << QByteArray("takeThree")
+ << -3
+ << qreal(-3 * 100.0);
+
+ QTest::newRow("clear with delayRemove")
+ << true
+ << QByteArray("takeAll")
+ << -5
+ << qreal(-5 * 100.0);
+}
+
+void tst_QQuickListView::contentHeightWithDelayRemove()
+{
+ QFETCH(bool, useDelayRemove);
+ QFETCH(QByteArray, removeFunc);
+ QFETCH(int, countDelta);
+ QFETCH(qreal, contentHeightDelta);
+
+ QQuickView *window = createView();
+ window->setSource(testFileUrl("contentHeightWithDelayRemove.qml"));
+ window->show();
+ QVERIFY(QTest::qWaitForWindowExposed(window));
+
+ QQuickListView *listview = window->rootObject()->findChild<QQuickListView*>();
+ QTRY_VERIFY(listview != 0);
+
+ const int initialCount(listview->count());
+ const int eventualCount(initialCount + countDelta);
+
+ const qreal initialContentHeight(listview->contentHeight());
+ const int eventualContentHeight(qRound(initialContentHeight + contentHeightDelta));
+
+ listview->setProperty("useDelayRemove", useDelayRemove);
+ QMetaObject::invokeMethod(window->rootObject(), removeFunc.constData());
+ QTest::qWait(50);
+ QCOMPARE(listview->count(), eventualCount);
+
+ if (useDelayRemove) {
+ QCOMPARE(qRound(listview->contentHeight()), qRound(initialContentHeight));
+ QTRY_COMPARE(qRound(listview->contentHeight()), eventualContentHeight);
+ } else {
+ QCOMPARE(qRound(listview->contentHeight()), eventualContentHeight);
+ }
+
+ delete window;
+}
+
+void tst_QQuickListView::QTBUG_48044_currentItemNotVisibleAfterTransition()
+{
+ QQuickView *window = createView();
+ window->setSource(testFileUrl("qtbug48044.qml"));
+ window->show();
+ QVERIFY(QTest::qWaitForWindowExposed(window));
+
+ QQuickListView *listview = window->rootObject()->findChild<QQuickListView*>();
+ QTRY_VERIFY(listview != 0);
+
+ // Expand 2nd header
+ listview->setProperty("transitionsDone", QVariant(false));
+ QTest::mouseClick(window, Qt::LeftButton, Qt::NoModifier, QPoint(window->width() / 2, 75));
+ QTRY_VERIFY(listview->property("transitionsDone").toBool());
+
+ // Flick listview to the bottom
+ flick(window, QPoint(window->width() / 2, 400), QPoint(window->width() / 2, 0), 100);
+ QTRY_VERIFY(!listview->isMoving());
+
+ // Expand 3rd header
+ listview->setProperty("transitionsDone", QVariant(false));
+ QTest::mouseClick(window, Qt::LeftButton, Qt::NoModifier, QPoint(window->width() / 2, window->height() - 25));
+ QTRY_VERIFY(listview->property("transitionsDone").toBool());
+
+ // Check current item is what we expect
+ QCOMPARE(listview->currentIndex(), 2);
+ QQuickItem *currentItem = listview->currentItem();
+ QVERIFY(currentItem);
+ QVERIFY(currentItem->isVisible());
+
+ // This is the actual test
+ QQuickItemPrivate *currentPriv = QQuickItemPrivate::get(currentItem);
+ QVERIFY(!currentPriv->culled);
+}
+
+static bool testVisibleItems(const QQuickItemViewPrivate *priv, bool *nonUnique, FxViewItem **failItem, int *expectedIdx)
+{
+ QHash<QQuickItem*, int> uniqueItems;
+
+ int skip = 0;
+ for (int i = 0; i < priv->visibleItems.count(); ++i) {
+ FxViewItem *item = priv->visibleItems.at(i);
+ if (!item) {
+ *failItem = Q_NULLPTR;
+ return false;
+ }
+#if 0
+ qDebug() << "\t" << item->index
+ << item->item
+ << item->position()
+ << (!item->item || QQuickItemPrivate::get(item->item)->culled ? "hidden" : "visible");
+#endif
+ if (item->index == -1) {
+ ++skip;
+ } else if (item->index != priv->visibleIndex + i - skip) {
+ *nonUnique = false;
+ *failItem = item;
+ *expectedIdx = priv->visibleIndex + i - skip;
+ return false;
+ } else if (uniqueItems.contains(item->item)) {
+ *nonUnique = true;
+ *failItem = item;
+ *expectedIdx = uniqueItems.find(item->item).value();
+ return false;
+ }
+
+ uniqueItems.insert(item->item, item->index);
+ }
+
+ return true;
+}
+
+class QTBUG_48870_Model : public QAbstractListModel
+{
+ Q_OBJECT
+
+public:
+
+ QTBUG_48870_Model()
+ : QAbstractListModel()
+ , m_rowCount(20)
+ {
+ QTimer *t = new QTimer(this);
+ t->setInterval(500);
+ t->start();
+
+ qsrand(qHash(QDateTime::currentDateTime()));
+ connect(t, &QTimer::timeout, this, &QTBUG_48870_Model::updateModel);
+ }
+
+ int rowCount(const QModelIndex &) const
+ {
+ return m_rowCount;
+ }
+
+ QVariant data(const QModelIndex &, int) const
+ {
+ return QVariant();
+ }
+
+public Q_SLOTS:
+ void updateModel()
+ {
+ if (m_rowCount > 10) {
+ for (int i = 0; i < 10; ++i) {
+ int rnum = qrand() % m_rowCount;
+ beginRemoveRows(QModelIndex(), rnum, rnum);
+ m_rowCount--;
+ endRemoveRows();
+ }
+ }
+ if (m_rowCount < 20) {
+ for (int i = 0; i < 10; ++i) {
+ int rnum = qrand() % m_rowCount;
+ beginInsertRows(QModelIndex(), rnum, rnum);
+ m_rowCount++;
+ endInsertRows();
+ }
+ }
+ }
+
+private:
+ int m_rowCount;
+};
+
+void tst_QQuickListView::QTBUG_48870_fastModelUpdates()
+{
+ QTBUG_48870_Model model;
+
+ QQuickView *window = createView();
+ QVERIFY(window);
+ QQmlContext *ctxt = window->rootContext();
+ QVERIFY(ctxt);
+ ctxt->setContextProperty("testModel", &model);
+
+ window->setSource(testFileUrl("qtbug48870.qml"));
+ window->show();
+ QVERIFY(QTest::qWaitForWindowExposed(window));
+
+ QQuickListView *listview = findItem<QQuickListView>(window->rootObject(), "list");
+ QTRY_VERIFY(listview != 0);
+
+ QQuickItemViewPrivate *priv = QQuickItemViewPrivate::get(listview);
+ bool nonUnique;
+ FxViewItem *item = Q_NULLPTR;
+ int expectedIdx;
+ QVERIFY(testVisibleItems(priv, &nonUnique, &item, &expectedIdx));
+
+ for (int i = 0; i < 10; i++) {
+ QTest::qWait(100);
+ QVERIFY2(testVisibleItems(priv, &nonUnique, &item, &expectedIdx),
+ qPrintable(!item ? QString("Unexpected null item")
+ : nonUnique ? QString("Non-unique item at %1 and %2").arg(item->index).arg(expectedIdx)
+ : QString("Found index %1, expected index is %3").arg(item->index).arg(expectedIdx)));
+ if (i % 3 != 0) {
+ if (i & 1)
+ flick(window, QPoint(100, 200), QPoint(100, 0), 100);
+ else
+ flick(window, QPoint(100, 200), QPoint(100, 400), 100);
+ }
+ }
+
+ delete window;
+}
+
+// infinite loop in overlay header positioning due to undesired rounding in QQuickFlickablePrivate::fixup()
+void tst_QQuickListView::QTBUG_50105()
+{
+ QQmlEngine engine;
+ QQmlComponent component(&engine);
+ component.loadUrl(testFileUrl("qtbug50105.qml"));
+
+ QScopedPointer<QQuickWindow> window(qobject_cast<QQuickWindow *>(component.create()));
+ QVERIFY(window.data());
+ QVERIFY(QTest::qWaitForWindowExposed(window.data()));
+}
+
+void tst_QQuickListView::QTBUG_50097_stickyHeader_positionViewAtIndex()
+{
+ QQuickView *window = createView();
+ window->setSource(testFileUrl("qtbug50097.qml"));
+ window->show();
+ QVERIFY(QTest::qWaitForWindowExposed(window));
+
+ QQuickListView *listview = qobject_cast<QQuickListView*>(window->rootObject());
+ QVERIFY(listview != 0);
+ QTRY_COMPARE(listview->contentY(), -100.0); // the header size, since the header is overlaid
+ listview->setProperty("currentPage", 2);
+ QTRY_COMPARE(listview->contentY(), 400.0); // a full page of items down, sans the original negative header position
+ listview->setProperty("currentPage", 1);
+ QTRY_COMPARE(listview->contentY(), -100.0); // back to the same position: header visible, items not under the header.
+}
+
QTEST_MAIN(tst_QQuickListView)
#include "tst_qquicklistview.moc"
diff --git a/tests/auto/quick/qquickloader/tst_qquickloader.cpp b/tests/auto/quick/qquickloader/tst_qquickloader.cpp
index 3dd2551d9d..f4fab1d79f 100644
--- a/tests/auto/quick/qquickloader/tst_qquickloader.cpp
+++ b/tests/auto/quick/qquickloader/tst_qquickloader.cpp
@@ -236,7 +236,7 @@ void tst_QQuickLoader::clear()
QCOMPARE(loader->progress(), 1.0);
QCOMPARE(static_cast<QQuickItem*>(loader)->childItems().count(), 1);
- QTRY_VERIFY(loader->item() == 0);
+ QTRY_VERIFY(!loader->item());
QCOMPARE(loader->progress(), 0.0);
QCOMPARE(loader->status(), QQuickLoader::Null);
QCOMPARE(static_cast<QQuickItem*>(loader)->childItems().count(), 0);
@@ -256,7 +256,7 @@ void tst_QQuickLoader::clear()
loader->setSourceComponent(0);
- QVERIFY(loader->item() == 0);
+ QVERIFY(!loader->item());
QCOMPARE(loader->progress(), 0.0);
QCOMPARE(loader->status(), QQuickLoader::Null);
QCOMPARE(static_cast<QQuickItem*>(loader)->childItems().count(), 0);
@@ -276,7 +276,7 @@ void tst_QQuickLoader::clear()
QMetaObject::invokeMethod(item, "clear");
- QVERIFY(loader->item() == 0);
+ QVERIFY(!loader->item());
QCOMPARE(loader->progress(), 0.0);
QCOMPARE(loader->status(), QQuickLoader::Null);
QCOMPARE(static_cast<QQuickItem*>(loader)->childItems().count(), 0);
@@ -435,9 +435,7 @@ void tst_QQuickLoader::noResize()
void tst_QQuickLoader::networkRequestUrl()
{
- TestHTTPServer server;
- QVERIFY2(server.listen(), qPrintable(server.errorString()));
- server.serveDirectory(dataDirectory());
+ ThreadedTestHTTPServer server(dataDirectory());
QQmlComponent component(&engine);
const QString qml = "import QtQuick 2.0\nLoader { property int signalCount : 0; source: \"" + server.baseUrl().toString() + "/Rect120x60.qml\"; onLoaded: signalCount += 1 }";
@@ -447,7 +445,7 @@ void tst_QQuickLoader::networkRequestUrl()
QQuickLoader *loader = qobject_cast<QQuickLoader*>(component.create());
QVERIFY(loader != 0);
- QTRY_VERIFY(loader->status() == QQuickLoader::Ready);
+ QTRY_COMPARE(loader->status(), QQuickLoader::Ready);
QVERIFY(loader->item());
QCOMPARE(loader->progress(), 1.0);
@@ -460,9 +458,7 @@ void tst_QQuickLoader::networkRequestUrl()
/* XXX Component waits until all dependencies are loaded. Is this actually possible? */
void tst_QQuickLoader::networkComponent()
{
- TestHTTPServer server;
- QVERIFY2(server.listen(), qPrintable(server.errorString()));
- server.serveDirectory(dataDirectory(), TestHTTPServer::Delay);
+ ThreadedTestHTTPServer server(dataDirectory(), TestHTTPServer::Delay);
QQmlComponent component(&engine);
const QString qml = "import QtQuick 2.0\n"
@@ -471,8 +467,9 @@ void tst_QQuickLoader::networkComponent()
" Component { id: comp; NW.Rect120x60 {} }\n"
" Loader { sourceComponent: comp } }";
component.setData(qml.toUtf8(), dataDirectory());
- QCOMPARE(component.status(), QQmlComponent::Loading);
- server.sendDelayedItem();
+ // The component may be loaded synchronously or asynchronously, so we cannot test for
+ // status == Loading here. Also, it makes no sense to instruct the server to send here
+ // because in the synchronous case we're already done loading.
QTRY_COMPARE(component.status(), QQmlComponent::Ready);
QQuickItem *item = qobject_cast<QQuickItem*>(component.create());
@@ -480,7 +477,7 @@ void tst_QQuickLoader::networkComponent()
QQuickLoader *loader = qobject_cast<QQuickLoader*>(item->children().at(1));
QVERIFY(loader);
- QTRY_VERIFY(loader->status() == QQuickLoader::Ready);
+ QTRY_COMPARE(loader->status(), QQuickLoader::Ready);
QVERIFY(loader->item());
QCOMPARE(loader->progress(), 1.0);
@@ -492,9 +489,7 @@ void tst_QQuickLoader::networkComponent()
void tst_QQuickLoader::failNetworkRequest()
{
- TestHTTPServer server;
- QVERIFY2(server.listen(), qPrintable(server.errorString()));
- server.serveDirectory(dataDirectory());
+ ThreadedTestHTTPServer server(dataDirectory());
QTest::ignoreMessage(QtWarningMsg, QString(server.baseUrl().toString() + "/IDontExist.qml: File not found").toUtf8());
@@ -505,9 +500,9 @@ void tst_QQuickLoader::failNetworkRequest()
QQuickLoader *loader = qobject_cast<QQuickLoader*>(component.create());
QVERIFY(loader != 0);
- QTRY_VERIFY(loader->status() == QQuickLoader::Error);
+ QTRY_COMPARE(loader->status(), QQuickLoader::Error);
- QVERIFY(loader->item() == 0);
+ QVERIFY(!loader->item());
QCOMPARE(loader->progress(), 1.0);
QCOMPARE(loader->property("did_load").toInt(), 123);
QCOMPARE(static_cast<QQuickItem*>(loader)->childItems().count(), 0);
@@ -525,11 +520,11 @@ void tst_QQuickLoader::active()
QQuickLoader *loader = object->findChild<QQuickLoader*>("loader");
QVERIFY(loader->active() == false); // set manually to false
- QVERIFY(loader->item() == 0);
+ QVERIFY(!loader->item());
QMetaObject::invokeMethod(object, "doSetSourceComponent");
- QVERIFY(loader->item() == 0);
+ QVERIFY(!loader->item());
QMetaObject::invokeMethod(object, "doSetSource");
- QVERIFY(loader->item() == 0);
+ QVERIFY(!loader->item());
QMetaObject::invokeMethod(object, "doSetActive");
QVERIFY(loader->item() != 0);
@@ -598,7 +593,7 @@ void tst_QQuickLoader::active()
QVERIFY(loader->item() != 0);
int currItemChangedCount = loader->property("itemChangedCount").toInt();
QMetaObject::invokeMethod(object, "doSetInactive");
- QVERIFY(loader->item() == 0);
+ QVERIFY(!loader->item());
QCOMPARE(loader->property("itemChangedCount").toInt(), (currItemChangedCount+1));
delete object;
@@ -708,9 +703,7 @@ void tst_QQuickLoader::initialPropertyValues()
QFETCH(QStringList, propertyNames);
QFETCH(QVariantList, propertyValues);
- TestHTTPServer server;
- QVERIFY2(server.listen(), qPrintable(server.errorString()));
- server.serveDirectory(dataDirectory());
+ ThreadedTestHTTPServer server(dataDirectory());
foreach (const QString &warning, expectedWarnings)
QTest::ignoreMessage(QtWarningMsg, warning.toLatin1().constData());
@@ -781,7 +774,7 @@ void tst_QQuickLoader::initialPropertyValuesError()
QVERIFY(object != 0);
QQuickLoader *loader = object->findChild<QQuickLoader*>("loader");
QVERIFY(loader != 0);
- QVERIFY(loader->item() == 0);
+ QVERIFY(!loader->item());
delete object;
}
@@ -803,7 +796,7 @@ void tst_QQuickLoader::deleteComponentCrash()
QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete);
QCoreApplication::processEvents();
QTRY_COMPARE(static_cast<QQuickItem*>(loader)->childItems().count(), 1);
- QVERIFY(loader->source() == testFileUrl("BlueRect.qml"));
+ QCOMPARE(loader->source(), testFileUrl("BlueRect.qml"));
delete item;
}
@@ -833,7 +826,7 @@ void tst_QQuickLoader::vmeErrors()
QTest::ignoreMessage(QtWarningMsg, err.toLatin1().constData());
QQuickLoader *loader = qobject_cast<QQuickLoader*>(component.create());
QVERIFY(loader);
- QVERIFY(loader->item() == 0);
+ QVERIFY(!loader->item());
delete loader;
}
@@ -1098,7 +1091,7 @@ void tst_QQuickLoader::parented()
QQuickItem *item = root->findChild<QQuickItem*>("comp");
QVERIFY(item);
- QVERIFY(item->parentItem() == root);
+ QCOMPARE(item->parentItem(), root);
QCOMPARE(item->width(), 300.);
QCOMPARE(item->height(), 300.);
diff --git a/tests/auto/quick/qquickmousearea/tst_qquickmousearea.cpp b/tests/auto/quick/qquickmousearea/tst_qquickmousearea.cpp
index 5bdc6f415a..82c053d76a 100644
--- a/tests/auto/quick/qquickmousearea/tst_qquickmousearea.cpp
+++ b/tests/auto/quick/qquickmousearea/tst_qquickmousearea.cpp
@@ -169,7 +169,7 @@ void tst_QQuickMouseArea::dragProperties()
// target
QQuickItem *blackRect = window.rootObject()->findChild<QQuickItem*>("blackrect");
QVERIFY(blackRect != 0);
- QVERIFY(blackRect == drag->target());
+ QCOMPARE(blackRect, drag->target());
QQuickItem *rootItem = qobject_cast<QQuickItem*>(window.rootObject());
QVERIFY(rootItem != 0);
QSignalSpy targetSpy(drag, SIGNAL(targetChanged()));
@@ -267,14 +267,14 @@ void tst_QQuickMouseArea::resetDrag()
// target
QQuickItem *blackRect = window.rootObject()->findChild<QQuickItem*>("blackrect");
QVERIFY(blackRect != 0);
- QVERIFY(blackRect == drag->target());
+ QCOMPARE(blackRect, drag->target());
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));
QCOMPARE(targetSpy.count(),1);
- QVERIFY(drag->target() == 0);
+ QVERIFY(!drag->target());
}
void tst_QQuickMouseArea::dragging()
@@ -300,7 +300,7 @@ void tst_QQuickMouseArea::dragging()
// target
QQuickItem *blackRect = window.rootObject()->findChild<QQuickItem*>("blackrect");
QVERIFY(blackRect != 0);
- QVERIFY(blackRect == drag->target());
+ QCOMPARE(blackRect, drag->target());
QVERIFY(!drag->active());
@@ -347,7 +347,7 @@ void tst_QQuickMouseArea::dragSmoothed()
mouseRegion->setAcceptedButtons(Qt::LeftButton);
QQuickItem *blackRect = window.rootObject()->findChild<QQuickItem*>("blackrect");
QVERIFY(blackRect != 0);
- QVERIFY(blackRect == drag->target());
+ QCOMPARE(blackRect, drag->target());
QVERIFY(!drag->active());
QTest::mousePress(&window, Qt::LeftButton, 0, QPoint(100,100));
QVERIFY(!drag->active());
@@ -393,7 +393,7 @@ void tst_QQuickMouseArea::dragThreshold()
mouseRegion->setAcceptedButtons(Qt::LeftButton);
QQuickItem *blackRect = window.rootObject()->findChild<QQuickItem*>("blackrect");
QVERIFY(blackRect != 0);
- QVERIFY(blackRect == drag->target());
+ QCOMPARE(blackRect, drag->target());
QVERIFY(!drag->active());
QTest::mousePress(&window, Qt::LeftButton, 0, QPoint(100,100));
QVERIFY(!drag->active());
@@ -451,7 +451,7 @@ void tst_QQuickMouseArea::invalidDrag()
// target
QQuickItem *blackRect = window.rootObject()->findChild<QQuickItem*>("blackrect");
QVERIFY(blackRect != 0);
- QVERIFY(blackRect == drag->target());
+ QCOMPARE(blackRect, drag->target());
QVERIFY(!drag->active());
@@ -501,7 +501,7 @@ void tst_QQuickMouseArea::cancelDragging()
// target
QQuickItem *blackRect = window.rootObject()->findChild<QQuickItem*>("blackrect");
QVERIFY(blackRect != 0);
- QVERIFY(blackRect == drag->target());
+ QCOMPARE(blackRect, drag->target());
QVERIFY(!drag->active());
@@ -655,7 +655,7 @@ void tst_QQuickMouseArea::noOnClickedWithPressAndHold()
QMouseEvent pressEvent(QEvent::MouseButtonPress, QPoint(100, 100), Qt::LeftButton, Qt::LeftButton, 0);
QGuiApplication::sendEvent(&window, &pressEvent);
- QVERIFY(mouseArea->pressedButtons() == Qt::LeftButton);
+ QCOMPARE(mouseArea->pressedButtons(), Qt::LeftButton);
QVERIFY(!window.rootObject()->property("clicked").toBool());
QVERIFY(!window.rootObject()->property("held").toBool());
@@ -1281,7 +1281,7 @@ void tst_QQuickMouseArea::disableAfterPress()
// target
QQuickItem *blackRect = window.rootObject()->findChild<QQuickItem*>("blackrect");
QVERIFY(blackRect != 0);
- QVERIFY(blackRect == drag->target());
+ QCOMPARE(blackRect, drag->target());
QVERIFY(!drag->active());
@@ -1574,7 +1574,7 @@ void tst_QQuickMouseArea::changeAxis()
// target
QQuickItem *blackRect = view.rootObject()->findChild<QQuickItem*>("blackrect");
QVERIFY(blackRect != 0);
- QVERIFY(blackRect == drag->target());
+ QCOMPARE(blackRect, drag->target());
QVERIFY(!drag->active());
diff --git a/tests/auto/quick/qquickmultipointtoucharea/BLACKLIST b/tests/auto/quick/qquickmultipointtoucharea/BLACKLIST
new file mode 100644
index 0000000000..1777af9e0c
--- /dev/null
+++ b/tests/auto/quick/qquickmultipointtoucharea/BLACKLIST
@@ -0,0 +1,2 @@
+[inFlickable]
+*
diff --git a/tests/auto/quick/qquickmultipointtoucharea/tst_qquickmultipointtoucharea.cpp b/tests/auto/quick/qquickmultipointtoucharea/tst_qquickmultipointtoucharea.cpp
index e69ebfa8fe..4da4767d7b 100644
--- a/tests/auto/quick/qquickmultipointtoucharea/tst_qquickmultipointtoucharea.cpp
+++ b/tests/auto/quick/qquickmultipointtoucharea/tst_qquickmultipointtoucharea.cpp
@@ -719,7 +719,7 @@ void tst_QQuickMultiPointTouchArea::inFlickable()
QTest::mouseMove(window.data(), p1);
QQuickTouchUtils::flush(window.data());
- QVERIFY(flickable->contentY() == 0);
+ QCOMPARE(flickable->contentY(), qreal(0));
QCOMPARE(point11->pressed(), true);
QCOMPARE(point12->pressed(), true);
@@ -1186,14 +1186,14 @@ void tst_QQuickMultiPointTouchArea::mouseInteraction()
QPoint p1 = QPoint(100, 100);
QTest::mousePress(view.data(), (Qt::MouseButton) buttons, 0, p1);
QCOMPARE(area->property("touchCount").toInt(), accept);
- QCOMPARE(point1->pressed(), accept);
+ QCOMPARE(point1->pressed(), accept != 0);
p1 += QPoint(10, 10);
QTest::mouseMove(view.data(), p1);
- QCOMPARE(point1->pressed(), accept);
+ QCOMPARE(point1->pressed(), accept != 0);
QCOMPARE(area->property("touchCount").toInt(), accept);
p1 += QPoint(10, 10);
QTest::mouseMove(view.data(), p1);
- QCOMPARE(point1->pressed(), accept);
+ QCOMPARE(point1->pressed(), accept != 0);
QCOMPARE(area->property("touchCount").toInt(), accept);
QTest::mouseRelease(view.data(), (Qt::MouseButton) buttons);
QCOMPARE(point1->pressed(), false);
diff --git a/tests/auto/quick/qquickpathview/data/customAttribute.qml b/tests/auto/quick/qquickpathview/data/customAttribute.qml
new file mode 100644
index 0000000000..bd4c9fd1de
--- /dev/null
+++ b/tests/auto/quick/qquickpathview/data/customAttribute.qml
@@ -0,0 +1,58 @@
+import QtQuick 2.4
+
+PathView {
+ width: 200
+ height: 600
+
+ pathItemCount: 7
+
+ model: ListModel {
+ ListElement { color: "salmon" }
+ ListElement { color: "seagreen" }
+ ListElement { color: "navy" }
+ ListElement { color: "goldenrod" }
+ }
+ path: Path {
+ startX: width / 2; startY: -100
+ PathAttribute { name: "BEGIN" }
+
+ PathLine { relativeX: 0; y: height / 2 }
+ PathAttribute { name: "BEGIN" }
+
+ PathLine { relativeX: 0; y: height + 100 }
+ PathAttribute { name: "BEGIN" }
+ }
+ delegate: Rectangle {
+ width: 200
+ height: 200
+ color: model.color
+ opacity: PathView.transparency
+ }
+
+ Component {
+ id: attributeComponent
+ PathAttribute {}
+ }
+
+ function addAttribute(name, values) {
+ var valueIndex = 0
+ var elements = []
+ for (var i = 0; i < path.pathElements.length; ++i) {
+ elements.push(path.pathElements[i])
+
+ if (path.pathElements[i].name === "BEGIN") {
+ if (values[valueIndex] !== undefined) {
+ var attribute = attributeComponent.createObject(this, { "name": name, "value": values[valueIndex] })
+ elements.push(attribute)
+ }
+ ++valueIndex
+ }
+ }
+
+ console.log("??")
+ path.pathElements = elements
+ console.log("!!")
+ }
+
+ Component.onCompleted: addAttribute("transparency", [0, 1, 0])
+}
diff --git a/tests/auto/quick/qquickpathview/data/qtbug42716.qml b/tests/auto/quick/qquickpathview/data/qtbug42716.qml
new file mode 100644
index 0000000000..81d52d5ea3
--- /dev/null
+++ b/tests/auto/quick/qquickpathview/data/qtbug42716.qml
@@ -0,0 +1,111 @@
+import QtQuick 2.0
+
+Rectangle {
+ //Note that this file was originally the manual reproduction, MouseAreas were left in.
+ id: qmlBrowser
+
+ width: 500
+ height: 350
+
+ ListModel {
+ id: myModel
+ ListElement {
+ name: "Bill Jones 0"
+ }
+ ListElement {
+ name: "Jane Doe 1"
+ }
+ ListElement {
+ name: "John Smith 2"
+ }
+ ListElement {
+ name: "Bill Jones 3"
+ }
+ ListElement {
+ name: "Jane Doe 4"
+ }
+ ListElement {
+ name: "John Smith 5"
+ }
+ ListElement {
+ name: "John Smith 6"
+ }
+ ListElement {
+ name: "John Smith 7"
+ }
+ }
+
+ Component {
+ id: delegate
+
+ Text {
+ id: nameText
+ height: 33
+ width: parent.width
+ objectName: "delegate"+index
+
+ text: "index: " + index + " text: " + name
+ font.pointSize: 16
+ color: PathView.isCurrentItem ? "red" : "black"
+ }
+ }
+
+ PathView {
+ id: contentList
+ objectName: "pathView"
+ anchors.fill: parent
+
+ property int maxPathItemCount: 7
+ property real itemHeight: 34
+
+ delegate: delegate
+ model: myModel
+ currentIndex: 5
+ pathItemCount: maxPathItemCount
+ highlightMoveDuration: 0
+
+ path: Path {
+ startX: 30 + contentList.width / 2
+ startY: 30
+ PathLine {
+ relativeX: 0
+ relativeY: contentList.itemHeight * contentList.maxPathItemCount
+ }
+ }
+
+ focus: true
+ Keys.onLeftPressed: decrementCurrentIndex()
+ Keys.onRightPressed: incrementCurrentIndex()
+ }
+
+ Column {
+ anchors.right: parent.right
+ Text {
+ text: "Go 1"
+ font.weight: Font.Bold
+ font.pixelSize: 24
+ MouseArea {
+ anchors.fill: parent
+ onClicked: contentList.offset = 2.55882
+ }
+ }
+ Text {
+ text: "Go 2"
+ font.weight: Font.Bold
+ font.pixelSize: 24
+ MouseArea {
+ anchors.fill: parent
+ onClicked: contentList.offset = 0.0882353
+ }
+ }
+ Text {
+ text: "Go 3"
+ font.weight: Font.Bold
+ font.pixelSize: 24
+ MouseArea {
+ anchors.fill: parent
+ onClicked: contentList.offset = 0.99987
+ }
+ }
+ }
+}
diff --git a/tests/auto/quick/qquickpathview/tst_qquickpathview.cpp b/tests/auto/quick/qquickpathview/tst_qquickpathview.cpp
index 7db15522b5..fc5dd3bbca 100644
--- a/tests/auto/quick/qquickpathview/tst_qquickpathview.cpp
+++ b/tests/auto/quick/qquickpathview/tst_qquickpathview.cpp
@@ -140,6 +140,8 @@ private slots:
void nestedinFlickable();
void flickableDelegate();
void jsArrayChange();
+ void qtbug42716();
+ void addCustomAttribute();
};
class TestObject : public QObject
@@ -183,8 +185,8 @@ void tst_QQuickPathView::initValues()
QQuickPathView *obj = qobject_cast<QQuickPathView*>(c.create());
QVERIFY(obj != 0);
- QVERIFY(obj->path() == 0);
- QVERIFY(obj->delegate() == 0);
+ QVERIFY(!obj->path());
+ QVERIFY(!obj->delegate());
QCOMPARE(obj->model(), QVariant());
QCOMPARE(obj->currentIndex(), 0);
QCOMPARE(obj->offset(), 0.);
@@ -799,7 +801,7 @@ void tst_QQuickPathView::dataModel()
QVERIFY(pathview != 0);
QMetaObject::invokeMethod(window->rootObject(), "checkProperties");
- QVERIFY(testObject->error() == false);
+ QVERIFY(!testObject->error());
QQuickItem *item = findItem<QQuickItem>(pathview, "wrapper", 0);
QVERIFY(item);
@@ -828,14 +830,14 @@ void tst_QQuickPathView::dataModel()
testObject->setPathItemCount(5);
QMetaObject::invokeMethod(window->rootObject(), "checkProperties");
- QVERIFY(testObject->error() == false);
+ QVERIFY(!testObject->error());
QTRY_COMPARE(findItems<QQuickItem>(pathview, "wrapper").count(), 5);
QQuickRectangle *testItem = findItem<QQuickRectangle>(pathview, "wrapper", 4);
QVERIFY(testItem != 0);
testItem = findItem<QQuickRectangle>(pathview, "wrapper", 5);
- QVERIFY(testItem == 0);
+ QVERIFY(!testItem);
pathview->setCurrentIndex(1);
QCOMPARE(pathview->currentIndex(), 1);
@@ -1111,6 +1113,15 @@ void tst_QQuickPathView::setCurrentIndex()
QCOMPARE(pathview->currentItem(), firstItem);
QCOMPARE(firstItem->property("onPath"), QVariant(true));
+ // check for bogus currentIndexChanged() signals
+ QSignalSpy currentIndexSpy(pathview, SIGNAL(currentIndexChanged()));
+ QVERIFY(currentIndexSpy.isValid());
+ pathview->setHighlightMoveDuration(100);
+ pathview->setHighlightRangeMode(QQuickPathView::StrictlyEnforceRange);
+ pathview->setSnapMode(QQuickPathView::SnapToItem);
+ pathview->setCurrentIndex(3);
+ QTRY_COMPARE(pathview->currentIndex(), 3);
+ QCOMPARE(currentIndexSpy.count(), 1);
}
void tst_QQuickPathView::resetModel()
@@ -1814,7 +1825,7 @@ void tst_QQuickPathView::cancelDrag()
item->grabMouse();
// returns to a snap point.
- QTRY_VERIFY(pathview->offset() == qFloor(pathview->offset()));
+ QTRY_COMPARE(pathview->offset(), qreal(qFloor(pathview->offset())));
QTRY_VERIFY(!pathview->isMoving());
QVERIFY(!pathview->isDragging());
QCOMPARE(draggingSpy.count(), 2);
@@ -1897,7 +1908,7 @@ void tst_QQuickPathView::snapToItem()
QVERIFY(pathview->isMoving());
QTRY_VERIFY_WITH_TIMEOUT(!pathview->isMoving(), 50000);
- QVERIFY(pathview->offset() == qFloor(pathview->offset()));
+ QCOMPARE(pathview->offset(), qreal(qFloor(pathview->offset())));
if (enforceRange)
QVERIFY(pathview->currentIndex() != currentIndex);
@@ -2051,7 +2062,7 @@ void tst_QQuickPathView::indexAt_itemAt()
QVERIFY(item);
}
QCOMPARE(pathview->indexAt(x,y), index);
- QVERIFY(pathview->itemAt(x,y) == item);
+ QCOMPARE(pathview->itemAt(x,y), item);
}
@@ -2322,6 +2333,61 @@ void tst_QQuickPathView::jsArrayChange()
QCOMPARE(spy.count(), 1);
}
+/* This bug was one where if you jump the list such that the sole missing item needed to be
+ * added in the middle of the list, it would instead move an item somewhere else in the list
+ * to the middle (messing it up very badly).
+ *
+ * The test checks correct visual order both before and after the jump.
+ */
+void tst_QQuickPathView::qtbug42716()
+{
+ QScopedPointer<QQuickView> window(createView());
+
+ window->setSource(testFileUrl("qtbug42716.qml"));
+ window->show();
+ QVERIFY(QTest::qWaitForWindowActive(window.data()));
+ QCOMPARE(window.data(), qGuiApp->focusWindow());
+
+ QQuickPathView *pathView = findItem<QQuickPathView>(window->rootObject(), "pathView");
+ QVERIFY(pathView != 0);
+
+ int order1[] = {5,6,7,0,1,2,3};
+ int missing1 = 4;
+ int order2[] = {0,1,2,3,4,5,6};
+ int missing2 = 7;
+
+ qreal lastY = 0.0;
+ for (int i = 0; i<7; i++) {
+ QQuickItem *item = findItem<QQuickItem>(pathView, QString("delegate%1").arg(order1[i]));
+ QVERIFY(item);
+ QVERIFY(item->y() > lastY);
+ lastY = item->y();
+ }
+ QQuickItem *itemMiss = findItem<QQuickItem>(pathView, QString("delegate%1").arg(missing1));
+ QVERIFY(!itemMiss);
+
+ pathView->setOffset(0.0882353);
+ //Note refill is delayed, needs time to take effect
+ QTest::qWait(100);
+
+ lastY = 0.0;
+ for (int i = 0; i<7; i++) {
+ QQuickItem *item = findItem<QQuickItem>(pathView, QString("delegate%1").arg(order2[i]));
+ QVERIFY(item);
+ QVERIFY(item->y() > lastY);
+ lastY = item->y();
+ }
+ itemMiss = findItem<QQuickItem>(pathView, QString("delegate%1").arg(missing2));
+ QVERIFY(!itemMiss);
+}
+
+void tst_QQuickPathView::addCustomAttribute()
+{
+ const QScopedPointer<QQuickView> window(createView());
+ window->setSource(testFileUrl("customAttribute.qml"));
+ window->show();
+}
+
QTEST_MAIN(tst_QQuickPathView)
#include "tst_qquickpathview.moc"
diff --git a/tests/auto/quick/qquickpincharea/tst_qquickpincharea.cpp b/tests/auto/quick/qquickpincharea/tst_qquickpincharea.cpp
index 8063453993..3988a90aed 100644
--- a/tests/auto/quick/qquickpincharea/tst_qquickpincharea.cpp
+++ b/tests/auto/quick/qquickpincharea/tst_qquickpincharea.cpp
@@ -91,7 +91,7 @@ void tst_QQuickPinchArea::pinchProperties()
// target
QQuickItem *blackRect = window->rootObject()->findChild<QQuickItem*>("blackrect");
QVERIFY(blackRect != 0);
- QVERIFY(blackRect == pinch->target());
+ QCOMPARE(blackRect, pinch->target());
QQuickItem *rootItem = qobject_cast<QQuickItem*>(window->rootObject());
QVERIFY(rootItem != 0);
QSignalSpy targetSpy(pinch, SIGNAL(targetChanged()));
diff --git a/tests/auto/quick/qquickpixmapcache/tst_qquickpixmapcache.cpp b/tests/auto/quick/qquickpixmapcache/tst_qquickpixmapcache.cpp
index b9f93a4dcf..0fc8a7f001 100644
--- a/tests/auto/quick/qquickpixmapcache/tst_qquickpixmapcache.cpp
+++ b/tests/auto/quick/qquickpixmapcache/tst_qquickpixmapcache.cpp
@@ -110,12 +110,14 @@ void tst_qquickpixmapcache::initTestCase()
QVERIFY2(server.listen(), qPrintable(server.errorString()));
+#ifndef QT_NO_BEARERMANAGEMENT
// This avoids a race condition/deadlock bug in network config
// manager when it is accessed by the HTTP server thread before
// anything else. Bug report can be found at:
// QTBUG-26355
QNetworkConfigurationManager cm;
cm.updateConfigurations();
+#endif
server.serveDirectory(testFile("http"));
}
@@ -146,7 +148,7 @@ void tst_qquickpixmapcache::single()
QString expectedError;
if (neterror) {
- expectedError = "Error downloading " + target.toString() + " - server replied: Not found";
+ expectedError = "Error transferring " + target.toString() + " - server replied: Not found";
} else if (!exists) {
expectedError = "Cannot open: " + target.toString();
}
@@ -159,10 +161,10 @@ void tst_qquickpixmapcache::single()
if (incache) {
QCOMPARE(pixmap.error(), expectedError);
if (exists) {
- QVERIFY(pixmap.status() == QQuickPixmap::Ready);
+ QCOMPARE(pixmap.status(), QQuickPixmap::Ready);
QVERIFY(pixmap.width() > 0);
} else {
- QVERIFY(pixmap.status() == QQuickPixmap::Error);
+ QCOMPARE(pixmap.status(), QQuickPixmap::Error);
QVERIFY(pixmap.width() <= 0);
}
} else {
@@ -174,10 +176,10 @@ void tst_qquickpixmapcache::single()
QVERIFY(!QTestEventLoop::instance().timeout());
QVERIFY(getter.gotslot);
if (exists) {
- QVERIFY(pixmap.status() == QQuickPixmap::Ready);
+ QCOMPARE(pixmap.status(), QQuickPixmap::Ready);
QVERIFY(pixmap.width() > 0);
} else {
- QVERIFY(pixmap.status() == QQuickPixmap::Error);
+ QCOMPARE(pixmap.status(), QQuickPixmap::Error);
QVERIFY(pixmap.width() <= 0);
}
QCOMPARE(pixmap.error(), expectedError);
@@ -259,7 +261,9 @@ void tst_qquickpixmapcache::parallel()
}
}
- QCOMPARE(incache+slotters, targets.count());
+ if (incache + slotters != targets.count())
+ QFAIL(QString::fromLatin1("pixmap counts don't add up: %1 incache, %2 slotters, %3 total")
+ .arg(incache).arg(slotters).arg(targets.count()).toLatin1().constData());
if (cancel >= 0) {
pixmaps.at(cancel)->clear(getters[cancel]);
@@ -280,7 +284,12 @@ void tst_qquickpixmapcache::parallel()
if (pending[i])
QVERIFY(getters[i]->gotslot);
- QVERIFY(pixmap->isReady());
+ if (!pixmap->isReady()) {
+ QFAIL(QString::fromLatin1("pixmap %1 not ready, status %2: %3")
+ .arg(pixmap->url().toString()).arg(pixmap->status())
+ .arg(pixmap->error()).toLatin1().constData());
+
+ }
QVERIFY(pixmap->width() > 0);
delete getters[i];
}
@@ -307,7 +316,7 @@ void tst_qquickpixmapcache::massive()
QVERIFY(p2.isReady());
QVERIFY(p2.image().size() == QSize(10000, 1000));
- QVERIFY(p2.image().cacheKey() == cachekey);
+ QCOMPARE(p2.image().cacheKey(), cachekey);
}
// Confirm that massive images are removed from the cache when
diff --git a/tests/auto/quick/qquickpositioners/data/allInvisible.qml b/tests/auto/quick/qquickpositioners/data/allInvisible.qml
index 5894171434..3b95a5e1da 100644
--- a/tests/auto/quick/qquickpositioners/data/allInvisible.qml
+++ b/tests/auto/quick/qquickpositioners/data/allInvisible.qml
@@ -1,4 +1,4 @@
-import QtQuick 2.0
+import QtQuick 2.6
Item{
width: 400
@@ -41,4 +41,42 @@ Item{
visible: false
}
}
+ Grid{
+ spacing: 20
+ objectName: "grid"
+ Item{
+ width: 0
+ height: 20
+ visible: false
+ }
+ Item{
+ width: 20
+ height: 0
+ visible: false
+ }
+ Item{
+ width: 20
+ height: 20
+ visible: false
+ }
+ }
+ Flow{
+ spacing: 20
+ objectName: "flow"
+ Item{
+ width: 0
+ height: 20
+ visible: false
+ }
+ Item{
+ width: 20
+ height: 0
+ visible: false
+ }
+ Item{
+ width: 20
+ height: 20
+ visible: false
+ }
+ }
}
diff --git a/tests/auto/quick/qquickpositioners/data/flowtest-padding.qml b/tests/auto/quick/qquickpositioners/data/flowtest-padding.qml
new file mode 100644
index 0000000000..a85e7a5c52
--- /dev/null
+++ b/tests/auto/quick/qquickpositioners/data/flowtest-padding.qml
@@ -0,0 +1,44 @@
+import QtQuick 2.6
+
+Item {
+ width: 90
+ height: 480
+ property bool testRightToLeft: false
+
+ Flow {
+ objectName: "flow"
+ width: parent.width
+ layoutDirection: testRightToLeft ? Qt.RightToLeft : Qt.LeftToRight
+ padding: 1; topPadding: 2; leftPadding: 3; rightPadding: 4; bottomPadding: 5
+ Rectangle {
+ objectName: "one"
+ color: "red"
+ width: 50
+ height: 50
+ }
+ Rectangle {
+ objectName: "two"
+ color: "green"
+ width: 20
+ height: 50
+ }
+ Rectangle {
+ objectName: "three"
+ color: "blue"
+ width: 50
+ height: 20
+ }
+ Rectangle {
+ objectName: "four"
+ color: "cyan"
+ width: 50
+ height: 50
+ }
+ Rectangle {
+ objectName: "five"
+ color: "magenta"
+ width: 10
+ height: 10
+ }
+ }
+}
diff --git a/tests/auto/quick/qquickpositioners/data/gridtest-padding.qml b/tests/auto/quick/qquickpositioners/data/gridtest-padding.qml
new file mode 100644
index 0000000000..46244ecef5
--- /dev/null
+++ b/tests/auto/quick/qquickpositioners/data/gridtest-padding.qml
@@ -0,0 +1,47 @@
+import QtQuick 2.6
+
+Item {
+ width: 640
+ height: 480
+ property bool testRightToLeft: false
+ property int testHAlignment: Grid.AlignLeft;
+ property int testVAlignment: Grid.AlignTop;
+ Grid {
+ layoutDirection: testRightToLeft ? Qt.RightToLeft : Qt.LeftToRight
+ horizontalItemAlignment: testHAlignment
+ verticalItemAlignment: testVAlignment
+ objectName: "grid"
+ columns: 3
+ padding: 1; topPadding: 1; leftPadding: 1; rightPadding: 1; bottomPadding: 1
+ Rectangle {
+ objectName: "one"
+ color: "red"
+ width: 50
+ height: 50
+ }
+ Rectangle {
+ objectName: "two"
+ color: "green"
+ width: 20
+ height: 50
+ }
+ Rectangle {
+ objectName: "three"
+ color: "blue"
+ width: 30
+ height: 20
+ }
+ Rectangle {
+ objectName: "four"
+ color: "cyan"
+ width: 50
+ height: 50
+ }
+ Rectangle {
+ objectName: "five"
+ color: "magenta"
+ width: 10
+ height: 10
+ }
+ }
+}
diff --git a/tests/auto/quick/qquickpositioners/data/horizontal-padding.qml b/tests/auto/quick/qquickpositioners/data/horizontal-padding.qml
new file mode 100644
index 0000000000..d320c4789f
--- /dev/null
+++ b/tests/auto/quick/qquickpositioners/data/horizontal-padding.qml
@@ -0,0 +1,30 @@
+import QtQuick 2.6
+
+Item {
+ width: 640
+ height: 480
+ property bool testRightToLeft: false
+ Row {
+ objectName: "row"
+ layoutDirection: testRightToLeft ? Qt.RightToLeft : Qt.LeftToRight
+ padding: 1; topPadding: 1; leftPadding: 1; rightPadding: 1; bottomPadding: 1
+ Rectangle {
+ objectName: "one"
+ color: "red"
+ width: 50
+ height: 50
+ }
+ Rectangle {
+ objectName: "two"
+ color: "red"
+ width: 20
+ height: 10
+ }
+ Rectangle {
+ objectName: "three"
+ color: "red"
+ width: 40
+ height: 20
+ }
+ }
+}
diff --git a/tests/auto/quick/qquickpositioners/data/repeatertest-padding.qml b/tests/auto/quick/qquickpositioners/data/repeatertest-padding.qml
new file mode 100644
index 0000000000..577d4ef0b7
--- /dev/null
+++ b/tests/auto/quick/qquickpositioners/data/repeatertest-padding.qml
@@ -0,0 +1,53 @@
+import QtQuick 2.6
+
+Item {
+ width: 640
+ height: 480
+ Row {
+ padding: 1; topPadding: 2; leftPadding: 3; rightPadding: 4; bottomPadding: 5
+ Repeater{ model: 3;
+ delegate: Component {
+ Rectangle {
+ color: "red"
+ width: 50
+ height: 50
+ z: {
+ if (index == 0)
+ return 2;
+ else if (index == 1)
+ return 1;
+ else
+ return 3;
+ }
+ objectName: {
+ if (index == 0)
+ return "one";
+ else if (index == 1)
+ return "two";
+ else
+ return "three";
+ }
+ }
+ }
+ }
+ }
+
+ //This crashed once (QTBUG-16959) because the repeater ended up on the end of the list
+ //If this grid just instantiates without crashing, then it has not regressed.
+ Grid {
+ id: grid
+ rows: 2
+ flow: Grid.TopToBottom
+
+ Repeater {
+ model: 13
+ Rectangle {
+ color: "goldenrod"
+ width: 100
+ height: 100
+ radius: 10
+ border.width: 1
+ }
+ }
+ }
+}
diff --git a/tests/auto/quick/qquickpositioners/data/repeatertest.qml b/tests/auto/quick/qquickpositioners/data/repeatertest.qml
index d90e1cf160..ae3d961c75 100644
--- a/tests/auto/quick/qquickpositioners/data/repeatertest.qml
+++ b/tests/auto/quick/qquickpositioners/data/repeatertest.qml
@@ -10,8 +10,22 @@ Item {
color: "red"
width: 50
height: 50
- z: {if(index == 0){2;}else if(index == 1){1;} else{3;}}
- objectName: {if(index == 0){"one";}else if(index == 1){"two";} else{"three";}}
+ z: {
+ if (index == 0)
+ return 2;
+ else if (index == 1)
+ return 1;
+ else
+ return 3;
+ }
+ objectName: {
+ if (index == 0)
+ return "one";
+ else if (index == 1)
+ return "two";
+ else
+ return "three";
+ }
}
}
}
diff --git a/tests/auto/quick/qquickpositioners/data/transitions-padding.qml b/tests/auto/quick/qquickpositioners/data/transitions-padding.qml
new file mode 100644
index 0000000000..e3175c480c
--- /dev/null
+++ b/tests/auto/quick/qquickpositioners/data/transitions-padding.qml
@@ -0,0 +1,239 @@
+import QtQuick 2.6
+
+Rectangle {
+ id: root
+ width: 500
+ height: 500
+
+ property int duration: 50
+
+ property real incrementalSize: 5
+
+ property int populateTransitionsDone
+ property int addTransitionsDone
+ property int displaceTransitionsDone
+
+ property var targetTrans_items: new Object()
+ property var targetTrans_targetIndexes: new Array()
+ property var targetTrans_targetItems: new Array()
+
+ property var displacedTrans_items: new Object()
+ property var displacedTrans_targetIndexes: new Array()
+ property var displacedTrans_targetItems: new Array()
+
+ // for QQmlListProperty types
+ function copyList(propList) {
+ var temp = new Array()
+ for (var i=0; i<propList.length; i++)
+ temp.push(propList[i])
+ return temp
+ }
+
+ function checkPos(x, y, name) {
+ if (Qt.point(x, y) == targetItems_transitionFrom)
+ model_targetItems_transitionFrom.addItem(name, "")
+ if (Qt.point(x, y) == displacedItems_transitionVia)
+ model_displacedItems_transitionVia.addItem(name, "")
+ }
+
+ Component.onCompleted: {
+ if (dynamicallyPopulate) {
+ for (var i=0; i<30; i++)
+ testModel.addItem("item " + i, "")
+ }
+ }
+
+ Transition {
+ id: populateTransition
+ enabled: usePopulateTransition
+
+ SequentialAnimation {
+ ScriptAction {
+ script: {
+ root.targetTrans_items[populateTransition.ViewTransition.item.nameData] = populateTransition.ViewTransition.index
+ root.targetTrans_targetIndexes.push(populateTransition.ViewTransition.targetIndexes)
+ root.targetTrans_targetItems.push(root.copyList(populateTransition.ViewTransition.targetItems))
+ }
+ }
+ ParallelAnimation {
+ NumberAnimation { properties: "x"; from: targetItems_transitionFrom.x; duration: root.duration }
+ NumberAnimation { properties: "y"; from: targetItems_transitionFrom.y; duration: root.duration }
+ }
+
+ ScriptAction { script: root.populateTransitionsDone += 1 }
+ }
+ }
+
+ Transition {
+ id: addTransition
+ enabled: enableAddTransition
+
+ SequentialAnimation {
+ ScriptAction {
+ script: {
+ root.targetTrans_items[addTransition.ViewTransition.item.nameData] = addTransition.ViewTransition.index
+ root.targetTrans_targetIndexes.push(addTransition.ViewTransition.targetIndexes)
+ root.targetTrans_targetItems.push(root.copyList(addTransition.ViewTransition.targetItems))
+ }
+ }
+ ParallelAnimation {
+ NumberAnimation { properties: "x"; from: targetItems_transitionFrom.x; duration: root.duration }
+ NumberAnimation { properties: "y"; from: targetItems_transitionFrom.y; duration: root.duration }
+ }
+
+ ScriptAction { script: root.addTransitionsDone += 1 }
+ }
+ }
+
+ Transition {
+ id: displaced
+
+ SequentialAnimation {
+ ScriptAction {
+ script: {
+ root.displacedTrans_items[displaced.ViewTransition.item.nameData] = displaced.ViewTransition.index
+ root.displacedTrans_targetIndexes.push(displaced.ViewTransition.targetIndexes)
+ root.displacedTrans_targetItems.push(root.copyList(displaced.ViewTransition.targetItems))
+ }
+ }
+ ParallelAnimation {
+ NumberAnimation { properties: "x"; duration: root.duration; to: displacedItems_transitionVia.x }
+ NumberAnimation { properties: "y"; duration: root.duration; to: displacedItems_transitionVia.y }
+ }
+ NumberAnimation { properties: "x,y"; duration: root.duration }
+
+ ScriptAction { script: root.displaceTransitionsDone += 1 }
+ }
+
+ }
+
+ Row {
+ objectName: "row"
+
+ property int count: children.length - 1 // omit Repeater
+
+ x: 50; y: 50
+ width: 400; height: 400
+ padding: 1; topPadding: 2; leftPadding: 3; rightPadding: 4; bottomPadding: 5
+ Repeater {
+ objectName: "repeater"
+ model: testedPositioner == "row" ? testModel : undefined
+ Rectangle {
+ property string nameData: name
+ objectName: "wrapper"
+ width: 30 + index*root.incrementalSize
+ height: 30 + index*root.incrementalSize
+ border.width: 1
+ Column {
+ Text { text: index }
+ Text { objectName: "name"; text: name }
+ Text { text: parent.parent.y }
+ }
+ onXChanged: root.checkPos(x, y, name)
+ onYChanged: root.checkPos(x, y, name)
+ }
+ }
+
+ populate: populateTransition
+ add: addTransition
+ move: displaced
+ }
+
+ Column {
+ objectName: "column"
+
+ property int count: children.length - 1 // omit Repeater
+
+ x: 50; y: 50
+ width: 400; height: 400
+ padding: 1; topPadding: 2; leftPadding: 3; rightPadding: 4; bottomPadding: 5
+ Repeater {
+ objectName: "repeater"
+ model: testedPositioner == "column" ? testModel : undefined
+ Rectangle {
+ property string nameData: name
+ objectName: "wrapper"
+ width: 30 + index*root.incrementalSize
+ height: 30 + index*root.incrementalSize
+ border.width: 1
+ Column {
+ Text { text: index }
+ Text { objectName: "name"; text: name }
+ Text { text: parent.parent.y }
+ }
+ onXChanged: root.checkPos(x, y, name)
+ onYChanged: root.checkPos(x, y, name)
+ }
+ }
+
+ populate: populateTransition
+ add: addTransition
+ move: displaced
+ }
+
+ Grid {
+ objectName: "grid"
+
+ property int count: children.length - 1 // omit Repeater
+
+ x: 50; y: 50
+ width: 400; height: 400
+ padding: 1; topPadding: 2; leftPadding: 3; rightPadding: 4; bottomPadding: 5
+ Repeater {
+ objectName: "repeater"
+ model: testedPositioner == "grid" ? testModel : undefined
+ Rectangle {
+ property string nameData: name
+ objectName: "wrapper"
+ width: 30 + index*root.incrementalSize
+ height: 30 + index*root.incrementalSize
+ border.width: 1
+ Column {
+ Text { text: index }
+ Text { objectName: "name"; text: name }
+ Text { text: parent.parent.y }
+ }
+
+ onXChanged: root.checkPos(x, y, name)
+ onYChanged: root.checkPos(x, y, name)
+ }
+ }
+
+ populate: populateTransition
+ add: addTransition
+ move: displaced
+ }
+
+ Flow {
+ objectName: "flow"
+
+ property int count: children.length - 1 // omit Repeater
+
+ x: 50; y: 50
+ width: 400; height: 400
+ padding: 1; topPadding: 2; leftPadding: 3; rightPadding: 4; bottomPadding: 5
+ Repeater {
+ objectName: "repeater"
+ model: testedPositioner == "flow" ? testModel : undefined
+ Rectangle {
+ property string nameData: name
+ objectName: "wrapper"
+ width: 30 + index*root.incrementalSize
+ height: 30 + index*root.incrementalSize
+ border.width: 1
+ Column {
+ Text { text: index }
+ Text { objectName: "name"; text: name }
+ Text { text: parent.parent.x + " " + parent.parent.y }
+ }
+ onXChanged: root.checkPos(x, y, name)
+ onYChanged: root.checkPos(x, y, name)
+ }
+ }
+
+ populate: populateTransition
+ add: addTransition
+ move: displaced
+ }
+}
+
diff --git a/tests/auto/quick/qquickpositioners/tst_qquickpositioners.cpp b/tests/auto/quick/qquickpositioners/tst_qquickpositioners.cpp
index 3c44041ca5..69359503fe 100644
--- a/tests/auto/quick/qquickpositioners/tst_qquickpositioners.cpp
+++ b/tests/auto/quick/qquickpositioners/tst_qquickpositioners.cpp
@@ -53,33 +53,50 @@ public:
private slots:
void test_horizontal();
+ void test_horizontal_padding();
void test_horizontal_rtl();
void test_horizontal_spacing();
void test_horizontal_spacing_rightToLeft();
void test_horizontal_animated();
+ void test_horizontal_animated_padding();
void test_horizontal_animated_rightToLeft();
+ void test_horizontal_animated_rightToLeft_padding();
void test_horizontal_animated_disabled();
+ void test_horizontal_animated_disabled_padding();
void test_vertical();
+ void test_vertical_padding();
void test_vertical_spacing();
void test_vertical_animated();
+ void test_vertical_animated_padding();
void test_grid();
+ void test_grid_padding();
void test_grid_topToBottom();
void test_grid_rightToLeft();
void test_grid_spacing();
void test_grid_row_column_spacing();
void test_grid_animated();
+ void test_grid_animated_padding();
void test_grid_animated_rightToLeft();
+ void test_grid_animated_rightToLeft_padding();
void test_grid_zero_columns();
void test_grid_H_alignment();
+ void test_grid_H_alignment_padding();
void test_grid_V_alignment();
+ void test_grid_V_alignment_padding();
void test_propertychanges();
void test_repeater();
+ void test_repeater_padding();
void test_flow();
+ void test_flow_padding();
void test_flow_rightToLeft();
void test_flow_topToBottom();
+ void test_flow_topToBottom_padding();
void test_flow_resize();
+ void test_flow_resize_padding();
void test_flow_resize_rightToLeft();
+ void test_flow_resize_rightToLeft_padding();
void test_flow_implicit_resize();
+ void test_flow_implicit_resize_padding();
void test_conflictinganchors();
void test_mirroring();
void test_allInvisible();
@@ -198,18 +215,25 @@ void tst_qquickpositioners::addTransitions_grid_data()
// (adding items further down the grid can cause displace transitions at
// previous indexes, since grid is auto-resized to tightly fit all of its items)
+ QTest::addColumn<QString>("qmlFile");
QTest::addColumn<int>("initialItemCount");
QTest::addColumn<int>("insertionIndex");
QTest::addColumn<int>("insertionCount");
QTest::addColumn<ListRange>("expectedDisplacedIndexes");
- QTest::newRow("add one @ start") << 10 << 0 << 1 << ListRange(0, 9);
- QTest::newRow("add one @ middle") << 10 << 5 << 1 << ListRange(3, 3) + ListRange(5, 9);
- QTest::newRow("add one @ end") << 10 << 10 << 1 << ListRange(3, 3) + ListRange(7, 7);
+ QTest::newRow("add one @ start") << "transitions.qml" << 10 << 0 << 1 << ListRange(0, 9);
+ QTest::newRow("add one @ middle") << "transitions.qml" << 10 << 5 << 1 << ListRange(3, 3) + ListRange(5, 9);
+ QTest::newRow("add one @ end") << "transitions.qml" << 10 << 10 << 1 << ListRange(3, 3) + ListRange(7, 7);
+ QTest::newRow("padding, add one @ start") << "transitions-padding.qml" << 10 << 0 << 1 << ListRange(0, 9);
+ QTest::newRow("padding, add one @ middle") << "transitions-padding.qml" << 10 << 5 << 1 << ListRange(3, 3) + ListRange(5, 9);
+ QTest::newRow("padding, add one @ end") << "transitions-padding.qml" << 10 << 10 << 1 << ListRange(3, 3) + ListRange(7, 7);
- QTest::newRow("add multiple @ start") << 10 << 0 << 3 << ListRange(0, 9);
- QTest::newRow("add multiple @ middle") << 10 << 5 << 3 << ListRange(1, 3) + ListRange(5, 9);
- QTest::newRow("add multiple @ end") << 10 << 10 << 3 << ListRange(1, 3) + ListRange(5, 7) + ListRange(9, 9);
+ QTest::newRow("add multiple @ start") << "transitions.qml" << 10 << 0 << 3 << ListRange(0, 9);
+ QTest::newRow("add multiple @ middle") << "transitions.qml" << 10 << 5 << 3 << ListRange(1, 3) + ListRange(5, 9);
+ QTest::newRow("add multiple @ end") << "transitions.qml" << 10 << 10 << 3 << ListRange(1, 3) + ListRange(5, 7) + ListRange(9, 9);
+ QTest::newRow("padding, add multiple @ start") << "transitions-padding.qml" << 10 << 0 << 3 << ListRange(0, 9);
+ QTest::newRow("padding, add multiple @ middle") << "transitions-padding.qml" << 10 << 5 << 3 << ListRange(1, 3) + ListRange(5, 9);
+ QTest::newRow("padding, add multiple @ end") << "transitions-padding.qml" << 10 << 10 << 3 << ListRange(1, 3) + ListRange(5, 7) + ListRange(9, 9);
}
void tst_qquickpositioners::addTransitions_flow()
@@ -253,17 +277,24 @@ void tst_qquickpositioners::moveTransitions_grid_data()
// (removing items further down the grid can cause displace transitions at
// previous indexes, since grid is auto-resized to tightly fit all of its items)
+ QTest::addColumn<QString>("qmlFile");
QTest::addColumn<int>("initialItemCount");
QTest::addColumn<ListChange>("change");
QTest::addColumn<ListRange>("expectedDisplacedIndexes");
- QTest::newRow("remove one @ start") << 10 << ListChange::remove(0, 1) << ListRange(1, 9);
- QTest::newRow("remove one @ middle") << 10 << ListChange::remove(4, 1) << ListRange(2, 3) + ListRange(5, 9);
- QTest::newRow("remove one @ end") << 10 << ListChange::remove(9, 1) << ListRange(2, 3) + ListRange(6, 7);
+ QTest::newRow("remove one @ start") << "transitions.qml" << 10 << ListChange::remove(0, 1) << ListRange(1, 9);
+ QTest::newRow("remove one @ middle") << "transitions.qml" << 10 << ListChange::remove(4, 1) << ListRange(2, 3) + ListRange(5, 9);
+ QTest::newRow("remove one @ end") << "transitions.qml" << 10 << ListChange::remove(9, 1) << ListRange(2, 3) + ListRange(6, 7);
+ QTest::newRow("padding, remove one @ start") << "transitions-padding.qml" << 10 << ListChange::remove(0, 1) << ListRange(1, 9);
+ QTest::newRow("padding, remove one @ middle") << "transitions-padding.qml" << 10 << ListChange::remove(4, 1) << ListRange(2, 3) + ListRange(5, 9);
+ QTest::newRow("padding, remove one @ end") << "transitions-padding.qml" << 10 << ListChange::remove(9, 1) << ListRange(2, 3) + ListRange(6, 7);
- QTest::newRow("remove multiple @ start") << 10 << ListChange::remove(0, 3) << ListRange(3, 9);
- QTest::newRow("remove multiple @ middle") << 10 << ListChange::remove(4, 3) << ListRange(1, 3) + ListRange(7, 9);
- QTest::newRow("remove multiple @ end") << 10 << ListChange::remove(7, 3) << ListRange(1, 3) + ListRange(5, 6);
+ QTest::newRow("remove multiple @ start") << "transitions.qml" << 10 << ListChange::remove(0, 3) << ListRange(3, 9);
+ QTest::newRow("remove multiple @ middle") << "transitions.qml" << 10 << ListChange::remove(4, 3) << ListRange(1, 3) + ListRange(7, 9);
+ QTest::newRow("remove multiple @ end") << "transitions.qml" << 10 << ListChange::remove(7, 3) << ListRange(1, 3) + ListRange(5, 6);
+ QTest::newRow("padding, remove multiple @ start") << "transitions-padding.qml" << 10 << ListChange::remove(0, 3) << ListRange(3, 9);
+ QTest::newRow("padding, remove multiple @ middle") << "transitions-padding.qml" << 10 << ListChange::remove(4, 3) << ListRange(1, 3) + ListRange(7, 9);
+ QTest::newRow("padding, remove multiple @ end") << "transitions-padding.qml" << 10 << ListChange::remove(7, 3) << ListRange(1, 3) + ListRange(5, 6);
}
void tst_qquickpositioners::moveTransitions_flow()
@@ -305,6 +336,185 @@ void tst_qquickpositioners::test_horizontal()
QQuickItem *row = window->rootObject()->findChild<QQuickItem*>("row");
QCOMPARE(row->width(), 110.0);
QCOMPARE(row->height(), 50.0);
+
+ // test padding
+ row->setProperty("padding", 1);
+ row->setProperty("topPadding", 2);
+ row->setProperty("leftPadding", 3);
+ row->setProperty("rightPadding", 4);
+ row->setProperty("bottomPadding", 5);
+
+ QTRY_COMPARE(row->width(), 117.0);
+ QCOMPARE(row->height(), 57.0);
+
+ QCOMPARE(one->x(), 3.0);
+ QCOMPARE(one->y(), 2.0);
+ QCOMPARE(two->x(), 53.0);
+ QCOMPARE(two->y(), 2.0);
+ QCOMPARE(three->x(), 73.0);
+ QCOMPARE(three->y(), 2.0);
+}
+
+void tst_qquickpositioners::test_horizontal_padding()
+{
+ QScopedPointer<QQuickView> window(createView(testFile("horizontal.qml")));
+
+ window->rootObject()->setProperty("testRightToLeft", false);
+
+ QQuickRectangle *one = window->rootObject()->findChild<QQuickRectangle*>("one");
+ QVERIFY(one != 0);
+
+ QQuickRectangle *two = window->rootObject()->findChild<QQuickRectangle*>("two");
+ QVERIFY(two != 0);
+
+ QQuickRectangle *three = window->rootObject()->findChild<QQuickRectangle*>("three");
+ QVERIFY(three != 0);
+
+ QCOMPARE(one->x(), 0.0);
+ QCOMPARE(one->y(), 0.0);
+ QCOMPARE(two->x(), 50.0);
+ QCOMPARE(two->y(), 0.0);
+ QCOMPARE(three->x(), 70.0);
+ QCOMPARE(three->y(), 0.0);
+
+ QQuickItem *row = window->rootObject()->findChild<QQuickItem*>("row");
+ QCOMPARE(row->width(), 110.0);
+ QCOMPARE(row->height(), 50.0);
+
+ QQuickRow *obj = qobject_cast<QQuickRow*>(row);
+ QVERIFY(obj != 0);
+
+ QCOMPARE(row->property("padding").toDouble(), 0.0);
+ QCOMPARE(row->property("topPadding").toDouble(), 0.0);
+ QCOMPARE(row->property("leftPadding").toDouble(), 0.0);
+ QCOMPARE(row->property("rightPadding").toDouble(), 0.0);
+ QCOMPARE(row->property("bottomPadding").toDouble(), 0.0);
+
+ obj->setPadding(1.0);
+
+ QCOMPARE(row->property("padding").toDouble(), 1.0);
+ QCOMPARE(row->property("topPadding").toDouble(), 1.0);
+ QCOMPARE(row->property("leftPadding").toDouble(), 1.0);
+ QCOMPARE(row->property("rightPadding").toDouble(), 1.0);
+ QCOMPARE(row->property("bottomPadding").toDouble(), 1.0);
+
+ QTRY_COMPARE(row->width(), 112.0);
+ QCOMPARE(row->height(), 52.0);
+
+ QCOMPARE(one->x(), 1.0);
+ QCOMPARE(one->y(), 1.0);
+ QCOMPARE(two->x(), 51.0);
+ QCOMPARE(two->y(), 1.0);
+ QCOMPARE(three->x(), 71.0);
+ QCOMPARE(three->y(), 1.0);
+
+ obj->setTopPadding(2.0);
+
+ QCOMPARE(row->property("padding").toDouble(), 1.0);
+ QCOMPARE(row->property("topPadding").toDouble(), 2.0);
+ QCOMPARE(row->property("leftPadding").toDouble(), 1.0);
+ QCOMPARE(row->property("rightPadding").toDouble(), 1.0);
+ QCOMPARE(row->property("bottomPadding").toDouble(), 1.0);
+
+ QTRY_COMPARE(row->height(), 53.0);
+ QCOMPARE(row->width(), 112.0);
+
+ QCOMPARE(one->x(), 1.0);
+ QCOMPARE(one->y(), 2.0);
+ QCOMPARE(two->x(), 51.0);
+ QCOMPARE(two->y(), 2.0);
+ QCOMPARE(three->x(), 71.0);
+ QCOMPARE(three->y(), 2.0);
+
+ obj->setLeftPadding(3.0);
+
+ QCOMPARE(row->property("padding").toDouble(), 1.0);
+ QCOMPARE(row->property("topPadding").toDouble(), 2.0);
+ QCOMPARE(row->property("leftPadding").toDouble(), 3.0);
+ QCOMPARE(row->property("rightPadding").toDouble(), 1.0);
+ QCOMPARE(row->property("bottomPadding").toDouble(), 1.0);
+
+ QTRY_COMPARE(row->width(), 114.0);
+ QCOMPARE(row->height(), 53.0);
+
+ QCOMPARE(one->x(), 3.0);
+ QCOMPARE(one->y(), 2.0);
+ QCOMPARE(two->x(), 53.0);
+ QCOMPARE(two->y(), 2.0);
+ QCOMPARE(three->x(), 73.0);
+ QCOMPARE(three->y(), 2.0);
+
+ obj->setRightPadding(4.0);
+
+ QCOMPARE(row->property("padding").toDouble(), 1.0);
+ QCOMPARE(row->property("topPadding").toDouble(), 2.0);
+ QCOMPARE(row->property("leftPadding").toDouble(), 3.0);
+ QCOMPARE(row->property("rightPadding").toDouble(), 4.0);
+ QCOMPARE(row->property("bottomPadding").toDouble(), 1.0);
+
+ QTRY_COMPARE(row->width(), 117.0);
+ QCOMPARE(row->height(), 53.0);
+
+ QCOMPARE(one->x(), 3.0);
+ QCOMPARE(one->y(), 2.0);
+ QCOMPARE(two->x(), 53.0);
+ QCOMPARE(two->y(), 2.0);
+ QCOMPARE(three->x(), 73.0);
+ QCOMPARE(three->y(), 2.0);
+
+ obj->setBottomPadding(5.0);
+
+ QCOMPARE(row->property("padding").toDouble(), 1.0);
+ QCOMPARE(row->property("topPadding").toDouble(), 2.0);
+ QCOMPARE(row->property("leftPadding").toDouble(), 3.0);
+ QCOMPARE(row->property("rightPadding").toDouble(), 4.0);
+ QCOMPARE(row->property("bottomPadding").toDouble(), 5.0);
+
+ QTRY_COMPARE(row->height(), 57.0);
+ QCOMPARE(row->width(), 117.0);
+
+ QCOMPARE(one->x(), 3.0);
+ QCOMPARE(one->y(), 2.0);
+ QCOMPARE(two->x(), 53.0);
+ QCOMPARE(two->y(), 2.0);
+ QCOMPARE(three->x(), 73.0);
+ QCOMPARE(three->y(), 2.0);
+
+ obj->resetBottomPadding();
+ QCOMPARE(row->property("bottomPadding").toDouble(), 1.0);
+ QTRY_COMPARE(row->height(), 53.0);
+ QCOMPARE(row->width(), 117.0);
+
+ obj->resetRightPadding();
+ QCOMPARE(row->property("rightPadding").toDouble(), 1.0);
+ QTRY_COMPARE(row->width(), 114.0);
+ QCOMPARE(row->height(), 53.0);
+
+ obj->resetLeftPadding();
+ QCOMPARE(row->property("leftPadding").toDouble(), 1.0);
+ QTRY_COMPARE(row->width(), 112.0);
+ QCOMPARE(row->height(), 53.0);
+
+ obj->resetTopPadding();
+ QCOMPARE(row->property("topPadding").toDouble(), 1.0);
+ QTRY_COMPARE(row->height(), 52.0);
+ QCOMPARE(row->width(), 112.0);
+
+ obj->resetPadding();
+ QCOMPARE(row->property("padding").toDouble(), 0.0);
+ QCOMPARE(row->property("topPadding").toDouble(), 0.0);
+ QCOMPARE(row->property("leftPadding").toDouble(), 0.0);
+ QCOMPARE(row->property("rightPadding").toDouble(), 0.0);
+ QCOMPARE(row->property("bottomPadding").toDouble(), 0.0);
+ QTRY_COMPARE(row->height(), 50.0);
+ QCOMPARE(row->width(), 110.0);
+
+ QCOMPARE(one->x(), 0.0);
+ QCOMPARE(one->y(), 0.0);
+ QCOMPARE(two->x(), 50.0);
+ QCOMPARE(two->y(), 0.0);
+ QCOMPARE(three->x(), 70.0);
+ QCOMPARE(three->y(), 0.0);
}
void tst_qquickpositioners::test_horizontal_rtl()
@@ -333,6 +543,36 @@ void tst_qquickpositioners::test_horizontal_rtl()
QCOMPARE(row->width(), 110.0);
QCOMPARE(row->height(), 50.0);
+ // test padding
+ row->setProperty("padding", 1);
+ row->setProperty("topPadding", 2);
+ row->setProperty("leftPadding", 3);
+ row->setProperty("rightPadding", 4);
+ row->setProperty("bottomPadding", 5);
+
+ QTRY_COMPARE(row->width(), 117.0);
+ QCOMPARE(row->height(), 57.0);
+
+ QCOMPARE(one->x(), 63.0);
+ QCOMPARE(one->y(), 2.0);
+ QCOMPARE(two->x(), 43.0);
+ QCOMPARE(two->y(), 2.0);
+ QCOMPARE(three->x(), 3.0);
+ QCOMPARE(three->y(), 2.0);
+
+ row->setProperty("topPadding", 0);
+ row->setProperty("leftPadding", 0);
+ row->setProperty("rightPadding", 0);
+ row->setProperty("bottomPadding", 0);
+ row->setProperty("padding", 0);
+
+ QTRY_COMPARE(one->x(), 60.0);
+ QCOMPARE(one->y(), 0.0);
+ QCOMPARE(two->x(), 40.0);
+ QCOMPARE(two->y(), 0.0);
+ QCOMPARE(three->x(), 0.0);
+ QCOMPARE(three->y(), 0.0);
+
// Change the width of the row and check that items stay to the right
row->setWidth(200);
QTRY_COMPARE(one->x(), 150.0);
@@ -342,6 +582,18 @@ void tst_qquickpositioners::test_horizontal_rtl()
QCOMPARE(three->x(), 90.0);
QCOMPARE(three->y(), 0.0);
+ row->setProperty("padding", 1);
+ row->setProperty("topPadding", 2);
+ row->setProperty("leftPadding", 3);
+ row->setProperty("rightPadding", 4);
+ row->setProperty("bottomPadding", 5);
+
+ QTRY_COMPARE(one->x(), 146.0);
+ QCOMPARE(one->y(), 2.0);
+ QCOMPARE(two->x(), 126.0);
+ QCOMPARE(two->y(), 2.0);
+ QCOMPARE(three->x(), 86.0);
+ QCOMPARE(three->y(), 2.0);
}
void tst_qquickpositioners::test_horizontal_spacing()
@@ -370,6 +622,22 @@ void tst_qquickpositioners::test_horizontal_spacing()
QCOMPARE(row->width(), 130.0);
QCOMPARE(row->height(), 50.0);
+ // test padding
+ row->setProperty("padding", 1);
+ row->setProperty("topPadding", 2);
+ row->setProperty("leftPadding", 3);
+ row->setProperty("rightPadding", 4);
+ row->setProperty("bottomPadding", 5);
+
+ QTRY_COMPARE(row->width(), 137.0);
+ QCOMPARE(row->height(), 57.0);
+
+ QCOMPARE(one->x(), 3.0);
+ QCOMPARE(one->y(), 2.0);
+ QCOMPARE(two->x(), 63.0);
+ QCOMPARE(two->y(), 2.0);
+ QCOMPARE(three->x(), 93.0);
+ QCOMPARE(three->y(), 2.0);
}
void tst_qquickpositioners::test_horizontal_spacing_rightToLeft()
@@ -391,13 +659,29 @@ void tst_qquickpositioners::test_horizontal_spacing_rightToLeft()
QCOMPARE(one->y(), 0.0);
QCOMPARE(two->x(), 50.0);
QCOMPARE(two->y(), 0.0);
- QCOMPARE(three->x(), 00.0);
+ QCOMPARE(three->x(), 0.0);
QCOMPARE(three->y(), 0.0);
QQuickItem *row = window->rootObject()->findChild<QQuickItem*>("row");
QCOMPARE(row->width(), 130.0);
QCOMPARE(row->height(), 50.0);
+ // test padding
+ row->setProperty("padding", 1);
+ row->setProperty("topPadding", 2);
+ row->setProperty("leftPadding", 3);
+ row->setProperty("rightPadding", 4);
+ row->setProperty("bottomPadding", 5);
+
+ QTRY_COMPARE(row->width(), 137.0);
+ QCOMPARE(row->height(), 57.0);
+
+ QCOMPARE(one->x(), 83.0);
+ QCOMPARE(one->y(), 2.0);
+ QCOMPARE(two->x(), 53.0);
+ QCOMPARE(two->y(), 2.0);
+ QCOMPARE(three->x(), 3.0);
+ QCOMPARE(three->y(), 2.0);
}
void tst_qquickpositioners::test_horizontal_animated()
@@ -453,6 +737,70 @@ void tst_qquickpositioners::test_horizontal_animated()
}
+void tst_qquickpositioners::test_horizontal_animated_padding()
+{
+ QScopedPointer<QQuickView> window(createView(testFile("horizontal-animated.qml"), false));
+
+ window->rootObject()->setProperty("testRightToLeft", false);
+
+ QQuickRectangle *one = window->rootObject()->findChild<QQuickRectangle*>("one");
+ QVERIFY(one != 0);
+
+ QQuickRectangle *two = window->rootObject()->findChild<QQuickRectangle*>("two");
+ QVERIFY(two != 0);
+
+ QQuickRectangle *three = window->rootObject()->findChild<QQuickRectangle*>("three");
+ QVERIFY(three != 0);
+
+ //Note that they animate in
+ QCOMPARE(one->x(), -100.0);
+ QCOMPARE(two->x(), -100.0);
+ QCOMPARE(three->x(), -100.0);
+
+ QVERIFY(QTest::qWaitForWindowExposed(window.data())); //It may not relayout until the next frame, so it needs to be drawn
+
+ QQuickItem *row = window->rootObject()->findChild<QQuickItem*>("row");
+ QVERIFY(row);
+ QCOMPARE(row->width(), 100.0);
+ QCOMPARE(row->height(), 50.0);
+
+ // test padding
+ row->setProperty("padding", 1);
+ row->setProperty("topPadding", 2);
+ row->setProperty("leftPadding", 3);
+ row->setProperty("rightPadding", 4);
+ row->setProperty("bottomPadding", 5);
+
+ QTRY_COMPARE(row->width(), 107.0);
+ QCOMPARE(row->height(), 57.0);
+
+ //QTRY_COMPARE used instead of waiting for the expected time of animation completion
+ //Note that this means the duration of the animation is NOT tested
+
+ QTRY_COMPARE(one->x(), 3.0);
+ QTRY_COMPARE(one->y(), 2.0);
+ QTRY_COMPARE(two->isVisible(), false);
+ QTRY_COMPARE(two->x(), -100.0);//Not 'in' yet
+ QTRY_COMPARE(two->y(), 0.0);
+ QTRY_COMPARE(three->x(), 53.0);
+ QTRY_COMPARE(three->y(), 2.0);
+
+ //Add 'two'
+ two->setVisible(true);
+ QTRY_COMPARE(two->isVisible(), true);
+ QTRY_COMPARE(row->width(), 157.0);
+ QTRY_COMPARE(row->height(), 57.0);
+
+ QTest::qWait(0);//Let the animation start
+ QVERIFY(two->x() >= -100.0 && two->x() < 53.0);
+ QVERIFY(three->x() >= 53.0 && three->x() < 103.0);
+
+ QTRY_COMPARE(two->y(), 2.0);
+ QTRY_COMPARE(two->x(), 53.0);
+ QTRY_COMPARE(three->x(), 103.0);
+
+}
+
void tst_qquickpositioners::test_horizontal_animated_rightToLeft()
{
QScopedPointer<QQuickView> window(createView(testFile("horizontal-animated.qml"), false));
@@ -508,6 +856,72 @@ void tst_qquickpositioners::test_horizontal_animated_rightToLeft()
}
+void tst_qquickpositioners::test_horizontal_animated_rightToLeft_padding()
+{
+ QScopedPointer<QQuickView> window(createView(testFile("horizontal-animated.qml"), false));
+
+ window->rootObject()->setProperty("testRightToLeft", true);
+
+ QQuickRectangle *one = window->rootObject()->findChild<QQuickRectangle*>("one");
+ QVERIFY(one != 0);
+
+ QQuickRectangle *two = window->rootObject()->findChild<QQuickRectangle*>("two");
+ QVERIFY(two != 0);
+
+ QQuickRectangle *three = window->rootObject()->findChild<QQuickRectangle*>("three");
+ QVERIFY(three != 0);
+
+ //Note that they animate in
+ QCOMPARE(one->x(), -100.0);
+ QCOMPARE(two->x(), -100.0);
+ QCOMPARE(three->x(), -100.0);
+
+ QVERIFY(QTest::qWaitForWindowExposed(window.data())); //It may not relayout until the next frame, so it needs to be drawn
+
+ QQuickItem *row = window->rootObject()->findChild<QQuickItem*>("row");
+ QVERIFY(row);
+ QCOMPARE(row->width(), 100.0);
+ QCOMPARE(row->height(), 50.0);
+
+ // test padding
+ row->setProperty("padding", 1);
+ row->setProperty("topPadding", 2);
+ row->setProperty("leftPadding", 3);
+ row->setProperty("rightPadding", 4);
+ row->setProperty("bottomPadding", 5);
+
+ QTRY_COMPARE(row->width(), 107.0);
+ QCOMPARE(row->height(), 57.0);
+
+ //QTRY_COMPARE used instead of waiting for the expected time of animation completion
+ //Note that this means the duration of the animation is NOT tested
+
+ QTRY_COMPARE(one->x(), 53.0);
+ QTRY_COMPARE(one->y(), 2.0);
+ QTRY_COMPARE(two->isVisible(), false);
+ QTRY_COMPARE(two->x(), -100.0);//Not 'in' yet
+ QTRY_COMPARE(two->y(), 0.0);
+ QTRY_COMPARE(three->x(), 3.0);
+ QTRY_COMPARE(three->y(), 2.0);
+
+ //Add 'two'
+ two->setVisible(true);
+ QTRY_COMPARE(two->isVisible(), true);
+
+ // New size should propagate after visible change
+ QTRY_COMPARE(row->width(), 157.0);
+ QTRY_COMPARE(row->height(), 57.0);
+
+ QTest::qWait(0);//Let the animation start
+ QVERIFY(one->x() >= 53.0 && one->x() < 100);
+ QVERIFY(two->x() >= -100.0 && two->x() < 53.0);
+
+ QTRY_COMPARE(one->x(), 103.0);
+ QTRY_COMPARE(two->y(), 2.0);
+ QTRY_COMPARE(two->x(), 53.0);
+
+}
+
void tst_qquickpositioners::test_horizontal_animated_disabled()
{
QScopedPointer<QQuickView> window(createView(testFile("horizontal-animated-disabled.qml")));
@@ -526,6 +940,54 @@ void tst_qquickpositioners::test_horizontal_animated_disabled()
qApp->processEvents();
+ // test padding
+ row->setProperty("padding", 1);
+ row->setProperty("topPadding", 2);
+ row->setProperty("leftPadding", 3);
+ row->setProperty("rightPadding", 4);
+ row->setProperty("bottomPadding", 5);
+
+ QTRY_COMPARE(row->width(), 107.0);
+ QCOMPARE(row->height(), 57.0);
+
+ QCOMPARE(one->x(), 3.0);
+ QCOMPARE(one->y(), 2.0);
+ QCOMPARE(two->isVisible(), false);
+ QCOMPARE(two->x(), -100.0);//Not 'in' yet
+ QCOMPARE(two->y(), 0.0);
+ QCOMPARE(three->x(), 53.0);
+ QCOMPARE(three->y(), 2.0);
+
+ //Add 'two'
+ two->setVisible(true);
+ QCOMPARE(two->isVisible(), true);
+ QTRY_COMPARE(row->width(), 157.0);
+ QTRY_COMPARE(row->height(), 57.0);
+
+ QTRY_COMPARE(two->y(), 2.0);
+ QTRY_COMPARE(two->x(), 53.0);
+ QTRY_COMPARE(three->x(), 103.0);
+
+}
+
+void tst_qquickpositioners::test_horizontal_animated_disabled_padding()
+{
+ QScopedPointer<QQuickView> window(createView(testFile("horizontal-animated-disabled.qml")));
+
+ QQuickRectangle *one = window->rootObject()->findChild<QQuickRectangle*>("one");
+ QVERIFY(one != 0);
+
+ QQuickRectangle *two = window->rootObject()->findChild<QQuickRectangle*>("two");
+ QVERIFY(two != 0);
+
+ QQuickRectangle *three = window->rootObject()->findChild<QQuickRectangle*>("three");
+ QVERIFY(three != 0);
+
+ QQuickItem *row = window->rootObject()->findChild<QQuickItem*>("row");
+ QVERIFY(row);
+
+ qApp->processEvents();
+
QCOMPARE(one->x(), 0.0);
QCOMPARE(one->y(), 0.0);
QCOMPARE(two->isVisible(), false);
@@ -547,6 +1009,7 @@ void tst_qquickpositioners::test_horizontal_animated_disabled()
void tst_qquickpositioners::populateTransitions(const QString &positionerObjectName)
{
+ QFETCH(QString, qmlFile);
QFETCH(bool, dynamicallyPopulate);
QFETCH(bool, usePopulateTransition);
@@ -574,7 +1037,7 @@ void tst_qquickpositioners::populateTransitions(const QString &positionerObjectN
ctxt->setContextProperty("targetItems_transitionFrom", targetItems_transitionFrom);
ctxt->setContextProperty("displacedItems_transitionVia", displacedItems_transitionVia);
ctxt->setContextProperty("testedPositioner", positionerObjectName);
- window->setSource(testFileUrl("transitions.qml"));
+ window->setSource(testFileUrl(qmlFile));
QQuickItem *positioner = window->rootObject()->findChild<QQuickItem*>(positionerObjectName);
QVERIFY(positioner);
@@ -619,18 +1082,24 @@ void tst_qquickpositioners::populateTransitions(const QString &positionerObjectN
void tst_qquickpositioners::populateTransitions_data()
{
+ QTest::addColumn<QString>("qmlFile");
QTest::addColumn<bool>("dynamicallyPopulate");
QTest::addColumn<bool>("usePopulateTransition");
- QTest::newRow("statically populate") << false << true;
- QTest::newRow("statically populate, no populate transition") << false << false;
+ QTest::newRow("statically populate") << "transitions.qml" << false << true;
+ QTest::newRow("statically populate, no populate transition") << "transitions.qml" << false << false;
+ QTest::newRow("padding, statically populate") << "transitions-padding.qml" << false << true;
+ QTest::newRow("padding, statically populate, no populate transition") << "transitions-padding.qml" << false << false;
- QTest::newRow("dynamically populate") << true << true;
- QTest::newRow("dynamically populate, no populate transition") << true << false;
+ QTest::newRow("dynamically populate") << "transitions.qml" << true << true;
+ QTest::newRow("dynamically populate, no populate transition") << "transitions.qml" << true << false;
+ QTest::newRow("padding, dynamically populate") << "transitions-padding.qml" << true << true;
+ QTest::newRow("padding, dynamically populate, no populate transition") << "transitions-padding.qml" << true << false;
}
void tst_qquickpositioners::addTransitions(const QString &positionerObjectName)
{
+ QFETCH(QString, qmlFile);
QFETCH(int, initialItemCount);
QFETCH(int, insertionIndex);
QFETCH(int, insertionCount);
@@ -654,7 +1123,7 @@ void tst_qquickpositioners::addTransitions(const QString &positionerObjectName)
ctxt->setContextProperty("targetItems_transitionFrom", targetItems_transitionFrom);
ctxt->setContextProperty("displacedItems_transitionVia", displacedItems_transitionVia);
ctxt->setContextProperty("testedPositioner", QString());
- window->setSource(testFileUrl("transitions.qml"));
+ window->setSource(testFileUrl(qmlFile));
window->show();
QTest::qWaitForWindowExposed(window.data());
qApp->processEvents();
@@ -729,22 +1198,30 @@ void tst_qquickpositioners::addTransitions_data()
{
// If this data changes, update addTransitions_grid_data() also
+ QTest::addColumn<QString>("qmlFile");
QTest::addColumn<int>("initialItemCount");
QTest::addColumn<int>("insertionIndex");
QTest::addColumn<int>("insertionCount");
QTest::addColumn<ListRange>("expectedDisplacedIndexes");
- QTest::newRow("add one @ start") << 10 << 0 << 1 << ListRange(0, 9);
- QTest::newRow("add one @ middle") << 10 << 5 << 1 << ListRange(5, 9);
- QTest::newRow("add one @ end") << 10 << 10 << 1 << ListRange();
+ QTest::newRow("add one @ start") << "transitions.qml" << 10 << 0 << 1 << ListRange(0, 9);
+ QTest::newRow("add one @ middle") << "transitions.qml" << 10 << 5 << 1 << ListRange(5, 9);
+ QTest::newRow("add one @ end") << "transitions.qml" << 10 << 10 << 1 << ListRange();
+ QTest::newRow("padding, add one @ start") << "transitions-padding.qml" << 10 << 0 << 1 << ListRange(0, 9);
+ QTest::newRow("padding, add one @ middle") << "transitions-padding.qml" << 10 << 5 << 1 << ListRange(5, 9);
+ QTest::newRow("padding, add one @ end") << "transitions-padding.qml" << 10 << 10 << 1 << ListRange();
- QTest::newRow("add multiple @ start") << 10 << 0 << 3 << ListRange(0, 9);
- QTest::newRow("add multiple @ middle") << 10 << 5 << 3 << ListRange(5, 9);
- QTest::newRow("add multiple @ end") << 10 << 10 << 3 << ListRange();
+ QTest::newRow("add multiple @ start") << "transitions.qml" << 10 << 0 << 3 << ListRange(0, 9);
+ QTest::newRow("add multiple @ middle") << "transitions.qml" << 10 << 5 << 3 << ListRange(5, 9);
+ QTest::newRow("add multiple @ end") << "transitions.qml" << 10 << 10 << 3 << ListRange();
+ QTest::newRow("padding, add multiple @ start") << "transitions-padding.qml" << 10 << 0 << 3 << ListRange(0, 9);
+ QTest::newRow("padding, add multiple @ middle") << "transitions-padding.qml" << 10 << 5 << 3 << ListRange(5, 9);
+ QTest::newRow("padding, add multiple @ end") << "transitions-padding.qml" << 10 << 10 << 3 << ListRange();
}
void tst_qquickpositioners::moveTransitions(const QString &positionerObjectName)
{
+ QFETCH(QString, qmlFile);
QFETCH(int, initialItemCount);
QFETCH(ListChange, change);
QFETCH(ListRange, expectedDisplacedIndexes);
@@ -769,7 +1246,7 @@ void tst_qquickpositioners::moveTransitions(const QString &positionerObjectName)
ctxt->setContextProperty("targetItems_transitionFrom", targetItems_transitionFrom);
ctxt->setContextProperty("displacedItems_transitionVia", displacedItems_transitionVia);
ctxt->setContextProperty("testedPositioner", QString());
- window->setSource(testFileUrl("transitions.qml"));
+ window->setSource(testFileUrl(qmlFile));
window->show();
QTest::qWaitForWindowExposed(window.data());
qApp->processEvents();
@@ -840,27 +1317,36 @@ void tst_qquickpositioners::moveTransitions_data()
{
// If this data changes, update moveTransitions_grid_data() also
+ QTest::addColumn<QString>("qmlFile");
QTest::addColumn<int>("initialItemCount");
QTest::addColumn<ListChange>("change");
QTest::addColumn<ListRange>("expectedDisplacedIndexes");
- QTest::newRow("remove one @ start") << 10 << ListChange::remove(0, 1) << ListRange(1, 9);
- QTest::newRow("remove one @ middle") << 10 << ListChange::remove(4, 1) << ListRange(5, 9);
- QTest::newRow("remove one @ end") << 10 << ListChange::remove(9, 1) << ListRange();
+ QTest::newRow("remove one @ start") << "transitions.qml" << 10 << ListChange::remove(0, 1) << ListRange(1, 9);
+ QTest::newRow("remove one @ middle") << "transitions.qml" << 10 << ListChange::remove(4, 1) << ListRange(5, 9);
+ QTest::newRow("remove one @ end") << "transitions.qml" << 10 << ListChange::remove(9, 1) << ListRange();
+ QTest::newRow("padding, remove one @ start") << "transitions-padding.qml" << 10 << ListChange::remove(0, 1) << ListRange(1, 9);
+ QTest::newRow("padding, remove one @ middle") << "transitions-padding.qml" << 10 << ListChange::remove(4, 1) << ListRange(5, 9);
+ QTest::newRow("padding, remove one @ end") << "transitions-padding.qml" << 10 << ListChange::remove(9, 1) << ListRange();
- QTest::newRow("remove multiple @ start") << 10 << ListChange::remove(0, 3) << ListRange(3, 9);
- QTest::newRow("remove multiple @ middle") << 10 << ListChange::remove(4, 3) << ListRange(7, 9);
- QTest::newRow("remove multiple @ end") << 10 << ListChange::remove(7, 3) << ListRange();
+ QTest::newRow("remove multiple @ start") << "transitions.qml" << 10 << ListChange::remove(0, 3) << ListRange(3, 9);
+ QTest::newRow("remove multiple @ middle") << "transitions.qml" << 10 << ListChange::remove(4, 3) << ListRange(7, 9);
+ QTest::newRow("remove multiple @ end") << "transitions.qml" << 10 << ListChange::remove(7, 3) << ListRange();
+ QTest::newRow("padding, remove multiple @ start") << "transitions-padding.qml" << 10 << ListChange::remove(0, 3) << ListRange(3, 9);
+ QTest::newRow("padding, remove multiple @ middle") << "transitions-padding.qml" << 10 << ListChange::remove(4, 3) << ListRange(7, 9);
+ QTest::newRow("padding, remove multiple @ end") << "transitions-padding.qml" << 10 << ListChange::remove(7, 3) << ListRange();
}
-
void tst_qquickpositioners::checkItemPositions(QQuickItem *positioner, QaimModel *model, qreal incrementalSize)
{
QVERIFY(model->count() > 0);
+
+ QQuickBasePositioner *p = qobject_cast<QQuickBasePositioner*>(positioner);
+
qreal padding = 0;
qreal currentSize = 30;
- qreal rowX = 0;
- qreal rowY = 0;
+ qreal rowX = p->leftPadding();
+ qreal rowY = p->topPadding();
for (int i=0; i<model->count(); ++i) {
QQuickItem *item = findItem<QQuickItem>(positioner, "wrapper", i);
@@ -870,11 +1356,11 @@ void tst_qquickpositioners::checkItemPositions(QQuickItem *positioner, QaimModel
QCOMPARE(item->height(), currentSize);
if (qobject_cast<QQuickRow*>(positioner)) {
- QCOMPARE(item->x(), (i * 30.0) + padding);
- QCOMPARE(item->y(), 0.0);
+ QCOMPARE(item->x(), (i * 30.0) + padding + p->leftPadding());
+ QCOMPARE(item->y(), p->topPadding());
} else if (qobject_cast<QQuickColumn*>(positioner)) {
- QCOMPARE(item->x(), 0.0);
- QCOMPARE(item->y(), (i * 30.0) + padding);
+ QCOMPARE(item->x(), p->leftPadding());
+ QCOMPARE(item->y(), (i * 30.0) + padding + p->topPadding());
} else if (qobject_cast<QQuickGrid*>(positioner)) {
int columns = 4;
int rows = qCeil(model->count() / qreal(columns));
@@ -886,20 +1372,20 @@ void tst_qquickpositioners::checkItemPositions(QQuickItem *positioner, QaimModel
QVERIFY(finalAlignedRowItem);
QCOMPARE(item->x(), finalAlignedRowItem->x());
} else {
- QCOMPARE(item->x(), 0.0);
+ QCOMPARE(item->x(), p->leftPadding());
}
if (i / columns > 0) {
QQuickItem *prevRowLastItem = findItem<QQuickItem>(positioner, "wrapper", (i/columns * columns) - 1);
QVERIFY(prevRowLastItem);
QCOMPARE(item->y(), prevRowLastItem->y() + prevRowLastItem->height());
} else {
- QCOMPARE(item->y(), 0.0);
+ QCOMPARE(item->y(), p->topPadding());
}
} else if (qobject_cast<QQuickFlow*>(positioner)) {
if (rowX + item->width() > positioner->width()) {
QQuickItem *prevItem = findItem<QQuickItem>(positioner, "wrapper", i-1);
QVERIFY(prevItem);
- rowX = 0;
+ rowX = p->leftPadding();
rowY = prevItem->y() + prevItem->height();
}
QCOMPARE(item->x(), rowX);
@@ -942,6 +1428,183 @@ void tst_qquickpositioners::test_vertical()
QCOMPARE(column->height(), 80.0);
QCOMPARE(column->width(), 50.0);
+ // test padding
+ column->setProperty("padding", 1);
+ column->setProperty("topPadding", 2);
+ column->setProperty("leftPadding", 3);
+ column->setProperty("rightPadding", 4);
+ column->setProperty("bottomPadding", 5);
+
+ QTRY_COMPARE(column->height(), 87.0);
+ QCOMPARE(column->width(), 57.0);
+
+ QCOMPARE(one->x(), 3.0);
+ QCOMPARE(one->y(), 2.0);
+ QCOMPARE(two->x(), 3.0);
+ QCOMPARE(two->y(), 52.0);
+ QCOMPARE(three->x(), 3.0);
+ QCOMPARE(three->y(), 62.0);
+}
+
+void tst_qquickpositioners::test_vertical_padding()
+{
+ QScopedPointer<QQuickView> window(createView(testFile("vertical.qml")));
+
+ QQuickRectangle *one = window->rootObject()->findChild<QQuickRectangle*>("one");
+ QVERIFY(one != 0);
+
+ QQuickRectangle *two = window->rootObject()->findChild<QQuickRectangle*>("two");
+ QVERIFY(two != 0);
+
+ QQuickRectangle *three = window->rootObject()->findChild<QQuickRectangle*>("three");
+ QVERIFY(three != 0);
+
+ QCOMPARE(one->x(), 0.0);
+ QCOMPARE(one->y(), 0.0);
+ QCOMPARE(two->x(), 0.0);
+ QCOMPARE(two->y(), 50.0);
+ QCOMPARE(three->x(), 0.0);
+ QCOMPARE(three->y(), 60.0);
+
+ QQuickItem *column = window->rootObject()->findChild<QQuickItem*>("column");
+ QVERIFY(column);
+ QCOMPARE(column->height(), 80.0);
+ QCOMPARE(column->width(), 50.0);
+
+ QQuickColumn *obj = qobject_cast<QQuickColumn*>(column);
+ QVERIFY(obj != 0);
+
+ QCOMPARE(column->property("padding").toDouble(), 0.0);
+ QCOMPARE(column->property("topPadding").toDouble(), 0.0);
+ QCOMPARE(column->property("leftPadding").toDouble(), 0.0);
+ QCOMPARE(column->property("rightPadding").toDouble(), 0.0);
+ QCOMPARE(column->property("bottomPadding").toDouble(), 0.0);
+
+ obj->setPadding(1.0);
+
+ QCOMPARE(column->property("padding").toDouble(), 1.0);
+ QCOMPARE(column->property("topPadding").toDouble(), 1.0);
+ QCOMPARE(column->property("leftPadding").toDouble(), 1.0);
+ QCOMPARE(column->property("rightPadding").toDouble(), 1.0);
+ QCOMPARE(column->property("bottomPadding").toDouble(), 1.0);
+
+ QTRY_COMPARE(column->height(), 82.0);
+ QCOMPARE(column->width(), 52.0);
+
+ QCOMPARE(one->x(), 1.0);
+ QCOMPARE(one->y(), 1.0);
+ QCOMPARE(two->x(), 1.0);
+ QCOMPARE(two->y(), 51.0);
+ QCOMPARE(three->x(), 1.0);
+ QCOMPARE(three->y(), 61.0);
+
+ obj->setTopPadding(2.0);
+
+ QCOMPARE(column->property("padding").toDouble(), 1.0);
+ QCOMPARE(column->property("topPadding").toDouble(), 2.0);
+ QCOMPARE(column->property("leftPadding").toDouble(), 1.0);
+ QCOMPARE(column->property("rightPadding").toDouble(), 1.0);
+ QCOMPARE(column->property("bottomPadding").toDouble(), 1.0);
+
+ QTRY_COMPARE(column->height(), 83.0);
+ QCOMPARE(column->width(), 52.0);
+
+ QCOMPARE(one->x(), 1.0);
+ QCOMPARE(one->y(), 2.0);
+ QCOMPARE(two->x(), 1.0);
+ QCOMPARE(two->y(), 52.0);
+ QCOMPARE(three->x(), 1.0);
+ QCOMPARE(three->y(), 62.0);
+
+ obj->setLeftPadding(3.0);
+
+ QCOMPARE(column->property("padding").toDouble(), 1.0);
+ QCOMPARE(column->property("topPadding").toDouble(), 2.0);
+ QCOMPARE(column->property("leftPadding").toDouble(), 3.0);
+ QCOMPARE(column->property("rightPadding").toDouble(), 1.0);
+ QCOMPARE(column->property("bottomPadding").toDouble(), 1.0);
+
+ QTRY_COMPARE(column->width(), 54.0);
+ QCOMPARE(column->height(), 83.0);
+
+ QCOMPARE(one->x(), 3.0);
+ QCOMPARE(one->y(), 2.0);
+ QCOMPARE(two->x(), 3.0);
+ QCOMPARE(two->y(), 52.0);
+ QCOMPARE(three->x(), 3.0);
+ QCOMPARE(three->y(), 62.0);
+
+ obj->setRightPadding(4.0);
+
+ QCOMPARE(column->property("padding").toDouble(), 1.0);
+ QCOMPARE(column->property("topPadding").toDouble(), 2.0);
+ QCOMPARE(column->property("leftPadding").toDouble(), 3.0);
+ QCOMPARE(column->property("rightPadding").toDouble(), 4.0);
+ QCOMPARE(column->property("bottomPadding").toDouble(), 1.0);
+
+ QTRY_COMPARE(column->width(), 57.0);
+ QCOMPARE(column->height(), 83.0);
+
+ QCOMPARE(one->x(), 3.0);
+ QCOMPARE(one->y(), 2.0);
+ QCOMPARE(two->x(), 3.0);
+ QCOMPARE(two->y(), 52.0);
+ QCOMPARE(three->x(), 3.0);
+ QCOMPARE(three->y(), 62.0);
+
+ obj->setBottomPadding(5.0);
+
+ QCOMPARE(column->property("padding").toDouble(), 1.0);
+ QCOMPARE(column->property("topPadding").toDouble(), 2.0);
+ QCOMPARE(column->property("leftPadding").toDouble(), 3.0);
+ QCOMPARE(column->property("rightPadding").toDouble(), 4.0);
+ QCOMPARE(column->property("bottomPadding").toDouble(), 5.0);
+
+ QTRY_COMPARE(column->height(), 87.0);
+ QCOMPARE(column->width(), 57.0);
+
+ QCOMPARE(one->x(), 3.0);
+ QCOMPARE(one->y(), 2.0);
+ QCOMPARE(two->x(), 3.0);
+ QCOMPARE(two->y(), 52.0);
+ QCOMPARE(three->x(), 3.0);
+ QCOMPARE(three->y(), 62.0);
+
+ obj->resetBottomPadding();
+ QCOMPARE(column->property("bottomPadding").toDouble(), 1.0);
+ QTRY_COMPARE(column->height(), 83.0);
+ QCOMPARE(column->width(), 57.0);
+
+ obj->resetRightPadding();
+ QCOMPARE(column->property("rightPadding").toDouble(), 1.0);
+ QTRY_COMPARE(column->width(), 54.0);
+ QCOMPARE(column->height(), 83.0);
+
+ obj->resetLeftPadding();
+ QCOMPARE(column->property("leftPadding").toDouble(), 1.0);
+ QTRY_COMPARE(column->width(), 52.0);
+ QCOMPARE(column->height(), 83.0);
+
+ obj->resetTopPadding();
+ QCOMPARE(column->property("topPadding").toDouble(), 1.0);
+ QTRY_COMPARE(column->height(), 82.0);
+ QCOMPARE(column->width(), 52.0);
+
+ obj->resetPadding();
+ QCOMPARE(column->property("padding").toDouble(), 0.0);
+ QCOMPARE(column->property("topPadding").toDouble(), 0.0);
+ QCOMPARE(column->property("leftPadding").toDouble(), 0.0);
+ QCOMPARE(column->property("rightPadding").toDouble(), 0.0);
+ QCOMPARE(column->property("bottomPadding").toDouble(), 0.0);
+ QTRY_COMPARE(column->height(), 80.0);
+ QCOMPARE(column->width(), 50.0);
+
+ QCOMPARE(one->x(), 0.0);
+ QCOMPARE(one->y(), 0.0);
+ QCOMPARE(two->x(), 0.0);
+ QCOMPARE(two->y(), 50.0);
+ QCOMPARE(three->x(), 0.0);
+ QCOMPARE(three->y(), 60.0);
}
void tst_qquickpositioners::test_vertical_spacing()
@@ -968,6 +1631,22 @@ void tst_qquickpositioners::test_vertical_spacing()
QCOMPARE(column->height(), 100.0);
QCOMPARE(column->width(), 50.0);
+ // test padding
+ column->setProperty("padding", 1);
+ column->setProperty("topPadding", 2);
+ column->setProperty("leftPadding", 3);
+ column->setProperty("rightPadding", 4);
+ column->setProperty("bottomPadding", 5);
+
+ QTRY_COMPARE(column->height(), 107.0);
+ QCOMPARE(column->width(), 57.0);
+
+ QCOMPARE(one->x(), 3.0);
+ QCOMPARE(one->y(), 2.0);
+ QCOMPARE(two->x(), 3.0);
+ QCOMPARE(two->y(), 62.0);
+ QCOMPARE(three->x(), 3.0);
+ QCOMPARE(three->y(), 82.0);
}
void tst_qquickpositioners::test_vertical_animated()
@@ -1019,6 +1698,66 @@ void tst_qquickpositioners::test_vertical_animated()
}
+void tst_qquickpositioners::test_vertical_animated_padding()
+{
+ QScopedPointer<QQuickView> window(createView(testFile("vertical-animated.qml"), false));
+
+ //Note that they animate in
+ QQuickRectangle *one = window->rootObject()->findChild<QQuickRectangle*>("one");
+ QVERIFY(one != 0);
+ QCOMPARE(one->y(), -100.0);
+
+ QQuickRectangle *two = window->rootObject()->findChild<QQuickRectangle*>("two");
+ QVERIFY(two != 0);
+ QCOMPARE(two->y(), -100.0);
+
+ QQuickRectangle *three = window->rootObject()->findChild<QQuickRectangle*>("three");
+ QVERIFY(three != 0);
+ QCOMPARE(three->y(), -100.0);
+
+ QVERIFY(QTest::qWaitForWindowExposed(window.data())); //It may not relayout until the next frame, so it needs to be drawn
+
+ QQuickItem *column = window->rootObject()->findChild<QQuickItem*>("column");
+ QVERIFY(column);
+ QCOMPARE(column->height(), 100.0);
+ QCOMPARE(column->width(), 50.0);
+
+ // test padding
+ column->setProperty("padding", 1);
+ column->setProperty("topPadding", 2);
+ column->setProperty("leftPadding", 3);
+ column->setProperty("rightPadding", 4);
+ column->setProperty("bottomPadding", 5);
+
+ QTRY_COMPARE(column->height(), 107.0);
+ QCOMPARE(column->width(), 57.0);
+
+ //QTRY_COMPARE used instead of waiting for the expected time of animation completion
+ //Note that this means the duration of the animation is NOT tested
+
+ QTRY_COMPARE(one->y(), 2.0);
+ QTRY_COMPARE(one->x(), 3.0);
+ QTRY_COMPARE(two->isVisible(), false);
+ QTRY_COMPARE(two->y(), -100.0);//Not 'in' yet
+ QTRY_COMPARE(two->x(), 0.0);
+ QTRY_COMPARE(three->y(), 52.0);
+ QTRY_COMPARE(three->x(), 3.0);
+
+ //Add 'two'
+ two->setVisible(true);
+ QTRY_COMPARE(two->isVisible(), true);
+ QTRY_COMPARE(column->height(), 157.0);
+ QTRY_COMPARE(column->width(), 57.0);
+ QTest::qWait(0);//Let the animation start
+ QVERIFY(two->y() >= -100.0 && two->y() < 52.0);
+ QVERIFY(three->y() >= 52.0 && three->y() < 102.0);
+
+ QTRY_COMPARE(two->x(), 3.0);
+ QTRY_COMPARE(two->y(), 52.0);
+ QTRY_COMPARE(three->y(), 102.0);
+
+}
+
void tst_qquickpositioners::test_grid()
{
QScopedPointer<QQuickView> window(createView(testFile("gridtest.qml")));
@@ -1050,6 +1789,214 @@ void tst_qquickpositioners::test_grid()
QCOMPARE(grid->width(), 100.0);
QCOMPARE(grid->height(), 100.0);
+ // test padding
+ grid->setProperty("padding", 1);
+ grid->setProperty("topPadding", 2);
+ grid->setProperty("leftPadding", 3);
+ grid->setProperty("rightPadding", 4);
+ grid->setProperty("bottomPadding", 5);
+
+ QTRY_COMPARE(grid->width(), 107.0);
+ QCOMPARE(grid->height(), 107.0);
+
+ QCOMPARE(one->x(), 3.0);
+ QCOMPARE(one->y(), 2.0);
+ QCOMPARE(two->x(), 53.0);
+ QCOMPARE(two->y(), 2.0);
+ QCOMPARE(three->x(), 73.0);
+ QCOMPARE(three->y(), 2.0);
+ QCOMPARE(four->x(), 3.0);
+ QCOMPARE(four->y(), 52.0);
+ QCOMPARE(five->x(), 53.0);
+ QCOMPARE(five->y(), 52.0);
+}
+
+void tst_qquickpositioners::test_grid_padding()
+{
+ QScopedPointer<QQuickView> window(createView(testFile("gridtest.qml")));
+
+ QQuickRectangle *one = window->rootObject()->findChild<QQuickRectangle*>("one");
+ QVERIFY(one != 0);
+ QQuickRectangle *two = window->rootObject()->findChild<QQuickRectangle*>("two");
+ QVERIFY(two != 0);
+ QQuickRectangle *three = window->rootObject()->findChild<QQuickRectangle*>("three");
+ QVERIFY(three != 0);
+ QQuickRectangle *four = window->rootObject()->findChild<QQuickRectangle*>("four");
+ QVERIFY(four != 0);
+ QQuickRectangle *five = window->rootObject()->findChild<QQuickRectangle*>("five");
+ QVERIFY(five != 0);
+
+ QCOMPARE(one->x(), 0.0);
+ QCOMPARE(one->y(), 0.0);
+ QCOMPARE(two->x(), 50.0);
+ QCOMPARE(two->y(), 0.0);
+ QCOMPARE(three->x(), 70.0);
+ QCOMPARE(three->y(), 0.0);
+ QCOMPARE(four->x(), 0.0);
+ QCOMPARE(four->y(), 50.0);
+ QCOMPARE(five->x(), 50.0);
+ QCOMPARE(five->y(), 50.0);
+
+ QQuickGrid *grid = window->rootObject()->findChild<QQuickGrid*>("grid");
+ QCOMPARE(grid->flow(), QQuickGrid::LeftToRight);
+ QCOMPARE(grid->width(), 100.0);
+ QCOMPARE(grid->height(), 100.0);
+
+ QCOMPARE(grid->property("padding").toDouble(), 0.0);
+ QCOMPARE(grid->property("topPadding").toDouble(), 0.0);
+ QCOMPARE(grid->property("leftPadding").toDouble(), 0.0);
+ QCOMPARE(grid->property("rightPadding").toDouble(), 0.0);
+ QCOMPARE(grid->property("bottomPadding").toDouble(), 0.0);
+
+ grid->setPadding(1.0);
+
+ QCOMPARE(grid->property("padding").toDouble(), 1.0);
+ QCOMPARE(grid->property("topPadding").toDouble(), 1.0);
+ QCOMPARE(grid->property("leftPadding").toDouble(), 1.0);
+ QCOMPARE(grid->property("rightPadding").toDouble(), 1.0);
+ QCOMPARE(grid->property("bottomPadding").toDouble(), 1.0);
+
+ QTRY_COMPARE(grid->width(), 102.0);
+ QCOMPARE(grid->height(), 102.0);
+
+ QCOMPARE(one->x(), 1.0);
+ QCOMPARE(one->y(), 1.0);
+ QCOMPARE(two->x(), 51.0);
+ QCOMPARE(two->y(), 1.0);
+ QCOMPARE(three->x(), 71.0);
+ QCOMPARE(three->y(), 1.0);
+ QCOMPARE(four->x(), 1.0);
+ QCOMPARE(four->y(), 51.0);
+ QCOMPARE(five->x(), 51.0);
+ QCOMPARE(five->y(), 51.0);
+
+ grid->setTopPadding(2.0);
+
+ QCOMPARE(grid->property("padding").toDouble(), 1.0);
+ QCOMPARE(grid->property("topPadding").toDouble(), 2.0);
+ QCOMPARE(grid->property("leftPadding").toDouble(), 1.0);
+ QCOMPARE(grid->property("rightPadding").toDouble(), 1.0);
+ QCOMPARE(grid->property("bottomPadding").toDouble(), 1.0);
+
+ QTRY_COMPARE(grid->height(), 103.0);
+ QCOMPARE(grid->width(), 102.0);
+
+ QCOMPARE(one->x(), 1.0);
+ QCOMPARE(one->y(), 2.0);
+ QCOMPARE(two->x(), 51.0);
+ QCOMPARE(two->y(), 2.0);
+ QCOMPARE(three->x(), 71.0);
+ QCOMPARE(three->y(), 2.0);
+ QCOMPARE(four->x(), 1.0);
+ QCOMPARE(four->y(), 52.0);
+ QCOMPARE(five->x(), 51.0);
+ QCOMPARE(five->y(), 52.0);
+
+ grid->setLeftPadding(3.0);
+
+ QCOMPARE(grid->property("padding").toDouble(), 1.0);
+ QCOMPARE(grid->property("topPadding").toDouble(), 2.0);
+ QCOMPARE(grid->property("leftPadding").toDouble(), 3.0);
+ QCOMPARE(grid->property("rightPadding").toDouble(), 1.0);
+ QCOMPARE(grid->property("bottomPadding").toDouble(), 1.0);
+
+ QTRY_COMPARE(grid->width(), 104.0);
+ QCOMPARE(grid->height(), 103.0);
+
+ QCOMPARE(one->x(), 3.0);
+ QCOMPARE(one->y(), 2.0);
+ QCOMPARE(two->x(), 53.0);
+ QCOMPARE(two->y(), 2.0);
+ QCOMPARE(three->x(), 73.0);
+ QCOMPARE(three->y(), 2.0);
+ QCOMPARE(four->x(), 3.0);
+ QCOMPARE(four->y(), 52.0);
+ QCOMPARE(five->x(), 53.0);
+ QCOMPARE(five->y(), 52.0);
+
+ grid->setRightPadding(4.0);
+
+ QCOMPARE(grid->property("padding").toDouble(), 1.0);
+ QCOMPARE(grid->property("topPadding").toDouble(), 2.0);
+ QCOMPARE(grid->property("leftPadding").toDouble(), 3.0);
+ QCOMPARE(grid->property("rightPadding").toDouble(), 4.0);
+ QCOMPARE(grid->property("bottomPadding").toDouble(), 1.0);
+
+ QTRY_COMPARE(grid->width(), 107.0);
+ QCOMPARE(grid->height(), 103.0);
+
+ QCOMPARE(one->x(), 3.0);
+ QCOMPARE(one->y(), 2.0);
+ QCOMPARE(two->x(), 53.0);
+ QCOMPARE(two->y(), 2.0);
+ QCOMPARE(three->x(), 73.0);
+ QCOMPARE(three->y(), 2.0);
+ QCOMPARE(four->x(), 3.0);
+ QCOMPARE(four->y(), 52.0);
+ QCOMPARE(five->x(), 53.0);
+ QCOMPARE(five->y(), 52.0);
+
+ grid->setBottomPadding(5.0);
+
+ QCOMPARE(grid->property("padding").toDouble(), 1.0);
+ QCOMPARE(grid->property("topPadding").toDouble(), 2.0);
+ QCOMPARE(grid->property("leftPadding").toDouble(), 3.0);
+ QCOMPARE(grid->property("rightPadding").toDouble(), 4.0);
+ QCOMPARE(grid->property("bottomPadding").toDouble(), 5.0);
+
+ QTRY_COMPARE(grid->height(), 107.0);
+ QCOMPARE(grid->width(), 107.0);
+
+ QCOMPARE(one->x(), 3.0);
+ QCOMPARE(one->y(), 2.0);
+ QCOMPARE(two->x(), 53.0);
+ QCOMPARE(two->y(), 2.0);
+ QCOMPARE(three->x(), 73.0);
+ QCOMPARE(three->y(), 2.0);
+ QCOMPARE(four->x(), 3.0);
+ QCOMPARE(four->y(), 52.0);
+ QCOMPARE(five->x(), 53.0);
+ QCOMPARE(five->y(), 52.0);
+
+ grid->resetBottomPadding();
+ QCOMPARE(grid->property("bottomPadding").toDouble(), 1.0);
+ QTRY_COMPARE(grid->height(), 103.0);
+ QCOMPARE(grid->width(), 107.0);
+
+ grid->resetRightPadding();
+ QCOMPARE(grid->property("rightPadding").toDouble(), 1.0);
+ QTRY_COMPARE(grid->width(), 104.0);
+ QCOMPARE(grid->height(), 103.0);
+
+ grid->resetLeftPadding();
+ QCOMPARE(grid->property("leftPadding").toDouble(), 1.0);
+ QTRY_COMPARE(grid->width(), 102.0);
+ QCOMPARE(grid->height(), 103.0);
+
+ grid->resetTopPadding();
+ QCOMPARE(grid->property("topPadding").toDouble(), 1.0);
+ QTRY_COMPARE(grid->height(), 102.0);
+ QCOMPARE(grid->width(), 102.0);
+
+ grid->resetPadding();
+ QCOMPARE(grid->property("padding").toDouble(), 0.0);
+ QCOMPARE(grid->property("topPadding").toDouble(), 0.0);
+ QCOMPARE(grid->property("leftPadding").toDouble(), 0.0);
+ QCOMPARE(grid->property("rightPadding").toDouble(), 0.0);
+ QCOMPARE(grid->property("bottomPadding").toDouble(), 0.0);
+ QTRY_COMPARE(grid->height(), 100.0);
+ QCOMPARE(grid->width(), 100.0);
+
+ QCOMPARE(one->x(), 0.0);
+ QCOMPARE(one->y(), 0.0);
+ QCOMPARE(two->x(), 50.0);
+ QCOMPARE(two->y(), 0.0);
+ QCOMPARE(three->x(), 70.0);
+ QCOMPARE(three->y(), 0.0);
+ QCOMPARE(four->x(), 0.0);
+ QCOMPARE(four->y(), 50.0);
+ QCOMPARE(five->x(), 50.0);
+ QCOMPARE(five->y(), 50.0);
}
void tst_qquickpositioners::test_grid_topToBottom()
@@ -1083,6 +2030,26 @@ void tst_qquickpositioners::test_grid_topToBottom()
QCOMPARE(grid->width(), 100.0);
QCOMPARE(grid->height(), 120.0);
+ // test padding
+ grid->setProperty("padding", 1);
+ grid->setProperty("topPadding", 2);
+ grid->setProperty("leftPadding", 3);
+ grid->setProperty("rightPadding", 4);
+ grid->setProperty("bottomPadding", 5);
+
+ QTRY_COMPARE(grid->width(), 107.0);
+ QCOMPARE(grid->height(), 127.0);
+
+ QCOMPARE(one->x(), 3.0);
+ QCOMPARE(one->y(), 2.0);
+ QCOMPARE(two->x(), 3.0);
+ QCOMPARE(two->y(), 52.0);
+ QCOMPARE(three->x(), 3.0);
+ QCOMPARE(three->y(), 102.0);
+ QCOMPARE(four->x(), 53.0);
+ QCOMPARE(four->y(), 2.0);
+ QCOMPARE(five->x(), 53.0);
+ QCOMPARE(five->y(), 52.0);
}
void tst_qquickpositioners::test_grid_rightToLeft()
@@ -1118,6 +2085,44 @@ void tst_qquickpositioners::test_grid_rightToLeft()
QCOMPARE(grid->width(), 100.0);
QCOMPARE(grid->height(), 100.0);
+ // test padding
+ grid->setProperty("padding", 1);
+ grid->setProperty("topPadding", 2);
+ grid->setProperty("leftPadding", 3);
+ grid->setProperty("rightPadding", 4);
+ grid->setProperty("bottomPadding", 5);
+
+ QTRY_COMPARE(grid->width(), 107.0);
+ QCOMPARE(grid->height(), 107.0);
+
+ QCOMPARE(one->x(), 53.0);
+ QCOMPARE(one->y(), 2.0);
+ QCOMPARE(two->x(), 33.0);
+ QCOMPARE(two->y(), 2.0);
+ QCOMPARE(three->x(), 3.0);
+ QCOMPARE(three->y(), 2.0);
+ QCOMPARE(four->x(), 53.0);
+ QCOMPARE(four->y(), 52.0);
+ QCOMPARE(five->x(), 43.0);
+ QCOMPARE(five->y(), 52.0);
+
+ grid->setProperty("topPadding", 0);
+ grid->setProperty("leftPadding", 0);
+ grid->setProperty("rightPadding", 0);
+ grid->setProperty("bottomPadding", 0);
+ grid->setProperty("padding", 0);
+
+ QTRY_COMPARE(one->x(), 50.0);
+ QCOMPARE(one->y(), 0.0);
+ QCOMPARE(two->x(), 30.0);
+ QCOMPARE(two->y(), 0.0);
+ QCOMPARE(three->x(), 0.0);
+ QCOMPARE(three->y(), 0.0);
+ QCOMPARE(four->x(), 50.0);
+ QCOMPARE(four->y(), 50.0);
+ QCOMPARE(five->x(), 40.0);
+ QCOMPARE(five->y(), 50.0);
+
// Change the width of the grid and check that items stay to the right
grid->setWidth(200);
QTRY_COMPARE(one->x(), 150.0);
@@ -1131,6 +2136,22 @@ void tst_qquickpositioners::test_grid_rightToLeft()
QCOMPARE(five->x(), 140.0);
QCOMPARE(five->y(), 50.0);
+ grid->setProperty("padding", 1);
+ grid->setProperty("topPadding", 2);
+ grid->setProperty("leftPadding", 3);
+ grid->setProperty("rightPadding", 4);
+ grid->setProperty("bottomPadding", 5);
+
+ QTRY_COMPARE(one->x(), 146.0);
+ QCOMPARE(one->y(), 2.0);
+ QCOMPARE(two->x(), 126.0);
+ QCOMPARE(two->y(), 2.0);
+ QCOMPARE(three->x(), 96.0);
+ QCOMPARE(three->y(), 2.0);
+ QCOMPARE(four->x(), 146.0);
+ QCOMPARE(four->y(), 52.0);
+ QCOMPARE(five->x(), 136.0);
+ QCOMPARE(five->y(), 52.0);
}
void tst_qquickpositioners::test_grid_spacing()
@@ -1163,6 +2184,26 @@ void tst_qquickpositioners::test_grid_spacing()
QCOMPARE(grid->width(), 128.0);
QCOMPARE(grid->height(), 104.0);
+ // test padding
+ grid->setProperty("padding", 1);
+ grid->setProperty("topPadding", 2);
+ grid->setProperty("leftPadding", 3);
+ grid->setProperty("rightPadding", 4);
+ grid->setProperty("bottomPadding", 5);
+
+ QTRY_COMPARE(grid->width(), 135.0);
+ QCOMPARE(grid->height(), 111.0);
+
+ QCOMPARE(one->x(), 3.0);
+ QCOMPARE(one->y(), 2.0);
+ QCOMPARE(two->x(), 57.0);
+ QCOMPARE(two->y(), 2.0);
+ QCOMPARE(three->x(), 81.0);
+ QCOMPARE(three->y(), 2.0);
+ QCOMPARE(four->x(), 3.0);
+ QCOMPARE(four->y(), 56.0);
+ QCOMPARE(five->x(), 57.0);
+ QCOMPARE(five->y(), 56.0);
}
void tst_qquickpositioners::test_grid_row_column_spacing()
@@ -1195,6 +2236,26 @@ void tst_qquickpositioners::test_grid_row_column_spacing()
QCOMPARE(grid->width(), 142.0);
QCOMPARE(grid->height(), 107.0);
+ // test padding
+ grid->setProperty("padding", 1);
+ grid->setProperty("topPadding", 2);
+ grid->setProperty("leftPadding", 3);
+ grid->setProperty("rightPadding", 4);
+ grid->setProperty("bottomPadding", 5);
+
+ QTRY_COMPARE(grid->width(), 149.0);
+ QCOMPARE(grid->height(), 114.0);
+
+ QCOMPARE(one->x(), 3.0);
+ QCOMPARE(one->y(), 2.0);
+ QCOMPARE(two->x(), 64.0);
+ QCOMPARE(two->y(), 2.0);
+ QCOMPARE(three->x(), 95.0);
+ QCOMPARE(three->y(), 2.0);
+ QCOMPARE(four->x(), 3.0);
+ QCOMPARE(four->y(), 59.0);
+ QCOMPARE(five->x(), 64.0);
+ QCOMPARE(five->y(), 59.0);
}
void tst_qquickpositioners::test_grid_animated()
@@ -1281,6 +2342,100 @@ void tst_qquickpositioners::test_grid_animated()
}
+void tst_qquickpositioners::test_grid_animated_padding()
+{
+ QScopedPointer<QQuickView> window(createView(testFile("grid-animated.qml"), false));
+
+ window->rootObject()->setProperty("testRightToLeft", false);
+
+ //Note that all animate in
+ QQuickRectangle *one = window->rootObject()->findChild<QQuickRectangle*>("one");
+ QVERIFY(one != 0);
+ QCOMPARE(one->x(), -100.0);
+ QCOMPARE(one->y(), -100.0);
+
+ QQuickRectangle *two = window->rootObject()->findChild<QQuickRectangle*>("two");
+ QVERIFY(two != 0);
+ QCOMPARE(two->x(), -100.0);
+ QCOMPARE(two->y(), -100.0);
+
+ QQuickRectangle *three = window->rootObject()->findChild<QQuickRectangle*>("three");
+ QVERIFY(three != 0);
+ QCOMPARE(three->x(), -100.0);
+ QCOMPARE(three->y(), -100.0);
+
+ QQuickRectangle *four = window->rootObject()->findChild<QQuickRectangle*>("four");
+ QVERIFY(four != 0);
+ QCOMPARE(four->x(), -100.0);
+ QCOMPARE(four->y(), -100.0);
+
+ QQuickRectangle *five = window->rootObject()->findChild<QQuickRectangle*>("five");
+ QVERIFY(five != 0);
+ QCOMPARE(five->x(), -100.0);
+ QCOMPARE(five->y(), -100.0);
+
+ QVERIFY(QTest::qWaitForWindowExposed(window.data())); //It may not relayout until the next frame, so it needs to be drawn
+
+ QQuickItem *grid = window->rootObject()->findChild<QQuickItem*>("grid");
+ QVERIFY(grid);
+ QCOMPARE(grid->width(), 150.0);
+ QCOMPARE(grid->height(), 100.0);
+
+ // test padding
+ grid->setProperty("padding", 1);
+ grid->setProperty("topPadding", 2);
+ grid->setProperty("leftPadding", 3);
+ grid->setProperty("rightPadding", 4);
+ grid->setProperty("bottomPadding", 5);
+
+ QTRY_COMPARE(grid->width(), 157.0);
+ QCOMPARE(grid->height(), 107.0);
+
+ //QTRY_COMPARE used instead of waiting for the expected time of animation completion
+ //Note that this means the duration of the animation is NOT tested
+
+ QTRY_COMPARE(one->y(), 2.0);
+ QTRY_COMPARE(one->x(), 3.0);
+ QTRY_COMPARE(two->isVisible(), false);
+ QTRY_COMPARE(two->y(), -100.0);
+ QTRY_COMPARE(two->x(), -100.0);
+ QTRY_COMPARE(three->y(), 2.0);
+ QTRY_COMPARE(three->x(), 53.0);
+ QTRY_COMPARE(four->y(), 2.0);
+ QTRY_COMPARE(four->x(), 103.0);
+ QTRY_COMPARE(five->y(), 52.0);
+ QTRY_COMPARE(five->x(), 3.0);
+
+ //Add 'two'
+ two->setVisible(true);
+ QCOMPARE(two->isVisible(), true);
+ QCOMPARE(grid->width(), 157.0);
+ QCOMPARE(grid->height(), 107.0);
+ QTest::qWait(0);//Let the animation start
+ QCOMPARE(two->x(), -100.0);
+ QCOMPARE(two->y(), -100.0);
+ QCOMPARE(one->x(), 3.0);
+ QCOMPARE(one->y(), 2.0);
+ QCOMPARE(three->x(), 53.0);
+ QCOMPARE(three->y(), 2.0);
+ QCOMPARE(four->x(), 103.0);
+ QCOMPARE(four->y(), 2.0);
+ QCOMPARE(five->x(), 3.0);
+ QCOMPARE(five->y(), 52.0);
+ //Let the animation complete
+ QTRY_COMPARE(two->x(), 53.0);
+ QTRY_COMPARE(two->y(), 2.0);
+ QTRY_COMPARE(one->x(), 3.0);
+ QTRY_COMPARE(one->y(), 2.0);
+ QTRY_COMPARE(three->x(), 103.0);
+ QTRY_COMPARE(three->y(), 2.0);
+ QTRY_COMPARE(four->x(), 3.0);
+ QTRY_COMPARE(four->y(), 52.0);
+ QTRY_COMPARE(five->x(), 53.0);
+ QTRY_COMPARE(five->y(), 52.0);
+
+}
+
void tst_qquickpositioners::test_grid_animated_rightToLeft()
{
QScopedPointer<QQuickView> window(createView(testFile("grid-animated.qml"), false));
@@ -1365,6 +2520,100 @@ void tst_qquickpositioners::test_grid_animated_rightToLeft()
}
+void tst_qquickpositioners::test_grid_animated_rightToLeft_padding()
+{
+ QScopedPointer<QQuickView> window(createView(testFile("grid-animated.qml"), false));
+
+ window->rootObject()->setProperty("testRightToLeft", true);
+
+ //Note that all animate in
+ QQuickRectangle *one = window->rootObject()->findChild<QQuickRectangle*>("one");
+ QVERIFY(one != 0);
+ QCOMPARE(one->x(), -100.0);
+ QCOMPARE(one->y(), -100.0);
+
+ QQuickRectangle *two = window->rootObject()->findChild<QQuickRectangle*>("two");
+ QVERIFY(two != 0);
+ QCOMPARE(two->x(), -100.0);
+ QCOMPARE(two->y(), -100.0);
+
+ QQuickRectangle *three = window->rootObject()->findChild<QQuickRectangle*>("three");
+ QVERIFY(three != 0);
+ QCOMPARE(three->x(), -100.0);
+ QCOMPARE(three->y(), -100.0);
+
+ QQuickRectangle *four = window->rootObject()->findChild<QQuickRectangle*>("four");
+ QVERIFY(four != 0);
+ QCOMPARE(four->x(), -100.0);
+ QCOMPARE(four->y(), -100.0);
+
+ QQuickRectangle *five = window->rootObject()->findChild<QQuickRectangle*>("five");
+ QVERIFY(five != 0);
+ QCOMPARE(five->x(), -100.0);
+ QCOMPARE(five->y(), -100.0);
+
+ QVERIFY(QTest::qWaitForWindowExposed(window.data())); //It may not relayout until the next frame, so it needs to be drawn
+
+ QQuickItem *grid = window->rootObject()->findChild<QQuickItem*>("grid");
+ QVERIFY(grid);
+ QCOMPARE(grid->width(), 150.0);
+ QCOMPARE(grid->height(), 100.0);
+
+ // test padding
+ grid->setProperty("padding", 1);
+ grid->setProperty("topPadding", 2);
+ grid->setProperty("leftPadding", 3);
+ grid->setProperty("rightPadding", 4);
+ grid->setProperty("bottomPadding", 5);
+
+ QTRY_COMPARE(grid->width(), 157.0);
+ QCOMPARE(grid->height(), 107.0);
+
+ //QTRY_COMPARE used instead of waiting for the expected time of animation completion
+ //Note that this means the duration of the animation is NOT tested
+
+ QTRY_COMPARE(one->y(), 2.0);
+ QTRY_COMPARE(one->x(), 103.0);
+ QTRY_COMPARE(two->isVisible(), false);
+ QTRY_COMPARE(two->y(), -100.0);
+ QTRY_COMPARE(two->x(), -100.0);
+ QTRY_COMPARE(three->y(), 2.0);
+ QTRY_COMPARE(three->x(), 53.0);
+ QTRY_COMPARE(four->y(), 2.0);
+ QTRY_COMPARE(four->x(), 3.0);
+ QTRY_COMPARE(five->y(), 52.0);
+ QTRY_COMPARE(five->x(), 103.0);
+
+ //Add 'two'
+ two->setVisible(true);
+ QCOMPARE(two->isVisible(), true);
+ QCOMPARE(grid->width(), 157.0);
+ QCOMPARE(grid->height(), 107.0);
+ QTest::qWait(0);//Let the animation start
+ QCOMPARE(two->x(), -100.0);
+ QCOMPARE(two->y(), -100.0);
+ QCOMPARE(one->x(), 103.0);
+ QCOMPARE(one->y(), 2.0);
+ QCOMPARE(three->x(), 53.0);
+ QCOMPARE(three->y(), 2.0);
+ QCOMPARE(four->x(), 3.0);
+ QCOMPARE(four->y(), 2.0);
+ QCOMPARE(five->x(), 103.0);
+ QCOMPARE(five->y(), 52.0);
+ //Let the animation complete
+ QTRY_COMPARE(two->x(), 53.0);
+ QTRY_COMPARE(two->y(), 2.0);
+ QTRY_COMPARE(one->x(), 103.0);
+ QTRY_COMPARE(one->y(), 2.0);
+ QTRY_COMPARE(three->x(), 3.0);
+ QTRY_COMPARE(three->y(), 2.0);
+ QTRY_COMPARE(four->x(), 103.0);
+ QTRY_COMPARE(four->y(), 52.0);
+ QTRY_COMPARE(five->x(), 53.0);
+ QTRY_COMPARE(five->y(), 52.0);
+
+}
+
void tst_qquickpositioners::test_grid_zero_columns()
{
QScopedPointer<QQuickView> window(createView(testFile("gridzerocolumns.qml")));
@@ -1395,6 +2644,26 @@ void tst_qquickpositioners::test_grid_zero_columns()
QCOMPARE(grid->width(), 170.0);
QCOMPARE(grid->height(), 60.0);
+ // test padding
+ grid->setProperty("padding", 1);
+ grid->setProperty("topPadding", 2);
+ grid->setProperty("leftPadding", 3);
+ grid->setProperty("rightPadding", 4);
+ grid->setProperty("bottomPadding", 5);
+
+ QTRY_COMPARE(grid->width(), 177.0);
+ QCOMPARE(grid->height(), 67.0);
+
+ QCOMPARE(one->x(), 3.0);
+ QCOMPARE(one->y(), 2.0);
+ QCOMPARE(two->x(), 53.0);
+ QCOMPARE(two->y(), 2.0);
+ QCOMPARE(three->x(), 73.0);
+ QCOMPARE(three->y(), 2.0);
+ QCOMPARE(four->x(), 123.0);
+ QCOMPARE(four->y(), 2.0);
+ QCOMPARE(five->x(), 3.0);
+ QCOMPARE(five->y(), 52.0);
}
void tst_qquickpositioners::test_grid_H_alignment()
@@ -1476,6 +2745,95 @@ void tst_qquickpositioners::test_grid_H_alignment()
}
+void tst_qquickpositioners::test_grid_H_alignment_padding()
+{
+ QScopedPointer<QQuickView> window(createView(testFile("gridtest.qml")));
+
+ window->rootObject()->setProperty("testHAlignment", QQuickGrid::AlignHCenter);
+
+ QQuickRectangle *one = window->rootObject()->findChild<QQuickRectangle*>("one");
+ QVERIFY(one != 0);
+ QQuickRectangle *two = window->rootObject()->findChild<QQuickRectangle*>("two");
+ QVERIFY(two != 0);
+ QQuickRectangle *three = window->rootObject()->findChild<QQuickRectangle*>("three");
+ QVERIFY(three != 0);
+ QQuickRectangle *four = window->rootObject()->findChild<QQuickRectangle*>("four");
+ QVERIFY(four != 0);
+ QQuickRectangle *five = window->rootObject()->findChild<QQuickRectangle*>("five");
+ QVERIFY(five != 0);
+
+ QCOMPARE(one->x(), 0.0);
+ QCOMPARE(one->y(), 0.0);
+ QCOMPARE(two->x(), 50.0);
+ QCOMPARE(two->y(), 0.0);
+ QCOMPARE(three->x(), 70.0);
+ QCOMPARE(three->y(), 0.0);
+ QCOMPARE(four->x(), 0.0);
+ QCOMPARE(four->y(), 50.0);
+ QCOMPARE(five->x(), 55.0);
+ QCOMPARE(five->y(), 50.0);
+
+ QQuickItem *grid = window->rootObject()->findChild<QQuickItem*>("grid");
+ QCOMPARE(grid->width(), 100.0);
+ QCOMPARE(grid->height(), 100.0);
+
+ // test padding
+ grid->setProperty("padding", 1);
+ grid->setProperty("topPadding", 2);
+ grid->setProperty("leftPadding", 3);
+ grid->setProperty("rightPadding", 4);
+ grid->setProperty("bottomPadding", 5);
+
+ QTRY_COMPARE(grid->width(), 107.0);
+ QCOMPARE(grid->height(), 107.0);
+
+ window->rootObject()->setProperty("testHAlignment", QQuickGrid::AlignRight);
+
+ QCOMPARE(one->x(), 3.0);
+ QCOMPARE(one->y(), 2.0);
+ QCOMPARE(two->x(), 53.0);
+ QCOMPARE(two->y(), 2.0);
+ QCOMPARE(three->x(), 73.0);
+ QCOMPARE(three->y(), 2.0);
+ QCOMPARE(four->x(), 3.0);
+ QCOMPARE(four->y(), 52.0);
+ QCOMPARE(five->x(), 63.0);
+ QCOMPARE(five->y(), 52.0);
+ QCOMPARE(grid->width(), 107.0);
+ QCOMPARE(grid->height(), 107.0);
+
+ window->rootObject()->setProperty("testRightToLeft", true);
+
+ QCOMPARE(one->x(), 53.0);
+ QCOMPARE(one->y(), 2.0);
+ QCOMPARE(two->x(), 33.0);
+ QCOMPARE(two->y(), 2.0);
+ QCOMPARE(three->x(), 3.0);
+ QCOMPARE(three->y(), 2.0);
+ QCOMPARE(four->x(), 53.0);
+ QCOMPARE(four->y(), 52.0);
+ QCOMPARE(five->x(), 33.0);
+ QCOMPARE(five->y(), 52.0);
+ QCOMPARE(grid->width(), 107.0);
+ QCOMPARE(grid->height(), 107.0);
+
+ window->rootObject()->setProperty("testHAlignment", QQuickGrid::AlignHCenter);
+
+ QCOMPARE(one->x(), 53.0);
+ QCOMPARE(one->y(), 2.0);
+ QCOMPARE(two->x(), 33.0);
+ QCOMPARE(two->y(), 2.0);
+ QCOMPARE(three->x(), 3.0);
+ QCOMPARE(three->y(), 2.0);
+ QCOMPARE(four->x(), 53.0);
+ QCOMPARE(four->y(), 52.0);
+ QCOMPARE(five->x(), 38.0);
+ QCOMPARE(five->y(), 52.0);
+ QCOMPARE(grid->width(), 107.0);
+ QCOMPARE(grid->height(), 107.0);
+
+}
+
void tst_qquickpositioners::test_grid_V_alignment()
{
QScopedPointer<QQuickView> window(createView(testFile("gridtest.qml")));
@@ -1519,6 +2877,63 @@ void tst_qquickpositioners::test_grid_V_alignment()
}
+void tst_qquickpositioners::test_grid_V_alignment_padding()
+{
+ QScopedPointer<QQuickView> window(createView(testFile("gridtest.qml")));
+
+ window->rootObject()->setProperty("testVAlignment", QQuickGrid::AlignVCenter);
+
+ QQuickRectangle *one = window->rootObject()->findChild<QQuickRectangle*>("one");
+ QVERIFY(one != 0);
+ QQuickRectangle *two = window->rootObject()->findChild<QQuickRectangle*>("two");
+ QVERIFY(two != 0);
+ QQuickRectangle *three = window->rootObject()->findChild<QQuickRectangle*>("three");
+ QVERIFY(three != 0);
+ QQuickRectangle *four = window->rootObject()->findChild<QQuickRectangle*>("four");
+ QVERIFY(four != 0);
+ QQuickRectangle *five = window->rootObject()->findChild<QQuickRectangle*>("five");
+ QVERIFY(five != 0);
+
+ QQuickItem *grid = window->rootObject()->findChild<QQuickItem*>("grid");
+ QCOMPARE(grid->width(), 100.0);
+ QCOMPARE(grid->height(), 100.0);
+
+ // test padding
+ grid->setProperty("padding", 1);
+ grid->setProperty("topPadding", 2);
+ grid->setProperty("leftPadding", 3);
+ grid->setProperty("rightPadding", 4);
+ grid->setProperty("bottomPadding", 5);
+
+ QTRY_COMPARE(grid->width(), 107.0);
+ QCOMPARE(grid->height(), 107.0);
+
+ QCOMPARE(one->x(), 3.0);
+ QCOMPARE(one->y(), 2.0);
+ QCOMPARE(two->x(), 53.0);
+ QCOMPARE(two->y(), 2.0);
+ QCOMPARE(three->x(), 73.0);
+ QCOMPARE(three->y(), 17.0);
+ QCOMPARE(four->x(), 3.0);
+ QCOMPARE(four->y(), 52.0);
+ QCOMPARE(five->x(), 53.0);
+ QCOMPARE(five->y(), 72.0);
+
+ window->rootObject()->setProperty("testVAlignment", QQuickGrid::AlignBottom);
+
+ QCOMPARE(one->x(), 3.0);
+ QCOMPARE(one->y(), 2.0);
+ QCOMPARE(two->x(), 53.0);
+ QCOMPARE(two->y(), 2.0);
+ QCOMPARE(three->x(), 73.0);
+ QCOMPARE(three->y(), 32.0);
+ QCOMPARE(four->x(), 3.0);
+ QCOMPARE(four->y(), 52.0);
+ QCOMPARE(five->x(), 53.0);
+ QCOMPARE(five->y(), 92.0);
+
+}
+
void tst_qquickpositioners::test_propertychanges()
{
QScopedPointer<QQuickView> window(createView(testFile("propertychangestest.qml")));
@@ -1599,6 +3014,28 @@ void tst_qquickpositioners::test_repeater()
}
+void tst_qquickpositioners::test_repeater_padding()
+{
+ QScopedPointer<QQuickView> window(createView(testFile("repeatertest-padding.qml")));
+
+ QQuickRectangle *one = findItem<QQuickRectangle>(window->contentItem(), "one");
+ QVERIFY(one != 0);
+
+ QQuickRectangle *two = findItem<QQuickRectangle>(window->contentItem(), "two");
+ QVERIFY(two != 0);
+
+ QQuickRectangle *three = findItem<QQuickRectangle>(window->contentItem(), "three");
+ QVERIFY(three != 0);
+
+ QCOMPARE(one->x(), 3.0);
+ QCOMPARE(one->y(), 2.0);
+ QCOMPARE(two->x(), 53.0);
+ QCOMPARE(two->y(), 2.0);
+ QCOMPARE(three->x(), 103.0);
+ QCOMPARE(three->y(), 2.0);
+
+}
+
void tst_qquickpositioners::test_flow()
{
QScopedPointer<QQuickView> window(createView(testFile("flowtest.qml")));
@@ -1632,6 +3069,219 @@ void tst_qquickpositioners::test_flow()
QCOMPARE(flow->width(), 90.0);
QCOMPARE(flow->height(), 120.0);
+ // test padding
+ flow->setProperty("padding", 1);
+ flow->setProperty("topPadding", 2);
+ flow->setProperty("leftPadding", 3);
+ flow->setProperty("rightPadding", 4);
+ flow->setProperty("bottomPadding", 5);
+
+ QTRY_COMPARE(flow->height(), 127.0);
+ QCOMPARE(flow->width(), 90.0);
+
+ QCOMPARE(one->x(), 3.0);
+ QCOMPARE(one->y(), 2.0);
+ QCOMPARE(two->x(), 53.0);
+ QCOMPARE(two->y(), 2.0);
+ QCOMPARE(three->x(), 3.0);
+ QCOMPARE(three->y(), 52.0);
+ QCOMPARE(four->x(), 3.0);
+ QCOMPARE(four->y(), 72.0);
+ QCOMPARE(five->x(), 53.0);
+ QCOMPARE(five->y(), 72.0);
+}
+
+void tst_qquickpositioners::test_flow_padding()
+{
+ QScopedPointer<QQuickView> window(createView(testFile("flowtest.qml")));
+
+ window->rootObject()->setProperty("testRightToLeft", false);
+
+ QQuickRectangle *one = window->rootObject()->findChild<QQuickRectangle*>("one");
+ QVERIFY(one != 0);
+ QQuickRectangle *two = window->rootObject()->findChild<QQuickRectangle*>("two");
+ QVERIFY(two != 0);
+ QQuickRectangle *three = window->rootObject()->findChild<QQuickRectangle*>("three");
+ QVERIFY(three != 0);
+ QQuickRectangle *four = window->rootObject()->findChild<QQuickRectangle*>("four");
+ QVERIFY(four != 0);
+ QQuickRectangle *five = window->rootObject()->findChild<QQuickRectangle*>("five");
+ QVERIFY(five != 0);
+
+ QCOMPARE(one->x(), 0.0);
+ QCOMPARE(one->y(), 0.0);
+ QCOMPARE(two->x(), 50.0);
+ QCOMPARE(two->y(), 0.0);
+ QCOMPARE(three->x(), 0.0);
+ QCOMPARE(three->y(), 50.0);
+ QCOMPARE(four->x(), 0.0);
+ QCOMPARE(four->y(), 70.0);
+ QCOMPARE(five->x(), 50.0);
+ QCOMPARE(five->y(), 70.0);
+
+ QQuickItem *flow = window->rootObject()->findChild<QQuickItem*>("flow");
+ QVERIFY(flow);
+ QCOMPARE(flow->width(), 90.0);
+ QCOMPARE(flow->height(), 120.0);
+
+ QQuickFlow *obj = qobject_cast<QQuickFlow*>(flow);
+ QVERIFY(obj != 0);
+
+ QCOMPARE(flow->property("padding").toDouble(), 0.0);
+ QCOMPARE(flow->property("topPadding").toDouble(), 0.0);
+ QCOMPARE(flow->property("leftPadding").toDouble(), 0.0);
+ QCOMPARE(flow->property("rightPadding").toDouble(), 0.0);
+ QCOMPARE(flow->property("bottomPadding").toDouble(), 0.0);
+
+ obj->setPadding(1.0);
+
+ QCOMPARE(flow->property("padding").toDouble(), 1.0);
+ QCOMPARE(flow->property("topPadding").toDouble(), 1.0);
+ QCOMPARE(flow->property("leftPadding").toDouble(), 1.0);
+ QCOMPARE(flow->property("rightPadding").toDouble(), 1.0);
+ QCOMPARE(flow->property("bottomPadding").toDouble(), 1.0);
+
+ QTRY_COMPARE(flow->height(), 122.0);
+ QCOMPARE(flow->width(), 90.0);
+
+ QCOMPARE(one->x(), 1.0);
+ QCOMPARE(one->y(), 1.0);
+ QCOMPARE(two->x(), 51.0);
+ QCOMPARE(two->y(), 1.0);
+ QCOMPARE(three->x(), 1.0);
+ QCOMPARE(three->y(), 51.0);
+ QCOMPARE(four->x(), 1.0);
+ QCOMPARE(four->y(), 71.0);
+ QCOMPARE(five->x(), 51.0);
+ QCOMPARE(five->y(), 71.0);
+
+ obj->setTopPadding(2.0);
+
+ QCOMPARE(flow->property("padding").toDouble(), 1.0);
+ QCOMPARE(flow->property("topPadding").toDouble(), 2.0);
+ QCOMPARE(flow->property("leftPadding").toDouble(), 1.0);
+ QCOMPARE(flow->property("rightPadding").toDouble(), 1.0);
+ QCOMPARE(flow->property("bottomPadding").toDouble(), 1.0);
+
+ QTRY_COMPARE(flow->height(), 123.0);
+ QCOMPARE(flow->width(), 90.0);
+
+ QCOMPARE(one->x(), 1.0);
+ QCOMPARE(one->y(), 2.0);
+ QCOMPARE(two->x(), 51.0);
+ QCOMPARE(two->y(), 2.0);
+ QCOMPARE(three->x(), 1.0);
+ QCOMPARE(three->y(), 52.0);
+ QCOMPARE(four->x(), 1.0);
+ QCOMPARE(four->y(), 72.0);
+ QCOMPARE(five->x(), 51.0);
+ QCOMPARE(five->y(), 72.0);
+
+ obj->setLeftPadding(3.0);
+
+ QCOMPARE(flow->property("padding").toDouble(), 1.0);
+ QCOMPARE(flow->property("topPadding").toDouble(), 2.0);
+ QCOMPARE(flow->property("leftPadding").toDouble(), 3.0);
+ QCOMPARE(flow->property("rightPadding").toDouble(), 1.0);
+ QCOMPARE(flow->property("bottomPadding").toDouble(), 1.0);
+
+ QCOMPARE(flow->height(), 123.0);
+ QCOMPARE(flow->width(), 90.0);
+
+ QTRY_COMPARE(one->x(), 3.0);
+ QCOMPARE(one->y(), 2.0);
+ QCOMPARE(two->x(), 53.0);
+ QCOMPARE(two->y(), 2.0);
+ QCOMPARE(three->x(), 3.0);
+ QCOMPARE(three->y(), 52.0);
+ QCOMPARE(four->x(), 3.0);
+ QCOMPARE(four->y(), 72.0);
+ QCOMPARE(five->x(), 53.0);
+ QCOMPARE(five->y(), 72.0);
+
+ obj->setRightPadding(4.0);
+
+ QCOMPARE(flow->property("padding").toDouble(), 1.0);
+ QCOMPARE(flow->property("topPadding").toDouble(), 2.0);
+ QCOMPARE(flow->property("leftPadding").toDouble(), 3.0);
+ QCOMPARE(flow->property("rightPadding").toDouble(), 4.0);
+ QCOMPARE(flow->property("bottomPadding").toDouble(), 1.0);
+
+ QCOMPARE(flow->height(), 123.0);
+ QCOMPARE(flow->width(), 90.0);
+
+ QTRY_COMPARE(one->x(), 3.0);
+ QCOMPARE(one->y(), 2.0);
+ QCOMPARE(two->x(), 53.0);
+ QCOMPARE(two->y(), 2.0);
+ QCOMPARE(three->x(), 3.0);
+ QCOMPARE(three->y(), 52.0);
+ QCOMPARE(four->x(), 3.0);
+ QCOMPARE(four->y(), 72.0);
+ QCOMPARE(five->x(), 53.0);
+ QCOMPARE(five->y(), 72.0);
+
+ obj->setBottomPadding(5.0);
+
+ QCOMPARE(flow->property("padding").toDouble(), 1.0);
+ QCOMPARE(flow->property("topPadding").toDouble(), 2.0);
+ QCOMPARE(flow->property("leftPadding").toDouble(), 3.0);
+ QCOMPARE(flow->property("rightPadding").toDouble(), 4.0);
+ QCOMPARE(flow->property("bottomPadding").toDouble(), 5.0);
+
+ QTRY_COMPARE(flow->height(), 127.0);
+ QCOMPARE(flow->width(), 90.0);
+
+ QCOMPARE(one->x(), 3.0);
+ QCOMPARE(one->y(), 2.0);
+ QCOMPARE(two->x(), 53.0);
+ QCOMPARE(two->y(), 2.0);
+ QCOMPARE(three->x(), 3.0);
+ QCOMPARE(three->y(), 52.0);
+ QCOMPARE(four->x(), 3.0);
+ QCOMPARE(four->y(), 72.0);
+ QCOMPARE(five->x(), 53.0);
+ QCOMPARE(five->y(), 72.0);
+
+ obj->resetBottomPadding();
+ QCOMPARE(flow->property("bottomPadding").toDouble(), 1.0);
+ QTRY_COMPARE(flow->height(), 123.0);
+ QCOMPARE(flow->width(), 90.0);
+
+ obj->resetRightPadding();
+ QCOMPARE(flow->property("rightPadding").toDouble(), 1.0);
+ QTRY_COMPARE(flow->height(), 123.0);
+ QCOMPARE(flow->width(), 90.0);
+
+ obj->resetLeftPadding();
+ QCOMPARE(flow->property("leftPadding").toDouble(), 1.0);
+ QTRY_COMPARE(flow->height(), 123.0);
+ QCOMPARE(flow->width(), 90.0);
+
+ obj->resetTopPadding();
+ QCOMPARE(flow->property("topPadding").toDouble(), 1.0);
+ QTRY_COMPARE(flow->height(), 122.0);
+ QCOMPARE(flow->width(), 90.0);
+
+ obj->resetPadding();
+ QCOMPARE(flow->property("padding").toDouble(), 0.0);
+ QCOMPARE(flow->property("topPadding").toDouble(), 0.0);
+ QCOMPARE(flow->property("leftPadding").toDouble(), 0.0);
+ QCOMPARE(flow->property("rightPadding").toDouble(), 0.0);
+ QCOMPARE(flow->property("bottomPadding").toDouble(), 0.0);
+ QTRY_COMPARE(flow->height(), 120.0);
+ QCOMPARE(flow->width(), 90.0);
+
+ QCOMPARE(one->x(), 0.0);
+ QCOMPARE(one->y(), 0.0);
+ QCOMPARE(two->x(), 50.0);
+ QCOMPARE(two->y(), 0.0);
+ QCOMPARE(three->x(), 0.0);
+ QCOMPARE(three->y(), 50.0);
+ QCOMPARE(four->x(), 0.0);
+ QCOMPARE(four->y(), 70.0);
+ QCOMPARE(five->x(), 50.0);
+ QCOMPARE(five->y(), 70.0);
}
void tst_qquickpositioners::test_flow_rightToLeft()
@@ -1667,6 +3317,26 @@ void tst_qquickpositioners::test_flow_rightToLeft()
QCOMPARE(flow->width(), 90.0);
QCOMPARE(flow->height(), 120.0);
+ // test padding
+ flow->setProperty("padding", 1);
+ flow->setProperty("topPadding", 2);
+ flow->setProperty("leftPadding", 3);
+ flow->setProperty("rightPadding", 4);
+ flow->setProperty("bottomPadding", 5);
+
+ QTRY_COMPARE(flow->height(), 127.0);
+ QCOMPARE(flow->width(), 90.0);
+
+ QCOMPARE(one->x(), 36.0);
+ QCOMPARE(one->y(), 2.0);
+ QCOMPARE(two->x(), 16.0);
+ QCOMPARE(two->y(), 2.0);
+ QCOMPARE(three->x(), 36.0);
+ QCOMPARE(three->y(), 52.0);
+ QCOMPARE(four->x(), 36.0);
+ QCOMPARE(four->y(), 72.0);
+ QCOMPARE(five->x(), 26.0);
+ QCOMPARE(five->y(), 72.0);
}
void tst_qquickpositioners::test_flow_topToBottom()
@@ -1693,7 +3363,7 @@ void tst_qquickpositioners::test_flow_topToBottom()
QCOMPARE(three->x(), 50.0);
QCOMPARE(three->y(), 50.0);
QCOMPARE(four->x(), 100.0);
- QCOMPARE(four->y(), 00.0);
+ QCOMPARE(four->y(), 0.0);
QCOMPARE(five->x(), 100.0);
QCOMPARE(five->y(), 50.0);
@@ -1721,6 +3391,79 @@ void tst_qquickpositioners::test_flow_topToBottom()
}
+void tst_qquickpositioners::test_flow_topToBottom_padding()
+{
+ QScopedPointer<QQuickView> window(createView(testFile("flowtest-toptobottom.qml")));
+
+ window->rootObject()->setProperty("testRightToLeft", false);
+
+ QQuickRectangle *one = window->rootObject()->findChild<QQuickRectangle*>("one");
+ QVERIFY(one != 0);
+ QQuickRectangle *two = window->rootObject()->findChild<QQuickRectangle*>("two");
+ QVERIFY(two != 0);
+ QQuickRectangle *three = window->rootObject()->findChild<QQuickRectangle*>("three");
+ QVERIFY(three != 0);
+ QQuickRectangle *four = window->rootObject()->findChild<QQuickRectangle*>("four");
+ QVERIFY(four != 0);
+ QQuickRectangle *five = window->rootObject()->findChild<QQuickRectangle*>("five");
+ QVERIFY(five != 0);
+
+ QCOMPARE(one->x(), 0.0);
+ QCOMPARE(one->y(), 0.0);
+ QCOMPARE(two->x(), 50.0);
+ QCOMPARE(two->y(), 0.0);
+ QCOMPARE(three->x(), 50.0);
+ QCOMPARE(three->y(), 50.0);
+ QCOMPARE(four->x(), 100.0);
+ QCOMPARE(four->y(), 0.0);
+ QCOMPARE(five->x(), 100.0);
+ QCOMPARE(five->y(), 50.0);
+
+ QQuickItem *flow = window->rootObject()->findChild<QQuickItem*>("flow");
+ QVERIFY(flow);
+ QCOMPARE(flow->height(), 90.0);
+ QCOMPARE(flow->width(), 150.0);
+
+ // test padding
+ flow->setProperty("padding", 1);
+ flow->setProperty("topPadding", 2);
+ flow->setProperty("leftPadding", 3);
+ flow->setProperty("rightPadding", 4);
+ flow->setProperty("bottomPadding", 5);
+
+ QTRY_COMPARE(flow->width(), 157.0);
+ QCOMPARE(flow->height(), 90.0);
+
+ QCOMPARE(one->x(), 3.0);
+ QCOMPARE(one->y(), 2.0);
+ QCOMPARE(two->x(), 53.0);
+ QCOMPARE(two->y(), 2.0);
+ QCOMPARE(three->x(), 53.0);
+ QCOMPARE(three->y(), 52.0);
+ QCOMPARE(four->x(), 103.0);
+ QCOMPARE(four->y(), 2.0);
+ QCOMPARE(five->x(), 103.0);
+ QCOMPARE(five->y(), 52.0);
+
+ window->rootObject()->setProperty("testRightToLeft", true);
+
+ QVERIFY(flow);
+ QTRY_COMPARE(flow->width(), 157.0);
+ QCOMPARE(flow->height(), 90.0);
+
+ QCOMPARE(one->x(), 103.0);
+ QCOMPARE(one->y(), 2.0);
+ QCOMPARE(two->x(), 83.0);
+ QCOMPARE(two->y(), 2.0);
+ QCOMPARE(three->x(), 53.0);
+ QCOMPARE(three->y(), 52.0);
+ QCOMPARE(four->x(), 3.0);
+ QCOMPARE(four->y(), 2.0);
+ QCOMPARE(five->x(), 43.0);
+ QCOMPARE(five->y(), 52.0);
+
+}
+
void tst_qquickpositioners::test_flow_resize()
{
QScopedPointer<QQuickView> window(createView(testFile("flowtest.qml")));
@@ -1754,6 +3497,39 @@ void tst_qquickpositioners::test_flow_resize()
}
+void tst_qquickpositioners::test_flow_resize_padding()
+{
+ QScopedPointer<QQuickView> window(createView(testFile("flowtest-padding.qml")));
+
+ QQuickItem *root = qobject_cast<QQuickItem*>(window->rootObject());
+ QVERIFY(root);
+ root->setWidth(125);
+ root->setProperty("testRightToLeft", false);
+
+ QQuickRectangle *one = window->rootObject()->findChild<QQuickRectangle*>("one");
+ QVERIFY(one != 0);
+ QQuickRectangle *two = window->rootObject()->findChild<QQuickRectangle*>("two");
+ QVERIFY(two != 0);
+ QQuickRectangle *three = window->rootObject()->findChild<QQuickRectangle*>("three");
+ QVERIFY(three != 0);
+ QQuickRectangle *four = window->rootObject()->findChild<QQuickRectangle*>("four");
+ QVERIFY(four != 0);
+ QQuickRectangle *five = window->rootObject()->findChild<QQuickRectangle*>("five");
+ QVERIFY(five != 0);
+
+ QTRY_COMPARE(one->x(), 3.0);
+ QTRY_COMPARE(one->y(), 2.0);
+ QTRY_COMPARE(two->x(), 53.0);
+ QTRY_COMPARE(two->y(), 2.0);
+ QTRY_COMPARE(three->x(), 3.0);
+ QTRY_COMPARE(three->y(), 52.0);
+ QTRY_COMPARE(four->x(), 53.0);
+ QTRY_COMPARE(four->y(), 52.0);
+ QTRY_COMPARE(five->x(), 103.0);
+ QTRY_COMPARE(five->y(), 52.0);
+
+}
+
void tst_qquickpositioners::test_flow_resize_rightToLeft()
{
QScopedPointer<QQuickView> window(createView(testFile("flowtest.qml")));
@@ -1787,6 +3563,39 @@ void tst_qquickpositioners::test_flow_resize_rightToLeft()
}
+void tst_qquickpositioners::test_flow_resize_rightToLeft_padding()
+{
+ QScopedPointer<QQuickView> window(createView(testFile("flowtest-padding.qml")));
+
+ QQuickItem *root = qobject_cast<QQuickItem*>(window->rootObject());
+ QVERIFY(root);
+ root->setWidth(125);
+ root->setProperty("testRightToLeft", true);
+
+ QQuickRectangle *one = window->rootObject()->findChild<QQuickRectangle*>("one");
+ QTRY_VERIFY(one != 0);
+ QQuickRectangle *two = window->rootObject()->findChild<QQuickRectangle*>("two");
+ QVERIFY(two != 0);
+ QQuickRectangle *three = window->rootObject()->findChild<QQuickRectangle*>("three");
+ QVERIFY(three != 0);
+ QQuickRectangle *four = window->rootObject()->findChild<QQuickRectangle*>("four");
+ QVERIFY(four != 0);
+ QQuickRectangle *five = window->rootObject()->findChild<QQuickRectangle*>("five");
+ QVERIFY(five != 0);
+
+ QCOMPARE(one->x(), 71.0);
+ QCOMPARE(one->y(), 2.0);
+ QCOMPARE(two->x(), 51.0);
+ QCOMPARE(two->y(), 2.0);
+ QCOMPARE(three->x(), 71.0);
+ QCOMPARE(three->y(), 52.0);
+ QCOMPARE(four->x(), 21.0);
+ QCOMPARE(four->y(), 52.0);
+ QCOMPARE(five->x(), 11.0);
+ QCOMPARE(five->y(), 52.0);
+
+}
+
void tst_qquickpositioners::test_flow_implicit_resize()
{
QScopedPointer<QQuickView> window(createView(testFile("flow-testimplicitsize.qml")));
@@ -1815,6 +3624,44 @@ void tst_qquickpositioners::test_flow_implicit_resize()
}
+void tst_qquickpositioners::test_flow_implicit_resize_padding()
+{
+ QScopedPointer<QQuickView> window(createView(testFile("flow-testimplicitsize.qml")));
+ QVERIFY(window->rootObject() != 0);
+
+ QQuickFlow *flow = window->rootObject()->findChild<QQuickFlow*>("flow");
+ QVERIFY(flow != 0);
+
+ QCOMPARE(flow->width(), 100.0);
+ QCOMPARE(flow->height(), 120.0);
+
+ // test padding
+ flow->setProperty("padding", 1);
+ flow->setProperty("topPadding", 2);
+ flow->setProperty("leftPadding", 3);
+ flow->setProperty("rightPadding", 4);
+ flow->setProperty("bottomPadding", 5);
+
+ QTRY_COMPARE(flow->width(), 107.0);
+ QCOMPARE(flow->height(), 127.0);
+
+ window->rootObject()->setProperty("flowLayout", 0);
+ QCOMPARE(flow->flow(), QQuickFlow::LeftToRight);
+ QCOMPARE(flow->width(), 227.0);
+ QCOMPARE(flow->height(), 57.0);
+
+ window->rootObject()->setProperty("flowLayout", 1);
+ QCOMPARE(flow->flow(), QQuickFlow::TopToBottom);
+ QCOMPARE(flow->width(), 107.0);
+ QCOMPARE(flow->height(), 127.0);
+
+ window->rootObject()->setProperty("flowLayout", 2);
+ QCOMPARE(flow->layoutDirection(), Qt::RightToLeft);
+ QCOMPARE(flow->width(), 227.0);
+ QCOMPARE(flow->height(), 57.0);
+
+}
+
void tst_qquickpositioners::test_conflictinganchors()
{
QQmlTestMessageHandler messageHandler;
@@ -1924,7 +3771,9 @@ void tst_qquickpositioners::test_conflictinganchors()
void tst_qquickpositioners::test_mirroring()
{
QList<QString> qmlFiles;
- qmlFiles << "horizontal.qml" << "gridtest.qml" << "flowtest.qml";
+ qmlFiles << "horizontal.qml" << "horizontal-padding.qml"
+ << "gridtest.qml" << "gridtest-padding.qml"
+ << "flowtest.qml" << "flowtest-padding.qml";
QList<QString> objectNames;
objectNames << "one" << "two" << "three" << "four" << "five";
@@ -1942,8 +3791,8 @@ void tst_qquickpositioners::test_mirroring()
// LTR != RTL
foreach (const QString objectName, objectNames) {
- // horizontal.qml only has three items
- if (qmlFile == QString("horizontal.qml") && objectName == QString("four"))
+ // horizontal.qml and horizontal-padding.qml only have three items
+ if (qmlFile.startsWith(QString("horizontal")) && objectName == QString("four"))
break;
QQuickItem *itemA = rootA->findChild<QQuickItem*>(objectName);
QQuickItem *itemB = rootB->findChild<QQuickItem*>(objectName);
@@ -1957,8 +3806,8 @@ void tst_qquickpositioners::test_mirroring()
// RTL == mirror
foreach (const QString objectName, objectNames) {
- // horizontal.qml only has three items
- if (qmlFile == QString("horizontal.qml") && objectName == QString("four"))
+ // horizontal.qml and horizontal-padding.qml only have three items
+ if (qmlFile.startsWith(QString("horizontal")) && objectName == QString("four"))
break;
QQuickItem *itemA = rootA->findChild<QQuickItem*>(objectName);
QQuickItem *itemB = rootB->findChild<QQuickItem*>(objectName);
@@ -1978,8 +3827,8 @@ void tst_qquickpositioners::test_mirroring()
// LTR == RTL + mirror
foreach (const QString objectName, objectNames) {
- // horizontal.qml only has three items
- if (qmlFile == QString("horizontal.qml") && objectName == QString("four"))
+ // horizontal.qml and horizontal-padding.qml only have three items
+ if (qmlFile.startsWith(QString("horizontal")) && objectName == QString("four"))
break;
QQuickItem *itemA = rootA->findChild<QQuickItem*>(objectName);
QQuickItem *itemB = rootB->findChild<QQuickItem*>(objectName);
@@ -1998,12 +3847,63 @@ void tst_qquickpositioners::test_allInvisible()
QQuickRow *row = window->rootObject()->findChild<QQuickRow*>("row");
QVERIFY(row != 0);
- QVERIFY(row->width() == 0);
- QVERIFY(row->height() == 0);
+ QCOMPARE(row->width(), qreal(0));
+ QCOMPARE(row->height(), qreal(0));
+
+ // test padding
+ row->setProperty("padding", 1);
+ row->setProperty("topPadding", 2);
+ row->setProperty("leftPadding", 3);
+ row->setProperty("rightPadding", 4);
+ row->setProperty("bottomPadding", 5);
+
+ QTRY_COMPARE(row->height(), 7.0);
+ QCOMPARE(row->width(), 7.0);
+
QQuickColumn *column = window->rootObject()->findChild<QQuickColumn*>("column");
QVERIFY(column != 0);
- QVERIFY(column->width() == 0);
- QVERIFY(column->height() == 0);
+ QCOMPARE(column->width(), qreal(0));
+ QCOMPARE(column->height(), qreal(0));
+
+ // test padding
+ column->setProperty("padding", 1);
+ column->setProperty("topPadding", 2);
+ column->setProperty("leftPadding", 3);
+ column->setProperty("rightPadding", 4);
+ column->setProperty("bottomPadding", 5);
+
+ QTRY_COMPARE(column->height(), 7.0);
+ QCOMPARE(column->width(), 7.0);
+
+ QQuickGrid *grid = window->rootObject()->findChild<QQuickGrid*>("grid");
+ QVERIFY(grid != 0);
+ QCOMPARE(grid->width(), qreal(0));
+ QCOMPARE(grid->height(), qreal(0));
+
+ // test padding
+ grid->setProperty("padding", 1);
+ grid->setProperty("topPadding", 2);
+ grid->setProperty("leftPadding", 3);
+ grid->setProperty("rightPadding", 4);
+ grid->setProperty("bottomPadding", 5);
+
+ QTRY_COMPARE(grid->height(), 7.0);
+ QCOMPARE(grid->width(), 7.0);
+
+ QQuickFlow *flow = window->rootObject()->findChild<QQuickFlow*>("flow");
+ QVERIFY(flow != 0);
+ QCOMPARE(flow->width(), qreal(0));
+ QCOMPARE(flow->height(), qreal(0));
+
+ // test padding
+ flow->setProperty("padding", 1);
+ flow->setProperty("topPadding", 2);
+ flow->setProperty("leftPadding", 3);
+ flow->setProperty("rightPadding", 4);
+ flow->setProperty("bottomPadding", 5);
+
+ QTRY_COMPARE(flow->height(), 7.0);
+ QCOMPARE(flow->width(), 7.0);
}
void tst_qquickpositioners::test_attachedproperties()
@@ -2017,30 +3917,30 @@ void tst_qquickpositioners::test_attachedproperties()
QVERIFY(greenRect != 0);
int posIndex = greenRect->property("posIndex").toInt();
- QVERIFY(posIndex == 0);
+ QCOMPARE(posIndex, 0);
bool isFirst = greenRect->property("isFirstItem").toBool();
- QVERIFY(isFirst == true);
+ QVERIFY(isFirst);
bool isLast = greenRect->property("isLastItem").toBool();
- QVERIFY(isLast == false);
+ QVERIFY(!isLast);
QQuickRectangle *yellowRect = window->rootObject()->findChild<QQuickRectangle *>("yellowRect");
QVERIFY(yellowRect != 0);
posIndex = yellowRect->property("posIndex").toInt();
- QVERIFY(posIndex == -1);
+ QCOMPARE(posIndex, -1);
isFirst = yellowRect->property("isFirstItem").toBool();
- QVERIFY(isFirst == false);
+ QVERIFY(!isFirst);
isLast = yellowRect->property("isLastItem").toBool();
- QVERIFY(isLast == false);
+ QVERIFY(!isLast);
yellowRect->metaObject()->invokeMethod(yellowRect, "onDemandPositioner");
posIndex = yellowRect->property("posIndex").toInt();
- QVERIFY(posIndex == 1);
+ QCOMPARE(posIndex, 1);
isFirst = yellowRect->property("isFirstItem").toBool();
- QVERIFY(isFirst == false);
+ QVERIFY(!isFirst);
isLast = yellowRect->property("isLastItem").toBool();
- QVERIFY(isLast == true);
+ QVERIFY(isLast);
}
@@ -2066,46 +3966,46 @@ void tst_qquickpositioners::test_attachedproperties_dynamic()
QVERIFY(rect0 != 0);
int posIndex = rect0->property("index").toInt();
- QVERIFY(posIndex == 0);
+ QCOMPARE(posIndex, 0);
bool isFirst = rect0->property("firstItem").toBool();
- QVERIFY(isFirst == true);
+ QVERIFY(isFirst);
bool isLast = rect0->property("lastItem").toBool();
- QVERIFY(isLast == false);
+ QVERIFY(!isLast);
QQuickRectangle *rect1 = window->rootObject()->findChild<QQuickRectangle *>("rect1");
QVERIFY(rect1 != 0);
posIndex = rect1->property("index").toInt();
- QVERIFY(posIndex == 1);
+ QCOMPARE(posIndex, 1);
isFirst = rect1->property("firstItem").toBool();
- QVERIFY(isFirst == false);
+ QVERIFY(!isFirst);
isLast = rect1->property("lastItem").toBool();
- QVERIFY(isLast == true);
+ QVERIFY(isLast);
row->metaObject()->invokeMethod(row, "createSubRect");
- QTRY_VERIFY(rect1->property("index").toInt() == 1);
- QTRY_VERIFY(rect1->property("firstItem").toBool() == false);
- QTRY_VERIFY(rect1->property("lastItem").toBool() == false);
+ QTRY_COMPARE(rect1->property("index").toInt(), 1);
+ QTRY_VERIFY(!rect1->property("firstItem").toBool());
+ QTRY_VERIFY(!rect1->property("lastItem").toBool());
QQuickRectangle *rect2 = window->rootObject()->findChild<QQuickRectangle *>("rect2");
QVERIFY(rect2 != 0);
posIndex = rect2->property("index").toInt();
- QVERIFY(posIndex == 2);
+ QCOMPARE(posIndex, 2);
isFirst = rect2->property("firstItem").toBool();
- QVERIFY(isFirst == false);
+ QVERIFY(!isFirst);
isLast = rect2->property("lastItem").toBool();
- QVERIFY(isLast == true);
+ QVERIFY(isLast);
row->metaObject()->invokeMethod(row, "destroySubRect");
QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete);
QCoreApplication::processEvents();
- QTRY_VERIFY(rect1->property("index").toInt() == 1);
- QTRY_VERIFY(rect1->property("firstItem").toBool() == false);
- QTRY_VERIFY(rect1->property("lastItem").toBool() == true);
+ QTRY_COMPARE(rect1->property("index").toInt(), 1);
+ QTRY_VERIFY(!rect1->property("firstItem").toBool());
+ QTRY_VERIFY(rect1->property("lastItem").toBool());
}
@@ -2138,7 +4038,7 @@ void tst_qquickpositioners::matchIndexLists(const QVariantList &indexLists, cons
void tst_qquickpositioners::matchItemsAndIndexes(const QVariantMap &items, const QaimModel &model, const QList<int> &expectedIndexes)
{
for (QVariantMap::const_iterator it = items.begin(); it != items.end(); ++it) {
- QVERIFY(it.value().type() == QVariant::Int);
+ QCOMPARE(it.value().type(), QVariant::Int);
QString name = it.key();
int itemIndex = it.value().toInt();
QVERIFY2(expectedIndexes.contains(itemIndex), QTest::toString(QString("Index %1 not found in expectedIndexes").arg(itemIndex)));
@@ -2152,7 +4052,7 @@ void tst_qquickpositioners::matchItemsAndIndexes(const QVariantMap &items, const
void tst_qquickpositioners::matchItemLists(const QVariantList &itemLists, const QList<QQuickItem *> &expectedItems)
{
for (int i=0; i<itemLists.count(); i++) {
- QVERIFY(itemLists[i].type() == QVariant::List);
+ QCOMPARE(itemLists[i].type(), QVariant::List);
QVariantList current = itemLists[i].toList();
for (int j=0; j<current.count(); j++) {
QQuickItem *o = qobject_cast<QQuickItem*>(current[j].value<QObject*>());
diff --git a/tests/auto/quick/qquickrepeater/data/modelCleared.qml b/tests/auto/quick/qquickrepeater/data/modelCleared.qml
new file mode 100644
index 0000000000..1269e9bdf2
--- /dev/null
+++ b/tests/auto/quick/qquickrepeater/data/modelCleared.qml
@@ -0,0 +1,17 @@
+import QtQuick 2.0
+
+Row {
+ spacing: 2
+ height: 100
+
+ Repeater {
+ id: repeater
+ objectName: "repeater"
+ model: 10
+ Rectangle {
+ color: "green"
+ width: 10; height: 50
+ anchors.bottom: parent.bottom
+ }
+ }
+}
diff --git a/tests/auto/quick/qquickrepeater/data/objectmodel.qml b/tests/auto/quick/qquickrepeater/data/objectmodel.qml
new file mode 100644
index 0000000000..780f53e802
--- /dev/null
+++ b/tests/auto/quick/qquickrepeater/data/objectmodel.qml
@@ -0,0 +1,28 @@
+import QtQuick 2.0
+import QtQml.Models 2.1
+
+Row {
+ width: 360
+ height: 360
+
+ Repeater {
+ objectName: "repeater"
+ model: ObjectModel {
+ Rectangle {
+ width: 20
+ height: 20
+ color: "red"
+ }
+ Rectangle {
+ width: 20
+ height: 20
+ color: "green"
+ }
+ Rectangle {
+ width: 20
+ height: 20
+ color: "blue"
+ }
+ }
+ }
+}
diff --git a/tests/auto/quick/qquickrepeater/data/stackingorder.qml b/tests/auto/quick/qquickrepeater/data/stackingorder.qml
new file mode 100644
index 0000000000..41dadca0df
--- /dev/null
+++ b/tests/auto/quick/qquickrepeater/data/stackingorder.qml
@@ -0,0 +1,38 @@
+import QtQuick 2.0
+
+Item {
+ id: root
+ property bool stackingOrderOk: true
+
+ function verifyStackingOrder() {
+ var len = children.length
+ for (var i = 0; i < len; ++i) {
+ var expectedName;
+ if (i === 0) {
+ expectedName = "first"
+ } else if (i === len - 2) {
+ expectedName = "repeater"
+ } else if (i === len - 1) {
+ expectedName = "last"
+ } else {
+ expectedName = "middle" + (i - 1)
+ }
+ if (children[i].objectName !== expectedName)
+ stackingOrderOk = false
+ }
+ }
+ Item {
+ objectName: "first"
+ }
+ Repeater {
+ objectName: "repeater"
+ model: 1
+ Item {
+ objectName: "middle" + index
+ Component.onCompleted: { verifyStackingOrder();}
+ }
+ }
+ Item {
+ objectName: "last"
+ }
+}
diff --git a/tests/auto/quick/qquickrepeater/tst_qquickrepeater.cpp b/tests/auto/quick/qquickrepeater/tst_qquickrepeater.cpp
index b2039bd323..a34001b23a 100644
--- a/tests/auto/quick/qquickrepeater/tst_qquickrepeater.cpp
+++ b/tests/auto/quick/qquickrepeater/tst_qquickrepeater.cpp
@@ -41,6 +41,7 @@
#include <private/qquickrepeater_p.h>
#include <QtQuick/private/qquicktext_p.h>
#include <QtQml/private/qqmllistmodel_p.h>
+#include <QtQml/private/qqmlobjectmodel_p.h>
#include "../../shared/util.h"
#include "../shared/viewtestutil.h"
@@ -67,6 +68,7 @@ private slots:
void resetModel();
void modelChanged();
void modelReset();
+ void modelCleared();
void properties();
void asynchronous();
void initParent();
@@ -76,6 +78,8 @@ private slots:
void jsArrayChange();
void clearRemovalOrder();
void destroyCount();
+ void stackingOrder();
+ void objectModel();
};
class TestObject : public QObject
@@ -128,7 +132,7 @@ void tst_QQuickRepeater::numberModel()
QVERIFY(!repeater->itemAt(repeater->count()));
QMetaObject::invokeMethod(window->rootObject(), "checkProperties");
- QVERIFY(testObject->error() == false);
+ QVERIFY(!testObject->error());
delete testObject;
delete window;
@@ -440,19 +444,19 @@ void tst_QQuickRepeater::itemModel()
testObject->setUseModel(true);
QMetaObject::invokeMethod(window->rootObject(), "checkProperties");
- QVERIFY(testObject->error() == false);
+ QVERIFY(!testObject->error());
QCOMPARE(container->childItems().count(), 4);
- QVERIFY(qobject_cast<QObject*>(container->childItems().at(0))->objectName() == "item1");
- QVERIFY(qobject_cast<QObject*>(container->childItems().at(1))->objectName() == "item2");
- QVERIFY(qobject_cast<QObject*>(container->childItems().at(2))->objectName() == "item3");
- QVERIFY(container->childItems().at(3) == repeater);
+ QCOMPARE(qobject_cast<QObject*>(container->childItems().at(0))->objectName(), QLatin1String("item1"));
+ QCOMPARE(qobject_cast<QObject*>(container->childItems().at(1))->objectName(), QLatin1String("item2"));
+ QCOMPARE(qobject_cast<QObject*>(container->childItems().at(2))->objectName(), QLatin1String("item3"));
+ QCOMPARE(container->childItems().at(3), repeater);
QMetaObject::invokeMethod(window->rootObject(), "switchModel");
QCOMPARE(container->childItems().count(), 3);
- QVERIFY(qobject_cast<QObject*>(container->childItems().at(0))->objectName() == "item4");
- QVERIFY(qobject_cast<QObject*>(container->childItems().at(1))->objectName() == "item5");
- QVERIFY(container->childItems().at(2) == repeater);
+ QCOMPARE(qobject_cast<QObject*>(container->childItems().at(0))->objectName(), QLatin1String("item4"));
+ QCOMPARE(qobject_cast<QObject*>(container->childItems().at(1))->objectName(), QLatin1String("item5"));
+ QCOMPARE(container->childItems().at(2), repeater);
testObject->setUseModel(false);
QCOMPARE(container->childItems().count(), 1);
@@ -631,6 +635,26 @@ void tst_QQuickRepeater::modelReset()
QCOMPARE(addedSpy.count(), 0);
}
+// QTBUG-46828
+void tst_QQuickRepeater::modelCleared()
+{
+ QQmlEngine engine;
+ QQmlComponent component(&engine, testFileUrl("modelCleared.qml"));
+
+ QQuickItem *rootObject = qobject_cast<QQuickItem*>(component.create());
+ QVERIFY(rootObject);
+
+ QQuickRepeater *repeater = findItem<QQuickRepeater>(rootObject, "repeater");
+ QVERIFY(repeater);
+
+ // verify no error messages when the model is cleared and the items are destroyed
+ QQmlTestMessageHandler messageHandler;
+ repeater->setModel(0);
+ QVERIFY2(messageHandler.messages().isEmpty(), qPrintable(messageHandler.messageString()));
+
+ delete rootObject;
+}
+
void tst_QQuickRepeater::properties()
{
QQmlEngine engine;
@@ -788,8 +812,8 @@ void tst_QQuickRepeater::invalidContextCrash()
repeater->setParent(root.data());
QCOMPARE(root->children().count(), 2);
- QVERIFY(root->children().at(0) == model);
- QVERIFY(root->children().at(1) == repeater);
+ QCOMPARE(root->children().at(0), model);
+ QCOMPARE(root->children().at(1), repeater);
// Delete the root object, which will invalidate/delete the QML context
// and then delete the child QObjects, which may try to access the context.
@@ -894,6 +918,82 @@ void tst_QQuickRepeater::destroyCount()
QCOMPARE(repeater->property("componentCount").toInt(), 4);
}
+void tst_QQuickRepeater::stackingOrder()
+{
+ QQmlEngine engine;
+ QQmlComponent component(&engine, testFileUrl("stackingorder.qml"));
+
+ QQuickItem *rootObject = qobject_cast<QQuickItem*>(component.create());
+ QVERIFY(rootObject);
+
+ QQuickRepeater *repeater = findItem<QQuickRepeater>(rootObject, "repeater");
+ QVERIFY(repeater);
+ int count = 1;
+ do {
+ bool stackingOrderOk = rootObject->property("stackingOrderOk").toBool();
+ QVERIFY(stackingOrderOk);
+ repeater->setModel(QVariant(++count));
+ } while (count < 3);
+}
+
+static bool compareObjectModel(QQuickRepeater *repeater, QQmlObjectModel *model)
+{
+ if (repeater->count() != model->count())
+ return false;
+ for (int i = 0; i < repeater->count(); ++i) {
+ if (repeater->itemAt(i) != model->get(i))
+ return false;
+ }
+ return true;
+}
+
+void tst_QQuickRepeater::objectModel()
+{
+ QQmlEngine engine;
+ QQmlComponent component(&engine, testFileUrl("objectmodel.qml"));
+
+ QQuickItem *positioner = qobject_cast<QQuickItem *>(component.create());
+ QVERIFY(positioner);
+
+ QQuickRepeater *repeater = findItem<QQuickRepeater>(positioner, "repeater");
+ QVERIFY(repeater);
+
+ QQmlObjectModel *model = repeater->model().value<QQmlObjectModel *>();
+ QVERIFY(model);
+
+ QVERIFY(repeater->itemAt(0));
+ QVERIFY(repeater->itemAt(1));
+ QVERIFY(repeater->itemAt(2));
+ QCOMPARE(repeater->itemAt(0)->property("color").toString(), QColor("red").name());
+ QCOMPARE(repeater->itemAt(1)->property("color").toString(), QColor("green").name());
+ QCOMPARE(repeater->itemAt(2)->property("color").toString(), QColor("blue").name());
+
+ QQuickItem *item0 = new QQuickItem(positioner);
+ item0->setSize(QSizeF(20, 20));
+ model->append(item0);
+ QCOMPARE(model->count(), 4);
+ QVERIFY(compareObjectModel(repeater, model));
+
+ QQuickItem *item1 = new QQuickItem(positioner);
+ item1->setSize(QSizeF(20, 20));
+ model->insert(0, item1);
+ QCOMPARE(model->count(), 5);
+ QVERIFY(compareObjectModel(repeater, model));
+
+ model->move(1, 2, 3);
+ QVERIFY(compareObjectModel(repeater, model));
+
+ model->remove(2, 2);
+ QCOMPARE(model->count(), 3);
+ QVERIFY(compareObjectModel(repeater, model));
+
+ model->clear();
+ QCOMPARE(model->count(), 0);
+ QCOMPARE(repeater->count(), 0);
+
+ delete positioner;
+}
+
QTEST_MAIN(tst_QQuickRepeater)
#include "tst_qquickrepeater.moc"
diff --git a/tests/auto/quick/qquicksmoothedanimation/tst_qquicksmoothedanimation.cpp b/tests/auto/quick/qquicksmoothedanimation/tst_qquicksmoothedanimation.cpp
index 04fdc4ecf7..10e91c455b 100644
--- a/tests/auto/quick/qquicksmoothedanimation/tst_qquicksmoothedanimation.cpp
+++ b/tests/auto/quick/qquicksmoothedanimation/tst_qquicksmoothedanimation.cpp
@@ -130,9 +130,9 @@ void tst_qquicksmoothedanimation::simpleAnimation()
animation->setProperty("x");
animation->setTo(200);
animation->setDuration(250);
- QVERIFY(animation->target() == rect);
- QVERIFY(animation->property() == "x");
- QVERIFY(animation->to() == 200);
+ QCOMPARE(animation->target(), rect);
+ QCOMPARE(animation->property(), QLatin1String("x"));
+ QCOMPARE(animation->to(), qreal(200));
animation->start();
QVERIFY(animation->isRunning());
QTest::qWait(animation->duration());
@@ -147,7 +147,7 @@ void tst_qquicksmoothedanimation::simpleAnimation()
QVERIFY(animation->isRunning());
QVERIFY(animation->isPaused());
animation->setCurrentTime(125);
- QVERIFY(animation->currentTime() == 125);
+ QCOMPARE(animation->currentTime(), 125);
QCOMPARE(rect->x(), qreal(100));
}
diff --git a/tests/auto/quick/qquickstates/tst_qquickstates.cpp b/tests/auto/quick/qquickstates/tst_qquickstates.cpp
index 6c42a7a0ee..a375a55877 100644
--- a/tests/auto/quick/qquickstates/tst_qquickstates.cpp
+++ b/tests/auto/quick/qquickstates/tst_qquickstates.cpp
@@ -1241,7 +1241,7 @@ void tst_qquickstates::deletingState()
QVERIFY(state != 0);
delete state;
- QVERIFY(sg->findState("blue") == 0);
+ QVERIFY(!sg->findState("blue"));
//### should we warn that state doesn't exist
sg->setState("blue");
@@ -1317,7 +1317,7 @@ void tst_qquickstates::illegalObjectCreation()
QQmlComponent component(&engine, testFileUrl("illegalObj.qml"));
QList<QQmlError> errors = component.errors();
- QVERIFY(errors.count() == 1);
+ QCOMPARE(errors.count(), 1);
const QQmlError &error = errors.at(0);
QCOMPARE(error.line(), 9);
QCOMPARE(error.column(), 23);
@@ -1637,7 +1637,7 @@ void tst_qquickstates::QTBUG_38492()
void tst_qquickstates::revertListMemoryLeak()
{
- QWeakPointer<QQmlAbstractBinding> weakPtr;
+ QQmlAbstractBinding::Ptr bindingPtr;
{
QQmlEngine engine;
@@ -1651,12 +1651,12 @@ void tst_qquickstates::revertListMemoryLeak()
QQmlAbstractBinding *binding = state->bindingInRevertList(item, "height");
QVERIFY(binding);
- weakPtr = QQmlAbstractBinding::getPointer(binding);
- QVERIFY(!weakPtr.toStrongRef().isNull());
+ bindingPtr = binding;
+ QVERIFY(bindingPtr->ref > 1);
delete item;
}
- QVERIFY(weakPtr.toStrongRef().isNull());
+ QVERIFY(bindingPtr->ref == 1);
}
QTEST_MAIN(tst_qquickstates)
diff --git a/tests/auto/quick/qquickstyledtext/tst_qquickstyledtext.cpp b/tests/auto/quick/qquickstyledtext/tst_qquickstyledtext.cpp
index 816440b191..4678f5fbb9 100644
--- a/tests/auto/quick/qquickstyledtext/tst_qquickstyledtext.cpp
+++ b/tests/auto/quick/qquickstyledtext/tst_qquickstyledtext.cpp
@@ -171,16 +171,16 @@ void tst_qquickstyledtext::textOutput()
QCOMPARE(layout.text(), output);
- QList<QTextLayout::FormatRange> layoutFormats = layout.additionalFormats();
+ const QVector<QTextLayout::FormatRange> layoutFormats = layout.formats();
QCOMPARE(layoutFormats.count(), formats.count());
for (int i = 0; i < formats.count(); ++i) {
QCOMPARE(layoutFormats.at(i).start, formats.at(i).start);
QCOMPARE(layoutFormats.at(i).length, formats.at(i).length);
if (formats.at(i).type & Format::Bold)
- QVERIFY(layoutFormats.at(i).format.fontWeight() == QFont::Bold);
+ QCOMPARE(layoutFormats.at(i).format.fontWeight(), int(QFont::Bold));
else
- QVERIFY(layoutFormats.at(i).format.fontWeight() == QFont::Normal);
+ QCOMPARE(layoutFormats.at(i).format.fontWeight(), int(QFont::Normal));
QVERIFY(layoutFormats.at(i).format.fontItalic() == bool(formats.at(i).type & Format::Italic));
QVERIFY(layoutFormats.at(i).format.fontUnderline() == bool(formats.at(i).type & Format::Underline));
}
@@ -200,7 +200,7 @@ void tst_qquickstyledtext::anchors()
QCOMPARE(layout.text(), output);
- QList<QTextLayout::FormatRange> layoutFormats = layout.additionalFormats();
+ const QVector<QTextLayout::FormatRange> layoutFormats = layout.formats();
QCOMPARE(layoutFormats.count(), formats.count());
for (int i = 0; i < formats.count(); ++i) {
diff --git a/tests/auto/quick/qquicksystempalette/tst_qquicksystempalette.cpp b/tests/auto/quick/qquicksystempalette/tst_qquicksystempalette.cpp
index 5c0c5fd8d3..a4c4987ad9 100644
--- a/tests/auto/quick/qquicksystempalette/tst_qquicksystempalette.cpp
+++ b/tests/auto/quick/qquicksystempalette/tst_qquicksystempalette.cpp
@@ -97,7 +97,7 @@ void tst_qquicksystempalette::inactivePalette()
QQuickSystemPalette *object = qobject_cast<QQuickSystemPalette*>(component.create());
QVERIFY(object != 0);
- QVERIFY(object->colorGroup() == QQuickSystemPalette::Inactive);
+ QCOMPARE(object->colorGroup(), QQuickSystemPalette::Inactive);
QPalette palette;
palette.setCurrentColorGroup(QPalette::Inactive);
@@ -127,7 +127,7 @@ void tst_qquicksystempalette::disabledPalette()
QQuickSystemPalette *object = qobject_cast<QQuickSystemPalette*>(component.create());
QVERIFY(object != 0);
- QVERIFY(object->colorGroup() == QQuickSystemPalette::Disabled);
+ QCOMPARE(object->colorGroup(), QQuickSystemPalette::Disabled);
QPalette palette;
palette.setCurrentColorGroup(QPalette::Disabled);
diff --git a/tests/auto/quick/qquicktext/BLACKLIST b/tests/auto/quick/qquicktext/BLACKLIST
new file mode 100644
index 0000000000..0c65f1e245
--- /dev/null
+++ b/tests/auto/quick/qquicktext/BLACKLIST
@@ -0,0 +1,4 @@
+[dependentImplicitSizes]
+*
+[mouseSelection]
+*
diff --git a/tests/auto/quick/qquicktext/data/fontSizeMode.qml b/tests/auto/quick/qquicktext/data/fontSizeMode.qml
index 84f7ce8d50..48e7c7b6d0 100644
--- a/tests/auto/quick/qquicktext/data/fontSizeMode.qml
+++ b/tests/auto/quick/qquicktext/data/fontSizeMode.qml
@@ -13,10 +13,10 @@ Item {
id: myText
objectName: "myText"
width: 250
- height: 41
+ height: 35
minimumPointSize: 8
minimumPixelSize: 8
- font.pixelSize: 30
+ font.pixelSize: 25
font.family: "Helvetica"
}
}
diff --git a/tests/auto/quick/qquicktext/data/hAlignImplicitWidth.qml b/tests/auto/quick/qquicktext/data/hAlignImplicitWidth.qml
index 9c9318d3cc..45255691fb 100644
--- a/tests/auto/quick/qquicktext/data/hAlignImplicitWidth.qml
+++ b/tests/auto/quick/qquicktext/data/hAlignImplicitWidth.qml
@@ -1,7 +1,7 @@
import QtQuick 2.0
Rectangle {
- width: 200
+ width: 220
height: 100
Text {
diff --git a/tests/auto/quick/qquicktext/data/padding.qml b/tests/auto/quick/qquicktext/data/padding.qml
new file mode 100644
index 0000000000..ab0a37d041
--- /dev/null
+++ b/tests/auto/quick/qquicktext/data/padding.qml
@@ -0,0 +1,12 @@
+import QtQuick 2.6
+
+Text {
+ width: 200; height: 200
+ text: "Hello Qt"
+
+ padding: 10
+ topPadding: 20
+ leftPadding: 30
+ rightPadding: 40
+ bottomPadding: 50
+}
diff --git a/tests/auto/quick/qquicktext/tst_qquicktext.cpp b/tests/auto/quick/qquicktext/tst_qquicktext.cpp
index eb9f7529fe..46eae89024 100644
--- a/tests/auto/quick/qquicktext/tst_qquicktext.cpp
+++ b/tests/auto/quick/qquicktext/tst_qquicktext.cpp
@@ -38,6 +38,7 @@
#include <QtQuick/private/qquicktext_p.h>
#include <QtQuick/private/qquickmousearea_p.h>
#include <private/qquicktext_p_p.h>
+#include <private/qquicktextdocument_p.h>
#include <private/qquickvaluetypes_p.h>
#include <QFontMetrics>
#include <qmath.h>
@@ -148,6 +149,8 @@ private slots:
void growFromZeroWidth();
+ void padding();
+
private:
QStringList standard;
QStringList richText;
@@ -240,7 +243,7 @@ void tst_qquicktext::text()
QVERIFY(textObject != 0);
QCOMPARE(textObject->text(), QString(""));
- QVERIFY(textObject->width() == 0);
+ QCOMPARE(textObject->width(), qreal(0));
delete textObject;
}
@@ -357,7 +360,7 @@ void tst_qquicktext::width()
QVERIFY(doc != 0);
QCOMPARE(int(textObject->width()), int(doc->idealWidth()));
- QVERIFY(textObject->textFormat() == QQuickText::RichText);
+ QCOMPARE(textObject->textFormat(), QQuickText::RichText);
delete textObject;
}
@@ -374,7 +377,7 @@ void tst_qquicktext::wrap()
textHeight = textObject->height();
QVERIFY(textObject != 0);
- QVERIFY(textObject->wrapMode() == QQuickText::WordWrap);
+ QCOMPARE(textObject->wrapMode(), QQuickText::WordWrap);
QCOMPARE(textObject->width(), 300.);
delete textObject;
@@ -657,11 +660,11 @@ void tst_qquicktext::textFormat()
QQuickText *textObject = qobject_cast<QQuickText*>(textComponent.create());
QVERIFY(textObject != 0);
- QVERIFY(textObject->textFormat() == QQuickText::RichText);
+ QCOMPARE(textObject->textFormat(), QQuickText::RichText);
QQuickTextPrivate *textPrivate = QQuickTextPrivate::get(textObject);
QVERIFY(textPrivate != 0);
- QVERIFY(textPrivate->richText == true);
+ QVERIFY(textPrivate->richText);
delete textObject;
}
@@ -671,11 +674,11 @@ void tst_qquicktext::textFormat()
QQuickText *textObject = qobject_cast<QQuickText*>(textComponent.create());
QVERIFY(textObject != 0);
- QVERIFY(textObject->textFormat() == QQuickText::AutoText);
+ QCOMPARE(textObject->textFormat(), QQuickText::AutoText);
QQuickTextPrivate *textPrivate = QQuickTextPrivate::get(textObject);
QVERIFY(textPrivate != 0);
- QVERIFY(textPrivate->styledText == true);
+ QVERIFY(textPrivate->styledText);
delete textObject;
}
@@ -685,7 +688,7 @@ void tst_qquicktext::textFormat()
QQuickText *textObject = qobject_cast<QQuickText*>(textComponent.create());
QVERIFY(textObject != 0);
- QVERIFY(textObject->textFormat() == QQuickText::PlainText);
+ QCOMPARE(textObject->textFormat(), QQuickText::PlainText);
delete textObject;
}
@@ -911,7 +914,7 @@ void tst_qquicktext::hAlignImplicitWidth()
// Try to check whether alignment works by checking the number of black
// pixels in the thirds of the grabbed image.
- const int windowWidth = 200;
+ const int windowWidth = 220;
const int textWidth = qCeil(text->implicitWidth());
QVERIFY2(textWidth < windowWidth, "System font too large.");
const int sectionWidth = textWidth / 3;
@@ -2047,8 +2050,8 @@ void tst_qquicktext::embeddedImages_data()
QTest::newRow("local") << testFileUrl("embeddedImagesLocalRelative.qml") << "";
QTest::newRow("remote") << testFileUrl("embeddedImagesRemote.qml") << "";
QTest::newRow("remote-error") << testFileUrl("embeddedImagesRemoteError.qml")
- << testFileUrl("embeddedImagesRemoteError.qml").toString()+":3:1: QML Text: Error downloading {{ServerBaseUrl}}/notexists.png - server replied: Not found";
- QTest::newRow("remote") << testFileUrl("embeddedImagesRemoteRelative.qml") << "";
+ << testFileUrl("embeddedImagesRemoteError.qml").toString()+":3:1: QML Text: Error transferring {{ServerBaseUrl}}/notexists.png - server replied: Not found";
+ QTest::newRow("remote-relative") << testFileUrl("embeddedImagesRemoteRelative.qml") << "";
}
void tst_qquicktext::embeddedImages()
@@ -2058,6 +2061,14 @@ void tst_qquicktext::embeddedImages()
QFETCH(QUrl, qmlfile);
QFETCH(QString, error);
+#if defined(Q_OS_LINUX) && !defined(Q_OS_ANDROID)
+ if (qstrcmp(QTest::currentDataTag(), "remote") == 0
+ || qstrcmp(QTest::currentDataTag(), "remote-error") == 0
+ || qstrcmp(QTest::currentDataTag(), "remote-relative") == 0) {
+ QSKIP("Remote tests cause occasional hangs in the CI system -- QTBUG-45655");
+ }
+#endif
+
TestHTTPServer server;
QVERIFY2(server.listen(), qPrintable(server.errorString()));
server.serveDirectory(testFile("http"));
@@ -2126,8 +2137,8 @@ void tst_qquicktext::lineHeight()
QQuickText *myText = window->rootObject()->findChild<QQuickText*>("myText");
QVERIFY(myText != 0);
- QVERIFY(myText->lineHeight() == 1);
- QVERIFY(myText->lineHeightMode() == QQuickText::ProportionalHeight);
+ QCOMPARE(myText->lineHeight(), qreal(1));
+ QCOMPARE(myText->lineHeightMode(), QQuickText::ProportionalHeight);
qreal h = myText->height();
myText->setLineHeight(1.5);
@@ -2197,12 +2208,12 @@ void tst_qquicktext::implicitSize()
QQuickText *textObject = qobject_cast<QQuickText*>(textComponent.create());
QVERIFY(textObject->width() < textObject->implicitWidth());
- QVERIFY(textObject->height() == textObject->implicitHeight());
+ QCOMPARE(textObject->height(), textObject->implicitHeight());
QCOMPARE(textObject->property("iWidth").toReal(), textObject->implicitWidth());
textObject->resetWidth();
- QVERIFY(textObject->width() == textObject->implicitWidth());
- QVERIFY(textObject->height() == textObject->implicitHeight());
+ QCOMPARE(textObject->width(), textObject->implicitWidth());
+ QCOMPARE(textObject->height(), textObject->implicitHeight());
delete textObject;
}
@@ -2738,7 +2749,7 @@ void tst_qquicktext::lineLaidOut()
QVERIFY(r.x() == r.width() + 30);
if (i >= 60) {
QVERIFY(r.x() == r.width() * 2 + 60);
- QVERIFY(r.height() == 20);
+ QCOMPARE(r.height(), qreal(20));
}
}
@@ -2916,7 +2927,7 @@ void tst_qquicktext::imgTagsAlign()
QQuickText *textObject = qobject_cast<QQuickText*>(textComponent.create());
QVERIFY(textObject != 0);
- QVERIFY(textObject->height() == imgHeight);
+ QCOMPARE(textObject->height(), qreal(imgHeight));
QQuickTextPrivate *textPrivate = QQuickTextPrivate::get(textObject);
QVERIFY(textPrivate != 0);
@@ -2927,7 +2938,7 @@ void tst_qquicktext::imgTagsAlign()
else if (align == "middle")
QVERIFY(br.y() == imgHeight / 2.0 - br.height() / 2.0);
else if (align == "top")
- QVERIFY(br.y() == 0);
+ QCOMPARE(br.y(), qreal(0));
delete textObject;
}
@@ -2941,11 +2952,11 @@ void tst_qquicktext::imgTagsMultipleImages()
QQuickText *textObject = qobject_cast<QQuickText*>(textComponent.create());
QVERIFY(textObject != 0);
- QVERIFY(textObject->height() == 85);
+ QCOMPARE(textObject->height(), qreal(85));
QQuickTextPrivate *textPrivate = QQuickTextPrivate::get(textObject);
QVERIFY(textPrivate != 0);
- QVERIFY(textPrivate->extra->visibleImgTags.count() == 2);
+ QCOMPARE(textPrivate->extra->visibleImgTags.count(), 2);
delete textObject;
}
@@ -2958,9 +2969,9 @@ void tst_qquicktext::imgTagsElide()
QQuickTextPrivate *textPrivate = QQuickTextPrivate::get(myText);
QVERIFY(textPrivate != 0);
- QVERIFY(textPrivate->extra->visibleImgTags.count() == 0);
+ QCOMPARE(textPrivate->extra->visibleImgTags.count(), 0);
myText->setMaximumLineCount(20);
- QTRY_VERIFY(textPrivate->extra->visibleImgTags.count() == 1);
+ QTRY_COMPARE(textPrivate->extra->visibleImgTags.count(), 1);
delete myText;
delete window;
@@ -2978,16 +2989,16 @@ void tst_qquicktext::imgTagsUpdates()
QVERIFY(textPrivate != 0);
myText->setText("This is a heart<img src=\"images/heart200.png\">.");
- QVERIFY(textPrivate->extra->visibleImgTags.count() == 1);
- QVERIFY(spy.count() == 1);
+ QCOMPARE(textPrivate->extra->visibleImgTags.count(), 1);
+ QCOMPARE(spy.count(), 1);
myText->setMaximumLineCount(2);
myText->setText("This is another heart<img src=\"images/heart200.png\">.");
- QTRY_VERIFY(textPrivate->extra->visibleImgTags.count() == 1);
+ QTRY_COMPARE(textPrivate->extra->visibleImgTags.count(), 1);
// if maximumLineCount is set and the img tag doesn't have an explicit size
// we relayout twice.
- QVERIFY(spy.count() == 3);
+ QCOMPARE(spy.count(), 3);
delete myText;
delete window;
@@ -3634,19 +3645,19 @@ Q_DECLARE_METATYPE(ExpectedBaseline)
static qreal expectedBaselineTop(QQuickText *item)
{
QFontMetricsF fm(item->font());
- return fm.ascent();
+ return fm.ascent() + item->topPadding();
}
static qreal expectedBaselineBottom(QQuickText *item)
{
QFontMetricsF fm(item->font());
- return item->height() - item->contentHeight() + fm.ascent();
+ return item->height() - item->contentHeight() - item->bottomPadding() + fm.ascent();
}
static qreal expectedBaselineCenter(QQuickText *item)
{
QFontMetricsF fm(item->font());
- return ((item->height() - item->contentHeight()) / 2) + fm.ascent();
+ return ((item->height() - item->contentHeight() - item->topPadding() - item->bottomPadding()) / 2) + fm.ascent() + item->topPadding();
}
static qreal expectedBaselineBold(QQuickText *item)
@@ -3654,7 +3665,7 @@ static qreal expectedBaselineBold(QQuickText *item)
QFont font = item->font();
font.setBold(true);
QFontMetricsF fm(font);
- return fm.ascent();
+ return fm.ascent() + item->topPadding();
}
static qreal expectedBaselineImage(QQuickText *item)
@@ -3664,13 +3675,13 @@ static qreal expectedBaselineImage(QQuickText *item)
// or image height - line height and the baseline is line position + ascent. Because
// QTextLine's height is rounded up this can give slightly different results to image height
// - descent.
- return 181 - qCeil(fm.height()) + fm.ascent();
+ return 181 - qCeil(fm.height()) + fm.ascent() + item->topPadding();
}
static qreal expectedBaselineCustom(QQuickText *item)
{
QFontMetricsF fm(item->font());
- return 16 + fm.ascent();
+ return 16 + fm.ascent() + item->topPadding();
}
static qreal expectedBaselineScaled(QQuickText *item)
@@ -3689,11 +3700,11 @@ static qreal expectedBaselineScaled(QQuickText *item)
if (width < item->width()) {
QFontMetricsF fm(layout.font());
- return fm.ascent();
+ return fm.ascent() + item->topPadding();
}
font.setPointSize(font.pointSize() - 1);
} while (font.pointSize() > 0);
- return 0;
+ return item->topPadding();
}
static qreal expectedBaselineFixedBottom(QQuickText *item)
@@ -3702,7 +3713,7 @@ static qreal expectedBaselineFixedBottom(QQuickText *item)
qreal dy = item->text().contains(QLatin1Char('\n'))
? 160
: 180;
- return dy + fm.ascent();
+ return dy + fm.ascent() - item->bottomPadding();
}
static qreal expectedBaselineProportionalBottom(QQuickText *item)
@@ -3711,7 +3722,7 @@ static qreal expectedBaselineProportionalBottom(QQuickText *item)
qreal dy = item->text().contains(QLatin1Char('\n'))
? 200 - (qCeil(fm.height()) * 3)
: 200 - (qCeil(fm.height()) * 1.5);
- return dy + fm.ascent();
+ return dy + fm.ascent() - item->bottomPadding();
}
void tst_qquicktext::baselineOffset_data()
@@ -3746,8 +3757,8 @@ void tst_qquicktext::baselineOffset_data()
<< "<b>hello world</b>"
<< "<b>hello<br/>world</b>"
<< QByteArray("height: 200")
- << &expectedBaselineTop
- << &expectedBaselineBold;
+ << &expectedBaselineBold
+ << &expectedBaselineTop;
QTest::newRow("richText")
<< "<b>hello world</b>"
@@ -3818,6 +3829,102 @@ void tst_qquicktext::baselineOffset_data()
<< QByteArray("height: 200; lineHeightMode: Text.ProportionalHeight; lineHeight: 1.5; verticalAlignment: Text.AlignBottom")
<< &expectedBaselineProportionalBottom
<< &expectedBaselineProportionalBottom;
+
+ QTest::newRow("top align with padding")
+ << "hello world"
+ << "hello\nworld"
+ << QByteArray("height: 200; topPadding: 10; bottomPadding: 20; verticalAlignment: Text.AlignTop")
+ << &expectedBaselineTop
+ << &expectedBaselineTop;
+ QTest::newRow("bottom align with padding")
+ << "hello world"
+ << "hello\nworld"
+ << QByteArray("height: 200; topPadding: 10; bottomPadding: 20; verticalAlignment: Text.AlignBottom")
+ << &expectedBaselineBottom
+ << &expectedBaselineBottom;
+ QTest::newRow("center align with padding")
+ << "hello world"
+ << "hello\nworld"
+ << QByteArray("height: 200; topPadding: 10; bottomPadding: 20; verticalAlignment: Text.AlignVCenter")
+ << &expectedBaselineCenter
+ << &expectedBaselineCenter;
+
+ QTest::newRow("bold width padding")
+ << "<b>hello world</b>"
+ << "<b>hello<br/>world</b>"
+ << QByteArray("height: 200; topPadding: 10; bottomPadding: 20")
+ << &expectedBaselineBold
+ << &expectedBaselineTop;
+
+ QTest::newRow("richText with padding")
+ << "<b>hello world</b>"
+ << "<b>hello<br/>world</b>"
+ << QByteArray("height: 200; topPadding: 10; bottomPadding: 20; textFormat: Text.RichText")
+ << &expectedBaselineTop
+ << &expectedBaselineTop;
+
+ QTest::newRow("elided with padding")
+ << "hello world"
+ << "hello\nworld"
+ << QByteArray("width: 20; height: 8; topPadding: 10; bottomPadding: 20; elide: Text.ElideRight")
+ << &expectedBaselineTop
+ << &expectedBaselineTop;
+
+ QTest::newRow("elided bottom align with padding")
+ << "hello world"
+ << "hello\nworld!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
+ << QByteArray("width: 200; height: 200; topPadding: 10; bottomPadding: 20; elide: Text.ElideRight; verticalAlignment: Text.AlignBottom")
+ << &expectedBaselineBottom
+ << &expectedBaselineBottom;
+
+ QTest::newRow("image with padding")
+ << "hello <img src=\"images/heart200.png\" /> world"
+ << "hello <img src=\"images/heart200.png\" /><br/>world"
+ << QByteArray("height: 200\n; topPadding: 10; bottomPadding: 20; baseUrl: \"") + testFileUrl("reference").toEncoded() + QByteArray("\"")
+ << &expectedBaselineImage
+ << &expectedBaselineTop;
+
+ QTest::newRow("customLine with padding")
+ << "hello world"
+ << "hello\nworld"
+ << QByteArray("height: 200; topPadding: 10; bottomPadding: 20; onLineLaidOut: line.y += 16")
+ << &expectedBaselineCustom
+ << &expectedBaselineCustom;
+
+ QTest::newRow("scaled font with padding")
+ << "hello world"
+ << "hello\nworld"
+ << QByteArray("width: 200; topPadding: 10; bottomPadding: 20; minimumPointSize: 1; font.pointSize: 64; fontSizeMode: Text.HorizontalFit")
+ << &expectedBaselineScaled
+ << &expectedBaselineTop;
+
+ QTest::newRow("fixed line height top align with padding")
+ << "hello world"
+ << "hello\nworld"
+ << QByteArray("height: 200; topPadding: 10; bottomPadding: 20; lineHeightMode: Text.FixedHeight; lineHeight: 20; verticalAlignment: Text.AlignTop")
+ << &expectedBaselineTop
+ << &expectedBaselineTop;
+
+ QTest::newRow("fixed line height bottom align with padding")
+ << "hello world"
+ << "hello\nworld"
+ << QByteArray("height: 200; topPadding: 10; bottomPadding: 20; lineHeightMode: Text.FixedHeight; lineHeight: 20; verticalAlignment: Text.AlignBottom")
+ << &expectedBaselineFixedBottom
+ << &expectedBaselineFixedBottom;
+
+ QTest::newRow("proportional line height top align with padding")
+ << "hello world"
+ << "hello\nworld"
+ << QByteArray("height: 200; topPadding: 10; bottomPadding: 20; lineHeightMode: Text.ProportionalHeight; lineHeight: 1.5; verticalAlignment: Text.AlignTop")
+ << &expectedBaselineTop
+ << &expectedBaselineTop;
+
+ QTest::newRow("proportional line height bottom align with padding")
+ << "hello world"
+ << "hello\nworld"
+ << QByteArray("height: 200; topPadding: 10; bottomPadding: 20; lineHeightMode: Text.ProportionalHeight; lineHeight: 1.5; verticalAlignment: Text.AlignBottom")
+ << &expectedBaselineProportionalBottom
+ << &expectedBaselineProportionalBottom;
}
void tst_qquicktext::baselineOffset()
@@ -3830,7 +3937,7 @@ void tst_qquicktext::baselineOffset()
QQmlComponent component(&engine);
component.setData(
- "import QtQuick 2.0\n"
+ "import QtQuick 2.6\n"
"Text {\n"
+ bindings + "\n"
"}", QUrl());
@@ -3972,6 +4079,84 @@ void tst_qquicktext::growFromZeroWidth()
QVERIFY(text->lineCount() > 3);
}
+void tst_qquicktext::padding()
+{
+ QScopedPointer<QQuickView> window(new QQuickView);
+ window->setSource(testFileUrl("padding.qml"));
+ QTRY_COMPARE(window->status(), QQuickView::Ready);
+ window->show();
+ QVERIFY(QTest::qWaitForWindowExposed(window.data()));
+ QQuickItem *root = window->rootObject();
+ QVERIFY(root);
+ QQuickText *obj = qobject_cast<QQuickText*>(root);
+ QVERIFY(obj != 0);
+
+ qreal cw = obj->contentWidth();
+ qreal ch = obj->contentHeight();
+
+ QVERIFY(cw > 0);
+ QVERIFY(ch > 0);
+
+ QCOMPARE(obj->topPadding(), 20.0);
+ QCOMPARE(obj->leftPadding(), 30.0);
+ QCOMPARE(obj->rightPadding(), 40.0);
+ QCOMPARE(obj->bottomPadding(), 50.0);
+
+ QCOMPARE(obj->implicitWidth(), cw + obj->leftPadding() + obj->rightPadding());
+ QCOMPARE(obj->implicitHeight(), ch + obj->topPadding() + obj->bottomPadding());
+
+ obj->setTopPadding(2.25);
+ QCOMPARE(obj->topPadding(), 2.25);
+ QCOMPARE(obj->implicitHeight(), ch + obj->topPadding() + obj->bottomPadding());
+
+ obj->setLeftPadding(3.75);
+ QCOMPARE(obj->leftPadding(), 3.75);
+ QCOMPARE(obj->implicitWidth(), cw + obj->leftPadding() + obj->rightPadding());
+
+ obj->setRightPadding(4.4);
+ QCOMPARE(obj->rightPadding(), 4.4);
+ QCOMPARE(obj->implicitWidth(), cw + obj->leftPadding() + obj->rightPadding());
+
+ obj->setBottomPadding(1.11);
+ QCOMPARE(obj->bottomPadding(), 1.11);
+ QCOMPARE(obj->implicitHeight(), ch + obj->topPadding() + obj->bottomPadding());
+
+ obj->setText("Qt");
+ QVERIFY(obj->contentWidth() < cw);
+ QCOMPARE(obj->contentHeight(), ch);
+ cw = obj->contentWidth();
+
+ QCOMPARE(obj->implicitWidth(), cw + obj->leftPadding() + obj->rightPadding());
+ QCOMPARE(obj->implicitHeight(), ch + obj->topPadding() + obj->bottomPadding());
+
+ obj->setFont(QFont("Courier", 96));
+ QVERIFY(obj->contentWidth() > cw);
+ QVERIFY(obj->contentHeight() > ch);
+ cw = obj->contentWidth();
+ ch = obj->contentHeight();
+
+ QCOMPARE(obj->implicitWidth(), cw + obj->leftPadding() + obj->rightPadding());
+ QCOMPARE(obj->implicitHeight(), ch + obj->topPadding() + obj->bottomPadding());
+
+ obj->resetTopPadding();
+ QCOMPARE(obj->topPadding(), 10.0);
+ obj->resetLeftPadding();
+ QCOMPARE(obj->leftPadding(), 10.0);
+ obj->resetRightPadding();
+ QCOMPARE(obj->rightPadding(), 10.0);
+ obj->resetBottomPadding();
+ QCOMPARE(obj->bottomPadding(), 10.0);
+
+ obj->resetPadding();
+ QCOMPARE(obj->padding(), 0.0);
+ QCOMPARE(obj->topPadding(), 0.0);
+ QCOMPARE(obj->leftPadding(), 0.0);
+ QCOMPARE(obj->rightPadding(), 0.0);
+ QCOMPARE(obj->bottomPadding(), 0.0);
+
+ delete root;
+}
+
QTEST_MAIN(tst_qquicktext)
#include "tst_qquicktext.moc"
diff --git a/tests/auto/quick/qquicktextdocument/tst_qquicktextdocument.cpp b/tests/auto/quick/qquicktextdocument/tst_qquicktextdocument.cpp
index 302959dd7f..12fcbfda0e 100644
--- a/tests/auto/quick/qquicktextdocument/tst_qquicktextdocument.cpp
+++ b/tests/auto/quick/qquicktextdocument/tst_qquicktextdocument.cpp
@@ -36,7 +36,7 @@
#include <QtQuick/QQuickTextDocument>
#include <QtQuick/QQuickItem>
#include <QtQuick/private/qquicktextedit_p.h>
-#include <QtQuick/private/qquicktext_p_p.h>
+#include <QtQuick/private/qquicktextdocument_p.h>
#include <QtGui/QTextDocument>
#include <QtGui/QTextDocumentWriter>
#include <QtQml/QQmlEngine>
diff --git a/tests/auto/quick/qquicktextedit/BLACKLIST b/tests/auto/quick/qquicktextedit/BLACKLIST
new file mode 100644
index 0000000000..492d81531a
--- /dev/null
+++ b/tests/auto/quick/qquicktextedit/BLACKLIST
@@ -0,0 +1,2 @@
+[mouseSelection]
+*
diff --git a/tests/auto/quick/qquicktextedit/data/hAlignVisual.qml b/tests/auto/quick/qquicktextedit/data/hAlignVisual.qml
index 017bab97a7..1280a655f0 100644
--- a/tests/auto/quick/qquicktextedit/data/hAlignVisual.qml
+++ b/tests/auto/quick/qquicktextedit/data/hAlignVisual.qml
@@ -10,5 +10,6 @@ Rectangle {
anchors.centerIn: parent
horizontalAlignment: Text.AlignLeft
font.pointSize: 12
+ font.family: "Times New Roman"
}
}
diff --git a/tests/auto/quick/qquicktextedit/data/padding.qml b/tests/auto/quick/qquicktextedit/data/padding.qml
new file mode 100644
index 0000000000..f4852bec8b
--- /dev/null
+++ b/tests/auto/quick/qquicktextedit/data/padding.qml
@@ -0,0 +1,12 @@
+import QtQuick 2.6
+
+TextEdit {
+ width: 200; height: 200
+ text: "Hello Qt"
+
+ padding: 10
+ topPadding: 20
+ leftPadding: 30
+ rightPadding: 40
+ bottomPadding: 50
+}
diff --git a/tests/auto/quick/qquicktextedit/data/signal_editingfinished.qml b/tests/auto/quick/qquicktextedit/data/signal_editingfinished.qml
new file mode 100644
index 0000000000..b5caab5e7c
--- /dev/null
+++ b/tests/auto/quick/qquicktextedit/data/signal_editingfinished.qml
@@ -0,0 +1,13 @@
+import QtQuick 2.6
+
+Item {
+ property QtObject input1: input1
+ property QtObject input2: input2
+
+ width: 800; height: 600
+
+ Column{
+ TextEdit { id: input1; activeFocusOnTab: true }
+ TextEdit { id: input2; activeFocusOnTab: true }
+ }
+}
diff --git a/tests/auto/quick/qquicktextedit/qquicktextedit.pro b/tests/auto/quick/qquicktextedit/qquicktextedit.pro
index 2a6d753536..c6f2bb91a8 100644
--- a/tests/auto/quick/qquicktextedit/qquicktextedit.pro
+++ b/tests/auto/quick/qquicktextedit/qquicktextedit.pro
@@ -13,4 +13,6 @@ TESTDATA = data/*
QT += core-private gui-private qml-private quick-private network-private testlib
+osx: LIBS += -framework AppKit
+
DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0
diff --git a/tests/auto/quick/qquicktextedit/tst_qquicktextedit.cpp b/tests/auto/quick/qquicktextedit/tst_qquicktextedit.cpp
index 9d1d099c0e..7f454aaa11 100644
--- a/tests/auto/quick/qquicktextedit/tst_qquicktextedit.cpp
+++ b/tests/auto/quick/qquicktextedit/tst_qquicktextedit.cpp
@@ -43,7 +43,8 @@
#include <QtGui/qguiapplication.h>
#include <private/qquicktextedit_p.h>
#include <private/qquicktextedit_p_p.h>
-#include <private/qquicktext_p_p.h>
+#include <private/qquicktext_p.h>
+#include <private/qquicktextdocument_p.h>
#include <QFontMetrics>
#include <QtQuick/QQuickView>
#include <QDir>
@@ -72,7 +73,7 @@ QString createExpectedFileIfNotFound(const QString& filebasename, const QImage&
QString persistent_dir = QQmlDataTest::instance()->dataDirectory();
QString arch = "unknown-architecture"; // QTest needs to help with this.
- QString expectfile = persistent_dir + QDir::separator() + filebasename + "-" + arch + ".png";
+ QString expectfile = persistent_dir + QDir::separator() + filebasename + QLatin1Char('-') + arch + ".png";
if (!QFile::exists(expectfile)) {
actual.save(expectfile);
@@ -166,6 +167,8 @@ private slots:
void implicitSizeBinding_data();
void implicitSizeBinding();
+ void signal_editingfinished();
+
void preeditCursorRectangle();
void inputMethodComposing();
void cursorRectangleSize_data();
@@ -199,6 +202,9 @@ private slots:
void emptytags_QTBUG_22058();
void cursorRectangle_QTBUG_38947();
void textCached_QTBUG_41583();
+ void doubleSelect_QTBUG_38704();
+
+ void padding();
private:
void simulateKeys(QWindow *window, const QList<Key> &keys);
@@ -280,6 +286,9 @@ QList<Key> &operator <<(QList<Key> &keys, Qt::Key key)
tst_qquicktextedit::tst_qquicktextedit()
{
+ qRegisterMetaType<QQuickTextEdit::TextFormat>();
+ qRegisterMetaType<QQuickTextEdit::SelectionMode>();
+
standard << "the quick brown fox jumped over the lazy dog"
<< "the quick brown fox\n jumped over the lazy dog"
<< "Hello, world!"
@@ -573,7 +582,7 @@ void tst_qquicktextedit::textFormat()
QQuickTextEdit *textObject = qobject_cast<QQuickTextEdit*>(textComponent.create());
QVERIFY(textObject != 0);
- QVERIFY(textObject->textFormat() == QQuickTextEdit::RichText);
+ QCOMPARE(textObject->textFormat(), QQuickTextEdit::RichText);
}
{
QQmlComponent textComponent(&engine);
@@ -581,7 +590,7 @@ void tst_qquicktextedit::textFormat()
QQuickTextEdit *textObject = qobject_cast<QQuickTextEdit*>(textComponent.create());
QVERIFY(textObject != 0);
- QVERIFY(textObject->textFormat() == QQuickTextEdit::PlainText);
+ QCOMPARE(textObject->textFormat(), QQuickTextEdit::PlainText);
}
{
QQmlComponent component(&engine);
@@ -590,7 +599,7 @@ void tst_qquicktextedit::textFormat()
QQuickTextEdit *edit = qobject_cast<QQuickTextEdit *>(object.data());
QVERIFY(edit);
- QSignalSpy spy(edit, SIGNAL(textFormatChanged(TextFormat)));
+ QSignalSpy spy(edit, &QQuickTextEdit::textFormatChanged);
QCOMPARE(edit->textFormat(), QQuickTextEdit::PlainText);
@@ -798,7 +807,7 @@ void tst_qquicktextedit::hAlign_RightToLeft()
// keyboard input direction from qApp->inputMethod()->inputDirection
textEdit->setText("");
platformInputContext.setInputDirection(Qt::LeftToRight);
- QVERIFY(qApp->inputMethod()->inputDirection() == Qt::LeftToRight);
+ QCOMPARE(qApp->inputMethod()->inputDirection(), Qt::LeftToRight);
QCOMPARE(textEdit->hAlign(), QQuickTextEdit::AlignLeft);
QVERIFY(textEdit->positionToRectangle(0).x() < window.width()/2);
@@ -806,7 +815,7 @@ void tst_qquicktextedit::hAlign_RightToLeft()
platformInputContext.setInputDirection(Qt::RightToLeft);
QCOMPARE(cursorRectangleSpy.count(), 1);
- QVERIFY(qApp->inputMethod()->inputDirection() == Qt::RightToLeft);
+ QCOMPARE(qApp->inputMethod()->inputDirection(), Qt::RightToLeft);
QCOMPARE(textEdit->hAlign(), QQuickTextEdit::AlignRight);
QVERIFY(textEdit->positionToRectangle(0).x() > window.width()/2);
@@ -1397,22 +1406,22 @@ void tst_qquicktextedit::selection()
}
textEditObject->setCursorPosition(0);
- QVERIFY(textEditObject->cursorPosition() == 0);
- QVERIFY(textEditObject->selectionStart() == 0);
- QVERIFY(textEditObject->selectionEnd() == 0);
+ QCOMPARE(textEditObject->cursorPosition(), 0);
+ QCOMPARE(textEditObject->selectionStart(), 0);
+ QCOMPARE(textEditObject->selectionEnd(), 0);
QVERIFY(textEditObject->selectedText().isNull());
// Verify invalid positions are ignored.
textEditObject->setCursorPosition(-1);
- QVERIFY(textEditObject->cursorPosition() == 0);
- QVERIFY(textEditObject->selectionStart() == 0);
- QVERIFY(textEditObject->selectionEnd() == 0);
+ QCOMPARE(textEditObject->cursorPosition(), 0);
+ QCOMPARE(textEditObject->selectionStart(), 0);
+ QCOMPARE(textEditObject->selectionEnd(), 0);
QVERIFY(textEditObject->selectedText().isNull());
textEditObject->setCursorPosition(textEditObject->text().count()+1);
- QVERIFY(textEditObject->cursorPosition() == 0);
- QVERIFY(textEditObject->selectionStart() == 0);
- QVERIFY(textEditObject->selectionEnd() == 0);
+ QCOMPARE(textEditObject->cursorPosition(), 0);
+ QCOMPARE(textEditObject->selectionStart(), 0);
+ QCOMPARE(textEditObject->selectionEnd(), 0);
QVERIFY(textEditObject->selectedText().isNull());
//Test selection
@@ -1426,9 +1435,9 @@ void tst_qquicktextedit::selection()
}
textEditObject->setCursorPosition(0);
- QVERIFY(textEditObject->cursorPosition() == 0);
- QVERIFY(textEditObject->selectionStart() == 0);
- QVERIFY(textEditObject->selectionEnd() == 0);
+ QCOMPARE(textEditObject->cursorPosition(), 0);
+ QCOMPARE(textEditObject->selectionStart(), 0);
+ QCOMPARE(textEditObject->selectionEnd(), 0);
QVERIFY(textEditObject->selectedText().isNull());
//Test Error Ignoring behaviour
@@ -1443,20 +1452,20 @@ void tst_qquicktextedit::selection()
textEditObject->select(0,100);
QVERIFY(textEditObject->selectedText().isNull());
textEditObject->select(0,10);
- QVERIFY(textEditObject->selectedText().size() == 10);
+ QCOMPARE(textEditObject->selectedText().size(), 10);
textEditObject->select(-10,0);
- QVERIFY(textEditObject->selectedText().size() == 10);
+ QCOMPARE(textEditObject->selectedText().size(), 10);
textEditObject->select(100,101);
- QVERIFY(textEditObject->selectedText().size() == 10);
+ QCOMPARE(textEditObject->selectedText().size(), 10);
textEditObject->select(0,-10);
- QVERIFY(textEditObject->selectedText().size() == 10);
+ QCOMPARE(textEditObject->selectedText().size(), 10);
textEditObject->select(0,100);
- QVERIFY(textEditObject->selectedText().size() == 10);
+ QCOMPARE(textEditObject->selectedText().size(), 10);
textEditObject->deselect();
QVERIFY(textEditObject->selectedText().isNull());
textEditObject->select(0,10);
- QVERIFY(textEditObject->selectedText().size() == 10);
+ QCOMPARE(textEditObject->selectedText().size(), 10);
textEditObject->deselect();
QVERIFY(textEditObject->selectedText().isNull());
}
@@ -1535,31 +1544,31 @@ void tst_qquicktextedit::keySelection()
QSignalSpy spy(input, SIGNAL(selectedTextChanged()));
simulateKey(&window, Qt::Key_Right, Qt::ShiftModifier);
- QVERIFY(input->hasActiveFocus() == true);
+ QVERIFY(input->hasActiveFocus());
QCOMPARE(input->selectedText(), QString("a"));
QCOMPARE(spy.count(), 1);
simulateKey(&window, Qt::Key_Right);
- QVERIFY(input->hasActiveFocus() == true);
+ QVERIFY(input->hasActiveFocus());
QCOMPARE(input->selectedText(), QString());
QCOMPARE(spy.count(), 2);
simulateKey(&window, Qt::Key_Right);
- QVERIFY(input->hasActiveFocus() == false);
+ QVERIFY(!input->hasActiveFocus());
QCOMPARE(input->selectedText(), QString());
QCOMPARE(spy.count(), 2);
simulateKey(&window, Qt::Key_Left);
- QVERIFY(input->hasActiveFocus() == true);
+ QVERIFY(input->hasActiveFocus());
QCOMPARE(spy.count(), 2);
simulateKey(&window, Qt::Key_Left, Qt::ShiftModifier);
- QVERIFY(input->hasActiveFocus() == true);
+ QVERIFY(input->hasActiveFocus());
QCOMPARE(input->selectedText(), QString("a"));
QCOMPARE(spy.count(), 3);
simulateKey(&window, Qt::Key_Left);
- QVERIFY(input->hasActiveFocus() == true);
+ QVERIFY(input->hasActiveFocus());
QCOMPARE(input->selectedText(), QString());
QCOMPARE(spy.count(), 4);
simulateKey(&window, Qt::Key_Left);
- QVERIFY(input->hasActiveFocus() == false);
+ QVERIFY(!input->hasActiveFocus());
QCOMPARE(input->selectedText(), QString());
QCOMPARE(spy.count(), 4);
}
@@ -2107,7 +2116,7 @@ void tst_qquicktextedit::mouseSelectionMode_accessors()
QQuickTextEdit *edit = qobject_cast<QQuickTextEdit *>(object.data());
QVERIFY(edit);
- QSignalSpy spy(edit, SIGNAL(mouseSelectionModeChanged(SelectionMode)));
+ QSignalSpy spy(edit, &QQuickTextEdit::mouseSelectionModeChanged);
QCOMPARE(edit->mouseSelectionMode(), QQuickTextEdit::SelectCharacters);
@@ -2362,8 +2371,8 @@ void tst_qquicktextedit::positionAt()
secondLine.setLineWidth(texteditObject->width());
layout.endLayout();
- qreal y0;
- qreal y1;
+ qreal y0 = 0;
+ qreal y1 = 0;
switch (verticalAlignment) {
case QQuickTextEdit::AlignTop:
@@ -2594,9 +2603,7 @@ void tst_qquicktextedit::cursorDelegate()
void tst_qquicktextedit::remoteCursorDelegate()
{
- TestHTTPServer server;
- QVERIFY2(server.listen(), qPrintable(server.errorString()));
- server.serveDirectory(dataDirectory(), TestHTTPServer::Delay);
+ ThreadedTestHTTPServer server(dataDirectory(), TestHTTPServer::Delay);
QQuickView view;
@@ -2732,20 +2739,21 @@ void tst_qquicktextedit::delegateLoading()
QFETCH(QString, qmlfile);
QFETCH(QString, error);
- TestHTTPServer server;
- QVERIFY2(server.listen(), qPrintable(server.errorString()));
- server.serveDirectory(testFile("httpfail"), TestHTTPServer::Disconnect);
- server.serveDirectory(testFile("httpslow"), TestHTTPServer::Delay);
- server.serveDirectory(testFile("http"));
+ QHash<QString, TestHTTPServer::Mode> dirs;
+ dirs[testFile("httpfail")] = TestHTTPServer::Disconnect;
+ dirs[testFile("httpslow")] = TestHTTPServer::Delay;
+ dirs[testFile("http")] = TestHTTPServer::Normal;
+ ThreadedTestHTTPServer server(dirs);
error.replace(QStringLiteral("{{ServerBaseUrl}}"), server.baseUrl().toString());
+ if (!error.isEmpty())
+ QTest::ignoreMessage(QtWarningMsg, error.toUtf8());
QQuickView view(server.url(qmlfile));
view.show();
view.requestActivate();
if (!error.isEmpty()) {
- QTest::ignoreMessage(QtWarningMsg, error.toUtf8());
QTRY_VERIFY(view.status()==QQuickView::Error);
QTRY_VERIFY(!view.rootObject()); // there is fail item inside this test
} else {
@@ -2786,17 +2794,17 @@ void tst_qquicktextedit::navigation()
QQuickTextEdit *input = qobject_cast<QQuickTextEdit *>(qvariant_cast<QObject *>(window.rootObject()->property("myInput")));
QVERIFY(input != 0);
- QTRY_VERIFY(input->hasActiveFocus() == true);
+ QTRY_VERIFY(input->hasActiveFocus());
simulateKey(&window, Qt::Key_Left);
- QVERIFY(input->hasActiveFocus() == false);
+ QVERIFY(!input->hasActiveFocus());
simulateKey(&window, Qt::Key_Right);
- QVERIFY(input->hasActiveFocus() == true);
+ QVERIFY(input->hasActiveFocus());
simulateKey(&window, Qt::Key_Right);
- QVERIFY(input->hasActiveFocus() == true);
+ QVERIFY(input->hasActiveFocus());
simulateKey(&window, Qt::Key_Right);
- QVERIFY(input->hasActiveFocus() == false);
+ QVERIFY(!input->hasActiveFocus());
simulateKey(&window, Qt::Key_Left);
- QVERIFY(input->hasActiveFocus() == true);
+ QVERIFY(input->hasActiveFocus());
// Test left and right navigation works if the TextEdit is empty (QTBUG-25447).
input->setText(QString());
@@ -2976,8 +2984,8 @@ void tst_qquicktextedit::readOnly()
QQuickTextEdit *edit = qobject_cast<QQuickTextEdit *>(qvariant_cast<QObject *>(window.rootObject()->property("myInput")));
QVERIFY(edit != 0);
- QTRY_VERIFY(edit->hasActiveFocus() == true);
- QVERIFY(edit->isReadOnly() == true);
+ QTRY_VERIFY(edit->hasActiveFocus());
+ QVERIFY(edit->isReadOnly());
QString initial = edit->text();
for (int k=Qt::Key_0; k<=Qt::Key_Z; k++)
simulateKey(&window, k);
@@ -3009,7 +3017,7 @@ void tst_qquicktextedit::textInput()
QTest::qWaitForWindowActive(&view);
QQuickTextEdit *edit = qobject_cast<QQuickTextEdit *>(view.rootObject());
QVERIFY(edit);
- QVERIFY(edit->hasActiveFocus() == true);
+ QVERIFY(edit->hasActiveFocus());
// test that input method event is committed and change signal is emitted
QSignalSpy spy(edit, SIGNAL(textChanged()));
@@ -3045,7 +3053,7 @@ void tst_qquicktextedit::inputMethodUpdate()
QTest::qWaitForWindowActive(&view);
QQuickTextEdit *edit = qobject_cast<QQuickTextEdit *>(view.rootObject());
QVERIFY(edit);
- QVERIFY(edit->hasActiveFocus() == true);
+ QVERIFY(edit->hasActiveFocus());
// text change even without cursor position change needs to trigger update
edit->setText("test");
@@ -3219,15 +3227,15 @@ void tst_qquicktextedit::pastingRichText_QTBUG_14003()
QQuickTextEdit *obj = qobject_cast<QQuickTextEdit*>(component.create());
QTRY_VERIFY(obj != 0);
- QTRY_VERIFY(obj->textFormat() == QQuickTextEdit::PlainText);
+ QTRY_COMPARE(obj->textFormat(), QQuickTextEdit::PlainText);
QMimeData *mData = new QMimeData;
mData->setHtml("<font color=\"red\">Hello</font>");
QGuiApplication::clipboard()->setMimeData(mData);
obj->paste();
- QTRY_VERIFY(obj->text() == "");
- QTRY_VERIFY(obj->textFormat() == QQuickTextEdit::PlainText);
+ QTRY_COMPARE(obj->text(), QString());
+ QTRY_COMPARE(obj->textFormat(), QQuickTextEdit::PlainText);
}
#endif
@@ -3253,11 +3261,11 @@ void tst_qquicktextedit::implicitSize()
QQuickTextEdit *textObject = qobject_cast<QQuickTextEdit*>(textComponent.create());
QVERIFY(textObject->width() < textObject->implicitWidth());
- QVERIFY(textObject->height() == textObject->implicitHeight());
+ QCOMPARE(textObject->height(), textObject->implicitHeight());
textObject->resetWidth();
- QVERIFY(textObject->width() == textObject->implicitWidth());
- QVERIFY(textObject->height() == textObject->implicitHeight());
+ QCOMPARE(textObject->width(), textObject->implicitWidth());
+ QCOMPARE(textObject->height(), textObject->implicitHeight());
}
void tst_qquicktextedit::contentSize()
@@ -3316,6 +3324,53 @@ void tst_qquicktextedit::implicitSizeBinding()
QCOMPARE(textObject->height(), textObject->implicitHeight());
}
+void tst_qquicktextedit::signal_editingfinished()
+{
+ QQuickView *window = new QQuickView(0);
+ window->setBaseSize(QSize(800,600));
+
+ window->setSource(testFileUrl("signal_editingfinished.qml"));
+ window->show();
+ window->requestActivate();
+ QVERIFY(QTest::qWaitForWindowActive(window));
+ QCOMPARE(QGuiApplication::focusWindow(), window);
+
+ QVERIFY(window->rootObject() != 0);
+
+ QQuickTextEdit *input1 = qobject_cast<QQuickTextEdit *>(qvariant_cast<QObject *>(window->rootObject()->property("input1")));
+ QVERIFY(input1);
+ QQuickTextEdit *input2 = qobject_cast<QQuickTextEdit *>(qvariant_cast<QObject *>(window->rootObject()->property("input2")));
+ QVERIFY(input2);
+
+ QSignalSpy editingFinished1Spy(input1, SIGNAL(editingFinished()));
+
+ input1->setFocus(true);
+ QTRY_VERIFY(input1->hasActiveFocus());
+ QTRY_VERIFY(!input2->hasActiveFocus());
+
+ QKeyEvent key(QEvent::KeyPress, Qt::Key_Tab, Qt::ShiftModifier, "", false, 1);
+ QGuiApplication::sendEvent(window, &key);
+ QVERIFY(key.isAccepted());
+ QTRY_COMPARE(editingFinished1Spy.count(), 1);
+
+ QTRY_VERIFY(!input1->hasActiveFocus());
+ QTRY_VERIFY(input2->hasActiveFocus());
+
+ QSignalSpy editingFinished2Spy(input2, SIGNAL(editingFinished()));
+
+ input2->setFocus(true);
+ QTRY_VERIFY(!input1->hasActiveFocus());
+ QTRY_VERIFY(input2->hasActiveFocus());
+
+ key = QKeyEvent(QEvent::KeyPress, Qt::Key_Tab, Qt::ShiftModifier, "", false, 1);
+ QGuiApplication::sendEvent(window, &key);
+ QVERIFY(key.isAccepted());
+ QTRY_COMPARE(editingFinished2Spy.count(), 1);
+
+ QTRY_VERIFY(input1->hasActiveFocus());
+ QTRY_VERIFY(!input2->hasActiveFocus());
+}
+
void tst_qquicktextedit::clipRect()
{
QQmlComponent component(&engine);
@@ -3993,7 +4048,7 @@ void tst_qquicktextedit::append_data()
<< QString("Hello")
<< standard.at(0) + QString("\nHello")
<< 18 << standard.at(0).length() + 6 << standard.at(0).length() + 6
- << false << true;
+ << true << true;
QTest::newRow("reversed selection kept intact")
<< standard.at(0) << QQuickTextEdit::PlainText
@@ -4075,11 +4130,8 @@ void tst_qquicktextedit::append()
if (selectionStart > selectionEnd)
qSwap(selectionStart, selectionEnd);
- QEXPECT_FAIL("into selection", "selectedTextChanged signal isn't emitted on edits within selection", Continue);
- QEXPECT_FAIL("into reversed selection", "selectedTextChanged signal isn't emitted on edits within selection", Continue);
QCOMPARE(selectionSpy.count() > 0, selectionChanged);
QCOMPARE(selectionStartSpy.count() > 0, selectionStart != expectedSelectionStart);
- QEXPECT_FAIL("into reversed selection", "selectionEndChanged signal not emitted", Continue);
QCOMPARE(selectionEndSpy.count() > 0, selectionEnd != expectedSelectionEnd);
QCOMPARE(textSpy.count() > 0, text != expectedText);
QCOMPARE(cursorPositionSpy.count() > 0, cursorPositionChanged);
@@ -4162,7 +4214,7 @@ void tst_qquicktextedit::insert_data()
<< QString("Hello")
<< QString("Hello") + standard.at(0)
<< 19 << 24 << 24
- << false << true;
+ << true << true;
QTest::newRow("before reversed selection")
<< standard.at(0) << QQuickTextEdit::PlainText
@@ -4170,7 +4222,7 @@ void tst_qquicktextedit::insert_data()
<< QString("Hello")
<< QString("Hello") + standard.at(0)
<< 19 << 24 << 19
- << false << true;
+ << true << true;
QTest::newRow("after selection")
<< standard.at(0) << QQuickTextEdit::PlainText
@@ -4293,11 +4345,8 @@ void tst_qquicktextedit::insert()
if (selectionStart > selectionEnd)
qSwap(selectionStart, selectionEnd);
- QEXPECT_FAIL("into selection", "selectedTextChanged signal isn't emitted on edits within selection", Continue);
- QEXPECT_FAIL("into reversed selection", "selectedTextChanged signal isn't emitted on edits within selection", Continue);
QCOMPARE(selectionSpy.count() > 0, selectionChanged);
QCOMPARE(selectionStartSpy.count() > 0, selectionStart != expectedSelectionStart);
- QEXPECT_FAIL("into reversed selection", "selectionEndChanged signal not emitted", Continue);
QCOMPARE(selectionEndSpy.count() > 0, selectionEnd != expectedSelectionEnd);
QCOMPARE(textSpy.count() > 0, text != expectedText);
QCOMPARE(cursorPositionSpy.count() > 0, cursorPositionChanged);
@@ -4407,7 +4456,7 @@ void tst_qquicktextedit::remove_data()
<< 0 << 5
<< standard.at(0).mid(5)
<< 9 << 14 << 14
- << false << true;
+ << true << true;
QTest::newRow("before reversed selection")
<< standard.at(0) << QQuickTextEdit::PlainText
@@ -4415,7 +4464,7 @@ void tst_qquicktextedit::remove_data()
<< 0 << 5
<< standard.at(0).mid(5)
<< 9 << 14 << 9
- << false << true;
+ << true << true;
QTest::newRow("after selection")
<< standard.at(0) << QQuickTextEdit::PlainText
@@ -4537,11 +4586,8 @@ void tst_qquicktextedit::remove()
QCOMPARE(textEdit->selectionEnd(), expectedSelectionEnd);
QCOMPARE(textEdit->cursorPosition(), expectedCursorPosition);
- QEXPECT_FAIL("from selection", "selectedTextChanged signal isn't emitted on edits within selection", Continue);
- QEXPECT_FAIL("from reversed selection", "selectedTextChanged signal isn't emitted on edits within selection", Continue);
QCOMPARE(selectionSpy.count() > 0, selectionChanged);
QCOMPARE(selectionStartSpy.count() > 0, selectionStart != expectedSelectionStart);
- QEXPECT_FAIL("from reversed selection", "selectionEndChanged signal not emitted", Continue);
QCOMPARE(selectionEndSpy.count() > 0, selectionEnd != expectedSelectionEnd);
QCOMPARE(textSpy.count() > 0, text != expectedText);
@@ -5220,8 +5266,8 @@ void tst_qquicktextedit::embeddedImages_data()
QTest::newRow("local") << testFileUrl("embeddedImagesLocalRelative.qml") << "";
QTest::newRow("remote") << testFileUrl("embeddedImagesRemote.qml") << "";
QTest::newRow("remote-error") << testFileUrl("embeddedImagesRemoteError.qml")
- << testFileUrl("embeddedImagesRemoteError.qml").toString()+":3:1: QML TextEdit: Error downloading {{ServerBaseUrl}}/notexists.png - server replied: Not found";
- QTest::newRow("remote-relative") << testFileUrl("embeddedImagesRemoteRelative.qml") << "";
+ << testFileUrl("embeddedImagesRemoteError.qml").toString()+":3:1: QML TextEdit: Error transferring {{ServerBaseUrl}}/notexists.png - server replied: Not found";
+ QTest::newRow("remote") << testFileUrl("embeddedImagesRemoteRelative.qml") << "";
}
void tst_qquicktextedit::embeddedImages()
@@ -5323,6 +5369,104 @@ void tst_qquicktextedit::textCached_QTBUG_41583()
QVERIFY(!textedit->property("empty").toBool());
}
+void tst_qquicktextedit::doubleSelect_QTBUG_38704()
+{
+ QString componentStr = "import QtQuick 2.2\nTextEdit { text: \"TextEdit\" }";
+ QQmlComponent textEditComponent(&engine);
+ textEditComponent.setData(componentStr.toLatin1(), QUrl());
+ QQuickTextEdit *textEdit = qobject_cast<QQuickTextEdit*>(textEditComponent.create());
+ QVERIFY(textEdit != 0);
+
+ QSignalSpy selectionSpy(textEdit, SIGNAL(selectedTextChanged()));
+
+ textEdit->select(0,1); //Select some text initially
+ QCOMPARE(selectionSpy.count(), 1);
+ textEdit->select(0,1); //No change to selection start/end
+ QCOMPARE(selectionSpy.count(), 1);
+ textEdit->select(0,2); //Change selection end
+ QCOMPARE(selectionSpy.count(), 2);
+ textEdit->select(1,2); //Change selection start
+ QCOMPARE(selectionSpy.count(), 3);
+}
+
+void tst_qquicktextedit::padding()
+{
+ QScopedPointer<QQuickView> window(new QQuickView);
+ window->setSource(testFileUrl("padding.qml"));
+ QTRY_COMPARE(window->status(), QQuickView::Ready);
+ window->show();
+ QVERIFY(QTest::qWaitForWindowExposed(window.data()));
+ QQuickItem *root = window->rootObject();
+ QVERIFY(root);
+ QQuickTextEdit *obj = qobject_cast<QQuickTextEdit*>(root);
+ QVERIFY(obj != 0);
+
+ qreal cw = obj->contentWidth();
+ qreal ch = obj->contentHeight();
+
+ QVERIFY(cw > 0);
+ QVERIFY(ch > 0);
+
+ QCOMPARE(obj->topPadding(), 20.0);
+ QCOMPARE(obj->leftPadding(), 30.0);
+ QCOMPARE(obj->rightPadding(), 40.0);
+ QCOMPARE(obj->bottomPadding(), 50.0);
+
+ QCOMPARE(obj->implicitWidth(), cw + obj->leftPadding() + obj->rightPadding());
+ QCOMPARE(obj->implicitHeight(), ch + obj->topPadding() + obj->bottomPadding());
+
+ obj->setTopPadding(2.25);
+ QCOMPARE(obj->topPadding(), 2.25);
+ QCOMPARE(obj->implicitHeight(), ch + obj->topPadding() + obj->bottomPadding());
+
+ obj->setLeftPadding(3.75);
+ QCOMPARE(obj->leftPadding(), 3.75);
+ QCOMPARE(obj->implicitWidth(), cw + obj->leftPadding() + obj->rightPadding());
+
+ obj->setRightPadding(4.4);
+ QCOMPARE(obj->rightPadding(), 4.4);
+ QCOMPARE(obj->implicitWidth(), cw + obj->leftPadding() + obj->rightPadding());
+
+ obj->setBottomPadding(1.11);
+ QCOMPARE(obj->bottomPadding(), 1.11);
+ QCOMPARE(obj->implicitHeight(), ch + obj->topPadding() + obj->bottomPadding());
+
+ obj->setText("Qt");
+ QVERIFY(obj->contentWidth() < cw);
+ QCOMPARE(obj->contentHeight(), ch);
+ cw = obj->contentWidth();
+
+ QCOMPARE(obj->implicitWidth(), cw + obj->leftPadding() + obj->rightPadding());
+ QCOMPARE(obj->implicitHeight(), ch + obj->topPadding() + obj->bottomPadding());
+
+ obj->setFont(QFont("Courier", 96));
+ QVERIFY(obj->contentWidth() > cw);
+ QVERIFY(obj->contentHeight() > ch);
+ cw = obj->contentWidth();
+ ch = obj->contentHeight();
+
+ QCOMPARE(obj->implicitWidth(), cw + obj->leftPadding() + obj->rightPadding());
+ QCOMPARE(obj->implicitHeight(), ch + obj->topPadding() + obj->bottomPadding());
+
+ obj->resetTopPadding();
+ QCOMPARE(obj->topPadding(), 10.0);
+ obj->resetLeftPadding();
+ QCOMPARE(obj->leftPadding(), 10.0);
+ obj->resetRightPadding();
+ QCOMPARE(obj->rightPadding(), 10.0);
+ obj->resetBottomPadding();
+ QCOMPARE(obj->bottomPadding(), 10.0);
+
+ obj->resetPadding();
+ QCOMPARE(obj->padding(), 0.0);
+ QCOMPARE(obj->topPadding(), 0.0);
+ QCOMPARE(obj->leftPadding(), 0.0);
+ QCOMPARE(obj->rightPadding(), 0.0);
+ QCOMPARE(obj->bottomPadding(), 0.0);
+
+ delete root;
+}
+
QTEST_MAIN(tst_qquicktextedit)
#include "tst_qquicktextedit.moc"
diff --git a/tests/auto/quick/qquicktextinput/data/padding.qml b/tests/auto/quick/qquicktextinput/data/padding.qml
new file mode 100644
index 0000000000..23bfe20f22
--- /dev/null
+++ b/tests/auto/quick/qquicktextinput/data/padding.qml
@@ -0,0 +1,12 @@
+import QtQuick 2.6
+
+TextInput {
+ width: 200; height: 200
+ text: "Hello Qt"
+
+ padding: 10
+ topPadding: 20
+ leftPadding: 30
+ rightPadding: 40
+ bottomPadding: 50
+}
diff --git a/tests/auto/quick/qquicktextinput/qquicktextinput.pro b/tests/auto/quick/qquicktextinput/qquicktextinput.pro
index c14b09c545..4929289920 100644
--- a/tests/auto/quick/qquicktextinput/qquicktextinput.pro
+++ b/tests/auto/quick/qquicktextinput/qquicktextinput.pro
@@ -13,4 +13,6 @@ TESTDATA = data/*
QT += core-private gui-private qml-private quick-private testlib
+osx: LIBS += -framework AppKit
+
DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0
diff --git a/tests/auto/quick/qquicktextinput/tst_qquicktextinput.cpp b/tests/auto/quick/qquicktextinput/tst_qquicktextinput.cpp
index d87054ac9e..2a687b3c69 100644
--- a/tests/auto/quick/qquicktextinput/tst_qquicktextinput.cpp
+++ b/tests/auto/quick/qquicktextinput/tst_qquicktextinput.cpp
@@ -45,6 +45,7 @@
#include <QInputMethod>
#include <private/qquicktextinput_p.h>
#include <private/qquicktextinput_p_p.h>
+#include <private/qquickvalidator_p.h>
#include <QDebug>
#include <QDir>
#include <math.h>
@@ -70,7 +71,7 @@ QString createExpectedFileIfNotFound(const QString& filebasename, const QImage&
QString persistent_dir = QQmlDataTest::instance()->dataDirectory();
QString arch = "unknown-architecture"; // QTest needs to help with this.
- QString expectfile = persistent_dir + QDir::separator() + filebasename + "-" + arch + ".png";
+ QString expectfile = persistent_dir + QDir::separator() + filebasename + QLatin1Char('-') + arch + ".png";
if (!QFile::exists(expectfile)) {
actual.save(expectfile);
@@ -222,6 +223,7 @@ private slots:
void baselineOffset();
void ensureVisible();
+ void padding();
private:
void simulateKey(QWindow *, int key);
@@ -591,7 +593,7 @@ void tst_qquicktextinput::wrap()
textHeight = textObject->height();
QVERIFY(textObject != 0);
- QVERIFY(textObject->wrapMode() == QQuickTextInput::WrapAnywhere);
+ QCOMPARE(textObject->wrapMode(), QQuickTextInput::WrapAnywhere);
QCOMPARE(textObject->width(), 300.);
delete textObject;
@@ -658,22 +660,22 @@ void tst_qquicktextinput::selection()
}
textinputObject->setCursorPosition(0);
- QVERIFY(textinputObject->cursorPosition() == 0);
- QVERIFY(textinputObject->selectionStart() == 0);
- QVERIFY(textinputObject->selectionEnd() == 0);
+ QCOMPARE(textinputObject->cursorPosition(), 0);
+ QCOMPARE(textinputObject->selectionStart(), 0);
+ QCOMPARE(textinputObject->selectionEnd(), 0);
QVERIFY(textinputObject->selectedText().isNull());
// Verify invalid positions are ignored.
textinputObject->setCursorPosition(-1);
- QVERIFY(textinputObject->cursorPosition() == 0);
- QVERIFY(textinputObject->selectionStart() == 0);
- QVERIFY(textinputObject->selectionEnd() == 0);
+ QCOMPARE(textinputObject->cursorPosition(), 0);
+ QCOMPARE(textinputObject->selectionStart(), 0);
+ QCOMPARE(textinputObject->selectionEnd(), 0);
QVERIFY(textinputObject->selectedText().isNull());
textinputObject->setCursorPosition(textinputObject->text().count()+1);
- QVERIFY(textinputObject->cursorPosition() == 0);
- QVERIFY(textinputObject->selectionStart() == 0);
- QVERIFY(textinputObject->selectionEnd() == 0);
+ QCOMPARE(textinputObject->cursorPosition(), 0);
+ QCOMPARE(textinputObject->selectionStart(), 0);
+ QCOMPARE(textinputObject->selectionEnd(), 0);
QVERIFY(textinputObject->selectedText().isNull());
//Test selection
@@ -687,9 +689,9 @@ void tst_qquicktextinput::selection()
}
textinputObject->setCursorPosition(0);
- QVERIFY(textinputObject->cursorPosition() == 0);
- QVERIFY(textinputObject->selectionStart() == 0);
- QVERIFY(textinputObject->selectionEnd() == 0);
+ QCOMPARE(textinputObject->cursorPosition(), 0);
+ QCOMPARE(textinputObject->selectionStart(), 0);
+ QCOMPARE(textinputObject->selectionEnd(), 0);
QVERIFY(textinputObject->selectedText().isNull());
//Test Error Ignoring behaviour
@@ -704,20 +706,20 @@ void tst_qquicktextinput::selection()
textinputObject->select(0,100);
QVERIFY(textinputObject->selectedText().isNull());
textinputObject->select(0,10);
- QVERIFY(textinputObject->selectedText().size() == 10);
+ QCOMPARE(textinputObject->selectedText().size(), 10);
textinputObject->select(-10,10);
- QVERIFY(textinputObject->selectedText().size() == 10);
+ QCOMPARE(textinputObject->selectedText().size(), 10);
textinputObject->select(100,101);
- QVERIFY(textinputObject->selectedText().size() == 10);
+ QCOMPARE(textinputObject->selectedText().size(), 10);
textinputObject->select(0,-10);
- QVERIFY(textinputObject->selectedText().size() == 10);
+ QCOMPARE(textinputObject->selectedText().size(), 10);
textinputObject->select(0,100);
- QVERIFY(textinputObject->selectedText().size() == 10);
+ QCOMPARE(textinputObject->selectedText().size(), 10);
textinputObject->deselect();
QVERIFY(textinputObject->selectedText().isNull());
textinputObject->select(0,10);
- QVERIFY(textinputObject->selectedText().size() == 10);
+ QCOMPARE(textinputObject->selectedText().size(), 10);
textinputObject->deselect();
QVERIFY(textinputObject->selectedText().isNull());
@@ -1513,13 +1515,13 @@ void tst_qquicktextinput::horizontalAlignment_RightToLeft()
// keyboard input direction from QInputMethod::inputDirection()
textInput->setText("");
platformInputContext.setInputDirection(Qt::LeftToRight);
- QVERIFY(qApp->inputMethod()->inputDirection() == Qt::LeftToRight);
+ QCOMPARE(qApp->inputMethod()->inputDirection(), Qt::LeftToRight);
QCOMPARE(textInput->hAlign(), QQuickTextInput::AlignLeft);
QCOMPARE(textInput->boundingRect().left(), qreal(0));
QSignalSpy cursorRectangleSpy(textInput, SIGNAL(cursorRectangleChanged()));
platformInputContext.setInputDirection(Qt::RightToLeft);
- QVERIFY(qApp->inputMethod()->inputDirection() == Qt::RightToLeft);
+ QCOMPARE(qApp->inputMethod()->inputDirection(), Qt::RightToLeft);
QCOMPARE(cursorRectangleSpy.count(), 1);
QCOMPARE(textInput->hAlign(), QQuickTextInput::AlignRight);
QVERIFY(textInput->boundingRect().right() >= textInput->width() - 1);
@@ -1853,7 +1855,7 @@ void tst_qquicktextinput::maxLength()
QQuickTextInput *textinputObject = qobject_cast<QQuickTextInput *>(window.rootObject());
QVERIFY(textinputObject != 0);
QVERIFY(textinputObject->text().isEmpty());
- QVERIFY(textinputObject->maxLength() == 10);
+ QCOMPARE(textinputObject->maxLength(), 10);
foreach (const QString &str, standard) {
QVERIFY(textinputObject->text().length() <= 10);
textinputObject->setText(str);
@@ -1861,7 +1863,7 @@ void tst_qquicktextinput::maxLength()
}
textinputObject->setText("");
- QTRY_VERIFY(textinputObject->hasActiveFocus() == true);
+ QTRY_VERIFY(textinputObject->hasActiveFocus());
for (int i=0; i<20; i++) {
QTRY_COMPARE(textinputObject->text().length(), qMin(i,10));
//simulateKey(&window, Qt::Key_A);
@@ -1880,8 +1882,8 @@ void tst_qquicktextinput::masks()
QVERIFY(window.rootObject() != 0);
QQuickTextInput *textinputObject = qobject_cast<QQuickTextInput *>(window.rootObject());
QVERIFY(textinputObject != 0);
- QTRY_VERIFY(textinputObject->hasActiveFocus() == true);
- QVERIFY(textinputObject->text().length() == 0);
+ QTRY_VERIFY(textinputObject->hasActiveFocus());
+ QCOMPARE(textinputObject->text().length(), 0);
QCOMPARE(textinputObject->inputMask(), QString("HHHHhhhh; "));
QCOMPARE(textinputObject->length(), 8);
for (int i=0; i<10; i++) {
@@ -1997,7 +1999,7 @@ void tst_qquicktextinput::validators()
QCOMPARE(dblInput->validator()->locale(), defaultLocale);
dblInput->setFocus(true);
- QVERIFY(dblInput->hasActiveFocus() == true);
+ QVERIFY(dblInput->hasActiveFocus());
QCOMPARE(dblInput->hasAcceptableInput(), false);
QCOMPARE(dblInput->property("acceptable").toBool(), false);
QTest::keyPress(&window, Qt::Key_1);
@@ -2131,7 +2133,7 @@ void tst_qquicktextinput::validators()
QVERIFY(strInput);
QSignalSpy strSpy(strInput, SIGNAL(acceptableInputChanged()));
strInput->setFocus(true);
- QVERIFY(strInput->hasActiveFocus() == true);
+ QVERIFY(strInput->hasActiveFocus());
QCOMPARE(strInput->hasAcceptableInput(), false);
QCOMPARE(strInput->property("acceptable").toBool(), false);
QTest::keyPress(&window, Qt::Key_1);
@@ -2175,7 +2177,7 @@ void tst_qquicktextinput::validators()
QVERIFY(unvalidatedInput);
QSignalSpy unvalidatedSpy(unvalidatedInput, SIGNAL(acceptableInputChanged()));
unvalidatedInput->setFocus(true);
- QVERIFY(unvalidatedInput->hasActiveFocus() == true);
+ QVERIFY(unvalidatedInput->hasActiveFocus());
QCOMPARE(unvalidatedInput->hasAcceptableInput(), true);
QCOMPARE(unvalidatedInput->property("acceptable").toBool(), true);
QTest::keyPress(&window, Qt::Key_1);
@@ -2216,7 +2218,7 @@ void tst_qquicktextinput::inputMethods()
QCOMPARE(plainInput.inputMethodHints(), Qt::ImhNone);
input->setFocus(true);
- QVERIFY(input->hasActiveFocus() == true);
+ QVERIFY(input->hasActiveFocus());
// test that input method event is committed
QInputMethodEvent event;
event.setCommitString( "My ", -12, 0);
@@ -2399,23 +2401,23 @@ void tst_qquicktextinput::navigation()
QVERIFY(input != 0);
input->setCursorPosition(0);
- QTRY_VERIFY(input->hasActiveFocus() == true);
+ QTRY_VERIFY(input->hasActiveFocus());
simulateKey(&window, Qt::Key_Left);
- QVERIFY(input->hasActiveFocus() == false);
+ QVERIFY(!input->hasActiveFocus());
simulateKey(&window, Qt::Key_Right);
- QVERIFY(input->hasActiveFocus() == true);
+ QVERIFY(input->hasActiveFocus());
//QT-2944: If text is selected, ensure we deselect upon cursor motion
input->setCursorPosition(input->text().length());
input->select(0,input->text().length());
QVERIFY(input->selectionStart() != input->selectionEnd());
simulateKey(&window, Qt::Key_Right);
- QVERIFY(input->selectionStart() == input->selectionEnd());
- QVERIFY(input->selectionStart() == input->text().length());
- QVERIFY(input->hasActiveFocus() == true);
+ QCOMPARE(input->selectionStart(), input->selectionEnd());
+ QCOMPARE(input->selectionStart(), input->text().length());
+ QVERIFY(input->hasActiveFocus());
simulateKey(&window, Qt::Key_Right);
- QVERIFY(input->hasActiveFocus() == false);
+ QVERIFY(!input->hasActiveFocus());
simulateKey(&window, Qt::Key_Left);
- QVERIFY(input->hasActiveFocus() == true);
+ QVERIFY(input->hasActiveFocus());
// Up and Down should NOT do Home/End, even on OS X (QTBUG-10438).
input->setCursorPosition(2);
@@ -2451,26 +2453,26 @@ void tst_qquicktextinput::navigation_RTL()
input->setText(QString::fromUtf16(arabic_str, 11));
input->setCursorPosition(0);
- QTRY_VERIFY(input->hasActiveFocus() == true);
+ QTRY_VERIFY(input->hasActiveFocus());
// move off
simulateKey(&window, Qt::Key_Right);
- QVERIFY(input->hasActiveFocus() == false);
+ QVERIFY(!input->hasActiveFocus());
// move back
simulateKey(&window, Qt::Key_Left);
- QVERIFY(input->hasActiveFocus() == true);
+ QVERIFY(input->hasActiveFocus());
input->setCursorPosition(input->text().length());
- QVERIFY(input->hasActiveFocus() == true);
+ QVERIFY(input->hasActiveFocus());
// move off
simulateKey(&window, Qt::Key_Left);
- QVERIFY(input->hasActiveFocus() == false);
+ QVERIFY(!input->hasActiveFocus());
// move back
simulateKey(&window, Qt::Key_Right);
- QVERIFY(input->hasActiveFocus() == true);
+ QVERIFY(input->hasActiveFocus());
}
#ifndef QT_NO_CLIPBOARD
@@ -2855,10 +2857,7 @@ void tst_qquicktextinput::cursorDelegate()
void tst_qquicktextinput::remoteCursorDelegate()
{
- TestHTTPServer server;
- QVERIFY2(server.listen(), qPrintable(server.errorString()));
- server.serveDirectory(dataDirectory(), TestHTTPServer::Delay);
-
+ ThreadedTestHTTPServer server(dataDirectory(), TestHTTPServer::Delay);
QQuickView view;
QQmlComponent component(view.engine(), server.url("/RemoteCursor.qml"));
@@ -2996,6 +2995,14 @@ void tst_qquicktextinput::cursorRectangle_data()
<< false;
}
+#ifndef QT_NO_IM
+#define COMPARE_INPUT_METHOD_QUERY(type, input, property, method, result) \
+ QCOMPARE((type) input->inputMethodQuery(property).method(), result);
+#else
+#define COMPARE_INPUT_METHOD_QUERY(type, input, property, method, result) \
+ qt_noop()
+#endif
+
void tst_qquicktextinput::cursorRectangle()
{
QFETCH(QString, text);
@@ -3035,7 +3042,7 @@ void tst_qquicktextinput::cursorRectangle()
r = input.cursorRectangle();
QCOMPARE(r.left(), line.cursorToX(i, QTextLine::Leading) - offset);
- QCOMPARE(input.inputMethodQuery(Qt::ImCursorRectangle).toRectF(), r);
+ COMPARE_INPUT_METHOD_QUERY(QRectF, (&input), Qt::ImCursorRectangle, toRectF, r);
QCOMPARE(input.positionToRectangle(i), r);
}
@@ -3045,7 +3052,7 @@ void tst_qquicktextinput::cursorRectangle()
for (int i = positionAtWidth + 1; i < text.length(); ++i) {
input.setCursorPosition(i);
QCOMPARE(r, input.cursorRectangle());
- QCOMPARE(input.inputMethodQuery(Qt::ImCursorRectangle).toRectF(), r);
+ COMPARE_INPUT_METHOD_QUERY(QRectF, (&input), Qt::ImCursorRectangle, toRectF, r);
QCOMPARE(input.positionToRectangle(i), r);
}
@@ -3058,7 +3065,7 @@ void tst_qquicktextinput::cursorRectangle()
} else {
QVERIFY(r.left() <= input.width());
}
- QCOMPARE(input.inputMethodQuery(Qt::ImCursorRectangle).toRectF(), r);
+ COMPARE_INPUT_METHOD_QUERY(QRectF, (&input), Qt::ImCursorRectangle, toRectF, r);
QCOMPARE(input.positionToRectangle(i), r);
}
@@ -3071,7 +3078,7 @@ void tst_qquicktextinput::cursorRectangle()
QCOMPARE(r.left(), line.cursorToX(i, QTextLine::Leading) - offset);
QCOMPARE(r.top(), 0.);
- QCOMPARE(input.inputMethodQuery(Qt::ImCursorRectangle).toRectF(), r);
+ COMPARE_INPUT_METHOD_QUERY(QRectF, (&input), Qt::ImCursorRectangle, toRectF, r);
QCOMPARE(input.positionToRectangle(i), r);
}
@@ -3082,15 +3089,17 @@ void tst_qquicktextinput::cursorRectangle()
} else {
QCOMPARE(r.left(), input.width());
}
- QVERIFY(r.top() >= line.height() - 1);
- QCOMPARE(input.inputMethodQuery(Qt::ImCursorRectangle).toRectF(), r);
+ // we can't be exact here, as the space character can have a different ascent/descent from the arabic chars
+ // this then leads to different line heights between the wrapped and non wrapped texts
+ QVERIFY(r.top() >= line.height() - 5);
+ COMPARE_INPUT_METHOD_QUERY(QRectF, (&input), Qt::ImCursorRectangle, toRectF, r);
QCOMPARE(input.positionToRectangle(11), r);
for (int i = wrapPosition + 1; i < text.length(); ++i) {
input.setCursorPosition(i);
r = input.cursorRectangle();
- QVERIFY(r.top() >= line.height() - 1);
- QCOMPARE(input.inputMethodQuery(Qt::ImCursorRectangle).toRectF(), r);
+ QVERIFY(r.top() >= line.height() - 5);
+ COMPARE_INPUT_METHOD_QUERY(QRectF, (&input), Qt::ImCursorRectangle, toRectF, r);
QCOMPARE(input.positionToRectangle(i), r);
}
@@ -3102,7 +3111,7 @@ void tst_qquicktextinput::cursorRectangle()
QCOMPARE(r.left(), line.cursorToX(i, QTextLine::Leading) - offset);
QCOMPARE(r.top(), 0.);
- QCOMPARE(input.inputMethodQuery(Qt::ImCursorRectangle).toRectF(), r);
+ COMPARE_INPUT_METHOD_QUERY(QRectF, (&input), Qt::ImCursorRectangle, toRectF, r);
QCOMPARE(input.positionToRectangle(i), r);
}
@@ -3112,7 +3121,7 @@ void tst_qquicktextinput::cursorRectangle()
for (int i = positionAtWidth + 1; i < wrapPosition && leftToRight; ++i) {
input.setCursorPosition(i);
QCOMPARE(r, input.cursorRectangle());
- QCOMPARE(input.inputMethodQuery(Qt::ImCursorRectangle).toRectF(), r);
+ COMPARE_INPUT_METHOD_QUERY(QRectF, (&input), Qt::ImCursorRectangle, toRectF, r);
QCOMPARE(input.positionToRectangle(i), r);
}
@@ -3124,14 +3133,14 @@ void tst_qquicktextinput::cursorRectangle()
QCOMPARE(r.left(), input.width());
}
QVERIFY(r.bottom() >= input.height());
- QCOMPARE(input.inputMethodQuery(Qt::ImCursorRectangle).toRectF(), r);
+ COMPARE_INPUT_METHOD_QUERY(QRectF, (&input), Qt::ImCursorRectangle, toRectF, r);
QCOMPARE(input.positionToRectangle(11), r);
for (int i = wrapPosition + 1; i < text.length(); ++i) {
input.setCursorPosition(i);
r = input.cursorRectangle();
QVERIFY(r.bottom() >= input.height());
- QCOMPARE(input.inputMethodQuery(Qt::ImCursorRectangle).toRectF(), r);
+ COMPARE_INPUT_METHOD_QUERY(QRectF, (&input), Qt::ImCursorRectangle, toRectF, r);
QCOMPARE(input.positionToRectangle(i), r);
}
@@ -3139,7 +3148,7 @@ void tst_qquicktextinput::cursorRectangle()
input.setCursorPosition(i);
r = input.cursorRectangle();
QVERIFY(r.bottom() >= input.height());
- QCOMPARE(input.inputMethodQuery(Qt::ImCursorRectangle).toRectF(), r);
+ COMPARE_INPUT_METHOD_QUERY(QRectF, (&input), Qt::ImCursorRectangle, toRectF, r);
QCOMPARE(input.positionToRectangle(i), r);
}
@@ -3147,13 +3156,13 @@ void tst_qquicktextinput::cursorRectangle()
r = input.cursorRectangle();
QCOMPARE(r.top(), 0.);
QCOMPARE(r.left(), leftToRight ? input.width() : 0);
- QCOMPARE(input.inputMethodQuery(Qt::ImCursorRectangle).toRectF(), r);
+ COMPARE_INPUT_METHOD_QUERY(QRectF, (&input), Qt::ImCursorRectangle, toRectF, r);
QCOMPARE(input.positionToRectangle(10), r);
for (int i = wrapPosition - 2; i >= positionAtWidth + 1; --i) {
input.setCursorPosition(i);
QCOMPARE(r, input.cursorRectangle());
- QCOMPARE(input.inputMethodQuery(Qt::ImCursorRectangle).toRectF(), r);
+ COMPARE_INPUT_METHOD_QUERY(QRectF, (&input), Qt::ImCursorRectangle, toRectF, r);
QCOMPARE(input.positionToRectangle(i), r);
}
@@ -3161,7 +3170,7 @@ void tst_qquicktextinput::cursorRectangle()
input.setCursorPosition(i);
r = input.cursorRectangle();
QCOMPARE(r.top(), 0.);
- QCOMPARE(input.inputMethodQuery(Qt::ImCursorRectangle).toRectF(), r);
+ COMPARE_INPUT_METHOD_QUERY(QRectF, (&input), Qt::ImCursorRectangle, toRectF, r);
QCOMPARE(input.positionToRectangle(i), r);
}
@@ -3190,9 +3199,9 @@ void tst_qquicktextinput::readOnly()
QQuickTextInput *input = qobject_cast<QQuickTextInput *>(qvariant_cast<QObject *>(window.rootObject()->property("myInput")));
QVERIFY(input != 0);
- QTRY_VERIFY(input->hasActiveFocus() == true);
- QVERIFY(input->isReadOnly() == true);
- QVERIFY(input->isCursorVisible() == false);
+ QTRY_VERIFY(input->hasActiveFocus());
+ QVERIFY(input->isReadOnly());
+ QVERIFY(!input->isCursorVisible());
QString initial = input->text();
for (int k=Qt::Key_0; k<=Qt::Key_Z; k++)
simulateKey(&window, k);
@@ -3205,7 +3214,7 @@ void tst_qquicktextinput::readOnly()
input->setReadOnly(false);
QCOMPARE(input->isReadOnly(), false);
QCOMPARE(input->cursorPosition(), input->text().length());
- QVERIFY(input->isCursorVisible() == true);
+ QVERIFY(input->isCursorVisible());
}
void tst_qquicktextinput::echoMode()
@@ -3220,7 +3229,7 @@ void tst_qquicktextinput::echoMode()
QQuickTextInput *input = qobject_cast<QQuickTextInput *>(qvariant_cast<QObject *>(window.rootObject()->property("myInput")));
QVERIFY(input != 0);
- QTRY_VERIFY(input->hasActiveFocus() == true);
+ QTRY_VERIFY(input->hasActiveFocus());
QString initial = input->text();
Qt::InputMethodHints ref;
QCOMPARE(initial, QLatin1String("ABCDefgh"));
@@ -3230,7 +3239,7 @@ void tst_qquicktextinput::echoMode()
//Normal
ref &= ~Qt::ImhHiddenText;
ref &= ~(Qt::ImhNoAutoUppercase | Qt::ImhNoPredictiveText | Qt::ImhSensitiveData);
- QCOMPARE((Qt::InputMethodHints) input->inputMethodQuery(Qt::ImHints).toInt(), ref);
+ COMPARE_INPUT_METHOD_QUERY(Qt::InputMethodHints, input, Qt::ImHints, toInt, ref);
input->setEchoMode(QQuickTextInput::NoEcho);
QCOMPARE(input->text(), initial);
QCOMPARE(input->displayText(), QLatin1String(""));
@@ -3238,17 +3247,17 @@ void tst_qquicktextinput::echoMode()
//NoEcho
ref |= Qt::ImhHiddenText;
ref |= (Qt::ImhNoAutoUppercase | Qt::ImhNoPredictiveText | Qt::ImhSensitiveData);
- QCOMPARE((Qt::InputMethodHints) input->inputMethodQuery(Qt::ImHints).toInt(), ref);
+ COMPARE_INPUT_METHOD_QUERY(Qt::InputMethodHints, input, Qt::ImHints, toInt, ref);
input->setEchoMode(QQuickTextInput::Password);
//Password
ref |= Qt::ImhHiddenText;
ref |= (Qt::ImhNoAutoUppercase | Qt::ImhNoPredictiveText | Qt::ImhSensitiveData);
QCOMPARE(input->text(), initial);
QCOMPARE(input->displayText(), QString(8, passwordMaskCharacter.at(0)));
- QCOMPARE((Qt::InputMethodHints) input->inputMethodQuery(Qt::ImHints).toInt(), ref);
+ COMPARE_INPUT_METHOD_QUERY(Qt::InputMethodHints, input, Qt::ImHints, toInt, ref);
// clearing input hints do not clear bits set by echo mode
input->setInputMethodHints(Qt::ImhNone);
- QCOMPARE((Qt::InputMethodHints) input->inputMethodQuery(Qt::ImHints).toInt(), ref);
+ COMPARE_INPUT_METHOD_QUERY(Qt::InputMethodHints, input, Qt::ImHints, toInt, ref);
input->setPasswordCharacter(QChar('Q'));
QCOMPARE(input->passwordCharacter(), QLatin1String("Q"));
QCOMPARE(input->text(), initial);
@@ -3257,19 +3266,20 @@ void tst_qquicktextinput::echoMode()
//PasswordEchoOnEdit
ref &= ~Qt::ImhHiddenText;
ref |= (Qt::ImhNoAutoUppercase | Qt::ImhNoPredictiveText | Qt::ImhSensitiveData);
- QCOMPARE((Qt::InputMethodHints) input->inputMethodQuery(Qt::ImHints).toInt(), ref);
+ COMPARE_INPUT_METHOD_QUERY(Qt::InputMethodHints, input, Qt::ImHints, toInt, ref);
QCOMPARE(input->text(), initial);
QCOMPARE(input->displayText(), QLatin1String("QQQQQQQQ"));
- QCOMPARE(input->inputMethodQuery(Qt::ImSurroundingText).toString(), QLatin1String("QQQQQQQQ"));
+ COMPARE_INPUT_METHOD_QUERY(QString, input, Qt::ImSurroundingText, toString,
+ QLatin1String("QQQQQQQQ"));
QTest::keyPress(&window, Qt::Key_A);//Clearing previous entry is part of PasswordEchoOnEdit
QTest::keyRelease(&window, Qt::Key_A, Qt::NoModifier ,10);
QCOMPARE(input->text(), QLatin1String("a"));
QCOMPARE(input->displayText(), QLatin1String("a"));
- QCOMPARE(input->inputMethodQuery(Qt::ImSurroundingText).toString(), QLatin1String("a"));
+ COMPARE_INPUT_METHOD_QUERY(QString, input, Qt::ImSurroundingText, toString, QLatin1String("a"));
input->setFocus(false);
- QVERIFY(input->hasActiveFocus() == false);
+ QVERIFY(!input->hasActiveFocus());
QCOMPARE(input->displayText(), QLatin1String("Q"));
- QCOMPARE(input->inputMethodQuery(Qt::ImSurroundingText).toString(), QLatin1String("Q"));
+ COMPARE_INPUT_METHOD_QUERY(QString, input, Qt::ImSurroundingText, toString, QLatin1String("Q"));
input->setFocus(true);
QVERIFY(input->hasActiveFocus());
QInputMethodEvent inputEvent;
@@ -3277,7 +3287,7 @@ void tst_qquicktextinput::echoMode()
QGuiApplication::sendEvent(input, &inputEvent);
QCOMPARE(input->text(), initial);
QCOMPARE(input->displayText(), initial);
- QCOMPARE(input->inputMethodQuery(Qt::ImSurroundingText).toString(), initial);
+ COMPARE_INPUT_METHOD_QUERY(QString, input, Qt::ImSurroundingText, toString, initial);
}
void tst_qquicktextinput::passwordEchoDelay()
@@ -5077,6 +5087,10 @@ void tst_qquicktextinput::keySequence_data()
<< standard.at(0) << QKeySequence(QKeySequence::DeleteStartOfWord) << 7 << 7
<< 4 << (standard.at(0).mid(0, 4) + standard.at(0).mid(7)) << QString()
<< QQuickTextInput::Normal << Qt::Key_Direction_L;
+ QTest::newRow("delete complete line")
+ << standard.at(0) << QKeySequence(QKeySequence::DeleteCompleteLine) << 0 << 0
+ << 0 << QString() << QString()
+ << QQuickTextInput::Normal << Qt::Key_Direction_L;
}
void tst_qquicktextinput::keySequence()
@@ -5819,11 +5833,11 @@ void tst_qquicktextinput::implicitSize()
QQuickTextInput *textObject = qobject_cast<QQuickTextInput*>(textComponent.create());
QVERIFY(textObject->width() < textObject->implicitWidth());
- QVERIFY(textObject->height() == textObject->implicitHeight());
+ QCOMPARE(textObject->height(), textObject->implicitHeight());
textObject->resetWidth();
- QVERIFY(textObject->width() == textObject->implicitWidth());
- QVERIFY(textObject->height() == textObject->implicitHeight());
+ QCOMPARE(textObject->width(), textObject->implicitWidth());
+ QCOMPARE(textObject->height(), textObject->implicitHeight());
}
void tst_qquicktextinput::implicitSizeBinding_data()
@@ -6370,25 +6384,25 @@ Q_DECLARE_METATYPE(ExpectedBaseline)
static qreal expectedBaselineTop(QQuickTextInput *item)
{
QFontMetricsF fm(item->font());
- return fm.ascent();
+ return fm.ascent() + item->topPadding();
}
static qreal expectedBaselineBottom(QQuickTextInput *item)
{
QFontMetricsF fm(item->font());
- return item->height() - item->contentHeight() + fm.ascent();
+ return item->height() - item->contentHeight() - item->bottomPadding() + fm.ascent();
}
static qreal expectedBaselineCenter(QQuickTextInput *item)
{
QFontMetricsF fm(item->font());
- return ((item->height() - item->contentHeight()) / 2) + fm.ascent();
+ return ((item->height() - item->contentHeight() - item->topPadding() - item->bottomPadding()) / 2) + fm.ascent() + item->topPadding();
}
static qreal expectedBaselineMultilineBottom(QQuickTextInput *item)
{
QFontMetricsF fm(item->font());
- return item->height() - item->contentHeight() + fm.ascent();
+ return item->height() - item->contentHeight() - item->bottomPadding() + fm.ascent();
}
void tst_qquicktextinput::baselineOffset_data()
@@ -6433,6 +6447,41 @@ void tst_qquicktextinput::baselineOffset_data()
<< -1.
<< &expectedBaselineMultilineBottom
<< &expectedBaselineBottom;
+
+ QTest::newRow("padding")
+ << "Typography"
+ << QByteArray("topPadding: 10; bottomPadding: 20")
+ << -1.
+ << &expectedBaselineTop
+ << &expectedBaselineTop;
+
+ QTest::newRow("top align with padding")
+ << "Typography"
+ << QByteArray("height: 200; verticalAlignment: Text.AlignTop; topPadding: 10; bottomPadding: 20")
+ << -1.
+ << &expectedBaselineTop
+ << &expectedBaselineTop;
+
+ QTest::newRow("bottom align with padding")
+ << "Typography"
+ << QByteArray("height: 200; verticalAlignment: Text.AlignBottom; topPadding: 10; bottomPadding: 20")
+ << 100.
+ << &expectedBaselineBottom
+ << &expectedBaselineBottom;
+
+ QTest::newRow("center align with padding")
+ << "Typography"
+ << QByteArray("height: 200; verticalAlignment: Text.AlignVCenter; topPadding: 10; bottomPadding: 20")
+ << 100.
+ << &expectedBaselineCenter
+ << &expectedBaselineCenter;
+
+ QTest::newRow("multiline bottom aligned with padding")
+ << "The quick brown fox jumps over the lazy dog"
+ << QByteArray("height: 200; width: 30; verticalAlignment: Text.AlignBottom; wrapMode: TextInput.WordWrap; topPadding: 10; bottomPadding: 20")
+ << -1.
+ << &expectedBaselineMultilineBottom
+ << &expectedBaselineBottom;
}
void tst_qquicktextinput::baselineOffset()
@@ -6445,7 +6494,7 @@ void tst_qquicktextinput::baselineOffset()
QQmlComponent component(&engine);
component.setData(
- "import QtQuick 2.0\n"
+ "import QtQuick 2.6\n"
"TextInput {\n"
+ bindings + "\n"
"}", QUrl());
@@ -6510,6 +6559,85 @@ void tst_qquicktextinput::ensureVisible()
QCOMPARE(input->boundingRect().height(), line.height());
}
+void tst_qquicktextinput::padding()
+{
+ QScopedPointer<QQuickView> window(new QQuickView);
+ window->setSource(testFileUrl("padding.qml"));
+ QTRY_COMPARE(window->status(), QQuickView::Ready);
+ window->show();
+ QVERIFY(QTest::qWaitForWindowExposed(window.data()));
+ QQuickItem *root = window->rootObject();
+ QVERIFY(root);
+ QQuickTextInput *obj = qobject_cast<QQuickTextInput*>(root);
+ QVERIFY(obj != 0);
+
+ qreal cw = obj->contentWidth();
+ qreal ch = obj->contentHeight();
+
+ QVERIFY(cw > 0);
+ QVERIFY(ch > 0);
+
+ QCOMPARE(obj->padding(), 10.0);
+ QCOMPARE(obj->topPadding(), 20.0);
+ QCOMPARE(obj->leftPadding(), 30.0);
+ QCOMPARE(obj->rightPadding(), 40.0);
+ QCOMPARE(obj->bottomPadding(), 50.0);
+
+ QCOMPARE(obj->implicitWidth(), qCeil(cw) + obj->leftPadding() + obj->rightPadding());
+ QCOMPARE(obj->implicitHeight(), qCeil(ch) + obj->topPadding() + obj->bottomPadding());
+
+ obj->setTopPadding(2.25);
+ QCOMPARE(obj->topPadding(), 2.25);
+ QCOMPARE(obj->implicitHeight(), qCeil(ch) + obj->topPadding() + obj->bottomPadding());
+
+ obj->setLeftPadding(3.75);
+ QCOMPARE(obj->leftPadding(), 3.75);
+ QCOMPARE(obj->implicitWidth(), qCeil(cw) + obj->leftPadding() + obj->rightPadding());
+
+ obj->setRightPadding(4.4);
+ QCOMPARE(obj->rightPadding(), 4.4);
+ QCOMPARE(obj->implicitWidth(), qCeil(cw) + obj->leftPadding() + obj->rightPadding());
+
+ obj->setBottomPadding(1.11);
+ QCOMPARE(obj->bottomPadding(), 1.11);
+ QCOMPARE(obj->implicitHeight(), qCeil(ch) + obj->topPadding() + obj->bottomPadding());
+
+ obj->setText("Qt");
+ QVERIFY(obj->contentWidth() < cw);
+ QCOMPARE(obj->contentHeight(), ch);
+ cw = obj->contentWidth();
+
+ QCOMPARE(obj->implicitWidth(), qCeil(cw) + obj->leftPadding() + obj->rightPadding());
+ QCOMPARE(obj->implicitHeight(), qCeil(ch) + obj->topPadding() + obj->bottomPadding());
+
+ obj->setFont(QFont("Courier", 96));
+ QVERIFY(obj->contentWidth() > cw);
+ QVERIFY(obj->contentHeight() > ch);
+ cw = obj->contentWidth();
+ ch = obj->contentHeight();
+
+ QCOMPARE(obj->implicitWidth(), qCeil(cw) + obj->leftPadding() + obj->rightPadding());
+ QCOMPARE(obj->implicitHeight(), qCeil(ch) + obj->topPadding() + obj->bottomPadding());
+
+ obj->resetTopPadding();
+ QCOMPARE(obj->topPadding(), 10.0);
+ obj->resetLeftPadding();
+ QCOMPARE(obj->leftPadding(), 10.0);
+ obj->resetRightPadding();
+ QCOMPARE(obj->rightPadding(), 10.0);
+ obj->resetBottomPadding();
+ QCOMPARE(obj->bottomPadding(), 10.0);
+
+ obj->resetPadding();
+ QCOMPARE(obj->padding(), 0.0);
+ QCOMPARE(obj->topPadding(), 0.0);
+ QCOMPARE(obj->leftPadding(), 0.0);
+ QCOMPARE(obj->rightPadding(), 0.0);
+ QCOMPARE(obj->bottomPadding(), 0.0);
+
+ delete root;
+}
+
QTEST_MAIN(tst_qquicktextinput)
#include "tst_qquicktextinput.moc"
diff --git a/tests/auto/quick/qquickview/data/error2.qml b/tests/auto/quick/qquickview/data/error2.qml
new file mode 100644
index 0000000000..1d754b64f0
--- /dev/null
+++ b/tests/auto/quick/qquickview/data/error2.qml
@@ -0,0 +1,4 @@
+import QtQuick.Window 2.0
+
+Window {
+}
diff --git a/tests/auto/quick/qquickview/tst_qquickview.cpp b/tests/auto/quick/qquickview/tst_qquickview.cpp
index a980c69140..69e27984c7 100644
--- a/tests/auto/quick/qquickview/tst_qquickview.cpp
+++ b/tests/auto/quick/qquickview/tst_qquickview.cpp
@@ -182,10 +182,23 @@ void tst_QQuickView::errors()
{
{
QQuickView view;
+ QVERIFY(view.errors().isEmpty()); // don't crash
+ }
+ {
+ QQuickView view;
QQmlTestMessageHandler messageHandler;
view.setSource(testFileUrl("error1.qml"));
- QVERIFY(view.status() == QQuickView::Error);
- QVERIFY(view.errors().count() == 1);
+ QCOMPARE(view.status(), QQuickView::Error);
+ QCOMPARE(view.errors().count(), 1);
+ }
+
+ {
+ QQuickView view;
+ QQmlTestMessageHandler messageHandler;
+ view.setSource(testFileUrl("error2.qml"));
+ QCOMPARE(view.status(), QQuickView::Error);
+ QCOMPARE(view.errors().count(), 1);
+ view.show();
}
}
@@ -196,16 +209,16 @@ void tst_QQuickView::engine()
QQuickView *view = new QQuickView(engine, 0);
QVERIFY(view);
- QVERIFY(engine->incubationController() == view->incubationController());
+ QCOMPARE(engine->incubationController(), view->incubationController());
QQuickView *view2 = new QQuickView(engine, 0);
QVERIFY(view);
- QVERIFY(engine->incubationController() == view->incubationController());
+ QCOMPARE(engine->incubationController(), view->incubationController());
delete view;
QVERIFY(!engine->incubationController());
engine->setIncubationController(view2->incubationController());
- QVERIFY(engine->incubationController() == view2->incubationController());
+ QCOMPARE(engine->incubationController(), view2->incubationController());
delete view2;
QVERIFY(!engine->incubationController());
diff --git a/tests/auto/quick/qquickvisualdatamodel/tst_qquickvisualdatamodel.cpp b/tests/auto/quick/qquickvisualdatamodel/tst_qquickvisualdatamodel.cpp
index 2dd9e77370..d578a0900c 100644
--- a/tests/auto/quick/qquickvisualdatamodel/tst_qquickvisualdatamodel.cpp
+++ b/tests/auto/quick/qquickvisualdatamodel/tst_qquickvisualdatamodel.cpp
@@ -513,15 +513,15 @@ void tst_qquickvisualdatamodel::rootIndex()
QVERIFY(obj != 0);
QMetaObject::invokeMethod(obj, "setRoot");
- QVERIFY(qvariant_cast<QModelIndex>(obj->rootIndex()) == model.index(0,0));
+ QCOMPARE(qvariant_cast<QModelIndex>(obj->rootIndex()), model.index(0,0));
QMetaObject::invokeMethod(obj, "setRootToParent");
- QVERIFY(qvariant_cast<QModelIndex>(obj->rootIndex()) == QModelIndex());
+ QCOMPARE(qvariant_cast<QModelIndex>(obj->rootIndex()), QModelIndex());
QMetaObject::invokeMethod(obj, "setRoot");
- QVERIFY(qvariant_cast<QModelIndex>(obj->rootIndex()) == model.index(0,0));
+ QCOMPARE(qvariant_cast<QModelIndex>(obj->rootIndex()), model.index(0,0));
model.clear(); // will emit modelReset()
- QVERIFY(qvariant_cast<QModelIndex>(obj->rootIndex()) == QModelIndex());
+ QCOMPARE(qvariant_cast<QModelIndex>(obj->rootIndex()), QModelIndex());
delete obj;
}
@@ -628,7 +628,7 @@ void tst_qquickvisualdatamodel::childChanged()
model.item(1,0)->takeRow(1);
name = findItem<QQuickText>(contentItem, "display", 1);
- QVERIFY(name == 0);
+ QVERIFY(!name);
vdm->setRootIndex(QVariant::fromValue(QModelIndex()));
QCOMPARE(listview->count(), 3);
diff --git a/tests/auto/quick/qquickwindow/tst_qquickwindow.cpp b/tests/auto/quick/qquickwindow/tst_qquickwindow.cpp
index dfe5276e8e..f53ade9541 100644
--- a/tests/auto/quick/qquickwindow/tst_qquickwindow.cpp
+++ b/tests/auto/quick/qquickwindow/tst_qquickwindow.cpp
@@ -277,6 +277,10 @@ class tst_qquickwindow : public QQmlDataTest
{
Q_OBJECT
public:
+ tst_qquickwindow()
+ {
+ QQuickWindow::setDefaultAlphaBuffer(true);
+ }
private slots:
void initTestCase()
@@ -504,7 +508,7 @@ void tst_qquickwindow::touchEvent_basic()
window->resize(250, 250);
window->setPosition(100, 100);
window->show();
- QVERIFY(QTest::qWaitForWindowExposed(window));
+ QVERIFY(QTest::qWaitForWindowActive(window));
TestTouchItem *bottomItem = new TestTouchItem(window->contentItem());
bottomItem->setObjectName("Bottom Item");
@@ -635,7 +639,7 @@ void tst_qquickwindow::touchEvent_propagation()
window->setPosition(100, 100);
window->setTitle(QTest::currentTestFunction());
window->show();
- QVERIFY(QTest::qWaitForWindowExposed(window));
+ QVERIFY(QTest::qWaitForWindowActive(window));
TestTouchItem *bottomItem = new TestTouchItem(window->contentItem());
bottomItem->setObjectName("Bottom Item");
@@ -769,18 +773,18 @@ void tst_qquickwindow::touchEvent_cancel()
window->setPosition(100, 100);
window->setTitle(QTest::currentTestFunction());
window->show();
- QVERIFY(QTest::qWaitForWindowExposed(window));
+ QVERIFY(QTest::qWaitForWindowActive(window));
TestTouchItem *item = new TestTouchItem(window->contentItem());
item->setPosition(QPointF(50, 50));
item->setSize(QSizeF(150, 150));
- QPointF pos(10, 10);
- QTest::touchEvent(window, touchDevice).press(0, item->mapToScene(pos).toPoint(),window);
+ QPointF pos(50, 50);
+ QTest::touchEvent(window, touchDevice).press(0, item->mapToScene(pos).toPoint(), window);
QCoreApplication::processEvents();
QTRY_COMPARE(item->lastEvent.touchPoints.count(), 1);
- TouchEventData d = makeTouchData(QEvent::TouchBegin, window, Qt::TouchPointPressed, makeTouchPoint(item,pos));
+ TouchEventData d = makeTouchData(QEvent::TouchBegin, window, Qt::TouchPointPressed, makeTouchPoint(item, pos));
COMPARE_TOUCH_DATA(item->lastEvent, d);
item->reset();
@@ -803,7 +807,7 @@ void tst_qquickwindow::touchEvent_reentrant()
window->setPosition(100, 100);
window->setTitle(QTest::currentTestFunction());
window->show();
- QVERIFY(QTest::qWaitForWindowExposed(window));
+ QVERIFY(QTest::qWaitForWindowActive(window));
TestTouchItem *item = new TestTouchItem(window->contentItem());
@@ -978,7 +982,7 @@ void tst_qquickwindow::clearWindow()
delete window;
- QVERIFY(item->window() == 0);
+ QVERIFY(!item->window());
delete item;
}
@@ -993,7 +997,7 @@ void tst_qquickwindow::mouseFiltering()
window->setPosition(100, 100);
window->setTitle(QTest::currentTestFunction());
window->show();
- QVERIFY(QTest::qWaitForWindowExposed(window));
+ QVERIFY(QTest::qWaitForWindowActive(window));
TestTouchItem *bottomItem = new TestTouchItem(window->contentItem());
bottomItem->setObjectName("Bottom Item");
@@ -1081,17 +1085,25 @@ void tst_qquickwindow::defaultState()
void tst_qquickwindow::grab_data()
{
QTest::addColumn<bool>("visible");
- QTest::newRow("visible") << true;
- QTest::newRow("invisible") << false;
+ QTest::addColumn<bool>("alpha");
+ QTest::newRow("visible,opaque") << true << false;
+ QTest::newRow("invisible,opaque") << false << false;
+ QTest::newRow("visible,transparent") << true << true;
+ QTest::newRow("invisible,transparent") << false << true;
}
void tst_qquickwindow::grab()
{
QFETCH(bool, visible);
+ QFETCH(bool, alpha);
QQuickWindow window;
window.setTitle(QLatin1String(QTest::currentTestFunction()) + QLatin1Char(' ') + QLatin1String(QTest::currentDataTag()));
- window.setColor(Qt::red);
+ if (alpha) {
+ window.setColor(QColor(0, 0, 0, 0));
+ } else {
+ window.setColor(Qt::red);
+ }
window.resize(250, 250);
@@ -1103,9 +1115,14 @@ void tst_qquickwindow::grab()
}
QImage content = window.grabWindow();
- QCOMPARE(content.width(), window.width());
- QCOMPARE(content.height(), window.height());
- QCOMPARE((uint) content.convertToFormat(QImage::Format_RGB32).pixel(0, 0), (uint) 0xffff0000);
+ QCOMPARE(content.width(), int(window.width() * window.devicePixelRatio()));
+ QCOMPARE(content.height(), int(window.height() * window.devicePixelRatio()));
+
+ if (alpha) {
+ QCOMPARE((uint) content.convertToFormat(QImage::Format_ARGB32_Premultiplied).pixel(0, 0), (uint) 0x00000000);
+ } else {
+ QCOMPARE((uint) content.convertToFormat(QImage::Format_RGB32).pixel(0, 0), (uint) 0xffff0000);
+ }
}
void tst_qquickwindow::multipleWindows()
@@ -1232,7 +1249,7 @@ void tst_qquickwindow::headless()
if (threaded) {
QTRY_COMPARE(invalidated.size(), 1);
- QVERIFY(window->openglContext() == 0);
+ QVERIFY(!window->openglContext());
}
if (QGuiApplication::platformName() == QLatin1String("windows")
@@ -1242,7 +1259,7 @@ void tst_qquickwindow::headless()
// Destroy the native windowing system buffers
window->destroy();
- QVERIFY(window->handle() == 0);
+ QVERIFY(!window->handle());
// Show and verify that we are back and running
window->show();
@@ -1452,7 +1469,7 @@ void tst_qquickwindow::cursor()
clippedItem.setParentItem(&clippingItem);
window.show();
- QVERIFY(QTest::qWaitForWindowExposed(&window));
+ QVERIFY(QTest::qWaitForWindowActive(&window));
// Position the cursor over the parent and child item and the clipped section of clippedItem.
QTest::mouseMove(&window, QPoint(100, 100));
@@ -1609,7 +1626,7 @@ void tst_qquickwindow::hideThenDelete()
if (!persistentGL)
QVERIFY(openglDestroyed->size() > 0);
else
- QVERIFY(openglDestroyed->size() == 0);
+ QCOMPARE(openglDestroyed->size(), 0);
} else {
QCOMPARE(sgInvalidated->size(), 0);
QCOMPARE(openglDestroyed->size(), 0);
@@ -1693,7 +1710,7 @@ void tst_qquickwindow::requestActivate()
window1->requestActivate(); // and then transfer the focus to window1
QTRY_COMPARE(QGuiApplication::focusWindow(), window1.data());
- QVERIFY(window1->isActive() == true);
+ QVERIFY(window1->isActive());
QQuickItem *item = QQuickVisualTestUtil::findItem<QQuickItem>(window1->contentItem(), "item1");
QVERIFY(item);
@@ -1805,7 +1822,7 @@ void tst_qquickwindow::crashWhenHoverItemDeleted()
QVERIFY(!window.isNull());
window->setTitle(QTest::currentTestFunction());
window->show();
- QTest::qWaitForWindowExposed(window.data());
+ QTest::qWaitForWindowActive(window.data());
// 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
@@ -1844,7 +1861,7 @@ void tst_qquickwindow::qobjectEventFilter_touch()
window.setPosition(100, 100);
window.setTitle(QTest::currentTestFunction());
window.show();
- QVERIFY(QTest::qWaitForWindowExposed(&window));
+ QVERIFY(QTest::qWaitForWindowActive(&window));
TestTouchItem *item = new TestTouchItem(window.contentItem());
item->setSize(QSizeF(150, 150));
@@ -1870,7 +1887,7 @@ void tst_qquickwindow::qobjectEventFilter_key()
window.setPosition(100, 100);
window.setTitle(QTest::currentTestFunction());
window.show();
- QVERIFY(QTest::qWaitForWindowExposed(&window));
+ QVERIFY(QTest::qWaitForWindowActive(&window));
TestTouchItem *item = new TestTouchItem(window.contentItem());
item->setSize(QSizeF(150, 150));
@@ -1899,8 +1916,7 @@ void tst_qquickwindow::qobjectEventFilter_mouse()
window.setPosition(100, 100);
window.setTitle(QTest::currentTestFunction());
window.show();
-
- QVERIFY(QTest::qWaitForWindowExposed(&window));
+ QVERIFY(QTest::qWaitForWindowActive(&window));
TestTouchItem *item = new TestTouchItem(window.contentItem());
item->setSize(QSizeF(150, 150));
@@ -1909,6 +1925,7 @@ void tst_qquickwindow::qobjectEventFilter_mouse()
item->installEventFilter(&eventFilter);
QPoint point = item->mapToScene(QPointF(10, 10)).toPoint();
+ QTest::mouseMove(&window, point);
QTest::mousePress(&window, Qt::LeftButton, Qt::NoModifier, point);
QVERIFY(eventFilter.events.contains((int)QEvent::MouseButtonPress));
@@ -2048,44 +2065,108 @@ public:
static int deleted;
};
+class GlRenderJob : public QRunnable
+{
+public:
+ GlRenderJob(GLubyte *buf) : readPixel(buf), mutex(0), condition(0) {}
+ ~GlRenderJob() {}
+ void run() {
+ QOpenGLContext::currentContext()->functions()->glClearColor(1.0f, 0, 0, 1.0f);
+ QOpenGLContext::currentContext()->functions()->glClear(GL_COLOR_BUFFER_BIT);
+ QOpenGLContext::currentContext()->functions()->glReadPixels(0, 0, 1, 1, GL_RGBA,
+ GL_UNSIGNED_BYTE,
+ (void *)readPixel);
+ if (mutex) {
+ mutex->lock();
+ condition->wakeOne();
+ mutex->unlock();
+ }
+ }
+ GLubyte *readPixel;
+ QMutex *mutex;
+ QWaitCondition *condition;
+};
+
int RenderJob::deleted = 0;
void tst_qquickwindow::testRenderJob()
{
QList<QQuickWindow::RenderStage> completedJobs;
- QQuickWindow window;
- window.setTitle(QTest::currentTestFunction());
-
QQuickWindow::RenderStage stages[] = {
QQuickWindow::BeforeSynchronizingStage,
QQuickWindow::AfterSynchronizingStage,
QQuickWindow::BeforeRenderingStage,
QQuickWindow::AfterRenderingStage,
- QQuickWindow::AfterSwapStage
+ QQuickWindow::AfterSwapStage,
+ QQuickWindow::NoStage
};
- // Schedule the jobs
- for (int i=0; i<5; ++i)
- window.scheduleRenderJob(new RenderJob(stages[i], &completedJobs), stages[i]);
- window.show();
- QTRY_COMPARE(completedJobs.size(), 5);
+ const int numJobs = 6;
+
+ {
+ QQuickWindow window;
+ window.setTitle(QTest::currentTestFunction());
+ RenderJob::deleted = 0;
- for (int i=0; i<5; ++i) {
- QCOMPARE(completedJobs.at(i), stages[i]);
+ // Schedule the jobs
+ for (int i = 0; i < numJobs; ++i)
+ window.scheduleRenderJob(new RenderJob(stages[i], &completedJobs), stages[i]);
+ window.show();
+ QVERIFY(QTest::qWaitForWindowExposed(&window));
+
+ // All jobs should be deleted
+ QTRY_COMPARE(RenderJob::deleted, numJobs);
+
+ // The NoStage job is not completed, if it is issued when there is no context,
+ // but the rest will be queued and completed once relevant render stage is hit.
+ QCOMPARE(completedJobs.size(), numJobs - 1);
+
+ // Verify jobs were completed in correct order
+ for (int i = 0; i < numJobs - 1; ++i)
+ QCOMPARE(completedJobs.at(i), stages[i]);
+
+
+ // Check that NoStage job gets executed if it is scheduled when window is exposed
+ completedJobs.clear();
+ RenderJob::deleted = 0;
+ window.scheduleRenderJob(new RenderJob(QQuickWindow::NoStage, &completedJobs),
+ QQuickWindow::NoStage);
+ QTRY_COMPARE(RenderJob::deleted, 1);
+ QCOMPARE(completedJobs.size(), 1);
+
+ // Do a synchronized GL job.
+ GLubyte readPixel[4] = {0, 0, 0, 0};
+ GlRenderJob *glJob = new GlRenderJob(readPixel);
+ if (window.openglContext()->thread() != QThread::currentThread()) {
+ QMutex mutex;
+ QWaitCondition condition;
+ glJob->mutex = &mutex;
+ glJob->condition = &condition;
+ mutex.lock();
+ window.scheduleRenderJob(glJob, QQuickWindow::NoStage);
+ condition.wait(&mutex);
+ mutex.unlock();
+ } else {
+ window.scheduleRenderJob(glJob, QQuickWindow::NoStage);
+ }
+ QCOMPARE(int(readPixel[0]), 255);
+ QCOMPARE(int(readPixel[1]), 0);
+ QCOMPARE(int(readPixel[2]), 0);
+ QCOMPARE(int(readPixel[3]), 255);
}
- // Verify that jobs are deleted when window has not been rendered at all...
+ // Verify that jobs are deleted when window is not rendered at all
completedJobs.clear();
RenderJob::deleted = 0;
{
QQuickWindow window2;
- for (int i=0; i<5; ++i) {
+ for (int i = 0; i < numJobs; ++i) {
window2.scheduleRenderJob(new RenderJob(stages[i], &completedJobs), stages[i]);
}
}
+ QTRY_COMPARE(RenderJob::deleted, numJobs);
QCOMPARE(completedJobs.size(), 0);
- QCOMPARE(RenderJob::deleted, 5);
}
class EventCounter : public QQuickRectangle
@@ -2144,7 +2225,7 @@ void tst_qquickwindow::testHoverChildMouseEventFilter()
window.setPosition(100, 100);
window.setTitle(QTest::currentTestFunction());
window.show();
- QVERIFY(QTest::qWaitForWindowExposed(&window));
+ QVERIFY(QTest::qWaitForWindowActive(&window));
EventCounter *bottomItem = new EventCounter(window.contentItem());
bottomItem->setObjectName("Bottom Item");
diff --git a/tests/auto/quick/qquickxmllistmodel/tst_qquickxmllistmodel.cpp b/tests/auto/quick/qquickxmllistmodel/tst_qquickxmllistmodel.cpp
index 5372a4d3b3..09ceb7aebd 100644
--- a/tests/auto/quick/qquickxmllistmodel/tst_qquickxmllistmodel.cpp
+++ b/tests/auto/quick/qquickxmllistmodel/tst_qquickxmllistmodel.cpp
@@ -115,15 +115,15 @@ private:
QString xml;
if (!data.isEmpty()) {
- QStringList items = data.split(";");
+ QStringList items = data.split(QLatin1Char(';'));
foreach(const QString &item, items) {
if (item.isEmpty())
continue;
QVariantList variants;
xml += QLatin1String("<item>");
- QStringList fields = item.split(",");
+ QStringList fields = item.split(QLatin1Char(','));
foreach(const QString &field, fields) {
- QStringList values = field.split("=");
+ QStringList values = field.split(QLatin1Char('='));
if (values.count() != 2) {
qWarning() << "makeItemXmlAndData: invalid field:" << field;
continue;
@@ -760,9 +760,9 @@ void tst_qquickxmllistmodel::noKeysValueChanges()
QTRY_VERIFY(model->data(model->index(0, 0), roles.at(2)).toString() != QLatin1String("Football"));
QCOMPARE(model->data(model->index(0, 0), roles.at(2)).toString(), QLatin1String("AussieRules"));
- QVERIFY(spyInsert.count() == 0);
- QVERIFY(spyRemove.count() == 0);
- QVERIFY(spyCount.count() == 0);
+ QCOMPARE(spyInsert.count(), 0);
+ QCOMPARE(spyRemove.count(), 0);
+ QCOMPARE(spyCount.count(), 0);
QCOMPARE(model->rowCount(), 2);
@@ -857,22 +857,22 @@ void tst_qquickxmllistmodel::threading()
QModelIndex index = m1->index(i, 0);
QList<int> roles = m1->roleNames().keys();
std::sort(roles.begin(), roles.end());
- QCOMPARE(m1->data(index, roles.at(0)).toString(), QString("A" + QString::number(i)));
- QCOMPARE(m1->data(index, roles.at(1)).toString(), QString("1" + QString::number(i)));
+ QCOMPARE(m1->data(index, roles.at(0)).toString(), QLatin1Char('A') + QString::number(i));
+ QCOMPARE(m1->data(index, roles.at(1)).toString(), QLatin1Char('1') + QString::number(i));
QCOMPARE(m1->data(index, roles.at(2)).toString(), QString("Football"));
index = m2->index(i, 0);
roles = m2->roleNames().keys();
std::sort(roles.begin(), roles.end());
- QCOMPARE(m2->data(index, roles.at(0)).toString(), QString("B" + QString::number(i)));
- QCOMPARE(m2->data(index, roles.at(1)).toString(), QString("2" + QString::number(i)));
+ QCOMPARE(m2->data(index, roles.at(0)).toString(), QLatin1Char('B') + QString::number(i));
+ QCOMPARE(m2->data(index, roles.at(1)).toString(), QLatin1Char('2') + QString::number(i));
QCOMPARE(m2->data(index, roles.at(2)).toString(), QString("Athletics"));
index = m3->index(i, 0);
roles = m3->roleNames().keys();
std::sort(roles.begin(), roles.end());
- QCOMPARE(m3->data(index, roles.at(0)).toString(), QString("C" + QString::number(i)));
- QCOMPARE(m3->data(index, roles.at(1)).toString(), QString("3" + QString::number(i)));
+ QCOMPARE(m3->data(index, roles.at(0)).toString(), QLatin1Char('C') + QString::number(i));
+ QCOMPARE(m3->data(index, roles.at(1)).toString(), QLatin1Char('3') + QString::number(i));
QCOMPARE(m3->data(index, roles.at(2)).toString(), QString("Curling"));
}
}
@@ -940,7 +940,7 @@ void tst_qquickxmllistmodel::propertyChanges()
QCOMPARE(model->property("query").toString(), QString("/Pets"));
QCOMPARE(model->property("namespaceDeclarations").toString(), QString("declare namespace media=\"http://search.yahoo.com/mrss/\";"));
- QTRY_VERIFY(model->rowCount() == 1);
+ QTRY_COMPARE(model->rowCount(), 1);
QCOMPARE(sourceSpy.count(),1);
QCOMPARE(xmlSpy.count(),1);
@@ -957,7 +957,7 @@ void tst_qquickxmllistmodel::propertyChanges()
QCOMPARE(modelQuerySpy.count(),1);
QCOMPARE(namespaceDeclarationsSpy.count(),1);
- QTRY_VERIFY(model->rowCount() == 1);
+ QTRY_COMPARE(model->rowCount(), 1);
delete model;
}
diff --git a/tests/auto/quick/quick.pro b/tests/auto/quick/quick.pro
index c2b7a4cc8d..f25a28d45b 100644
--- a/tests/auto/quick/quick.pro
+++ b/tests/auto/quick/quick.pro
@@ -18,6 +18,7 @@ PRIVATETESTS += \
qquickapplication \
qquickbehaviors \
qquickfontloader \
+ qquickfontloader_static \
qquickfontmetrics \
qquickimageprovider \
qquickpath \
@@ -74,8 +75,8 @@ QUICKTESTS = \
qquickview \
qquickcanvasitem \
qquickscreen \
- touchmouse
-
+ touchmouse \
+ scenegraph
SUBDIRS += $$PUBLICTESTS
diff --git a/tests/auto/quick/scenegraph/data/mipmap_large.png b/tests/auto/quick/scenegraph/data/mipmap_large.png
index 9cb0fc7de1..1b6d99c45c 100644
--- a/tests/auto/quick/scenegraph/data/mipmap_large.png
+++ b/tests/auto/quick/scenegraph/data/mipmap_large.png
Binary files differ
diff --git a/tests/auto/quick/scenegraph/data/mipmap_small.png b/tests/auto/quick/scenegraph/data/mipmap_small.png
index dc5216fb6c..2e53012ef5 100644
--- a/tests/auto/quick/scenegraph/data/mipmap_small.png
+++ b/tests/auto/quick/scenegraph/data/mipmap_small.png
Binary files differ
diff --git a/tests/auto/quick/scenegraph/data/render_Mipmap.qml b/tests/auto/quick/scenegraph/data/render_Mipmap.qml
index 6d9191c5ac..9bd585373a 100644
--- a/tests/auto/quick/scenegraph/data/render_Mipmap.qml
+++ b/tests/auto/quick/scenegraph/data/render_Mipmap.qml
@@ -32,6 +32,7 @@
****************************************************************************/
import QtQuick 2.3
+import QtQuick.Window 2.2
/*
The test verifies that scaled down mipmapped images contains
@@ -39,8 +40,8 @@ import QtQuick 2.3
#samples: 2
PixelPos R G B Error-tolerance
- #final: 0 0 0.33 0.33 0.33 0.1
- #final: 1 0 0.33 0.33 0.33 0.1
+ #final: 0 0 0.25 0.25 0.25 0.1
+ #final: 1 0 0.25 0.25 0.25 0.1
*/
RenderTestBase
@@ -52,7 +53,7 @@ RenderTestBase
source: "mipmap_small.png"
mipmap: true
smooth: false
- scale: 1 / width;
+ scale: 1 / (width * Screen.devicePixelRatio);
}
Image {
@@ -62,7 +63,7 @@ RenderTestBase
source: "mipmap_large.png"
mipmap: true
smooth: false
- scale: 1 / width;
+ scale: 1 / (width * Screen.devicePixelRatio);
}
onEnterFinalStage: finalStageComplete = true;
diff --git a/tests/auto/quick/scenegraph/tst_scenegraph.cpp b/tests/auto/quick/scenegraph/tst_scenegraph.cpp
index d2d3643ca8..80672e234e 100644
--- a/tests/auto/quick/scenegraph/tst_scenegraph.cpp
+++ b/tests/auto/quick/scenegraph/tst_scenegraph.cpp
@@ -33,11 +33,17 @@
#include <qtest.h>
+#include <QOffscreenSurface>
+#include <QOpenGLContext>
+#include <QOpenGLFunctions>
+
#include <QtQuick>
+#include <QtQml>
#include <private/qopenglcontext_p.h>
+#include <private/qsgcontext_p.h>
+#include <private/qsgrenderloop_p.h>
-#include <QtQml>
class PerPixelRect : public QQuickItem
{
@@ -97,6 +103,12 @@ private slots:
void render();
void hideWithOtherContext();
+
+ void createTextureFromImage_data();
+ void createTextureFromImage();
+
+private:
+ bool m_brokenMipmapSupport;
};
template <typename T> class ScopedList : public QList<T> {
@@ -107,6 +119,42 @@ public:
void tst_SceneGraph::initTestCase()
{
qmlRegisterType<PerPixelRect>("SceneGraphTest", 1, 0, "PerPixelRect");
+
+ QSGRenderLoop *loop = QSGRenderLoop::instance();
+ qDebug() << "RenderLoop: " << loop;
+
+ QOpenGLContext context;
+ context.setFormat(loop->sceneGraphContext()->defaultSurfaceFormat());
+ context.create();
+ QSurfaceFormat format = context.format();
+
+ QOffscreenSurface surface;
+ surface.setFormat(format);
+ surface.create();
+ if (!context.makeCurrent(&surface))
+ qFatal("Failed to create a GL context...");
+
+ QOpenGLFunctions *funcs = QOpenGLContext::currentContext()->functions();
+ qDebug() << "R/G/B/A Buffers: " << format.redBufferSize() << format.greenBufferSize() << format.blueBufferSize() << format.alphaBufferSize();
+ qDebug() << "Depth Buffer: " << format.depthBufferSize();
+ qDebug() << "Stencil Buffer: " << format.stencilBufferSize();
+ qDebug() << "Samples: " << format.samples();
+ int textureSize;
+ funcs->glGetIntegerv(GL_MAX_TEXTURE_SIZE, &textureSize);
+ qDebug() << "Max Texture Size: " << textureSize;
+ qDebug() << "GL_VENDOR: " << (const char *) funcs->glGetString(GL_VENDOR);
+ qDebug() << "GL_RENDERER: " << (const char *) funcs->glGetString(GL_RENDERER);
+ QByteArray version = (const char *) funcs->glGetString(GL_VERSION);
+ qDebug() << "GL_VERSION: " << version.constData();
+ QSet<QByteArray> exts = context.extensions();
+ QByteArray all;
+ foreach (const QByteArray &e, exts) all += ' ' + e;
+ qDebug() << "GL_EXTENSIONS: " << all.constData();
+
+ m_brokenMipmapSupport = version.contains("Mesa 10.1") || version.contains("Mesa 9.");
+ qDebug() << "Broken Mipmap: " << m_brokenMipmapSupport;
+
+ context.doneCurrent();
}
QQuickView *createView(const QString &file, QWindow *parent = 0, int x = -1, int y = -1, int w = -1, int h = -1)
@@ -210,7 +258,7 @@ void tst_SceneGraph::manyWindows_data()
struct ShareContextResetter {
public:
- ~ShareContextResetter() { QOpenGLContextPrivate::setGlobalShareContext(0); }
+ ~ShareContextResetter() { qt_gl_set_global_share_context(0); }
};
void tst_SceneGraph::manyWindows()
@@ -223,7 +271,7 @@ void tst_SceneGraph::manyWindows()
ShareContextResetter cleanup; // To avoid dangling pointer in case of test-failure.
if (shared) {
QVERIFY(sharedGLContext.create());
- QOpenGLContextPrivate::setGlobalShareContext(&sharedGLContext);
+ qt_gl_set_global_share_context(&sharedGLContext);
}
QScopedPointer<QWindow> parent;
@@ -297,8 +345,8 @@ struct Sample {
.arg(color.redF()).arg(color.greenF()).arg(color.blueF());
}
- bool check(const QImage &image) {
- QColor color(image.pixel(x, y));
+ bool check(const QImage &image, qreal scale) {
+ QColor color(image.pixel(x * scale, y * scale));
return qAbs(color.redF() - r) <= tolerance
&& qAbs(color.greenF() - g) <= tolerance
&& qAbs(color.blueF() - b) <= tolerance;
@@ -368,11 +416,11 @@ void tst_SceneGraph::render_data()
<< "data/render_BreakOpacityBatch.qml"
<< "data/render_OutOfFloatRange.qml"
<< "data/render_StackingOrder.qml"
- << "data/render_Mipmap.qml"
<< "data/render_ImageFiltering.qml"
<< "data/render_bug37422.qml"
- << "data/render_OpacityThroughBatchRoot.qml"
- ;
+ << "data/render_OpacityThroughBatchRoot.qml";
+ if (!m_brokenMipmapSupport)
+ files << "data/render_Mipmap.qml";
QRegExp sampleCount("#samples: *(\\d+)");
// X:int Y:int R:float G:float B:float Error:float
@@ -428,11 +476,18 @@ void tst_SceneGraph::render()
view.show();
QVERIFY(QTest::qWaitForWindowExposed(&view));
+ // We're checking actual pixels, so scale up the sample point to the top-left of the
+ // 2x2 pixel block and hope that this is good enough. Ideally, view and content
+ // would be in identical coordinate space, meaning pixels, but we're not in an
+ // ideal world.
+ // Just keep this in mind when writing tests.
+ qreal scale = view.devicePixelRatio();
+
// Grab the window and check all our base stage samples
QImage content = view.grabWindow();
for (int i=0; i<baseStage.size(); ++i) {
Sample sample = baseStage.at(i);
- QVERIFY2(sample.check(content), qPrintable(sample.toString(content)));
+ QVERIFY2(sample.check(content, scale), qPrintable(sample.toString(content)));
}
// Put the qml file into the final stage and wait for it to
@@ -445,7 +500,7 @@ void tst_SceneGraph::render()
content = view.grabWindow();
for (int i=0; i<finalStage.size(); ++i) {
Sample sample = finalStage.at(i);
- QVERIFY2(sample.check(content), qPrintable(sample.toString(content)));
+ QVERIFY2(sample.check(content, scale), qPrintable(sample.toString(content)));
}
}
@@ -482,6 +537,34 @@ void tst_SceneGraph::hideWithOtherContext()
QVERIFY(!renderingOnMainThread || QOpenGLContext::currentContext() != &context);
}
+void tst_SceneGraph::createTextureFromImage_data()
+{
+ QImage rgba(64, 64, QImage::Format_ARGB32_Premultiplied);
+ QImage rgb(64, 64, QImage::Format_RGB32);
+
+ QTest::addColumn<QImage>("image");
+ QTest::addColumn<uint>("flags");
+ QTest::addColumn<bool>("expectedAlpha");
+
+ QTest::newRow("rgb") << rgb << uint(0) << false;
+ QTest::newRow("argb") << rgba << uint(0) << true;
+ QTest::newRow("rgb,alpha") << rgb << uint(QQuickWindow::TextureHasAlphaChannel) << false;
+ QTest::newRow("argb,alpha") << rgba << uint(QQuickWindow::TextureHasAlphaChannel) << true;
+ QTest::newRow("rgb,!alpha") << rgb << uint(QQuickWindow::TextureIsOpaque) << false;
+ QTest::newRow("argb,!alpha") << rgba << uint(QQuickWindow::TextureIsOpaque) << false;
+}
+
+void tst_SceneGraph::createTextureFromImage()
+{
+ QFETCH(QImage, image);
+ QFETCH(uint, flags);
+ QFETCH(bool, expectedAlpha);
+
+ QQuickView view;
+ QScopedPointer<QSGTexture> texture(view.createTextureFromImage(image, (QQuickWindow::CreateTextureOptions) flags));
+ QCOMPARE(texture->hasAlphaChannel(), expectedAlpha);
+}
+
#include "tst_scenegraph.moc"
diff --git a/tests/auto/quick/shared/viewtestutil.cpp b/tests/auto/quick/shared/viewtestutil.cpp
index 5b9111d448..1330cbccc9 100644
--- a/tests/auto/quick/shared/viewtestutil.cpp
+++ b/tests/auto/quick/shared/viewtestutil.cpp
@@ -72,18 +72,30 @@ void QQuickViewTestUtil::moveMouseAway(QQuickView *window)
#endif
}
+void QQuickViewTestUtil::moveAndRelease(QQuickView *window, const QPoint &position)
+{
+ QTest::mouseMove(window, position);
+ QTest::mouseRelease(window, Qt::LeftButton, 0, position);
+}
+
+void QQuickViewTestUtil::moveAndPress(QQuickView *window, const QPoint &position)
+{
+ QTest::mouseMove(window, position);
+ QTest::mousePress(window, Qt::LeftButton, 0, position);
+}
+
void QQuickViewTestUtil::flick(QQuickView *window, const QPoint &from, const QPoint &to, int duration)
{
const int pointCount = 5;
QPoint diff = to - from;
// send press, five equally spaced moves, and release.
- QTest::mousePress(window, Qt::LeftButton, 0, from);
+ moveAndPress(window, from);
for (int i = 0; i < pointCount; ++i)
QTest::mouseMove(window, from + (i+1)*diff/pointCount, duration / pointCount);
- QTest::mouseRelease(window, Qt::LeftButton, 0, to);
+ moveAndRelease(window, to);
QTest::qWait(50);
}
@@ -265,11 +277,11 @@ void QQuickViewTestUtil::QaimModel::resetItems(const QList<QPair<QString, QStrin
void QQuickViewTestUtil::QaimModel::matchAgainst(const QList<QPair<QString, QString> > &other, const QString &error1, const QString &error2) {
for (int i=0; i<other.count(); i++) {
QVERIFY2(list.contains(other[i]),
- QTest::toString(other[i].first + " " + other[i].second + " " + error1));
+ QTest::toString(other[i].first + QLatin1Char(' ') + other[i].second + QLatin1Char(' ') + error1));
}
for (int i=0; i<list.count(); i++) {
QVERIFY2(other.contains(list[i]),
- QTest::toString(list[i].first + " " + list[i].second + " " + error2));
+ QTest::toString(list[i].first + QLatin1Char(' ') + list[i].second + QLatin1Char(' ') + error2));
}
}
diff --git a/tests/auto/quick/shared/viewtestutil.h b/tests/auto/quick/shared/viewtestutil.h
index 8c5f5c54e6..1643eca979 100644
--- a/tests/auto/quick/shared/viewtestutil.h
+++ b/tests/auto/quick/shared/viewtestutil.h
@@ -48,6 +48,8 @@ namespace QQuickViewTestUtil
void centerOnScreen(QQuickView *window, const QSize &size);
void centerOnScreen(QQuickView *window);
void moveMouseAway(QQuickView *window);
+ void moveAndPress(QQuickView *window, const QPoint &position);
+ void moveAndRelease(QQuickView *window, const QPoint &position);
QList<int> adjustIndexesForAddDisplaced(const QList<int> &indexes, int index, int count);
QList<int> adjustIndexesForMove(const QList<int> &indexes, int from, int to, int count);
diff --git a/tests/auto/quick/touchmouse/data/hoverMouseAreas.qml b/tests/auto/quick/touchmouse/data/hoverMouseAreas.qml
new file mode 100644
index 0000000000..1bdd0b3caf
--- /dev/null
+++ b/tests/auto/quick/touchmouse/data/hoverMouseAreas.qml
@@ -0,0 +1,39 @@
+import QtQuick 2.4
+
+Item {
+ width: 500
+ height: 500
+
+ Rectangle {
+ width: 300
+ height: 90
+ color: mouseArea1.containsMouse ? "red" : "grey"
+ x: 100
+ y: 100
+
+ MouseArea {
+ id: mouseArea1
+ objectName: "mouseArea1"
+ anchors.fill: parent
+ hoverEnabled: true
+ onPressed: parent.border.width = 4
+ onReleased: parent.border.width = 0
+ }
+ }
+ Rectangle {
+ width: 300
+ height: 100
+ color: mouseArea2.containsMouse ? "red" : "lightblue"
+ x: 100
+ y: 200
+
+ MouseArea {
+ id: mouseArea2
+ objectName: "mouseArea2"
+ anchors.fill: parent
+ hoverEnabled: true
+ onPressed: parent.border.width = 4
+ onReleased: parent.border.width = 0
+ }
+ }
+}
diff --git a/tests/auto/quick/touchmouse/tst_touchmouse.cpp b/tests/auto/quick/touchmouse/tst_touchmouse.cpp
index 539bbb4703..e14b7d7c84 100644
--- a/tests/auto/quick/touchmouse/tst_touchmouse.cpp
+++ b/tests/auto/quick/touchmouse/tst_touchmouse.cpp
@@ -161,6 +161,8 @@ private slots:
void touchGrabCausesMouseUngrab();
+ void hoverEnabled();
+
protected:
bool eventFilter(QObject *, QEvent *event)
{
@@ -863,7 +865,7 @@ void tst_TouchMouse::pinchOnFlickable()
QVERIFY(rect);
// flickable - single touch point
- QVERIFY(flickable->contentX() == 0.0);
+ QCOMPARE(flickable->contentX(), 0.0);
QPoint p = QPoint(100, 100);
QTest::touchEvent(window, device).press(0, p, window);
QQuickTouchUtils::flush(window);
@@ -945,7 +947,7 @@ void tst_TouchMouse::flickableOnPinch()
QVERIFY(rect);
// flickable - single touch point
- QVERIFY(flickable->contentX() == 0.0);
+ QCOMPARE(flickable->contentX(), 0.0);
QPoint p = QPoint(100, 100);
QTest::touchEvent(window, device).press(0, p, window);
QQuickTouchUtils::flush(window);
@@ -1025,7 +1027,7 @@ void tst_TouchMouse::mouseOnFlickableOnPinch()
QVERIFY(rect);
// flickable - single touch point
- QVERIFY(flickable->contentX() == 0.0);
+ QCOMPARE(flickable->contentX(), 0.0);
QPoint p = QPoint(100, 100);
QTest::touchEvent(window, device).press(0, p, window);
QQuickTouchUtils::flush(window);
@@ -1232,6 +1234,93 @@ void tst_TouchMouse::touchGrabCausesMouseUngrab()
delete window;
}
+void tst_TouchMouse::hoverEnabled()
+{
+ // QTouchDevice *device = new QTouchDevice;
+ // device->setType(QTouchDevice::TouchScreen);
+ // QWindowSystemInterface::registerTouchDevice(device);
+
+ QQuickView *window = createView();
+ window->setSource(testFileUrl("hoverMouseAreas.qml"));
+
+ window->show();
+ window->requestActivate();
+ QVERIFY(QTest::qWaitForWindowExposed(window));
+ QQuickItem *root = window->rootObject();
+ QVERIFY(root != 0);
+
+ QQuickMouseArea *mouseArea1 = root->findChild<QQuickMouseArea*>("mouseArea1");
+ QVERIFY(mouseArea1 != 0);
+
+ QQuickMouseArea *mouseArea2 = root->findChild<QQuickMouseArea*>("mouseArea2");
+ QVERIFY(mouseArea2 != 0);
+
+ QSignalSpy enterSpy1(mouseArea1, SIGNAL(entered()));
+ QSignalSpy exitSpy1(mouseArea1, SIGNAL(exited()));
+ QSignalSpy clickSpy1(mouseArea1, SIGNAL(clicked(QQuickMouseEvent *)));
+
+ QSignalSpy enterSpy2(mouseArea2, SIGNAL(entered()));
+ QSignalSpy exitSpy2(mouseArea2, SIGNAL(exited()));
+ QSignalSpy clickSpy2(mouseArea2, SIGNAL(clicked(QQuickMouseEvent *)));
+
+ QPoint p0(50, 50);
+ QPoint p1(150, 150);
+ QPoint p2(150, 250);
+
+ // ------------------------- Mouse move to mouseArea1
+ QTest::mouseMove(window, p1);
+
+ QVERIFY(enterSpy1.count() == 1);
+ QVERIFY(mouseArea1->hovered());
+ QVERIFY(!mouseArea2->hovered());
+
+ // ------------------------- Touch click on mouseArea1
+ QTest::touchEvent(window, device).press(0, p1, window);
+
+ QVERIFY(enterSpy1.count() == 1);
+ QVERIFY(enterSpy2.count() == 0);
+ QVERIFY(mouseArea1->pressed());
+ QVERIFY(mouseArea1->hovered());
+ QVERIFY(!mouseArea2->hovered());
+
+ QTest::touchEvent(window, device).release(0, p1, window);
+ QVERIFY(clickSpy1.count() == 1);
+ QVERIFY(mouseArea1->hovered());
+ QVERIFY(!mouseArea2->hovered());
+
+ // ------------------------- Touch click on mouseArea2
+ QTest::touchEvent(window, device).press(0, p2, window);
+
+ QVERIFY(mouseArea1->hovered());
+ QVERIFY(mouseArea2->hovered());
+ QVERIFY(mouseArea2->pressed());
+ QVERIFY(enterSpy1.count() == 1);
+ QVERIFY(enterSpy2.count() == 1);
+
+ QTest::touchEvent(window, device).release(0, p2, window);
+
+ QVERIFY(clickSpy2.count() == 1);
+ QVERIFY(mouseArea1->hovered());
+ QVERIFY(!mouseArea2->hovered());
+ QVERIFY(exitSpy1.count() == 0);
+ QVERIFY(exitSpy2.count() == 1);
+
+ // ------------------------- Another touch click on mouseArea1
+ QTest::touchEvent(window, device).press(0, p1, window);
+
+ QVERIFY(enterSpy1.count() == 1);
+ QVERIFY(enterSpy2.count() == 1);
+ QVERIFY(mouseArea1->pressed());
+ QVERIFY(mouseArea1->hovered());
+ QVERIFY(!mouseArea2->hovered());
+
+ QTest::touchEvent(window, device).release(0, p1, window);
+ QVERIFY(clickSpy1.count() == 2);
+ QVERIFY(mouseArea1->hovered());
+ QVERIFY(!mouseArea1->pressed());
+ QVERIFY(!mouseArea2->hovered());
+}
+
QTEST_MAIN(tst_TouchMouse)
#include "tst_touchmouse.moc"