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

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

Issue 14197014: Add TestBrowserThreadBundle into RenderViewHostTestHarness. Kill some unnecessary real threads. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: merged ToT Created 7 years, 6 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
« no previous file with comments | « no previous file | chrome/browser/captive_portal/captive_portal_tab_reloader_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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"
11 #include "chrome/common/chrome_notification_types.h" 11 #include "chrome/common/chrome_notification_types.h"
12 #include "chrome/test/base/chrome_render_view_host_test_harness.h" 12 #include "chrome/test/base/chrome_render_view_host_test_harness.h"
13 #include "content/public/browser/notification_details.h" 13 #include "content/public/browser/notification_details.h"
14 #include "content/public/browser/notification_service.h" 14 #include "content/public/browser/notification_service.h"
15 #include "content/public/browser/notification_source.h" 15 #include "content/public/browser/notification_source.h"
16 #include "content/public/browser/notification_types.h" 16 #include "content/public/browser/notification_types.h"
17 #include "content/public/browser/render_view_host.h" 17 #include "content/public/browser/render_view_host.h"
18 #include "content/public/browser/render_process_host.h" 18 #include "content/public/browser/render_process_host.h"
19 #include "content/public/browser/web_contents.h" 19 #include "content/public/browser/web_contents.h"
20 #include "content/public/test/test_browser_thread.h"
21 #include "net/base/net_errors.h" 20 #include "net/base/net_errors.h"
22 #include "testing/gmock/include/gmock/gmock.h" 21 #include "testing/gmock/include/gmock/gmock.h"
23 #include "testing/gtest/include/gtest/gtest.h" 22 #include "testing/gtest/include/gtest/gtest.h"
24 23
25 namespace captive_portal { 24 namespace captive_portal {
26 25
27 namespace { 26 namespace {
28 27
29 const char* const kHttpUrl = "http://whatever.com/"; 28 const char* const kHttpUrl = "http://whatever.com/";
30 const char* const kHttpsUrl = "https://whatever.com/"; 29 const char* const kHttpsUrl = "https://whatever.com/";
(...skipping 28 matching lines...) Expand all
59 }; 58 };
60 59
61 // Inherits from the ChromeRenderViewHostTestHarness to gain access to 60 // Inherits from the ChromeRenderViewHostTestHarness to gain access to
62 // CreateTestWebContents. Since the tests need to micromanage order of 61 // CreateTestWebContents. Since the tests need to micromanage order of
63 // WebContentsObserver function calls, does not actually make sure of 62 // WebContentsObserver function calls, does not actually make sure of
64 // the harness in any other way. 63 // the harness in any other way.
65 class CaptivePortalTabHelperTest : public ChromeRenderViewHostTestHarness { 64 class CaptivePortalTabHelperTest : public ChromeRenderViewHostTestHarness {
66 public: 65 public:
67 CaptivePortalTabHelperTest() 66 CaptivePortalTabHelperTest()
68 : tab_helper_(NULL), 67 : tab_helper_(NULL),
69 mock_reloader_(new testing::StrictMock<MockCaptivePortalTabReloader>), 68 mock_reloader_(new testing::StrictMock<MockCaptivePortalTabReloader>) {
70 ui_thread_(content::BrowserThread::UI, &message_loop_) {
71 tab_helper_.SetTabReloaderForTest(mock_reloader_); 69 tab_helper_.SetTabReloaderForTest(mock_reloader_);
72 } 70 }
73 virtual ~CaptivePortalTabHelperTest() {} 71 virtual ~CaptivePortalTabHelperTest() {}
74 72
75 virtual void SetUp() OVERRIDE { 73 virtual void SetUp() OVERRIDE {
76 ChromeRenderViewHostTestHarness::SetUp(); 74 ChromeRenderViewHostTestHarness::SetUp();
77 web_contents1_.reset(CreateTestWebContents()); 75 web_contents1_.reset(CreateTestWebContents());
78 web_contents2_.reset(CreateTestWebContents()); 76 web_contents2_.reset(CreateTestWebContents());
79 } 77 }
80 78
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
213 private: 211 private:
214 // Only the RenderViewHosts are used. 212 // Only the RenderViewHosts are used.
215 scoped_ptr<content::WebContents> web_contents1_; 213 scoped_ptr<content::WebContents> web_contents1_;
216 scoped_ptr<content::WebContents> web_contents2_; 214 scoped_ptr<content::WebContents> web_contents2_;
217 215
218 CaptivePortalTabHelper tab_helper_; 216 CaptivePortalTabHelper tab_helper_;
219 217
220 // Owned by |tab_helper_|. 218 // Owned by |tab_helper_|.
221 testing::StrictMock<MockCaptivePortalTabReloader>* mock_reloader_; 219 testing::StrictMock<MockCaptivePortalTabReloader>* mock_reloader_;
222 220
223 content::TestBrowserThread ui_thread_;
224
225 DISALLOW_COPY_AND_ASSIGN(CaptivePortalTabHelperTest); 221 DISALLOW_COPY_AND_ASSIGN(CaptivePortalTabHelperTest);
226 }; 222 };
227 223
228 TEST_F(CaptivePortalTabHelperTest, HttpSuccess) { 224 TEST_F(CaptivePortalTabHelperTest, HttpSuccess) {
229 SimulateSuccess(GURL(kHttpUrl), render_view_host1()); 225 SimulateSuccess(GURL(kHttpUrl), render_view_host1());
230 tab_helper().DidStopLoading(render_view_host1()); 226 tab_helper().DidStopLoading(render_view_host1());
231 } 227 }
232 228
233 TEST_F(CaptivePortalTabHelperTest, HttpTimeout) { 229 TEST_F(CaptivePortalTabHelperTest, HttpTimeout) {
234 SimulateTimeout(GURL(kHttpUrl), render_view_host1()); 230 SimulateTimeout(GURL(kHttpUrl), render_view_host1());
(...skipping 369 matching lines...) Expand 10 before | Expand all | Expand 10 after
604 EXPECT_FALSE(tab_helper().IsLoginTab()); 600 EXPECT_FALSE(tab_helper().IsLoginTab());
605 601
606 ObservePortalResult(RESULT_BEHIND_CAPTIVE_PORTAL, RESULT_NO_RESPONSE); 602 ObservePortalResult(RESULT_BEHIND_CAPTIVE_PORTAL, RESULT_NO_RESPONSE);
607 EXPECT_FALSE(tab_helper().IsLoginTab()); 603 EXPECT_FALSE(tab_helper().IsLoginTab());
608 604
609 ObservePortalResult(RESULT_NO_RESPONSE, RESULT_INTERNET_CONNECTED); 605 ObservePortalResult(RESULT_NO_RESPONSE, RESULT_INTERNET_CONNECTED);
610 EXPECT_FALSE(tab_helper().IsLoginTab()); 606 EXPECT_FALSE(tab_helper().IsLoginTab());
611 } 607 }
612 608
613 } // namespace captive_portal 609 } // namespace captive_portal
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/captive_portal/captive_portal_tab_reloader_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698