Chromium Code Reviews| 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 21 matching lines...) Expand all Loading... | |
| 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/base/model_type.h" |
| 35 #include "sync/internal_api/public/user_share.h" | 35 #include "sync/internal_api/public/user_share.h" |
| 36 | 36 |
| 37 namespace syncer { | 37 namespace syncer { |
| 38 | 38 |
| 39 class SyncEncryptionHandler; | 39 class SyncEncryptionHandler; |
| 40 class TestDirectorySetterUpper; | 40 class TestDirectorySetterUpper; |
| 41 | 41 |
| 42 namespace syncable { | |
| 43 class MockTransactionObserver; | |
| 44 } | |
| 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 // Returns the directory's transaction observer. This transaction observer | |
| 69 // has methods which can be helpful when writing test assertions. | |
| 70 syncable::MockTransactionObserver* transaction_observer(); | |
| 71 | |
| 64 // A helper function to pretend to download this type's root node. | 72 // A helper function to pretend to download this type's root node. |
| 65 static bool CreateRoot(syncer::ModelType model_type, | 73 static bool CreateRoot(syncer::ModelType model_type, |
| 66 syncer::UserShare* service); | 74 syncer::UserShare* service); |
| 67 | 75 |
| 76 | |
|
Nicolas Zea
2012/11/16 19:42:27
remove extra newline
rlarocque
2012/11/17 00:07:21
Done.
| |
| 68 private: | 77 private: |
| 69 scoped_ptr<TestDirectorySetterUpper> dir_maker_; | 78 scoped_ptr<TestDirectorySetterUpper> dir_maker_; |
| 70 scoped_ptr<UserShare> user_share_; | 79 scoped_ptr<UserShare> user_share_; |
| 71 | 80 |
| 72 DISALLOW_COPY_AND_ASSIGN(TestUserShare); | 81 DISALLOW_COPY_AND_ASSIGN(TestUserShare); |
| 73 }; | 82 }; |
| 74 | 83 |
| 75 } // namespace syncer | 84 } // namespace syncer |
| 76 | 85 |
| 77 #endif // SYNC_INTERNAL_API_PUBLIC_TEST_TEST_USER_SHARE_H_ | 86 #endif // SYNC_INTERNAL_API_PUBLIC_TEST_TEST_USER_SHARE_H_ |
| OLD | NEW |