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

Side by Side Diff: chrome/browser/previews/previews_infobar_tab_helper_unittest.cc

Issue 2619603002: Remove android_java_ui as it is not used (Closed)
Patch Set: Created 3 years, 11 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
OLDNEW
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/memory/ptr_util.h" 10 #include "base/memory/ptr_util.h"
11 #include "base/strings/stringprintf.h" 11 #include "base/strings/stringprintf.h"
12 #include "base/threading/thread_task_runner_handle.h" 12 #include "base/threading/thread_task_runner_handle.h"
13 #include "chrome/browser/infobars/infobar_service.h" 13 #include "chrome/browser/infobars/infobar_service.h"
14 #include "chrome/browser/net/spdyproxy/data_reduction_proxy_chrome_settings.h" 14 #include "chrome/browser/net/spdyproxy/data_reduction_proxy_chrome_settings.h"
15 #include "chrome/browser/net/spdyproxy/data_reduction_proxy_chrome_settings_fact ory.h" 15 #include "chrome/browser/net/spdyproxy/data_reduction_proxy_chrome_settings_fact ory.h"
16 #include "chrome/browser/previews/previews_infobar_tab_helper.h" 16 #include "chrome/browser/previews/previews_infobar_tab_helper.h"
17 #include "chrome/common/features.h" 17 #include "chrome/common/features.h"
18 #include "chrome/test/base/chrome_render_view_host_test_harness.h" 18 #include "chrome/test/base/chrome_render_view_host_test_harness.h"
19 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_test _utils.h" 19 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_test _utils.h"
20 #include "components/data_reduction_proxy/core/common/data_reduction_proxy_heade rs.h" 20 #include "components/data_reduction_proxy/core/common/data_reduction_proxy_heade rs.h"
21 #include "components/data_reduction_proxy/core/common/data_reduction_proxy_pref_ names.h" 21 #include "components/data_reduction_proxy/core/common/data_reduction_proxy_pref_ names.h"
22 #include "components/offline_pages/core/offline_page_item.h" 22 #include "components/offline_pages/core/offline_page_item.h"
23 #include "components/offline_pages/core/request_header/offline_page_header.h" 23 #include "components/offline_pages/core/request_header/offline_page_header.h"
24 #include "components/prefs/pref_registry_simple.h" 24 #include "components/prefs/pref_registry_simple.h"
25 #include "components/proxy_config/proxy_config_pref_names.h" 25 #include "components/proxy_config/proxy_config_pref_names.h"
26 #include "content/public/browser/navigation_handle.h" 26 #include "content/public/browser/navigation_handle.h"
27 #include "content/public/test/web_contents_tester.h" 27 #include "content/public/test/web_contents_tester.h"
28 #include "net/http/http_util.h" 28 #include "net/http/http_util.h"
29 29
30 #if BUILDFLAG(ANDROID_JAVA_UI) 30 #if defined(OS_ANDROID)
31 #include "chrome/browser/android/offline_pages/offline_page_tab_helper.h" 31 #include "chrome/browser/android/offline_pages/offline_page_tab_helper.h"
32 #endif // BUILDFLAG(ANDROID_JAVA_UI) 32 #endif // defined(OS_ANDROID)
33 33
34 namespace { 34 namespace {
35 const char kTestUrl[] = "http://www.test.com/"; 35 const char kTestUrl[] = "http://www.test.com/";
36 } 36 }
37 37
38 class PreviewsInfoBarTabHelperUnitTest 38 class PreviewsInfoBarTabHelperUnitTest
39 : public ChromeRenderViewHostTestHarness { 39 : public ChromeRenderViewHostTestHarness {
40 protected: 40 protected:
41 void SetUp() override { 41 void SetUp() override {
42 ChromeRenderViewHostTestHarness::SetUp(); 42 ChromeRenderViewHostTestHarness::SetUp();
43 // Insert an OfflinePageTabHelper before PreviewsInfoBarTabHelper. 43 // Insert an OfflinePageTabHelper before PreviewsInfoBarTabHelper.
44 #if BUILDFLAG(ANDROID_JAVA_UI) 44 #if defined(OS_ANDROID)
45 offline_pages::OfflinePageTabHelper::CreateForWebContents(web_contents()); 45 offline_pages::OfflinePageTabHelper::CreateForWebContents(web_contents());
46 #endif // BUILDFLAG(ANDROID_JAVA_UI) 46 #endif // defined(OS_ANDROID)
47 InfoBarService::CreateForWebContents(web_contents()); 47 InfoBarService::CreateForWebContents(web_contents());
48 PreviewsInfoBarTabHelper::CreateForWebContents(web_contents()); 48 PreviewsInfoBarTabHelper::CreateForWebContents(web_contents());
49 test_handle_ = content::NavigationHandle::CreateNavigationHandleForTesting( 49 test_handle_ = content::NavigationHandle::CreateNavigationHandleForTesting(
50 GURL(kTestUrl), main_rfh()); 50 GURL(kTestUrl), main_rfh());
51 content::RenderFrameHostTester::For(main_rfh()) 51 content::RenderFrameHostTester::For(main_rfh())
52 ->InitializeRenderFrameIfNeeded(); 52 ->InitializeRenderFrameIfNeeded();
53 53
54 drp_test_context_ = 54 drp_test_context_ =
55 data_reduction_proxy::DataReductionProxyTestContext::Builder() 55 data_reduction_proxy::DataReductionProxyTestContext::Builder()
56 .WithMockConfig() 56 .WithMockConfig()
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
116 EXPECT_EQ(1U, infobar_service->infobar_count()); 116 EXPECT_EQ(1U, infobar_service->infobar_count());
117 EXPECT_TRUE(infobar_tab_helper->displayed_preview_infobar()); 117 EXPECT_TRUE(infobar_tab_helper->displayed_preview_infobar());
118 118
119 // Navigate to reset the displayed state. 119 // Navigate to reset the displayed state.
120 content::WebContentsTester::For(web_contents()) 120 content::WebContentsTester::For(web_contents())
121 ->NavigateAndCommit(GURL(kTestUrl)); 121 ->NavigateAndCommit(GURL(kTestUrl));
122 122
123 EXPECT_FALSE(infobar_tab_helper->displayed_preview_infobar()); 123 EXPECT_FALSE(infobar_tab_helper->displayed_preview_infobar());
124 } 124 }
125 125
126 #if BUILDFLAG(ANDROID_JAVA_UI) 126 #if defined(OS_ANDROID)
127 TEST_F(PreviewsInfoBarTabHelperUnitTest, CreateOfflineInfoBar) { 127 TEST_F(PreviewsInfoBarTabHelperUnitTest, CreateOfflineInfoBar) {
128 PreviewsInfoBarTabHelper* infobar_tab_helper = 128 PreviewsInfoBarTabHelper* infobar_tab_helper =
129 PreviewsInfoBarTabHelper::FromWebContents(web_contents()); 129 PreviewsInfoBarTabHelper::FromWebContents(web_contents());
130 EXPECT_FALSE(infobar_tab_helper->displayed_preview_infobar()); 130 EXPECT_FALSE(infobar_tab_helper->displayed_preview_infobar());
131 131
132 SimulateCommit(); 132 SimulateCommit();
133 offline_pages::OfflinePageItem item; 133 offline_pages::OfflinePageItem item;
134 item.url = GURL(kTestUrl); 134 item.url = GURL(kTestUrl);
135 offline_pages::OfflinePageHeader header; 135 offline_pages::OfflinePageHeader header;
136 offline_pages::OfflinePageTabHelper::FromWebContents(web_contents()) 136 offline_pages::OfflinePageTabHelper::FromWebContents(web_contents())
137 ->SetOfflinePage(item, header, true); 137 ->SetOfflinePage(item, header, true);
138 CallDidFinishNavigation(); 138 CallDidFinishNavigation();
139 139
140 InfoBarService* infobar_service = 140 InfoBarService* infobar_service =
141 InfoBarService::FromWebContents(web_contents()); 141 InfoBarService::FromWebContents(web_contents());
142 EXPECT_EQ(1U, infobar_service->infobar_count()); 142 EXPECT_EQ(1U, infobar_service->infobar_count());
143 EXPECT_TRUE(infobar_tab_helper->displayed_preview_infobar()); 143 EXPECT_TRUE(infobar_tab_helper->displayed_preview_infobar());
144 144
145 // Navigate to reset the displayed state. 145 // Navigate to reset the displayed state.
146 content::WebContentsTester::For(web_contents()) 146 content::WebContentsTester::For(web_contents())
147 ->NavigateAndCommit(GURL(kTestUrl)); 147 ->NavigateAndCommit(GURL(kTestUrl));
148 148
149 EXPECT_FALSE(infobar_tab_helper->displayed_preview_infobar()); 149 EXPECT_FALSE(infobar_tab_helper->displayed_preview_infobar());
150 } 150 }
151 #endif // BUILDFLAG(ANDROID_JAVA_UI) 151 #endif // defined(OS_ANDROID)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698