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

Unified Diff: content/browser/payments/payment_app_content_unittest_base.cc

Issue 2936623002: Implement dumb URLLoader{Factory} for ServiceWorker script loading (for try)
Patch Set: . Created 3 years, 6 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 side-by-side diff with in-line comments
Download patch
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 37294f68bfdab0aba24182671853e164a7c806f9..5ef9dda2495bd5ce519b481ee6d863ff6e11aa1e 100644
--- a/content/browser/payments/payment_app_content_unittest_base.cc
+++ b/content/browser/payments/payment_app_content_unittest_base.cc
@@ -28,11 +28,13 @@ namespace content {
namespace {
void RegisterServiceWorkerCallback(bool* called,
+ int64_t* out_registration_id,
ServiceWorkerStatusCode status,
const std::string& status_message,
int64_t registration_id) {
EXPECT_EQ(SERVICE_WORKER_OK, status) << ServiceWorkerStatusToString(status);
*called = true;
+ *out_registration_id = registration_id;
}
void UnregisterServiceWorkerCallback(bool* called,
@@ -41,6 +43,11 @@ void UnregisterServiceWorkerCallback(bool* called,
*called = true;
}
+void StopWorkerCallback(bool* called, ServiceWorkerStatusCode status) {
+ EXPECT_EQ(SERVICE_WORKER_OK, status) << ServiceWorkerStatusToString(status);
+ *called = true;
+}
+
} // namespace
class PaymentAppContentUnitTestBase::PaymentAppForWorkerTestHelper
@@ -51,21 +58,23 @@ class PaymentAppContentUnitTestBase::PaymentAppForWorkerTestHelper
last_sw_registration_id_(kInvalidServiceWorkerRegistrationId) {}
~PaymentAppForWorkerTestHelper() override {}
- void OnStartWorker(int embedded_worker_id,
- int64_t service_worker_version_id,
- const GURL& scope,
- const GURL& script_url,
- bool pause_after_download,
- mojom::ServiceWorkerEventDispatcherRequest request,
- mojom::EmbeddedWorkerInstanceHostAssociatedPtrInfo
- instance_host) override {
+ void OnStartWorker(
+ int embedded_worker_id,
+ int64_t service_worker_version_id,
+ const GURL& scope,
+ const GURL& script_url,
+ bool pause_after_download,
+ mojom::ServiceWorkerEventDispatcherRequest request,
+ mojom::EmbeddedWorkerInstanceHostAssociatedPtrInfo instance_host,
+ mojom::ServiceWorkerProviderClientInfoPtr provider_client_info) override {
ServiceWorkerVersion* version =
context()->GetLiveVersion(service_worker_version_id);
last_sw_registration_id_ = version->registration_id();
last_sw_scope_ = scope;
EmbeddedWorkerTestHelper::OnStartWorker(
embedded_worker_id, service_worker_version_id, scope, script_url,
- pause_after_download, std::move(request), std::move(instance_host));
+ pause_after_download, std::move(request), std::move(instance_host),
+ std::move(provider_client_info));
}
void OnPaymentRequestEvent(
@@ -111,9 +120,23 @@ PaymentManager* PaymentAppContentUnitTestBase::CreatePaymentManager(
const GURL& sw_script_url) {
// Register service worker for payment manager.
bool called = false;
+ int64_t registration_id;
worker_helper_->context()->RegisterServiceWorker(
scope_url, sw_script_url, nullptr,
- base::Bind(&RegisterServiceWorkerCallback, &called));
+ base::Bind(&RegisterServiceWorkerCallback, &called, &registration_id));
+ base::RunLoop().RunUntilIdle();
+ EXPECT_TRUE(called);
+
+ // Ensure the worker used for installation has stopped.
+ called = false;
+ ServiceWorkerRegistration* registration =
+ worker_helper_->context()->GetLiveRegistration(registration_id);
+ EXPECT_TRUE(registration);
+ EXPECT_TRUE(registration->active_version());
+ EXPECT_FALSE(registration->waiting_version());
+ EXPECT_FALSE(registration->installing_version());
+ registration->active_version()->StopWorker(
+ base::Bind(&StopWorkerCallback, &called));
base::RunLoop().RunUntilIdle();
EXPECT_TRUE(called);

Powered by Google App Engine
This is Rietveld 408576698