chromium/components/favicon/content/content_favicon_driver_unittest.cc

// Copyright 2015 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "components/favicon/content/content_favicon_driver.h"

#include <memory>
#include <vector>

#include "base/run_loop.h"
#include "base/task/single_thread_task_runner.h"
#include "base/test/bind.h"
#include "base/test/metrics/histogram_tester.h"
#include "components/favicon/core/favicon_client.h"
#include "components/favicon/core/favicon_handler.h"
#include "components/favicon/core/test/favicon_driver_impl_test_helper.h"
#include "components/favicon/core/test/mock_favicon_service.h"
#include "content/public/browser/web_contents_observer.h"
#include "content/public/test/navigation_simulator.h"
#include "content/public/test/test_renderer_host.h"
#include "content/public/test/web_contents_tester.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/blink/public/mojom/favicon/favicon_url.mojom.h"
#include "third_party/skia/include/core/SkBitmap.h"
#include "ui/gfx/favicon_size.h"

namespace favicon {
namespace {

_;
Return;
SizeIs;

void TestFetchFaviconForPage(
    content::WebContents* web_contents,
    const GURL& page_url,
    const std::vector<blink::mojom::FaviconURLPtr>& candidates) {}

class ContentFaviconDriverTest : public content::RenderViewHostTestHarness {};

// Test that a download is initiated when there isn't a favicon in the database
// for either the page URL or the icon URL.
TEST_F(ContentFaviconDriverTest, ShouldCauseImageDownload) {}

// Ensures that we do not consider a manifest URL if it arrives before the
// onload handler has fired.
// TODO(crbug.com/40180290): This may not necessarily the desired behavior, but
// this test will prevent unintentional behavioral changes until the issue is
// resolved.
TEST_F(ContentFaviconDriverTest, IgnoreManifestURLBeforeOnLoad) {}

// Ensures that we use a manifest URL if it arrives after the onload handler
// has fired. See crbug.com/1205018 for details.
TEST_F(ContentFaviconDriverTest, UseManifestURLAFterOnLoad) {}

// Test that no download is initiated when
// DocumentOnLoadCompletedInPrimaryMainFrame() is not triggered (e.g. user
// stopped an ongoing page load).
TEST_F(ContentFaviconDriverTest, ShouldNotCauseImageDownload) {}

// Test that Favicon is not requested repeatedly during the same session if
// the favicon is known to be unavailable (e.g. due to HTTP 404 status).
TEST_F(ContentFaviconDriverTest, ShouldNotRequestRepeatedlyIfUnavailable) {}

TEST_F(ContentFaviconDriverTest, ShouldDownloadSecondIfFirstUnavailable) {}

ContentFaviconDriverTestNoFaviconService;

// This test verifies a crash doesn't happen during deletion of the
// WebContents. The crash occurred because ~WebContentsImpl would trigger
// running callbacks for manifests. This mean FaviconHandler would be called
// while ContentFaviconDriver::web_contents() was null, which is unexpected and
// crashed. See https://crbug.com/1114237 for more.
TEST_F(ContentFaviconDriverTestNoFaviconService,
       WebContentsDeletedWithInProgressManifestRequest) {}

}  // namespace
}  // namespace favicon