| 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 #import <UIKit/UIKit.h> | 7 #import <UIKit/UIKit.h> |
| 8 | 8 |
| 9 #include "base/files/scoped_temp_dir.h" | 9 #include "base/files/scoped_temp_dir.h" |
| 10 #include "base/mac/scoped_cftyperef.h" | 10 #include "base/mac/scoped_cftyperef.h" |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 99 // Methods to check if persistence is on or not. | 99 // Methods to check if persistence is on or not. |
| 100 template <class T> bool ShouldPersist(); | 100 template <class T> bool ShouldPersist(); |
| 101 template <> bool ShouldPersist<TestImageStore>() { return false; } | 101 template <> bool ShouldPersist<TestImageStore>() { return false; } |
| 102 template <> bool ShouldPersist<PersistentImageStore>() { return true; } | 102 template <> bool ShouldPersist<PersistentImageStore>() { return true; } |
| 103 | 103 |
| 104 // Test fixture class template for the abstract API. | 104 // Test fixture class template for the abstract API. |
| 105 template <class T> | 105 template <class T> |
| 106 class ImageStoreUnitTestIOS : public PlatformTest { | 106 class ImageStoreUnitTestIOS : public PlatformTest { |
| 107 protected: | 107 protected: |
| 108 ImageStoreUnitTestIOS() {} | 108 ImageStoreUnitTestIOS() {} |
| 109 virtual ~ImageStoreUnitTestIOS() {} | 109 ~ImageStoreUnitTestIOS() override {} |
| 110 | 110 |
| 111 virtual void SetUp() override { | 111 void SetUp() override { |
| 112 bool success = temp_dir_.CreateUniqueTempDir(); | 112 bool success = temp_dir_.CreateUniqueTempDir(); |
| 113 ASSERT_TRUE(success); | 113 ASSERT_TRUE(success); |
| 114 store_.reset(CreateStore<T>(temp_dir_)); | 114 store_.reset(CreateStore<T>(temp_dir_)); |
| 115 } | 115 } |
| 116 | 116 |
| 117 virtual void TearDown() override { | 117 void TearDown() override { |
| 118 if (store_ && use_persistent_store()) | 118 if (store_ && use_persistent_store()) |
| 119 store_->ClearAll(); | 119 store_->ClearAll(); |
| 120 } | 120 } |
| 121 | 121 |
| 122 bool use_persistent_store() const { return ShouldPersist<T>(); } | 122 bool use_persistent_store() const { return ShouldPersist<T>(); } |
| 123 void ResetStore() { store_.reset(CreateStore<T>(temp_dir_)); } | 123 void ResetStore() { store_.reset(CreateStore<T>(temp_dir_)); } |
| 124 | 124 |
| 125 // The directory the database is saved into. | 125 // The directory the database is saved into. |
| 126 base::ScopedTempDir temp_dir_; | 126 base::ScopedTempDir temp_dir_; |
| 127 // The object the fixture is testing, via its base interface. | 127 // The object the fixture is testing, via its base interface. |
| (...skipping 23 matching lines...) Expand all Loading... |
| 151 scoped_refptr<enhanced_bookmarks::ImageRecord> image_out = | 151 scoped_refptr<enhanced_bookmarks::ImageRecord> image_out = |
| 152 this->store_->Get(url); | 152 this->store_->Get(url); |
| 153 | 153 |
| 154 EXPECT_EQ(image_in->url, image_out->url); | 154 EXPECT_EQ(image_in->url, image_out->url); |
| 155 EXPECT_TRUE(CompareImages(*image_in->image, *image_out->image)); | 155 EXPECT_TRUE(CompareImages(*image_in->image, *image_out->image)); |
| 156 EXPECT_EQ(image_in->dominant_color, image_out->dominant_color); | 156 EXPECT_EQ(image_in->dominant_color, image_out->dominant_color); |
| 157 } | 157 } |
| 158 } | 158 } |
| 159 | 159 |
| 160 } // namespace | 160 } // namespace |
| OLD | NEW |