| 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/captive_portal/captive_portal_detector.h" | 5 #include "chrome/browser/captive_portal/captive_portal_detector.h" |
| 6 | 6 |
| 7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
| 8 #include "base/bind.h" | 8 #include "base/bind.h" |
| 9 #include "base/run_loop.h" | 9 #include "base/run_loop.h" |
| 10 #include "base/time/time.h" | 10 #include "base/time/time.h" |
| 11 #include "chrome/browser/captive_portal/testing_utils.h" | 11 #include "chrome/browser/captive_portal/testing_utils.h" |
| 12 #include "chrome/test/base/testing_profile.h" | 12 #include "chrome/test/base/testing_profile.h" |
| 13 #include "content/public/test/test_browser_thread_bundle.h" | 13 #include "content/public/test/test_browser_thread_bundle.h" |
| 14 #include "net/base/net_errors.h" | 14 #include "net/base/net_errors.h" |
| 15 #include "net/url_request/url_fetcher.h" | 15 #include "net/url_request/url_fetcher.h" |
| 16 #include "testing/gtest/include/gtest/gtest.h" | 16 #include "testing/gtest/include/gtest/gtest.h" |
| 17 #include "url/gurl.h" | 17 #include "url/gurl.h" |
| 18 | 18 |
| 19 namespace captive_portal { | 19 namespace captive_portal { |
| 20 | 20 |
| 21 namespace { | 21 namespace { |
| 22 | 22 |
| 23 class CaptivePortalClient { | 23 class CaptivePortalClient { |
| 24 public: | 24 public: |
| 25 explicit CaptivePortalClient(CaptivePortalDetector* captive_portal_detector) | 25 explicit CaptivePortalClient(CaptivePortalDetector* captive_portal_detector) |
| 26 : captive_portal_detector_(captive_portal_detector), | 26 : num_results_received_(0) { |
| 27 num_results_received_(0) { | |
| 28 } | 27 } |
| 29 | 28 |
| 30 void OnPortalDetectionCompleted( | 29 void OnPortalDetectionCompleted( |
| 31 const CaptivePortalDetector::Results& results) { | 30 const CaptivePortalDetector::Results& results) { |
| 32 results_ = results; | 31 results_ = results; |
| 33 ++num_results_received_; | 32 ++num_results_received_; |
| 34 } | 33 } |
| 35 | 34 |
| 36 const CaptivePortalDetector::Results& captive_portal_results() const { | 35 const CaptivePortalDetector::Results& captive_portal_results() const { |
| 37 return results_; | 36 return results_; |
| 38 } | 37 } |
| 39 | 38 |
| 40 int num_results_received() const { return num_results_received_; } | 39 int num_results_received() const { return num_results_received_; } |
| 41 | 40 |
| 42 private: | 41 private: |
| 43 CaptivePortalDetector* captive_portal_detector_; | |
| 44 | |
| 45 CaptivePortalDetector::Results results_; | 42 CaptivePortalDetector::Results results_; |
| 46 int num_results_received_; | 43 int num_results_received_; |
| 47 | 44 |
| 48 DISALLOW_COPY_AND_ASSIGN(CaptivePortalClient); | 45 DISALLOW_COPY_AND_ASSIGN(CaptivePortalClient); |
| 49 }; | 46 }; |
| 50 | 47 |
| 51 } // namespace | 48 } // namespace |
| 52 | 49 |
| 53 class CaptivePortalDetectorTest : public testing::Test, | 50 class CaptivePortalDetectorTest : public testing::Test, |
| 54 public CaptivePortalDetectorTestBase { | 51 public CaptivePortalDetectorTestBase { |
| (...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 199 | 196 |
| 200 TEST_F(CaptivePortalDetectorTest, Cancel) { | 197 TEST_F(CaptivePortalDetectorTest, Cancel) { |
| 201 RunCancelTest(); | 198 RunCancelTest(); |
| 202 CaptivePortalDetector::Results results; | 199 CaptivePortalDetector::Results results; |
| 203 results.result = RESULT_INTERNET_CONNECTED; | 200 results.result = RESULT_INTERNET_CONNECTED; |
| 204 results.response_code = 204; | 201 results.response_code = 204; |
| 205 RunTest(results, net::OK, 204, NULL); | 202 RunTest(results, net::OK, 204, NULL); |
| 206 } | 203 } |
| 207 | 204 |
| 208 } // namespace captive_portal | 205 } // namespace captive_portal |
| OLD | NEW |