on xenial help sign in
Merged better test branch
fdf1d13Andrea Cimitan
plugins/Dash/CardCreator.js+21−1
@@ -244,7 +244,7 @@ var kMascotImageCode = 'Image { \n\
244 }\n';
244 }\n';
245
245
246// %1 is used as anchors of titleLabel
246// %1 is used as anchors of titleLabel
247−// %1 is used as color of titleLabel
247+// %2 is used as color of titleLabel
248// %3 is used as extra condition for visible of titleLabel
248// %3 is used as extra condition for visible of titleLabel
249var kTitleLabelCode = 'Label { \n\
249var kTitleLabelCode = 'Label { \n\
250 id: titleLabel; \n\
250 id: titleLabel; \n\
@@ -274,6 +274,16 @@ var kEmblemImageCode = 'Image { \n\
274 fillMode: Image.PreserveAspectFit; \n\
274 fillMode: Image.PreserveAspectFit; \n\
275 }\n';
275 }\n';
276
276
277+// %1 is used as anchors of touchdown effect
278+var kTouchdownCode = 'UbuntuShape { \n\
279+ id: touchdown; \n\
280+ objectName: "touchdown"; \n\
281+ anchors { %1 } \n\
282+ visible: root.pressed; \n\
283+ radius: "medium"; \n\
284+ borderSource: "radius_pressed.sci" \n\
285+ }\n';
286+
277// %1 is used as anchors of subtitleLabel
287// %1 is used as anchors of subtitleLabel
278// %2 is used as color of subtitleLabel
288// %2 is used as color of subtitleLabel
279var kSubtitleLabelCode = 'Label { \n\
289var kSubtitleLabelCode = 'Label { \n\
@@ -571,6 +581,16 @@ function cardString(template, components) {
571 code += kSummaryLabelCode.arg(summaryTopAnchor).arg(summaryTopMargin).arg(color);
581 code += kSummaryLabelCode.arg(summaryTopAnchor).arg(summaryTopMargin).arg(color);
572 }
582 }
573
583
584+ var touchdownAnchors;
585+ if (hasBackground) {
586+ touchdownAnchors = 'fill: backgroundLoader';
587+ } else if (hasArt && !hasMascot && !hasSummary) {
588+ touchdownAnchors = 'fill: artShapeHolder';
589+ } else {
590+ touchdownAnchors = 'fill: root'
591+ }
592+ code += kTouchdownCode.arg(touchdownAnchors);
593+
574 if (hasSummary) {
594 if (hasSummary) {
575 code += 'implicitHeight: summary.y + summary.height + (summary.text ? units.gu(1) : 0);\n';
595 code += 'implicitHeight: summary.y + summary.height + (summary.text ? units.gu(1) : 0);\n';
576 } else if (hasHeaderRow) {
596 } else if (hasHeaderRow) {
tests/plugins/Dash/cardcreator/1.res+8
@@ -82,5 +82,13 @@ leftMargin: units.gu(1);
82 font.weight: components && components["subtitle"] ? Font.DemiBold : Font.Normal;
82 font.weight: components && components["subtitle"] ? Font.DemiBold : Font.Normal;
83 horizontalAlignment: root.headerAlignment;
83 horizontalAlignment: root.headerAlignment;
84 }
84 }
85+UbuntuShape {
86+ id: touchdown;
87+ objectName: "touchdown";
88+ anchors { fill: artShapeHolder }
89+ visible: root.pressed;
90+ radius: "medium";
91+ borderSource: "radius_pressed.sci"
92+}
85implicitHeight: titleLabel.y + titleLabel.height + units.gu(1);
93implicitHeight: titleLabel.y + titleLabel.height + units.gu(1);
86}
94}
tests/plugins/Dash/cardcreator/2.res+8
@@ -113,5 +113,13 @@ Label {
113}
113}
114]
114]
115}
115}
116+UbuntuShape {
117+ id: touchdown;
118+ objectName: "touchdown";
119+ anchors { fill: backgroundLoader }
120+ visible: root.pressed;
121+ radius: "medium";
122+ borderSource: "radius_pressed.sci"
123+}
116implicitHeight: row.y + row.height + units.gu(1);
124implicitHeight: row.y + row.height + units.gu(1);
117}
125}
tests/plugins/Dash/cardcreator/3.res+8
@@ -100,5 +100,13 @@ Label {
100 font.weight: Font.Light;
100 font.weight: Font.Light;
101 horizontalAlignment: root.headerAlignment;
101 horizontalAlignment: root.headerAlignment;
102 }
102 }
103+UbuntuShape {
104+ id: touchdown;
105+ objectName: "touchdown";
106+ anchors { fill: artShapeHolder }
107+ visible: root.pressed;
108+ radius: "medium";
109+ borderSource: "radius_pressed.sci"
110+}
103implicitHeight: subtitleLabel.y + subtitleLabel.height + units.gu(1);
111implicitHeight: subtitleLabel.y + subtitleLabel.height + units.gu(1);
104}
112}
tests/plugins/Dash/cardcreator/4.res+8
@@ -94,5 +94,13 @@ Label {
94}
94}
95]
95]
96}
96}
97+UbuntuShape {
98+ id: touchdown;
99+ objectName: "touchdown";
100+ anchors { fill: root }
101+ visible: root.pressed;
102+ radius: "medium";
103+ borderSource: "radius_pressed.sci"
104+}
97implicitHeight: row.y + row.height + units.gu(1);
105implicitHeight: row.y + row.height + units.gu(1);
98}
106}
tests/plugins/Dash/cardcreator/5.res+8
@@ -141,5 +141,13 @@ Label {
141 font.weight: Font.Light;
141 font.weight: Font.Light;
142 horizontalAlignment: root.headerAlignment;
142 horizontalAlignment: root.headerAlignment;
143 }
143 }
144+UbuntuShape {
145+ id: touchdown;
146+ objectName: "touchdown";
147+ anchors { fill: artShapeHolder }
148+ visible: root.pressed;
149+ radius: "medium";
150+ borderSource: "radius_pressed.sci"
151+}
144implicitHeight: subtitleLabel.y + subtitleLabel.height + units.gu(1);
152implicitHeight: subtitleLabel.y + subtitleLabel.height + units.gu(1);
145}
153}
tests/plugins/Dash/cardcreator/6.res+8
@@ -63,5 +63,13 @@ Item {
63 }
63 }
64 }
64 }
65readonly property int headerHeight: 0;
65readonly property int headerHeight: 0;
66+UbuntuShape {
67+ id: touchdown;
68+ objectName: "touchdown";
69+ anchors { fill: artShapeHolder }
70+ visible: root.pressed;
71+ radius: "medium";
72+ borderSource: "radius_pressed.sci"
73+}
66implicitHeight: artShapeHolder.height;
74implicitHeight: artShapeHolder.height;
67}
75}
tests/plugins/Dash/cardcreatortest.cpp+6−2
@@ -19,6 +19,7 @@
19#include <QQuickItem>
19#include <QQuickItem>
20#include <QQuickView>
20#include <QQuickView>
21#include <QtTestGui>
21#include <QtTestGui>
22+#include <QDebug>
22
23
23class CardCreatorTest : public QObject
24class CardCreatorTest : public QObject
24{
25{
@@ -73,8 +74,11 @@ private Q_SLOTS:
73 QFile testResultFile(testDirPath + resultFileName);
74 QFile testResultFile(testDirPath + resultFileName);
74 QVERIFY(testResultFile.open(QIODevice::ReadOnly));
75 QVERIFY(testResultFile.open(QIODevice::ReadOnly));
75 QTextStream ts2(&testResultFile);
76 QTextStream ts2(&testResultFile);
76− const QString expectedResult = ts2.readAll();
77+ const QStringList expectedLines = ts2.readAll().trimmed().replace(QRegExp("\n\\s*\n"),"\n").split("\n");
77− QCOMPARE(cardStringResult.toString().simplified(), expectedResult.simplified());
78+ const QStringList cardStringResultLines = cardStringResult.toString().trimmed().replace(QRegExp("\n\\s*\n"),"\n").split("\n");
79+ for (int i = 0; i < expectedLines.size(); ++i) {
80+ QCOMPARE(cardStringResultLines[i].simplified(), expectedLines[i].simplified());
81+ }
78
82
79 QVariant createCardComponentResult;
83 QVariant createCardComponentResult;
80 QMetaObject::invokeMethod(view->rootObject(), "createCardComponent", Q_RETURN_ARG(QVariant, createCardComponentResult), Q_ARG(QVariant, templateJSON), Q_ARG(QVariant, componentsJSON));
84 QMetaObject::invokeMethod(view->rootObject(), "createCardComponent", Q_RETURN_ARG(QVariant, createCardComponentResult), Q_ARG(QVariant, templateJSON), Q_ARG(QVariant, componentsJSON));
tests/qmltests/Dash/tst_Card.qml+12
@@ -491,5 +491,17 @@ Rectangle {
491 compare(shape !== null, data.shape);
491 compare(shape !== null, data.shape);
492 tryCompare(mascotImage, "visible", !data.shape);
492 tryCompare(mascotImage, "visible", !data.shape);
493 }
493 }
494+
495+ function test_touchdown_visibility() {
496+ selector.selectedIndex = 0;
497+
498+ var touchdown = findChild(card, "touchdown");
499+
500+ compare(touchdown.visible, false);
501+ mousePress(card, card.width/2, card.height/2);
502+ compare(touchdown.visible, true);
503+ mouseRelease(card, card.width/2, card.height/2);
504+ compare(touchdown.visible, false);
505+ }
494 }
506 }
495}
507}