Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(458)

Unified Diff: components/suggestions/image_manager_unittest.cc

Issue 1156003008: Decode ImageManager cached images on demand. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Include stddef to get size_t Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: components/suggestions/image_manager_unittest.cc
diff --git a/components/suggestions/image_manager_unittest.cc b/components/suggestions/image_manager_unittest.cc
index e9d16e31ceaf642dc935ff7c9e2ff87662f8f16c..01b0f1eb080377b5dcb35f09521c4422cbc94978 100644
--- a/components/suggestions/image_manager_unittest.cc
+++ b/components/suggestions/image_manager_unittest.cc
@@ -13,6 +13,7 @@
#include "components/suggestions/image_fetcher_delegate.h"
#include "components/suggestions/image_manager.h"
#include "components/suggestions/proto/suggestions.pb.h"
+#include "content/public/test/test_browser_thread.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "ui/gfx/image/image_skia.h"
@@ -21,6 +22,7 @@
using ::testing::Return;
using ::testing::StrictMock;
using ::testing::_;
+using content::BrowserThread;
namespace suggestions {
@@ -52,7 +54,10 @@ class ImageManagerTest : public testing::Test {
ImageManagerTest()
: mock_image_fetcher_(NULL),
num_callback_null_called_(0),
- num_callback_valid_called_(0) {}
+ num_callback_valid_called_(0),
+ db_thread_(BrowserThread::DB) {
+ db_thread_.Start();
+ }
void SetUp() override {
fake_db_ = new FakeDB<ImageData>(&db_model_);
@@ -125,6 +130,10 @@ class ImageManagerTest : public testing::Test {
int num_callback_null_called_;
int num_callback_valid_called_;
+
+ base::MessageLoop message_loop_;
+ content::TestBrowserThread db_thread_;
+
// Under test.
scoped_ptr<ImageManager> image_manager_;
};
@@ -181,8 +190,9 @@ TEST_F(ImageManagerTest, GetImageForURLNetworkCacheHit) {
fake_db->InitCallback(true);
fake_db->LoadCallback(true);
// Expect something in the cache.
- SkBitmap* bitmap = image_manager_->GetBitmapFromCache(GURL(kTestUrl1));
- EXPECT_FALSE(bitmap->isNull());
+ auto encoded_image =
+ image_manager_->GetEncodedImageFromCache(GURL(kTestUrl1));
+ EXPECT_NE(nullptr, encoded_image);
base::RunLoop run_loop;
image_manager_->GetImageForURL(GURL(kTestUrl1),
« components/suggestions/image_manager.cc ('K') | « components/suggestions/image_manager.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698