| 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 <string> | 5 #include <string> |
| 6 | 6 |
| 7 #include "base/files/file_path.h" | 7 #include "base/files/file_path.h" |
| 8 #include "base/run_loop.h" | 8 #include "base/run_loop.h" |
| 9 #include "base/thread_task_runner_handle.h" | 9 #include "base/thread_task_runner_handle.h" |
| 10 #include "components/leveldb_proto/proto_database.h" | 10 #include "components/leveldb_proto/proto_database.h" |
| 11 #include "components/leveldb_proto/testing/fake_db.h" | 11 #include "components/leveldb_proto/testing/fake_db.h" |
| 12 #include "components/suggestions/image_encoder.h" | 12 #include "components/suggestions/image_encoder.h" |
| 13 #include "components/suggestions/image_fetcher.h" | 13 #include "components/suggestions/image_fetcher.h" |
| 14 #include "components/suggestions/image_fetcher_delegate.h" | 14 #include "components/suggestions/image_fetcher_delegate.h" |
| 15 #include "components/suggestions/image_manager.h" | 15 #include "components/suggestions/image_manager.h" |
| 16 #include "components/suggestions/proto/suggestions.pb.h" | 16 #include "components/suggestions/proto/suggestions.pb.h" |
| 17 #include "testing/gmock/include/gmock/gmock.h" | 17 #include "testing/gmock/include/gmock/gmock.h" |
| 18 #include "testing/gtest/include/gtest/gtest.h" | 18 #include "testing/gtest/include/gtest/gtest.h" |
| 19 #include "ui/gfx/image/image_skia.h" | 19 #include "ui/gfx/image/image_skia.h" |
| 20 #include "url/gurl.h" | 20 #include "url/gurl.h" |
| 21 | 21 |
| 22 using ::testing::Return; | 22 using ::testing::Return; |
| 23 using ::testing::StrictMock; | 23 using ::testing::StrictMock; |
| 24 using ::testing::_; | 24 using ::testing::_; |
| 25 | 25 |
| 26 namespace suggestions { | 26 namespace suggestions { |
| 27 | 27 |
| 28 const char kTestUrl1[] = "http://go.com/"; | 28 const char kTestUrl1[] = "http://go.com/"; |
| 29 const char kTestUrl2[] = "http://goal.com/"; | 29 const char kTestUrl2[] = "http://goal.com/"; |
| 30 const char kTestImagePath[] = "files/image_decoding/droids.png"; | 30 const char kTestImagePath[] = "/image_decoding/droids.png"; |
| 31 const char kInvalidImagePath[] = "files/DOESNOTEXIST"; | 31 const char kInvalidImagePath[] = "/DOESNOTEXIST"; |
| 32 | 32 |
| 33 using leveldb_proto::test::FakeDB; | 33 using leveldb_proto::test::FakeDB; |
| 34 using suggestions::ImageData; | 34 using suggestions::ImageData; |
| 35 using suggestions::ImageManager; | 35 using suggestions::ImageManager; |
| 36 | 36 |
| 37 typedef base::hash_map<std::string, ImageData> EntryMap; | 37 typedef base::hash_map<std::string, ImageData> EntryMap; |
| 38 | 38 |
| 39 void AddEntry(const ImageData& d, EntryMap* map) { (*map)[d.url()] = d; } | 39 void AddEntry(const ImageData& d, EntryMap* map) { (*map)[d.url()] = d; } |
| 40 | 40 |
| 41 class MockImageFetcher : public suggestions::ImageFetcher { | 41 class MockImageFetcher : public suggestions::ImageFetcher { |
| (...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 207 image_manager_->GetImageForURL(GURL(kTestUrl1), | 207 image_manager_->GetImageForURL(GURL(kTestUrl1), |
| 208 base::Bind(&ImageManagerTest::OnImageAvailable, | 208 base::Bind(&ImageManagerTest::OnImageAvailable, |
| 209 base::Unretained(this), &run_loop)); | 209 base::Unretained(this), &run_loop)); |
| 210 run_loop.Run(); | 210 run_loop.Run(); |
| 211 | 211 |
| 212 EXPECT_EQ(0, num_callback_null_called_); | 212 EXPECT_EQ(0, num_callback_null_called_); |
| 213 EXPECT_EQ(1, num_callback_valid_called_); | 213 EXPECT_EQ(1, num_callback_valid_called_); |
| 214 } | 214 } |
| 215 | 215 |
| 216 } // namespace suggestions | 216 } // namespace suggestions |
| OLD | NEW |