| Index: chrome/browser/extensions/extension_service_unittest.cc
|
| diff --git a/chrome/browser/extensions/extension_service_unittest.cc b/chrome/browser/extensions/extension_service_unittest.cc
|
| index 0a4c7fa0d49631f886faaef9710f702817bf5ca1..aa263273161ec0f6c19230a5104673ebc62eabf4 100644
|
| --- a/chrome/browser/extensions/extension_service_unittest.cc
|
| +++ b/chrome/browser/extensions/extension_service_unittest.cc
|
| @@ -72,6 +72,7 @@
|
| #include "chrome/common/extensions/api/plugins/plugins_handler.h"
|
| #include "chrome/common/extensions/manifest_handlers/app_launch_info.h"
|
| #include "chrome/common/extensions/manifest_handlers/content_scripts_handler.h"
|
| +#include "chrome/common/extensions/sync_helper.h"
|
| #include "chrome/common/pref_names.h"
|
| #include "chrome/common/url_constants.h"
|
| #include "chrome/test/base/scoped_browser_locale.h"
|
| @@ -5921,8 +5922,8 @@ TEST_F(ExtensionServiceTest, DisableExtensionFromSync) {
|
| ASSERT_FALSE(service()->IsExtensionEnabled(good0));
|
| }
|
|
|
| -TEST_F(ExtensionServiceTest, DontDisableExtensionWithPendingEnableFromSync) {
|
| - // Start the extensions service with one external extension already installed.
|
| +TEST_F(ExtensionServiceTest, IgnoreSyncChangesWhenLocalStateIsMoreRecent) {
|
| + // Start the extension service with three extensions already installed.
|
| base::FilePath source_install_dir =
|
| data_dir().AppendASCII("good").AppendASCII("Extensions");
|
| base::FilePath pref_path =
|
| @@ -5940,34 +5941,44 @@ TEST_F(ExtensionServiceTest, DontDisableExtensionWithPendingEnableFromSync) {
|
| ASSERT_TRUE(service()->is_ready());
|
| ASSERT_EQ(3u, loaded_.size());
|
|
|
| - const Extension* extension = service()->GetExtensionById(good0, true);
|
| ASSERT_TRUE(service()->IsExtensionEnabled(good0));
|
| + ASSERT_TRUE(service()->IsExtensionEnabled(good2));
|
|
|
| - // Disable extension before first sync data arrives.
|
| + // Disable and re-enable good0 before first sync data arrives.
|
| service()->DisableExtension(good0, Extension::DISABLE_USER_ACTION);
|
| ASSERT_FALSE(service()->IsExtensionEnabled(good0));
|
| -
|
| - // Enable extension - this is now the most recent state.
|
| service()->EnableExtension(good0);
|
| ASSERT_TRUE(service()->IsExtensionEnabled(good0));
|
| -
|
| - // Now sync data comes in that says to disable good0. This should be
|
| - // ignored.
|
| - ExtensionSyncData disable_good_crx(*extension, false,
|
| - Extension::DISABLE_USER_ACTION, false,
|
| - false, ExtensionSyncData::BOOLEAN_UNSET);
|
| + // Disable good2 before first sync data arrives (good1 is considered
|
| + // non-syncable because it has plugin permission).
|
| + service()->DisableExtension(good2, Extension::DISABLE_USER_ACTION);
|
| + ASSERT_FALSE(service()->IsExtensionEnabled(good2));
|
| +
|
| + const Extension* extension0 = service()->GetExtensionById(good0, true);
|
| + const Extension* extension2 = service()->GetExtensionById(good2, true);
|
| + ASSERT_TRUE(extensions::sync_helper::IsSyncable(extension0));
|
| + ASSERT_TRUE(extensions::sync_helper::IsSyncable(extension2));
|
| +
|
| + // Now sync data comes in that says to disable good0 and enable good2.
|
| + ExtensionSyncData disable_good0(*extension0, false,
|
| + Extension::DISABLE_USER_ACTION, false, false,
|
| + ExtensionSyncData::BOOLEAN_UNSET);
|
| + ExtensionSyncData enable_good2(*extension2, true, Extension::DISABLE_NONE,
|
| + false, false,
|
| + ExtensionSyncData::BOOLEAN_UNSET);
|
| syncer::SyncDataList sync_data;
|
| - sync_data.push_back(disable_good_crx.GetSyncData());
|
| + sync_data.push_back(disable_good0.GetSyncData());
|
| + sync_data.push_back(enable_good2.GetSyncData());
|
| extension_sync_service()->MergeDataAndStartSyncing(
|
| syncer::EXTENSIONS,
|
| sync_data,
|
| - scoped_ptr<syncer::SyncChangeProcessor>(
|
| - new syncer::FakeSyncChangeProcessor),
|
| - scoped_ptr<syncer::SyncErrorFactory>(new syncer::SyncErrorFactoryMock()));
|
| + make_scoped_ptr(new syncer::FakeSyncChangeProcessor),
|
| + make_scoped_ptr(new syncer::SyncErrorFactoryMock));
|
|
|
| - // The extension was enabled locally before the sync data arrived, so it
|
| - // should still be enabled now.
|
| - ASSERT_TRUE(service()->IsExtensionEnabled(good0));
|
| + // Both sync changes should be ignored, since the local state was changed
|
| + // before sync started, and so the local state is considered more recent.
|
| + EXPECT_TRUE(service()->IsExtensionEnabled(good0));
|
| + EXPECT_FALSE(service()->IsExtensionEnabled(good2));
|
| }
|
|
|
| TEST_F(ExtensionServiceTest, GetSyncData) {
|
|
|