OLD | NEW |
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 #ifndef CHROME_FRAME_TEST_TEST_WITH_WEB_SERVER_H_ | 5 #ifndef CHROME_FRAME_TEST_TEST_WITH_WEB_SERVER_H_ |
6 #define CHROME_FRAME_TEST_TEST_WITH_WEB_SERVER_H_ | 6 #define CHROME_FRAME_TEST_TEST_WITH_WEB_SERVER_H_ |
7 | 7 |
8 #include <windows.h> | 8 #include <windows.h> |
9 #include <string> | 9 #include <string> |
10 | 10 |
(...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
267 const base::FilePath& directory) { | 267 const base::FilePath& directory) { |
268 for (int i = 0; i < count; ++i) { | 268 for (int i = 0; i < count; ++i) { |
269 server_.AddResponse(new ResponseClass( | 269 server_.AddResponse(new ResponseClass( |
270 base::StringPrintf("/%ls", pages[i]).c_str(), | 270 base::StringPrintf("/%ls", pages[i]).c_str(), |
271 directory.Append(pages[i]))); | 271 directory.Append(pages[i]))); |
272 } | 272 } |
273 } | 273 } |
274 | 274 |
275 std::wstring FormatHttpPath(const wchar_t* document_path) { | 275 std::wstring FormatHttpPath(const wchar_t* document_path) { |
276 return base::StringPrintf(L"http://%ls:%i/%ls", | 276 return base::StringPrintf(L"http://%ls:%i/%ls", |
277 ASCIIToWide(server_.host()).c_str(), port_, | 277 base::ASCIIToWide(server_.host()).c_str(), port_, |
278 document_path); | 278 document_path); |
279 } | 279 } |
280 | 280 |
281 // Returns the last client request object. | 281 // Returns the last client request object. |
282 // Under normal circumstances this will be the request for /quit. | 282 // Under normal circumstances this will be the request for /quit. |
283 const test_server::Request& last_request() const { | 283 const test_server::Request& last_request() const { |
284 const test_server::ConnectionList& connections = server_.connections(); | 284 const test_server::ConnectionList& connections = server_.connections(); |
285 DCHECK(connections.size()); | 285 DCHECK(connections.size()); |
286 const test_server::Connection* c = connections.back(); | 286 const test_server::Connection* c = connections.back(); |
287 return c->request(); | 287 return c->request(); |
(...skipping 19 matching lines...) Expand all Loading... |
307 // |expected_method|. If expected_method is NULL no such check is made. | 307 // |expected_method|. If expected_method is NULL no such check is made. |
308 int GetRequestCountForPage(const wchar_t* page, const char* expected_method) { | 308 int GetRequestCountForPage(const wchar_t* page, const char* expected_method) { |
309 // Check how many requests we got for the cf page. | 309 // Check how many requests we got for the cf page. |
310 test_server::ConnectionList::const_iterator it; | 310 test_server::ConnectionList::const_iterator it; |
311 int requests = 0; | 311 int requests = 0; |
312 const test_server::ConnectionList& connections = server_.connections(); | 312 const test_server::ConnectionList& connections = server_.connections(); |
313 for (it = connections.begin(); it != connections.end(); ++it) { | 313 for (it = connections.begin(); it != connections.end(); ++it) { |
314 const test_server::Connection* c = (*it); | 314 const test_server::Connection* c = (*it); |
315 const test_server::Request& r = c->request(); | 315 const test_server::Request& r = c->request(); |
316 if (!r.path().empty() && | 316 if (!r.path().empty() && |
317 ASCIIToWide(r.path().substr(1)).compare(page) == 0) { | 317 base::ASCIIToWide(r.path().substr(1)).compare(page) == 0) { |
318 if (expected_method) { | 318 if (expected_method) { |
319 EXPECT_EQ(expected_method, r.method()); | 319 EXPECT_EQ(expected_method, r.method()); |
320 } | 320 } |
321 requests++; | 321 requests++; |
322 } | 322 } |
323 } | 323 } |
324 return requests; | 324 return requests; |
325 } | 325 } |
326 | 326 |
327 test_server::SimpleWebServer* web_server() { | 327 test_server::SimpleWebServer* web_server() { |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
363 // Same as above except that the response does not include the no-cache header. | 363 // Same as above except that the response does not include the no-cache header. |
364 ACTION_P2(SendAllowCacheResponse, server, invocation) { | 364 ACTION_P2(SendAllowCacheResponse, server, invocation) { |
365 server->SendResponseHelper(arg0, arg1, invocation, false); | 365 server->SendResponseHelper(arg0, arg1, invocation, false); |
366 } | 366 } |
367 | 367 |
368 ACTION_P2(HandlePostedResponseHelper, server, invocation) { | 368 ACTION_P2(HandlePostedResponseHelper, server, invocation) { |
369 server->HandlePostedResponse(arg0, arg2); | 369 server->HandlePostedResponse(arg0, arg2); |
370 } | 370 } |
371 | 371 |
372 #endif // CHROME_FRAME_TEST_TEST_WITH_WEB_SERVER_H_ | 372 #endif // CHROME_FRAME_TEST_TEST_WITH_WEB_SERVER_H_ |
OLD | NEW |