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

Unified Diff: sync/test/fake_server/fake_server.cc

Issue 310103004: Add integraton test for sync backup/rollback. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « sync/test/fake_server/fake_server.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sync/test/fake_server/fake_server.cc
diff --git a/sync/test/fake_server/fake_server.cc b/sync/test/fake_server/fake_server.cc
index 25ec36ae1c38a2a4b2b4873a0557238c04fadcea..0d519e760b7c983544fdbc44b5cb2c0d3ae94c20 100644
--- a/sync/test/fake_server/fake_server.cc
+++ b/sync/test/fake_server/fake_server.cc
@@ -147,7 +147,8 @@ scoped_ptr<UpdateSieve> UpdateSieve::Create(
FakeServer::FakeServer() : version_(0),
store_birthday_(kDefaultStoreBirthday),
- authenticated_(true) {
+ authenticated_(true),
+ error_type_(sync_pb::SyncEnums::SUCCESS) {
keystore_keys_.push_back(kDefaultKeystoreKey);
CHECK(CreateDefaultPermanentItems());
}
@@ -231,6 +232,8 @@ void FakeServer::HandleCommand(const string& request,
if (message.has_store_birthday() &&
message.store_birthday() != store_birthday_) {
error_code = sync_pb::SyncEnums::NOT_MY_BIRTHDAY;
+ } else if (error_type_ != sync_pb::SyncEnums::SUCCESS) {
+ error_code = error_type_;
} else {
bool success = false;
switch (message.message_contents()) {
@@ -505,6 +508,15 @@ void FakeServer::SetUnauthenticated() {
authenticated_ = false;
}
+// TODO(pvalenzuela): comments from Richard: we should look at
+// mock_connection_manager.cc and take it as a warning. This style of injecting
+// errors works when there's one or two conditions we care about, but it can
+// eventually lead to a hairball once we have many different conditions and
+// triggering logic.
+void FakeServer::TriggerError(const sync_pb::SyncEnums::ErrorType& error_type) {
+ error_type_ = error_type;
+}
+
void FakeServer::AddObserver(Observer* observer) {
observers_.AddObserver(observer);
}
« no previous file with comments | « sync/test/fake_server/fake_server.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698