#include "components/omnibox/browser/shortcuts_provider.h"
#include <math.h>
#include <stddef.h>
#include <algorithm>
#include <functional>
#include <memory>
#include <optional>
#include <set>
#include <string>
#include <vector>
#include "base/files/scoped_temp_dir.h"
#include "base/memory/ref_counted.h"
#include "base/run_loop.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/stringprintf.h"
#include "base/strings/utf_string_conversions.h"
#include "base/test/scoped_feature_list.h"
#include "base/test/task_environment.h"
#include "components/history/core/browser/url_database.h"
#include "components/omnibox/browser/autocomplete_input.h"
#include "components/omnibox/browser/autocomplete_match.h"
#include "components/omnibox/browser/autocomplete_provider.h"
#include "components/omnibox/browser/autocomplete_result.h"
#include "components/omnibox/browser/fake_autocomplete_provider_client.h"
#include "components/omnibox/browser/in_memory_url_index.h"
#include "components/omnibox/browser/omnibox_feature_configs.h"
#include "components/omnibox/browser/omnibox_triggered_feature_service.h"
#include "components/omnibox/browser/shortcuts_backend.h"
#include "components/omnibox/browser/shortcuts_provider_test_util.h"
#include "components/omnibox/common/omnibox_features.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/omnibox_proto/groups.pb.h"
ASCIIToUTF16;
ExpectedURLs;
namespace {
std::string GetGuid() { … }
struct TestShortcutData shortcut_test_db[] = …;
ShortcutsDatabase::Shortcut MakeShortcut(
std::u16string text,
const base::Time& last_access_time = base::Time::Now(),
int number_of_hits = 1) { … }
TestShortcutData MakeShortcutData(std::string text,
std::string destination_url = "",
int days_from_now = 0,
int number_of_hits = 0) { … }
TestShortcutData MakeShortcutData(std::string text, int number_of_hits) { … }
void VerifyMatches(ACMatches matches,
std::vector<std::string> expected_destination_urls) { … }
}
class MockHistoryService : public history::HistoryService { … };
class ShortcutsProviderTest : public testing::Test { … };
ShortcutsProviderTest::ShortcutsProviderTest() { … }
void ShortcutsProviderTest::SetUp() { … }
void ShortcutsProviderTest::TearDown() { … }
int ShortcutsProviderTest::CalculateAggregateScore(
size_t input_length,
const std::vector<const ShortcutsDatabase::Shortcut*>& shortcuts) { … }
void ShortcutsProviderTest::DoAutocompleteWithScoringSignals(
const AutocompleteInput& input) { … }
TEST_F(ShortcutsProviderTest, SimpleSingleMatch) { … }
TEST_F(ShortcutsProviderTest, TrickySingleMatch) { … }
TEST_F(ShortcutsProviderTest, SimpleSingleMatchKeyword) { … }
TEST_F(ShortcutsProviderTest, MultiMatch) { … }
TEST_F(ShortcutsProviderTest, RemoveDuplicates) { … }
TEST_F(ShortcutsProviderTest, TypedCountMatches) { … }
TEST_F(ShortcutsProviderTest, FragmentLengthMatches) { … }
TEST_F(ShortcutsProviderTest, DaysAgoMatches) { … }
TEST_F(ShortcutsProviderTest, DeleteMatch) { … }
TEST_F(ShortcutsProviderTest, DoesNotProvideOnFocus) { … }
TEST_F(ShortcutsProviderTest, DoAutocompleteAggregateShortcuts) { … }
TEST_F(ShortcutsProviderTest, DoAutocompleteWithScoringSignals) { … }
TEST_F(ShortcutsProviderTest, Score) { … }
TEST_F(ShortcutsProviderTest, ScoreBoost) { … }
#if !BUILDFLAG(IS_IOS)
TEST_F(ShortcutsProviderTest, HistoryClusterSuggestions) { … }
#endif