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 "components/captive_portal/captive_portal_detector.h" | 5 #include "components/captive_portal/captive_portal_detector.h" |
6 | 6 |
| 7 #include <memory> |
| 8 |
7 #include "base/bind.h" | 9 #include "base/bind.h" |
8 #include "base/macros.h" | 10 #include "base/macros.h" |
9 #include "base/memory/ref_counted.h" | 11 #include "base/memory/ref_counted.h" |
10 #include "base/memory/scoped_ptr.h" | |
11 #include "base/run_loop.h" | 12 #include "base/run_loop.h" |
12 #include "base/thread_task_runner_handle.h" | 13 #include "base/thread_task_runner_handle.h" |
13 #include "base/time/time.h" | 14 #include "base/time/time.h" |
14 #include "components/captive_portal/captive_portal_testing_utils.h" | 15 #include "components/captive_portal/captive_portal_testing_utils.h" |
15 #include "net/base/net_errors.h" | 16 #include "net/base/net_errors.h" |
16 #include "net/url_request/url_request_test_util.h" | 17 #include "net/url_request/url_request_test_util.h" |
17 #include "testing/gtest/include/gtest/gtest.h" | 18 #include "testing/gtest/include/gtest/gtest.h" |
18 #include "url/gurl.h" | 19 #include "url/gurl.h" |
19 | 20 |
20 namespace captive_portal { | 21 namespace captive_portal { |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
106 base::RunLoop().RunUntilIdle(); | 107 base::RunLoop().RunUntilIdle(); |
107 | 108 |
108 detector()->Cancel(); | 109 detector()->Cancel(); |
109 | 110 |
110 ASSERT_FALSE(FetchingURL()); | 111 ASSERT_FALSE(FetchingURL()); |
111 EXPECT_EQ(0, client.num_results_received()); | 112 EXPECT_EQ(0, client.num_results_received()); |
112 } | 113 } |
113 | 114 |
114 private: | 115 private: |
115 base::MessageLoop message_loop_; | 116 base::MessageLoop message_loop_; |
116 scoped_ptr<CaptivePortalDetector> detector_; | 117 std::unique_ptr<CaptivePortalDetector> detector_; |
117 }; | 118 }; |
118 | 119 |
119 // Test that the CaptivePortalDetector returns the expected result | 120 // Test that the CaptivePortalDetector returns the expected result |
120 // codes in response to a variety of probe results. | 121 // codes in response to a variety of probe results. |
121 TEST_F(CaptivePortalDetectorTest, CaptivePortalResultCodes) { | 122 TEST_F(CaptivePortalDetectorTest, CaptivePortalResultCodes) { |
122 CaptivePortalDetector::Results results; | 123 CaptivePortalDetector::Results results; |
123 results.result = captive_portal::RESULT_INTERNET_CONNECTED; | 124 results.result = captive_portal::RESULT_INTERNET_CONNECTED; |
124 results.response_code = 204; | 125 results.response_code = 204; |
125 | 126 |
126 RunTest(results, net::OK, 204, NULL); | 127 RunTest(results, net::OK, 204, NULL); |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
202 | 203 |
203 TEST_F(CaptivePortalDetectorTest, Cancel) { | 204 TEST_F(CaptivePortalDetectorTest, Cancel) { |
204 RunCancelTest(); | 205 RunCancelTest(); |
205 CaptivePortalDetector::Results results; | 206 CaptivePortalDetector::Results results; |
206 results.result = captive_portal::RESULT_INTERNET_CONNECTED; | 207 results.result = captive_portal::RESULT_INTERNET_CONNECTED; |
207 results.response_code = 204; | 208 results.response_code = 204; |
208 RunTest(results, net::OK, 204, NULL); | 209 RunTest(results, net::OK, 204, NULL); |
209 } | 210 } |
210 | 211 |
211 } // namespace captive_portal | 212 } // namespace captive_portal |
OLD | NEW |