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 21 matching lines...) Expand all Loading... |
32 #include <string> | 32 #include <string> |
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 "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 { |
| 43 |
42 namespace syncable { | 44 namespace syncable { |
43 class Directory; | 45 class Directory; |
| 46 class TestTransactionObserver; |
44 } | 47 } |
45 | 48 |
46 namespace syncer { | |
47 | |
48 class TestDirectorySetterUpper { | 49 class TestDirectorySetterUpper { |
49 public: | 50 public: |
50 TestDirectorySetterUpper(); | 51 TestDirectorySetterUpper(); |
51 virtual ~TestDirectorySetterUpper(); | 52 virtual ~TestDirectorySetterUpper(); |
52 | 53 |
53 // Create a Directory instance open it. | 54 // Create a Directory instance open it. |
54 virtual void SetUp(); | 55 virtual void SetUp(); |
55 | 56 |
56 // Undo everything done by SetUp(): close the directory and delete the | 57 // Undo everything done by SetUp(): close the directory and delete the |
57 // backing files. Before closing the directory, this will run the directory | 58 // backing files. Before closing the directory, this will run the directory |
58 // invariant checks and perform the SaveChanges action on the directory. | 59 // invariant checks and perform the SaveChanges action on the directory. |
59 virtual void TearDown(); | 60 virtual void TearDown(); |
60 | 61 |
61 syncable::Directory* directory() { return directory_.get(); } | 62 syncable::Directory* directory() { return directory_.get(); } |
62 | 63 |
63 SyncEncryptionHandler* encryption_handler() { return &encryption_handler_; } | 64 SyncEncryptionHandler* encryption_handler() { return &encryption_handler_; } |
64 | 65 |
| 66 syncable::TestTransactionObserver* transaction_observer() { |
| 67 return test_transaction_observer_.get(); |
| 68 } |
| 69 |
65 private: | 70 private: |
66 syncable::NullDirectoryChangeDelegate delegate_; | 71 syncable::NullDirectoryChangeDelegate delegate_; |
| 72 scoped_ptr<syncable::TestTransactionObserver> test_transaction_observer_; |
67 TestUnrecoverableErrorHandler handler_; | 73 TestUnrecoverableErrorHandler handler_; |
68 | 74 |
69 void RunInvariantCheck(); | 75 void RunInvariantCheck(); |
70 | 76 |
71 FakeSyncEncryptionHandler encryption_handler_; | 77 FakeSyncEncryptionHandler encryption_handler_; |
72 scoped_ptr<syncable::Directory> directory_; | 78 scoped_ptr<syncable::Directory> directory_; |
73 std::string name_; | 79 std::string name_; |
74 | 80 |
75 DISALLOW_COPY_AND_ASSIGN(TestDirectorySetterUpper); | 81 DISALLOW_COPY_AND_ASSIGN(TestDirectorySetterUpper); |
76 }; | 82 }; |
77 | 83 |
78 } // namespace syncer | 84 } // namespace syncer |
79 | 85 |
80 #endif // SYNC_TEST_ENGINE_TEST_DIRECTORY_SETTER_UPPER_H_ | 86 #endif // SYNC_TEST_ENGINE_TEST_DIRECTORY_SETTER_UPPER_H_ |
OLD | NEW |