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 "base/basictypes.h" | 7 #include "base/basictypes.h" |
8 #include "base/bind.h" | 8 #include "base/bind.h" |
9 #include "base/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
45 | 45 |
46 DISALLOW_COPY_AND_ASSIGN(CaptivePortalClient); | 46 DISALLOW_COPY_AND_ASSIGN(CaptivePortalClient); |
47 }; | 47 }; |
48 | 48 |
49 } // namespace | 49 } // namespace |
50 | 50 |
51 class CaptivePortalDetectorTest : public testing::Test, | 51 class CaptivePortalDetectorTest : public testing::Test, |
52 public CaptivePortalDetectorTestBase { | 52 public CaptivePortalDetectorTestBase { |
53 public: | 53 public: |
54 CaptivePortalDetectorTest() {} | 54 CaptivePortalDetectorTest() {} |
55 virtual ~CaptivePortalDetectorTest() {} | 55 ~CaptivePortalDetectorTest() override {} |
56 | 56 |
57 virtual void SetUp() override { | 57 void SetUp() override { |
58 CHECK(base::MessageLoopProxy::current().get()); | 58 CHECK(base::MessageLoopProxy::current().get()); |
59 scoped_refptr<net::URLRequestContextGetter> request_context_getter( | 59 scoped_refptr<net::URLRequestContextGetter> request_context_getter( |
60 new net::TestURLRequestContextGetter( | 60 new net::TestURLRequestContextGetter( |
61 base::MessageLoopProxy::current())); | 61 base::MessageLoopProxy::current())); |
62 | 62 |
63 detector_.reset(new CaptivePortalDetector(request_context_getter.get())); | 63 detector_.reset(new CaptivePortalDetector(request_context_getter.get())); |
64 set_detector(detector_.get()); | 64 set_detector(detector_.get()); |
65 } | 65 } |
66 | 66 |
67 virtual void TearDown() override { | 67 void TearDown() override { detector_.reset(); } |
68 detector_.reset(); | |
69 } | |
70 | 68 |
71 void RunTest(const CaptivePortalDetector::Results& expected_results, | 69 void RunTest(const CaptivePortalDetector::Results& expected_results, |
72 int net_error, | 70 int net_error, |
73 int status_code, | 71 int status_code, |
74 const char* response_headers) { | 72 const char* response_headers) { |
75 ASSERT_FALSE(FetchingURL()); | 73 ASSERT_FALSE(FetchingURL()); |
76 | 74 |
77 GURL url(CaptivePortalDetector::kDefaultURL); | 75 GURL url(CaptivePortalDetector::kDefaultURL); |
78 CaptivePortalClient client(detector()); | 76 CaptivePortalClient client(detector()); |
79 | 77 |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
205 | 203 |
206 TEST_F(CaptivePortalDetectorTest, Cancel) { | 204 TEST_F(CaptivePortalDetectorTest, Cancel) { |
207 RunCancelTest(); | 205 RunCancelTest(); |
208 CaptivePortalDetector::Results results; | 206 CaptivePortalDetector::Results results; |
209 results.result = captive_portal::RESULT_INTERNET_CONNECTED; | 207 results.result = captive_portal::RESULT_INTERNET_CONNECTED; |
210 results.response_code = 204; | 208 results.response_code = 204; |
211 RunTest(results, net::OK, 204, NULL); | 209 RunTest(results, net::OK, 204, NULL); |
212 } | 210 } |
213 | 211 |
214 } // namespace captive_portal | 212 } // namespace captive_portal |
OLD | NEW |