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

Unified Diff: net/http/bidirectional_stream_create_helper_unittest.cc

Issue 1326503003: Added a net::BidirectionalStream to expose a bidirectional streaming interface (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Avoid inlining Created 5 years, 2 months 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/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

Powered by Google App Engine
This is Rietveld 408576698