OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 20 matching lines...) Expand all Loading... |
31 #define CHROME_TEST_SYNC_ENGINE_TEST_DIRECTORY_SETTER_UPPER_H_ | 31 #define CHROME_TEST_SYNC_ENGINE_TEST_DIRECTORY_SETTER_UPPER_H_ |
32 #pragma once | 32 #pragma once |
33 | 33 |
34 #include <string> | 34 #include <string> |
35 | 35 |
36 #include "base/basictypes.h" | 36 #include "base/basictypes.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 "chrome/browser/sync/syncable/directory_manager.h" | 39 #include "chrome/browser/sync/syncable/directory_manager.h" |
40 #include "chrome/browser/sync/syncable/syncable.h" | 40 #include "chrome/browser/sync/syncable/syncable.h" |
| 41 #include "chrome/test/sync/null_directory_change_delegate.h" |
41 #include "testing/gmock/include/gmock/gmock.h" | 42 #include "testing/gmock/include/gmock/gmock.h" |
42 | 43 |
43 namespace syncable { | 44 namespace syncable { |
44 class DirectoryManager; | 45 class DirectoryManager; |
45 class ScopedDirLookup; | 46 class ScopedDirLookup; |
46 } // namespace syncable | 47 } // namespace syncable |
47 | 48 |
48 namespace browser_sync { | 49 namespace browser_sync { |
49 | 50 |
50 class TestDirectorySetterUpper { | 51 class TestDirectorySetterUpper { |
(...skipping 12 matching lines...) Expand all Loading... |
63 | 64 |
64 syncable::DirectoryManager* manager() const { return manager_.get(); } | 65 syncable::DirectoryManager* manager() const { return manager_.get(); } |
65 const std::string& name() const { return name_; } | 66 const std::string& name() const { return name_; } |
66 | 67 |
67 protected: | 68 protected: |
68 // Subclasses may want to use a different directory name. | 69 // Subclasses may want to use a different directory name. |
69 explicit TestDirectorySetterUpper(const std::string& name); | 70 explicit TestDirectorySetterUpper(const std::string& name); |
70 virtual void Init(); | 71 virtual void Init(); |
71 void reset_directory_manager(syncable::DirectoryManager* d); | 72 void reset_directory_manager(syncable::DirectoryManager* d); |
72 | 73 |
| 74 syncable::NullDirectoryChangeDelegate delegate_; |
| 75 |
73 private: | 76 private: |
74 void RunInvariantCheck(const syncable::ScopedDirLookup& dir); | 77 void RunInvariantCheck(const syncable::ScopedDirLookup& dir); |
75 | 78 |
76 scoped_ptr<syncable::DirectoryManager> manager_; | 79 scoped_ptr<syncable::DirectoryManager> manager_; |
77 const std::string name_; | 80 const std::string name_; |
78 ScopedTempDir temp_dir_; | 81 ScopedTempDir temp_dir_; |
79 | 82 |
80 DISALLOW_COPY_AND_ASSIGN(TestDirectorySetterUpper); | 83 DISALLOW_COPY_AND_ASSIGN(TestDirectorySetterUpper); |
81 }; | 84 }; |
82 | 85 |
(...skipping 30 matching lines...) Expand all Loading... |
113 public: | 116 public: |
114 Manager(const FilePath& root_path, syncable::Directory* dir); | 117 Manager(const FilePath& root_path, syncable::Directory* dir); |
115 virtual ~Manager() { managed_directory_ = NULL; } | 118 virtual ~Manager() { managed_directory_ = NULL; } |
116 }; | 119 }; |
117 | 120 |
118 class MockDirectory : public syncable::Directory { | 121 class MockDirectory : public syncable::Directory { |
119 public: | 122 public: |
120 explicit MockDirectory(const std::string& name); | 123 explicit MockDirectory(const std::string& name); |
121 virtual ~MockDirectory(); | 124 virtual ~MockDirectory(); |
122 MOCK_METHOD1(PurgeEntriesWithTypeIn, void(const syncable::ModelTypeSet&)); | 125 MOCK_METHOD1(PurgeEntriesWithTypeIn, void(const syncable::ModelTypeSet&)); |
| 126 |
| 127 private: |
| 128 syncable::NullDirectoryChangeDelegate delegate_; |
123 }; | 129 }; |
124 | 130 |
125 MockDirectorySetterUpper(); | 131 MockDirectorySetterUpper(); |
126 virtual ~MockDirectorySetterUpper(); | 132 virtual ~MockDirectorySetterUpper(); |
127 | 133 |
128 virtual void SetUp(); | 134 virtual void SetUp(); |
129 virtual void TearDown(); | 135 virtual void TearDown(); |
130 MockDirectory* directory() { return directory_.get(); } | 136 MockDirectory* directory() { return directory_.get(); } |
131 | 137 |
132 private: | 138 private: |
133 scoped_ptr<MockDirectory> directory_; | 139 scoped_ptr<MockDirectory> directory_; |
134 }; | 140 }; |
135 | 141 |
136 } // namespace browser_sync | 142 } // namespace browser_sync |
137 | 143 |
138 #endif // CHROME_TEST_SYNC_ENGINE_TEST_DIRECTORY_SETTER_UPPER_H_ | 144 #endif // CHROME_TEST_SYNC_ENGINE_TEST_DIRECTORY_SETTER_UPPER_H_ |
OLD | NEW |