chromium/chrome/browser/extensions/api/storage/settings_sync_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 <stddef.h>

#include <memory>
#include <utility>

#include "base/files/scoped_temp_dir.h"
#include "base/functional/bind.h"
#include "base/json/json_reader.h"
#include "base/json/json_writer.h"
#include "base/memory/raw_ptr.h"
#include "base/strings/string_number_conversions.h"
#include "base/values.h"
#include "build/build_config.h"
#include "chrome/browser/extensions/api/storage/settings_sync_util.h"
#include "chrome/browser/extensions/api/storage/sync_storage_backend.h"
#include "chrome/browser/extensions/api/storage/sync_value_store_cache.h"
#include "chrome/browser/extensions/api/storage/syncable_settings_storage.h"
#include "chrome/test/base/testing_profile.h"
#include "components/sync/model/sync_change_processor.h"
#include "components/sync/test/sync_change_processor_wrapper_for_test.h"
#include "components/value_store/test_value_store_factory.h"
#include "components/value_store/testing_value_store.h"
#include "content/public/test/browser_task_environment.h"
#include "content/public/test/test_utils.h"
#include "extensions/browser/api/storage/backend_task_runner.h"
#include "extensions/browser/api/storage/settings_test_util.h"
#include "extensions/browser/api/storage/storage_frontend.h"
#include "extensions/browser/api/storage/value_store_util.h"
#include "extensions/browser/event_router.h"
#include "extensions/browser/event_router_factory.h"
#include "extensions/browser/extension_system.h"
#include "extensions/browser/mock_extension_system.h"
#include "extensions/common/extension_id.h"
#include "extensions/common/manifest.h"
#include "testing/gtest/include/gtest/gtest.h"

ValueStore;

namespace extensions {

namespace {

// To save typing ValueStore::DEFAULTS everywhere.
const ValueStore::WriteOptions DEFAULTS =;

// More saving typing. Maps extension IDs to a list of sync changes for that
// extension.
SettingSyncDataMultimap;

// Gets the pretty-printed JSON for a value.
static std::string GetJson(const base::Value& value) {}

// Returns whether two Values are equal.
testing::AssertionResult ValuesEq(
    const char* _1, const char* _2,
    const base::Value* expected,
    const base::Value* actual) {}

// Returns whether the result of a storage operation is an expected value.
// Logs when different.
testing::AssertionResult SettingsEq(const char* _1,
                                    const char* _2,
                                    const base::Value::Dict& expected,
                                    ValueStore::ReadResult actual) {}

// SyncChangeProcessor which just records the changes made, accessed after
// being converted to the more useful SettingSyncData via changes().
class MockSyncChangeProcessor : public syncer::SyncChangeProcessor {};

std::unique_ptr<KeyedService> MockExtensionSystemFactoryFunction(
    content::BrowserContext* context) {}

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

}  // namespace

class ExtensionSettingsSyncTest : public testing::Test {};

// Get a semblance of coverage for both EXTENSION_SETTINGS and APP_SETTINGS
// sync by roughly alternative which one to test.

TEST_F(ExtensionSettingsSyncTest, NoDataDoesNotInvokeSync) {}

TEST_F(ExtensionSettingsSyncTest, InSyncDataDoesNotInvokeSync) {}

TEST_F(ExtensionSettingsSyncTest, LocalDataWithNoSyncDataIsPushedToSync) {}

TEST_F(ExtensionSettingsSyncTest, AnySyncDataOverwritesLocalData) {}

TEST_F(ExtensionSettingsSyncTest, ProcessSyncChanges) {}

TEST_F(ExtensionSettingsSyncTest, PushToSync) {}

TEST_F(ExtensionSettingsSyncTest, ExtensionAndAppSettingsSyncSeparately) {}

TEST_F(ExtensionSettingsSyncTest, FailingStartSyncingDisablesSync) {}

TEST_F(ExtensionSettingsSyncTest, FailingProcessChangesDisablesSync) {}

TEST_F(ExtensionSettingsSyncTest, FailingGetAllSyncDataDoesntStopSync) {}

TEST_F(ExtensionSettingsSyncTest, FailureToReadChangesToPushDisablesSync) {}

TEST_F(ExtensionSettingsSyncTest, FailureToPushLocalStateDisablesSync) {}

TEST_F(ExtensionSettingsSyncTest, FailureToPushLocalChangeDisablesSync) {}

TEST_F(ExtensionSettingsSyncTest,
       LargeOutgoingChangeRejectedButIncomingAccepted) {}

TEST_F(ExtensionSettingsSyncTest, Dots) {}

// In other (frontend) tests, we assume that the result of GetStorage
// is a pointer to the a Storage owned by a Frontend object, but for
// the unlimitedStorage case, this might not be true. So, write the
// tests in a "callback" style.  We should really rewrite all tests to
// be asynchronous in this way.

namespace {

static void UnlimitedSyncStorageTestCallback(ValueStore* sync_storage) {}

static void UnlimitedLocalStorageTestCallback(ValueStore* local_storage) {}

}  // namespace

TEST_F(ExtensionSettingsSyncTest, UnlimitedStorageForLocalButNotSync) {}

}  // namespace extensions