| OLD | NEW |
| 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 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 144 candidate_manager.first->Init(scope_url.spec()); | 144 candidate_manager.first->Init(scope_url.spec()); |
| 145 base::RunLoop().RunUntilIdle(); | 145 base::RunLoop().RunUntilIdle(); |
| 146 return candidate_manager.first; | 146 return candidate_manager.first; |
| 147 } | 147 } |
| 148 } | 148 } |
| 149 | 149 |
| 150 NOTREACHED(); | 150 NOTREACHED(); |
| 151 return nullptr; | 151 return nullptr; |
| 152 } | 152 } |
| 153 | 153 |
| 154 void PaymentAppContentUnitTestBase::SetManifest( | |
| 155 PaymentManager* manager, | |
| 156 payments::mojom::PaymentAppManifestPtr manifest, | |
| 157 PaymentManager::SetManifestCallback callback) { | |
| 158 ASSERT_NE(nullptr, manager); | |
| 159 manager->SetManifest(std::move(manifest), std::move(callback)); | |
| 160 base::RunLoop().RunUntilIdle(); | |
| 161 } | |
| 162 | |
| 163 void PaymentAppContentUnitTestBase::GetManifest( | |
| 164 PaymentManager* manager, | |
| 165 PaymentManager::GetManifestCallback callback) { | |
| 166 ASSERT_NE(nullptr, manager); | |
| 167 manager->GetManifest(std::move(callback)); | |
| 168 base::RunLoop().RunUntilIdle(); | |
| 169 } | |
| 170 | |
| 171 payments::mojom::PaymentAppManifestPtr | |
| 172 PaymentAppContentUnitTestBase::CreatePaymentAppManifestForTest( | |
| 173 const std::string& name) { | |
| 174 payments::mojom::PaymentAppOptionPtr option = | |
| 175 payments::mojom::PaymentAppOption::New(); | |
| 176 option->name = "Visa ****"; | |
| 177 option->id = "payment-app-id"; | |
| 178 option->icon = std::string("payment-app-icon"); | |
| 179 option->enabled_methods.push_back("visa"); | |
| 180 | |
| 181 payments::mojom::PaymentAppManifestPtr manifest = | |
| 182 payments::mojom::PaymentAppManifest::New(); | |
| 183 manifest->icon = std::string("payment-app-icon"); | |
| 184 manifest->name = name; | |
| 185 manifest->options.push_back(std::move(option)); | |
| 186 | |
| 187 return manifest; | |
| 188 } | |
| 189 | |
| 190 void PaymentAppContentUnitTestBase::UnregisterServiceWorker( | 154 void PaymentAppContentUnitTestBase::UnregisterServiceWorker( |
| 191 const GURL& scope_url) { | 155 const GURL& scope_url) { |
| 192 // Unregister service worker. | 156 // Unregister service worker. |
| 193 bool called = false; | 157 bool called = false; |
| 194 worker_helper_->context()->UnregisterServiceWorker( | 158 worker_helper_->context()->UnregisterServiceWorker( |
| 195 scope_url, base::Bind(&UnregisterServiceWorkerCallback, &called)); | 159 scope_url, base::Bind(&UnregisterServiceWorkerCallback, &called)); |
| 196 base::RunLoop().RunUntilIdle(); | 160 base::RunLoop().RunUntilIdle(); |
| 197 EXPECT_TRUE(called); | 161 EXPECT_TRUE(called); |
| 198 } | 162 } |
| 199 | 163 |
| 200 int64_t PaymentAppContentUnitTestBase::last_sw_registration_id() const { | 164 int64_t PaymentAppContentUnitTestBase::last_sw_registration_id() const { |
| 201 return worker_helper_->last_sw_registration_id_; | 165 return worker_helper_->last_sw_registration_id_; |
| 202 } | 166 } |
| 203 | 167 |
| 204 const GURL& PaymentAppContentUnitTestBase::last_sw_scope_url() const { | 168 const GURL& PaymentAppContentUnitTestBase::last_sw_scope_url() const { |
| 205 return worker_helper_->last_sw_scope_; | 169 return worker_helper_->last_sw_scope_; |
| 206 } | 170 } |
| 207 | 171 |
| 208 StoragePartitionImpl* PaymentAppContentUnitTestBase::storage_partition() { | 172 StoragePartitionImpl* PaymentAppContentUnitTestBase::storage_partition() { |
| 209 return static_cast<StoragePartitionImpl*>( | 173 return static_cast<StoragePartitionImpl*>( |
| 210 BrowserContext::GetDefaultStoragePartition(browser_context())); | 174 BrowserContext::GetDefaultStoragePartition(browser_context())); |
| 211 } | 175 } |
| 212 | 176 |
| 213 PaymentAppContextImpl* PaymentAppContentUnitTestBase::payment_app_context() { | 177 PaymentAppContextImpl* PaymentAppContentUnitTestBase::payment_app_context() { |
| 214 return storage_partition()->GetPaymentAppContext(); | 178 return storage_partition()->GetPaymentAppContext(); |
| 215 } | 179 } |
| 216 | 180 |
| 217 } // namespace content | 181 } // namespace content |
| OLD | NEW |