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

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

Issue 188283003: Add ServiceWorkerVersion::status() (which is to be persisted unlike running status) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 9 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 | Annotate | Revision Log
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/service_worker/service_worker_registration.h" 5 #include "content/browser/service_worker/service_worker_registration.h"
6 6
7 #include "base/files/scoped_temp_dir.h" 7 #include "base/files/scoped_temp_dir.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/message_loop/message_loop.h" 9 #include "base/message_loop/message_loop.h"
10 #include "content/browser/browser_thread_impl.h" 10 #include "content/browser/browser_thread_impl.h"
(...skipping 17 matching lines...) Expand all
28 TEST_F(ServiceWorkerRegistrationTest, Shutdown) { 28 TEST_F(ServiceWorkerRegistrationTest, Shutdown) {
29 const int64 registration_id = -1L; 29 const int64 registration_id = -1L;
30 const int64 version_id = -1L; 30 const int64 version_id = -1L;
31 scoped_refptr<ServiceWorkerRegistration> registration = 31 scoped_refptr<ServiceWorkerRegistration> registration =
32 new ServiceWorkerRegistration( 32 new ServiceWorkerRegistration(
33 GURL("http://www.example.com/*"), 33 GURL("http://www.example.com/*"),
34 GURL("http://www.example.com/service_worker.js"), 34 GURL("http://www.example.com/service_worker.js"),
35 registration_id); 35 registration_id);
36 36
37 scoped_refptr<ServiceWorkerVersion> active_version = 37 scoped_refptr<ServiceWorkerVersion> active_version =
38 new ServiceWorkerVersion(registration, NULL, version_id); 38 new ServiceWorkerVersion(registration, NULL, version_id,
39 ServiceWorkerVersion::NEW);
39 registration->set_active_version(active_version); 40 registration->set_active_version(active_version);
40 41
41 registration->Shutdown(); 42 registration->Shutdown();
42 43
43 DCHECK(registration->is_shutdown()); 44 DCHECK(registration->is_shutdown());
44 DCHECK(active_version->is_shutdown()); 45 DCHECK(active_version->is_shutdown());
45 DCHECK(registration->HasOneRef()); 46 DCHECK(registration->HasOneRef());
46 DCHECK(active_version->HasOneRef()); 47 DCHECK(active_version->HasOneRef());
47 } 48 }
48 49
49 // Make sure that activation does not leak 50 // Make sure that activation does not leak
50 TEST_F(ServiceWorkerRegistrationTest, ActivatePending) { 51 TEST_F(ServiceWorkerRegistrationTest, ActivatePending) {
51 int64 registration_id = -1L; 52 int64 registration_id = -1L;
52 scoped_refptr<ServiceWorkerRegistration> registration = 53 scoped_refptr<ServiceWorkerRegistration> registration =
53 new ServiceWorkerRegistration( 54 new ServiceWorkerRegistration(
54 GURL("http://www.example.com/*"), 55 GURL("http://www.example.com/*"),
55 GURL("http://www.example.com/service_worker.js"), 56 GURL("http://www.example.com/service_worker.js"),
56 registration_id); 57 registration_id);
57 58
58 const int64 version_1_id = 1L; 59 const int64 version_1_id = 1L;
59 const int64 version_2_id = 2L; 60 const int64 version_2_id = 2L;
60 scoped_refptr<ServiceWorkerVersion> version_1 = 61 scoped_refptr<ServiceWorkerVersion> version_1 =
61 new ServiceWorkerVersion(registration, NULL, version_1_id); 62 new ServiceWorkerVersion(registration, NULL, version_1_id,
63 ServiceWorkerVersion::ACTIVE);
62 registration->set_active_version(version_1); 64 registration->set_active_version(version_1);
63 65
64 scoped_refptr<ServiceWorkerVersion> version_2 = 66 scoped_refptr<ServiceWorkerVersion> version_2 =
65 new ServiceWorkerVersion(registration, NULL, version_2_id); 67 new ServiceWorkerVersion(registration, NULL, version_2_id,
68 ServiceWorkerVersion::NEW);
66 registration->set_pending_version(version_2); 69 registration->set_pending_version(version_2);
67 70
68 registration->ActivatePendingVersion(); 71 registration->ActivatePendingVersion();
69 DCHECK_EQ(version_2, registration->active_version()); 72 DCHECK_EQ(version_2, registration->active_version());
70 DCHECK(version_1->is_shutdown()); 73 DCHECK(version_1->is_shutdown());
71 DCHECK(version_1->HasOneRef()); 74 DCHECK(version_1->HasOneRef());
72 version_1 = NULL; 75 version_1 = NULL;
73 76
74 DCHECK(!version_2->is_shutdown()); 77 DCHECK(!version_2->is_shutdown());
75 DCHECK(!version_2->HasOneRef()); 78 DCHECK(!version_2->HasOneRef());
76 79
77 registration->Shutdown(); 80 registration->Shutdown();
78 81
79 DCHECK(registration->is_shutdown()); 82 DCHECK(registration->is_shutdown());
80 DCHECK(version_2->is_shutdown()); 83 DCHECK(version_2->is_shutdown());
81 DCHECK(registration->HasOneRef()); 84 DCHECK(registration->HasOneRef());
82 DCHECK(version_2->HasOneRef()); 85 DCHECK(version_2->HasOneRef());
83 } 86 }
84 87
85 } // namespace content 88 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698