| 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 "base/files/file_enumerator.h" | 7 #include "base/files/file_enumerator.h" |
| 8 #include "base/files/file_util.h" | 8 #include "base/files/file_util.h" |
| 9 #include "base/files/scoped_temp_dir.h" | 9 #include "base/files/scoped_temp_dir.h" |
| 10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
| (...skipping 17 matching lines...) Expand all Loading... |
| 28 LeveldbValueStore, | 28 LeveldbValueStore, |
| 29 ValueStoreTest, | 29 ValueStoreTest, |
| 30 testing::Values(&Param)); | 30 testing::Values(&Param)); |
| 31 | 31 |
| 32 class LeveldbValueStoreUnitTest : public testing::Test { | 32 class LeveldbValueStoreUnitTest : public testing::Test { |
| 33 public: | 33 public: |
| 34 LeveldbValueStoreUnitTest() {} | 34 LeveldbValueStoreUnitTest() {} |
| 35 virtual ~LeveldbValueStoreUnitTest() {} | 35 virtual ~LeveldbValueStoreUnitTest() {} |
| 36 | 36 |
| 37 protected: | 37 protected: |
| 38 virtual void SetUp() OVERRIDE { | 38 virtual void SetUp() override { |
| 39 ASSERT_TRUE(database_dir_.CreateUniqueTempDir()); | 39 ASSERT_TRUE(database_dir_.CreateUniqueTempDir()); |
| 40 OpenStore(); | 40 OpenStore(); |
| 41 ASSERT_FALSE(store_->Get()->HasError()); | 41 ASSERT_FALSE(store_->Get()->HasError()); |
| 42 } | 42 } |
| 43 | 43 |
| 44 virtual void TearDown() OVERRIDE { | 44 virtual void TearDown() override { |
| 45 store_->Clear(); | 45 store_->Clear(); |
| 46 store_.reset(); | 46 store_.reset(); |
| 47 } | 47 } |
| 48 | 48 |
| 49 void CloseStore() { store_.reset(); } | 49 void CloseStore() { store_.reset(); } |
| 50 | 50 |
| 51 void OpenStore() { store_.reset(new LeveldbValueStore(database_path())); } | 51 void OpenStore() { store_.reset(new LeveldbValueStore(database_path())); } |
| 52 | 52 |
| 53 LeveldbValueStore* store() { return store_.get(); } | 53 LeveldbValueStore* store() { return store_.get(); } |
| 54 const base::FilePath& database_path() { return database_dir_.path(); } | 54 const base::FilePath& database_path() { return database_dir_.path(); } |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 175 ValueStore::ReadResult result = store()->Get(); | 175 ValueStore::ReadResult result = store()->Get(); |
| 176 ASSERT_TRUE(result->HasError()); | 176 ASSERT_TRUE(result->HasError()); |
| 177 ASSERT_EQ(ValueStore::CORRUPTION, result->error().code); | 177 ASSERT_EQ(ValueStore::CORRUPTION, result->error().code); |
| 178 | 178 |
| 179 ASSERT_TRUE(store()->Restore()); | 179 ASSERT_TRUE(store()->Restore()); |
| 180 result = store()->Get(); | 180 result = store()->Get(); |
| 181 EXPECT_FALSE(result->HasError()); | 181 EXPECT_FALSE(result->HasError()); |
| 182 // We couldn't recover anything, but we should be in a sane state again. | 182 // We couldn't recover anything, but we should be in a sane state again. |
| 183 EXPECT_EQ(0u, result->settings().size()); | 183 EXPECT_EQ(0u, result->settings().size()); |
| 184 } | 184 } |
| OLD | NEW |