@@ -48,19 +48,28 @@ Rectangle {
4848 UT.UnityTestCase {
4949 name: "PreviewPaymentsTest"
5050 when: windowShown
51+ property var paymentClient
52+
53+ function init()
54+ {
55+ paymentClient = findInvisibleChild(previewPayments, "paymentClient");
56+ verify(paymentClient, "Could not find the payment client object.");
57+ }
5158
5259 function cleanup()
5360 {
61+ paymentClient = null;
62+ previewPayments.widgetData = null;
5463 spy.clear();
55− var button = findChild(root, "paymentButton");
64+ var button = findChild(previewPayments, "paymentButton");
5665 button.opacity = 1;
5766 }
5867
5968 function test_purchase_text_display() {
6069 previewPayments.widgetData = jsonPurchase;
6170
62− var button = findChild(root, "paymentButton");
63− verify(button != null, "Button not found.");
71+ var button = findChild(previewPayments, "paymentButton");
72+ verify(button, "Button not found.");
6473 compare(button.text, "0.99USD");
6574 }
6675
@@ -68,11 +77,12 @@ Rectangle {
6877 // Exercise the purchaseCompleted signal here.
6978 previewPayments.widgetData = jsonPurchase;
7079
71− var button = findChild(root, "paymentButton");
72− verify(button != null, "Button not found.");
80+ var button = findChild(previewPayments, "paymentButton");
81+ verify(button, "Button not found.");
7382
7483 mouseClick(button, button.width / 2, button.height / 2);
7584
85+ paymentClient.process();
7686 spy.wait();
7787
7888 var args = spy.signalArguments[0];
@@ -85,8 +95,8 @@ Rectangle {
8595 // Make sure the progress bar is shown.
8696 previewPayments.widgetData = jsonPurchase;
8797
88− var button = findChild(root, "paymentButton");
89− var progress = findChild(root, "loadingBar");
98+ var button = findChild(previewPayments, "paymentButton");
99+ var progress = findChild(previewPayments, "loadingBar");
90100
91101 tryCompare(progress, "visible", false);
92102 tryCompare(progress, "opacity", 0);
@@ -95,6 +105,7 @@ Rectangle {
95105
96106 mouseClick(button, button.width / 2, button.height / 2);
97107
108+ paymentClient.process();
98109 spy.wait();
99110
100111 tryCompare(progress, "visible", true);
@@ -105,10 +116,10 @@ Rectangle {
105116
106117 function test_progress_show_cancel() {
107118 // Make sure the progress bar is shown.
108− previewPayments.widgetData = jsonPurchase;
119+ previewPayments.widgetData = jsonPurchaseError;
109120
110− var button = findChild(root, "paymentButton");
111− var progress = findChild(root, "loadingBar");
121+ var button = findChild(previewPayments, "paymentButton");
122+ var progress = findChild(previewPayments, "loadingBar");
112123
113124 tryCompare(progress, "visible", false);
114125 tryCompare(progress, "opacity", 0);
@@ -117,16 +128,13 @@ Rectangle {
117128
118129 mouseClick(button, button.width / 2, button.height / 2);
119130
120− spy.wait();
121−
122131 tryCompare(progress, "visible", true);
123132 tryCompare(progress, "opacity", 1);
124133 tryCompare(button, "visible", false);
125134 tryCompare(button, "opacity", 0);
126135
127− var paymentClient = findChild(root, "paymentClient");
128− paymentClient.storeItemId = "com.example.invalid";
129− paymentClient.start();
136+ paymentClient.process();
137+ spy.wait();
130138
131139 tryCompare(progress, "visible", false);
132140 tryCompare(progress, "opacity", 0);
@@ -139,11 +147,12 @@ Rectangle {
139147 // passed to it as store_item_id. Exercise it here
140148 previewPayments.widgetData = jsonPurchaseError;
141149
142− var button = findChild(root, "paymentButton");
143− verify(button != null, "Button not found.");
150+ var button = findChild(previewPayments, "paymentButton");
151+ verify(button, "Button not found.");
144152
145153 mouseClick(button, button.width / 2, button.height / 2);
146154
155+ paymentClient.process();
147156 spy.wait();
148157
149158 var args = spy.signalArguments[0];