on xenial help sign in
Remove the payments widget and dependency on libpay as no longer needed.
commit0671ee81e254fdcd1ac90c2f991f052b85c17e34 authorRodney Dawes <rodney.dawes@canonical.com> dateMon 5 Dec 2016, 13:30 (10 years ago) parent317fbd4
20 files changed−811
debian/control−2 plugins/Ubuntu/CMakeLists.txt−1 plugins/Ubuntu/Payments/CMakeLists.txt−20 plugins/Ubuntu/Payments/Payments.cpp−136 plugins/Ubuntu/Payments/Payments.h−69 plugins/Ubuntu/Payments/plugin.cpp−28 plugins/Ubuntu/Payments/plugin.h−31 plugins/Ubuntu/Payments/qmldir−3 qml/Dash/Previews/PreviewPayments.qml−81 qml/Dash/Previews/PreviewWidgetFactory.qml−1 tests/mocks/Ubuntu/CMakeLists.txt−1 tests/mocks/Ubuntu/Payments/CMakeLists.txt−10 tests/mocks/Ubuntu/Payments/MockPayments.cpp−95 tests/mocks/Ubuntu/Payments/MockPayments.h−62 tests/mocks/Ubuntu/Payments/plugin.cpp−28 tests/mocks/Ubuntu/Payments/plugin.h−31 tests/mocks/Ubuntu/Payments/qmldir−3 tests/qmltests/CMakeLists.txt−1 tests/qmltests/Dash/Previews/tst_PreviewExpandable.qml−5 tests/qmltests/Dash/Previews/tst_PreviewPayments.qml−203
debian/control−2
@@ -26,7 +26,6 @@ Build-Depends: cmake,
2626 libhardware-dev,
2727 liblightdm-qt5-3-dev,
2828 libpam0g-dev,
29− libpay2-dev,
3029 libpulse-dev,
3130 libqmenumodel-dev (>= 0.2.10),
3231 libqt5svg5-dev,
@@ -219,7 +218,6 @@ Pre-Depends: ${misc:Pre-Depends},
219218Depends: accountsservice-ubuntu-schemas (>= 0.0.7),
220219 gsettings-ubuntu-schemas (>= 0.0.2+14.10.20140815),
221220 libhardware2,
222− pay-service,
223221 unity-schemas (>= 7.3.1+14.10.20140915),
224222 qtdeclarative5-gsettings1.0,
225223 qml-module-qtmultimedia,
plugins/Ubuntu/CMakeLists.txt−1
@@ -1,4 +1,3 @@
11add_subdirectory(Gestures)
22add_subdirectory(DownloadDaemonListener)
3−add_subdirectory(Payments)
43add_subdirectory(SystemImage)
plugins/Ubuntu/Payments/CMakeLists.txtdeleted−20
@@ -1,20 +0,0 @@
1−include_directories(
2− ${CMAKE_CURRENT_SOURCE_DIR}
3− ${CMAKE_CURRENT_BINARY_DIR}
4−)
5−
6−set(PAYMENTS_SOURCES
7− plugin.cpp
8− Payments.cpp
9−)
10−
11−add_library(Payments MODULE ${PAYMENTS_SOURCES})
12−
13−qt5_use_modules(Payments Qml Quick DBus Core)
14−
15−add_unity8_plugin(Ubuntu.Payments 0.1 Ubuntu/Payments TARGETS Payments)
16−
17−pkg_check_modules(LIBPAY REQUIRED pay-2)
18−add_definitions(${LIBPAY_CFLAGS} ${LIBPAY_CFLAGS_OTHER})
19−
20−target_link_libraries(Payments ${LIBPAY_LDFLAGS})
plugins/Ubuntu/Payments/Payments.cppdeleted−136
@@ -1,136 +0,0 @@
1−/*
2− * Copyright (C) 2014 Canonical, Ltd.
3− *
4− * This program is free software; you can redistribute it and/or modify
5− * it under the terms of the GNU General Public License as published by
6− * the Free Software Foundation; version 3.
7− *
8− * This program is distributed in the hope that it will be useful,
9− * but WITHOUT ANY WARRANTY; without even the implied warranty of
10− * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11− * GNU General Public License for more details.
12− *
13− * You should have received a copy of the GNU General Public License
14− * along with this program. If not, see <http://www.gnu.org/licenses/>.
15− */
16−
17−#include "Payments.h"
18−
19−#include <QLocale>
20−
21−#include <libpay/pay-package.h>
22−
23−
24−// The observer callback for the package we are watching.
25−static void observer(PayPackage* /* package */, const char* itemid, PayPackageItemStatus status, void* user_data) {
26− // This function is called in libpay's thread, so be careful what you call
27− // Emitting signals should be fine as long as they use Queued or Auto
28− // connections (the default)
29− // http://qt-project.org/doc/qt-5/threads-qobject.html#signals-and-slots-across-threads
30−
31− Payments *self = static_cast<Payments*>(user_data);
32−
33− // If the item ID is different, ignore it.
34− if (itemid != self->storeItemId()) {
35− return;
36− }
37−
38− // FIXME: No error reporting from libpay, but we need to show some
39− // types of errors to the user. https://launchpad.net/bugs/1333403
40− switch (status) {
41− case PAY_PACKAGE_ITEM_STATUS_PURCHASED:
42− Q_EMIT self->purchaseCompleted();
43− break;
44− case PAY_PACKAGE_ITEM_STATUS_PURCHASING:
45− self->setPurchasing(true);
46− break;
47− case PAY_PACKAGE_ITEM_STATUS_NOT_PURCHASED:
48− if (self->purchasing()) {
49− self->setPurchasing(false);
50− Q_EMIT self->purchaseCancelled();
51− }
52− break;
53− default:
54− break;
55− }
56−}
57−
58−Payments::Payments(QObject *parent)
59− : QObject(parent),
60− m_purchasing(false)
61−{
62− m_package = pay_package_new("click-scope");
63− pay_package_item_observer_install(m_package, observer, this);
64−}
65−
66−Payments::~Payments()
67−{
68− pay_package_item_observer_uninstall(m_package, observer, this);
69− pay_package_delete(m_package);
70−}
71−
72−QString Payments::currency() const
73−{
74− return m_currency;
75−}
76−
77−double Payments::price() const
78−{
79− return m_price;
80−}
81−
82−QString Payments::storeItemId() const
83−{
84− return m_store_item_id;
85−}
86−
87−QString Payments::formattedPrice() const
88−{
89− QLocale locale;
90− return locale.toCurrencyString(m_price, m_currency);
91−}
92−
93−bool Payments::purchasing() const
94−{
95− return m_purchasing;
96−}
97−
98−void Payments::setCurrency(const QString &currency)
99−{
100− if(m_currency != currency) {
101− m_currency = currency;
102− Q_EMIT currencyChanged(currency);
103− Q_EMIT formattedPriceChanged(formattedPrice());
104− }
105−}
106−
107−void Payments::setPrice(const double price)
108−{
109− if(m_price != price) {
110− m_price = price;
111− Q_EMIT priceChanged(price);
112− Q_EMIT formattedPriceChanged(formattedPrice());
113− }
114−}
115−
116−void Payments::setStoreItemId(const QString &store_item_id)
117−{
118− if (m_store_item_id != store_item_id) {
119− m_store_item_id = store_item_id;
120− Q_EMIT storeItemIdChanged(m_store_item_id);
121− }
122−
123− if (m_store_item_id.isEmpty()) {
124− return;
125− }
126−}
127−
128−void Payments::setPurchasing(bool is_purchasing)
129−{
130− m_purchasing = is_purchasing;
131−}
132−
133−void Payments::start()
134−{
135− pay_package_item_start_purchase(m_package, m_store_item_id.toLocal8Bit().data());
136−}
plugins/Ubuntu/Payments/Payments.hdeleted−69
@@ -1,69 +0,0 @@
1−/*
2− * Copyright (C) 2014 Canonical, Ltd.
3− *
4− * This program is free software; you can redistribute it and/or modify
5− * it under the terms of the GNU General Public License as published by
6− * the Free Software Foundation; version 3.
7− *
8− * This program is distributed in the hope that it will be useful,
9− * but WITHOUT ANY WARRANTY; without even the implied warranty of
10− * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11− * GNU General Public License for more details.
12− *
13− * You should have received a copy of the GNU General Public License
14− * along with this program. If not, see <http://www.gnu.org/licenses/>.
15− */
16−
17−#ifndef PAYMENTS_H
18−#define PAYMENTS_H
19−
20−#include <QObject>
21−
22−#include <libpay/pay-package.h>
23−
24−
25−class Payments : public QObject
26−{
27− Q_OBJECT
28− Q_DISABLE_COPY(Payments)
29− Q_PROPERTY(QString currency READ currency WRITE setCurrency NOTIFY currencyChanged)
30− Q_PROPERTY(double price READ price WRITE setPrice NOTIFY priceChanged)
31− Q_PROPERTY(QString storeItemId READ storeItemId WRITE setStoreItemId NOTIFY storeItemIdChanged)
32− Q_PROPERTY(QString formattedPrice READ formattedPrice NOTIFY formattedPriceChanged)
33−
34−public:
35− explicit Payments(QObject *parent = 0);
36− virtual ~Payments();
37−
38− QString currency() const;
39− double price() const;
40− QString storeItemId() const;
41− QString formattedPrice() const;
42− bool purchasing() const;
43−
44− void setCurrency(const QString& currency);
45− void setPrice(const double price);
46− void setStoreItemId(const QString& store_item_id);
47− void setPurchasing(bool is_purchasing);
48− Q_INVOKABLE void start();
49−
50−Q_SIGNALS:
51− void currencyChanged(const QString& currency);
52− void priceChanged(const double price);
53− void storeItemIdChanged(const QString &store_item_id);
54− void formattedPriceChanged(const QString &formatted_price);
55−
56− void purchaseError(const QString &error);
57− void purchaseCompleted();
58− void purchaseCancelled();
59−
60−private:
61− QString m_currency;
62− double m_price;
63− QString m_store_item_id;
64− bool m_purchasing;
65−
66− PayPackage *m_package;
67−};
68−
69−#endif // PAYMENTS_H
plugins/Ubuntu/Payments/plugin.cppdeleted−28
@@ -1,28 +0,0 @@
1−/*
2− * Copyright (C) 2014 Canonical, Ltd.
3− *
4− * This program is free software; you can redistribute it and/or modify
5− * it under the terms of the GNU General Public License as published by
6− * the Free Software Foundation; version 3.
7− *
8− * This program is distributed in the hope that it will be useful,
9− * but WITHOUT ANY WARRANTY; without even the implied warranty of
10− * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11− * GNU General Public License for more details.
12− *
13− * You should have received a copy of the GNU General Public License
14− * along with this program. If not, see <http://www.gnu.org/licenses/>.
15− */
16−
17−#include "plugin.h"
18−#include "Payments.h"
19−
20−#include <QtQml>
21−
22−
23−void BackendPlugin::registerTypes(const char *uri)
24−{
25− Q_ASSERT(uri == QLatin1String("Ubuntu.Payments"));
26−
27− qmlRegisterType<Payments>(uri, 0, 1, "Payments");
28−}
plugins/Ubuntu/Payments/plugin.hdeleted−31
@@ -1,31 +0,0 @@
1−/*
2− * Copyright (C) 2014 Canonical, Ltd.
3− *
4− * This program is free software; you can redistribute it and/or modify
5− * it under the terms of the GNU General Public License as published by
6− * the Free Software Foundation; version 3.
7− *
8− * This program is distributed in the hope that it will be useful,
9− * but WITHOUT ANY WARRANTY; without even the implied warranty of
10− * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11− * GNU General Public License for more details.
12− *
13− * You should have received a copy of the GNU General Public License
14− * along with this program. If not, see <http://www.gnu.org/licenses/>.
15− */
16−
17−#ifndef PAYMENTS_PLUGIN_H
18−#define PAYMENTS_PLUGIN_H
19−
20−#include <QQmlExtensionPlugin>
21−
22−class BackendPlugin : public QQmlExtensionPlugin
23−{
24− Q_OBJECT
25− Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface")
26−
27−public:
28− void registerTypes(const char *uri) override;
29−};
30−
31−#endif // PAYMENTS_PLUGIN_H
plugins/Ubuntu/Payments/qmldirdeleted−3
@@ -1,3 +0,0 @@
1−module Ubuntu.Payments
2−plugin Payments
3−typeinfo Payments.qmltypes
qml/Dash/Previews/PreviewPayments.qmldeleted−81
@@ -1,81 +0,0 @@
1−/*
2− * Copyright (C) 2014 Canonical, Ltd.
3− *
4− * This program is free software; you can redistribute it and/or modify
5− * it under the terms of the GNU General Public License as published by
6− * the Free Software Foundation; version 3.
7− *
8− * This program is distributed in the hope that it will be useful,
9− * but WITHOUT ANY WARRANTY; without even the implied warranty of
10− * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11− * GNU General Public License for more details.
12− *
13− * You should have received a copy of the GNU General Public License
14− * along with this program. If not, see <http://www.gnu.org/licenses/>.
15− */
16−
17−import QtQuick 2.4
18−import Ubuntu.Components 1.3
19−import Ubuntu.Payments 0.1
20−
21−/*! \brief Preview widget for a purchase button.
22− *
23− * When clicked, this button starts the payments service.
24− * Then it waits until the purchase finishes or fails.
25− * Those events trigger the corresponding actions.
26− */
27−
28−PreviewWidget {
29− id: root
30−
31− implicitHeight: paymentButton.implicitHeight
32− implicitWidth: paymentButton.implicitWidth
33−
34− Button {
35− id: paymentButton
36− objectName: "paymentButton"
37−
38− color: theme.palette.normal.positive
39− text: paymentClient.formattedPrice
40− onClicked: {
41− paymentClient.start();
42− paymentButton.opacity = 0;
43− }
44− anchors.right: parent.right
45− width: (root.width - units.gu(1)) / 2
46− opacity: 1
47− visible: paymentButton.opacity == 0 ? false : true
48− Behavior on opacity { PropertyAnimation { duration: UbuntuAnimation.FastDuration } }
49−
50− Payments {
51− id: paymentClient
52− objectName: "paymentClient"
53−
54− property var source: widgetData["source"]
55−
56− price: source["price"]
57− currency: source["currency"]
58− storeItemId: source["store_item_id"]
59− onPurchaseCompleted: {
60− root.triggered(widgetId, "purchaseCompleted", source);
61− }
62− onPurchaseError: {
63− paymentButton.opacity = 1;
64− root.triggered(widgetId, "purchaseError", source);
65− }
66− onPurchaseCancelled: {
67− paymentButton.opacity = 1;
68− root.triggered(widgetId, "purchaseCancelled", source);
69− }
70− }
71− }
72−
73− ProgressBar {
74− id: loadingBar
75− objectName: "loadingBar"
76− indeterminate: true
77− anchors.fill: paymentButton
78− opacity: 1 - paymentButton.opacity
79− visible: !paymentButton.visible
80− }
81−}
qml/Dash/Previews/PreviewWidgetFactory.qml−1
@@ -67,7 +67,6 @@ Loader {
6767 case "icon-actions": return "PreviewIconActions.qml";
6868 case "image": return "PreviewZoomableImage.qml";
6969 case "progress": return "PreviewProgress.qml";
70− case "payments": return "PreviewPayments.qml";
7170 case "rating-input": return "PreviewRatingInput.qml";
7271 case "rating-edit": return "PreviewRatingEdit.qml";
7372 case "reviews": return "PreviewRatingDisplay.qml";
tests/mocks/Ubuntu/CMakeLists.txt−1
@@ -1,6 +1,5 @@
11add_subdirectory(Connectivity)
22add_subdirectory(DownloadDaemonListener)
3−add_subdirectory(Payments)
43add_subdirectory(SystemImage)
54add_subdirectory(SystemSettings)
65add_subdirectory(Telephony)
tests/mocks/Ubuntu/Payments/CMakeLists.txtdeleted−10
@@ -1,10 +0,0 @@
1−set(FakeUbuntuPaymentsQml_SOURCES
2− plugin.cpp
3− MockPayments.cpp
4− )
5−
6−add_library(FakeUbuntuPaymentsQml MODULE ${FakeUbuntuPaymentsQml_SOURCES})
7−
8−qt5_use_modules(FakeUbuntuPaymentsQml Qml Quick Core)
9−
10−add_unity8_mock(Ubuntu.Payments 0.1 Ubuntu/Payments TARGETS FakeUbuntuPaymentsQml)
tests/mocks/Ubuntu/Payments/MockPayments.cppdeleted−95
@@ -1,95 +0,0 @@
1−/*
2− * Copyright (C) 2014 Canonical, Ltd.
3− *
4− * This program is free software; you can redistribute it and/or modify
5− * it under the terms of the GNU General Public License as published by
6− * the Free Software Foundation; version 3.
7− *
8− * This program is distributed in the hope that it will be useful,
9− * but WITHOUT ANY WARRANTY; without even the implied warranty of
10− * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11− * GNU General Public License for more details.
12− *
13− * You should have received a copy of the GNU General Public License
14− * along with this program. If not, see <http://www.gnu.org/licenses/>.
15− */
16−
17−#include "MockPayments.h"
18−
19−#include <QLocale>
20−
21−
22−MockPayments::MockPayments(QObject *parent)
23− : QObject(parent)
24− , m_price(0)
25−{
26−}
27−
28−QString MockPayments::currency() const
29−{
30− return m_currency;
31−}
32−
33−double MockPayments::price() const
34−{
35− return m_price;
36−}
37−
38−QString MockPayments::storeItemId() const
39−{
40− return m_store_item_id;
41−}
42−
43−QString MockPayments::formattedPrice() const
44−{
45− QLocale locale;
46− return locale.toCurrencyString(m_price, m_currency);
47−}
48−
49−void MockPayments::setCurrency(const QString &currency)
50−{
51− if(m_currency != currency) {
52− m_currency = currency;
53− Q_EMIT currencyChanged(currency);
54− Q_EMIT formattedPriceChanged(formattedPrice());
55− }
56−}
57−
58−void MockPayments::setPrice(const double price)
59−{
60− if(m_price != price) {
61− m_price = price;
62− Q_EMIT priceChanged(price);
63− Q_EMIT formattedPriceChanged(formattedPrice());
64− }
65−}
66−
67−void MockPayments::setStoreItemId(const QString &store_item_id)
68−{
69− if (m_store_item_id != store_item_id) {
70− m_store_item_id = store_item_id;
71− Q_EMIT storeItemIdChanged(m_store_item_id);
72− }
73−
74− if (m_store_item_id.isEmpty()) {
75− return;
76− }
77−}
78−
79−void MockPayments::start()
80−{
81− if (m_store_item_id.isEmpty()) {
82− Q_EMIT purchaseError("No item ID supplied.");
83− }
84−}
85−
86−void MockPayments::process()
87−{
88− if (m_store_item_id == "com.example.cancel") {
89− Q_EMIT purchaseCancelled();
90− } else if (m_store_item_id == "com.example.invalid") {
91− Q_EMIT purchaseError("Purchase failed.");
92− } else {
93− Q_EMIT purchaseCompleted();
94− }
95−}
tests/mocks/Ubuntu/Payments/MockPayments.hdeleted−62
@@ -1,62 +0,0 @@
1−/*
2− * Copyright (C) 2014 Canonical, Ltd.
3− *
4− * This program is free software; you can redistribute it and/or modify
5− * it under the terms of the GNU General Public License as published by
6− * the Free Software Foundation; version 3.
7− *
8− * This program is distributed in the hope that it will be useful,
9− * but WITHOUT ANY WARRANTY; without even the implied warranty of
10− * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11− * GNU General Public License for more details.
12− *
13− * You should have received a copy of the GNU General Public License
14− * along with this program. If not, see <http://www.gnu.org/licenses/>.
15− */
16−
17−#ifndef MOCK_PAYMENTS_H
18−#define MOCK_PAYMENTS_H
19−
20−#include <QObject>
21−
22−
23−class MockPayments : public QObject
24−{
25− Q_OBJECT
26− Q_DISABLE_COPY(MockPayments)
27− Q_PROPERTY(QString currency READ currency WRITE setCurrency NOTIFY currencyChanged)
28− Q_PROPERTY(double price READ price WRITE setPrice NOTIFY priceChanged)
29− Q_PROPERTY(QString storeItemId READ storeItemId WRITE setStoreItemId NOTIFY storeItemIdChanged)
30− Q_PROPERTY(QString formattedPrice READ formattedPrice NOTIFY formattedPriceChanged)
31−
32−public:
33− explicit MockPayments(QObject *parent = 0);
34−
35− QString currency() const;
36− double price() const;
37− QString storeItemId() const;
38− QString formattedPrice() const;
39−
40− void setCurrency(const QString& currency);
41− void setPrice(const double price);
42− void setStoreItemId(const QString& store_item_id);
43− Q_INVOKABLE void start();
44− Q_INVOKABLE void process(); // only available for testing
45−
46−Q_SIGNALS:
47− void currencyChanged(const QString& currency);
48− void priceChanged(const double price);
49− void storeItemIdChanged(const QString &store_item_id);
50− void formattedPriceChanged(const QString &formatted_price);
51−
52− void purchaseError(const QString &error);
53− void purchaseCompleted();
54− void purchaseCancelled();
55−
56−private:
57− QString m_currency;
58− double m_price;
59− QString m_store_item_id;
60−};
61−
62−#endif // MOCK_PAYMENTS_H
tests/mocks/Ubuntu/Payments/plugin.cppdeleted−28
@@ -1,28 +0,0 @@
1−/*
2− * Copyright (C) 2014 Canonical, Ltd.
3− *
4− * This program is free software; you can redistribute it and/or modify
5− * it under the terms of the GNU General Public License as published by
6− * the Free Software Foundation; version 3.
7− *
8− * This program is distributed in the hope that it will be useful,
9− * but WITHOUT ANY WARRANTY; without even the implied warranty of
10− * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11− * GNU General Public License for more details.
12− *
13− * You should have received a copy of the GNU General Public License
14− * along with this program. If not, see <http://www.gnu.org/licenses/>.
15− */
16−
17−#include "plugin.h"
18−#include "MockPayments.h"
19−
20−#include <QtQml>
21−
22−
23−void BackendPlugin::registerTypes(const char *uri)
24−{
25− Q_ASSERT(uri == QLatin1String("Ubuntu.Payments"));
26−
27− qmlRegisterType<MockPayments>(uri, 0, 1, "Payments");
28−}
tests/mocks/Ubuntu/Payments/plugin.hdeleted−31
@@ -1,31 +0,0 @@
1−/*
2− * Copyright (C) 2014 Canonical, Ltd.
3− *
4− * This program is free software; you can redistribute it and/or modify
5− * it under the terms of the GNU General Public License as published by
6− * the Free Software Foundation; version 3.
7− *
8− * This program is distributed in the hope that it will be useful,
9− * but WITHOUT ANY WARRANTY; without even the implied warranty of
10− * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11− * GNU General Public License for more details.
12− *
13− * You should have received a copy of the GNU General Public License
14− * along with this program. If not, see <http://www.gnu.org/licenses/>.
15− */
16−
17−#ifndef PAYMENTS_PLUGIN_H
18−#define PAYMENTS_PLUGIN_H
19−
20−#include <QQmlExtensionPlugin>
21−
22−class BackendPlugin : public QQmlExtensionPlugin
23−{
24− Q_OBJECT
25− Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface")
26−
27−public:
28− void registerTypes(const char *uri) override;
29−};
30−
31−#endif // PAYMENTS_PLUGIN_H
tests/mocks/Ubuntu/Payments/qmldirdeleted−3
@@ -1,3 +0,0 @@
1−module Ubuntu.Payments
2−plugin FakeUbuntuPaymentsQml
3−typeinfo Payments.qmltypes
tests/qmltests/CMakeLists.txt−1
@@ -44,7 +44,6 @@ add_unity8_qmltest(Dash/Previews PreviewIconActions)
4444add_unity8_qmltest(Dash/Previews PreviewImageGallery)
4545add_unity8_qmltest(Dash/Previews PreviewInlineVideo)
4646add_unity8_qmltest(Dash/Previews PreviewMediaToolbar)
47−add_unity8_qmltest(Dash/Previews PreviewPayments)
4847add_unity8_qmltest(Dash/Previews PreviewProgress)
4948add_unity8_qmltest(Dash/Previews PreviewRatingDisplay)
5049add_unity8_qmltest(Dash/Previews PreviewRatingDisplayCreationRanges)
tests/qmltests/Dash/Previews/tst_PreviewExpandable.qml−5
@@ -75,10 +75,6 @@ Rectangle {
7575 "zoomable": false
7676 }
7777
78− property var paymentsData: {
79− "source": { "price" : 0.99, "currency": "USD", "store_item_id": "com.example.package" }
80− }
81−
8278 property var progressData: {
8379 "type": "progress",
8480 "source": { "dbus-name" : "somename", "dbus-object": "somestring" }
@@ -155,7 +151,6 @@ Rectangle {
155151 allWidgetsModel.append({"type": "header", "widgetId": "header1", "properties": headerData });
156152 allWidgetsModel.append({"type": "icon-actions", "widgetId": "icon-actions1", "properties": iconActionsData } );
157153 allWidgetsModel.append({"type": "image", "widgetId": "image1", "properties": imageData });
158− allWidgetsModel.append({"type": "payments", "widgetId": "payments1", "properties": paymentsData });
159154 allWidgetsModel.append({"type": "progress", "widgetId": "progress1", "properties": progressData });
160155 allWidgetsModel.append({"type": "rating-input", "widgetId": "rating-input1", "properties": ratingInputData });
161156 allWidgetsModel.append({"type": "rating-edit", "widgetId": "rating-edit1", "properties": ratingEditData });
tests/qmltests/Dash/Previews/tst_PreviewPayments.qmldeleted−203
@@ -1,203 +0,0 @@
1−/*
2− * Copyright 2014 Canonical Ltd.
3− *
4− * This program is free software; you can redistribute it and/or modify
5− * it under the terms of the GNU General Public License as published by
6− * the Free Software Foundation; version 3.
7− *
8− * This program is distributed in the hope that it will be useful,
9− * but WITHOUT ANY WARRANTY; without even the implied warranty of
10− * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11− * GNU General Public License for more details.
12− *
13− * You should have received a copy of the GNU General Public License
14− * along with this program. If not, see <http://www.gnu.org/licenses/>.
15− */
16−
17−import QtQuick 2.4
18−import QtTest 1.0
19−import "../../../../qml/Dash/Previews"
20−import Unity.Test 0.1 as UT
21−import Ubuntu.Components 1.3
22−
23−Rectangle {
24− id: root
25− width: units.gu(60)
26− height: units.gu(80)
27−
28− property var jsonPurchase: {
29− "source": { "price" : 0.99, "currency": "USD", "store_item_id": "com.example.package" }
30− }
31−
32− property var jsonPurchaseError: {
33− "source": { "price" : 0.99, "currency": "USD", "store_item_id": "com.example.invalid" }
34− }
35−
36− property var jsonPurchaseCancel: {
37− "source": { "price" : 0.99, "currency": "USD", "store_item_id": "com.example.cancel" }
38− }
39−
40− SignalSpy {
41− id: spy
42− target: previewPayments
43− signalName: "triggered"
44− }
45−
46− PreviewPayments {
47− id: previewPayments
48− widgetId: "previewPayments"
49− width: units.gu(30)
50− }
51−
52− UT.UnityTestCase {
53− name: "PreviewPaymentsTest"
54− when: windowShown
55− property var paymentClient
56−
57− function init()
58− {
59− paymentClient = findInvisibleChild(previewPayments, "paymentClient");
60− verify(paymentClient, "Could not find the payment client object.");
61− }
62−
63− function cleanup()
64− {
65− paymentClient = null;
66− previewPayments.widgetData = null;
67− spy.clear();
68− var button = findChild(previewPayments, "paymentButton");
69− button.opacity = 1;
70− }
71−
72− function test_purchase_text_display() {
73− previewPayments.widgetData = jsonPurchase;
74−
75− var button = findChild(previewPayments, "paymentButton");
76− verify(button, "Button not found.");
77− compare(button.text, "0.99USD");
78− }
79−
80− function test_purchase_completed() {
81− // Exercise the purchaseCompleted signal here.
82− previewPayments.widgetData = jsonPurchase;
83−
84− var button = findChild(previewPayments, "paymentButton");
85− verify(button, "Button not found.");
86−
87− mouseClick(button);
88−
89− paymentClient.process();
90− spy.wait();
91−
92− var args = spy.signalArguments[0];
93− compare(args[0], "previewPayments");
94− compare(args[1], "purchaseCompleted");
95− compare(args[2], jsonPurchase["source"]);
96− }
97−
98− function test_progress_show() {
99− // Make sure the progress bar is shown.
100− previewPayments.widgetData = jsonPurchase;
101−
102− var button = findChild(previewPayments, "paymentButton");
103− var progress = findChild(previewPayments, "loadingBar");
104−
105− tryCompare(progress, "visible", false);
106− tryCompare(progress, "opacity", 0);
107− tryCompare(button, "visible", true);
108− tryCompare(button, "opacity", 1);
109−
110− mouseClick(button);
111−
112− paymentClient.process();
113− spy.wait();
114−
115− tryCompare(progress, "visible", true);
116− tryCompare(progress, "opacity", 1);
117− tryCompare(button, "visible", false);
118− tryCompare(button, "opacity", 0);
119− }
120−
121− function test_progress_show_cancel() {
122− // Make sure the progress bar is shown.
123− previewPayments.widgetData = jsonPurchaseError;
124−
125− var button = findChild(previewPayments, "paymentButton");
126− var progress = findChild(previewPayments, "loadingBar");
127−
128− tryCompare(progress, "visible", false);
129− tryCompare(progress, "opacity", 0);
130− tryCompare(button, "visible", true);
131− tryCompare(button, "opacity", 1);
132−
133− mouseClick(button);
134−
135− tryCompare(progress, "visible", true);
136− tryCompare(progress, "opacity", 1);
137− tryCompare(button, "visible", false);
138− tryCompare(button, "opacity", 0);
139−
140− paymentClient.process();
141− spy.wait();
142−
143− tryCompare(progress, "visible", false);
144− tryCompare(progress, "opacity", 0);
145− tryCompare(button, "visible", true);
146− tryCompare(button, "opacity", 1);
147− }
148−
149− function test_purchase_error() {
150− // The mock Payments triggers an error when com.example.invalid is
151− // passed to it as store_item_id. Exercise it here
152− previewPayments.widgetData = jsonPurchaseError;
153−
154− var button = findChild(previewPayments, "paymentButton");
155− verify(button, "Button not found.");
156−
157− mouseClick(button);
158−
159− paymentClient.process();
160− spy.wait();
161−
162− var args = spy.signalArguments[0];
163− compare(args[0], "previewPayments");
164− compare(args[1], "purchaseError");
165− compare(args[2], jsonPurchaseError["source"]);
166− }
167−
168− function test_purchase_cancelled() {
169− // The mock Payments triggers cancellation when com.example.cancel
170− // is passed to it as store_item_id. Exercise it here
171− previewPayments.widgetData = jsonPurchaseCancel;
172−
173− var button = findChild(previewPayments, "paymentButton");
174− var progress = findChild(previewPayments, "loadingBar");
175− verify(button, "Button not found.");
176− verify(progress, "Progress not found.");
177−
178− mouseClick(button);
179−
180− tryCompare(progress, "visible", true);
181− tryCompare(progress, "opacity", 1);
182− tryCompare(button, "visible", false);
183− tryCompare(button, "opacity", 0);
184−
185− paymentClient.process();
186−
187− // Signal is not used at the moment, to avoid preview refresh.
188− /*
189− *spy.wait();
190− *
191− * var args = spy.signalArguments[0];
192− * compare(args[0], "previewPayments");
193− * compare(args[1], "purchaseCancelled");
194− * compare(args[2], jsonPurchaseCancel["source"]);
195− */
196−
197− tryCompare(progress, "visible", false);
198− tryCompare(progress, "opacity", 0);
199− tryCompare(button, "visible", true);
200− tryCompare(button, "opacity", 1);
201− }
202− }
203−}