Merge lp:~alecu/unity-scope-click/fix-empty-preview into lp:unity-scope-click/devel

Proposed by Alejandro J. Cura
Status: Merged
Approved by: dobey
Approved revision: 423
Merged at revision: 426
Proposed branch: lp:~alecu/unity-scope-click/fix-empty-preview
Merge into: lp:unity-scope-click/devel
Diff against target: 113 lines (+20/-11)
5 files modified
libclickscope/click/download-manager.cpp (+1/-1)
libclickscope/click/preview.cpp (+13/-8)
libclickscope/click/preview.h (+2/-0)
libclickscope/click/webclient.cpp (+2/-1)
libclickscope/tests/test_preview.cpp (+2/-1)
To merge this branch: bzr merge lp:~alecu/unity-scope-click/fix-empty-preview
Reviewer Review Type Date Requested Status
PS Jenkins bot (community) continuous-integration Approve
dobey (community) Approve
Review via email: mp+231943@code.launchpad.net

Commit message

Do not push preview widgets until all data is available

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
420. By Alejandro J. Cura

Fix existing unit tests

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
421. By Alejandro J. Cura

More debugging

422. By Alejandro J. Cura

Move captured vars from closure to object attributes

423. By Alejandro J. Cura

Clean up of debugging messages

Revision history for this message
dobey (dobey) wrote :

Looks ok to me, and seems to solve the issue at hand, in testing the branch under unity-scope-tool.

review: Approve
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'libclickscope/click/download-manager.cpp'
2--- libclickscope/click/download-manager.cpp 2014-08-21 14:29:45 +0000
3+++ libclickscope/click/download-manager.cpp 2014-08-26 15:16:39 +0000
4@@ -313,7 +313,7 @@
5 }
6 qDebug() << "Found object path" << QString::fromStdString(object_path)
7 << "for package" << QString::fromStdString(package_name);
8- if (downloads.size() != 1) {
9+ if (downloads.size() > 1) {
10 qWarning() << "More than one download with the same object path";
11 }
12 callback(object_path);
13
14=== modified file 'libclickscope/click/preview.cpp'
15--- libclickscope/click/preview.cpp 2014-08-21 17:11:08 +0000
16+++ libclickscope/click/preview.cpp 2014-08-26 15:16:39 +0000
17@@ -336,6 +336,7 @@
18 header.add_attribute_value("mascot", scopes::Variant(details.package.icon_url));
19 widgets.push_back(header);
20
21+ qDebug() << "Pushed widgets for package:" << QString::fromStdString(details.package.title);
22 return widgets;
23 }
24
25@@ -822,6 +823,7 @@
26 : PreviewStrategy(result, client),
27 DepartmentUpdater(depts), nam(nam)
28 {
29+ qDebug() << "Creating new UninstalledPreview for result" << QString::fromStdString(result["name"].get_string());
30 }
31
32 UninstalledPreview::~UninstalledPreview()
33@@ -833,26 +835,29 @@
34 qDebug() << "in UninstalledPreview::run, about to populate details";
35 populateDetails([this, reply](const PackageDetails &details){
36 store_department(details);
37+ found_details = details;
38 std::string app_name = result["name"].get_string();
39 get_downloader(nam)->get_download_progress(app_name,
40- [this, reply, details](std::string object_path){
41- scopes::PreviewWidgetList button_widgets;
42- if(object_path.empty()) {
43- button_widgets = uninstalledActionButtonWidgets(details);
44- } else {
45- button_widgets = progressBarWidget(object_path);
46- }
47- pushPackagePreviewWidgets(reply, details, button_widgets);
48+ [this, reply](std::string object_path){
49+ found_object_path = object_path;
50 });
51 },
52 [this, reply](const ReviewList& reviewlist,
53 click::Reviews::Error error) {
54+ scopes::PreviewWidgetList button_widgets;
55+ if(found_object_path.empty()) {
56+ button_widgets = uninstalledActionButtonWidgets(found_details);
57+ } else {
58+ button_widgets = progressBarWidget(found_object_path);
59+ }
60+ pushPackagePreviewWidgets(reply, found_details, button_widgets);
61 if (error == click::Reviews::Error::NoError) {
62 reply->push(reviewsWidgets(reviewlist));
63 } else {
64 qDebug() << "There was an error getting reviews for:" << result["name"].get_string().c_str();
65 }
66 reply->finished();
67+ qDebug() << "---------- Finished reply for:" << result["name"].get_string().c_str();
68 });
69 }
70
71
72=== modified file 'libclickscope/click/preview.h'
73--- libclickscope/click/preview.h 2014-08-21 14:29:45 +0000
74+++ libclickscope/click/preview.h 2014-08-26 15:16:39 +0000
75@@ -256,6 +256,8 @@
76
77 void run(unity::scopes::PreviewReplyProxy const& reply) override;
78 protected:
79+ PackageDetails found_details;
80+ std::string found_object_path;
81 virtual click::Downloader* get_downloader(const QSharedPointer<click::network::AccessManager>& nam);
82 virtual scopes::PreviewWidgetList uninstalledActionButtonWidgets(const PackageDetails &details);
83 };
84
85=== modified file 'libclickscope/click/webclient.cpp'
86--- libclickscope/click/webclient.cpp 2014-08-11 15:16:18 +0000
87+++ libclickscope/click/webclient.cpp 2014-08-26 15:16:39 +0000
88@@ -172,7 +172,8 @@
89 void click::web::Response::replyFinished()
90 {
91 auto response = reply->readAll();
92- qDebug() << "got response" << response.toPercentEncoding(" ");
93+ qDebug() << "Response for: " << request->url();
94+ qDebug() << response.toPercentEncoding(" ");
95 emit finished(response);
96 }
97
98
99=== modified file 'libclickscope/tests/test_preview.cpp'
100--- libclickscope/tests/test_preview.cpp 2014-08-21 17:11:08 +0000
101+++ libclickscope/tests/test_preview.cpp 2014-08-26 15:16:39 +0000
102@@ -275,9 +275,10 @@
103 }
104
105 void populateDetails(std::function<void (const click::PackageDetails &)> details_callback,
106- std::function<void (const click::ReviewList &, click::Reviews::Error)> /*reviews_callback*/) {
107+ std::function<void (const click::ReviewList &, click::Reviews::Error)> reviews_callback) {
108 click::PackageDetails details;
109 details_callback(details);
110+ reviews_callback({}, click::Reviews::Error::NoError);
111 }
112 MOCK_METHOD1(uninstalledActionButtonWidgets, scopes::PreviewWidgetList (const click::PackageDetails &details));
113 MOCK_METHOD1(progressBarWidget, scopes::PreviewWidgetList(const std::string& object_path));

Subscribers

People subscribed via source and target branches

to all changes: