OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
220 // SimpleWebServer class. | 220 // SimpleWebServer class. |
221 class SimpleWebServerTest { | 221 class SimpleWebServerTest { |
222 public: | 222 public: |
223 explicit SimpleWebServerTest(int port) : server_(port), port_(port) { | 223 explicit SimpleWebServerTest(int port) : server_(port), port_(port) { |
224 } | 224 } |
225 | 225 |
226 ~SimpleWebServerTest() { | 226 ~SimpleWebServerTest() { |
227 server_.DeleteAllResponses(); | 227 server_.DeleteAllResponses(); |
228 } | 228 } |
229 | 229 |
230 void PopulateStaticFileList(const wchar_t* pages[], int count, | 230 template <class ResponseClass> |
231 const FilePath& directory) { | 231 void PopulateStaticFileListT(const wchar_t* pages[], int count, |
| 232 const FilePath& directory) { |
232 for (int i = 0; i < count; ++i) { | 233 for (int i = 0; i < count; ++i) { |
233 server_.AddResponse(new test_server::FileResponse( | 234 server_.AddResponse(new ResponseClass( |
234 StringPrintf("/%ls", pages[i]).c_str(), directory.Append(pages[i]))); | 235 StringPrintf("/%ls", pages[i]).c_str(), directory.Append(pages[i]))); |
235 } | 236 } |
236 } | 237 } |
237 | 238 |
238 std::wstring FormatHttpPath(const wchar_t* document_path) { | 239 std::wstring FormatHttpPath(const wchar_t* document_path) { |
239 return StringPrintf(L"http://localhost:%i/%ls", port_, document_path); | 240 return StringPrintf(L"http://localhost:%i/%ls", port_, document_path); |
240 } | 241 } |
241 | 242 |
242 // Returns the last client request object. | 243 // Returns the last client request object. |
243 // Under normal circumstances this will be the request for /quit. | 244 // Under normal circumstances this will be the request for /quit. |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
324 // Same as above except that the response does not include the no-cache header. | 325 // Same as above except that the response does not include the no-cache header. |
325 ACTION_P2(SendAllowCacheResponse, server, invocation) { | 326 ACTION_P2(SendAllowCacheResponse, server, invocation) { |
326 server->SendResponseHelper(arg0, arg1, invocation, false); | 327 server->SendResponseHelper(arg0, arg1, invocation, false); |
327 } | 328 } |
328 | 329 |
329 ACTION_P2(HandlePostedResponseHelper, server, invocation) { | 330 ACTION_P2(HandlePostedResponseHelper, server, invocation) { |
330 server->HandlePostedResponse(arg0, arg2); | 331 server->HandlePostedResponse(arg0, arg2); |
331 } | 332 } |
332 | 333 |
333 #endif // CHROME_FRAME_TEST_TEST_WITH_WEB_SERVER_H_ | 334 #endif // CHROME_FRAME_TEST_TEST_WITH_WEB_SERVER_H_ |
OLD | NEW |