Chromium Code Reviews| 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 "chrome/browser/sync/profile_sync_service.h" | 7 #include "chrome/browser/sync/profile_sync_service.h" |
| 8 #include "chrome/browser/sync/test/integration/bookmarks_helper.h" | 8 #include "chrome/browser/sync/test/integration/bookmarks_helper.h" |
| 9 #include "chrome/browser/sync/test/integration/passwords_helper.h" | 9 #include "chrome/browser/sync/test/integration/passwords_helper.h" |
| 10 #include "chrome/browser/sync/test/integration/profile_sync_service_harness.h" | 10 #include "chrome/browser/sync/test/integration/profile_sync_service_harness.h" |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 25 virtual ~SyncErrorTest() {} | 25 virtual ~SyncErrorTest() {} |
| 26 | 26 |
| 27 private: | 27 private: |
| 28 DISALLOW_COPY_AND_ASSIGN(SyncErrorTest); | 28 DISALLOW_COPY_AND_ASSIGN(SyncErrorTest); |
| 29 }; | 29 }; |
| 30 | 30 |
| 31 // Helper class that waits until the sync engine has hit an actionable error. | 31 // Helper class that waits until the sync engine has hit an actionable error. |
| 32 class ActionableErrorChecker : public StatusChangeChecker { | 32 class ActionableErrorChecker : public StatusChangeChecker { |
| 33 public: | 33 public: |
| 34 explicit ActionableErrorChecker(ProfileSyncService* service) | 34 explicit ActionableErrorChecker(ProfileSyncService* service) |
| 35 : StatusChangeChecker("ActionableErrorChecker"), | 35 : service_(service) {} |
| 36 service_(service) {} | |
| 37 | 36 |
| 38 virtual ~ActionableErrorChecker() {} | 37 virtual ~ActionableErrorChecker() {} |
| 39 | 38 |
| 40 // Checks if an actionable error has been hit. Called repeatedly each time PSS | 39 // Checks if an actionable error has been hit. Called repeatedly each time PSS |
| 41 // notifies observers of a state change. | 40 // notifies observers of a state change. |
| 42 virtual bool IsExitConditionSatisfied() OVERRIDE { | 41 virtual bool IsExitConditionSatisfied() OVERRIDE { |
| 43 DCHECK(service_); | 42 DCHECK(service_); |
| 44 ProfileSyncService::Status status; | 43 ProfileSyncService::Status status; |
| 45 service_->QueryDetailedSyncStatus(&status); | 44 service_->QueryDetailedSyncStatus(&status); |
| 46 return (status.sync_protocol_error.action != syncer::UNKNOWN_ACTION && | 45 return (status.sync_protocol_error.action != syncer::UNKNOWN_ACTION && |
| 47 service_->HasUnrecoverableError()); | 46 service_->HasUnrecoverableError()); |
| 48 } | 47 } |
| 49 | 48 |
| 49 virtual std::string GetDebugMessage() const OVERRIDE { | |
| 50 return "ActionableErrorChecker"; | |
|
tim (not reviewing)
2014/02/18 19:25:44
uber nit - might be nice to try to stick to a simp
| |
| 51 } | |
| 52 | |
| 50 private: | 53 private: |
| 51 // The PSS instance that will eventually hit an actionable error. | 54 // The PSS instance that will eventually hit an actionable error. |
| 52 ProfileSyncService* service_; | 55 ProfileSyncService* service_; |
| 53 | 56 |
| 54 DISALLOW_COPY_AND_ASSIGN(ActionableErrorChecker); | 57 DISALLOW_COPY_AND_ASSIGN(ActionableErrorChecker); |
| 55 }; | 58 }; |
| 56 | 59 |
| 57 IN_PROC_BROWSER_TEST_F(SyncErrorTest, BirthdayErrorTest) { | 60 IN_PROC_BROWSER_TEST_F(SyncErrorTest, BirthdayErrorTest) { |
| 58 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; | 61 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; |
| 59 | 62 |
| (...skipping 22 matching lines...) Expand all Loading... | |
| 82 protocol_error.error_description = "Not My Fault"; | 85 protocol_error.error_description = "Not My Fault"; |
| 83 protocol_error.url = "www.google.com"; | 86 protocol_error.url = "www.google.com"; |
| 84 TriggerSyncError(protocol_error, SyncTest::ERROR_FREQUENCY_ALWAYS); | 87 TriggerSyncError(protocol_error, SyncTest::ERROR_FREQUENCY_ALWAYS); |
| 85 | 88 |
| 86 // Now make one more change so we will do another sync. | 89 // Now make one more change so we will do another sync. |
| 87 const BookmarkNode* node2 = AddFolder(0, 0, L"title2"); | 90 const BookmarkNode* node2 = AddFolder(0, 0, L"title2"); |
| 88 SetTitle(0, node2, L"new_title2"); | 91 SetTitle(0, node2, L"new_title2"); |
| 89 | 92 |
| 90 // Wait until an actionable error is encountered. | 93 // Wait until an actionable error is encountered. |
| 91 ActionableErrorChecker actionable_error_checker(GetClient(0)->service()); | 94 ActionableErrorChecker actionable_error_checker(GetClient(0)->service()); |
| 92 ASSERT_TRUE(GetClient(0)->AwaitStatusChange(&actionable_error_checker, | 95 ASSERT_TRUE(GetClient(0)->AwaitStatusChange(&actionable_error_checker)); |
| 93 "Awaiting actionable error")); | |
| 94 | 96 |
| 95 ProfileSyncService::Status status = GetClient(0)->GetStatus(); | 97 ProfileSyncService::Status status = GetClient(0)->GetStatus(); |
| 96 ASSERT_EQ(status.sync_protocol_error.error_type, protocol_error.error_type); | 98 ASSERT_EQ(status.sync_protocol_error.error_type, protocol_error.error_type); |
| 97 ASSERT_EQ(status.sync_protocol_error.action, protocol_error.action); | 99 ASSERT_EQ(status.sync_protocol_error.action, protocol_error.action); |
| 98 ASSERT_EQ(status.sync_protocol_error.url, protocol_error.url); | 100 ASSERT_EQ(status.sync_protocol_error.url, protocol_error.url); |
| 99 ASSERT_EQ(status.sync_protocol_error.error_description, | 101 ASSERT_EQ(status.sync_protocol_error.error_description, |
| 100 protocol_error.error_description); | 102 protocol_error.error_description); |
| 101 } | 103 } |
| 102 | 104 |
| 103 IN_PROC_BROWSER_TEST_F(SyncErrorTest, ErrorWhileSettingUp) { | 105 IN_PROC_BROWSER_TEST_F(SyncErrorTest, ErrorWhileSettingUp) { |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 169 synced_datatypes = GetClient(0)->service()->GetPreferredDataTypes(); | 171 synced_datatypes = GetClient(0)->service()->GetPreferredDataTypes(); |
| 170 ASSERT_FALSE(synced_datatypes.Has(syncer::TYPED_URLS)); | 172 ASSERT_FALSE(synced_datatypes.Has(syncer::TYPED_URLS)); |
| 171 | 173 |
| 172 const BookmarkNode* node1 = AddFolder(0, 0, L"title1"); | 174 const BookmarkNode* node1 = AddFolder(0, 0, L"title1"); |
| 173 SetTitle(0, node1, L"new_title1"); | 175 SetTitle(0, node1, L"new_title1"); |
| 174 ASSERT_TRUE(GetClient(0)->AwaitCommitActivityCompletion()); | 176 ASSERT_TRUE(GetClient(0)->AwaitCommitActivityCompletion()); |
| 175 // TODO(lipalani)" Verify initial sync ended for typed url is false. | 177 // TODO(lipalani)" Verify initial sync ended for typed url is false. |
| 176 } | 178 } |
| 177 | 179 |
| 178 } // namespace | 180 } // namespace |
| OLD | NEW |