summaryrefslogtreecommitdiffstats
path: root/chrome/test/sync/engine/syncer_command_test.h
diff options
context:
space:
mode:
authornick@chromium.org <nick@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-02-09 17:41:51 +0000
committernick@chromium.org <nick@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-02-09 17:41:51 +0000
commitf466a30ddd61518eb511aad85b71b2ccd231e4ee (patch)
tree3332901f74108b6fa0f3592893fc4a7a400936fe /chrome/test/sync/engine/syncer_command_test.h
parentbe63d2855bad91d9be16c78742dc3616b5d5748c (diff)
downloadchromium_src-f466a30ddd61518eb511aad85b71b2ccd231e4ee.zip
chromium_src-f466a30ddd61518eb511aad85b71b2ccd231e4ee.tar.gz
chromium_src-f466a30ddd61518eb511aad85b71b2ccd231e4ee.tar.bz2
Fix a bug where positions inside of a newly-committed folder would be
reversed if the children of the folder weren't committed in the same batch as the folder. Refactor ApplyUpdatesCommandTest, pulling out functionality that would be useful for any SyncerCommand test, into syncer_command_test.h. Add a test case for ProcessCommitResponseCommand using the new SyncerCommandTest framework. Add a test for the bug. BUG=33081 TEST=sync_unit_tests. Also, manual testing, using the reduced repro instructions described in comment #26 of the bug. Review URL: http://codereview.chromium.org/572021 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@38472 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/test/sync/engine/syncer_command_test.h')
-rwxr-xr-xchrome/test/sync/engine/syncer_command_test.h80
1 files changed, 80 insertions, 0 deletions
diff --git a/chrome/test/sync/engine/syncer_command_test.h b/chrome/test/sync/engine/syncer_command_test.h
new file mode 100755
index 0000000..e5ef5dc
--- /dev/null
+++ b/chrome/test/sync/engine/syncer_command_test.h
@@ -0,0 +1,80 @@
+// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_TEST_SYNC_ENGINE_SYNCER_COMMAND_TEST_H_
+#define CHROME_TEST_SYNC_ENGINE_SYNCER_COMMAND_TEST_H_
+
+#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 "testing/gtest/include/gtest/gtest.h"
+
+namespace browser_sync {
+
+// A test fixture that simplifies writing unit tests for individual
+// SyncerCommands, providing convenient access to a test directory
+// and a syncer session.
+class SyncerCommandTest : public testing::Test,
+ public sessions::SyncSession::Delegate,
+ public ModelSafeWorkerRegistrar {
+ public:
+ // SyncSession::Delegate implementation.
+ virtual void OnSilencedUntil(const base::TimeTicks& silenced_until) {
+ FAIL() << "Should not get silenced.";
+ }
+ virtual bool IsSyncingCurrentlySilenced() {
+ ADD_FAILURE() << "No requests for silenced state should be made.";
+ return false;
+ }
+ virtual void OnReceivedLongPollIntervalUpdate(
+ const base::TimeDelta& new_interval) {
+ FAIL() << "Should not get poll interval update.";
+ }
+ virtual void OnReceivedShortPollIntervalUpdate(
+ const base::TimeDelta& new_interval) {
+ FAIL() << "Should not get poll interval update.";
+ }
+
+ // ModelSafeWorkerRegistrar implementation.
+ virtual void GetWorkers(std::vector<ModelSafeWorker*>* out) {}
+ virtual void GetModelSafeRoutingInfo(ModelSafeRoutingInfo* out) {}
+
+ protected:
+ SyncerCommandTest() {}
+ virtual ~SyncerCommandTest() {}
+ virtual void SetUp() {
+ syncdb_.SetUp();
+ context_.reset(new sessions::SyncSessionContext(NULL, syncdb_.manager(),
+ registrar()));
+ context_->set_account_name(syncdb_.name());
+ }
+ virtual void TearDown() {
+ syncdb_.TearDown();
+ }
+
+ const TestDirectorySetterUpper& syncdb() const { return syncdb_; }
+ sessions::SyncSessionContext* context() const { return context_.get(); }
+ sessions::SyncSession::Delegate* delegate() { return this; }
+ ModelSafeWorkerRegistrar* registrar() { return this; }
+ // Lazily create a session.
+ sessions::SyncSession* session() {
+ if (!session_.get())
+ session_.reset(new sessions::SyncSession(context(), delegate()));
+ return session_.get();
+ }
+ void ClearSession() {
+ session_.reset();
+ }
+
+ private:
+ TestDirectorySetterUpper syncdb_;
+ scoped_ptr<sessions::SyncSessionContext> context_;
+ scoped_ptr<sessions::SyncSession> session_;
+ DISALLOW_COPY_AND_ASSIGN(SyncerCommandTest);
+};
+
+} // namespace browser_sync
+
+#endif // CHROME_TEST_SYNC_ENGINE_SYNCER_COMMAND_TEST_H_