Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(10)

Side by Side Diff: sync/engine/backoff_delay_provider_unittest.cc

Issue 1553433002: [Sync] Sync should run canary cycle after any network related error (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix android test Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « sync/engine/backoff_delay_provider.cc ('k') | sync/engine/net/server_connection_manager.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/time.h" 8 #include "base/time/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 28 matching lines...) Expand all
39 state.last_get_key_result = SYNC_SERVER_ERROR; 39 state.last_get_key_result = SYNC_SERVER_ERROR;
40 EXPECT_EQ(kInitialBackoffRetrySeconds, 40 EXPECT_EQ(kInitialBackoffRetrySeconds,
41 delay->GetInitialDelay(state).InSeconds()); 41 delay->GetInitialDelay(state).InSeconds());
42 42
43 state.last_get_key_result = UNSET; 43 state.last_get_key_result = UNSET;
44 state.last_download_updates_result = SERVER_RETURN_MIGRATION_DONE; 44 state.last_download_updates_result = SERVER_RETURN_MIGRATION_DONE;
45 EXPECT_EQ(kInitialBackoffImmediateRetrySeconds, 45 EXPECT_EQ(kInitialBackoffImmediateRetrySeconds,
46 delay->GetInitialDelay(state).InSeconds()); 46 delay->GetInitialDelay(state).InSeconds());
47 47
48 state.last_download_updates_result = NETWORK_CONNECTION_UNAVAILABLE; 48 state.last_download_updates_result = NETWORK_CONNECTION_UNAVAILABLE;
49 EXPECT_EQ(kInitialBackoffImmediateRetrySeconds, 49 EXPECT_EQ(kInitialBackoffRetrySeconds,
50 delay->GetInitialDelay(state).InSeconds()); 50 delay->GetInitialDelay(state).InSeconds());
51 51
52 state.last_download_updates_result = SERVER_RETURN_TRANSIENT_ERROR; 52 state.last_download_updates_result = SERVER_RETURN_TRANSIENT_ERROR;
53 EXPECT_EQ(kInitialBackoffRetrySeconds, 53 EXPECT_EQ(kInitialBackoffRetrySeconds,
54 delay->GetInitialDelay(state).InSeconds()); 54 delay->GetInitialDelay(state).InSeconds());
55 55
56 state.last_download_updates_result = SERVER_RESPONSE_VALIDATION_FAILED; 56 state.last_download_updates_result = SERVER_RESPONSE_VALIDATION_FAILED;
57 EXPECT_EQ(kInitialBackoffRetrySeconds, 57 EXPECT_EQ(kInitialBackoffRetrySeconds,
58 delay->GetInitialDelay(state).InSeconds()); 58 delay->GetInitialDelay(state).InSeconds());
59 59
60 state.last_download_updates_result = DATATYPE_TRIGGERED_RETRY; 60 state.last_download_updates_result = DATATYPE_TRIGGERED_RETRY;
61 EXPECT_EQ(kInitialBackoffImmediateRetrySeconds, 61 EXPECT_EQ(kInitialBackoffImmediateRetrySeconds,
62 delay->GetInitialDelay(state).InSeconds()); 62 delay->GetInitialDelay(state).InSeconds());
63 63
64 state.last_download_updates_result = SYNCER_OK; 64 state.last_download_updates_result = SYNCER_OK;
65 // Note that updating credentials triggers a canary job, trumping 65 // Note that updating credentials triggers a canary job, trumping
66 // the initial delay, but in theory we still expect this function to treat 66 // the initial delay, but in theory we still expect this function to treat
67 // it like any other error in the system (except migration). 67 // it like any other error in the system (except migration).
68 state.commit_result = SERVER_RETURN_INVALID_CREDENTIAL; 68 state.commit_result = SERVER_RETURN_INVALID_CREDENTIAL;
69 EXPECT_EQ(kInitialBackoffRetrySeconds, 69 EXPECT_EQ(kInitialBackoffRetrySeconds,
70 delay->GetInitialDelay(state).InSeconds()); 70 delay->GetInitialDelay(state).InSeconds());
71 71
72 state.commit_result = SERVER_RETURN_MIGRATION_DONE; 72 state.commit_result = SERVER_RETURN_MIGRATION_DONE;
73 EXPECT_EQ(kInitialBackoffImmediateRetrySeconds, 73 EXPECT_EQ(kInitialBackoffImmediateRetrySeconds,
74 delay->GetInitialDelay(state).InSeconds()); 74 delay->GetInitialDelay(state).InSeconds());
75 75
76 state.commit_result = NETWORK_CONNECTION_UNAVAILABLE; 76 state.commit_result = NETWORK_CONNECTION_UNAVAILABLE;
77 EXPECT_EQ(kInitialBackoffImmediateRetrySeconds, 77 EXPECT_EQ(kInitialBackoffRetrySeconds,
78 delay->GetInitialDelay(state).InSeconds()); 78 delay->GetInitialDelay(state).InSeconds());
79 79
80 state.commit_result = SERVER_RETURN_CONFLICT; 80 state.commit_result = SERVER_RETURN_CONFLICT;
81 EXPECT_EQ(kInitialBackoffImmediateRetrySeconds, 81 EXPECT_EQ(kInitialBackoffImmediateRetrySeconds,
82 delay->GetInitialDelay(state).InSeconds()); 82 delay->GetInitialDelay(state).InSeconds());
83 } 83 }
84 84
85 TEST_F(BackoffDelayProviderTest, GetInitialDelayWithOverride) { 85 TEST_F(BackoffDelayProviderTest, GetInitialDelayWithOverride) {
86 scoped_ptr<BackoffDelayProvider> delay( 86 scoped_ptr<BackoffDelayProvider> delay(
87 BackoffDelayProvider::WithShortInitialRetryOverride()); 87 BackoffDelayProvider::WithShortInitialRetryOverride());
(...skipping 30 matching lines...) Expand all
118 state.commit_result = SERVER_RETURN_MIGRATION_DONE; 118 state.commit_result = SERVER_RETURN_MIGRATION_DONE;
119 EXPECT_EQ(kInitialBackoffImmediateRetrySeconds, 119 EXPECT_EQ(kInitialBackoffImmediateRetrySeconds,
120 delay->GetInitialDelay(state).InSeconds()); 120 delay->GetInitialDelay(state).InSeconds());
121 121
122 state.commit_result = SERVER_RETURN_CONFLICT; 122 state.commit_result = SERVER_RETURN_CONFLICT;
123 EXPECT_EQ(kInitialBackoffImmediateRetrySeconds, 123 EXPECT_EQ(kInitialBackoffImmediateRetrySeconds,
124 delay->GetInitialDelay(state).InSeconds()); 124 delay->GetInitialDelay(state).InSeconds());
125 } 125 }
126 126
127 } // namespace syncer 127 } // namespace syncer
OLDNEW
« no previous file with comments | « sync/engine/backoff_delay_provider.cc ('k') | sync/engine/net/server_connection_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698