| 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 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 235 static FilePath results_dir_; | 235 static FilePath results_dir_; |
| 236 static FilePath CFInstall_path_; | 236 static FilePath CFInstall_path_; |
| 237 static FilePath CFInstance_path_; | 237 static FilePath CFInstance_path_; |
| 238 static FilePath chrome_user_data_dir_; | 238 static FilePath chrome_user_data_dir_; |
| 239 | 239 |
| 240 // The user data directory used for Chrome instances. | 240 // The user data directory used for Chrome instances. |
| 241 static ScopedTempDir temp_dir_; | 241 static ScopedTempDir temp_dir_; |
| 242 | 242 |
| 243 // The web server from which we serve the web! | 243 // The web server from which we serve the web! |
| 244 static chrome_frame_test::TimedMsgLoop* loop_; | 244 static chrome_frame_test::TimedMsgLoop* loop_; |
| 245 static std::string local_address_; |
| 245 static testing::StrictMock<MockWebServerListener>* listener_mock_; | 246 static testing::StrictMock<MockWebServerListener>* listener_mock_; |
| 246 static testing::StrictMock<MockWebServer>* server_mock_; | 247 static testing::StrictMock<MockWebServer>* server_mock_; |
| 247 | 248 |
| 248 BrowserKind browser_; | 249 BrowserKind browser_; |
| 249 base::win::ScopedHandle browser_handle_; | 250 base::win::ScopedHandle browser_handle_; |
| 250 }; | 251 }; |
| 251 | 252 |
| 252 // A helper class for doing some bookkeeping when using the | 253 // A helper class for doing some bookkeeping when using the |
| 253 // SimpleWebServer class. | 254 // SimpleWebServer class. |
| 254 class SimpleWebServerTest { | 255 class SimpleWebServerTest { |
| 255 public: | 256 public: |
| 256 explicit SimpleWebServerTest(int port) : server_(port), port_(port) { | 257 SimpleWebServerTest(const std::string& address, int port) |
| 258 : server_(address, port), port_(port) { |
| 257 } | 259 } |
| 258 | 260 |
| 259 ~SimpleWebServerTest() { | 261 ~SimpleWebServerTest() { |
| 260 server_.DeleteAllResponses(); | 262 server_.DeleteAllResponses(); |
| 261 } | 263 } |
| 262 | 264 |
| 263 template <class ResponseClass> | 265 template <class ResponseClass> |
| 264 void PopulateStaticFileListT(const wchar_t* pages[], int count, | 266 void PopulateStaticFileListT(const wchar_t* pages[], int count, |
| 265 const FilePath& directory) { | 267 const FilePath& directory) { |
| 266 for (int i = 0; i < count; ++i) { | 268 for (int i = 0; i < count; ++i) { |
| 267 server_.AddResponse(new ResponseClass( | 269 server_.AddResponse(new ResponseClass( |
| 268 base::StringPrintf("/%ls", pages[i]).c_str(), | 270 base::StringPrintf("/%ls", pages[i]).c_str(), |
| 269 directory.Append(pages[i]))); | 271 directory.Append(pages[i]))); |
| 270 } | 272 } |
| 271 } | 273 } |
| 272 | 274 |
| 273 std::wstring FormatHttpPath(const wchar_t* document_path) { | 275 std::wstring FormatHttpPath(const wchar_t* document_path) { |
| 274 return base::StringPrintf(L"http://localhost:%i/%ls", port_, | 276 return base::StringPrintf(L"http://%hs:%i/%ls", server_.host().c_str(), |
| 275 document_path); | 277 port_, document_path); |
| 276 } | 278 } |
| 277 | 279 |
| 278 // Returns the last client request object. | 280 // Returns the last client request object. |
| 279 // Under normal circumstances this will be the request for /quit. | 281 // Under normal circumstances this will be the request for /quit. |
| 280 const test_server::Request& last_request() const { | 282 const test_server::Request& last_request() const { |
| 281 const test_server::ConnectionList& connections = server_.connections(); | 283 const test_server::ConnectionList& connections = server_.connections(); |
| 282 DCHECK(connections.size()); | 284 DCHECK(connections.size()); |
| 283 const test_server::Connection* c = connections.back(); | 285 const test_server::Connection* c = connections.back(); |
| 284 return c->request(); | 286 return c->request(); |
| 285 } | 287 } |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 360 // Same as above except that the response does not include the no-cache header. | 362 // Same as above except that the response does not include the no-cache header. |
| 361 ACTION_P2(SendAllowCacheResponse, server, invocation) { | 363 ACTION_P2(SendAllowCacheResponse, server, invocation) { |
| 362 server->SendResponseHelper(arg0, arg1, invocation, false); | 364 server->SendResponseHelper(arg0, arg1, invocation, false); |
| 363 } | 365 } |
| 364 | 366 |
| 365 ACTION_P2(HandlePostedResponseHelper, server, invocation) { | 367 ACTION_P2(HandlePostedResponseHelper, server, invocation) { |
| 366 server->HandlePostedResponse(arg0, arg2); | 368 server->HandlePostedResponse(arg0, arg2); |
| 367 } | 369 } |
| 368 | 370 |
| 369 #endif // CHROME_FRAME_TEST_TEST_WITH_WEB_SERVER_H_ | 371 #endif // CHROME_FRAME_TEST_TEST_WITH_WEB_SERVER_H_ |
| OLD | NEW |