@@ -0,0 +1,232 @@
2+ * Copyright 2015 Canonical Ltd.
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.
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.
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/>.
19+import Ubuntu.Components 1.3
20+import "../../../../qml/Dash/Filters"
21+import Unity.Test 0.1 as UT
28+ color: theme.palette.selected.background
33+ property real startValue
34+ property real endValue
35+ property bool hasStartValue
36+ property bool hasEndValue
37+ property string startPrefixLabel
38+ property string startPostfixLabel
39+ property string centralLabel
40+ property string endPrefixLabel
41+ property string endPostfixLabel
43+ onStartValueChanged: {
44+ hasStartValue = true;
51+ function eraseStartValue() {
52+ hasStartValue = false;
55+ function eraseEndValue() {
60+ Component.onCompleted: {
64+ function generateData() {
65+ widgetData1.startValue = startValue.text;
66+ widgetData1.endValue = endValue.text;
67+ widgetData1.hasStartValue = startValueHasValue.checked;
68+ widgetData1.hasEndValue = endValueHasValue.checked;
69+ widgetData1.startPrefixLabel = startValuePrefixLabel.text;
70+ widgetData1.startPostfixLabel = startValuePostfixLabel.text;
71+ widgetData1.centralLabel = centralLabel.text;
72+ widgetData1.endPrefixLabel = endValuePrefixLabel.text;
73+ widgetData1.endPostfixLabel = endValuePostfixLabel.text;
75+ factory.widgetData = widgetData1;
78+ FilterWidgetFactory {
80+ widgetId: "testRangeInputFilter"
81+ widgetType: Filters.RangeInputFilter
90+ anchors.top: factory.bottom
101+ text: "Start Value Prefix Label"
102+ verticalAlignment: Text.AlignVCenter
103+ height: parent.height
106+ id: startValuePrefixLabel
112+ spacing: units.gu(1)
114+ text: "Start Value Postfix Label"
115+ verticalAlignment: Text.AlignVCenter
116+ height: parent.height
119+ id: startValuePostfixLabel
125+ spacing: units.gu(1)
127+ text: "Central Label"
128+ verticalAlignment: Text.AlignVCenter
129+ height: parent.height
138+ spacing: units.gu(1)
140+ text: "End Value Prefix Label"
141+ verticalAlignment: Text.AlignVCenter
142+ height: parent.height
145+ id: endValuePrefixLabel
151+ spacing: units.gu(1)
153+ text: "End Value Postfix Label"
154+ verticalAlignment: Text.AlignVCenter
155+ height: parent.height
158+ id: endValuePostfixLabel
164+ spacing: units.gu(1)
167+ verticalAlignment: Text.AlignVCenter
168+ height: parent.height
175+ id: startValueHasValue
181+ spacing: units.gu(1)
184+ verticalAlignment: Text.AlignVCenter
185+ height: parent.height
192+ id: endValueHasValue
199+ onClicked: root.generateData();
204+ name: "FilterRangeInput"
208+ root.generateData();
211+ function test_initialStatus() {
212+ var startValueField = findChild(factory, "startValueField");
213+ compare(startValueField.text, "");
215+ var endValueField = findChild(factory, "endValueField");
216+ compare(endValueField.text, "5");
219+ function test_dotStays() {
220+ var startValueField = findChild(factory, "startValueField");
221+ compare(startValueField.text, "");
223+ startValueField.text = "4.5";
224+ compare(startValueField.text, "4.5");
225+ compare(widgetData1.startValue, 4.5);
227+ startValueField.text = "4.";
228+ compare(startValueField.text, "4.");
229+ compare(widgetData1.startValue, 4);