| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include <string> | 5 #include <string> |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
| 9 #include "base/location.h" | 9 #include "base/location.h" |
| 10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 106 ServerResponse response_; | 106 ServerResponse response_; |
| 107 scoped_refptr<net::HttpServer> server_; | 107 scoped_refptr<net::HttpServer> server_; |
| 108 scoped_refptr<URLRequestContextGetter> context_getter_; | 108 scoped_refptr<URLRequestContextGetter> context_getter_; |
| 109 std::string server_url_; | 109 std::string server_url_; |
| 110 }; | 110 }; |
| 111 | 111 |
| 112 } // namespace | 112 } // namespace |
| 113 | 113 |
| 114 TEST_F(FetchUrlTest, Http200) { | 114 TEST_F(FetchUrlTest, Http200) { |
| 115 std::string response("stuff"); | 115 std::string response("stuff"); |
| 116 ASSERT_TRUE(FetchUrl(server_url_, context_getter_, &response)); | 116 ASSERT_TRUE(FetchUrl(server_url_, context_getter_.get(), &response)); |
| 117 ASSERT_STREQ("hello", response.c_str()); | 117 ASSERT_STREQ("hello", response.c_str()); |
| 118 } | 118 } |
| 119 | 119 |
| 120 TEST_F(FetchUrlTest, HttpNon200) { | 120 TEST_F(FetchUrlTest, HttpNon200) { |
| 121 response_ = kSend404; | 121 response_ = kSend404; |
| 122 std::string response("stuff"); | 122 std::string response("stuff"); |
| 123 ASSERT_FALSE(FetchUrl(server_url_, context_getter_, &response)); | 123 ASSERT_FALSE(FetchUrl(server_url_, context_getter_.get(), &response)); |
| 124 ASSERT_STREQ("stuff", response.c_str()); | 124 ASSERT_STREQ("stuff", response.c_str()); |
| 125 } | 125 } |
| 126 | 126 |
| 127 TEST_F(FetchUrlTest, ConnectionClose) { | 127 TEST_F(FetchUrlTest, ConnectionClose) { |
| 128 response_ = kClose; | 128 response_ = kClose; |
| 129 std::string response("stuff"); | 129 std::string response("stuff"); |
| 130 ASSERT_FALSE(FetchUrl(server_url_, context_getter_, &response)); | 130 ASSERT_FALSE(FetchUrl(server_url_, context_getter_.get(), &response)); |
| 131 ASSERT_STREQ("stuff", response.c_str()); | 131 ASSERT_STREQ("stuff", response.c_str()); |
| 132 } | 132 } |
| 133 | 133 |
| 134 TEST_F(FetchUrlTest, NoServer) { | 134 TEST_F(FetchUrlTest, NoServer) { |
| 135 std::string response("stuff"); | 135 std::string response("stuff"); |
| 136 ASSERT_FALSE(FetchUrl("http://localhost:33333", context_getter_, &response)); | 136 ASSERT_FALSE( |
| 137 FetchUrl("http://localhost:33333", context_getter_.get(), &response)); |
| 137 ASSERT_STREQ("stuff", response.c_str()); | 138 ASSERT_STREQ("stuff", response.c_str()); |
| 138 } | 139 } |
| OLD | NEW |