Merge lp:~stolowski/unity-scopes-shell/fix-1335761 into lp:unity-scopes-shell

Proposed by Paweł Stołowski
Status: Merged
Approved by: Marcus Tomlinson
Approved revision: 211
Merged at revision: 209
Proposed branch: lp:~stolowski/unity-scopes-shell/fix-1335761
Merge into: lp:unity-scopes-shell
Diff against target: 286 lines (+114/-3)
10 files modified
po/unity-plugin-scopes.pot (+1/-1)
src/Unity/previewstack.cpp (+5/-0)
src/Unity/previewstack.h (+1/-0)
src/Unity/scope.cpp (+2/-0)
src/scope-harness/internal/preview-widget-arguments.h (+3/-0)
src/scope-harness/preview/preview-widget.cpp (+39/-1)
src/scope-harness/view/preview-view.cpp (+1/-1)
src/scope-harness/view/results-view.h (+2/-0)
tests/data/mock-scope/mock-scope.cpp (+34/-0)
tests/previewtest.cpp (+26/-0)
To merge this branch: bzr merge lp:~stolowski/unity-scopes-shell/fix-1335761
Reviewer Review Type Date Requested Status
Marcus Tomlinson (community) Approve
PS Jenkins bot (community) continuous-integration Approve
Pete Woods (community) Approve
Review via email: mp+256793@code.launchpad.net

Commit message

Emit showDash() signal if canned query is executed for current scope.

Description of the change

Emit showDash() signal if canned query is executed for current scope. This hides the preview if displayed (the solution was consulted with tsdgeos and I've tested it with a modified version of mediascanner scope that reproduces the bug linked with this branch).

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Marcus Tomlinson (marcustomlinson) wrote :

9 + } else {
10 + Q_EMIT showDash();
11 + }

Sorry! The smallest of fixes: The last curly bracket is not indented correctly. Its picking at my OCD man... :P

review: Needs Fixing
210. By Paweł Stołowski

Updated scope harness for showDash signal when canned query is executed.

Revision history for this message
Paweł Stołowski (stolowski) wrote :

> 9 + } else {
> 10 + Q_EMIT showDash();
> 11 + }
>
> Sorry! The smallest of fixes: The last curly bracket is not indented
> correctly. Its picking at my OCD man... :P

Fixed :)

Unfortunately the change you reviewed was a tip of an iceberg; Pete requested that I update scope harness code to reflect this change, so here it some extra stuff to review ;)

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Pete Woods (pete-woods) wrote :

Thanks for adding the tests :)

review: Approve
211. By Paweł Stołowski

More friendly trigger method.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Marcus Tomlinson (marcustomlinson) wrote :

