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

Unified Diff: content/browser/service_worker/service_worker_dispatcher_host_unittest.cc

Issue 1186803002: ServiceWorker: Route unregister() through WebServiceWorkerRegistration for refactoring (4) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@route_web_sw_reg_2
Patch Set: rebase Created 5 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/service_worker/service_worker_dispatcher_host_unittest.cc
diff --git a/content/browser/service_worker/service_worker_dispatcher_host_unittest.cc b/content/browser/service_worker/service_worker_dispatcher_host_unittest.cc
index 4a2e0f1eeecda98b01ce59417946046324edeac8..462d093bae277e4b025794237f480e329178cbfa 100644
--- a/content/browser/service_worker/service_worker_dispatcher_host_unittest.cc
+++ b/content/browser/service_worker/service_worker_dispatcher_host_unittest.cc
@@ -99,6 +99,22 @@ class ServiceWorkerDispatcherHostTest : public testing::Test {
dispatcher_host_->ipc_sink()->ClearMessages();
}
+ void SendUnregister(int64 provider_id, int64 registration_id) {
+ dispatcher_host_->OnMessageReceived(
+ ServiceWorkerHostMsg_UnregisterServiceWorker(-1, -1, provider_id,
+ registration_id));
+ base::RunLoop().RunUntilIdle();
+ }
+
+ void Unregister(int64 provider_id,
+ int64 registration_id,
+ uint32 expected_message) {
+ SendUnregister(provider_id, registration_id);
+ EXPECT_TRUE(dispatcher_host_->ipc_sink()->GetUniqueMessageMatching(
+ expected_message));
+ dispatcher_host_->ipc_sink()->ClearMessages();
+ }
+
void SendGetRegistration(int64 provider_id, GURL document_url) {
dispatcher_host_->OnMessageReceived(
ServiceWorkerHostMsg_GetRegistration(
@@ -175,7 +191,15 @@ TEST_F(ServiceWorkerDispatcherHostTest,
ServiceWorkerMsg_ServiceWorkerGetRegistrationError::ID);
GetRegistrations(kProviderId,
ServiceWorkerMsg_ServiceWorkerGetRegistrationsError::ID);
- // TODO(nhiroki): Test Unregister() (http://crbug.com/500404).
+
+ // Add a registration into a live registration map so that Unregister() can
+ // find it.
+ const int64 kRegistrationId = 999; // Dummy value
+ scoped_refptr<ServiceWorkerRegistration> registration(
+ new ServiceWorkerRegistration(GURL("https://www.example.com/"),
+ kRegistrationId, context()->AsWeakPtr()));
+ Unregister(kProviderId, kRegistrationId,
+ ServiceWorkerMsg_ServiceWorkerUnregistrationError::ID);
SetBrowserClientForTesting(old_browser_client);
}

Powered by Google App Engine
This is Rietveld 408576698