| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 <stdint.h> | 5 #include <stdint.h> |
| 6 | 6 |
| 7 #include "base/location.h" | 7 #include "base/location.h" |
| 8 #include "base/memory/weak_ptr.h" | 8 #include "base/memory/weak_ptr.h" |
| 9 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
| 10 #include "base/run_loop.h" | 10 #include "base/run_loop.h" |
| (...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 259 StrictMock<MockServiceWatcherClient> delegate; | 259 StrictMock<MockServiceWatcherClient> delegate; |
| 260 | 260 |
| 261 std::unique_ptr<ServiceWatcher> watcher( | 261 std::unique_ptr<ServiceWatcher> watcher( |
| 262 service_discovery_client_.CreateServiceWatcher("_privet._tcp.local", | 262 service_discovery_client_.CreateServiceWatcher("_privet._tcp.local", |
| 263 delegate.GetCallback())); | 263 delegate.GetCallback())); |
| 264 | 264 |
| 265 watcher->Start(); | 265 watcher->Start(); |
| 266 | 266 |
| 267 EXPECT_CALL(socket_factory_, OnSendTo(_)).Times(2); | 267 EXPECT_CALL(socket_factory_, OnSendTo(_)).Times(2); |
| 268 | 268 |
| 269 watcher->DiscoverNewServices(false); | 269 watcher->DiscoverNewServices(); |
| 270 | 270 |
| 271 EXPECT_CALL(socket_factory_, OnSendTo(_)).Times(2); | 271 EXPECT_CALL(socket_factory_, OnSendTo(_)).Times(2); |
| 272 | 272 |
| 273 RunFor(base::TimeDelta::FromSeconds(2)); | 273 RunFor(base::TimeDelta::FromSeconds(2)); |
| 274 } | 274 } |
| 275 | 275 |
| 276 TEST_F(ServiceDiscoveryTest, ReadCachedServices) { | 276 TEST_F(ServiceDiscoveryTest, ReadCachedServices) { |
| 277 socket_factory_.SimulateReceive(kSamplePacketPTR, sizeof(kSamplePacketPTR)); | 277 socket_factory_.SimulateReceive(kSamplePacketPTR, sizeof(kSamplePacketPTR)); |
| 278 | |
| 279 StrictMock<MockServiceWatcherClient> delegate; | 278 StrictMock<MockServiceWatcherClient> delegate; |
| 280 | 279 |
| 281 std::unique_ptr<ServiceWatcher> watcher( | 280 std::unique_ptr<ServiceWatcher> watcher( |
| 282 service_discovery_client_.CreateServiceWatcher("_privet._tcp.local", | 281 service_discovery_client_.CreateServiceWatcher("_privet._tcp.local", |
| 283 delegate.GetCallback())); | 282 delegate.GetCallback())); |
| 284 | 283 |
| 285 watcher->Start(); | 284 watcher->Start(); |
| 286 | 285 |
| 287 EXPECT_CALL(delegate, OnServiceUpdated(ServiceWatcher::UPDATE_ADDED, | 286 EXPECT_CALL(delegate, OnServiceUpdated(ServiceWatcher::UPDATE_ADDED, |
| 288 "hello._privet._tcp.local")) | 287 "hello._privet._tcp.local")) |
| (...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 507 ServiceResolver::STATUS_REQUEST_TIMEOUT, _, _, _)); | 506 ServiceResolver::STATUS_REQUEST_TIMEOUT, _, _, _)); |
| 508 | 507 |
| 509 // TODO(noamsml): When NSEC record support is added, change this to use an | 508 // TODO(noamsml): When NSEC record support is added, change this to use an |
| 510 // NSEC record. | 509 // NSEC record. |
| 511 RunFor(base::TimeDelta::FromSeconds(4)); | 510 RunFor(base::TimeDelta::FromSeconds(4)); |
| 512 } | 511 } |
| 513 | 512 |
| 514 } // namespace | 513 } // namespace |
| 515 | 514 |
| 516 } // namespace local_discovery | 515 } // namespace local_discovery |
| OLD | NEW |