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

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

Issue 2785523003: PaymentHandler: Rename PaymentAppManager to PaymentManager. (Closed)
Patch Set: PaymentHandler: Rename PaymentAppManager to PaymentManager. Created 3 years, 8 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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 "content/browser/payments/payment_app_content_unittest_base.h" 5 #include "content/browser/payments/payment_app_content_unittest_base.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 8
9 #include <set> 9 #include <set>
10 #include <utility> 10 #include <utility>
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 base::RunLoop().RunUntilIdle(); 96 base::RunLoop().RunUntilIdle();
97 } 97 }
98 98
99 PaymentAppContentUnitTestBase::~PaymentAppContentUnitTestBase() {} 99 PaymentAppContentUnitTestBase::~PaymentAppContentUnitTestBase() {}
100 100
101 BrowserContext* PaymentAppContentUnitTestBase::browser_context() { 101 BrowserContext* PaymentAppContentUnitTestBase::browser_context() {
102 DCHECK(worker_helper_); 102 DCHECK(worker_helper_);
103 return worker_helper_->browser_context(); 103 return worker_helper_->browser_context();
104 } 104 }
105 105
106 PaymentAppManager* PaymentAppContentUnitTestBase::CreatePaymentAppManager( 106 PaymentManager* PaymentAppContentUnitTestBase::CreatePaymentManager(
107 const GURL& scope_url, 107 const GURL& scope_url,
108 const GURL& sw_script_url) { 108 const GURL& sw_script_url) {
109 // Register service worker for payment app manager. 109 // Register service worker for payment manager.
110 bool called = false; 110 bool called = false;
111 worker_helper_->context()->RegisterServiceWorker( 111 worker_helper_->context()->RegisterServiceWorker(
112 scope_url, sw_script_url, nullptr, 112 scope_url, sw_script_url, nullptr,
113 base::Bind(&RegisterServiceWorkerCallback, &called)); 113 base::Bind(&RegisterServiceWorkerCallback, &called));
114 base::RunLoop().RunUntilIdle(); 114 base::RunLoop().RunUntilIdle();
115 EXPECT_TRUE(called); 115 EXPECT_TRUE(called);
116 116
117 // This function should eventually return created payment app manager 117 // This function should eventually return created payment manager
118 // but there is no way to get last created payment app manager from 118 // but there is no way to get last created payment manager from
119 // payment_app_context()->payment_app_managers_ because its type is std::map 119 // payment_app_context()->payment_managers_ because its type is std::map
120 // and can not ensure its order. So, just make a set of existing payment app 120 // and can not ensure its order. So, just make a set of existing payment app
121 // managers before creating a new manager and then check what is a new thing. 121 // managers before creating a new manager and then check what is a new thing.
122 std::set<PaymentAppManager*> existing_managers; 122 std::set<PaymentManager*> existing_managers;
123 for (const auto& existing_manager : 123 for (const auto& existing_manager :
124 payment_app_context()->payment_app_managers_) { 124 payment_app_context()->payment_managers_) {
125 existing_managers.insert(existing_manager.first); 125 existing_managers.insert(existing_manager.first);
126 } 126 }
127 127
128 // Create a new payment app manager. 128 // Create a new payment manager.
129 payments::mojom::PaymentAppManagerPtr manager; 129 payments::mojom::PaymentManagerPtr manager;
130 mojo::InterfaceRequest<payments::mojom::PaymentAppManager> request = 130 mojo::InterfaceRequest<payments::mojom::PaymentManager> request =
131 mojo::MakeRequest(&manager); 131 mojo::MakeRequest(&manager);
132 payment_app_managers_.push_back(std::move(manager)); 132 payment_managers_.push_back(std::move(manager));
133 payment_app_context()->CreatePaymentAppManager(std::move(request)); 133 payment_app_context()->CreatePaymentManager(std::move(request));
134 base::RunLoop().RunUntilIdle(); 134 base::RunLoop().RunUntilIdle();
135 135
136 // Find a last registered payment app manager. 136 // Find a last registered payment manager.
137 for (const auto& candidate_manager : 137 for (const auto& candidate_manager :
138 payment_app_context()->payment_app_managers_) { 138 payment_app_context()->payment_managers_) {
139 if (!base::ContainsKey(existing_managers, candidate_manager.first)) { 139 if (!base::ContainsKey(existing_managers, candidate_manager.first)) {
140 candidate_manager.first->Init(scope_url.spec()); 140 candidate_manager.first->Init(scope_url.spec());
141 base::RunLoop().RunUntilIdle(); 141 base::RunLoop().RunUntilIdle();
142 return candidate_manager.first; 142 return candidate_manager.first;
143 } 143 }
144 } 144 }
145 145
146 NOTREACHED(); 146 NOTREACHED();
147 return nullptr; 147 return nullptr;
148 } 148 }
149 149
150 void PaymentAppContentUnitTestBase::SetManifest( 150 void PaymentAppContentUnitTestBase::SetManifest(
151 PaymentAppManager* manager, 151 PaymentManager* manager,
152 payments::mojom::PaymentAppManifestPtr manifest, 152 payments::mojom::PaymentAppManifestPtr manifest,
153 const PaymentAppManager::SetManifestCallback& callback) { 153 const PaymentManager::SetManifestCallback& callback) {
154 ASSERT_NE(nullptr, manager); 154 ASSERT_NE(nullptr, manager);
155 manager->SetManifest(std::move(manifest), callback); 155 manager->SetManifest(std::move(manifest), callback);
156 base::RunLoop().RunUntilIdle(); 156 base::RunLoop().RunUntilIdle();
157 } 157 }
158 158
159 void PaymentAppContentUnitTestBase::GetManifest( 159 void PaymentAppContentUnitTestBase::GetManifest(
160 PaymentAppManager* manager, 160 PaymentManager* manager,
161 const PaymentAppManager::GetManifestCallback& callback) { 161 const PaymentManager::GetManifestCallback& callback) {
162 ASSERT_NE(nullptr, manager); 162 ASSERT_NE(nullptr, manager);
163 manager->GetManifest(callback); 163 manager->GetManifest(callback);
164 base::RunLoop().RunUntilIdle(); 164 base::RunLoop().RunUntilIdle();
165 } 165 }
166 166
167 payments::mojom::PaymentAppManifestPtr 167 payments::mojom::PaymentAppManifestPtr
168 PaymentAppContentUnitTestBase::CreatePaymentAppManifestForTest( 168 PaymentAppContentUnitTestBase::CreatePaymentAppManifestForTest(
169 const std::string& name) { 169 const std::string& name) {
170 payments::mojom::PaymentAppOptionPtr option = 170 payments::mojom::PaymentAppOptionPtr option =
171 payments::mojom::PaymentAppOption::New(); 171 payments::mojom::PaymentAppOption::New();
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
204 StoragePartitionImpl* PaymentAppContentUnitTestBase::storage_partition() { 204 StoragePartitionImpl* PaymentAppContentUnitTestBase::storage_partition() {
205 return static_cast<StoragePartitionImpl*>( 205 return static_cast<StoragePartitionImpl*>(
206 BrowserContext::GetDefaultStoragePartition(browser_context())); 206 BrowserContext::GetDefaultStoragePartition(browser_context()));
207 } 207 }
208 208
209 PaymentAppContextImpl* PaymentAppContentUnitTestBase::payment_app_context() { 209 PaymentAppContextImpl* PaymentAppContentUnitTestBase::payment_app_context() {
210 return storage_partition()->GetPaymentAppContext(); 210 return storage_partition()->GetPaymentAppContext();
211 } 211 }
212 212
213 } // namespace content 213 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/payments/payment_app_content_unittest_base.h ('k') | content/browser/payments/payment_app_context_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698