| 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 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <windows.h> | 9 #include <windows.h> |
| 10 #include <string> | 10 #include <string> |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 116 // send 404. Modify the file data according to the given invocation method. | 116 // send 404. Modify the file data according to the given invocation method. |
| 117 void SendResponseHelper(test_server::ConfigurableConnection* connection, | 117 void SendResponseHelper(test_server::ConfigurableConnection* connection, |
| 118 const std::wstring& resource_uri, | 118 const std::wstring& resource_uri, |
| 119 const test_server::Request& request, | 119 const test_server::Request& request, |
| 120 CFInvocation invocation, | 120 CFInvocation invocation, |
| 121 bool add_no_cache_header); | 121 bool add_no_cache_header); |
| 122 // Handles the posted /writefile response | 122 // Handles the posted /writefile response |
| 123 void HandlePostedResponse(test_server::ConfigurableConnection* connection, | 123 void HandlePostedResponse(test_server::ConfigurableConnection* connection, |
| 124 const test_server::Request& request); | 124 const test_server::Request& request); |
| 125 | 125 |
| 126 void ClearResults() { |
| 127 posted_result_.clear(); |
| 128 expected_result_.clear(); |
| 129 } |
| 130 |
| 126 void set_expected_result(const std::string& expected_result) { | 131 void set_expected_result(const std::string& expected_result) { |
| 127 expected_result_ = expected_result; | 132 expected_result_ = expected_result; |
| 128 } | 133 } |
| 129 | 134 |
| 130 const std::string& posted_result() const { | 135 const std::string& posted_result() const { |
| 131 return posted_result_; | 136 return posted_result_; |
| 132 } | 137 } |
| 133 | 138 |
| 134 private: | 139 private: |
| 135 // Holds the results of tests which post success/failure. | 140 // Holds the results of tests which post success/failure. |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 171 | 176 |
| 172 void CloseBrowser(); | 177 void CloseBrowser(); |
| 173 | 178 |
| 174 // Ensures (well, at least tries to ensure) that the browser window has focus. | 179 // Ensures (well, at least tries to ensure) that the browser window has focus. |
| 175 bool BringBrowserToTop(); | 180 bool BringBrowserToTop(); |
| 176 | 181 |
| 177 const FilePath& GetCFTestFilePath() { | 182 const FilePath& GetCFTestFilePath() { |
| 178 return test_file_path_; | 183 return test_file_path_; |
| 179 } | 184 } |
| 180 | 185 |
| 186 static chrome_frame_test::TimedMsgLoop& loop() { |
| 187 return *loop_; |
| 188 } |
| 189 |
| 190 static testing::StrictMock<MockWebServer>& server_mock() { |
| 191 return *server_mock_; |
| 192 } |
| 193 |
| 181 static void SetUpTestCase(); | 194 static void SetUpTestCase(); |
| 182 static void TearDownTestCase(); | 195 static void TearDownTestCase(); |
| 183 | 196 |
| 184 static const FilePath& GetChromeUserDataDirectory(); | 197 static const FilePath& GetChromeUserDataDirectory(); |
| 185 | 198 |
| 186 virtual void SetUp() OVERRIDE; | 199 virtual void SetUp() OVERRIDE; |
| 187 virtual void TearDown() OVERRIDE; | 200 virtual void TearDown() OVERRIDE; |
| 188 | 201 |
| 189 // The on-disk path to our html test files. | 202 // The on-disk path to our html test files. |
| 190 static FilePath test_file_path_; | 203 static FilePath test_file_path_; |
| 191 static FilePath results_dir_; | 204 static FilePath results_dir_; |
| 192 static FilePath CFInstall_path_; | 205 static FilePath CFInstall_path_; |
| 193 static FilePath CFInstance_path_; | 206 static FilePath CFInstance_path_; |
| 194 static FilePath chrome_user_data_dir_; | 207 static FilePath chrome_user_data_dir_; |
| 195 | 208 |
| 196 // The user data directory used for Chrome instances. | 209 // The user data directory used for Chrome instances. |
| 197 static ScopedTempDir temp_dir_; | 210 static ScopedTempDir temp_dir_; |
| 198 | 211 |
| 212 // The web server from which we serve the web! |
| 213 static chrome_frame_test::TimedMsgLoop* loop_; |
| 214 static testing::StrictMock<MockWebServer>* server_mock_; |
| 215 |
| 199 BrowserKind browser_; | 216 BrowserKind browser_; |
| 200 base::win::ScopedHandle browser_handle_; | 217 base::win::ScopedHandle browser_handle_; |
| 201 chrome_frame_test::TimedMsgLoop loop_; | |
| 202 testing::StrictMock<MockWebServer> server_mock_; | |
| 203 }; | 218 }; |
| 204 | 219 |
| 205 // A helper class for doing some bookkeeping when using the | 220 // A helper class for doing some bookkeeping when using the |
| 206 // SimpleWebServer class. | 221 // SimpleWebServer class. |
| 207 class SimpleWebServerTest { | 222 class SimpleWebServerTest { |
| 208 public: | 223 public: |
| 209 explicit SimpleWebServerTest(int port) : server_(port), port_(port) { | 224 explicit SimpleWebServerTest(int port) : server_(port), port_(port) { |
| 210 } | 225 } |
| 211 | 226 |
| 212 ~SimpleWebServerTest() { | 227 ~SimpleWebServerTest() { |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 313 // Same as above except that the response does not include the no-cache header. | 328 // Same as above except that the response does not include the no-cache header. |
| 314 ACTION_P2(SendAllowCacheResponse, server, invocation) { | 329 ACTION_P2(SendAllowCacheResponse, server, invocation) { |
| 315 server->SendResponseHelper(arg0, arg1, invocation, false); | 330 server->SendResponseHelper(arg0, arg1, invocation, false); |
| 316 } | 331 } |
| 317 | 332 |
| 318 ACTION_P2(HandlePostedResponseHelper, server, invocation) { | 333 ACTION_P2(HandlePostedResponseHelper, server, invocation) { |
| 319 server->HandlePostedResponse(arg0, arg2); | 334 server->HandlePostedResponse(arg0, arg2); |
| 320 } | 335 } |
| 321 | 336 |
| 322 #endif // CHROME_FRAME_TEST_TEST_WITH_WEB_SERVER_H_ | 337 #endif // CHROME_FRAME_TEST_TEST_WITH_WEB_SERVER_H_ |
| OLD | NEW |