| 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 #include "chrome/browser/sync_file_system/drive_backend/leveldb_wrapper.h" | 5 #include "chrome/browser/sync_file_system/drive_backend/leveldb_wrapper.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/files/scoped_temp_dir.h" | 9 #include "base/files/scoped_temp_dir.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 20 matching lines...) Expand all Loading... |
| 31 in_memory_env_.reset(leveldb::NewMemEnv(leveldb::Env::Default())); | 31 in_memory_env_.reset(leveldb::NewMemEnv(leveldb::Env::Default())); |
| 32 InitializeLevelDB(); | 32 InitializeLevelDB(); |
| 33 } | 33 } |
| 34 | 34 |
| 35 virtual void TearDown() OVERRIDE { | 35 virtual void TearDown() OVERRIDE { |
| 36 db_.reset(); | 36 db_.reset(); |
| 37 in_memory_env_.reset(); | 37 in_memory_env_.reset(); |
| 38 } | 38 } |
| 39 | 39 |
| 40 void CreateDefaultDatabase() { | 40 void CreateDefaultDatabase() { |
| 41 leveldb::DB* db = db_->GetLevelDBForTesting(); | 41 leveldb::DB* db = db_->GetLevelDB(); |
| 42 | 42 |
| 43 // Expected contents are | 43 // Expected contents are |
| 44 // {"a": "1", "ab": "0", "bb": "3", "d": "4"} | 44 // {"a": "1", "ab": "0", "bb": "3", "d": "4"} |
| 45 const char* keys[] = {"ab", "a", "d", "bb", "d"}; | 45 const char* keys[] = {"ab", "a", "d", "bb", "d"}; |
| 46 for (size_t i = 0; i < arraysize(keys); ++i) { | 46 for (size_t i = 0; i < arraysize(keys); ++i) { |
| 47 leveldb::Status status = | 47 leveldb::Status status = |
| 48 db->Put(leveldb::WriteOptions(), keys[i], base::Int64ToString(i)); | 48 db->Put(leveldb::WriteOptions(), keys[i], base::Int64ToString(i)); |
| 49 ASSERT_TRUE(status.ok()); | 49 ASSERT_TRUE(status.ok()); |
| 50 } | 50 } |
| 51 } | 51 } |
| (...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 201 GetDB()->Delete("ab"); | 201 GetDB()->Delete("ab"); |
| 202 GetDB()->Commit(); | 202 GetDB()->Commit(); |
| 203 GetDB()->Clear(); | 203 GetDB()->Clear(); |
| 204 | 204 |
| 205 SCOPED_TRACE("DeleteTest_Commit"); | 205 SCOPED_TRACE("DeleteTest_Commit"); |
| 206 CheckDBContents(merged_data, arraysize(merged_data)); | 206 CheckDBContents(merged_data, arraysize(merged_data)); |
| 207 } | 207 } |
| 208 | 208 |
| 209 } // namespace drive_backend | 209 } // namespace drive_backend |
| 210 } // namespace sync_file_system | 210 } // namespace sync_file_system |
| OLD | NEW |