Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(174)

Side by Side Diff: chrome/browser/captive_portal/captive_portal_tab_helper_unittest.cc

Issue 242483003: Move CaptivePortalDetector to src/components/captive_portal (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Move CaptivePortalDetector to a component Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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_tab_helper.h" 5 #include "chrome/browser/captive_portal/captive_portal_tab_helper.h"
6 6
7 #include "base/callback.h" 7 #include "base/callback.h"
8 #include "base/memory/scoped_ptr.h" 8 #include "base/memory/scoped_ptr.h"
9 #include "chrome/browser/captive_portal/captive_portal_service.h" 9 #include "chrome/browser/captive_portal/captive_portal_service.h"
10 #include "chrome/browser/captive_portal/captive_portal_tab_reloader.h" 10 #include "chrome/browser/captive_portal/captive_portal_tab_reloader.h"
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
47 class MockCaptivePortalTabReloader : public CaptivePortalTabReloader { 47 class MockCaptivePortalTabReloader : public CaptivePortalTabReloader {
48 public: 48 public:
49 MockCaptivePortalTabReloader() 49 MockCaptivePortalTabReloader()
50 : CaptivePortalTabReloader(NULL, NULL, base::Callback<void()>()) { 50 : CaptivePortalTabReloader(NULL, NULL, base::Callback<void()>()) {
51 } 51 }
52 52
53 MOCK_METHOD1(OnLoadStart, void(bool)); 53 MOCK_METHOD1(OnLoadStart, void(bool));
54 MOCK_METHOD1(OnLoadCommitted, void(int)); 54 MOCK_METHOD1(OnLoadCommitted, void(int));
55 MOCK_METHOD0(OnAbort, void()); 55 MOCK_METHOD0(OnAbort, void());
56 MOCK_METHOD1(OnRedirect, void(bool)); 56 MOCK_METHOD1(OnRedirect, void(bool));
57 MOCK_METHOD2(OnCaptivePortalResults, void(Result, Result)); 57 MOCK_METHOD2(OnCaptivePortalResults,
58 void(CaptivePortalResult, CaptivePortalResult));
58 }; 59 };
59 60
60 // Inherits from the ChromeRenderViewHostTestHarness to gain access to 61 // Inherits from the ChromeRenderViewHostTestHarness to gain access to
61 // CreateTestWebContents. Since the tests need to micromanage order of 62 // CreateTestWebContents. Since the tests need to micromanage order of
62 // WebContentsObserver function calls, does not actually make sure of 63 // WebContentsObserver function calls, does not actually make sure of
63 // the harness in any other way. 64 // the harness in any other way.
64 class CaptivePortalTabHelperTest : public ChromeRenderViewHostTestHarness { 65 class CaptivePortalTabHelperTest : public ChromeRenderViewHostTestHarness {
65 public: 66 public:
66 CaptivePortalTabHelperTest() 67 CaptivePortalTabHelperTest()
67 : tab_helper_(NULL), 68 : tab_helper_(NULL),
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
172 // Make sure that above call resulted in abort, for tests that continue 173 // Make sure that above call resulted in abort, for tests that continue
173 // after the abort. 174 // after the abort.
174 EXPECT_CALL(mock_reloader(), OnAbort()).Times(0); 175 EXPECT_CALL(mock_reloader(), OnAbort()).Times(0);
175 } 176 }
176 177
177 CaptivePortalTabHelper& tab_helper() { 178 CaptivePortalTabHelper& tab_helper() {
178 return tab_helper_; 179 return tab_helper_;
179 } 180 }
180 181
181 // Simulates a captive portal redirect by calling the Observe method. 182 // Simulates a captive portal redirect by calling the Observe method.
182 void ObservePortalResult(Result previous_result, Result result) { 183 void ObservePortalResult(CaptivePortalResult previous_result,
184 CaptivePortalResult result) {
183 content::Source<Profile> source_profile(NULL); 185 content::Source<Profile> source_profile(NULL);
184 186
185 CaptivePortalService::Results results; 187 CaptivePortalService::Results results;
186 results.previous_result = previous_result; 188 results.previous_result = previous_result;
187 results.result = result; 189 results.result = result;
188 content::Details<CaptivePortalService::Results> details_results(&results); 190 content::Details<CaptivePortalService::Results> details_results(&results);
189 191
190 EXPECT_CALL(mock_reloader(), OnCaptivePortalResults(previous_result, 192 EXPECT_CALL(mock_reloader(), OnCaptivePortalResults(previous_result,
191 result)).Times(1); 193 result)).Times(1);
192 tab_helper().Observe(chrome::NOTIFICATION_CAPTIVE_PORTAL_CHECK_RESULT, 194 tab_helper().Observe(chrome::NOTIFICATION_CAPTIVE_PORTAL_CHECK_RESULT,
(...skipping 417 matching lines...) Expand 10 before | Expand all | Expand 10 after
610 EXPECT_FALSE(tab_helper().IsLoginTab()); 612 EXPECT_FALSE(tab_helper().IsLoginTab());
611 613
612 ObservePortalResult(RESULT_BEHIND_CAPTIVE_PORTAL, RESULT_NO_RESPONSE); 614 ObservePortalResult(RESULT_BEHIND_CAPTIVE_PORTAL, RESULT_NO_RESPONSE);
613 EXPECT_FALSE(tab_helper().IsLoginTab()); 615 EXPECT_FALSE(tab_helper().IsLoginTab());
614 616
615 ObservePortalResult(RESULT_NO_RESPONSE, RESULT_INTERNET_CONNECTED); 617 ObservePortalResult(RESULT_NO_RESPONSE, RESULT_INTERNET_CONNECTED);
616 EXPECT_FALSE(tab_helper().IsLoginTab()); 618 EXPECT_FALSE(tab_helper().IsLoginTab());
617 } 619 }
618 620
619 } // namespace captive_portal 621 } // namespace captive_portal
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698