OLD | NEW |
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/public/browser/service_worker_context.h" | 5 #include "content/public/browser/service_worker_context.h" |
6 | 6 |
7 #include <stdint.h> | 7 #include <stdint.h> |
8 | 8 |
9 #include "base/files/scoped_temp_dir.h" | 9 #include "base/files/scoped_temp_dir.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
11 #include "base/memory/ptr_util.h" | 11 #include "base/memory/ptr_util.h" |
12 #include "base/message_loop/message_loop.h" | 12 #include "base/message_loop/message_loop.h" |
13 #include "base/time/time.h" | 13 #include "base/time/time.h" |
14 #include "content/browser/browser_thread_impl.h" | 14 #include "content/browser/browser_thread_impl.h" |
15 #include "content/browser/service_worker/embedded_worker_registry.h" | 15 #include "content/browser/service_worker/embedded_worker_registry.h" |
16 #include "content/browser/service_worker/embedded_worker_test_helper.h" | 16 #include "content/browser/service_worker/embedded_worker_test_helper.h" |
17 #include "content/browser/service_worker/service_worker_context_core.h" | 17 #include "content/browser/service_worker/service_worker_context_core.h" |
18 #include "content/browser/service_worker/service_worker_context_observer.h" | 18 #include "content/browser/service_worker/service_worker_context_core_observer.h" |
19 #include "content/browser/service_worker/service_worker_context_wrapper.h" | 19 #include "content/browser/service_worker/service_worker_context_wrapper.h" |
20 #include "content/browser/service_worker/service_worker_provider_host.h" | 20 #include "content/browser/service_worker/service_worker_provider_host.h" |
21 #include "content/browser/service_worker/service_worker_registration.h" | 21 #include "content/browser/service_worker/service_worker_registration.h" |
22 #include "content/browser/service_worker/service_worker_storage.h" | 22 #include "content/browser/service_worker/service_worker_storage.h" |
23 #include "content/browser/service_worker/service_worker_test_utils.h" | 23 #include "content/browser/service_worker/service_worker_test_utils.h" |
24 #include "content/common/service_worker/embedded_worker_messages.h" | 24 #include "content/common/service_worker/embedded_worker_messages.h" |
25 #include "content/common/service_worker/service_worker_messages.h" | 25 #include "content/common/service_worker/service_worker_messages.h" |
26 #include "content/public/test/test_browser_thread_bundle.h" | 26 #include "content/public/test/test_browser_thread_bundle.h" |
27 #include "content/public/test/test_utils.h" | 27 #include "content/public/test/test_utils.h" |
28 #include "testing/gtest/include/gtest/gtest.h" | 28 #include "testing/gtest/include/gtest/gtest.h" |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
115 }; | 115 }; |
116 | 116 |
117 struct NotificationLog { | 117 struct NotificationLog { |
118 NotificationType type; | 118 NotificationType type; |
119 GURL pattern; | 119 GURL pattern; |
120 int64_t registration_id; | 120 int64_t registration_id; |
121 }; | 121 }; |
122 | 122 |
123 } // namespace | 123 } // namespace |
124 | 124 |
125 class ServiceWorkerContextTest : public ServiceWorkerContextObserver, | 125 class ServiceWorkerContextTest : public ServiceWorkerContextCoreObserver, |
126 public testing::Test { | 126 public testing::Test { |
127 public: | 127 public: |
128 ServiceWorkerContextTest() | 128 ServiceWorkerContextTest() |
129 : browser_thread_bundle_(TestBrowserThreadBundle::IO_MAINLOOP) {} | 129 : browser_thread_bundle_(TestBrowserThreadBundle::IO_MAINLOOP) {} |
130 | 130 |
131 void SetUp() override { | 131 void SetUp() override { |
132 helper_.reset(new EmbeddedWorkerTestHelper(base::FilePath())); | 132 helper_.reset(new EmbeddedWorkerTestHelper(base::FilePath())); |
133 helper_->context_wrapper()->AddObserver(this); | 133 helper_->context_wrapper()->AddObserver(this); |
134 } | 134 } |
135 | 135 |
136 void TearDown() override { helper_.reset(); } | 136 void TearDown() override { helper_.reset(); } |
137 | 137 |
138 // ServiceWorkerContextObserver overrides. | 138 // ServiceWorkerContextCoreObserver overrides. |
139 void OnRegistrationStored(int64_t registration_id, | 139 void OnRegistrationStored(int64_t registration_id, |
140 const GURL& pattern) override { | 140 const GURL& pattern) override { |
141 NotificationLog log; | 141 NotificationLog log; |
142 log.type = REGISTRATION_STORED; | 142 log.type = REGISTRATION_STORED; |
143 log.pattern = pattern; | 143 log.pattern = pattern; |
144 log.registration_id = registration_id; | 144 log.registration_id = registration_id; |
145 notifications_.push_back(log); | 145 notifications_.push_back(log); |
146 } | 146 } |
147 void OnRegistrationDeleted(int64_t registration_id, | 147 void OnRegistrationDeleted(int64_t registration_id, |
148 const GURL& pattern) override { | 148 const GURL& pattern) override { |
(...skipping 616 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
765 EXPECT_EQ(REGISTRATION_STORED, notifications_[2].type); | 765 EXPECT_EQ(REGISTRATION_STORED, notifications_[2].type); |
766 EXPECT_EQ(pattern, notifications_[2].pattern); | 766 EXPECT_EQ(pattern, notifications_[2].pattern); |
767 EXPECT_EQ(registration_id, notifications_[2].registration_id); | 767 EXPECT_EQ(registration_id, notifications_[2].registration_id); |
768 } | 768 } |
769 | 769 |
770 INSTANTIATE_TEST_CASE_P(ServiceWorkerContextRecoveryTest, | 770 INSTANTIATE_TEST_CASE_P(ServiceWorkerContextRecoveryTest, |
771 ServiceWorkerContextRecoveryTest, | 771 ServiceWorkerContextRecoveryTest, |
772 testing::Bool()); | 772 testing::Bool()); |
773 | 773 |
774 } // namespace content | 774 } // namespace content |
OLD | NEW |