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

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: Rename SetWebSocketHandshakeCreateHelper 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
« no previous file with comments | « net/http/http_cache_transaction.cc ('k') | net/http/http_network_session_peer.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..29066804daff939b08b2a3f9df265dc1fd7e9085 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 FakeWebSocketHandshakeStreamCreateHelper
+ : public net::WebSocketHandshakeStreamBase::CreateHelper {
+ public:
+ virtual ~FakeWebSocketHandshakeStreamCreateHelper() {}
+ 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,35 @@ TEST(HttpCache, SetPriority) {
EXPECT_EQ(net::OK, callback.WaitForResult());
}
+// Make sure that calling SetWebSocketHandshakeStreamCreateHelper on a cache
+// transaction passes on its argument to the underlying network transaction.
+TEST(HttpCache, SetWebSocketHandshakeStreamCreateHelper) {
+ MockHttpCache cache;
+
+ FakeWebSocketHandshakeStreamCreateHelper create_helper;
+ 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_create_helper());
+ trans->SetWebSocketHandshakeStreamCreateHelper(&create_helper);
+ EXPECT_EQ(&create_helper,
+ cache.network_layer()->last_transaction()->
+ websocket_handshake_stream_create_helper());
+ EXPECT_EQ(net::OK, callback.WaitForResult());
+}
+
// Make sure that a cache transaction passes on its priority to
// newly-created network transactions.
TEST(HttpCache, SetPriorityNewTransaction) {
« no previous file with comments | « net/http/http_cache_transaction.cc ('k') | net/http/http_network_session_peer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698