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
3 // found in the LICENSE file.
5 #include "chrome/browser/local_discovery/test_service_discovery_client.h"
7 #include "chrome/utility/local_discovery/service_discovery_client_impl.h"
8 #include "net/dns/mdns_client_impl.h"
10 namespace local_discovery
{
12 TestServiceDiscoveryClient::TestServiceDiscoveryClient() {
15 TestServiceDiscoveryClient::~TestServiceDiscoveryClient() {
18 void TestServiceDiscoveryClient::Start() {
19 mdns_client_
.reset(new net::MDnsClientImpl());
20 service_discovery_client_impl_
.reset(new ServiceDiscoveryClientImpl(
22 mdns_client_
->StartListening(&mock_socket_factory_
);
24 EXPECT_CALL(mock_socket_factory_
, OnSendTo(testing::_
))
25 .Times(testing::AnyNumber())
26 .WillRepeatedly(testing::Invoke(this,
27 &TestServiceDiscoveryClient::OnSendTo
));
30 scoped_ptr
<ServiceWatcher
> TestServiceDiscoveryClient::CreateServiceWatcher(
31 const std::string
& service_type
,
32 const ServiceWatcher::UpdatedCallback
& callback
) {
33 return service_discovery_client_impl_
->CreateServiceWatcher(service_type
,
37 scoped_ptr
<ServiceResolver
> TestServiceDiscoveryClient::CreateServiceResolver(
38 const std::string
& service_name
,
39 const ServiceResolver::ResolveCompleteCallback
& callback
) {
40 return service_discovery_client_impl_
->CreateServiceResolver(service_name
,
44 scoped_ptr
<LocalDomainResolver
>
45 TestServiceDiscoveryClient::CreateLocalDomainResolver(
46 const std::string
& domain
,
47 net::AddressFamily address_family
,
48 const LocalDomainResolver::IPAddressCallback
& callback
) {
49 return service_discovery_client_impl_
->CreateLocalDomainResolver(
50 domain
, address_family
, callback
);
53 void TestServiceDiscoveryClient::SimulateReceive(const uint8
* packet
,
55 mock_socket_factory_
.SimulateReceive(packet
, size
);
58 } // namespace local_discovery