on xenial help sign in
Merged and fixes
3f50430Andrea Cimitan
qml/Dash/Previews/PreviewHeader.qmlnew file+38
@@ -0,0 +1,38 @@
1+/*
2+ * Copyright (C) 2014 Canonical, Ltd.
3+ *
4+ * 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 by
6+ * the Free Software Foundation; version 3.
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 General Public License for more details.
12+ *
13+ * You should have received a copy of the GNU General Public License
14+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
15+ */
16+
17+import QtQuick 2.0
18+import "../"
19+
20+/*! This preview widget shows a header that is the same as the card header
21+ * The title comes in widgetData["title"]
22+ * The mascot comes in widgetData["mascot"]
23+ * The subtitle comes in widgetData["subtitle"]
24+ */
25+
26+PreviewWidget {
27+ id: root
28+
29+ height: childrenRect.height
30+
31+ CardHeader {
32+ objectName: "cardHeader"
33+ mascot: root.widgetData["mascot"] || ""
34+ title: root.widgetData["title"] || ""
35+ subtitle: root.widgetData["subtitle"] || ""
36+ width: parent.width
37+ }
38+}
qml/Dash/Previews/PreviewWidgetFactory.qml+2−1
@@ -45,7 +45,8 @@ Loader {
45 case "actions": return "PreviewActions.qml";
45 case "actions": return "PreviewActions.qml";
46 case "audio": return "PreviewAudioPlayback.qml";
46 case "audio": return "PreviewAudioPlayback.qml";
47 case "gallery": return "PreviewImageGallery.qml";
47 case "gallery": return "PreviewImageGallery.qml";
48+ case "header": return "PreviewHeader.qml";
48− case "image": return "PreviewZoomableImage.qml";
49+ case "image": return "PreviewZoomableImage.qml"
49 case "text": return "PreviewTextSummary.qml";
50 case "text": return "PreviewTextSummary.qml";
50 case "video": return "PreviewVideoPlayback.qml";
51 case "video": return "PreviewVideoPlayback.qml";
51 default: return "";
52 default: return "";
tests/qmltests/CMakeLists.txt+1
@@ -60,6 +60,7 @@ add_qml_test(Dash/Previews PreviewWidgetFactory IMPORT_PATHS ${qmltest_DEFAULT_I
60add_qml_test(Dash/Previews PreviewActions IMPORT_PATHS ${qmltest_DEFAULT_IMPORT_PATHS} ${CMAKE_BINARY_DIR}/tests/mocks)
60add_qml_test(Dash/Previews PreviewActions IMPORT_PATHS ${qmltest_DEFAULT_IMPORT_PATHS} ${CMAKE_BINARY_DIR}/tests/mocks)
61add_qml_test(Dash/Previews PreviewAudioPlayback IMPORT_PATHS ${qmltest_DEFAULT_IMPORT_PATHS} ${CMAKE_BINARY_DIR}/tests/mocks)
61add_qml_test(Dash/Previews PreviewAudioPlayback IMPORT_PATHS ${qmltest_DEFAULT_IMPORT_PATHS} ${CMAKE_BINARY_DIR}/tests/mocks)
62add_qml_test(Dash/Previews PreviewImageGallery IMPORT_PATHS ${qmltest_DEFAULT_IMPORT_PATHS} ${CMAKE_BINARY_DIR}/tests/mocks)
62add_qml_test(Dash/Previews PreviewImageGallery IMPORT_PATHS ${qmltest_DEFAULT_IMPORT_PATHS} ${CMAKE_BINARY_DIR}/tests/mocks)
63+add_qml_test(Dash/Previews PreviewHeader IMPORT_PATHS ${qmltest_DEFAULT_IMPORT_PATHS} ${CMAKE_BINARY_DIR}/tests/mocks)
63add_qml_test(Dash/Previews PreviewTextSummary IMPORT_PATHS ${qmltest_DEFAULT_IMPORT_PATHS} ${CMAKE_BINARY_DIR}/tests/mocks)
64add_qml_test(Dash/Previews PreviewTextSummary IMPORT_PATHS ${qmltest_DEFAULT_IMPORT_PATHS} ${CMAKE_BINARY_DIR}/tests/mocks)
64add_qml_test(Dash/Previews PreviewVideoPlayback IMPORT_PATHS ${qmltest_DEFAULT_IMPORT_PATHS} ${CMAKE_BINARY_DIR}/tests/mocks)
65add_qml_test(Dash/Previews PreviewVideoPlayback IMPORT_PATHS ${qmltest_DEFAULT_IMPORT_PATHS} ${CMAKE_BINARY_DIR}/tests/mocks)
65add_qml_test(Dash/Previews PreviewZoomableImage IMPORT_PATHS ${qmltest_DEFAULT_IMPORT_PATHS} ${CMAKE_BINARY_DIR}/tests/mocks)
66add_qml_test(Dash/Previews PreviewZoomableImage IMPORT_PATHS ${qmltest_DEFAULT_IMPORT_PATHS} ${CMAKE_BINARY_DIR}/tests/mocks)
tests/qmltests/Dash/Previews/tst_PreviewHeader.qmlnew file+56
@@ -0,0 +1,56 @@
1+/*
2+ * Copyright 2014 Canonical Ltd.
3+ *
4+ * 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 by
6+ * the Free Software Foundation; version 3.
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 General Public License for more details.
12+ *
13+ * You should have received a copy of the GNU General Public License
14+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
15+ */
16+
17+import QtQuick 2.0
18+import QtTest 1.0
19+import "../../../../qml/Dash/Previews"
20+import Unity.Test 0.1 as UT
21+
22+Rectangle {
23+ id: root
24+ width: units.gu(60)
25+ height: units.gu(80)
26+
27+ property var headerjson: {
28+ "title": "THE TITLE",
29+ "subtitle": "Something catchy",
30+ "mascot": "../graphics/play_button.png"
31+ }
32+
33+ PreviewHeader {
34+ id: previewHeader
35+ widgetData: headerjson
36+ width: units.gu(30)
37+
38+ Rectangle {
39+ anchors.fill: parent
40+ color: "red"
41+ opacity: 0.1
42+ }
43+ }
44+
45+ UT.UnityTestCase {
46+ name: "PreviewHeaderTest"
47+ when: windowShown
48+
49+ function test_json() {
50+ var cardHeader = findChild(previewHeader, "cardHeader");
51+ compare(cardHeader.title, "THE TITLE");
52+ compare(cardHeader.subtitle, "Something catchy");
53+ compare(cardHeader.mascot.toString().slice(-24), "graphics/play_button.png");
54+ }
55+ }
56+}
tests/qmltests/Dash/Previews/tst_PreviewWidgetFactory.qml+2−1
@@ -77,8 +77,9 @@ Rectangle {
77 return [
77 return [
78 { tag: "Actions", type: "actions", source: "PreviewActions.qml" },
78 { tag: "Actions", type: "actions", source: "PreviewActions.qml" },
79 { tag: "Audio", type: "audio", source: "PreviewAudioPlayback.qml" },
79 { tag: "Audio", type: "audio", source: "PreviewAudioPlayback.qml" },
80− { tag: "Image", type: "image", source: "PreviewZoomableImage.qml" },
81 { tag: "Gallery", type: "gallery", source: "PreviewImageGallery.qml" },
80 { tag: "Gallery", type: "gallery", source: "PreviewImageGallery.qml" },
81+ { tag: "Header", type: "header", source: "PreviewHeader.qml" },
82+ { tag: "Image", type: "image", source: "PreviewZoomableImage.qml" },
82 { tag: "Text", type: "text", source: "PreviewTextSummary.qml" },
83 { tag: "Text", type: "text", source: "PreviewTextSummary.qml" },
83 { tag: "Video", type: "video", source: "PreviewVideoPlayback.qml" },
84 { tag: "Video", type: "video", source: "PreviewVideoPlayback.qml" },
84 ];
85 ];