test_service_discovery_client.h revision a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7
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.
4
5#ifndef CHROME_BROWSER_LOCAL_DISCOVERY_TEST_SERVICE_DISCOVERY_CLIENT_H_
6#define CHROME_BROWSER_LOCAL_DISCOVERY_TEST_SERVICE_DISCOVERY_CLIENT_H_
7
8#include "chrome/browser/local_discovery/service_discovery_shared_client.h"
9#include "chrome/common/local_discovery/service_discovery_client.h"
10#include "net/dns/mdns_client.h"
11#include "net/dns/mock_mdns_socket_factory.h"
12#include "testing/gmock/include/gmock/gmock.h"
13
14namespace local_discovery {
15
16class TestServiceDiscoveryClient : public ServiceDiscoverySharedClient {
17 public:
18  TestServiceDiscoveryClient();
19
20  void Start();
21
22  virtual scoped_ptr<ServiceWatcher> CreateServiceWatcher(
23      const std::string& service_type,
24      const ServiceWatcher::UpdatedCallback& callback) OVERRIDE;
25  virtual scoped_ptr<ServiceResolver> CreateServiceResolver(
26      const std::string& service_name,
27      const ServiceResolver::ResolveCompleteCallback& callback) OVERRIDE;
28  virtual scoped_ptr<LocalDomainResolver> CreateLocalDomainResolver(
29      const std::string& domain,
30      net::AddressFamily address_family,
31      const LocalDomainResolver::IPAddressCallback& callback) OVERRIDE;
32
33  MOCK_METHOD1(OnSendTo, void(const std::string& data));
34
35  void SimulateReceive(const uint8* packet, int size);
36
37 private:
38  ~TestServiceDiscoveryClient();
39
40  // Owned by mdns_client_impl_.
41  net::MockMDnsSocketFactory mock_socket_factory_;
42  scoped_ptr<net::MDnsClient> mdns_client_;
43  scoped_ptr<ServiceDiscoveryClient> service_discovery_client_impl_;
44};
45
46}  // namespace local_discovery
47
48#endif  // CHROME_BROWSER_LOCAL_DISCOVERY_TEST_SERVICE_DISCOVERY_CLIENT_H_
49