| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "remoting/protocol/http_ice_config_request.h" | 5 #include "remoting/protocol/http_ice_config_request.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/memory/ptr_util.h" | 9 #include "base/memory/ptr_util.h" |
| 10 #include "remoting/base/url_request.h" | 10 #include "remoting/base/url_request.h" |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 52 UrlRequest::Type type, | 52 UrlRequest::Type type, |
| 53 const std::string& url) override { | 53 const std::string& url) override { |
| 54 EXPECT_EQ(UrlRequest::Type::POST, type); | 54 EXPECT_EQ(UrlRequest::Type::POST, type); |
| 55 CHECK(results_.count(url)); | 55 CHECK(results_.count(url)); |
| 56 return base::WrapUnique(new FakeUrlRequest(results_[url])); | 56 return base::WrapUnique(new FakeUrlRequest(results_[url])); |
| 57 } | 57 } |
| 58 | 58 |
| 59 std::map<std::string, UrlRequest::Result> results_; | 59 std::map<std::string, UrlRequest::Result> results_; |
| 60 }; | 60 }; |
| 61 | 61 |
| 62 bool operator==(const cricket::ProtocolAddress& a, | |
| 63 const cricket::ProtocolAddress& b) { | |
| 64 return a.address == b.address && a.proto == b.proto && a.secure == b.secure; | |
| 65 } | |
| 66 bool operator==(const cricket::RelayServerConfig& a, | |
| 67 const cricket::RelayServerConfig& b) { | |
| 68 if (a.ports.size() != b.ports.size()) | |
| 69 return false; | |
| 70 for (size_t i = 0; i < a.ports.size(); ++i) { | |
| 71 if (!(a.ports[i] == b.ports[i])) | |
| 72 return false; | |
| 73 } | |
| 74 return a.type == b.type && | |
| 75 a.credentials.username == b.credentials.username && | |
| 76 a.credentials.password == b.credentials.password; | |
| 77 } | |
| 78 | |
| 79 } // namespace | 62 } // namespace |
| 80 | 63 |
| 81 static const char kTestUrl[] = "http://host/ice_config"; | 64 static const char kTestUrl[] = "http://host/ice_config"; |
| 82 | 65 |
| 83 class HttpIceConfigRequestTest : public testing::Test { | 66 class HttpIceConfigRequestTest : public testing::Test { |
| 84 public: | 67 public: |
| 85 void OnResult(const IceConfig& config) { | 68 void OnResult(const IceConfig& config) { |
| 86 received_config_ = base::WrapUnique(new IceConfig(config)); | 69 received_config_ = base::WrapUnique(new IceConfig(config)); |
| 87 } | 70 } |
| 88 | 71 |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 204 TEST_F(HttpIceConfigRequestTest, FailedRequest) { | 187 TEST_F(HttpIceConfigRequestTest, FailedRequest) { |
| 205 url_request_factory_.SetResult(kTestUrl, UrlRequest::Result::Failed()); | 188 url_request_factory_.SetResult(kTestUrl, UrlRequest::Result::Failed()); |
| 206 request_.reset(new HttpIceConfigRequest(&url_request_factory_, kTestUrl)); | 189 request_.reset(new HttpIceConfigRequest(&url_request_factory_, kTestUrl)); |
| 207 request_->Send( | 190 request_->Send( |
| 208 base::Bind(&HttpIceConfigRequestTest::OnResult, base::Unretained(this))); | 191 base::Bind(&HttpIceConfigRequestTest::OnResult, base::Unretained(this))); |
| 209 EXPECT_TRUE(received_config_->is_null()); | 192 EXPECT_TRUE(received_config_->is_null()); |
| 210 } | 193 } |
| 211 | 194 |
| 212 } // namespace protocol | 195 } // namespace protocol |
| 213 } // namespace remoting | 196 } // namespace remoting |
| OLD | NEW |