Merge lp:~aacid/unity8/expandable_filter into lp:unity8

Proposed by Albert Astals Cid on 2016-03-14
Status: Merged
Approved by: Andrea Cimitan on 2016-04-26
Approved revision: 2054
Merged at revision: 2391
Proposed branch: lp:~aacid/unity8/expandable_filter
Merge into: lp:unity8
Prerequisite: lp:~aacid/unity8/valueslider_filter
Diff against target: 534 lines (+334/-17)
13 files modified
debian/control (+2/-2)
qml/Dash/Filters/FilterExpandableWidget.qml (+96/-0)
qml/Dash/Filters/FilterWidget.qml (+3/-0)
qml/Dash/Filters/FilterWidgetFactory.qml (+2/-1)
tests/mocks/Unity/CMakeLists.txt (+3/-1)
tests/mocks/Unity/fake_expandablefilterwidget.cpp (+53/-0)
tests/mocks/Unity/fake_expandablefilterwidget.h (+48/-0)
tests/mocks/Unity/fake_filters.cpp (+19/-8)
tests/mocks/Unity/fake_filters.h (+4/-4)
tests/mocks/Unity/fake_scope.cpp (+2/-0)
tests/qmltests/CMakeLists.txt (+1/-0)
tests/qmltests/Dash/Filters/tst_FilterExpandableWidget.qml (+99/-0)
tests/qmltests/Dash/Filters/tst_FilterWidgetFactory.qml (+2/-1)
To merge this branch: bzr merge lp:~aacid/unity8/expandable_filter
Reviewer Review Type Date Requested Status
Andrea Cimitan (community) 2016-03-14 Approve on 2016-04-26
Unity8 CI Bot continuous-integration Needs Fixing on 2016-04-25
Paweł Stołowski Approve on 2016-04-22
Review via email: mp+288957@code.launchpad.net

Commit Message

Expandable Filter Widget

Description of the Change

 * Are there any related MPs required for this MP to build/function as expected?
https://code.launchpad.net/~stolowski/unity-api/expandable-filter-widget

 * Did you perform an exploratory manual test run of your code change and any related functionality?
Yes (via make tryDash)

 * Did you make sure that your branch does not contain spurious tags?
Yes

 * If you changed the packaging (debian), did you subscribe the ubuntu-unity team to this MP?
N/A

 * If you changed the UI, has there been a design review?
N/A

To post a comment you must log in.
Andrea Cimitan (cimi) wrote :

a couple of comments plus... why is it called ExpandableFilterWidget and not ExpandableFilter like all other Filters we have so far?

review: Needs Fixing
lp:~aacid/unity8/expandable_filter updated on 2016-04-19
2050. By Albert Astals Cid on 2016-04-19

Merge

2051. By Albert Astals Cid on 2016-04-19

increase dep versions

Unity8 CI Bot (unity8-ci-bot) wrote :

FAILED: Continuous integration, rev:2050
https://unity8-jenkins.ubuntu.com/job/lp-unity8-ci/1007/
Executed test runs:
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-0-fetch/1354
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-1-sourcepkg/release=vivid+overlay/1326
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-1-sourcepkg/release=xenial/1326
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-1-sourcepkg/release=xenial+overlay/1326
    FAILURE: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=amd64,release=vivid+overlay/1325/console
    FAILURE: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=amd64,release=xenial/1325/console
    FAILURE: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=amd64,release=xenial+overlay/1325/console
    FAILURE: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=armhf,release=vivid+overlay/1325/console
    FAILURE: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=armhf,release=xenial/1325/console
    FAILURE: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=armhf,release=xenial+overlay/1325/console
    FAILURE: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=i386,release=vivid+overlay/1325/console
    FAILURE: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=i386,release=xenial/1325/console
    FAILURE: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=i386,release=xenial+overlay/1325/console

Click here to trigger a rebuild:
https://unity8-jenkins.ubuntu.com/job/lp-unity8-ci/1007/rebuild

review: Needs Fixing (continuous-integration)
Unity8 CI Bot (unity8-ci-bot) wrote :

