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

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

Issue 62203007: Implement memory-persistent registration (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Working version Created 7 years, 1 month 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 (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 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/command_line.h" 7 #include "base/command_line.h"
8 #include "base/files/file_path.h" 8 #include "base/files/file_path.h"
9 #include "content/browser/service_worker/service_worker_context_core.h" 9 #include "content/browser/service_worker/service_worker_context_core.h"
10 #include "content/common/service_worker_messages.h" 10 #include "content/common/service_worker_messages.h"
11 #include "content/public/common/content_switches.h" 11 #include "content/public/common/content_switches.h"
12 #include "testing/gtest/include/gtest/gtest.h" 12 #include "testing/gtest/include/gtest/gtest.h"
13 13
14 using base::MessageLoop; 14 using base::MessageLoop;
15 15
16 namespace content { 16 namespace content {
17 17
18 class ServiceWorkerDispatcherHostTest : public testing::Test { 18 class ServiceWorkerDispatcherHostTest : public testing::Test {
19 protected: 19 protected:
20 virtual void SetUp() { 20 virtual void SetUp() {
21 context_.reset(new ServiceWorkerContextCore(base::FilePath(), NULL)); 21 context_.reset(new ServiceWorkerContextCore(base::FilePath(), NULL));
22 } 22 }
23 23
24 virtual void TearDown() { 24 virtual void TearDown() {
25 context_.reset(); 25 if (context_) {
26 context_->Shutdown();
27 context_.reset();
28 }
26 } 29 }
27 30
28 scoped_ptr<ServiceWorkerContextCore> context_; 31 scoped_ptr<ServiceWorkerContextCore> context_;
29 }; 32 };
30 33
31 static const int kRenderProcessId = 1; 34 static const int kRenderProcessId = 1;
32 35
33 class TestingServiceWorkerDispatcherHost : public ServiceWorkerDispatcherHost { 36 class TestingServiceWorkerDispatcherHost : public ServiceWorkerDispatcherHost {
34 public: 37 public:
35 TestingServiceWorkerDispatcherHost(int process_id, 38 TestingServiceWorkerDispatcherHost(int process_id,
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 95
93 TEST_F(ServiceWorkerDispatcherHostTest, EarlyContextDeletion) { 96 TEST_F(ServiceWorkerDispatcherHostTest, EarlyContextDeletion) {
94 DCHECK(!CommandLine::ForCurrentProcess()->HasSwitch( 97 DCHECK(!CommandLine::ForCurrentProcess()->HasSwitch(
95 switches::kEnableServiceWorker)); 98 switches::kEnableServiceWorker));
96 CommandLine::ForCurrentProcess()->AppendSwitch( 99 CommandLine::ForCurrentProcess()->AppendSwitch(
97 switches::kEnableServiceWorker); 100 switches::kEnableServiceWorker);
98 101
99 scoped_refptr<TestingServiceWorkerDispatcherHost> dispatcher_host = 102 scoped_refptr<TestingServiceWorkerDispatcherHost> dispatcher_host =
100 new TestingServiceWorkerDispatcherHost(kRenderProcessId, context_.get()); 103 new TestingServiceWorkerDispatcherHost(kRenderProcessId, context_.get());
101 104
105 context_->Shutdown();
102 context_.reset(); 106 context_.reset();
103 107
104 bool handled; 108 bool handled;
105 dispatcher_host->OnMessageReceived( 109 dispatcher_host->OnMessageReceived(
106 ServiceWorkerHostMsg_RegisterServiceWorker(-1, -1, GURL(), GURL()), 110 ServiceWorkerHostMsg_RegisterServiceWorker(-1, -1, GURL(), GURL()),
107 &handled); 111 &handled);
108 DCHECK(handled); 112 DCHECK(handled);
109 113
110 // TODO(alecflett): Pump the message loop when this becomes async. 114 // TODO(alecflett): Pump the message loop when this becomes async.
111 DCHECK_EQ(1UL, dispatcher_host->sent_messages_.size()); 115 DCHECK_EQ(1UL, dispatcher_host->sent_messages_.size());
112 DCHECK_EQ( 116 DCHECK_EQ(
113 static_cast<uint32>(ServiceWorkerMsg_ServiceWorkerRegistrationError::ID), 117 static_cast<uint32>(ServiceWorkerMsg_ServiceWorkerRegistrationError::ID),
114 dispatcher_host->sent_messages_[0]->type()); 118 dispatcher_host->sent_messages_[0]->type());
115 } 119 }
116 120
117 } // namespace content 121 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698