| 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 #ifndef COMPONENTS_SYNC_SYNCABLE_TEST_USER_SHARE_H_ |
| 6 #define COMPONENTS_SYNC_SYNCABLE_TEST_USER_SHARE_H_ |
| 7 |
| 8 #include <stddef.h> |
| 9 |
| 10 #include <memory> |
| 11 |
| 12 #include "base/macros.h" |
| 13 #include "components/sync/base/model_type.h" |
| 14 #include "components/sync/syncable/user_share.h" |
| 15 |
| 16 namespace syncer { |
| 17 |
| 18 class SyncEncryptionHandler; |
| 19 class TestDirectorySetterUpper; |
| 20 |
| 21 namespace syncable { |
| 22 class TestTransactionObserver; |
| 23 } |
| 24 |
| 5 // A handy class that takes care of setting up and destroying a | 25 // A handy class that takes care of setting up and destroying a |
| 6 // UserShare instance for unit tests that require one. | 26 // UserShare instance for unit tests that require one. |
| 7 // | 27 // |
| 8 // The expected usage is to make this a component of your test fixture: | 28 // The expected usage is to make this a component of your test fixture: |
| 9 // | 29 // |
| 10 // class AwesomenessTest : public testing::Test { | 30 // class AwesomenessTest : public testing::Test { |
| 11 // public: | 31 // public: |
| 12 // virtual void SetUp() { | 32 // virtual void SetUp() { |
| 13 // test_user_share_.SetUp(); | 33 // test_user_share_.SetUp(); |
| 14 // } | 34 // } |
| 15 // virtual void TearDown() { | 35 // virtual void TearDown() { |
| 16 // test_user_share_.TearDown(); | 36 // test_user_share_.TearDown(); |
| 17 // } | 37 // } |
| 18 // protected: | 38 // protected: |
| 19 // TestUserShare test_user_share_; | 39 // TestUserShare test_user_share_; |
| 20 // }; | 40 // }; |
| 21 // | 41 // |
| 22 // Then, in your tests: | 42 // Then, in your tests: |
| 23 // | 43 // |
| 24 // TEST_F(AwesomenessTest, IsMaximal) { | 44 // TEST_F(AwesomenessTest, IsMaximal) { |
| 25 // ReadTransaction trans(test_user_share_.user_share()); | 45 // ReadTransaction trans(test_user_share_.user_share()); |
| 26 // ... | 46 // ... |
| 27 // } | 47 // } |
| 28 // | 48 // |
| 29 | |
| 30 #ifndef COMPONENTS_SYNC_SYNCABLE_TEST_USER_SHARE_H_ | |
| 31 #define COMPONENTS_SYNC_SYNCABLE_TEST_USER_SHARE_H_ | |
| 32 | |
| 33 #include <stddef.h> | |
| 34 | |
| 35 #include <memory> | |
| 36 | |
| 37 #include "base/macros.h" | |
| 38 #include "components/sync/base/model_type.h" | |
| 39 #include "components/sync/syncable/user_share.h" | |
| 40 | |
| 41 namespace syncer { | |
| 42 | |
| 43 class SyncEncryptionHandler; | |
| 44 class TestDirectorySetterUpper; | |
| 45 | |
| 46 namespace syncable { | |
| 47 class TestTransactionObserver; | |
| 48 } | |
| 49 | |
| 50 class TestUserShare { | 49 class TestUserShare { |
| 51 public: | 50 public: |
| 52 TestUserShare(); | 51 TestUserShare(); |
| 53 ~TestUserShare(); | 52 ~TestUserShare(); |
| 54 | 53 |
| 55 // Sets up the UserShare instance. Clears any existing database | 54 // Sets up the UserShare instance. Clears any existing database |
| 56 // backing files that might exist on disk. | 55 // backing files that might exist on disk. |
| 57 void SetUp(); | 56 void SetUp(); |
| 58 | 57 |
| 59 // Undo everything done by SetUp(): closes the UserShare and deletes | 58 // Undo everything done by SetUp(): closes the UserShare and deletes |
| (...skipping 24 matching lines...) Expand all Loading... |
| 84 private: | 83 private: |
| 85 std::unique_ptr<TestDirectorySetterUpper> dir_maker_; | 84 std::unique_ptr<TestDirectorySetterUpper> dir_maker_; |
| 86 std::unique_ptr<UserShare> user_share_; | 85 std::unique_ptr<UserShare> user_share_; |
| 87 | 86 |
| 88 DISALLOW_COPY_AND_ASSIGN(TestUserShare); | 87 DISALLOW_COPY_AND_ASSIGN(TestUserShare); |
| 89 }; | 88 }; |
| 90 | 89 |
| 91 } // namespace syncer | 90 } // namespace syncer |
| 92 | 91 |
| 93 #endif // COMPONENTS_SYNC_SYNCABLE_TEST_USER_SHARE_H_ | 92 #endif // COMPONENTS_SYNC_SYNCABLE_TEST_USER_SHARE_H_ |
| OLD | NEW |