FAILED: Continuous integration, rev:2051
https://unity8-jenkins.ubuntu.com/job/lp-unity8-ci/1008/
Executed test runs:
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-0-fetch/1356
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-1-sourcepkg/release=vivid+overlay/1327
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-1-sourcepkg/release=xenial/1327
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-1-sourcepkg/release=xenial+overlay/1327
    FAILURE: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=amd64,release=vivid+overlay/1326/console
    FAILURE: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=amd64,release=xenial/1326/console
    FAILURE: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=amd64,release=xenial+overlay/1326/console
    FAILURE: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=armhf,release=vivid+overlay/1326/console
    FAILURE: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=armhf,release=xenial/1326/console
    FAILURE: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=armhf,release=xenial+overlay/1326/console
    FAILURE: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=i386,release=vivid+overlay/1326/console
    FAILURE: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=i386,release=xenial/1326/console
    FAILURE: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=i386,release=xenial+overlay/1326/console

Click here to trigger a rebuild:
https://unity8-jenkins.ubuntu.com/job/lp-unity8-ci/1008/rebuild

review: Needs Fixing (continuous-integration)
Albert Astals Cid (aacid) wrote :

> a couple of comments plus... why is it called ExpandableFilterWidget and not
> ExpandableFilter like all other Filters we have so far?

