Merge lp:~mvo/unity-scope-click/lp1292645-use-libclick into lp:unity-scope-click/devel
- lp1292645-use-libclick
- Merge into devel
Status: | Rejected |
---|---|
Rejected by: | Alejandro J. Cura |
Proposed branch: | lp:~mvo/unity-scope-click/lp1292645-use-libclick |
Merge into: | lp:unity-scope-click/devel |
Diff against target: |
483 lines (+93/-248) 9 files modified
debian/control (+1/-0) debian/tests/control (+1/-0) scope/click/CMakeLists.txt (+3/-0) scope/click/configuration.cpp (+16/-2) scope/click/configuration.h (+0/-3) scope/click/interface.cpp (+67/-57) scope/click/interface.h (+0/-4) scope/tests/test_configuration.cpp (+4/-44) scope/tests/test_interface.cpp (+1/-138) |
To merge this branch: | bzr merge lp:~mvo/unity-scope-click/lp1292645-use-libclick |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Alejandro J. Cura (community) | Needs Information | ||
PS Jenkins bot (community) | continuous-integration | Approve | |
Michael Vogt (community) | Abstain | ||
dobey (community) | Needs Fixing | ||
Review via email: mp+220061@code.launchpad.net |
Commit message
Use libclick instead of spawning "click {info,list}"
Description of the change
This branch uses libclick to get the data of installed apps instead of doing run_process().
Please let me know how you want the tests. E.g. do you still want to test for the json parsing exception? Can gmock mock external libs and should I do this?
PS Jenkins bot (ps-jenkins) wrote : | # |
dobey (dobey) wrote : | # |
Can you please do "bzr commit --fixes=lp:1292645" to link the bug if this branch is fixing it? Thanks.
- 266. By Michael Vogt
-
* add missing --fixes=lp:1292645
Michael Vogt (mvo) wrote : | # |
Thanks, I commited the missing --fixes as the r266 to this branch.
dobey (dobey) wrote : | # |
Please don't vote "resubmit" on your own MPs. It's not necessary to vote on your own MP (can you please change your vote to "Abstain" instead)? That is not how one resubmits an MP (it's a vote by a reviewer that the submitter should resubmit for whatever provided reason). There's no need to generally resubmit reviews for every change made to satisfy a review request. :)
Michael Vogt (mvo) : | # |
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:266
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
Alejandro J. Cura (alecu) wrote : | # |
Hi mvo, thanks for working on this.
We can drop the tests that do the specific things that are now done on libclick, but I'd like to keep at least some of the tests that apply to these functions, so eg, looking at:
http://
in that branch I see that we can keep getAvailableFra
But gmock can only mock non-static methods, so the workaround is adding yet another class, like explained here: https:/
I started preparing a branch that show how to do this:
https:/
That branch is missing a way to create fake Framework instances, because their constructor is private; what should happen is that a new GObject type should be created that has the same "name" property as Framework. Or, perhaps simpler, its constructor should be made public in the vala library. I'm travelling tomorrow to the sprint, so I won't be able to continue working on this for a few days; feel free to take over it, or else I can work on my return.
In any case, I agree that this is a lot of work to test these functions that look so simple, so I'm open to discussing alternative options.
Thomas Voß (thomas-voss) wrote : | # |
Hey Michael,
thanks for getting this started. Looking at the code, we might want to have a click::Database abstract base-class, with simple structs Manifest and Framework summarizing all the attributes that the scope is interested in. With that, we could have:
namespace click
{
struct Manifest
{
// Omitting details here.
};
struct Framework
{
// Omitting details here.
};
class Database
{
public:
// Omitting boilerplate here
virtual void for_each_
virtual void for_each_
};
}
We then could think about having a:
namespace libclick
{
class Database : public click::Database
{
};
}
and would still be able to easily create instances of Manifest and Framework without requiring an instance of click::Database.
What do you think?
Michael Vogt (mvo) wrote : | # |
This is now superseeded by https:/
Unmerged revisions
- 266. By Michael Vogt
-
* add missing --fixes=lp:1292645
- 265. By Michael Vogt
-
fix typo
- 264. By Michael Vogt
-
use libclick instead of run_process("click {info,list}")
- 263. By Michael Vogt
-
use libclick instead of using list_folder() to get available frameworks
Preview Diff
1 | === modified file 'debian/control' | |||
2 | --- debian/control 2014-05-16 13:09:36 +0000 | |||
3 | +++ debian/control 2014-05-19 18:49:23 +0000 | |||
4 | @@ -6,6 +6,7 @@ | |||
5 | 6 | dh-translations, | 6 | dh-translations, |
6 | 7 | google-mock, | 7 | google-mock, |
7 | 8 | intltool, | 8 | intltool, |
8 | 9 | libclick-0.4-dev, | ||
9 | 9 | libglib2.0-dev (>= 2.32), | 10 | libglib2.0-dev (>= 2.32), |
10 | 10 | libjsoncpp-dev, | 11 | libjsoncpp-dev, |
11 | 11 | libubuntu-download-manager-client-dev (>= 0.3+14.10.20140430-0ubuntu1), | 12 | libubuntu-download-manager-client-dev (>= 0.3+14.10.20140430-0ubuntu1), |
12 | 12 | 13 | ||
13 | === modified file 'debian/tests/control' | |||
14 | --- debian/tests/control 2013-12-17 17:56:49 +0000 | |||
15 | +++ debian/tests/control 2014-05-19 18:49:23 +0000 | |||
16 | @@ -5,6 +5,7 @@ | |||
17 | 5 | dh-autoreconf, | 5 | dh-autoreconf, |
18 | 6 | gnome-common, | 6 | gnome-common, |
19 | 7 | libaccounts-glib-dev, | 7 | libaccounts-glib-dev, |
20 | 8 | libclick-0.4-dev, | ||
21 | 8 | libdee-dev (>= 1.2.5), | 9 | libdee-dev (>= 1.2.5), |
22 | 9 | libgee-dev, | 10 | libgee-dev, |
23 | 10 | libglib2.0-dev (>= 2.32), | 11 | libglib2.0-dev (>= 2.32), |
24 | 11 | 12 | ||
25 | === modified file 'scope/click/CMakeLists.txt' | |||
26 | --- scope/click/CMakeLists.txt 2014-05-13 19:32:29 +0000 | |||
27 | +++ scope/click/CMakeLists.txt 2014-05-19 18:49:23 +0000 | |||
28 | @@ -2,6 +2,7 @@ | |||
29 | 2 | SET (CMAKE_AUTOMOC ON) | 2 | SET (CMAKE_AUTOMOC ON) |
30 | 3 | find_package (Qt5Core REQUIRED) | 3 | find_package (Qt5Core REQUIRED) |
31 | 4 | pkg_check_modules(JSON_CPP REQUIRED jsoncpp) | 4 | pkg_check_modules(JSON_CPP REQUIRED jsoncpp) |
32 | 5 | pkg_check_modules(CLICK REQUIRED click-0.4) | ||
33 | 5 | 6 | ||
34 | 6 | add_definitions( | 7 | add_definitions( |
35 | 7 | -DGETTEXT_PACKAGE=\"${PROJECT_NAME}\" | 8 | -DGETTEXT_PACKAGE=\"${PROJECT_NAME}\" |
36 | @@ -30,6 +31,7 @@ | |||
37 | 30 | include_directories( | 31 | include_directories( |
38 | 31 | ${CMAKE_SOURCE_DIR}/libclickscope | 32 | ${CMAKE_SOURCE_DIR}/libclickscope |
39 | 32 | ${JSON_CPP_INCLUDE_DIRS} | 33 | ${JSON_CPP_INCLUDE_DIRS} |
40 | 34 | ${CLICK_INCLUDE_DIRS} | ||
41 | 33 | ) | 35 | ) |
42 | 34 | 36 | ||
43 | 35 | qt5_use_modules (${SCOPE_LIB_UNVERSIONED} Network) | 37 | qt5_use_modules (${SCOPE_LIB_UNVERSIONED} Network) |
44 | @@ -42,6 +44,7 @@ | |||
45 | 42 | ${UBUNTUONE_LDFLAGS} | 44 | ${UBUNTUONE_LDFLAGS} |
46 | 43 | ${UBUNTU_DOWNLOAD_MANAGER_CLIENT_LDFLAGS} | 45 | ${UBUNTU_DOWNLOAD_MANAGER_CLIENT_LDFLAGS} |
47 | 44 | ${UBUNTU_DOWNLOAD_MANAGER_COMMON_LDFLAGS} | 46 | ${UBUNTU_DOWNLOAD_MANAGER_COMMON_LDFLAGS} |
48 | 47 | ${CLICK_LDFLAGS} | ||
49 | 45 | ) | 48 | ) |
50 | 46 | 49 | ||
51 | 47 | install( | 50 | install( |
52 | 48 | 51 | ||
53 | === modified file 'scope/click/configuration.cpp' | |||
54 | --- scope/click/configuration.cpp 2014-05-01 21:04:23 +0000 | |||
55 | +++ scope/click/configuration.cpp 2014-05-19 18:49:23 +0000 | |||
56 | @@ -27,6 +27,10 @@ | |||
57 | 27 | * files in the program, then also delete it here. | 27 | * files in the program, then also delete it here. |
58 | 28 | */ | 28 | */ |
59 | 29 | 29 | ||
60 | 30 | #include <glib.h> | ||
61 | 31 | #include <click.h> | ||
62 | 32 | |||
63 | 33 | |||
64 | 30 | #include <string> | 34 | #include <string> |
65 | 31 | #include <vector> | 35 | #include <vector> |
66 | 32 | 36 | ||
67 | @@ -57,10 +61,20 @@ | |||
68 | 57 | 61 | ||
69 | 58 | std::vector<std::string> Configuration::get_available_frameworks() | 62 | std::vector<std::string> Configuration::get_available_frameworks() |
70 | 59 | { | 63 | { |
71 | 64 | GList *l = nullptr; | ||
72 | 65 | GList *frameworks = l = click_framework_get_frameworks(); | ||
73 | 66 | |||
74 | 60 | std::vector<std::string> result; | 67 | std::vector<std::string> result; |
77 | 61 | for (auto f: list_folder(FRAMEWORKS_FOLDER, FRAMEWORKS_PATTERN)) { | 68 | while (l != nullptr) { |
78 | 62 | result.push_back(f.substr(0, f.size()-FRAMEWORKS_EXTENSION_LENGTH)); | 69 | gchar *framework_name = nullptr; |
79 | 70 | GObject *framework = (GObject *)l->data; | ||
80 | 71 | g_object_get(framework, "name", &framework_name, nullptr); | ||
81 | 72 | result.push_back(framework_name); | ||
82 | 73 | l = g_list_next(l); | ||
83 | 74 | g_free(framework_name); | ||
84 | 63 | } | 75 | } |
85 | 76 | g_list_free_full(frameworks, g_object_unref); | ||
86 | 77 | |||
87 | 64 | return result; | 78 | return result; |
88 | 65 | } | 79 | } |
89 | 66 | 80 | ||
90 | 67 | 81 | ||
91 | === modified file 'scope/click/configuration.h' | |||
92 | --- scope/click/configuration.h 2014-05-01 21:04:23 +0000 | |||
93 | +++ scope/click/configuration.h 2014-05-19 18:49:23 +0000 | |||
94 | @@ -39,9 +39,6 @@ | |||
95 | 39 | class Configuration | 39 | class Configuration |
96 | 40 | { | 40 | { |
97 | 41 | public: | 41 | public: |
98 | 42 | constexpr static const char* FRAMEWORKS_FOLDER {"/usr/share/click/frameworks/"}; | ||
99 | 43 | constexpr static const char* FRAMEWORKS_PATTERN {"*.framework"}; | ||
100 | 44 | constexpr static const int FRAMEWORKS_EXTENSION_LENGTH = 10; // strlen(".framework") | ||
101 | 45 | constexpr static const char* LANGUAGE_ENVVAR {"LANGUAGE"}; | 42 | constexpr static const char* LANGUAGE_ENVVAR {"LANGUAGE"}; |
102 | 46 | 43 | ||
103 | 47 | virtual std::vector<std::string> get_available_frameworks(); | 44 | virtual std::vector<std::string> get_available_frameworks(); |
104 | 48 | 45 | ||
105 | === modified file 'scope/click/interface.cpp' | |||
106 | --- scope/click/interface.cpp 2014-05-13 19:32:29 +0000 | |||
107 | +++ scope/click/interface.cpp 2014-05-19 18:49:23 +0000 | |||
108 | @@ -27,6 +27,8 @@ | |||
109 | 27 | * files in the program, then also delete it here. | 27 | * files in the program, then also delete it here. |
110 | 28 | */ | 28 | */ |
111 | 29 | 29 | ||
112 | 30 | #include <click-0.4/click.h> | ||
113 | 31 | |||
114 | 30 | #include <QDebug> | 32 | #include <QDebug> |
115 | 31 | #include <QDir> | 33 | #include <QDir> |
116 | 32 | #include <QProcess> | 34 | #include <QProcess> |
117 | @@ -323,39 +325,76 @@ | |||
118 | 323 | 325 | ||
119 | 324 | void Interface::get_manifests(std::function<void(ManifestList, ManifestError)> callback) | 326 | void Interface::get_manifests(std::function<void(ManifestList, ManifestError)> callback) |
120 | 325 | { | 327 | { |
135 | 326 | std::string command = "click list --manifest"; | 328 | ClickDB *db = click_db_new(); |
136 | 327 | qDebug() << "Running command:" << command.c_str(); | 329 | GError *error = NULL; |
137 | 328 | run_process(command, [callback](int code, const std::string& stdout_data, const std::string&) { | 330 | char *c_output = NULL; |
138 | 329 | if (code == 0) { | 331 | std::string manifest_data; |
139 | 330 | try { | 332 | |
140 | 331 | ManifestList manifests = manifest_list_from_json(stdout_data); | 333 | c_output = click_db_get_manifests_as_string(db, false, &error); |
141 | 332 | callback(manifests, ManifestError::NoError); | 334 | g_object_unref(db); |
142 | 333 | } catch (...) { | 335 | if (error != NULL) |
143 | 334 | callback(ManifestList(), ManifestError::ParseError); | 336 | { |
144 | 335 | } | 337 | g_error_free(error); |
145 | 336 | } else { | 338 | // FIXME: pass the GError details on |
146 | 337 | callback(ManifestList(), ManifestError::CallError); | 339 | callback(ManifestList(), ManifestError::CallError); |
147 | 338 | } | 340 | } |
148 | 339 | }); | 341 | manifest_data = c_output; |
149 | 342 | g_free(c_output); | ||
150 | 343 | |||
151 | 344 | try { | ||
152 | 345 | ManifestList manifests = manifest_list_from_json(manifest_data); | ||
153 | 346 | callback(manifests, ManifestError::NoError); | ||
154 | 347 | } catch (...) { | ||
155 | 348 | callback(ManifestList(), ManifestError::ParseError); | ||
156 | 349 | } | ||
157 | 340 | } | 350 | } |
158 | 341 | 351 | ||
159 | 342 | void Interface::get_manifest_for_app(const std::string &app_id, | 352 | void Interface::get_manifest_for_app(const std::string &app_id, |
160 | 343 | std::function<void(Manifest, ManifestError)> callback) | 353 | std::function<void(Manifest, ManifestError)> callback) |
161 | 344 | { | 354 | { |
176 | 345 | std::string command = "click info " + app_id; | 355 | GError *error = NULL; |
177 | 346 | qDebug() << "Running command:" << command.c_str(); | 356 | ClickDB *db = NULL; |
178 | 347 | run_process(command, [callback](int code, const std::string& stdout_data, const std::string&) { | 357 | ClickUser *user = NULL; |
179 | 348 | if (code == 0) { | 358 | char *c_output = NULL; |
180 | 349 | try { | 359 | |
181 | 350 | Manifest manifest = manifest_from_json(stdout_data); | 360 | db = click_db_new(); |
182 | 351 | callback(manifest, ManifestError::NoError); | 361 | click_db_read(db, NULL, &error); |
183 | 352 | } catch (...) { | 362 | if (error != NULL) { |
184 | 353 | callback(Manifest(), ManifestError::ParseError); | 363 | g_error_free (error); |
185 | 354 | } | 364 | g_object_unref(db); |
186 | 355 | } else { | 365 | // FIXME: pass error data along |
187 | 356 | callback(Manifest(), ManifestError::CallError); | 366 | callback(Manifest(), ManifestError::CallError); |
188 | 357 | } | 367 | } |
189 | 358 | }); | 368 | |
190 | 369 | user = click_user_new_for_user(db, NULL, &error); | ||
191 | 370 | if (error != NULL) { | ||
192 | 371 | g_error_free (error); | ||
193 | 372 | g_object_unref(db); | ||
194 | 373 | // FIXME: pass error data along | ||
195 | 374 | callback(Manifest(), ManifestError::CallError); | ||
196 | 375 | } | ||
197 | 376 | if (click_user_has_package_name(user, app_id.c_str()) == false) { | ||
198 | 377 | g_error_free (error); | ||
199 | 378 | g_object_unref(db); | ||
200 | 379 | g_object_unref(user); | ||
201 | 380 | // FIXME: hm, not a call error as such really more a NotInstalledError ? | ||
202 | 381 | callback(Manifest(), ManifestError::CallError); | ||
203 | 382 | } | ||
204 | 383 | |||
205 | 384 | c_output = click_user_get_manifest_as_string (user, app_id.c_str(), &error); | ||
206 | 385 | std::string json_output = c_output; | ||
207 | 386 | |||
208 | 387 | g_free(c_output); | ||
209 | 388 | g_object_unref(db); | ||
210 | 389 | g_object_unref(user); | ||
211 | 390 | |||
212 | 391 | try { | ||
213 | 392 | Manifest manifest = manifest_from_json(json_output); | ||
214 | 393 | callback(manifest, ManifestError::NoError); | ||
215 | 394 | } catch (...) { | ||
216 | 395 | callback(Manifest(), ManifestError::ParseError); | ||
217 | 396 | } | ||
218 | 397 | |||
219 | 359 | } | 398 | } |
220 | 360 | 399 | ||
221 | 361 | void Interface::get_dotdesktop_filename(const std::string &app_id, | 400 | void Interface::get_dotdesktop_filename(const std::string &app_id, |
222 | @@ -380,33 +419,4 @@ | |||
223 | 380 | }); | 419 | }); |
224 | 381 | } | 420 | } |
225 | 382 | 421 | ||
226 | 383 | void Interface::run_process(const std::string& command, | ||
227 | 384 | std::function<void(int code, | ||
228 | 385 | const std::string& stdout_data, | ||
229 | 386 | const std::string& stderr_data)> callback) | ||
230 | 387 | { | ||
231 | 388 | QSharedPointer<QProcess> process(new QProcess()); | ||
232 | 389 | typedef void(QProcess::*QProcessFinished)(int, QProcess::ExitStatus); | ||
233 | 390 | typedef void(QProcess::*QProcessError)(QProcess::ProcessError); | ||
234 | 391 | QObject::connect(process.data(), | ||
235 | 392 | static_cast<QProcessFinished>(&QProcess::finished), | ||
236 | 393 | [callback, process](int code, QProcess::ExitStatus /*status*/) { | ||
237 | 394 | qDebug() << "command finished with exit code:" << code; | ||
238 | 395 | auto data = process.data()->readAllStandardOutput().data(); | ||
239 | 396 | auto errors = process.data()->readAllStandardError().data(); | ||
240 | 397 | callback(code, data, errors); | ||
241 | 398 | } ); | ||
242 | 399 | |||
243 | 400 | QObject::connect(process.data(), | ||
244 | 401 | static_cast<QProcessError>(&QProcess::error), | ||
245 | 402 | [callback, process](QProcess::ProcessError error) { | ||
246 | 403 | qCritical() << "error running command:" << error; | ||
247 | 404 | auto data = process.data()->readAllStandardOutput().data(); | ||
248 | 405 | auto errors = process.data()->readAllStandardError().data(); | ||
249 | 406 | callback(process.data()->exitCode(), data, errors); | ||
250 | 407 | } ); | ||
251 | 408 | |||
252 | 409 | process->start(command.c_str()); | ||
253 | 410 | } | ||
254 | 411 | |||
255 | 412 | } // namespace click | 422 | } // namespace click |
256 | 413 | 423 | ||
257 | === modified file 'scope/click/interface.h' | |||
258 | --- scope/click/interface.h 2014-05-06 19:17:30 +0000 | |||
259 | +++ scope/click/interface.h 2014-05-19 18:49:23 +0000 | |||
260 | @@ -95,10 +95,6 @@ | |||
261 | 95 | virtual bool is_visible_app(const unity::util::IniParser& keyFile); | 95 | virtual bool is_visible_app(const unity::util::IniParser& keyFile); |
262 | 96 | virtual bool show_desktop_apps(); | 96 | virtual bool show_desktop_apps(); |
263 | 97 | 97 | ||
264 | 98 | virtual void run_process(const std::string& command, | ||
265 | 99 | std::function<void(int code, | ||
266 | 100 | const std::string& stdout_data, | ||
267 | 101 | const std::string& stderr_data)> callback); | ||
268 | 102 | private: | 98 | private: |
269 | 103 | QSharedPointer<KeyFileLocator> keyFileLocator; | 99 | QSharedPointer<KeyFileLocator> keyFileLocator; |
270 | 104 | }; | 100 | }; |
271 | 105 | 101 | ||
272 | === modified file 'scope/tests/test_configuration.cpp' | |||
273 | --- scope/tests/test_configuration.cpp 2014-05-01 21:04:23 +0000 | |||
274 | +++ scope/tests/test_configuration.cpp 2014-05-19 18:49:23 +0000 | |||
275 | @@ -46,50 +46,10 @@ | |||
276 | 46 | 46 | ||
277 | 47 | } | 47 | } |
278 | 48 | 48 | ||
323 | 49 | 49 | TEST(Configuration, getAvailableFrameworksSmokeTest) | |
324 | 50 | TEST(Configuration, getAvailableFrameworksUsesRightFolder) | 50 | { |
325 | 51 | { | 51 | FakeConfiguration locator; |
326 | 52 | using namespace ::testing; | 52 | std::vector<std::string> frameworks = locator.get_available_frameworks(); |
283 | 53 | FakeConfiguration locator; | ||
284 | 54 | EXPECT_CALL(locator, list_folder(Configuration::FRAMEWORKS_FOLDER, _)) | ||
285 | 55 | .Times(1).WillOnce(Return(std::vector<std::string>())); | ||
286 | 56 | locator.get_available_frameworks(); | ||
287 | 57 | } | ||
288 | 58 | |||
289 | 59 | TEST(Configuration, getAvailableFrameworksUsesRightPattern) | ||
290 | 60 | { | ||
291 | 61 | using namespace ::testing; | ||
292 | 62 | FakeConfiguration locator; | ||
293 | 63 | EXPECT_CALL(locator, list_folder(_, Configuration::FRAMEWORKS_PATTERN)) | ||
294 | 64 | .Times(1).WillOnce(Return(std::vector<std::string>())); | ||
295 | 65 | locator.get_available_frameworks(); | ||
296 | 66 | } | ||
297 | 67 | |||
298 | 68 | TEST(Configuration, getAvailableFrameworksTwoResults) | ||
299 | 69 | { | ||
300 | 70 | using namespace ::testing; | ||
301 | 71 | |||
302 | 72 | FakeConfiguration locator; | ||
303 | 73 | std::vector<std::string> response = {"abc.framework", "def.framework"}; | ||
304 | 74 | EXPECT_CALL(locator, list_folder(_, _)) | ||
305 | 75 | .Times(1) | ||
306 | 76 | .WillOnce(Return(response)); | ||
307 | 77 | auto frameworks = locator.get_available_frameworks(); | ||
308 | 78 | std::vector<std::string> expected = {"abc", "def"}; | ||
309 | 79 | EXPECT_EQ(expected, frameworks); | ||
310 | 80 | } | ||
311 | 81 | |||
312 | 82 | TEST(Configuration, getAvailableFrameworksNoResults) | ||
313 | 83 | { | ||
314 | 84 | using namespace ::testing; | ||
315 | 85 | |||
316 | 86 | FakeConfiguration locator; | ||
317 | 87 | std::vector<std::string> response = {}; | ||
318 | 88 | EXPECT_CALL(locator, list_folder(_, _)) | ||
319 | 89 | .Times(1) | ||
320 | 90 | .WillOnce(Return(response)); | ||
321 | 91 | auto frameworks = locator.get_available_frameworks(); | ||
322 | 92 | EXPECT_EQ(0, frameworks.size()); | ||
327 | 93 | } | 53 | } |
328 | 94 | 54 | ||
329 | 95 | TEST(Configuration, getLanguageCorrect) | 55 | TEST(Configuration, getLanguageCorrect) |
330 | 96 | 56 | ||
331 | === modified file 'scope/tests/test_interface.cpp' | |||
332 | --- scope/tests/test_interface.cpp 2014-05-06 19:17:30 +0000 | |||
333 | +++ scope/tests/test_interface.cpp 2014-05-19 18:49:23 +0000 | |||
334 | @@ -130,7 +130,6 @@ | |||
335 | 130 | FakeClickInterface() {} | 130 | FakeClickInterface() {} |
336 | 131 | 131 | ||
337 | 132 | MOCK_METHOD0(show_desktop_apps, bool()); | 132 | MOCK_METHOD0(show_desktop_apps, bool()); |
338 | 133 | MOCK_METHOD2(run_process, void(const std::string&, std::function<void(int, const std::string&, const std::string&)>)); | ||
339 | 134 | }; | 133 | }; |
340 | 135 | 134 | ||
341 | 136 | TEST(ClickInterface, testIsNonClickAppFalse) | 135 | TEST(ClickInterface, testIsNonClickAppFalse) |
342 | @@ -320,140 +319,4 @@ | |||
343 | 320 | EXPECT_FALSE(iface.show_desktop_apps()); | 319 | EXPECT_FALSE(iface.show_desktop_apps()); |
344 | 321 | } | 320 | } |
345 | 322 | 321 | ||
483 | 323 | TEST(ClickInterface, testGetManifestForAppCorrectCommand) | 322 | // FIXME: re-add tests by mocking libclick |
347 | 324 | { | ||
348 | 325 | FakeClickInterface iface; | ||
349 | 326 | std::string command = "click info " + FAKE_PACKAGENAME; | ||
350 | 327 | EXPECT_CALL(iface, run_process(command, _)). | ||
351 | 328 | Times(1); | ||
352 | 329 | iface.get_manifest_for_app(FAKE_PACKAGENAME, [](Manifest, ManifestError){}); | ||
353 | 330 | } | ||
354 | 331 | |||
355 | 332 | TEST_F(ClickInterfaceTest, testGetManifestForAppParseError) | ||
356 | 333 | { | ||
357 | 334 | FakeClickInterface iface; | ||
358 | 335 | EXPECT_CALL(iface, run_process(_, _)). | ||
359 | 336 | Times(1). | ||
360 | 337 | WillOnce(Invoke([&](const std::string&, | ||
361 | 338 | std::function<void(int, const std::string&, | ||
362 | 339 | const std::string&)> callback){ | ||
363 | 340 | callback(0, "INVALID JSON", ""); | ||
364 | 341 | })); | ||
365 | 342 | EXPECT_CALL(*this, manifest_callback(_, ManifestError::ParseError)); | ||
366 | 343 | iface.get_manifest_for_app(FAKE_PACKAGENAME, [this](Manifest manifest, | ||
367 | 344 | ManifestError error){ | ||
368 | 345 | manifest_callback(manifest, error); | ||
369 | 346 | }); | ||
370 | 347 | } | ||
371 | 348 | |||
372 | 349 | TEST_F(ClickInterfaceTest, testGetManifestForAppCommandFailed) | ||
373 | 350 | { | ||
374 | 351 | FakeClickInterface iface; | ||
375 | 352 | EXPECT_CALL(iface, run_process(_, _)). | ||
376 | 353 | Times(1). | ||
377 | 354 | WillOnce(Invoke([&](const std::string&, | ||
378 | 355 | std::function<void(int, const std::string&, | ||
379 | 356 | const std::string&)> callback){ | ||
380 | 357 | callback(-1, "", "CRITICAL: FAIL"); | ||
381 | 358 | })); | ||
382 | 359 | EXPECT_CALL(*this, manifest_callback(_, ManifestError::CallError)); | ||
383 | 360 | iface.get_manifest_for_app(FAKE_PACKAGENAME, [this](Manifest manifest, | ||
384 | 361 | ManifestError error){ | ||
385 | 362 | manifest_callback(manifest, error); | ||
386 | 363 | }); | ||
387 | 364 | } | ||
388 | 365 | |||
389 | 366 | TEST_F(ClickInterfaceTest, testGetManifestForAppIsRemovable) | ||
390 | 367 | { | ||
391 | 368 | FakeClickInterface iface; | ||
392 | 369 | EXPECT_CALL(iface, run_process(_, _)). | ||
393 | 370 | Times(1). | ||
394 | 371 | WillOnce(Invoke([&](const std::string&, | ||
395 | 372 | std::function<void(int, const std::string&, | ||
396 | 373 | const std::string&)> callback){ | ||
397 | 374 | callback(0, FAKE_JSON_MANIFEST_REMOVABLE, ""); | ||
398 | 375 | })); | ||
399 | 376 | iface.get_manifest_for_app(FAKE_PACKAGENAME, [](Manifest manifest, | ||
400 | 377 | ManifestError error){ | ||
401 | 378 | ASSERT_TRUE(error == ManifestError::NoError); | ||
402 | 379 | ASSERT_TRUE(manifest.removable); | ||
403 | 380 | }); | ||
404 | 381 | } | ||
405 | 382 | |||
406 | 383 | TEST_F(ClickInterfaceTest, testGetManifestForAppIsNotRemovable) | ||
407 | 384 | { | ||
408 | 385 | FakeClickInterface iface; | ||
409 | 386 | EXPECT_CALL(iface, run_process(_, _)). | ||
410 | 387 | Times(1). | ||
411 | 388 | WillOnce(Invoke([&](const std::string&, | ||
412 | 389 | std::function<void(int, const std::string&, | ||
413 | 390 | const std::string&)> callback){ | ||
414 | 391 | callback(0, FAKE_JSON_MANIFEST_NONREMOVABLE, ""); | ||
415 | 392 | })); | ||
416 | 393 | iface.get_manifest_for_app(FAKE_PACKAGENAME, [](Manifest manifest, | ||
417 | 394 | ManifestError error){ | ||
418 | 395 | ASSERT_TRUE(error == ManifestError::NoError); | ||
419 | 396 | ASSERT_FALSE(manifest.removable); | ||
420 | 397 | }); | ||
421 | 398 | } | ||
422 | 399 | |||
423 | 400 | TEST(ClickInterface, testGetManifestsCorrectCommand) | ||
424 | 401 | { | ||
425 | 402 | FakeClickInterface iface; | ||
426 | 403 | std::string command = "click list --manifest"; | ||
427 | 404 | EXPECT_CALL(iface, run_process(command, _)). | ||
428 | 405 | Times(1); | ||
429 | 406 | iface.get_manifests([](ManifestList, ManifestError){}); | ||
430 | 407 | } | ||
431 | 408 | |||
432 | 409 | TEST_F(ClickInterfaceTest, testGetManifestsParseError) | ||
433 | 410 | { | ||
434 | 411 | FakeClickInterface iface; | ||
435 | 412 | EXPECT_CALL(iface, run_process(_, _)). | ||
436 | 413 | Times(1). | ||
437 | 414 | WillOnce(Invoke([&](const std::string&, | ||
438 | 415 | std::function<void(int, const std::string&, | ||
439 | 416 | const std::string&)> callback){ | ||
440 | 417 | callback(0, "INVALID JSON", ""); | ||
441 | 418 | })); | ||
442 | 419 | EXPECT_CALL(*this, manifests_callback(_, ManifestError::ParseError)); | ||
443 | 420 | iface.get_manifests([this](ManifestList manifests, ManifestError error){ | ||
444 | 421 | manifests_callback(manifests, error); | ||
445 | 422 | }); | ||
446 | 423 | } | ||
447 | 424 | |||
448 | 425 | TEST_F(ClickInterfaceTest, testGetManifestsCommandFailed) | ||
449 | 426 | { | ||
450 | 427 | FakeClickInterface iface; | ||
451 | 428 | EXPECT_CALL(iface, run_process(_, _)). | ||
452 | 429 | Times(1). | ||
453 | 430 | WillOnce(Invoke([&](const std::string&, | ||
454 | 431 | std::function<void(int, const std::string&, | ||
455 | 432 | const std::string&)> callback){ | ||
456 | 433 | callback(-1, "", "CRITICAL: FAIL"); | ||
457 | 434 | })); | ||
458 | 435 | EXPECT_CALL(*this, manifests_callback(_, ManifestError::CallError)); | ||
459 | 436 | iface.get_manifests([this](ManifestList manifests, ManifestError error){ | ||
460 | 437 | manifests_callback(manifests, error); | ||
461 | 438 | }); | ||
462 | 439 | } | ||
463 | 440 | |||
464 | 441 | TEST_F(ClickInterfaceTest, testGetManifestsParsed) | ||
465 | 442 | { | ||
466 | 443 | FakeClickInterface iface; | ||
467 | 444 | std::string expected_str = "[" + FAKE_JSON_MANIFEST_NONREMOVABLE + "," + | ||
468 | 445 | FAKE_JSON_MANIFEST_REMOVABLE + "]"; | ||
469 | 446 | ManifestList expected = manifest_list_from_json(expected_str); | ||
470 | 447 | |||
471 | 448 | EXPECT_CALL(iface, run_process(_, _)). | ||
472 | 449 | Times(1). | ||
473 | 450 | WillOnce(Invoke([&](const std::string&, | ||
474 | 451 | std::function<void(int, const std::string&, | ||
475 | 452 | const std::string&)> callback){ | ||
476 | 453 | callback(0, expected_str, ""); | ||
477 | 454 | })); | ||
478 | 455 | iface.get_manifests([expected](ManifestList manifests, ManifestError error){ | ||
479 | 456 | ASSERT_TRUE(error == ManifestError::NoError); | ||
480 | 457 | ASSERT_TRUE(manifests.size() == expected.size()); | ||
481 | 458 | }); | ||
482 | 459 | } |
FAILED: Continuous integration, rev:265 /code.launchpad .net/~mvo/ unity-scope- click/lp1292645 -use-libclick/ +merge/ 220061/ +edit-commit- message
No commit message was specified in the merge proposal. Click on the following link and set the commit message (if you want a jenkins rebuild you need to trigger it yourself):
https:/
http:// jenkins. qa.ubuntu. com/job/ unity-team- unity-scope- click-devel- ci/68/ jenkins. qa.ubuntu. com/job/ unity-team- unity-scope- click-devel- utopic- amd64-ci/ 43 jenkins. qa.ubuntu. com/job/ unity-team- unity-scope- click-devel- utopic- armhf-ci/ 42 jenkins. qa.ubuntu. com/job/ unity-team- unity-scope- click-devel- utopic- armhf-ci/ 42/artifact/ work/output/ *zip*/output. zip jenkins. qa.ubuntu. com/job/ unity-team- unity-scope- click-devel- utopic- i386-ci/ 42
Executed test runs:
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
Click here to trigger a rebuild: s-jenkins. ubuntu- ci:8080/ job/unity- team-unity- scope-click- devel-ci/ 68/rebuild
http://