diff options
author | davemoore@chromium.org <davemoore@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-09-24 21:05:36 +0000 |
---|---|---|
committer | davemoore@chromium.org <davemoore@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-09-24 21:05:36 +0000 |
commit | 506cb1db9a466aad6b8d3fdce9cb94eb54516e47 (patch) | |
tree | 8959bc3c7ab135de91fa746bf416603cc6c98bdd /chrome/test/sync | |
parent | 7b3c0312746e6f21478a01c3d56db4714b48618f (diff) | |
download | chromium_src-506cb1db9a466aad6b8d3fdce9cb94eb54516e47.zip chromium_src-506cb1db9a466aad6b8d3fdce9cb94eb54516e47.tar.gz chromium_src-506cb1db9a466aad6b8d3fdce9cb94eb54516e47.tar.bz2 |
Reverting 27117.
Review URL: http://codereview.chromium.org/235010
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@27124 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/test/sync')
4 files changed, 9 insertions, 64 deletions
diff --git a/chrome/test/sync/engine/mock_server_connection.cc b/chrome/test/sync/engine/mock_server_connection.cc index c4595bd..bd3d90f 100644 --- a/chrome/test/sync/engine/mock_server_connection.cc +++ b/chrome/test/sync/engine/mock_server_connection.cc @@ -25,7 +25,6 @@ using sync_pb::CommitResponse_EntryResponse; using sync_pb::GetUpdatesMessage; using sync_pb::SyncEntity; using syncable::DirectoryManager; -using syncable::ScopedDirLookup; using syncable::WriteTransaction; MockConnectionManager::MockConnectionManager(DirectoryManager* dirmgr, @@ -39,13 +38,12 @@ MockConnectionManager::MockConnectionManager(DirectoryManager* dirmgr, client_stuck_(false), commit_time_rename_prepended_string_(""), fail_next_postbuffer_(false), - directory_manager_(dirmgr), - directory_name_(name), + directory_(dirmgr, name), mid_commit_callback_function_(NULL), - mid_commit_observer_(NULL), client_command_(NULL), next_position_in_parent_(2) { server_reachable_ = true; + CHECK(directory_.good()); }; MockConnectionManager::~MockConnectionManager() { @@ -62,18 +60,9 @@ void MockConnectionManager::SetMidCommitCallbackFunction( mid_commit_callback_function_ = callback; } -void MockConnectionManager::SetMidCommitObserver( - MockConnectionManager::MidCommitObserver* observer) { - mid_commit_observer_ = observer; -} - bool MockConnectionManager::PostBufferToPath(const PostBufferParams* params, const string& path, const string& auth_token) { - - ScopedDirLookup directory(directory_manager_, directory_name_); - CHECK(directory.good()); - ClientToServerMessage post; CHECK(post.ParseFromString(params->buffer_in)); client_stuck_ = post.sync_problem_detected(); @@ -84,7 +73,7 @@ bool MockConnectionManager::PostBufferToPath(const PostBufferParams* params, // network. As we can't test this we do the next best thing and hang here // when there's an issue. { - WriteTransaction wt(directory, syncable::UNITTEST, __FILE__, __LINE__); + WriteTransaction wt(directory_, syncable::UNITTEST, __FILE__, __LINE__); } if (fail_next_postbuffer_) { fail_next_postbuffer_ = false; @@ -116,12 +105,9 @@ bool MockConnectionManager::PostBufferToPath(const PostBufferParams* params, } response.SerializeToString(params->buffer_out); if (mid_commit_callback_function_) { - if (mid_commit_callback_function_(directory)) + if (mid_commit_callback_function_(directory_)) mid_commit_callback_function_ = 0; } - if (mid_commit_observer_) { - mid_commit_observer_->Observe(); - } return result; } diff --git a/chrome/test/sync/engine/mock_server_connection.h b/chrome/test/sync/engine/mock_server_connection.h index 8c0cca7..e5573e0 100644 --- a/chrome/test/sync/engine/mock_server_connection.h +++ b/chrome/test/sync/engine/mock_server_connection.h @@ -31,10 +31,6 @@ class MockConnectionManager : public browser_sync::ServerConnectionManager { // activity would normally take place. This aids simulation of race // conditions. typedef bool (*TestCallbackFunction)(syncable::Directory* dir); - class MidCommitObserver { - public: - virtual void Observe() = 0; - }; MockConnectionManager(syncable::DirectoryManager* dirmgr, PathString name); virtual ~MockConnectionManager(); @@ -49,7 +45,6 @@ class MockConnectionManager : public browser_sync::ServerConnectionManager { // Control of commit response. void SetMidCommitCallbackFunction(TestCallbackFunction callback); - void SetMidCommitObserver(MidCommitObserver* observer); // Set this if you want commit to perform commit time rename. Will request // that the client renames all commited entries, prepending this string. @@ -182,13 +177,11 @@ class MockConnectionManager : public browser_sync::ServerConnectionManager { bool fail_next_postbuffer_; // Our directory. - syncable::DirectoryManager* directory_manager_; - PathString directory_name_; + syncable::ScopedDirLookup directory_; // The updates we'll return to the next request. sync_pb::GetUpdatesResponse updates_; TestCallbackFunction mid_commit_callback_function_; - MidCommitObserver* mid_commit_observer_; scoped_ptr<sync_pb::ClientCommand> client_command_; diff --git a/chrome/test/sync/engine/test_directory_setter_upper.cc b/chrome/test/sync/engine/test_directory_setter_upper.cc index 0a7b32d..468875a 100644 --- a/chrome/test/sync/engine/test_directory_setter_upper.cc +++ b/chrome/test/sync/engine/test_directory_setter_upper.cc @@ -20,15 +20,12 @@ TestDirectorySetterUpper::TestDirectorySetterUpper() : name_(PSTR("Test")) {} TestDirectorySetterUpper::~TestDirectorySetterUpper() {} -void TestDirectorySetterUpper::Init() { +void TestDirectorySetterUpper::SetUp() { PathString test_data_dir_ = PSTR("."); manager_.reset(new DirectoryManager(test_data_dir_)); file_path_ = manager_->GetSyncDataDatabasePath(); PathRemove(file_path_.c_str()); -} -void TestDirectorySetterUpper::SetUp() { - Init(); ASSERT_TRUE(manager()->Open(name())); } @@ -67,19 +64,4 @@ void TestDirectorySetterUpper::RunInvariantCheck(const ScopedDirLookup& dir) { } } -void ManuallyOpenedTestDirectorySetterUpper::SetUp() { - Init(); -} - -void ManuallyOpenedTestDirectorySetterUpper::Open() { - ASSERT_TRUE(manager()->Open(name())); - was_opened_ = true; -} - -void ManuallyOpenedTestDirectorySetterUpper::TearDown() { - if (was_opened_) { - TestDirectorySetterUpper::TearDown(); - } -} - } // namespace browser_sync diff --git a/chrome/test/sync/engine/test_directory_setter_upper.h b/chrome/test/sync/engine/test_directory_setter_upper.h index 0cfa3e6..0cac7e1 100644 --- a/chrome/test/sync/engine/test_directory_setter_upper.h +++ b/chrome/test/sync/engine/test_directory_setter_upper.h @@ -44,23 +44,20 @@ namespace browser_sync { class TestDirectorySetterUpper { public: TestDirectorySetterUpper(); - virtual ~TestDirectorySetterUpper(); + ~TestDirectorySetterUpper(); // Create a DirectoryManager instance and use it to open the directory. // Clears any existing database backing files that might exist on disk. - virtual void SetUp(); + void SetUp(); // Undo everything done by SetUp(): close the directory and delete the // backing files. Before closing the directory, this will run the directory // invariant checks and perform the SaveChanges action on the directory. - virtual void TearDown(); + void TearDown(); syncable::DirectoryManager* manager() const { return manager_.get(); } const PathString& name() const { return name_; } - protected: - virtual void Init(); - private: void RunInvariantCheck(const syncable::ScopedDirLookup& dir); @@ -69,19 +66,6 @@ class TestDirectorySetterUpper { PathString file_path_; }; -// A variant of the above where SetUp does not actually open the directory. -// You must manually invoke Open(). This is useful if you are writing a test -// that depends on the DirectoryManager::OPENED event. -class ManuallyOpenedTestDirectorySetterUpper : public TestDirectorySetterUpper { - public: - ManuallyOpenedTestDirectorySetterUpper() : was_opened_(false) {} - virtual void SetUp(); - virtual void TearDown(); - void Open(); - private: - bool was_opened_; -}; - } // namespace browser_sync #endif // CHROME_TEST_SYNC_ENGINE_TEST_DIRECTORY_SETTER_UPPER_H_ |