Merge lp:~saviq/unity8/card-visual-tweaks into lp:unity8

Proposed by Michał Sawicz
Status: Superseded
Proposed branch: lp:~saviq/unity8/card-visual-tweaks
Merge into: lp:unity8
Diff against target: 2247 lines (+830/-318)
50 files modified
build.sh (+1/-0)
cmake/modules/QmlTest.cmake (+2/-1)
debian/control (+1/-0)
plugins/Dash/CardAttributes.qml (+1/-1)
plugins/Dash/CardCreator.js (+12/-10)
plugins/Dash/listviewwithpageheader.cpp (+28/-7)
plugins/Dash/listviewwithpageheader.h (+8/-0)
qml/Dash/CardGrid.qml (+2/-1)
qml/Dash/CardHorizontalList.qml (+1/-1)
qml/Dash/CardTool.qml (+27/-19)
qml/Dash/CardVerticalJournal.qml (+2/-1)
qml/Dash/DashContent.qml (+1/-0)
qml/Dash/DashRenderer.qml (+4/-0)
qml/Dash/GenericScopeView.qml (+111/-22)
qml/Dash/ScopeListView.qml (+1/-0)
qml/Dash/ScopesOverviewAll.qml (+2/-0)
qml/Dash/ScopesOverviewFavorites.qml (+1/-1)
tests/autopilot/unity8/shell/emulators/dash.py (+2/-2)
tests/mocks/Ubuntu/CMakeLists.txt (+1/-0)
tests/mocks/Ubuntu/Connectivity/CMakeLists.txt (+10/-0)
tests/mocks/Ubuntu/Connectivity/networking-status.cpp (+65/-0)
tests/mocks/Ubuntu/Connectivity/networking-status.h (+73/-0)
tests/mocks/Ubuntu/Connectivity/plugin.cpp (+46/-0)
tests/mocks/Ubuntu/Connectivity/plugin.h (+35/-0)
tests/mocks/Ubuntu/Connectivity/qmldir (+2/-0)
tests/mocks/Unity/fake_categories.cpp (+100/-141)
tests/mocks/Unity/fake_categories.h (+7/-12)
tests/mocks/Unity/fake_resultsmodel.cpp (+9/-0)
tests/mocks/Unity/fake_resultsmodel.h (+3/-0)
tests/mocks/Unity/fake_scope.cpp (+17/-0)
tests/mocks/Unity/fake_scope.h (+2/-0)
tests/plugins/Dash/CMakeLists.txt (+3/-3)
tests/plugins/Dash/cardcreator/1.res (+6/-5)
tests/plugins/Dash/cardcreator/2.res (+7/-7)
tests/plugins/Dash/cardcreator/3.res (+8/-8)
tests/plugins/Dash/cardcreator/4.res (+8/-8)
tests/plugins/Dash/cardcreator/5.res (+8/-8)
tests/plugins/Dash/cardcreator/6.res (+6/-8)
tests/plugins/Dash/cardcreator/7.res (+8/-8)
tests/plugins/Dash/listviewwithpageheadertest.cpp (+39/-0)
tests/plugins/Dash/listviewwithpageheadertest.qml (+1/-0)
tests/plugins/Dash/listviewwithpageheadertestsection.qml (+1/-0)
tests/plugins/Dash/listviewwithpageheadertestsectionexternalmodel.qml (+1/-0)
tests/plugins/Ubuntu/Gestures/CMakeLists.txt (+1/-1)
tests/qmltests/Components/CMakeLists.txt (+1/-1)
tests/qmltests/Dash/CardHelpers.js (+1/-12)
tests/qmltests/Dash/tst_Card.qml (+21/-0)
tests/qmltests/Dash/tst_CardTool.qml (+29/-21)
tests/qmltests/Dash/tst_Dash.qml (+1/-2)
tests/qmltests/Dash/tst_GenericScopeView.qml (+103/-7)
To merge this branch: bzr merge lp:~saviq/unity8/card-visual-tweaks
Reviewer Review Type Date Requested Status
PS Jenkins bot (community) continuous-integration Needs Fixing
Alejandro J. Cura (community) Needs Fixing
Review via email: mp+233392@code.launchpad.net

This proposal has been superseded by a proposal from 2014-09-11.

Commit message

Tweak card header to match the spec

- title is Medium only if subtitle is non-empty
- title is only centered if explicitly requested by the scope ("align": "center" in components), with only one allowed line
- subtitle is x-small
- highlighted attribute is Bold
- emblem is allowed non-square

Description of the change

* Are there any related MPs required for this MP to build/function as expected? Please list.
All scopes that want center alignment need to adapt
 * Did you perform an exploratory manual test run of your code change and any related functionality?
Y
 * Did you make sure that your branch does not contain spurious tags?
Y
 * If you changed the packaging (debian), did you subscribe the ubuntu-unity team to this MP?
N/A
 * If you changed the UI, has there been a design review?
This comes from design, see the referenced bugs.

To post a comment you must log in.
lp:~saviq/unity8/card-visual-tweaks updated
1234. By Michał Sawicz

Bigger coverage.

1235. By Michał Sawicz

Unneeded layout assignment.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Alejandro J. Cura (alecu) wrote :

Tested the debs produced by jenkins on mako, it looks much nicer overall, but the title is still centered by default.

I'm attaching a screenshot to show this.

review: Needs Fixing
Revision history for this message
Alejandro J. Cura (alecu) wrote :
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Chris Wayne (cwayne) wrote :

I've verified that this makes rectangular emblems look *much* better, but I'm still seeing the titles centered by default as well

lp:~saviq/unity8/card-visual-tweaks updated
1236. By Michał Sawicz

Fix title alignment test and binding, clean up old components from CardHelpers.js

1237. By Michał Sawicz

Fix typo

Revision history for this message
Michał Sawicz (saviq) wrote :

Yeah, shouldn't have worked so late... Fixed the tests and alignment, as well as the single-line enforcing, even though I expect we won't be doing that in the end.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Chris Wayne (cwayne) wrote :

Verified that emblems look better + Titles are now left-aligned as expected

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
lp:~saviq/unity8/card-visual-tweaks updated
1238. By Michał Sawicz

Merge trunk.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
lp:~saviq/unity8/card-visual-tweaks updated
1239. By Michał Sawicz

Merge lp:~unity-team/unity8/scopes_more_things_on_memory

