chromium/chrome/browser/extensions/extension_service_sync_unittest.cc

// Copyright 2015 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 <stddef.h>

#include <map>
#include <memory>
#include <string>
#include <utility>

#include "base/command_line.h"
#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/memory/raw_ref.h"
#include "base/memory/weak_ptr.h"
#include "chrome/browser/extensions/chrome_test_extension_loader.h"
#include "chrome/browser/extensions/component_loader.h"
#include "chrome/browser/extensions/extension_service.h"
#include "chrome/browser/extensions/extension_service_test_with_install.h"
#include "chrome/browser/extensions/extension_sync_data.h"
#include "chrome/browser/extensions/extension_sync_service.h"
#include "chrome/browser/extensions/extension_util.h"
#include "chrome/browser/extensions/test_blocklist.h"
#include "chrome/browser/extensions/updater/extension_updater.h"
#include "chrome/browser/profiles/profile_key.h"
#include "chrome/browser/themes/test/theme_service_changed_waiter.h"
#include "chrome/browser/themes/theme_service.h"
#include "chrome/browser/themes/theme_service_factory.h"
#include "chrome/common/chrome_constants.h"
#include "chrome/common/extensions/extension_test_util.h"
#include "chrome/common/extensions/sync_helper.h"
#include "chrome/test/base/testing_profile.h"
#include "components/crx_file/id_util.h"
#include "components/sync/model/sync_data.h"
#include "components/sync/protocol/app_specifics.pb.h"
#include "components/sync/protocol/entity_specifics.pb.h"
#include "components/sync/protocol/extension_specifics.pb.h"
#include "components/sync/test/fake_sync_change_processor.h"
#include "components/sync/test/sync_change_processor_wrapper_for_test.h"
#include "components/variations/variations_associated_data.h"
#include "content/public/browser/browser_context.h"
#include "content/public/browser/storage_partition.h"
#include "extensions/browser/app_sorting.h"
#include "extensions/browser/disable_reason.h"
#include "extensions/browser/extension_prefs.h"
#include "extensions/browser/extension_registry.h"
#include "extensions/browser/extension_system.h"
#include "extensions/browser/extension_util.h"
#include "extensions/browser/management_policy.h"
#include "extensions/common/extension_builder.h"
#include "extensions/common/extension_urls.h"
#include "extensions/common/manifest_url_handlers.h"
#include "extensions/common/mojom/manifest.mojom-shared.h"
#include "extensions/common/permissions/permission_set.h"

AppSorting;
Extension;
ExtensionPrefs;
ExtensionRegistry;
ExtensionSyncData;
ExtensionSystem;
Manifest;
PermissionSet;
ManifestLocation;
SyncChange;
SyncChangeList;
Mock;

namespace {

const char good0[] =;
const char good2[] =;
const char good_crx[] =;
const char page_action[] =;
const char theme2_crx[] =;

ExtensionSyncData GetDisableSyncData(const Extension& extension,
                                     int disable_reasons) {}

ExtensionSyncData GetEnableSyncData(const Extension& extension) {}

SyncChangeList MakeSyncChangeList(const std::string& id,
                                  const sync_pb::EntitySpecifics& specifics,
                                  SyncChange::SyncChangeType change_type) {}

// This is a FakeSyncChangeProcessor specialization that maintains a store of
// SyncData items in the superclass' data_ member variable, treating it like a
// map keyed by the extension id from the SyncData. Each instance of this class
// should only be used for one data type (which should be either extensions or
// apps) to match how the real sync system handles things.
class StatefulChangeProcessor : public syncer::FakeSyncChangeProcessor {};

}  // namespace

class ExtensionServiceSyncTest
    : public extensions::ExtensionServiceTestWithInstall {};

TEST_F(ExtensionServiceSyncTest, DeferredSyncStartupPreInstalledComponent) {}

TEST_F(ExtensionServiceSyncTest, DeferredSyncStartupPreInstalledNormal) {}

