| 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 #ifndef COMPONENTS_SYNC_TEST_ENGINE_TEST_DIRECTORY_SETTER_UPPER_H_ |
| 6 #define COMPONENTS_SYNC_TEST_ENGINE_TEST_DIRECTORY_SETTER_UPPER_H_ |
| 7 |
| 8 #include <memory> |
| 9 #include <string> |
| 10 |
| 11 #include "base/compiler_specific.h" |
| 12 #include "base/macros.h" |
| 13 #include "components/sync/base/test_unrecoverable_error_handler.h" |
| 14 #include "components/sync/test/fake_sync_encryption_handler.h" |
| 15 #include "components/sync/test/null_directory_change_delegate.h" |
| 16 #include "testing/gmock/include/gmock/gmock.h" |
| 17 |
| 18 namespace syncer { |
| 19 |
| 20 namespace syncable { |
| 21 class Directory; |
| 22 class DirectoryBackingStore; |
| 23 class TestTransactionObserver; |
| 24 } |
| 25 |
| 5 // A handy class that takes care of setting up and destroying a | 26 // A handy class that takes care of setting up and destroying a |
| 6 // syncable::Directory instance for unit tests that require one. | 27 // syncable::Directory instance for unit tests that require one. |
| 7 // | 28 // |
| 8 // The expected usage is to make this a component of your test fixture: | 29 // The expected usage is to make this a component of your test fixture: |
| 9 // | 30 // |
| 10 // class AwesomenessTest : public testing::Test { | 31 // class AwesomenessTest : public testing::Test { |
| 11 // public: | 32 // public: |
| 12 // virtual void SetUp() { | 33 // virtual void SetUp() { |
| 13 // metadb_.SetUp(); | 34 // metadb_.SetUp(); |
| 14 // } | 35 // } |
| 15 // virtual void TearDown() { | 36 // virtual void TearDown() { |
| 16 // metadb_.TearDown(); | 37 // metadb_.TearDown(); |
| 17 // } | 38 // } |
| 18 // protected: | 39 // protected: |
| 19 // TestDirectorySetterUpper metadb_; | 40 // TestDirectorySetterUpper metadb_; |
| 20 // }; | 41 // }; |
| 21 // | 42 // |
| 22 // Then, in your tests, get at the directory like so: | 43 // Then, in your tests, get at the directory like so: |
| 23 // | 44 // |
| 24 // TEST_F(AwesomenessTest, IsMaximal) { | 45 // TEST_F(AwesomenessTest, IsMaximal) { |
| 25 // ... now use metadb_.directory() to get at syncable::Entry objects ... | 46 // ... now use metadb_.directory() to get at syncable::Entry objects ... |
| 26 // } | 47 // } |
| 27 // | 48 // |
| 28 | |
| 29 #ifndef COMPONENTS_SYNC_TEST_ENGINE_TEST_DIRECTORY_SETTER_UPPER_H_ | |
| 30 #define COMPONENTS_SYNC_TEST_ENGINE_TEST_DIRECTORY_SETTER_UPPER_H_ | |
| 31 | |
| 32 #include <memory> | |
| 33 #include <string> | |
| 34 | |
| 35 #include "base/compiler_specific.h" | |
| 36 #include "base/macros.h" | |
| 37 #include "components/sync/base/test_unrecoverable_error_handler.h" | |
| 38 #include "components/sync/test/fake_sync_encryption_handler.h" | |
| 39 #include "components/sync/test/null_directory_change_delegate.h" | |
| 40 #include "testing/gmock/include/gmock/gmock.h" | |
| 41 | |
| 42 namespace syncer { | |
| 43 | |
| 44 namespace syncable { | |
| 45 class Directory; | |
| 46 class DirectoryBackingStore; | |
| 47 class TestTransactionObserver; | |
| 48 } | |
| 49 | |
| 50 class TestDirectorySetterUpper { | 49 class TestDirectorySetterUpper { |
| 51 public: | 50 public: |
| 52 TestDirectorySetterUpper(); | 51 TestDirectorySetterUpper(); |
| 53 virtual ~TestDirectorySetterUpper(); | 52 virtual ~TestDirectorySetterUpper(); |
| 54 | 53 |
| 55 // Create a Directory instance open it. | 54 // Create a Directory instance open it. |
| 56 virtual void SetUp(); | 55 virtual void SetUp(); |
| 57 | 56 |
| 58 // Create a Directory instance using |directory_store| as backend storage. | 57 // Create a Directory instance using |directory_store| as backend storage. |
| 59 // Takes ownership of |directory_store|. | 58 // Takes ownership of |directory_store|. |
| (...skipping 22 matching lines...) Expand all Loading... |
| 82 FakeSyncEncryptionHandler encryption_handler_; | 81 FakeSyncEncryptionHandler encryption_handler_; |
| 83 std::unique_ptr<syncable::Directory> directory_; | 82 std::unique_ptr<syncable::Directory> directory_; |
| 84 std::string name_; | 83 std::string name_; |
| 85 | 84 |
| 86 DISALLOW_COPY_AND_ASSIGN(TestDirectorySetterUpper); | 85 DISALLOW_COPY_AND_ASSIGN(TestDirectorySetterUpper); |
| 87 }; | 86 }; |
| 88 | 87 |
| 89 } // namespace syncer | 88 } // namespace syncer |
| 90 | 89 |
| 91 #endif // COMPONENTS_SYNC_TEST_ENGINE_TEST_DIRECTORY_SETTER_UPPER_H_ | 90 #endif // COMPONENTS_SYNC_TEST_ENGINE_TEST_DIRECTORY_SETTER_UPPER_H_ |
| OLD | NEW |