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

Side by Side Diff: content/browser/devtools/devtools_http_handler_unittest.cc

Issue 691863002: [DevTools] Remove DevToolsHttpHandler::Stop. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@httpHandler
Patch Set: Removed comment Created 6 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/file_util.h" 5 #include "base/files/file_util.h"
6 #include "base/files/scoped_temp_dir.h" 6 #include "base/files/scoped_temp_dir.h"
7 #include "base/message_loop/message_loop.h" 7 #include "base/message_loop/message_loop.h"
8 #include "base/run_loop.h" 8 #include "base/run_loop.h"
9 #include "base/strings/string_number_conversions.h" 9 #include "base/strings/string_number_conversions.h"
10 #include "content/browser/browser_thread_impl.h" 10 #include "content/browser/browser_thread_impl.h"
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
130 base::MessageLoopForIO message_loop_; 130 base::MessageLoopForIO message_loop_;
131 BrowserThreadImpl ui_thread_; 131 BrowserThreadImpl ui_thread_;
132 scoped_ptr<BrowserThreadImpl> file_thread_; 132 scoped_ptr<BrowserThreadImpl> file_thread_;
133 }; 133 };
134 134
135 TEST_F(DevToolsHttpHandlerTest, TestStartStop) { 135 TEST_F(DevToolsHttpHandlerTest, TestStartStop) {
136 base::RunLoop run_loop, run_loop_2; 136 base::RunLoop run_loop, run_loop_2;
137 scoped_ptr<DevToolsHttpHandler::ServerSocketFactory> factory( 137 scoped_ptr<DevToolsHttpHandler::ServerSocketFactory> factory(
138 new DummyServerSocketFactory(run_loop.QuitClosure(), 138 new DummyServerSocketFactory(run_loop.QuitClosure(),
139 run_loop_2.QuitClosure())); 139 run_loop_2.QuitClosure()));
140 content::DevToolsHttpHandler* devtools_http_handler = 140 scoped_ptr<content::DevToolsHttpHandler> devtools_http_handler(
141 content::DevToolsHttpHandler::Start(factory.Pass(), 141 content::DevToolsHttpHandler::Start(factory.Pass(),
142 std::string(), 142 std::string(),
143 new DummyDelegate(), 143 new DummyDelegate(),
144 base::FilePath()); 144 base::FilePath()));
145 // Our dummy socket factory will post a quit message once the server will 145 // Our dummy socket factory will post a quit message once the server will
146 // become ready. 146 // become ready.
147 run_loop.Run(); 147 run_loop.Run();
148 devtools_http_handler->Stop(); 148 devtools_http_handler.reset();
149 // Make sure the handler actually stops. 149 // Make sure the handler actually stops.
150 run_loop_2.Run(); 150 run_loop_2.Run();
151 } 151 }
152 152
153 TEST_F(DevToolsHttpHandlerTest, TestServerSocketFailed) { 153 TEST_F(DevToolsHttpHandlerTest, TestServerSocketFailed) {
154 base::RunLoop run_loop, run_loop_2; 154 base::RunLoop run_loop, run_loop_2;
155 scoped_ptr<DevToolsHttpHandler::ServerSocketFactory> factory( 155 scoped_ptr<DevToolsHttpHandler::ServerSocketFactory> factory(
156 new FailingServerSocketFactory(run_loop.QuitClosure(), 156 new FailingServerSocketFactory(run_loop.QuitClosure(),
157 run_loop_2.QuitClosure())); 157 run_loop_2.QuitClosure()));
158 content::DevToolsHttpHandler* devtools_http_handler = 158 scoped_ptr<content::DevToolsHttpHandler> devtools_http_handler(
159 content::DevToolsHttpHandler::Start(factory.Pass(), 159 content::DevToolsHttpHandler::Start(factory.Pass(),
160 std::string(), 160 std::string(),
161 new DummyDelegate(), 161 new DummyDelegate(),
162 base::FilePath()); 162 base::FilePath()));
163 // Our dummy socket factory will post a quit message once the server will 163 // Our dummy socket factory will post a quit message once the server will
164 // become ready. 164 // become ready.
165 run_loop.Run(); 165 run_loop.Run();
166 for (int i = 0; i < 5; i++) { 166 for (int i = 0; i < 5; i++) {
167 RunAllPendingInMessageLoop(BrowserThread::UI); 167 RunAllPendingInMessageLoop(BrowserThread::UI);
168 RunAllPendingInMessageLoop(BrowserThread::FILE); 168 RunAllPendingInMessageLoop(BrowserThread::FILE);
169 } 169 }
170 devtools_http_handler->Stop(); 170 devtools_http_handler.reset();
171 // Make sure the handler actually stops. 171 // Make sure the handler actually stops.
172 run_loop_2.Run(); 172 run_loop_2.Run();
173 } 173 }
174 174
175 175
176 TEST_F(DevToolsHttpHandlerTest, TestDevToolsActivePort) { 176 TEST_F(DevToolsHttpHandlerTest, TestDevToolsActivePort) {
177 base::RunLoop run_loop, run_loop_2; 177 base::RunLoop run_loop, run_loop_2;
178 base::ScopedTempDir temp_dir; 178 base::ScopedTempDir temp_dir;
179 EXPECT_TRUE(temp_dir.CreateUniqueTempDir()); 179 EXPECT_TRUE(temp_dir.CreateUniqueTempDir());
180 scoped_ptr<DevToolsHttpHandler::ServerSocketFactory> factory( 180 scoped_ptr<DevToolsHttpHandler::ServerSocketFactory> factory(
181 new DummyServerSocketFactory(run_loop.QuitClosure(), 181 new DummyServerSocketFactory(run_loop.QuitClosure(),
182 run_loop_2.QuitClosure())); 182 run_loop_2.QuitClosure()));
183 content::DevToolsHttpHandler* devtools_http_handler = 183 scoped_ptr<content::DevToolsHttpHandler> devtools_http_handler(
184 content::DevToolsHttpHandler::Start(factory.Pass(), 184 content::DevToolsHttpHandler::Start(factory.Pass(),
185 std::string(), 185 std::string(),
186 new DummyDelegate(), 186 new DummyDelegate(),
187 temp_dir.path()); 187 temp_dir.path()));
188 // Our dummy socket factory will post a quit message once the server will 188 // Our dummy socket factory will post a quit message once the server will
189 // become ready. 189 // become ready.
190 run_loop.Run(); 190 run_loop.Run();
191 devtools_http_handler->Stop(); 191 devtools_http_handler.reset();
192 // Make sure the handler actually stops. 192 // Make sure the handler actually stops.
193 run_loop_2.Run(); 193 run_loop_2.Run();
194 194
195 // Now make sure the DevToolsActivePort was written into the 195 // Now make sure the DevToolsActivePort was written into the
196 // temporary directory and its contents are as expected. 196 // temporary directory and its contents are as expected.
197 base::FilePath active_port_file = temp_dir.path().Append( 197 base::FilePath active_port_file = temp_dir.path().Append(
198 kDevToolsActivePortFileName); 198 kDevToolsActivePortFileName);
199 EXPECT_TRUE(base::PathExists(active_port_file)); 199 EXPECT_TRUE(base::PathExists(active_port_file));
200 std::string file_contents; 200 std::string file_contents;
201 EXPECT_TRUE(base::ReadFileToString(active_port_file, &file_contents)); 201 EXPECT_TRUE(base::ReadFileToString(active_port_file, &file_contents));
202 int port = 0; 202 int port = 0;
203 EXPECT_TRUE(base::StringToInt(file_contents, &port)); 203 EXPECT_TRUE(base::StringToInt(file_contents, &port));
204 EXPECT_EQ(kDummyPort, port); 204 EXPECT_EQ(kDummyPort, port);
205 } 205 }
206 206
207 } // namespace content 207 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/devtools/devtools_http_handler_impl.cc ('k') | content/public/browser/devtools_http_handler.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698