on xenial help sign in
Add test for the expandable filter widget
commit4a474ac56efe83858bcf8799849bb8bd74bf4087 authorAlbert Astals Cid <albert.astals@canonical.com> dateMon 25 Apr 2016, 14:27 (10 years ago) parent363eaed
2 files changed+98
tests/qmltests/CMakeLists.txt+1 tests/qmltests/Dash/Filters/tst_FilterExpandableWidget.qml+97
tests/qmltests/CMakeLists.txt+1
@@ -57,6 +57,7 @@ add_unity8_qmltest(Dash/Filters FilterOptionSelector)
5757add_unity8_qmltest(Dash/Filters FilterRangeInput)
5858add_unity8_qmltest(Dash/Filters FilterValueSlider)
5959add_unity8_qmltest(Dash/Filters FilterWidgetFactory)
60+add_unity8_qmltest(Dash/Filters FilterExpandableWidget)
6061add_unity8_qmltest(Dash/ScopeSettings ScopeSettingBoolean)
6162add_unity8_qmltest(Dash/ScopeSettings ScopeSettingList)
6263add_unity8_qmltest(Dash/ScopeSettings ScopeSettingNumber)
tests/qmltests/Dash/Filters/tst_FilterExpandableWidget.qmlnew file+97
@@ -0,0 +1,97 @@
1+/*
2+ * Copyright 2016 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 "../../../../qml/Dash/Filters"
21+import Unity.Test 0.1 as UT
22+import Unity 0.2
23+
24+Rectangle {
25+ id: root
26+ width: units.gu(60)
27+ height: units.gu(80)
28+ color: theme.palette.selected.background
29+
30+ QtObject {
31+ id: widgetData1
32+
33+ property string title: "Expand me!"
34+ property ListModel filters: ListModel {
35+ dynamicRoles: true
36+ }
37+ }
38+
39+ QtObject {
40+ id: sliderObject
41+
42+ property string title
43+ property int value: 30
44+ property int minValue: 10
45+ property int maxValue: 150
46+
47+ property ListModel values: ListModel {
48+ ListElement {
49+ value: 10
50+ label: "10"
51+ }
52+ ListElement {
53+ value: 30
54+ label: "30"
55+ }
56+ ListElement {
57+ value: 100
58+ label: "100"
59+ }
60+ ListElement {
61+ value: 150
62+ label: "150"
63+ }
64+ }
65+ }
66+
67+ Component.onCompleted: {
68+ widgetData1.filters.append({"type": Filters.ValueSliderFilter, "filter": sliderObject, id: "trololo"});
69+ }
70+
71+ FilterWidgetFactory {
72+ id: factory
73+ widgetId: "testExpandableWidget"
74+ widgetType: Filters.ExpandableFilterWidget
75+ widgetData: widgetData1
76+ anchors {
77+ left: parent.left
78+ right: parent.right
79+ }
80+ height: implicitHeight
81+ clip: true
82+ }
83+
84+ UT.UnityTestCase {
85+ name: "FilterExpandableWidget"
86+ when: windowShown
87+
88+ function test_expandedChanges() {
89+ var expandingItem = findChild(factory, "expandingItem");
90+ verify(!expandingItem.expanded)
91+ mouseClick(expandingItem);
92+ verify(expandingItem.expanded)
93+ tryCompare(expandingItem, "height", units.gu(15))
94+ }
95+
96+ }
97+}