chromium/components/omnibox/browser/history_url_provider_unittest.cc

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

#ifdef UNSAFE_BUFFERS_BUILD
// TODO(crbug.com/40285824): Remove this and convert code to safer constructs.
#pragma allow_unsafe_buffers
#endif

#include "components/omnibox/browser/history_url_provider.h"

#include <stddef.h>

#include <algorithm>
#include <memory>
#include <utility>

#include "base/run_loop.h"
#include "base/strings/string_util.h"
#include "base/strings/stringprintf.h"
#include "base/strings/utf_string_conversions.h"
#include "base/test/bind.h"
#include "base/test/scoped_feature_list.h"
#include "base/test/task_environment.h"
#include "base/time/time.h"
#include "build/build_config.h"
#include "components/bookmarks/test/test_bookmark_client.h"
#include "components/history/core/browser/history_service.h"
#include "components/history/core/browser/url_database.h"
#include "components/history/core/test/history_service_test_util.h"
#include "components/omnibox/browser/autocomplete_match.h"
#include "components/omnibox/browser/autocomplete_provider.h"
#include "components/omnibox/browser/autocomplete_provider_listener.h"
#include "components/omnibox/browser/autocomplete_result.h"
#include "components/omnibox/browser/fake_autocomplete_provider_client.h"
#include "components/omnibox/browser/history_quick_provider.h"
#include "components/omnibox/browser/verbatim_match.h"
#include "components/omnibox/common/omnibox_features.h"
#include "components/prefs/pref_service.h"
#include "components/search_engines/default_search_manager.h"
#include "components/search_engines/template_url.h"
#include "components/search_engines/template_url_service.h"
#include "components/search_engines/template_url_starter_pack_data.h"
#include "components/url_formatter/url_fixer.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/metrics_proto/omnibox_event.pb.h"
#include "third_party/metrics_proto/omnibox_focus_type.pb.h"
#include "third_party/metrics_proto/omnibox_input_type.pb.h"
#include "ui/base/page_transition_types.h"
#include "url/url_features.h"

ASCIIToUTF16;
Time;

namespace {

struct TestURLInfo {} test_db[] =;

}  // namespace

class HistoryURLProviderPublic : public HistoryURLProvider {};

class HistoryURLProviderTest : public testing::Test,
                               public AutocompleteProviderListener {};

class HistoryURLProviderTestNoDB : public HistoryURLProviderTest {};

class HistoryURLProviderTestNoSearchProvider : public HistoryURLProviderTest {};

void HistoryURLProviderTest::OnProviderUpdate(
    bool updated_matches,
    const AutocompleteProvider* provider) {}

bool HistoryURLProviderTest::SetUpImpl(bool create_history_db) {}

void HistoryURLProviderTest::TearDown() {}

void HistoryURLProviderTest::FillData() {}

void HistoryURLProviderTest::RunTest(
    const std::u16string& text,
    const std::string& desired_tld,
    bool prevent_inline_autocomplete,
    const UrlAndLegalDefault* expected_urls,
    size_t num_results,
    metrics::OmniboxInputType* identified_input_type) {}

void HistoryURLProviderTest::ExpectFormattedFullMatch(
    const std::string& input_text,
    const wchar_t* expected_match_contents,
    size_t expected_match_location,
    size_t expected_match_length) {}

TEST_F(HistoryURLProviderTest, PromoteShorterURLs) {}

TEST_F(HistoryURLProviderTest, CullRedirects) {}

TEST_F(HistoryURLProviderTestNoSearchProvider, WhatYouTypedNoSearchProvider) {}

TEST_F(HistoryURLProviderTest, WhatYouTyped) {}

// Test that the exact history match does not lose username/password
// credentials.
TEST_F(HistoryURLProviderTest,
       WhatYouTyped_Exact_URLPreservesUsernameAndPassword) {}

// Test that file: URLs are handled appropriately on each platform.
// url_formatter has per-platform logic for Windows vs POSIX, and
// AutocompleteInput has special casing for iOS and Android.
TEST_F(HistoryURLProviderTest, Files) {}

TEST_F(HistoryURLProviderTest, Fixup) {}

// Make sure the results for the input 'p' don't change between the first and
// second passes.
TEST_F(HistoryURLProviderTest, EmptyVisits) {}

TEST_F(HistoryURLProviderTestNoDB, NavigateWithoutDB) {}

TEST_F(HistoryURLProviderTest, AutocompleteOnTrailingWhitespace) {}

TEST_F(HistoryURLProviderTest, TreatEmailsAsSearches) {}

TEST_F(HistoryURLProviderTest, IntranetURLsWithPaths) {}

// Makes sure autocompletion happens for intranet sites that have been
// previoulsy visited.
TEST_F(HistoryURLProviderTest, IntranetURLCompletion) {}

TEST_F(HistoryURLProviderTest, CrashDueToFixup) {}

TEST_F(HistoryURLProviderTest, DoesNotProvideMatchesOnFocus) {}

TEST_F(HistoryURLProviderTest, DoesNotInlinePunycodeMatches) {}

TEST_F(HistoryURLProviderTest, CullSearchResults) {}

// Non-special URLs behavior is affected by the
// StandardCompliantNonSpecialSchemeURLParsing feature.
// See https://crbug.com/40063064 for details.
class HistoryURLProviderParamTest : public HistoryURLProviderTest,
                                    public ::testing::WithParamInterface<bool> {};

TEST_P(HistoryURLProviderParamTest, SuggestExactInput) {}

INSTANTIATE_TEST_SUITE_P();

TEST_F(HistoryURLProviderTest, HUPScoringExperiment) {}

TEST_F(HistoryURLProviderTest, MatchURLFormatting) {}

std::unique_ptr<HistoryURLProviderParams> BuildHistoryURLProviderParams(
    const std::string& input_text,
    const std::string& url_text,
    bool match_in_scheme) {}

// Make sure "http://" scheme is generally trimmed.
TEST_F(HistoryURLProviderTest, DoTrimHttpScheme) {}

// Make sure "http://" scheme is not trimmed if input has a scheme too.
TEST_F(HistoryURLProviderTest, DontTrimHttpSchemeIfInputHasScheme) {}

// Make sure "http://" scheme is not trimmed if input matches in scheme.
TEST_F(HistoryURLProviderTest, DontTrimHttpSchemeIfInputMatchesInScheme) {}

// Make sure "https://" scheme is not trimmed if the input has a scheme.
TEST_F(HistoryURLProviderTest, DontTrimHttpsSchemeIfInputMatchesInScheme) {}

// Make sure "https://" scheme is trimmed if nothing prevents it.
TEST_F(HistoryURLProviderTest, DoTrimHttpsScheme) {}

// Make sure that user input is trimmed correctly for starter pack keyword mode.
// In this mode, suggestions should be provided for only the user input after
// the keyword, i.e. "@history google" should only match "google".
TEST_F(HistoryURLProviderTest, KeywordModeExtractUserInput) {}

TEST_F(HistoryURLProviderTest, MaxMatches) {}

TEST_F(HistoryURLProviderTest, HistoryMatchToACMatchWithScoringSignals) {}