chromium/chrome/browser/preloading/prefetch/zero_suggest_prefetch/zero_suggest_prefetch_tab_helper_browsertest.cc

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

#include "chrome/browser/preloading/prefetch/zero_suggest_prefetch/zero_suggest_prefetch_tab_helper.h"

#include <memory>

#include "base/functional/callback.h"
#include "base/memory/raw_ptr.h"
#include "base/test/scoped_feature_list.h"
#include "build/chromeos_buildflags.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/search_engine_choice/search_engine_choice_service_factory.h"
#include "chrome/browser/search_engines/template_url_service_factory.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_window.h"
#include "chrome/browser/ui/location_bar/location_bar.h"
#include "chrome/common/webui_url_constants.h"
#include "chrome/test/base/in_process_browser_test.h"
#include "chrome/test/base/ui_test_utils.h"
#include "components/omnibox/browser/autocomplete_controller.h"
#include "components/omnibox/browser/mock_autocomplete_provider_client.h"
#include "components/omnibox/browser/omnibox_controller.h"
#include "components/omnibox/browser/omnibox_view.h"
#include "components/omnibox/common/omnibox_features.h"
#include "components/search_engines/template_url_service.h"
#include "components/search_engines/template_url_service_client.h"
#include "content/public/test/browser_test.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "third_party/metrics_proto/omnibox_event.pb.h"

namespace {

class MockAutocompleteController : public AutocompleteController {};

}  // namespace

class ZeroSuggestPrefetchTabHelperBrowserTest : public InProcessBrowserTest {};

class ZeroSuggestPrefetchTabHelperBrowserTestOnNTP
    : public ZeroSuggestPrefetchTabHelperBrowserTest {};

class ZeroSuggestPrefetchTabHelperBrowserTestOnSRP
    : public ZeroSuggestPrefetchTabHelperBrowserTest {};

class ZeroSuggestPrefetchTabHelperBrowserTestOnWeb
    : public ZeroSuggestPrefetchTabHelperBrowserTest {};

// Tests that navigating to or switching to the NTP starts a prefetch request
// with the expected page classification.
IN_PROC_BROWSER_TEST_F(ZeroSuggestPrefetchTabHelperBrowserTestOnNTP,
                       StartPrefetch) {}

// Tests that navigating to or switching to the SRP starts a prefetch request
// with the expected page classification.
IN_PROC_BROWSER_TEST_F(ZeroSuggestPrefetchTabHelperBrowserTestOnSRP,
                       StartPrefetch) {}

// Tests that navigating to or switching to a Web URL (non-NTP/non-SRP) starts a
// prefetch request with the expected page classification.
IN_PROC_BROWSER_TEST_F(ZeroSuggestPrefetchTabHelperBrowserTestOnWeb,
                       StartPrefetch) {}