@@ -0,0 +1,87 @@
1+/*
2+ * Copyright (C) 2013 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.4
18+import QtTest 1.0
19+import Ubuntu.Components 1.3
20+import Unity.Test 0.1 as UT
21+import "../../../qml/Dash"
22+import "CardHelpers.js" as Helpers
23+
24+Rectangle {
25+ id: root
26+ width: units.gu(80)
27+ height: units.gu(72)
28+ color: "#88FFFFFF"
29+
30+ property var overlaidTemplate: {"card-layout":"vertical", "card-size":"small", "category-layout":"carousel", "overlay": true }
31+ property var nonOverlaidTemplate: {"card-layout":"vertical", "card-size":"small", "category-layout":"carousel" }
32+
33+ CardTool {
34+ id: cTool
35+ count: 10
36+ objectName: "cardTool"
37+ template: nonOverlaidTemplate
38+ components: {"art":{"aspect-ratio":1.6,"field":"art"}, "title":{"field":"title"}, "attributes":{}}
39+ viewWidth: parent.width
40+ }
41+
42+ ListModel {
43+ id: lModel
44+
45+ Component.onCompleted: {
46+ cTool.templateChanged();
47+ for (var i = 0; i < cTool.count; ++i) {
48+ lModel.append( { title: "fqg\nfqg", art: Qt.resolvedUrl("artwork/music-player-design.png").toString() } );
49+ }
50+ }
51+ }
52+
53+ CardCarousel {
54+ id: cardCarousel
55+ cardTool: cTool
56+ width: parent.width
57+ height: expandedHeight
58+ model: lModel
59+
60+ Rectangle {
61+ color: "red"
62+ opacity: 0.2
63+ anchors.fill: parent
64+ }
65+ }
66+
67+ UT.UnityTestCase {
68+ id: testCase
69+ name: "CardCarousel"
70+
71+ when: windowShown
72+
73+ function test_non_overlaid_header_layout() {
74+ // When the header is non overlaid
75+ // we grow down to accomodate the header but the y of the list is the same
76+ var listView = findChild(cardCarousel, "listView");
77+
78+ cTool.template = overlaidTemplate;
79+ var yPos = listView.y;
80+ var height = cardCarousel.height;
81+
82+ cTool.template = nonOverlaidTemplate;
83+ compare(listView.y, yPos);
84+ compare(cardCarousel.height, height + cTool.headerHeight);
85+ }
86+ }
87+}