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 "base/memory/ref_counted.h" | 5 #include "base/memory/ref_counted.h" |
6 #include "base/message_loop.h" | 6 #include "base/message_loop.h" |
7 #include "chrome/browser/extensions/api/dial/dial_device_data.h" | 7 #include "chrome/browser/extensions/api/dial/dial_device_data.h" |
8 #include "chrome/browser/extensions/api/dial/dial_service.h" | 8 #include "chrome/browser/extensions/api/dial/dial_service.h" |
9 #include "net/base/capturing_net_log.h" | 9 #include "net/base/capturing_net_log.h" |
10 #include "net/base/ip_endpoint.h" | 10 #include "net/base/ip_endpoint.h" |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
46 dial_service_.AddObserver(&mock_observer_); | 46 dial_service_.AddObserver(&mock_observer_); |
47 } | 47 } |
48 protected: | 48 protected: |
49 net::CapturingNetLog capturing_net_log_; | 49 net::CapturingNetLog capturing_net_log_; |
50 net::IPAddressNumber mock_ip_; | 50 net::IPAddressNumber mock_ip_; |
51 DialServiceImpl dial_service_; | 51 DialServiceImpl dial_service_; |
52 MockObserver mock_observer_; | 52 MockObserver mock_observer_; |
53 }; | 53 }; |
54 | 54 |
55 TEST_F(DialServiceTest, TestSendMultipleRequests) { | 55 TEST_F(DialServiceTest, TestSendMultipleRequests) { |
56 MessageLoop loop(MessageLoop::TYPE_IO); | 56 base::MessageLoop loop(base::MessageLoop::TYPE_IO); |
57 // Setting the finish delay to zero disables the timer that invokes | 57 // Setting the finish delay to zero disables the timer that invokes |
58 // FinishDiscovery(). | 58 // FinishDiscovery(). |
59 dial_service_.finish_delay_ = TimeDelta::FromSeconds(0); | 59 dial_service_.finish_delay_ = TimeDelta::FromSeconds(0); |
60 dial_service_.request_interval_ = TimeDelta::FromSeconds(0); | 60 dial_service_.request_interval_ = TimeDelta::FromSeconds(0); |
61 dial_service_.max_requests_ = 4; | 61 dial_service_.max_requests_ = 4; |
62 dial_service_.discovery_active_ = true; | 62 dial_service_.discovery_active_ = true; |
63 EXPECT_CALL(mock_observer_, OnDiscoveryRequest(A<DialService*>())).Times(4); | 63 EXPECT_CALL(mock_observer_, OnDiscoveryRequest(A<DialService*>())).Times(4); |
64 EXPECT_CALL(mock_observer_, OnDiscoveryFinished(A<DialService*>())).Times(1); | 64 EXPECT_CALL(mock_observer_, OnDiscoveryFinished(A<DialService*>())).Times(1); |
65 dial_service_.BindSocketAndSendRequest(mock_ip_); | 65 dial_service_.BindSocketAndSendRequest(mock_ip_); |
66 loop.RunUntilIdle(); | 66 loop.RunUntilIdle(); |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
150 | 150 |
151 // Empty USN | 151 // Empty USN |
152 EXPECT_FALSE(DialServiceImpl::ParseResponse( | 152 EXPECT_FALSE(DialServiceImpl::ParseResponse( |
153 "HTTP/1.1 OK\r\n" | 153 "HTTP/1.1 OK\r\n" |
154 "LOCATION: http://127.0.0.1/dd.xml\r\n" | 154 "LOCATION: http://127.0.0.1/dd.xml\r\n" |
155 "USN:\r\n\r\n", | 155 "USN:\r\n\r\n", |
156 now, ¬_parsed)); | 156 now, ¬_parsed)); |
157 } | 157 } |
158 | 158 |
159 } // namespace extensions | 159 } // namespace extensions |
OLD | NEW |