@@ -35,20 +35,14 @@ Rectangle {
36 SignalSpy {
36 SignalSpy {
38+ target: previewPayments
38 signalName: "triggered"
39 signalName: "triggered"
41 PreviewPayments {
42 PreviewPayments {
42 id: previewPayments
43 id: previewPayments
43 widgetId: "previewPayments"
44 widgetId: "previewPayments"
44− widgetData: jsonPurchase
45 width: units.gu(30)
45 width: units.gu(30)
54 UT.UnityTestCase {
48 UT.UnityTestCase {
@@ -60,16 +54,25 @@ Rectangle {
60 spy.clear();
54 spy.clear();
63− function test_purchase_completed() {
57+ function test_purchase_text_display() {
64− var button = findChild(root, "previewPayments");
58+ previewPayments.widgetData = jsonPurchase;
65− verify(button != null);
66− spy.target = previewPayments;
60+ var button = findChild(root, "paymentButton");
61+ verify(button != null, "Button not found.");
62+ compare(button.text, "USD0.99");
65+ function test_purchase_completed() {
68 // Exercise the purchaseCompleted signal here.
66 // Exercise the purchaseCompleted signal here.
69 previewPayments.widgetData = jsonPurchase;
67 previewPayments.widgetData = jsonPurchase;
69+ var button = findChild(root, "paymentButton");
70+ verify(button != null, "Button not found.");
70 mouseClick(button, button.width / 2, button.height / 2);
72 mouseClick(button, button.width / 2, button.height / 2);
72− compare(spy.count, 1);
74+ spy.wait();
73 var args = spy.signalArguments[0];
76 var args = spy.signalArguments[0];
74 compare(args[0], "previewPayments");
77 compare(args[0], "previewPayments");
75 compare(args[1], "purchaseCompleted");
78 compare(args[1], "purchaseCompleted");
@@ -77,16 +80,17 @@ Rectangle {
79 function test_purchase_error() {
82 function test_purchase_error() {
80− var button = findChild(root, "previewPayments");
81− verify(button != null);
82− spy.target = previewPayments;
84 // The mock Payments triggers an error when com.example.invalid is
83 // The mock Payments triggers an error when com.example.invalid is
85 // passed to it as store_item_id. Exercise it here
84 // passed to it as store_item_id. Exercise it here
86 previewPayments.widgetData = jsonPurchaseError;
85 previewPayments.widgetData = jsonPurchaseError;
87+ var button = findChild(root, "paymentButton");
88+ verify(button != null, "Button not found.");
87 mouseClick(button, button.width / 2, button.height / 2);
90 mouseClick(button, button.width / 2, button.height / 2);
89− compare(spy.count, 1);
92+ spy.wait();
90 var args = spy.signalArguments[0];
94 var args = spy.signalArguments[0];
91 compare(args[0], "previewPayments");
95 compare(args[0], "previewPayments");
92 compare(args[1], "purchaseError");
96 compare(args[1], "purchaseError");