Merge lp:~dobey/unity8/drop-payments into lp:unity8

Proposed by dobey on 2016-12-05
Status: Merged
Approved by: Andrea Cimitan on 2016-12-13
Approved revision: 2727
Merged at revision: 2756
Proposed branch: lp:~dobey/unity8/drop-payments
Merge into: lp:unity8
Diff against target: 958 lines (+0/-811)
20 files modified
debian/control (+0/-2)
plugins/Ubuntu/CMakeLists.txt (+0/-1)
plugins/Ubuntu/Payments/CMakeLists.txt (+0/-20)
plugins/Ubuntu/Payments/Payments.cpp (+0/-136)
plugins/Ubuntu/Payments/Payments.h (+0/-69)
plugins/Ubuntu/Payments/plugin.cpp (+0/-28)
plugins/Ubuntu/Payments/plugin.h (+0/-31)
plugins/Ubuntu/Payments/qmldir (+0/-3)
qml/Dash/Previews/PreviewPayments.qml (+0/-81)
qml/Dash/Previews/PreviewWidgetFactory.qml (+0/-1)
tests/mocks/Ubuntu/CMakeLists.txt (+0/-1)
tests/mocks/Ubuntu/Payments/CMakeLists.txt (+0/-10)
tests/mocks/Ubuntu/Payments/MockPayments.cpp (+0/-95)
tests/mocks/Ubuntu/Payments/MockPayments.h (+0/-62)
tests/mocks/Ubuntu/Payments/plugin.cpp (+0/-28)
tests/mocks/Ubuntu/Payments/plugin.h (+0/-31)
tests/mocks/Ubuntu/Payments/qmldir (+0/-3)
tests/qmltests/CMakeLists.txt (+0/-1)
tests/qmltests/Dash/Previews/tst_PreviewExpandable.qml (+0/-5)
tests/qmltests/Dash/Previews/tst_PreviewPayments.qml (+0/-203)
To merge this branch: bzr merge lp:~dobey/unity8/drop-payments
Reviewer Review Type Date Requested Status
Unity8 CI Bot continuous-integration Approve on 2016-12-23
Andrea Cimitan (community) 2016-12-05 Approve on 2016-12-13
Review via email: mp+312500@code.launchpad.net

Commit Message

Remove the payments widget and dependency on libpay as no longer needed.

Description of the Change

This must NOT land into vivid+overlay, only to zesty and xenial+overlay for the snap-based future Unity 8 sessions where we no longer support clicks, and where the store is being replaced by a web app which will handle purchasing.

 * Are there any related MPs required for this MP to build/function as expected?

N/A

 * Did you perform an exploratory manual test run of your code change and any related functionality?

N/A

 * If you changed the packaging (debian), did you subscribe the ubuntu-unity team to this MP?

Was automatic? Only packaging change is removing of deps to match code removal.

 * If you changed the UI, has there been a design review?

N/A

To post a comment you must log in.
Unity8 CI Bot (unity8-ci-bot) wrote :

PASSED: Continuous integration, rev:2727
https://unity8-jenkins.ubuntu.com/job/lp-unity8-ci/2652/
Executed test runs:
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build/3485
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/test-0-autopkgtest/label=amd64,release=xenial+overlay,testname=qmluitests.sh/2004
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/test-0-autopkgtest/label=amd64,release=zesty,testname=qmluitests.sh/2004
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-0-fetch/3513
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=amd64,release=xenial+overlay/3360
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=amd64,release=xenial+overlay/3360/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=amd64,release=zesty/3360
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=amd64,release=zesty/3360/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=armhf,release=xenial+overlay/3360
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=armhf,release=xenial+overlay/3360/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=armhf,release=zesty/3360
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=armhf,release=zesty/3360/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=i386,release=xenial+overlay/3360
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=i386,release=xenial+overlay/3360/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=i386,release=zesty/3360
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=i386,release=zesty/3360/artifact/output/*zip*/output.zip

Click here to trigger a rebuild:
https://unity8-jenkins.ubuntu.com/job/lp-unity8-ci/2652/rebuild

review: Approve (continuous-integration)
Andrea Cimitan (cimi) wrote :

Please follow the checklist https://wiki.ubuntu.com/Process/Merges/Checklists/Unity8 here and put it in the bug description. I tested the branch locally, builds and runs fine... I didn't find other traces of Payments we forgot to remove, will approve once we add the checklist

review: Needs Information
Andrea Cimitan (cimi) wrote :

 * Did you perform an exploratory manual test run of the code change and any related functionality?
yes
 * Did CI run pass? If not, please explain why.
yes

review: Approve
Unity8 CI Bot (unity8-ci-bot) wrote :

PASSED: Continuous integration, rev:2727
https://unity8-jenkins.ubuntu.com/job/lp-unity8-ci/2774/
Executed test runs:
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build/3634
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/test-0-autopkgtest/label=amd64,release=xenial+overlay,testname=qmluitests.sh/2079
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/test-0-autopkgtest/label=amd64,release=zesty,testname=qmluitests.sh/2079
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-0-fetch/3662
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=amd64,release=xenial+overlay/3509
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=amd64,release=xenial+overlay/3509/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=amd64,release=zesty/3509
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=amd64,release=zesty/3509/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=armhf,release=xenial+overlay/3509
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=armhf,release=xenial+overlay/3509/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=armhf,release=zesty/3509
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=armhf,release=zesty/3509/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=i386,release=xenial+overlay/3509
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=i386,release=xenial+overlay/3509/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=i386,release=zesty/3509
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=i386,release=zesty/3509/artifact/output/*zip*/output.zip

