| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 // | 4 // |
| 5 // A handy class that takes care of setting up and destroying a | 5 // A handy class that takes care of setting up and destroying a |
| 6 // syncable::Directory instance for unit tests that require one. | 6 // syncable::Directory instance for unit tests that require one. |
| 7 // | 7 // |
| 8 // The expected usage is to make this a component of your test fixture: | 8 // The expected usage is to make this a component of your test fixture: |
| 9 // | 9 // |
| 10 // class AwesomenessTest : public testing::Test { | 10 // class AwesomenessTest : public testing::Test { |
| (...skipping 22 matching lines...) Expand all Loading... |
| 33 | 33 |
| 34 #include "base/basictypes.h" | 34 #include "base/basictypes.h" |
| 35 #include "base/compiler_specific.h" | 35 #include "base/compiler_specific.h" |
| 36 #include "base/memory/scoped_ptr.h" | 36 #include "base/memory/scoped_ptr.h" |
| 37 #include "base/scoped_temp_dir.h" | 37 #include "base/scoped_temp_dir.h" |
| 38 #include "sync/test/fake_sync_encryption_handler.h" | 38 #include "sync/test/fake_sync_encryption_handler.h" |
| 39 #include "sync/test/null_directory_change_delegate.h" | 39 #include "sync/test/null_directory_change_delegate.h" |
| 40 #include "sync/util/test_unrecoverable_error_handler.h" | 40 #include "sync/util/test_unrecoverable_error_handler.h" |
| 41 #include "testing/gmock/include/gmock/gmock.h" | 41 #include "testing/gmock/include/gmock/gmock.h" |
| 42 | 42 |
| 43 namespace syncer { |
| 44 |
| 43 namespace syncable { | 45 namespace syncable { |
| 44 class Directory; | 46 class Directory; |
| 47 class MockTransactionObserver; |
| 45 } | 48 } |
| 46 | 49 |
| 47 namespace syncer { | |
| 48 | |
| 49 class TestDirectorySetterUpper { | 50 class TestDirectorySetterUpper { |
| 50 public: | 51 public: |
| 51 TestDirectorySetterUpper(); | 52 TestDirectorySetterUpper(); |
| 52 virtual ~TestDirectorySetterUpper(); | 53 virtual ~TestDirectorySetterUpper(); |
| 53 | 54 |
| 54 // Create a Directory instance open it. | 55 // Create a Directory instance open it. |
| 55 virtual void SetUp(); | 56 virtual void SetUp(); |
| 56 | 57 |
| 57 // Undo everything done by SetUp(): close the directory and delete the | 58 // Undo everything done by SetUp(): close the directory and delete the |
| 58 // backing files. Before closing the directory, this will run the directory | 59 // backing files. Before closing the directory, this will run the directory |
| 59 // invariant checks and perform the SaveChanges action on the directory. | 60 // invariant checks and perform the SaveChanges action on the directory. |
| 60 virtual void TearDown(); | 61 virtual void TearDown(); |
| 61 | 62 |
| 62 syncable::Directory* directory() { return directory_.get(); } | 63 syncable::Directory* directory() { return directory_.get(); } |
| 63 | 64 |
| 64 SyncEncryptionHandler* encryption_handler() { return &encryption_handler_; } | 65 SyncEncryptionHandler* encryption_handler() { return &encryption_handler_; } |
| 65 | 66 |
| 67 syncable::MockTransactionObserver* transaction_observer() { |
| 68 return mock_transaction_observer_.get(); |
| 69 } |
| 70 |
| 66 private: | 71 private: |
| 67 syncable::NullDirectoryChangeDelegate delegate_; | 72 syncable::NullDirectoryChangeDelegate delegate_; |
| 73 scoped_ptr<syncable::MockTransactionObserver> mock_transaction_observer_; |
| 68 TestUnrecoverableErrorHandler handler_; | 74 TestUnrecoverableErrorHandler handler_; |
| 69 | 75 |
| 70 void RunInvariantCheck(); | 76 void RunInvariantCheck(); |
| 71 | 77 |
| 72 ScopedTempDir temp_dir_; | 78 ScopedTempDir temp_dir_; |
| 73 FakeSyncEncryptionHandler encryption_handler_; | 79 FakeSyncEncryptionHandler encryption_handler_; |
| 74 scoped_ptr<syncable::Directory> directory_; | 80 scoped_ptr<syncable::Directory> directory_; |
| 75 std::string name_; | 81 std::string name_; |
| 76 | 82 |
| 77 DISALLOW_COPY_AND_ASSIGN(TestDirectorySetterUpper); | 83 DISALLOW_COPY_AND_ASSIGN(TestDirectorySetterUpper); |
| 78 }; | 84 }; |
| 79 | 85 |
| 80 } // namespace syncer | 86 } // namespace syncer |
| 81 | 87 |
| 82 #endif // SYNC_TEST_ENGINE_TEST_DIRECTORY_SETTER_UPPER_H_ | 88 #endif // SYNC_TEST_ENGINE_TEST_DIRECTORY_SETTER_UPPER_H_ |
| OLD | NEW |