summaryrefslogtreecommitdiffstats
path: root/net/spdy/spdy_stream_unittest.cc
diff options
context:
space:
mode:
authorukai@chromium.org <ukai@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-06-14 04:13:40 +0000
committerukai@chromium.org <ukai@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-06-14 04:13:40 +0000
commit65d56aaadc75327749c62400a846a9e2cb12ea73 (patch)
treeaa05833579eb90d65de4d1f232810268f512c97c /net/spdy/spdy_stream_unittest.cc
parent495caf3da866d8967176bf4102532dba412a1012 (diff)
downloadchromium_src-65d56aaadc75327749c62400a846a9e2cb12ea73.zip
chromium_src-65d56aaadc75327749c62400a846a9e2cb12ea73.tar.gz
chromium_src-65d56aaadc75327749c62400a846a9e2cb12ea73.tar.bz2
Refactor SpdyStream.
Split SpdyStream into two parts: base SpdyStream and SpdyHttpStream. SpdyStream is an interface to SpdySession and provides base implementation as spdy stream. SpdyHttpStream is derived class of SpdyStream and used for [Spdy|Http]NetworkTransaction. BUG=42320 TEST=none Review URL: http://codereview.chromium.org/2564001 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@49667 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/spdy/spdy_stream_unittest.cc')
-rw-r--r--net/spdy/spdy_stream_unittest.cc131
1 files changed, 0 insertions, 131 deletions
diff --git a/net/spdy/spdy_stream_unittest.cc b/net/spdy/spdy_stream_unittest.cc
deleted file mode 100644
index 9f15fae..0000000
--- a/net/spdy/spdy_stream_unittest.cc
+++ /dev/null
@@ -1,131 +0,0 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "net/spdy/spdy_stream.h"
-#include "base/ref_counted.h"
-#include "net/base/mock_host_resolver.h"
-#include "net/base/net_errors.h"
-#include "net/base/ssl_config_service.h"
-#include "net/base/ssl_config_service_defaults.h"
-#include "net/base/test_completion_callback.h"
-#include "net/http/http_auth_handler_factory.h"
-#include "net/http/http_network_session.h"
-#include "net/http/http_request_info.h"
-#include "net/http/http_response_info.h"
-#include "net/proxy/proxy_service.h"
-#include "net/socket/socket_test_util.h"
-#include "net/spdy/spdy_session.h"
-#include "net/spdy/spdy_session_pool.h"
-#include "testing/gtest/include/gtest/gtest.h"
-
-namespace net {
-
-class SpdySessionPoolPeer {
- public:
- explicit SpdySessionPoolPeer(const scoped_refptr<SpdySessionPool>& pool)
- : pool_(pool) {}
-
- void RemoveSpdySession(const scoped_refptr<SpdySession>& session) {
- pool_->Remove(session);
- }
-
- private:
- const scoped_refptr<SpdySessionPool> pool_;
-
- DISALLOW_COPY_AND_ASSIGN(SpdySessionPoolPeer);
-};
-
-namespace {
-
-// Create a proxy service which fails on all requests (falls back to direct).
-ProxyService* CreateNullProxyService() {
- return ProxyService::CreateNull();
-}
-
-// Helper to manage the lifetimes of the dependencies for a
-// SpdyNetworkTransaction.
-class SessionDependencies {
- public:
- // Default set of dependencies -- "null" proxy service.
- SessionDependencies()
- : host_resolver(new MockHostResolver),
- proxy_service(CreateNullProxyService()),
- ssl_config_service(new SSLConfigServiceDefaults),
- http_auth_handler_factory(HttpAuthHandlerFactory::CreateDefault()),
- spdy_session_pool(new SpdySessionPool(NULL)) {}
-
- // Custom proxy service dependency.
- explicit SessionDependencies(ProxyService* proxy_service)
- : host_resolver(new MockHostResolver),
- proxy_service(proxy_service),
- ssl_config_service(new SSLConfigServiceDefaults),
- http_auth_handler_factory(HttpAuthHandlerFactory::CreateDefault()),
- spdy_session_pool(new SpdySessionPool(NULL)) {}
-
- scoped_refptr<MockHostResolverBase> host_resolver;
- scoped_refptr<ProxyService> proxy_service;
- scoped_refptr<SSLConfigService> ssl_config_service;
- MockClientSocketFactory socket_factory;
- scoped_ptr<HttpAuthHandlerFactory> http_auth_handler_factory;
- scoped_refptr<SpdySessionPool> spdy_session_pool;
-};
-
-HttpNetworkSession* CreateSession(SessionDependencies* session_deps) {
- return new HttpNetworkSession(NULL,
- session_deps->host_resolver,
- session_deps->proxy_service,
- &session_deps->socket_factory,
- session_deps->ssl_config_service,
- session_deps->spdy_session_pool,
- session_deps->http_auth_handler_factory.get(),
- NULL);
-}
-
-class SpdyStreamTest : public testing::Test {
- protected:
- SpdyStreamTest()
- : session_(CreateSession(&session_deps_)),
- pool_peer_(session_->spdy_session_pool()) {}
-
- scoped_refptr<SpdySession> CreateSpdySession() {
- HostPortPair host_port_pair("www.google.com", 80);
- scoped_refptr<SpdySession> session(
- session_->spdy_session_pool()->Get(
- host_port_pair, session_, BoundNetLog()));
- return session;
- }
-
- virtual void TearDown() {
- MessageLoop::current()->RunAllPending();
- }
-
- SessionDependencies session_deps_;
- scoped_refptr<HttpNetworkSession> session_;
- SpdySessionPoolPeer pool_peer_;
-};
-
-// Needs fixing, see http://crbug.com/28622
-TEST_F(SpdyStreamTest, SendRequest) {
- scoped_refptr<SpdySession> session(CreateSpdySession());
- HttpRequestInfo request;
- request.method = "GET";
- request.url = GURL("http://www.google.com/");
- TestCompletionCallback callback;
- HttpResponseInfo response;
-
- scoped_refptr<SpdyStream> stream(new SpdyStream(session, 1, false));
- stream->SetRequestInfo(request);
- EXPECT_EQ(ERR_IO_PENDING, stream->SendRequest(NULL, &response, &callback));
-
- // Need to manually remove the spdy session since normally it gets removed on
- // socket close/error, but we aren't communicating over a socket here.
- pool_peer_.RemoveSpdySession(session);
-}
-
-// TODO(willchan): Write a longer test for SpdyStream that exercises all
-// methods.
-
-} // namespace
-
-} // namespace net