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

Unified Diff: sync/test/engine/mock_connection_manager.cc

Issue 10455012: [Sync] Add support for performing a GetKey on startup. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 8 years, 5 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
Index: sync/test/engine/mock_connection_manager.cc
diff --git a/sync/test/engine/mock_connection_manager.cc b/sync/test/engine/mock_connection_manager.cc
index 58bd0d1e68694b792b4a0daff886d671106a5fc5..427564b7165800088d745c5b4a70bebc8cb7c0b1 100644
--- a/sync/test/engine/mock_connection_manager.cc
+++ b/sync/test/engine/mock_connection_manager.cc
@@ -11,6 +11,7 @@
#include "base/location.h"
#include "base/stringprintf.h"
#include "sync/engine/syncer_proto_util.h"
+#include "sync/test/engine/test_id_factory.h"
#include "sync/protocol/bookmark_specifics.pb.h"
#include "sync/syncable/directory.h"
#include "sync/syncable/write_transaction.h"
@@ -44,6 +45,8 @@ MockConnectionManager::MockConnectionManager(syncable::Directory* directory)
countdown_to_postbuffer_fail_(0),
directory_(directory),
mid_commit_observer_(NULL),
+ clear_user_data_response_errortype_(sync_pb::SyncEnums::SUCCESS),
+ get_key_response_errortype_(sync_pb::SyncEnums::SUCCESS),
throttling_(false),
fail_with_auth_invalid_(false),
fail_non_periodic_get_updates_(false),
@@ -138,6 +141,9 @@ bool MockConnectionManager::PostBufferToPath(PostBufferParams* params,
ProcessCommit(&post, &response);
} else if (post.message_contents() == ClientToServerMessage::GET_UPDATES) {
ProcessGetUpdates(&post, &response);
+ } else if (post.message_contents() ==
+ ClientToServerMessage::GET_ENCRYPTION_KEY) {
+ ProcessGetKey(&post, &response);
} else {
EXPECT_TRUE(false) << "Unknown/unsupported ClientToServerMessage";
return false;
@@ -451,6 +457,28 @@ void MockConnectionManager::ProcessGetUpdates(
update_queue_.pop_front();
}
+void MockConnectionManager::SetKeystoreKey(const std::string& key) {
+ // Note: this is not a thread-safe set, ok for now. NOT ok if tests
+ // run the syncer on the background thread while this method is called.
+ keystore_key_ = key;
+}
+
+void MockConnectionManager::SetGetKeyResponseStatus(
+ sync_pb::SyncEnums::ErrorType errortype ) {
+ // Note: this is not a thread-safe set, ok for now. NOT ok if tests
+ // run the syncer on the background thread while this method is called.
+ get_key_response_errortype_ = errortype;
+}
+
+void MockConnectionManager::ProcessGetKey(
+ sync_pb::ClientToServerMessage* csm,
+ sync_pb::ClientToServerResponse* response) {
+ CHECK(csm->has_get_encryption_key());
tim (not reviewing) 2012/07/19 21:42:03 why CHECK over ASSERT_TRUE?
Nicolas Zea 2012/07/24 22:51:24 Done.
+ ASSERT_EQ(csm->message_contents(), ClientToServerMessage::GET_ENCRYPTION_KEY);
+ response->mutable_get_encryption_key()->set_key(keystore_key_);
+ response->set_error_code(get_key_response_errortype_);
+}
+
bool MockConnectionManager::ShouldConflictThisCommit() {
bool conflict = false;
if (conflict_all_commits_) {

Powered by Google App Engine
This is Rietveld 408576698