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 "base/strings/stringprintf.h" | 6 #include "base/strings/stringprintf.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/retry_verifier.h" | 9 #include "chrome/browser/sync/test/integration/retry_verifier.h" |
10 #include "chrome/browser/sync/test/integration/single_client_status_change_check
er.h" | 10 #include "chrome/browser/sync/test/integration/single_client_status_change_check
er.h" |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
60 // related bookkeeping information for verification. | 60 // related bookkeeping information for verification. |
61 RetryVerifier retry_verifier_; | 61 RetryVerifier retry_verifier_; |
62 | 62 |
63 DISALLOW_COPY_AND_ASSIGN(ExponentialBackoffChecker); | 63 DISALLOW_COPY_AND_ASSIGN(ExponentialBackoffChecker); |
64 }; | 64 }; |
65 | 65 |
66 IN_PROC_BROWSER_TEST_F(SyncExponentialBackoffTest, OfflineToOnline) { | 66 IN_PROC_BROWSER_TEST_F(SyncExponentialBackoffTest, OfflineToOnline) { |
67 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; | 67 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; |
68 | 68 |
69 // Add an item and ensure that sync is successful. | 69 // Add an item and ensure that sync is successful. |
70 ASSERT_TRUE(AddFolder(0, 0, L"folder1")); | 70 ASSERT_TRUE(AddFolder(0, 0, "folder1")); |
71 ASSERT_TRUE(AwaitCommitActivityCompletion(GetSyncService((0)))); | 71 ASSERT_TRUE(AwaitCommitActivityCompletion(GetSyncService((0)))); |
72 | 72 |
73 // Trigger a network error at the client side. | 73 // Trigger a network error at the client side. |
74 DisableNetwork(GetProfile(0)); | 74 DisableNetwork(GetProfile(0)); |
75 | 75 |
76 // Add a new item to trigger another sync cycle. | 76 // Add a new item to trigger another sync cycle. |
77 ASSERT_TRUE(AddFolder(0, 0, L"folder2")); | 77 ASSERT_TRUE(AddFolder(0, 0, "folder2")); |
78 | 78 |
79 // Verify that the client goes into exponential backoff while it is unable to | 79 // Verify that the client goes into exponential backoff while it is unable to |
80 // reach the sync server. | 80 // reach the sync server. |
81 ExponentialBackoffChecker exponential_backoff_checker( | 81 ExponentialBackoffChecker exponential_backoff_checker( |
82 GetSyncService((0))); | 82 GetSyncService((0))); |
83 exponential_backoff_checker.Wait(); | 83 exponential_backoff_checker.Wait(); |
84 ASSERT_FALSE(exponential_backoff_checker.TimedOut()); | 84 ASSERT_FALSE(exponential_backoff_checker.TimedOut()); |
85 | 85 |
86 // Recover from the network error. | 86 // Recover from the network error. |
87 EnableNetwork(GetProfile(0)); | 87 EnableNetwork(GetProfile(0)); |
88 | 88 |
89 // Verify that sync was able to recover. | 89 // Verify that sync was able to recover. |
90 ASSERT_TRUE(AwaitCommitActivityCompletion(GetSyncService((0)))); | 90 ASSERT_TRUE(AwaitCommitActivityCompletion(GetSyncService((0)))); |
91 ASSERT_TRUE(ModelMatchesVerifier(0)); | 91 ASSERT_TRUE(ModelMatchesVerifier(0)); |
92 } | 92 } |
93 | 93 |
94 IN_PROC_BROWSER_TEST_F(SyncExponentialBackoffTest, TransientErrorTest) { | 94 IN_PROC_BROWSER_TEST_F(SyncExponentialBackoffTest, TransientErrorTest) { |
95 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; | 95 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; |
96 | 96 |
97 // Add an item and ensure that sync is successful. | 97 // Add an item and ensure that sync is successful. |
98 ASSERT_TRUE(AddFolder(0, 0, L"folder1")); | 98 ASSERT_TRUE(AddFolder(0, 0, "folder1")); |
99 ASSERT_TRUE(AwaitCommitActivityCompletion(GetSyncService((0)))); | 99 ASSERT_TRUE(AwaitCommitActivityCompletion(GetSyncService((0)))); |
100 | 100 |
101 // Trigger a transient error on the server. | 101 // Trigger a transient error on the server. |
102 TriggerTransientError(); | 102 TriggerTransientError(); |
103 | 103 |
104 // Add a new item to trigger another sync cycle. | 104 // Add a new item to trigger another sync cycle. |
105 ASSERT_TRUE(AddFolder(0, 0, L"folder2")); | 105 ASSERT_TRUE(AddFolder(0, 0, "folder2")); |
106 | 106 |
107 // Verify that the client goes into exponential backoff while it is unable to | 107 // Verify that the client goes into exponential backoff while it is unable to |
108 // reach the sync server. | 108 // reach the sync server. |
109 ExponentialBackoffChecker exponential_backoff_checker( | 109 ExponentialBackoffChecker exponential_backoff_checker( |
110 GetSyncService((0))); | 110 GetSyncService((0))); |
111 exponential_backoff_checker.Wait(); | 111 exponential_backoff_checker.Wait(); |
112 ASSERT_FALSE(exponential_backoff_checker.TimedOut()); | 112 ASSERT_FALSE(exponential_backoff_checker.TimedOut()); |
113 } | 113 } |
114 | 114 |
115 } // namespace | 115 } // namespace |
OLD | NEW |