| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/bind.h" | 5 #include "base/bind.h" |
| 6 #include "chrome/browser/sync/test/integration/bookmarks_helper.h" | 6 #include "chrome/browser/sync/test/integration/bookmarks_helper.h" |
| 7 #include "chrome/browser/sync/test/integration/profile_sync_service_harness.h" | 7 #include "chrome/browser/sync/test/integration/profile_sync_service_harness.h" |
| 8 #include "chrome/browser/sync/test/integration/retry_verifier.h" | 8 #include "chrome/browser/sync/test/integration/retry_verifier.h" |
| 9 #include "chrome/browser/sync/test/integration/status_change_checker.h" | 9 #include "chrome/browser/sync/test/integration/status_change_checker.h" |
| 10 #include "chrome/browser/sync/test/integration/sync_test.h" | 10 #include "chrome/browser/sync/test/integration/sync_test.h" |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 55 RetryVerifier retry_verifier_; | 55 RetryVerifier retry_verifier_; |
| 56 | 56 |
| 57 DISALLOW_COPY_AND_ASSIGN(ExponentialBackoffChecker); | 57 DISALLOW_COPY_AND_ASSIGN(ExponentialBackoffChecker); |
| 58 }; | 58 }; |
| 59 | 59 |
| 60 IN_PROC_BROWSER_TEST_F(SyncExponentialBackoffTest, OfflineToOnline) { | 60 IN_PROC_BROWSER_TEST_F(SyncExponentialBackoffTest, OfflineToOnline) { |
| 61 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; | 61 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; |
| 62 | 62 |
| 63 // Add an item and ensure that sync is successful. | 63 // Add an item and ensure that sync is successful. |
| 64 ASSERT_TRUE(AddFolder(0, 0, L"folder1")); | 64 ASSERT_TRUE(AddFolder(0, 0, L"folder1")); |
| 65 ASSERT_TRUE(GetClient(0)->AwaitFullSyncCompletion()); | 65 ASSERT_TRUE(GetClient(0)->AwaitCommitActivityCompletion()); |
| 66 | 66 |
| 67 // Trigger a network error at the client side. | 67 // Trigger a network error at the client side. |
| 68 DisableNetwork(GetProfile(0)); | 68 DisableNetwork(GetProfile(0)); |
| 69 | 69 |
| 70 // Add a new item to trigger another sync cycle. | 70 // Add a new item to trigger another sync cycle. |
| 71 ASSERT_TRUE(AddFolder(0, 0, L"folder2")); | 71 ASSERT_TRUE(AddFolder(0, 0, L"folder2")); |
| 72 | 72 |
| 73 // Verify that the client goes into exponential backoff while it is unable to | 73 // Verify that the client goes into exponential backoff while it is unable to |
| 74 // reach the sync server. | 74 // reach the sync server. |
| 75 ExponentialBackoffChecker exponential_backoff_checker(GetClient(0)); | 75 ExponentialBackoffChecker exponential_backoff_checker(GetClient(0)); |
| 76 ASSERT_TRUE(GetClient(0)->AwaitStatusChange(&exponential_backoff_checker, | 76 ASSERT_TRUE(GetClient(0)->AwaitStatusChange(&exponential_backoff_checker, |
| 77 "Checking exponential backoff")); | 77 "Checking exponential backoff")); |
| 78 | 78 |
| 79 // Recover from the network error. | 79 // Recover from the network error. |
| 80 EnableNetwork(GetProfile(0)); | 80 EnableNetwork(GetProfile(0)); |
| 81 | 81 |
| 82 // Verify that sync was able to recover. | 82 // Verify that sync was able to recover. |
| 83 ASSERT_TRUE(GetClient(0)->AwaitFullSyncCompletion()); | 83 ASSERT_TRUE(GetClient(0)->AwaitCommitActivityCompletion()); |
| 84 ASSERT_TRUE(ModelMatchesVerifier(0)); | 84 ASSERT_TRUE(ModelMatchesVerifier(0)); |
| 85 } | 85 } |
| 86 | 86 |
| 87 IN_PROC_BROWSER_TEST_F(SyncExponentialBackoffTest, TransientErrorTest) { | 87 IN_PROC_BROWSER_TEST_F(SyncExponentialBackoffTest, TransientErrorTest) { |
| 88 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; | 88 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; |
| 89 | 89 |
| 90 // Add an item and ensure that sync is successful. | 90 // Add an item and ensure that sync is successful. |
| 91 ASSERT_TRUE(AddFolder(0, 0, L"folder1")); | 91 ASSERT_TRUE(AddFolder(0, 0, L"folder1")); |
| 92 ASSERT_TRUE(GetClient(0)->AwaitFullSyncCompletion()); | 92 ASSERT_TRUE(GetClient(0)->AwaitCommitActivityCompletion()); |
| 93 | 93 |
| 94 // Trigger a transient error on the server. | 94 // Trigger a transient error on the server. |
| 95 TriggerTransientError(); | 95 TriggerTransientError(); |
| 96 | 96 |
| 97 // Add a new item to trigger another sync cycle. | 97 // Add a new item to trigger another sync cycle. |
| 98 ASSERT_TRUE(AddFolder(0, 0, L"folder2")); | 98 ASSERT_TRUE(AddFolder(0, 0, L"folder2")); |
| 99 | 99 |
| 100 // Verify that the client goes into exponential backoff while it is unable to | 100 // Verify that the client goes into exponential backoff while it is unable to |
| 101 // reach the sync server. | 101 // reach the sync server. |
| 102 ExponentialBackoffChecker exponential_backoff_checker(GetClient(0)); | 102 ExponentialBackoffChecker exponential_backoff_checker(GetClient(0)); |
| 103 ASSERT_TRUE(GetClient(0)->AwaitStatusChange(&exponential_backoff_checker, | 103 ASSERT_TRUE(GetClient(0)->AwaitStatusChange(&exponential_backoff_checker, |
| 104 "Checking exponential backoff")); | 104 "Checking exponential backoff")); |
| 105 } | 105 } |
| 106 | 106 |
| 107 } // namespace | 107 } // namespace |
| OLD | NEW |