OLD | NEW |
1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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 #import "ios/chrome/browser/web/blocked_popup_tab_helper.h" | 5 #import "ios/chrome/browser/web/blocked_popup_tab_helper.h" |
6 | 6 |
7 #include "base/memory/ptr_util.h" | 7 #include "base/memory/ptr_util.h" |
8 #include "components/content_settings/core/browser/host_content_settings_map.h" | 8 #include "components/content_settings/core/browser/host_content_settings_map.h" |
9 #include "components/infobars/core/confirm_infobar_delegate.h" | 9 #include "components/infobars/core/confirm_infobar_delegate.h" |
10 #include "components/infobars/core/infobar.h" | 10 #include "components/infobars/core/infobar.h" |
11 #include "components/infobars/core/infobar_manager.h" | 11 #include "components/infobars/core/infobar_manager.h" |
12 #include "ios/chrome/browser/browser_state/test_chrome_browser_state.h" | 12 #include "ios/chrome/browser/browser_state/test_chrome_browser_state.h" |
13 #include "ios/chrome/browser/content_settings/host_content_settings_map_factory.
h" | 13 #include "ios/chrome/browser/content_settings/host_content_settings_map_factory.
h" |
14 #include "ios/chrome/browser/infobars/infobar_manager_impl.h" | 14 #include "ios/chrome/browser/infobars/infobar_manager_impl.h" |
15 #import "ios/chrome/browser/web/chrome_web_test.h" | 15 #import "ios/chrome/browser/web/chrome_web_test.h" |
16 #import "ios/web/public/test/fakes/test_navigation_manager.h" | 16 #import "ios/web/public/test/fakes/test_navigation_manager.h" |
17 #import "ios/web/public/test/fakes/test_web_state.h" | 17 #import "ios/web/public/test/fakes/test_web_state.h" |
18 #import "ios/web/public/test/fakes/test_web_state_delegate.h" | 18 #import "ios/web/public/test/fakes/test_web_state_delegate.h" |
19 #include "testing/gtest/include/gtest/gtest.h" | 19 #include "testing/gtest/include/gtest/gtest.h" |
20 #include "url/gurl.h" | 20 #include "url/gurl.h" |
21 | 21 |
| 22 #if !defined(__has_feature) || !__has_feature(objc_arc) |
| 23 #error "This file requires ARC support." |
| 24 #endif |
| 25 |
22 using web::WebState; | 26 using web::WebState; |
23 | 27 |
24 // Test fixture for BlockedPopupTabHelper class. | 28 // Test fixture for BlockedPopupTabHelper class. |
25 class BlockedPopupTabHelperTest : public ChromeWebTest { | 29 class BlockedPopupTabHelperTest : public ChromeWebTest { |
26 protected: | 30 protected: |
27 void SetUp() override { | 31 void SetUp() override { |
28 ChromeWebTest::SetUp(); | 32 ChromeWebTest::SetUp(); |
29 web_state()->SetDelegate(&web_state_delegate_); | 33 web_state()->SetDelegate(&web_state_delegate_); |
30 BlockedPopupTabHelper::CreateForWebState(web_state()); | 34 BlockedPopupTabHelper::CreateForWebState(web_state()); |
31 InfoBarManagerImpl::CreateForWebState(web_state()); | 35 InfoBarManagerImpl::CreateForWebState(web_state()); |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
139 GetBlockedPopupTabHelper()->HandlePopup(test_url, web::Referrer()); | 143 GetBlockedPopupTabHelper()->HandlePopup(test_url, web::Referrer()); |
140 ASSERT_EQ(1U, GetInfobarManager()->infobar_count()); | 144 ASSERT_EQ(1U, GetInfobarManager()->infobar_count()); |
141 EXPECT_TRUE(IsObservingSources()); | 145 EXPECT_TRUE(IsObservingSources()); |
142 | 146 |
143 // Dismiss the infobar and check that the tab helper no longer has any | 147 // Dismiss the infobar and check that the tab helper no longer has any |
144 // registered observers. | 148 // registered observers. |
145 GetInfobarManager()->infobar_at(0)->RemoveSelf(); | 149 GetInfobarManager()->infobar_at(0)->RemoveSelf(); |
146 EXPECT_EQ(0U, GetInfobarManager()->infobar_count()); | 150 EXPECT_EQ(0U, GetInfobarManager()->infobar_count()); |
147 EXPECT_FALSE(IsObservingSources()); | 151 EXPECT_FALSE(IsObservingSources()); |
148 } | 152 } |
OLD | NEW |