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 25 matching lines...) Expand all Loading... | |
36 #include "base/memory/scoped_ptr.h" | 36 #include "base/memory/scoped_ptr.h" |
37 #include "sync/test/fake_sync_encryption_handler.h" | 37 #include "sync/test/fake_sync_encryption_handler.h" |
38 #include "sync/test/null_directory_change_delegate.h" | 38 #include "sync/test/null_directory_change_delegate.h" |
39 #include "sync/util/test_unrecoverable_error_handler.h" | 39 #include "sync/util/test_unrecoverable_error_handler.h" |
40 #include "testing/gmock/include/gmock/gmock.h" | 40 #include "testing/gmock/include/gmock/gmock.h" |
41 | 41 |
42 namespace syncer { | 42 namespace syncer { |
43 | 43 |
44 namespace syncable { | 44 namespace syncable { |
45 class Directory; | 45 class Directory; |
46 class DirectoryBackingStore; | |
46 class TestTransactionObserver; | 47 class TestTransactionObserver; |
47 } | 48 } |
48 | 49 |
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 and open it. Take ownership of |
55 virtual void SetUp(); | 56 // |directory_store| and use it as backend storage if it's not NULL, |
57 // otherwise create an in-memory store. | |
58 virtual void SetUp(syncer::syncable::DirectoryBackingStore* directory_store); | |
tim (not reviewing)
2013/01/14 23:32:48
Could we have a separate SetUpWith(DBS*) function,
haitaol1
2013/01/15 19:44:31
Done.
| |
56 | 59 |
57 // Undo everything done by SetUp(): close the directory and delete the | 60 // Undo everything done by SetUp(): close the directory and delete the |
58 // backing files. Before closing the directory, this will run the directory | 61 // backing files. Before closing the directory, this will run the directory |
59 // invariant checks and perform the SaveChanges action on the directory. | 62 // invariant checks and perform the SaveChanges action on the directory. |
60 virtual void TearDown(); | 63 virtual void TearDown(); |
61 | 64 |
62 syncable::Directory* directory() { return directory_.get(); } | 65 syncable::Directory* directory() { return directory_.get(); } |
63 | 66 |
64 SyncEncryptionHandler* encryption_handler() { return &encryption_handler_; } | 67 SyncEncryptionHandler* encryption_handler() { return &encryption_handler_; } |
65 | 68 |
(...skipping 11 matching lines...) Expand all Loading... | |
77 FakeSyncEncryptionHandler encryption_handler_; | 80 FakeSyncEncryptionHandler encryption_handler_; |
78 scoped_ptr<syncable::Directory> directory_; | 81 scoped_ptr<syncable::Directory> directory_; |
79 std::string name_; | 82 std::string name_; |
80 | 83 |
81 DISALLOW_COPY_AND_ASSIGN(TestDirectorySetterUpper); | 84 DISALLOW_COPY_AND_ASSIGN(TestDirectorySetterUpper); |
82 }; | 85 }; |
83 | 86 |
84 } // namespace syncer | 87 } // namespace syncer |
85 | 88 |
86 #endif // SYNC_TEST_ENGINE_TEST_DIRECTORY_SETTER_UPPER_H_ | 89 #endif // SYNC_TEST_ENGINE_TEST_DIRECTORY_SETTER_UPPER_H_ |
OLD | NEW |