| 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 "extensions/browser/value_store/value_store_unittest.h" | 5 #include "extensions/browser/value_store/value_store_unittest.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include "base/files/file_enumerator.h" | 9 #include "base/files/file_enumerator.h" |
| 10 #include "base/files/file_util.h" | 10 #include "base/files/file_util.h" |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 53 } | 53 } |
| 54 | 54 |
| 55 void CloseStore() { store_.reset(); } | 55 void CloseStore() { store_.reset(); } |
| 56 | 56 |
| 57 void CreateStore() { | 57 void CreateStore() { |
| 58 store_.reset( | 58 store_.reset( |
| 59 new LeveldbValueStore(kDatabaseUMAClientName, database_path())); | 59 new LeveldbValueStore(kDatabaseUMAClientName, database_path())); |
| 60 } | 60 } |
| 61 | 61 |
| 62 LeveldbValueStore* store() { return store_.get(); } | 62 LeveldbValueStore* store() { return store_.get(); } |
| 63 const base::FilePath& database_path() { return database_dir_.path(); } | 63 const base::FilePath& database_path() { return database_dir_.GetPath(); } |
| 64 | 64 |
| 65 private: | 65 private: |
| 66 std::unique_ptr<LeveldbValueStore> store_; | 66 std::unique_ptr<LeveldbValueStore> store_; |
| 67 base::ScopedTempDir database_dir_; | 67 base::ScopedTempDir database_dir_; |
| 68 | 68 |
| 69 content::TestBrowserThreadBundle thread_bundle_; | 69 content::TestBrowserThreadBundle thread_bundle_; |
| 70 }; | 70 }; |
| 71 | 71 |
| 72 // Check that we can restore a single corrupted key in the LeveldbValueStore. | 72 // Check that we can restore a single corrupted key in the LeveldbValueStore. |
| 73 TEST_F(LeveldbValueStoreUnitTest, RestoreKeyTest) { | 73 TEST_F(LeveldbValueStoreUnitTest, RestoreKeyTest) { |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 181 } | 181 } |
| 182 CreateStore(); | 182 CreateStore(); |
| 183 | 183 |
| 184 // We couldn't recover anything, but we should be in a sane state again. | 184 // We couldn't recover anything, but we should be in a sane state again. |
| 185 ValueStore::ReadResult result = store()->Get(); | 185 ValueStore::ReadResult result = store()->Get(); |
| 186 ASSERT_EQ(ValueStore::DB_RESTORE_REPAIR_SUCCESS, | 186 ASSERT_EQ(ValueStore::DB_RESTORE_REPAIR_SUCCESS, |
| 187 result->status().restore_status); | 187 result->status().restore_status); |
| 188 EXPECT_TRUE(result->status().ok()); | 188 EXPECT_TRUE(result->status().ok()); |
| 189 EXPECT_EQ(0u, result->settings().size()); | 189 EXPECT_EQ(0u, result->settings().size()); |
| 190 } | 190 } |
| OLD | NEW |