on xenial help sign in
Fix showHeader in an edge case of notShownByItsOwn

Not all the tests i've added fail without the code fix, but i've added them just to be more covered . Fixes: https://bugs.launchpad.net/bugs/1230187. Approved by PS Jenkins bot, Michał Sawicz.

commita9858ca7769e491ddeca2b0bc3ee73006d8e071c authorAlbert Astals <albert.astals@canonical.com> dateThu 26 Sep 2013, 23:44 (13 years ago) parent85f94d3429685a
2 files changed+117−1
plugins/ListViewWithPageHeader/listviewwithpageheader.cpp+1−1 tests/plugins/ListViewWithPageHeader/listviewwithpageheadertest.cpp+116
plugins/ListViewWithPageHeader/listviewwithpageheader.cpp+1−1
@@ -485,7 +485,7 @@ void ListViewWithPageHeader::viewportMoved(Qt::Orientations orient)
485485 // or the header is partially shown and we are not doing a maximizeVisibleArea either
486486 const bool scrolledUp = m_previousContentY > contentY();
487487 const bool notRebounding = contentY() + height() < contentHeight();
488− const bool notShownByItsOwn = contentY() + diff > m_headerItem->y() + m_headerItem->height();
488+ const bool notShownByItsOwn = contentY() + diff >= m_headerItem->y() + m_headerItem->height();
489489 const bool maximizeVisibleAreaRunning = m_contentYAnimation->isRunning() && contentYAnimationType == ContentYAnimationMaximizeVisibleArea;
490490
491491 if (!scrolledUp && contentY() == -m_minYExtent) {
tests/plugins/ListViewWithPageHeader/listviewwithpageheadertest.cpp+116
@@ -1699,6 +1699,122 @@ private Q_SLOTS:
16991699 verifyItem(1, 442., 100., false);
17001700 }
17011701
1702+ void testMaximizeVisibleAreaMoveDownAndShowHeader()
1703+ {
1704+ model->setProperty(0, "size", 800);
1705+ verifyItem(0, 50., 800., false);
1706+
1707+ lvwph->maximizeVisibleArea(0);
1708+ QTRY_COMPARE(lvwph->contentY(), 50.);
1709+
1710+ changeContentY(10);
1711+ QTRY_COMPARE(lvwph->contentY(), 60.);
1712+
1713+ lvwph->showHeader();
1714+ QTRY_VERIFY(!lvwph->m_contentYAnimation->isRunning());
1715+ QTRY_COMPARE(lvwph->m_visibleItems.count(), 2);
1716+ QCOMPARE(lvwph->m_minYExtent, 50.);
1717+ QCOMPARE(lvwph->m_clipItem->y(), 60.);
1718+ QCOMPARE(lvwph->m_clipItem->clip(), true);
1719+ QCOMPARE(lvwph->m_headerItem->y(), 10.);
1720+ QCOMPARE(lvwph->m_headerItem->height(), 50.);
1721+ QCOMPARE(lvwph->contentY(), 10.);
1722+ verifyItem(0, -60., 800., false);
1723+ }
1724+
1725+ void testMaximizeVisibleAreaMoveUpAndShowHeader()
1726+ {
1727+ model->setProperty(0, "size", 800);
1728+ verifyItem(0, 50., 800., false);
1729+
1730+ lvwph->maximizeVisibleArea(0);
1731+ QTRY_COMPARE(lvwph->contentY(), 50.);
1732+
1733+ changeContentY(-10);
1734+ QTRY_COMPARE(lvwph->contentY(), 40.);
1735+
1736+ lvwph->showHeader();
1737+ QTRY_VERIFY(!lvwph->m_contentYAnimation->isRunning());
1738+ QTRY_COMPARE(lvwph->m_visibleItems.count(), 2);
1739+ QCOMPARE(lvwph->m_minYExtent, 40.);
1740+ QCOMPARE(lvwph->m_clipItem->y(), 50.);
1741+ QCOMPARE(lvwph->m_clipItem->clip(), true);
1742+ QTRY_COMPARE(lvwph->m_headerItem->y(), 0.);
1743+ QCOMPARE(lvwph->m_headerItem->height(), 50.);
1744+ QCOMPARE(lvwph->contentY(), 0.);
1745+ verifyItem(0, -40., 800., false);
1746+ }
1747+
1748+ void testMaximizeVisibleAreaMoveDownAndUpAndShowHeader()
1749+ {
1750+ model->setProperty(0, "size", 800);
1751+ verifyItem(0, 50., 800., false);
1752+
1753+ lvwph->maximizeVisibleArea(0);
1754+ QTRY_COMPARE(lvwph->contentY(), 50.);
1755+
1756+ changeContentY(-10);
1757+ QTRY_COMPARE(lvwph->contentY(), 40.);
1758+ changeContentY(10);
1759+ QTRY_COMPARE(lvwph->contentY(), 50.);
1760+
1761+ lvwph->showHeader();
1762+ QTRY_VERIFY(!lvwph->m_contentYAnimation->isRunning());
1763+
1764+ QTRY_COMPARE(lvwph->m_visibleItems.count(), 2);
1765+ QCOMPARE(lvwph->m_minYExtent, 50.);
1766+ QCOMPARE(lvwph->m_clipItem->y(), 50.);
1767+ QCOMPARE(lvwph->m_clipItem->clip(), true);
1768+ QCOMPARE(lvwph->m_headerItem->y(), 0.);
1769+ QCOMPARE(lvwph->m_headerItem->height(), 50.);
1770+ QCOMPARE(lvwph->contentY(), 0.);
1771+ verifyItem(0, -50., 800., false);
1772+ }
1773+
1774+ void testMaximizeVisibleAreaMoveUpAndDownAndShowHeader()
1775+ {
1776+ model->setProperty(0, "size", 800);
1777+ verifyItem(0, 50., 800., false);
1778+
1779+ lvwph->maximizeVisibleArea(0);
1780+ QTRY_COMPARE(lvwph->contentY(), 50.);
1781+
1782+ changeContentY(10);
1783+ QTRY_COMPARE(lvwph->contentY(), 60.);
1784+ changeContentY(-10);
1785+ QTRY_COMPARE(lvwph->contentY(), 50.);
1786+
1787+ lvwph->showHeader();
1788+ QTRY_VERIFY(!lvwph->m_contentYAnimation->isRunning());
1789+ QTRY_COMPARE(lvwph->m_visibleItems.count(), 2);
1790+ QCOMPARE(lvwph->m_minYExtent, 40.);
1791+ QCOMPARE(lvwph->m_clipItem->y(), 60.);
1792+ QCOMPARE(lvwph->m_clipItem->clip(), true);
1793+ QCOMPARE(lvwph->m_headerItem->y(), 10.);
1794+ QCOMPARE(lvwph->m_headerItem->height(), 50.);
1795+ QCOMPARE(lvwph->contentY(), 10.);
1796+ verifyItem(0, -50., 800., false);
1797+ }
1798+
1799+ void testMaximizeVisibleAreaAndShowHeader()
1800+ {
1801+ model->setProperty(0, "size", 800);
1802+ verifyItem(0, 50., 800., false);
1803+
1804+ lvwph->maximizeVisibleArea(0);
1805+ QTRY_COMPARE(lvwph->contentY(), 50.);
1806+
1807+ lvwph->showHeader();
1808+ QTRY_VERIFY(!lvwph->m_contentYAnimation->isRunning());
1809+ QTRY_COMPARE(lvwph->m_visibleItems.count(), 2);
1810+ QCOMPARE(lvwph->m_minYExtent, 50.);
1811+ QCOMPARE(lvwph->m_clipItem->y(), 50.);
1812+ QCOMPARE(lvwph->m_clipItem->clip(), true);
1813+ QCOMPARE(lvwph->m_headerItem->y(), 0.);
1814+ QCOMPARE(lvwph->m_headerItem->height(), 50.);
1815+ QCOMPARE(lvwph->contentY(), 0.);
1816+ verifyItem(0, -50., 800., false);
1817+ }
17021818
17031819private:
17041820 QQuickView *view;