| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "chrome/browser/local_discovery/privet_http_asynchronous_factory.h" | 5 #include "chrome/browser/local_discovery/privet_http_asynchronous_factory.h" |
| 6 | 6 |
| 7 #include "chrome/browser/local_discovery/privet_http_impl.h" | 7 #include "chrome/browser/local_discovery/privet_http_impl.h" |
| 8 #include "chrome/browser/local_discovery/privet_notifications.h" | 8 #include "chrome/browser/local_discovery/privet_notifications.h" |
| 9 #include "net/url_request/test_url_fetcher_factory.h" | 9 #include "net/url_request/test_url_fetcher_factory.h" |
| 10 #include "net/url_request/url_request_test_util.h" | 10 #include "net/url_request/url_request_test_util.h" |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 45 const std::string& name, | 45 const std::string& name, |
| 46 net::URLRequestContextGetter* request_context, | 46 net::URLRequestContextGetter* request_context, |
| 47 const ResultCallback& callback) | 47 const ResultCallback& callback) |
| 48 : name_(name), request_context_(request_context), callback_(callback) { | 48 : name_(name), request_context_(request_context), callback_(callback) { |
| 49 } | 49 } |
| 50 | 50 |
| 51 virtual ~MockResolution() { | 51 virtual ~MockResolution() { |
| 52 } | 52 } |
| 53 | 53 |
| 54 virtual void Start() OVERRIDE { | 54 virtual void Start() OVERRIDE { |
| 55 callback_.Run(scoped_ptr<PrivetHTTPClient>( | 55 callback_.Run(scoped_ptr<PrivetHTTPClient>(new PrivetHTTPClientImpl( |
| 56 new PrivetHTTPClientImpl( | 56 name_, net::HostPortPair("1.2.3.4", 8080), request_context_.get()))); |
| 57 name_, | |
| 58 net::HostPortPair("1.2.3.4", 8080), | |
| 59 request_context_))); | |
| 60 } | 57 } |
| 61 | 58 |
| 62 virtual const std::string& GetName() OVERRIDE { | 59 virtual const std::string& GetName() OVERRIDE { |
| 63 return name_; | 60 return name_; |
| 64 } | 61 } |
| 65 | 62 |
| 66 private: | 63 private: |
| 67 std::string name_; | 64 std::string name_; |
| 68 scoped_refptr<net::URLRequestContextGetter> request_context_; | 65 scoped_refptr<net::URLRequestContextGetter> request_context_; |
| 69 ResultCallback callback_; | 66 ResultCallback callback_; |
| 70 }; | 67 }; |
| 71 | 68 |
| 72 explicit MockPrivetHttpFactory(net::URLRequestContextGetter* request_context) | 69 explicit MockPrivetHttpFactory(net::URLRequestContextGetter* request_context) |
| 73 : request_context_(request_context) { | 70 : request_context_(request_context) { |
| 74 } | 71 } |
| 75 | 72 |
| 76 virtual scoped_ptr<PrivetHTTPResolution> CreatePrivetHTTP( | 73 virtual scoped_ptr<PrivetHTTPResolution> CreatePrivetHTTP( |
| 77 const std::string& name, | 74 const std::string& name, |
| 78 const net::HostPortPair& address, | 75 const net::HostPortPair& address, |
| 79 const ResultCallback& callback) OVERRIDE { | 76 const ResultCallback& callback) OVERRIDE { |
| 80 return scoped_ptr<PrivetHTTPResolution>( | 77 return scoped_ptr<PrivetHTTPResolution>( |
| 81 new MockResolution(name, request_context_, callback)); | 78 new MockResolution(name, request_context_.get(), callback)); |
| 82 } | 79 } |
| 83 | 80 |
| 84 private: | 81 private: |
| 85 scoped_refptr<net::URLRequestContextGetter> request_context_; | 82 scoped_refptr<net::URLRequestContextGetter> request_context_; |
| 86 }; | 83 }; |
| 87 | 84 |
| 88 class PrivetNotificationsListenerTest : public ::testing::Test { | 85 class PrivetNotificationsListenerTest : public ::testing::Test { |
| 89 public: | 86 public: |
| 90 PrivetNotificationsListenerTest() : request_context_( | 87 PrivetNotificationsListenerTest() : request_context_( |
| 91 new net::TestURLRequestContextGetter(base::MessageLoopProxy::current())) { | 88 new net::TestURLRequestContextGetter(base::MessageLoopProxy::current())) { |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 214 true, | 211 true, |
| 215 kExampleDeviceName, | 212 kExampleDeviceName, |
| 216 description_); | 213 description_); |
| 217 | 214 |
| 218 SuccessfulResponseToInfo(kInfoResponseNoUptime); | 215 SuccessfulResponseToInfo(kInfoResponseNoUptime); |
| 219 } | 216 } |
| 220 | 217 |
| 221 } // namespace | 218 } // namespace |
| 222 | 219 |
| 223 } // namespace local_discovery | 220 } // namespace local_discovery |
| OLD | NEW |