| 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 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 71 // "<html>Lalalala</html>", 3, 1000)); | 71 // "<html>Lalalala</html>", 3, 1000)); |
| 72 // | 72 // |
| 73 // EXPECT_CALL(mock, Get(_, StrEq("/library"), _)).WillRepeatedly(Send( | 73 // EXPECT_CALL(mock, Get(_, StrEq("/library"), _)).WillRepeatedly(Send( |
| 74 // "HTTP/1.1 200 OK\r\n" | 74 // "HTTP/1.1 200 OK\r\n" |
| 75 // "Connection: close\r\n" | 75 // "Connection: close\r\n" |
| 76 // "Content-Type: text/html\r\n", | 76 // "Content-Type: text/html\r\n", |
| 77 // "<html><meta http-equiv=\"X-UA-Compatible\" content=\"chrome=1\" />" | 77 // "<html><meta http-equiv=\"X-UA-Compatible\" content=\"chrome=1\" />" |
| 78 // "<body>Rendered in CF.</body></html>", 4, 1000)); | 78 // "<body>Rendered in CF.</body></html>", 4, 1000)); |
| 79 class MockWebServer : public test_server::HTTPTestServer { | 79 class MockWebServer : public test_server::HTTPTestServer { |
| 80 public: | 80 public: |
| 81 MockWebServer(int port, const std::wstring& address, FilePath root_dir) | 81 MockWebServer(int port, const std::wstring& address, base::FilePath root_dir) |
| 82 : test_server::HTTPTestServer(port, address, root_dir), listener_(NULL) {} | 82 : test_server::HTTPTestServer(port, address, root_dir), listener_(NULL) {} |
| 83 | 83 |
| 84 // Overriden from test_server::HTTPTestServer. | 84 // Overriden from test_server::HTTPTestServer. |
| 85 MOCK_METHOD3(Get, void(test_server::ConfigurableConnection* connection, | 85 MOCK_METHOD3(Get, void(test_server::ConfigurableConnection* connection, |
| 86 const std::wstring& path, | 86 const std::wstring& path, |
| 87 const test_server::Request& r)); | 87 const test_server::Request& r)); |
| 88 MOCK_METHOD3(Post, void(test_server::ConfigurableConnection* connection, | 88 MOCK_METHOD3(Post, void(test_server::ConfigurableConnection* connection, |
| 89 const std::wstring& path, | 89 const std::wstring& path, |
| 90 const test_server::Request& r)); | 90 const test_server::Request& r)); |
| 91 | 91 |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 199 void ExpectAndHandlePostedResult(); | 199 void ExpectAndHandlePostedResult(); |
| 200 | 200 |
| 201 // Test if chrome frame correctly reports its version. | 201 // Test if chrome frame correctly reports its version. |
| 202 void VersionTest(BrowserKind browser, const wchar_t* page); | 202 void VersionTest(BrowserKind browser, const wchar_t* page); |
| 203 | 203 |
| 204 void CloseBrowser(); | 204 void CloseBrowser(); |
| 205 | 205 |
| 206 // Ensures (well, at least tries to ensure) that the browser window has focus. | 206 // Ensures (well, at least tries to ensure) that the browser window has focus. |
| 207 bool BringBrowserToTop(); | 207 bool BringBrowserToTop(); |
| 208 | 208 |
| 209 const FilePath& GetCFTestFilePath() { | 209 const base::FilePath& GetCFTestFilePath() { |
| 210 return test_file_path_; | 210 return test_file_path_; |
| 211 } | 211 } |
| 212 | 212 |
| 213 static chrome_frame_test::TimedMsgLoop& loop() { | 213 static chrome_frame_test::TimedMsgLoop& loop() { |
| 214 return *loop_; | 214 return *loop_; |
| 215 } | 215 } |
| 216 | 216 |
| 217 static testing::StrictMock<MockWebServerListener>& listener_mock() { | 217 static testing::StrictMock<MockWebServerListener>& listener_mock() { |
| 218 return *listener_mock_; | 218 return *listener_mock_; |
| 219 } | 219 } |
| 220 | 220 |
| 221 static testing::StrictMock<MockWebServer>& server_mock() { | 221 static testing::StrictMock<MockWebServer>& server_mock() { |
| 222 return *server_mock_; | 222 return *server_mock_; |
| 223 } | 223 } |
| 224 | 224 |
| 225 static void SetUpTestCase(); | 225 static void SetUpTestCase(); |
| 226 static void TearDownTestCase(); | 226 static void TearDownTestCase(); |
| 227 | 227 |
| 228 static const FilePath& GetChromeUserDataDirectory(); | 228 static const base::FilePath& GetChromeUserDataDirectory(); |
| 229 | 229 |
| 230 virtual void SetUp() OVERRIDE; | 230 virtual void SetUp() OVERRIDE; |
| 231 virtual void TearDown() OVERRIDE; | 231 virtual void TearDown() OVERRIDE; |
| 232 | 232 |
| 233 // The on-disk path to our html test files. | 233 // The on-disk path to our html test files. |
| 234 static FilePath test_file_path_; | 234 static base::FilePath test_file_path_; |
| 235 static FilePath results_dir_; | 235 static base::FilePath results_dir_; |
| 236 static FilePath CFInstall_path_; | 236 static base::FilePath CFInstall_path_; |
| 237 static FilePath CFInstance_path_; | 237 static base::FilePath CFInstance_path_; |
| 238 static FilePath chrome_user_data_dir_; | 238 static base::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 base::ScopedTempDir temp_dir_; | 241 static base::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 std::string local_address_; |
| 246 static testing::StrictMock<MockWebServerListener>* listener_mock_; | 246 static testing::StrictMock<MockWebServerListener>* listener_mock_; |
| 247 static testing::StrictMock<MockWebServer>* server_mock_; | 247 static testing::StrictMock<MockWebServer>* server_mock_; |
| 248 | 248 |
| 249 BrowserKind browser_; | 249 BrowserKind browser_; |
| 250 base::win::ScopedHandle browser_handle_; | 250 base::win::ScopedHandle browser_handle_; |
| 251 }; | 251 }; |
| 252 | 252 |
| 253 // A helper class for doing some bookkeeping when using the | 253 // A helper class for doing some bookkeeping when using the |
| 254 // SimpleWebServer class. | 254 // SimpleWebServer class. |
| 255 class SimpleWebServerTest { | 255 class SimpleWebServerTest { |
| 256 public: | 256 public: |
| 257 SimpleWebServerTest(const std::string& address, int port) | 257 SimpleWebServerTest(const std::string& address, int port) |
| 258 : server_(address, port), port_(port) { | 258 : server_(address, port), port_(port) { |
| 259 } | 259 } |
| 260 | 260 |
| 261 ~SimpleWebServerTest() { | 261 ~SimpleWebServerTest() { |
| 262 server_.DeleteAllResponses(); | 262 server_.DeleteAllResponses(); |
| 263 } | 263 } |
| 264 | 264 |
| 265 template <class ResponseClass> | 265 template <class ResponseClass> |
| 266 void PopulateStaticFileListT(const wchar_t* pages[], int count, | 266 void PopulateStaticFileListT(const wchar_t* pages[], int count, |
| 267 const 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 ASCIIToWide(server_.host()).c_str(), port_, |
| (...skipping 85 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 |