Merge lp:~unity-api-team/unity-scope-click/blacklist-apps into lp:unity-scope-click
- blacklist-apps
- Merge into trunk
Status: | Rejected |
---|---|
Rejected by: | dobey |
Proposed branch: | lp:~unity-api-team/unity-scope-click/blacklist-apps |
Merge into: | lp:unity-scope-click |
Diff against target: |
377 lines (+143/-32) 10 files modified
data/com.canonical.unity.clickscope.gschema.xml (+6/-1) libclickscope/click/application.h (+22/-0) libclickscope/click/configuration.cpp (+15/-1) libclickscope/click/configuration.h (+2/-0) libclickscope/click/interface.cpp (+8/-2) libclickscope/click/interface.h (+2/-1) libclickscope/tests/test_configuration.cpp (+54/-0) libclickscope/tests/test_interface.cpp (+32/-2) scope/clickapps/apps-query.cpp (+2/-24) scope/clickapps/apps-query.h (+0/-1) |
To merge this branch: | bzr merge lp:~unity-api-team/unity-scope-click/blacklist-apps |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
dobey (community) | Needs Fixing | ||
PS Jenkins bot | continuous-integration | Needs Fixing | |
Review via email: mp+286518@code.launchpad.net |
Commit message
* Add "apps-blacklist" key to com.canonical.
- also change the description of "core-apps" keys
* Move click::
click:
* Add application blacklisting support to click::
- add get_apps_
- filter get_core_apps() through the blacklist
* Add blacklisting support for the click::
Description of the change
.
PS Jenkins bot (ps-jenkins) wrote : | # |
dobey (dobey) wrote : | # |
First thing I see is that the bug is not linked with commit --fixes on the commit.
Beyond that, the more I've looked at this MP, the less I like it. The code itself isn't terribly incorrect or anything, but the term "blacklist" just disturbs me, and the implementation here has some inconsistency with the existing implementation of the core-apps gsettings key. I'm also not fond of moving the one function into the struct in application.h. I also noticed that you modified the find_installed_
I've made an MP at https:/
Unmerged revisions
- 419. By Antti Kaijanmäki
-
blacklist applications
Preview Diff
1 | === modified file 'data/com.canonical.unity.clickscope.gschema.xml' | |||
2 | --- data/com.canonical.unity.clickscope.gschema.xml 2014-07-04 13:10:05 +0000 | |||
3 | +++ data/com.canonical.unity.clickscope.gschema.xml 2016-02-18 14:56:35 +0000 | |||
4 | @@ -4,7 +4,12 @@ | |||
5 | 4 | <key type="as" name="core-apps"> | 4 | <key type="as" name="core-apps"> |
6 | 5 | <default>[]</default> | 5 | <default>[]</default> |
7 | 6 | <summary>Applications to display in the top category of the Apps scope</summary> | 6 | <summary>Applications to display in the top category of the Apps scope</summary> |
9 | 7 | <description>List of application IDs that will be displayed in the upper area of the Applications scope for quick access.</description> | 7 | <description>List of application names that will be displayed in the upper area of the Applications scope for quick access.</description> |
10 | 8 | </key> | ||
11 | 9 | <key type="as" name="apps-blacklist"> | ||
12 | 10 | <default>[]</default> | ||
13 | 11 | <summary>Applications to be blacklisted from the Apps scope</summary> | ||
14 | 12 | <description>List of application names that will not be displayed in the Apps scope. Blacklisting is applied to search results as well as core-apps.</description> | ||
15 | 8 | </key> | 13 | </key> |
16 | 9 | </schema> | 14 | </schema> |
17 | 10 | </schemalist> | 15 | </schemalist> |
18 | 11 | 16 | ||
19 | === modified file 'libclickscope/click/application.h' | |||
20 | --- libclickscope/click/application.h 2014-08-08 08:20:38 +0000 | |||
21 | +++ libclickscope/click/application.h 2016-02-18 14:56:35 +0000 | |||
22 | @@ -62,6 +62,28 @@ | |||
23 | 62 | std::string default_department; | 62 | std::string default_department; |
24 | 63 | std::string real_department; | 63 | std::string real_department; |
25 | 64 | time_t installed_time; | 64 | time_t installed_time; |
26 | 65 | |||
27 | 66 | // | ||
28 | 67 | // Return an application name used to match applications against core-apps dconf key; | ||
29 | 68 | // For click apps, it just returns application name (e.g. com.canonical.calculator). | ||
30 | 69 | // For non-click apps, it return the desktop file name (without extension), taken from app uri. | ||
31 | 70 | std::string get_app_name() const | ||
32 | 71 | { | ||
33 | 72 | static const std::string app_prefix("application:///"); | ||
34 | 73 | if (!name.empty()) | ||
35 | 74 | { | ||
36 | 75 | return name; | ||
37 | 76 | } | ||
38 | 77 | if (url.size() > app_prefix.size()) | ||
39 | 78 | { | ||
40 | 79 | auto i = url.rfind('.'); | ||
41 | 80 | if (i != std::string::npos) | ||
42 | 81 | { | ||
43 | 82 | return url.substr(app_prefix.size(), i - app_prefix.size()); | ||
44 | 83 | } | ||
45 | 84 | } | ||
46 | 85 | throw std::runtime_error("Cannot determine application identifier for" + url); | ||
47 | 86 | } | ||
48 | 65 | }; | 87 | }; |
49 | 66 | 88 | ||
50 | 67 | std::ostream& operator<<(std::ostream& out, const Application& app); | 89 | std::ostream& operator<<(std::ostream& out, const Application& app); |
51 | 68 | 90 | ||
52 | === modified file 'libclickscope/click/configuration.cpp' | |||
53 | --- libclickscope/click/configuration.cpp 2015-11-24 19:14:11 +0000 | |||
54 | +++ libclickscope/click/configuration.cpp 2016-02-18 14:56:35 +0000 | |||
55 | @@ -27,6 +27,7 @@ | |||
56 | 27 | * files in the program, then also delete it here. | 27 | * files in the program, then also delete it here. |
57 | 28 | */ | 28 | */ |
58 | 29 | 29 | ||
59 | 30 | #include <algorithm> | ||
60 | 30 | #include <string> | 31 | #include <string> |
61 | 31 | #include <vector> | 32 | #include <vector> |
62 | 32 | 33 | ||
63 | @@ -232,7 +233,20 @@ | |||
64 | 232 | if (apps.empty()) { | 233 | if (apps.empty()) { |
65 | 233 | apps = get_default_core_apps(); | 234 | apps = get_default_core_apps(); |
66 | 234 | } | 235 | } |
68 | 235 | return apps; | 236 | |
69 | 237 | auto blacklist = get_apps_blacklist(); | ||
70 | 238 | auto end = std::remove_if(apps.begin(), | ||
71 | 239 | apps.end(), | ||
72 | 240 | [blacklist](std::string i) { | ||
73 | 241 | return std::count(blacklist.begin(), blacklist.end(), i) != 0; | ||
74 | 242 | }); | ||
75 | 243 | return std::vector<std::string>(apps.begin(), end); | ||
76 | 244 | } | ||
77 | 245 | |||
78 | 246 | const std::vector<std::string> Configuration::get_apps_blacklist() const | ||
79 | 247 | { | ||
80 | 248 | auto blacklist = get_dconf_strings(Configuration::COREAPPS_SCHEMA, Configuration::BLACKLIST_KEY); | ||
81 | 249 | return blacklist; | ||
82 | 236 | } | 250 | } |
83 | 237 | 251 | ||
84 | 238 | } // namespace click | 252 | } // namespace click |
85 | 239 | 253 | ||
86 | === modified file 'libclickscope/click/configuration.h' | |||
87 | --- libclickscope/click/configuration.h 2015-11-24 19:14:11 +0000 | |||
88 | +++ libclickscope/click/configuration.h 2016-02-18 14:56:35 +0000 | |||
89 | @@ -66,8 +66,10 @@ | |||
90 | 66 | 66 | ||
91 | 67 | constexpr static const char* COREAPPS_SCHEMA {"com.canonical.Unity.ClickScope"}; | 67 | constexpr static const char* COREAPPS_SCHEMA {"com.canonical.Unity.ClickScope"}; |
92 | 68 | constexpr static const char* COREAPPS_KEY {"coreApps"}; | 68 | constexpr static const char* COREAPPS_KEY {"coreApps"}; |
93 | 69 | constexpr static const char* BLACKLIST_KEY {"appsBlacklist"}; | ||
94 | 69 | 70 | ||
95 | 70 | virtual const std::vector<std::string> get_core_apps() const; | 71 | virtual const std::vector<std::string> get_core_apps() const; |
96 | 72 | virtual const std::vector<std::string> get_apps_blacklist() const; | ||
97 | 71 | virtual ~Configuration() {} | 73 | virtual ~Configuration() {} |
98 | 72 | protected: | 74 | protected: |
99 | 73 | virtual std::vector<std::string> list_folder(const std::string &folder, const std::string &pattern); | 75 | virtual std::vector<std::string> list_folder(const std::string &folder, const std::string &pattern); |
100 | 74 | 76 | ||
101 | === modified file 'libclickscope/click/interface.cpp' | |||
102 | --- libclickscope/click/interface.cpp 2016-01-04 20:56:17 +0000 | |||
103 | +++ libclickscope/click/interface.cpp 2016-02-18 14:56:35 +0000 | |||
104 | @@ -33,6 +33,7 @@ | |||
105 | 33 | #include <QStandardPaths> | 33 | #include <QStandardPaths> |
106 | 34 | #include <QTimer> | 34 | #include <QTimer> |
107 | 35 | 35 | ||
108 | 36 | #include <algorithm> | ||
109 | 36 | #include <cstdio> | 37 | #include <cstdio> |
110 | 37 | #include <list> | 38 | #include <list> |
111 | 38 | #include <sys/stat.h> | 39 | #include <sys/stat.h> |
112 | @@ -240,7 +241,8 @@ | |||
113 | 240 | */ | 241 | */ |
114 | 241 | std::vector<click::Application> Interface::find_installed_apps(const std::string& search_query, | 242 | std::vector<click::Application> Interface::find_installed_apps(const std::string& search_query, |
115 | 242 | const std::string& current_department, | 243 | const std::string& current_department, |
117 | 243 | const std::shared_ptr<click::DepartmentsDb>& depts_db) | 244 | const std::shared_ptr<click::DepartmentsDb>& depts_db, |
118 | 245 | const std::vector<std::string>& blacklist) | ||
119 | 244 | { | 246 | { |
120 | 245 | // | 247 | // |
121 | 246 | // only apply department filtering if not in root of all departments. | 248 | // only apply department filtering if not in root of all departments. |
122 | @@ -265,7 +267,7 @@ | |||
123 | 265 | 267 | ||
124 | 266 | bool include_desktop_results = show_desktop_apps(); | 268 | bool include_desktop_results = show_desktop_apps(); |
125 | 267 | 269 | ||
127 | 268 | auto enumerator = [&result, this, search_query, current_department, packages_in_department, apply_department_filter, include_desktop_results, depts_db] | 270 | auto enumerator = [&result, this, search_query, current_department, packages_in_department, apply_department_filter, include_desktop_results, depts_db, blacklist] |
128 | 269 | (const unity::util::IniParser& keyFile, const std::string& filename) | 271 | (const unity::util::IniParser& keyFile, const std::string& filename) |
129 | 270 | { | 272 | { |
130 | 271 | if (keyFile.has_group(DESKTOP_FILE_GROUP) == false) { | 273 | if (keyFile.has_group(DESKTOP_FILE_GROUP) == false) { |
131 | @@ -340,6 +342,10 @@ | |||
132 | 340 | } | 342 | } |
133 | 341 | } | 343 | } |
134 | 342 | 344 | ||
135 | 345 | if (std::count(blacklist.begin(), blacklist.end(), app.get_app_name()) != 0) { | ||
136 | 346 | return; | ||
137 | 347 | } | ||
138 | 348 | |||
139 | 343 | if (search_query.empty()) { | 349 | if (search_query.empty()) { |
140 | 344 | result.push_back(app); | 350 | result.push_back(app); |
141 | 345 | } else { | 351 | } else { |
142 | 346 | 352 | ||
143 | === modified file 'libclickscope/click/interface.h' | |||
144 | --- libclickscope/click/interface.h 2014-07-18 11:18:27 +0000 | |||
145 | +++ libclickscope/click/interface.h 2016-02-18 14:56:35 +0000 | |||
146 | @@ -94,7 +94,8 @@ | |||
147 | 94 | static std::vector<Application> sort_apps(const std::vector<Application>& apps); | 94 | static std::vector<Application> sort_apps(const std::vector<Application>& apps); |
148 | 95 | virtual std::vector<Application> find_installed_apps(const std::string& search_query, | 95 | virtual std::vector<Application> find_installed_apps(const std::string& search_query, |
149 | 96 | const std::string& current_department = "", | 96 | const std::string& current_department = "", |
151 | 97 | const std::shared_ptr<click::DepartmentsDb>& depts_db = nullptr); | 97 | const std::shared_ptr<click::DepartmentsDb>& depts_db = nullptr, |
152 | 98 | const std::vector<std::string>& blacklist = {}); | ||
153 | 98 | 99 | ||
154 | 99 | static bool is_non_click_app(const QString& filename); | 100 | static bool is_non_click_app(const QString& filename); |
155 | 100 | 101 | ||
156 | 101 | 102 | ||
157 | === modified file 'libclickscope/tests/test_configuration.cpp' | |||
158 | --- libclickscope/tests/test_configuration.cpp 2015-11-24 19:14:11 +0000 | |||
159 | +++ libclickscope/tests/test_configuration.cpp 2016-02-18 14:56:35 +0000 | |||
160 | @@ -27,6 +27,7 @@ | |||
161 | 27 | * files in the program, then also delete it here. | 27 | * files in the program, then also delete it here. |
162 | 28 | */ | 28 | */ |
163 | 29 | 29 | ||
164 | 30 | #include <algorithm> | ||
165 | 30 | #include <QStringList> | 31 | #include <QStringList> |
166 | 31 | 32 | ||
167 | 32 | #include <gmock/gmock.h> | 33 | #include <gmock/gmock.h> |
168 | @@ -47,6 +48,7 @@ | |||
169 | 47 | const std::string& folder, const std::string& pattern)); | 48 | const std::string& folder, const std::string& pattern)); |
170 | 48 | MOCK_CONST_METHOD2(get_dconf_strings, const std::vector<std::string>(const std::string& schema, const std::string& key)); | 49 | MOCK_CONST_METHOD2(get_dconf_strings, const std::vector<std::string>(const std::string& schema, const std::string& key)); |
171 | 49 | using Configuration::get_default_core_apps; | 50 | using Configuration::get_default_core_apps; |
172 | 51 | using Configuration::get_apps_blacklist; | ||
173 | 50 | }; | 52 | }; |
174 | 51 | 53 | ||
175 | 52 | } | 54 | } |
176 | @@ -56,6 +58,9 @@ | |||
177 | 56 | using namespace ::testing; | 58 | using namespace ::testing; |
178 | 57 | FakeConfiguration c; | 59 | FakeConfiguration c; |
179 | 58 | EXPECT_CALL(c, get_dconf_strings(Configuration::COREAPPS_SCHEMA, | 60 | EXPECT_CALL(c, get_dconf_strings(Configuration::COREAPPS_SCHEMA, |
180 | 61 | Configuration::BLACKLIST_KEY)) | ||
181 | 62 | .WillOnce(Return(std::vector<std::string>{})); | ||
182 | 63 | EXPECT_CALL(c, get_dconf_strings(Configuration::COREAPPS_SCHEMA, | ||
183 | 59 | Configuration::COREAPPS_KEY)) | 64 | Configuration::COREAPPS_KEY)) |
184 | 60 | .WillOnce(Return(std::vector<std::string>{"package1", "package2"})); | 65 | .WillOnce(Return(std::vector<std::string>{"package1", "package2"})); |
185 | 61 | auto found_apps = c.get_core_apps(); | 66 | auto found_apps = c.get_core_apps(); |
186 | @@ -68,6 +73,9 @@ | |||
187 | 68 | using namespace ::testing; | 73 | using namespace ::testing; |
188 | 69 | FakeConfiguration c; | 74 | FakeConfiguration c; |
189 | 70 | EXPECT_CALL(c, get_dconf_strings(Configuration::COREAPPS_SCHEMA, | 75 | EXPECT_CALL(c, get_dconf_strings(Configuration::COREAPPS_SCHEMA, |
190 | 76 | Configuration::BLACKLIST_KEY)) | ||
191 | 77 | .WillOnce(Return(std::vector<std::string>{})); | ||
192 | 78 | EXPECT_CALL(c, get_dconf_strings(Configuration::COREAPPS_SCHEMA, | ||
193 | 71 | Configuration::COREAPPS_KEY)) | 79 | Configuration::COREAPPS_KEY)) |
194 | 72 | .WillOnce(Return(std::vector<std::string>{})); | 80 | .WillOnce(Return(std::vector<std::string>{})); |
195 | 73 | auto found_apps = c.get_core_apps(); | 81 | auto found_apps = c.get_core_apps(); |
196 | @@ -75,6 +83,52 @@ | |||
197 | 75 | ASSERT_EQ(found_apps, expected_apps); | 83 | ASSERT_EQ(found_apps, expected_apps); |
198 | 76 | } | 84 | } |
199 | 77 | 85 | ||
200 | 86 | TEST(Configuration, getAppsBlacklist) | ||
201 | 87 | { | ||
202 | 88 | using namespace ::testing; | ||
203 | 89 | FakeConfiguration c; | ||
204 | 90 | EXPECT_CALL(c, get_dconf_strings(Configuration::COREAPPS_SCHEMA, | ||
205 | 91 | Configuration::BLACKLIST_KEY)) | ||
206 | 92 | .WillOnce(Return(std::vector<std::string>{"package1", "package2"})); | ||
207 | 93 | auto blacklist = c.get_apps_blacklist(); | ||
208 | 94 | auto expected = std::vector<std::string>{"package1", "package2"}; | ||
209 | 95 | ASSERT_EQ(blacklist, expected); | ||
210 | 96 | } | ||
211 | 97 | |||
212 | 98 | TEST(Configuration, getCoreAppsFoundBlacklisted) | ||
213 | 99 | { | ||
214 | 100 | using namespace ::testing; | ||
215 | 101 | FakeConfiguration c; | ||
216 | 102 | EXPECT_CALL(c, get_dconf_strings(Configuration::COREAPPS_SCHEMA, | ||
217 | 103 | Configuration::BLACKLIST_KEY)) | ||
218 | 104 | .WillOnce(Return(std::vector<std::string>{"package1"})); | ||
219 | 105 | EXPECT_CALL(c, get_dconf_strings(Configuration::COREAPPS_SCHEMA, | ||
220 | 106 | Configuration::COREAPPS_KEY)) | ||
221 | 107 | .WillOnce(Return(std::vector<std::string>{"package1", "package2"})); | ||
222 | 108 | auto found_apps = c.get_core_apps(); | ||
223 | 109 | auto expected_apps = std::vector<std::string>{"package2"}; | ||
224 | 110 | ASSERT_EQ(found_apps, expected_apps); | ||
225 | 111 | } | ||
226 | 112 | |||
227 | 113 | TEST(Configuration, getCoreAppsEmptyBlacklisted) | ||
228 | 114 | { | ||
229 | 115 | using namespace ::testing; | ||
230 | 116 | FakeConfiguration c; | ||
231 | 117 | EXPECT_CALL(c, get_dconf_strings(Configuration::COREAPPS_SCHEMA, | ||
232 | 118 | Configuration::BLACKLIST_KEY)) | ||
233 | 119 | .WillOnce(Return(std::vector<std::string>{"dialer-app", "messaging-app"})); | ||
234 | 120 | EXPECT_CALL(c, get_dconf_strings(Configuration::COREAPPS_SCHEMA, | ||
235 | 121 | Configuration::COREAPPS_KEY)) | ||
236 | 122 | .WillOnce(Return(std::vector<std::string>{})); | ||
237 | 123 | auto found_apps = c.get_core_apps(); | ||
238 | 124 | |||
239 | 125 | auto tmp = c.get_default_core_apps(); | ||
240 | 126 | auto end = std::remove_if(tmp.begin(), tmp.end(), [&c](std::string i){ return i == "dialer-app" || i == "messaging-app"; }); | ||
241 | 127 | std::vector<std::string> expected_apps(tmp.begin(), end); | ||
242 | 128 | |||
243 | 129 | ASSERT_EQ(found_apps, expected_apps); | ||
244 | 130 | } | ||
245 | 131 | |||
246 | 78 | TEST(Configuration, getAvailableFrameworksUsesRightFolder) | 132 | TEST(Configuration, getAvailableFrameworksUsesRightFolder) |
247 | 79 | { | 133 | { |
248 | 80 | using namespace ::testing; | 134 | using namespace ::testing; |
249 | 81 | 135 | ||
250 | === modified file 'libclickscope/tests/test_interface.cpp' | |||
251 | --- libclickscope/tests/test_interface.cpp 2016-01-04 20:56:17 +0000 | |||
252 | +++ libclickscope/tests/test_interface.cpp 2016-02-18 14:56:35 +0000 | |||
253 | @@ -35,6 +35,7 @@ | |||
254 | 35 | #include <QDir> | 35 | #include <QDir> |
255 | 36 | #include <QTimer> | 36 | #include <QTimer> |
256 | 37 | 37 | ||
257 | 38 | #include <algorithm> | ||
258 | 38 | #include <cstdlib> | 39 | #include <cstdlib> |
259 | 39 | 40 | ||
260 | 40 | #include <gmock/gmock.h> | 41 | #include <gmock/gmock.h> |
261 | @@ -379,7 +380,7 @@ | |||
262 | 379 | Interface::add_theme_scheme("/usr/share/unity8/graphics/applicationIcons/contacts-app@18.png")); | 380 | Interface::add_theme_scheme("/usr/share/unity8/graphics/applicationIcons/contacts-app@18.png")); |
263 | 380 | } | 381 | } |
264 | 381 | 382 | ||
266 | 382 | std::vector<click::Application> find_installed_apps(const std::string& query, bool include_desktop_results) | 383 | std::vector<click::Application> find_installed_apps(const std::string& query, bool include_desktop_results, const std::vector<std::string>& blacklist={}) |
267 | 383 | { | 384 | { |
268 | 384 | using namespace ::testing; | 385 | using namespace ::testing; |
269 | 385 | QSharedPointer<click::KeyFileLocator> keyFileLocator( | 386 | QSharedPointer<click::KeyFileLocator> keyFileLocator( |
270 | @@ -392,7 +393,7 @@ | |||
271 | 392 | .Times(1) | 393 | .Times(1) |
272 | 393 | .WillOnce(Return(include_desktop_results)); | 394 | .WillOnce(Return(include_desktop_results)); |
273 | 394 | 395 | ||
275 | 395 | return iface.find_installed_apps(query); | 396 | return iface.find_installed_apps(query, "", nullptr, blacklist); |
276 | 396 | } | 397 | } |
277 | 397 | 398 | ||
278 | 398 | TEST(ClickInterface, testFindInstalledAppsOnPhone) | 399 | TEST(ClickInterface, testFindInstalledAppsOnPhone) |
279 | @@ -410,6 +411,35 @@ | |||
280 | 410 | EXPECT_EQ(result.end(), std::find(result.begin(), result.end(), desktop_application)); | 411 | EXPECT_EQ(result.end(), std::find(result.begin(), result.end(), desktop_application)); |
281 | 411 | } | 412 | } |
282 | 412 | 413 | ||
283 | 414 | TEST(ClickInterface, testFindInstalledAppsOnPhoneBlacklist) | ||
284 | 415 | { | ||
285 | 416 | auto result = find_installed_apps(emptyQuery, false, {"com.ubuntu.terminal", "messaging-app"}); | ||
286 | 417 | |||
287 | 418 | EXPECT_TRUE(result.size() > 0); | ||
288 | 419 | |||
289 | 420 | std::vector<Application> tmp; | ||
290 | 421 | std::copy_if(non_desktop_applications.begin(), | ||
291 | 422 | non_desktop_applications.end(), | ||
292 | 423 | std::back_inserter(tmp), | ||
293 | 424 | [](const Application &app) { | ||
294 | 425 | if (app.get_app_name() == "com.ubuntu.terminal") { | ||
295 | 426 | return false; | ||
296 | 427 | } | ||
297 | 428 | if (app.get_app_name() == "messaging-app") { | ||
298 | 429 | return false; | ||
299 | 430 | } | ||
300 | 431 | return true; | ||
301 | 432 | }); | ||
302 | 433 | |||
303 | 434 | for (const auto& app : tmp) | ||
304 | 435 | { | ||
305 | 436 | qDebug() << "comparing" << QString::fromStdString(app.title); | ||
306 | 437 | EXPECT_NE(result.end(), std::find(result.begin(), result.end(), app)); | ||
307 | 438 | } | ||
308 | 439 | |||
309 | 440 | EXPECT_EQ(result.end(), std::find(result.begin(), result.end(), desktop_application)); | ||
310 | 441 | } | ||
311 | 442 | |||
312 | 413 | TEST(ClickInterface, testFindInstalledAppsOnDesktop) | 443 | TEST(ClickInterface, testFindInstalledAppsOnDesktop) |
313 | 414 | { | 444 | { |
314 | 415 | auto result = find_installed_apps(emptyQuery, true); | 445 | auto result = find_installed_apps(emptyQuery, true); |
315 | 416 | 446 | ||
316 | === modified file 'scope/clickapps/apps-query.cpp' | |||
317 | --- scope/clickapps/apps-query.cpp 2016-01-06 18:08:33 +0000 | |||
318 | +++ scope/clickapps/apps-query.cpp 2016-02-18 14:56:35 +0000 | |||
319 | @@ -130,28 +130,6 @@ | |||
320 | 130 | replyProxy->push(res); | 130 | replyProxy->push(res); |
321 | 131 | } | 131 | } |
322 | 132 | 132 | ||
323 | 133 | // | ||
324 | 134 | // Return an application identifier used to match applications against core-apps dconf key; | ||
325 | 135 | // For click apps, it just returns application name (e.g. com.canonical.calculator). | ||
326 | 136 | // For non-click apps, it return the desktop file name (without extension), taken from app uri. | ||
327 | 137 | std::string click::apps::ResultPusher::get_app_identifier(const click::Application& app) | ||
328 | 138 | { | ||
329 | 139 | static const std::string app_prefix("application:///"); | ||
330 | 140 | if (!app.name.empty()) | ||
331 | 141 | { | ||
332 | 142 | return app.name; | ||
333 | 143 | } | ||
334 | 144 | if (app.url.size() > app_prefix.size()) | ||
335 | 145 | { | ||
336 | 146 | auto i = app.url.rfind('.'); | ||
337 | 147 | if (i != std::string::npos) | ||
338 | 148 | { | ||
339 | 149 | return app.url.substr(app_prefix.size(), i - app_prefix.size()); | ||
340 | 150 | } | ||
341 | 151 | } | ||
342 | 152 | throw std::runtime_error("Cannot determine application identifier for" + app.url); | ||
343 | 153 | } | ||
344 | 154 | |||
345 | 155 | void click::apps::ResultPusher::push_local_results( | 133 | void click::apps::ResultPusher::push_local_results( |
346 | 156 | const std::vector<click::Application> &apps, | 134 | const std::vector<click::Application> &apps, |
347 | 157 | const std::string &categoryTemplate, | 135 | const std::string &categoryTemplate, |
348 | @@ -164,7 +142,7 @@ | |||
349 | 164 | { | 142 | { |
350 | 165 | try | 143 | try |
351 | 166 | { | 144 | { |
353 | 167 | if (top_apps_lookup.size() == 0 || top_apps_lookup.find(get_app_identifier(a)) == top_apps_lookup.end()) | 145 | if (top_apps_lookup.size() == 0 || top_apps_lookup.find(a.get_app_name()) == top_apps_lookup.end()) |
354 | 168 | { | 146 | { |
355 | 169 | push_result(cat, a); | 147 | push_result(cat, a); |
356 | 170 | } | 148 | } |
357 | @@ -190,7 +168,7 @@ | |||
358 | 190 | { | 168 | { |
359 | 191 | try | 169 | try |
360 | 192 | { | 170 | { |
362 | 193 | const auto id = get_app_identifier(a); | 171 | const auto id = a.get_app_name(); |
363 | 194 | if (top_apps_lookup.find(id) != top_apps_lookup.end()) | 172 | if (top_apps_lookup.find(id) != top_apps_lookup.end()) |
364 | 195 | { | 173 | { |
365 | 196 | top_apps_to_push[id] = a; | 174 | top_apps_to_push[id] = a; |
366 | 197 | 175 | ||
367 | === modified file 'scope/clickapps/apps-query.h' | |||
368 | --- scope/clickapps/apps-query.h 2014-08-19 18:21:14 +0000 | |||
369 | +++ scope/clickapps/apps-query.h 2016-02-18 14:56:35 +0000 | |||
370 | @@ -102,7 +102,6 @@ | |||
371 | 102 | const std::string& categoryTemplate); | 102 | const std::string& categoryTemplate); |
372 | 103 | protected: | 103 | protected: |
373 | 104 | virtual void push_result(scopes::Category::SCPtr& cat, const click::Application& a); | 104 | virtual void push_result(scopes::Category::SCPtr& cat, const click::Application& a); |
374 | 105 | static std::string get_app_identifier(const click::Application& app); | ||
375 | 106 | }; | 105 | }; |
376 | 107 | } // namespace apps | 106 | } // namespace apps |
377 | 108 | } // namespace query | 107 | } // namespace query |
FAILED: Continuous integration, rev:419 jenkins. qa.ubuntu. com/job/ unity-scope- click-ci/ 707/ jenkins. qa.ubuntu. com/job/ unity-scope- click-wily- amd64-ci/ 111/console jenkins. qa.ubuntu. com/job/ unity-scope- click-wily- armhf-ci/ 107/console
http://
Executed test runs:
FAILURE: http://
FAILURE: http://
Click here to trigger a rebuild: s-jenkins. ubuntu- ci:8080/ job/unity- scope-click- ci/707/ rebuild
http://