OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/previews/previews_infobar_tab_helper.h" | 5 #include "chrome/browser/previews/previews_infobar_tab_helper.h" |
6 | 6 |
7 #include <memory> | 7 #include <memory> |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/strings/stringprintf.h" | 10 #include "base/strings/stringprintf.h" |
(...skipping 17 matching lines...) Expand all Loading... |
28 | 28 |
29 class PreviewsInfoBarTabHelperUnitTest | 29 class PreviewsInfoBarTabHelperUnitTest |
30 : public ChromeRenderViewHostTestHarness { | 30 : public ChromeRenderViewHostTestHarness { |
31 protected: | 31 protected: |
32 void SetUp() override { | 32 void SetUp() override { |
33 ChromeRenderViewHostTestHarness::SetUp(); | 33 ChromeRenderViewHostTestHarness::SetUp(); |
34 InfoBarService::CreateForWebContents(web_contents()); | 34 InfoBarService::CreateForWebContents(web_contents()); |
35 PreviewsInfoBarTabHelper::CreateForWebContents(web_contents()); | 35 PreviewsInfoBarTabHelper::CreateForWebContents(web_contents()); |
36 test_handle_ = content::NavigationHandle::CreateNavigationHandleForTesting( | 36 test_handle_ = content::NavigationHandle::CreateNavigationHandleForTesting( |
37 GURL(kTestUrl), main_rfh()); | 37 GURL(kTestUrl), main_rfh()); |
| 38 content::RenderFrameHostTester::For(main_rfh()) |
| 39 ->InitializeRenderFrameIfNeeded(); |
38 | 40 |
39 drp_test_context_ = | 41 drp_test_context_ = |
40 data_reduction_proxy::DataReductionProxyTestContext::Builder() | 42 data_reduction_proxy::DataReductionProxyTestContext::Builder() |
41 .WithMockConfig() | 43 .WithMockConfig() |
42 .SkipSettingsInitialization() | 44 .SkipSettingsInitialization() |
43 .Build(); | 45 .Build(); |
44 | 46 |
45 auto* data_reduction_proxy_settings = | 47 auto* data_reduction_proxy_settings = |
46 DataReductionProxyChromeSettingsFactory::GetForBrowserContext( | 48 DataReductionProxyChromeSettingsFactory::GetForBrowserContext( |
47 web_contents()->GetBrowserContext()); | 49 web_contents()->GetBrowserContext()); |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
95 InfoBarService* infobar_service = | 97 InfoBarService* infobar_service = |
96 InfoBarService::FromWebContents(web_contents()); | 98 InfoBarService::FromWebContents(web_contents()); |
97 EXPECT_EQ(1U, infobar_service->infobar_count()); | 99 EXPECT_EQ(1U, infobar_service->infobar_count()); |
98 EXPECT_TRUE(infobar_tab_helper->displayed_preview_infobar()); | 100 EXPECT_TRUE(infobar_tab_helper->displayed_preview_infobar()); |
99 | 101 |
100 // Navigate to reset the displayed state. | 102 // Navigate to reset the displayed state. |
101 content::WebContentsTester::For(web_contents()) | 103 content::WebContentsTester::For(web_contents()) |
102 ->NavigateAndCommit(GURL(kTestUrl)); | 104 ->NavigateAndCommit(GURL(kTestUrl)); |
103 EXPECT_FALSE(infobar_tab_helper->displayed_preview_infobar()); | 105 EXPECT_FALSE(infobar_tab_helper->displayed_preview_infobar()); |
104 } | 106 } |
OLD | NEW |