LGTM

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'po/unity-plugin-scopes.pot'
2--- po/unity-plugin-scopes.pot 2015-03-04 10:10:56 +0000
3+++ po/unity-plugin-scopes.pot 2015-04-27 11:28:49 +0000
4@@ -8,7 +8,7 @@
5 msgstr ""
6 "Project-Id-Version: PACKAGE VERSION\n"
7 "Report-Msgid-Bugs-To: \n"
8-"POT-Creation-Date: 2015-03-04 11:02+0100\n"
9+"POT-Creation-Date: 2015-04-27 13:27+0200\n"
10 "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
11 "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
12 "Language-Team: LANGUAGE <LL@li.org>\n"
13
14=== modified file 'src/Unity/previewstack.cpp'
15--- src/Unity/previewstack.cpp 2015-01-30 07:45:25 +0000
16+++ src/Unity/previewstack.cpp 2015-04-27 11:28:49 +0000
17@@ -84,6 +84,11 @@
18 m_userAgent = userAgent;
19 }
20
21+scopes_ng::Scope* PreviewStack::associatedScope() const
22+{
23+ return m_associatedScope;
24+}
25+
26 void PreviewStack::loadForResult(scopes::Result::SPtr const& result)
27 {
28 m_previewedResult = result;
29
30=== modified file 'src/Unity/previewstack.h'
31--- src/Unity/previewstack.h 2014-09-23 11:33:38 +0000
32+++ src/Unity/previewstack.h 2015-04-27 11:28:49 +0000
33@@ -61,6 +61,7 @@
34 void setWidgetColumnCount(int columnCount) override;
35 int widgetColumnCount() const override;
36 void setAssociatedScope(scopes_ng::Scope*, QUuid const&, QString const&);
37+ scopes_ng::Scope* associatedScope() const;
38
39 private Q_SLOTS:
40 void widgetTriggered(QString const&, QString const&, QVariantMap const&);
41
42=== modified file 'src/Unity/scope.cpp'
43--- src/Unity/scope.cpp 2015-03-20 14:44:32 +0000
44+++ src/Unity/scope.cpp 2015-04-27 11:28:49 +0000
45@@ -298,6 +298,8 @@
46 }
47 if (scope != this) {
48 Q_EMIT gotoScope(scopeId);
49+ } else {
50+ Q_EMIT showDash();
51 }
52 } else {
53 // create temp dash page
54
55=== modified file 'src/scope-harness/internal/preview-widget-arguments.h'
56--- src/scope-harness/internal/preview-widget-arguments.h 2015-01-07 14:22:42 +0000
57+++ src/scope-harness/internal/preview-widget-arguments.h 2015-04-27 11:28:49 +0000
58@@ -31,6 +31,7 @@
59 {
60 class PreviewWidgetModelInterface;
61 class PreviewModelInterface;
62+ class PreviewStackInterface;
63 }
64 }
65 namespace scopeharness
66@@ -53,6 +54,8 @@
67 std::shared_ptr<view::ResultsView> resultsView;
68
69 std::shared_ptr<view::PreviewView> previewView;
70+
71+ std::shared_ptr<unity::shell::scopes::PreviewStackInterface> previewStack;
72 };
73 }
74 }
75
76=== modified file 'src/scope-harness/preview/preview-widget.cpp'
77--- src/scope-harness/preview/preview-widget.cpp 2015-03-10 11:23:01 +0000
78+++ src/scope-harness/preview/preview-widget.cpp 2015-04-27 11:28:49 +0000
79@@ -20,15 +20,18 @@
80 #include <scope-harness/preview/preview-widget.h>
81 #include <scope-harness/view/abstract-view.h>
82 #include <scope-harness/view/preview-view.h>
83+#include <scope-harness/view/results-view.h>
84 #include <scope-harness/test-utils.h>
85
86 #include <unity/shell/scopes/PreviewModelInterface.h>
87 #include <unity/shell/scopes/PreviewWidgetModelInterface.h>
88
89 #include <Unity/utils.h>
90+#include <Unity/previewstack.h>
91
92 #include <QDebug>
93 #include <QSignalSpy>
94+#include <memory>
95
96 using namespace std;
97 namespace ng = scopes_ng;
98@@ -54,6 +57,8 @@
99 weak_ptr<view::ResultsView> m_resultsView;
100
101 weak_ptr<view::PreviewView> m_previewView;
102+
103+ std::shared_ptr<unity::shell::scopes::PreviewStackInterface> m_previewStack;
104 };
105
106 PreviewWidget::PreviewWidget(const internal::PreviewWidgetArguments& arguments) :
107@@ -64,6 +69,7 @@
108 p->m_index = arguments.index;
109 p->m_resultsView = arguments.resultsView;
110 p->m_previewView = arguments.previewView;
111+ p->m_previewStack = arguments.previewStack;
112 }
113
114
115@@ -85,6 +91,7 @@
116 p->m_index = other.p->m_index;
117 p->m_resultsView = other.p->m_resultsView;
118 p->m_previewView = other.p->m_previewView;
119+ p->m_previewStack = other.p->m_previewStack;
120 return *this;
121 }
122
123@@ -120,9 +127,40 @@
124
125 view::AbstractView::SPtr PreviewWidget::trigger(const string& name, const sc::Variant& v)
126 {
127+ auto ps = std::dynamic_pointer_cast<ng::PreviewStack>(p->m_previewStack);
128+ TestUtils::throwIfNot(bool(ps), "No preview stack");
129+ TestUtils::throwIfNot(bool(ps->associatedScope()), "Preview stack has no associated scope");
130+ QSignalSpy showDashSpy(ps->associatedScope(), SIGNAL(showDash()));
131+
132+ QVariant widgetData;
133+
134+ if (type() == "actions" &&
135+ v.which() == sc::Variant::Dict &&
136+ v.get_dict()["actions"].which() == sc::Variant::Array)
137+ {
138+ for (auto el: v.get_dict()["actions"].get_array())
139+ {
140+ auto d = el.get_dict();
141+ if (d["id"].get_string() == name)
142+ {
143+ widgetData = ng::scopeVariantToQVariant(el);
144+ break;
145+ }
146+ }
147+ }
148+ else
149+ {
150+ widgetData = ng::scopeVariantToQVariant(v);
151+ }
152+
153 Q_EMIT p->m_previewModel->triggered(
154 QString::fromStdString(id()), QString::fromStdString(name),
155- ng::scopeVariantToQVariant(v).toMap());
156+ widgetData.toMap());
157+
158+ if (!showDashSpy.empty())
159+ {
160+ return p->m_resultsView.lock();
161+ }
162
163 TestUtils::throwIfNot(p->m_previewModel->processingAction(), "Should be processing action");
164 QSignalSpy spy(p->m_previewModel, SIGNAL(processingActionChanged()));
165
166=== modified file 'src/scope-harness/view/preview-view.cpp'
167--- src/scope-harness/view/preview-view.cpp 2015-03-10 11:23:01 +0000
168+++ src/scope-harness/view/preview-view.cpp 2015-04-27 11:28:49 +0000
169@@ -53,7 +53,7 @@
170 {
171 previewWidgets.emplace_back(
172 preview::PreviewWidget(internal::PreviewWidgetArguments
173- { previewWidgetModel, previewWidgetModel->index(row), previewModel, m_resultsView.lock(), previewView}));
174+ { previewWidgetModel, previewWidgetModel->index(row), previewModel, m_resultsView.lock(), previewView, m_previewStack}));
175 }
176
177 return preview::PreviewWidgetList(internal::PreviewWidgetListArguments{previewWidgets});
178
179=== modified file 'src/scope-harness/view/results-view.h'
180--- src/scope-harness/view/results-view.h 2015-03-10 11:23:01 +0000
181+++ src/scope-harness/view/results-view.h 2015-04-27 11:28:49 +0000
182@@ -23,6 +23,7 @@
183 #include <scope-harness/view/preview-view.h>
184 #include <scope-harness/results/category.h>
185 #include <scope-harness/results/department.h>
186+#include <scope-harness/preview/preview-widget.h>
187
188 #include <string>
189
190@@ -127,6 +128,7 @@
191
192 protected:
193 friend ScopeHarness;
194+ friend preview::PreviewWidget;
195
196 void setPreviewView(std::shared_ptr<PreviewView> previewView);
197
198
199=== modified file 'tests/data/mock-scope/mock-scope.cpp'
200--- tests/data/mock-scope/mock-scope.cpp 2015-03-04 10:10:56 +0000
201+++ tests/data/mock-scope/mock-scope.cpp 2015-04-27 11:28:49 +0000
202@@ -136,6 +136,15 @@
203 res.set_title("result for: \"" + query_ + "\"");
204 reply->push(res);
205 }
206+ else if (query_ == "query")
207+ {
208+ CategoryRenderer minimal_rndr(R"({"schema-version": 1, "components": {"title": "title"}})");
209+ auto cat = reply->register_category("cat1", "Category 1", "", minimal_rndr);
210+ CategorisedResult res(cat);
211+ res.set_uri("test:query");
212+ res.set_title("result for: \"" + query_ + "\"");
213+ reply->push(res);
214+ }
215 else if (query_ == "expandable-widget")
216 {
217 CategoryRenderer minimal_rndr(R"({"schema-version": 1, "components": {"title": "title"}})");
218@@ -317,6 +326,31 @@
219 reply->push(widgets);
220 return;
221 }
222+ else if (result().uri().find("query") != std::string::npos)
223+ {
224+ PreviewWidget w1("actions", "actions");
225+
226+ VariantBuilder builder;
227+ auto uri = CannedQuery("mock-scope").to_uri();
228+ builder.add_tuple({
229+ {"id", Variant("nothing")},
230+ {"label", Variant("Do nothing")}
231+ });
232+ builder.add_tuple({
233+ {"id", Variant("query")},
234+ {"label", Variant("Search")},
235+ {"uri", Variant(uri)}
236+ });
237+ w1.add_attribute_value("actions", builder.end());
238+
239+ ColumnLayout l1(1);
240+ l1.add_column({"actions"});
241+
242+ reply->register_layout({l1});
243+ PreviewWidgetList widgets({w1});
244+ reply->push(widgets);
245+ return;
246+ }
247 else if (result().uri().find("expandable-widget") != std::string::npos)
248 {
249 PreviewWidget w1("exp", "expandable");
250
251=== modified file 'tests/previewtest.cpp'
252--- tests/previewtest.cpp 2015-03-04 10:10:56 +0000
253+++ tests/previewtest.cpp 2015-04-27 11:28:49 +0000
254@@ -280,6 +280,32 @@
255 QVERIFY(bool(previewView2));
256 }
257
258+ void testPreviewActionRequestingSearch()
259+ {
260+ m_resultsView->setQuery("query");
261+
262+ auto abstractView = m_resultsView->category(0).result(0).longPress();
263+ QVERIFY(bool(abstractView));
264+ auto previewView = dynamic_pointer_cast<shv::PreviewView>(abstractView);
265+ QVERIFY(bool(previewView));
266+
267+ QVERIFY_MATCHRESULT(
268+ shm::PreviewColumnMatcher()
269+ .column(
270+ shm::PreviewMatcher()
271+ .widget(shm::PreviewWidgetMatcher("actions"))
272+ )
273+ .match(previewView->widgets())
274+ );
275+
276+ auto resView = previewView->widgetsInFirstColumn().at("actions").trigger("query",
277+ previewView->widgetsInFirstColumn().at("actions").data());
278+ // action with canned query uri should trigger a search
279+ auto resultsView2 = dynamic_pointer_cast<shv::ResultsView>(resView);
280+ QVERIFY(bool(resultsView2));
281+ QCOMPARE(m_resultsView, resultsView2);
282+ }
283+
284 void testPreviewReplacingPreview()
285 {
286 m_resultsView->setQuery("layout");

Subscribers

People subscribed via source and target branches

to all changes: