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