| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 SYNC_SYNCABLE_DIRECTORY_UNITTEST_H_ | 5 #ifndef SYNC_SYNCABLE_DIRECTORY_UNITTEST_H_ |
| 6 #define SYNC_SYNCABLE_DIRECTORY_UNITTEST_H_ | 6 #define SYNC_SYNCABLE_DIRECTORY_UNITTEST_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| (...skipping 13 matching lines...) Expand all Loading... |
| 24 | 24 |
| 25 namespace syncable { | 25 namespace syncable { |
| 26 | 26 |
| 27 class BaseTransaction; | 27 class BaseTransaction; |
| 28 | 28 |
| 29 // A test fixture for syncable::Directory. Uses an in-memory database to keep | 29 // A test fixture for syncable::Directory. Uses an in-memory database to keep |
| 30 // the unit tests fast. | 30 // the unit tests fast. |
| 31 // | 31 // |
| 32 // Serves as base class for several other test fixtures. | 32 // Serves as base class for several other test fixtures. |
| 33 class SyncableDirectoryTest : public testing::Test { | 33 class SyncableDirectoryTest : public testing::Test { |
| 34 private: |
| 34 protected: | 35 protected: |
| 35 static const char kDirectoryName[]; | 36 static const char kDirectoryName[]; |
| 36 | 37 |
| 37 SyncableDirectoryTest(); | 38 SyncableDirectoryTest(); |
| 38 virtual ~SyncableDirectoryTest(); | 39 virtual ~SyncableDirectoryTest(); |
| 39 | 40 |
| 40 virtual void SetUp(); | 41 virtual void SetUp(); |
| 41 virtual void TearDown(); | 42 virtual void TearDown(); |
| 42 | 43 |
| 43 // Destroys any currently opened directory, creates and opens a new one. | 44 // Destroys any currently opened directory, creates and opens a new one. |
| 44 // | 45 // |
| 45 // Returns result of the Open call. | 46 // Returns result of the Open call. |
| 46 DirOpenResult ReopenDirectory(); | 47 DirOpenResult ReopenDirectory(); |
| 47 | 48 |
| 48 // Creates an empty entry and sets the ID field to a default one. | 49 // Creates an empty entry and sets the ID field to a default one. |
| 49 void CreateEntry(const ModelType& model_type, const std::string& entryname); | 50 void CreateEntry(const std::string& entryname); |
| 50 | 51 |
| 51 // Creates an empty entry and sets the ID field to id. | 52 // Creates an empty entry and sets the ID field to id. |
| 52 void CreateEntry(const ModelType& model_type, | 53 void CreateEntry(const std::string& entryname, const int id); |
| 53 const std::string& entryname, | |
| 54 const int id); | |
| 55 | 54 |
| 56 void CreateEntry(const ModelType& model_type, | 55 void CreateEntry(const std::string& entryname, Id id); |
| 57 const std::string& entryname, | |
| 58 const Id& id); | |
| 59 | |
| 60 void CreateEntryWithAttachmentMetadata( | |
| 61 const ModelType& model_type, | |
| 62 const std::string& entryname, | |
| 63 const Id& id, | |
| 64 const sync_pb::AttachmentMetadata& attachment_metadata); | |
| 65 | |
| 66 void DeleteEntry(const Id& id); | |
| 67 | 56 |
| 68 // When a directory is saved then loaded from disk, it will pass through | 57 // When a directory is saved then loaded from disk, it will pass through |
| 69 // DropDeletedEntries(). This will remove some entries from the directory. | 58 // DropDeletedEntries(). This will remove some entries from the directory. |
| 70 // This function is intended to simulate that process. | 59 // This function is intended to simulate that process. |
| 71 // | 60 // |
| 72 // WARNING: The directory will be deleted by this operation. You should | 61 // WARNING: The directory will be deleted by this operation. You should |
| 73 // not have any pointers to the directory (open transactions included) | 62 // not have any pointers to the directory (open transactions included) |
| 74 // when you call this. | 63 // when you call this. |
| 75 DirOpenResult SimulateSaveAndReloadDir(); | 64 DirOpenResult SimulateSaveAndReloadDir(); |
| 76 | 65 |
| (...skipping 28 matching lines...) Expand all Loading... |
| 105 FakeEncryptor encryptor_; | 94 FakeEncryptor encryptor_; |
| 106 TestUnrecoverableErrorHandler handler_; | 95 TestUnrecoverableErrorHandler handler_; |
| 107 sql::Connection connection_; | 96 sql::Connection connection_; |
| 108 }; | 97 }; |
| 109 | 98 |
| 110 } // namespace syncable | 99 } // namespace syncable |
| 111 | 100 |
| 112 } // namespace syncer | 101 } // namespace syncer |
| 113 | 102 |
| 114 #endif // SYNC_SYNCABLE_DIRECTORY_UNITTEST_H_ | 103 #endif // SYNC_SYNCABLE_DIRECTORY_UNITTEST_H_ |
| OLD | NEW |