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 "sync/engine/backoff_delay_provider.h" | 5 #include "sync/engine/backoff_delay_provider.h" |
6 | 6 |
7 #include "base/memory/scoped_ptr.h" | 7 #include "base/memory/scoped_ptr.h" |
8 #include "base/time.h" | 8 #include "base/time.h" |
9 #include "sync/internal_api/public/engine/polling_constants.h" | 9 #include "sync/internal_api/public/engine/polling_constants.h" |
10 #include "sync/internal_api/public/sessions/model_neutral_state.h" | 10 #include "sync/internal_api/public/sessions/model_neutral_state.h" |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
65 EXPECT_EQ(kInitialBackoffRetrySeconds, | 65 EXPECT_EQ(kInitialBackoffRetrySeconds, |
66 delay->GetInitialDelay(state).InSeconds()); | 66 delay->GetInitialDelay(state).InSeconds()); |
67 | 67 |
68 state.commit_result = SERVER_RETURN_MIGRATION_DONE; | 68 state.commit_result = SERVER_RETURN_MIGRATION_DONE; |
69 EXPECT_EQ(kInitialBackoffImmediateRetrySeconds, | 69 EXPECT_EQ(kInitialBackoffImmediateRetrySeconds, |
70 delay->GetInitialDelay(state).InSeconds()); | 70 delay->GetInitialDelay(state).InSeconds()); |
71 | 71 |
72 state.commit_result = NETWORK_CONNECTION_UNAVAILABLE; | 72 state.commit_result = NETWORK_CONNECTION_UNAVAILABLE; |
73 EXPECT_EQ(kInitialBackoffImmediateRetrySeconds, | 73 EXPECT_EQ(kInitialBackoffImmediateRetrySeconds, |
74 delay->GetInitialDelay(state).InSeconds()); | 74 delay->GetInitialDelay(state).InSeconds()); |
| 75 |
| 76 state.commit_result = SERVER_RETURN_CONFLICT; |
| 77 EXPECT_EQ(kInitialBackoffImmediateRetrySeconds, |
| 78 delay->GetInitialDelay(state).InSeconds()); |
75 } | 79 } |
76 | 80 |
77 TEST_F(BackoffDelayProviderTest, GetInitialDelayWithOverride) { | 81 TEST_F(BackoffDelayProviderTest, GetInitialDelayWithOverride) { |
78 scoped_ptr<BackoffDelayProvider> delay( | 82 scoped_ptr<BackoffDelayProvider> delay( |
79 BackoffDelayProvider::WithShortInitialRetryOverride()); | 83 BackoffDelayProvider::WithShortInitialRetryOverride()); |
80 sessions::ModelNeutralState state; | 84 sessions::ModelNeutralState state; |
81 state.last_get_key_result = SYNC_SERVER_ERROR; | 85 state.last_get_key_result = SYNC_SERVER_ERROR; |
82 EXPECT_EQ(kInitialBackoffShortRetrySeconds, | 86 EXPECT_EQ(kInitialBackoffShortRetrySeconds, |
83 delay->GetInitialDelay(state).InSeconds()); | 87 delay->GetInitialDelay(state).InSeconds()); |
84 | 88 |
(...skipping 14 matching lines...) Expand all Loading... |
99 // Note that updating credentials triggers a canary job, trumping | 103 // Note that updating credentials triggers a canary job, trumping |
100 // the initial delay, but in theory we still expect this function to treat | 104 // the initial delay, but in theory we still expect this function to treat |
101 // it like any other error in the system (except migration). | 105 // it like any other error in the system (except migration). |
102 state.commit_result = SERVER_RETURN_INVALID_CREDENTIAL; | 106 state.commit_result = SERVER_RETURN_INVALID_CREDENTIAL; |
103 EXPECT_EQ(kInitialBackoffShortRetrySeconds, | 107 EXPECT_EQ(kInitialBackoffShortRetrySeconds, |
104 delay->GetInitialDelay(state).InSeconds()); | 108 delay->GetInitialDelay(state).InSeconds()); |
105 | 109 |
106 state.commit_result = SERVER_RETURN_MIGRATION_DONE; | 110 state.commit_result = SERVER_RETURN_MIGRATION_DONE; |
107 EXPECT_EQ(kInitialBackoffImmediateRetrySeconds, | 111 EXPECT_EQ(kInitialBackoffImmediateRetrySeconds, |
108 delay->GetInitialDelay(state).InSeconds()); | 112 delay->GetInitialDelay(state).InSeconds()); |
| 113 |
| 114 state.commit_result = SERVER_RETURN_CONFLICT; |
| 115 EXPECT_EQ(kInitialBackoffImmediateRetrySeconds, |
| 116 delay->GetInitialDelay(state).InSeconds()); |
109 } | 117 } |
110 | 118 |
111 } // namespace syncer | 119 } // namespace syncer |
OLD | NEW |