Merge lp:~townsend/libertine-scope/release-1.3.2 into lp:libertine-scope/release
- release-1.3.2
- Merge into 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 | ||||||||
Related bugs: |
|
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.
Description of the change
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 | # |
review:
Approve
(continuous-integration)
- 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
1 | === modified file 'CMakeLists.txt' | |||
2 | --- CMakeLists.txt 2016-07-21 16:07:09 +0000 | |||
3 | +++ CMakeLists.txt 2016-08-01 13:24:59 +0000 | |||
4 | @@ -2,7 +2,7 @@ | |||
5 | 2 | cmake_policy(SET CMP0048 NEW) | 2 | cmake_policy(SET CMP0048 NEW) |
6 | 3 | 3 | ||
7 | 4 | project(libertine-scope | 4 | project(libertine-scope |
9 | 5 | VERSION 1.3.1 | 5 | VERSION 1.3.2 |
10 | 6 | LANGUAGES CXX) | 6 | LANGUAGES CXX) |
11 | 7 | 7 | ||
12 | 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. |
13 | 9 | 9 | ||
14 | === modified file 'debian/changelog' | |||
15 | --- debian/changelog 2016-07-22 13:48:17 +0000 | |||
16 | +++ debian/changelog 2016-08-01 13:24:59 +0000 | |||
17 | @@ -1,3 +1,14 @@ | |||
18 | 1 | libertine-scope (1.3.2-0ubuntu1) UNRELEASED; urgency=medium | ||
19 | 2 | |||
20 | 3 | [ Larry Price ] | ||
21 | 4 | * Use full scope name in canned queries to properly return from Show/Hide | ||
22 | 5 | actions. | ||
23 | 6 | * Initialize libertine object in Query::run() to allow constructor to execute | ||
24 | 7 | in time. (LP: #1595944) | ||
25 | 8 | * Showing/hiding applications should retain filter state. (LP: #1592407) | ||
26 | 9 | |||
27 | 10 | -- Chris Townsend <christopher.townsend@canonical.com> Fri, 29 Jul 2016 12:35:35 -0400 | ||
28 | 11 | |||
29 | 1 | libertine-scope (1.3.1+16.10.20160722-0ubuntu1) yakkety; urgency=medium | 12 | libertine-scope (1.3.1+16.10.20160722-0ubuntu1) yakkety; urgency=medium |
30 | 2 | 13 | ||
31 | 3 | [ Chris Townsend ] | 14 | [ Chris Townsend ] |
32 | 4 | 15 | ||
33 | === modified file 'scope/apps/action.cpp' | |||
34 | --- scope/apps/action.cpp 2016-07-19 20:20:12 +0000 | |||
35 | +++ scope/apps/action.cpp 2016-08-01 13:24:59 +0000 | |||
36 | @@ -29,14 +29,30 @@ | |||
37 | 29 | namespace usc = unity::scopes; | 29 | namespace usc = unity::scopes; |
38 | 30 | 30 | ||
39 | 31 | 31 | ||
40 | 32 | namespace | ||
41 | 33 | { | ||
42 | 34 | static usc::ActivationResponse | ||
43 | 35 | sendToResults(usc::FilterState const& filter_state) | ||
44 | 36 | { | ||
45 | 37 | usc::CannedQuery query(FULLY_QUALIFIED_APPS_SCOPE); | ||
46 | 38 | query.set_filter_state(filter_state); | ||
47 | 39 | return usc::ActivationResponse(query); | ||
48 | 40 | } | ||
49 | 41 | } | ||
50 | 42 | |||
51 | 43 | |||
52 | 32 | Action:: | 44 | Action:: |
60 | 33 | Action(usc::Result const& result, | 45 | Action(unity::scopes::Result const& result, |
61 | 34 | usc::ActionMetadata const& metadata, | 46 | unity::scopes::ActionMetadata const& metadata, |
62 | 35 | std::string const& action_id, | 47 | std::string const& action_id, |
63 | 36 | std::shared_ptr<HiddenApps> hidden) | 48 | Action::OpenUriAction open_action, |
64 | 37 | : usc::ActivationQueryBase(result, metadata), | 49 | std::shared_ptr<HiddenApps> hidden, |
65 | 38 | action_id_(action_id), | 50 | unity::scopes::FilterState const& filter_state) |
66 | 39 | hidden_(hidden) | 51 | : usc::ActivationQueryBase(result, metadata) |
67 | 52 | , action_id_(action_id) | ||
68 | 53 | , open_action_(open_action) | ||
69 | 54 | , hidden_(hidden) | ||
70 | 55 | , filter_state_(filter_state) | ||
71 | 40 | { | 56 | { |
72 | 41 | } | 57 | } |
73 | 42 | 58 | ||
74 | @@ -46,22 +62,17 @@ | |||
75 | 46 | { | 62 | { |
76 | 47 | if (action_id_ == "open") | 63 | if (action_id_ == "open") |
77 | 48 | { | 64 | { |
80 | 49 | url_dispatch_send(result().uri().c_str() , NULL, NULL); | 65 | open_action_(result().uri()); |
79 | 50 | return usc::ActivationResponse(usc::ActivationResponse::Status::NotHandled); | ||
81 | 51 | } | 66 | } |
82 | 52 | else if (action_id_ == "hide") | 67 | else if (action_id_ == "hide") |
83 | 53 | { | 68 | { |
84 | 54 | hidden_->add(QString::fromStdString(result()["app_id"].get_string())); | 69 | hidden_->add(QString::fromStdString(result()["app_id"].get_string())); |
88 | 55 | 70 | return sendToResults(filter_state_); | |
86 | 56 | usc::CannedQuery cq(SCOPE_PKG); | ||
87 | 57 | return usc::ActivationResponse(cq); | ||
89 | 58 | } | 71 | } |
90 | 59 | else if (action_id_ == "show") | 72 | else if (action_id_ == "show") |
91 | 60 | { | 73 | { |
92 | 61 | hidden_->remove(QString::fromStdString(result()["app_id"].get_string())); | 74 | hidden_->remove(QString::fromStdString(result()["app_id"].get_string())); |
96 | 62 | 75 | return sendToResults(filter_state_); | |
94 | 63 | usc::CannedQuery cq(SCOPE_PKG); | ||
95 | 64 | return usc::ActivationResponse(cq); | ||
97 | 65 | } | 76 | } |
98 | 66 | return usc::ActivationResponse(usc::ActivationResponse::Status::NotHandled); | 77 | return usc::ActivationResponse(usc::ActivationResponse::Status::NotHandled); |
99 | 67 | } | 78 | } |
100 | 68 | 79 | ||
101 | === modified file 'scope/apps/action.h' | |||
102 | --- scope/apps/action.h 2016-07-12 18:26:07 +0000 | |||
103 | +++ scope/apps/action.h 2016-08-01 13:24:59 +0000 | |||
104 | @@ -15,31 +15,37 @@ | |||
105 | 15 | * * Authored by: | 15 | * * Authored by: |
106 | 16 | * Kyle Nitzsche <kyle.nitzsche@canonical.com> | 16 | * Kyle Nitzsche <kyle.nitzsche@canonical.com> |
107 | 17 | */ | 17 | */ |
108 | 18 | |||
109 | 19 | #ifndef SCOPE_ACTION_H_ | 18 | #ifndef SCOPE_ACTION_H_ |
110 | 20 | #define SCOPE_ACTION_H_ | 19 | #define SCOPE_ACTION_H_ |
111 | 21 | 20 | ||
113 | 22 | #include "scope/apps/scope.h" | 21 | |
114 | 23 | #include <unity/scopes/ActionMetadata.h> | 22 | #include <unity/scopes/ActionMetadata.h> |
115 | 24 | #include <unity/scopes/ActivationQueryBase.h> | 23 | #include <unity/scopes/ActivationQueryBase.h> |
116 | 25 | #include <unity/scopes/ActivationResponse.h> | 24 | #include <unity/scopes/ActivationResponse.h> |
117 | 26 | #include <unity/scopes/Result.h> | 25 | #include <unity/scopes/Result.h> |
118 | 27 | 26 | ||
119 | 27 | |||
120 | 28 | class HiddenApps; | 28 | class HiddenApps; |
121 | 29 | 29 | ||
122 | 30 | class Action : public unity::scopes::ActivationQueryBase { | 30 | class Action : public unity::scopes::ActivationQueryBase { |
136 | 31 | public: | 31 | public: |
137 | 32 | Action(unity::scopes::Result const& result, | 32 | typedef std::function<void(std::string const&)> OpenUriAction; |
138 | 33 | unity::scopes::ActionMetadata const& metadata, | 33 | |
139 | 34 | std::string const& action_id, | 34 | explicit Action(unity::scopes::Result const& result, |
140 | 35 | std::shared_ptr<HiddenApps> hidden); | 35 | unity::scopes::ActionMetadata const& metadata, |
141 | 36 | 36 | std::string const& action_id, | |
142 | 37 | virtual ~Action() = default; | 37 | OpenUriAction open_action, |
143 | 38 | virtual unity::scopes::ActivationResponse activate() override; | 38 | std::shared_ptr<HiddenApps> hidden, |
144 | 39 | 39 | unity::scopes::FilterState const& filterState); | |
145 | 40 | private: | 40 | |
146 | 41 | std::string action_id_; | 41 | virtual ~Action() = default; |
147 | 42 | std::string cache_dir_; | 42 | virtual unity::scopes::ActivationResponse activate() override; |
148 | 43 | std::shared_ptr<HiddenApps> hidden_; | 43 | |
149 | 44 | private: | ||
150 | 45 | std::string action_id_; | ||
151 | 46 | std::string cache_dir_; | ||
152 | 47 | OpenUriAction open_action_; | ||
153 | 48 | std::shared_ptr<HiddenApps> hidden_; | ||
154 | 49 | unity::scopes::FilterState filter_state_; | ||
155 | 44 | }; | 50 | }; |
156 | 45 | #endif | 51 | #endif |
157 | 46 | 52 | ||
158 | === modified file 'scope/apps/config.h.in' | |||
159 | --- scope/apps/config.h.in 2016-07-19 20:20:12 +0000 | |||
160 | +++ scope/apps/config.h.in 2016-08-01 13:24:59 +0000 | |||
161 | @@ -16,10 +16,8 @@ | |||
162 | 16 | #ifndef LIBERTINE_SCOPE_CONFIG_H_ | 16 | #ifndef LIBERTINE_SCOPE_CONFIG_H_ |
163 | 17 | #define LIBERTINE_SCOPE_CONFIG_H_ | 17 | #define LIBERTINE_SCOPE_CONFIG_H_ |
164 | 18 | 18 | ||
166 | 19 | const std::string SCOPE_PKG = "@PACKAGE_NAME@"; | 19 | const std::string FULLY_QUALIFIED_APPS_SCOPE = "@FULLY_QUALIFIED_NAME@"; |
167 | 20 | const std::string ROOT_DEPT_ID = "root_dept"; | 20 | const std::string ROOT_DEPT_ID = "root_dept"; |
168 | 21 | const std::string HIDDEN_DEPT_ID = "hidden_dept"; | 21 | const std::string HIDDEN_DEPT_ID = "hidden_dept"; |
169 | 22 | 22 | ||
170 | 23 | #endif // LIBERTINE_SCOPE_CONFIG_H_ | 23 | #endif // LIBERTINE_SCOPE_CONFIG_H_ |
171 | 24 | |||
172 | 25 | |||
173 | 26 | 24 | ||
174 | === modified file 'scope/apps/libertine.cpp' | |||
175 | --- scope/apps/libertine.cpp 2016-07-12 18:26:07 +0000 | |||
176 | +++ scope/apps/libertine.cpp 2016-08-01 13:24:59 +0000 | |||
177 | @@ -91,6 +91,5 @@ | |||
178 | 91 | Libertine::UPtr Libertine:: | 91 | Libertine::UPtr Libertine:: |
179 | 92 | from_libertine_cli() | 92 | from_libertine_cli() |
180 | 93 | { | 93 | { |
182 | 94 | return Libertine::UPtr(new LibertineCli()); | 94 | return std::make_shared<LibertineCli>(); |
183 | 95 | } | 95 | } |
184 | 96 | |||
185 | 97 | 96 | ||
186 | === modified file 'scope/apps/libertine.h' | |||
187 | --- scope/apps/libertine.h 2016-01-13 00:38:37 +0000 | |||
188 | +++ scope/apps/libertine.h 2016-08-01 13:24:59 +0000 | |||
189 | @@ -29,7 +29,7 @@ | |||
190 | 29 | class Libertine | 29 | class Libertine |
191 | 30 | { | 30 | { |
192 | 31 | public: | 31 | public: |
194 | 32 | using UPtr = std::unique_ptr<Libertine>; | 32 | using UPtr = std::shared_ptr<Libertine>; |
195 | 33 | using ContainerList = std::vector<std::unique_ptr<Container>>; | 33 | using ContainerList = std::vector<std::unique_ptr<Container>>; |
196 | 34 | 34 | ||
197 | 35 | /** | 35 | /** |
198 | 36 | 36 | ||
199 | === modified file 'scope/apps/query.cpp' | |||
200 | --- scope/apps/query.cpp 2016-07-19 13:57:43 +0000 | |||
201 | +++ scope/apps/query.cpp 2016-08-01 13:24:59 +0000 | |||
202 | @@ -121,7 +121,7 @@ | |||
203 | 121 | std::shared_ptr<HiddenApps> hidden, | 121 | std::shared_ptr<HiddenApps> hidden, |
204 | 122 | std::shared_ptr<Blacklist> blacklist) | 122 | std::shared_ptr<Blacklist> blacklist) |
205 | 123 | : usc::SearchQueryBase(query, metadata) | 123 | : usc::SearchQueryBase(query, metadata) |
207 | 124 | , libertine_(libertine_factory()) | 124 | , libertine_factory_(libertine_factory) |
208 | 125 | , hidden_(hidden) | 125 | , hidden_(hidden) |
209 | 126 | , blacklist_(blacklist) | 126 | , blacklist_(blacklist) |
210 | 127 | { | 127 | { |
211 | @@ -135,14 +135,14 @@ | |||
212 | 135 | 135 | ||
213 | 136 | 136 | ||
214 | 137 | QStringList Query:: | 137 | QStringList Query:: |
216 | 138 | make_filters(usc::SearchReplyProxy const& reply) const | 138 | make_filters(usc::SearchReplyProxy const& reply, Libertine::UPtr libertine) const |
217 | 139 | { | 139 | { |
218 | 140 | auto filter_state = query().filter_state(); | 140 | auto filter_state = query().filter_state(); |
219 | 141 | QStringList excludes_by_filter; | 141 | QStringList excludes_by_filter; |
220 | 142 | std::list<usc::FilterBase::SCPtr> app_filters; | 142 | std::list<usc::FilterBase::SCPtr> app_filters; |
221 | 143 | 143 | ||
222 | 144 | //make exclude scope filter for apps | 144 | //make exclude scope filter for apps |
224 | 145 | for (auto const& container: libertine_->get_container_list()) | 145 | for (auto const& container: libertine->get_container_list()) |
225 | 146 | { | 146 | { |
226 | 147 | usc::OptionSelectorFilter::SPtr filter{usc::OptionSelectorFilter::create(container->id(), | 147 | usc::OptionSelectorFilter::SPtr filter{usc::OptionSelectorFilter::create(container->id(), |
227 | 148 | EXCLUDED_APPS_FILTER_TITLE + container->name(), | 148 | EXCLUDED_APPS_FILTER_TITLE + container->name(), |
228 | @@ -208,18 +208,20 @@ | |||
229 | 208 | register_departments(reply); | 208 | register_departments(reply); |
230 | 209 | } | 209 | } |
231 | 210 | 210 | ||
232 | 211 | auto libertine = libertine_factory_(); | ||
233 | 212 | |||
234 | 211 | // only provide filters in root department | 213 | // only provide filters in root department |
235 | 212 | QStringList excludes_by_filter; | 214 | QStringList excludes_by_filter; |
236 | 213 | if (query().department_id().empty()) | 215 | if (query().department_id().empty()) |
237 | 214 | { | 216 | { |
239 | 215 | excludes_by_filter = make_filters(reply); | 217 | excludes_by_filter = make_filters(reply, libertine); |
240 | 216 | } | 218 | } |
241 | 217 | 219 | ||
242 | 218 | QRegExp search_query(QString::fromStdString(query().query_string()), Qt::CaseInsensitive); | 220 | QRegExp search_query(QString::fromStdString(query().query_string()), Qt::CaseInsensitive); |
243 | 219 | bool has_no_apps = true, | 221 | bool has_no_apps = true, |
244 | 220 | all_filtered = true; | 222 | all_filtered = true; |
245 | 221 | 223 | ||
247 | 222 | for (auto const& container: libertine_->get_container_list()) | 224 | for (auto const& container: libertine->get_container_list()) |
248 | 223 | { | 225 | { |
249 | 224 | auto category = reply->register_category(container->id(), | 226 | auto category = reply->register_category(container->id(), |
250 | 225 | container->name(), | 227 | container->name(), |
251 | 226 | 228 | ||
252 | === modified file 'scope/apps/query.h' | |||
253 | --- scope/apps/query.h 2016-07-12 18:26:07 +0000 | |||
254 | +++ scope/apps/query.h 2016-08-01 13:24:59 +0000 | |||
255 | @@ -50,11 +50,11 @@ | |||
256 | 50 | 50 | ||
257 | 51 | private: | 51 | private: |
258 | 52 | QStringList get_hidden_department() const; | 52 | QStringList get_hidden_department() const; |
260 | 53 | QStringList make_filters(unity::scopes::SearchReplyProxy const& reply) const; | 53 | QStringList make_filters(unity::scopes::SearchReplyProxy const& reply, Libertine::UPtr libertine) const; |
261 | 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; |
262 | 55 | void parse_blacklist(const std::string& data_dir); | 55 | void parse_blacklist(const std::string& data_dir); |
263 | 56 | 56 | ||
265 | 57 | Libertine::UPtr libertine_; | 57 | Libertine::Factory libertine_factory_; |
266 | 58 | std::shared_ptr<HiddenApps> hidden_; | 58 | std::shared_ptr<HiddenApps> hidden_; |
267 | 59 | std::shared_ptr<Blacklist> blacklist_; | 59 | std::shared_ptr<Blacklist> blacklist_; |
268 | 60 | }; | 60 | }; |
269 | 61 | 61 | ||
270 | === modified file 'scope/apps/scope.cpp' | |||
271 | --- scope/apps/scope.cpp 2016-07-12 18:26:07 +0000 | |||
272 | +++ scope/apps/scope.cpp 2016-08-01 13:24:59 +0000 | |||
273 | @@ -29,6 +29,16 @@ | |||
274 | 29 | namespace usc = unity::scopes; | 29 | namespace usc = unity::scopes; |
275 | 30 | 30 | ||
276 | 31 | 31 | ||
277 | 32 | namespace | ||
278 | 33 | { | ||
279 | 34 | static void | ||
280 | 35 | open_application(std::string const& app_uri) | ||
281 | 36 | { | ||
282 | 37 | url_dispatch_send(app_uri.c_str(), NULL, NULL); | ||
283 | 38 | } | ||
284 | 39 | } | ||
285 | 40 | |||
286 | 41 | |||
287 | 32 | Scope:: | 42 | Scope:: |
288 | 33 | Scope(Libertine::Factory const& libertine_factory) | 43 | Scope(Libertine::Factory const& libertine_factory) |
289 | 34 | : libertine_factory_(libertine_factory) | 44 | : libertine_factory_(libertine_factory) |
290 | @@ -56,6 +66,7 @@ | |||
291 | 56 | search(usc::CannedQuery const& query, | 66 | search(usc::CannedQuery const& query, |
292 | 57 | usc::SearchMetadata const& metadata) | 67 | usc::SearchMetadata const& metadata) |
293 | 58 | { | 68 | { |
294 | 69 | filter_state_ = query.filter_state(); | ||
295 | 59 | return usc::SearchQueryBase::UPtr(new Query(query, | 70 | return usc::SearchQueryBase::UPtr(new Query(query, |
296 | 60 | metadata, | 71 | metadata, |
297 | 61 | libertine_factory_, | 72 | libertine_factory_, |
298 | @@ -81,7 +92,9 @@ | |||
299 | 81 | return usc::ActivationQueryBase::UPtr(new Action(result, | 92 | return usc::ActivationQueryBase::UPtr(new Action(result, |
300 | 82 | metadata, | 93 | metadata, |
301 | 83 | action_id, | 94 | action_id, |
303 | 84 | std::make_shared<HiddenApps>(cache_directory()))); | 95 | open_application, |
304 | 96 | std::make_shared<HiddenApps>(cache_directory()), | ||
305 | 97 | filter_state_)); | ||
306 | 85 | } | 98 | } |
307 | 86 | 99 | ||
308 | 87 | 100 | ||
309 | 88 | 101 | ||
310 | === modified file 'scope/apps/scope.h' | |||
311 | --- scope/apps/scope.h 2016-07-12 18:26:07 +0000 | |||
312 | +++ scope/apps/scope.h 2016-08-01 13:24:59 +0000 | |||
313 | @@ -78,6 +78,7 @@ | |||
314 | 78 | 78 | ||
315 | 79 | private: | 79 | private: |
316 | 80 | Libertine::Factory libertine_factory_; | 80 | Libertine::Factory libertine_factory_; |
317 | 81 | unity::scopes::FilterState filter_state_; | ||
318 | 81 | }; | 82 | }; |
319 | 82 | 83 | ||
320 | 83 | #endif // LIBERTINE_SCOPE_SCOPE_H_ | 84 | #endif // LIBERTINE_SCOPE_SCOPE_H_ |
321 | 84 | 85 | ||
322 | === modified file 'tests/CMakeLists.txt' | |||
323 | --- tests/CMakeLists.txt 2016-07-12 18:26:07 +0000 | |||
324 | +++ tests/CMakeLists.txt 2016-08-01 13:24:59 +0000 | |||
325 | @@ -7,6 +7,7 @@ | |||
326 | 7 | add_executable(${test_name}_exe | 7 | add_executable(${test_name}_exe |
327 | 8 | fake_container.cpp | 8 | fake_container.cpp |
328 | 9 | fake_libertine.cpp | 9 | fake_libertine.cpp |
329 | 10 | mock_hidden_apps.h | ||
330 | 10 | ${test_name}.cpp | 11 | ${test_name}.cpp |
331 | 11 | ) | 12 | ) |
332 | 12 | 13 | ||
333 | @@ -25,5 +26,6 @@ | |||
334 | 25 | create_test(test_query) | 26 | create_test(test_query) |
335 | 26 | create_test(test_hidden_apps) | 27 | create_test(test_hidden_apps) |
336 | 27 | create_test(test_blacklist) | 28 | create_test(test_blacklist) |
337 | 29 | create_test(test_action) | ||
338 | 28 | 30 | ||
339 | 29 | file(COPY data DESTINATION ${CMAKE_CURRENT_BINARY_DIR}) | 31 | file(COPY data DESTINATION ${CMAKE_CURRENT_BINARY_DIR}) |
340 | 30 | 32 | ||
341 | === added file 'tests/mock_hidden_apps.h' | |||
342 | --- tests/mock_hidden_apps.h 1970-01-01 00:00:00 +0000 | |||
343 | +++ tests/mock_hidden_apps.h 2016-08-01 13:24:59 +0000 | |||
344 | @@ -0,0 +1,32 @@ | |||
345 | 1 | /* | ||
346 | 2 | * Copyright 2016 Canonical Ltd. | ||
347 | 3 | * | ||
348 | 4 | * This program is free software: you can redistribute it and/or modify it under | ||
349 | 5 | * the terms of the GNU General Public License, version 3, as published by the | ||
350 | 6 | * Free Software Foundation. | ||
351 | 7 | * | ||
352 | 8 | * This program is distributed in the hope that it will be useful, | ||
353 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
354 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
355 | 11 | * GNU General Public License for more details. | ||
356 | 12 | * | ||
357 | 13 | * You should have received a copy of the GNU General Public License | ||
358 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
359 | 15 | */ | ||
360 | 16 | #include "scope/apps/hidden_apps.h" | ||
361 | 17 | #include <gmock/gmock.h> | ||
362 | 18 | |||
363 | 19 | |||
364 | 20 | class MockHiddenApps : public HiddenApps | ||
365 | 21 | { | ||
366 | 22 | public: | ||
367 | 23 | MockHiddenApps() | ||
368 | 24 | : HiddenApps("") | ||
369 | 25 | { | ||
370 | 26 | } | ||
371 | 27 | |||
372 | 28 | MOCK_CONST_METHOD1(app_is_hidden, bool(QString const&)); | ||
373 | 29 | MOCK_CONST_METHOD0(empty, bool()); | ||
374 | 30 | MOCK_METHOD1(remove, void(QString const&)); | ||
375 | 31 | MOCK_METHOD1(add, void(QString const&)); | ||
376 | 32 | }; | ||
377 | 0 | 33 | ||
378 | === added file 'tests/test_action.cpp' | |||
379 | --- tests/test_action.cpp 1970-01-01 00:00:00 +0000 | |||
380 | +++ tests/test_action.cpp 2016-08-01 13:24:59 +0000 | |||
381 | @@ -0,0 +1,82 @@ | |||
382 | 1 | /* | ||
383 | 2 | * Copyright 2016 Canonical Ltd. | ||
384 | 3 | * | ||
385 | 4 | * This program is free software: you can redistribute it and/or modify it under | ||
386 | 5 | * the terms of the GNU General Public License, version 3, as published by the | ||
387 | 6 | * Free Software Foundation. | ||
388 | 7 | * | ||
389 | 8 | * This program is distributed in the hope that it will be useful, | ||
390 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
391 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
392 | 11 | * GNU General Public License for more details. | ||
393 | 12 | * | ||
394 | 13 | * You should have received a copy of the GNU General Public License | ||
395 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
396 | 15 | */ | ||
397 | 16 | #include "scope/apps/action.h" | ||
398 | 17 | #include "tests/mock_hidden_apps.h" | ||
399 | 18 | |||
400 | 19 | #include <unity/scopes/ActionMetadata.h> | ||
401 | 20 | #include <unity/scopes/testing/Result.h> | ||
402 | 21 | #include <gmock/gmock.h> | ||
403 | 22 | |||
404 | 23 | |||
405 | 24 | namespace | ||
406 | 25 | { | ||
407 | 26 | TEST(ActionTest, OpenSendsDispatchURI) | ||
408 | 27 | { | ||
409 | 28 | unity::scopes::testing::Result result; | ||
410 | 29 | result.set_uri("app://this/is/my/app"); | ||
411 | 30 | unity::scopes::ActionMetadata metadata("en_US", "phone"); | ||
412 | 31 | auto hidden = std::make_shared<testing::NiceMock<MockHiddenApps> >(); | ||
413 | 32 | unity::scopes::FilterState filter_state; | ||
414 | 33 | |||
415 | 34 | std::string uri; | ||
416 | 35 | |||
417 | 36 | Action action(result, metadata, "open", [&](std::string const& app_uri) { | ||
418 | 37 | uri = app_uri; | ||
419 | 38 | }, hidden, filter_state); | ||
420 | 39 | |||
421 | 40 | auto response = action.activate(); | ||
422 | 41 | EXPECT_EQ(unity::scopes::ActivationResponse::Status::NotHandled, response.status()); | ||
423 | 42 | EXPECT_EQ(result.uri(), uri); | ||
424 | 43 | } | ||
425 | 44 | |||
426 | 45 | |||
427 | 46 | TEST(ActionTest, ShowRemovesAppFromHidden) | ||
428 | 47 | { | ||
429 | 48 | unity::scopes::testing::Result result; | ||
430 | 49 | unity::scopes::ActionMetadata metadata("en_US", "phone"); | ||
431 | 50 | unity::scopes::FilterState filter_state; | ||
432 | 51 | auto hidden = std::make_shared<testing::NiceMock<MockHiddenApps> >(); | ||
433 | 52 | |||
434 | 53 | QString app_id = "something.desktop"; | ||
435 | 54 | result["app_id"] = app_id.toStdString(); | ||
436 | 55 | EXPECT_CALL(*hidden, remove(app_id)); | ||
437 | 56 | |||
438 | 57 | Action action(result, metadata, "show", Action::OpenUriAction{}, hidden, filter_state); | ||
439 | 58 | |||
440 | 59 | auto response = action.activate(); | ||
441 | 60 | EXPECT_EQ(filter_state.serialize(), response.query().filter_state().serialize()); | ||
442 | 61 | EXPECT_EQ(unity::scopes::ActivationResponse::Status::PerformQuery, response.status()); | ||
443 | 62 | } | ||
444 | 63 | |||
445 | 64 | |||
446 | 65 | TEST(ActionTest, HideAddsAppToHidden) | ||
447 | 66 | { | ||
448 | 67 | unity::scopes::testing::Result result; | ||
449 | 68 | unity::scopes::ActionMetadata metadata("en_US", "phone"); | ||
450 | 69 | unity::scopes::FilterState filter_state; | ||
451 | 70 | auto hidden = std::make_shared<testing::NiceMock<MockHiddenApps> >(); | ||
452 | 71 | |||
453 | 72 | QString app_id = "something.desktop"; | ||
454 | 73 | result["app_id"] = app_id.toStdString(); | ||
455 | 74 | EXPECT_CALL(*hidden, add(app_id)); | ||
456 | 75 | |||
457 | 76 | Action action(result, metadata, "hide", Action::OpenUriAction{}, hidden, filter_state); | ||
458 | 77 | |||
459 | 78 | auto response = action.activate(); | ||
460 | 79 | EXPECT_EQ(filter_state.serialize(), response.query().filter_state().serialize()); | ||
461 | 80 | EXPECT_EQ(unity::scopes::ActivationResponse::Status::PerformQuery, response.status()); | ||
462 | 81 | } | ||
463 | 82 | } | ||
464 | 0 | 83 | ||
465 | === modified file 'tests/test_query.cpp' | |||
466 | --- tests/test_query.cpp 2016-07-12 18:26:07 +0000 | |||
467 | +++ tests/test_query.cpp 2016-08-01 13:24:59 +0000 | |||
468 | @@ -17,6 +17,7 @@ | |||
469 | 17 | #include "scope/apps/query.h" | 17 | #include "scope/apps/query.h" |
470 | 18 | #include "scope/apps/config.h" | 18 | #include "scope/apps/config.h" |
471 | 19 | #include "tests/fake_libertine.h" | 19 | #include "tests/fake_libertine.h" |
472 | 20 | #include "tests/mock_hidden_apps.h" | ||
473 | 20 | #include <unity/scopes/SearchMetadata.h> | 21 | #include <unity/scopes/SearchMetadata.h> |
474 | 21 | #include <unity/scopes/CannedQuery.h> | 22 | #include <unity/scopes/CannedQuery.h> |
475 | 22 | #include <unity/scopes/SearchReplyProxyFwd.h> | 23 | #include <unity/scopes/SearchReplyProxyFwd.h> |
476 | @@ -67,18 +68,6 @@ | |||
477 | 67 | }; | 68 | }; |
478 | 68 | 69 | ||
479 | 69 | 70 | ||
480 | 70 | class MockHiddenApps : public HiddenApps | ||
481 | 71 | { | ||
482 | 72 | public: | ||
483 | 73 | MockHiddenApps() | ||
484 | 74 | : HiddenApps("") | ||
485 | 75 | { | ||
486 | 76 | } | ||
487 | 77 | |||
488 | 78 | MOCK_CONST_METHOD1(app_is_hidden, bool(QString const&)); | ||
489 | 79 | MOCK_CONST_METHOD0(empty, bool()); | ||
490 | 80 | }; | ||
491 | 81 | |||
492 | 82 | class MockBlacklist : public Blacklist | 71 | class MockBlacklist : public Blacklist |
493 | 83 | { | 72 | { |
494 | 84 | public: | 73 | public: |
PASSED: Continuous integration, rev:56 /jenkins. canonical. com/libertine/ job/lp- libertine- scope-ci/ 63/ /jenkins. canonical. com/libertine/ job/build/ 224 /jenkins. canonical. com/libertine/ job/test- 0-autopkgtest/ label=amd64, release= vivid+overlay, testname= default/ 182 /jenkins. canonical. com/libertine/ job/test- 0-autopkgtest/ label=amd64, release= xenial+ overlay, testname= default/ 182 /jenkins. canonical. com/libertine/ job/test- 0-autopkgtest/ label=amd64, release= yakkety, testname= default/ 182 /jenkins. canonical. com/libertine/ job/test- 0-autopkgtest/ label=i386, release= vivid+overlay, testname= default/ 182 /jenkins. canonical. com/libertine/ job/test- 0-autopkgtest/ label=i386, release= xenial+ overlay, testname= default/ 182 /jenkins. canonical. com/libertine/ job/test- 0-autopkgtest/ label=i386, release= yakkety, testname= default/ 182 /jenkins. canonical. com/libertine/ job/lp- generic- update- mp/170/ console /jenkins. canonical. com/libertine/ job/build- 0-fetch/ 227 /jenkins. canonical. com/libertine/ job/build- 1-sourcepkg/ release= vivid+overlay/ 212 /jenkins. canonical. com/libertine/ job/build- 1-sourcepkg/ release= xenial+ overlay/ 212 /jenkins. canonical. com/libertine/ job/build- 1-sourcepkg/ release= yakkety/ 212 /jenkins. canonical. com/libertine/ job/build- 2-binpkg/ arch=amd64, release= vivid+overlay/ 205 /jenkins. canonical. com/libertine/ job/build- 2-binpkg/ arch=amd64, release= vivid+overlay/ 205/artifact/ output/ *zip*/output. zip /jenkins. canonical. com/libertine/ job/build- 2-binpkg/ arch=amd64, release= xenial+ overlay/ 205 /jenkins. canonical. com/libertine/ job/build- 2-binpkg/ arch=amd64, release= xenial+ overlay/ 205/artifact/ output/ *zip*/output. zip /jenkins. canonical. com/libertine/ job/build- 2-binpkg/ arch=amd64, release= yakkety/ 205 /jenkins. canonical. com/libertine/ job/build- 2-binpkg/ arch=amd64, release= yakkety/ 205/artifact/ output/ *zip*/output. zip /jenkins. canonical. com/libertine/ job/build- 2-binpkg/ arch=i386, release= vivid+overlay/ 205 /jenkins. canonical. com/libertine/ job/build- 2-binpkg/ arch=i386, release= vivid+overlay/ 205/artifact/ output/ *zip*/output. zip /jenkins. canonical. com/libertine/ job/build- 2-binpkg/ arch=i386, release= xenial+ overlay/ 205 /jenkins. canonical. com/libertine/ job/build- 2-binpkg/ arch=i386, release= xenial+ overlay/ 205/artifact/ output/ *zip*/output. zip /jenkins. canonical. com/libertine/ job/build- 2-binpkg/ arch=i386, release= yakkety/ 205 /jenkins. canonical. com/libertine/ job/build- 2-binpkg/ arch=i386, release= yakkety/ 205/artifact/ output/ *zip*/output. zip
https:/
Executed test runs:
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
None: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
Click here to trigger a rebuild: /jenkins. canonical. com/libertine/ job/lp- libertine- scope-ci/ 63/rebuild
https:/