OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/prefs/pref_member.h" | 5 #include "base/prefs/pref_member.h" |
6 #include "base/prefs/pref_service.h" | 6 #include "base/prefs/pref_service.h" |
7 #include "base/run_loop.h" | 7 #include "base/run_loop.h" |
8 #include "chrome/browser/sync/profile_sync_service.h" | 8 #include "chrome/browser/sync/profile_sync_service.h" |
9 #include "chrome/browser/sync/test/integration/bookmarks_helper.h" | 9 #include "chrome/browser/sync/test/integration/bookmarks_helper.h" |
10 #include "chrome/browser/sync/test/integration/passwords_helper.h" | 10 #include "chrome/browser/sync/test/integration/passwords_helper.h" |
(...skipping 19 matching lines...) Expand all Loading... |
30 virtual bool IsExitConditionSatisfied() OVERRIDE { | 30 virtual bool IsExitConditionSatisfied() OVERRIDE { |
31 return !service()->setup_in_progress() && | 31 return !service()->setup_in_progress() && |
32 !service()->HasSyncSetupCompleted(); | 32 !service()->HasSyncSetupCompleted(); |
33 } | 33 } |
34 | 34 |
35 virtual std::string GetDebugMessage() const OVERRIDE { | 35 virtual std::string GetDebugMessage() const OVERRIDE { |
36 return "Sync Disabled"; | 36 return "Sync Disabled"; |
37 } | 37 } |
38 }; | 38 }; |
39 | 39 |
| 40 class TypeDisabledChecker : public SingleClientStatusChangeChecker { |
| 41 public: |
| 42 explicit TypeDisabledChecker(ProfileSyncService* service, |
| 43 syncer::ModelType type) |
| 44 : SingleClientStatusChangeChecker(service), type_(type) {} |
| 45 |
| 46 virtual bool IsExitConditionSatisfied() OVERRIDE { |
| 47 return !service()->GetActiveDataTypes().Has(type_); |
| 48 } |
| 49 |
| 50 virtual std::string GetDebugMessage() const OVERRIDE { |
| 51 return "Type disabled"; |
| 52 } |
| 53 private: |
| 54 syncer::ModelType type_; |
| 55 }; |
| 56 |
40 bool AwaitSyncDisabled(ProfileSyncService* service) { | 57 bool AwaitSyncDisabled(ProfileSyncService* service) { |
41 SyncDisabledChecker checker(service); | 58 SyncDisabledChecker checker(service); |
42 checker.Wait(); | 59 checker.Wait(); |
43 return !checker.TimedOut(); | 60 return !checker.TimedOut(); |
44 } | 61 } |
45 | 62 |
| 63 bool AwaitTypeDisabled(ProfileSyncService* service, |
| 64 syncer::ModelType type) { |
| 65 TypeDisabledChecker checker(service, type); |
| 66 checker.Wait(); |
| 67 return !checker.TimedOut(); |
| 68 } |
| 69 |
46 class SyncErrorTest : public SyncTest { | 70 class SyncErrorTest : public SyncTest { |
47 public: | 71 public: |
48 SyncErrorTest() : SyncTest(SINGLE_CLIENT) {} | 72 SyncErrorTest() : SyncTest(SINGLE_CLIENT) {} |
49 virtual ~SyncErrorTest() {} | 73 virtual ~SyncErrorTest() {} |
50 | 74 |
51 private: | 75 private: |
52 DISALLOW_COPY_AND_ASSIGN(SyncErrorTest); | 76 DISALLOW_COPY_AND_ASSIGN(SyncErrorTest); |
53 }; | 77 }; |
54 | 78 |
55 // TODO(pvalenzuela): Remove this class when all tests here are converted to | 79 // TODO(pvalenzuela): Remove this class when all tests here are converted to |
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
196 | 220 |
197 IN_PROC_BROWSER_TEST_F(LegacySyncErrorTest, DisableDatatypeWhileRunning) { | 221 IN_PROC_BROWSER_TEST_F(LegacySyncErrorTest, DisableDatatypeWhileRunning) { |
198 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; | 222 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; |
199 syncer::ModelTypeSet synced_datatypes = | 223 syncer::ModelTypeSet synced_datatypes = |
200 GetSyncService((0))->GetActiveDataTypes(); | 224 GetSyncService((0))->GetActiveDataTypes(); |
201 ASSERT_TRUE(synced_datatypes.Has(syncer::TYPED_URLS)); | 225 ASSERT_TRUE(synced_datatypes.Has(syncer::TYPED_URLS)); |
202 ASSERT_TRUE(synced_datatypes.Has(syncer::SESSIONS)); | 226 ASSERT_TRUE(synced_datatypes.Has(syncer::SESSIONS)); |
203 GetProfile(0)->GetPrefs()->SetBoolean( | 227 GetProfile(0)->GetPrefs()->SetBoolean( |
204 prefs::kSavingBrowserHistoryDisabled, true); | 228 prefs::kSavingBrowserHistoryDisabled, true); |
205 | 229 |
206 // Flush any tasks posted by observers of the pref change. | 230 // Wait for reconfigurations. |
207 base::RunLoop().RunUntilIdle(); | 231 ASSERT_TRUE(AwaitTypeDisabled(GetSyncService(0), syncer::TYPED_URLS)); |
208 | 232 ASSERT_TRUE(AwaitTypeDisabled(GetSyncService(0), syncer::SESSIONS)); |
209 synced_datatypes = GetSyncService((0))->GetActiveDataTypes(); | |
210 ASSERT_FALSE(synced_datatypes.Has(syncer::TYPED_URLS)); | |
211 ASSERT_FALSE(synced_datatypes.Has(syncer::SESSIONS)); | |
212 | 233 |
213 const BookmarkNode* node1 = AddFolder(0, 0, "title1"); | 234 const BookmarkNode* node1 = AddFolder(0, 0, "title1"); |
214 SetTitle(0, node1, "new_title1"); | 235 SetTitle(0, node1, "new_title1"); |
215 ASSERT_TRUE(AwaitCommitActivityCompletion(GetSyncService((0)))); | 236 ASSERT_TRUE(AwaitCommitActivityCompletion(GetSyncService((0)))); |
216 // TODO(lipalani)" Verify initial sync ended for typed url is false. | 237 // TODO(lipalani)" Verify initial sync ended for typed url is false. |
217 } | 238 } |
218 | 239 |
219 } // namespace | 240 } // namespace |
OLD | NEW |