We started redesigning GpuMemoryBuffer interface to handle multiple buffers [0].
[chromium-blink-merge.git] / sync / test / engine / test_directory_setter_upper.h
blob587236a125977f62a0828be68f2b22b0290b6ec0
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
3 // found in the LICENSE file.
4 //
5 // A handy class that takes care of setting up and destroying a
6 // syncable::Directory instance for unit tests that require one.
7 //
8 // The expected usage is to make this a component of your test fixture:
9 //
10 // class AwesomenessTest : public testing::Test {
11 // public:
12 // virtual void SetUp() {
13 // metadb_.SetUp();
14 // }
15 // virtual void TearDown() {
16 // metadb_.TearDown();
17 // }
18 // protected:
19 // TestDirectorySetterUpper metadb_;
20 // };
22 // Then, in your tests, get at the directory like so:
24 // TEST_F(AwesomenessTest, IsMaximal) {
25 // ... now use metadb_.directory() to get at syncable::Entry objects ...
26 // }
29 #ifndef SYNC_TEST_ENGINE_TEST_DIRECTORY_SETTER_UPPER_H_
30 #define SYNC_TEST_ENGINE_TEST_DIRECTORY_SETTER_UPPER_H_
32 #include <string>
34 #include "base/basictypes.h"
35 #include "base/compiler_specific.h"
36 #include "base/memory/scoped_ptr.h"
37 #include "sync/test/fake_sync_encryption_handler.h"
38 #include "sync/test/null_directory_change_delegate.h"
39 #include "sync/util/test_unrecoverable_error_handler.h"
40 #include "testing/gmock/include/gmock/gmock.h"
42 namespace syncer {
44 namespace syncable {
45 class Directory;
46 class DirectoryBackingStore;
47 class TestTransactionObserver;
50 class TestDirectorySetterUpper {
51 public:
52 TestDirectorySetterUpper();
53 virtual ~TestDirectorySetterUpper();
55 // Create a Directory instance open it.
56 virtual void SetUp();
58 // Create a Directory instance using |directory_store| as backend storage.
59 // Takes ownership of |directory_store|.
60 virtual void SetUpWith(
61 syncer::syncable::DirectoryBackingStore* directory_store);
63 // Undo everything done by SetUp(): close the directory and delete the
64 // backing files. Before closing the directory, this will run the directory
65 // invariant checks and perform the SaveChanges action on the directory.
66 virtual void TearDown();
68 syncable::Directory* directory() { return directory_.get(); }
70 SyncEncryptionHandler* encryption_handler() { return &encryption_handler_; }
72 syncable::TestTransactionObserver* transaction_observer() {
73 return test_transaction_observer_.get();
76 private:
77 syncable::NullDirectoryChangeDelegate delegate_;
78 scoped_ptr<syncable::TestTransactionObserver> test_transaction_observer_;
79 TestUnrecoverableErrorHandler handler_;
81 void RunInvariantCheck();
83 FakeSyncEncryptionHandler encryption_handler_;
84 scoped_ptr<syncable::Directory> directory_;
85 std::string name_;
87 DISALLOW_COPY_AND_ASSIGN(TestDirectorySetterUpper);
90 } // namespace syncer
92 #endif // SYNC_TEST_ENGINE_TEST_DIRECTORY_SETTER_UPPER_H_