aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorLiang Qi <liang.qi@qt.io>2016-09-30 00:16:40 +0200
committerLiang Qi <liang.qi@qt.io>2016-09-30 00:16:40 +0200
commit0bf14044178d7aa212ac7e28530f9077790a3df4 (patch)
tree4c403571abbc5e18c6962ba67d9cb584d8e121c4 /tests
parent0aea009425242417bffdb171c8eca02ff52f4a7b (diff)
parent79cfc8788d6267eeb263983466ba21758f618dcd (diff)
Merge remote-tracking branch 'origin/5.6' into 5.7
Conflicts: tests/auto/quick/qquicktext/tst_qquicktext.cpp Change-Id: I241cd418bb7e7b95e0a0a2ee4c465d48be2a5582
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/qml/qjsengine/tst_qjsengine.cpp9
-rw-r--r--tests/auto/quick/qquickflickable/data/wheel.qml5
-rw-r--r--tests/auto/quick/qquickflickable/tst_qquickflickable.cpp20
-rw-r--r--tests/auto/quick/qquickmousearea/data/nestedFlickableStopAtBounds.qml44
-rw-r--r--tests/auto/quick/qquickmousearea/tst_qquickmousearea.cpp93
-rw-r--r--tests/auto/quick/qquicktext/data/hAlignWidthDependsOnImplicitWidth.qml25
-rw-r--r--tests/auto/quick/qquicktext/tst_qquicktext.cpp60
7 files changed, 255 insertions, 1 deletions
diff --git a/tests/auto/qml/qjsengine/tst_qjsengine.cpp b/tests/auto/qml/qjsengine/tst_qjsengine.cpp
index 0001a22103..13bfa16581 100644
--- a/tests/auto/qml/qjsengine/tst_qjsengine.cpp
+++ b/tests/auto/qml/qjsengine/tst_qjsengine.cpp
@@ -138,6 +138,7 @@ private slots:
void arrayPop_QTBUG_35979();
void array_unshift_QTBUG_52065();
+ void array_join_QTBUG_53672();
void regexpLastMatch();
void indexedAccesses();
@@ -3020,6 +3021,14 @@ void tst_QJSEngine::array_unshift_QTBUG_52065()
QCOMPARE(result.property(i).toInt(), i);
}
+void tst_QJSEngine::array_join_QTBUG_53672()
+{
+ QJSEngine eng;
+ QJSValue result = eng.evaluate("Array.prototype.join.call(0)");
+ QVERIFY(result.isString());
+ QCOMPARE(result.toString(), QString(""));
+}
+
void tst_QJSEngine::regexpLastMatch()
{
QJSEngine eng;
diff --git a/tests/auto/quick/qquickflickable/data/wheel.qml b/tests/auto/quick/qquickflickable/data/wheel.qml
index 2928bbcd72..2be543cdde 100644
--- a/tests/auto/quick/qquickflickable/data/wheel.qml
+++ b/tests/auto/quick/qquickflickable/data/wheel.qml
@@ -8,9 +8,14 @@ Rectangle {
Flickable {
id: flick
objectName: "flick"
+ property bool ended: false
+ property int movementsAfterEnd: 0
anchors.fill: parent
contentWidth: 800
contentHeight: 800
+ onContentXChanged: if (ended) ++movementsAfterEnd
+ onContentYChanged: if (ended) ++movementsAfterEnd
+ onMovementEnded: ended = true
Rectangle {
width: flick.contentWidth
diff --git a/tests/auto/quick/qquickflickable/tst_qquickflickable.cpp b/tests/auto/quick/qquickflickable/tst_qquickflickable.cpp
index bbaccfe534..339e8946e8 100644
--- a/tests/auto/quick/qquickflickable/tst_qquickflickable.cpp
+++ b/tests/auto/quick/qquickflickable/tst_qquickflickable.cpp
@@ -741,7 +741,10 @@ void tst_qquickflickable::wheel()
QQuickFlickable *flick = window->rootObject()->findChild<QQuickFlickable*>("flick");
QVERIFY(flick != 0);
+ QQuickFlickablePrivate *fp = QQuickFlickablePrivate::get(flick);
+ QSignalSpy moveEndSpy(flick, SIGNAL(movementEnded()));
+ // test a vertical flick
{
QPoint pos(200, 200);
QWheelEvent event(pos, window->mapToGlobal(pos), QPoint(), QPoint(0,-120), -120, Qt::Vertical, Qt::NoButton, Qt::NoModifier);
@@ -752,9 +755,19 @@ void tst_qquickflickable::wheel()
QTRY_VERIFY(flick->contentY() > 0);
QCOMPARE(flick->contentX(), qreal(0));
- flick->setContentY(0);
+ QTRY_COMPARE(moveEndSpy.count(), 1);
+ QCOMPARE(fp->velocityTimeline.isActive(), false);
+ QCOMPARE(fp->timeline.isActive(), false);
+ QTest::qWait(50); // make sure that onContentYChanged won't sneak in again
+ QCOMPARE(flick->property("movementsAfterEnd").value<int>(), 0); // QTBUG-55886
+
+ // get ready to test horizontal flick
+ flick->setContentY(0); // which triggers movementEnded again
+ flick->setProperty("movementsAfterEnd", 0);
+ flick->setProperty("ended", false);
QCOMPARE(flick->contentY(), qreal(0));
+ // test a horizontal flick
{
QPoint pos(200, 200);
QWheelEvent event(pos, window->mapToGlobal(pos), QPoint(), QPoint(-120,0), -120, Qt::Horizontal, Qt::NoButton, Qt::NoModifier);
@@ -765,6 +778,11 @@ void tst_qquickflickable::wheel()
QTRY_VERIFY(flick->contentX() > 0);
QCOMPARE(flick->contentY(), qreal(0));
+ QTRY_COMPARE(moveEndSpy.count(), 2);
+ QCOMPARE(fp->velocityTimeline.isActive(), false);
+ QCOMPARE(fp->timeline.isActive(), false);
+ QTest::qWait(50); // make sure that onContentXChanged won't sneak in again
+ QCOMPARE(flick->property("movementsAfterEnd").value<int>(), 0); // QTBUG-55886
}
void tst_qquickflickable::movingAndFlicking_data()
diff --git a/tests/auto/quick/qquickmousearea/data/nestedFlickableStopAtBounds.qml b/tests/auto/quick/qquickmousearea/data/nestedFlickableStopAtBounds.qml
new file mode 100644
index 0000000000..0d5b496766
--- /dev/null
+++ b/tests/auto/quick/qquickmousearea/data/nestedFlickableStopAtBounds.qml
@@ -0,0 +1,44 @@
+import QtQuick 2.5
+
+
+Rectangle {
+ width: 240
+ height: 320
+
+ MouseArea {
+ objectName: "mouseArea"
+ anchors.fill: parent
+
+ drag.target: moveable
+ drag.filterChildren: true
+
+ Rectangle {
+ id: moveable
+ objectName: "moveable"
+ color: "red"
+ x: 50
+ y: 80
+ width: 200
+ height: 200
+ }
+
+ Flickable {
+ objectName: "flickable"
+ anchors.fill: parent
+ contentHeight: 450
+
+ Rectangle {
+ x: 100
+ y: 50
+ width: 50
+ height: 350
+ color: "yellow"
+ }
+
+ MouseArea {
+ width: 240
+ height: 450
+ }
+ }
+ }
+}
diff --git a/tests/auto/quick/qquickmousearea/tst_qquickmousearea.cpp b/tests/auto/quick/qquickmousearea/tst_qquickmousearea.cpp
index 89d48c4f09..5891e67df6 100644
--- a/tests/auto/quick/qquickmousearea/tst_qquickmousearea.cpp
+++ b/tests/auto/quick/qquickmousearea/tst_qquickmousearea.cpp
@@ -120,6 +120,7 @@ private slots:
void moveAndReleaseWithoutPress();
void nestedStopAtBounds();
void nestedStopAtBounds_data();
+ void nestedFlickableStopAtBounds();
void containsPress_data();
void containsPress();
void ignoreBySource();
@@ -1751,6 +1752,98 @@ void tst_QQuickMouseArea::nestedStopAtBounds()
QTest::mouseRelease(&view, Qt::LeftButton, 0, position);
}
+void tst_QQuickMouseArea::nestedFlickableStopAtBounds()
+{
+ QQuickView view;
+ QByteArray errorMessage;
+ QVERIFY2(initView(view, testFileUrl("nestedFlickableStopAtBounds.qml"), false, &errorMessage), errorMessage.constData());
+ view.show();
+ view.requestActivate();
+ QVERIFY(QTest::qWaitForWindowExposed(&view));
+ QVERIFY(view.rootObject());
+
+ QQuickMouseArea *mouseArea = view.rootObject()->findChild<QQuickMouseArea*>("mouseArea");
+ QVERIFY(mouseArea);
+
+ QQuickFlickable *flickable = mouseArea->findChild<QQuickFlickable*>("flickable");
+ QVERIFY(flickable);
+
+ const int threshold = qApp->styleHints()->startDragDistance();
+
+ QPoint position(200, 280);
+ int &pos = position.ry();
+
+ // Drag up - should move the Flickable to end
+ QTest::mousePress(&view, Qt::LeftButton, 0, position);
+ QTest::qWait(10);
+ pos -= threshold * 2;
+ QTest::mouseMove(&view, position);
+ pos -= threshold * 2;
+ QTest::mouseMove(&view, position);
+ QTest::qWait(10);
+ pos -= 150;
+ QTest::mouseMove(&view, position);
+ QVERIFY(flickable->isDragging());
+ QVERIFY(!mouseArea->drag()->active());
+ QCOMPARE(flickable->isAtYEnd(), true);
+ QTest::mouseRelease(&view, Qt::LeftButton, 0, position);
+
+ QTRY_VERIFY(!flickable->isMoving());
+
+ pos = 280;
+
+ // Drag up again - should activate MouseArea drag
+ QVERIFY(!mouseArea->drag()->active());
+ QTest::mousePress(&view, Qt::LeftButton, 0, position);
+ QTest::qWait(10);
+ pos -= threshold * 2;
+ QTest::mouseMove(&view, position);
+ pos -= threshold * 2;
+ QTest::mouseMove(&view, position);
+ QTest::qWait(10);
+ pos -= 20;
+ QTest::mouseMove(&view, position);
+ QVERIFY(mouseArea->drag()->active());
+ QCOMPARE(flickable->isAtYEnd(), true);
+ QVERIFY(!flickable->isDragging());
+ QTest::mouseRelease(&view, Qt::LeftButton, 0, position);
+
+ // Drag to the top and verify that the MouseArea doesn't steal the grab when we drag back (QTBUG-56036)
+ pos = 50;
+
+ QTest::mousePress(&view, Qt::LeftButton, 0, position);
+ QTest::qWait(10);
+ pos += threshold;
+ QTest::mouseMove(&view, position);
+ pos += threshold;
+ QTest::mouseMove(&view, position);
+ QTest::qWait(10);
+ pos += 150;
+ QTest::mouseMove(&view, position);
+ QVERIFY(flickable->isDragging());
+ QVERIFY(!mouseArea->drag()->active());
+ QCOMPARE(flickable->isAtYBeginning(), true);
+ QTest::mouseRelease(&view, Qt::LeftButton, 0, position);
+
+ QTRY_VERIFY(!flickable->isMoving());
+
+ pos = 280;
+
+ // Drag up again - should not activate MouseArea drag
+ QTest::mousePress(&view, Qt::LeftButton, 0, position);
+ QTest::qWait(10);
+ pos -= threshold;
+ QTest::mouseMove(&view, position);
+ pos -= threshold;
+ QTest::mouseMove(&view, position);
+ QTest::qWait(10);
+ pos -= 100;
+ QTest::mouseMove(&view, position);
+ QVERIFY(flickable->isDragging());
+ QVERIFY(!mouseArea->drag()->active());
+ QTest::mouseRelease(&view, Qt::LeftButton, 0, position);
+}
+
void tst_QQuickMouseArea::containsPress_data()
{
QTest::addColumn<bool>("hoverEnabled");
diff --git a/tests/auto/quick/qquicktext/data/hAlignWidthDependsOnImplicitWidth.qml b/tests/auto/quick/qquicktext/data/hAlignWidthDependsOnImplicitWidth.qml
new file mode 100644
index 0000000000..4358a58f57
--- /dev/null
+++ b/tests/auto/quick/qquicktext/data/hAlignWidthDependsOnImplicitWidth.qml
@@ -0,0 +1,25 @@
+import QtQuick 2.6
+
+Item {
+ width: 200
+ height: 200
+
+ property alias text: label.text
+ property alias horizontalAlignment: label.horizontalAlignment
+ property alias elide: label.elide
+ property int extraWidth: 0
+
+ Rectangle {
+ border.color: "red"
+ x: 100
+ width: label.implicitWidth + extraWidth
+ height: label.implicitHeight
+
+ Text {
+ id: label
+ anchors.fill: parent
+ text: 'press me'
+ horizontalAlignment: Text.AlignHCenter
+ }
+ }
+}
diff --git a/tests/auto/quick/qquicktext/tst_qquicktext.cpp b/tests/auto/quick/qquicktext/tst_qquicktext.cpp
index 5ee811fd37..f31859ee49 100644
--- a/tests/auto/quick/qquicktext/tst_qquicktext.cpp
+++ b/tests/auto/quick/qquicktext/tst_qquicktext.cpp
@@ -150,6 +150,9 @@ private slots:
void zeroWidthAndElidedDoesntRender();
+ void hAlignWidthDependsOnImplicitWidth_data();
+ void hAlignWidthDependsOnImplicitWidth();
+
private:
QStringList standard;
QStringList richText;
@@ -4114,6 +4117,18 @@ void tst_qquicktext::padding()
QCOMPARE(obj->bottomPadding(), 1.11);
QCOMPARE(obj->implicitHeight(), ch + obj->topPadding() + obj->bottomPadding());
+ obj->setWidth(cw / 2);
+ obj->setElideMode(QQuickText::ElideRight);
+ QCOMPARE(obj->implicitWidth(), cw + obj->leftPadding() + obj->rightPadding());
+ QCOMPARE(obj->implicitHeight(), ch + obj->topPadding() + obj->bottomPadding());
+ obj->setElideMode(QQuickText::ElideNone);
+ obj->resetWidth();
+
+ obj->setWrapMode(QQuickText::WordWrap);
+ QCOMPARE(obj->implicitWidth(), cw + obj->leftPadding() + obj->rightPadding());
+ QCOMPARE(obj->implicitHeight(), ch + obj->topPadding() + obj->bottomPadding());
+ obj->setWrapMode(QQuickText::NoWrap);
+
obj->setText("Qt");
QVERIFY(obj->contentWidth() < cw);
QCOMPARE(obj->contentHeight(), ch);
@@ -4170,6 +4185,51 @@ void tst_qquicktext::zeroWidthAndElidedDoesntRender()
QCOMPARE(text->contentWidth(), reference->contentWidth());
}
+void tst_qquicktext::hAlignWidthDependsOnImplicitWidth_data()
+{
+ QTest::addColumn<QQuickText::HAlignment>("horizontalAlignment");
+ QTest::addColumn<QQuickText::TextElideMode>("elide");
+ QTest::addColumn<int>("extraWidth");
+
+ QTest::newRow("AlignHCenter, ElideNone, 0 extraWidth") << QQuickText::AlignHCenter << QQuickText::ElideNone << 0;
+ QTest::newRow("AlignRight, ElideNone, 0 extraWidth") << QQuickText::AlignRight << QQuickText::ElideNone << 0;
+ QTest::newRow("AlignHCenter, ElideRight, 0 extraWidth") << QQuickText::AlignHCenter << QQuickText::ElideRight << 0;
+ QTest::newRow("AlignRight, ElideRight, 0 extraWidth") << QQuickText::AlignRight << QQuickText::ElideRight << 0;
+ QTest::newRow("AlignHCenter, ElideNone, 20 extraWidth") << QQuickText::AlignHCenter << QQuickText::ElideNone << 20;
+ QTest::newRow("AlignRight, ElideNone, 20 extraWidth") << QQuickText::AlignRight << QQuickText::ElideNone << 20;
+ QTest::newRow("AlignHCenter, ElideRight, 20 extraWidth") << QQuickText::AlignHCenter << QQuickText::ElideRight << 20;
+ QTest::newRow("AlignRight, ElideRight, 20 extraWidth") << QQuickText::AlignRight << QQuickText::ElideRight << 20;
+}
+
+void tst_qquicktext::hAlignWidthDependsOnImplicitWidth()
+{
+ QFETCH(QQuickText::HAlignment, horizontalAlignment);
+ QFETCH(QQuickText::TextElideMode, elide);
+ QFETCH(int, extraWidth);
+
+ QScopedPointer<QQuickView> window(new QQuickView);
+ window->setSource(testFileUrl("hAlignWidthDependsOnImplicitWidth.qml"));
+ QTRY_COMPARE(window->status(), QQuickView::Ready);
+
+ window->show();
+ QVERIFY(QTest::qWaitForWindowExposed(window.data()));
+
+ QQuickItem *rect = window->rootObject();
+ QVERIFY(rect);
+
+ QVERIFY(rect->setProperty("horizontalAlignment", horizontalAlignment));
+ QVERIFY(rect->setProperty("elide", elide));
+ QVERIFY(rect->setProperty("extraWidth", extraWidth));
+
+ QImage image = window->grabWindow();
+ const int rectX = 100 * window->screen()->devicePixelRatio();
+ QCOMPARE(numberOfNonWhitePixels(0, rectX - 1, image), 0);
+
+ QVERIFY(rect->setProperty("text", "this is mis-aligned"));
+ image = window->grabWindow();
+ QCOMPARE(numberOfNonWhitePixels(0, rectX - 1, image), 0);
+}
+
QTEST_MAIN(tst_qquicktext)
#include "tst_qquicktext.moc"