on xenial help sign in
Merge 5.2 fixes
commit91d9f956fbbac0c2086df4c7b4e69d95d3363b8f authorMichał Sawicz <michal.sawicz@canonical.com> dateFri 14 Mar 2014, 16:05 (13 years ago) parent12668a6b63ffea
12 files changed+61−60
plugins/DashViews/listviewwithpageheader.cpp+33−10 qml/Components/Stage.qml+4−6 tests/plugins/DashViews/listviewwithpageheadertest.cpp−6 tests/plugins/DashViews/listviewwithpageheadertestsection.cpp−3 tests/qmltests/Components/tst_LazyImage.qml+1−1 tests/qmltests/Dash/Previews/tst_PreviewVideoPlayback.qml−6 tests/qmltests/Dash/Previews/tst_PreviewZoomableImage.qml+3−4 tests/qmltests/Dash/tst_CardHeader.qml+1−1 tests/qmltests/Dash/tst_GenericScopeView.qml+1−1 tests/qmltests/Launcher/tst_Launcher.qml+6−4 tests/qmltests/tst_Shell.qml+2−2 tests/utils/modules/Unity/Test/UnityTestCase.qml+10−16
plugins/DashViews/listviewwithpageheader.cpp+33−10
@@ -91,6 +91,7 @@
9191
9292#include "listviewwithpageheader.h"
9393
94+#include <QCoreApplication>
9495#include <QDebug>
9596#include <qqmlinfo.h>
9697#include <qqmlengine.h>
@@ -484,6 +485,11 @@ void ListViewWithPageHeader::componentComplete()
484485 polish();
485486}
486487
488+static inline bool uFuzzyCompare(qreal r1, qreal r2)
489+{
490+ return qFuzzyCompare(r1, r2) || (qFuzzyIsNull(r1) && qFuzzyIsNull(r2));
491+}
492+
487493void ListViewWithPageHeader::viewportMoved(Qt::Orientations orient)
488494{
489495 // Check we are not being taken down and don't paint anything
@@ -498,11 +504,7 @@ void ListViewWithPageHeader::viewportMoved(Qt::Orientations orient)
498504 const bool showHeaderAnimationRunning = m_contentYAnimation->isRunning() && contentYAnimationType == ContentYAnimationShowHeader;
499505 if (m_headerItem) {
500506 const auto oldHeaderItemShownHeight = m_headerItemShownHeight;
501− if (contentY() < -m_minYExtent) {
502− // Stick the header item to the top when dragging down
503− m_headerItem->setY(contentY());
504− m_headerItem->setHeight(m_headerItem->implicitHeight() + (-m_minYExtent - contentY()));
505− } else {
507+ if (uFuzzyCompare(contentY(), -m_minYExtent) || contentY() > -m_minYExtent) {
506508 m_headerItem->setHeight(m_headerItem->implicitHeight());
507509 // We are going down (but it's not because of the rebound at the end)
508510 // (but the header was not shown by it's own position)
@@ -516,21 +518,32 @@ void ListViewWithPageHeader::viewportMoved(Qt::Orientations orient)
516518 m_headerItemShownHeight = 0;
517519 m_headerItem->setY(-m_minYExtent);
518520 } else if ((scrolledUp && notRebounding && notShownByItsOwn && !maximizeVisibleAreaRunning) || (m_headerItemShownHeight > 0) || m_inContentHeightKeepHeaderShown) {
519− if (maximizeVisibleAreaRunning && diff > 0) // If we are maximizing and the header was shown, make sure we hide it
521+ if (maximizeVisibleAreaRunning && diff > 0) {
522+ // If we are maximizing and the header was shown, make sure we hide it
520523 m_headerItemShownHeight -= diff;
521− else
524+ } else {
522525 m_headerItemShownHeight += diff;
523− if (contentY() == -m_minYExtent) {
526+ }
527+ if (uFuzzyCompare(contentY(), -m_minYExtent)) {
524528 m_headerItemShownHeight = 0;
525529 } else {
526530 m_headerItemShownHeight = qBound(static_cast<qreal>(0.), m_headerItemShownHeight, m_headerItem->height());
527531 }
528532 if (m_headerItemShownHeight > 0) {
529− m_headerItem->setY(contentY() - m_headerItem->height() + m_headerItemShownHeight);
533+ if (uFuzzyCompare(m_headerItem->height(), m_headerItemShownHeight)) {
534+ m_headerItem->setY(contentY());
535+ m_headerItemShownHeight = m_headerItem->height();
536+ } else {
537+ m_headerItem->setY(contentY() - m_headerItem->height() + m_headerItemShownHeight);
538+ }
530539 } else {
531540 m_headerItem->setY(-m_minYExtent);
532541 }
533542 }
543+ } else {
544+ // Stick the header item to the top when dragging down
545+ m_headerItem->setY(contentY());
546+ m_headerItem->setHeight(m_headerItem->implicitHeight() + (-m_minYExtent - contentY()));
534547 }
535548 // We will be changing the clip item, need to accomadate for it
536549 // otherwise we move the firstItem down/up twice (unless the
@@ -1135,7 +1148,12 @@ void ListViewWithPageHeader::adjustMinYExtent()
11351148 nonCreatedHeight = m_firstVisibleIndex * visibleItemsHeight / visibleItems;
11361149// qDebug() << m_firstVisibleIndex << visibleItemsHeight << visibleItems << nonCreatedHeight;
11371150 }
1138− m_minYExtent = nonCreatedHeight - m_visibleItems.first()->y() - m_clipItem->y() + (m_headerItem ? m_headerItem->implicitHeight() : 0);
1151+ const qreal headerHeight = (m_headerItem ? m_headerItem->implicitHeight() : 0);
1152+ m_minYExtent = nonCreatedHeight - m_visibleItems.first()->y() - m_clipItem->y() + headerHeight;
1153+ if (m_minYExtent != 0 && qFuzzyIsNull(m_minYExtent)) {
1154+ m_minYExtent = 0;
1155+ m_visibleItems.first()->setY(nonCreatedHeight - m_clipItem->y() + headerHeight);
1156+ }
11391157 }
11401158}
11411159
@@ -1271,6 +1289,11 @@ void ListViewWithPageHeader::updatePolish()
12711289 refill();
12721290
12731291 if (m_contentHeightDirty) {
1292+ // We need to make sure all bindings have updated otherwise
1293+ // we may end up with bindings updating when we call setContentHeight
1294+ // and then everything gets out of sync, i.e. testHeaderPositionBug1240118
1295+ QCoreApplication::instance()->processEvents();
1296+
12741297 qreal contentHeight;
12751298 if (m_visibleItems.isEmpty()) {
12761299 contentHeight = m_headerItem ? m_headerItem->height() : 0;
qml/Components/Stage.qml+4−6
@@ -339,13 +339,11 @@ Showable {
339339
340340 ScriptAction {
341341 script: {
342− if (!stage.focusedApplicationWhenUsingScreenshots) {
343− // FIXME: only here to support case where application does
344− // not exist yet but is about to
345− return;
342+ // FIXME: only here to support case where application does
343+ // not exist yet but is about to
344+ if (stage.focusedApplicationWhenUsingScreenshots) {
345+ stage.__focusApplication(stage.focusedApplicationWhenUsingScreenshots);
346346 }
347−
348− stage.__focusApplication(stage.focusedApplicationWhenUsingScreenshots);
349347 }
350348 }
351349 }
tests/plugins/DashViews/listviewwithpageheadertest.cpp−6
@@ -1281,9 +1281,6 @@ private Q_SLOTS:
12811281
12821282 void testShowHeaderHalfShown()
12831283 {
1284−#if (QT_VERSION < QT_VERSION_CHECK(5, 1, 0))
1285− QSKIP("This test is extremely unstable in 5.0.x");
1286−#endif
12871284 changeContentY(20);
12881285
12891286 QTRY_COMPARE(lvwph->m_visibleItems.count(), 4);
@@ -1860,9 +1857,6 @@ private Q_SLOTS:
18601857 model->setProperty(4, "size", 10);
18611858 model->setProperty(5, "size", 10);
18621859 model->setProperty(6, "size", 10);
1863−#if (QT_VERSION > QT_VERSION_CHECK(5, 0, 3))
1864− QTRY_COMPARE(lvwph->m_minYExtent, 210.);
1865−#endif
18661860 QTRY_COMPARE(lvwph->m_headerItem->y(), -lvwph->m_minYExtent);
18671861 }
18681862
tests/plugins/DashViews/listviewwithpageheadertestsection.cpp−3
@@ -1486,9 +1486,6 @@ private Q_SLOTS:
14861486
14871487 void testShowHeaderHalfShown()
14881488 {
1489−#if (QT_VERSION < QT_VERSION_CHECK(5, 1, 0))
1490− QSKIP("This test is extremely unstable in 5.0.x");
1491−#endif
14921489 changeContentY(20);
14931490
14941491 QTRY_COMPARE(lvwph->m_visibleItems.count(), 3);
tests/qmltests/Components/tst_LazyImage.qml+1−1
@@ -155,7 +155,7 @@ Rectangle {
155155
156156 if (data.transition) {
157157 // wait for the transition to complete
158− var transition = findInvisibleChild(data.image, data.transition);
158+ var transition = findChildIn(data.image, "transitions", data.transition);
159159 tryCompare(transition, "running", true);
160160 tryCompare(transition, "running", false);
161161 }
tests/qmltests/Dash/Previews/tst_PreviewVideoPlayback.qml−6
@@ -53,12 +53,6 @@ Rectangle {
5353 function test_loadScreenshot() {
5454 var screenshot = findChild(videoPlayback, "screenshot");
5555
56− videoPlayback.widgetData = widgetData0;
57− tryCompare(screenshot.visible, false);
58−
59− videoPlayback.widgetData = widgetData1;
60− tryCompare(screenshot.visible, true);
61−
6256 videoPlayback.widgetData = widgetData2;
6357 var screenshotSource = screenshot.source
6458 verify(screenshotSource.toString().indexOf("image://thumbnailer/") === 0)
tests/qmltests/Dash/Previews/tst_PreviewZoomableImage.qml+3−4
@@ -30,14 +30,13 @@ Rectangle {
3030 }
3131
3232 property var widgetData1: {
33− "source": "../../graphics/phone_background.jpg",
33+ "source": Qt.resolvedUrl("../artwork/checkers.png"),
3434 "zoomable": false
3535 }
3636
3737 PreviewZoomableImage {
3838 id: zoomableImage
3939 width: parent.width
40− widgetData: widgetData1
4140 }
4241
4342 UT.UnityTestCase {
@@ -48,10 +47,10 @@ Rectangle {
4847 var image = findChild(zoomableImage, "image");
4948
5049 zoomableImage.widgetData = widgetData0;
51− tryCompare(image.state, "default");
50+ tryCompare(image, "state", "default");
5251
5352 zoomableImage.widgetData = widgetData1;
54− tryCompare(image.state, "ready");
53+ tryCompare(image, "state", "ready");
5554 }
5655 }
5756}
tests/qmltests/Dash/tst_CardHeader.qml+1−1
@@ -122,7 +122,7 @@ Rectangle {
122122 return [
123123 { tag: "Column width", object: column, width: cardHeader.width },
124124 { tag: "Column width with mascot", object: column, width: cardHeader.width - mascot.width - outerRow.margins * 3, mascot: "artwork/avatar.png" },
125− { tag: "Header height", object: cardHeader, height: function() { return subtitleLabel.y + subtitleLabel.height + outerRow.margins * 2 } },
125+ { tag: "Header height", object: cardHeader, height: function() { return outerRow.height + outerRow.margins * 2 } },
126126 ]
127127 }
128128
tests/qmltests/Dash/tst_GenericScopeView.qml+1−1
@@ -69,7 +69,7 @@ Item {
6969 function init() {
7070 shell.width = units.gu(120)
7171 genericScopeView.categoryView.positionAtBeginning();
72− tryCompare(genericScopeView.categoryView.contentY, 0)
72+ tryCompare(genericScopeView.categoryView, "contentY", 0)
7373 }
7474
7575 function test_isCurrent() {
tests/qmltests/Launcher/tst_Launcher.qml+6−4
@@ -121,8 +121,7 @@ Item {
121121 revealer.dragLauncherIntoView()
122122
123123 var listView = findChild(launcher, "launcherListView");
124− listView.flick(0, units.gu(500));
125− tryCompare(listView, "flicking", false);
124+ listView.positionViewAtEnd();
126125
127126 var appIcon = findChild(launcher, "launcherDelegate0")
128127
@@ -397,8 +396,11 @@ Item {
397396
398397 // Position launcher to where we need it
399398 var listView = findChild(launcher, "launcherListView");
400− listView.flick(0, units.gu(200) * (data.flickTo === "top" ? 1 : -1));
401− tryCompare(listView, "flicking", false);
399+ if (data.flickTo == "top") {
400+ listView.positionViewAtEnd();
401+ } else {
402+ listView.positionViewAtBeginning();
403+ }
402404
403405 // Doing longpress
404406 mousePress(draggedItem, draggedItem.width / 2, draggedItem.height / 2)
tests/qmltests/tst_Shell.qml+2−2
@@ -232,8 +232,8 @@ Item {
232232
233233 var dash = findChild(shell, "dash");
234234 // check that dash has normal scale and opacity
235− tryCompare(dash.contentScale, 1.0);
236− tryCompare(dash.opacity, 1.0);
235+ tryCompare(dash, "contentScale", 1.0);
236+ tryCompare(dash, "opacity", 1.0);
237237
238238 touchFlick(shell, touchX, touchY, shell.width * 0.1, touchY,
239239 true /* beginTouch */, false /* endTouch */);
tests/utils/modules/Unity/Test/UnityTestCase.qml+10−16
@@ -71,19 +71,8 @@ TestCase {
7171
7272
7373 // Find an object with the given name in the children tree of "obj"
74− function findChild(obj,objectName) {
75− var childs = new Array(0);
76− childs.push(obj)
77− while (childs.length > 0) {
78− if (childs[0].objectName == objectName) {
79− return childs[0]
80− }
81− for (var i in childs[0].children) {
82− childs.push(childs[0].children[i])
83− }
84− childs.splice(0, 1);
85− }
86− return null;
74+ function findChild(obj, objectName) {
75+ return findChildIn(obj, "children", objectName);
8776 }
8877
8978 // Find an object with the given name in the children tree of "obj"
@@ -91,15 +80,20 @@ TestCase {
9180 // Note: you should use findChild if you're not sure you need this
9281 // as this tree is much bigger and might contain stuff that goes
9382 // away randomly.
94− function findInvisibleChild(obj,objectName) {
83+ function findInvisibleChild(obj, objectName) {
84+ return findChildIn(obj, "data", objectName);
85+ }
86+
87+ // Find a child in the named property
88+ function findChildIn(obj, prop, objectName) {
9589 var childs = new Array(0);
9690 childs.push(obj)
9791 while (childs.length > 0) {
9892 if (childs[0].objectName == objectName) {
9993 return childs[0]
10094 }
101− for (var i in childs[0].data) {
102− childs.push(childs[0].data[i])
95+ for (var i in childs[0][prop]) {
96+ childs.push(childs[0][prop][i])
10397 }
10498 childs.splice(0, 1);
10599 }