From: Martin Jones Date: Tue, 8 Nov 2011 23:06:39 +0000 (+1000) Subject: tst_QSGGridView enforceRange_rightToLeft fails X-Git-Tag: qt-v5.0.0-alpha1~1194 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=15547ac366bdfd6f35779995b5d56df669b5e564;p=profile%2Fivi%2Fqtdeclarative.git tst_QSGGridView enforceRange_rightToLeft fails Change 9bd6361400a2a4e4045a090de73d70082cc6d1bf corrected the highlight range for right to left layout, i.e. positioned relative to the right. This change fixes the autotest to account for this and fixes flicking in StrictlyEnforceRange mode with RTL layout. Task-number: QTBUG-22162 Change-Id: I133b7e647883e51783bcf54111871451a3a7e67f Reviewed-by: Bea Lam --- diff --git a/src/declarative/items/qquickgridview.cpp b/src/declarative/items/qquickgridview.cpp index a194772..2793032 100644 --- a/src/declarative/items/qquickgridview.cpp +++ b/src/declarative/items/qquickgridview.cpp @@ -335,9 +335,6 @@ qreal QQuickGridViewPrivate::snapPosAt(qreal pos) const qreal snapPos = 0; if (!visibleItems.isEmpty()) { qreal highlightStart = highlightRangeStart; - if (isRightToLeftTopToBottom()) - highlightStart = highlightRangeEndValid ? -size() + highlightRangeEnd : -size(); - pos += highlightStart; pos += rowSize()/2; snapPos = static_cast(visibleItems.first())->rowPos() - visibleIndex / columns * rowSize(); @@ -346,8 +343,8 @@ qreal QQuickGridViewPrivate::snapPosAt(qreal pos) const qreal maxExtent; qreal minExtent; if (isRightToLeftTopToBottom()) { - maxExtent = q->minXExtent(); - minExtent = q->maxXExtent(); + maxExtent = q->minXExtent()-size(); + minExtent = q->maxXExtent()-size(); } else { maxExtent = flow == QQuickGridView::LeftToRight ? -q->maxYExtent() : -q->maxXExtent(); minExtent = flow == QQuickGridView::LeftToRight ? -q->minYExtent() : -q->minXExtent(); diff --git a/tests/auto/declarative/qquickgridview/tst_qquickgridview.cpp b/tests/auto/declarative/qquickgridview/tst_qquickgridview.cpp index 5f3842a..9492605 100644 --- a/tests/auto/declarative/qquickgridview/tst_qquickgridview.cpp +++ b/tests/auto/declarative/qquickgridview/tst_qquickgridview.cpp @@ -2356,18 +2356,17 @@ void tst_QQuickGridView::enforceRange_rightToLeft() QQuickGridView *gridview = findItem(canvas->rootObject(), "grid"); QTRY_VERIFY(gridview != 0); - QTRY_COMPARE(gridview->preferredHighlightBegin(), 100.0); - QTRY_COMPARE(gridview->preferredHighlightEnd(), 100.0); - QTRY_COMPARE(gridview->highlightRangeMode(), QQuickGridView::StrictlyEnforceRange); + QCOMPARE(gridview->preferredHighlightBegin(), 100.0); + QCOMPARE(gridview->preferredHighlightEnd(), 100.0); + QCOMPARE(gridview->highlightRangeMode(), QQuickGridView::StrictlyEnforceRange); QQuickItem *contentItem = gridview->contentItem(); - QTRY_VERIFY(contentItem != 0); + QVERIFY(contentItem != 0); // view should be positioned at the top of the range. QQuickItem *item = findItem(contentItem, "wrapper", 0); - QTRY_VERIFY(item); - QEXPECT_FAIL("", "QTBUG-22162", Abort); - QTRY_COMPARE(gridview->contentX(), -100.); + QVERIFY(item); + QTRY_COMPARE(gridview->contentX(), -140.); QTRY_COMPARE(gridview->contentY(), 0.0); QQuickText *name = findItem(contentItem, "textName", 0); @@ -2378,11 +2377,11 @@ void tst_QQuickGridView::enforceRange_rightToLeft() QTRY_COMPARE(number->text(), model.number(0)); // Check currentIndex is updated when contentItem moves - gridview->setContentX(-200); + gridview->setContentX(-240); QTRY_COMPARE(gridview->currentIndex(), 3); gridview->setCurrentIndex(7); - QTRY_COMPARE(gridview->contentX(), -300.); + QTRY_COMPARE(gridview->contentX(), -340.); QTRY_COMPARE(gridview->contentY(), 0.0); TestModel model2;