Index: content/browser/payments/payment_app_content_unittest_base.cc |
diff --git a/content/browser/payments/payment_app_content_unittest_base.cc b/content/browser/payments/payment_app_content_unittest_base.cc |
index 4d95eee40ef74e803f468d03d14a8a76df25d5e7..a8aac646f97ccb1bcbdaf46ebdd2713cbbcebe28 100644 |
--- a/content/browser/payments/payment_app_content_unittest_base.cc |
+++ b/content/browser/payments/payment_app_content_unittest_base.cc |
@@ -33,6 +33,12 @@ void RegisterServiceWorkerCallback(bool* called, |
*called = true; |
} |
+void UnregisterServiceWorkerCallback(bool* called, |
+ ServiceWorkerStatusCode status) { |
+ EXPECT_EQ(SERVICE_WORKER_OK, status) << ServiceWorkerStatusToString(status); |
+ *called = true; |
+} |
+ |
} // namespace |
PaymentAppContentUnitTestBase::PaymentAppContentUnitTestBase() |
@@ -88,8 +94,11 @@ PaymentAppManager* PaymentAppContentUnitTestBase::CreatePaymentAppManager( |
// Find a last registered payment app manager. |
for (const auto& candidate_manager : |
payment_app_context_->payment_app_managers_) { |
- if (!base::ContainsKey(existing_managers, candidate_manager.first)) |
+ if (!base::ContainsKey(existing_managers, candidate_manager.first)) { |
+ candidate_manager.first->Init(scope_url.spec()); |
+ base::RunLoop().RunUntilIdle(); |
return candidate_manager.first; |
+ } |
} |
NOTREACHED(); |
@@ -98,20 +107,18 @@ PaymentAppManager* PaymentAppContentUnitTestBase::CreatePaymentAppManager( |
void PaymentAppContentUnitTestBase::SetManifest( |
PaymentAppManager* manager, |
- const std::string& scope, |
payments::mojom::PaymentAppManifestPtr manifest, |
const PaymentAppManager::SetManifestCallback& callback) { |
ASSERT_NE(nullptr, manager); |
- manager->SetManifest(scope, std::move(manifest), callback); |
+ manager->SetManifest(std::move(manifest), callback); |
base::RunLoop().RunUntilIdle(); |
} |
void PaymentAppContentUnitTestBase::GetManifest( |
PaymentAppManager* manager, |
- const std::string& scope, |
const PaymentAppManager::GetManifestCallback& callback) { |
ASSERT_NE(nullptr, manager); |
- manager->GetManifest(scope, callback); |
+ manager->GetManifest(callback); |
base::RunLoop().RunUntilIdle(); |
} |
@@ -134,4 +141,14 @@ PaymentAppContentUnitTestBase::CreatePaymentAppManifestForTest( |
return manifest; |
} |
+void PaymentAppContentUnitTestBase::UnregisterServiceWorker( |
+ const GURL& scope_url) { |
+ // Unregister service worker. |
+ bool called = false; |
+ embedded_worker_helper_->context()->UnregisterServiceWorker( |
+ scope_url, base::Bind(&UnregisterServiceWorkerCallback, &called)); |
+ base::RunLoop().RunUntilIdle(); |
+ EXPECT_TRUE(called); |
+} |
+ |
} // namespace content |