on xenial help sign in
Show progress bar on payment button click

The payment process has a small delay before the UI comes up which might cause confusion. Show a progress bar with unknown value to indicate activity. Fixes: 1354139 Approved by: Michał Sawicz, PS Jenkins bot

commit6fea321e20fe9063168a039b02a2ea6feb49d3e7 authorDiego Sarmentero <diego.sarmentero@gmail.com> dateFri 22 Aug 2014, 09:27 (12 years ago) parent54602d4478fe95
2 files changed+46−3
qml/Dash/Previews/PreviewPayments.qml+22−3 tests/qmltests/Dash/Previews/tst_PreviewPayments.qml+24
qml/Dash/Previews/PreviewPayments.qml+22−3
@@ -37,9 +37,15 @@ PreviewWidget {
3737
3838 color: Theme.palette.selected.foreground
3939 text: paymentClient.formattedPrice
40− onClicked: paymentClient.start()
40+ onClicked: {
41+ paymentClient.start();
42+ paymentButton.opacity = 0;
43+ }
4144 anchors.right: parent.right
4245 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 } }
4349
4450 Payments {
4551 id: paymentClient
@@ -49,8 +55,21 @@ PreviewWidget {
4955 price: source["price"]
5056 currency: source["currency"]
5157 storeItemId: source["store_item_id"]
52− onPurchaseCompleted: root.triggered(widgetId, "purchaseCompleted", source)
53− onPurchaseError: root.triggered(widgetId, "purchaseError", source)
58+ onPurchaseCompleted: {
59+ root.triggered(widgetId, "purchaseCompleted", source);
60+ }
61+ onPurchaseError: {
62+ root.triggered(widgetId, "purchaseError", source);
63+ }
5464 }
5565 }
66+
67+ ProgressBar {
68+ id: loadingBar
69+ objectName: "loadingBar"
70+ indeterminate: true
71+ anchors.fill: paymentButton
72+ opacity: 1 - paymentButton.opacity
73+ visible: !paymentButton.visible
74+ }
5675}
tests/qmltests/Dash/Previews/tst_PreviewPayments.qml+24
@@ -52,6 +52,8 @@ Rectangle {
5252 function cleanup()
5353 {
5454 spy.clear();
55+ var button = findChild(root, "paymentButton");
56+ button.opacity = 1;
5557 }
5658
5759 function test_purchase_text_display() {
@@ -79,6 +81,28 @@ Rectangle {
7981 compare(args[2], jsonPurchase["source"]);
8082 }
8183
84+ function test_progress_show() {
85+ // Make sure the progress bar is shown.
86+ previewPayments.widgetData = jsonPurchase;
87+
88+ var button = findChild(root, "paymentButton");
89+ var progress = findChild(root, "loadingBar");
90+
91+ tryCompare(progress, "visible", false);
92+ tryCompare(progress, "opacity", 0);
93+ tryCompare(button, "visible", true);
94+ tryCompare(button, "opacity", 1);
95+
96+ mouseClick(button, button.width / 2, button.height / 2);
97+
98+ spy.wait();
99+
100+ tryCompare(progress, "visible", true);
101+ tryCompare(progress, "opacity", 1);
102+ tryCompare(button, "visible", false);
103+ tryCompare(button, "opacity", 0);
104+ }
105+
82106 function test_purchase_error() {
83107 // The mock Payments triggers an error when com.example.invalid is
84108 // passed to it as store_item_id. Exercise it here