Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(163)

Side by Side Diff: chrome_frame/test/test_with_web_server.h

Issue 2620006: Yeat another test web server. Supports speed throttle and dump of the traffic... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 10 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome_frame/test/test_server.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2006-2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-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 #ifndef CHROME_FRAME_TEST_TEST_WITH_WEB_SERVER_H_ 4 #ifndef CHROME_FRAME_TEST_TEST_WITH_WEB_SERVER_H_
5 #define CHROME_FRAME_TEST_TEST_WITH_WEB_SERVER_H_ 5 #define CHROME_FRAME_TEST_TEST_WITH_WEB_SERVER_H_
6 6
7 #include <windows.h> 7 #include <windows.h>
8 #include <string> 8 #include <string>
9 9
10 #include "chrome_frame/test/http_server.h" 10 #include "chrome_frame/test/http_server.h"
11 #include "chrome_frame/test/test_server.h" 11 #include "chrome_frame/test/test_server.h"
12 #include "testing/gtest/include/gtest/gtest.h" 12 #include "testing/gtest/include/gtest/gtest.h"
13 #include "testing/gmock/include/gmock/gmock.h"
13 14
14 // Include without path to make GYP build see it. 15 // Include without path to make GYP build see it.
15 #include "chrome_tab.h" // NOLINT 16 #include "chrome_tab.h" // NOLINT
16 17
17 // Class that: 18 // Class that:
18 // 1) Starts the local webserver, 19 // 1) Starts the local webserver,
19 // 2) Supports launching browsers - Internet Explorer and Firefox with local url 20 // 2) Supports launching browsers - Internet Explorer and Firefox with local url
20 // 3) Wait the webserver to finish. It is supposed the test webpage to shutdown 21 // 3) Wait the webserver to finish. It is supposed the test webpage to shutdown
21 // the server by navigating to "kill" page 22 // the server by navigating to "kill" page
22 // 4) Supports read the posted results from the test webpage to the "dump" 23 // 4) Supports read the posted results from the test webpage to the "dump"
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
168 169
169 test_server::SimpleWebServer* web_server() { 170 test_server::SimpleWebServer* web_server() {
170 return &server_; 171 return &server_;
171 } 172 }
172 173
173 protected: 174 protected:
174 test_server::SimpleWebServer server_; 175 test_server::SimpleWebServer server_;
175 int port_; 176 int port_;
176 }; 177 };
177 178
179 // Simple Gmock friendly web server. Sample usage:
180 // MockWebServer mock(9999, "0.0.0.0");
181 // EXPECT_CALL(mock, Get(_, StrEq("/favicon.ico"), _)).WillRepeatedly(SendFast(
182 // "HTTP/1.1 404 Not Found"
183 // "text/html; charset=UTF-8", EmptyString()));
184 //
185 // EXPECT_CALL(mock, Get(_, StrEq("/book"), _)).WillRepeatedly(Send(
186 // "HTTP/1.1 302 Found\r\n"
187 // "Connection: close\r\n"
188 // "Content-Type: text/html\r\n"
189 // "Location: library\r\n",
190 // "<html>Lalalala</html>", 3, 1000));
191 //
192 // EXPECT_CALL(mock, Get(_, StrEq("/library"), _)).WillRepeatedly(Send(
193 // "HTTP/1.1 200 OK\r\n"
194 // "Connection: close\r\n"
195 // "Content-Type: text/html\r\n",
196 // "<html><meta http-equiv=\"X-UA-Compatible\" content=\"chrome=1\" />"
197 // "<body>Rendered in CF.</body></html>", 4, 1000));
198
199 class MockWebServer : public test_server::HTTPTestServer {
200 public:
201 MockWebServer(int port, const char* address = "127.0.0.1")
202 : test_server::HTTPTestServer(port, address) {}
203 MOCK_METHOD3(Get, void(test_server::ConfigurableConnection* connection,
204 const std::string& path,
205 const test_server::Request&r));
206 MOCK_METHOD3(Post, void(test_server::ConfigurableConnection* connection,
207 const std::string& path,
208 const test_server::Request&r));
209 };
210
211 ACTION_P2(SendFast, headers, content) {
212 arg0->Send(headers, content);
213 }
214
215 ACTION_P4(Send, headers, content, chunk, timeout) {
216 test_server::ConfigurableConnection::SendOptions options(
217 test_server::ConfigurableConnection::SendOptions::
218 IMMEDIATE_HEADERS_DELAYED_CONTENT, chunk, timeout);
219 arg0->SendWithOptions(std::string(headers),
220 std::string(content),
221 options);
222 }
223
224 ACTION_P4(SendSlow, headers, content, chunk, timeout) {
225 test_server::ConfigurableConnection::SendOptions options(
226 test_server::ConfigurableConnection::SendOptions::DELAYED, chunk, timeout);
227 arg0->SendWithOptions(std::string(headers),
228 std::string(content),
229 options);
230 }
231
178 #endif // CHROME_FRAME_TEST_TEST_WITH_WEB_SERVER_H_ 232 #endif // CHROME_FRAME_TEST_TEST_WITH_WEB_SERVER_H_
179 233
OLDNEW
« no previous file with comments | « chrome_frame/test/test_server.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698