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 // Mock ServerConnectionManager class for use in client regression tests. | 5 // Mock ServerConnectionManager class for use in client regression tests. |
6 | 6 |
7 #include "sync/test/engine/mock_connection_manager.h" | 7 #include "sync/test/engine/mock_connection_manager.h" |
8 | 8 |
9 #include <map> | 9 #include <map> |
10 | 10 |
(...skipping 30 matching lines...) Expand all Loading... |
41 MockConnectionManager::MockConnectionManager(syncable::Directory* directory) | 41 MockConnectionManager::MockConnectionManager(syncable::Directory* directory) |
42 : ServerConnectionManager("unused", 0, false, "version"), | 42 : ServerConnectionManager("unused", 0, false, "version"), |
43 server_reachable_(true), | 43 server_reachable_(true), |
44 conflict_all_commits_(false), | 44 conflict_all_commits_(false), |
45 conflict_n_commits_(0), | 45 conflict_n_commits_(0), |
46 next_new_id_(10000), | 46 next_new_id_(10000), |
47 store_birthday_("Store BDay!"), | 47 store_birthday_("Store BDay!"), |
48 store_birthday_sent_(false), | 48 store_birthday_sent_(false), |
49 client_stuck_(false), | 49 client_stuck_(false), |
50 commit_time_rename_prepended_string_(""), | 50 commit_time_rename_prepended_string_(""), |
51 countdown_to_postbuffer_fail_(0), | 51 fail_next_postbuffer_(false), |
52 directory_(directory), | 52 directory_(directory), |
53 mid_commit_observer_(NULL), | 53 mid_commit_observer_(NULL), |
54 throttling_(false), | 54 throttling_(false), |
55 fail_with_auth_invalid_(false), | 55 fail_with_auth_invalid_(false), |
56 fail_non_periodic_get_updates_(false), | 56 fail_non_periodic_get_updates_(false), |
57 client_command_(NULL), | 57 client_command_(NULL), |
58 next_position_in_parent_(2), | 58 next_position_in_parent_(2), |
59 use_legacy_bookmarks_protocol_(false), | 59 use_legacy_bookmarks_protocol_(false), |
60 num_get_updates_requests_(0) { | 60 num_get_updates_requests_(0) { |
61 SetNewTimestamp(0); | 61 SetNewTimestamp(0); |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
104 params->response.server_status = HttpResponse::SYNC_AUTH_ERROR; | 104 params->response.server_status = HttpResponse::SYNC_AUTH_ERROR; |
105 return false; | 105 return false; |
106 } | 106 } |
107 | 107 |
108 if (auth_token != kValidAuthToken) { | 108 if (auth_token != kValidAuthToken) { |
109 // Simulate server-side auth failure. | 109 // Simulate server-side auth failure. |
110 params->response.server_status = HttpResponse::SYNC_AUTH_ERROR; | 110 params->response.server_status = HttpResponse::SYNC_AUTH_ERROR; |
111 InvalidateAndClearAuthToken(); | 111 InvalidateAndClearAuthToken(); |
112 } | 112 } |
113 | 113 |
114 if (--countdown_to_postbuffer_fail_ == 0) { | 114 if (fail_next_postbuffer_) { |
115 // Fail as countdown hits zero. | 115 fail_next_postbuffer_ = false; |
116 params->response.server_status = HttpResponse::SYNC_SERVER_ERROR; | |
117 return false; | 116 return false; |
118 } | 117 } |
119 | 118 |
120 if (!server_reachable_) { | 119 if (!server_reachable_) { |
121 params->response.server_status = HttpResponse::CONNECTION_UNAVAILABLE; | 120 params->response.server_status = HttpResponse::CONNECTION_UNAVAILABLE; |
122 return false; | 121 return false; |
123 } | 122 } |
124 | 123 |
125 // Default to an ok connection. | 124 // Default to an ok connection. |
126 params->response.server_status = HttpResponse::SERVER_CONNECTION_OK; | 125 params->response.server_status = HttpResponse::SERVER_CONNECTION_OK; |
(...skipping 497 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
624 server_reachable_ = false; | 623 server_reachable_ = false; |
625 } | 624 } |
626 | 625 |
627 void MockConnectionManager::UpdateConnectionStatus() { | 626 void MockConnectionManager::UpdateConnectionStatus() { |
628 if (!server_reachable_) { | 627 if (!server_reachable_) { |
629 server_status_ = HttpResponse::CONNECTION_UNAVAILABLE; | 628 server_status_ = HttpResponse::CONNECTION_UNAVAILABLE; |
630 } else { | 629 } else { |
631 server_status_ = HttpResponse::SERVER_CONNECTION_OK; | 630 server_status_ = HttpResponse::SERVER_CONNECTION_OK; |
632 } | 631 } |
633 } | 632 } |
OLD | NEW |