| 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 49791c7ffb915ae38dbb3b6edc6370e0ea8a161c..c3a945c32a1034cfdc418be0ece7a75164b9c9aa 100644
|
| --- a/content/browser/payments/payment_app_browsertest.cc
|
| +++ b/content/browser/payments/payment_app_browsertest.cc
|
| @@ -19,6 +19,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) {
|
| @@ -26,10 +35,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();
|
| }
|
| @@ -93,17 +101,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),
|
| @@ -126,8 +151,25 @@ 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);
|
| +
|
| + 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
|
|
|