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

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

Issue 650463003: Improve error triggering in sync_integration_tests (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 2 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 | « chrome/browser/sync/test/integration/sync_test.cc ('k') | sync/test/fake_server/fake_server.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sync/test/fake_server/fake_server.h
diff --git a/sync/test/fake_server/fake_server.h b/sync/test/fake_server/fake_server.h
index d9a2b8befe6167c43f1a71afe50d3e0183122c6c..338ce5a89935e6e89c1d8eeec7c4d8e3308b9730 100644
--- a/sync/test/fake_server/fake_server.h
+++ b/sync/test/fake_server/fake_server.h
@@ -72,20 +72,28 @@ class FakeServer {
// Force the server to return |error_type| in the error_code field of
// ClientToServerResponse on all subsequent sync requests. This method should
- // not be called if TriggerActionableError has previously been called.
- // TODO(pvalenzuela): Return a bool here to indicate whether the call
- // succeeded.
- void TriggerError(const sync_pb::SyncEnums::ErrorType& error_type);
+ // not be called if TriggerActionableError has previously been called. Returns
+ // true if error triggering was successfully configured.
+ bool TriggerError(const sync_pb::SyncEnums::ErrorType& error_type);
// Force the server to return the given data as part of the error field of
// ClientToServerResponse on all subsequent sync requests. This method should
- // not be called if TriggerError has previously been called.
+ // not be called if TriggerError has previously been called. Returns true if
+ // error triggering was successfully configured.
bool TriggerActionableError(
const sync_pb::SyncEnums::ErrorType& error_type,
const std::string& description,
const std::string& url,
const sync_pb::SyncEnums::Action& action);
+ // Instructs the server to send triggered errors on every other request
+ // (starting with the first one after this call). This feature can be used to
+ // test the resiliency of the client when communicating with a problematic
+ // server or flaky network connection. This method should only be called
+ // after a call to TriggerError or TriggerActionableError. Returns true if
+ // triggered error alternating was successful.
+ bool EnableAlternatingTriggeredErrors();
+
// Adds |observer| to FakeServer's observer list. This should be called
// before the Profile associated with |observer| is connected to the server.
void AddObserver(Observer* observer);
@@ -147,6 +155,9 @@ class FakeServer {
// |id|. A tombstone is not created for the entity itself.
bool DeleteChildren(const std::string& id);
+ // Returns whether a triggered error should be sent for the request.
+ bool ShouldSendTriggeredError() const;
+
// This is the last version number assigned to an entity. The next entity will
// have a version number of version_ + 1.
int64 version_;
@@ -173,6 +184,16 @@ class FakeServer {
// NULL.
scoped_ptr<sync_pb::ClientToServerResponse_Error> triggered_actionable_error_;
+ // These values are used in tandem to return a triggered error (either
+ // |error_type_| or |triggered_actionable_error_|) on every other request.
+ // |alternate_triggered_errors_| is set if this feature is enabled and
+ // |request_counter_| is used to send triggered errors on odd-numbered
+ // requests. Note that |request_counter_| can be reset and is not necessarily
+ // indicative of the total number of requests handled during the object's
+ // lifetime.
+ bool alternate_triggered_errors_;
+ int request_counter_;
+
// FakeServer's observers.
ObserverList<Observer, true> observers_;
« no previous file with comments | « chrome/browser/sync/test/integration/sync_test.cc ('k') | sync/test/fake_server/fake_server.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698