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/suggestions/image_manager.h" | 5 #include "components/suggestions/image_manager.h" |
6 | 6 |
7 #include <memory> | 7 #include <memory> |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
197 // Create the ImageManager with an added entry in the database. | 197 // Create the ImageManager with an added entry in the database. |
198 AddEntry(GetSampleImageData(kTestUrl1), &db_model_); | 198 AddEntry(GetSampleImageData(kTestUrl1), &db_model_); |
199 FakeDB<ImageData>* fake_db = new FakeDB<ImageData>(&db_model_); | 199 FakeDB<ImageData>* fake_db = new FakeDB<ImageData>(&db_model_); |
200 image_manager_.reset(CreateImageManager(fake_db)); | 200 image_manager_.reset(CreateImageManager(fake_db)); |
201 image_manager_->Initialize(suggestions_profile); | 201 image_manager_->Initialize(suggestions_profile); |
202 fake_db->InitCallback(true); | 202 fake_db->InitCallback(true); |
203 fake_db->LoadCallback(true); | 203 fake_db->LoadCallback(true); |
204 // Expect something in the cache. | 204 // Expect something in the cache. |
205 auto encoded_image = | 205 auto encoded_image = |
206 image_manager_->GetEncodedImageFromCache(GURL(kTestUrl1)); | 206 image_manager_->GetEncodedImageFromCache(GURL(kTestUrl1)); |
207 EXPECT_NE(nullptr, encoded_image); | 207 EXPECT_TRUE(encoded_image); |
208 | 208 |
209 base::RunLoop run_loop; | 209 base::RunLoop run_loop; |
210 image_manager_->GetImageForURL(GURL(kTestUrl1), | 210 image_manager_->GetImageForURL(GURL(kTestUrl1), |
211 base::Bind(&ImageManagerTest::OnImageAvailable, | 211 base::Bind(&ImageManagerTest::OnImageAvailable, |
212 base::Unretained(this), &run_loop)); | 212 base::Unretained(this), &run_loop)); |
213 run_loop.Run(); | 213 run_loop.Run(); |
214 | 214 |
215 EXPECT_EQ(0, num_callback_null_called_); | 215 EXPECT_EQ(0, num_callback_null_called_); |
216 EXPECT_EQ(1, num_callback_valid_called_); | 216 EXPECT_EQ(1, num_callback_valid_called_); |
217 } | 217 } |
218 | 218 |
219 } // namespace suggestions | 219 } // namespace suggestions |
OLD | NEW |