| 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 "components/enhanced_bookmarks/image_store.h" | 5 #include "components/enhanced_bookmarks/image_store.h" |
| 6 | 6 |
| 7 #include "base/files/file_path.h" | 7 #include "base/files/file_path.h" |
| 8 #include "base/files/scoped_temp_dir.h" | 8 #include "base/files/scoped_temp_dir.h" |
| 9 #include "base/strings/string_number_conversions.h" | 9 #include "base/strings/string_number_conversions.h" |
| 10 #include "components/enhanced_bookmarks/image_record.h" | 10 #include "components/enhanced_bookmarks/image_record.h" |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 126 // Methods to check if persistence is on or not. | 126 // Methods to check if persistence is on or not. |
| 127 template <class T> bool ShouldPersist(); | 127 template <class T> bool ShouldPersist(); |
| 128 template <> bool ShouldPersist<TestImageStore>() { return false; } | 128 template <> bool ShouldPersist<TestImageStore>() { return false; } |
| 129 template <> bool ShouldPersist<PersistentImageStore>() { return true; } | 129 template <> bool ShouldPersist<PersistentImageStore>() { return true; } |
| 130 | 130 |
| 131 // Test fixture class template for the abstract API. | 131 // Test fixture class template for the abstract API. |
| 132 template <class T> | 132 template <class T> |
| 133 class ImageStoreUnitTest : public PlatformTest { | 133 class ImageStoreUnitTest : public PlatformTest { |
| 134 protected: | 134 protected: |
| 135 ImageStoreUnitTest() {} | 135 ImageStoreUnitTest() {} |
| 136 virtual ~ImageStoreUnitTest() {} | 136 ~ImageStoreUnitTest() override {} |
| 137 | 137 |
| 138 virtual void SetUp() override { | 138 void SetUp() override { |
| 139 bool success = tempDir_.CreateUniqueTempDir(); | 139 bool success = tempDir_.CreateUniqueTempDir(); |
| 140 ASSERT_TRUE(success); | 140 ASSERT_TRUE(success); |
| 141 store_.reset(CreateStore<T>(tempDir_)); | 141 store_.reset(CreateStore<T>(tempDir_)); |
| 142 } | 142 } |
| 143 | 143 |
| 144 virtual void TearDown() override { | 144 void TearDown() override { |
| 145 if (store_ && use_persistent_store()) | 145 if (store_ && use_persistent_store()) |
| 146 store_->ClearAll(); | 146 store_->ClearAll(); |
| 147 } | 147 } |
| 148 | 148 |
| 149 bool use_persistent_store() const { return ShouldPersist<T>(); } | 149 bool use_persistent_store() const { return ShouldPersist<T>(); } |
| 150 void ResetStore() { store_.reset(CreateStore<T>(tempDir_)); } | 150 void ResetStore() { store_.reset(CreateStore<T>(tempDir_)); } |
| 151 | 151 |
| 152 // The directory the database is saved into. | 152 // The directory the database is saved into. |
| 153 base::ScopedTempDir tempDir_; | 153 base::ScopedTempDir tempDir_; |
| 154 // The object the fixture is testing, via its base interface. | 154 // The object the fixture is testing, via its base interface. |
| (...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 328 if (this->use_persistent_store()) { | 328 if (this->use_persistent_store()) { |
| 329 EXPECT_GE(this->store_->GetStoreSizeInBytes(), 80 * 1024); // 80kb | 329 EXPECT_GE(this->store_->GetStoreSizeInBytes(), 80 * 1024); // 80kb |
| 330 EXPECT_LE(this->store_->GetStoreSizeInBytes(), 200 * 1024); // 200kb | 330 EXPECT_LE(this->store_->GetStoreSizeInBytes(), 200 * 1024); // 200kb |
| 331 } else { | 331 } else { |
| 332 EXPECT_GE(this->store_->GetStoreSizeInBytes(), 400 * 1024); // 400kb | 332 EXPECT_GE(this->store_->GetStoreSizeInBytes(), 400 * 1024); // 400kb |
| 333 EXPECT_LE(this->store_->GetStoreSizeInBytes(), 500 * 1024); // 500kb | 333 EXPECT_LE(this->store_->GetStoreSizeInBytes(), 500 * 1024); // 500kb |
| 334 } | 334 } |
| 335 } | 335 } |
| 336 | 336 |
| 337 } // namespace | 337 } // namespace |
| OLD | NEW |