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

Side by Side Diff: chrome/browser/local_discovery/test_service_discovery_client.cc

Issue 87693002: Refactored to make MDnsSocketFactory return array of sockets. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years 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 | Annotate | Revision Log
OLDNEW
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/test_service_discovery_client.h" 5 #include "chrome/browser/local_discovery/test_service_discovery_client.h"
6 6
7 #include "chrome/utility/local_discovery/service_discovery_client_impl.h" 7 #include "chrome/utility/local_discovery/service_discovery_client_impl.h"
8 #include "net/dns/mdns_client_impl.h" 8 #include "net/dns/mdns_client_impl.h"
9 9
10 namespace local_discovery { 10 namespace local_discovery {
11 11
12 TestServiceDiscoveryClient::TestServiceDiscoveryClient() { 12 TestServiceDiscoveryClient::TestServiceDiscoveryClient() {
13 } 13 }
14 14
15 TestServiceDiscoveryClient::~TestServiceDiscoveryClient() { 15 TestServiceDiscoveryClient::~TestServiceDiscoveryClient() {
16 } 16 }
17 17
18 void TestServiceDiscoveryClient::Start() { 18 void TestServiceDiscoveryClient::Start() {
19 mock_socket_factory_ = new net::MockMDnsSocketFactory(); 19 mdns_client_.reset(new net::MDnsClientImpl());
20 mdns_client_.reset(new net::MDnsClientImpl(
21 scoped_ptr<net::MDnsConnection::SocketFactory>(mock_socket_factory_)));
22 service_discovery_client_impl_.reset(new ServiceDiscoveryClientImpl( 20 service_discovery_client_impl_.reset(new ServiceDiscoveryClientImpl(
23 mdns_client_.get())); 21 mdns_client_.get()));
24 mdns_client_->StartListening(); 22 mdns_client_->StartListening(&mock_socket_factory_);
25 23
26 EXPECT_CALL(*mock_socket_factory_, OnSendTo(testing::_)) 24 EXPECT_CALL(mock_socket_factory_, OnSendTo(testing::_))
27 .Times(testing::AnyNumber()) 25 .Times(testing::AnyNumber())
28 .WillRepeatedly(testing::Invoke(this, 26 .WillRepeatedly(testing::Invoke(this,
29 &TestServiceDiscoveryClient::OnSendTo)); 27 &TestServiceDiscoveryClient::OnSendTo));
30 } 28 }
31 29
32 scoped_ptr<ServiceWatcher> TestServiceDiscoveryClient::CreateServiceWatcher( 30 scoped_ptr<ServiceWatcher> TestServiceDiscoveryClient::CreateServiceWatcher(
33 const std::string& service_type, 31 const std::string& service_type,
34 const ServiceWatcher::UpdatedCallback& callback) { 32 const ServiceWatcher::UpdatedCallback& callback) {
35 return service_discovery_client_impl_->CreateServiceWatcher(service_type, 33 return service_discovery_client_impl_->CreateServiceWatcher(service_type,
36 callback); 34 callback);
(...skipping 10 matching lines...) Expand all
47 TestServiceDiscoveryClient::CreateLocalDomainResolver( 45 TestServiceDiscoveryClient::CreateLocalDomainResolver(
48 const std::string& domain, 46 const std::string& domain,
49 net::AddressFamily address_family, 47 net::AddressFamily address_family,
50 const LocalDomainResolver::IPAddressCallback& callback) { 48 const LocalDomainResolver::IPAddressCallback& callback) {
51 return service_discovery_client_impl_->CreateLocalDomainResolver( 49 return service_discovery_client_impl_->CreateLocalDomainResolver(
52 domain, address_family, callback); 50 domain, address_family, callback);
53 } 51 }
54 52
55 void TestServiceDiscoveryClient::SimulateReceive(const uint8* packet, 53 void TestServiceDiscoveryClient::SimulateReceive(const uint8* packet,
56 int size) { 54 int size) {
57 mock_socket_factory_->SimulateReceive(packet, size); 55 mock_socket_factory_.SimulateReceive(packet, size);
58 } 56 }
59 57
60 } // namespace local_discovery 58 } // namespace local_discovery
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698