| 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 "chrome/browser/sync/profile_sync_service.h" | 5 #include "chrome/browser/sync/profile_sync_service.h" |
| 6 #include "chrome/browser/sync/profile_sync_service_harness.h" | 6 #include "chrome/browser/sync/profile_sync_service_harness.h" |
| 7 #include "chrome/browser/sync/protocol/sync_protocol_error.h" | 7 #include "chrome/browser/sync/protocol/sync_protocol_error.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/sync_test.h" | 9 #include "chrome/browser/sync/test/integration/sync_test.h" |
| 10 | 10 |
| 11 using bookmarks_helper::AddFolder; | 11 using bookmarks_helper::AddFolder; |
| 12 using bookmarks_helper::SetTitle; | 12 using bookmarks_helper::SetTitle; |
| 13 | 13 |
| 14 class SyncErrorTest : public SyncTest{ | 14 class SyncErrorTest : public SyncTest{ |
| 15 public: | 15 public: |
| 16 SyncErrorTest() : SyncTest(SINGLE_CLIENT) {} | 16 SyncErrorTest() : SyncTest(SINGLE_CLIENT) {} |
| 17 virtual ~SyncErrorTest() {} | 17 virtual ~SyncErrorTest() {} |
| 18 | 18 |
| 19 private: | 19 private: |
| 20 DISALLOW_COPY_AND_ASSIGN(SyncErrorTest); | 20 DISALLOW_COPY_AND_ASSIGN(SyncErrorTest); |
| 21 }; | 21 }; |
| 22 | 22 |
| 23 IN_PROC_BROWSER_TEST_F(SyncErrorTest, BirthdayErrorTest) { | 23 IN_PROC_BROWSER_TEST_F(SyncErrorTest, BirthdayErrorTest) { |
| 24 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; | 24 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; |
| 25 | 25 |
| 26 const BookmarkNode* node1 = AddFolder(0, 0, L"title1"); | 26 const BookmarkNode* node1 = AddFolder(0, 0, L"title1"); |
| 27 SetTitle(0, node1, L"new_title1"); | 27 SetTitle(0, node1, L"new_title1"); |
| 28 ASSERT_TRUE(GetClient(0)->AwaitSyncCycleCompletion("Offline state change.")); | 28 ASSERT_TRUE(GetClient(0)->AwaitFullSyncCompletion("Offline state change.")); |
| 29 TriggerBirthdayError(); | 29 TriggerBirthdayError(); |
| 30 | 30 |
| 31 // Now make one more change so we will do another sync. | 31 // Now make one more change so we will do another sync. |
| 32 const BookmarkNode* node2 = AddFolder(0, 0, L"title2"); | 32 const BookmarkNode* node2 = AddFolder(0, 0, L"title2"); |
| 33 SetTitle(0, node2, L"new_title2"); | 33 SetTitle(0, node2, L"new_title2"); |
| 34 ASSERT_TRUE(GetClient(0)->AwaitSyncDisabled("Birthday error.")); | 34 ASSERT_TRUE(GetClient(0)->AwaitSyncDisabled("Birthday error.")); |
| 35 } | 35 } |
| 36 | 36 |
| 37 IN_PROC_BROWSER_TEST_F(SyncErrorTest, TransientErrorTest) { | 37 IN_PROC_BROWSER_TEST_F(SyncErrorTest, TransientErrorTest) { |
| 38 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; | 38 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; |
| 39 | 39 |
| 40 const BookmarkNode* node1 = AddFolder(0, 0, L"title1"); | 40 const BookmarkNode* node1 = AddFolder(0, 0, L"title1"); |
| 41 SetTitle(0, node1, L"new_title1"); | 41 SetTitle(0, node1, L"new_title1"); |
| 42 ASSERT_TRUE(GetClient(0)->AwaitSyncCycleCompletion("Offline state change.")); | 42 ASSERT_TRUE(GetClient(0)->AwaitFullSyncCompletion("Offline state change.")); |
| 43 TriggerTransientError(); | 43 TriggerTransientError(); |
| 44 | 44 |
| 45 // Now make one more change so we will do another sync. | 45 // Now make one more change so we will do another sync. |
| 46 const BookmarkNode* node2 = AddFolder(0, 0, L"title2"); | 46 const BookmarkNode* node2 = AddFolder(0, 0, L"title2"); |
| 47 SetTitle(0, node2, L"new_title2"); | 47 SetTitle(0, node2, L"new_title2"); |
| 48 ASSERT_TRUE( | 48 ASSERT_TRUE( |
| 49 GetClient(0)->AwaitExponentialBackoffVerification()); | 49 GetClient(0)->AwaitExponentialBackoffVerification()); |
| 50 } | 50 } |
| 51 | 51 |
| 52 IN_PROC_BROWSER_TEST_F(SyncErrorTest, ActionableErrorTest) { | 52 IN_PROC_BROWSER_TEST_F(SyncErrorTest, ActionableErrorTest) { |
| 53 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; | 53 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; |
| 54 | 54 |
| 55 const BookmarkNode* node1 = AddFolder(0, 0, L"title1"); | 55 const BookmarkNode* node1 = AddFolder(0, 0, L"title1"); |
| 56 SetTitle(0, node1, L"new_title1"); | 56 SetTitle(0, node1, L"new_title1"); |
| 57 ASSERT_TRUE(GetClient(0)->AwaitSyncCycleCompletion("Sync.")); | 57 ASSERT_TRUE(GetClient(0)->AwaitFullSyncCompletion("Sync.")); |
| 58 | 58 |
| 59 browser_sync::SyncProtocolError protocol_error; | 59 browser_sync::SyncOperationResult protocol_error; |
| 60 protocol_error.error_type = browser_sync::TRANSIENT_ERROR; | 60 protocol_error.error_type = browser_sync::TRANSIENT_ERROR; |
| 61 protocol_error.action = browser_sync::UPGRADE_CLIENT; | 61 protocol_error.action = browser_sync::UPGRADE_CLIENT; |
| 62 protocol_error.error_description = "Not My Fault"; | 62 protocol_error.error_description = "Not My Fault"; |
| 63 protocol_error.url = "www.google.com"; | 63 protocol_error.url = "www.google.com"; |
| 64 TriggerSyncError(protocol_error); | 64 TriggerSyncError(protocol_error); |
| 65 | 65 |
| 66 // Now make one more change so we will do another sync. | 66 // Now make one more change so we will do another sync. |
| 67 const BookmarkNode* node2 = AddFolder(0, 0, L"title2"); | 67 const BookmarkNode* node2 = AddFolder(0, 0, L"title2"); |
| 68 SetTitle(0, node2, L"new_title2"); | 68 SetTitle(0, node2, L"new_title2"); |
| 69 ASSERT_TRUE( | 69 ASSERT_TRUE( |
| 70 GetClient(0)->AwaitActionableError()); | 70 GetClient(0)->AwaitActionableError()); |
| 71 ProfileSyncService::Status status = GetClient(0)->GetStatus(); | 71 ProfileSyncService::Status status = GetClient(0)->GetStatus(); |
| 72 ASSERT_EQ(status.sync_protocol_error.error_type, protocol_error.error_type); | 72 ASSERT_EQ(status.sync_protocol_error.error_type, protocol_error.error_type); |
| 73 ASSERT_EQ(status.sync_protocol_error.action, protocol_error.action); | 73 ASSERT_EQ(status.sync_protocol_error.action, protocol_error.action); |
| 74 ASSERT_EQ(status.sync_protocol_error.url, protocol_error.url); | 74 ASSERT_EQ(status.sync_protocol_error.url, protocol_error.url); |
| 75 ASSERT_EQ(status.sync_protocol_error.error_description, | 75 ASSERT_EQ(status.sync_protocol_error.error_description, |
| 76 protocol_error.error_description); | 76 protocol_error.error_description); |
| 77 } | 77 } |
| 78 | 78 |
| 79 IN_PROC_BROWSER_TEST_F(SyncErrorTest, | 79 IN_PROC_BROWSER_TEST_F(SyncErrorTest, |
| 80 BirthdayErrorUsingActionableErrorTest) { | 80 BirthdayErrorUsingActionableErrorTest) { |
| 81 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; | 81 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; |
| 82 | 82 |
| 83 const BookmarkNode* node1 = AddFolder(0, 0, L"title1"); | 83 const BookmarkNode* node1 = AddFolder(0, 0, L"title1"); |
| 84 SetTitle(0, node1, L"new_title1"); | 84 SetTitle(0, node1, L"new_title1"); |
| 85 ASSERT_TRUE(GetClient(0)->AwaitSyncCycleCompletion("Sync.")); | 85 ASSERT_TRUE(GetClient(0)->AwaitFullSyncCompletion("Sync.")); |
| 86 | 86 |
| 87 browser_sync::SyncProtocolError protocol_error; | 87 browser_sync::SyncOperationResult protocol_error; |
| 88 protocol_error.error_type = browser_sync::NOT_MY_BIRTHDAY; | 88 protocol_error.error_type = browser_sync::NOT_MY_BIRTHDAY; |
| 89 protocol_error.action = browser_sync::DISABLE_SYNC_ON_CLIENT; | 89 protocol_error.action = browser_sync::DISABLE_SYNC_ON_CLIENT; |
| 90 protocol_error.error_description = "Not My Fault"; | 90 protocol_error.error_description = "Not My Fault"; |
| 91 protocol_error.url = "www.google.com"; | 91 protocol_error.url = "www.google.com"; |
| 92 TriggerSyncError(protocol_error); | 92 TriggerSyncError(protocol_error); |
| 93 | 93 |
| 94 // Now make one more change so we will do another sync. | 94 // Now make one more change so we will do another sync. |
| 95 const BookmarkNode* node2 = AddFolder(0, 0, L"title2"); | 95 const BookmarkNode* node2 = AddFolder(0, 0, L"title2"); |
| 96 SetTitle(0, node2, L"new_title2"); | 96 SetTitle(0, node2, L"new_title2"); |
| 97 ASSERT_TRUE( | 97 ASSERT_TRUE( |
| 98 GetClient(0)->AwaitSyncDisabled("Birthday Error.")); | 98 GetClient(0)->AwaitSyncDisabled("Birthday Error.")); |
| 99 ProfileSyncService::Status status = GetClient(0)->GetStatus(); | 99 ProfileSyncService::Status status = GetClient(0)->GetStatus(); |
| 100 ASSERT_EQ(status.sync_protocol_error.error_type, protocol_error.error_type); | 100 ASSERT_EQ(status.sync_protocol_error.error_type, protocol_error.error_type); |
| 101 ASSERT_EQ(status.sync_protocol_error.action, protocol_error.action); | 101 ASSERT_EQ(status.sync_protocol_error.action, protocol_error.action); |
| 102 ASSERT_EQ(status.sync_protocol_error.url, protocol_error.url); | 102 ASSERT_EQ(status.sync_protocol_error.url, protocol_error.url); |
| 103 ASSERT_EQ(status.sync_protocol_error.error_description, | 103 ASSERT_EQ(status.sync_protocol_error.error_description, |
| 104 protocol_error.error_description); | 104 protocol_error.error_description); |
| 105 } | 105 } |
| OLD | NEW |