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

Side by Side Diff: components/ntp_tiles/icon_cacher_impl_unittest.cc

Issue 2725293002: Handle null callbacks in OnFaviconDownloaded (Closed)
Patch Set: Created 3 years, 9 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 unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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/ntp_tiles/icon_cacher_impl.h" 5 #include "components/ntp_tiles/icon_cacher_impl.h"
6 6
7 #include <set> 7 #include <set>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/files/scoped_temp_dir.h" 10 #include "base/files/scoped_temp_dir.h"
(...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after
268 .WillOnce(FailFetch()); 268 .WillOnce(FailFetch());
269 } 269 }
270 270
271 IconCacherImpl cacher(&favicon_service_, std::move(image_fetcher_)); 271 IconCacherImpl cacher(&favicon_service_, std::move(image_fetcher_));
272 cacher.StartFetch(site_, done.Get(), done.Get()); 272 cacher.StartFetch(site_, done.Get(), done.Get());
273 WaitForTasksToFinish(); 273 WaitForTasksToFinish();
274 EXPECT_FALSE(IconIsCachedFor(site_.url, favicon_base::FAVICON)); 274 EXPECT_FALSE(IconIsCachedFor(site_.url, favicon_base::FAVICON));
275 EXPECT_FALSE(IconIsCachedFor(site_.url, favicon_base::TOUCH_ICON)); 275 EXPECT_FALSE(IconIsCachedFor(site_.url, favicon_base::TOUCH_ICON));
276 } 276 }
277 277
278 TEST_F(IconCacherTest, HandlesEmptyClosuresNicely) {
Marc Treib 2017/03/03 10:29:42 nit: s/Closures/Callbacks/ ? (The fact that they h
fhorschig 2017/03/03 10:35:26 Done.
279 EXPECT_CALL(*image_fetcher_, SetDataUseServiceName(_));
280 EXPECT_CALL(*image_fetcher_, SetDesiredImageFrameSize(_));
281 ON_CALL(*image_fetcher_, StartOrQueueNetworkRequest(_, _, _))
282 .WillByDefault(PassFetch(128, 128));
283 IconCacherImpl cacher(&favicon_service_, std::move(image_fetcher_));
284 cacher.StartFetch(site_, base::Closure(), base::Closure());
285 WaitForTasksToFinish();
286 }
287
278 TEST_F(IconCacherTest, ProvidesDefaultIconAndSucceedsWithFetching) { 288 TEST_F(IconCacherTest, ProvidesDefaultIconAndSucceedsWithFetching) {
279 // We are not interested which delegate function actually handles the call to 289 // We are not interested which delegate function actually handles the call to
280 // |GetNativeImageNamed| as long as we receive the right image. 290 // |GetNativeImageNamed| as long as we receive the right image.
281 ON_CALL(mock_resource_delegate_, GetNativeImageNamed(12345)) 291 ON_CALL(mock_resource_delegate_, GetNativeImageNamed(12345))
282 .WillByDefault(Return(gfx::test::CreateImage(64, 64))); 292 .WillByDefault(Return(gfx::test::CreateImage(64, 64)));
283 ON_CALL(mock_resource_delegate_, GetImageNamed(12345)) 293 ON_CALL(mock_resource_delegate_, GetImageNamed(12345))
284 .WillByDefault(Return(gfx::test::CreateImage(64, 64))); 294 .WillByDefault(Return(gfx::test::CreateImage(64, 64)));
285 base::MockCallback<base::Closure> preliminary_icon_available; 295 base::MockCallback<base::Closure> preliminary_icon_available;
286 base::MockCallback<base::Closure> icon_available; 296 base::MockCallback<base::Closure> icon_available;
287 base::RunLoop default_loop; 297 base::RunLoop default_loop;
(...skipping 22 matching lines...) Expand all
310 Eq(gfx::Size(64, 64))); // Compares dimensions, not objects. 320 Eq(gfx::Size(64, 64))); // Compares dimensions, not objects.
311 321
312 // Let the fetcher continue and wait for the second call of the callback. 322 // Let the fetcher continue and wait for the second call of the callback.
313 fetch_loop.Run(); // Wait for the updated image. 323 fetch_loop.Run(); // Wait for the updated image.
314 EXPECT_THAT(GetCachedIconFor(site_.url, favicon_base::TOUCH_ICON).Size(), 324 EXPECT_THAT(GetCachedIconFor(site_.url, favicon_base::TOUCH_ICON).Size(),
315 Eq(gfx::Size(128, 128))); // Compares dimensions, not objects. 325 Eq(gfx::Size(128, 128))); // Compares dimensions, not objects.
316 } 326 }
317 327
318 } // namespace 328 } // namespace
319 } // namespace ntp_tiles 329 } // namespace ntp_tiles
OLDNEW
« components/ntp_tiles/icon_cacher_impl.cc ('K') | « components/ntp_tiles/icon_cacher_impl.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698