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

Issue 2703603002: Improve FaviconHandler tests by testing public API (Closed)

Created:
3 years, 10 months ago by mastiz
Modified:
3 years, 9 months ago
Reviewers:
pkotwicz
CC:
chromium-reviews, jam, darin-cc_chromium.org
Target Ref:
refs/pending/heads/master
Project:
chromium
Visibility:
Public.

Description

Improve FaviconHandler tests by testing public API No behavioral changes: instead of subclassing the class under test to bypass/intercept internal calls, let's instead verify external interactions by injecting test doubles and testing the public API. The new ones are more concise by adopting mocks to verify call arguments or fakes (mock-to-fake delegation) for the simplest cases. This greatly reduces the size of tests to ~50%, ~800 LoC less! The actual diffstat is smaller due to newly added tests, increasing the total number of tests from 18 to 28, including basic test coverage for incognito (DownloadUnknownFaviconInIncognito) or a corner case that is prone to regressions (MultipleFaviconsLast404). BUG=694312 Review-Url: https://codereview.chromium.org/2703603002 Cr-Commit-Position: refs/heads/master@{#458084} Committed: https://chromium.googlesource.com/chromium/src/+/36c9189e71036d65209df554c9ddc96be6f78869

Patch Set 1 #

Total comments: 8

Patch Set 2 : WIP #

Patch Set 3 : Rebased. #

Patch Set 4 : Rebased. #

Patch Set 5 : Remove comments. #

Patch Set 6 : Shorter tests. #

Patch Set 7 : Rebased. #

Patch Set 8 : Rebased. #

Patch Set 9 : Rebased. #

Patch Set 10 : Minor changes. #

Patch Set 11 : Updated missing tests. #

Patch Set 12 : Fixed missing build dependency. #

Patch Set 13 : Removed TODO. #

Patch Set 14 : Reintroduce HasPendingTasksForTest. #

Patch Set 15 : Helper functions to set fake images. #

Patch Set 16 : Added comments. #

Patch Set 17 : Adopt FakeImageDownloader. #

Total comments: 51

Patch Set 18 : Addressed more comments. #

Patch Set 19 : Fixed Windows build. #

Patch Set 20 : Conditioned test to OS_ANDROID #

Patch Set 21 : Adopted fake downloads() and db_requests(). #

Patch Set 22 : Minor changes. #

Patch Set 23 : Reverted ifdef. #

Total comments: 132

Patch Set 24 : Addressed more comments. #

Patch Set 25 : Inject scale factors. #

Patch Set 26 : Inject scale factors to CreateFaviconImageSkia() #

Patch Set 27 : Reverted injecting scale factors. #

Total comments: 83

Patch Set 28 : Addressed nits. #

Patch Set 29 : Removed UpdateFaviconMappingsAndFetch() #

Unified diffs Side-by-side diffs Delta from patch set Stats (+849 lines, -1586 lines) Patch
M components/favicon/core/BUILD.gn View 1 2 3 4 5 6 7 8 9 10 11 1 chunk +1 line, -0 lines 0 comments Download
M components/favicon/core/favicon_handler.h View 1 2 3 4 5 6 7 8 9 10 11 12 13 25 26 5 chunks +6 lines, -40 lines 0 comments Download
M components/favicon/core/favicon_handler.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 25 26 8 chunks +36 lines, -88 lines 0 comments Download
M components/favicon/core/favicon_handler_unittest.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 6 chunks +806 lines, -1458 lines 0 comments Download

Dependent Patchsets:

Messages

