on xenial help sign in
Merged better test branch
commitfdf1d130a6b928ad9ac75af70485ac51a060936e authorAndrea Cimitan <andrea.cimitan@gmail.com> dateTue 29 Jul 2014, 11:57 (12 years ago) parent3f3ad6ff8802b8
9 files changed+87−3
plugins/Dash/CardCreator.js+21−1 tests/plugins/Dash/cardcreator/1.res+8 tests/plugins/Dash/cardcreator/2.res+8 tests/plugins/Dash/cardcreator/3.res+8 tests/plugins/Dash/cardcreator/4.res+8 tests/plugins/Dash/cardcreator/5.res+8 tests/plugins/Dash/cardcreator/6.res+8 tests/plugins/Dash/cardcreatortest.cpp+6−2 tests/qmltests/Dash/tst_Card.qml+12
plugins/Dash/CardCreator.js+21−1
@@ -244,7 +244,7 @@ var kMascotImageCode = 'Image { \n\
244244 }\n';
245245
246246// %1 is used as anchors of titleLabel
247−// %1 is used as color of titleLabel
247+// %2 is used as color of titleLabel
248248// %3 is used as extra condition for visible of titleLabel
249249var kTitleLabelCode = 'Label { \n\
250250 id: titleLabel; \n\
@@ -274,6 +274,16 @@ var kEmblemImageCode = 'Image { \n\
274274 fillMode: Image.PreserveAspectFit; \n\
275275 }\n';
276276
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+
277287// %1 is used as anchors of subtitleLabel
278288// %2 is used as color of subtitleLabel
279289var kSubtitleLabelCode = 'Label { \n\
@@ -571,6 +581,16 @@ function cardString(template, components) {
571581 code += kSummaryLabelCode.arg(summaryTopAnchor).arg(summaryTopMargin).arg(color);
572582 }
573583
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+
574594 if (hasSummary) {
575595 code += 'implicitHeight: summary.y + summary.height + (summary.text ? units.gu(1) : 0);\n';
576596 } else if (hasHeaderRow) {
tests/plugins/Dash/cardcreator/1.res+8
@@ -82,5 +82,13 @@ leftMargin: units.gu(1);
8282 font.weight: components && components["subtitle"] ? Font.DemiBold : Font.Normal;
8383 horizontalAlignment: root.headerAlignment;
8484 }
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+}
8593implicitHeight: titleLabel.y + titleLabel.height + units.gu(1);
8694}
tests/plugins/Dash/cardcreator/2.res+8
@@ -113,5 +113,13 @@ Label {
113113}
114114]
115115}
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+}
116124implicitHeight: row.y + row.height + units.gu(1);
117125}
tests/plugins/Dash/cardcreator/3.res+8
@@ -100,5 +100,13 @@ Label {
100100 font.weight: Font.Light;
101101 horizontalAlignment: root.headerAlignment;
102102 }
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+}
103111implicitHeight: subtitleLabel.y + subtitleLabel.height + units.gu(1);
104112}
tests/plugins/Dash/cardcreator/4.res+8
@@ -94,5 +94,13 @@ Label {
9494}
9595]
9696}
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+}
97105implicitHeight: row.y + row.height + units.gu(1);
98106}
tests/plugins/Dash/cardcreator/5.res+8
@@ -141,5 +141,13 @@ Label {
141141 font.weight: Font.Light;
142142 horizontalAlignment: root.headerAlignment;
143143 }
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+}
144152implicitHeight: subtitleLabel.y + subtitleLabel.height + units.gu(1);
145153}
tests/plugins/Dash/cardcreator/6.res+8
@@ -63,5 +63,13 @@ Item {
6363 }
6464 }
6565readonly 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+}
6674implicitHeight: artShapeHolder.height;
6775}
tests/plugins/Dash/cardcreatortest.cpp+6−2
@@ -19,6 +19,7 @@
1919#include <QQuickItem>
2020#include <QQuickView>
2121#include <QtTestGui>
22+#include <QDebug>
2223
2324class CardCreatorTest : public QObject
2425{
@@ -73,8 +74,11 @@ private Q_SLOTS:
7374 QFile testResultFile(testDirPath + resultFileName);
7475 QVERIFY(testResultFile.open(QIODevice::ReadOnly));
7576 QTextStream ts2(&testResultFile);
76− const QString expectedResult = ts2.readAll();
77− QCOMPARE(cardStringResult.toString().simplified(), expectedResult.simplified());
77+ const QStringList expectedLines = ts2.readAll().trimmed().replace(QRegExp("\n\\s*\n"),"\n").split("\n");
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+ }
7882
7983 QVariant createCardComponentResult;
8084 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 {
491491 compare(shape !== null, data.shape);
492492 tryCompare(mascotImage, "visible", !data.shape);
493493 }
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+ }
494506 }
495507}