on xenial help sign in
Some fixes for the tests
61687ceAlbert Astals
plugins/DashViews/listviewwithpageheader.cpp+26−9
@@ -477,6 +477,11 @@ void ListViewWithPageHeader::componentComplete()
477 polish();
477 polish();
478}
478}
479
479
480+static inline bool uFuzzyCompare(qreal r1, qreal r2)
481+{
482+ return qFuzzyCompare(r1, r2) || (qFuzzyIsNull(r1) && qFuzzyIsNull(r2));
483+}
484+
480void ListViewWithPageHeader::viewportMoved(Qt::Orientations orient)
485void ListViewWithPageHeader::viewportMoved(Qt::Orientations orient)
481{
486{
482 // Check we are not being taken down and don't paint anything
487 // Check we are not being taken down and don't paint anything
@@ -491,11 +496,7 @@ void ListViewWithPageHeader::viewportMoved(Qt::Orientations orient)
491 const bool showHeaderAnimationRunning = m_contentYAnimation->isRunning() && contentYAnimationType == ContentYAnimationShowHeader;
496 const bool showHeaderAnimationRunning = m_contentYAnimation->isRunning() && contentYAnimationType == ContentYAnimationShowHeader;
492 if (m_headerItem) {
497 if (m_headerItem) {
493 const auto oldHeaderItemShownHeight = m_headerItemShownHeight;
498 const auto oldHeaderItemShownHeight = m_headerItemShownHeight;
494− if (contentY() < -m_minYExtent) {
499+ if (uFuzzyCompare(contentY(), -m_minYExtent) || contentY() > -m_minYExtent) {
495− // Stick the header item to the top when dragging down
496− m_headerItem->setY(contentY());
497− m_headerItem->setHeight(m_headerItem->implicitHeight() + (-m_minYExtent - contentY()));
498− } else {
499 m_headerItem->setHeight(m_headerItem->implicitHeight());
500 m_headerItem->setHeight(m_headerItem->implicitHeight());
500 // We are going down (but it's not because of the rebound at the end)
501 // We are going down (but it's not because of the rebound at the end)
501 // (but the header was not shown by it's own position)
502 // (but the header was not shown by it's own position)
@@ -509,21 +510,32 @@ void ListViewWithPageHeader::viewportMoved(Qt::Orientations orient)
509 m_headerItemShownHeight = 0;
510 m_headerItemShownHeight = 0;
510 m_headerItem->setY(-m_minYExtent);
511 m_headerItem->setY(-m_minYExtent);
511 } else if ((scrolledUp && notRebounding && notShownByItsOwn && !maximizeVisibleAreaRunning) || (m_headerItemShownHeight > 0) || m_inContentHeightKeepHeaderShown) {
512 } else if ((scrolledUp && notRebounding && notShownByItsOwn && !maximizeVisibleAreaRunning) || (m_headerItemShownHeight > 0) || m_inContentHeightKeepHeaderShown) {
513+ if (maximizeVisibleAreaRunning && diff > 0) {
512− if (maximizeVisibleAreaRunning && diff > 0) // If we are maximizing and the header was shown, make sure we hide it
514+ // If we are maximizing and the header was shown, make sure we hide it
513 m_headerItemShownHeight -= diff;
515 m_headerItemShownHeight -= diff;
514− else
516+ } else {
515 m_headerItemShownHeight += diff;
517 m_headerItemShownHeight += diff;
518+ }
516− if (contentY() == -m_minYExtent) {
519+ if (uFuzzyCompare(contentY(), -m_minYExtent)) {
517 m_headerItemShownHeight = 0;
520 m_headerItemShownHeight = 0;
518 } else {
521 } else {
519 m_headerItemShownHeight = qBound(static_cast<qreal>(0.), m_headerItemShownHeight, m_headerItem->height());
522 m_headerItemShownHeight = qBound(static_cast<qreal>(0.), m_headerItemShownHeight, m_headerItem->height());
520 }
523 }
521 if (m_headerItemShownHeight > 0) {
524 if (m_headerItemShownHeight > 0) {
525+ if (uFuzzyCompare(m_headerItem->height(), m_headerItemShownHeight)) {
526+ m_headerItem->setY(contentY());
527+ m_headerItemShownHeight = m_headerItem->height();
528+ } else {
522− m_headerItem->setY(contentY() - m_headerItem->height() + m_headerItemShownHeight);
529+ m_headerItem->setY(contentY() - m_headerItem->height() + m_headerItemShownHeight);
530+ }
523 } else {
531 } else {
524 m_headerItem->setY(-m_minYExtent);
532 m_headerItem->setY(-m_minYExtent);
525 }
533 }
526 }
534 }
535+ } else {
536+ // Stick the header item to the top when dragging down
537+ m_headerItem->setY(contentY());
538+ m_headerItem->setHeight(m_headerItem->implicitHeight() + (-m_minYExtent - contentY()));
527 }
539 }
528 // We will be changing the clip item, need to accomadate for it
540 // We will be changing the clip item, need to accomadate for it
529 // otherwise we move the firstItem down/up twice (unless the
541 // otherwise we move the firstItem down/up twice (unless the
@@ -1264,6 +1276,11 @@ void ListViewWithPageHeader::updatePolish()
1264 refill();
1276 refill();
1265
1277
1266 if (m_contentHeightDirty) {
1278 if (m_contentHeightDirty) {
1279+ // We need to make sure all bindings have updated otherwise
1280+ // we may end up with bindings updating when we call setContentHeight
1281+ // and then everything gets out of sync, i.e. testHeaderPositionBug1240118
1282+ qApp->processEvents();
1283+
1267 qreal contentHeight;
1284 qreal contentHeight;
1268 if (m_visibleItems.isEmpty()) {
1285 if (m_visibleItems.isEmpty()) {
1269 contentHeight = m_headerItem ? m_headerItem->height() : 0;
1286 contentHeight = m_headerItem ? m_headerItem->height() : 0;
tests/plugins/DashViews/listviewwithpageheadertest.cpp−6
@@ -1281,8 +1281,6 @@ private Q_SLOTS:
1281
1281
1282 void testShowHeaderHalfShown()
1282 void testShowHeaderHalfShown()
1283 {
1283 {
1284− QSKIP("This test is extremely unstable.");
1285−
1286 changeContentY(20);
1284 changeContentY(20);
1287
1285
1288 QTRY_COMPARE(lvwph->m_visibleItems.count(), 4);
1286 QTRY_COMPARE(lvwph->m_visibleItems.count(), 4);
@@ -1850,7 +1848,6 @@ private Q_SLOTS:
1850
1848
1851 void testHeaderPositionBug1240118()
1849 void testHeaderPositionBug1240118()
1852 {
1850 {
1853− QSKIP("This test is unstable.");
1854 scrollToBottom();
1851 scrollToBottom();
1855 lvwph->showHeader();
1852 lvwph->showHeader();
1856 QTRY_VERIFY(!lvwph->m_contentYAnimation->isRunning());
1853 QTRY_VERIFY(!lvwph->m_contentYAnimation->isRunning());
@@ -1860,9 +1857,6 @@ private Q_SLOTS:
1860 model->setProperty(4, "size", 10);
1857 model->setProperty(4, "size", 10);
1861 model->setProperty(5, "size", 10);
1858 model->setProperty(5, "size", 10);
1862 model->setProperty(6, "size", 10);
1859 model->setProperty(6, "size", 10);
1863−#if (QT_VERSION > QT_VERSION_CHECK(5, 0, 3))
1864− QTRY_COMPARE(lvwph->m_minYExtent, 210.);
1865−#endif
1866 QTRY_COMPARE(lvwph->m_headerItem->y(), -lvwph->m_minYExtent);
1860 QTRY_COMPARE(lvwph->m_headerItem->y(), -lvwph->m_minYExtent);
1867 }
1861 }
1868
1862
tests/plugins/DashViews/listviewwithpageheadertestsection.cpp−4
@@ -1486,8 +1486,6 @@ private Q_SLOTS:
1486
1486
1487 void testShowHeaderHalfShown()
1487 void testShowHeaderHalfShown()
1488 {
1488 {
1489− QSKIP("This test is extremely unstable.");
1490−
1491 changeContentY(20);
1489 changeContentY(20);
1492
1490
1493 QTRY_COMPARE(lvwph->m_visibleItems.count(), 3);
1491 QTRY_COMPARE(lvwph->m_visibleItems.count(), 3);
@@ -2095,8 +2093,6 @@ private Q_SLOTS:
2095
2093
2096 void testDownAndUp()
2094 void testDownAndUp()
2097 {
2095 {
2098− QSKIP("This test is unstable.");
2099−
2100 QMetaObject::invokeMethod(model, "removeItems", Q_ARG(QVariant, 1), Q_ARG(QVariant, 5));
2096 QMetaObject::invokeMethod(model, "removeItems", Q_ARG(QVariant, 1), Q_ARG(QVariant, 5));
2101
2097
2102 QTRY_COMPARE(lvwph->m_visibleItems.count(), 1);
2098 QTRY_COMPARE(lvwph->m_visibleItems.count(), 1);