summaryrefslogtreecommitdiffstats
path: root/chrome/test/sync
diff options
context:
space:
mode:
authornick@chromium.org <nick@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-04-01 22:39:59 +0000
committernick@chromium.org <nick@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-04-01 22:39:59 +0000
commit29574e6f108129848e090a555254be8791732064 (patch)
tree9b05dd2867e31f02d2e5d77405c739431e911608 /chrome/test/sync
parent36bcd7e5cfb726859c10bb596cb1fdd876479799 (diff)
downloadchromium_src-29574e6f108129848e090a555254be8791732064.zip
chromium_src-29574e6f108129848e090a555254be8791732064.tar.gz
chromium_src-29574e6f108129848e090a555254be8791732064.tar.bz2
Make last_download_timestamp and initial_sync_ended per-datatype.
Persist them on a per-datatype basis. Add a migration from the old database scheme. In DownloadUpdates, pick the datatype(s) with the lowest last_download_timestamp; and fetch those. Keep running DownloadUpdatesCommand until we've gotten a "no-timestamp" result when requesting all datatypes. BUG=33065,37359,37331,37369,37373 TEST=included unit tests. Also, ran with Bookmark sync enabled, then added autofill the next time I started up, and observed that the incremental GetUpdates happened for autofill only, and that eventually the timestamps for bookmarks and autofill coalesced. Review URL: http://codereview.chromium.org/1521005 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@43397 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/test/sync')
-rw-r--r--chrome/test/sync/engine/mock_server_connection.cc9
-rw-r--r--chrome/test/sync/engine/mock_server_connection.h7
-rw-r--r--chrome/test/sync/engine/syncer_command_test.h29
3 files changed, 35 insertions, 10 deletions
diff --git a/chrome/test/sync/engine/mock_server_connection.cc b/chrome/test/sync/engine/mock_server_connection.cc
index ce3b03d..86f4e69 100644
--- a/chrome/test/sync/engine/mock_server_connection.cc
+++ b/chrome/test/sync/engine/mock_server_connection.cc
@@ -26,6 +26,8 @@ using sync_pb::CommitResponse_EntryResponse;
using sync_pb::GetUpdatesMessage;
using sync_pb::SyncEntity;
using syncable::DirectoryManager;
+using syncable::FIRST_REAL_MODEL_TYPE;
+using syncable::MODEL_TYPE_COUNT;
using syncable::ModelType;
using syncable::ScopedDirLookup;
using syncable::WriteTransaction;
@@ -80,6 +82,7 @@ bool MockConnectionManager::PostBufferToPath(const PostBufferParams* params,
browser_sync::ScopedServerStatusWatcher* watcher) {
ClientToServerMessage post;
CHECK(post.ParseFromString(params->buffer_in));
+ last_request_.CopyFrom(post);
client_stuck_ = post.sync_problem_detected();
ClientToServerResponse response;
response.Clear();
@@ -287,11 +290,7 @@ void MockConnectionManager::ProcessGetUpdates(ClientToServerMessage* csm,
// Verify that the GetUpdates filter sent by the Syncer matches the test
// expectation.
- for (int i = 0; i < syncable::MODEL_TYPE_COUNT; ++i) {
- if (i == syncable::UNSPECIFIED || i == syncable::TOP_LEVEL_FOLDER) {
- DCHECK(!expected_filter_[i]) << "Protocol doesn't support this type.";
- continue;
- }
+ for (int i = FIRST_REAL_MODEL_TYPE; i < MODEL_TYPE_COUNT; ++i) {
ModelType model_type = syncable::ModelTypeFromInt(i);
EXPECT_EQ(expected_filter_[i],
IsModelTypePresentInSpecifics(gu.requested_types(), model_type))
diff --git a/chrome/test/sync/engine/mock_server_connection.h b/chrome/test/sync/engine/mock_server_connection.h
index dc9af6f..33242c1 100644
--- a/chrome/test/sync/engine/mock_server_connection.h
+++ b/chrome/test/sync/engine/mock_server_connection.h
@@ -144,6 +144,11 @@ class MockConnectionManager : public browser_sync::ServerConnectionManager {
// Retrieve the last sent commit message.
const sync_pb::CommitMessage& last_sent_commit() const;
+ // Retrieve the last request submitted to the server (regardless of type).
+ const sync_pb::ClientToServerMessage& last_request() const {
+ return last_request_;
+ }
+
void set_conflict_all_commits(bool value) {
conflict_all_commits_ = value;
}
@@ -277,6 +282,8 @@ class MockConnectionManager : public browser_sync::ServerConnectionManager {
int num_get_updates_requests_;
+ sync_pb::ClientToServerMessage last_request_;
+
DISALLOW_COPY_AND_ASSIGN(MockConnectionManager);
};
diff --git a/chrome/test/sync/engine/syncer_command_test.h b/chrome/test/sync/engine/syncer_command_test.h
index 92175ed..5ce3faf 100644
--- a/chrome/test/sync/engine/syncer_command_test.h
+++ b/chrome/test/sync/engine/syncer_command_test.h
@@ -7,10 +7,11 @@
#include <vector>
-#include "chrome/test/sync/engine/test_directory_setter_upper.h"
#include "chrome/browser/sync/engine/model_safe_worker.h"
#include "chrome/browser/sync/sessions/sync_session.h"
#include "chrome/browser/sync/sessions/sync_session_context.h"
+#include "chrome/test/sync/engine/mock_server_connection.h"
+#include "chrome/test/sync/engine/test_directory_setter_upper.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace browser_sync {
@@ -56,9 +57,7 @@ class SyncerCommandTestWithParam : public testing::TestWithParam<T>,
virtual ~SyncerCommandTestWithParam() {}
virtual void SetUp() {
syncdb_.SetUp();
- context_.reset(new sessions::SyncSessionContext(NULL, NULL,
- syncdb_.manager(), registrar()));
- context_->set_account_name(syncdb_.name());
+ ResetContext();
}
virtual void TearDown() {
syncdb_.TearDown();
@@ -78,16 +77,36 @@ class SyncerCommandTestWithParam : public testing::TestWithParam<T>,
session_.reset();
}
+ void ResetContext() {
+ context_.reset(new sessions::SyncSessionContext(
+ mock_server_.get(), NULL, syncdb_.manager(), registrar()));
+ context_->set_account_name(syncdb_.name());
+ ClearSession();
+ }
+
+ // Install a MockServerConnection. Resets the context. By default,
+ // the context does not have a MockServerConnection attached.
+ void ConfigureMockServerConnection() {
+ mock_server_.reset(
+ new MockConnectionManager(syncdb_.manager(), syncdb_.name()));
+ ResetContext();
+ }
+
std::vector<scoped_refptr<ModelSafeWorker> >* workers() {
return &workers_;
}
- const ModelSafeRoutingInfo& routing_info() {return routing_info_; }
+ const ModelSafeRoutingInfo& routing_info() { return routing_info_; }
ModelSafeRoutingInfo* mutable_routing_info() { return &routing_info_; }
+ MockConnectionManager* mock_server() {
+ return mock_server_.get();
+ }
+
private:
TestDirectorySetterUpper syncdb_;
scoped_ptr<sessions::SyncSessionContext> context_;
+ scoped_ptr<MockConnectionManager> mock_server_;
scoped_ptr<sessions::SyncSession> session_;
std::vector<scoped_refptr<ModelSafeWorker> > workers_;
ModelSafeRoutingInfo routing_info_;