Total messages: 101 (68 generated)
pkotwicz
https://codereview.chromium.org/2703603002/diff/1/components/favicon/core/favicon_handler_unittest.cc File components/favicon/core/favicon_handler_unittest.cc (right): https://codereview.chromium.org/2703603002/diff/1/components/favicon/core/favicon_handler_unittest.cc#newcode284 components/favicon/core/favicon_handler_unittest.cc:284: GetFaviconForPageURL(page_url, favicon_base::FAVICON, _, _, _)); I don't think that ...
3 years, 10 months ago (2017-02-16 16:36:17 UTC) #2
pkotwicz
I'll look at this some more on Friday morning
3 years, 10 months ago (2017-02-17 05:38:44 UTC) #3
pkotwicz
https://codereview.chromium.org/2703603002/diff/1/components/favicon/core/favicon_handler_unittest.cc File components/favicon/core/favicon_handler_unittest.cc (right): https://codereview.chromium.org/2703603002/diff/1/components/favicon/core/favicon_handler_unittest.cc#newcode295 components/favicon/core/favicon_handler_unittest.cc:295: icon_url, favicon_base::FAVICON, /*expired=*/false))); The test right now tests the ...
3 years, 10 months ago (2017-02-17 15:46:24 UTC) #4
mastiz
Note that this is WIP. In particular, two different techniques are implemented, leading to duplicate ...
3 years, 10 months ago (2017-02-21 16:22:16 UTC) #15
pkotwicz
I need to think about this CL some more. There are a lot of good ...
3 years, 10 months ago (2017-02-23 06:13:59 UTC) #16
pkotwicz
As an update I have made progress but there are lots of tests. I have ...
3 years, 9 months ago (2017-02-26 18:15:58 UTC) #17
mastiz
On 2017/02/26 18:15:58, pkotwicz wrote: > As an update I have made progress but there ...
3 years, 9 months ago (2017-03-03 14:25:32 UTC) #18
pkotwicz
Making more progress. Will try to be done by Monday night my time
3 years, 9 months ago (2017-03-06 06:48:06 UTC) #19
mastiz
On 2017/03/06 06:48:06, pkotwicz wrote: > Making more progress. Will try to be done by ...
3 years, 9 months ago (2017-03-06 14:28:29 UTC) #29
pkotwicz
Your CL looks better than I expected that it would. I did something stupid and ...
3 years, 9 months ago (2017-03-07 07:00:46 UTC) #35
mastiz
On 2017/03/07 07:00:46, pkotwicz wrote: > Your CL looks better than I expected that it ...
3 years, 9 months ago (2017-03-07 09:57:03 UTC) #36
mastiz
Thanks, PTAL! Wrt to the points we discussed yesterday: 1. Camelcasing of URL: I took ...
3 years, 9 months ago (2017-03-08 12:33:53 UTC) #37
pkotwicz
Some initial comments. I think that it would be nice to use EXPECT_THAT(Delegate::downloads(), ElementsAre()) EXPECT_THAT(FaviconService::db_requets(), ...
3 years, 9 months ago (2017-03-09 02:15:09 UTC) #38
mastiz
Thanks, PTAL! Addressed most comments with two main pushbacks: 1. Addition of new tests: this ...
3 years, 9 months ago (2017-03-09 10:40:08 UTC) #41
pkotwicz
In the interest of time, I think it is most expedient to proceed with landing ...
3 years, 9 months ago (2017-03-10 05:07:34 UTC) #52
pkotwicz
To answer your question about NiceMock, yes I prefer NiceMock.
3 years, 9 months ago (2017-03-10 05:22:06 UTC) #53
mastiz
Thanks, PTAL! I hope most controversial points have converged in this version, let me know ...
3 years, 9 months ago (2017-03-10 11:10:47 UTC) #54
pkotwicz
Thank you for making the changes. I will look over your CL by Monday
3 years, 9 months ago (2017-03-10 16:00:40 UTC) #59
pkotwicz
I've gotten through most of the CL. Nothing major :) https://codereview.chromium.org/2703603002/diff/320001/components/favicon/core/favicon_handler_unittest.cc File components/favicon/core/favicon_handler_unittest.cc (right): https://codereview.chromium.org/2703603002/diff/320001/components/favicon/core/favicon_handler_unittest.cc#newcode433 ...
3 years, 9 months ago (2017-03-13 05:16:34 UTC) #60
mastiz
Thanks, PTAL! Addressed all comments except a few that need clarification in UpdateSameIconURLs. https://codereview.chromium.org/2703603002/diff/320001/components/favicon/core/favicon_handler_unittest.cc File ...
3 years, 9 months ago (2017-03-13 12:46:05 UTC) #65
mastiz
FYI, you'll see additional changes to inject scale factors. As it turns out, ui::test::ScopedSetSupportedScaleFactors doesn't ...
3 years, 9 months ago (2017-03-13 15:01:41 UTC) #70
mastiz
On 2017/03/13 15:01:41, mastiz wrote: > FYI, you'll see additional changes to inject scale factors. ...
3 years, 9 months ago (2017-03-14 14:18:07 UTC) #79
pkotwicz
Just nits! https://codereview.chromium.org/2703603002/diff/440001/components/favicon/core/favicon_handler_unittest.cc File components/favicon/core/favicon_handler_unittest.cc (right): https://codereview.chromium.org/2703603002/diff/440001/components/favicon/core/favicon_handler_unittest.cc#newcode655 components/favicon/core/favicon_handler_unittest.cc:655: TEST_F(FaviconHandlerTest, UpdateSameIconURLs) { My bad. Yes the ...
3 years, 9 months ago (2017-03-17 05:43:11 UTC) #82
pkotwicz
Just nits! https://codereview.chromium.org/2703603002/diff/440001/components/favicon/core/favicon_handler_unittest.cc File components/favicon/core/favicon_handler_unittest.cc (right): https://codereview.chromium.org/2703603002/diff/440001/components/favicon/core/favicon_handler_unittest.cc#newcode655 components/favicon/core/favicon_handler_unittest.cc:655: TEST_F(FaviconHandlerTest, UpdateSameIconURLs) { My bad. Yes the ...
3 years, 9 months ago (2017-03-17 05:43:13 UTC) #83
pkotwicz
Just nits!
3 years, 9 months ago (2017-03-17 05:43:22 UTC) #84
mastiz
Thanks, PTAL! Addressed all comments except one group that requires clarification. https://codereview.chromium.org/2703603002/diff/520001/components/favicon/core/favicon_handler_unittest.cc File components/favicon/core/favicon_handler_unittest.cc (right): ...
3 years, 9 months ago (2017-03-17 12:17:33 UTC) #85
pkotwicz
LGTM with nits. Thank you for bearing with me. Can you please update the CL ...
3 years, 9 months ago (2017-03-17 15:22:31 UTC) #90
mastiz
https://codereview.chromium.org/2703603002/diff/520001/components/favicon/core/favicon_handler_unittest.cc File components/favicon/core/favicon_handler_unittest.cc (right): https://codereview.chromium.org/2703603002/diff/520001/components/favicon/core/favicon_handler_unittest.cc#newcode412 components/favicon/core/favicon_handler_unittest.cc:412: FAVICON, _, _, _)); On 2017/03/17 15:22:31, pkotwicz wrote: ...
3 years, 9 months ago (2017-03-17 15:49:28 UTC) #91
mastiz
On 2017/03/17 15:49:28, mastiz wrote: > https://codereview.chromium.org/2703603002/diff/520001/components/favicon/core/favicon_handler_unittest.cc > File components/favicon/core/favicon_handler_unittest.cc (right): > > https://codereview.chromium.org/2703603002/diff/520001/components/favicon/core/favicon_handler_unittest.cc#newcode412 > ...
3 years, 9 months ago (2017-03-20 08:22:57 UTC) #92
pkotwicz
https://codereview.chromium.org/2703603002/diff/520001/components/favicon/core/favicon_handler_unittest.cc File components/favicon/core/favicon_handler_unittest.cc (right): https://codereview.chromium.org/2703603002/diff/520001/components/favicon/core/favicon_handler_unittest.cc#newcode417 components/favicon/core/favicon_handler_unittest.cc:417: kIconURL16x16, /*icon_url_changed=*/true, _)); Fair enough. You can test all ...
3 years, 9 months ago (2017-03-20 15:01:17 UTC) #94
mastiz
On 2017/03/20 15:01:17, pkotwicz wrote: > https://codereview.chromium.org/2703603002/diff/520001/components/favicon/core/favicon_handler_unittest.cc > File components/favicon/core/favicon_handler_unittest.cc (right): > > https://codereview.chromium.org/2703603002/diff/520001/components/favicon/core/favicon_handler_unittest.cc#newcode417 > ...
3 years, 9 months ago (2017-03-20 15:21:19 UTC) #95
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.org/2703603002/560001
3 years, 9 months ago (2017-03-20 15:23:08 UTC) #98
commit-bot: I haz the power
3 years, 9 months ago (2017-03-20 16:35:07 UTC) #101
Message was sent while issue was closed.
Committed patchset #29 (id:560001) as
https://chromium.googlesource.com/chromium/src/+/36c9189e71036d65209df554c9dd...

Powered by Google App Engine
This is Rietveld 408576698