OLD | NEW |
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/await_match_status_change_checker
.h" |
7 #include "chrome/browser/sync/test/integration/extensions_helper.h" | 7 #include "chrome/browser/sync/test/integration/extensions_helper.h" |
8 #include "chrome/browser/sync/test/integration/sync_integration_test_util.h" | |
9 #include "chrome/browser/sync/test/integration/sync_test.h" | 8 #include "chrome/browser/sync/test/integration/sync_test.h" |
| 9 #include "chrome/browser/sync/test/integration/updated_progress_marker_checker.h
" |
10 #include "components/browser_sync/profile_sync_service.h" | 10 #include "components/browser_sync/profile_sync_service.h" |
11 #include "components/sync/test/fake_server/tombstone_entity.h" | 11 #include "components/sync/test/fake_server/tombstone_entity.h" |
12 | 12 |
13 using extensions_helper::AllProfilesHaveSameExtensionsAsVerifier; | 13 using extensions_helper::AllProfilesHaveSameExtensionsAsVerifier; |
14 using extensions_helper::DisableExtension; | 14 using extensions_helper::DisableExtension; |
15 using extensions_helper::GetInstalledExtensions; | 15 using extensions_helper::GetInstalledExtensions; |
16 using extensions_helper::InstallExtension; | 16 using extensions_helper::InstallExtension; |
17 using extensions_helper::InstallExtensionForAllProfiles; | 17 using extensions_helper::InstallExtensionForAllProfiles; |
18 using sync_integration_test_util::AwaitCommitActivityCompletion; | |
19 | 18 |
20 class SingleClientExtensionsSyncTest : public SyncTest { | 19 class SingleClientExtensionsSyncTest : public SyncTest { |
21 public: | 20 public: |
22 SingleClientExtensionsSyncTest() : SyncTest(SINGLE_CLIENT) {} | 21 SingleClientExtensionsSyncTest() : SyncTest(SINGLE_CLIENT) {} |
23 | 22 |
24 ~SingleClientExtensionsSyncTest() override {} | 23 ~SingleClientExtensionsSyncTest() override {} |
25 | 24 |
26 private: | 25 private: |
27 DISALLOW_COPY_AND_ASSIGN(SingleClientExtensionsSyncTest); | 26 DISALLOW_COPY_AND_ASSIGN(SingleClientExtensionsSyncTest); |
28 }; | 27 }; |
29 | 28 |
30 IN_PROC_BROWSER_TEST_F(SingleClientExtensionsSyncTest, StartWithNoExtensions) { | 29 IN_PROC_BROWSER_TEST_F(SingleClientExtensionsSyncTest, StartWithNoExtensions) { |
31 ASSERT_TRUE(SetupSync()); | 30 ASSERT_TRUE(SetupSync()); |
32 | |
33 ASSERT_TRUE(AllProfilesHaveSameExtensionsAsVerifier()); | 31 ASSERT_TRUE(AllProfilesHaveSameExtensionsAsVerifier()); |
34 } | 32 } |
35 | 33 |
36 IN_PROC_BROWSER_TEST_F(SingleClientExtensionsSyncTest, | 34 IN_PROC_BROWSER_TEST_F(SingleClientExtensionsSyncTest, |
37 StartWithSomeExtensions) { | 35 StartWithSomeExtensions) { |
38 ASSERT_TRUE(SetupClients()); | 36 ASSERT_TRUE(SetupClients()); |
39 | 37 |
40 const int kNumExtensions = 5; | 38 const int kNumExtensions = 5; |
41 for (int i = 0; i < kNumExtensions; ++i) { | 39 for (int i = 0; i < kNumExtensions; ++i) { |
42 InstallExtension(GetProfile(0), i); | 40 InstallExtension(GetProfile(0), i); |
43 InstallExtension(verifier(), i); | 41 InstallExtension(verifier(), i); |
44 } | 42 } |
45 | 43 |
46 ASSERT_TRUE(SetupSync()); | 44 ASSERT_TRUE(SetupSync()); |
47 | |
48 ASSERT_TRUE(AllProfilesHaveSameExtensionsAsVerifier()); | 45 ASSERT_TRUE(AllProfilesHaveSameExtensionsAsVerifier()); |
49 } | 46 } |
50 | 47 |
51 IN_PROC_BROWSER_TEST_F(SingleClientExtensionsSyncTest, InstallSomeExtensions) { | 48 IN_PROC_BROWSER_TEST_F(SingleClientExtensionsSyncTest, InstallSomeExtensions) { |
52 ASSERT_TRUE(SetupSync()); | 49 ASSERT_TRUE(SetupSync()); |
53 | 50 |
54 const int kNumExtensions = 5; | 51 const int kNumExtensions = 5; |
55 for (int i = 0; i < kNumExtensions; ++i) { | 52 for (int i = 0; i < kNumExtensions; ++i) { |
56 InstallExtension(GetProfile(0), i); | 53 InstallExtension(GetProfile(0), i); |
57 InstallExtension(verifier(), i); | 54 InstallExtension(verifier(), i); |
58 } | 55 } |
59 | 56 |
60 ASSERT_TRUE(AwaitCommitActivityCompletion(GetSyncService(0))); | 57 ASSERT_TRUE(UpdatedProgressMarkerChecker(GetSyncService(0)).Wait()); |
61 | |
62 ASSERT_TRUE(AllProfilesHaveSameExtensionsAsVerifier()); | 58 ASSERT_TRUE(AllProfilesHaveSameExtensionsAsVerifier()); |
63 } | 59 } |
64 | 60 |
65 // Helper function for waiting to see the extension count in a profile | 61 // Helper function for waiting to see the extension count in a profile |
66 // become a specific number. | 62 // become a specific number. |
67 static bool ExtensionCountCheck(Profile* profile, size_t expected_count) { | 63 static bool ExtensionCountCheck(Profile* profile, size_t expected_count) { |
68 return GetInstalledExtensions(profile).size() == expected_count; | 64 return GetInstalledExtensions(profile).size() == expected_count; |
69 } | 65 } |
70 | 66 |
71 // Tests the case of an uninstall from the server conflicting with a local | 67 // Tests the case of an uninstall from the server conflicting with a local |
(...skipping 24 matching lines...) Expand all Loading... |
96 // and get uninstalled locally. | 92 // and get uninstalled locally. |
97 const syncer::ModelTypeSet kExtensionsType(syncer::EXTENSIONS); | 93 const syncer::ModelTypeSet kExtensionsType(syncer::EXTENSIONS); |
98 TriggerSyncForModelTypes(0, kExtensionsType); | 94 TriggerSyncForModelTypes(0, kExtensionsType); |
99 server_extensions = | 95 server_extensions = |
100 GetFakeServer()->GetSyncEntitiesByModelType(syncer::EXTENSIONS); | 96 GetFakeServer()->GetSyncEntitiesByModelType(syncer::EXTENSIONS); |
101 EXPECT_EQ(0ul, server_extensions.size()); | 97 EXPECT_EQ(0ul, server_extensions.size()); |
102 | 98 |
103 AwaitMatchStatusChangeChecker checker( | 99 AwaitMatchStatusChangeChecker checker( |
104 base::Bind(&ExtensionCountCheck, GetProfile(0), 0u), | 100 base::Bind(&ExtensionCountCheck, GetProfile(0), 0u), |
105 "Waiting for profile to have no extensions"); | 101 "Waiting for profile to have no extensions"); |
106 checker.Wait(); | 102 EXPECT_TRUE(checker.Wait()); |
107 EXPECT_TRUE(!checker.TimedOut()); | |
108 EXPECT_TRUE(GetInstalledExtensions(GetProfile(0)).empty()); | 103 EXPECT_TRUE(GetInstalledExtensions(GetProfile(0)).empty()); |
109 } | 104 } |
OLD | NEW |