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

Side by Side Diff: chrome/browser/favicon/content_favicon_driver_browsertest.cc

Issue 2958503002: Enable feature to load icons from Web Manifests by defaut (Closed)
Patch Set: Update unit tests. Created 3 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
« no previous file with comments | « no previous file | components/favicon/core/favicon_handler_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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "components/favicon/content/content_favicon_driver.h" 5 #include "components/favicon/content/content_favicon_driver.h"
6 6
7 #include "base/location.h" 7 #include "base/location.h"
8 #include "base/macros.h" 8 #include "base/macros.h"
9 #include "base/memory/weak_ptr.h" 9 #include "base/memory/weak_ptr.h"
10 #include "base/run_loop.h" 10 #include "base/run_loop.h"
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after
255 chrome::ExecuteCommand(browser(), IDC_RELOAD_BYPASSING_CACHE); 255 chrome::ExecuteCommand(browser(), IDC_RELOAD_BYPASSING_CACHE);
256 waiter.Wait(); 256 waiter.Wait();
257 } 257 }
258 ASSERT_TRUE(delegate->was_requested()); 258 ASSERT_TRUE(delegate->was_requested());
259 EXPECT_TRUE(delegate->bypassed_cache()); 259 EXPECT_TRUE(delegate->bypassed_cache());
260 } 260 }
261 261
262 // Test that loading a page that contains icons only in the Web Manifest causes 262 // Test that loading a page that contains icons only in the Web Manifest causes
263 // those icons to be used. 263 // those icons to be used.
264 IN_PROC_BROWSER_TEST_F(ContentFaviconDriverTest, LoadIconFromWebManifest) { 264 IN_PROC_BROWSER_TEST_F(ContentFaviconDriverTest, LoadIconFromWebManifest) {
265 base::test::ScopedFeatureList override_features;
266 override_features.InitAndEnableFeature(favicon::kFaviconsFromWebManifest);
267
268 ASSERT_TRUE(embedded_test_server()->Start()); 265 ASSERT_TRUE(embedded_test_server()->Start());
269 GURL url = embedded_test_server()->GetURL("/favicon/page_with_manifest.html"); 266 GURL url = embedded_test_server()->GetURL("/favicon/page_with_manifest.html");
270 GURL icon_url = embedded_test_server()->GetURL("/favicon/icon.png"); 267 GURL icon_url = embedded_test_server()->GetURL("/favicon/icon.png");
271 268
272 std::unique_ptr<TestResourceDispatcherHostDelegate> delegate( 269 std::unique_ptr<TestResourceDispatcherHostDelegate> delegate(
273 new TestResourceDispatcherHostDelegate(icon_url)); 270 new TestResourceDispatcherHostDelegate(icon_url));
274 content::ResourceDispatcherHost::Get()->SetDelegate(delegate.get()); 271 content::ResourceDispatcherHost::Get()->SetDelegate(delegate.get());
275 272
276 PendingTaskWaiter waiter(web_contents(), this); 273 PendingTaskWaiter waiter(web_contents(), this);
277 ui_test_utils::NavigateToURLWithDisposition( 274 ui_test_utils::NavigateToURLWithDisposition(
(...skipping 11 matching lines...) Expand all
289 // Test that loading a page that contains a Web Manifest without icons and a 286 // Test that loading a page that contains a Web Manifest without icons and a
290 // regular favicon in the HTML reports the icon. The regular icon is initially 287 // regular favicon in the HTML reports the icon. The regular icon is initially
291 // cached in the Favicon database. 288 // cached in the Favicon database.
292 IN_PROC_BROWSER_TEST_F(ContentFaviconDriverTest, 289 IN_PROC_BROWSER_TEST_F(ContentFaviconDriverTest,
293 LoadRegularIconDespiteWebManifestWithoutIcons) { 290 LoadRegularIconDespiteWebManifestWithoutIcons) {
294 ASSERT_TRUE(embedded_test_server()->Start()); 291 ASSERT_TRUE(embedded_test_server()->Start());
295 GURL url = embedded_test_server()->GetURL( 292 GURL url = embedded_test_server()->GetURL(
296 "/favicon/page_with_manifest_without_icons.html"); 293 "/favicon/page_with_manifest_without_icons.html");
297 GURL icon_url = embedded_test_server()->GetURL("/favicon/icon.png"); 294 GURL icon_url = embedded_test_server()->GetURL("/favicon/icon.png");
298 295
299 // Initial visit with the feature still disabled, to populate the cache. 296 // Initial visit with the feature disabled, to populate the cache.
300 { 297 {
298 base::test::ScopedFeatureList override_features;
299 override_features.InitAndDisableFeature(favicon::kFaviconsFromWebManifest);
300
301 PendingTaskWaiter waiter(web_contents(), this); 301 PendingTaskWaiter waiter(web_contents(), this);
302 ui_test_utils::NavigateToURLWithDisposition( 302 ui_test_utils::NavigateToURLWithDisposition(
303 browser(), url, WindowOpenDisposition::CURRENT_TAB, 303 browser(), url, WindowOpenDisposition::CURRENT_TAB,
304 ui_test_utils::BROWSER_TEST_NONE); 304 ui_test_utils::BROWSER_TEST_NONE);
305 waiter.Wait(); 305 waiter.Wait();
306 } 306 }
307 ASSERT_NE(nullptr, GetFaviconForPageURL(url).bitmap_data); 307 ASSERT_NE(nullptr, GetFaviconForPageURL(url).bitmap_data);
308 308
309 ui_test_utils::NavigateToURL(browser(), GURL(url::kAboutBlankURL)); 309 ui_test_utils::NavigateToURL(browser(), GURL(url::kAboutBlankURL));
310 310
311 // Enable the feature and visit the page again. 311 // Visit the page again now that the feature is enabled (default).
312 base::test::ScopedFeatureList override_features;
313 override_features.InitAndEnableFeature(favicon::kFaviconsFromWebManifest);
314
315 { 312 {
316 PendingTaskWaiter waiter(web_contents(), this); 313 PendingTaskWaiter waiter(web_contents(), this);
317 ui_test_utils::NavigateToURLWithDisposition( 314 ui_test_utils::NavigateToURLWithDisposition(
318 browser(), url, WindowOpenDisposition::CURRENT_TAB, 315 browser(), url, WindowOpenDisposition::CURRENT_TAB,
319 ui_test_utils::BROWSER_TEST_NONE); 316 ui_test_utils::BROWSER_TEST_NONE);
320 waiter.Wait(); 317 waiter.Wait();
321 } 318 }
322 319
323 EXPECT_NE(nullptr, GetFaviconForPageURL(url).bitmap_data); 320 EXPECT_NE(nullptr, GetFaviconForPageURL(url).bitmap_data);
324 } 321 }
OLDNEW
« no previous file with comments | « no previous file | components/favicon/core/favicon_handler_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698