Chromium Code Reviews| Index: net/http/bidirectional_stream_helper_unittest.cc |
| diff --git a/net/http/bidirectional_stream_helper_unittest.cc b/net/http/bidirectional_stream_helper_unittest.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..7f91e136d2abd692451c3cf2ae193164ce023405 |
| --- /dev/null |
| +++ b/net/http/bidirectional_stream_helper_unittest.cc |
| @@ -0,0 +1,67 @@ |
| +// Copyright 2015 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/http/bidirectional_stream_helper.h" |
| + |
| +#include "base/memory/scoped_ptr.h" |
| +#include "base/run_loop.h" |
| +#include "net/base/net_errors.h" |
| +#include "net/http/bidirectional_stream.h" |
| +#include "net/http/http_network_session.h" |
| +#include "net/http/http_request_info.h" |
| +#include "net/log/net_log.h" |
| +#include "net/spdy/spdy_test_util_common.h" |
| +#include "net/url_request/url_request_test_util.h" |
| +#include "testing/gtest/include/gtest/gtest.h" |
| + |
| +namespace net { |
| + |
| +namespace { |
| + |
| +class TestHelperDelegate : public BidirectionalStreamHelper::Delegate { |
| + public: |
| + TestHelperDelegate() : error_code_(OK), loop_(new base::RunLoop) {} |
| + |
| + ~TestHelperDelegate() override {} |
| + |
| + void OnStreamReady() override { loop_->Quit(); } |
| + |
| + void OnStreamFailed(int error) override { |
| + error_code_ = error; |
| + loop_->Quit(); |
| + } |
| + |
| + void CreateBidirectionalStreamHelper(const HttpRequestInfo& request_info, |
| + RequestPriority priority, |
| + HttpNetworkSession* session) { |
| + helper_.reset( |
| + new BidirectionalStreamHelper(request_info, priority, session, this)); |
| + loop_->Run(); |
| + } |
| + |
| + int error_code_; |
| + |
| + private: |
| + scoped_ptr<base::RunLoop> loop_; |
|
mmenke
2015/11/03 20:32:13
don't need to make this a scoped_ptr.
xunjieli
2015/11/05 23:17:13
Done.
|
| + scoped_ptr<BidirectionalStreamHelper> helper_; |
| +}; |
| +} |
|
mmenke
2015/11/03 20:32:13
} // namespace
mmenke
2015/11/03 20:32:13
blank line before end of namespace.
xunjieli
2015/11/05 23:17:13
Done.
xunjieli
2015/11/05 23:17:13
Done.
|
| + |
| +class BidirectionalStreamHelperTest : public testing::Test {}; |
|
mmenke
2015/11/03 20:32:13
Don't need this - just use TEST instead of TEST_F.
xunjieli
2015/11/05 23:17:13
Done.
|
| + |
| +TEST_F(BidirectionalStreamHelperTest, CreateInsecureStream) { |
|
mef
2015/11/02 18:00:42
Do we need a successful test as well?
xunjieli
2015/11/05 23:17:13
Done.
|
| + HttpRequestInfo request; |
| + request.method = "GET"; |
| + request.url = GURL("http://www.example.org/"); |
| + |
| + TestHelperDelegate delegate; |
| + SpdySessionDependencies session_deps(kProtoHTTP2); |
| + HttpNetworkSession::Params params = |
| + SpdySessionDependencies::CreateSessionParams(&session_deps); |
| + scoped_ptr<HttpNetworkSession> session(new HttpNetworkSession(params)); |
| + delegate.CreateBidirectionalStreamHelper(request, LOWEST, session.get()); |
| + EXPECT_EQ(ERR_DISALLOWED_URL_SCHEME, delegate.error_code_); |
| +} |
| + |
| +} // namespace net |