chromium/components/omnibox/browser/shortcuts_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.

#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 {

// Returns up to 99,999 incrementing GUIDs of the format
// "BD85DBA2-8C29-49F9-84AE-48E1E_____E0".
std::string GetGuid() {}

// Don't add more shortcuts here. It's difficult to reuse shortcuts for
// different tests, so each test ends up adding new shortcuts, and this list
// keeps growing with no reuse benefit. Add shortcuts locally in each test.
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) {}

// Helpers to create `TestShortcutData`.
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) {}

// Verifies the values and order of match `destination_url`s.
void VerifyMatches(ACMatches matches,
                   std::vector<std::string> expected_destination_urls) {}

}  // namespace

class MockHistoryService : public history::HistoryService {};

// ShortcutsProviderTest ------------------------------------------------------

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) {}

// Actual tests ---------------------------------------------------------------

TEST_F(ShortcutsProviderTest, SimpleSingleMatch) {}

// These tests are like those in SimpleSingleMatch but more complex,
// involving URLs that need to be fixed up to match properly.
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  // !BUILDFLAG(IS_IOS)