aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/quick
diff options
context:
space:
mode:
authorLiang Qi <liang.qi@qt.io>2016-05-13 00:28:14 +0200
committerLiang Qi <liang.qi@qt.io>2016-05-13 08:28:27 +0200
commitae745746a666134d9e9258b8c2ff00540624d835 (patch)
tree8294fffa3d752d61f79004fb04e21e927472fd8f /tests/auto/quick
parenta7b383ab989e74ef552c2ef9c38377e065f1ab0e (diff)
parent531d00c1909527cb1bc28f17197267ccde408b0c (diff)
Merge remote-tracking branch 'origin/5.7' into dev
Conflicts: src/qml/jsapi/qjsengine.cpp src/qml/qml/qqmlengine_p.h src/quick/items/qquickanchors.cpp src/quick/items/qquickanimatedimage_p_p.h src/quick/items/qquickitem_p.h tests/auto/qml/qqmlecmascript/testtypes.h tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp tests/benchmarks/qml/creation/tst_creation.cpp Change-Id: I65861e32f16e8a04c7090a90231627e1ebf6ba6f
Diffstat (limited to 'tests/auto/quick')
-rw-r--r--tests/auto/quick/qquickanchors/tst_qquickanchors.cpp33
-rw-r--r--tests/auto/quick/qquickanimatedimage/tst_qquickanimatedimage.cpp29
-rw-r--r--tests/auto/quick/qquickcanvasitem/data/tst_imagedata.qml22
-rw-r--r--tests/auto/quick/qquickcanvasitem/qquickcanvasitem.pro1
-rw-r--r--tests/auto/quick/qquickdrag/tst_qquickdrag.cpp46
-rw-r--r--tests/auto/quick/qquickpathview/data/movementDirection.qml43
-rw-r--r--tests/auto/quick/qquickpathview/tst_qquickpathview.cpp68
-rw-r--r--tests/auto/quick/qquickstates/tst_qquickstates.cpp4
-rw-r--r--tests/auto/quick/qquicktext/tst_qquicktext.cpp2
-rw-r--r--tests/auto/quick/qquicktextinput/tst_qquicktextinput.cpp2
-rw-r--r--tests/auto/quick/quick.pro1
11 files changed, 224 insertions, 27 deletions
diff --git a/tests/auto/quick/qquickanchors/tst_qquickanchors.cpp b/tests/auto/quick/qquickanchors/tst_qquickanchors.cpp
index ab111a6cd3..77fa1292c4 100644
--- a/tests/auto/quick/qquickanchors/tst_qquickanchors.cpp
+++ b/tests/auto/quick/qquickanchors/tst_qquickanchors.cpp
@@ -39,7 +39,6 @@
#include "../shared/visualtestutil.h"
Q_DECLARE_METATYPE(QQuickAnchors::Anchor)
-Q_DECLARE_METATYPE(QQuickAnchorLine::AnchorLine)
using namespace QQuickVisualTestUtil;
@@ -351,14 +350,13 @@ void tst_qquickanchors::illegalSets_data()
void tst_qquickanchors::reset()
{
QFETCH(QString, side);
- QFETCH(QQuickAnchorLine::AnchorLine, anchorLine);
- QFETCH(QQuickAnchors::Anchor, usedAnchor);
+ QFETCH(QQuickAnchors::Anchor, anchor);
QQuickItem *baseItem = new QQuickItem;
- QQuickAnchorLine anchor;
- anchor.item = baseItem;
- anchor.anchorLine = anchorLine;
+ QQuickAnchorLine anchorLine;
+ anchorLine.item = baseItem;
+ anchorLine.anchorLine = anchor;
QQuickItem *item = new QQuickItem;
QQuickItemPrivate *itemPrivate = QQuickItemPrivate::get(item);
@@ -366,11 +364,11 @@ void tst_qquickanchors::reset()
const QMetaObject *meta = itemPrivate->anchors()->metaObject();
QMetaProperty p = meta->property(meta->indexOfProperty(side.toUtf8().constData()));
- QVERIFY(p.write(itemPrivate->anchors(), qVariantFromValue(anchor)));
- QCOMPARE(itemPrivate->anchors()->usedAnchors().testFlag(usedAnchor), true);
+ QVERIFY(p.write(itemPrivate->anchors(), qVariantFromValue(anchorLine)));
+ QCOMPARE(itemPrivate->anchors()->usedAnchors().testFlag(anchor), true);
QVERIFY(p.reset(itemPrivate->anchors()));
- QCOMPARE(itemPrivate->anchors()->usedAnchors().testFlag(usedAnchor), false);
+ QCOMPARE(itemPrivate->anchors()->usedAnchors().testFlag(anchor), false);
delete item;
delete baseItem;
@@ -379,17 +377,16 @@ void tst_qquickanchors::reset()
void tst_qquickanchors::reset_data()
{
QTest::addColumn<QString>("side");
- QTest::addColumn<QQuickAnchorLine::AnchorLine>("anchorLine");
- QTest::addColumn<QQuickAnchors::Anchor>("usedAnchor");
+ QTest::addColumn<QQuickAnchors::Anchor>("anchor");
- QTest::newRow("left") << "left" << QQuickAnchorLine::Left << QQuickAnchors::LeftAnchor;
- QTest::newRow("top") << "top" << QQuickAnchorLine::Top << QQuickAnchors::TopAnchor;
- QTest::newRow("right") << "right" << QQuickAnchorLine::Right << QQuickAnchors::RightAnchor;
- QTest::newRow("bottom") << "bottom" << QQuickAnchorLine::Bottom << QQuickAnchors::BottomAnchor;
+ QTest::newRow("left") << "left" << QQuickAnchors::LeftAnchor;
+ QTest::newRow("top") << "top" << QQuickAnchors::TopAnchor;
+ QTest::newRow("right") << "right" << QQuickAnchors::RightAnchor;
+ QTest::newRow("bottom") << "bottom" << QQuickAnchors::BottomAnchor;
- QTest::newRow("hcenter") << "horizontalCenter" << QQuickAnchorLine::HCenter << QQuickAnchors::HCenterAnchor;
- QTest::newRow("vcenter") << "verticalCenter" << QQuickAnchorLine::VCenter << QQuickAnchors::VCenterAnchor;
- QTest::newRow("baseline") << "baseline" << QQuickAnchorLine::Baseline << QQuickAnchors::BaselineAnchor;
+ QTest::newRow("hcenter") << "horizontalCenter" << QQuickAnchors::HCenterAnchor;
+ QTest::newRow("vcenter") << "verticalCenter" << QQuickAnchors::VCenterAnchor;
+ QTest::newRow("baseline") << "baseline" << QQuickAnchors::BaselineAnchor;
}
void tst_qquickanchors::resetConvenience()
diff --git a/tests/auto/quick/qquickanimatedimage/tst_qquickanimatedimage.cpp b/tests/auto/quick/qquickanimatedimage/tst_qquickanimatedimage.cpp
index b0f0f886a0..b34f58f7c4 100644
--- a/tests/auto/quick/qquickanimatedimage/tst_qquickanimatedimage.cpp
+++ b/tests/auto/quick/qquickanimatedimage/tst_qquickanimatedimage.cpp
@@ -60,6 +60,7 @@ private slots:
void remote_data();
void sourceSize();
void sourceSizeChanges();
+ void sourceSizeChanges_intermediate();
void sourceSizeReadOnly();
void invalidSource();
void qtbug_16520();
@@ -205,16 +206,12 @@ void tst_qquickanimatedimage::mirror_notRunning()
int frame = anim->currentFrame();
bool playing = anim->isPlaying();
- bool paused = anim->isPlaying();
+ bool paused = anim->isPaused();
anim->setProperty("mirror", true);
screenshot = window.grabWindow();
screenshot.save("screen.png");
-#if defined(Q_OS_WIN)
- // QTBUG-36717
- QSKIP("This test is failing in the CI system under mysterious circumstances");
-#endif
QCOMPARE(screenshot, expected);
// mirroring should not change the current frame or playing status
@@ -374,6 +371,28 @@ void tst_qquickanimatedimage::sourceSizeChanges()
delete anim;
}
+void tst_qquickanimatedimage::sourceSizeChanges_intermediate()
+{
+ QQmlEngine engine;
+ QQmlComponent component(&engine);
+ component.setData("import QtQuick 2.0\nAnimatedImage { readonly property int testWidth: status === AnimatedImage.Ready ? sourceSize.width : -1; source: srcImage }", QUrl::fromLocalFile(""));
+ QTRY_VERIFY(component.isReady());
+ QQmlContext *ctxt = engine.rootContext();
+ ctxt->setContextProperty("srcImage", "");
+
+ QScopedPointer<QQuickAnimatedImage> anim(qobject_cast<QQuickAnimatedImage*>(component.create()));
+ QVERIFY(anim != 0);
+
+ ctxt->setContextProperty("srcImage", testFileUrl("hearts.gif"));
+ QTRY_COMPARE(anim->status(), QQuickAnimatedImage::Ready);
+ QTRY_COMPARE(anim->property("testWidth").toInt(), anim->sourceSize().width());
+
+ ctxt->setContextProperty("srcImage", testFileUrl("hearts_copy.gif"));
+ QTRY_COMPARE(anim->status(), QQuickAnimatedImage::Ready);
+ QTRY_COMPARE(anim->property("testWidth").toInt(), anim->sourceSize().width());
+}
+
+
void tst_qquickanimatedimage::qtbug_16520()
{
TestHTTPServer server;
diff --git a/tests/auto/quick/qquickcanvasitem/data/tst_imagedata.qml b/tests/auto/quick/qquickcanvasitem/data/tst_imagedata.qml
new file mode 100644
index 0000000000..7095602ea2
--- /dev/null
+++ b/tests/auto/quick/qquickcanvasitem/data/tst_imagedata.qml
@@ -0,0 +1,22 @@
+import QtQuick 2.0
+import QtTest 1.1
+
+CanvasTestCase {
+ id:testCase
+ name: "imagedata"
+ function init_data() { return testData("2d"); }
+ function test_rounding(row) {
+ var canvas = createCanvasObject(row);
+ var ctx = canvas.getContext('2d');
+ var size = 17
+ ctx.reset();
+ ctx.fillStyle = Qt.rgba(0.7, 0.8, 0.9, 1.0);
+ ctx.fillRect(0, 0, size, size);
+
+ var center = size / 2;
+ var imageData = ctx.getImageData(center, center, center, center);
+ comparePixel(ctx, center, center, imageData.data[0], imageData.data[1], imageData.data[2], imageData.data[3]);
+
+ canvas.destroy();
+ }
+}
diff --git a/tests/auto/quick/qquickcanvasitem/qquickcanvasitem.pro b/tests/auto/quick/qquickcanvasitem/qquickcanvasitem.pro
index 3c41d498e5..c6d2a69f8c 100644
--- a/tests/auto/quick/qquickcanvasitem/qquickcanvasitem.pro
+++ b/tests/auto/quick/qquickcanvasitem/qquickcanvasitem.pro
@@ -25,6 +25,7 @@ OTHER_FILES += \
data/tst_arcto.qml \
data/tst_arc.qml \
data/tst_context.qml \
+ data/tst_imagedata.qml \
data/CanvasTestCase.qml \
data/CanvasComponent.qml \
data/tst_image.qml \
diff --git a/tests/auto/quick/qquickdrag/tst_qquickdrag.cpp b/tests/auto/quick/qquickdrag/tst_qquickdrag.cpp
index a7b5f4943e..6a919d048e 100644
--- a/tests/auto/quick/qquickdrag/tst_qquickdrag.cpp
+++ b/tests/auto/quick/qquickdrag/tst_qquickdrag.cpp
@@ -139,6 +139,8 @@ private slots:
void cleanupTestCase();
void active();
+ void setActive_data();
+ void setActive();
void drop();
void move();
void parentChange();
@@ -374,6 +376,50 @@ void tst_QQuickDrag::active()
QCOMPARE(dropTarget.enterEvents, 0); QCOMPARE(dropTarget.leaveEvents, 0); QCOMPARE(dropTarget.moveEvents, 0);
}
+void tst_QQuickDrag::setActive_data()
+{
+ QTest::addColumn<QString>("dragType");
+
+ QTest::newRow("default") << "";
+ QTest::newRow("internal") << "Drag.dragType: Drag.Internal";
+ QTest::newRow("none") << "Drag.dragType: Drag.None";
+ /* We don't test Drag.Automatic, because that causes QDrag::exec() to be
+ * invoked, and on some platforms tha's implemented by running a main loop
+ * until the drag has finished -- and at that point, the Drag.active will
+ * be false again. */
+}
+
+// QTBUG-52540
+void tst_QQuickDrag::setActive()
+{
+ QFETCH(QString, dragType);
+
+ QQuickWindow window;
+ TestDropTarget dropTarget(window.contentItem());
+ dropTarget.setSize(QSizeF(100, 100));
+ QQmlComponent component(&engine);
+ component.setData(
+ "import QtQuick 2.0\n"
+ "Item {\n"
+ "property bool dragActive: Drag.active\n"
+ "property Item dragTarget: Drag.target\n" +
+ dragType.toUtf8() + "\n"
+ "x: 50; y: 50\n"
+ "width: 10; height: 10\n"
+ "}", QUrl());
+ QScopedPointer<QObject> object(component.create());
+ QQuickItem *item = qobject_cast<QQuickItem *>(object.data());
+ QVERIFY(item);
+ item->setParentItem(&dropTarget);
+
+ QCOMPARE(evaluate<bool>(item, "Drag.active"), false);
+ QCOMPARE(evaluate<bool>(item, "dragActive"), false);
+
+ evaluate<void>(item, "Drag.active = true");
+ QCOMPARE(evaluate<bool>(item, "Drag.active"), true);
+ QCOMPARE(evaluate<bool>(item, "dragActive"), true);
+}
+
void tst_QQuickDrag::drop()
{
QQuickWindow window;
diff --git a/tests/auto/quick/qquickpathview/data/movementDirection.qml b/tests/auto/quick/qquickpathview/data/movementDirection.qml
new file mode 100644
index 0000000000..fce914dd68
--- /dev/null
+++ b/tests/auto/quick/qquickpathview/data/movementDirection.qml
@@ -0,0 +1,43 @@
+import QtQuick 2.0
+
+Item {
+ id: root
+ width: 320; height: 480
+
+ PathView {
+ id: view
+ objectName: "view"
+ anchors.fill: parent
+
+ model: ListModel {
+ ListElement { lColor: "red" }
+ ListElement { lColor: "green" }
+ ListElement { lColor: "yellow" }
+ ListElement { lColor: "blue" }
+ ListElement { lColor: "purple" }
+ ListElement { lColor: "gray" }
+ ListElement { lColor: "brown" }
+ ListElement { lColor: "thistle" }
+ }
+
+ delegate: Component {
+ id: photoDelegate
+ Rectangle {
+ id: wrapper
+ objectName: "wrapper"
+ width: 40; height: 40; color: lColor
+
+ Text { text: index }
+ }
+ }
+
+ snapMode: PathView.SnapToItem
+ highlightMoveDuration: 1000
+ path: Path {
+ startX: 0+20; startY: root.height/2
+ PathLine { x: root.width*2; y: root.height/2 }
+ }
+
+ Text { text: "Offset: " + view.offset }
+ }
+}
diff --git a/tests/auto/quick/qquickpathview/tst_qquickpathview.cpp b/tests/auto/quick/qquickpathview/tst_qquickpathview.cpp
index 51c772f540..6761313210 100644
--- a/tests/auto/quick/qquickpathview/tst_qquickpathview.cpp
+++ b/tests/auto/quick/qquickpathview/tst_qquickpathview.cpp
@@ -137,6 +137,8 @@ private slots:
void jsArrayChange();
void qtbug42716();
void addCustomAttribute();
+ void movementDirection_data();
+ void movementDirection();
};
class TestObject : public QObject
@@ -2383,6 +2385,72 @@ void tst_QQuickPathView::addCustomAttribute()
window->show();
}
+void tst_QQuickPathView::movementDirection_data()
+{
+ QTest::addColumn<QQuickPathView::MovementDirection>("movementdirection");
+ QTest::addColumn<int>("toidx");
+ QTest::addColumn<qreal>("fromoffset");
+ QTest::addColumn<qreal>("tooffset");
+
+ QTest::newRow("default-shortest") << QQuickPathView::Shortest << 3 << 8.0 << 5.0;
+ QTest::newRow("negative") << QQuickPathView::Negative << 2 << 0.0 << 6.0;
+ QTest::newRow("positive") << QQuickPathView::Positive << 3 << 8.0 << 5.0;
+
+}
+
+static void verify_offsets(QQuickPathView *pathview, int toidx, qreal fromoffset, qreal tooffset)
+{
+ pathview->setCurrentIndex(toidx);
+ bool started = false;
+ qreal first, second;
+ QTest::qWait(100);
+ first = pathview->offset();
+ while (1) {
+ QTest::qWait(10); // highlightMoveDuration: 1000
+ second = pathview->offset();
+ if (!started && second != first) { // animation started
+ started = true;
+ break;
+ }
+ }
+
+ if (tooffset > fromoffset) {
+ QVERIFY(fromoffset <= first);
+ QVERIFY(first <= second);
+ QVERIFY(second <= tooffset);
+ } else {
+ QVERIFY(fromoffset >= first);
+ QVERIFY(first >= second);
+ QVERIFY(second >= tooffset);
+ }
+ QTRY_COMPARE(pathview->offset(), tooffset);
+}
+
+void tst_QQuickPathView::movementDirection()
+{
+ QFETCH(QQuickPathView::MovementDirection, movementdirection);
+ QFETCH(int, toidx);
+ QFETCH(qreal, fromoffset);
+ QFETCH(qreal, tooffset);
+
+ QScopedPointer<QQuickView> window(createView());
+ QQuickViewTestUtil::moveMouseAway(window.data());
+ window->setSource(testFileUrl("movementDirection.qml"));
+ window->show();
+ window->requestActivate();
+ QVERIFY(QTest::qWaitForWindowActive(window.data()));
+ QCOMPARE(window.data(), qGuiApp->focusWindow());
+
+ QQuickPathView *pathview = window->rootObject()->findChild<QQuickPathView*>("view");
+ QVERIFY(pathview != 0);
+ QVERIFY(pathview->offset() == 0.0);
+ QVERIFY(pathview->currentIndex() == 0);
+ pathview->setMovementDirection(movementdirection);
+ QVERIFY(pathview->movementDirection() == movementdirection);
+
+ verify_offsets(pathview, toidx, fromoffset, tooffset);
+}
+
QTEST_MAIN(tst_QQuickPathView)
#include "tst_qquickpathview.moc"
diff --git a/tests/auto/quick/qquickstates/tst_qquickstates.cpp b/tests/auto/quick/qquickstates/tst_qquickstates.cpp
index 562d53bceb..9b152b0676 100644
--- a/tests/auto/quick/qquickstates/tst_qquickstates.cpp
+++ b/tests/auto/quick/qquickstates/tst_qquickstates.cpp
@@ -698,7 +698,7 @@ void tst_qquickstates::anchorChanges()
rectPrivate->setState("right");
QCOMPARE(innerRect->x(), qreal(150));
QCOMPARE(aChanges->object(), qobject_cast<QQuickItem*>(innerRect));
- QCOMPARE(QQuickItemPrivate::get(aChanges->object())->anchors()->left().anchorLine, QQuickAnchorLine::Invalid); //### was reset (how do we distinguish from not set at all)
+ QCOMPARE(QQuickItemPrivate::get(aChanges->object())->anchors()->left().anchorLine, QQuickAnchors::InvalidAnchor); //### was reset (how do we distinguish from not set at all)
QCOMPARE(QQuickItemPrivate::get(aChanges->object())->anchors()->right().item, rectPrivate->right().item);
QCOMPARE(QQuickItemPrivate::get(aChanges->object())->anchors()->right().anchorLine, rectPrivate->right().anchorLine);
@@ -891,7 +891,7 @@ void tst_qquickstates::anchorChangesRTL()
rectPrivate->setState("right");
QCOMPARE(innerRect->x(), offsetRTL(rect, innerRect) - qreal(150));
QCOMPARE(aChanges->object(), qobject_cast<QQuickItem*>(innerRect));
- QCOMPARE(QQuickItemPrivate::get(aChanges->object())->anchors()->left().anchorLine, QQuickAnchorLine::Invalid); //### was reset (how do we distinguish from not set at all)
+ QCOMPARE(QQuickItemPrivate::get(aChanges->object())->anchors()->left().anchorLine, QQuickAnchors::InvalidAnchor); //### was reset (how do we distinguish from not set at all)
QCOMPARE(QQuickItemPrivate::get(aChanges->object())->anchors()->right().item, rectPrivate->right().item);
QCOMPARE(QQuickItemPrivate::get(aChanges->object())->anchors()->right().anchorLine, rectPrivate->right().anchorLine);
diff --git a/tests/auto/quick/qquicktext/tst_qquicktext.cpp b/tests/auto/quick/qquicktext/tst_qquicktext.cpp
index 7ea36bbafa..79d4adbb3d 100644
--- a/tests/auto/quick/qquicktext/tst_qquicktext.cpp
+++ b/tests/auto/quick/qquicktext/tst_qquicktext.cpp
@@ -701,7 +701,7 @@ void tst_qquicktext::textFormat()
QQuickText *text = qobject_cast<QQuickText *>(object.data());
QVERIFY(text);
- QSignalSpy spy(text, SIGNAL(textFormatChanged(TextFormat)));
+ QSignalSpy spy(text, &QQuickText::textFormatChanged);
QCOMPARE(text->textFormat(), QQuickText::AutoText);
diff --git a/tests/auto/quick/qquicktextinput/tst_qquicktextinput.cpp b/tests/auto/quick/qquicktextinput/tst_qquicktextinput.cpp
index e26bf6f4e4..24cfadc2d3 100644
--- a/tests/auto/quick/qquicktextinput/tst_qquicktextinput.cpp
+++ b/tests/auto/quick/qquicktextinput/tst_qquicktextinput.cpp
@@ -1390,7 +1390,7 @@ void tst_qquicktextinput::mouseSelectionMode_accessors()
QQuickTextInput *input = qobject_cast<QQuickTextInput *>(object.data());
QVERIFY(input);
- QSignalSpy spy(input, SIGNAL(mouseSelectionModeChanged(SelectionMode)));
+ QSignalSpy spy(input, &QQuickTextInput::mouseSelectionModeChanged);
QCOMPARE(input->mouseSelectionMode(), QQuickTextInput::SelectCharacters);
diff --git a/tests/auto/quick/quick.pro b/tests/auto/quick/quick.pro
index 13bd6d78e2..2e43702e7c 100644
--- a/tests/auto/quick/quick.pro
+++ b/tests/auto/quick/quick.pro
@@ -75,6 +75,7 @@ QUICKTESTS = \
qquickvisualdatamodel \
qquickview \
qquickcanvasitem \
+ qquickdesignersupport \
qquickscreen \
touchmouse \
scenegraph