Merge lp:~townsend/libertine-scope/release-1.3.2 into lp:libertine-scope/release

Proposed by Christopher Townsend
Status: Merged
Approved by: Larry Price
Approved revision: 56
Merged at revision: 57
Proposed branch: lp:~townsend/libertine-scope/release-1.3.2
Merge into: lp:libertine-scope/release
Diff against target: 494 lines (+203/-57)
15 files modified
CMakeLists.txt (+1/-1)
debian/changelog (+11/-0)
scope/apps/action.cpp (+26/-15)
scope/apps/action.h (+21/-15)
scope/apps/config.h.in (+1/-3)
scope/apps/libertine.cpp (+1/-2)
scope/apps/libertine.h (+1/-1)
scope/apps/query.cpp (+7/-5)
scope/apps/query.h (+2/-2)
scope/apps/scope.cpp (+14/-1)
scope/apps/scope.h (+1/-0)
tests/CMakeLists.txt (+2/-0)
tests/mock_hidden_apps.h (+32/-0)
tests/test_action.cpp (+82/-0)
tests/test_query.cpp (+1/-12)
To merge this branch: bzr merge lp:~townsend/libertine-scope/release-1.3.2
Reviewer Review Type Date Requested Status
Larry Price Approve
Libertine CI Bot continuous-integration Pending
Review via email: mp+301524@code.launchpad.net

This proposal supersedes a proposal from 2016-07-29.

Commit message

