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

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

Issue 252633003: Introduce worker_devtools_agent_route_id for EmbeddedWorker. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix unit tests failure Created 6 years, 8 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 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_dispatcher_host.h" 5 #include "content/browser/service_worker/service_worker_dispatcher_host.h"
6 6
7 #include "base/atomic_sequence_num.h"
8 #include "base/bind.h"
7 #include "base/command_line.h" 9 #include "base/command_line.h"
8 #include "base/files/file_path.h" 10 #include "base/files/file_path.h"
9 #include "base/run_loop.h" 11 #include "base/run_loop.h"
10 #include "content/browser/browser_thread_impl.h" 12 #include "content/browser/browser_thread_impl.h"
11 #include "content/browser/service_worker/embedded_worker_instance.h" 13 #include "content/browser/service_worker/embedded_worker_instance.h"
12 #include "content/browser/service_worker/embedded_worker_registry.h" 14 #include "content/browser/service_worker/embedded_worker_registry.h"
13 #include "content/browser/service_worker/embedded_worker_test_helper.h" 15 #include "content/browser/service_worker/embedded_worker_test_helper.h"
14 #include "content/browser/service_worker/service_worker_context_core.h" 16 #include "content/browser/service_worker/service_worker_context_core.h"
15 #include "content/browser/service_worker/service_worker_context_wrapper.h" 17 #include "content/browser/service_worker/service_worker_context_wrapper.h"
16 #include "content/common/service_worker/embedded_worker_messages.h" 18 #include "content/common/service_worker/embedded_worker_messages.h"
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 54
53 class TestingServiceWorkerDispatcherHost : public ServiceWorkerDispatcherHost { 55 class TestingServiceWorkerDispatcherHost : public ServiceWorkerDispatcherHost {
54 public: 56 public:
55 TestingServiceWorkerDispatcherHost( 57 TestingServiceWorkerDispatcherHost(
56 int process_id, 58 int process_id,
57 ServiceWorkerContextWrapper* context_wrapper, 59 ServiceWorkerContextWrapper* context_wrapper,
58 EmbeddedWorkerTestHelper* helper) 60 EmbeddedWorkerTestHelper* helper)
59 : ServiceWorkerDispatcherHost(process_id, NULL), 61 : ServiceWorkerDispatcherHost(process_id, NULL),
60 bad_messages_received_count_(0), 62 bad_messages_received_count_(0),
61 helper_(helper) { 63 helper_(helper) {
62 Init(context_wrapper); 64 Init(context_wrapper,
65 base::Bind(&base::AtomicSequenceNumber::GetNext,
66 base::Unretained(&next_routing_id_)));
63 } 67 }
64 68
65 virtual bool Send(IPC::Message* message) OVERRIDE { 69 virtual bool Send(IPC::Message* message) OVERRIDE {
66 return helper_->Send(message); 70 return helper_->Send(message);
67 } 71 }
68 72
69 IPC::TestSink* ipc_sink() { return helper_->ipc_sink(); } 73 IPC::TestSink* ipc_sink() { return helper_->ipc_sink(); }
70 74
71 virtual void BadMessageReceived() OVERRIDE { 75 virtual void BadMessageReceived() OVERRIDE {
72 ++bad_messages_received_count_; 76 ++bad_messages_received_count_;
73 } 77 }
74 78
75 int bad_messages_received_count_; 79 int bad_messages_received_count_;
76 80
77 protected: 81 protected:
78 EmbeddedWorkerTestHelper* helper_; 82 EmbeddedWorkerTestHelper* helper_;
83 base::AtomicSequenceNumber next_routing_id_;
79 virtual ~TestingServiceWorkerDispatcherHost() {} 84 virtual ~TestingServiceWorkerDispatcherHost() {}
80 }; 85 };
81 86
82 TEST_F(ServiceWorkerDispatcherHostTest, DisabledCausesError) { 87 TEST_F(ServiceWorkerDispatcherHostTest, DisabledCausesError) {
83 DCHECK(!CommandLine::ForCurrentProcess()->HasSwitch( 88 DCHECK(!CommandLine::ForCurrentProcess()->HasSwitch(
84 switches::kEnableServiceWorker)); 89 switches::kEnableServiceWorker));
85 90
86 scoped_refptr<TestingServiceWorkerDispatcherHost> dispatcher_host = 91 scoped_refptr<TestingServiceWorkerDispatcherHost> dispatcher_host =
87 new TestingServiceWorkerDispatcherHost( 92 new TestingServiceWorkerDispatcherHost(
88 kRenderProcessId, context_wrapper_.get(), helper_.get()); 93 kRenderProcessId, context_wrapper_.get(), helper_.get());
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
197 ServiceWorkerHostMsg_ProviderCreated(kProviderId), 202 ServiceWorkerHostMsg_ProviderCreated(kProviderId),
198 &handled); 203 &handled);
199 EXPECT_TRUE(handled); 204 EXPECT_TRUE(handled);
200 EXPECT_TRUE(context()->GetProviderHost(kRenderProcessId, kProviderId)); 205 EXPECT_TRUE(context()->GetProviderHost(kRenderProcessId, kProviderId));
201 EXPECT_TRUE(dispatcher_host->HasOneRef()); 206 EXPECT_TRUE(dispatcher_host->HasOneRef());
202 dispatcher_host = NULL; 207 dispatcher_host = NULL;
203 EXPECT_FALSE(context()->GetProviderHost(kRenderProcessId, kProviderId)); 208 EXPECT_FALSE(context()->GetProviderHost(kRenderProcessId, kProviderId));
204 } 209 }
205 210
206 } // namespace content 211 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698