Merge lp:~aacid/unity8/lvwph_weirdness2 into lp:unity8

Proposed by Albert Astals Cid
Status: Merged
Approved by: Michał Sawicz
Approved revision: 209
Merged at revision: 211
Proposed branch: lp:~aacid/unity8/lvwph_weirdness2
Merge into: lp:unity8
Diff against target: 107 lines (+45/-2)
3 files modified
plugins/ListViewWithPageHeader/listviewwithpageheader.cpp (+1/-0)
tests/plugins/ListViewWithPageHeader/listviewwithpageheadertest.cpp (+22/-1)
tests/plugins/ListViewWithPageHeader/listviewwithpageheadertestsection.cpp (+22/-1)
To merge this branch: bzr merge lp:~aacid/unity8/lvwph_weirdness2
Reviewer Review Type Date Requested Status
PS Jenkins bot (community) continuous-integration Approve
Michał Sawicz Approve
Review via email: mp+180613@code.launchpad.net

Commit message

Make sure minYExtent is updated before setting the new content height

Otherwise bad things can happen in the positioning

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Michał Sawicz (saviq) :
review: Approve
Revision history for this message
PS Jenkins bot (ps-jenkins) :
review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'plugins/ListViewWithPageHeader/listviewwithpageheader.cpp'
2--- plugins/ListViewWithPageHeader/listviewwithpageheader.cpp 2013-08-14 11:05:58 +0000
3+++ plugins/ListViewWithPageHeader/listviewwithpageheader.cpp 2013-08-16 16:32:30 +0000
4@@ -1244,6 +1244,7 @@
5 }
6
7 m_contentHeightDirty = false;
8+ adjustMinYExtent();
9 setContentHeight(contentHeight);
10 }
11 }
12
13=== modified file 'tests/plugins/ListViewWithPageHeader/listviewwithpageheadertest.cpp'
14--- tests/plugins/ListViewWithPageHeader/listviewwithpageheadertest.cpp 2013-08-08 15:34:52 +0000
15+++ tests/plugins/ListViewWithPageHeader/listviewwithpageheadertest.cpp 2013-08-16 16:32:30 +0000
16@@ -19,6 +19,7 @@
17 #include <QAbstractItemModel>
18 #include <QQmlEngine>
19 #include <QQuickView>
20+#include <QSignalSpy>
21 #include <QtTestGui>
22 #pragma GCC diagnostic push
23 #pragma GCC diagnostic ignored "-pedantic"
24@@ -1521,7 +1522,7 @@
25 QCOMPARE(lvwph->m_firstVisibleIndex, 1);
26 verifyItem(0, -458., 1000., false);
27 verifyItem(1, 542., 350., true);
28- QCOMPARE(lvwph->m_minYExtent, 362.5);
29+ QCOMPARE(lvwph->m_minYExtent, 525.);
30 QCOMPARE(lvwph->m_clipItem->y(), 658.);
31 QCOMPARE(lvwph->m_clipItem->clip(), false);
32 QCOMPARE(lvwph->m_headerItem->y(), 0.);
33@@ -1634,6 +1635,26 @@
34 QCOMPARE(lvwph->m_headerItemShownHeight, 0.);
35 }
36
37+ void addingRemoveItemsShouldNotChangeContentY()
38+ {
39+ QSignalSpy spy(lvwph, SIGNAL(contentYChanged()));
40+ QMetaObject::invokeMethod(model, "insertItem", Q_ARG(QVariant, 0), Q_ARG(QVariant, 150));
41+ QMetaObject::invokeMethod(model, "removeItems", Q_ARG(QVariant, 1), Q_ARG(QVariant, 6));
42+
43+ QTRY_COMPARE(lvwph->m_visibleItems.count(), 1);
44+ QCOMPARE(lvwph->m_firstVisibleIndex, 0);
45+ verifyItem(0, 50., 150., false);
46+ QCOMPARE(lvwph->m_minYExtent, 0.);
47+ QCOMPARE(lvwph->m_clipItem->y(), 0.);
48+ QCOMPARE(lvwph->m_clipItem->clip(), false);
49+ QCOMPARE(lvwph->m_headerItem->y(), 0.);
50+ QCOMPARE(lvwph->m_headerItem->height(), 50.);
51+ QCOMPARE(lvwph->contentY(), 0.);
52+ QCOMPARE(lvwph->m_headerItemShownHeight, 0.);
53+
54+ QCOMPARE(spy.count(), 0);
55+ }
56+
57 private:
58 QQuickView *view;
59 ListViewWithPageHeader *lvwph;
60
61=== modified file 'tests/plugins/ListViewWithPageHeader/listviewwithpageheadertestsection.cpp'
62--- tests/plugins/ListViewWithPageHeader/listviewwithpageheadertestsection.cpp 2013-08-08 15:34:52 +0000
63+++ tests/plugins/ListViewWithPageHeader/listviewwithpageheadertestsection.cpp 2013-08-16 16:32:30 +0000
64@@ -19,6 +19,7 @@
65 #include <QAbstractItemModel>
66 #include <QQmlEngine>
67 #include <QQuickView>
68+#include <QSignalSpy>
69 #include <QtTestGui>
70 #pragma GCC diagnostic push
71 #pragma GCC diagnostic ignored "-pedantic"
72@@ -1875,7 +1876,7 @@
73 QCOMPARE(lvwph->m_firstVisibleIndex, 1);
74 verifyItem(0, -498., 1040., false, "Regular", true);
75 verifyItem(1, 542., 390., true, "Mild", true);
76- QCOMPARE(lvwph->m_minYExtent, 1250/3.);
77+ QCOMPARE(lvwph->m_minYExtent, 525.);
78 QCOMPARE(lvwph->m_clipItem->y(), 738.);
79 QCOMPARE(lvwph->m_clipItem->clip(), false);
80 QCOMPARE(lvwph->m_headerItem->y(), 0.);
81@@ -2055,6 +2056,26 @@
82 QCOMPARE(lvwph->m_headerItemShownHeight, 0.);
83 }
84
85+ void addingRemoveItemsShouldNotChangeContentY()
86+ {
87+ QSignalSpy spy(lvwph, SIGNAL(contentYChanged()));
88+ QMetaObject::invokeMethod(model, "insertItem", Q_ARG(QVariant, 0), Q_ARG(QVariant, 150), Q_ARG(QVariant, "Agressive"));
89+ QMetaObject::invokeMethod(model, "removeItems", Q_ARG(QVariant, 1), Q_ARG(QVariant, 6));
90+
91+ QTRY_COMPARE(lvwph->m_visibleItems.count(), 1);
92+ QCOMPARE(lvwph->m_firstVisibleIndex, 0);
93+ verifyItem(0, 50., 190., false, "Agressive", false);
94+ QCOMPARE(lvwph->m_minYExtent, 0.);
95+ QCOMPARE(lvwph->m_clipItem->y(), 0.);
96+ QCOMPARE(lvwph->m_clipItem->clip(), false);
97+ QCOMPARE(lvwph->m_headerItem->y(), 0.);
98+ QCOMPARE(lvwph->m_headerItem->height(), 50.);
99+ QCOMPARE(lvwph->contentY(), 0.);
100+ QCOMPARE(lvwph->m_headerItemShownHeight, 0.);
101+
102+ QCOMPARE(spy.count(), 0);
103+ }
104+
105 private:
106 QQuickView *view;
107 ListViewWithPageHeader *lvwph;

Subscribers

People subscribed via source and target branches