Index: content/browser/payments/payment_app_browsertest.cc |
diff --git a/content/browser/payments/payment_app_browsertest.cc b/content/browser/payments/payment_app_browsertest.cc |
index dcb4a21b09094a5fbce89566207aed312f19be35..f5e732ca7c3f8df4e1a840f2565abb40a83f0b97 100644 |
--- a/content/browser/payments/payment_app_browsertest.cc |
+++ b/content/browser/payments/payment_app_browsertest.cc |
@@ -21,6 +21,15 @@ |
namespace content { |
namespace { |
+using ::payments::mojom::PaymentAppRequest; |
+using ::payments::mojom::PaymentAppRequestPtr; |
+using ::payments::mojom::PaymentAppResponsePtr; |
+using ::payments::mojom::PaymentCurrencyAmount; |
+using ::payments::mojom::PaymentDetailsModifier; |
+using ::payments::mojom::PaymentDetailsModifierPtr; |
+using ::payments::mojom::PaymentItem; |
+using ::payments::mojom::PaymentMethodData; |
+ |
void GetAllPaymentAppsCallback(const base::Closure& done_callback, |
PaymentAppProvider::PaymentApps* out_apps, |
PaymentAppProvider::PaymentApps apps) { |
@@ -28,10 +37,9 @@ void GetAllPaymentAppsCallback(const base::Closure& done_callback, |
done_callback.Run(); |
} |
-void InvokePaymentAppCallback( |
- const base::Closure& done_callback, |
- payments::mojom::PaymentAppResponsePtr* out_response, |
- payments::mojom::PaymentAppResponsePtr response) { |
+void InvokePaymentAppCallback(const base::Closure& done_callback, |
+ PaymentAppResponsePtr* out_response, |
+ PaymentAppResponsePtr response) { |
*out_response = std::move(response); |
done_callback.Run(); |
} |
@@ -95,17 +103,34 @@ class PaymentAppBrowserTest : public ContentBrowserTest { |
return ids; |
} |
- payments::mojom::PaymentAppResponsePtr InvokePaymentApp( |
- int64_t registration_id) { |
- payments::mojom::PaymentAppRequestPtr app_request = |
- payments::mojom::PaymentAppRequest::New(); |
- app_request->method_data.push_back( |
- payments::mojom::PaymentMethodData::New()); |
- app_request->total = payments::mojom::PaymentItem::New(); |
- app_request->total->amount = payments::mojom::PaymentCurrencyAmount::New(); |
+ PaymentAppResponsePtr InvokePaymentAppWithTestData(int64_t registration_id) { |
+ PaymentAppRequestPtr app_request = PaymentAppRequest::New(); |
+ |
+ app_request->top_level_origin = GURL("https://example.com"); |
+ |
+ app_request->payment_request_origin = GURL("https://example.com"); |
+ |
+ app_request->payment_request_id = "payment-request-id"; |
+ |
+ app_request->method_data.push_back(PaymentMethodData::New()); |
+ app_request->method_data[0]->supported_methods = {"basic-card"}; |
+ |
+ app_request->total = PaymentItem::New(); |
+ app_request->total->amount = PaymentCurrencyAmount::New(); |
+ app_request->total->amount->currency = "USD"; |
+ |
+ PaymentDetailsModifierPtr modifier = PaymentDetailsModifier::New(); |
+ modifier->total = PaymentItem::New(); |
+ modifier->total->amount = PaymentCurrencyAmount::New(); |
+ modifier->total->amount->currency = "USD"; |
+ modifier->method_data = PaymentMethodData::New(); |
+ modifier->method_data->supported_methods = {"basic-card"}; |
+ app_request->modifiers.push_back(std::move(modifier)); |
+ |
+ app_request->instrument_key = "instrument-key"; |
base::RunLoop run_loop; |
- payments::mojom::PaymentAppResponsePtr response; |
+ PaymentAppResponsePtr response; |
PaymentAppProvider::GetInstance()->InvokePaymentApp( |
shell()->web_contents()->GetBrowserContext(), registration_id, |
std::move(app_request), |
@@ -144,13 +169,30 @@ IN_PROC_BROWSER_TEST_F(PaymentAppBrowserTest, PaymentAppInvocation) { |
std::vector<int64_t> ids = GetAllPaymentAppIDs(); |
ASSERT_EQ(1U, ids.size()); |
- payments::mojom::PaymentAppResponsePtr response(InvokePaymentApp(ids[0])); |
+ PaymentAppResponsePtr response(InvokePaymentAppWithTestData(ids[0])); |
ASSERT_EQ("test", response->method_name); |
ClearStoragePartitionData(); |
ids = GetAllPaymentAppIDs(); |
ASSERT_EQ(0U, ids.size()); |
+ |
+ EXPECT_EQ("https://example.com/", PopConsoleString() /* topLevelOrigin */); |
+ EXPECT_EQ("https://example.com/", |
+ PopConsoleString() /* paymentRequestOrigin */); |
+ EXPECT_EQ("payment-request-id", PopConsoleString() /* paymentRequestId */); |
+ EXPECT_EQ("[{\"supportedMethods\":[\"basic-card\"]}]", |
+ PopConsoleString() /* methodData */); |
+ EXPECT_EQ( |
+ "{\"amount\":{\"currency\":\"USD\",\"currencySystem\":\"urn:iso:std:iso:" |
+ "4217\",\"value\":\"\"},\"label\":\"\",\"pending\":false}", |
+ PopConsoleString() /* total */); |
+ EXPECT_EQ( |
+ "[{\"additionalDisplayItems\":[],\"supportedMethods\":[\"basic-card\"]," |
+ "\"total\":{\"amount\":{\"currency\":\"USD\",\"currencySystem\":\"urn:" |
+ "iso:std:iso:4217\",\"value\":\"\"},\"label\":\"\",\"pending\":false}}]", |
+ PopConsoleString() /* modifiers */); |
+ EXPECT_EQ("instrument-key", PopConsoleString() /* instrumentKey */); |
} |
} // namespace content |