TEST_F(ExtensionServiceSyncTest, DeferredSyncStartupOnInstall) {}

TEST_F(ExtensionServiceSyncTest, DisableExtensionFromSync) {}

// Test that sync can enable and disable installed extensions.
TEST_F(ExtensionServiceSyncTest, ReenableDisabledExtensionFromSync) {}

// Tests that default-installed extensions won't be affected by incoming sync
// data. (It's feasible to have a sync entry for an extension that could be
// default installed, since one installation may be default-installed while
// another may not be).
TEST_F(ExtensionServiceSyncTest,
       DefaultInstalledExtensionsAreNotReenabledOrDisabledBySync) {}

TEST_F(ExtensionServiceSyncTest, IgnoreSyncChangesWhenLocalStateIsMoreRecent) {}

TEST_F(ExtensionServiceSyncTest, DontSelfNotify) {}

TEST_F(ExtensionServiceSyncTest, GetSyncData) {}

TEST_F(ExtensionServiceSyncTest, GetSyncDataDisableReasons) {}

TEST_F(ExtensionServiceSyncTest, GetSyncDataTerminated) {}

TEST_F(ExtensionServiceSyncTest, GetSyncDataFilter) {}

TEST_F(ExtensionServiceSyncTest, GetSyncExtensionDataUserSettings) {}

TEST_F(ExtensionServiceSyncTest, SyncForUninstalledExternalExtension) {}

TEST_F(ExtensionServiceSyncTest, GetSyncAppDataUserSettings) {}

// TODO (rdevlin.cronin): The OnExtensionMoved() method has been removed from
// ExtensionService, so this test probably needs a new home. Unfortunately, it
// relies pretty heavily on things like InitializeExtension[Sync]Service() and
// PackAndInstallCRX(). When we clean up a bit more, this should move out.
TEST_F(ExtensionServiceSyncTest, GetSyncAppDataUserSettingsOnExtensionMoved) {}

TEST_F(ExtensionServiceSyncTest, GetSyncDataList) {}

TEST_F(ExtensionServiceSyncTest, ProcessSyncDataUninstall) {}

TEST_F(ExtensionServiceSyncTest, ProcessSyncDataWrongType) {}

TEST_F(ExtensionServiceSyncTest, ProcessSyncDataSettings) {}

TEST_F(ExtensionServiceSyncTest, ProcessSyncDataNewExtension) {}

TEST_F(ExtensionServiceSyncTest, ProcessSyncDataTerminatedExtension) {}

TEST_F(ExtensionServiceSyncTest, ProcessSyncDataVersionCheck) {}

TEST_F(ExtensionServiceSyncTest, ProcessSyncDataNotInstalled) {}

TEST_F(ExtensionServiceSyncTest, ProcessSyncDataEnableDisable) {}

class ExtensionServiceSyncCustomGalleryTest : public ExtensionServiceSyncTest {};

TEST_F(ExtensionServiceSyncCustomGalleryTest, ProcessSyncDataDeferredEnable) {}

TEST_F(ExtensionServiceSyncCustomGalleryTest,
       ProcessSyncDataPermissionApproval) {}

// Regression test for crbug.com/558299
TEST_F(ExtensionServiceSyncTest, DontSyncThemes) {}

// Tests sync behavior in the case of an item that starts out as an app and gets
// updated to become an extension.
TEST_F(ExtensionServiceSyncTest, AppToExtension) {}

class BlocklistedExtensionSyncServiceTest : public ExtensionServiceSyncTest {};

// Test that sync cannot enable blocklisted extensions.
TEST_F(BlocklistedExtensionSyncServiceTest, SyncBlocklistedExtension) {}

// Test that some greylisted extensions can be enabled through sync.
TEST_F(BlocklistedExtensionSyncServiceTest, SyncAllowedGreylistedExtension) {}

// Test that blocklisted extension cannot be installed/synchronized.
TEST_F(BlocklistedExtensionSyncServiceTest, InstallBlocklistedExtension) {}