#ifdef UNSAFE_BUFFERS_BUILD
#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[] = …;
}
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_F(HistoryURLProviderTest,
WhatYouTyped_Exact_URLPreservesUsernameAndPassword) { … }
TEST_F(HistoryURLProviderTest, Files) { … }
TEST_F(HistoryURLProviderTest, Fixup) { … }
TEST_F(HistoryURLProviderTest, EmptyVisits) { … }
TEST_F(HistoryURLProviderTestNoDB, NavigateWithoutDB) { … }
TEST_F(HistoryURLProviderTest, AutocompleteOnTrailingWhitespace) { … }
TEST_F(HistoryURLProviderTest, TreatEmailsAsSearches) { … }
TEST_F(HistoryURLProviderTest, IntranetURLsWithPaths) { … }
TEST_F(HistoryURLProviderTest, IntranetURLCompletion) { … }
TEST_F(HistoryURLProviderTest, CrashDueToFixup) { … }
TEST_F(HistoryURLProviderTest, DoesNotProvideMatchesOnFocus) { … }
TEST_F(HistoryURLProviderTest, DoesNotInlinePunycodeMatches) { … }
TEST_F(HistoryURLProviderTest, CullSearchResults) { … }
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) { … }
TEST_F(HistoryURLProviderTest, DoTrimHttpScheme) { … }
TEST_F(HistoryURLProviderTest, DontTrimHttpSchemeIfInputHasScheme) { … }
TEST_F(HistoryURLProviderTest, DontTrimHttpSchemeIfInputMatchesInScheme) { … }
TEST_F(HistoryURLProviderTest, DontTrimHttpsSchemeIfInputMatchesInScheme) { … }
TEST_F(HistoryURLProviderTest, DoTrimHttpsScheme) { … }
TEST_F(HistoryURLProviderTest, KeywordModeExtractUserInput) { … }
TEST_F(HistoryURLProviderTest, MaxMatches) { … }
TEST_F(HistoryURLProviderTest, HistoryMatchToACMatchWithScoringSignals) { … }