| 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 18 matching lines...) Expand all Loading... |
| 29 #ifndef SYNC_TEST_ENGINE_TEST_DIRECTORY_SETTER_UPPER_H_ | 29 #ifndef SYNC_TEST_ENGINE_TEST_DIRECTORY_SETTER_UPPER_H_ |
| 30 #define SYNC_TEST_ENGINE_TEST_DIRECTORY_SETTER_UPPER_H_ | 30 #define SYNC_TEST_ENGINE_TEST_DIRECTORY_SETTER_UPPER_H_ |
| 31 #pragma once | 31 #pragma once |
| 32 | 32 |
| 33 #include <string> | 33 #include <string> |
| 34 | 34 |
| 35 #include "base/basictypes.h" | 35 #include "base/basictypes.h" |
| 36 #include "base/compiler_specific.h" | 36 #include "base/compiler_specific.h" |
| 37 #include "base/memory/scoped_ptr.h" | 37 #include "base/memory/scoped_ptr.h" |
| 38 #include "base/scoped_temp_dir.h" | 38 #include "base/scoped_temp_dir.h" |
| 39 #include "sync/util/test_unrecoverable_error_handler.h" | |
| 40 #include "sync/syncable/syncable.h" | |
| 41 #include "sync/test/fake_encryptor.h" | 39 #include "sync/test/fake_encryptor.h" |
| 42 #include "sync/test/null_directory_change_delegate.h" | 40 #include "sync/test/null_directory_change_delegate.h" |
| 41 #include "sync/util/test_unrecoverable_error_handler.h" |
| 43 #include "testing/gmock/include/gmock/gmock.h" | 42 #include "testing/gmock/include/gmock/gmock.h" |
| 44 | 43 |
| 44 namespace syncable { |
| 45 class Directory; |
| 46 } |
| 47 |
| 45 namespace browser_sync { | 48 namespace browser_sync { |
| 46 | 49 |
| 47 class TestDirectorySetterUpper { | 50 class TestDirectorySetterUpper { |
| 48 public: | 51 public: |
| 49 TestDirectorySetterUpper(); | 52 TestDirectorySetterUpper(); |
| 50 virtual ~TestDirectorySetterUpper(); | 53 virtual ~TestDirectorySetterUpper(); |
| 51 | 54 |
| 52 // Create a Directory instance open it. | 55 // Create a Directory instance open it. |
| 53 virtual void SetUp(); | 56 virtual void SetUp(); |
| 54 | 57 |
| 55 // Undo everything done by SetUp(): close the directory and delete the | 58 // Undo everything done by SetUp(): close the directory and delete the |
| 56 // backing files. Before closing the directory, this will run the directory | 59 // backing files. Before closing the directory, this will run the directory |
| 57 // invariant checks and perform the SaveChanges action on the directory. | 60 // invariant checks and perform the SaveChanges action on the directory. |
| 58 virtual void TearDown(); | 61 virtual void TearDown(); |
| 59 | 62 |
| 60 syncable::Directory* directory() { return directory_.get(); } | 63 syncable::Directory* directory() { return directory_.get(); } |
| 61 | 64 |
| 62 protected: | 65 private: |
| 63 syncable::NullDirectoryChangeDelegate delegate_; | 66 syncable::NullDirectoryChangeDelegate delegate_; |
| 64 TestUnrecoverableErrorHandler handler_; | 67 TestUnrecoverableErrorHandler handler_; |
| 65 | 68 |
| 66 private: | |
| 67 void RunInvariantCheck(); | 69 void RunInvariantCheck(); |
| 68 | 70 |
| 69 ScopedTempDir temp_dir_; | 71 ScopedTempDir temp_dir_; |
| 70 FakeEncryptor encryptor_; | 72 FakeEncryptor encryptor_; |
| 71 scoped_ptr<syncable::Directory> directory_; | 73 scoped_ptr<syncable::Directory> directory_; |
| 72 std::string name_; | 74 std::string name_; |
| 73 | 75 |
| 74 DISALLOW_COPY_AND_ASSIGN(TestDirectorySetterUpper); | 76 DISALLOW_COPY_AND_ASSIGN(TestDirectorySetterUpper); |
| 75 }; | 77 }; |
| 76 | 78 |
| 77 } // namespace browser_sync | 79 } // namespace browser_sync |
| 78 | 80 |
| 79 #endif // SYNC_TEST_ENGINE_TEST_DIRECTORY_SETTER_UPPER_H_ | 81 #endif // SYNC_TEST_ENGINE_TEST_DIRECTORY_SETTER_UPPER_H_ |
| OLD | NEW |