Follows the API naming, according to Pawel it's because it's not really a Filter (doesn't filter anything) just a Filter Widget.

lp:~aacid/unity8/expandable_filter updated on 2016-04-19
2052. By Albert Astals Cid on 2016-04-19

fix too much c&p

2053. By Albert Astals Cid on 2016-04-19

Use anchors instead of width as suggested in review

Albert Astals Cid (aacid) wrote :

> a couple of comments plus...
Addressed the comments (i think)

Unity8 CI Bot (unity8-ci-bot) wrote :

FAILED: Continuous integration, rev:2053
https://unity8-jenkins.ubuntu.com/job/lp-unity8-ci/1015/
Executed test runs:
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-0-fetch/1363
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-1-sourcepkg/release=vivid+overlay/1334
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-1-sourcepkg/release=xenial/1334
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-1-sourcepkg/release=xenial+overlay/1334
    FAILURE: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=amd64,release=vivid+overlay/1334/console
    FAILURE: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=amd64,release=xenial/1334/console
    FAILURE: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=amd64,release=xenial+overlay/1334/console
    FAILURE: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=armhf,release=vivid+overlay/1334/console
    FAILURE: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=armhf,release=xenial/1334/console
    FAILURE: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=armhf,release=xenial+overlay/1334/console
    FAILURE: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=i386,release=vivid+overlay/1334/console
    FAILURE: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=i386,release=xenial/1334/console
    FAILURE: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=i386,release=xenial+overlay/1334/console

Click here to trigger a rebuild:
https://unity8-jenkins.ubuntu.com/job/lp-unity8-ci/1015/rebuild

review: Needs Fixing (continuous-integration)
Paweł Stołowski (stolowski) wrote :

Tested in silo 59, works as expected. +1

review: Approve
Andrea Cimitan (cimi) wrote :

any reason we didn't add qml tests for the component?

review: Needs Information
lp:~aacid/unity8/expandable_filter updated on 2016-04-25
2054. By Albert Astals Cid on 2016-04-25

Add test for the expandable filter widget

Albert Astals Cid (aacid) wrote :

> any reason we didn't add qml tests for the component?

Added a test, it doesn't do much but it won't hurt.

Unity8 CI Bot (unity8-ci-bot) wrote :

FAILED: Continuous integration, rev:2054
https://unity8-jenkins.ubuntu.com/job/lp-unity8-ci/1045/
Executed test runs:
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-0-fetch/1408
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-1-sourcepkg/release=vivid+overlay/1377
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-1-sourcepkg/release=xenial/1377
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-1-sourcepkg/release=xenial+overlay/1377
    FAILURE: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=amd64,release=vivid+overlay/1377/console
    FAILURE: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=amd64,release=xenial/1377/console
    FAILURE: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=amd64,release=xenial+overlay/1377/console
    FAILURE: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=armhf,release=vivid+overlay/1377/console
    FAILURE: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=armhf,release=xenial/1377/console
    FAILURE: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=armhf,release=xenial+overlay/1377/console
    FAILURE: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=i386,release=vivid+overlay/1377/console
    FAILURE: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=i386,release=xenial/1377/console
    FAILURE: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=i386,release=xenial+overlay/1377/console

Click here to trigger a rebuild:
https://unity8-jenkins.ubuntu.com/job/lp-unity8-ci/1045/rebuild

review: Needs Fixing (continuous-integration)
Andrea Cimitan (cimi) wrote :

 * Did you perform an exploratory manual test run of the code change and any related functionality?
pawel did for me since I had an issue with his click package
 * Did CI run pass? If not, please explain why.
unrelated

review: Approve
lp:~aacid/unity8/expandable_filter updated on 2016-04-27
2055. By Albert Astals Cid on 2016-04-26

Increase version number

2056. By Albert Astals Cid on 2016-04-26

Merge

2057. By Albert Astals Cid on 2016-04-27

Make the test work better with different px per gu values

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'debian/control'
2--- debian/control 2016-04-13 16:50:51 +0000
3+++ debian/control 2016-04-27 12:56:09 +0000
4@@ -30,7 +30,7 @@
5 libqt5xmlpatterns5-dev,
6 libsystemsettings-dev,
7 libudev-dev,
8- libunity-api-dev (>= 7.110),
9+ libunity-api-dev (>= 7.111),
10 libusermetricsoutput1-dev,
11 # Need those X11 libs touch emulation from mouse events in manual QML tests on a X11 desktop
12 libx11-dev[!armhf],
13@@ -136,7 +136,7 @@
14 unity-application-impl-15,
15 unity-notifications-impl-3,
16 unity-plugin-scopes | unity-scopes-impl,
17- unity-scopes-impl-11,
18+ unity-scopes-impl-12,
19 unity8-fake-env | unity-application-impl,
20 ${misc:Depends},
21 Breaks: unity8 (<< 7.86),
22
23=== added file 'qml/Dash/Filters/FilterExpandableWidget.qml'
24--- qml/Dash/Filters/FilterExpandableWidget.qml 1970-01-01 00:00:00 +0000
25+++ qml/Dash/Filters/FilterExpandableWidget.qml 2016-04-27 12:56:09 +0000
26@@ -0,0 +1,96 @@
27+/*
28+ * Copyright (C) 2016 Canonical, Ltd.
29+ *
30+ * This program is free software; you can redistribute it and/or modify
31+ * it under the terms of the GNU General Public License as published by
32+ * the Free Software Foundation; version 3.
33+ *
34+ * This program is distributed in the hope that it will be useful,
35+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
36+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
37+ * GNU General Public License for more details.
38+ *
39+ * You should have received a copy of the GNU General Public License
40+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
41+ */
42+
43+import QtQuick 2.4
44+import Ubuntu.Components 1.3
45+import Ubuntu.Components.ListItems 1.3 as ListItems
46+
47+/*! Expandable Filter Widget. */
48+
49+FilterWidget {
50+ id: root
51+
52+ showsTitleOnItsOwn: true
53+
54+ implicitHeight: expandingItem.height
55+
56+ ListItems.Expandable {
57+ id: expandingItem
58+ objectName: "expandingItem"
59+
60+ expandedHeight: collapsedHeight + column.height
61+ anchors.left: parent.left
62+ anchors.right: parent.right
63+ showDivider: false
64+
65+ onClicked: {
66+ expanded = !expanded;
67+ forceActiveFocus();
68+ }
69+ __contentsMargins: 0
70+
71+ Item {
72+ id: titleHolder
73+ anchors.top: parent.top
74+ height: expandingItem.collapsedHeight
75+ anchors.left: parent.left
76+ anchors.right: parent.right
77+
78+ Label {
79+ anchors.left: parent.left
80+ anchors.leftMargin: units.gu(2)
81+ anchors.right: dropDown.left
82+ anchors.verticalCenter: parent.verticalCenter
83+ text: widgetData.title || ""
84+ }
85+
86+ Image {
87+ id: dropDown
88+ height: units.gu(3)
89+ fillMode: Image.PreserveAspectFit
90+ anchors.right: parent.right
91+ anchors.rightMargin: units.gu(2)
92+ anchors.verticalCenter: parent.verticalCenter
93+ source: expandingItem.expanded ? "image://theme/up" : "image://theme/down"
94+ }
95+ }
96+
97+ Column {
98+ id: column
99+ anchors.left: parent.left
100+ anchors.right: parent.right
101+ anchors.top: titleHolder.bottom
102+
103+ Repeater {
104+ id: repeater
105+ model: widgetData.filters
106+
107+ delegate: FilterWidgetFactory {
108+ width: parent.width
109+
110+ widgetId: id
111+ widgetType: type
112+ widgetData: filter
113+
114+ ListItems.ThinDivider {
115+ anchors.bottom: parent.bottom
116+ visible: index !== repeater.count - 1
117+ }
118+ }
119+ }
120+ }
121+ }
122+}
123
124=== modified file 'qml/Dash/Filters/FilterWidget.qml'
125--- qml/Dash/Filters/FilterWidget.qml 2015-11-17 10:32:29 +0000
126+++ qml/Dash/Filters/FilterWidget.qml 2016-04-27 12:56:09 +0000
127@@ -25,5 +25,8 @@
128 //! Variable used to contain widget's data
129 property var widgetData: null
130
131+ //! Does the widget show the title inside?
132+ property bool showsTitleOnItsOwn: false
133+
134 objectName: widgetId
135 }
136
137=== modified file 'qml/Dash/Filters/FilterWidgetFactory.qml'
138--- qml/Dash/Filters/FilterWidgetFactory.qml 2016-03-15 19:16:10 +0000
139+++ qml/Dash/Filters/FilterWidgetFactory.qml 2016-04-27 12:56:09 +0000
140@@ -35,7 +35,7 @@
141
142 Label {
143 id: title
144- text: widgetData ? widgetData.title : ""
145+ text: widgetData && !(loader.item && loader.item.showsTitleOnItsOwn) ? widgetData.title : ""
146 height: text != "" ? implicitHeight : 0
147
148 anchors {
149@@ -68,6 +68,7 @@
150 case Filters.OptionSelectorFilter: return "FilterOptionSelector.qml";
151 case Filters.RangeInputFilter: return "FilterRangeInput.qml";
152 case Filters.ValueSliderFilter: return "FilterValueSlider.qml";
153+ case Filters.ExpandableFilterWidget: return "FilterExpandableWidget.qml";
154 default: return "";
155 }
156 }
157
158=== modified file 'tests/mocks/Unity/CMakeLists.txt'
159--- tests/mocks/Unity/CMakeLists.txt 2016-03-08 15:01:00 +0000
160+++ tests/mocks/Unity/CMakeLists.txt 2016-04-27 12:56:09 +0000
161@@ -8,7 +8,7 @@
162 add_subdirectory(Screens)
163
164 pkg_search_module(GOBJECT gobject-2.0 REQUIRED)
165-pkg_check_modules(SCOPES_API REQUIRED unity-shell-scopes=11)
166+pkg_check_modules(SCOPES_API REQUIRED unity-shell-scopes=12)
167
168 include_directories(
169 ${CMAKE_CURRENT_BINARY_DIR}
170@@ -34,6 +34,7 @@
171 fake_optionselectoroptions.cpp
172 fake_rangeinputfilter.cpp
173 fake_valuesliderfilter.cpp
174+ fake_expandablefilterwidget.cpp
175 fake_valueslidervalues.cpp
176 fake_unity_plugin.cpp
177 ${SCOPES_API_INCLUDEDIR}/unity/shell/scopes/CategoriesInterface.h
178@@ -51,6 +52,7 @@
179 ${SCOPES_API_INCLUDEDIR}/unity/shell/scopes/SettingsModelInterface.h
180 ${SCOPES_API_INCLUDEDIR}/unity/shell/scopes/ValueSliderFilterInterface.h
181 ${SCOPES_API_INCLUDEDIR}/unity/shell/scopes/ValueSliderValuesInterface.h
182+ ${SCOPES_API_INCLUDEDIR}/unity/shell/scopes/ExpandableFilterWidgetInterface.h
183 )
184
185 # Workaround for gcc failure LP: #1417664
186
187=== added file 'tests/mocks/Unity/fake_expandablefilterwidget.cpp'
188--- tests/mocks/Unity/fake_expandablefilterwidget.cpp 1970-01-01 00:00:00 +0000
189+++ tests/mocks/Unity/fake_expandablefilterwidget.cpp 2016-04-27 12:56:09 +0000
190@@ -0,0 +1,53 @@
191+/*
192+ * Copyright (C) 2016 Canonical, Ltd.
193+ *
194+ * This program is free software; you can redistribute it and/or modify
195+ * it under the terms of the GNU General Public License as published by
196+ * the Free Software Foundation; version 3.
197+ *
198+ * This program is distributed in the hope that it will be useful,
199+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
200+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
201+ * GNU General Public License for more details.
202+ *
203+ * You should have received a copy of the GNU General Public License
204+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
205+ */
206+
207+#include "fake_expandablefilterwidget.h"
208+
209+#include "fake_filters.h"
210+
211+FakeExpandbleFilterWidget::FakeExpandbleFilterWidget(const QString &id, const QString &tag, const QString &title, QObject* parent)
212+ : unity::shell::scopes::ExpandableFilterWidgetInterface(parent)
213+ , m_filterId(id)
214+ , m_filterTag(tag)
215+ , m_title(title)
216+{
217+ m_filters = new Filters(this);
218+}
219+
220+QString FakeExpandbleFilterWidget::filterId() const
221+{
222+ return m_filterId;
223+}
224+
225+QString FakeExpandbleFilterWidget::filterTag() const
226+{
227+ return m_filterTag;
228+}
229+
230+QString FakeExpandbleFilterWidget::title() const
231+{
232+ return m_title;
233+}
234+
235+unity::shell::scopes::FiltersInterface* FakeExpandbleFilterWidget::filters() const
236+{
237+ return m_filters;
238+}
239+
240+void FakeExpandbleFilterWidget::addFilter(unity::shell::scopes::FilterBaseInterface* f)
241+{
242+ m_filters->addFilter(f);
243+}
244
245=== added file 'tests/mocks/Unity/fake_expandablefilterwidget.h'
246--- tests/mocks/Unity/fake_expandablefilterwidget.h 1970-01-01 00:00:00 +0000
247+++ tests/mocks/Unity/fake_expandablefilterwidget.h 2016-04-27 12:56:09 +0000
248@@ -0,0 +1,48 @@
249+/*
250+ * Copyright (C) 2016 Canonical, Ltd.
251+ *
252+ * This program is free software; you can redistribute it and/or modify
253+ * it under the terms of the GNU General Public License as published by
254+ * the Free Software Foundation; version 3.
255+ *
256+ * This program is distributed in the hope that it will be useful,
257+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
258+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
259+ * GNU General Public License for more details.
260+ *
261+ * You should have received a copy of the GNU General Public License
262+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
263+ */
264+
265+#ifndef FAKE_EXPANDABLEFILTERWIDGET_H
266+#define FAKE_EXPANDABLEFILTERWIDGET_H
267+
268+#include <unity/shell/scopes/ExpandableFilterWidgetInterface.h>
269+
270+class Filters;
271+
272+class FakeExpandbleFilterWidget : public unity::shell::scopes::ExpandableFilterWidgetInterface
273+{
274+ Q_OBJECT
275+
276+public:
277+ FakeExpandbleFilterWidget(const QString &id, const QString &tag, const QString &title, QObject* parent);
278+
279+ QString filterId() const override;
280+ QString filterTag() const override;
281+ QString title() const override;
282+
283+ unity::shell::scopes::FiltersInterface* filters() const override;
284+
285+ // mock API
286+ void addFilter(unity::shell::scopes::FilterBaseInterface* f);
287+
288+private:
289+ QString m_filterId;
290+ QString m_filterTag;
291+ QString m_title;
292+
293+ Filters *m_filters;
294+};
295+
296+#endif
297
298=== modified file 'tests/mocks/Unity/fake_filters.cpp'
299--- tests/mocks/Unity/fake_filters.cpp 2015-12-09 11:35:29 +0000
300+++ tests/mocks/Unity/fake_filters.cpp 2016-04-27 12:56:09 +0000
301@@ -19,11 +19,15 @@
302 #include "fake_optionselectorfilter.h"
303 #include "fake_rangeinputfilter.h"
304 #include "fake_valuesliderfilter.h"
305-#include "fake_scope.h"
306+#include "fake_expandablefilterwidget.h"
307
308-Filters::Filters(Scope* parent)
309+Filters::Filters(QObject* parent)
310 : unity::shell::scopes::FiltersInterface(parent)
311 {
312+}
313+
314+void Filters::addFakeFilters()
315+{
316 addFilter(new FakeOptionSelectorFilter("OSF1", "Tag1", "Which Cake you like More", false, QStringList() << "cheese" << "carrot" << "chocolate", this));
317
318 FakeRangeInputFilter *rif = new FakeRangeInputFilter("RIF1", "Tag3", this);
319@@ -41,6 +45,11 @@
320 addFilter(vsf);
321
322 addFilter(new FakeOptionSelectorFilter("OSF2", "Tag2", "Which Countries have you been to?", true, QStringList() << "Germany" << "UK" << "New Zealand", this));
323+
324+ auto expandableFilter = new FakeExpandbleFilterWidget("EFW", "Tag5", "Advanced Settings", this);
325+ expandableFilter->addFilter(new FakeValueSliderFilter("VS2", "Tag6", 15, 10, 150, labels, this));
326+
327+ addFilter(expandableFilter);
328 }
329
330 void Filters::addFilter(unity::shell::scopes::FilterBaseInterface *f)
331@@ -58,9 +67,10 @@
332 }
333 break;
334
335- case FiltersInterface::ValueSliderFilter: {
336- // Not counting value slider as active in the mock
337- }
338+ case FiltersInterface::ExpandableFilterWidget:
339+ // Can't be active
340+ case FiltersInterface::ValueSliderFilter:
341+ // Not counting value as active in the mock
342
343 case Invalid:
344 break;
345@@ -113,9 +123,10 @@
346 }
347 break;
348
349- case FiltersInterface::ValueSliderFilter: {
350- // Not counting value slider as active in the mock
351- }
352+ case FiltersInterface::ExpandableFilterWidget:
353+ // Can't be active
354+ case FiltersInterface::ValueSliderFilter:
355+ // Not counting value as active in the mock
356
357 case Invalid:
358 break;
359
360=== modified file 'tests/mocks/Unity/fake_filters.h'
361--- tests/mocks/Unity/fake_filters.h 2015-11-17 10:32:29 +0000
362+++ tests/mocks/Unity/fake_filters.h 2016-04-27 12:56:09 +0000
363@@ -20,25 +20,25 @@
364 #include <unity/shell/scopes/FiltersInterface.h>
365 #include <unity/shell/scopes/FilterBaseInterface.h>
366
367-class Scope;
368-
369 class Filters : public unity::shell::scopes::FiltersInterface
370 {
371 Q_OBJECT
372
373 public:
374- Filters(Scope* parent);
375+ Filters(QObject* parent);
376
377 int rowCount(const QModelIndex &parent) const override;
378 QVariant data(const QModelIndex &index, int role) const override;
379
380+ // Mock API
381 int activeFiltersCount() const;
382+ void addFakeFilters();
383+ void addFilter(unity::shell::scopes::FilterBaseInterface* f);
384
385 Q_SIGNALS:
386 void activeFiltersCountChanged();
387
388 private:
389- void addFilter(unity::shell::scopes::FilterBaseInterface* f);
390
391 QVector<unity::shell::scopes::FilterBaseInterface*> m_filters;
392 };
393
394=== modified file 'tests/mocks/Unity/fake_scope.cpp'
395--- tests/mocks/Unity/fake_scope.cpp 2016-03-07 08:46:16 +0000
396+++ tests/mocks/Unity/fake_scope.cpp 2016-04-27 12:56:09 +0000
397@@ -49,6 +49,8 @@
398 , m_filters(new Filters(this))
399 , m_returnNullPreview(returnNullPreview)
400 {
401+ m_filters->addFakeFilters();
402+
403 m_primaryNavigationFilter = new FakeOptionSelectorFilter("OSF3", "PFTag", "Which food you like More", false, QStringList() << "meat" << "vegetables", this);
404 connect(m_filters, &Filters::activeFiltersCountChanged, this, &Scope::activeFiltersCountChanged);
405 }
406
407=== modified file 'tests/qmltests/CMakeLists.txt'
408--- tests/qmltests/CMakeLists.txt 2016-04-04 13:37:49 +0000
409+++ tests/qmltests/CMakeLists.txt 2016-04-27 12:56:09 +0000
410@@ -57,6 +57,7 @@
411 add_unity8_qmltest(Dash/Filters FilterRangeInput)
412 add_unity8_qmltest(Dash/Filters FilterValueSlider)
413 add_unity8_qmltest(Dash/Filters FilterWidgetFactory)
414+add_unity8_qmltest(Dash/Filters FilterExpandableWidget)
415 add_unity8_qmltest(Dash/ScopeSettings ScopeSettingBoolean)
416 add_unity8_qmltest(Dash/ScopeSettings ScopeSettingList)
417 add_unity8_qmltest(Dash/ScopeSettings ScopeSettingNumber)
418
419=== added file 'tests/qmltests/Dash/Filters/tst_FilterExpandableWidget.qml'
420--- tests/qmltests/Dash/Filters/tst_FilterExpandableWidget.qml 1970-01-01 00:00:00 +0000
421+++ tests/qmltests/Dash/Filters/tst_FilterExpandableWidget.qml 2016-04-27 12:56:09 +0000
422@@ -0,0 +1,99 @@
423+/*
424+ * Copyright 2016 Canonical Ltd.
425+ *
426+ * This program is free software; you can redistribute it and/or modify
427+ * it under the terms of the GNU General Public License as published by
428+ * the Free Software Foundation; version 3.
429+ *
430+ * This program is distributed in the hope that it will be useful,
431+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
432+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
433+ * GNU General Public License for more details.
434+ *
435+ * You should have received a copy of the GNU General Public License
436+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
437+ */
438+
439+import QtQuick 2.4
440+import QtTest 1.0
441+import Ubuntu.Components 1.3
442+import "../../../../qml/Dash/Filters"
443+import Unity.Test 0.1 as UT
444+import Unity 0.2
445+
446+Rectangle {
447+ id: root
448+ width: units.gu(60)
449+ height: units.gu(80)
450+ color: theme.palette.selected.background
451+
452+ QtObject {
453+ id: widgetData1
454+
455+ property string title: "Expand me!"
456+ property ListModel filters: ListModel {
457+ dynamicRoles: true
458+ }
459+ }
460+
461+ QtObject {
462+ id: sliderObject
463+
464+ property string title
465+ property int value: 30
466+ property int minValue: 10
467+ property int maxValue: 150
468+
469+ property ListModel values: ListModel {
470+ ListElement {
471+ value: 10
472+ label: "10"
473+ }
474+ ListElement {
475+ value: 30
476+ label: "30"
477+ }
478+ ListElement {
479+ value: 100
480+ label: "100"
481+ }
482+ ListElement {
483+ value: 150
484+ label: "150"
485+ }
486+ }
487+ }
488+
489+ Component.onCompleted: {
490+ widgetData1.filters.append({"type": Filters.ValueSliderFilter, "filter": sliderObject, id: "trololo"});
491+ }
492+
493+ FilterWidgetFactory {
494+ id: factory
495+ widgetId: "testExpandableWidget"
496+ widgetType: Filters.ExpandableFilterWidget
497+ widgetData: widgetData1
498+ anchors {
499+ left: parent.left
500+ right: parent.right
501+ }
502+ height: implicitHeight
503+ clip: true
504+ }
505+
506+ UT.UnityTestCase {
507+ name: "FilterExpandableWidget"
508+ when: windowShown
509+
510+ function test_expandedChanges() {
511+ var expandingItem = findChild(factory, "expandingItem");
512+ verify(!expandingItem.expanded)
513+ compare(expandingItem.height, expandingItem.collapsedHeight)
514+ mouseClick(expandingItem);
515+ verify(expandingItem.expanded)
516+ tryCompare(expandingItem, "height", expandingItem.expandedHeight)
517+ verify(expandingItem.collapsedHeight < expandingItem.expandedHeight / 2);
518+ }
519+
520+ }
521+}
522
523=== modified file 'tests/qmltests/Dash/Filters/tst_FilterWidgetFactory.qml'
524--- tests/qmltests/Dash/Filters/tst_FilterWidgetFactory.qml 2016-03-15 19:16:10 +0000
525+++ tests/qmltests/Dash/Filters/tst_FilterWidgetFactory.qml 2016-04-27 12:56:09 +0000
526@@ -43,7 +43,8 @@
527 return [
528 { tag: "OptionSelector", type: Filters.OptionSelectorFilter, source: "FilterOptionSelector.qml" },
529 { tag: "RangeInputFilter", type: Filters.RangeInputFilter, source: "FilterRangeInput.qml" },
530- { tag: "ValueSliderFilter", type: Filters.ValueSliderFilter, source: "FilterValueSlider.qml" }
531+ { tag: "ValueSliderFilter", type: Filters.ValueSliderFilter, source: "FilterValueSlider.qml" },
532+ { tag: "ExpandableFilter", type: Filters.ExpandableFilterWidget, source: "FilterExpandableWidget.qml" }
533 ];
534 }
535

Subscribers

People subscribed via source and target branches