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 // UserShare instance for unit tests that require one. | 6 // UserShare 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 13 matching lines...) Expand all Loading... | |
24 // TEST_F(AwesomenessTest, IsMaximal) { | 24 // TEST_F(AwesomenessTest, IsMaximal) { |
25 // ReadTransaction trans(test_user_share_.user_share()); | 25 // ReadTransaction trans(test_user_share_.user_share()); |
26 // ... | 26 // ... |
27 // } | 27 // } |
28 // | 28 // |
29 | 29 |
30 #ifndef SYNC_INTERNAL_API_PUBLIC_TEST_TEST_USER_SHARE_H_ | 30 #ifndef SYNC_INTERNAL_API_PUBLIC_TEST_TEST_USER_SHARE_H_ |
31 #define SYNC_INTERNAL_API_PUBLIC_TEST_TEST_USER_SHARE_H_ | 31 #define SYNC_INTERNAL_API_PUBLIC_TEST_TEST_USER_SHARE_H_ |
32 | 32 |
33 #include "base/basictypes.h" | 33 #include "base/basictypes.h" |
34 #include "sync/internal_api/public/base/model_type.h" | |
34 #include "sync/internal_api/public/user_share.h" | 35 #include "sync/internal_api/public/user_share.h" |
35 | 36 |
36 namespace syncer { | 37 namespace syncer { |
37 | 38 |
38 class SyncEncryptionHandler; | 39 class SyncEncryptionHandler; |
40 class TestDirectorySetterUpper; | |
39 | 41 |
40 class TestDirectorySetterUpper; | 42 namespace syncable { |
43 class MockTransactionObserver; | |
44 } | |
41 | 45 |
42 class TestUserShare { | 46 class TestUserShare { |
43 public: | 47 public: |
44 TestUserShare(); | 48 TestUserShare(); |
45 ~TestUserShare(); | 49 ~TestUserShare(); |
46 | 50 |
47 // Sets up the UserShare instance. Clears any existing database | 51 // Sets up the UserShare instance. Clears any existing database |
48 // backing files that might exist on disk. | 52 // backing files that might exist on disk. |
49 void SetUp(); | 53 void SetUp(); |
50 | 54 |
51 // Undo everything done by SetUp(): closes the UserShare and deletes | 55 // Undo everything done by SetUp(): closes the UserShare and deletes |
52 // the backing files. Before closing the directory, this will run | 56 // the backing files. Before closing the directory, this will run |
53 // the directory invariant checks and perform the SaveChanges action | 57 // the directory invariant checks and perform the SaveChanges action |
54 // on the user share's directory. | 58 // on the user share's directory. |
55 void TearDown(); | 59 void TearDown(); |
56 | 60 |
57 // Non-NULL iff called between a call to SetUp() and TearDown(). | 61 // Non-NULL iff called between a call to SetUp() and TearDown(). |
58 UserShare* user_share(); | 62 UserShare* user_share(); |
59 | 63 |
60 // Sync's encryption handler. Used by tests to invoke the sync encryption | 64 // Sync's encryption handler. Used by tests to invoke the sync encryption |
61 // methods normally handled via the SyncBackendHost | 65 // methods normally handled via the SyncBackendHost |
62 SyncEncryptionHandler* encryption_handler(); | 66 SyncEncryptionHandler* encryption_handler(); |
63 | 67 |
68 syncable::MockTransactionObserver* transaction_observer(); | |
Nicolas Zea
2012/09/14 19:15:08
comment about method
rlarocque
2012/09/15 01:36:37
Done.
| |
69 | |
64 private: | 70 private: |
65 scoped_ptr<TestDirectorySetterUpper> dir_maker_; | 71 scoped_ptr<TestDirectorySetterUpper> dir_maker_; |
66 scoped_ptr<UserShare> user_share_; | 72 scoped_ptr<UserShare> user_share_; |
67 | 73 |
68 DISALLOW_COPY_AND_ASSIGN(TestUserShare); | 74 DISALLOW_COPY_AND_ASSIGN(TestUserShare); |
69 }; | 75 }; |
70 | 76 |
71 } // namespace syncer | 77 } // namespace syncer |
72 | 78 |
73 #endif // SYNC_INTERNAL_API_PUBLIC_TEST_TEST_USER_SHARE_H_ | 79 #endif // SYNC_INTERNAL_API_PUBLIC_TEST_TEST_USER_SHARE_H_ |
OLD | NEW |