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

Side by Side Diff: content/browser/service_worker/service_worker_job_unittest.cc

Issue 554573002: SWRegistration::unregister returns false when the registration is already unregistered. (2/3) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add const Created 6 years, 3 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "base/files/scoped_temp_dir.h" 5 #include "base/files/scoped_temp_dir.h"
6 #include "base/logging.h" 6 #include "base/logging.h"
7 #include "base/run_loop.h" 7 #include "base/run_loop.h"
8 #include "content/browser/browser_thread_impl.h" 8 #include "content/browser/browser_thread_impl.h"
9 #include "content/browser/service_worker/embedded_worker_registry.h" 9 #include "content/browser/service_worker/embedded_worker_registry.h"
10 #include "content/browser/service_worker/embedded_worker_test_helper.h" 10 #include "content/browser/service_worker/embedded_worker_test_helper.h"
(...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after
273 base::RunLoop().RunUntilIdle(); 273 base::RunLoop().RunUntilIdle();
274 ASSERT_TRUE(called); 274 ASSERT_TRUE(called);
275 275
276 ASSERT_EQ(scoped_refptr<ServiceWorkerRegistration>(NULL), registration); 276 ASSERT_EQ(scoped_refptr<ServiceWorkerRegistration>(NULL), registration);
277 } 277 }
278 278
279 TEST_F(ServiceWorkerJobTest, Unregister_NothingRegistered) { 279 TEST_F(ServiceWorkerJobTest, Unregister_NothingRegistered) {
280 GURL pattern("http://www.example.com/"); 280 GURL pattern("http://www.example.com/");
281 281
282 bool called; 282 bool called;
283 job_coordinator()->Unregister(pattern, 283 job_coordinator()->Unregister(
284 SaveUnregistration(SERVICE_WORKER_OK, &called)); 284 pattern,
285 SaveUnregistration(SERVICE_WORKER_ERROR_NOT_FOUND, &called));
285 286
286 ASSERT_FALSE(called); 287 ASSERT_FALSE(called);
287 base::RunLoop().RunUntilIdle(); 288 base::RunLoop().RunUntilIdle();
288 ASSERT_TRUE(called); 289 ASSERT_TRUE(called);
289 } 290 }
290 291
291 // Make sure registering a new script creates a new version and shares an 292 // Make sure registering a new script creates a new version and shares an
292 // existing registration. 293 // existing registration.
293 TEST_F(ServiceWorkerJobTest, RegisterNewScript) { 294 TEST_F(ServiceWorkerJobTest, RegisterNewScript) {
294 GURL pattern("http://www.example.com/"); 295 GURL pattern("http://www.example.com/");
(...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after
560 } 561 }
561 562
562 // Call simulataneous unregister calls. 563 // Call simulataneous unregister calls.
563 TEST_F(ServiceWorkerJobTest, ParallelUnreg) { 564 TEST_F(ServiceWorkerJobTest, ParallelUnreg) {
564 GURL pattern("http://www.example.com/"); 565 GURL pattern("http://www.example.com/");
565 566
566 GURL script_url("http://www.example.com/service_worker.js"); 567 GURL script_url("http://www.example.com/service_worker.js");
567 bool unregistration1_called = false; 568 bool unregistration1_called = false;
568 job_coordinator()->Unregister( 569 job_coordinator()->Unregister(
569 pattern, 570 pattern,
570 SaveUnregistration(SERVICE_WORKER_OK, &unregistration1_called)); 571 SaveUnregistration(SERVICE_WORKER_ERROR_NOT_FOUND,
572 &unregistration1_called));
571 573
572 bool unregistration2_called = false; 574 bool unregistration2_called = false;
573 job_coordinator()->Unregister( 575 job_coordinator()->Unregister(
574 pattern, SaveUnregistration(SERVICE_WORKER_OK, &unregistration2_called)); 576 pattern,
577 SaveUnregistration(SERVICE_WORKER_ERROR_NOT_FOUND,
578 &unregistration2_called));
575 579
576 ASSERT_FALSE(unregistration1_called); 580 ASSERT_FALSE(unregistration1_called);
577 ASSERT_FALSE(unregistration2_called); 581 ASSERT_FALSE(unregistration2_called);
578 base::RunLoop().RunUntilIdle(); 582 base::RunLoop().RunUntilIdle();
579 ASSERT_TRUE(unregistration1_called); 583 ASSERT_TRUE(unregistration1_called);
580 ASSERT_TRUE(unregistration2_called); 584 ASSERT_TRUE(unregistration2_called);
581 585
582 // There isn't really a way to test that they are being coalesced, 586 // There isn't really a way to test that they are being coalesced,
583 // but we can make sure they can exist simultaneously without 587 // but we can make sure they can exist simultaneously without
584 // crashing. 588 // crashing.
(...skipping 602 matching lines...) Expand 10 before | Expand all | Expand 10 after
1187 EXPECT_TRUE(called); 1191 EXPECT_TRUE(called);
1188 1192
1189 // Verify the registration was not modified by the Update. 1193 // Verify the registration was not modified by the Update.
1190 EXPECT_TRUE(registration->is_uninstalling()); 1194 EXPECT_TRUE(registration->is_uninstalling());
1191 EXPECT_EQ(active_version, registration->active_version()); 1195 EXPECT_EQ(active_version, registration->active_version());
1192 EXPECT_EQ(NULL, registration->waiting_version()); 1196 EXPECT_EQ(NULL, registration->waiting_version());
1193 EXPECT_EQ(NULL, registration->installing_version()); 1197 EXPECT_EQ(NULL, registration->installing_version());
1194 } 1198 }
1195 1199
1196 } // namespace content 1200 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698