Unmerged revisions

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'build.sh'
--- build.sh 2014-08-14 13:37:22 +0000
+++ build.sh 2014-09-11 16:03:35 +0000
@@ -51,6 +51,7 @@
51 qtdeclarative5-ubuntu-settings-components \51 qtdeclarative5-ubuntu-settings-components \
52 qtdeclarative5-ubuntu-telephony0.1 \52 qtdeclarative5-ubuntu-telephony0.1 \
53 qtdeclarative5-ubuntu-thumbnailer0.1 \53 qtdeclarative5-ubuntu-thumbnailer0.1 \
54 qml-module-ubuntu-connectivity \
54 unity-notifications-impl \55 unity-notifications-impl \
55 ubuntu-mobile-icons \56 ubuntu-mobile-icons \
56 unity-scope-home \57 unity-scope-home \
5758
=== modified file 'cmake/modules/QmlTest.cmake'
--- cmake/modules/QmlTest.cmake 2014-08-07 15:32:25 +0000
+++ cmake/modules/QmlTest.cmake 2014-09-11 16:03:35 +0000
@@ -131,7 +131,7 @@
131 add_manual_qml_test(${SUBPATH} ${COMPONENT_NAME} ${ARGN})131 add_manual_qml_test(${SUBPATH} ${COMPONENT_NAME} ${ARGN})
132endmacro(add_qml_test_internal)132endmacro(add_qml_test_internal)
133133
134macro(add_binary_qml_test CLASS_NAME LD_PATH DEPS)134macro(add_binary_qml_test CLASS_NAME LD_PATH DEPS ENVVAR)
135 set(testCommand135 set(testCommand
136 LD_LIBRARY_PATH=${LD_PATH}136 LD_LIBRARY_PATH=${LD_PATH}
137 ${CMAKE_CURRENT_BINARY_DIR}/${CLASS_NAME}TestExec137 ${CMAKE_CURRENT_BINARY_DIR}/${CLASS_NAME}TestExec
@@ -148,6 +148,7 @@
148 endif()148 endif()
149 set(xvfbtestCommand149 set(xvfbtestCommand
150 ${LD_PRELOAD_PATH}150 ${LD_PRELOAD_PATH}
151 ${ENVVAR}
151 LD_LIBRARY_PATH=${LD_PATH}152 LD_LIBRARY_PATH=${LD_PATH}
152 xvfb-run --server-args "-screen 0 1024x768x24" --auto-servernum153 xvfb-run --server-args "-screen 0 1024x768x24" --auto-servernum
153 ${CMAKE_CURRENT_BINARY_DIR}/${CLASS_NAME}TestExec154 ${CMAKE_CURRENT_BINARY_DIR}/${CLASS_NAME}TestExec
154155
=== modified file 'debian/control'
--- debian/control 2014-09-03 07:58:32 +0000
+++ debian/control 2014-09-11 16:03:35 +0000
@@ -173,6 +173,7 @@
173 libhardware2,173 libhardware2,
174 libunity-core-6.0-9,174 libunity-core-6.0-9,
175 pay-service,175 pay-service,
176 qml-module-ubuntu-connectivity,
176 ${misc:Depends},177 ${misc:Depends},
177 ${shlibs:Depends},178 ${shlibs:Depends},
178Provides: unity-launcher-impl,179Provides: unity-launcher-impl,
179180
=== modified file 'plugins/Dash/CardAttributes.qml'
--- plugins/Dash/CardAttributes.qml 2014-08-16 12:41:11 +0000
+++ plugins/Dash/CardAttributes.qml 2014-09-11 16:03:35 +0000
@@ -59,7 +59,7 @@
59 text: "value" in modelData && modelData["value"] || "";59 text: "value" in modelData && modelData["value"] || "";
60 elide: Text.ElideRight60 elide: Text.ElideRight
61 maximumLineCount: 161 maximumLineCount: 1
62 font.weight: "style" in modelData && modelData["style"] == "highlighted" ? Font.DemiBold : Font.Light62 font.weight: "style" in modelData && modelData["style"] === "highlighted" ? Font.Bold : Font.Light
63 fontSize: "small"63 fontSize: "small"
64 font.pixelSize: Math.round(FontUtils.sizeToPixels(fontSize) * fontScale)64 font.pixelSize: Math.round(FontUtils.sizeToPixels(fontSize) * fontScale)
65 color: grid.color65 color: grid.color
6666
=== modified file 'plugins/Dash/CardCreator.js'
--- plugins/Dash/CardCreator.js 2014-08-29 08:19:53 +0000
+++ plugins/Dash/CardCreator.js 2014-09-11 16:03:35 +0000
@@ -84,7 +84,8 @@
84 } \n\84 } \n\
85 image: Image { \n\85 image: Image { \n\
86 objectName: "artImage"; \n\86 objectName: "artImage"; \n\
87 source: cardData && cardData["art"] || ""; \n\87 property bool doLoadSource: !NetworkingStatus.limitedBandwith; \n\
88 source: { if (root.visible) doLoadSource = true; return doLoadSource && cardData && cardData["art"] || ""; } \n\
88 cache: true; \n\89 cache: true; \n\
89 asynchronous: root.asynchronous; \n\90 asynchronous: root.asynchronous; \n\
90 fillMode: Image.PreserveAspectCrop; \n\91 fillMode: Image.PreserveAspectCrop; \n\
@@ -195,7 +196,8 @@
195 objectName: "mascotImage"; \n\196 objectName: "mascotImage"; \n\
196 anchors { %1 } \n\197 anchors { %1 } \n\
197 readonly property int maxSize: Math.max(width, height) * 4; \n\198 readonly property int maxSize: Math.max(width, height) * 4; \n\
198 source: cardData && cardData["mascot"] || ""; \n\199 property bool doLoadSource: !NetworkingStatus.limitedBandwith; \n\
200 source: { if (root.visible) doLoadSource = true; return doLoadSource && cardData && cardData["mascot"] || ""; } \n\
199 width: units.gu(6); \n\201 width: units.gu(6); \n\
200 height: units.gu(5.625); \n\202 height: units.gu(5.625); \n\
201 sourceSize { width: maxSize; height: maxSize } \n\203 sourceSize { width: maxSize; height: maxSize } \n\
@@ -215,18 +217,18 @@
215 elide: Text.ElideRight; \n\217 elide: Text.ElideRight; \n\
216 fontSize: "small"; \n\218 fontSize: "small"; \n\
217 wrapMode: Text.Wrap; \n\219 wrapMode: Text.Wrap; \n\
218 maximumLineCount: 2; \n\220 maximumLineCount: horizontalAlignment === Text.AlignHCenter ? 1 : 2; \n\
219 font.pixelSize: Math.round(FontUtils.sizeToPixels(fontSize) * fontScale); \n\221 font.pixelSize: Math.round(FontUtils.sizeToPixels(fontSize) * fontScale); \n\
220 color: %2; \n\222 color: %2; \n\
221 visible: showHeader %3; \n\223 visible: showHeader %3; \n\
222 text: root.title; \n\224 text: root.title; \n\
223 font.weight: components && components["subtitle"] ? Font.DemiBold : Font.Normal; \n\225 font.weight: cardData && cardData["subtitle"] ? Font.DemiBold : Font.Normal; \n\
224 horizontalAlignment: root.headerAlignment; \n\226 horizontalAlignment: root.titleAlignment; \n\
225 }\n';227 }\n';
226228
227// %1 is used as extra anchors of emblemIcon229// %1 is used as extra anchors of emblemIcon
228// %2 is used as color of emblemIcon230// %2 is used as color of emblemIcon
229var kEmblemIconCode = 'Icon { \n\231var kEmblemIconCode = 'StatusIcon { \n\
230 id: emblemIcon; \n\232 id: emblemIcon; \n\
231 objectName: "emblemIcon"; \n\233 objectName: "emblemIcon"; \n\
232 anchors { \n\234 anchors { \n\
@@ -236,7 +238,6 @@
236 } \n\238 } \n\
237 source: cardData && cardData["emblem"] || ""; \n\239 source: cardData && cardData["emblem"] || ""; \n\
238 color: %2; \n\240 color: %2; \n\
239 width: height; \n\
240 height: source != "" ? titleLabel.font.pixelSize : 0; \n\241 height: source != "" ? titleLabel.font.pixelSize : 0; \n\
241 }\n';242 }\n';
242243
@@ -258,13 +259,12 @@
258 anchors { %1 } \n\259 anchors { %1 } \n\
259 anchors.topMargin: units.dp(2); \n\260 anchors.topMargin: units.dp(2); \n\
260 elide: Text.ElideRight; \n\261 elide: Text.ElideRight; \n\
261 fontSize: "small"; \n\262 fontSize: "x-small"; \n\
262 font.pixelSize: Math.round(FontUtils.sizeToPixels(fontSize) * fontScale); \n\263 font.pixelSize: Math.round(FontUtils.sizeToPixels(fontSize) * fontScale); \n\
263 color: %2; \n\264 color: %2; \n\
264 visible: titleLabel.visible && titleLabel.text; \n\265 visible: titleLabel.visible && titleLabel.text; \n\
265 text: cardData && cardData["subtitle"] || ""; \n\266 text: cardData && cardData["subtitle"] || ""; \n\
266 font.weight: Font.Light; \n\267 font.weight: Font.Light; \n\
267 horizontalAlignment: root.headerAlignment; \n\
268 }\n';268 }\n';
269269
270// %1 is used as anchors of attributesRow270// %1 is used as anchors of attributesRow
@@ -310,7 +310,7 @@
310 property var artShapeBorderSource: undefined; \n\310 property var artShapeBorderSource: undefined; \n\
311 property real fontScale: 1.0; \n\311 property real fontScale: 1.0; \n\
312 property var scopeStyle: null; \n\312 property var scopeStyle: null; \n\
313 property int headerAlignment: Text.AlignLeft; \n\313 property int titleAlignment: Text.AlignLeft; \n\
314 property int fixedHeaderHeight: -1; \n\314 property int fixedHeaderHeight: -1; \n\
315 property size fixedArtShapeSize: Qt.size(-1, -1); \n\315 property size fixedArtShapeSize: Qt.size(-1, -1); \n\
316 readonly property string title: cardData && cardData["title"] || ""; \n\316 readonly property string title: cardData && cardData["title"] || ""; \n\
@@ -655,6 +655,8 @@
655function createCardComponent(parent, template, components) {655function createCardComponent(parent, template, components) {
656 var imports = 'import QtQuick 2.2; \n\656 var imports = 'import QtQuick 2.2; \n\
657 import Ubuntu.Components 1.1; \n\657 import Ubuntu.Components 1.1; \n\
658 import Ubuntu.Settings.Components 0.1; \n\
659 import Ubuntu.Connectivity 1.0; \n\
658 import Dash 0.1;\n\660 import Dash 0.1;\n\
659 import Utils 0.1;\n';661 import Utils 0.1;\n';
660 var card = cardString(template, components);662 var card = cardString(template, components);
661663
=== modified file 'plugins/Dash/listviewwithpageheader.cpp'
--- plugins/Dash/listviewwithpageheader.cpp 2014-09-01 10:45:25 +0000
+++ plugins/Dash/listviewwithpageheader.cpp 2014-09-11 16:03:35 +0000
@@ -104,8 +104,6 @@
104#pragma GCC diagnostic pop104#pragma GCC diagnostic pop
105// #include <private/qquickrectangle_p.h>105// #include <private/qquickrectangle_p.h>
106106
107static const qreal bufferRatio = 0.5;
108
109qreal ListViewWithPageHeader::ListItem::height() const107qreal ListViewWithPageHeader::ListItem::height() const
110{108{
111 return m_item->height() + (m_sectionItem ? m_sectionItem->height() : 0);109 return m_item->height() + (m_sectionItem ? m_sectionItem->height() : 0);
@@ -158,6 +156,7 @@
158 , m_forceNoClip(false)156 , m_forceNoClip(false)
159 , m_inLayout(false)157 , m_inLayout(false)
160 , m_inContentHeightKeepHeaderShown(false)158 , m_inContentHeightKeepHeaderShown(false)
159 , m_cacheBuffer(0)
161{160{
162 m_clipItem = new QQuickItem(contentItem());161 m_clipItem = new QQuickItem(contentItem());
163// m_clipItem = new QQuickRectangle(contentItem());162// m_clipItem = new QQuickRectangle(contentItem());
@@ -335,6 +334,20 @@
335 return m_headerItemShownHeight;334 return m_headerItemShownHeight;
336}335}
337336
337qreal ListViewWithPageHeader::cacheBuffer() const
338{
339 return m_cacheBuffer;
340}
341
342void ListViewWithPageHeader::setCacheBuffer(qreal cacheBuffer)
343{
344 if (cacheBuffer != m_cacheBuffer) {
345 m_cacheBuffer = cacheBuffer;
346 Q_EMIT cacheBufferChanged();
347 polish();
348 }
349}
350
338void ListViewWithPageHeader::positionAtBeginning()351void ListViewWithPageHeader::positionAtBeginning()
339{352{
340 if (m_delegateModel->count() <= 0)353 if (m_delegateModel->count() <= 0)
@@ -356,8 +369,7 @@
356 // Create the subsequent items369 // Create the subsequent items
357 int modelIndex = 1;370 int modelIndex = 1;
358 qreal pos = item->y() + item->height();371 qreal pos = item->y() + item->height();
359 const qreal buffer = height() * bufferRatio;372 const qreal bufferTo = height() + m_cacheBuffer;
360 const qreal bufferTo = height() + buffer;
361 while (modelIndex < m_delegateModel->count() && pos <= bufferTo) {373 while (modelIndex < m_delegateModel->count() && pos <= bufferTo) {
362 if (!(item = createItem(modelIndex, false)))374 if (!(item = createItem(modelIndex, false)))
363 break;375 break;
@@ -409,6 +421,16 @@
409 }421 }
410}422}
411423
424Q_INVOKABLE int ListViewWithPageHeader::firstCreatedIndex() const
425{
426 return m_firstVisibleIndex;
427}
428
429Q_INVOKABLE int ListViewWithPageHeader::createdItemCount() const
430{
431 return m_visibleItems.count();
432}
433
412QQuickItem *ListViewWithPageHeader::item(int modelIndex) const434QQuickItem *ListViewWithPageHeader::item(int modelIndex) const
413{435{
414 ListItem *item = itemAtIndex(modelIndex);436 ListItem *item = itemAtIndex(modelIndex);
@@ -593,11 +615,10 @@
593 return;615 return;
594 }616 }
595617
596 const qreal buffer = height() * bufferRatio;
597 const qreal from = contentY();618 const qreal from = contentY();
598 const qreal to = from + height();619 const qreal to = from + height();
599 const qreal bufferFrom = from - buffer;620 const qreal bufferFrom = from - m_cacheBuffer;
600 const qreal bufferTo = to + buffer;621 const qreal bufferTo = to + m_cacheBuffer;
601622
602 bool added = addVisibleItems(from, to, false);623 bool added = addVisibleItems(from, to, false);
603 bool removed = removeNonVisibleItems(bufferFrom, bufferTo);624 bool removed = removeNonVisibleItems(bufferFrom, bufferTo);
604625
=== modified file 'plugins/Dash/listviewwithpageheader.h'
--- plugins/Dash/listviewwithpageheader.h 2014-09-01 10:45:25 +0000
+++ plugins/Dash/listviewwithpageheader.h 2014-09-11 16:03:35 +0000
@@ -54,6 +54,7 @@
54 Q_PROPERTY(bool forceNoClip READ forceNoClip WRITE setForceNoClip NOTIFY forceNoClipChanged)54 Q_PROPERTY(bool forceNoClip READ forceNoClip WRITE setForceNoClip NOTIFY forceNoClipChanged)
55 Q_PROPERTY(int stickyHeaderHeight READ stickyHeaderHeight NOTIFY stickyHeaderHeightChanged)55 Q_PROPERTY(int stickyHeaderHeight READ stickyHeaderHeight NOTIFY stickyHeaderHeightChanged)
56 Q_PROPERTY(qreal headerItemShownHeight READ headerItemShownHeight NOTIFY headerItemShownHeightChanged)56 Q_PROPERTY(qreal headerItemShownHeight READ headerItemShownHeight NOTIFY headerItemShownHeightChanged)
57 Q_PROPERTY(qreal cacheBuffer READ cacheBuffer WRITE setCacheBuffer NOTIFY cacheBufferChanged)
5758
58 friend class ListViewWithPageHeaderTest;59 friend class ListViewWithPageHeaderTest;
59 friend class ListViewWithPageHeaderTestSection;60 friend class ListViewWithPageHeaderTestSection;
@@ -84,8 +85,13 @@
84 int stickyHeaderHeight() const;85 int stickyHeaderHeight() const;
85 qreal headerItemShownHeight() const;86 qreal headerItemShownHeight() const;
8687
88 qreal cacheBuffer() const;
89 void setCacheBuffer(qreal cacheBuffer);
90
87 Q_INVOKABLE void positionAtBeginning();91 Q_INVOKABLE void positionAtBeginning();
88 Q_INVOKABLE void showHeader();92 Q_INVOKABLE void showHeader();
93 Q_INVOKABLE int firstCreatedIndex() const;
94 Q_INVOKABLE int createdItemCount() const;
89 Q_INVOKABLE QQuickItem *item(int modelIndex) const;95 Q_INVOKABLE QQuickItem *item(int modelIndex) const;
9096
91 // The index has to be created for this to try to do something97 // The index has to be created for this to try to do something
@@ -103,6 +109,7 @@
103 void forceNoClipChanged();109 void forceNoClipChanged();
104 void stickyHeaderHeightChanged();110 void stickyHeaderHeightChanged();
105 void headerItemShownHeightChanged();111 void headerItemShownHeightChanged();
112 void cacheBufferChanged();
106113
107protected:114protected:
108 void componentComplete() override;115 void componentComplete() override;
@@ -197,6 +204,7 @@
197 bool m_forceNoClip;204 bool m_forceNoClip;
198 bool m_inLayout;205 bool m_inLayout;
199 bool m_inContentHeightKeepHeaderShown;206 bool m_inContentHeightKeepHeaderShown;
207 qreal m_cacheBuffer;
200208
201 // Qt 5.0 doesn't like releasing the items just after itemCreated209 // Qt 5.0 doesn't like releasing the items just after itemCreated
202 // so we delay the releasing until the next updatePolish210 // so we delay the releasing until the next updatePolish
203211
=== modified file 'qml/Dash/CardGrid.qml'
--- qml/Dash/CardGrid.qml 2014-07-29 08:57:29 +0000
+++ qml/Dash/CardGrid.qml 2014-09-11 16:03:35 +0000
@@ -55,6 +55,7 @@
55 delegate: Item {55 delegate: Item {
56 width: grid.cellWidth56 width: grid.cellWidth
57 height: grid.cellHeight57 height: grid.cellHeight
58 visible: y + height >= root.visibleRangeBegin && y <= root.visibleRangeEnd
58 Loader {59 Loader {
59 id: loader60 id: loader
60 sourceComponent: cardTool.cardComponent61 sourceComponent: cardTool.cardComponent
@@ -68,7 +69,7 @@
68 item.cardData = Qt.binding(function() { return model; });69 item.cardData = Qt.binding(function() { return model; });
69 item.template = Qt.binding(function() { return cardTool.template; });70 item.template = Qt.binding(function() { return cardTool.template; });
70 item.components = Qt.binding(function() { return cardTool.components; });71 item.components = Qt.binding(function() { return cardTool.components; });
71 item.headerAlignment = Qt.binding(function() { return cardTool.headerAlignment; });72 item.titleAlignment = Qt.binding(function() { return cardTool.titleAlignment; });
72 item.scopeStyle = root.scopeStyle;73 item.scopeStyle = root.scopeStyle;
73 }74 }
74 Connections {75 Connections {
7576
=== modified file 'qml/Dash/CardHorizontalList.qml'
--- qml/Dash/CardHorizontalList.qml 2014-08-15 14:21:42 +0000
+++ qml/Dash/CardHorizontalList.qml 2014-09-11 16:03:35 +0000
@@ -49,7 +49,7 @@
49 item.cardData = Qt.binding(function() { return model; });49 item.cardData = Qt.binding(function() { return model; });
50 item.template = Qt.binding(function() { return cardTool.template; });50 item.template = Qt.binding(function() { return cardTool.template; });
51 item.components = Qt.binding(function() { return cardTool.components; });51 item.components = Qt.binding(function() { return cardTool.components; });
52 item.headerAlignment = Qt.binding(function() { return cardTool.headerAlignment; });52 item.titleAlignment = Qt.binding(function() { return cardTool.titleAlignment; });
53 item.scopeStyle = root.scopeStyle;53 item.scopeStyle = root.scopeStyle;
54 }54 }
55 Connections {55 Connections {
5656
=== modified file 'qml/Dash/CardTool.qml'
--- qml/Dash/CardTool.qml 2014-09-08 14:11:57 +0000
+++ qml/Dash/CardTool.qml 2014-09-11 16:03:35 +0000
@@ -131,21 +131,26 @@
131 property size artShapeSize: cardLoader.item ? cardLoader.item.artShapeSize : 0131 property size artShapeSize: cardLoader.item ? cardLoader.item.artShapeSize : 0
132132
133 /*!133 /*!
134 \brief Desired alignment of header components.134 \brief Desired alignment of title
135 */135 */
136 readonly property int headerAlignment: {136 readonly property int titleAlignment: {
137 var subtitle = components["subtitle"];137 if (template["card-layout"] === "horizontal"
138 var price = components["price"];138 || typeof components["title"] !== "object"
139 var summary = components["summary"];139 || components["title"]["align"] !== "center") return Text.AlignLeft;
140140
141 var hasSubtitle = subtitle && (typeof subtitle === "string" || subtitle["field"])141 var keys = ["mascot", "emblem", "subtitle", "attributes", "summary"];
142 var hasPrice = price && (typeof price === "string" || subtitle["field"]);142
143 var hasSummary = summary && (typeof summary === "string" || summary["field"])143 for (var key in keys) {
144144 key = keys[key];
145 var isOnlyTextComponent = !hasSubtitle && !hasPrice && !hasSummary;145 try {
146 if (!isOnlyTextComponent) return Text.AlignLeft;146 if (typeof components[key] === "string"
147147 || typeof components[key]["field"] === "string") return Text.AlignLeft;
148 return (template["card-layout"] === "horizontal") ? Text.AlignLeft : Text.AlignHCenter;148 } catch (e) {
149 continue;
150 }
151 }
152
153 return Text.AlignHCenter;
149 }154 }
150155
151 QtObject {156 QtObject {
@@ -169,16 +174,19 @@
169174
170 Item {175 Item {
171 id: attributesModel176 id: attributesModel
172 property int numOfAttributes: {177 property int numOfAttributes: 0
178 property var model: []
179 property bool hasAttributes: {
173 var attributes = components["attributes"];180 var attributes = components["attributes"];
174 if ((attributes != undefined) && attributes["field"]) {181 var hasAttributesFlag = (attributes != undefined) && attributes["field"];
182
183 if (hasAttributesFlag) {
175 if (attributes["max-count"]) {184 if (attributes["max-count"]) {
176 return attributes["max-count"];185 numOfAttributes = attributes["max-count"];
177 }186 }
178 }187 }
179 return 0;188 return hasAttributesFlag
180 }189 }
181 property var model: []
182190
183 onNumOfAttributesChanged: {191 onNumOfAttributesChanged: {
184 model = []192 model = []
185193
=== modified file 'qml/Dash/CardVerticalJournal.qml'
--- qml/Dash/CardVerticalJournal.qml 2014-07-29 08:57:29 +0000
+++ qml/Dash/CardVerticalJournal.qml 2014-09-11 16:03:35 +0000
@@ -49,6 +49,7 @@
49 id: loader49 id: loader
50 sourceComponent: cardTool.cardComponent50 sourceComponent: cardTool.cardComponent
51 width: cardTool.cardWidth51 width: cardTool.cardWidth
52 visible: y + height >= root.visibleRangeBegin && y <= root.visibleRangeEnd
52 onLoaded: {53 onLoaded: {
53 item.objectName = "delegate" + index;54 item.objectName = "delegate" + index;
54 item.fixedArtShapeSize = Qt.binding(function() { return cardTool.artShapeSize; });55 item.fixedArtShapeSize = Qt.binding(function() { return cardTool.artShapeSize; });
@@ -56,7 +57,7 @@
56 item.cardData = Qt.binding(function() { return model; });57 item.cardData = Qt.binding(function() { return model; });
57 item.template = Qt.binding(function() { return cardTool.template; });58 item.template = Qt.binding(function() { return cardTool.template; });
58 item.components = Qt.binding(function() { return cardTool.components; });59 item.components = Qt.binding(function() { return cardTool.components; });
59 item.headerAlignment = Qt.binding(function() { return cardTool.headerAlignment; });60 item.titleAlignment = Qt.binding(function() { return cardTool.titleAlignment; });
60 item.scopeStyle = root.scopeStyle;61 item.scopeStyle = root.scopeStyle;
61 }62 }
62 Connections {63 Connections {
6364
=== modified file 'qml/Dash/DashContent.qml'
--- qml/Dash/DashContent.qml 2014-08-27 15:35:52 +0000
+++ qml/Dash/DashContent.qml 2014-09-11 16:03:35 +0000
@@ -177,6 +177,7 @@
177 dashContent.scopeLoaded(item.scope.id)177 dashContent.scopeLoaded(item.scope.id)
178 item.paginationCount = Qt.binding(function() { return dashContentList.count } )178 item.paginationCount = Qt.binding(function() { return dashContentList.count } )
179 item.paginationIndex = Qt.binding(function() { return dashContentList.currentIndex } )179 item.paginationIndex = Qt.binding(function() { return dashContentList.currentIndex } )
180 item.holdingList = dashContentList;
180 }181 }
181 Connections {182 Connections {
182 target: isCurrent ? scope : null183 target: isCurrent ? scope : null
183184
=== modified file 'qml/Dash/DashRenderer.qml'
--- qml/Dash/DashRenderer.qml 2014-07-29 08:57:29 +0000
+++ qml/Dash/DashRenderer.qml 2014-09-11 16:03:35 +0000
@@ -27,6 +27,10 @@
2727
28 property int displayMarginEnd: 028 property int displayMarginEnd: 0
2929
30 property int visibleRangeBegin: 0
31
32 property int visibleRangeEnd: 0
33
30 property real originY: 034 property real originY: 0
3135
32 // The model to renderer36 // The model to renderer
3337
=== modified file 'qml/Dash/GenericScopeView.qml'
--- qml/Dash/GenericScopeView.qml 2014-09-08 14:15:01 +0000
+++ qml/Dash/GenericScopeView.qml 2014-09-11 16:03:35 +0000
@@ -38,6 +38,7 @@
38 property int paginationCount: 038 property int paginationCount: 0
39 property int paginationIndex: 039 property int paginationIndex: 0
40 property alias pageHeaderTotallyVisible: categoryView.pageHeaderTotallyVisible40 property alias pageHeaderTotallyVisible: categoryView.pageHeaderTotallyVisible
41 property var holdingList: null
4142
42 property var scopeStyle: ScopeStyle {43 property var scopeStyle: ScopeStyle {
43 style: scope ? scope.customizations : {}44 style: scope ? scope.customizations : {}
@@ -47,6 +48,10 @@
4748
48 signal backClicked()49 signal backClicked()
4950
51 onScopeChanged: {
52 floatingSeeLess.companionBase = null;
53 }
54
50 function positionAtBeginning() {55 function positionAtBeginning() {
51 categoryView.positionAtBeginning()56 categoryView.positionAtBeginning()
52 }57 }
@@ -152,11 +157,55 @@
152 forceNoClip: subPageLoader.open157 forceNoClip: subPageLoader.open
153 pixelAligned: true158 pixelAligned: true
154159
155 property Item expandedCategoryItem: null160 property string expandedCategoryId: ""
161 property int runMaximizeAfterSizeChanges: 0
156162
157 readonly property bool pageHeaderTotallyVisible: scopeView.showPageHeader &&163 readonly property bool pageHeaderTotallyVisible: scopeView.showPageHeader &&
158 ((headerItemShownHeight == 0 && categoryView.contentY <= categoryView.originY) || (headerItemShownHeight == pageHeaderLoader.item.height))164 ((headerItemShownHeight == 0 && categoryView.contentY <= categoryView.originY) || (headerItemShownHeight == pageHeaderLoader.item.height))
159165
166 onExpandedCategoryIdChanged: {
167 var firstCreated = firstCreatedIndex();
168 var shrinkingAny = false;
169 var shrinkHeightDifference = 0;
170 for (var i = 0; i < createdItemCount(); ++i) {
171 var baseItem = item(firstCreated + i);
172 if (baseItem.expandable) {
173 var shouldExpand = baseItem.category === expandedCategoryId;
174 if (shouldExpand != baseItem.expanded) {
175
176 var animate = false;
177 if (!subPageLoader.open) {
178 var animateShrinking = !shouldExpand && baseItem.y + baseItem.item.collapsedHeight + baseItem.seeAll.height < categoryView.height;
179 var animateGrowing = shouldExpand && baseItem.y + baseItem.height < categoryView.height;
180 animate = shrinkingAny || animateShrinking || animateGrowing;
181 }
182
183 if (!shouldExpand) {
184 shrinkingAny = true;
185 shrinkHeightDifference = baseItem.item.expandedHeight - baseItem.item.collapsedHeight;
186 }
187
188 if (shouldExpand && !subPageLoader.open) {
189 if (!shrinkingAny) {
190 categoryView.maximizeVisibleArea(firstCreated + i, baseItem.item.expandedHeight + baseItem.seeAll.height);
191 } else {
192 // If the space that shrkinking is smaller than the one we need to grow we'll call maximizeVisibleArea
193 // after the shrink/grow animation ends
194 var growHeightDifference = baseItem.item.expandedHeight - baseItem.item.collapsedHeight;
195 if (growHeightDifference > shrinkHeightDifference) {
196 runMaximizeAfterSizeChanges = 2;
197 } else {
198 runMaximizeAfterSizeChanges = 0;
199 }
200 }
201 }
202
203 baseItem.expand(shouldExpand, animate);
204 }
205 }
206 }
207 }
208
160 delegate: ListItems.Base {209 delegate: ListItems.Base {
161 id: baseItem210 id: baseItem
162 objectName: "dashCategory" + category211 objectName: "dashCategory" + category
@@ -175,6 +224,7 @@
175 readonly property string category: categoryId224 readonly property string category: categoryId
176 readonly property string headerLink: model.headerLink225 readonly property string headerLink: model.headerLink
177 readonly property var item: rendererLoader.item226 readonly property var item: rendererLoader.item
227 readonly property var seeAll: seeAll
178228
179 function expand(expand, animate) {229 function expand(expand, animate) {
180 heightBehaviour.enabled = animate;230 heightBehaviour.enabled = animate;
@@ -194,13 +244,13 @@
194 // This can happen with the VJ that doesn't know how height it will be on creation244 // This can happen with the VJ that doesn't know how height it will be on creation
195 // so doesn't set expandable until a bit too late for onLoaded245 // so doesn't set expandable until a bit too late for onLoaded
196 if (expandable) {246 if (expandable) {
197 var shouldExpand = baseItem === categoryView.expandedCategoryItem;247 var shouldExpand = baseItem.category === categoryView.expandedCategoryId;
198 baseItem.expand(shouldExpand, false /*animate*/);248 baseItem.expand(shouldExpand, false /*animate*/);
199 }249 }
200 }250 }
201251
202 onHeightChanged: rendererLoader.updateDelegateCreationRange();252 onHeightChanged: rendererLoader.updateRanges();
203 onYChanged: rendererLoader.updateDelegateCreationRange();253 onYChanged: rendererLoader.updateRanges();
204254
205 Loader {255 Loader {
206 id: rendererLoader256 id: rendererLoader
@@ -215,9 +265,23 @@
215 id: heightBehaviour265 id: heightBehaviour
216 enabled: false266 enabled: false
217 animation: UbuntuNumberAnimation {267 animation: UbuntuNumberAnimation {
268 duration: UbuntuAnimation.FastDuration
218 onRunningChanged: {269 onRunningChanged: {
219 if (!running) {270 if (!running) {
220 heightBehaviour.enabled = false271 heightBehaviour.enabled = false
272 if (categoryView.runMaximizeAfterSizeChanges > 0) {
273 categoryView.runMaximizeAfterSizeChanges--;
274 if (categoryView.runMaximizeAfterSizeChanges == 0) {
275 var firstCreated = categoryView.firstCreatedIndex();
276 for (var i = 0; i < categoryView.createdItemCount(); ++i) {
277 var baseItem = categoryView.item(firstCreated + i);
278 if (baseItem.category === categoryView.expandedCategoryId) {
279 categoryView.maximizeVisibleArea(firstCreated + i, baseItem.item.expandedHeight + baseItem.seeAll.height);
280 break;
281 }
282 }
283 }
284 }
221 }285 }
222 }286 }
223 }287 }
@@ -245,10 +309,10 @@
245 item.objectName = Qt.binding(function() { return categoryId })309 item.objectName = Qt.binding(function() { return categoryId })
246 item.scopeStyle = scopeView.scopeStyle;310 item.scopeStyle = scopeView.scopeStyle;
247 if (baseItem.expandable) {311 if (baseItem.expandable) {
248 var shouldExpand = baseItem === categoryView.expandedCategoryItem;312 var shouldExpand = baseItem.category === categoryView.expandedCategoryId;
249 baseItem.expand(shouldExpand, false /*animate*/);313 baseItem.expand(shouldExpand, false /*animate*/);
250 }314 }
251 updateDelegateCreationRange();315 updateRanges();
252 if (scope && scope.id === "clickscope" && (categoryId === "predefined" || categoryId === "local")) {316 if (scope && scope.id === "clickscope" && (categoryId === "predefined" || categoryId === "local")) {
253 // Yeah, hackish :/317 // Yeah, hackish :/
254 cardTool.artShapeSize = Qt.size(units.gu(8), units.gu(7.5));318 cardTool.artShapeSize = Qt.size(units.gu(8), units.gu(7.5));
@@ -303,13 +367,25 @@
303 }367 }
304 }368 }
305 }369 }
306 onOriginYChanged: rendererLoader.updateDelegateCreationRange();370 onOriginYChanged: rendererLoader.updateRanges();
307 onContentYChanged: rendererLoader.updateDelegateCreationRange();371 onContentYChanged: rendererLoader.updateRanges();
308 onHeightChanged: rendererLoader.updateDelegateCreationRange();372 onHeightChanged: rendererLoader.updateRanges();
309 onContentHeightChanged: rendererLoader.updateDelegateCreationRange();373 onContentHeightChanged: rendererLoader.updateRanges();
310 }374 }
311375 Connections {
312 function updateDelegateCreationRange() {376 target: scopeView
377 onIsCurrentChanged: rendererLoader.updateRanges();
378 }
379 Connections {
380 target: holdingList
381 onMovingChanged: if (!moving) rendererLoader.updateRanges();
382 }
383
384 function updateRanges() {
385 if (holdingList && holdingList.moving) {
386 return;
387 }
388
313 if (categoryView.moving) {389 if (categoryView.moving) {
314 // Do not update the range if we are overshooting up or down, since we'll come back390 // Do not update the range if we are overshooting up or down, since we'll come back
315 // to the stable position and delete/create items without any reason391 // to the stable position and delete/create items without any reason
@@ -321,10 +397,18 @@
321 }397 }
322 }398 }
323399
400 if (item && item.hasOwnProperty("visibleRangeBegin")) {
401 item.visibleRangeBegin = Math.max(-baseItem.y, 0)
402 item.visibleRangeEnd = item.visibleRangeBegin + Math.min(categoryView.height, rendererLoader.height)
403 }
404
324 if (item && item.hasOwnProperty("displayMarginBeginning")) {405 if (item && item.hasOwnProperty("displayMarginBeginning")) {
325 // TODO do we need item.originY here, test 1300302 once we have a silo406 // TODO do we need item.originY here, test 1300302 once we have a silo
326 // and we can run it on the phone407 // and we can run it on the phone
327 if (baseItem.y + baseItem.height <= 0) {408 if (scopeView.isCurrent) {
409 item.displayMarginBeginning = 1073741823;
410 item.displayMarginEnd = 1073741823;
411 } else if (baseItem.y + baseItem.height <= 0) {
328 // Not visible (item at top of the list viewport)412 // Not visible (item at top of the list viewport)
329 item.displayMarginBeginning = -baseItem.height;413 item.displayMarginBeginning = -baseItem.height;
330 item.displayMarginEnd = 0;414 item.displayMarginEnd = 0;
@@ -333,9 +417,9 @@
333 item.displayMarginBeginning = 0;417 item.displayMarginBeginning = 0;
334 item.displayMarginEnd = -baseItem.height;418 item.displayMarginEnd = -baseItem.height;
335 } else {419 } else {
336 item.displayMarginBeginning = -Math.max(-baseItem.y, 0);420 item.displayMarginBeginning = Math.round(-Math.max(-baseItem.y, 0));
337 item.displayMarginEnd = -Math.max(baseItem.height - seeAll.height421 item.displayMarginEnd = -Math.round(Math.max(baseItem.height - seeAll.height
338 - categoryView.height + baseItem.y, 0)422 - categoryView.height + baseItem.y, 0));
339 }423 }
340 }424 }
341 }425 }
@@ -352,10 +436,11 @@
352 height: seeAllLabel.visible ? seeAllLabel.font.pixelSize + units.gu(4) : 0436 height: seeAllLabel.visible ? seeAllLabel.font.pixelSize + units.gu(4) : 0
353437
354 onClicked: {438 onClicked: {
355 if (categoryView.expandedCategoryItem !== baseItem) {439 if (categoryView.expandedCategoryId !== baseItem.category) {
356 categoryView.expandedCategoryItem = baseItem;440 categoryView.expandedCategoryId = baseItem.category;
441 floatingSeeLess.companionBase = baseItem;
357 } else {442 } else {
358 categoryView.expandedCategoryItem = null;443 categoryView.expandedCategoryId = "";
359 }444 }
360 }445 }
361446
@@ -455,7 +540,7 @@
455 objectName: "floatingSeeLess"540 objectName: "floatingSeeLess"
456541
457 property Item companionTo: companionBase ? companionBase.seeAllButton : null542 property Item companionTo: companionBase ? companionBase.seeAllButton : null
458 property Item companionBase: categoryView.expandedCategoryItem543 property Item companionBase: null
459 property bool showBecausePosition: false544 property bool showBecausePosition: false
460 property real yOffset: 0545 property real yOffset: 0
461546
@@ -467,7 +552,7 @@
467 height: seeLessLabel.font.pixelSize + units.gu(4)552 height: seeLessLabel.font.pixelSize + units.gu(4)
468 visible: companionTo && showBecausePosition553 visible: companionTo && showBecausePosition
469554
470 onClicked: categoryView.expandedCategoryItem = null;555 onClicked: categoryView.expandedCategoryId = "";
471556
472 function updateVisibility() {557 function updateVisibility() {
473 var companionPos = companionTo.mapToItem(floatingSeeLess, 0, 0);558 var companionPos = companionTo.mapToItem(floatingSeeLess, 0, 0);
@@ -476,6 +561,10 @@
476 var posToBase = floatingSeeLess.mapToItem(companionBase, 0, -yOffset).y;561 var posToBase = floatingSeeLess.mapToItem(companionBase, 0, -yOffset).y;
477 yOffset = Math.max(0, companionBase.item.collapsedHeight - posToBase);562 yOffset = Math.max(0, companionBase.item.collapsedHeight - posToBase);
478 yOffset = Math.min(yOffset, height);563 yOffset = Math.min(yOffset, height);
564
565 if (!showBecausePosition && categoryView.expandedCategoryId === "") {
566 companionBase = null;
567 }
479 }568 }
480569
481 Label {570 Label {
482571
=== modified file 'qml/Dash/ScopeListView.qml'
--- qml/Dash/ScopeListView.qml 2014-07-23 06:54:10 +0000
+++ qml/Dash/ScopeListView.qml 2014-09-11 16:03:35 +0000
@@ -20,4 +20,5 @@
20ListViewWithPageHeader {20ListViewWithPageHeader {
21 maximumFlickVelocity: height * 1021 maximumFlickVelocity: height * 10
22 flickDeceleration: height * 222 flickDeceleration: height * 2
23 cacheBuffer: Number.MAX_VALUE
23}24}
2425
=== modified file 'qml/Dash/ScopesOverviewAll.qml'
--- qml/Dash/ScopesOverviewAll.qml 2014-07-25 08:47:40 +0000
+++ qml/Dash/ScopesOverviewAll.qml 2014-09-11 16:03:35 +0000
@@ -43,6 +43,8 @@
43 id: cardGrid43 id: cardGrid
44 width: root.width44 width: root.width
45 height: parent.height45 height: parent.height
46 visibleRangeBegin: root.contentY
47 visibleRangeEnd: root.contentY + root.height
4648
47 onClicked: {49 onClicked: {
48 root.clicked(index, result, item, itemModel);50 root.clicked(index, result, item, itemModel);
4951
=== modified file 'qml/Dash/ScopesOverviewFavorites.qml'
--- qml/Dash/ScopesOverviewFavorites.qml 2014-07-30 10:14:35 +0000
+++ qml/Dash/ScopesOverviewFavorites.qml 2014-09-11 16:03:35 +0000
@@ -61,7 +61,7 @@
61 item.cardData = Qt.binding(function() { return model; });61 item.cardData = Qt.binding(function() { return model; });
62 item.template = Qt.binding(function() { return cardTool.template; });62 item.template = Qt.binding(function() { return cardTool.template; });
63 item.components = Qt.binding(function() { return cardTool.components; });63 item.components = Qt.binding(function() { return cardTool.components; });
64 item.headerAlignment = Qt.binding(function() { return cardTool.headerAlignment; });64 item.titleAlignment = Qt.binding(function() { return cardTool.titleAlignment; });
65 }65 }
6666
67 Connections {67 Connections {
6868
=== modified file 'tests/autopilot/unity8/shell/emulators/dash.py'
--- tests/autopilot/unity8/shell/emulators/dash.py 2014-08-25 16:07:45 +0000
+++ tests/autopilot/unity8/shell/emulators/dash.py 2014-09-11 16:03:35 +0000
@@ -93,7 +93,7 @@
93 'No scope found with id {0}'.format(scope_id))93 'No scope found with id {0}'.format(scope_id))
9494
95 def _get_scope_from_loader(self, loader):95 def _get_scope_from_loader(self, loader):
96 return loader.get_children()[0]96 return loader.wait_select_single('GenericScopeView');
9797
98 def _open_scope_scrolling(self, scope_loader):98 def _open_scope_scrolling(self, scope_loader):
99 scroll = self._get_scroll_direction(scope_loader)99 scroll = self._get_scroll_direction(scope_loader)
@@ -102,8 +102,8 @@
102 scroll()102 scroll()
103 self.dash_content_list.moving.wait_for(False)103 self.dash_content_list.moving.wait_for(False)
104104
105 scope_loader.isCurrent.wait_for(True)
105 scope = self._get_scope_from_loader(scope_loader)106 scope = self._get_scope_from_loader(scope_loader)
106 scope.isCurrent.wait_for(True)
107 return scope107 return scope
108108
109 def _get_scroll_direction(self, scope_loader):109 def _get_scroll_direction(self, scope_loader):
110110
=== modified file 'tests/mocks/Ubuntu/CMakeLists.txt'
--- tests/mocks/Ubuntu/CMakeLists.txt 2014-08-25 10:05:13 +0000
+++ tests/mocks/Ubuntu/CMakeLists.txt 2014-09-11 16:03:35 +0000
@@ -1,3 +1,4 @@
1add_subdirectory(Connectivity)
1add_subdirectory(DownloadDaemonListener)2add_subdirectory(DownloadDaemonListener)
2add_subdirectory(Payments)3add_subdirectory(Payments)
3add_subdirectory(SystemImage)4add_subdirectory(SystemImage)
45
=== added directory 'tests/mocks/Ubuntu/Connectivity'
=== added file 'tests/mocks/Ubuntu/Connectivity/CMakeLists.txt'
--- tests/mocks/Ubuntu/Connectivity/CMakeLists.txt 1970-01-01 00:00:00 +0000
+++ tests/mocks/Ubuntu/Connectivity/CMakeLists.txt 2014-09-11 16:03:35 +0000
@@ -0,0 +1,10 @@
1add_library(connectivity-qml SHARED
2 networking-status.cpp
3 plugin.cpp
4)
5qt5_use_modules(connectivity-qml Qml)
6
7# copy qmldir file into build directory for shadow builds
8file(COPY "${CMAKE_CURRENT_SOURCE_DIR}/qmldir"
9 DESTINATION ${CMAKE_CURRENT_BINARY_DIR}
10 )
011
=== added file 'tests/mocks/Ubuntu/Connectivity/networking-status.cpp'
--- tests/mocks/Ubuntu/Connectivity/networking-status.cpp 1970-01-01 00:00:00 +0000
+++ tests/mocks/Ubuntu/Connectivity/networking-status.cpp 2014-09-11 16:03:35 +0000
@@ -0,0 +1,65 @@
1/*
2 * Copyright © 2013 Canonical Ltd.
3 *
4 * This program is free software: you can redistribute it and/or modify it
5 * under the terms of the GNU Lesser General Public License version 3,
6 * as published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authors:
17 * Antti Kaijanmäki <antti.kaijanmaki@canonical.com>
18 */
19
20#include "networking-status.h"
21
22NetworkingStatus::NetworkingStatus(QObject *parent)
23 : QObject(parent)
24{
25
26 qRegisterMetaType<NetworkingStatus::Limitations>();
27 qRegisterMetaType<QVector<NetworkingStatus::Limitations>>();
28 qRegisterMetaType<NetworkingStatus::Status>();
29}
30
31NetworkingStatus::~NetworkingStatus()
32{}
33
34QVector<NetworkingStatus::Limitations>
35NetworkingStatus::limitations() const
36{
37 return m_limitations;
38}
39
40NetworkingStatus::Status
41NetworkingStatus::status() const
42{
43 return Status::Online;
44}
45
46bool
47NetworkingStatus::online() const
48{
49 return status() == Status::Online;
50}
51
52bool
53NetworkingStatus::limitedBandwith() const
54{
55 return limitations().contains(Limitations::Bandwith);
56}
57
58void NetworkingStatus::setLimitedBandwidth(bool limited)
59{
60 if (limited) {
61 m_limitations << Limitations::Bandwith;
62 } else if (limitedBandwith()) {
63 m_limitations.remove(m_limitations.indexOf(Limitations::Bandwith));
64 }
65}
066
=== added file 'tests/mocks/Ubuntu/Connectivity/networking-status.h'
--- tests/mocks/Ubuntu/Connectivity/networking-status.h 1970-01-01 00:00:00 +0000
+++ tests/mocks/Ubuntu/Connectivity/networking-status.h 2014-09-11 16:03:35 +0000
@@ -0,0 +1,73 @@
1/*
2 * Copyright © 2014 Canonical Ltd.
3 *
4 * This program is free software: you can redistribute it and/or modify it
5 * under the terms of the GNU Lesser General Public License version 3,
6 * as published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 */
17
18#ifndef FAKE_NETWORKING_STATUS_H
19#define FAKE_NETWORKING_STATUS_H
20
21#include <QObject>
22#include <QVector>
23
24class Q_DECL_EXPORT NetworkingStatus : public QObject
25{
26 Q_OBJECT
27 Q_DISABLE_COPY(NetworkingStatus)
28
29 Q_ENUMS(Limitations)
30 Q_ENUMS(Status)
31
32 Q_PROPERTY(QVector<Limitations> limitations READ limitations NOTIFY limitationsChanged)
33 Q_PROPERTY(Status status READ status NOTIFY statusChanged)
34 Q_PROPERTY(bool online READ online NOTIFY onlineChanged)
35 Q_PROPERTY(bool limitedBandwith READ limitedBandwith WRITE setLimitedBandwidth NOTIFY limitedBandwithChanged)
36
37public:
38 explicit NetworkingStatus(QObject *parent = 0);
39 virtual ~NetworkingStatus();
40
41 enum Limitations {
42 Bandwith
43 };
44
45 enum Status {
46 Offline,
47 Connecting,
48 Online
49 };
50
51 QVector<Limitations> limitations() const;
52 Status status() const;
53 bool online() const;
54 bool limitedBandwith() const;
55
56 // Only in the fake one
57 void setLimitedBandwidth(bool limited);
58
59Q_SIGNALS:
60 void limitationsChanged();
61 void statusChanged(Status value);
62 void onlineChanged(bool value);
63 void limitedBandwithChanged(bool value);
64
65private:
66 QVector<NetworkingStatus::Limitations> m_limitations;
67};
68
69Q_DECLARE_METATYPE(NetworkingStatus::Limitations)
70Q_DECLARE_METATYPE(QVector<NetworkingStatus::Limitations>)
71Q_DECLARE_METATYPE(NetworkingStatus::Status)
72
73#endif // FAKE_NETWORKING_STATUS_H
074
=== added file 'tests/mocks/Ubuntu/Connectivity/plugin.cpp'
--- tests/mocks/Ubuntu/Connectivity/plugin.cpp 1970-01-01 00:00:00 +0000
+++ tests/mocks/Ubuntu/Connectivity/plugin.cpp 2014-09-11 16:03:35 +0000
@@ -0,0 +1,46 @@
1/*
2 * Copyright © 2014 Canonical Ltd.
3 *
4 * This program is free software: you can redistribute it and/or modify it
5 * under the terms of the GNU Lesser General Public License version 3,
6 * as published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authors:
17 * Antti Kaijanmäki <antti.kaijanmaki@canonical.com>
18 */
19
20#include "plugin.h"
21
22#include <QtQml>
23
24#include "networking-status.h"
25
26static QObject *
27networkingStatusSingletonProvider(QQmlEngine *engine, QJSEngine *scriptEngine)
28{
29 Q_UNUSED(scriptEngine)
30
31 return new NetworkingStatus(engine);
32}
33
34void
35QmlConnectivityNetworkingPlugin::registerTypes(const char *uri)
36{
37 // @uri Ubuntu.Connectivity
38 qmlRegisterSingletonType<NetworkingStatus>(uri, 1, 0, "NetworkingStatus", networkingStatusSingletonProvider);
39}
40
41void
42QmlConnectivityNetworkingPlugin::initializeEngine(QQmlEngine *engine, const char *uri)
43{
44 Q_UNUSED(uri);
45 Q_UNUSED(engine);
46}
047
=== added file 'tests/mocks/Ubuntu/Connectivity/plugin.h'
--- tests/mocks/Ubuntu/Connectivity/plugin.h 1970-01-01 00:00:00 +0000
+++ tests/mocks/Ubuntu/Connectivity/plugin.h 2014-09-11 16:03:35 +0000
@@ -0,0 +1,35 @@
1/*
2 * Copyright © 2014 Canonical Ltd.
3 *
4 * This program is free software: you can redistribute it and/or modify it
5 * under the terms of the GNU Lesser General Public License version 3,
6 * as published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authors:
17 * Antti Kaijanmäki <antti.kaijanmaki@canonical.com>
18 */
19
20#ifndef QML_CONNECTIVITY_PLUGIN_H
21#define QML_CONNECTIVITY_PLUGIN_H
22
23#include <QQmlExtensionPlugin>
24
25class QmlConnectivityNetworkingPlugin : public QQmlExtensionPlugin {
26 Q_OBJECT
27 Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface")
28 Q_INTERFACES(QQmlExtensionInterface)
29
30public:
31 void registerTypes(const char *uri);
32 void initializeEngine(QQmlEngine *engine, const char *uri);
33};
34
35#endif // QML_CONNECTIVITY_PLUGIN_H
036
=== added file 'tests/mocks/Ubuntu/Connectivity/qmldir'
--- tests/mocks/Ubuntu/Connectivity/qmldir 1970-01-01 00:00:00 +0000
+++ tests/mocks/Ubuntu/Connectivity/qmldir 2014-09-11 16:03:35 +0000
@@ -0,0 +1,2 @@
1module Ubuntu.Connectivity
2plugin connectivity-qml
03
=== modified file 'tests/mocks/Unity/fake_categories.cpp'
--- tests/mocks/Unity/fake_categories.cpp 2014-08-15 14:21:42 +0000
+++ tests/mocks/Unity/fake_categories.cpp 2014-09-11 16:03:35 +0000
@@ -29,25 +29,12 @@
2929
30int Categories::rowCount(const QModelIndex& /*parent*/) const30int Categories::rowCount(const QModelIndex& /*parent*/) const
31{31{
32 return m_category_count + m_specialCategories.count();32 return m_category_count;
33}33}
3434
35void Categories::addSpecialCategory(QString const& categoryId, QString const& name, QString const& icon, QString const& rawTemplate, QObject* countObject)35void Categories::addSpecialCategory(QString const& /*categoryId*/, QString const& /*name*/, QString const& /*icon*/, QString const& /*rawTemplate*/, QObject* /*countObject*/)
36{36{
37 CategoryData catData;37 qFatal("Using un-implemented Categories::addSpecialCategory");
38 catData.categoryId = categoryId;
39 catData.name = name;
40 catData.icon = icon;
41 catData.rawTemplate = rawTemplate;
42 catData.countObject = countObject;
43
44 beginInsertRows(QModelIndex(), 0, 0);
45 m_specialCategories.prepend(catData);
46 endInsertRows();
47
48 if (countObject) {
49 connect(countObject, SIGNAL(countChanged()), this, SLOT(countChanged()));
50 }
51}38}
5239
53bool Categories::overrideCategoryJson(QString const& /* categoryId */, QString const& /* json */)40bool Categories::overrideCategoryJson(QString const& /* categoryId */, QString const& /* json */)
@@ -55,23 +42,6 @@
55 qFatal("Using un-implemented Categories::overrideCategoryJson");42 qFatal("Using un-implemented Categories::overrideCategoryJson");
56}43}
5744
58void Categories::countChanged()
59{
60 QObject* countObject = sender();
61
62 for (int i = 0; i < m_specialCategories.count(); ++i) {
63 const CategoryData &catData = m_specialCategories.at(i);
64 if (catData.countObject == countObject) {
65 QVector<int> roles;
66 roles.append(RoleCount);
67
68 QModelIndex changedIndex(index(i));
69 dataChanged(changedIndex, changedIndex, roles);
70 break;
71 }
72 }
73}
74
75QVariant45QVariant
76Categories::data(const QModelIndex& index, int role) const46Categories::data(const QModelIndex& index, int role) const
77{47{
@@ -79,115 +49,74 @@
79 return QVariant();49 return QVariant();
80 }50 }
8151
82 ResultsModel *resultsModel = m_resultsModels[index.row()];52 ResultsModel *resultsModel = resultModel(index.row());
83 if (!resultsModel) {53 switch (role) {
84 resultsModel = new ResultsModel(15, index.row());54 case RoleCategoryId:
85 m_resultsModels[index.row()] = resultsModel;55 return QString("%1").arg(index.row());
86 }56 case RoleName:
87 if (index.row() < m_specialCategories.count()) {57 return QString("Category %1").arg(index.row());
88 const CategoryData &catData = m_specialCategories.at(index.row());58 case RoleIcon:
89 switch (role) {59 return "gtk-apply";
90 case RoleCategoryId:60 case RoleRawRendererTemplate:
91 return catData.categoryId;61 qFatal("Using un-implemented RoleRawRendererTemplate Categories role");
92 case RoleName:62 return QVariant();
93 return catData.name;63 case RoleRenderer:
94 case RoleIcon:64 {
95 return catData.icon;65 QVariantMap map;
96 case RoleRawRendererTemplate:66 if (index.row() % 2 == 0) {
97 return catData.rawTemplate;67 map["category-layout"] = "grid";
98 case RoleRenderer:68 } else {
99 {69 map["category-layout"] = "carousel";
100 QVariantMap map;70 }
101 if (index.row() % 2 == 0) {71 if (index.row() == 18) {
102 map["category-layout"] = "grid";72 map["category-layout"] = "horizontal-list";
103 } else {73 }
104 map["category-layout"] = "carousel";74 if (index.row() == 19) {
105 map["overlay"] = true;75 map["category-layout"] = "grid";
106 }76 map["collapsed-rows"] = 0;
107 map["card-size"] = "small";77 }
108 return map;78 map["card-size"] = "small";
109 }79
110 case RoleComponents:80 map["category-layout"] = m_layouts.value(index.row(), map["category-layout"].toString());
111 {81
112 QVariantMap map, artMap, attributeMap;82 if (map["category-layout"] == "carousel") {
83 map["overlay"] = true;
84 }
85
86 return map;
87 }
88 case RoleComponents:
89 {
90 QVariantMap map, artMap, attributeMap;
91 if (index.row() % 2 != 0) {
92 artMap["aspect-ratio"] = QString("1.%1").arg(index.row());
93 } else {
113 artMap["aspect-ratio"] = "1.0";94 artMap["aspect-ratio"] = "1.0";
114 artMap["field"] = "art";95 }
115 map["art"] = artMap;96 artMap["field"] = "art";
116 map["title"] = "HOLA";97 map["art"] = artMap;
117 attributeMap["field"] = "attribute";98 map["title"] = "HOLA";
118 map["attributes"] = attributeMap;99 map["subtitle"] = "HOLA";
119 return map;100 attributeMap["field"] = "attribute";
120 }101 map["attributes"] = attributeMap;
121 case RoleHeaderLink:102 return map;
122 return QString();103 }
123 case RoleResults:104 case RoleHeaderLink:
124 return QVariant();105 {
125 case RoleCount:106 QString res;
126 return catData.countObject->property("count");107 if (index.row() == 1 || index.row() == 4) {
127 default:108 res = QString("scope://query/1");
128 qFatal("Using un-implemented Categories role");109 }
129 return QVariant();110 res = m_headerLinks.value(index.row(), res);
130 }111 return res;
131 } else {112 }
132 switch (role) {113 case RoleResults:
133 case RoleCategoryId:114 return QVariant::fromValue(resultsModel);
134 return QString("%1").arg(index.row());115 case RoleCount:
135 case RoleName:116 return resultsModel->rowCount();
136 return QString("Category %1").arg(index.row());117 default:
137 case RoleIcon:118 qFatal("Using un-implemented Categories role");
138 return "gtk-apply";119 return QVariant();
139 case RoleRawRendererTemplate:
140 qFatal("Using un-implemented RoleRawRendererTemplate Categories role");
141 return QVariant();
142 case RoleRenderer:
143 {
144 QVariantMap map;
145 if (index.row() % 2 == 0) {
146 map["category-layout"] = "grid";
147 } else {
148 map["category-layout"] = "carousel";
149 map["card-size"] = "medium";
150 map["overlay"] = true;
151 }
152 if (index.row() == 18) {
153 map["category-layout"] = "horizontal-list";
154 }
155 if (index.row() == 19) {
156 map["category-layout"] = "grid";
157 map["collapsed-rows"] = 0;
158 }
159 map["card-size"] = "small";
160 return map;
161 }
162 case RoleComponents:
163 {
164 QVariantMap map, artMap, attributeMap;
165 if (index.row() % 2 != 0) {
166 artMap["aspect-ratio"] = QString("1.%1").arg(index.row());
167 } else {
168 artMap["aspect-ratio"] = "1.0";
169 }
170 artMap["field"] = "art";
171 map["art"] = artMap;
172 map["title"] = "HOLA";
173 map["subtitle"] = "HOLA";
174 attributeMap["field"] = "attribute";
175 map["attributes"] = attributeMap;
176 return map;
177 }
178 case RoleHeaderLink:
179 if (index.row() == 1 || index.row() == 4) {
180 return QString("scope://query/1");
181 }
182 return QString();
183 case RoleResults:
184 return QVariant::fromValue(resultsModel);
185 case RoleCount:
186 return resultsModel->rowCount();
187 default:
188 qFatal("Using un-implemented Categories role");
189 return QVariant();
190 }
191 }120 }
192}121}
193122
@@ -196,3 +125,33 @@
196{125{
197 return data(index(row, 0), role);126 return data(index(row, 0), role);
198}127}
128
129void Categories::setCount(int count)
130{
131 if (m_category_count != count) {
132 beginResetModel(); // This is just for test setup so we can be lazy and reset
133 m_category_count = count;
134 endResetModel();
135 }
136}
137
138ResultsModel* Categories::resultModel(int row) const
139{
140 ResultsModel *result = m_resultsModels[row];
141 if (!result) {
142 Categories *that = const_cast<Categories*>(this);
143 result = new ResultsModel(15, row, that);
144 m_resultsModels[row] = result;
145 }
146 return result;
147}
148
149void Categories::setLayout(int row, const QString &layout)
150{
151 m_layouts[row] = layout;
152}
153
154void Categories::setHeaderLink(int row, const QString &headerLink)
155{
156 m_headerLinks[row] = headerLink;
157}
199158
=== modified file 'tests/mocks/Unity/fake_categories.h'
--- tests/mocks/Unity/fake_categories.h 2014-07-11 16:39:33 +0000
+++ tests/mocks/Unity/fake_categories.h 2014-09-11 16:03:35 +0000
@@ -39,22 +39,17 @@
3939
40 Q_INVOKABLE QVariant data(int row, int role) const;40 Q_INVOKABLE QVariant data(int row, int role) const;
4141
42private Q_SLOTS:42 // For testing purposes
43 void countChanged();43 Q_INVOKABLE void setCount(int count);
44 Q_INVOKABLE ResultsModel* resultModel(int row) const;
45 Q_INVOKABLE void setLayout(int row, const QString &layout);
46 Q_INVOKABLE void setHeaderLink(int row, const QString &headerLink);
4447
45private:48private:
46 mutable QHash<int, ResultsModel*> m_resultsModels;49 mutable QHash<int, ResultsModel*> m_resultsModels;
50 QHash<int, QString> m_layouts;
51 QHash<int, QString> m_headerLinks;
47 int m_category_count;52 int m_category_count;
48
49 struct CategoryData {
50 QString categoryId;
51 QString name;
52 QString icon;
53 QString rawTemplate;
54 QObject* countObject;
55 };
56
57 QList<CategoryData> m_specialCategories;
58};53};
5954
60#endif // FAKE_CATEGORIES_H55#endif // FAKE_CATEGORIES_H
6156
=== modified file 'tests/mocks/Unity/fake_resultsmodel.cpp'
--- tests/mocks/Unity/fake_resultsmodel.cpp 2014-08-13 16:06:40 +0000
+++ tests/mocks/Unity/fake_resultsmodel.cpp 2014-09-11 16:03:35 +0000
@@ -44,6 +44,15 @@
44 qFatal("Calling un-implemented ResultsModel::setCategoryId");44 qFatal("Calling un-implemented ResultsModel::setCategoryId");
45}45}
4646
47void ResultsModel::setResultCount(int result_count)
48{
49 if (m_result_count != result_count) {
50 beginResetModel(); // This is just for test setup so we can be lazy and reset
51 m_result_count = result_count;
52 endResetModel();
53 }
54}
55
47int ResultsModel::rowCount(const QModelIndex& parent) const56int ResultsModel::rowCount(const QModelIndex& parent) const
48{57{
49 Q_UNUSED(parent);58 Q_UNUSED(parent);
5059
=== modified file 'tests/mocks/Unity/fake_resultsmodel.h'
--- tests/mocks/Unity/fake_resultsmodel.h 2014-08-11 09:57:29 +0000
+++ tests/mocks/Unity/fake_resultsmodel.h 2014-09-11 16:03:35 +0000
@@ -41,6 +41,9 @@
41 /* setters */41 /* setters */
42 void setCategoryId(QString const& id) override;42 void setCategoryId(QString const& id) override;
4343
44 // For testing purposes
45 Q_INVOKABLE void setResultCount(int result_count);
46
44private:47private:
45 int m_result_count;48 int m_result_count;
46 int m_categoryId;49 int m_categoryId;
4750
=== modified file 'tests/mocks/Unity/fake_scope.cpp'
--- tests/mocks/Unity/fake_scope.cpp 2014-08-27 08:01:40 +0000
+++ tests/mocks/Unity/fake_scope.cpp 2014-09-11 16:03:35 +0000
@@ -145,6 +145,23 @@
145 Q_EMIT favoriteChanged();145 Q_EMIT favoriteChanged();
146 }146 }
147}147}
148
149void Scope::setId(const QString &id)
150{
151 if (id != m_id) {
152 m_id = id;
153 Q_EMIT idChanged();
154 }
155}
156
157void Scope::setName(const QString &name)
158{
159 if (name != m_name) {
160 m_name = name;
161 Q_EMIT nameChanged();
162 }
163}
164
148void Scope::setSearchInProgress(const bool inProg)165void Scope::setSearchInProgress(const bool inProg)
149{166{
150 if (inProg != m_searching) {167 if (inProg != m_searching) {
151168
=== modified file 'tests/mocks/Unity/fake_scope.h'
--- tests/mocks/Unity/fake_scope.h 2014-08-12 12:09:49 +0000
+++ tests/mocks/Unity/fake_scope.h 2014-09-11 16:03:35 +0000
@@ -56,6 +56,8 @@
56 void setFormFactor(const QString& form_factor) override;56 void setFormFactor(const QString& form_factor) override;
57 void setActive(const bool) override;57 void setActive(const bool) override;
58 void setFavorite(const bool) override;58 void setFavorite(const bool) override;
59 Q_INVOKABLE void setId(const QString &id); // This is not invokable in the Interface, here for testing benefits
60 Q_INVOKABLE void setName(const QString &name); // This is not invokable in the Interface, here for testing benefits
59 Q_INVOKABLE void setSearchInProgress(const bool inProg); // This is not invokable in the Interface, here for testing benefits61 Q_INVOKABLE void setSearchInProgress(const bool inProg); // This is not invokable in the Interface, here for testing benefits
6062
61 Q_INVOKABLE void activate(QVariant const& result) override;63 Q_INVOKABLE void activate(QVariant const& result) override;
6264
=== modified file 'tests/plugins/Dash/CMakeLists.txt'
--- tests/plugins/Dash/CMakeLists.txt 2014-07-22 10:03:37 +0000
+++ tests/plugins/Dash/CMakeLists.txt 2014-09-11 16:03:35 +0000
@@ -32,7 +32,7 @@
32 qt5_use_modules(${TESTNAME}TestExec Test Core Qml)32 qt5_use_modules(${TESTNAME}TestExec Test Core Qml)
33 target_link_libraries(${TESTNAME}TestExec ${Qt5Gui_LIBRARIES} ${Qt5Quick_LIBRARIES})33 target_link_libraries(${TESTNAME}TestExec ${Qt5Gui_LIBRARIES} ${Qt5Quick_LIBRARIES})
3434
35 add_binary_qml_test(${TESTNAME} "" "Dash-qml")35 add_binary_qml_test(${TESTNAME} "" "Dash-qml" "")
36endmacro()36endmacro()
3737
38add_lvwph_test(listviewwithpageheader ListViewWithPageHeader)38add_lvwph_test(listviewwithpageheader ListViewWithPageHeader)
@@ -48,7 +48,7 @@
48 qt5_use_modules(${TESTNAME}TestExec Test Core Qml)48 qt5_use_modules(${TESTNAME}TestExec Test Core Qml)
49 target_link_libraries(${TESTNAME}TestExec ${Qt5Gui_LIBRARIES} ${Qt5Quick_LIBRARIES})49 target_link_libraries(${TESTNAME}TestExec ${Qt5Gui_LIBRARIES} ${Qt5Quick_LIBRARIES})
5050
51 add_binary_qml_test(${TESTNAME} "" "Dash-qml")51 add_binary_qml_test(${TESTNAME} "" "Dash-qml" "")
5252
53 add_executable(${TESTNAME}tryExec53 add_executable(${TESTNAME}tryExec
54 ${FILENAME}try.cpp54 ${FILENAME}try.cpp
@@ -71,7 +71,7 @@
71add_executable(CardCreatorTestExec cardcreatortest.cpp)71add_executable(CardCreatorTestExec cardcreatortest.cpp)
72qt5_use_modules(CardCreatorTestExec Test Core Qml)72qt5_use_modules(CardCreatorTestExec Test Core Qml)
73target_link_libraries(CardCreatorTestExec ${Qt5Gui_LIBRARIES} ${Qt5Quick_LIBRARIES})73target_link_libraries(CardCreatorTestExec ${Qt5Gui_LIBRARIES} ${Qt5Quick_LIBRARIES})
74add_binary_qml_test(CardCreator "" "Dash-qml")74add_binary_qml_test(CardCreator "" "Dash-qml" "QML2_IMPORT_PATH=${CMAKE_BINARY_DIR}/tests/mocks/")
7575
76# plain qml test76# plain qml test
77set(qmltest_DEFAULT_TARGETS qmluitests)77set(qmltest_DEFAULT_TARGETS qmluitests)
7878
=== modified file 'tests/plugins/Dash/cardcreator/1.res'
--- tests/plugins/Dash/cardcreator/1.res 2014-08-13 10:29:21 +0000
+++ tests/plugins/Dash/cardcreator/1.res 2014-09-11 16:03:35 +0000
@@ -6,7 +6,7 @@
6 property var artShapeBorderSource: undefined; 6 property var artShapeBorderSource: undefined;
7 property real fontScale: 1.0; 7 property real fontScale: 1.0;
8 property var scopeStyle: null; 8 property var scopeStyle: null;
9 property int headerAlignment: Text.AlignLeft; 9 property int titleAlignment: Text.AlignLeft;
10 property int fixedHeaderHeight: -1; 10 property int fixedHeaderHeight: -1;
11 property size fixedArtShapeSize: Qt.size(-1, -1); 11 property size fixedArtShapeSize: Qt.size(-1, -1);
12 readonly property string title: cardData && cardData["title"] || ""; 12 readonly property string title: cardData && cardData["title"] || "";
@@ -46,7 +46,8 @@
46 } 46 }
47 image: Image { 47 image: Image {
48 objectName: "artImage"; 48 objectName: "artImage";
49 source: cardData && cardData["art"] || ""; 49 property bool doLoadSource: !NetworkingStatus.limitedBandwith;
50 source: { if (root.visible) doLoadSource = true; return doLoadSource && cardData && cardData["art"] || ""; }
50 cache: true; 51 cache: true;
51 asynchronous: root.asynchronous; 52 asynchronous: root.asynchronous;
52 fillMode: Image.PreserveAspectCrop;53 fillMode: Image.PreserveAspectCrop;
@@ -68,13 +69,13 @@
68 elide: Text.ElideRight; 69 elide: Text.ElideRight;
69 fontSize: "small"; 70 fontSize: "small";
70 wrapMode: Text.Wrap; 71 wrapMode: Text.Wrap;
71 maximumLineCount: 2; 72 maximumLineCount: horizontalAlignment === Text.AlignHCenter ? 1 : 2;
72 font.pixelSize: Math.round(FontUtils.sizeToPixels(fontSize) * fontScale); 73 font.pixelSize: Math.round(FontUtils.sizeToPixels(fontSize) * fontScale);
73 color: root.scopeStyle ? root.scopeStyle.foreground : Theme.palette.normal.baseText;74 color: root.scopeStyle ? root.scopeStyle.foreground : Theme.palette.normal.baseText;
74 visible: showHeader ; 75 visible: showHeader ;
75 text: root.title; 76 text: root.title;
76 font.weight: components && components["subtitle"] ? Font.DemiBold : Font.Normal; 77 font.weight: cardData && cardData["subtitle"] ? Font.DemiBold : Font.Normal;
77 horizontalAlignment: root.headerAlignment; 78 horizontalAlignment: root.titleAlignment;
78 }79 }
79UbuntuShape {80UbuntuShape {
80 id: touchdown;81 id: touchdown;
8182
=== modified file 'tests/plugins/Dash/cardcreator/2.res'
--- tests/plugins/Dash/cardcreator/2.res 2014-08-29 08:31:22 +0000
+++ tests/plugins/Dash/cardcreator/2.res 2014-09-11 16:03:35 +0000
@@ -6,7 +6,7 @@
6 property var artShapeBorderSource: undefined; 6 property var artShapeBorderSource: undefined;
7 property real fontScale: 1.0; 7 property real fontScale: 1.0;
8 property var scopeStyle: null; 8 property var scopeStyle: null;
9 property int headerAlignment: Text.AlignLeft; 9 property int titleAlignment: Text.AlignLeft;
10 property int fixedHeaderHeight: -1; 10 property int fixedHeaderHeight: -1;
11 property size fixedArtShapeSize: Qt.size(-1, -1); 11 property size fixedArtShapeSize: Qt.size(-1, -1);
12 readonly property string title: cardData && cardData["title"] || ""; 12 readonly property string title: cardData && cardData["title"] || "";
@@ -67,7 +67,8 @@
67 objectName: "mascotImage"; 67 objectName: "mascotImage";
68 anchors { verticalCenter: parent.verticalCenter; } 68 anchors { verticalCenter: parent.verticalCenter; }
69 readonly property int maxSize: Math.max(width, height) * 4; 69 readonly property int maxSize: Math.max(width, height) * 4;
70 source: cardData && cardData["mascot"] || "";70 property bool doLoadSource: !NetworkingStatus.limitedBandwith;
71 source: { if (root.visible) doLoadSource = true; return doLoadSource && cardData && cardData["mascot"] || ""; }
71 width: units.gu(6); 72 width: units.gu(6);
72 height: units.gu(5.625); 73 height: units.gu(5.625);
73 sourceSize { width: maxSize; height: maxSize } 74 sourceSize { width: maxSize; height: maxSize }
@@ -92,13 +93,13 @@
92 elide: Text.ElideRight; 93 elide: Text.ElideRight;
93 fontSize: "small"; 94 fontSize: "small";
94 wrapMode: Text.Wrap; 95 wrapMode: Text.Wrap;
95 maximumLineCount: 2; 96 maximumLineCount: horizontalAlignment === Text.AlignHCenter ? 1 : 2;
96 font.pixelSize: Math.round(FontUtils.sizeToPixels(fontSize) * fontScale); 97 font.pixelSize: Math.round(FontUtils.sizeToPixels(fontSize) * fontScale);
97 color: backgroundLoader.active && backgroundLoader.item && root.scopeStyle ? root.scopeStyle.getTextColor(backgroundLoader.item.luminance) : (backgroundLoader.item && backgroundLoader.item.luminance > 0.7 ? Theme.palette.normal.baseText : "white");98 color: backgroundLoader.active && backgroundLoader.item && root.scopeStyle ? root.scopeStyle.getTextColor(backgroundLoader.item.luminance) : (backgroundLoader.item && backgroundLoader.item.luminance > 0.7 ? Theme.palette.normal.baseText : "white");
98 visible: showHeader ; 99 visible: showHeader ;
99 text: root.title; 100 text: root.title;
100 font.weight: components && components["subtitle"] ? Font.DemiBold : Font.Normal; 101 font.weight: cardData && cardData["subtitle"] ? Font.DemiBold : Font.Normal;
101 horizontalAlignment: root.headerAlignment; 102 horizontalAlignment: root.titleAlignment;
102 }103 }
103 ,Label { 104 ,Label {
104 id: subtitleLabel; 105 id: subtitleLabel;
@@ -110,13 +111,12 @@
110 } 111 }
111 anchors.topMargin: units.dp(2); 112 anchors.topMargin: units.dp(2);
112 elide: Text.ElideRight; 113 elide: Text.ElideRight;
113 fontSize: "small"; 114 fontSize: "x-small";
114 font.pixelSize: Math.round(FontUtils.sizeToPixels(fontSize) * fontScale); 115 font.pixelSize: Math.round(FontUtils.sizeToPixels(fontSize) * fontScale);
115 color: backgroundLoader.active && backgroundLoader.item && root.scopeStyle ? root.scopeStyle.getTextColor(backgroundLoader.item.luminance) : (backgroundLoader.item && backgroundLoader.item.luminance > 0.7 ? Theme.palette.normal.baseText : "white");116 color: backgroundLoader.active && backgroundLoader.item && root.scopeStyle ? root.scopeStyle.getTextColor(backgroundLoader.item.luminance) : (backgroundLoader.item && backgroundLoader.item.luminance > 0.7 ? Theme.palette.normal.baseText : "white");
116 visible: titleLabel.visible && titleLabel.text; 117 visible: titleLabel.visible && titleLabel.text;
117 text: cardData && cardData["subtitle"] || ""; 118 text: cardData && cardData["subtitle"] || "";
118 font.weight: Font.Light; 119 font.weight: Font.Light;
119 horizontalAlignment: root.headerAlignment;
120 }120 }
121 121
122 ] 122 ]
123123
=== modified file 'tests/plugins/Dash/cardcreator/3.res'
--- tests/plugins/Dash/cardcreator/3.res 2014-08-13 10:29:21 +0000
+++ tests/plugins/Dash/cardcreator/3.res 2014-09-11 16:03:35 +0000
@@ -6,7 +6,7 @@
6 property var artShapeBorderSource: undefined; 6 property var artShapeBorderSource: undefined;
7 property real fontScale: 1.0; 7 property real fontScale: 1.0;
8 property var scopeStyle: null; 8 property var scopeStyle: null;
9 property int headerAlignment: Text.AlignLeft; 9 property int titleAlignment: Text.AlignLeft;
10 property int fixedHeaderHeight: -1; 10 property int fixedHeaderHeight: -1;
11 property size fixedArtShapeSize: Qt.size(-1, -1); 11 property size fixedArtShapeSize: Qt.size(-1, -1);
12 readonly property string title: cardData && cardData["title"] || ""; 12 readonly property string title: cardData && cardData["title"] || "";
@@ -46,8 +46,9 @@
46 } 46 }
47 image: Image { 47 image: Image {
48 objectName: "artImage"; 48 objectName: "artImage";
49 source: cardData && cardData["art"] || ""; 49 property bool doLoadSource: !NetworkingStatus.limitedBandwith;
50 cache: true; 50 source: { if (root.visible) doLoadSource = true; return doLoadSource && cardData && cardData["art"] || ""; }
51 cache: true;
51 asynchronous: root.asynchronous; 52 asynchronous: root.asynchronous;
52 fillMode: Image.PreserveAspectCrop;53 fillMode: Image.PreserveAspectCrop;
53 width: root.width; 54 width: root.width;
@@ -68,13 +69,13 @@
68 elide: Text.ElideRight; 69 elide: Text.ElideRight;
69 fontSize: "small"; 70 fontSize: "small";
70 wrapMode: Text.Wrap; 71 wrapMode: Text.Wrap;
71 maximumLineCount: 2; 72 maximumLineCount: horizontalAlignment === Text.AlignHCenter ? 1 : 2;
72 font.pixelSize: Math.round(FontUtils.sizeToPixels(fontSize) * fontScale); 73 font.pixelSize: Math.round(FontUtils.sizeToPixels(fontSize) * fontScale);
73 color: root.scopeStyle ? root.scopeStyle.foreground : Theme.palette.normal.baseText;74 color: root.scopeStyle ? root.scopeStyle.foreground : Theme.palette.normal.baseText;
74 visible: showHeader ; 75 visible: showHeader ;
75 text: root.title; 76 text: root.title;
76 font.weight: components && components["subtitle"] ? Font.DemiBold : Font.Normal; 77 font.weight: cardData && cardData["subtitle"] ? Font.DemiBold : Font.Normal;
77 horizontalAlignment: root.headerAlignment; 78 horizontalAlignment: root.titleAlignment;
78 }79 }
79Label { 80Label {
80 id: subtitleLabel; 81 id: subtitleLabel;
@@ -86,13 +87,12 @@
86 } 87 }
87 anchors.topMargin: units.dp(2);88 anchors.topMargin: units.dp(2);
88 elide: Text.ElideRight; 89 elide: Text.ElideRight;
89 fontSize: "small"; 90 fontSize: "x-small";
90 font.pixelSize: Math.round(FontUtils.sizeToPixels(fontSize) * fontScale); 91 font.pixelSize: Math.round(FontUtils.sizeToPixels(fontSize) * fontScale);
91 color: root.scopeStyle ? root.scopeStyle.foreground : Theme.palette.normal.baseText;92 color: root.scopeStyle ? root.scopeStyle.foreground : Theme.palette.normal.baseText;
92 visible: titleLabel.visible && titleLabel.text; 93 visible: titleLabel.visible && titleLabel.text;
93 text: cardData && cardData["subtitle"] || ""; 94 text: cardData && cardData["subtitle"] || "";
94 font.weight: Font.Light; 95 font.weight: Font.Light;
95 horizontalAlignment: root.headerAlignment;
96 }96 }
97UbuntuShape {97UbuntuShape {
98 id: touchdown;98 id: touchdown;
9999
=== modified file 'tests/plugins/Dash/cardcreator/4.res'
--- tests/plugins/Dash/cardcreator/4.res 2014-08-13 10:29:21 +0000
+++ tests/plugins/Dash/cardcreator/4.res 2014-09-11 16:03:35 +0000
@@ -6,7 +6,7 @@
6 property var artShapeBorderSource: undefined; 6 property var artShapeBorderSource: undefined;
7 property real fontScale: 1.0; 7 property real fontScale: 1.0;
8 property var scopeStyle: null;8 property var scopeStyle: null;
9 property int headerAlignment: Text.AlignLeft;9 property int titleAlignment: Text.AlignLeft;
10 property int fixedHeaderHeight: -1; 10 property int fixedHeaderHeight: -1;
11 property size fixedArtShapeSize: Qt.size(-1, -1); 11 property size fixedArtShapeSize: Qt.size(-1, -1);
12 readonly property string title: cardData && cardData["title"] || ""; 12 readonly property string title: cardData && cardData["title"] || "";
@@ -46,8 +46,9 @@
46 objectName: "mascotImage"; 46 objectName: "mascotImage";
47 anchors { verticalCenter: parent.verticalCenter; }47 anchors { verticalCenter: parent.verticalCenter; }
48 readonly property int maxSize: Math.max(width, height) * 4; 48 readonly property int maxSize: Math.max(width, height) * 4;
49 source: cardData && cardData["mascot"] || ""; 49 property bool doLoadSource: !NetworkingStatus.limitedBandwith;
50 width: units.gu(6); 50 source: { if (root.visible) doLoadSource = true; return doLoadSource && cardData && cardData["mascot"] || ""; }
51 width: units.gu(6);
51 height: units.gu(5.625); 52 height: units.gu(5.625);
52 sourceSize { width: maxSize; height: maxSize } 53 sourceSize { width: maxSize; height: maxSize }
53 fillMode: Image.PreserveAspectCrop; 54 fillMode: Image.PreserveAspectCrop;
@@ -72,13 +73,13 @@
72 elide: Text.ElideRight; 73 elide: Text.ElideRight;
73 fontSize: "small"; 74 fontSize: "small";
74 wrapMode: Text.Wrap; 75 wrapMode: Text.Wrap;
75 maximumLineCount: 2; 76 maximumLineCount: horizontalAlignment === Text.AlignHCenter ? 1 : 2;
76 font.pixelSize: Math.round(FontUtils.sizeToPixels(fontSize) * fontScale); 77 font.pixelSize: Math.round(FontUtils.sizeToPixels(fontSize) * fontScale);
77 color: root.scopeStyle ? root.scopeStyle.foreground : Theme.palette.normal.baseText;78 color: root.scopeStyle ? root.scopeStyle.foreground : Theme.palette.normal.baseText;
78 visible: showHeader ; 79 visible: showHeader ;
79 text: root.title; 80 text: root.title;
80 font.weight: components && components["subtitle"] ? Font.DemiBold : Font.Normal; 81 font.weight: cardData && cardData["subtitle"] ? Font.DemiBold : Font.Normal;
81 horizontalAlignment: root.headerAlignment; 82 horizontalAlignment: root.titleAlignment;
82 }83 }
83,Label { 84,Label {
84 id: subtitleLabel; 85 id: subtitleLabel;
@@ -90,13 +91,12 @@
90 }91 }
91 anchors.topMargin: units.dp(2);92 anchors.topMargin: units.dp(2);
92 elide: Text.ElideRight; 93 elide: Text.ElideRight;
93 fontSize: "small"; 94 fontSize: "x-small";
94 font.pixelSize: Math.round(FontUtils.sizeToPixels(fontSize) * fontScale); 95 font.pixelSize: Math.round(FontUtils.sizeToPixels(fontSize) * fontScale);
95 color: root.scopeStyle ? root.scopeStyle.foreground : Theme.palette.normal.baseText;96 color: root.scopeStyle ? root.scopeStyle.foreground : Theme.palette.normal.baseText;
96 visible: titleLabel.visible && titleLabel.text; 97 visible: titleLabel.visible && titleLabel.text;
97 text: cardData && cardData["subtitle"] || ""; 98 text: cardData && cardData["subtitle"] || "";
98 font.weight: Font.Light; 99 font.weight: Font.Light;
99 horizontalAlignment: root.headerAlignment;
100 }100 }
101]101]
102}102}
103103
=== modified file 'tests/plugins/Dash/cardcreator/5.res'
--- tests/plugins/Dash/cardcreator/5.res 2014-08-29 08:31:22 +0000
+++ tests/plugins/Dash/cardcreator/5.res 2014-09-11 16:03:35 +0000
@@ -6,7 +6,7 @@
6 property var artShapeBorderSource: undefined; 6 property var artShapeBorderSource: undefined;
7 property real fontScale: 1.0; 7 property real fontScale: 1.0;
8 property var scopeStyle: null; 8 property var scopeStyle: null;
9 property int headerAlignment: Text.AlignLeft; 9 property int titleAlignment: Text.AlignLeft;
10 property int fixedHeaderHeight: -1; 10 property int fixedHeaderHeight: -1;
11 property size fixedArtShapeSize: Qt.size(-1, -1); 11 property size fixedArtShapeSize: Qt.size(-1, -1);
12 readonly property string title: cardData && cardData["title"] || ""; 12 readonly property string title: cardData && cardData["title"] || "";
@@ -46,8 +46,9 @@
46 } 46 }
47 image: Image { 47 image: Image {
48 objectName: "artImage"; 48 objectName: "artImage";
49 source: cardData && cardData["art"] || ""; 49 property bool doLoadSource: !NetworkingStatus.limitedBandwith;
50 cache: true; 50 source: { if (root.visible) doLoadSource = true; return doLoadSource && cardData && cardData["art"] || ""; }
51 cache: true;
51 asynchronous: root.asynchronous; 52 asynchronous: root.asynchronous;
52 fillMode: Image.PreserveAspectCrop;53 fillMode: Image.PreserveAspectCrop;
53 width: root.width; 54 width: root.width;
@@ -112,13 +113,13 @@
112 elide: Text.ElideRight; 113 elide: Text.ElideRight;
113 fontSize: "small"; 114 fontSize: "small";
114 wrapMode: Text.Wrap; 115 wrapMode: Text.Wrap;
115 maximumLineCount: 2; 116 maximumLineCount: horizontalAlignment === Text.AlignHCenter ? 1 : 2;
116 font.pixelSize: Math.round(FontUtils.sizeToPixels(fontSize) * fontScale); 117 font.pixelSize: Math.round(FontUtils.sizeToPixels(fontSize) * fontScale);
117 color: root.scopeStyle && overlayLoader.item ? root.scopeStyle.getTextColor(overlayLoader.item.luminance) : (overlayLoader.item && overlayLoader.item.luminance > 0.7 ? Theme.palette.normal.baseText : "white");118 color: root.scopeStyle && overlayLoader.item ? root.scopeStyle.getTextColor(overlayLoader.item.luminance) : (overlayLoader.item && overlayLoader.item.luminance > 0.7 ? Theme.palette.normal.baseText : "white");
118 visible: showHeader && overlayLoader.active; 119 visible: showHeader && overlayLoader.active;
119 text: root.title; 120 text: root.title;
120 font.weight: components && components["subtitle"] ? Font.DemiBold : Font.Normal; 121 font.weight: cardData && cardData["subtitle"] ? Font.DemiBold : Font.Normal;
121 horizontalAlignment: root.headerAlignment; 122 horizontalAlignment: root.titleAlignment;
122 }123 }
123Label { 124Label {
124 id: subtitleLabel; 125 id: subtitleLabel;
@@ -131,13 +132,12 @@
131 } 132 }
132 anchors.topMargin: units.dp(2); 133 anchors.topMargin: units.dp(2);
133 elide: Text.ElideRight; 134 elide: Text.ElideRight;
134 fontSize: "small"; 135 fontSize: "x-small";
135 font.pixelSize: Math.round(FontUtils.sizeToPixels(fontSize) * fontScale); 136 font.pixelSize: Math.round(FontUtils.sizeToPixels(fontSize) * fontScale);
136 color: root.scopeStyle && overlayLoader.item ? root.scopeStyle.getTextColor(overlayLoader.item.luminance) : (overlayLoader.item && overlayLoader.item.luminance > 0.7 ? Theme.palette.normal.baseText : "white");137 color: root.scopeStyle && overlayLoader.item ? root.scopeStyle.getTextColor(overlayLoader.item.luminance) : (overlayLoader.item && overlayLoader.item.luminance > 0.7 ? Theme.palette.normal.baseText : "white");
137 visible: titleLabel.visible && titleLabel.text; 138 visible: titleLabel.visible && titleLabel.text;
138 text: cardData && cardData["subtitle"] || ""; 139 text: cardData && cardData["subtitle"] || "";
139 font.weight: Font.Light; 140 font.weight: Font.Light;
140 horizontalAlignment: root.headerAlignment;
141 }141 }
142UbuntuShape { 142UbuntuShape {
143 id: touchdown; 143 id: touchdown;
144144
=== modified file 'tests/plugins/Dash/cardcreator/6.res'
--- tests/plugins/Dash/cardcreator/6.res 2014-08-29 08:31:22 +0000
+++ tests/plugins/Dash/cardcreator/6.res 2014-09-11 16:03:35 +0000
@@ -6,7 +6,7 @@
6 property var artShapeBorderSource: undefined;6 property var artShapeBorderSource: undefined;
7 property real fontScale: 1.0;7 property real fontScale: 1.0;
8 property var scopeStyle: null;8 property var scopeStyle: null;
9 property int headerAlignment: Text.AlignLeft;9 property int titleAlignment: Text.AlignLeft;
10 property int fixedHeaderHeight: -1;10 property int fixedHeaderHeight: -1;
11 property size fixedArtShapeSize: Qt.size(-1, -1);11 property size fixedArtShapeSize: Qt.size(-1, -1);
12 readonly property string title: cardData && cardData["title"] || "";12 readonly property string title: cardData && cardData["title"] || "";
@@ -68,13 +68,13 @@
68 elide: Text.ElideRight; 68 elide: Text.ElideRight;
69 fontSize: "small"; 69 fontSize: "small";
70 wrapMode: Text.Wrap; 70 wrapMode: Text.Wrap;
71 maximumLineCount: 2; 71 maximumLineCount: horizontalAlignment === Text.AlignHCenter ? 1 : 2;
72 font.pixelSize: Math.round(FontUtils.sizeToPixels(fontSize) * fontScale); 72 font.pixelSize: Math.round(FontUtils.sizeToPixels(fontSize) * fontScale);
73 color: backgroundLoader.active && backgroundLoader.item && root.scopeStyle ? root.scopeStyle.getTextColor(backgroundLoader.item.luminance) : (backgroundLoader.item && backgroundLoader.item.luminance > 0.7 ? Theme.palette.normal.baseText : "white");73 color: backgroundLoader.active && backgroundLoader.item && root.scopeStyle ? root.scopeStyle.getTextColor(backgroundLoader.item.luminance) : (backgroundLoader.item && backgroundLoader.item.luminance > 0.7 ? Theme.palette.normal.baseText : "white");
74 visible: showHeader ; 74 visible: showHeader ;
75 text: root.title; 75 text: root.title;
76 font.weight: components && components["subtitle"] ? Font.DemiBold : Font.Normal; 76 font.weight: cardData && cardData["subtitle"] ? Font.DemiBold : Font.Normal;
77 horizontalAlignment: root.headerAlignment; 77 horizontalAlignment: root.titleAlignment;
78 }78 }
79,Label { 79,Label {
80 id: subtitleLabel; 80 id: subtitleLabel;
@@ -86,15 +86,14 @@
86 } 86 }
87 anchors.topMargin: units.dp(2); 87 anchors.topMargin: units.dp(2);
88 elide: Text.ElideRight; 88 elide: Text.ElideRight;
89 fontSize: "small"; 89 fontSize: "x-small";
90 font.pixelSize: Math.round(FontUtils.sizeToPixels(fontSize) * fontScale); 90 font.pixelSize: Math.round(FontUtils.sizeToPixels(fontSize) * fontScale);
91 color: backgroundLoader.active && backgroundLoader.item && root.scopeStyle ? root.scopeStyle.getTextColor(backgroundLoader.item.luminance) : (backgroundLoader.item && backgroundLoader.item.luminance > 0.7 ? Theme.palette.normal.baseText : "white");91 color: backgroundLoader.active && backgroundLoader.item && root.scopeStyle ? root.scopeStyle.getTextColor(backgroundLoader.item.luminance) : (backgroundLoader.item && backgroundLoader.item.luminance > 0.7 ? Theme.palette.normal.baseText : "white");
92 visible: titleLabel.visible && titleLabel.text; 92 visible: titleLabel.visible && titleLabel.text;
93 text: cardData && cardData["subtitle"] || ""; 93 text: cardData && cardData["subtitle"] || "";
94 font.weight: Font.Light; 94 font.weight: Font.Light;
95 horizontalAlignment: root.headerAlignment;
96 }95 }
97,Icon { 96,StatusIcon {
98 id: emblemIcon; 97 id: emblemIcon;
99 objectName: "emblemIcon"; 98 objectName: "emblemIcon";
100 anchors { 99 anchors {
@@ -104,7 +103,6 @@
104 } 103 }
105 source: cardData && cardData["emblem"] || ""; 104 source: cardData && cardData["emblem"] || "";
106 color: backgroundLoader.active && backgroundLoader.item && root.scopeStyle ? root.scopeStyle.getTextColor(backgroundLoader.item.luminance) : (backgroundLoader.item && backgroundLoader.item.luminance > 0.7 ? Theme.palette.normal.baseText : "white");105 color: backgroundLoader.active && backgroundLoader.item && root.scopeStyle ? root.scopeStyle.getTextColor(backgroundLoader.item.luminance) : (backgroundLoader.item && backgroundLoader.item.luminance > 0.7 ? Theme.palette.normal.baseText : "white");
107 width: height;
108 height: source != "" ? titleLabel.font.pixelSize : 0; 106 height: source != "" ? titleLabel.font.pixelSize : 0;
109 }107 }
110 108
111109
=== modified file 'tests/plugins/Dash/cardcreator/7.res'
--- tests/plugins/Dash/cardcreator/7.res 2014-08-29 08:31:22 +0000
+++ tests/plugins/Dash/cardcreator/7.res 2014-09-11 16:03:35 +0000
@@ -6,7 +6,7 @@
6 property var artShapeBorderSource: undefined; 6 property var artShapeBorderSource: undefined;
7 property real fontScale: 1.0; 7 property real fontScale: 1.0;
8 property var scopeStyle: null; 8 property var scopeStyle: null;
9 property int headerAlignment: Text.AlignLeft; 9 property int titleAlignment: Text.AlignLeft;
10 property int fixedHeaderHeight: -1; 10 property int fixedHeaderHeight: -1;
11 property size fixedArtShapeSize: Qt.size(-1, -1); 11 property size fixedArtShapeSize: Qt.size(-1, -1);
12 readonly property string title: cardData && cardData["title"] || ""; 12 readonly property string title: cardData && cardData["title"] || "";
@@ -67,8 +67,9 @@
67 objectName: "mascotImage"; 67 objectName: "mascotImage";
68 anchors { verticalCenter: parent.verticalCenter; } 68 anchors { verticalCenter: parent.verticalCenter; }
69 readonly property int maxSize: Math.max(width, height) * 4; 69 readonly property int maxSize: Math.max(width, height) * 4;
70 source: cardData && cardData["mascot"] || ""; 70 property bool doLoadSource: !NetworkingStatus.limitedBandwith;
71 width: units.gu(6); 71 source: { if (root.visible) doLoadSource = true; return doLoadSource && cardData && cardData["mascot"] || ""; }
72 width: units.gu(6);
72 height: units.gu(5.625); 73 height: units.gu(5.625);
73 sourceSize { width: maxSize; height: maxSize } 74 sourceSize { width: maxSize; height: maxSize }
74 fillMode: Image.PreserveAspectCrop; 75 fillMode: Image.PreserveAspectCrop;
@@ -93,13 +94,13 @@
93 elide: Text.ElideRight; 94 elide: Text.ElideRight;
94 fontSize: "small"; 95 fontSize: "small";
95 wrapMode: Text.Wrap; 96 wrapMode: Text.Wrap;
96 maximumLineCount: 2; 97 maximumLineCount: horizontalAlignment === Text.AlignHCenter ? 1 : 2;
97 font.pixelSize: Math.round(FontUtils.sizeToPixels(fontSize) * fontScale); 98 font.pixelSize: Math.round(FontUtils.sizeToPixels(fontSize) * fontScale);
98 color: backgroundLoader.active && backgroundLoader.item && root.scopeStyle ? root.scopeStyle.getTextColor(backgroundLoader.item.luminance) : (backgroundLoader.item && backgroundLoader.item.luminance > 0.7 ? Theme.palette.normal.baseText : "white");99 color: backgroundLoader.active && backgroundLoader.item && root.scopeStyle ? root.scopeStyle.getTextColor(backgroundLoader.item.luminance) : (backgroundLoader.item && backgroundLoader.item.luminance > 0.7 ? Theme.palette.normal.baseText : "white");
99 visible: showHeader ; 100 visible: showHeader ;
100 text: root.title; 101 text: root.title;
101 font.weight: components && components["subtitle"] ? Font.DemiBold : Font.Normal; 102 font.weight: cardData && cardData["subtitle"] ? Font.DemiBold : Font.Normal;
102 horizontalAlignment: root.headerAlignment; 103 horizontalAlignment: root.titleAlignment;
103 }104 }
104,Label { 105,Label {
105 id: subtitleLabel; 106 id: subtitleLabel;
@@ -111,13 +112,12 @@
111 } 112 }
112 anchors.topMargin: units.dp(2); 113 anchors.topMargin: units.dp(2);
113 elide: Text.ElideRight; 114 elide: Text.ElideRight;
114 fontSize: "small"; 115 fontSize: "x-small";
115 font.pixelSize: Math.round(FontUtils.sizeToPixels(fontSize) * fontScale); 116 font.pixelSize: Math.round(FontUtils.sizeToPixels(fontSize) * fontScale);
116 color: backgroundLoader.active && backgroundLoader.item && root.scopeStyle ? root.scopeStyle.getTextColor(backgroundLoader.item.luminance) : (backgroundLoader.item && backgroundLoader.item.luminance > 0.7 ? Theme.palette.normal.baseText : "white");117 color: backgroundLoader.active && backgroundLoader.item && root.scopeStyle ? root.scopeStyle.getTextColor(backgroundLoader.item.luminance) : (backgroundLoader.item && backgroundLoader.item.luminance > 0.7 ? Theme.palette.normal.baseText : "white");
117 visible: titleLabel.visible && titleLabel.text; 118 visible: titleLabel.visible && titleLabel.text;
118 text: cardData && cardData["subtitle"] || ""; 119 text: cardData && cardData["subtitle"] || "";
119 font.weight: Font.Light; 120 font.weight: Font.Light;
120 horizontalAlignment: root.headerAlignment;
121 }121 }
122,CardAttributes { 122,CardAttributes {
123 id: attributesRow; 123 id: attributesRow;
124124
=== modified file 'tests/plugins/Dash/listviewwithpageheadertest.cpp'
--- tests/plugins/Dash/listviewwithpageheadertest.cpp 2014-04-24 14:13:21 +0000
+++ tests/plugins/Dash/listviewwithpageheadertest.cpp 2014-09-11 16:03:35 +0000
@@ -28,6 +28,8 @@
28#include <private/qquickitem_p.h>28#include <private/qquickitem_p.h>
29#pragma GCC diagnostic pop29#pragma GCC diagnostic pop
3030
31#include <limits>
32
31// TODO Think on how doing a test for lost items33// TODO Think on how doing a test for lost items
32// particullary making sure that lost items are culled34// particullary making sure that lost items are culled
33// and then removed in the next updatePolish cycle35// and then removed in the next updatePolish cycle
@@ -1899,6 +1901,43 @@
1899 QTRY_COMPARE(lvwph->m_firstVisibleIndex, 0);1901 QTRY_COMPARE(lvwph->m_firstVisibleIndex, 0);
1900 }1902 }
19011903
1904 void testNoCacheBuffer()
1905 {
1906 lvwph->setCacheBuffer(0);
1907 QTRY_COMPARE(lvwph->m_visibleItems.count(), 3);
1908 QCOMPARE(lvwph->m_firstVisibleIndex, 0);
1909 verifyItem(0, 50., 150., false);
1910 verifyItem(1, 200., 200., false);
1911 verifyItem(2, 400., 350., false);
1912 QCOMPARE(lvwph->m_minYExtent, 0.);
1913 QCOMPARE(lvwph->m_clipItem->y(), 0.);
1914 QCOMPARE(lvwph->m_clipItem->clip(), false);
1915 QCOMPARE(lvwph->m_headerItem->y(), 0.);
1916 QCOMPARE(lvwph->m_headerItem->height(), 50.);
1917 QCOMPARE(lvwph->contentY(), 0.);
1918 QCOMPARE(lvwph->m_headerItemShownHeight, 0.);
1919 }
1920
1921 void testAllCacheBuffer()
1922 {
1923 lvwph->setCacheBuffer(std::numeric_limits<qreal>::max());
1924 QTRY_COMPARE(lvwph->m_visibleItems.count(), 6);
1925 QCOMPARE(lvwph->m_firstVisibleIndex, 0);
1926 verifyItem(0, 50., 150., false);
1927 verifyItem(1, 200., 200., false);
1928 verifyItem(2, 400., 350., false);
1929 verifyItem(3, 750., 350., true);
1930 verifyItem(4, 1100., 350., true);
1931 verifyItem(5, 1450., 350., true);
1932 QCOMPARE(lvwph->m_minYExtent, 0.);
1933 QCOMPARE(lvwph->m_clipItem->y(), 0.);
1934 QCOMPARE(lvwph->m_clipItem->clip(), false);
1935 QCOMPARE(lvwph->m_headerItem->y(), 0.);
1936 QCOMPARE(lvwph->m_headerItem->height(), 50.);
1937 QCOMPARE(lvwph->contentY(), 0.);
1938 QCOMPARE(lvwph->m_headerItemShownHeight, 0.);
1939 }
1940
1902private:1941private:
1903 QQuickView *view;1942 QQuickView *view;
1904 ListViewWithPageHeader *lvwph;1943 ListViewWithPageHeader *lvwph;
19051944
=== modified file 'tests/plugins/Dash/listviewwithpageheadertest.qml'
--- tests/plugins/Dash/listviewwithpageheadertest.qml 2014-04-30 10:06:33 +0000
+++ tests/plugins/Dash/listviewwithpageheadertest.qml 2014-09-11 16:03:35 +0000
@@ -60,6 +60,7 @@
60 anchors.top: parent.top60 anchors.top: parent.top
61 anchors.bottom: parent.bottom61 anchors.bottom: parent.bottom
62 model: model62 model: model
63 cacheBuffer: height * 0.5
63 delegate: Rectangle {64 delegate: Rectangle {
64 property bool timerDone: false65 property bool timerDone: false
65 width: parent.width - 2066 width: parent.width - 20
6667
=== modified file 'tests/plugins/Dash/listviewwithpageheadertestsection.qml'
--- tests/plugins/Dash/listviewwithpageheadertestsection.qml 2014-04-30 10:06:33 +0000
+++ tests/plugins/Dash/listviewwithpageheadertestsection.qml 2014-09-11 16:03:35 +0000
@@ -60,6 +60,7 @@
60 anchors.top: parent.top60 anchors.top: parent.top
61 anchors.bottom: parent.bottom61 anchors.bottom: parent.bottom
62 model: model62 model: model
63 cacheBuffer: height * 0.5
63 delegate: Rectangle {64 delegate: Rectangle {
64 property bool timerDone: false65 property bool timerDone: false
65 width: parent.width - 2066 width: parent.width - 20
6667
=== modified file 'tests/plugins/Dash/listviewwithpageheadertestsectionexternalmodel.qml'
--- tests/plugins/Dash/listviewwithpageheadertestsectionexternalmodel.qml 2014-04-30 10:06:33 +0000
+++ tests/plugins/Dash/listviewwithpageheadertestsectionexternalmodel.qml 2014-09-11 16:03:35 +0000
@@ -28,6 +28,7 @@
28 anchors.top: parent.top28 anchors.top: parent.top
29 anchors.bottom: parent.bottom29 anchors.bottom: parent.bottom
30 model: model30 model: model
31 cacheBuffer: height * 0.5
31 delegate: Rectangle {32 delegate: Rectangle {
32 property bool timerDone: false33 property bool timerDone: false
33 width: parent.width - 2034 width: parent.width - 20
3435
=== modified file 'tests/plugins/Ubuntu/Gestures/CMakeLists.txt'
--- tests/plugins/Ubuntu/Gestures/CMakeLists.txt 2014-05-01 14:25:18 +0000
+++ tests/plugins/Ubuntu/Gestures/CMakeLists.txt 2014-09-11 16:03:35 +0000
@@ -19,7 +19,7 @@
19 qt5_use_modules(${CLASSNAME}TestExec Test Core Qml Gui Quick)19 qt5_use_modules(${CLASSNAME}TestExec Test Core Qml Gui Quick)
20 target_link_libraries(${CLASSNAME}TestExec UbuntuGestureQml)20 target_link_libraries(${CLASSNAME}TestExec UbuntuGestureQml)
2121
22 add_binary_qml_test(${CLASSNAME} ${CMAKE_BINARY_DIR}/plugins/Ubuntu/Gestures UbuntuGesturesTestQmlFiles)22 add_binary_qml_test(${CLASSNAME} ${CMAKE_BINARY_DIR}/plugins/Ubuntu/Gestures UbuntuGesturesTestQmlFiles "")
23 add_manual_qml_test(. ${CLASSNAME} IMPORT_PATHS ${CMAKE_BINARY_DIR}/plugins)23 add_manual_qml_test(. ${CLASSNAME} IMPORT_PATHS ${CMAKE_BINARY_DIR}/plugins)
24endmacro(add_gesture_ui_test)24endmacro(add_gesture_ui_test)
2525
2626
=== modified file 'tests/qmltests/Components/CMakeLists.txt'
--- tests/qmltests/Components/CMakeLists.txt 2014-05-01 14:25:18 +0000
+++ tests/qmltests/Components/CMakeLists.txt 2014-09-11 16:03:35 +0000
@@ -10,7 +10,7 @@
10qt5_use_modules(DragHandleTestExec Test Core Qml Gui Quick)10qt5_use_modules(DragHandleTestExec Test Core Qml Gui Quick)
11target_link_libraries(DragHandleTestExec UbuntuGestureQml)11target_link_libraries(DragHandleTestExec UbuntuGestureQml)
1212
13add_binary_qml_test(DragHandle ${CMAKE_BINARY_DIR}/plugins/Ubuntu/Gestures "")13add_binary_qml_test(DragHandle ${CMAKE_BINARY_DIR}/plugins/Ubuntu/Gestures "" "")
14add_manual_qml_test(. DragHandle IMPORT_PATHS ${CMAKE_BINARY_DIR}/plugins)14add_manual_qml_test(. DragHandle IMPORT_PATHS ${CMAKE_BINARY_DIR}/plugins)
1515
16add_definitions(-DUBUNTU_GESTURES_PLUGIN_DIR="${CMAKE_BINARY_DIR}/plugins")16add_definitions(-DUBUNTU_GESTURES_PLUGIN_DIR="${CMAKE_BINARY_DIR}/plugins")
1717
=== modified file 'tests/qmltests/Dash/CardHelpers.js'
--- tests/qmltests/Dash/CardHelpers.js 2014-08-08 14:56:53 +0000
+++ tests/qmltests/Dash/CardHelpers.js 2014-09-11 16:03:35 +0000
@@ -16,7 +16,7 @@
1616
17.pragma library17.pragma library
1818
19var components = ["title", "art", "subtitle", "mascot", "emblem", "old-price", "price", "alt-price", "rating", "alt-rating", "summary", "attributes", "overlayColor"]19var components = ["title", "art", "subtitle", "mascot", "emblem", "summary", "attributes", "overlayColor"]
2020
21var defaultLayout = ' \21var defaultLayout = ' \
22{ \22{ \
@@ -37,17 +37,6 @@
37 "overlayColor": null, \37 "overlayColor": null, \
38 "mascot": null, \38 "mascot": null, \
39 "emblem": null, \39 "emblem": null, \
40 "old-price": null, \
41 "price": null, \
42 "alt-price": null, \
43 "rating": { \
44 "type": "stars", \
45 "range": [0, 5], \
46 "full": "image://theme/rating-star-full", \
47 "half": "image://theme/rating-star-half", \
48 "empty": "image://theme/rating-star-empty" \
49 }, \
50 "alt-rating": null, \
51 "summary": null, \40 "summary": null, \
52 "attributes": { "max-count": 2 } \41 "attributes": { "max-count": 2 } \
53 }, \42 }, \
5443
=== modified file 'tests/qmltests/Dash/tst_Card.qml'
--- tests/qmltests/Dash/tst_Card.qml 2014-08-22 14:43:02 +0000
+++ tests/qmltests/Dash/tst_Card.qml 2014-09-11 16:03:35 +0000
@@ -17,6 +17,7 @@
17import QtQuick 2.017import QtQuick 2.0
18import QtTest 1.018import QtTest 1.0
19import Ubuntu.Components 0.119import Ubuntu.Components 0.1
20import Ubuntu.Connectivity 1.0
20import Unity.Test 0.1 as UT21import Unity.Test 0.1 as UT
21import "../../../qml/Dash"22import "../../../qml/Dash"
22import "CardHelpers.js" as Helpers23import "CardHelpers.js" as Helpers
@@ -566,5 +567,25 @@
566 verify((card.width - titleToCard.x - titleToCard.width) === units.gu(1));567 verify((card.width - titleToCard.x - titleToCard.width) === units.gu(1));
567 }568 }
568 }569 }
570
571 function test_load_images_visibility_network_data() {
572 return [
573 { tag: "Visible, network", visible: true, limitedBandwith: false },
574 { tag: "Visible, no network", visible: true, limitedBandwith: true },
575 { tag: "Not Visible, network", visible: false, limitedBandwith: false },
576 { tag: "Not Visible, no network", visible: false, limitedBandwith: true }
577 ];
578 }
579
580 function test_load_images_visibility_network(data) {
581 loader.visible = data.visible;
582 NetworkingStatus.limitedBandwith = data.limitedBandwith;
583
584 selector.selectedIndex = 0;
585 waitForRendering(selector);
586 waitForRendering(card);
587
588 verify(data.visible || !data.limitedBandwith || artImage.source == "");
589 }
569 }590 }
570}591}
571592
=== modified file 'tests/qmltests/Dash/tst_CardTool.qml'
--- tests/qmltests/Dash/tst_CardTool.qml 2014-08-14 23:07:21 +0000
+++ tests/qmltests/Dash/tst_CardTool.qml 2014-09-11 16:03:35 +0000
@@ -85,8 +85,8 @@
85 "layout": { "template": { "card-layout": "vertical" }, "components": { "title": "title", "subtitle": "subtitle" } }85 "layout": { "template": { "card-layout": "vertical" }, "components": { "title": "title", "subtitle": "subtitle" } }
86 },86 },
87 {87 {
88 "name": "Title, price - horizontal",88 "name": "Title, attributes - horizontal",
89 "layout": { "template": { "card-layout": "horizontal" }, "components": { "title": "title", "price": "price" } }89 "layout": { "template": { "card-layout": "horizontal" }, "components": { "title": "title", "attributes": "attributes" } }
90 },90 },
91 ]91 ]
9292
@@ -100,6 +100,7 @@
100 }100 }
101101
102 Column {102 Column {
103 id: column
103 width: units.gu(38)104 width: units.gu(38)
104 anchors { left: parent.left; top: parent.top; margins: units.gu(1) }105 anchors { left: parent.left; top: parent.top; margins: units.gu(1) }
105106
@@ -111,7 +112,7 @@
111 ]112 ]
112113
113 delegate: Row {114 delegate: Row {
114 anchors { left: parent.left; right: parent.right; margins: units.gu(3) }115 anchors { left: column.left; right: column.right; margins: units.gu(3) }
115116
116 Label {117 Label {
117 height: units.gu(5)118 height: units.gu(5)
@@ -315,28 +316,35 @@
315 }316 }
316 }317 }
317318
318 function test_card_header_component_alignment_data() {319 function test_card_title_alignment_data() {
319 return [320 return [
320 { tag: "Title - vertical", component: "titleLabel", property: "headerAlignment",321 { tag: "Art, header, summary", value: Text.AlignLeft, index: 0 },
321 value: Text.AlignHCenter, index: 11, layout_index: 0 },322 { tag: "Header, summary", value: Text.AlignLeft, index: 1 },
322 { tag: "Title - horizontal", component: "titleLabel", property: "headerAlignment",323 { tag: "Art, header", value: Text.AlignLeft, index: 2 },
323 value: Text.AlignLeft, index: 12, layout_index: 0},324 { tag: "Header only", value: Text.AlignLeft, index: 3 },
324 { tag: "Title, subtitle - vertical", component: "titleLabel", property: "headerAlignment",325 { tag: "Header title only", value: Text.AlignHCenter, index: 4 },
325 value: Text.AlignLeft, index: 13, layout_index: 0},326 { tag: "Header title and subtitle", value: Text.AlignLeft, index: 5 },
326 { tag: "Title, price - horizontal", component: "titleLabel", property: "headerAlignment",327 { tag: "Header title and mascot", value: Text.AlignLeft, index: 6 },
327 value: Text.AlignLeft, index: 14, layout_index: 0},328 { tag: "Art, header, summary - small", value: Text.AlignLeft, index: 7 },
328 ]329 { tag: "Art, header, summary - large", value: Text.AlignLeft, index: 8 },
330 { tag: "Art, header, summary - horizontal", value: Text.AlignLeft, index: 9 },
331 { tag: "Art, header - portrait", value: Text.AlignLeft, index: 10 },
332 { tag: "Title - vertical", value: Text.AlignHCenter, index: 11 },
333 { tag: "Title - horizontal", value: Text.AlignLeft, index: 12 },
334 { tag: "Title, subtitle - vertical", value: Text.AlignLeft, index: 13 },
335 { tag: "Title, attributes - horizontal", value: Text.AlignLeft, index: 14 },
336 ];
329 }337 }
330338
331 function test_card_header_component_alignment(data) {339 function test_card_title_alignment(data) {
332 selector.selectedIndex = data.index;340 selector.selectedIndex = data.index;
333 if (data.hasOwnProperty("layout_index")) {341
334 layoutSelector.selectedIndex = data.layout_index;342 tryCompare(cardTool, "titleAlignment", Text.AlignLeft);
335 }343
336344 cardTool.components['title'] = { "field": "title", "align": "center" };
337 if (data.hasOwnProperty("property")) {345 cardTool.componentsChanged();
338 tryCompare(cardTool, data.property, data.value);346
339 }347 tryCompare(cardTool, "titleAlignment", data.value);
340 }348 }
341349
342 function test_categoryLayout_data() {350 function test_categoryLayout_data() {
343351
=== modified file 'tests/qmltests/Dash/tst_Dash.qml'
--- tests/qmltests/Dash/tst_Dash.qml 2014-09-08 14:14:12 +0000
+++ tests/qmltests/Dash/tst_Dash.qml 2014-09-11 16:03:35 +0000
@@ -249,8 +249,7 @@
249 var categoryListView = findChild(dashContentList.currentItem, "categoryListView");249 var categoryListView = findChild(dashContentList.currentItem, "categoryListView");
250 var dashCategory2 = findChild(categoryListView, "dashCategory2");250 var dashCategory2 = findChild(categoryListView, "dashCategory2");
251 tryCompareFunction(function() {251 tryCompareFunction(function() {
252 var d = findChild(dashCategory2, "delegate2");252 if (dashCategory2.y < 200) return true;
253 if (d) return true;
254 categoryListView.contentY += 100;253 categoryListView.contentY += 100;
255 return false;254 return false;
256 }, true);255 }, true);
257256
=== modified file 'tests/qmltests/Dash/tst_GenericScopeView.qml'
--- tests/qmltests/Dash/tst_GenericScopeView.qml 2014-08-26 19:25:41 +0000
+++ tests/qmltests/Dash/tst_GenericScopeView.qml 2014-09-11 16:03:35 +0000
@@ -1,5 +1,5 @@
1/*1/*
2 * Copyright 2013 Canonical Ltd.2 * Copyright 2013, 2014 Canonical Ltd.
3 *3 *
4 * This program is free software; you can redistribute it and/or modify4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by5 * it under the terms of the GNU General Public License as published by
@@ -43,6 +43,10 @@
43 onLoadedChanged: if (loaded) genericScopeView.scope = scopes.getScope(2);43 onLoadedChanged: if (loaded) genericScopeView.scope = scopes.getScope(2);
44 }44 }
4545
46 MockScope {
47 id: mockScope
48 }
49
46 SignalSpy {50 SignalSpy {
47 id: spy51 id: spy
48 }52 }
@@ -78,18 +82,29 @@
78 spy.signalName = "";82 spy.signalName = "";
79 }83 }
8084
81 function scrollToCategory(category) {85 function scrollToCategory(categoryName) {
82 var categoryListView = findChild(genericScopeView, "categoryListView");86 var categoryListView = findChild(genericScopeView, "categoryListView");
83 tryCompareFunction(function() {87 tryCompareFunction(function() {
84 if (findChild(genericScopeView, category)) return true;88 var category = findChild(genericScopeView, categoryName);
89 if (category && category.y > 0 && category.y < genericScopeView.height) return true;
85 mouseFlick(genericScopeView, genericScopeView.width/2, genericScopeView.height,90 mouseFlick(genericScopeView, genericScopeView.width/2, genericScopeView.height,
86 genericScopeView.width/2, genericScopeView.y)91 genericScopeView.width/2, genericScopeView.y)
87 tryCompare(categoryListView, "moving", false);92 tryCompare(categoryListView, "moving", false);
88 return findChild(genericScopeView, category) !== null;93 return false;
89 }, true);94 }, true);
9095
91 tryCompareFunction(function() { return findChild(genericScopeView, "delegate0") !== null; }, true);96 tryCompareFunction(function() { return findChild(genericScopeView, "delegate0") !== null; }, true);
92 return findChild(genericScopeView, category);97 return findChild(genericScopeView, categoryName);
98 }
99
100 function scrollToEnd()
101 {
102 var categoryListView = findChild(genericScopeView, "categoryListView");
103 while (!categoryListView.atYEnd) {
104 mouseFlick(genericScopeView, genericScopeView.width/2, genericScopeView.height - units.gu(8),
105 genericScopeView.width/2, genericScopeView.y)
106 tryCompare(categoryListView, "moving", false);
107 }
93 }108 }
94109
95 function test_isActive() {110 function test_isActive() {
@@ -268,7 +283,7 @@
268 if (category === undefined) category = 0;283 if (category === undefined) category = 0;
269 if (delegate === undefined) delegate = 0;284 if (delegate === undefined) delegate = 0;
270 tryCompareFunction(function() {285 tryCompareFunction(function() {
271 var cardGrid = findChild(genericScopeView, category);286 var cardGrid = findChild(genericScopeView, "dashCategory"+category);
272 if (cardGrid != null) {287 if (cardGrid != null) {
273 var tile = findChild(cardGrid, "delegate"+delegate);288 var tile = findChild(cardGrid, "delegate"+delegate);
274 return tile != null;289 return tile != null;
@@ -276,7 +291,7 @@
276 return false;291 return false;
277 },292 },
278 true);293 true);
279 var tile = findChild(findChild(genericScopeView, category), "delegate"+delegate);294 var tile = findChild(findChild(genericScopeView, "dashCategory"+category), "delegate"+delegate);
280 mouseClick(tile, tile.width / 2, tile.height / 2);295 mouseClick(tile, tile.width / 2, tile.height / 2);
281 tryCompare(testCase.subPageLoader, "open", true);296 tryCompare(testCase.subPageLoader, "open", true);
282 tryCompare(testCase.subPageLoader, "x", 0);297 tryCompare(testCase.subPageLoader, "x", 0);
@@ -426,6 +441,87 @@
426 compare(image.source, data.logo, "Title image has the wrong source");441 compare(image.source, data.logo, "Title image has the wrong source");
427 }442 }
428443
444 function test_seeAllTwoCategoriesScenario1() {
445 mockScope.setId("mockScope");
446 mockScope.setName("Mock Scope");
447 mockScope.categories.setCount(2);
448 mockScope.categories.resultModel(0).setResultCount(50);
449 mockScope.categories.resultModel(1).setResultCount(15);
450 mockScope.categories.setLayout(0, "grid");
451 mockScope.categories.setLayout(1, "grid");
452 mockScope.categories.setHeaderLink(0, "");
453 mockScope.categories.setHeaderLink(1, "");
454 genericScopeView.scope = mockScope;
455 waitForRendering(genericScopeView.categoryView);
456
457 var category0 = findChild(genericScopeView, "dashCategory0")
458 var seeAll0 = findChild(category0, "seeAll")
459
460 waitForRendering(seeAll0);
461 verify(category0.expandable);
462 verify(!category0.expanded);
463
464 mouseClick(seeAll0, seeAll0.width / 2, seeAll0.height / 2);
465 verify(category0.expanded);
466 tryCompare(category0, "height", category0.item.expandedHeight + seeAll0.height);
467 tryCompare(genericScopeView.categoryView, "contentY", units.gu(13.5));
468
469 scrollToEnd();
470
471 tryCompareFunction(function() { return findChild(genericScopeView, "dashCategory1") !== null; }, true);
472 var category1 = findChild(genericScopeView, "dashCategory1")
473 var seeAll1 = findChild(category1, "seeAll")
474 verify(category1.expandable);
475 verify(!category1.expanded);
476
477 mouseClick(seeAll1, seeAll1.width / 2, seeAll1.height / 2);
478 verify(!category0.expanded);
479 verify(category1.expanded);
480 tryCompare(category1, "height", category1.item.expandedHeight + seeAll1.height);
481 tryCompareFunction(function() {
482 return genericScopeView.categoryView.contentY + category1.y + category1.height + genericScopeView.categoryView.pageHeader.height
483 == genericScopeView.categoryView.contentHeight;}
484 , true);
485 }
486
487 function test_seeAllTwoCategoriesScenario2() {
488 mockScope.setId("mockScope");
489 mockScope.setName("Mock Scope");
490 mockScope.categories.setCount(2);
491 mockScope.categories.resultModel(0).setResultCount(15);
492 mockScope.categories.resultModel(1).setResultCount(50);
493 mockScope.categories.setLayout(0, "grid");
494 mockScope.categories.setLayout(1, "grid");
495 mockScope.categories.setHeaderLink(0, "");
496 mockScope.categories.setHeaderLink(1, "");
497 genericScopeView.scope = mockScope;
498 waitForRendering(genericScopeView.categoryView);
499
500 var category0 = findChild(genericScopeView, "dashCategory0")
501 var seeAll0 = findChild(category0, "seeAll")
502
503 waitForRendering(seeAll0);
504 verify(category0.expandable);
505 verify(!category0.expanded);
506
507 mouseClick(seeAll0, seeAll0.width / 2, seeAll0.height / 2);
508 verify(category0.expanded);
509 tryCompare(category0, "height", category0.item.expandedHeight + seeAll0.height);
510
511 scrollToEnd();
512
513 var category1 = findChild(genericScopeView, "dashCategory1")
514 var seeAll1 = findChild(category1, "seeAll")
515 verify(category1.expandable);
516 verify(!category1.expanded);
517
518 mouseClick(seeAll1, seeAll1.width / 2, seeAll1.height / 2);
519 verify(!category0.expanded);
520 verify(category1.expanded);
521 tryCompare(category1, "height", category1.item.expandedHeight + seeAll1.height);
522 tryCompare(category1, "y", units.gu(5));
523 }
524
429 function test_favorite_data() {525 function test_favorite_data() {
430 return [526 return [
431 { tag: "People", id: "MockScope1", favorite: true },527 { tag: "People", id: "MockScope1", favorite: true },

Subscribers

People subscribed via source and target branches