| 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: | |
| 35 protected: | 34 protected: |
| 36 static const char kDirectoryName[]; | 35 static const char kDirectoryName[]; |
| 37 | 36 |
| 38 SyncableDirectoryTest(); | 37 SyncableDirectoryTest(); |
| 39 virtual ~SyncableDirectoryTest(); | 38 virtual ~SyncableDirectoryTest(); |
| 40 | 39 |
| 41 virtual void SetUp(); | 40 virtual void SetUp(); |
| 42 virtual void TearDown(); | 41 virtual void TearDown(); |
| 43 | 42 |
| 44 // Destroys any currently opened directory, creates and opens a new one. | 43 // Destroys any currently opened directory, creates and opens a new one. |
| 45 // | 44 // |
| 46 // Returns result of the Open call. | 45 // Returns result of the Open call. |
| 47 DirOpenResult ReopenDirectory(); | 46 DirOpenResult ReopenDirectory(); |
| 48 | 47 |
| 49 // Creates an empty entry and sets the ID field to a default one. | 48 // Creates an empty entry and sets the ID field to a default one. |
| 50 void CreateEntry(const std::string& entryname); | 49 void CreateEntry(const ModelType& model_type, const std::string& entryname); |
| 51 | 50 |
| 52 // Creates an empty entry and sets the ID field to id. | 51 // Creates an empty entry and sets the ID field to id. |
| 53 void CreateEntry(const std::string& entryname, const int id); | 52 void CreateEntry(const ModelType& model_type, |
| 53 const std::string& entryname, |
| 54 const int id); |
| 54 | 55 |
| 55 void CreateEntry(const std::string& entryname, Id id); | 56 void CreateEntry(const ModelType& model_type, |
| 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); |
| 56 | 67 |
| 57 // When a directory is saved then loaded from disk, it will pass through | 68 // When a directory is saved then loaded from disk, it will pass through |
| 58 // DropDeletedEntries(). This will remove some entries from the directory. | 69 // DropDeletedEntries(). This will remove some entries from the directory. |
| 59 // This function is intended to simulate that process. | 70 // This function is intended to simulate that process. |
| 60 // | 71 // |
| 61 // WARNING: The directory will be deleted by this operation. You should | 72 // WARNING: The directory will be deleted by this operation. You should |
| 62 // not have any pointers to the directory (open transactions included) | 73 // not have any pointers to the directory (open transactions included) |
| 63 // when you call this. | 74 // when you call this. |
| 64 DirOpenResult SimulateSaveAndReloadDir(); | 75 DirOpenResult SimulateSaveAndReloadDir(); |
| 65 | 76 |
| (...skipping 28 matching lines...) Expand all Loading... |
| 94 FakeEncryptor encryptor_; | 105 FakeEncryptor encryptor_; |
| 95 TestUnrecoverableErrorHandler handler_; | 106 TestUnrecoverableErrorHandler handler_; |
| 96 sql::Connection connection_; | 107 sql::Connection connection_; |
| 97 }; | 108 }; |
| 98 | 109 |
| 99 } // namespace syncable | 110 } // namespace syncable |
| 100 | 111 |
| 101 } // namespace syncer | 112 } // namespace syncer |
| 102 | 113 |
| 103 #endif // SYNC_SYNCABLE_DIRECTORY_UNITTEST_H_ | 114 #endif // SYNC_SYNCABLE_DIRECTORY_UNITTEST_H_ |
| OLD | NEW |