chromium/chrome/browser/spellchecker/spellcheck_custom_dictionary_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 "chrome/browser/spellchecker/spellcheck_custom_dictionary.h"

#include <stddef.h>

#include <list>
#include <memory>
#include <utility>
#include <vector>

#include "base/files/file_util.h"
#include "base/functional/bind.h"
#include "base/memory/ptr_util.h"
#include "base/memory/raw_ptr.h"
#include "base/metrics/histogram_samples.h"
#include "base/metrics/statistics_recorder.h"
#include "base/strings/string_number_conversions.h"
#include "build/build_config.h"
#include "chrome/browser/spellchecker/spellcheck_factory.h"
#include "chrome/browser/spellchecker/spellcheck_service.h"
#include "chrome/common/chrome_constants.h"
#include "chrome/test/base/testing_profile.h"
#include "components/spellcheck/browser/spellcheck_host_metrics.h"
#include "components/spellcheck/common/spellcheck_common.h"
#include "components/sync/base/client_tag_hash.h"
#include "components/sync/model/sync_change.h"
#include "components/sync/model/sync_data.h"
#include "components/sync/protocol/dictionary_specifics.pb.h"
#include "components/sync/protocol/entity_specifics.pb.h"
#include "components/sync/test/sync_change_processor_wrapper_for_test.h"
#include "content/public/test/browser_task_environment.h"
#include "content/public/test/test_utils.h"
#include "net/test/embedded_test_server/default_handlers.h"
#include "net/test/embedded_test_server/embedded_test_server.h"
#include "net/test/embedded_test_server/http_request.h"
#include "net/test/embedded_test_server/http_response.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"

HistogramBase;
HistogramSamples;
StatisticsRecorder;

namespace {

// Get all sync data for the custom dictionary without limiting to maximum
// number of syncable words.
syncer::SyncDataList GetAllSyncDataNoLimit(
    const SpellcheckCustomDictionary* dictionary) {}

}  // namespace

static std::unique_ptr<KeyedService> BuildSpellcheckService(
    content::BrowserContext* profile) {}

class SpellcheckCustomDictionaryTest : public testing::Test {};

// Counts the number of notifications for dictionary load and change.
class DictionaryObserverCounter : public SpellcheckCustomDictionary::Observer {};

TEST_F(SpellcheckCustomDictionaryTest, SaveAndLoad) {}

TEST_F(SpellcheckCustomDictionaryTest, MultiProfile) {}

// Legacy empty dictionary should be converted to new format empty dictionary.
TEST_F(SpellcheckCustomDictionaryTest, LegacyEmptyDictionaryShouldBeConverted) {}

// Legacy dictionary with two words should be converted to new format dictionary
// with two words.
TEST_F(SpellcheckCustomDictionaryTest,
       LegacyDictionaryWithTwoWordsShouldBeConverted) {}

// Illegal words should be removed. Leading and trailing whitespace should be
// trimmed.
TEST_F(SpellcheckCustomDictionaryTest,
       IllegalWordsShouldBeRemovedFromDictionary) {}

// Write to dictionary should backup previous version and write the word to the
// end of the dictionary. If the dictionary file is corrupted on disk, the
// previous version should be reloaded.
TEST_F(SpellcheckCustomDictionaryTest, CorruptedWriteShouldBeRecovered) {}

TEST_F(SpellcheckCustomDictionaryTest,
       GetAllSyncDataAccuratelyReflectsDictionaryState) {}

TEST_F(SpellcheckCustomDictionaryTest, GetAllSyncDataHasLimit) {}

TEST_F(SpellcheckCustomDictionaryTest, ProcessSyncChanges) {}

TEST_F(SpellcheckCustomDictionaryTest, MergeDataAndStartSyncing) {}

TEST_F(SpellcheckCustomDictionaryTest, SyncBeforeLoadDoesNotDuplicateWords) {}

TEST_F(SpellcheckCustomDictionaryTest, DictionaryTooBigBeforeSyncing) {}

TEST_F(SpellcheckCustomDictionaryTest, DictionaryTooBigAndServerFull) {}

TEST_F(SpellcheckCustomDictionaryTest, ServerTooBig) {}

TEST_F(SpellcheckCustomDictionaryTest, DictionaryTooBigToStartSyncing) {}

TEST_F(SpellcheckCustomDictionaryTest, DictionaryTooBigToContiueSyncing) {}

TEST_F(SpellcheckCustomDictionaryTest, LoadAfterSyncStart) {}

TEST_F(SpellcheckCustomDictionaryTest, LoadAfterSyncStartTooBigToSync) {}

TEST_F(SpellcheckCustomDictionaryTest, LoadDuplicatesAfterSync) {}

TEST_F(SpellcheckCustomDictionaryTest, DictionaryLoadNotification) {}

TEST_F(SpellcheckCustomDictionaryTest, DictionaryAddWordNotification) {}

TEST_F(SpellcheckCustomDictionaryTest, DictionaryRemoveWordNotification) {}

TEST_F(SpellcheckCustomDictionaryTest, DictionarySyncNotification) {}

// The server has maximum number of words and the client has maximum number of
// different words before association time. No new words should be pushed to the
// sync server upon association. The client should accept words from the sync
// server, however.
TEST_F(SpellcheckCustomDictionaryTest, DictionarySyncLimit) {}

TEST_F(SpellcheckCustomDictionaryTest, HasWord) {}