OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/extensions/api/dial/dial_service.h" |
| 6 |
5 #include <stddef.h> | 7 #include <stddef.h> |
6 | 8 |
| 9 #include <memory> |
| 10 |
7 #include "base/macros.h" | 11 #include "base/macros.h" |
8 #include "base/memory/ref_counted.h" | 12 #include "base/memory/ref_counted.h" |
9 #include "base/memory/scoped_ptr.h" | |
10 #include "base/message_loop/message_loop.h" | 13 #include "base/message_loop/message_loop.h" |
11 #include "chrome/browser/extensions/api/dial/dial_device_data.h" | 14 #include "chrome/browser/extensions/api/dial/dial_device_data.h" |
12 #include "chrome/browser/extensions/api/dial/dial_service.h" | |
13 #include "net/base/ip_address.h" | 15 #include "net/base/ip_address.h" |
14 #include "net/base/ip_endpoint.h" | 16 #include "net/base/ip_endpoint.h" |
15 #include "net/base/network_interfaces.h" | 17 #include "net/base/network_interfaces.h" |
16 #include "net/log/test_net_log.h" | 18 #include "net/log/test_net_log.h" |
17 #include "testing/gmock/include/gmock/gmock.h" | 19 #include "testing/gmock/include/gmock/gmock.h" |
18 #include "testing/gtest/include/gtest/gtest.h" | 20 #include "testing/gtest/include/gtest/gtest.h" |
19 | 21 |
20 using base::Time; | 22 using base::Time; |
21 using base::TimeDelta; | 23 using base::TimeDelta; |
22 using ::testing::A; | 24 using ::testing::A; |
(...skipping 27 matching lines...) Expand all Loading... |
50 DialServiceTest() | 52 DialServiceTest() |
51 : mock_ip_(net::IPAddress::IPv4AllZeros()), | 53 : mock_ip_(net::IPAddress::IPv4AllZeros()), |
52 dial_service_(&test_net_log_) { | 54 dial_service_(&test_net_log_) { |
53 dial_service_.AddObserver(&mock_observer_); | 55 dial_service_.AddObserver(&mock_observer_); |
54 dial_socket_ = dial_service_.CreateDialSocket(); | 56 dial_socket_ = dial_service_.CreateDialSocket(); |
55 } | 57 } |
56 protected: | 58 protected: |
57 net::TestNetLog test_net_log_; | 59 net::TestNetLog test_net_log_; |
58 net::IPAddress mock_ip_; | 60 net::IPAddress mock_ip_; |
59 DialServiceImpl dial_service_; | 61 DialServiceImpl dial_service_; |
60 scoped_ptr<DialServiceImpl::DialSocket> dial_socket_; | 62 std::unique_ptr<DialServiceImpl::DialSocket> dial_socket_; |
61 MockObserver mock_observer_; | 63 MockObserver mock_observer_; |
62 }; | 64 }; |
63 | 65 |
64 TEST_F(DialServiceTest, TestSendMultipleRequests) { | 66 TEST_F(DialServiceTest, TestSendMultipleRequests) { |
65 base::MessageLoopForIO loop; | 67 base::MessageLoopForIO loop; |
66 // Setting the finish delay to zero disables the timer that invokes | 68 // Setting the finish delay to zero disables the timer that invokes |
67 // FinishDiscovery(). | 69 // FinishDiscovery(). |
68 dial_service_.finish_delay_ = TimeDelta::FromSeconds(0); | 70 dial_service_.finish_delay_ = TimeDelta::FromSeconds(0); |
69 dial_service_.request_interval_ = TimeDelta::FromSeconds(0); | 71 dial_service_.request_interval_ = TimeDelta::FromSeconds(0); |
70 dial_service_.max_requests_ = 4; | 72 dial_service_.max_requests_ = 4; |
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
221 | 223 |
222 // Empty USN | 224 // Empty USN |
223 EXPECT_FALSE(DialServiceImpl::DialSocket::ParseResponse( | 225 EXPECT_FALSE(DialServiceImpl::DialSocket::ParseResponse( |
224 "HTTP/1.1 OK\r\n" | 226 "HTTP/1.1 OK\r\n" |
225 "LOCATION: http://127.0.0.1/dd.xml\r\n" | 227 "LOCATION: http://127.0.0.1/dd.xml\r\n" |
226 "USN:\r\n\r\n", | 228 "USN:\r\n\r\n", |
227 now, ¬_parsed)); | 229 now, ¬_parsed)); |
228 } | 230 } |
229 | 231 |
230 } // namespace extensions | 232 } // namespace extensions |
OLD | NEW |