Index: net/http/bidirectional_stream_create_helper_unittest.cc |
diff --git a/net/http/bidirectional_stream_create_helper_unittest.cc b/net/http/bidirectional_stream_create_helper_unittest.cc |
new file mode 100644 |
index 0000000000000000000000000000000000000000..eec3aa3cddda69e41e6e6c77afb7f1d17ce8f796 |
--- /dev/null |
+++ b/net/http/bidirectional_stream_create_helper_unittest.cc |
@@ -0,0 +1,62 @@ |
+// 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_create_helper.h" |
+ |
+#include "base/memory/scoped_ptr.h" |
+#include "base/run_loop.h" |
+#include "net/base/net_errors.h" |
+#include "net/http/http_request_info.h" |
+#include "net/url_request/url_request_test_util.h" |
+#include "testing/gtest/include/gtest/gtest.h" |
+ |
+namespace net { |
+ |
+namespace { |
+ |
+class TestCreateHelperDelegate |
+ : public BidirectionalStreamCreateHelper::Delegate { |
+ public: |
+ TestCreateHelperDelegate() : error_code_(OK), loop_(new base::RunLoop) {} |
+ |
+ ~TestCreateHelperDelegate() override {} |
+ |
+ void OnStreamCreated() override { loop_->Quit(); } |
+ |
+ void OnStreamFailed(int error) override { |
+ error_code_ = error; |
+ loop_->Quit(); |
+ } |
+ |
+ void CreateBidirectionalStream(const HttpRequestInfo* request_info, |
+ RequestPriority priority, |
+ const URLRequestContext* context) { |
+ helper_.reset(new BidirectionalStreamCreateHelper(request_info, priority, |
+ context, this)); |
+ helper_->CreateBidirectionalStream(); |
+ loop_->Run(); |
+ } |
+ |
+ int error_code_; |
+ |
+ private: |
+ scoped_ptr<base::RunLoop> loop_; |
+ scoped_ptr<BidirectionalStreamCreateHelper> helper_; |
+}; |
+} |
+ |
+class BidirectionalStreamCreateHelperTest : public testing::Test {}; |
+ |
+TEST_F(BidirectionalStreamCreateHelperTest, CreateInsecureStream) { |
+ HttpRequestInfo request; |
+ request.method = "GET"; |
+ request.url = GURL("http://www.example.org/"); |
+ |
+ TestURLRequestContext context; |
+ TestCreateHelperDelegate delegate; |
+ delegate.CreateBidirectionalStream(&request, LOWEST, &context); |
+ EXPECT_EQ(ERR_DISALLOWED_URL_SCHEME, delegate.error_code_); |
+} |
+ |
+} // namespace net |