| 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" |
| 11 #include "chrome/browser/sync/test/integration/status_change_checker.h" | 11 #include "chrome/browser/sync/test/integration/single_client_status_change_check
er.h" |
| 12 #include "chrome/browser/sync/test/integration/sync_test.h" | 12 #include "chrome/browser/sync/test/integration/sync_test.h" |
| 13 #include "chrome/common/pref_names.h" | 13 #include "chrome/common/pref_names.h" |
| 14 #include "google_apis/gaia/google_service_auth_error.h" | 14 #include "google_apis/gaia/google_service_auth_error.h" |
| 15 #include "sync/protocol/sync_protocol_error.h" | 15 #include "sync/protocol/sync_protocol_error.h" |
| 16 | 16 |
| 17 using bookmarks_helper::AddFolder; | 17 using bookmarks_helper::AddFolder; |
| 18 using bookmarks_helper::SetTitle; | 18 using bookmarks_helper::SetTitle; |
| 19 | 19 |
| 20 namespace { | 20 namespace { |
| 21 | 21 |
| 22 class SyncErrorTest : public SyncTest { | 22 class SyncErrorTest : public SyncTest { |
| 23 public: | 23 public: |
| 24 SyncErrorTest() : SyncTest(SINGLE_CLIENT) {} | 24 SyncErrorTest() : SyncTest(SINGLE_CLIENT) {} |
| 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 SingleClientStatusChangeChecker { |
| 33 public: | 33 public: |
| 34 explicit ActionableErrorChecker(ProfileSyncService* service) | 34 explicit ActionableErrorChecker(ProfileSyncService* service) |
| 35 : StatusChangeChecker("ActionableErrorChecker"), | 35 : SingleClientStatusChangeChecker(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_); | |
| 44 ProfileSyncService::Status status; | 42 ProfileSyncService::Status status; |
| 45 service_->QueryDetailedSyncStatus(&status); | 43 service()->QueryDetailedSyncStatus(&status); |
| 46 return (status.sync_protocol_error.action != syncer::UNKNOWN_ACTION && | 44 return (status.sync_protocol_error.action != syncer::UNKNOWN_ACTION && |
| 47 service_->HasUnrecoverableError()); | 45 service()->HasUnrecoverableError()); |
| 46 } |
| 47 |
| 48 virtual std::string GetDebugMessage() const OVERRIDE { |
| 49 return "ActionableErrorChecker"; |
| 48 } | 50 } |
| 49 | 51 |
| 50 private: | 52 private: |
| 51 // The PSS instance that will eventually hit an actionable error. | |
| 52 ProfileSyncService* service_; | |
| 53 | |
| 54 DISALLOW_COPY_AND_ASSIGN(ActionableErrorChecker); | 53 DISALLOW_COPY_AND_ASSIGN(ActionableErrorChecker); |
| 55 }; | 54 }; |
| 56 | 55 |
| 57 IN_PROC_BROWSER_TEST_F(SyncErrorTest, BirthdayErrorTest) { | 56 IN_PROC_BROWSER_TEST_F(SyncErrorTest, BirthdayErrorTest) { |
| 58 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; | 57 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; |
| 59 | 58 |
| 60 // Add an item, wait for sync, and trigger a birthday error on the server. | 59 // Add an item, wait for sync, and trigger a birthday error on the server. |
| 61 const BookmarkNode* node1 = AddFolder(0, 0, L"title1"); | 60 const BookmarkNode* node1 = AddFolder(0, 0, L"title1"); |
| 62 SetTitle(0, node1, L"new_title1"); | 61 SetTitle(0, node1, L"new_title1"); |
| 63 ASSERT_TRUE(GetClient(0)->AwaitCommitActivityCompletion()); | 62 ASSERT_TRUE(GetClient(0)->AwaitCommitActivityCompletion()); |
| (...skipping 18 matching lines...) Expand all Loading... |
| 82 protocol_error.error_description = "Not My Fault"; | 81 protocol_error.error_description = "Not My Fault"; |
| 83 protocol_error.url = "www.google.com"; | 82 protocol_error.url = "www.google.com"; |
| 84 TriggerSyncError(protocol_error, SyncTest::ERROR_FREQUENCY_ALWAYS); | 83 TriggerSyncError(protocol_error, SyncTest::ERROR_FREQUENCY_ALWAYS); |
| 85 | 84 |
| 86 // Now make one more change so we will do another sync. | 85 // Now make one more change so we will do another sync. |
| 87 const BookmarkNode* node2 = AddFolder(0, 0, L"title2"); | 86 const BookmarkNode* node2 = AddFolder(0, 0, L"title2"); |
| 88 SetTitle(0, node2, L"new_title2"); | 87 SetTitle(0, node2, L"new_title2"); |
| 89 | 88 |
| 90 // Wait until an actionable error is encountered. | 89 // Wait until an actionable error is encountered. |
| 91 ActionableErrorChecker actionable_error_checker(GetClient(0)->service()); | 90 ActionableErrorChecker actionable_error_checker(GetClient(0)->service()); |
| 92 ASSERT_TRUE(GetClient(0)->AwaitStatusChange(&actionable_error_checker, | 91 ASSERT_TRUE(GetClient(0)->AwaitStatusChange(&actionable_error_checker)); |
| 93 "Awaiting actionable error")); | |
| 94 | 92 |
| 95 ProfileSyncService::Status status = GetClient(0)->GetStatus(); | 93 ProfileSyncService::Status status = GetClient(0)->GetStatus(); |
| 96 ASSERT_EQ(status.sync_protocol_error.error_type, protocol_error.error_type); | 94 ASSERT_EQ(status.sync_protocol_error.error_type, protocol_error.error_type); |
| 97 ASSERT_EQ(status.sync_protocol_error.action, protocol_error.action); | 95 ASSERT_EQ(status.sync_protocol_error.action, protocol_error.action); |
| 98 ASSERT_EQ(status.sync_protocol_error.url, protocol_error.url); | 96 ASSERT_EQ(status.sync_protocol_error.url, protocol_error.url); |
| 99 ASSERT_EQ(status.sync_protocol_error.error_description, | 97 ASSERT_EQ(status.sync_protocol_error.error_description, |
| 100 protocol_error.error_description); | 98 protocol_error.error_description); |
| 101 } | 99 } |
| 102 | 100 |
| 103 IN_PROC_BROWSER_TEST_F(SyncErrorTest, ErrorWhileSettingUp) { | 101 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(); | 167 synced_datatypes = GetClient(0)->service()->GetPreferredDataTypes(); |
| 170 ASSERT_FALSE(synced_datatypes.Has(syncer::TYPED_URLS)); | 168 ASSERT_FALSE(synced_datatypes.Has(syncer::TYPED_URLS)); |
| 171 | 169 |
| 172 const BookmarkNode* node1 = AddFolder(0, 0, L"title1"); | 170 const BookmarkNode* node1 = AddFolder(0, 0, L"title1"); |
| 173 SetTitle(0, node1, L"new_title1"); | 171 SetTitle(0, node1, L"new_title1"); |
| 174 ASSERT_TRUE(GetClient(0)->AwaitCommitActivityCompletion()); | 172 ASSERT_TRUE(GetClient(0)->AwaitCommitActivityCompletion()); |
| 175 // TODO(lipalani)" Verify initial sync ended for typed url is false. | 173 // TODO(lipalani)" Verify initial sync ended for typed url is false. |
| 176 } | 174 } |
| 177 | 175 |
| 178 } // namespace | 176 } // namespace |
| OLD | NEW |