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 "base/bind.h" | 5 #include "base/bind.h" |
6 #include "base/json/json_reader.h" | 6 #include "base/json/json_reader.h" |
7 #include "base/json/json_writer.h" | 7 #include "base/json/json_writer.h" |
8 #include "base/message_loop/message_loop.h" | 8 #include "base/message_loop/message_loop.h" |
9 #include "chrome/browser/local_discovery/privet_http_impl.h" | 9 #include "chrome/browser/local_discovery/privet_http_impl.h" |
10 #include "net/base/host_port_pair.h" | 10 #include "net/base/host_port_pair.h" |
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
235 MOCK_METHOD1(OnRequestEnd, void(int fetcher_id)); | 235 MOCK_METHOD1(OnRequestEnd, void(int fetcher_id)); |
236 }; | 236 }; |
237 | 237 |
238 class PrivetHTTPTest : public ::testing::Test { | 238 class PrivetHTTPTest : public ::testing::Test { |
239 public: | 239 public: |
240 PrivetHTTPTest() { | 240 PrivetHTTPTest() { |
241 PrivetURLFetcher::ResetTokenMapForTests(); | 241 PrivetURLFetcher::ResetTokenMapForTests(); |
242 | 242 |
243 request_context_= new net::TestURLRequestContextGetter( | 243 request_context_= new net::TestURLRequestContextGetter( |
244 base::MessageLoopProxy::current()); | 244 base::MessageLoopProxy::current()); |
245 privet_client_.reset(new PrivetHTTPClientImpl( | 245 privet_client_ = PrivetV1HTTPClient::CreateDefault( |
246 "sampleDevice._privet._tcp.local", | 246 make_scoped_ptr<PrivetHTTPClient>( |
247 net::HostPortPair("10.0.0.8", 6006), | 247 new PrivetHTTPClientImpl("sampleDevice._privet._tcp.local", |
248 request_context_.get())); | 248 net::HostPortPair("10.0.0.8", 6006), |
| 249 request_context_))); |
249 fetcher_factory_.SetDelegateForTests(&fetcher_delegate_); | 250 fetcher_factory_.SetDelegateForTests(&fetcher_delegate_); |
250 } | 251 } |
251 | 252 |
252 virtual ~PrivetHTTPTest() { | 253 virtual ~PrivetHTTPTest() { |
253 } | 254 } |
254 | 255 |
255 bool SuccessfulResponseToURL(const GURL& url, | 256 bool SuccessfulResponseToURL(const GURL& url, |
256 const std::string& response) { | 257 const std::string& response) { |
257 net::TestURLFetcher* fetcher = fetcher_factory_.GetFetcherByID(0); | 258 net::TestURLFetcher* fetcher = fetcher_factory_.GetFetcherByID(0); |
258 EXPECT_TRUE(fetcher); | 259 EXPECT_TRUE(fetcher); |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
330 } | 331 } |
331 | 332 |
332 void Stop() { | 333 void Stop() { |
333 base::MessageLoop::current()->Quit(); | 334 base::MessageLoop::current()->Quit(); |
334 } | 335 } |
335 | 336 |
336 protected: | 337 protected: |
337 base::MessageLoop loop_; | 338 base::MessageLoop loop_; |
338 scoped_refptr<net::TestURLRequestContextGetter> request_context_; | 339 scoped_refptr<net::TestURLRequestContextGetter> request_context_; |
339 net::TestURLFetcherFactory fetcher_factory_; | 340 net::TestURLFetcherFactory fetcher_factory_; |
340 scoped_ptr<PrivetHTTPClient> privet_client_; | 341 scoped_ptr<PrivetV1HTTPClient> privet_client_; |
341 NiceMock<MockTestURLFetcherFactoryDelegate> fetcher_delegate_; | 342 NiceMock<MockTestURLFetcherFactoryDelegate> fetcher_delegate_; |
342 }; | 343 }; |
343 | 344 |
344 class MockJSONCallback{ | 345 class MockJSONCallback{ |
345 public: | 346 public: |
346 MockJSONCallback() {} | 347 MockJSONCallback() {} |
347 ~MockJSONCallback() {} | 348 ~MockJSONCallback() {} |
348 | 349 |
349 void OnPrivetJSONDone(const base::DictionaryValue* value) { | 350 void OnPrivetJSONDone(const base::DictionaryValue* value) { |
350 if (!value) { | 351 if (!value) { |
(...skipping 734 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1085 | 1086 |
1086 EXPECT_TRUE(SuccessfulResponseToURL( | 1087 EXPECT_TRUE(SuccessfulResponseToURL( |
1087 GURL("http://10.0.0.8:6006/privet/printer/createjob"), | 1088 GURL("http://10.0.0.8:6006/privet/printer/createjob"), |
1088 kSampleCreatejobResponse)); | 1089 kSampleCreatejobResponse)); |
1089 }; | 1090 }; |
1090 | 1091 |
1091 | 1092 |
1092 } // namespace | 1093 } // namespace |
1093 | 1094 |
1094 } // namespace local_discovery | 1095 } // namespace local_discovery |
OLD | NEW |