chromium/components/omnibox/browser/in_memory_url_index_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/in_memory_url_index.h"

#include <stddef.h>
#include <stdint.h>

#include <fstream>
#include <memory>
#include <numeric>
#include <string>
#include <utility>

#include "base/files/file_path.h"
#include "base/files/file_util.h"
#include "base/files/scoped_temp_dir.h"
#include "base/i18n/case_conversion.h"
#include "base/memory/raw_ptr.h"
#include "base/path_service.h"
#include "base/ranges/algorithm.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/string_split.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/task_environment.h"
#include "base/time/time.h"
#include "components/history/core/browser/history_backend.h"
#include "components/history/core/browser/history_database.h"
#include "components/history/core/browser/history_service.h"
#include "components/history/core/test/history_service_test_util.h"
#include "components/omnibox/browser/in_memory_url_index_types.h"
#include "components/omnibox/browser/omnibox_triggered_feature_service.h"
#include "components/omnibox/browser/url_index_private_data.h"
#include "components/search_engines/search_engines_test_environment.h"
#include "components/search_engines/template_url_service.h"
#include "components/url_formatter/url_formatter.h"
#include "testing/gtest/include/gtest/gtest.h"

// The test version of the history url database table ('url') is contained in
// a database file created from a text file('in_memory_url_index_test.db.txt').
// The only difference between this table and a live 'urls' table from a
// profile is that the last_visit_time column in the test table contains a
// number specifying the number of days relative to 'today' to which the
// absolute time should be set during the test setup stage.
//
// The format of the test database text file is of a SQLite .dump file.
// Note that only lines whose first character is an upper-case letter are
// processed when creating the test database.

namespace {
const size_t kInvalid =;
const size_t kProviderMaxMatches =;
const char kClientAllowlistedScheme[] =;

// TemplateURLs used to test filtering of search engine URLs.
const char16_t kDefaultTemplateURLKeyword[] =;
const char16_t kNonDefaultTemplateURLKeyword[] =;
const TemplateURLService::Initializer kTemplateURLData[] =;

// Helper function to set lower case |lower_string| and |lower_terms| (words
// list) based on supplied |search_string| and |cursor_position|. If
// |cursor_position| is set and useful (not at either end of the string), allow
// the |search_string| to be broken at |cursor_position|. We do this by
// pretending there's a space where the cursor is. |lower_terms| are obtained by
// splitting the |lower_string| on whitespace into tokens.
void StringToTerms(const char* search_string,
                   size_t cursor_position,
                   std::u16string* lower_string,
                   String16Vector* lower_terms) {}

}  // namespace

// -----------------------------------------------------------------------------

class InMemoryURLIndexTest : public testing::Test {};

TemplateURLService* InMemoryURLIndexTest::template_url_service() {}

sql::Database& InMemoryURLIndexTest::GetDB() {}

URLIndexPrivateData* InMemoryURLIndexTest::GetPrivateData() const {}

base::CancelableTaskTracker* InMemoryURLIndexTest::GetPrivateDataTracker()
    const {}

void InMemoryURLIndexTest::ClearPrivateData() {}

const SchemeSet& InMemoryURLIndexTest::scheme_allowlist() {}

bool InMemoryURLIndexTest::UpdateURL(const history::URLRow& row) {}

bool InMemoryURLIndexTest::DeleteURL(const GURL& url) {}

void InMemoryURLIndexTest::SetUp() {}

void InMemoryURLIndexTest::TearDown() {}

base::FilePath::StringType InMemoryURLIndexTest::TestDBName() const {}

bool InMemoryURLIndexTest::InitializeInMemoryURLIndexInSetUp() const {}

void InMemoryURLIndexTest::InitializeInMemoryURLIndex() {}

void InMemoryURLIndexTest::CheckTerm(
    const URLIndexPrivateData::SearchTermCacheMap& cache,
    std::u16string term) const {}

void InMemoryURLIndexTest::ExpectPrivateDataNotEmpty(
    const URLIndexPrivateData& data) {}

void InMemoryURLIndexTest::ExpectPrivateDataEmpty(
    const URLIndexPrivateData& data) {}

// Helper function which compares two maps for equivalence. The maps' values
// are associative containers and their contents are compared as well.
template <typename T>
void ExpectMapOfContainersIdentical(const T& expected, const T& actual) {}

void InMemoryURLIndexTest::ExpectPrivateDataEqual(
    const URLIndexPrivateData& expected,
    const URLIndexPrivateData& actual) {}

//------------------------------------------------------------------------------

class LimitedInMemoryURLIndexTest : public InMemoryURLIndexTest {};

base::FilePath::StringType LimitedInMemoryURLIndexTest::TestDBName() const {}

bool LimitedInMemoryURLIndexTest::InitializeInMemoryURLIndexInSetUp() const {}

TEST_F(LimitedInMemoryURLIndexTest, Initialization) {}

TEST_F(InMemoryURLIndexTest, HiddenURLRowsAreIgnored) {}

TEST_F(InMemoryURLIndexTest, Retrieval) {}

// Regression test for crbug.com/1494484. Exercises a URL that is valid but may
// become invalid if handled with url_formatter::FormatUrl().
TEST_F(InMemoryURLIndexTest,
       RetrievalWithInternationalizedDomainNameWithInvalidCodePoint) {}

TEST_F(InMemoryURLIndexTest, CursorPositionRetrieval) {}

TEST_F(InMemoryURLIndexTest, URLPrefixMatching) {}

TEST_F(InMemoryURLIndexTest, ProperStringMatching) {}

TEST_F(InMemoryURLIndexTest, TrimHistoryIds) {}

TEST_F(InMemoryURLIndexTest, HugeResultSet) {}

TEST_F(InMemoryURLIndexTest, TitleSearch) {}

TEST_F(InMemoryURLIndexTest, TitleChange) {}

TEST_F(InMemoryURLIndexTest, NonUniqueTermCharacterSets) {}

TEST_F(InMemoryURLIndexTest, TypedCharacterCaching) {}

TEST_F(InMemoryURLIndexTest, AddNewRows) {}

TEST_F(InMemoryURLIndexTest, DeleteRows) {}

TEST_F(InMemoryURLIndexTest, ExpireRow) {}

TEST_F(InMemoryURLIndexTest, AllowlistedURLs) {}

TEST_F(InMemoryURLIndexTest, ReadVisitsFromHistory) {}

TEST_F(InMemoryURLIndexTest, CalculateWordStartsOffsets) {}