on xenial help sign in
- Handling error signal from the DownloadTracker plugin (BUG: #1229744). Fixes: https://bugs.launchpad.net/bugs/1229744.

Approved by PS Jenkins bot, Michał Sawicz, Roberto Alsina.

commit81f0882d80834c583ce82d46cb98c8cc9d018c0e authorDiego Sarmentero <diego.sarmentero@gmail.com> dateThu 26 Sep 2013, 17:08 (13 years ago) parent392b686a5f50bb
3 files changed+62−2
Dash/Apps/AppPreview.qml+4 tests/mocks/Ubuntu/DownloadDaemonListener/MockDownloadTracker.cpp+5 tests/qmltests/Dash/Apps/tst_AppPreview.qml+53−2
Dash/Apps/AppPreview.qml+4
@@ -110,6 +110,10 @@ DashPreview {
110110 onFinished: {
111111 root.previewData.execute(progressBar.model[0].id, { })
112112 }
113+
114+ onError: {
115+ root.previewData.execute(progressBar.model[1].id, { "error": error });
116+ }
113117 }
114118
115119 }
tests/mocks/Ubuntu/DownloadDaemonListener/MockDownloadTracker.cpp+5
@@ -63,5 +63,10 @@ void MockDownloadTracker::startService()
6363 if(!m_service.isEmpty() && !m_dbusPath.isEmpty()) {
6464 m_active = true;
6565 Q_EMIT serviceReadyChanged(m_active);
66+ if(m_dbusPath == "finish") {
67+ Q_EMIT finished("downloadComplete");
68+ }else if(m_dbusPath == "error") {
69+ Q_EMIT error("DOWNLOAD ERROR");
70+ }
6671 }
6772}
tests/qmltests/Dash/Apps/tst_AppPreview.qml+53−2
@@ -45,6 +45,8 @@ Item {
4545 ["Unity User", 10, "10/02/2013", root.commentary],
4646 ]
4747 }
48+ QtObject { id: showProgress; property bool value: true }
49+ QtObject { id: progressSource; property string value: "service" }
4850
4951 QtObject {
5052 id: data
@@ -66,8 +68,30 @@ Item {
6668 ]
6769 }
6870
71+ QtObject {
72+ id: dataProgress
73+ property string title: "Unity App"
74+ property string appIcon: "fake_image.png"
75+ property string description: "This is an Application description"
76+ property real rating: rating.value
77+ property int numRatings: reviews.value
78+ property var execute: root.fake_call
79+ property var infoMap: {
80+ "show_progressbar": showProgress,
81+ "more-screenshots": screenshots,
82+ "rated": rated,
83+ "comments": comments,
84+ "progressbar_source": progressSource
85+ }
86+ property var actions: [
87+ { "id": 123, "displayName": "action1" },
88+ { "id": 456, "displayName": "action2" },
89+ { "id": 789, "displayName": "action3" },
90+ ]
91+ }
92+
6993 function fake_call(id, data){
70− root.calls[root.calls.length] = id;
94+ root.calls[root.calls.length] = [id, data];
7195 }
7296
7397 // The component under test
@@ -89,6 +113,7 @@ Item {
89113 reviewField.focus = false;
90114 reviewField.text = "";
91115 data.rating = rating.value;
116+ dataProgress.infoMap["progressbar_source"].value = "service";
92117 }
93118
94119 function test_actions() {
@@ -102,7 +127,7 @@ Item {
102127
103128 var actions = data.actions;
104129 for(var i = 0; i < actions.length; i++) {
105− compare(root.calls[i], actions[i].id, "Id of action not found.");
130+ compare(root.calls[i][0], actions[i].id, "Id of action not found.");
106131 }
107132 }
108133
@@ -162,5 +187,31 @@ Item {
162187 verify(buttons.visible == true);
163188 }
164189
190+ function test_progress_show() {
191+ appPreview.previewData = dataProgress;
192+ var progress = findChild(appPreview, "progressBar");
193+ verify(progress.visible == true);
194+ }
195+
196+ function test_progress_download_finish() {
197+ appPreview.previewData = dataProgress;
198+ var progress = findChild(appPreview, "progressBar");
199+ dataProgress.infoMap["progressbar_source"].value = "finish";
200+
201+ var actions = dataProgress.actions;
202+ compare(root.calls[0][0], actions[0].id, "Id of action not found.");
203+ compare(root.calls[0][1], {}, "Data of action not found.");
204+ }
205+
206+ function test_progress_download_error() {
207+ appPreview.previewData = dataProgress;
208+ var progress = findChild(appPreview, "progressBar");
209+ dataProgress.infoMap["progressbar_source"].value = "error";
210+
211+ var actions = dataProgress.actions;
212+ compare(root.calls[0][0], actions[1].id, "Id of action not found.");
213+ compare(root.calls[0][1], {"error": "DOWNLOAD ERROR"}, "Data of action not found.");
214+ }
215+
165216 }
166217}