Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(68)

Side by Side Diff: chrome/browser/sync/test/integration/single_client_extensions_sync_test.cc

Issue 1664643003: Change sync conflict resolution for extensions (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: moved entry type check lower down in ProcessSimpleConflict Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | sync/engine/conflict_resolver.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/macros.h" 5 #include "base/macros.h"
6 #include "chrome/browser/sync/test/integration/await_match_status_change_checker .h"
6 #include "chrome/browser/sync/test/integration/extensions_helper.h" 7 #include "chrome/browser/sync/test/integration/extensions_helper.h"
7 #include "chrome/browser/sync/test/integration/sync_integration_test_util.h" 8 #include "chrome/browser/sync/test/integration/sync_integration_test_util.h"
8 #include "chrome/browser/sync/test/integration/sync_test.h" 9 #include "chrome/browser/sync/test/integration/sync_test.h"
9 #include "components/browser_sync/browser/profile_sync_service.h" 10 #include "components/browser_sync/browser/profile_sync_service.h"
11 #include "sync/test/fake_server/tombstone_entity.h"
10 12
11 using extensions_helper::AllProfilesHaveSameExtensionsAsVerifier; 13 using extensions_helper::AllProfilesHaveSameExtensionsAsVerifier;
14 using extensions_helper::DisableExtension;
15 using extensions_helper::GetInstalledExtensions;
12 using extensions_helper::InstallExtension; 16 using extensions_helper::InstallExtension;
17 using extensions_helper::InstallExtensionForAllProfiles;
13 using sync_integration_test_util::AwaitCommitActivityCompletion; 18 using sync_integration_test_util::AwaitCommitActivityCompletion;
14 19
15 class SingleClientExtensionsSyncTest : public SyncTest { 20 class SingleClientExtensionsSyncTest : public SyncTest {
16 public: 21 public:
17 SingleClientExtensionsSyncTest() : SyncTest(SINGLE_CLIENT) {} 22 SingleClientExtensionsSyncTest() : SyncTest(SINGLE_CLIENT) {}
18 23
19 ~SingleClientExtensionsSyncTest() override {} 24 ~SingleClientExtensionsSyncTest() override {}
20 25
21 private: 26 private:
22 DISALLOW_COPY_AND_ASSIGN(SingleClientExtensionsSyncTest); 27 DISALLOW_COPY_AND_ASSIGN(SingleClientExtensionsSyncTest);
(...skipping 26 matching lines...) Expand all
49 const int kNumExtensions = 5; 54 const int kNumExtensions = 5;
50 for (int i = 0; i < kNumExtensions; ++i) { 55 for (int i = 0; i < kNumExtensions; ++i) {
51 InstallExtension(GetProfile(0), i); 56 InstallExtension(GetProfile(0), i);
52 InstallExtension(verifier(), i); 57 InstallExtension(verifier(), i);
53 } 58 }
54 59
55 ASSERT_TRUE(AwaitCommitActivityCompletion(GetSyncService((0)))); 60 ASSERT_TRUE(AwaitCommitActivityCompletion(GetSyncService((0))));
56 61
57 ASSERT_TRUE(AllProfilesHaveSameExtensionsAsVerifier()); 62 ASSERT_TRUE(AllProfilesHaveSameExtensionsAsVerifier());
58 } 63 }
64
65 // Helper function for waiting to see the extension count in a profile
66 // become a specific number.
67 static bool ExtensionCountCheck(Profile* profile, size_t expected_count) {
68 return GetInstalledExtensions(profile).size() == expected_count;
69 }
70
71 // Tests the case of an uninstall from the server conflicting with a local
72 // modification, which we expect to be resolved in favor of the uninstall.
73 IN_PROC_BROWSER_TEST_F(SingleClientExtensionsSyncTest, UninstallWinsConflicts) {
74 ASSERT_TRUE(SetupClients());
75
76 // Start with an extension installed, and setup sync.
77 InstallExtensionForAllProfiles(0);
78 ASSERT_TRUE(SetupSync());
79 EXPECT_TRUE(AllProfilesHaveSameExtensionsAsVerifier());
80
81 // Simulate a delete at the server.
82 std::vector<sync_pb::SyncEntity> server_extensions =
83 GetFakeServer()->GetSyncEntitiesByModelType(syncer::EXTENSIONS);
84 ASSERT_EQ(1ul, server_extensions.size());
85 std::string entity_id = server_extensions[0].id_string();
86 scoped_ptr<fake_server::FakeServerEntity> tombstone(
87 fake_server::TombstoneEntity::Create(entity_id));
88 GetFakeServer()->InjectEntity(std::move(tombstone));
89
90 // Modify the extension in the local profile to cause a conflict.
91 DisableExtension(GetProfile(0), 0);
92 EXPECT_EQ(1u, GetInstalledExtensions(GetProfile(0)).size());
93
94 // Trigger sync, and expect the extension to remain uninstalled at the server
95 // and get uninstalled locally.
96 const syncer::ModelTypeSet kExtensionsType(syncer::EXTENSIONS);
97 TriggerSyncForModelTypes(0, kExtensionsType);
98 server_extensions =
99 GetFakeServer()->GetSyncEntitiesByModelType(syncer::EXTENSIONS);
100 EXPECT_EQ(0ul, server_extensions.size());
101
102 AwaitMatchStatusChangeChecker checker(
103 base::Bind(&ExtensionCountCheck, GetProfile(0), 0u),
104 "Waiting for profile to have no extensions");
105 checker.Wait();
106 EXPECT_TRUE(!checker.TimedOut());
107 EXPECT_TRUE(GetInstalledExtensions(GetProfile(0)).empty());
108 }
OLDNEW
« no previous file with comments | « no previous file | sync/engine/conflict_resolver.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698