Merge lp:~larryprice/libertine-scope/libertine-store-link-from-apps into lp:~larryprice/libertine-scope/libertine-store-search
- libertine-store-link-from-apps
- Merge into libertine-store-search
Proposed by
Larry Price
Status: | Merged |
---|---|
Approved by: | Larry Price |
Approved revision: | 104 |
Merged at revision: | 103 |
Proposed branch: | lp:~larryprice/libertine-scope/libertine-store-link-from-apps |
Merge into: | lp:~larryprice/libertine-scope/libertine-store-search |
Diff against target: |
603 lines (+246/-57) 10 files modified
CMakeLists.txt (+0/-1) data/CMakeLists.txt (+4/-5) data/store.svg (+77/-0) debian/libertine-scope.install (+1/-0) scope/apps/config.h.in (+2/-0) scope/apps/query.cpp (+91/-32) scope/apps/query.h (+4/-1) scope/apps/scope.cpp (+2/-1) tests/scope/apps/test_query.cpp (+62/-14) tests/scope/apps/test_scope.cpp (+3/-3) |
To merge this branch: | bzr merge lp:~larryprice/libertine-scope/libertine-store-link-from-apps |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Christopher Townsend (community) | Approve | ||
Review via email: mp+304418@code.launchpad.net |
Commit message
Add a category in the Apps scope linking to the Store scope.
Description of the change
Add a category in the Apps scope linking to the Store scope. Note that I don't show the link in the Hidden department. Also, I suppose the image is tentative?
To post a comment you must log in.
- 102. By Larry Price
-
merge
- 103. By Larry Price
-
merge
Revision history for this message
Christopher Townsend (townsend) wrote : | # |
review:
Needs Information
- 104. By Larry Price
-
remove unnecessary include
Revision history for this message
Christopher Townsend (townsend) wrote : | # |
Ok, I approve of this. Let's get it merged into the main branch.
review:
Approve
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-29 14:32:44 +0000 |
3 | +++ CMakeLists.txt 2016-09-19 14:03:05 +0000 |
4 | @@ -36,7 +36,6 @@ |
5 | set(APPS_LIB_DIR ${CMAKE_INSTALL_FULL_LIBDIR}/unity-scopes/libertine-scope/) |
6 | set(APPS_DATA_DIR ${CMAKE_INSTALL_FULL_DATADIR}/unity/scopes/libertine-scope/) |
7 | set(STORE_LIB_DIR ${CMAKE_INSTALL_FULL_LIBDIR}/unity-scopes/libertine-scope/) |
8 | -set(STORE_DATA_DIR ${CMAKE_INSTALL_FULL_DATADIR}/unity/scopes/libertine-scope/) |
9 | set(SCOPE_NAME "libertine-scope") |
10 | set(SCOPE_DISPLAY_NAME "Desktop Apps") |
11 | set(PACKAGE_NAME "libertine-scope.ubuntu") |
12 | |
13 | === modified file 'data/CMakeLists.txt' |
14 | --- data/CMakeLists.txt 2016-08-26 18:15:41 +0000 |
15 | +++ data/CMakeLists.txt 2016-09-19 14:03:05 +0000 |
16 | @@ -1,11 +1,10 @@ |
17 | -# Put the ini files in the build directory next to the scope |
18 | -# .so file so that the test tools can find them. |
19 | +# Copy data files into apps scope dir for dev |
20 | +file(COPY store.svg blacklist DESTINATION ${CMAKE_BINARY_DIR}/scope/apps/) |
21 | |
22 | -# Install the scope images |
23 | -install(FILES "apps.png" |
24 | +install(FILES apps.png apps.svg |
25 | DESTINATION ${APPS_DATA_DIR}) |
26 | |
27 | -install(FILES "blacklist" |
28 | +install(FILES blacklist store.svg |
29 | DESTINATION ${SCOPE_INSTALL_DIR}) |
30 | |
31 | install(FILES com.canonical.libertine.ContainerManager.service |
32 | |
33 | === added file 'data/store.svg' |
34 | --- data/store.svg 1970-01-01 00:00:00 +0000 |
35 | +++ data/store.svg 2016-09-19 14:03:05 +0000 |
36 | @@ -0,0 +1,77 @@ |
37 | +<?xml version="1.0" encoding="UTF-8" standalone="no"?> |
38 | +<!-- Created with Inkscape (http://www.inkscape.org/) --> |
39 | + |
40 | +<svg |
41 | + xmlns:dc="http://purl.org/dc/elements/1.1/" |
42 | + xmlns:cc="http://creativecommons.org/ns#" |
43 | + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" |
44 | + xmlns:svg="http://www.w3.org/2000/svg" |
45 | + xmlns="http://www.w3.org/2000/svg" |
46 | + xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" |
47 | + xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" |
48 | + width="351.27005mm" |
49 | + height="433.59958mm" |
50 | + viewBox="0 0 1244.6577 1536.3765" |
51 | + id="svg3637" |
52 | + version="1.1" |
53 | + inkscape:version="0.91 r13725" |
54 | + sodipodi:docname="store.svg"> |
55 | + <defs |
56 | + id="defs3639" /> |
57 | + <sodipodi:namedview |
58 | + id="base" |
59 | + pagecolor="#00ffff" |
60 | + bordercolor="#666666" |
61 | + borderopacity="1.0" |
62 | + inkscape:pageopacity="0" |
63 | + inkscape:pageshadow="2" |
64 | + inkscape:zoom="0.24748737" |
65 | + inkscape:cx="-563.75562" |
66 | + inkscape:cy="519.26806" |
67 | + inkscape:document-units="px" |
68 | + inkscape:current-layer="layer1" |
69 | + showgrid="false" |
70 | + inkscape:window-width="1920" |
71 | + inkscape:window-height="1056" |
72 | + inkscape:window-x="1920" |
73 | + inkscape:window-y="24" |
74 | + inkscape:window-maximized="1" |
75 | + fit-margin-left="118.5" |
76 | + fit-margin-right="118.5" |
77 | + fit-margin-top="120" |
78 | + fit-margin-bottom="180" /> |
79 | + <metadata |
80 | + id="metadata3642"> |
81 | + <rdf:RDF> |
82 | + <cc:Work |
83 | + rdf:about=""> |
84 | + <dc:format>image/svg+xml</dc:format> |
85 | + <dc:type |
86 | + rdf:resource="http://purl.org/dc/dcmitype/StillImage" /> |
87 | + <dc:title></dc:title> |
88 | + </cc:Work> |
89 | + </rdf:RDF> |
90 | + </metadata> |
91 | + <g |
92 | + inkscape:label="Layer 1" |
93 | + inkscape:groupmode="layer" |
94 | + id="layer1" |
95 | + transform="translate(-388.21849,836.02937)"> |
96 | + <g |
97 | + id="g3343" |
98 | + transform="matrix(0.74113597,0,0,0.78153068,321.48718,23.928691)"> |
99 | + <path |
100 | + transform="translate(229.97523,-735.66029)" |
101 | + inkscape:connector-curvature="0" |
102 | + id="path3734" |
103 | + d="m 435.93411,771.50865 c 5.13251,-7.46428 23.15091,-32.85714 40.04089,-56.42857 16.88998,-23.57143 36.65936,-51.21428 43.93196,-61.42857 7.2726,-10.21428 21.97523,-30.46508 32.67251,-45.00177 10.69727,-14.53669 27.61176,-38.11043 37.58774,-52.38611 9.97598,-14.27566 24.24529,-34.14652 31.70958,-44.15743 7.46428,-10.01089 13.57143,-19.48897 13.57143,-21.06235 0,-2.71828 -17.5498,-29.26911 -81.37207,-123.10662 -15.49738,-22.78572 -40.3902,-59.42858 -55.31738,-81.42858 -14.92718,-22 -35.00329,-51.57142 -44.61358,-65.71428 -9.6103,-14.14286 -19.70681,-29.25 -22.4367,-33.57143 l -4.96343,-7.85714 65.44846,0 65.44845,0 33.90313,50.17117 c 18.64671,27.59414 35.20443,52.34414 36.79492,55 4.96144,8.28476 14.04967,21.90535 15.61363,23.40026 5.56962,5.32368 80.066,120.17946 80.066,123.44281 0,2.24606 -7.49798,14.28313 -16.66215,26.74904 -31.75367,43.19412 -68.03182,92.82957 -153.20253,209.6104 l -85.57896,117.3406 -20.98687,0 -20.98687,0 9.33184,-13.57143 z" |
104 | + style="fill:#ffffff" /> |
105 | + <path |
106 | + transform="translate(229.97523,-735.66029)" |
107 | + inkscape:connector-curvature="0" |
108 | + id="path3736" |
109 | + d="m 831.21335,770.08008 c -5.66053,-8.25 -20.06228,-29.14285 -32.00388,-46.42857 -11.9416,-17.28571 -38.73039,-56.5 -59.53064,-87.14286 -20.80026,-30.64285 -44.68152,-65.72971 -53.06948,-77.97082 -13.98989,-20.41635 -14.92937,-22.77866 -11.36275,-28.57143 2.13845,-3.47317 18.80864,-26.80949 37.04485,-51.85846 18.23622,-25.04895 38.94248,-53.61705 46.01391,-63.48466 7.07143,-9.86761 23.78571,-33.00848 37.14286,-51.42417 13.35714,-18.41568 28.87474,-39.99043 34.48356,-47.9439 5.60881,-7.95346 26.18024,-36.33887 45.71429,-63.07868 19.53404,-26.73982 39.227,-54.06125 43.76215,-60.71429 l 8.24572,-12.09644 22.55911,0 22.55911,0 -8.89011,12.14285 c -12.05808,16.46994 -89.78558,123.80437 -110.17606,152.14286 -16.77918,23.31954 -41.38224,57.29953 -74.11675,102.36479 l -18.32072,25.22193 59.10118,87.6352 c 32.50564,48.19937 70.71004,104.99237 84.89866,126.20665 14.18861,21.21429 26.78352,39 27.98867,39.5238 1.20515,0.52383 2.19119,1.99846 2.19119,3.277 0,1.27855 8.43058,14.6714 18.73463,29.76192 l 18.73462,27.43728 -65.70612,0 -65.70611,0 -10.29189,-15 z" |
110 | + style="fill:#ffffff" /> |
111 | + </g> |
112 | + </g> |
113 | +</svg> |
114 | |
115 | === modified file 'debian/libertine-scope.install' |
116 | --- debian/libertine-scope.install 2016-08-29 16:20:35 +0000 |
117 | +++ debian/libertine-scope.install 2016-09-19 14:03:05 +0000 |
118 | @@ -1,3 +1,4 @@ |
119 | usr/lib/*/unity-scopes/* |
120 | usr/share/unity/scopes/libertine-scope/*png |
121 | +usr/share/unity/scopes/libertine-scope/*svg |
122 | usr/share/locale/*/LC_MESSAGES/libertine-scope.mo |
123 | |
124 | === modified file 'scope/apps/config.h.in' |
125 | --- scope/apps/config.h.in 2016-07-29 14:32:44 +0000 |
126 | +++ scope/apps/config.h.in 2016-09-19 14:03:05 +0000 |
127 | @@ -17,7 +17,9 @@ |
128 | #define LIBERTINE_SCOPE_CONFIG_H_ |
129 | |
130 | const std::string FULLY_QUALIFIED_APPS_SCOPE = "@FULLY_QUALIFIED_NAME@"; |
131 | +const std::string STORE_SCOPE_FULL_NAME = "@STORE_PACKAGE_NAME@"; |
132 | const std::string ROOT_DEPT_ID = "root_dept"; |
133 | const std::string HIDDEN_DEPT_ID = "hidden_dept"; |
134 | +const std::string DATA_DIR = "@APPS_DATA_DIR@"; |
135 | |
136 | #endif // LIBERTINE_SCOPE_CONFIG_H_ |
137 | |
138 | === modified file 'scope/apps/query.cpp' |
139 | --- scope/apps/query.cpp 2016-07-29 14:32:44 +0000 |
140 | +++ scope/apps/query.cpp 2016-09-19 14:03:05 +0000 |
141 | @@ -31,8 +31,10 @@ |
142 | #include <QFile> |
143 | #include <QTextStream> |
144 | |
145 | + |
146 | namespace usc = unity::scopes; |
147 | |
148 | + |
149 | namespace |
150 | { |
151 | static const auto ROOT_DEPT_TITLE = _("Desktop Apps"); |
152 | @@ -41,6 +43,8 @@ |
153 | static const auto APP_ID_FIELD = "app_id"; |
154 | static const auto DEPARTMENT_ID_FIELD = "department_id"; |
155 | static const auto EXCLUDED_APPS_FILTER_TITLE = _("Exclude Apps: "); |
156 | +static const auto SEARCH_STORE_HINT = _("Search for '%s' in the store"); |
157 | +static const auto SEARCH_STORE_CATEGORY_TITLE = _("Get more apps from the store"); |
158 | |
159 | struct AppInfo |
160 | { |
161 | @@ -107,23 +111,45 @@ |
162 | } |
163 | } |
164 | )"; |
165 | + |
166 | + |
167 | +static const auto CATEGORY_STORE = R"( |
168 | + { |
169 | + "schema-version": 1, |
170 | + "template": { |
171 | + "category-layout": "grid", |
172 | + "overlay": true, |
173 | + "card-background": "color:///#E95420" |
174 | + }, |
175 | + "components": { |
176 | + "title": "title", |
177 | + "art": { |
178 | + "aspect-ratio": 0.55, |
179 | + "field": "art" |
180 | + }, |
181 | + "overlay-color": "overlay-color" |
182 | + } |
183 | + } |
184 | +)"; |
185 | } // anonymous namespace |
186 | |
187 | |
188 | -std::string const Query::NO_RESULTS_HINT = _("No applications available. Install new applications with the Libertine Manager."); |
189 | -std::string const Query::ALL_RESULTS_FILTERED_HINT = _("All applications hidden. Reset filters or check the Hidden Desktop Apps department."); |
190 | +std::string const Query::NO_RESULTS_HINT = _("No applications available in this department."); |
191 | +std::string const Query::ALL_RESULTS_FILTERED_HINT = _("All applications filtered. Reset filters or clear department."); |
192 | |
193 | |
194 | Query:: |
195 | -Query(usc::CannedQuery const& query, |
196 | - usc::SearchMetadata const& metadata, |
197 | - Libertine::Factory const& libertine_factory, |
198 | +Query(usc::CannedQuery const& query, |
199 | + usc::SearchMetadata const& metadata, |
200 | + Libertine::Factory const& libertine_factory, |
201 | std::shared_ptr<HiddenApps> hidden, |
202 | - std::shared_ptr<Blacklist> blacklist) |
203 | + std::shared_ptr<Blacklist> blacklist, |
204 | + std::string const& data_directory) |
205 | : usc::SearchQueryBase(query, metadata) |
206 | , libertine_factory_(libertine_factory) |
207 | , hidden_(hidden) |
208 | , blacklist_(blacklist) |
209 | + , data_directory_(data_directory) |
210 | { |
211 | } |
212 | |
213 | @@ -201,6 +227,35 @@ |
214 | |
215 | |
216 | void Query:: |
217 | +add_store_link(usc::SearchReplyProxy const& reply) const |
218 | +{ |
219 | + const auto querystr = query().query_string(); |
220 | + auto cat_title = SEARCH_STORE_CATEGORY_TITLE; |
221 | + |
222 | + if (!querystr.empty()) |
223 | + { |
224 | + char tmp[512]; |
225 | + if (snprintf(tmp, sizeof(tmp), SEARCH_STORE_HINT, querystr.c_str()) > 0) |
226 | + { |
227 | + cat_title = tmp; |
228 | + } |
229 | + } |
230 | + |
231 | + usc::CategoryRenderer rdr(CATEGORY_STORE); |
232 | + auto cat = reply->register_category("hint", cat_title, "", rdr); |
233 | + |
234 | + const unity::scopes::CannedQuery store_scope(STORE_SCOPE_FULL_NAME, querystr, ""); |
235 | + |
236 | + usc::CategorisedResult res(cat); |
237 | + res.set_title(_("Install X Apps")); |
238 | + res.set_art(data_directory_ + "/store.svg"); |
239 | + res.set_uri(store_scope.to_uri()); |
240 | + res["overlay-color"] = "transparent"; |
241 | + reply->push(res); |
242 | +} |
243 | + |
244 | + |
245 | +void Query:: |
246 | run(usc::SearchReplyProxy const& reply) |
247 | { |
248 | if (!hidden_->empty()) |
249 | @@ -219,7 +274,8 @@ |
250 | |
251 | QRegExp search_query(QString::fromStdString(query().query_string()), Qt::CaseInsensitive); |
252 | bool has_no_apps = true, |
253 | - all_filtered = true; |
254 | + all_filtered = true, |
255 | + is_hidden_dept = query().department_id() == HIDDEN_DEPT_ID; |
256 | |
257 | for (auto const& container: libertine->get_container_list()) |
258 | { |
259 | @@ -230,44 +286,40 @@ |
260 | |
261 | for (auto const& app: container->app_launchers()) |
262 | { |
263 | + auto app_info = parse_app_info(app.uri()); |
264 | + |
265 | + // ignore blacklisted apps |
266 | + if (blacklist_->app_is_blacklisted(app_info.app_id, container->id())) |
267 | + { |
268 | + continue; |
269 | + } |
270 | + |
271 | + // ignore hidden apps unless in hidden dept |
272 | + if ((!is_hidden_dept && hidden_->app_is_hidden(app_info.key)) || |
273 | + (is_hidden_dept && !hidden_->app_is_hidden(app_info.key))) |
274 | + { |
275 | + continue; |
276 | + } |
277 | + |
278 | has_no_apps = false; |
279 | + |
280 | if (!(search_query.isEmpty() || QString::fromStdString(app.name()).contains(search_query))) |
281 | { |
282 | continue; |
283 | } |
284 | |
285 | - auto app_info = parse_app_info(app.uri()); |
286 | - |
287 | - if (blacklist_->app_is_blacklisted(app_info.app_id, container->id())) |
288 | - { |
289 | - continue; |
290 | - } |
291 | - |
292 | if (excludes_by_filter.contains(app_info.key)) |
293 | { |
294 | continue; |
295 | } |
296 | |
297 | - // ignore hidden apps in root department |
298 | - if (query().department_id().empty() || query().department_id() == ROOT_DEPT_ID) |
299 | - { |
300 | - if (hidden_->app_is_hidden(app_info.key)) |
301 | - { |
302 | - continue; |
303 | - } |
304 | - } |
305 | - else if (!hidden_->app_is_hidden(app_info.key)) |
306 | - { |
307 | - continue; |
308 | - } |
309 | - |
310 | usc::CategorisedResult result(category); |
311 | result.set_title(app.name()); |
312 | result.set_art(app.icon()); |
313 | result.set_uri(app.uri()); |
314 | result[DESCRIPTION_FIELD] = app.description(); |
315 | result[APP_ID_FIELD] = app_info.key.toStdString(); |
316 | - result[DEPARTMENT_ID_FIELD] = (query().department_id().empty() || query().department_id() == ROOT_DEPT_ID) ? ROOT_DEPT_ID : HIDDEN_DEPT_ID; |
317 | + result[DEPARTMENT_ID_FIELD] = is_hidden_dept ? HIDDEN_DEPT_ID : ROOT_DEPT_ID; |
318 | |
319 | if (!reply->push(result)) |
320 | { |
321 | @@ -278,12 +330,19 @@ |
322 | } |
323 | } |
324 | |
325 | - if (has_no_apps) |
326 | + if (is_hidden_dept) |
327 | { |
328 | - show_hint(reply, NO_RESULTS_HINT); |
329 | + if (has_no_apps) |
330 | + { |
331 | + show_hint(reply, NO_RESULTS_HINT); |
332 | + } |
333 | + else if (all_filtered) |
334 | + { |
335 | + show_hint(reply, ALL_RESULTS_FILTERED_HINT); |
336 | + } |
337 | } |
338 | - else if (all_filtered) |
339 | + else |
340 | { |
341 | - show_hint(reply, ALL_RESULTS_FILTERED_HINT); |
342 | + add_store_link(reply); |
343 | } |
344 | } |
345 | |
346 | === modified file 'scope/apps/query.h' |
347 | --- scope/apps/query.h 2016-07-28 14:04:27 +0000 |
348 | +++ scope/apps/query.h 2016-09-19 14:03:05 +0000 |
349 | @@ -35,7 +35,8 @@ |
350 | unity::scopes::SearchMetadata const& metadata, |
351 | Libertine::Factory const& libertine_factory, |
352 | std::shared_ptr<HiddenApps> hidden_apps, |
353 | - std::shared_ptr<Blacklist> blacklist); |
354 | + std::shared_ptr<Blacklist> blacklist, |
355 | + std::string const& data_directory); |
356 | |
357 | ~Query() = default; |
358 | |
359 | @@ -53,10 +54,12 @@ |
360 | QStringList make_filters(unity::scopes::SearchReplyProxy const& reply, Libertine::UPtr libertine) const; |
361 | void show_hint(unity::scopes::SearchReplyProxy const& reply, std::string const& reason) const; |
362 | void parse_blacklist(const std::string& data_dir); |
363 | + void add_store_link(unity::scopes::SearchReplyProxy const& reply) const; |
364 | |
365 | Libertine::Factory libertine_factory_; |
366 | std::shared_ptr<HiddenApps> hidden_; |
367 | std::shared_ptr<Blacklist> blacklist_; |
368 | + const std::string data_directory_; |
369 | }; |
370 | |
371 | #endif // LIBERTINE_SCOPE_QUERY_H_ |
372 | |
373 | === modified file 'scope/apps/scope.cpp' |
374 | --- scope/apps/scope.cpp 2016-07-29 13:21:34 +0000 |
375 | +++ scope/apps/scope.cpp 2016-09-19 14:03:05 +0000 |
376 | @@ -71,7 +71,8 @@ |
377 | metadata, |
378 | libertine_factory_, |
379 | std::make_shared<HiddenApps>(cache_directory()), |
380 | - std::make_shared<Blacklist>(scope_directory()))); |
381 | + std::make_shared<Blacklist>(scope_directory()), |
382 | + scope_directory())); |
383 | } |
384 | |
385 | |
386 | |
387 | === modified file 'tests/scope/apps/test_query.cpp' |
388 | --- tests/scope/apps/test_query.cpp 2016-07-29 14:45:01 +0000 |
389 | +++ tests/scope/apps/test_query.cpp 2016-09-19 14:03:05 +0000 |
390 | @@ -25,8 +25,8 @@ |
391 | #include <unity/scopes/Category.h> |
392 | #include <vector> |
393 | #include <memory> |
394 | -#include <gtest/gtest.h> |
395 | #include <gmock/gmock.h> |
396 | +#include <QUrl> |
397 | |
398 | namespace |
399 | { |
400 | @@ -95,6 +95,15 @@ |
401 | } |
402 | |
403 | |
404 | +MATCHER_P4(HintPropertiesMatch, title, art, uri, overlay, "") |
405 | +{ |
406 | + return arg.contains("title") && arg["title"] == unity::scopes::Variant(title) && |
407 | + arg.contains("art") && arg["art"] == unity::scopes::Variant(art) && |
408 | + arg.contains("uri") && arg["uri"] == unity::scopes::Variant(uri) && |
409 | + arg.contains("overlay-color") && arg["overlay-color"] == unity::scopes::Variant(overlay); |
410 | +} |
411 | + |
412 | + |
413 | class TestQueryFixture : public ::testing::Test |
414 | { |
415 | public: |
416 | @@ -106,6 +115,7 @@ |
417 | , category(std::make_shared<FakeCategory>("fake-container", "fake-container", "Application", unity::scopes::CategoryRenderer())) |
418 | , hidden(new testing::NiceMock<MockHiddenApps>()) |
419 | , blacklist(new testing::NiceMock<MockBlacklist>()) |
420 | + , data_dir("/some/fake/path") |
421 | { |
422 | } |
423 | |
424 | @@ -124,6 +134,26 @@ |
425 | EXPECT_CALL(reply, register_category("fake-container", "fake-container", "Application", testing::_)).WillOnce(testing::Return(category)); |
426 | } |
427 | |
428 | + void expect_hint_registry(QString const& query = "") |
429 | + { |
430 | + if (query.isEmpty()) |
431 | + { |
432 | + EXPECT_CALL(reply, register_category("hint", "Get more apps from the store", "", testing::_)).WillOnce(testing::Return(category)); |
433 | + } |
434 | + else |
435 | + { |
436 | + EXPECT_CALL(reply, register_category("hint", QString("Search for '%1' in the store").arg(query).toStdString(), "", testing::_)) |
437 | + .WillOnce(testing::Return(category)); |
438 | + } |
439 | + |
440 | + auto full_scope = QString("scope://%1?q=%2") |
441 | + .arg(QString::fromStdString(STORE_SCOPE_FULL_NAME)) |
442 | + .arg(QString(QUrl::toPercentEncoding(query, QByteArray{}, QByteArray{"."}))) |
443 | + .toStdString(); |
444 | + EXPECT_CALL(reply, push(testing::Matcher<unity::scopes::CategorisedResult const&>(HintPropertiesMatch("Install X Apps", data_dir+"/store.svg", full_scope, "transparent")))) |
445 | + .WillOnce(testing::Return(true)); |
446 | + } |
447 | + |
448 | void expect_push(std::string title, std::string art, std::string description, std::string appId, bool success = true) |
449 | { |
450 | EXPECT_CALL(reply, push(testing::Matcher<unity::scopes::CategorisedResult const&>(ResultPropertiesMatch(title, art, description, appId)))).WillOnce(testing::Return(success)); |
451 | @@ -151,6 +181,7 @@ |
452 | std::shared_ptr<FakeCategory> category; |
453 | std::shared_ptr<MockHiddenApps> hidden; |
454 | std::shared_ptr<MockBlacklist> blacklist; |
455 | + std::string data_dir; |
456 | }; |
457 | |
458 | |
459 | @@ -160,10 +191,11 @@ |
460 | expect_push_libreoffice(); |
461 | expect_push_linux(); |
462 | expect_push_library(); |
463 | + expect_hint_registry(); |
464 | |
465 | Query query(canned_query, metadata, []() { |
466 | return FakeLibertine::make_fake(LIBERTINE_OUTPUT_WITH_APPS); |
467 | - }, hidden, blacklist); |
468 | + }, hidden, blacklist, data_dir); |
469 | query.run(proxy); |
470 | } |
471 | |
472 | @@ -172,11 +204,12 @@ |
473 | { |
474 | expect_registry(); |
475 | expect_push_libreoffice(); |
476 | + expect_hint_registry("li.*office"); |
477 | canned_query.set_query_string("li.*office"); |
478 | |
479 | Query query(canned_query, metadata, []() { |
480 | return FakeLibertine::make_fake(LIBERTINE_OUTPUT_WITH_APPS); |
481 | - }, hidden, blacklist); |
482 | + }, hidden, blacklist, data_dir); |
483 | query.run(proxy); |
484 | } |
485 | |
486 | @@ -188,7 +221,7 @@ |
487 | |
488 | Query query(canned_query, metadata, []() { |
489 | return FakeLibertine::make_fake(LIBERTINE_OUTPUT_WITH_APPS); |
490 | - }, hidden, blacklist); |
491 | + }, hidden, blacklist, data_dir); |
492 | query.run(proxy); |
493 | } |
494 | |
495 | @@ -198,13 +231,14 @@ |
496 | expect_registry(); |
497 | expect_push_linux(); |
498 | expect_push_library(); |
499 | + expect_hint_registry(); |
500 | |
501 | EXPECT_CALL(*blacklist, app_is_blacklisted(QString("libreoffice"), "fake-container")) |
502 | .WillRepeatedly(testing::Return(true)); |
503 | |
504 | Query query(canned_query, metadata, []() { |
505 | return FakeLibertine::make_fake(LIBERTINE_OUTPUT_WITH_APPS); |
506 | - }, hidden, blacklist); |
507 | + }, hidden, blacklist, data_dir); |
508 | query.run(proxy); |
509 | } |
510 | |
511 | @@ -214,6 +248,7 @@ |
512 | expect_registry(); |
513 | expect_push_linux(); |
514 | expect_push_libreoffice(); |
515 | + expect_hint_registry(); |
516 | |
517 | EXPECT_CALL(*hidden, app_is_hidden(QString("fake-container/library"))) |
518 | .WillRepeatedly(testing::Return(true)); |
519 | @@ -222,7 +257,7 @@ |
520 | |
521 | Query query(canned_query, metadata, []() { |
522 | return FakeLibertine::make_fake(LIBERTINE_OUTPUT_WITH_APPS); |
523 | - }, hidden, blacklist); |
524 | + }, hidden, blacklist, data_dir); |
525 | query.run(proxy); |
526 | } |
527 | |
528 | @@ -241,37 +276,50 @@ |
529 | |
530 | Query query(canned_query, metadata, []() { |
531 | return FakeLibertine::make_fake(LIBERTINE_OUTPUT_WITH_APPS); |
532 | - }, hidden, blacklist); |
533 | + }, hidden, blacklist, data_dir); |
534 | query.run(proxy); |
535 | } |
536 | |
537 | |
538 | -TEST_F(TestQueryFixture, showsHintWhenAllAppsFiltered) |
539 | +TEST_F(TestQueryFixture, showsHintInHiddenDepartmentWhenAllAppsFiltered) |
540 | { |
541 | expect_registry(); |
542 | |
543 | EXPECT_CALL(reply, register_category("hint", "", "", testing::_)).WillOnce(testing::Return(category)); |
544 | EXPECT_CALL(reply, push(testing::Matcher<unity::scopes::CategorisedResult const&>(ResultTitleMatch(Query::ALL_RESULTS_FILTERED_HINT)))).WillOnce(testing::Return(true)); |
545 | |
546 | - EXPECT_CALL(*hidden, app_is_hidden(testing::_)).WillRepeatedly(testing::Return(true)); |
547 | + EXPECT_CALL(*hidden, app_is_hidden(QString("fake-container/library"))) |
548 | + .WillRepeatedly(testing::Return(true)); |
549 | + EXPECT_CALL(*hidden, empty()) |
550 | + .WillOnce(testing::Return(false)); |
551 | + |
552 | + canned_query.set_department_id(HIDDEN_DEPT_ID); |
553 | + canned_query.set_query_string("li.*office"); |
554 | |
555 | Query query(canned_query, metadata, []() { |
556 | return FakeLibertine::make_fake(LIBERTINE_OUTPUT_WITH_APPS); |
557 | - }, hidden, blacklist); |
558 | + }, hidden, blacklist, data_dir); |
559 | query.run(proxy); |
560 | } |
561 | |
562 | |
563 | -TEST_F(TestQueryFixture, showsHintWhenNoAppsInContainer) |
564 | +TEST_F(TestQueryFixture, showsHintInHiddenDepartmentWhenNoApps) |
565 | { |
566 | expect_registry(); |
567 | |
568 | EXPECT_CALL(reply, register_category("hint", "", "", testing::_)).WillOnce(testing::Return(category)); |
569 | EXPECT_CALL(reply, push(testing::Matcher<unity::scopes::CategorisedResult const&>(ResultTitleMatch(Query::NO_RESULTS_HINT)))).WillOnce(testing::Return(true)); |
570 | |
571 | + EXPECT_CALL(*hidden, app_is_hidden(QString("fake-container/library"))) |
572 | + .WillRepeatedly(testing::Return(true)); |
573 | + EXPECT_CALL(*hidden, empty()) |
574 | + .WillOnce(testing::Return(false)); |
575 | + |
576 | + canned_query.set_department_id(HIDDEN_DEPT_ID); |
577 | + |
578 | Query query(canned_query, metadata, []() { |
579 | return FakeLibertine::make_fake(""); |
580 | - }, hidden, blacklist); |
581 | - query.run(proxy); |
582 | -} |
583 | + }, hidden, blacklist, data_dir); |
584 | + query.run(proxy); |
585 | + } |
586 | } // anonymous namespace |
587 | |
588 | === modified file 'tests/scope/apps/test_scope.cpp' |
589 | --- tests/scope/apps/test_scope.cpp 2016-07-18 13:53:20 +0000 |
590 | +++ tests/scope/apps/test_scope.cpp 2016-09-19 14:03:05 +0000 |
591 | @@ -47,9 +47,9 @@ |
592 | |
593 | NiceMock<MockSearchReply> reply; |
594 | EXPECT_CALL(reply, register_category(_, _, _, _)) |
595 | - .Times(1) |
596 | - .WillOnce(Return(unity::scopes::Category::SCPtr(new unity::scopes::testing::Category("x", "y", "z", renderer)))); |
597 | - EXPECT_CALL(reply, push(Matcher<CategorisedResult const&>(_))).Times(2).WillRepeatedly(Return(true)); |
598 | + .Times(2) |
599 | + .WillRepeatedly(Return(unity::scopes::Category::SCPtr(new unity::scopes::testing::Category("x", "y", "z", renderer)))); |
600 | + EXPECT_CALL(reply, push(Matcher<CategorisedResult const&>(_))).Times(3).WillRepeatedly(Return(true)); |
601 | |
602 | SearchReplyProxy search_reply_proxy(&reply, [](unity::scopes::SearchReply*) {}); |
603 | search_query->run(search_reply_proxy); |
This works well. I'm sure the icon/graphic will change as well as the names for the store, but the only way to get it to change is put this in and make Design fix it:)
One little inline below...