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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome_frame/test/test_server.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome_frame/test/test_with_web_server.h
===================================================================
--- chrome_frame/test/test_with_web_server.h (revision 48838)
+++ chrome_frame/test/test_with_web_server.h (working copy)
@@ -10,6 +10,7 @@
#include "chrome_frame/test/http_server.h"
#include "chrome_frame/test/test_server.h"
#include "testing/gtest/include/gtest/gtest.h"
+#include "testing/gmock/include/gmock/gmock.h"
// Include without path to make GYP build see it.
#include "chrome_tab.h" // NOLINT
@@ -175,5 +176,58 @@
int port_;
};
+// Simple Gmock friendly web server. Sample usage:
+// MockWebServer mock(9999, "0.0.0.0");
+// EXPECT_CALL(mock, Get(_, StrEq("/favicon.ico"), _)).WillRepeatedly(SendFast(
+// "HTTP/1.1 404 Not Found"
+// "text/html; charset=UTF-8", EmptyString()));
+//
+// EXPECT_CALL(mock, Get(_, StrEq("/book"), _)).WillRepeatedly(Send(
+// "HTTP/1.1 302 Found\r\n"
+// "Connection: close\r\n"
+// "Content-Type: text/html\r\n"
+// "Location: library\r\n",
+// "<html>Lalalala</html>", 3, 1000));
+//
+// EXPECT_CALL(mock, Get(_, StrEq("/library"), _)).WillRepeatedly(Send(
+// "HTTP/1.1 200 OK\r\n"
+// "Connection: close\r\n"
+// "Content-Type: text/html\r\n",
+// "<html><meta http-equiv=\"X-UA-Compatible\" content=\"chrome=1\" />"
+// "<body>Rendered in CF.</body></html>", 4, 1000));
+
+class MockWebServer : public test_server::HTTPTestServer {
+ public:
+ MockWebServer(int port, const char* address = "127.0.0.1")
+ : test_server::HTTPTestServer(port, address) {}
+ MOCK_METHOD3(Get, void(test_server::ConfigurableConnection* connection,
+ const std::string& path,
+ const test_server::Request&r));
+ MOCK_METHOD3(Post, void(test_server::ConfigurableConnection* connection,
+ const std::string& path,
+ const test_server::Request&r));
+};
+
+ACTION_P2(SendFast, headers, content) {
+ arg0->Send(headers, content);
+}
+
+ACTION_P4(Send, headers, content, chunk, timeout) {
+ test_server::ConfigurableConnection::SendOptions options(
+ test_server::ConfigurableConnection::SendOptions::
+ IMMEDIATE_HEADERS_DELAYED_CONTENT, chunk, timeout);
+ arg0->SendWithOptions(std::string(headers),
+ std::string(content),
+ options);
+}
+
+ACTION_P4(SendSlow, headers, content, chunk, timeout) {
+ test_server::ConfigurableConnection::SendOptions options(
+ test_server::ConfigurableConnection::SendOptions::DELAYED, chunk, timeout);
+ arg0->SendWithOptions(std::string(headers),
+ std::string(content),
+ options);
+}
+
#endif // CHROME_FRAME_TEST_TEST_WITH_WEB_SERVER_H_
« 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