* Use full scope name in canned queries to properly return from Show/Hide actions.
* Initialize libertine object in Query::run() to allow constructor to execute in time. (LP: #1595944)
* Showing/hiding applications should retain filter state. (LP: #1592407)

To post a comment you must log in.
Revision history for this message
Libertine CI Bot (libertine-ci-bot) wrote : Posted in a previous version of this proposal

PASSED: Continuous integration, rev:56
https://jenkins.canonical.com/libertine/job/lp-libertine-scope-ci/63/
Executed test runs:
    SUCCESS: https://jenkins.canonical.com/libertine/job/build/224
    SUCCESS: https://jenkins.canonical.com/libertine/job/test-0-autopkgtest/label=amd64,release=vivid+overlay,testname=default/182
    SUCCESS: https://jenkins.canonical.com/libertine/job/test-0-autopkgtest/label=amd64,release=xenial+overlay,testname=default/182
    SUCCESS: https://jenkins.canonical.com/libertine/job/test-0-autopkgtest/label=amd64,release=yakkety,testname=default/182
    SUCCESS: https://jenkins.canonical.com/libertine/job/test-0-autopkgtest/label=i386,release=vivid+overlay,testname=default/182
    SUCCESS: https://jenkins.canonical.com/libertine/job/test-0-autopkgtest/label=i386,release=xenial+overlay,testname=default/182
    SUCCESS: https://jenkins.canonical.com/libertine/job/test-0-autopkgtest/label=i386,release=yakkety,testname=default/182
    None: https://jenkins.canonical.com/libertine/job/lp-generic-update-mp/170/console
    SUCCESS: https://jenkins.canonical.com/libertine/job/build-0-fetch/227
    SUCCESS: https://jenkins.canonical.com/libertine/job/build-1-sourcepkg/release=vivid+overlay/212
    SUCCESS: https://jenkins.canonical.com/libertine/job/build-1-sourcepkg/release=xenial+overlay/212
    SUCCESS: https://jenkins.canonical.com/libertine/job/build-1-sourcepkg/release=yakkety/212
    SUCCESS: https://jenkins.canonical.com/libertine/job/build-2-binpkg/arch=amd64,release=vivid+overlay/205
        deb: https://jenkins.canonical.com/libertine/job/build-2-binpkg/arch=amd64,release=vivid+overlay/205/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/libertine/job/build-2-binpkg/arch=amd64,release=xenial+overlay/205
        deb: https://jenkins.canonical.com/libertine/job/build-2-binpkg/arch=amd64,release=xenial+overlay/205/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/libertine/job/build-2-binpkg/arch=amd64,release=yakkety/205
        deb: https://jenkins.canonical.com/libertine/job/build-2-binpkg/arch=amd64,release=yakkety/205/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/libertine/job/build-2-binpkg/arch=i386,release=vivid+overlay/205
        deb: https://jenkins.canonical.com/libertine/job/build-2-binpkg/arch=i386,release=vivid+overlay/205/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/libertine/job/build-2-binpkg/arch=i386,release=xenial+overlay/205
        deb: https://jenkins.canonical.com/libertine/job/build-2-binpkg/arch=i386,release=xenial+overlay/205/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/libertine/job/build-2-binpkg/arch=i386,release=yakkety/205
        deb: https://jenkins.canonical.com/libertine/job/build-2-binpkg/arch=i386,release=yakkety/205/artifact/output/*zip*/output.zip

Click here to trigger a rebuild:
https://jenkins.canonical.com/libertine/job/lp-libertine-scope-ci/63/rebuild

review: Approve (continuous-integration)
Revision history for this message
Larry Price (larryprice) wrote :

lgtm

review: Approve
57. By Christopher Townsend

Change version to 1.3.2.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'CMakeLists.txt'
--- CMakeLists.txt 2016-07-21 16:07:09 +0000
+++ CMakeLists.txt 2016-08-01 13:24:59 +0000
@@ -2,7 +2,7 @@
2cmake_policy(SET CMP0048 NEW)2cmake_policy(SET CMP0048 NEW)
33
4project(libertine-scope4project(libertine-scope
5 VERSION 1.3.15 VERSION 1.3.2
6 LANGUAGES CXX)6 LANGUAGES CXX)
77
8# We require at least g++ 4.9, to avoid ABI breakage with earlier versions.8# We require at least g++ 4.9, to avoid ABI breakage with earlier versions.
99
=== modified file 'debian/changelog'
--- debian/changelog 2016-07-22 13:48:17 +0000
+++ debian/changelog 2016-08-01 13:24:59 +0000
@@ -1,3 +1,14 @@
1libertine-scope (1.3.2-0ubuntu1) UNRELEASED; urgency=medium
2
3 [ Larry Price ]
4 * Use full scope name in canned queries to properly return from Show/Hide
5 actions.
6 * Initialize libertine object in Query::run() to allow constructor to execute
7 in time. (LP: #1595944)
8 * Showing/hiding applications should retain filter state. (LP: #1592407)
9
10 -- Chris Townsend <christopher.townsend@canonical.com> Fri, 29 Jul 2016 12:35:35 -0400
11
1libertine-scope (1.3.1+16.10.20160722-0ubuntu1) yakkety; urgency=medium12libertine-scope (1.3.1+16.10.20160722-0ubuntu1) yakkety; urgency=medium
213
3 [ Chris Townsend ]14 [ Chris Townsend ]
415
=== modified file 'scope/apps/action.cpp'
--- scope/apps/action.cpp 2016-07-19 20:20:12 +0000
+++ scope/apps/action.cpp 2016-08-01 13:24:59 +0000
@@ -29,14 +29,30 @@
29namespace usc = unity::scopes;29namespace usc = unity::scopes;
3030
3131
32namespace
33{
34static usc::ActivationResponse
35sendToResults(usc::FilterState const& filter_state)
36{
37 usc::CannedQuery query(FULLY_QUALIFIED_APPS_SCOPE);
38 query.set_filter_state(filter_state);
39 return usc::ActivationResponse(query);
40}
41}
42
43
32Action::44Action::
33Action(usc::Result const& result,45Action(unity::scopes::Result const& result,
34 usc::ActionMetadata const& metadata,46 unity::scopes::ActionMetadata const& metadata,
35 std::string const& action_id, 47 std::string const& action_id,
36 std::shared_ptr<HiddenApps> hidden)48 Action::OpenUriAction open_action,
37 : usc::ActivationQueryBase(result, metadata),49 std::shared_ptr<HiddenApps> hidden,
38 action_id_(action_id),50 unity::scopes::FilterState const& filter_state)
39 hidden_(hidden)51 : usc::ActivationQueryBase(result, metadata)
52 , action_id_(action_id)
53 , open_action_(open_action)
54 , hidden_(hidden)
55 , filter_state_(filter_state)
40{56{
41}57}
4258
@@ -46,22 +62,17 @@
46{62{
47 if (action_id_ == "open")63 if (action_id_ == "open")
48 {64 {
49 url_dispatch_send(result().uri().c_str() , NULL, NULL);65 open_action_(result().uri());
50 return usc::ActivationResponse(usc::ActivationResponse::Status::NotHandled);
51 }66 }
52 else if (action_id_ == "hide")67 else if (action_id_ == "hide")
53 {68 {
54 hidden_->add(QString::fromStdString(result()["app_id"].get_string()));69 hidden_->add(QString::fromStdString(result()["app_id"].get_string()));
5570 return sendToResults(filter_state_);
56 usc::CannedQuery cq(SCOPE_PKG);
57 return usc::ActivationResponse(cq);
58 }71 }
59 else if (action_id_ == "show")72 else if (action_id_ == "show")
60 {73 {
61 hidden_->remove(QString::fromStdString(result()["app_id"].get_string()));74 hidden_->remove(QString::fromStdString(result()["app_id"].get_string()));
6275 return sendToResults(filter_state_);
63 usc::CannedQuery cq(SCOPE_PKG);
64 return usc::ActivationResponse(cq);
65 }76 }
66 return usc::ActivationResponse(usc::ActivationResponse::Status::NotHandled);77 return usc::ActivationResponse(usc::ActivationResponse::Status::NotHandled);
67}78}
6879
=== modified file 'scope/apps/action.h'
--- scope/apps/action.h 2016-07-12 18:26:07 +0000
+++ scope/apps/action.h 2016-08-01 13:24:59 +0000
@@ -15,31 +15,37 @@
15 * * Authored by:15 * * Authored by:
16 * Kyle Nitzsche <kyle.nitzsche@canonical.com>16 * Kyle Nitzsche <kyle.nitzsche@canonical.com>
17 */17 */
18
19#ifndef SCOPE_ACTION_H_18#ifndef SCOPE_ACTION_H_
20#define SCOPE_ACTION_H_19#define SCOPE_ACTION_H_
2120
22#include "scope/apps/scope.h"21
23#include <unity/scopes/ActionMetadata.h>22#include <unity/scopes/ActionMetadata.h>
24#include <unity/scopes/ActivationQueryBase.h>23#include <unity/scopes/ActivationQueryBase.h>
25#include <unity/scopes/ActivationResponse.h>24#include <unity/scopes/ActivationResponse.h>
26#include <unity/scopes/Result.h>25#include <unity/scopes/Result.h>
2726
27
28class HiddenApps;28class HiddenApps;
2929
30class Action : public unity::scopes::ActivationQueryBase {30class Action : public unity::scopes::ActivationQueryBase {
31 public:31public:
32 Action(unity::scopes::Result const& result,32 typedef std::function<void(std::string const&)> OpenUriAction;
33 unity::scopes::ActionMetadata const& metadata,33
34 std::string const& action_id, 34 explicit Action(unity::scopes::Result const& result,
35 std::shared_ptr<HiddenApps> hidden);35 unity::scopes::ActionMetadata const& metadata,
3636 std::string const& action_id,
37 virtual ~Action() = default;37 OpenUriAction open_action,
38 virtual unity::scopes::ActivationResponse activate() override;38 std::shared_ptr<HiddenApps> hidden,
3939 unity::scopes::FilterState const& filterState);
40 private:40
41 std::string action_id_;41 virtual ~Action() = default;
42 std::string cache_dir_;42 virtual unity::scopes::ActivationResponse activate() override;
43 std::shared_ptr<HiddenApps> hidden_;43
44private:
45 std::string action_id_;
46 std::string cache_dir_;
47 OpenUriAction open_action_;
48 std::shared_ptr<HiddenApps> hidden_;
49 unity::scopes::FilterState filter_state_;
44};50};
45#endif51#endif
4652
=== modified file 'scope/apps/config.h.in'
--- scope/apps/config.h.in 2016-07-19 20:20:12 +0000
+++ scope/apps/config.h.in 2016-08-01 13:24:59 +0000
@@ -16,10 +16,8 @@
16#ifndef LIBERTINE_SCOPE_CONFIG_H_16#ifndef LIBERTINE_SCOPE_CONFIG_H_
17#define LIBERTINE_SCOPE_CONFIG_H_17#define LIBERTINE_SCOPE_CONFIG_H_
1818
19const std::string SCOPE_PKG = "@PACKAGE_NAME@";19const std::string FULLY_QUALIFIED_APPS_SCOPE = "@FULLY_QUALIFIED_NAME@";
20const std::string ROOT_DEPT_ID = "root_dept";20const std::string ROOT_DEPT_ID = "root_dept";
21const std::string HIDDEN_DEPT_ID = "hidden_dept";21const std::string HIDDEN_DEPT_ID = "hidden_dept";
2222
23#endif // LIBERTINE_SCOPE_CONFIG_H_23#endif // LIBERTINE_SCOPE_CONFIG_H_
24
25
2624
=== modified file 'scope/apps/libertine.cpp'
--- scope/apps/libertine.cpp 2016-07-12 18:26:07 +0000
+++ scope/apps/libertine.cpp 2016-08-01 13:24:59 +0000
@@ -91,6 +91,5 @@
91Libertine::UPtr Libertine::91Libertine::UPtr Libertine::
92from_libertine_cli()92from_libertine_cli()
93{93{
94 return Libertine::UPtr(new LibertineCli());94 return std::make_shared<LibertineCli>();
95}95}
96
9796
=== modified file 'scope/apps/libertine.h'
--- scope/apps/libertine.h 2016-01-13 00:38:37 +0000
+++ scope/apps/libertine.h 2016-08-01 13:24:59 +0000
@@ -29,7 +29,7 @@
29class Libertine29class Libertine
30{30{
31public:31public:
32 using UPtr = std::unique_ptr<Libertine>;32 using UPtr = std::shared_ptr<Libertine>;
33 using ContainerList = std::vector<std::unique_ptr<Container>>;33 using ContainerList = std::vector<std::unique_ptr<Container>>;
3434
35 /**35 /**
3636
=== modified file 'scope/apps/query.cpp'
--- scope/apps/query.cpp 2016-07-19 13:57:43 +0000
+++ scope/apps/query.cpp 2016-08-01 13:24:59 +0000
@@ -121,7 +121,7 @@
121 std::shared_ptr<HiddenApps> hidden,121 std::shared_ptr<HiddenApps> hidden,
122 std::shared_ptr<Blacklist> blacklist)122 std::shared_ptr<Blacklist> blacklist)
123 : usc::SearchQueryBase(query, metadata)123 : usc::SearchQueryBase(query, metadata)
124 , libertine_(libertine_factory())124 , libertine_factory_(libertine_factory)
125 , hidden_(hidden)125 , hidden_(hidden)
126 , blacklist_(blacklist)126 , blacklist_(blacklist)
127{127{
@@ -135,14 +135,14 @@
135135
136136
137QStringList Query::137QStringList Query::
138make_filters(usc::SearchReplyProxy const& reply) const138make_filters(usc::SearchReplyProxy const& reply, Libertine::UPtr libertine) const
139{139{
140 auto filter_state = query().filter_state();140 auto filter_state = query().filter_state();
141 QStringList excludes_by_filter;141 QStringList excludes_by_filter;
142 std::list<usc::FilterBase::SCPtr> app_filters;142 std::list<usc::FilterBase::SCPtr> app_filters;
143143
144 //make exclude scope filter for apps144 //make exclude scope filter for apps
145 for (auto const& container: libertine_->get_container_list())145 for (auto const& container: libertine->get_container_list())
146 {146 {
147 usc::OptionSelectorFilter::SPtr filter{usc::OptionSelectorFilter::create(container->id(),147 usc::OptionSelectorFilter::SPtr filter{usc::OptionSelectorFilter::create(container->id(),
148 EXCLUDED_APPS_FILTER_TITLE + container->name(),148 EXCLUDED_APPS_FILTER_TITLE + container->name(),
@@ -208,18 +208,20 @@
208 register_departments(reply);208 register_departments(reply);
209 }209 }
210210
211 auto libertine = libertine_factory_();
212
211 // only provide filters in root department213 // only provide filters in root department
212 QStringList excludes_by_filter;214 QStringList excludes_by_filter;
213 if (query().department_id().empty())215 if (query().department_id().empty())
214 {216 {
215 excludes_by_filter = make_filters(reply);217 excludes_by_filter = make_filters(reply, libertine);
216 }218 }
217219
218 QRegExp search_query(QString::fromStdString(query().query_string()), Qt::CaseInsensitive);220 QRegExp search_query(QString::fromStdString(query().query_string()), Qt::CaseInsensitive);
219 bool has_no_apps = true,221 bool has_no_apps = true,
220 all_filtered = true;222 all_filtered = true;
221223
222 for (auto const& container: libertine_->get_container_list())224 for (auto const& container: libertine->get_container_list())
223 {225 {
224 auto category = reply->register_category(container->id(),226 auto category = reply->register_category(container->id(),
225 container->name(),227 container->name(),
226228
=== modified file 'scope/apps/query.h'
--- scope/apps/query.h 2016-07-12 18:26:07 +0000
+++ scope/apps/query.h 2016-08-01 13:24:59 +0000
@@ -50,11 +50,11 @@
5050
51private:51private:
52 QStringList get_hidden_department() const;52 QStringList get_hidden_department() const;
53 QStringList make_filters(unity::scopes::SearchReplyProxy const& reply) const;53 QStringList make_filters(unity::scopes::SearchReplyProxy const& reply, Libertine::UPtr libertine) const;
54 void show_hint(unity::scopes::SearchReplyProxy const& reply, std::string const& reason) const;54 void show_hint(unity::scopes::SearchReplyProxy const& reply, std::string const& reason) const;
55 void parse_blacklist(const std::string& data_dir);55 void parse_blacklist(const std::string& data_dir);
5656
57 Libertine::UPtr libertine_;57 Libertine::Factory libertine_factory_;
58 std::shared_ptr<HiddenApps> hidden_;58 std::shared_ptr<HiddenApps> hidden_;
59 std::shared_ptr<Blacklist> blacklist_;59 std::shared_ptr<Blacklist> blacklist_;
60};60};
6161
=== modified file 'scope/apps/scope.cpp'
--- scope/apps/scope.cpp 2016-07-12 18:26:07 +0000
+++ scope/apps/scope.cpp 2016-08-01 13:24:59 +0000
@@ -29,6 +29,16 @@
29namespace usc = unity::scopes;29namespace usc = unity::scopes;
3030
3131
32namespace
33{
34static void
35open_application(std::string const& app_uri)
36{
37 url_dispatch_send(app_uri.c_str(), NULL, NULL);
38}
39}
40
41
32Scope::42Scope::
33Scope(Libertine::Factory const& libertine_factory)43Scope(Libertine::Factory const& libertine_factory)
34: libertine_factory_(libertine_factory)44: libertine_factory_(libertine_factory)
@@ -56,6 +66,7 @@
56search(usc::CannedQuery const& query,66search(usc::CannedQuery const& query,
57 usc::SearchMetadata const& metadata)67 usc::SearchMetadata const& metadata)
58{68{
69 filter_state_ = query.filter_state();
59 return usc::SearchQueryBase::UPtr(new Query(query,70 return usc::SearchQueryBase::UPtr(new Query(query,
60 metadata,71 metadata,
61 libertine_factory_,72 libertine_factory_,
@@ -81,7 +92,9 @@
81 return usc::ActivationQueryBase::UPtr(new Action(result,92 return usc::ActivationQueryBase::UPtr(new Action(result,
82 metadata,93 metadata,
83 action_id,94 action_id,
84 std::make_shared<HiddenApps>(cache_directory())));95 open_application,
96 std::make_shared<HiddenApps>(cache_directory()),
97 filter_state_));
85}98}
8699
87100
88101
=== modified file 'scope/apps/scope.h'
--- scope/apps/scope.h 2016-07-12 18:26:07 +0000
+++ scope/apps/scope.h 2016-08-01 13:24:59 +0000
@@ -78,6 +78,7 @@
7878
79private:79private:
80 Libertine::Factory libertine_factory_;80 Libertine::Factory libertine_factory_;
81 unity::scopes::FilterState filter_state_;
81};82};
8283
83#endif // LIBERTINE_SCOPE_SCOPE_H_84#endif // LIBERTINE_SCOPE_SCOPE_H_
8485
=== modified file 'tests/CMakeLists.txt'
--- tests/CMakeLists.txt 2016-07-12 18:26:07 +0000
+++ tests/CMakeLists.txt 2016-08-01 13:24:59 +0000
@@ -7,6 +7,7 @@
7 add_executable(${test_name}_exe7 add_executable(${test_name}_exe
8 fake_container.cpp8 fake_container.cpp
9 fake_libertine.cpp9 fake_libertine.cpp
10 mock_hidden_apps.h
10 ${test_name}.cpp11 ${test_name}.cpp
11 )12 )
1213
@@ -25,5 +26,6 @@
25create_test(test_query)26create_test(test_query)
26create_test(test_hidden_apps)27create_test(test_hidden_apps)
27create_test(test_blacklist)28create_test(test_blacklist)
29create_test(test_action)
2830
29file(COPY data DESTINATION ${CMAKE_CURRENT_BINARY_DIR})31file(COPY data DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
3032
=== added file 'tests/mock_hidden_apps.h'
--- tests/mock_hidden_apps.h 1970-01-01 00:00:00 +0000
+++ tests/mock_hidden_apps.h 2016-08-01 13:24:59 +0000
@@ -0,0 +1,32 @@
1/*
2 * Copyright 2016 Canonical Ltd.
3 *
4 * This program is free software: you can redistribute it and/or modify it under
5 * the terms of the GNU General Public License, version 3, as published by the
6 * Free Software Foundation.
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#include "scope/apps/hidden_apps.h"
17#include <gmock/gmock.h>
18
19
20class MockHiddenApps : public HiddenApps
21{
22public:
23 MockHiddenApps()
24 : HiddenApps("")
25 {
26 }
27
28 MOCK_CONST_METHOD1(app_is_hidden, bool(QString const&));
29 MOCK_CONST_METHOD0(empty, bool());
30 MOCK_METHOD1(remove, void(QString const&));
31 MOCK_METHOD1(add, void(QString const&));
32};
033
=== added file 'tests/test_action.cpp'
--- tests/test_action.cpp 1970-01-01 00:00:00 +0000
+++ tests/test_action.cpp 2016-08-01 13:24:59 +0000
@@ -0,0 +1,82 @@
1/*
2 * Copyright 2016 Canonical Ltd.
3 *
4 * This program is free software: you can redistribute it and/or modify it under
5 * the terms of the GNU General Public License, version 3, as published by the
6 * Free Software Foundation.
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#include "scope/apps/action.h"
17#include "tests/mock_hidden_apps.h"
18
19#include <unity/scopes/ActionMetadata.h>
20#include <unity/scopes/testing/Result.h>
21#include <gmock/gmock.h>
22
23
24namespace
25{
26TEST(ActionTest, OpenSendsDispatchURI)
27{
28 unity::scopes::testing::Result result;
29 result.set_uri("app://this/is/my/app");
30 unity::scopes::ActionMetadata metadata("en_US", "phone");
31 auto hidden = std::make_shared<testing::NiceMock<MockHiddenApps> >();
32 unity::scopes::FilterState filter_state;
33
34 std::string uri;
35
36 Action action(result, metadata, "open", [&](std::string const& app_uri) {
37 uri = app_uri;
38 }, hidden, filter_state);
39
40 auto response = action.activate();
41 EXPECT_EQ(unity::scopes::ActivationResponse::Status::NotHandled, response.status());
42 EXPECT_EQ(result.uri(), uri);
43}
44
45
46TEST(ActionTest, ShowRemovesAppFromHidden)
47{
48 unity::scopes::testing::Result result;
49 unity::scopes::ActionMetadata metadata("en_US", "phone");
50 unity::scopes::FilterState filter_state;
51 auto hidden = std::make_shared<testing::NiceMock<MockHiddenApps> >();
52
53 QString app_id = "something.desktop";
54 result["app_id"] = app_id.toStdString();
55 EXPECT_CALL(*hidden, remove(app_id));
56
57 Action action(result, metadata, "show", Action::OpenUriAction{}, hidden, filter_state);
58
59 auto response = action.activate();
60 EXPECT_EQ(filter_state.serialize(), response.query().filter_state().serialize());
61 EXPECT_EQ(unity::scopes::ActivationResponse::Status::PerformQuery, response.status());
62}
63
64
65TEST(ActionTest, HideAddsAppToHidden)
66{
67 unity::scopes::testing::Result result;
68 unity::scopes::ActionMetadata metadata("en_US", "phone");
69 unity::scopes::FilterState filter_state;
70 auto hidden = std::make_shared<testing::NiceMock<MockHiddenApps> >();
71
72 QString app_id = "something.desktop";
73 result["app_id"] = app_id.toStdString();
74 EXPECT_CALL(*hidden, add(app_id));
75
76 Action action(result, metadata, "hide", Action::OpenUriAction{}, hidden, filter_state);
77
78 auto response = action.activate();
79 EXPECT_EQ(filter_state.serialize(), response.query().filter_state().serialize());
80 EXPECT_EQ(unity::scopes::ActivationResponse::Status::PerformQuery, response.status());
81}
82}
083
=== modified file 'tests/test_query.cpp'
--- tests/test_query.cpp 2016-07-12 18:26:07 +0000
+++ tests/test_query.cpp 2016-08-01 13:24:59 +0000
@@ -17,6 +17,7 @@
17#include "scope/apps/query.h"17#include "scope/apps/query.h"
18#include "scope/apps/config.h"18#include "scope/apps/config.h"
19#include "tests/fake_libertine.h"19#include "tests/fake_libertine.h"
20#include "tests/mock_hidden_apps.h"
20#include <unity/scopes/SearchMetadata.h>21#include <unity/scopes/SearchMetadata.h>
21#include <unity/scopes/CannedQuery.h>22#include <unity/scopes/CannedQuery.h>
22#include <unity/scopes/SearchReplyProxyFwd.h>23#include <unity/scopes/SearchReplyProxyFwd.h>
@@ -67,18 +68,6 @@
67};68};
6869
6970
70class MockHiddenApps : public HiddenApps
71{
72public:
73 MockHiddenApps()
74 : HiddenApps("")
75 {
76 }
77
78 MOCK_CONST_METHOD1(app_is_hidden, bool(QString const&));
79 MOCK_CONST_METHOD0(empty, bool());
80};
81
82class MockBlacklist : public Blacklist71class MockBlacklist : public Blacklist
83{72{
84public:73public:

Subscribers

People subscribed via source and target branches