| 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_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/browser/chrome_notification_types.h" | 11 #include "chrome/browser/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_renderer_host.h" |
| 20 #include "net/base/net_errors.h" | 21 #include "net/base/net_errors.h" |
| 21 #include "testing/gmock/include/gmock/gmock.h" | 22 #include "testing/gmock/include/gmock/gmock.h" |
| 22 #include "testing/gtest/include/gtest/gtest.h" | 23 #include "testing/gtest/include/gtest/gtest.h" |
| 23 | 24 |
| 24 using captive_portal::CaptivePortalResult; | 25 using captive_portal::CaptivePortalResult; |
| 25 using content::ResourceType; | 26 using content::ResourceType; |
| 26 | 27 |
| 27 namespace { | 28 namespace { |
| 28 | 29 |
| 29 const char* const kHttpUrl = "http://whatever.com/"; | 30 const char* const kHttpUrl = "http://whatever.com/"; |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 69 : tab_helper_(NULL), | 70 : tab_helper_(NULL), |
| 70 mock_reloader_(new testing::StrictMock<MockCaptivePortalTabReloader>) { | 71 mock_reloader_(new testing::StrictMock<MockCaptivePortalTabReloader>) { |
| 71 tab_helper_.SetTabReloaderForTest(mock_reloader_); | 72 tab_helper_.SetTabReloaderForTest(mock_reloader_); |
| 72 } | 73 } |
| 73 ~CaptivePortalTabHelperTest() override {} | 74 ~CaptivePortalTabHelperTest() override {} |
| 74 | 75 |
| 75 void SetUp() override { | 76 void SetUp() override { |
| 76 ChromeRenderViewHostTestHarness::SetUp(); | 77 ChromeRenderViewHostTestHarness::SetUp(); |
| 77 web_contents1_.reset(CreateTestWebContents()); | 78 web_contents1_.reset(CreateTestWebContents()); |
| 78 web_contents2_.reset(CreateTestWebContents()); | 79 web_contents2_.reset(CreateTestWebContents()); |
| 80 |
| 81 // This will simulate the initialization of the RenderFrame in the renderer |
| 82 // process. This is needed because WebContents does not initialize a |
| 83 // RenderFrame on construction, and the tests expect one to exist. |
| 84 content::RenderFrameHostTester::For(main_render_frame1()) |
| 85 ->InitializeRenderFrameIfNeeded(); |
| 86 content::RenderFrameHostTester::For(main_render_frame2()) |
| 87 ->InitializeRenderFrameIfNeeded(); |
| 79 } | 88 } |
| 80 | 89 |
| 81 void TearDown() override { | 90 void TearDown() override { |
| 82 web_contents2_.reset(NULL); | 91 web_contents2_.reset(NULL); |
| 83 web_contents1_.reset(NULL); | 92 web_contents1_.reset(NULL); |
| 84 ChromeRenderViewHostTestHarness::TearDown(); | 93 ChromeRenderViewHostTestHarness::TearDown(); |
| 85 } | 94 } |
| 86 | 95 |
| 87 // Simulates a successful load of |url|. | 96 // Simulates a successful load of |url|. |
| 88 void SimulateSuccess(const GURL& url, | 97 void SimulateSuccess(const GURL& url, |
| (...skipping 550 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 639 EXPECT_FALSE(tab_helper().IsLoginTab()); | 648 EXPECT_FALSE(tab_helper().IsLoginTab()); |
| 640 | 649 |
| 641 ObservePortalResult(captive_portal::RESULT_BEHIND_CAPTIVE_PORTAL, | 650 ObservePortalResult(captive_portal::RESULT_BEHIND_CAPTIVE_PORTAL, |
| 642 captive_portal::RESULT_NO_RESPONSE); | 651 captive_portal::RESULT_NO_RESPONSE); |
| 643 EXPECT_FALSE(tab_helper().IsLoginTab()); | 652 EXPECT_FALSE(tab_helper().IsLoginTab()); |
| 644 | 653 |
| 645 ObservePortalResult(captive_portal::RESULT_NO_RESPONSE, | 654 ObservePortalResult(captive_portal::RESULT_NO_RESPONSE, |
| 646 captive_portal::RESULT_INTERNET_CONNECTED); | 655 captive_portal::RESULT_INTERNET_CONNECTED); |
| 647 EXPECT_FALSE(tab_helper().IsLoginTab()); | 656 EXPECT_FALSE(tab_helper().IsLoginTab()); |
| 648 } | 657 } |
| OLD | NEW |