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 "chrome/browser/local_discovery/privet_device_lister_impl.h" | 6 #include "chrome/browser/local_discovery/privet_device_lister_impl.h" |
7 #include "testing/gmock/include/gmock/gmock.h" | 7 #include "testing/gmock/include/gmock/gmock.h" |
8 #include "testing/gtest/include/gtest/gtest.h" | 8 #include "testing/gtest/include/gtest/gtest.h" |
9 | 9 |
10 using testing::SaveArg; | 10 using testing::SaveArg; |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
72 MockServiceResolver(const std::string& service_name, | 72 MockServiceResolver(const std::string& service_name, |
73 const ServiceResolver::ResolveCompleteCallback& callback, | 73 const ServiceResolver::ResolveCompleteCallback& callback, |
74 ServiceDiscoveryMockDelegate* mock_delegate) | 74 ServiceDiscoveryMockDelegate* mock_delegate) |
75 : started_resolving_(false), service_name_(service_name), | 75 : started_resolving_(false), service_name_(service_name), |
76 callback_(callback), mock_delegate_(mock_delegate) { | 76 callback_(callback), mock_delegate_(mock_delegate) { |
77 } | 77 } |
78 | 78 |
79 virtual ~MockServiceResolver() { | 79 virtual ~MockServiceResolver() { |
80 } | 80 } |
81 | 81 |
82 virtual void StartResolving() OVERRIDE { | 82 virtual void StartResolving() override { |
83 started_resolving_ = true; | 83 started_resolving_ = true; |
84 mock_delegate_->ServiceResolverStarted(service_name_, this); | 84 mock_delegate_->ServiceResolverStarted(service_name_, this); |
85 } | 85 } |
86 | 86 |
87 bool IsResolving() const { | 87 bool IsResolving() const { |
88 return started_resolving_; | 88 return started_resolving_; |
89 } | 89 } |
90 | 90 |
91 virtual std::string GetName() const OVERRIDE { | 91 virtual std::string GetName() const override { |
92 return service_name_; | 92 return service_name_; |
93 } | 93 } |
94 | 94 |
95 const ServiceResolver::ResolveCompleteCallback& callback() { | 95 const ServiceResolver::ResolveCompleteCallback& callback() { |
96 return callback_; } | 96 return callback_; } |
97 | 97 |
98 private: | 98 private: |
99 bool started_resolving_; | 99 bool started_resolving_; |
100 std::string service_name_; | 100 std::string service_name_; |
101 ServiceResolver::ResolveCompleteCallback callback_; | 101 ServiceResolver::ResolveCompleteCallback callback_; |
102 ServiceDiscoveryMockDelegate* mock_delegate_; | 102 ServiceDiscoveryMockDelegate* mock_delegate_; |
103 }; | 103 }; |
104 | 104 |
105 class MockServiceDiscoveryClient : public ServiceDiscoveryClient { | 105 class MockServiceDiscoveryClient : public ServiceDiscoveryClient { |
106 public: | 106 public: |
107 explicit MockServiceDiscoveryClient( | 107 explicit MockServiceDiscoveryClient( |
108 ServiceDiscoveryMockDelegate* mock_delegate) | 108 ServiceDiscoveryMockDelegate* mock_delegate) |
109 : mock_delegate_(mock_delegate) { | 109 : mock_delegate_(mock_delegate) { |
110 } | 110 } |
111 | 111 |
112 virtual ~MockServiceDiscoveryClient() { | 112 virtual ~MockServiceDiscoveryClient() { |
113 } | 113 } |
114 | 114 |
115 // Create a service watcher object listening for DNS-SD service announcements | 115 // Create a service watcher object listening for DNS-SD service announcements |
116 // on service type |service_type|. | 116 // on service type |service_type|. |
117 virtual scoped_ptr<ServiceWatcher> CreateServiceWatcher( | 117 virtual scoped_ptr<ServiceWatcher> CreateServiceWatcher( |
118 const std::string& service_type, | 118 const std::string& service_type, |
119 const ServiceWatcher::UpdatedCallback& callback) OVERRIDE { | 119 const ServiceWatcher::UpdatedCallback& callback) override { |
120 scoped_ptr<MockServiceWatcher> mock_service_watcher( | 120 scoped_ptr<MockServiceWatcher> mock_service_watcher( |
121 new MockServiceWatcher(service_type, callback, mock_delegate_)); | 121 new MockServiceWatcher(service_type, callback, mock_delegate_)); |
122 return mock_service_watcher.PassAs<ServiceWatcher>(); | 122 return mock_service_watcher.PassAs<ServiceWatcher>(); |
123 } | 123 } |
124 | 124 |
125 // Create a service resolver object for getting detailed service information | 125 // Create a service resolver object for getting detailed service information |
126 // for the service called |service_name|. | 126 // for the service called |service_name|. |
127 virtual scoped_ptr<ServiceResolver> CreateServiceResolver( | 127 virtual scoped_ptr<ServiceResolver> CreateServiceResolver( |
128 const std::string& service_name, | 128 const std::string& service_name, |
129 const ServiceResolver::ResolveCompleteCallback& callback) OVERRIDE { | 129 const ServiceResolver::ResolveCompleteCallback& callback) override { |
130 scoped_ptr<MockServiceResolver> mock_service_resolver( | 130 scoped_ptr<MockServiceResolver> mock_service_resolver( |
131 new MockServiceResolver(service_name, callback, mock_delegate_)); | 131 new MockServiceResolver(service_name, callback, mock_delegate_)); |
132 return mock_service_resolver.PassAs<ServiceResolver>(); | 132 return mock_service_resolver.PassAs<ServiceResolver>(); |
133 } | 133 } |
134 | 134 |
135 // Not used in this test. | 135 // Not used in this test. |
136 virtual scoped_ptr<LocalDomainResolver> CreateLocalDomainResolver( | 136 virtual scoped_ptr<LocalDomainResolver> CreateLocalDomainResolver( |
137 const std::string& domain, | 137 const std::string& domain, |
138 net::AddressFamily address_family, | 138 net::AddressFamily address_family, |
139 const LocalDomainResolver::IPAddressCallback& callback) OVERRIDE { | 139 const LocalDomainResolver::IPAddressCallback& callback) override { |
140 NOTREACHED(); | 140 NOTREACHED(); |
141 return scoped_ptr<LocalDomainResolver>(); | 141 return scoped_ptr<LocalDomainResolver>(); |
142 } | 142 } |
143 | 143 |
144 private: | 144 private: |
145 ServiceDiscoveryMockDelegate* mock_delegate_; | 145 ServiceDiscoveryMockDelegate* mock_delegate_; |
146 }; | 146 }; |
147 | 147 |
148 class MockServiceDiscoveryMockDelegate : public ServiceDiscoveryMockDelegate { | 148 class MockServiceDiscoveryMockDelegate : public ServiceDiscoveryMockDelegate { |
149 public: | 149 public: |
(...skipping 21 matching lines...) Expand all Loading... |
171 }; | 171 }; |
172 | 172 |
173 class PrivetDeviceListerTest : public testing::Test { | 173 class PrivetDeviceListerTest : public testing::Test { |
174 public: | 174 public: |
175 PrivetDeviceListerTest() : mock_client_(&mock_delegate_) { | 175 PrivetDeviceListerTest() : mock_client_(&mock_delegate_) { |
176 } | 176 } |
177 | 177 |
178 virtual ~PrivetDeviceListerTest() { | 178 virtual ~PrivetDeviceListerTest() { |
179 } | 179 } |
180 | 180 |
181 virtual void SetUp() OVERRIDE { | 181 virtual void SetUp() override { |
182 example_attrs_.push_back("tXtvers=1"); | 182 example_attrs_.push_back("tXtvers=1"); |
183 example_attrs_.push_back("ty=My Printer"); | 183 example_attrs_.push_back("ty=My Printer"); |
184 example_attrs_.push_back("nOte=This is my Printer"); | 184 example_attrs_.push_back("nOte=This is my Printer"); |
185 example_attrs_.push_back("CS=ONlInE"); | 185 example_attrs_.push_back("CS=ONlInE"); |
186 example_attrs_.push_back("id="); | 186 example_attrs_.push_back("id="); |
187 | 187 |
188 service_description_.service_name = "myprinter._privet._tcp.local"; | 188 service_description_.service_name = "myprinter._privet._tcp.local"; |
189 service_description_.address = net::HostPortPair("myprinter.local", 6006); | 189 service_description_.address = net::HostPortPair("myprinter.local", 6006); |
190 service_description_.metadata = example_attrs_; | 190 service_description_.metadata = example_attrs_; |
191 service_description_.last_seen = base::Time() + | 191 service_description_.last_seen = base::Time() + |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
312 testing::Mock::VerifyAndClear(&mock_delegate_); | 312 testing::Mock::VerifyAndClear(&mock_delegate_); |
313 | 313 |
314 EXPECT_CALL(*service_watcher, DiscoverNewServices(false)); | 314 EXPECT_CALL(*service_watcher, DiscoverNewServices(false)); |
315 privet_lister.DiscoverNewDevices(false); | 315 privet_lister.DiscoverNewDevices(false); |
316 } | 316 } |
317 | 317 |
318 | 318 |
319 } // namespace | 319 } // namespace |
320 | 320 |
321 } // namespace local_discovery | 321 } // namespace local_discovery |
OLD | NEW |