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
=== modified file 'po/unity-plugin-scopes.pot'
--- po/unity-plugin-scopes.pot 2015-03-04 10:10:56 +0000
+++ po/unity-plugin-scopes.pot 2015-04-27 11:28:49 +0000
@@ -8,7 +8,7 @@
8msgstr ""8msgstr ""
9"Project-Id-Version: PACKAGE VERSION\n"9"Project-Id-Version: PACKAGE VERSION\n"
10"Report-Msgid-Bugs-To: \n"10"Report-Msgid-Bugs-To: \n"
11"POT-Creation-Date: 2015-03-04 11:02+0100\n"11"POT-Creation-Date: 2015-04-27 13:27+0200\n"
12"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"12"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
13"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"13"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
14"Language-Team: LANGUAGE <LL@li.org>\n"14"Language-Team: LANGUAGE <LL@li.org>\n"
1515
=== modified file 'src/Unity/previewstack.cpp'
--- src/Unity/previewstack.cpp 2015-01-30 07:45:25 +0000
+++ src/Unity/previewstack.cpp 2015-04-27 11:28:49 +0000
@@ -84,6 +84,11 @@
84 m_userAgent = userAgent;84 m_userAgent = userAgent;
85}85}
8686
87scopes_ng::Scope* PreviewStack::associatedScope() const
88{
89 return m_associatedScope;
90}
91
87void PreviewStack::loadForResult(scopes::Result::SPtr const& result)92void PreviewStack::loadForResult(scopes::Result::SPtr const& result)
88{93{
89 m_previewedResult = result;94 m_previewedResult = result;
9095
=== modified file 'src/Unity/previewstack.h'
--- src/Unity/previewstack.h 2014-09-23 11:33:38 +0000
+++ src/Unity/previewstack.h 2015-04-27 11:28:49 +0000
@@ -61,6 +61,7 @@
61 void setWidgetColumnCount(int columnCount) override;61 void setWidgetColumnCount(int columnCount) override;
62 int widgetColumnCount() const override;62 int widgetColumnCount() const override;
63 void setAssociatedScope(scopes_ng::Scope*, QUuid const&, QString const&);63 void setAssociatedScope(scopes_ng::Scope*, QUuid const&, QString const&);
64 scopes_ng::Scope* associatedScope() const;
6465
65private Q_SLOTS:66private Q_SLOTS:
66 void widgetTriggered(QString const&, QString const&, QVariantMap const&);67 void widgetTriggered(QString const&, QString const&, QVariantMap const&);
6768
=== modified file 'src/Unity/scope.cpp'
--- src/Unity/scope.cpp 2015-03-20 14:44:32 +0000
+++ src/Unity/scope.cpp 2015-04-27 11:28:49 +0000
@@ -298,6 +298,8 @@
298 }298 }
299 if (scope != this) {299 if (scope != this) {
300 Q_EMIT gotoScope(scopeId);300 Q_EMIT gotoScope(scopeId);
301 } else {
302 Q_EMIT showDash();
301 }303 }
302 } else {304 } else {
303 // create temp dash page305 // create temp dash page
304306
=== modified file 'src/scope-harness/internal/preview-widget-arguments.h'
--- src/scope-harness/internal/preview-widget-arguments.h 2015-01-07 14:22:42 +0000
+++ src/scope-harness/internal/preview-widget-arguments.h 2015-04-27 11:28:49 +0000
@@ -31,6 +31,7 @@
31{31{
32 class PreviewWidgetModelInterface;32 class PreviewWidgetModelInterface;
33 class PreviewModelInterface;33 class PreviewModelInterface;
34 class PreviewStackInterface;
34}35}
35}36}
36namespace scopeharness37namespace scopeharness
@@ -53,6 +54,8 @@
53 std::shared_ptr<view::ResultsView> resultsView;54 std::shared_ptr<view::ResultsView> resultsView;
5455
55 std::shared_ptr<view::PreviewView> previewView;56 std::shared_ptr<view::PreviewView> previewView;
57
58 std::shared_ptr<unity::shell::scopes::PreviewStackInterface> previewStack;
56};59};
57}60}
58}61}
5962
=== modified file 'src/scope-harness/preview/preview-widget.cpp'
--- src/scope-harness/preview/preview-widget.cpp 2015-03-10 11:23:01 +0000
+++ src/scope-harness/preview/preview-widget.cpp 2015-04-27 11:28:49 +0000
@@ -20,15 +20,18 @@
20#include <scope-harness/preview/preview-widget.h>20#include <scope-harness/preview/preview-widget.h>
21#include <scope-harness/view/abstract-view.h>21#include <scope-harness/view/abstract-view.h>
22#include <scope-harness/view/preview-view.h>22#include <scope-harness/view/preview-view.h>
23#include <scope-harness/view/results-view.h>
23#include <scope-harness/test-utils.h>24#include <scope-harness/test-utils.h>
2425
25#include <unity/shell/scopes/PreviewModelInterface.h>26#include <unity/shell/scopes/PreviewModelInterface.h>
26#include <unity/shell/scopes/PreviewWidgetModelInterface.h>27#include <unity/shell/scopes/PreviewWidgetModelInterface.h>
2728
28#include <Unity/utils.h>29#include <Unity/utils.h>
30#include <Unity/previewstack.h>
2931
30#include <QDebug>32#include <QDebug>
31#include <QSignalSpy>33#include <QSignalSpy>
34#include <memory>
3235
33using namespace std;36using namespace std;
34namespace ng = scopes_ng;37namespace ng = scopes_ng;
@@ -54,6 +57,8 @@
54 weak_ptr<view::ResultsView> m_resultsView;57 weak_ptr<view::ResultsView> m_resultsView;
5558
56 weak_ptr<view::PreviewView> m_previewView;59 weak_ptr<view::PreviewView> m_previewView;
60
61 std::shared_ptr<unity::shell::scopes::PreviewStackInterface> m_previewStack;
57};62};
5863
59PreviewWidget::PreviewWidget(const internal::PreviewWidgetArguments& arguments) :64PreviewWidget::PreviewWidget(const internal::PreviewWidgetArguments& arguments) :
@@ -64,6 +69,7 @@
64 p->m_index = arguments.index;69 p->m_index = arguments.index;
65 p->m_resultsView = arguments.resultsView;70 p->m_resultsView = arguments.resultsView;
66 p->m_previewView = arguments.previewView;71 p->m_previewView = arguments.previewView;
72 p->m_previewStack = arguments.previewStack;
67}73}
6874
6975
@@ -85,6 +91,7 @@
85 p->m_index = other.p->m_index;91 p->m_index = other.p->m_index;
86 p->m_resultsView = other.p->m_resultsView;92 p->m_resultsView = other.p->m_resultsView;
87 p->m_previewView = other.p->m_previewView;93 p->m_previewView = other.p->m_previewView;
94 p->m_previewStack = other.p->m_previewStack;
88 return *this;95 return *this;
89}96}
9097
@@ -120,9 +127,40 @@
120127
121view::AbstractView::SPtr PreviewWidget::trigger(const string& name, const sc::Variant& v)128view::AbstractView::SPtr PreviewWidget::trigger(const string& name, const sc::Variant& v)
122{129{
130 auto ps = std::dynamic_pointer_cast<ng::PreviewStack>(p->m_previewStack);
131 TestUtils::throwIfNot(bool(ps), "No preview stack");
132 TestUtils::throwIfNot(bool(ps->associatedScope()), "Preview stack has no associated scope");
133 QSignalSpy showDashSpy(ps->associatedScope(), SIGNAL(showDash()));
134
135 QVariant widgetData;
136
137 if (type() == "actions" &&
138 v.which() == sc::Variant::Dict &&
139 v.get_dict()["actions"].which() == sc::Variant::Array)
140 {
141 for (auto el: v.get_dict()["actions"].get_array())
142 {
143 auto d = el.get_dict();
144 if (d["id"].get_string() == name)
145 {
146 widgetData = ng::scopeVariantToQVariant(el);
147 break;
148 }
149 }
150 }
151 else
152 {
153 widgetData = ng::scopeVariantToQVariant(v);
154 }
155
123 Q_EMIT p->m_previewModel->triggered(156 Q_EMIT p->m_previewModel->triggered(
124 QString::fromStdString(id()), QString::fromStdString(name),157 QString::fromStdString(id()), QString::fromStdString(name),
125 ng::scopeVariantToQVariant(v).toMap());158 widgetData.toMap());
159
160 if (!showDashSpy.empty())
161 {
162 return p->m_resultsView.lock();
163 }
126164
127 TestUtils::throwIfNot(p->m_previewModel->processingAction(), "Should be processing action");165 TestUtils::throwIfNot(p->m_previewModel->processingAction(), "Should be processing action");
128 QSignalSpy spy(p->m_previewModel, SIGNAL(processingActionChanged()));166 QSignalSpy spy(p->m_previewModel, SIGNAL(processingActionChanged()));
129167
=== modified file 'src/scope-harness/view/preview-view.cpp'
--- src/scope-harness/view/preview-view.cpp 2015-03-10 11:23:01 +0000
+++ src/scope-harness/view/preview-view.cpp 2015-04-27 11:28:49 +0000
@@ -53,7 +53,7 @@
53 {53 {
54 previewWidgets.emplace_back(54 previewWidgets.emplace_back(
55 preview::PreviewWidget(internal::PreviewWidgetArguments55 preview::PreviewWidget(internal::PreviewWidgetArguments
56 { previewWidgetModel, previewWidgetModel->index(row), previewModel, m_resultsView.lock(), previewView}));56 { previewWidgetModel, previewWidgetModel->index(row), previewModel, m_resultsView.lock(), previewView, m_previewStack}));
57 }57 }
5858
59 return preview::PreviewWidgetList(internal::PreviewWidgetListArguments{previewWidgets});59 return preview::PreviewWidgetList(internal::PreviewWidgetListArguments{previewWidgets});
6060
=== modified file 'src/scope-harness/view/results-view.h'
--- src/scope-harness/view/results-view.h 2015-03-10 11:23:01 +0000
+++ src/scope-harness/view/results-view.h 2015-04-27 11:28:49 +0000
@@ -23,6 +23,7 @@
23#include <scope-harness/view/preview-view.h>23#include <scope-harness/view/preview-view.h>
24#include <scope-harness/results/category.h>24#include <scope-harness/results/category.h>
25#include <scope-harness/results/department.h>25#include <scope-harness/results/department.h>
26#include <scope-harness/preview/preview-widget.h>
2627
27#include <string>28#include <string>
2829
@@ -127,6 +128,7 @@
127128
128protected:129protected:
129 friend ScopeHarness;130 friend ScopeHarness;
131 friend preview::PreviewWidget;
130132
131 void setPreviewView(std::shared_ptr<PreviewView> previewView);133 void setPreviewView(std::shared_ptr<PreviewView> previewView);
132134
133135
=== modified file 'tests/data/mock-scope/mock-scope.cpp'
--- tests/data/mock-scope/mock-scope.cpp 2015-03-04 10:10:56 +0000
+++ tests/data/mock-scope/mock-scope.cpp 2015-04-27 11:28:49 +0000
@@ -136,6 +136,15 @@
136 res.set_title("result for: \"" + query_ + "\"");136 res.set_title("result for: \"" + query_ + "\"");
137 reply->push(res);137 reply->push(res);
138 }138 }
139 else if (query_ == "query")
140 {
141 CategoryRenderer minimal_rndr(R"({"schema-version": 1, "components": {"title": "title"}})");
142 auto cat = reply->register_category("cat1", "Category 1", "", minimal_rndr);
143 CategorisedResult res(cat);
144 res.set_uri("test:query");
145 res.set_title("result for: \"" + query_ + "\"");
146 reply->push(res);
147 }
139 else if (query_ == "expandable-widget")148 else if (query_ == "expandable-widget")
140 {149 {
141 CategoryRenderer minimal_rndr(R"({"schema-version": 1, "components": {"title": "title"}})");150 CategoryRenderer minimal_rndr(R"({"schema-version": 1, "components": {"title": "title"}})");
@@ -317,6 +326,31 @@
317 reply->push(widgets);326 reply->push(widgets);
318 return;327 return;
319 }328 }
329 else if (result().uri().find("query") != std::string::npos)
330 {
331 PreviewWidget w1("actions", "actions");
332
333 VariantBuilder builder;
334 auto uri = CannedQuery("mock-scope").to_uri();
335 builder.add_tuple({
336 {"id", Variant("nothing")},
337 {"label", Variant("Do nothing")}
338 });
339 builder.add_tuple({
340 {"id", Variant("query")},
341 {"label", Variant("Search")},
342 {"uri", Variant(uri)}
343 });
344 w1.add_attribute_value("actions", builder.end());
345
346 ColumnLayout l1(1);
347 l1.add_column({"actions"});
348
349 reply->register_layout({l1});
350 PreviewWidgetList widgets({w1});
351 reply->push(widgets);
352 return;
353 }
320 else if (result().uri().find("expandable-widget") != std::string::npos)354 else if (result().uri().find("expandable-widget") != std::string::npos)
321 {355 {
322 PreviewWidget w1("exp", "expandable");356 PreviewWidget w1("exp", "expandable");
323357
=== modified file 'tests/previewtest.cpp'
--- tests/previewtest.cpp 2015-03-04 10:10:56 +0000
+++ tests/previewtest.cpp 2015-04-27 11:28:49 +0000
@@ -280,6 +280,32 @@
280 QVERIFY(bool(previewView2));280 QVERIFY(bool(previewView2));
281 }281 }
282282
283 void testPreviewActionRequestingSearch()
284 {
285 m_resultsView->setQuery("query");
286
287 auto abstractView = m_resultsView->category(0).result(0).longPress();
288 QVERIFY(bool(abstractView));
289 auto previewView = dynamic_pointer_cast<shv::PreviewView>(abstractView);
290 QVERIFY(bool(previewView));
291
292 QVERIFY_MATCHRESULT(
293 shm::PreviewColumnMatcher()
294 .column(
295 shm::PreviewMatcher()
296 .widget(shm::PreviewWidgetMatcher("actions"))
297 )
298 .match(previewView->widgets())
299 );
300
301 auto resView = previewView->widgetsInFirstColumn().at("actions").trigger("query",
302 previewView->widgetsInFirstColumn().at("actions").data());
303 // action with canned query uri should trigger a search
304 auto resultsView2 = dynamic_pointer_cast<shv::ResultsView>(resView);
305 QVERIFY(bool(resultsView2));
306 QCOMPARE(m_resultsView, resultsView2);
307 }
308
283 void testPreviewReplacingPreview()309 void testPreviewReplacingPreview()
284 {310 {
285 m_resultsView->setQuery("layout");311 m_resultsView->setQuery("layout");

Subscribers

People subscribed via source and target branches

to all changes: