Merge lp:~unity-team/unity8/ota9.5 into lp:unity8/stable
- ota9.5
- Merge into stable
Proposed by
Michał Sawicz
Status: | Merged |
---|---|
Approved by: | Michał Sawicz |
Approved revision: | 2142 |
Merged at revision: | 2140 |
Proposed branch: | lp:~unity-team/unity8/ota9.5 |
Merge into: | lp:unity8/stable |
Diff against target: |
755 lines (+464/-66) 13 files modified
plugins/Dash/CardCreator.js (+34/-30) plugins/Dash/CardCreatorCache.qml (+1/-1) plugins/Dash/listviewwithpageheader.cpp (+18/-9) plugins/Dash/listviewwithpageheader.h (+1/-0) tests/plugins/Dash/cardcreator/10.res (+142/-0) tests/plugins/Dash/cardcreator/10.tst (+2/-1) tests/plugins/Dash/cardcreator/11.res (+217/-0) tests/plugins/Dash/cardcreator/11.tst (+3/-0) tests/plugins/Dash/cardcreator/3.res (+1/-1) tests/plugins/Dash/cardcreator/6.res (+1/-1) tests/plugins/Dash/cardcreatortest.cpp (+21/-22) tests/plugins/Dash/listviewwithpageheadertest.cpp (+23/-0) tests/plugins/Dash/listviewwithpageheadertest.qml (+0/-1) |
To merge this branch: | bzr merge lp:~unity-team/unity8/ota9.5 |
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Michał Sawicz | code | Approve | |
Review via email: mp+285731@code.launchpad.net |
Commit message
[r2175] LVWPH: Reset to initial values when list is empty
[r2166] Better attempt at sanitization
[r2162] Do not use the same filepath parameter for all the card creator createQmlObject calls
Description of the change
To post a comment you must log in.
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'plugins/Dash/CardCreator.js' | |||
2 | --- plugins/Dash/CardCreator.js 2016-01-21 22:33:46 +0000 | |||
3 | +++ plugins/Dash/CardCreator.js 2016-02-11 14:27:32 +0000 | |||
4 | @@ -16,9 +16,9 @@ | |||
5 | 16 | 16 | ||
6 | 17 | .pragma library | 17 | .pragma library |
7 | 18 | 18 | ||
11 | 19 | // %1 is the template["card-background"] string | 19 | // %1 is the template["card-background"]["elements"][0] |
12 | 20 | // %2 is the template["card-background"]["elements"][0] | 20 | // %2 is the template["card-background"]["elements"][1] |
13 | 21 | // %3 is the template["card-background"]["elements"][1] | 21 | // %3 is the template["card-background"] string |
14 | 22 | var kBackgroundLoaderCode = 'Loader {\n\ | 22 | var kBackgroundLoaderCode = 'Loader {\n\ |
15 | 23 | id: backgroundLoader; \n\ | 23 | id: backgroundLoader; \n\ |
16 | 24 | objectName: "backgroundLoader"; \n\ | 24 | objectName: "backgroundLoader"; \n\ |
17 | @@ -46,14 +46,14 @@ | |||
18 | 46 | objectName: "backgroundImage"; \n\ | 46 | objectName: "backgroundImage"; \n\ |
19 | 47 | source: { \n\ | 47 | source: { \n\ |
20 | 48 | if (cardData && typeof cardData["background"] === "string") return cardData["background"]; \n\ | 48 | if (cardData && typeof cardData["background"] === "string") return cardData["background"]; \n\ |
22 | 49 | else return "%1"; \n\ | 49 | else return %3; \n\ |
23 | 50 | } \n\ | 50 | } \n\ |
24 | 51 | } \n\ | 51 | } \n\ |
25 | 52 | function getColor(index) { \n\ | 52 | function getColor(index) { \n\ |
26 | 53 | if (cardData && typeof cardData["background"] === "object" \n\ | 53 | if (cardData && typeof cardData["background"] === "object" \n\ |
27 | 54 | && (cardData["background"]["type"] === "color" || cardData["background"]["type"] === "gradient")) { \n\ | 54 | && (cardData["background"]["type"] === "color" || cardData["background"]["type"] === "gradient")) { \n\ |
28 | 55 | return cardData["background"]["elements"][index]; \n\ | 55 | return cardData["background"]["elements"][index]; \n\ |
30 | 56 | } else return index === 0 ? %2 : %3; \n\ | 56 | } else return index === 0 ? %1 : %2; \n\ |
31 | 57 | } \n\ | 57 | } \n\ |
32 | 58 | } \n\ | 58 | } \n\ |
33 | 59 | }\n'; | 59 | }\n'; |
34 | @@ -373,27 +373,21 @@ | |||
35 | 373 | color: %3; \n\ | 373 | color: %3; \n\ |
36 | 374 | }'; | 374 | }'; |
37 | 375 | 375 | ||
45 | 376 | function evil_param(object) { | 376 | function sanitizeColor(colorString) { |
46 | 377 | for (var x in object) { | 377 | if (colorString !== undefined) { |
47 | 378 | if (typeof object[x] === "object" && evil_param(object[x])) | 378 | if (colorString.match(/^[#a-z0-9]*$/i) === null) { |
48 | 379 | return true; | 379 | // This is not the perfect regexp for color |
49 | 380 | 380 | // but what we're trying to do here is just protect | |
50 | 381 | if (typeof object[x] === "string" && object[x].match(/"(?:[^"\\]|\\.)*"/) != null) | 381 | // against injection so it's ok |
51 | 382 | return true; | 382 | return ""; |
52 | 383 | } | ||
53 | 383 | } | 384 | } |
56 | 384 | 385 | return colorString; | |
55 | 385 | return false; | ||
57 | 386 | } | 386 | } |
58 | 387 | 387 | ||
59 | 388 | function cardString(template, components) { | 388 | function cardString(template, components) { |
60 | 389 | var code; | 389 | var code; |
61 | 390 | 390 | ||
62 | 391 | if (evil_param(template)) | ||
63 | 392 | return ""; | ||
64 | 393 | |||
65 | 394 | if (evil_param(components)) | ||
66 | 395 | return ""; | ||
67 | 396 | |||
68 | 397 | var templateInteractive = (template == null ? true : (template["non-interactive"] !== undefined ? !template["non-interactive"] : true)) ? "true" : "false"; | 391 | var templateInteractive = (template == null ? true : (template["non-interactive"] !== undefined ? !template["non-interactive"] : true)) ? "true" : "false"; |
69 | 398 | 392 | ||
70 | 399 | code = 'AbstractButton { \n\ | 393 | code = 'AbstractButton { \n\ |
71 | @@ -442,18 +436,26 @@ | |||
72 | 442 | } | 436 | } |
73 | 443 | 437 | ||
74 | 444 | if (hasBackground) { | 438 | if (hasBackground) { |
76 | 445 | var templateCardBackground = (template && typeof template["card-background"] === "string") ? template["card-background"] : ""; | 439 | var templateCardBackground; |
77 | 440 | if (template && typeof template["card-background"] === "string") { | ||
78 | 441 | templateCardBackground = 'decodeURI("' + encodeURI(template["card-background"]) + '")'; | ||
79 | 442 | } else { | ||
80 | 443 | templateCardBackground = '""'; | ||
81 | 444 | } | ||
82 | 445 | |||
83 | 446 | var backgroundElements0; | 446 | var backgroundElements0; |
84 | 447 | var backgroundElements1; | 447 | var backgroundElements1; |
85 | 448 | if (template && typeof template["card-background"] === "object" && (template["card-background"]["type"] === "color" || template["card-background"]["type"] === "gradient")) { | 448 | if (template && typeof template["card-background"] === "object" && (template["card-background"]["type"] === "color" || template["card-background"]["type"] === "gradient")) { |
88 | 449 | if (template["card-background"]["elements"][0] !== undefined) { | 449 | var element0 = sanitizeColor(template["card-background"]["elements"][0]); |
89 | 450 | backgroundElements0 = '"%1"'.arg(template["card-background"]["elements"][0]); | 450 | var element1 = sanitizeColor(template["card-background"]["elements"][1]); |
90 | 451 | if (element0 !== undefined) { | ||
91 | 452 | backgroundElements0 = '"%1"'.arg(element0); | ||
92 | 451 | } | 453 | } |
95 | 452 | if (template["card-background"]["elements"][1] !== undefined) { | 454 | if (element1 !== undefined) { |
96 | 453 | backgroundElements1 = '"%1"'.arg(template["card-background"]["elements"][1]); | 455 | backgroundElements1 = '"%1"'.arg(element1); |
97 | 454 | } | 456 | } |
98 | 455 | } | 457 | } |
100 | 456 | code += kBackgroundLoaderCode.arg(templateCardBackground).arg(backgroundElements0).arg(backgroundElements1); | 458 | code += kBackgroundLoaderCode.arg(backgroundElements0).arg(backgroundElements1).arg(templateCardBackground); |
101 | 457 | } | 459 | } |
102 | 458 | 460 | ||
103 | 459 | if (hasArt) { | 461 | if (hasArt) { |
104 | @@ -479,9 +481,10 @@ | |||
105 | 479 | } | 481 | } |
106 | 480 | 482 | ||
107 | 481 | var fallback = components["art"] && components["art"]["fallback"] || ""; | 483 | var fallback = components["art"] && components["art"]["fallback"] || ""; |
108 | 484 | fallback = encodeURI(fallback); | ||
109 | 482 | var fallbackCode = ""; | 485 | var fallbackCode = ""; |
110 | 483 | if (fallback !== "") { | 486 | if (fallback !== "") { |
112 | 484 | fallbackCode += 'onStatusChanged: if (status === Image.Error) source = "%1";'.arg(fallback); | 487 | fallbackCode += 'onStatusChanged: if (status === Image.Error) source = decodeURI("%1");'.arg(fallback); |
113 | 485 | } | 488 | } |
114 | 486 | code += kArtShapeHolderCode.arg(artAnchors).arg(widthCode).arg(heightCode).arg(fallbackCode); | 489 | code += kArtShapeHolderCode.arg(artAnchors).arg(widthCode).arg(heightCode).arg(fallbackCode); |
115 | 487 | } else { | 490 | } else { |
116 | @@ -576,9 +579,10 @@ | |||
117 | 576 | 579 | ||
118 | 577 | var mascotImageVisible = useMascotShape ? 'false' : 'showHeader'; | 580 | var mascotImageVisible = useMascotShape ? 'false' : 'showHeader'; |
119 | 578 | var fallback = components["mascot"] && components["mascot"]["fallback"] || ""; | 581 | var fallback = components["mascot"] && components["mascot"]["fallback"] || ""; |
120 | 582 | fallback = encodeURI(fallback); | ||
121 | 579 | var fallbackCode = ""; | 583 | var fallbackCode = ""; |
122 | 580 | if (fallback !== "") { | 584 | if (fallback !== "") { |
124 | 581 | fallbackCode += 'onStatusChanged: if (status === Image.Error) source = "%1";'.arg(fallback); | 585 | fallbackCode += 'onStatusChanged: if (status === Image.Error) source = decodeURI("%1");'.arg(fallback); |
125 | 582 | } | 586 | } |
126 | 583 | mascotCode = kMascotImageCode.arg(mascotAnchors).arg(mascotImageVisible).arg(fallbackCode); | 587 | mascotCode = kMascotImageCode.arg(mascotAnchors).arg(mascotImageVisible).arg(fallbackCode); |
127 | 584 | } | 588 | } |
128 | @@ -825,7 +829,7 @@ | |||
129 | 825 | return code; | 829 | return code; |
130 | 826 | } | 830 | } |
131 | 827 | 831 | ||
133 | 828 | function createCardComponent(parent, template, components) { | 832 | function createCardComponent(parent, template, components, identifier) { |
134 | 829 | var imports = 'import QtQuick 2.4; \n\ | 833 | var imports = 'import QtQuick 2.4; \n\ |
135 | 830 | import Ubuntu.Components 1.3; \n\ | 834 | import Ubuntu.Components 1.3; \n\ |
136 | 831 | import Ubuntu.Settings.Components 0.1; \n\ | 835 | import Ubuntu.Settings.Components 0.1; \n\ |
137 | @@ -835,7 +839,7 @@ | |||
138 | 835 | var code = imports + 'Component {\n' + card + '}\n'; | 839 | var code = imports + 'Component {\n' + card + '}\n'; |
139 | 836 | 840 | ||
140 | 837 | try { | 841 | try { |
142 | 838 | return Qt.createQmlObject(code, parent, "createCardComponent"); | 842 | return Qt.createQmlObject(code, parent, identifier); |
143 | 839 | } catch (e) { | 843 | } catch (e) { |
144 | 840 | console.error("ERROR: Invalid component created."); | 844 | console.error("ERROR: Invalid component created."); |
145 | 841 | console.error("Template:"); | 845 | console.error("Template:"); |
146 | 842 | 846 | ||
147 | === modified file 'plugins/Dash/CardCreatorCache.qml' | |||
148 | --- plugins/Dash/CardCreatorCache.qml 2015-07-15 15:07:19 +0000 | |||
149 | +++ plugins/Dash/CardCreatorCache.qml 2016-02-11 14:27:32 +0000 | |||
150 | @@ -32,7 +32,7 @@ | |||
151 | 32 | var allString = tString + cString; | 32 | var allString = tString + cString; |
152 | 33 | var component = cache[allString]; | 33 | var component = cache[allString]; |
153 | 34 | if (component === undefined) { | 34 | if (component === undefined) { |
155 | 35 | component = CardCreator.createCardComponent(root, template, components); | 35 | component = CardCreator.createCardComponent(root, template, components, allString); |
156 | 36 | cache[allString] = component; | 36 | cache[allString] = component; |
157 | 37 | } | 37 | } |
158 | 38 | return component; | 38 | return component; |
159 | 39 | 39 | ||
160 | === modified file 'plugins/Dash/listviewwithpageheader.cpp' | |||
161 | --- plugins/Dash/listviewwithpageheader.cpp 2016-01-05 09:24:58 +0000 | |||
162 | +++ plugins/Dash/listviewwithpageheader.cpp 2016-02-11 14:27:32 +0000 | |||
163 | @@ -219,13 +219,7 @@ | |||
164 | 219 | Q_FOREACH(ListItem *item, m_visibleItems) | 219 | Q_FOREACH(ListItem *item, m_visibleItems) |
165 | 220 | releaseItem(item); | 220 | releaseItem(item); |
166 | 221 | m_visibleItems.clear(); | 221 | m_visibleItems.clear(); |
174 | 222 | m_firstVisibleIndex = -1; | 222 | initializeValuesForEmptyList(); |
168 | 223 | adjustMinYExtent(); | ||
169 | 224 | setContentY(0); | ||
170 | 225 | m_clipItem->setY(0); | ||
171 | 226 | if (m_topSectionItem) { | ||
172 | 227 | QQuickItemPrivate::get(m_topSectionItem)->setCulled(true); | ||
173 | 228 | } | ||
175 | 229 | 223 | ||
176 | 230 | m_delegateModel->setDelegate(delegate); | 224 | m_delegateModel->setDelegate(delegate); |
177 | 231 | 225 | ||
178 | @@ -236,6 +230,17 @@ | |||
179 | 236 | } | 230 | } |
180 | 237 | } | 231 | } |
181 | 238 | 232 | ||
182 | 233 | void ListViewWithPageHeader::initializeValuesForEmptyList() | ||
183 | 234 | { | ||
184 | 235 | m_firstVisibleIndex = -1; | ||
185 | 236 | adjustMinYExtent(); | ||
186 | 237 | setContentY(0); | ||
187 | 238 | m_clipItem->setY(0); | ||
188 | 239 | if (m_topSectionItem) { | ||
189 | 240 | QQuickItemPrivate::get(m_topSectionItem)->setCulled(true); | ||
190 | 241 | } | ||
191 | 242 | } | ||
192 | 243 | |||
193 | 239 | QQuickItem *ListViewWithPageHeader::header() const | 244 | QQuickItem *ListViewWithPageHeader::header() const |
194 | 240 | { | 245 | { |
195 | 241 | return m_headerItem; | 246 | return m_headerItem; |
196 | @@ -835,7 +840,7 @@ | |||
197 | 835 | } | 840 | } |
198 | 836 | } | 841 | } |
199 | 837 | if (!foundVisible) { | 842 | if (!foundVisible) { |
201 | 838 | m_firstVisibleIndex = -1; | 843 | initializeValuesForEmptyList(); |
202 | 839 | } | 844 | } |
203 | 840 | if (m_firstVisibleIndex != oldFirstVisibleIndex) { | 845 | if (m_firstVisibleIndex != oldFirstVisibleIndex) { |
204 | 841 | adjustMinYExtent(); | 846 | adjustMinYExtent(); |
205 | @@ -1092,7 +1097,11 @@ | |||
206 | 1092 | } | 1097 | } |
207 | 1093 | 1098 | ||
208 | 1094 | if (m_firstVisibleIndex != oldFirstVisibleIndex) { | 1099 | if (m_firstVisibleIndex != oldFirstVisibleIndex) { |
210 | 1095 | adjustMinYExtent(); | 1100 | if (m_visibleItems.isEmpty()) { |
211 | 1101 | initializeValuesForEmptyList(); | ||
212 | 1102 | } else { | ||
213 | 1103 | adjustMinYExtent(); | ||
214 | 1104 | } | ||
215 | 1096 | } | 1105 | } |
216 | 1097 | 1106 | ||
217 | 1098 | for (int i = 0; i < m_visibleItems.count(); ++i) { | 1107 | for (int i = 0; i < m_visibleItems.count(); ++i) { |
218 | 1099 | 1108 | ||
219 | === modified file 'plugins/Dash/listviewwithpageheader.h' | |||
220 | --- plugins/Dash/listviewwithpageheader.h 2015-11-26 13:50:56 +0000 | |||
221 | +++ plugins/Dash/listviewwithpageheader.h 2016-02-11 14:27:32 +0000 | |||
222 | @@ -168,6 +168,7 @@ | |||
223 | 168 | QQuickItem *getSectionItem(int modelIndex, bool alreadyInserted); | 168 | QQuickItem *getSectionItem(int modelIndex, bool alreadyInserted); |
224 | 169 | QQuickItem *getSectionItem(const QString §ionText); | 169 | QQuickItem *getSectionItem(const QString §ionText); |
225 | 170 | void updateSectionItem(int modelIndex); | 170 | void updateSectionItem(int modelIndex); |
226 | 171 | void initializeValuesForEmptyList(); | ||
227 | 171 | 172 | ||
228 | 172 | QQmlDelegateModel *m_delegateModel; | 173 | QQmlDelegateModel *m_delegateModel; |
229 | 173 | 174 | ||
230 | 174 | 175 | ||
231 | === added directory 'plugins/UInput' | |||
232 | === added file 'tests/plugins/Dash/cardcreator/10.res' | |||
233 | --- tests/plugins/Dash/cardcreator/10.res 1970-01-01 00:00:00 +0000 | |||
234 | +++ tests/plugins/Dash/cardcreator/10.res 2016-02-11 14:27:32 +0000 | |||
235 | @@ -0,0 +1,142 @@ | |||
236 | 1 | AbstractButton { | ||
237 | 2 | id: root; | ||
238 | 3 | property var components; | ||
239 | 4 | property var cardData; | ||
240 | 5 | property string artShapeStyle: "inset"; | ||
241 | 6 | property string backgroundShapeStyle: "inset"; | ||
242 | 7 | property real fontScale: 1.0; | ||
243 | 8 | property var scopeStyle: null; | ||
244 | 9 | property int titleAlignment: Text.AlignLeft; | ||
245 | 10 | property int fixedHeaderHeight: -1; | ||
246 | 11 | property size fixedArtShapeSize: Qt.size(-1, -1); | ||
247 | 12 | readonly property string title: cardData && cardData["title"] || ""; | ||
248 | 13 | property bool asynchronous: true; | ||
249 | 14 | property bool showHeader: true; | ||
250 | 15 | implicitWidth: childrenRect.width; | ||
251 | 16 | enabled: true; | ||
252 | 17 | |||
253 | 18 | Loader { | ||
254 | 19 | id: backgroundLoader; | ||
255 | 20 | objectName: "backgroundLoader"; | ||
256 | 21 | anchors.fill: parent; | ||
257 | 22 | asynchronous: root.asynchronous; | ||
258 | 23 | visible: status == Loader.Ready; | ||
259 | 24 | sourceComponent: UbuntuShape { | ||
260 | 25 | objectName: "background"; | ||
261 | 26 | radius: "medium"; | ||
262 | 27 | aspect: { | ||
263 | 28 | switch (root.backgroundShapeStyle) { | ||
264 | 29 | case "inset": return UbuntuShape.Inset; | ||
265 | 30 | case "shadow": return UbuntuShape.DropShadow; | ||
266 | 31 | default: | ||
267 | 32 | case "flat": return UbuntuShape.Flat; | ||
268 | 33 | } | ||
269 | 34 | } | ||
270 | 35 | backgroundColor: getColor(0) || "white"; | ||
271 | 36 | secondaryBackgroundColor: getColor(1) || backgroundColor; | ||
272 | 37 | backgroundMode: UbuntuShape.VerticalGradient; | ||
273 | 38 | anchors.fill: parent; | ||
274 | 39 | source: backgroundImage.source ? backgroundImage : null; | ||
275 | 40 | property real luminance: Style.luminance(backgroundColor); | ||
276 | 41 | property Image backgroundImage: Image { | ||
277 | 42 | objectName: "backgroundImage"; | ||
278 | 43 | source: { | ||
279 | 44 | if (cardData && typeof cardData["background"] === "string") return cardData["background"]; | ||
280 | 45 | else return ""; | ||
281 | 46 | } | ||
282 | 47 | } | ||
283 | 48 | function getColor(index) { | ||
284 | 49 | if (cardData && typeof cardData["background"] === "object" | ||
285 | 50 | && (cardData["background"]["type"] === "color" || cardData["background"]["type"] === "gradient")) { | ||
286 | 51 | return cardData["background"]["elements"][index]; | ||
287 | 52 | } else return index === 0 ? "" : ""; | ||
288 | 53 | } | ||
289 | 54 | } | ||
290 | 55 | } | ||
291 | 56 | readonly property size artShapeSize: Qt.size(-1, -1); | ||
292 | 57 | readonly property int headerHeight: row.height; | ||
293 | 58 | Row { | ||
294 | 59 | id: row; | ||
295 | 60 | objectName: "outerRow"; | ||
296 | 61 | property real margins: units.gu(1); | ||
297 | 62 | spacing: margins; | ||
298 | 63 | height: root.fixedHeaderHeight != -1 ? root.fixedHeaderHeight : implicitHeight; | ||
299 | 64 | anchors { top: parent.top; | ||
300 | 65 | topMargin: units.gu(1); | ||
301 | 66 | left: parent.left; | ||
302 | 67 | } | ||
303 | 68 | anchors.right: parent.right; | ||
304 | 69 | anchors.margins: margins; | ||
305 | 70 | anchors.rightMargin: 0; | ||
306 | 71 | data: [ | ||
307 | 72 | CroppedImageMinimumSourceSize { | ||
308 | 73 | id: mascotImage; | ||
309 | 74 | objectName: "mascotImage"; | ||
310 | 75 | anchors { verticalCenter: parent.verticalCenter; } | ||
311 | 76 | source: cardData && cardData["mascot"] || ""; | ||
312 | 77 | width: units.gu(6); | ||
313 | 78 | height: units.gu(5.625); | ||
314 | 79 | horizontalAlignment: Image.AlignHCenter; | ||
315 | 80 | verticalAlignment: Image.AlignVCenter; | ||
316 | 81 | visible: showHeader; | ||
317 | 82 | |||
318 | 83 | } | ||
319 | 84 | ,Item { | ||
320 | 85 | id: headerTitleContainer; | ||
321 | 86 | anchors { verticalCenter: parent.verticalCenter; } | ||
322 | 87 | width: parent.width - x; | ||
323 | 88 | implicitHeight: titleLabel.height + subtitleLabel.height; | ||
324 | 89 | data: [ | ||
325 | 90 | Label { | ||
326 | 91 | id: titleLabel; | ||
327 | 92 | objectName: "titleLabel"; | ||
328 | 93 | anchors { right: parent.right; | ||
329 | 94 | rightMargin: units.gu(1); | ||
330 | 95 | left: parent.left; | ||
331 | 96 | top: parent.top; } | ||
332 | 97 | elide: Text.ElideRight; | ||
333 | 98 | fontSize: "small"; | ||
334 | 99 | wrapMode: Text.Wrap; | ||
335 | 100 | maximumLineCount: 2; | ||
336 | 101 | font.pixelSize: Math.round(FontUtils.sizeToPixels(fontSize) * fontScale); | ||
337 | 102 | 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"); | ||
338 | 103 | visible: showHeader ; | ||
339 | 104 | width: undefined; | ||
340 | 105 | text: root.title; | ||
341 | 106 | font.weight: cardData && cardData["subtitle"] ? Font.DemiBold : Font.Normal; | ||
342 | 107 | horizontalAlignment: root.titleAlignment; | ||
343 | 108 | } | ||
344 | 109 | ,Label { | ||
345 | 110 | id: subtitleLabel; | ||
346 | 111 | objectName: "subtitleLabel"; | ||
347 | 112 | anchors { right: parent.right; | ||
348 | 113 | left: parent.left; | ||
349 | 114 | rightMargin: units.gu(1); | ||
350 | 115 | top: titleLabel.bottom; | ||
351 | 116 | } | ||
352 | 117 | anchors.topMargin: units.dp(2); | ||
353 | 118 | elide: Text.ElideRight; | ||
354 | 119 | maximumLineCount: 1; | ||
355 | 120 | fontSize: "x-small"; | ||
356 | 121 | font.pixelSize: Math.round(FontUtils.sizeToPixels(fontSize) * fontScale); | ||
357 | 122 | 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"); | ||
358 | 123 | visible: titleLabel.visible && titleLabel.text; | ||
359 | 124 | text: cardData && cardData["subtitle"] || ""; | ||
360 | 125 | font.weight: Font.Light; | ||
361 | 126 | } | ||
362 | 127 | |||
363 | 128 | ] | ||
364 | 129 | } | ||
365 | 130 | |||
366 | 131 | ] | ||
367 | 132 | } | ||
368 | 133 | UbuntuShape { | ||
369 | 134 | id: touchdown; | ||
370 | 135 | objectName: "touchdown"; | ||
371 | 136 | anchors { fill: backgroundLoader } | ||
372 | 137 | visible: root.artShapeStyle != "shadow" && root.artShapeStyle != "icon" && root.pressed; | ||
373 | 138 | radius: "medium"; | ||
374 | 139 | borderSource: "radius_pressed.sci" | ||
375 | 140 | } | ||
376 | 141 | implicitHeight: row.y + row.height + units.gu(1); | ||
377 | 142 | } | ||
378 | 0 | 143 | ||
379 | === modified file 'tests/plugins/Dash/cardcreator/10.tst' | |||
380 | --- tests/plugins/Dash/cardcreator/10.tst 2016-01-21 22:33:46 +0000 | |||
381 | +++ tests/plugins/Dash/cardcreator/10.tst 2016-02-11 14:27:32 +0000 | |||
382 | @@ -1,2 +1,3 @@ | |||
384 | 1 | template: {"card-background":{"elements":["#E9E9E9"],"type":"color"},"card-layout":"vertical","card-size":"medium","category-layout":"grid","collapsed-rows":2, "card-background": { "type": "color", "elements": [ "\" : \"\";} Item { } function moo() { return true ? \"" ] } } | 1 | template: {"card-background":{"elements":["#E9E9E9"],"type":"color"},"card-layout":"vertical","card-size":"medium","category-layout":"grid","collapsed-rows":2, "card-background": { "type": "color", "elements": [ "\\", ": 3; } Item { } function moo () { \"" ] } } |
385 | 2 | components: {"art":{"aspect-ratio":1},"background":{"field":"background"},"mascot":{"field":"icon"},"subtitle":{"field":"author"},"title":{"field":"title"},"attributes":{}} | 2 | components: {"art":{"aspect-ratio":1},"background":{"field":"background"},"mascot":{"field":"icon"},"subtitle":{"field":"author"},"title":{"field":"title"},"attributes":{}} |
386 | 3 | result: 10.res | ||
387 | 3 | \ No newline at end of file | 4 | \ No newline at end of file |
388 | 4 | 5 | ||
389 | === added file 'tests/plugins/Dash/cardcreator/11.res' | |||
390 | --- tests/plugins/Dash/cardcreator/11.res 1970-01-01 00:00:00 +0000 | |||
391 | +++ tests/plugins/Dash/cardcreator/11.res 2016-02-11 14:27:32 +0000 | |||
392 | @@ -0,0 +1,217 @@ | |||
393 | 1 | AbstractButton { | ||
394 | 2 | id: root; | ||
395 | 3 | property var components; | ||
396 | 4 | property var cardData; | ||
397 | 5 | property string artShapeStyle: "inset"; | ||
398 | 6 | property string backgroundShapeStyle: "inset"; | ||
399 | 7 | property real fontScale: 1.0; | ||
400 | 8 | property var scopeStyle: null; | ||
401 | 9 | property int titleAlignment: Text.AlignLeft; | ||
402 | 10 | property int fixedHeaderHeight: -1; | ||
403 | 11 | property size fixedArtShapeSize: Qt.size(-1, -1); | ||
404 | 12 | readonly property string title: cardData && cardData["title"] || ""; | ||
405 | 13 | property bool asynchronous: true; | ||
406 | 14 | property bool showHeader: true; | ||
407 | 15 | implicitWidth: childrenRect.width; | ||
408 | 16 | enabled: true; | ||
409 | 17 | |||
410 | 18 | Loader { | ||
411 | 19 | id: backgroundLoader; | ||
412 | 20 | objectName: "backgroundLoader"; | ||
413 | 21 | anchors.fill: parent; | ||
414 | 22 | asynchronous: root.asynchronous; | ||
415 | 23 | visible: status == Loader.Ready; | ||
416 | 24 | sourceComponent: UbuntuShape { | ||
417 | 25 | objectName: "background"; | ||
418 | 26 | radius: "medium"; | ||
419 | 27 | aspect: { | ||
420 | 28 | switch (root.backgroundShapeStyle) { | ||
421 | 29 | case "inset": return UbuntuShape.Inset; | ||
422 | 30 | case "shadow": return UbuntuShape.DropShadow; | ||
423 | 31 | default: | ||
424 | 32 | case "flat": return UbuntuShape.Flat; | ||
425 | 33 | } | ||
426 | 34 | } | ||
427 | 35 | backgroundColor: getColor(0) || "white"; | ||
428 | 36 | secondaryBackgroundColor: getColor(1) || backgroundColor; | ||
429 | 37 | backgroundMode: UbuntuShape.VerticalGradient; | ||
430 | 38 | anchors.fill: parent; | ||
431 | 39 | source: backgroundImage.source ? backgroundImage : null; | ||
432 | 40 | property real luminance: Style.luminance(backgroundColor); | ||
433 | 41 | property Image backgroundImage: Image { | ||
434 | 42 | objectName: "backgroundImage"; | ||
435 | 43 | source: { | ||
436 | 44 | if (cardData && typeof cardData["background"] === "string") return cardData["background"]; | ||
437 | 45 | else return ""; | ||
438 | 46 | } | ||
439 | 47 | } | ||
440 | 48 | function getColor(index) { | ||
441 | 49 | if (cardData && typeof cardData["background"] === "object" | ||
442 | 50 | && (cardData["background"]["type"] === "color" || cardData["background"]["type"] === "gradient")) { | ||
443 | 51 | return cardData["background"]["elements"][index]; | ||
444 | 52 | } else return index === 0 ? "#E9E9E9" : undefined; | ||
445 | 53 | } | ||
446 | 54 | } | ||
447 | 55 | } | ||
448 | 56 | readonly property size artShapeSize: artShapeLoader.item ? Qt.size(artShapeLoader.item.width, artShapeLoader.item.height) : Qt.size(-1, -1); | ||
449 | 57 | Item { | ||
450 | 58 | id: artShapeHolder; | ||
451 | 59 | height: root.fixedArtShapeSize.height > 0 ? root.fixedArtShapeSize.height : artShapeLoader.height; | ||
452 | 60 | width: root.fixedArtShapeSize.width > 0 ? root.fixedArtShapeSize.width : artShapeLoader.width; | ||
453 | 61 | anchors { horizontalCenter: parent.horizontalCenter; } | ||
454 | 62 | Loader { | ||
455 | 63 | id: artShapeLoader; | ||
456 | 64 | objectName: "artShapeLoader"; | ||
457 | 65 | active: cardData && cardData["art"] || false; | ||
458 | 66 | asynchronous: root.asynchronous; | ||
459 | 67 | visible: status == Loader.Ready; | ||
460 | 68 | sourceComponent: Item { | ||
461 | 69 | id: artShape; | ||
462 | 70 | objectName: "artShape"; | ||
463 | 71 | readonly property bool doShapeItem: components["art"]["conciergeMode"] !== true; | ||
464 | 72 | visible: image.status == Image.Ready; | ||
465 | 73 | readonly property alias image: artImage; | ||
466 | 74 | ShaderEffectSource { | ||
467 | 75 | id: artShapeSource; | ||
468 | 76 | sourceItem: artImage; | ||
469 | 77 | anchors.centerIn: parent; | ||
470 | 78 | width: 1; | ||
471 | 79 | height: 1; | ||
472 | 80 | hideSource: doShapeItem; | ||
473 | 81 | } | ||
474 | 82 | Loader { | ||
475 | 83 | anchors.fill: parent; | ||
476 | 84 | visible: artShape.doShapeItem; | ||
477 | 85 | sourceComponent: root.artShapeStyle === "icon" ? artShapeIconComponent : artShapeShapeComponent; | ||
478 | 86 | Component { | ||
479 | 87 | id: artShapeShapeComponent; | ||
480 | 88 | UbuntuShape { | ||
481 | 89 | source: artShapeSource; | ||
482 | 90 | sourceFillMode: UbuntuShape.PreserveAspectCrop; | ||
483 | 91 | radius: "medium"; | ||
484 | 92 | aspect: { | ||
485 | 93 | switch (root.artShapeStyle) { | ||
486 | 94 | case "inset": return UbuntuShape.Inset; | ||
487 | 95 | case "shadow": return UbuntuShape.DropShadow; | ||
488 | 96 | default: | ||
489 | 97 | case "flat": return UbuntuShape.Flat; | ||
490 | 98 | } | ||
491 | 99 | } | ||
492 | 100 | } | ||
493 | 101 | } | ||
494 | 102 | Component { | ||
495 | 103 | id: artShapeIconComponent; | ||
496 | 104 | ProportionalShape { source: artShapeSource; aspect: UbuntuShape.DropShadow; } | ||
497 | 105 | } | ||
498 | 106 | } | ||
499 | 107 | readonly property real fixedArtShapeSizeAspect: (root.fixedArtShapeSize.height > 0 && root.fixedArtShapeSize.width > 0) ? root.fixedArtShapeSize.width / root.fixedArtShapeSize.height : -1; | ||
500 | 108 | readonly property real aspect: fixedArtShapeSizeAspect > 0 ? fixedArtShapeSizeAspect : components !== undefined ? components["art"]["aspect-ratio"] : 1; | ||
501 | 109 | Component.onCompleted: { updateWidthHeightBindings(); } | ||
502 | 110 | Connections { target: root; onFixedArtShapeSizeChanged: updateWidthHeightBindings(); } | ||
503 | 111 | function updateWidthHeightBindings() { | ||
504 | 112 | if (root.fixedArtShapeSize.height > 0 && root.fixedArtShapeSize.width > 0) { | ||
505 | 113 | width = root.fixedArtShapeSize.width; | ||
506 | 114 | height = root.fixedArtShapeSize.height; | ||
507 | 115 | } else { | ||
508 | 116 | width = Qt.binding(function() { return image.status !== Image.Ready ? 0 : image.width }); | ||
509 | 117 | height = Qt.binding(function() { return image.status !== Image.Ready ? 0 : image.height }); | ||
510 | 118 | } | ||
511 | 119 | } | ||
512 | 120 | CroppedImageMinimumSourceSize { | ||
513 | 121 | id: artImage; | ||
514 | 122 | objectName: "artImage"; | ||
515 | 123 | source: cardData && cardData["art"] || ""; | ||
516 | 124 | asynchronous: root.asynchronous; | ||
517 | 125 | width: root.width; | ||
518 | 126 | height: width / artShape.aspect; | ||
519 | 127 | onStatusChanged: if (status === Image.Error) source = decodeURI("%5C"); | ||
520 | 128 | } | ||
521 | 129 | } | ||
522 | 130 | } | ||
523 | 131 | } | ||
524 | 132 | readonly property int headerHeight: row.height; | ||
525 | 133 | Row { | ||
526 | 134 | id: row; | ||
527 | 135 | objectName: "outerRow"; | ||
528 | 136 | property real margins: units.gu(1); | ||
529 | 137 | spacing: margins; | ||
530 | 138 | height: root.fixedHeaderHeight != -1 ? root.fixedHeaderHeight : implicitHeight; | ||
531 | 139 | anchors { top: artShapeHolder.bottom; | ||
532 | 140 | topMargin: units.gu(1); | ||
533 | 141 | left: parent.left; | ||
534 | 142 | } | ||
535 | 143 | anchors.right: parent.right; | ||
536 | 144 | anchors.margins: margins; | ||
537 | 145 | anchors.rightMargin: 0; | ||
538 | 146 | data: [ | ||
539 | 147 | CroppedImageMinimumSourceSize { | ||
540 | 148 | id: mascotImage; | ||
541 | 149 | objectName: "mascotImage"; | ||
542 | 150 | anchors { verticalCenter: parent.verticalCenter; } | ||
543 | 151 | source: cardData && cardData["mascot"] || ""; | ||
544 | 152 | width: units.gu(6); | ||
545 | 153 | height: units.gu(5.625); | ||
546 | 154 | horizontalAlignment: Image.AlignHCenter; | ||
547 | 155 | verticalAlignment: Image.AlignVCenter; | ||
548 | 156 | visible: showHeader; | ||
549 | 157 | onStatusChanged: if (status === Image.Error) source = decodeURI("%22"); | ||
550 | 158 | } | ||
551 | 159 | ,Item { | ||
552 | 160 | id: headerTitleContainer; | ||
553 | 161 | anchors { verticalCenter: parent.verticalCenter; } | ||
554 | 162 | width: parent.width - x; | ||
555 | 163 | implicitHeight: titleLabel.height + subtitleLabel.height; | ||
556 | 164 | data: [ | ||
557 | 165 | Label { | ||
558 | 166 | id: titleLabel; | ||
559 | 167 | objectName: "titleLabel"; | ||
560 | 168 | anchors { right: parent.right; | ||
561 | 169 | rightMargin: units.gu(1); | ||
562 | 170 | left: parent.left; | ||
563 | 171 | top: parent.top; } | ||
564 | 172 | elide: Text.ElideRight; | ||
565 | 173 | fontSize: "small"; | ||
566 | 174 | wrapMode: Text.Wrap; | ||
567 | 175 | maximumLineCount: 2; | ||
568 | 176 | font.pixelSize: Math.round(FontUtils.sizeToPixels(fontSize) * fontScale); | ||
569 | 177 | 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"); | ||
570 | 178 | visible: showHeader ; | ||
571 | 179 | width: undefined; | ||
572 | 180 | text: root.title; | ||
573 | 181 | font.weight: cardData && cardData["subtitle"] ? Font.DemiBold : Font.Normal; | ||
574 | 182 | horizontalAlignment: root.titleAlignment; | ||
575 | 183 | } | ||
576 | 184 | ,Label { | ||
577 | 185 | id: subtitleLabel; | ||
578 | 186 | objectName: "subtitleLabel"; | ||
579 | 187 | anchors { right: parent.right; | ||
580 | 188 | left: parent.left; | ||
581 | 189 | rightMargin: units.gu(1); | ||
582 | 190 | top: titleLabel.bottom; | ||
583 | 191 | } | ||
584 | 192 | anchors.topMargin: units.dp(2); | ||
585 | 193 | elide: Text.ElideRight; | ||
586 | 194 | maximumLineCount: 1; | ||
587 | 195 | fontSize: "x-small"; | ||
588 | 196 | font.pixelSize: Math.round(FontUtils.sizeToPixels(fontSize) * fontScale); | ||
589 | 197 | 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"); | ||
590 | 198 | visible: titleLabel.visible && titleLabel.text; | ||
591 | 199 | text: cardData && cardData["subtitle"] || ""; | ||
592 | 200 | font.weight: Font.Light; | ||
593 | 201 | } | ||
594 | 202 | |||
595 | 203 | ] | ||
596 | 204 | } | ||
597 | 205 | |||
598 | 206 | ] | ||
599 | 207 | } | ||
600 | 208 | UbuntuShape { | ||
601 | 209 | id: touchdown; | ||
602 | 210 | objectName: "touchdown"; | ||
603 | 211 | anchors { fill: backgroundLoader } | ||
604 | 212 | visible: root.artShapeStyle != "shadow" && root.artShapeStyle != "icon" && root.pressed; | ||
605 | 213 | radius: "medium"; | ||
606 | 214 | borderSource: "radius_pressed.sci" | ||
607 | 215 | } | ||
608 | 216 | implicitHeight: row.y + row.height + units.gu(1); | ||
609 | 217 | } | ||
610 | 0 | 218 | ||
611 | === added file 'tests/plugins/Dash/cardcreator/11.tst' | |||
612 | --- tests/plugins/Dash/cardcreator/11.tst 1970-01-01 00:00:00 +0000 | |||
613 | +++ tests/plugins/Dash/cardcreator/11.tst 2016-02-11 14:27:32 +0000 | |||
614 | @@ -0,0 +1,3 @@ | |||
615 | 1 | template: {"card-background":{"elements":["#E9E9E9"],"type":"color"},"card-layout":"vertical","card-size":"medium","category-layout":"grid","collapsed-rows":2 } | ||
616 | 2 | components: {"art":{"aspect-ratio":1,"field":"art","fallback":"\\"},"background":{"field":"background"},"mascot":{"field":"icon","fallback":"\""},"subtitle":{"field":"author"},"title":{"field":"title"},"attributes":{}} | ||
617 | 3 | result: 11.res | ||
618 | 0 | \ No newline at end of file | 4 | \ No newline at end of file |
619 | 1 | 5 | ||
620 | === modified file 'tests/plugins/Dash/cardcreator/3.res' | |||
621 | --- tests/plugins/Dash/cardcreator/3.res 2016-01-21 22:44:41 +0000 | |||
622 | +++ tests/plugins/Dash/cardcreator/3.res 2016-02-11 14:27:32 +0000 | |||
623 | @@ -86,7 +86,7 @@ | |||
624 | 86 | asynchronous: root.asynchronous; | 86 | asynchronous: root.asynchronous; |
625 | 87 | width: root.width; | 87 | width: root.width; |
626 | 88 | height: width / artShape.aspect; | 88 | height: width / artShape.aspect; |
628 | 89 | onStatusChanged: if (status === Image.Error) source = "IHAVE\"ESCAPED\"QUOTES\""; | 89 | onStatusChanged: if (status === Image.Error) source = decodeURI("IHAVE%5C%22ESCAPED%5C%22QUOTES%5C%22"); |
629 | 90 | } | 90 | } |
630 | 91 | } | 91 | } |
631 | 92 | } | 92 | } |
632 | 93 | 93 | ||
633 | === modified file 'tests/plugins/Dash/cardcreator/6.res' | |||
634 | --- tests/plugins/Dash/cardcreator/6.res 2015-11-20 16:33:38 +0000 | |||
635 | +++ tests/plugins/Dash/cardcreator/6.res 2016-02-11 14:27:32 +0000 | |||
636 | @@ -42,7 +42,7 @@ | |||
637 | 42 | objectName: "backgroundImage"; | 42 | objectName: "backgroundImage"; |
638 | 43 | source: { | 43 | source: { |
639 | 44 | if (cardData && typeof cardData["background"] === "string") return cardData["background"]; | 44 | if (cardData && typeof cardData["background"] === "string") return cardData["background"]; |
641 | 45 | else return "http://assets.ubuntu.com/sites/ubuntu/latest/u/img/logos/logo-ubuntu-grey.png"; | 45 | else return decodeURI("http://assets.ubuntu.com/sites/ubuntu/latest/u/img/logos/logo-ubuntu-grey.png"); |
642 | 46 | } | 46 | } |
643 | 47 | } | 47 | } |
644 | 48 | function getColor(index) { | 48 | function getColor(index) { |
645 | 49 | 49 | ||
646 | === modified file 'tests/plugins/Dash/cardcreatortest.cpp' | |||
647 | --- tests/plugins/Dash/cardcreatortest.cpp 2016-01-21 22:33:46 +0000 | |||
648 | +++ tests/plugins/Dash/cardcreatortest.cpp 2016-02-11 14:27:32 +0000 | |||
649 | @@ -63,6 +63,7 @@ | |||
650 | 63 | 63 | ||
651 | 64 | QVERIFY(lines[0].startsWith(templateString)); | 64 | QVERIFY(lines[0].startsWith(templateString)); |
652 | 65 | QVERIFY(lines[1].startsWith(componentsString)); | 65 | QVERIFY(lines[1].startsWith(componentsString)); |
653 | 66 | QVERIFY(lines[2].startsWith(resultString)); | ||
654 | 66 | 67 | ||
655 | 67 | const QString templateJSON = lines[0].mid(templateString.length()); | 68 | const QString templateJSON = lines[0].mid(templateString.length()); |
656 | 68 | const QString componentsJSON = lines[1].mid(componentsString.length()); | 69 | const QString componentsJSON = lines[1].mid(componentsString.length()); |
657 | @@ -71,32 +72,30 @@ | |||
658 | 71 | QVariant cardStringResult; | 72 | QVariant cardStringResult; |
659 | 72 | QMetaObject::invokeMethod(view->rootObject(), "cardString", Q_RETURN_ARG(QVariant, cardStringResult), Q_ARG(QVariant, templateJSON), Q_ARG(QVariant, componentsJSON)); | 73 | QMetaObject::invokeMethod(view->rootObject(), "cardString", Q_RETURN_ARG(QVariant, cardStringResult), Q_ARG(QVariant, templateJSON), Q_ARG(QVariant, componentsJSON)); |
660 | 73 | 74 | ||
682 | 74 | if (!resultFileName.isEmpty()) { | 75 | QFile testResultFile(testDirPath + resultFileName); |
683 | 75 | QFile testResultFile(testDirPath + resultFileName); | 76 | QVERIFY(testResultFile.open(QIODevice::ReadOnly)); |
684 | 76 | QVERIFY(testResultFile.open(QIODevice::ReadOnly)); | 77 | QTextStream ts2(&testResultFile); |
685 | 77 | QTextStream ts2(&testResultFile); | 78 | |
686 | 78 | 79 | // Record failed results to /tmp | |
687 | 79 | // Record failed results to /tmp | 80 | const QString executedResult = cardStringResult.toString(); |
688 | 80 | const QString executedResult = cardStringResult.toString(); | 81 | QTemporaryFile tmpFile(QDir::tempPath() + QDir::separator() + "testCardCreatorFailedResultXXXXXX"); |
689 | 81 | QTemporaryFile tmpFile(QDir::tempPath() + QDir::separator() + "testCardCreatorFailedResultXXXXXX"); | 82 | tmpFile.open(); |
690 | 82 | tmpFile.open(); | 83 | tmpFile.setAutoRemove(false); |
691 | 83 | tmpFile.setAutoRemove(false); | 84 | tmpFile.write(executedResult.toUtf8().constData()); |
692 | 84 | tmpFile.write(executedResult.toUtf8().constData()); | 85 | |
693 | 85 | 86 | // Line by line comparison | |
694 | 86 | // Line by line comparison | 87 | const QStringList expectedLines = ts2.readAll().trimmed().replace(QRegExp("\n\\s*\n"),"\n").split("\n"); |
695 | 87 | const QStringList expectedLines = ts2.readAll().trimmed().replace(QRegExp("\n\\s*\n"),"\n").split("\n"); | 88 | const QStringList cardStringResultLines = cardStringResult.toString().trimmed().replace(QRegExp("\n\\s*\n"),"\n").split("\n"); |
696 | 88 | const QStringList cardStringResultLines = cardStringResult.toString().trimmed().replace(QRegExp("\n\\s*\n"),"\n").split("\n"); | 89 | for (int i = 0; i < expectedLines.size(); ++i) { |
697 | 89 | for (int i = 0; i < expectedLines.size(); ++i) { | 90 | QCOMPARE(cardStringResultLines[i].simplified(), expectedLines[i].simplified()); |
677 | 90 | QCOMPARE(cardStringResultLines[i].simplified(), expectedLines[i].simplified()); | ||
678 | 91 | } | ||
679 | 92 | |||
680 | 93 | // Remove the result if it passed | ||
681 | 94 | tmpFile.setAutoRemove(true); | ||
698 | 95 | } | 91 | } |
699 | 96 | 92 | ||
700 | 93 | // Remove the result if it passed | ||
701 | 94 | tmpFile.setAutoRemove(true); | ||
702 | 95 | |||
703 | 97 | QVariant createCardComponentResult; | 96 | QVariant createCardComponentResult; |
704 | 98 | QMetaObject::invokeMethod(view->rootObject(), "createCardComponent", Q_RETURN_ARG(QVariant, createCardComponentResult), Q_ARG(QVariant, templateJSON), Q_ARG(QVariant, componentsJSON)); | 97 | QMetaObject::invokeMethod(view->rootObject(), "createCardComponent", Q_RETURN_ARG(QVariant, createCardComponentResult), Q_ARG(QVariant, templateJSON), Q_ARG(QVariant, componentsJSON)); |
706 | 99 | QCOMPARE(createCardComponentResult.toBool(), !resultFileName.isEmpty()); | 98 | QVERIFY(createCardComponentResult.toBool()); |
707 | 100 | } | 99 | } |
708 | 101 | } | 100 | } |
709 | 102 | 101 | ||
710 | 103 | 102 | ||
711 | === modified file 'tests/plugins/Dash/listviewwithpageheadertest.cpp' | |||
712 | --- tests/plugins/Dash/listviewwithpageheadertest.cpp 2015-09-02 08:04:41 +0000 | |||
713 | +++ tests/plugins/Dash/listviewwithpageheadertest.cpp 2016-02-11 14:27:32 +0000 | |||
714 | @@ -1954,6 +1954,29 @@ | |||
715 | 1954 | QCOMPARE(lvwph->m_firstVisibleIndex, 0); | 1954 | QCOMPARE(lvwph->m_firstVisibleIndex, 0); |
716 | 1955 | } | 1955 | } |
717 | 1956 | 1956 | ||
718 | 1957 | void testBug1540490() | ||
719 | 1958 | { | ||
720 | 1959 | lvwph->header()->setImplicitHeight(150); | ||
721 | 1960 | verifyItem(0, 150., 150., false); | ||
722 | 1961 | |||
723 | 1962 | QMetaObject::invokeMethod(model, "removeItems", Q_ARG(QVariant, 3), Q_ARG(QVariant, 3)); | ||
724 | 1963 | model->setProperty(0, "size", 400); | ||
725 | 1964 | model->setProperty(1, "size", 600); | ||
726 | 1965 | model->setProperty(2, "size", 300); | ||
727 | 1966 | |||
728 | 1967 | scrollToBottom(); | ||
729 | 1968 | changeContentY(-200); | ||
730 | 1969 | |||
731 | 1970 | QMetaObject::invokeMethod(model, "removeItems", Q_ARG(QVariant, 1), Q_ARG(QVariant, 2)); | ||
732 | 1971 | model->setProperty(0, "size", 100); | ||
733 | 1972 | QMetaObject::invokeMethod(model, "removeItems", Q_ARG(QVariant, 0), Q_ARG(QVariant, 1)); | ||
734 | 1973 | lvwph->header()->setImplicitHeight(50); | ||
735 | 1974 | QMetaObject::invokeMethod(model, "insertItem", Q_ARG(QVariant, 0), Q_ARG(QVariant, 200)); | ||
736 | 1975 | |||
737 | 1976 | QTRY_COMPARE(lvwph->m_visibleItems.count(), 1); | ||
738 | 1977 | verifyItem(0, 50., 200., false); | ||
739 | 1978 | } | ||
740 | 1979 | |||
741 | 1957 | private: | 1980 | private: |
742 | 1958 | QQuickView *view; | 1981 | QQuickView *view; |
743 | 1959 | ListViewWithPageHeader *lvwph; | 1982 | ListViewWithPageHeader *lvwph; |
744 | 1960 | 1983 | ||
745 | === modified file 'tests/plugins/Dash/listviewwithpageheadertest.qml' | |||
746 | --- tests/plugins/Dash/listviewwithpageheadertest.qml 2015-07-15 15:07:19 +0000 | |||
747 | +++ tests/plugins/Dash/listviewwithpageheadertest.qml 2016-02-11 14:27:32 +0000 | |||
748 | @@ -85,7 +85,6 @@ | |||
749 | 85 | pageHeader: Rectangle { | 85 | pageHeader: Rectangle { |
750 | 86 | color: "transparent" | 86 | color: "transparent" |
751 | 87 | width: parent.width | 87 | width: parent.width |
752 | 88 | height: 50 | ||
753 | 89 | implicitHeight: 50 | 88 | implicitHeight: 50 |
754 | 90 | Text { | 89 | Text { |
755 | 91 | anchors.fill: parent | 90 | anchors.fill: parent |
Verified the diff is sane for the cherry-picks.