Click here to trigger a rebuild:
https://unity8-jenkins.ubuntu.com/job/lp-unity8-ci/2774/rebuild

review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'debian/control'
2--- debian/control 2016-11-29 09:40:16 +0000
3+++ debian/control 2016-12-05 18:39:29 +0000
4@@ -26,7 +26,6 @@
5 libhardware-dev,
6 liblightdm-qt5-3-dev,
7 libpam0g-dev,
8- libpay2-dev,
9 libpulse-dev,
10 libqmenumodel-dev (>= 0.2.10),
11 libqt5svg5-dev,
12@@ -219,7 +218,6 @@
13 Depends: accountsservice-ubuntu-schemas (>= 0.0.7),
14 gsettings-ubuntu-schemas (>= 0.0.2+14.10.20140815),
15 libhardware2,
16- pay-service,
17 unity-schemas (>= 7.3.1+14.10.20140915),
18 qtdeclarative5-gsettings1.0,
19 qml-module-qtmultimedia,
20
21=== modified file 'plugins/Ubuntu/CMakeLists.txt'
22--- plugins/Ubuntu/CMakeLists.txt 2014-08-25 10:05:13 +0000
23+++ plugins/Ubuntu/CMakeLists.txt 2016-12-05 18:39:29 +0000
24@@ -1,4 +1,3 @@
25 add_subdirectory(Gestures)
26 add_subdirectory(DownloadDaemonListener)
27-add_subdirectory(Payments)
28 add_subdirectory(SystemImage)
29
30=== removed directory 'plugins/Ubuntu/Payments'
31=== removed file 'plugins/Ubuntu/Payments/CMakeLists.txt'
32--- plugins/Ubuntu/Payments/CMakeLists.txt 2014-07-23 11:52:35 +0000
33+++ plugins/Ubuntu/Payments/CMakeLists.txt 1970-01-01 00:00:00 +0000
34@@ -1,20 +0,0 @@
35-include_directories(
36- ${CMAKE_CURRENT_SOURCE_DIR}
37- ${CMAKE_CURRENT_BINARY_DIR}
38-)
39-
40-set(PAYMENTS_SOURCES
41- plugin.cpp
42- Payments.cpp
43-)
44-
45-add_library(Payments MODULE ${PAYMENTS_SOURCES})
46-
47-qt5_use_modules(Payments Qml Quick DBus Core)
48-
49-add_unity8_plugin(Ubuntu.Payments 0.1 Ubuntu/Payments TARGETS Payments)
50-
51-pkg_check_modules(LIBPAY REQUIRED pay-2)
52-add_definitions(${LIBPAY_CFLAGS} ${LIBPAY_CFLAGS_OTHER})
53-
54-target_link_libraries(Payments ${LIBPAY_LDFLAGS})
55
56=== removed file 'plugins/Ubuntu/Payments/Payments.cpp'
57--- plugins/Ubuntu/Payments/Payments.cpp 2015-07-20 19:05:31 +0000
58+++ plugins/Ubuntu/Payments/Payments.cpp 1970-01-01 00:00:00 +0000
59@@ -1,136 +0,0 @@
60-/*
61- * Copyright (C) 2014 Canonical, Ltd.
62- *
63- * This program is free software; you can redistribute it and/or modify
64- * it under the terms of the GNU General Public License as published by
65- * the Free Software Foundation; version 3.
66- *
67- * This program is distributed in the hope that it will be useful,
68- * but WITHOUT ANY WARRANTY; without even the implied warranty of
69- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
70- * GNU General Public License for more details.
71- *
72- * You should have received a copy of the GNU General Public License
73- * along with this program. If not, see <http://www.gnu.org/licenses/>.
74- */
75-
76-#include "Payments.h"
77-
78-#include <QLocale>
79-
80-#include <libpay/pay-package.h>
81-
82-
83-// The observer callback for the package we are watching.
84-static void observer(PayPackage* /* package */, const char* itemid, PayPackageItemStatus status, void* user_data) {
85- // This function is called in libpay's thread, so be careful what you call
86- // Emitting signals should be fine as long as they use Queued or Auto
87- // connections (the default)
88- // http://qt-project.org/doc/qt-5/threads-qobject.html#signals-and-slots-across-threads
89-
90- Payments *self = static_cast<Payments*>(user_data);
91-
92- // If the item ID is different, ignore it.
93- if (itemid != self->storeItemId()) {
94- return;
95- }
96-
97- // FIXME: No error reporting from libpay, but we need to show some
98- // types of errors to the user. https://launchpad.net/bugs/1333403
99- switch (status) {
100- case PAY_PACKAGE_ITEM_STATUS_PURCHASED:
101- Q_EMIT self->purchaseCompleted();
102- break;
103- case PAY_PACKAGE_ITEM_STATUS_PURCHASING:
104- self->setPurchasing(true);
105- break;
106- case PAY_PACKAGE_ITEM_STATUS_NOT_PURCHASED:
107- if (self->purchasing()) {
108- self->setPurchasing(false);
109- Q_EMIT self->purchaseCancelled();
110- }
111- break;
112- default:
113- break;
114- }
115-}
116-
117-Payments::Payments(QObject *parent)
118- : QObject(parent),
119- m_purchasing(false)
120-{
121- m_package = pay_package_new("click-scope");
122- pay_package_item_observer_install(m_package, observer, this);
123-}
124-
125-Payments::~Payments()
126-{
127- pay_package_item_observer_uninstall(m_package, observer, this);
128- pay_package_delete(m_package);
129-}
130-
131-QString Payments::currency() const
132-{
133- return m_currency;
134-}
135-
136-double Payments::price() const
137-{
138- return m_price;
139-}
140-
141-QString Payments::storeItemId() const
142-{
143- return m_store_item_id;
144-}
145-
146-QString Payments::formattedPrice() const
147-{
148- QLocale locale;
149- return locale.toCurrencyString(m_price, m_currency);
150-}
151-
152-bool Payments::purchasing() const
153-{
154- return m_purchasing;
155-}
156-
157-void Payments::setCurrency(const QString &currency)
158-{
159- if(m_currency != currency) {
160- m_currency = currency;
161- Q_EMIT currencyChanged(currency);
162- Q_EMIT formattedPriceChanged(formattedPrice());
163- }
164-}
165-
166-void Payments::setPrice(const double price)
167-{
168- if(m_price != price) {
169- m_price = price;
170- Q_EMIT priceChanged(price);
171- Q_EMIT formattedPriceChanged(formattedPrice());
172- }
173-}
174-
175-void Payments::setStoreItemId(const QString &store_item_id)
176-{
177- if (m_store_item_id != store_item_id) {
178- m_store_item_id = store_item_id;
179- Q_EMIT storeItemIdChanged(m_store_item_id);
180- }
181-
182- if (m_store_item_id.isEmpty()) {
183- return;
184- }
185-}
186-
187-void Payments::setPurchasing(bool is_purchasing)
188-{
189- m_purchasing = is_purchasing;
190-}
191-
192-void Payments::start()
193-{
194- pay_package_item_start_purchase(m_package, m_store_item_id.toLocal8Bit().data());
195-}
196
197=== removed file 'plugins/Ubuntu/Payments/Payments.h'
198--- plugins/Ubuntu/Payments/Payments.h 2014-09-18 13:50:52 +0000
199+++ plugins/Ubuntu/Payments/Payments.h 1970-01-01 00:00:00 +0000
200@@ -1,69 +0,0 @@
201-/*
202- * Copyright (C) 2014 Canonical, Ltd.
203- *
204- * This program is free software; you can redistribute it and/or modify
205- * it under the terms of the GNU General Public License as published by
206- * the Free Software Foundation; version 3.
207- *
208- * This program is distributed in the hope that it will be useful,
209- * but WITHOUT ANY WARRANTY; without even the implied warranty of
210- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
211- * GNU General Public License for more details.
212- *
213- * You should have received a copy of the GNU General Public License
214- * along with this program. If not, see <http://www.gnu.org/licenses/>.
215- */
216-
217-#ifndef PAYMENTS_H
218-#define PAYMENTS_H
219-
220-#include <QObject>
221-
222-#include <libpay/pay-package.h>
223-
224-
225-class Payments : public QObject
226-{
227- Q_OBJECT
228- Q_DISABLE_COPY(Payments)
229- Q_PROPERTY(QString currency READ currency WRITE setCurrency NOTIFY currencyChanged)
230- Q_PROPERTY(double price READ price WRITE setPrice NOTIFY priceChanged)
231- Q_PROPERTY(QString storeItemId READ storeItemId WRITE setStoreItemId NOTIFY storeItemIdChanged)
232- Q_PROPERTY(QString formattedPrice READ formattedPrice NOTIFY formattedPriceChanged)
233-
234-public:
235- explicit Payments(QObject *parent = 0);
236- virtual ~Payments();
237-
238- QString currency() const;
239- double price() const;
240- QString storeItemId() const;
241- QString formattedPrice() const;
242- bool purchasing() const;
243-
244- void setCurrency(const QString& currency);
245- void setPrice(const double price);
246- void setStoreItemId(const QString& store_item_id);
247- void setPurchasing(bool is_purchasing);
248- Q_INVOKABLE void start();
249-
250-Q_SIGNALS:
251- void currencyChanged(const QString& currency);
252- void priceChanged(const double price);
253- void storeItemIdChanged(const QString &store_item_id);
254- void formattedPriceChanged(const QString &formatted_price);
255-
256- void purchaseError(const QString &error);
257- void purchaseCompleted();
258- void purchaseCancelled();
259-
260-private:
261- QString m_currency;
262- double m_price;
263- QString m_store_item_id;
264- bool m_purchasing;
265-
266- PayPackage *m_package;
267-};
268-
269-#endif // PAYMENTS_H
270
271=== removed file 'plugins/Ubuntu/Payments/plugin.cpp'
272--- plugins/Ubuntu/Payments/plugin.cpp 2014-06-30 14:47:07 +0000
273+++ plugins/Ubuntu/Payments/plugin.cpp 1970-01-01 00:00:00 +0000
274@@ -1,28 +0,0 @@
275-/*
276- * Copyright (C) 2014 Canonical, Ltd.
277- *
278- * This program is free software; you can redistribute it and/or modify
279- * it under the terms of the GNU General Public License as published by
280- * the Free Software Foundation; version 3.
281- *
282- * This program is distributed in the hope that it will be useful,
283- * but WITHOUT ANY WARRANTY; without even the implied warranty of
284- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
285- * GNU General Public License for more details.
286- *
287- * You should have received a copy of the GNU General Public License
288- * along with this program. If not, see <http://www.gnu.org/licenses/>.
289- */
290-
291-#include "plugin.h"
292-#include "Payments.h"
293-
294-#include <QtQml>
295-
296-
297-void BackendPlugin::registerTypes(const char *uri)
298-{
299- Q_ASSERT(uri == QLatin1String("Ubuntu.Payments"));
300-
301- qmlRegisterType<Payments>(uri, 0, 1, "Payments");
302-}
303
304=== removed file 'plugins/Ubuntu/Payments/plugin.h'
305--- plugins/Ubuntu/Payments/plugin.h 2015-04-30 09:31:51 +0000
306+++ plugins/Ubuntu/Payments/plugin.h 1970-01-01 00:00:00 +0000
307@@ -1,31 +0,0 @@
308-/*
309- * Copyright (C) 2014 Canonical, Ltd.
310- *
311- * This program is free software; you can redistribute it and/or modify
312- * it under the terms of the GNU General Public License as published by
313- * the Free Software Foundation; version 3.
314- *
315- * This program is distributed in the hope that it will be useful,
316- * but WITHOUT ANY WARRANTY; without even the implied warranty of
317- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
318- * GNU General Public License for more details.
319- *
320- * You should have received a copy of the GNU General Public License
321- * along with this program. If not, see <http://www.gnu.org/licenses/>.
322- */
323-
324-#ifndef PAYMENTS_PLUGIN_H
325-#define PAYMENTS_PLUGIN_H
326-
327-#include <QQmlExtensionPlugin>
328-
329-class BackendPlugin : public QQmlExtensionPlugin
330-{
331- Q_OBJECT
332- Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface")
333-
334-public:
335- void registerTypes(const char *uri) override;
336-};
337-
338-#endif // PAYMENTS_PLUGIN_H
339
340=== removed file 'plugins/Ubuntu/Payments/qmldir'
341--- plugins/Ubuntu/Payments/qmldir 2014-05-27 14:19:27 +0000
342+++ plugins/Ubuntu/Payments/qmldir 1970-01-01 00:00:00 +0000
343@@ -1,3 +0,0 @@
344-module Ubuntu.Payments
345-plugin Payments
346-typeinfo Payments.qmltypes
347
348=== removed file 'qml/Dash/Previews/PreviewPayments.qml'
349--- qml/Dash/Previews/PreviewPayments.qml 2016-05-17 20:46:51 +0000
350+++ qml/Dash/Previews/PreviewPayments.qml 1970-01-01 00:00:00 +0000
351@@ -1,81 +0,0 @@
352-/*
353- * Copyright (C) 2014 Canonical, Ltd.
354- *
355- * This program is free software; you can redistribute it and/or modify
356- * it under the terms of the GNU General Public License as published by
357- * the Free Software Foundation; version 3.
358- *
359- * This program is distributed in the hope that it will be useful,
360- * but WITHOUT ANY WARRANTY; without even the implied warranty of
361- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
362- * GNU General Public License for more details.
363- *
364- * You should have received a copy of the GNU General Public License
365- * along with this program. If not, see <http://www.gnu.org/licenses/>.
366- */
367-
368-import QtQuick 2.4
369-import Ubuntu.Components 1.3
370-import Ubuntu.Payments 0.1
371-
372-/*! \brief Preview widget for a purchase button.
373- *
374- * When clicked, this button starts the payments service.
375- * Then it waits until the purchase finishes or fails.
376- * Those events trigger the corresponding actions.
377- */
378-
379-PreviewWidget {
380- id: root
381-
382- implicitHeight: paymentButton.implicitHeight
383- implicitWidth: paymentButton.implicitWidth
384-
385- Button {
386- id: paymentButton
387- objectName: "paymentButton"
388-
389- color: theme.palette.normal.positive
390- text: paymentClient.formattedPrice
391- onClicked: {
392- paymentClient.start();
393- paymentButton.opacity = 0;
394- }
395- anchors.right: parent.right
396- width: (root.width - units.gu(1)) / 2
397- opacity: 1
398- visible: paymentButton.opacity == 0 ? false : true
399- Behavior on opacity { PropertyAnimation { duration: UbuntuAnimation.FastDuration } }
400-
401- Payments {
402- id: paymentClient
403- objectName: "paymentClient"
404-
405- property var source: widgetData["source"]
406-
407- price: source["price"]
408- currency: source["currency"]
409- storeItemId: source["store_item_id"]
410- onPurchaseCompleted: {
411- root.triggered(widgetId, "purchaseCompleted", source);
412- }
413- onPurchaseError: {
414- paymentButton.opacity = 1;
415- root.triggered(widgetId, "purchaseError", source);
416- }
417- onPurchaseCancelled: {
418- paymentButton.opacity = 1;
419- root.triggered(widgetId, "purchaseCancelled", source);
420- }
421- }
422- }
423-
424- ProgressBar {
425- id: loadingBar
426- objectName: "loadingBar"
427- indeterminate: true
428- anchors.fill: paymentButton
429- opacity: 1 - paymentButton.opacity
430- visible: !paymentButton.visible
431- }
432-}
433
434=== modified file 'qml/Dash/Previews/PreviewWidgetFactory.qml'
435--- qml/Dash/Previews/PreviewWidgetFactory.qml 2016-10-04 15:45:22 +0000
436+++ qml/Dash/Previews/PreviewWidgetFactory.qml 2016-12-05 18:39:29 +0000
437@@ -67,7 +67,6 @@
438 case "icon-actions": return "PreviewIconActions.qml";
439 case "image": return "PreviewZoomableImage.qml";
440 case "progress": return "PreviewProgress.qml";
441- case "payments": return "PreviewPayments.qml";
442 case "rating-input": return "PreviewRatingInput.qml";
443 case "rating-edit": return "PreviewRatingEdit.qml";
444 case "reviews": return "PreviewRatingDisplay.qml";
445
446=== modified file 'tests/mocks/Ubuntu/CMakeLists.txt'
447--- tests/mocks/Ubuntu/CMakeLists.txt 2016-05-03 13:41:11 +0000
448+++ tests/mocks/Ubuntu/CMakeLists.txt 2016-12-05 18:39:29 +0000
449@@ -1,6 +1,5 @@
450 add_subdirectory(Connectivity)
451 add_subdirectory(DownloadDaemonListener)
452-add_subdirectory(Payments)
453 add_subdirectory(SystemImage)
454 add_subdirectory(SystemSettings)
455 add_subdirectory(Telephony)
456
457=== removed directory 'tests/mocks/Ubuntu/Payments'
458=== removed file 'tests/mocks/Ubuntu/Payments/CMakeLists.txt'
459--- tests/mocks/Ubuntu/Payments/CMakeLists.txt 2014-06-27 20:53:24 +0000
460+++ tests/mocks/Ubuntu/Payments/CMakeLists.txt 1970-01-01 00:00:00 +0000
461@@ -1,10 +0,0 @@
462-set(FakeUbuntuPaymentsQml_SOURCES
463- plugin.cpp
464- MockPayments.cpp
465- )
466-
467-add_library(FakeUbuntuPaymentsQml MODULE ${FakeUbuntuPaymentsQml_SOURCES})
468-
469-qt5_use_modules(FakeUbuntuPaymentsQml Qml Quick Core)
470-
471-add_unity8_mock(Ubuntu.Payments 0.1 Ubuntu/Payments TARGETS FakeUbuntuPaymentsQml)
472
473=== removed file 'tests/mocks/Ubuntu/Payments/MockPayments.cpp'
474--- tests/mocks/Ubuntu/Payments/MockPayments.cpp 2016-05-26 13:15:35 +0000
475+++ tests/mocks/Ubuntu/Payments/MockPayments.cpp 1970-01-01 00:00:00 +0000
476@@ -1,95 +0,0 @@
477-/*
478- * Copyright (C) 2014 Canonical, Ltd.
479- *
480- * This program is free software; you can redistribute it and/or modify
481- * it under the terms of the GNU General Public License as published by
482- * the Free Software Foundation; version 3.
483- *
484- * This program is distributed in the hope that it will be useful,
485- * but WITHOUT ANY WARRANTY; without even the implied warranty of
486- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
487- * GNU General Public License for more details.
488- *
489- * You should have received a copy of the GNU General Public License
490- * along with this program. If not, see <http://www.gnu.org/licenses/>.
491- */
492-
493-#include "MockPayments.h"
494-
495-#include <QLocale>
496-
497-
498-MockPayments::MockPayments(QObject *parent)
499- : QObject(parent)
500- , m_price(0)
501-{
502-}
503-
504-QString MockPayments::currency() const
505-{
506- return m_currency;
507-}
508-
509-double MockPayments::price() const
510-{
511- return m_price;
512-}
513-
514-QString MockPayments::storeItemId() const
515-{
516- return m_store_item_id;
517-}
518-
519-QString MockPayments::formattedPrice() const
520-{
521- QLocale locale;
522- return locale.toCurrencyString(m_price, m_currency);
523-}
524-
525-void MockPayments::setCurrency(const QString &currency)
526-{
527- if(m_currency != currency) {
528- m_currency = currency;
529- Q_EMIT currencyChanged(currency);
530- Q_EMIT formattedPriceChanged(formattedPrice());
531- }
532-}
533-
534-void MockPayments::setPrice(const double price)
535-{
536- if(m_price != price) {
537- m_price = price;
538- Q_EMIT priceChanged(price);
539- Q_EMIT formattedPriceChanged(formattedPrice());
540- }
541-}
542-
543-void MockPayments::setStoreItemId(const QString &store_item_id)
544-{
545- if (m_store_item_id != store_item_id) {
546- m_store_item_id = store_item_id;
547- Q_EMIT storeItemIdChanged(m_store_item_id);
548- }
549-
550- if (m_store_item_id.isEmpty()) {
551- return;
552- }
553-}
554-
555-void MockPayments::start()
556-{
557- if (m_store_item_id.isEmpty()) {
558- Q_EMIT purchaseError("No item ID supplied.");
559- }
560-}
561-
562-void MockPayments::process()
563-{
564- if (m_store_item_id == "com.example.cancel") {
565- Q_EMIT purchaseCancelled();
566- } else if (m_store_item_id == "com.example.invalid") {
567- Q_EMIT purchaseError("Purchase failed.");
568- } else {
569- Q_EMIT purchaseCompleted();
570- }
571-}
572
573=== removed file 'tests/mocks/Ubuntu/Payments/MockPayments.h'
574--- tests/mocks/Ubuntu/Payments/MockPayments.h 2014-09-15 21:32:06 +0000
575+++ tests/mocks/Ubuntu/Payments/MockPayments.h 1970-01-01 00:00:00 +0000
576@@ -1,62 +0,0 @@
577-/*
578- * Copyright (C) 2014 Canonical, Ltd.
579- *
580- * This program is free software; you can redistribute it and/or modify
581- * it under the terms of the GNU General Public License as published by
582- * the Free Software Foundation; version 3.
583- *
584- * This program is distributed in the hope that it will be useful,
585- * but WITHOUT ANY WARRANTY; without even the implied warranty of
586- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
587- * GNU General Public License for more details.
588- *
589- * You should have received a copy of the GNU General Public License
590- * along with this program. If not, see <http://www.gnu.org/licenses/>.
591- */
592-
593-#ifndef MOCK_PAYMENTS_H
594-#define MOCK_PAYMENTS_H
595-
596-#include <QObject>
597-
598-
599-class MockPayments : public QObject
600-{
601- Q_OBJECT
602- Q_DISABLE_COPY(MockPayments)
603- Q_PROPERTY(QString currency READ currency WRITE setCurrency NOTIFY currencyChanged)
604- Q_PROPERTY(double price READ price WRITE setPrice NOTIFY priceChanged)
605- Q_PROPERTY(QString storeItemId READ storeItemId WRITE setStoreItemId NOTIFY storeItemIdChanged)
606- Q_PROPERTY(QString formattedPrice READ formattedPrice NOTIFY formattedPriceChanged)
607-
608-public:
609- explicit MockPayments(QObject *parent = 0);
610-
611- QString currency() const;
612- double price() const;
613- QString storeItemId() const;
614- QString formattedPrice() const;
615-
616- void setCurrency(const QString& currency);
617- void setPrice(const double price);
618- void setStoreItemId(const QString& store_item_id);
619- Q_INVOKABLE void start();
620- Q_INVOKABLE void process(); // only available for testing
621-
622-Q_SIGNALS:
623- void currencyChanged(const QString& currency);
624- void priceChanged(const double price);
625- void storeItemIdChanged(const QString &store_item_id);
626- void formattedPriceChanged(const QString &formatted_price);
627-
628- void purchaseError(const QString &error);
629- void purchaseCompleted();
630- void purchaseCancelled();
631-
632-private:
633- QString m_currency;
634- double m_price;
635- QString m_store_item_id;
636-};
637-
638-#endif // MOCK_PAYMENTS_H
639
640=== removed file 'tests/mocks/Ubuntu/Payments/plugin.cpp'
641--- tests/mocks/Ubuntu/Payments/plugin.cpp 2014-06-30 14:47:07 +0000
642+++ tests/mocks/Ubuntu/Payments/plugin.cpp 1970-01-01 00:00:00 +0000
643@@ -1,28 +0,0 @@
644-/*
645- * Copyright (C) 2014 Canonical, Ltd.
646- *
647- * This program is free software; you can redistribute it and/or modify
648- * it under the terms of the GNU General Public License as published by
649- * the Free Software Foundation; version 3.
650- *
651- * This program is distributed in the hope that it will be useful,
652- * but WITHOUT ANY WARRANTY; without even the implied warranty of
653- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
654- * GNU General Public License for more details.
655- *
656- * You should have received a copy of the GNU General Public License
657- * along with this program. If not, see <http://www.gnu.org/licenses/>.
658- */
659-
660-#include "plugin.h"
661-#include "MockPayments.h"
662-
663-#include <QtQml>
664-
665-
666-void BackendPlugin::registerTypes(const char *uri)
667-{
668- Q_ASSERT(uri == QLatin1String("Ubuntu.Payments"));
669-
670- qmlRegisterType<MockPayments>(uri, 0, 1, "Payments");
671-}
672
673=== removed file 'tests/mocks/Ubuntu/Payments/plugin.h'
674--- tests/mocks/Ubuntu/Payments/plugin.h 2015-04-30 09:31:51 +0000
675+++ tests/mocks/Ubuntu/Payments/plugin.h 1970-01-01 00:00:00 +0000
676@@ -1,31 +0,0 @@
677-/*
678- * Copyright (C) 2014 Canonical, Ltd.
679- *
680- * This program is free software; you can redistribute it and/or modify
681- * it under the terms of the GNU General Public License as published by
682- * the Free Software Foundation; version 3.
683- *
684- * This program is distributed in the hope that it will be useful,
685- * but WITHOUT ANY WARRANTY; without even the implied warranty of
686- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
687- * GNU General Public License for more details.
688- *
689- * You should have received a copy of the GNU General Public License
690- * along with this program. If not, see <http://www.gnu.org/licenses/>.
691- */
692-
693-#ifndef PAYMENTS_PLUGIN_H
694-#define PAYMENTS_PLUGIN_H
695-
696-#include <QQmlExtensionPlugin>
697-
698-class BackendPlugin : public QQmlExtensionPlugin
699-{
700- Q_OBJECT
701- Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface")
702-
703-public:
704- void registerTypes(const char *uri) override;
705-};
706-
707-#endif // PAYMENTS_PLUGIN_H
708
709=== removed file 'tests/mocks/Ubuntu/Payments/qmldir'
710--- tests/mocks/Ubuntu/Payments/qmldir 2014-06-27 20:53:24 +0000
711+++ tests/mocks/Ubuntu/Payments/qmldir 1970-01-01 00:00:00 +0000
712@@ -1,3 +0,0 @@
713-module Ubuntu.Payments
714-plugin FakeUbuntuPaymentsQml
715-typeinfo Payments.qmltypes
716
717=== modified file 'tests/qmltests/CMakeLists.txt'
718--- tests/qmltests/CMakeLists.txt 2016-09-22 14:19:36 +0000
719+++ tests/qmltests/CMakeLists.txt 2016-12-05 18:39:29 +0000
720@@ -44,7 +44,6 @@
721 add_unity8_qmltest(Dash/Previews PreviewImageGallery)
722 add_unity8_qmltest(Dash/Previews PreviewInlineVideo)
723 add_unity8_qmltest(Dash/Previews PreviewMediaToolbar)
724-add_unity8_qmltest(Dash/Previews PreviewPayments)
725 add_unity8_qmltest(Dash/Previews PreviewProgress)
726 add_unity8_qmltest(Dash/Previews PreviewRatingDisplay)
727 add_unity8_qmltest(Dash/Previews PreviewRatingDisplayCreationRanges)
728
729=== modified file 'tests/qmltests/Dash/Previews/tst_PreviewExpandable.qml'
730--- tests/qmltests/Dash/Previews/tst_PreviewExpandable.qml 2016-08-30 14:06:47 +0000
731+++ tests/qmltests/Dash/Previews/tst_PreviewExpandable.qml 2016-12-05 18:39:29 +0000
732@@ -75,10 +75,6 @@
733 "zoomable": false
734 }
735
736- property var paymentsData: {
737- "source": { "price" : 0.99, "currency": "USD", "store_item_id": "com.example.package" }
738- }
739-
740 property var progressData: {
741 "type": "progress",
742 "source": { "dbus-name" : "somename", "dbus-object": "somestring" }
743@@ -155,7 +151,6 @@
744 allWidgetsModel.append({"type": "header", "widgetId": "header1", "properties": headerData });
745 allWidgetsModel.append({"type": "icon-actions", "widgetId": "icon-actions1", "properties": iconActionsData } );
746 allWidgetsModel.append({"type": "image", "widgetId": "image1", "properties": imageData });
747- allWidgetsModel.append({"type": "payments", "widgetId": "payments1", "properties": paymentsData });
748 allWidgetsModel.append({"type": "progress", "widgetId": "progress1", "properties": progressData });
749 allWidgetsModel.append({"type": "rating-input", "widgetId": "rating-input1", "properties": ratingInputData });
750 allWidgetsModel.append({"type": "rating-edit", "widgetId": "rating-edit1", "properties": ratingEditData });
751
752=== removed file 'tests/qmltests/Dash/Previews/tst_PreviewPayments.qml'
753--- tests/qmltests/Dash/Previews/tst_PreviewPayments.qml 2015-07-15 15:07:19 +0000
754+++ tests/qmltests/Dash/Previews/tst_PreviewPayments.qml 1970-01-01 00:00:00 +0000
755@@ -1,203 +0,0 @@
756-/*
757- * Copyright 2014 Canonical Ltd.
758- *
759- * This program is free software; you can redistribute it and/or modify
760- * it under the terms of the GNU General Public License as published by
761- * the Free Software Foundation; version 3.
762- *
763- * This program is distributed in the hope that it will be useful,
764- * but WITHOUT ANY WARRANTY; without even the implied warranty of
765- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
766- * GNU General Public License for more details.
767- *
768- * You should have received a copy of the GNU General Public License
769- * along with this program. If not, see <http://www.gnu.org/licenses/>.
770- */
771-
772-import QtQuick 2.4
773-import QtTest 1.0
774-import "../../../../qml/Dash/Previews"
775-import Unity.Test 0.1 as UT
776-import Ubuntu.Components 1.3
777-
778-Rectangle {
779- id: root
780- width: units.gu(60)
781- height: units.gu(80)
782-
783- property var jsonPurchase: {
784- "source": { "price" : 0.99, "currency": "USD", "store_item_id": "com.example.package" }
785- }
786-
787- property var jsonPurchaseError: {
788- "source": { "price" : 0.99, "currency": "USD", "store_item_id": "com.example.invalid" }
789- }
790-
791- property var jsonPurchaseCancel: {
792- "source": { "price" : 0.99, "currency": "USD", "store_item_id": "com.example.cancel" }
793- }
794-
795- SignalSpy {
796- id: spy
797- target: previewPayments
798- signalName: "triggered"
799- }
800-
801- PreviewPayments {
802- id: previewPayments
803- widgetId: "previewPayments"
804- width: units.gu(30)
805- }
806-
807- UT.UnityTestCase {
808- name: "PreviewPaymentsTest"
809- when: windowShown
810- property var paymentClient
811-
812- function init()
813- {
814- paymentClient = findInvisibleChild(previewPayments, "paymentClient");
815- verify(paymentClient, "Could not find the payment client object.");
816- }
817-
818- function cleanup()
819- {
820- paymentClient = null;
821- previewPayments.widgetData = null;
822- spy.clear();
823- var button = findChild(previewPayments, "paymentButton");
824- button.opacity = 1;
825- }
826-
827- function test_purchase_text_display() {
828- previewPayments.widgetData = jsonPurchase;
829-
830- var button = findChild(previewPayments, "paymentButton");
831- verify(button, "Button not found.");
832- compare(button.text, "0.99USD");
833- }
834-
835- function test_purchase_completed() {
836- // Exercise the purchaseCompleted signal here.
837- previewPayments.widgetData = jsonPurchase;
838-
839- var button = findChild(previewPayments, "paymentButton");
840- verify(button, "Button not found.");
841-
842- mouseClick(button);
843-
844- paymentClient.process();
845- spy.wait();
846-
847- var args = spy.signalArguments[0];
848- compare(args[0], "previewPayments");
849- compare(args[1], "purchaseCompleted");
850- compare(args[2], jsonPurchase["source"]);
851- }
852-
853- function test_progress_show() {
854- // Make sure the progress bar is shown.
855- previewPayments.widgetData = jsonPurchase;
856-
857- var button = findChild(previewPayments, "paymentButton");
858- var progress = findChild(previewPayments, "loadingBar");
859-
860- tryCompare(progress, "visible", false);
861- tryCompare(progress, "opacity", 0);
862- tryCompare(button, "visible", true);
863- tryCompare(button, "opacity", 1);
864-
865- mouseClick(button);
866-
867- paymentClient.process();
868- spy.wait();
869-
870- tryCompare(progress, "visible", true);
871- tryCompare(progress, "opacity", 1);
872- tryCompare(button, "visible", false);
873- tryCompare(button, "opacity", 0);
874- }
875-
876- function test_progress_show_cancel() {
877- // Make sure the progress bar is shown.
878- previewPayments.widgetData = jsonPurchaseError;
879-
880- var button = findChild(previewPayments, "paymentButton");
881- var progress = findChild(previewPayments, "loadingBar");
882-
883- tryCompare(progress, "visible", false);
884- tryCompare(progress, "opacity", 0);
885- tryCompare(button, "visible", true);
886- tryCompare(button, "opacity", 1);
887-
888- mouseClick(button);
889-
890- tryCompare(progress, "visible", true);
891- tryCompare(progress, "opacity", 1);
892- tryCompare(button, "visible", false);
893- tryCompare(button, "opacity", 0);
894-
895- paymentClient.process();
896- spy.wait();
897-
898- tryCompare(progress, "visible", false);
899- tryCompare(progress, "opacity", 0);
900- tryCompare(button, "visible", true);
901- tryCompare(button, "opacity", 1);
902- }
903-
904- function test_purchase_error() {
905- // The mock Payments triggers an error when com.example.invalid is
906- // passed to it as store_item_id. Exercise it here
907- previewPayments.widgetData = jsonPurchaseError;
908-
909- var button = findChild(previewPayments, "paymentButton");
910- verify(button, "Button not found.");
911-
912- mouseClick(button);
913-
914- paymentClient.process();
915- spy.wait();
916-
917- var args = spy.signalArguments[0];
918- compare(args[0], "previewPayments");
919- compare(args[1], "purchaseError");
920- compare(args[2], jsonPurchaseError["source"]);
921- }
922-
923- function test_purchase_cancelled() {
924- // The mock Payments triggers cancellation when com.example.cancel
925- // is passed to it as store_item_id. Exercise it here
926- previewPayments.widgetData = jsonPurchaseCancel;
927-
928- var button = findChild(previewPayments, "paymentButton");
929- var progress = findChild(previewPayments, "loadingBar");
930- verify(button, "Button not found.");
931- verify(progress, "Progress not found.");
932-
933- mouseClick(button);
934-
935- tryCompare(progress, "visible", true);
936- tryCompare(progress, "opacity", 1);
937- tryCompare(button, "visible", false);
938- tryCompare(button, "opacity", 0);
939-
940- paymentClient.process();
941-
942- // Signal is not used at the moment, to avoid preview refresh.
943- /*
944- *spy.wait();
945- *
946- * var args = spy.signalArguments[0];
947- * compare(args[0], "previewPayments");
948- * compare(args[1], "purchaseCancelled");
949- * compare(args[2], jsonPurchaseCancel["source"]);
950- */
951-
952- tryCompare(progress, "visible", false);
953- tryCompare(progress, "opacity", 0);
954- tryCompare(button, "visible", true);
955- tryCompare(button, "opacity", 1);
956- }
957- }
958-}

Subscribers

People subscribed via source and target branches