Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(124)

Side by Side Diff: content/browser/payments/payment_app_browsertest.cc

Issue 2885793003: ** DO NOT COMMIT** Only for test
Patch Set: Replace yaho Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/browser/storage_partition_impl.h" 9 #include "content/browser/storage_partition_impl.h"
10 #include "content/public/browser/browser_context.h" 10 #include "content/public/browser/browser_context.h"
11 #include "content/public/browser/payment_app_provider.h" 11 #include "content/public/browser/payment_app_provider.h"
12 #include "content/public/browser/web_contents.h" 12 #include "content/public/browser/web_contents.h"
13 #include "content/public/common/content_switches.h" 13 #include "content/public/common/content_switches.h"
14 #include "content/public/test/browser_test_utils.h" 14 #include "content/public/test/browser_test_utils.h"
15 #include "content/public/test/content_browser_test.h" 15 #include "content/public/test/content_browser_test.h"
16 #include "content/public/test/content_browser_test_utils.h" 16 #include "content/public/test/content_browser_test_utils.h"
17 #include "content/shell/browser/shell.h" 17 #include "content/shell/browser/shell.h"
18 #include "net/test/embedded_test_server/embedded_test_server.h" 18 #include "net/test/embedded_test_server/embedded_test_server.h"
19 #include "testing/gtest/include/gtest/gtest.h" 19 #include "testing/gtest/include/gtest/gtest.h"
20 20
21 namespace content { 21 namespace content {
22 namespace { 22 namespace {
23 23
24 using ::payments::mojom::PaymentAppRequest;
25 using ::payments::mojom::PaymentAppRequestPtr;
26 using ::payments::mojom::PaymentAppResponsePtr;
27 using ::payments::mojom::PaymentCurrencyAmount;
28 using ::payments::mojom::PaymentDetailsModifier;
29 using ::payments::mojom::PaymentDetailsModifierPtr;
30 using ::payments::mojom::PaymentItem;
31 using ::payments::mojom::PaymentMethodData;
32
24 void GetAllPaymentAppsCallback(const base::Closure& done_callback, 33 void GetAllPaymentAppsCallback(const base::Closure& done_callback,
25 PaymentAppProvider::PaymentApps* out_apps, 34 PaymentAppProvider::PaymentApps* out_apps,
26 PaymentAppProvider::PaymentApps apps) { 35 PaymentAppProvider::PaymentApps apps) {
27 *out_apps = std::move(apps); 36 *out_apps = std::move(apps);
28 done_callback.Run(); 37 done_callback.Run();
29 } 38 }
30 39
31 void InvokePaymentAppCallback( 40 void InvokePaymentAppCallback(
32 const base::Closure& done_callback, 41 const base::Closure& done_callback,
33 payments::mojom::PaymentAppResponsePtr* out_response, 42 payments::mojom::PaymentAppResponsePtr* out_response,
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 106
98 payments::mojom::PaymentAppResponsePtr InvokePaymentApp( 107 payments::mojom::PaymentAppResponsePtr InvokePaymentApp(
99 int64_t registration_id) { 108 int64_t registration_id) {
100 payments::mojom::PaymentAppRequestPtr app_request = 109 payments::mojom::PaymentAppRequestPtr app_request =
101 payments::mojom::PaymentAppRequest::New(); 110 payments::mojom::PaymentAppRequest::New();
102 app_request->method_data.push_back( 111 app_request->method_data.push_back(
103 payments::mojom::PaymentMethodData::New()); 112 payments::mojom::PaymentMethodData::New());
104 app_request->total = payments::mojom::PaymentItem::New(); 113 app_request->total = payments::mojom::PaymentItem::New();
105 app_request->total->amount = payments::mojom::PaymentCurrencyAmount::New(); 114 app_request->total->amount = payments::mojom::PaymentCurrencyAmount::New();
106 115
116 PaymentDetailsModifierPtr modifier = PaymentDetailsModifier::New();
117 modifier->total = payments::mojom::PaymentItem::New();
118 modifier->total->amount = payments::mojom::PaymentCurrencyAmount::New();
119 modifier->method_data = payments::mojom::PaymentMethodData::New();
120 app_request->modifiers.push_back(std::move(modifier));
121
107 base::RunLoop run_loop; 122 base::RunLoop run_loop;
108 payments::mojom::PaymentAppResponsePtr response; 123 payments::mojom::PaymentAppResponsePtr response;
109 PaymentAppProvider::GetInstance()->InvokePaymentApp( 124 PaymentAppProvider::GetInstance()->InvokePaymentApp(
110 shell()->web_contents()->GetBrowserContext(), registration_id, 125 shell()->web_contents()->GetBrowserContext(), registration_id,
111 std::move(app_request), 126 std::move(app_request),
112 base::Bind(&InvokePaymentAppCallback, run_loop.QuitClosure(), 127 base::Bind(&InvokePaymentAppCallback, run_loop.QuitClosure(),
113 &response)); 128 &response));
114 run_loop.Run(); 129 run_loop.Run();
115 130
116 return response; 131 return response;
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
155 payments::mojom::PaymentAppResponsePtr response(InvokePaymentApp(ids[0])); 170 payments::mojom::PaymentAppResponsePtr response(InvokePaymentApp(ids[0]));
156 ASSERT_EQ("test", response->method_name); 171 ASSERT_EQ("test", response->method_name);
157 172
158 ClearStoragePartitionData(); 173 ClearStoragePartitionData();
159 174
160 ids = GetAllPaymentAppIDs(); 175 ids = GetAllPaymentAppIDs();
161 ASSERT_EQ(0U, ids.size()); 176 ASSERT_EQ(0U, ids.size());
162 } 177 }
163 178
164 } // namespace content 179 } // namespace content
OLDNEW
« no previous file with comments | « components/payments/mojom/payment_app.mojom ('k') | content/renderer/service_worker/service_worker_type_converters.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698