OLD | NEW |
1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "base/command_line.h" | 5 #include "base/command_line.h" |
6 #include "base/macros.h" | 6 #include "base/macros.h" |
7 #include "base/run_loop.h" | 7 #include "base/run_loop.h" |
8 #include "components/payments/mojom/payment_app.mojom.h" | 8 #include "components/payments/mojom/payment_app.mojom.h" |
9 #include "content/public/browser/payment_app_provider.h" | 9 #include "content/public/browser/payment_app_provider.h" |
10 #include "content/public/browser/web_contents.h" | 10 #include "content/public/browser/web_contents.h" |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
88 ids.push_back(manifest.first); | 88 ids.push_back(manifest.first); |
89 } | 89 } |
90 | 90 |
91 return ids; | 91 return ids; |
92 } | 92 } |
93 | 93 |
94 payments::mojom::PaymentAppResponsePtr InvokePaymentApp( | 94 payments::mojom::PaymentAppResponsePtr InvokePaymentApp( |
95 int64_t registration_id) { | 95 int64_t registration_id) { |
96 payments::mojom::PaymentAppRequestPtr app_request = | 96 payments::mojom::PaymentAppRequestPtr app_request = |
97 payments::mojom::PaymentAppRequest::New(); | 97 payments::mojom::PaymentAppRequest::New(); |
98 app_request->methodData.push_back( | 98 app_request->method_data.push_back( |
99 payments::mojom::PaymentMethodData::New()); | 99 payments::mojom::PaymentMethodData::New()); |
100 app_request->total = payments::mojom::PaymentItem::New(); | 100 app_request->total = payments::mojom::PaymentItem::New(); |
101 app_request->total->amount = payments::mojom::PaymentCurrencyAmount::New(); | 101 app_request->total->amount = payments::mojom::PaymentCurrencyAmount::New(); |
102 | 102 |
103 base::RunLoop run_loop; | 103 base::RunLoop run_loop; |
104 payments::mojom::PaymentAppResponsePtr response; | 104 payments::mojom::PaymentAppResponsePtr response; |
105 PaymentAppProvider::GetInstance()->InvokePaymentApp( | 105 PaymentAppProvider::GetInstance()->InvokePaymentApp( |
106 shell()->web_contents()->GetBrowserContext(), registration_id, | 106 shell()->web_contents()->GetBrowserContext(), registration_id, |
107 std::move(app_request), | 107 std::move(app_request), |
108 base::Bind(&InvokePaymentAppCallback, run_loop.QuitClosure(), | 108 base::Bind(&InvokePaymentAppCallback, run_loop.QuitClosure(), |
(...skipping 13 matching lines...) Expand all Loading... |
122 RegisterPaymentApp(); | 122 RegisterPaymentApp(); |
123 | 123 |
124 std::vector<int64_t> ids = GetAllPaymentAppIDs(); | 124 std::vector<int64_t> ids = GetAllPaymentAppIDs(); |
125 ASSERT_EQ(1U, ids.size()); | 125 ASSERT_EQ(1U, ids.size()); |
126 | 126 |
127 payments::mojom::PaymentAppResponsePtr response(InvokePaymentApp(ids[0])); | 127 payments::mojom::PaymentAppResponsePtr response(InvokePaymentApp(ids[0])); |
128 ASSERT_EQ("test", response->method_name); | 128 ASSERT_EQ("test", response->method_name); |
129 } | 129 } |
130 | 130 |
131 } // namespace content | 131 } // namespace content |
OLD | NEW |