| 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" |
| 11 #include "chrome/browser/sync/test/integration/profile_sync_service_harness.h" | 11 #include "chrome/browser/sync/test/integration/profile_sync_service_harness.h" |
| 12 #include "chrome/browser/sync/test/integration/single_client_status_change_check
er.h" | 12 #include "chrome/browser/sync/test/integration/single_client_status_change_check
er.h" |
| 13 #include "chrome/browser/sync/test/integration/sync_integration_test_util.h" | 13 #include "chrome/browser/sync/test/integration/sync_integration_test_util.h" |
| 14 #include "chrome/browser/sync/test/integration/sync_test.h" | 14 #include "chrome/browser/sync/test/integration/sync_test.h" |
| 15 #include "chrome/common/pref_names.h" | 15 #include "chrome/common/pref_names.h" |
| 16 #include "google_apis/gaia/google_service_auth_error.h" | 16 #include "google_apis/gaia/google_service_auth_error.h" |
| 17 #include "sync/protocol/sync_protocol_error.h" | 17 #include "sync/protocol/sync_protocol_error.h" |
| 18 | 18 |
| 19 using bookmarks_helper::AddFolder; | 19 using bookmarks_helper::AddFolder; |
| 20 using bookmarks_helper::SetTitle; | 20 using bookmarks_helper::SetTitle; |
| 21 using sync_integration_test_util::AwaitCommitActivityCompletion; | 21 using sync_integration_test_util::AwaitCommitActivityCompletion; |
| 22 | 22 |
| 23 namespace { | 23 namespace { |
| 24 | 24 |
| 25 class SyncDisabledChecker : public SingleClientStatusChangeChecker { | 25 class SyncDisabledChecker : public SingleClientStatusChangeChecker { |
| 26 public: | 26 public: |
| 27 explicit SyncDisabledChecker(ProfileSyncService* service) | 27 explicit SyncDisabledChecker(ProfileSyncService* service) |
| 28 : SingleClientStatusChangeChecker(service) {} | 28 : SingleClientStatusChangeChecker(service) {} |
| 29 | 29 |
| 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 { | 40 class TypeDisabledChecker : public SingleClientStatusChangeChecker { |
| 41 public: | 41 public: |
| 42 explicit TypeDisabledChecker(ProfileSyncService* service, | 42 explicit TypeDisabledChecker(ProfileSyncService* service, |
| 43 syncer::ModelType type) | 43 syncer::ModelType type) |
| 44 : SingleClientStatusChangeChecker(service), type_(type) {} | 44 : SingleClientStatusChangeChecker(service), type_(type) {} |
| 45 | 45 |
| 46 virtual bool IsExitConditionSatisfied() OVERRIDE { | 46 virtual bool IsExitConditionSatisfied() override { |
| 47 return !service()->GetActiveDataTypes().Has(type_); | 47 return !service()->GetActiveDataTypes().Has(type_); |
| 48 } | 48 } |
| 49 | 49 |
| 50 virtual std::string GetDebugMessage() const OVERRIDE { | 50 virtual std::string GetDebugMessage() const override { |
| 51 return "Type disabled"; | 51 return "Type disabled"; |
| 52 } | 52 } |
| 53 private: | 53 private: |
| 54 syncer::ModelType type_; | 54 syncer::ModelType type_; |
| 55 }; | 55 }; |
| 56 | 56 |
| 57 bool AwaitSyncDisabled(ProfileSyncService* service) { | 57 bool AwaitSyncDisabled(ProfileSyncService* service) { |
| 58 SyncDisabledChecker checker(service); | 58 SyncDisabledChecker checker(service); |
| 59 checker.Wait(); | 59 checker.Wait(); |
| 60 return !checker.TimedOut(); | 60 return !checker.TimedOut(); |
| (...skipping 29 matching lines...) Expand all Loading... |
| 90 // Helper class that waits until the sync engine has hit an actionable error. | 90 // Helper class that waits until the sync engine has hit an actionable error. |
| 91 class ActionableErrorChecker : public SingleClientStatusChangeChecker { | 91 class ActionableErrorChecker : public SingleClientStatusChangeChecker { |
| 92 public: | 92 public: |
| 93 explicit ActionableErrorChecker(ProfileSyncService* service) | 93 explicit ActionableErrorChecker(ProfileSyncService* service) |
| 94 : SingleClientStatusChangeChecker(service) {} | 94 : SingleClientStatusChangeChecker(service) {} |
| 95 | 95 |
| 96 virtual ~ActionableErrorChecker() {} | 96 virtual ~ActionableErrorChecker() {} |
| 97 | 97 |
| 98 // Checks if an actionable error has been hit. Called repeatedly each time PSS | 98 // Checks if an actionable error has been hit. Called repeatedly each time PSS |
| 99 // notifies observers of a state change. | 99 // notifies observers of a state change. |
| 100 virtual bool IsExitConditionSatisfied() OVERRIDE { | 100 virtual bool IsExitConditionSatisfied() override { |
| 101 ProfileSyncService::Status status; | 101 ProfileSyncService::Status status; |
| 102 service()->QueryDetailedSyncStatus(&status); | 102 service()->QueryDetailedSyncStatus(&status); |
| 103 return (status.sync_protocol_error.action != syncer::UNKNOWN_ACTION && | 103 return (status.sync_protocol_error.action != syncer::UNKNOWN_ACTION && |
| 104 service()->HasUnrecoverableError()); | 104 service()->HasUnrecoverableError()); |
| 105 } | 105 } |
| 106 | 106 |
| 107 virtual std::string GetDebugMessage() const OVERRIDE { | 107 virtual std::string GetDebugMessage() const override { |
| 108 return "ActionableErrorChecker"; | 108 return "ActionableErrorChecker"; |
| 109 } | 109 } |
| 110 | 110 |
| 111 private: | 111 private: |
| 112 DISALLOW_COPY_AND_ASSIGN(ActionableErrorChecker); | 112 DISALLOW_COPY_AND_ASSIGN(ActionableErrorChecker); |
| 113 }; | 113 }; |
| 114 | 114 |
| 115 IN_PROC_BROWSER_TEST_F(SyncErrorTest, BirthdayErrorTest) { | 115 IN_PROC_BROWSER_TEST_F(SyncErrorTest, BirthdayErrorTest) { |
| 116 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; | 116 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; |
| 117 | 117 |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 231 ASSERT_TRUE(AwaitTypeDisabled(GetSyncService(0), syncer::TYPED_URLS)); | 231 ASSERT_TRUE(AwaitTypeDisabled(GetSyncService(0), syncer::TYPED_URLS)); |
| 232 ASSERT_TRUE(AwaitTypeDisabled(GetSyncService(0), syncer::SESSIONS)); | 232 ASSERT_TRUE(AwaitTypeDisabled(GetSyncService(0), syncer::SESSIONS)); |
| 233 | 233 |
| 234 const BookmarkNode* node1 = AddFolder(0, 0, "title1"); | 234 const BookmarkNode* node1 = AddFolder(0, 0, "title1"); |
| 235 SetTitle(0, node1, "new_title1"); | 235 SetTitle(0, node1, "new_title1"); |
| 236 ASSERT_TRUE(AwaitCommitActivityCompletion(GetSyncService((0)))); | 236 ASSERT_TRUE(AwaitCommitActivityCompletion(GetSyncService((0)))); |
| 237 // TODO(lipalani)" Verify initial sync ended for typed url is false. | 237 // TODO(lipalani)" Verify initial sync ended for typed url is false. |
| 238 } | 238 } |
| 239 | 239 |
| 240 } // namespace | 240 } // namespace |
| OLD | NEW |