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

Unified Diff: net/http/http_cache_unittest.cc

Issue 23856018: Changes to HttpNetworkTransaction for WebSocket Handshake (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Add tests by yhirano Created 7 years, 1 month 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
Index: net/http/http_cache_unittest.cc
diff --git a/net/http/http_cache_unittest.cc b/net/http/http_cache_unittest.cc
index 67f8d988f68dd572f637e79f2610fd76e59fbeae..9e94ad01e6b5fdaf818b8526561e81d3471e88e6 100644
--- a/net/http/http_cache_unittest.cc
+++ b/net/http/http_cache_unittest.cc
@@ -32,6 +32,7 @@
#include "net/http/http_util.h"
#include "net/http/mock_http_cache.h"
#include "net/ssl/ssl_cert_request_info.h"
+#include "net/websockets/websocket_handshake_stream_base.h"
#include "testing/gtest/include/gtest/gtest.h"
using base::Time;
@@ -574,6 +575,21 @@ struct Context {
scoped_ptr<net::HttpTransaction> trans;
};
+class FakeWebSocketHandshakeStreamFactory
+ : public net::WebSocketHandshakeStreamBase::Factory {
+ public:
+ virtual ~FakeWebSocketHandshakeStreamFactory() {}
+ virtual net::WebSocketHandshakeStreamBase* CreateBasicStream(
+ net::ClientSocketHandle* connect, bool using_proxy) OVERRIDE {
+ return NULL;
+ }
+ virtual net::WebSocketHandshakeStreamBase* CreateSpdyStream(
+ const base::WeakPtr<net::SpdySession>& session,
+ bool use_relative_url) OVERRIDE {
+ return NULL;
+ }
+};
+
} // namespace
@@ -6298,6 +6314,36 @@ TEST(HttpCache, SetPriority) {
EXPECT_EQ(net::OK, callback.WaitForResult());
}
+// Make sure that calling SetWebSocketHandshakeStreamFactory on a cache
+// transaction passes on its factory updates to its underlying network
+// transaction.
+TEST(HttpCache, SetWebSocketHandshakeStreamFactory) {
+ MockHttpCache cache;
+
+ FakeWebSocketHandshakeStreamFactory factory;
+ scoped_ptr<net::HttpTransaction> trans;
+ EXPECT_EQ(net::OK, cache.http_cache()->CreateTransaction(
+ net::IDLE, &trans, NULL));
+ ASSERT_TRUE(trans.get());
+
+ EXPECT_FALSE(cache.network_layer()->last_transaction());
+
+ net::HttpRequestInfo info;
+ info.url = GURL(kSimpleGET_Transaction.url);
+ net::TestCompletionCallback callback;
+ EXPECT_EQ(net::ERR_IO_PENDING,
+ trans->Start(&info, callback.callback(), net::BoundNetLog()));
+
+ ASSERT_TRUE(cache.network_layer()->last_transaction());
+ EXPECT_FALSE(cache.network_layer()->last_transaction()->
+ websocket_handshake_stream_factory());
+ trans->SetWebSocketHandshakeStreamFactory(&factory);
+ EXPECT_EQ(&factory,
+ cache.network_layer()->last_transaction()->
+ websocket_handshake_stream_factory());
+ EXPECT_EQ(net::OK, callback.WaitForResult());
+}
+
// Make sure that a cache transaction passes on its priority to
// newly-created network transactions.
TEST(HttpCache, SetPriorityNewTransaction) {

Powered by Google App Engine
This is Rietveld 408576698