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

Side by Side 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: Address Misha's and Matt's comments Created 5 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "net/http/bidirectional_stream_create_helper.h"
6
7 #include "base/memory/scoped_ptr.h"
8 #include "base/run_loop.h"
9 #include "net/base/net_errors.h"
10 #include "net/http/http_request_info.h"
11 #include "net/url_request/url_request_test_util.h"
12 #include "testing/gtest/include/gtest/gtest.h"
13
14 namespace net {
15
16 namespace {
17
18 class TestCreateHelperDelegate
19 : public BidirectionalStreamCreateHelper::Delegate {
20 public:
21 TestCreateHelperDelegate() : error_code_(OK), loop_(new base::RunLoop) {}
22
23 ~TestCreateHelperDelegate() override {}
24
25 void OnStreamCreated() override { loop_->Quit(); }
26
27 void OnStreamFailed(int error) override {
28 error_code_ = error;
29 loop_->Quit();
30 }
31
32 void CreateBidirectionalStream(const HttpRequestInfo* request_info,
33 RequestPriority priority,
34 const URLRequestContext* context) {
35 helper_.reset(new BidirectionalStreamCreateHelper(request_info, priority,
36 context, this));
37 helper_->CreateBidirectionalStream();
38 loop_->Run();
39 }
40
41 int error_code_;
42
43 private:
44 scoped_ptr<base::RunLoop> loop_;
45 scoped_ptr<BidirectionalStreamCreateHelper> helper_;
46 };
47 }
48
49 class BidirectionalStreamCreateHelperTest : public testing::Test {};
50
51 TEST_F(BidirectionalStreamCreateHelperTest, CreateInsecureStream) {
52 HttpRequestInfo request;
53 request.method = "GET";
54 request.url = GURL("http://www.example.org/");
55
56 TestURLRequestContext context;
57 TestCreateHelperDelegate delegate;
58 delegate.CreateBidirectionalStream(&request, LOWEST, &context);
59 EXPECT_EQ(ERR_DISALLOWED_URL_SCHEME, delegate.error_code_);
60 }
61
62 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698