on xenial help sign in
Fix title alignment test and binding, clean up old components from CardHelpers.js
commit05bbb14985a5653f460154b5658ef2347d5fcc2c authorMichał Sawicz <michal.sawicz@canonical.com> dateFri 5 Sep 2014, 09:27 (12 years ago) parent5f19d21
3 files changed+13−18
qml/Dash/CardTool.qml+8−3 tests/qmltests/Dash/CardHelpers.js+1−12 tests/qmltests/Dash/tst_CardTool.qml+4−3
qml/Dash/CardTool.qml+8−3
@@ -136,13 +136,18 @@ Item {
136136 readonly property int titleAlignment: {
137137 if (template["card-layout"] === "horizontal"
138138 || typeof components["title"] !== "object"
139− || components["title"]["align"] !== "center") return Text.AlignHCenter;
139+ || components["title"]["align"] !== "center") return Text.AlignLeft;
140140
141141 var keys = ["mascot", "emblem", "subtitle", "attributes", "summary"];
142142
143143 for (var key in keys) {
144− if (typeof components[key] === "string"
145− || typeof components[key]["field"] === "string") return Text.AlignLeft;
144+ key = keys[key];
145+ try {
146+ if (typeof components[key] === "string"
147+ || typeof components[key]["field"] === "string") return Text.AlignLeft;
148+ } catch (e) {
149+ continue;
150+ }
146151 }
147152
148153 return Text.AlignHCenter;
tests/qmltests/Dash/CardHelpers.js+1−12
@@ -16,7 +16,7 @@
1616
1717.pragma library
1818
19−var components = ["title", "art", "subtitle", "mascot", "emblem", "old-price", "price", "alt-price", "rating", "alt-rating", "summary", "attributes", "overlayColor"]
19+var components = ["title", "art", "subtitle", "mascot", "emblem", "summary", "attributes", "overlayColor"]
2020
2121var defaultLayout = ' \
2222{ \
@@ -37,17 +37,6 @@ var defaultLayout = ' \
3737 "overlayColor": null, \
3838 "mascot": null, \
3939 "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, \
5140 "summary": null, \
5241 "attributes": { "max-count": 2 } \
5342 }, \
tests/qmltests/Dash/tst_CardTool.qml+4−3
@@ -339,11 +339,12 @@ Rectangle {
339339 function test_card_title_alignment(data) {
340340 selector.selectedIndex = data.index;
341341
342+ tryCompare(cardTool, "titleAlignment", Text.AlignLeft);
343+
342344 cardTool.components['title'] = { "field": "title", "align": "center" };
345+ cardTool.componentsChanged();
343346
344− if (data.hasOwnProperty("property")) {
345− tryCompare(cardTool, "titleAlignment", data.value);
346− }
347+ tryCompare(cardTool, "titleAlignment", data.value);
347348 }
348349
349350 function test_categoryLayout_data() {