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

Issue 2579813002: ntp_tiles: Add tests covering tile-fetching logic (Closed)

Created:
4 years ago by mastiz
Modified:
3 years, 11 months ago
Reviewers:
Marc Treib, sfiera
CC:
chromium-reviews, ntp-dev+reviews_chromium.org
Target Ref:
refs/pending/heads/master
Project:
chromium
Visibility:
Public.

Description

ntp_tiles: Add tests covering tile-fetching logic The previous tests only covered a tiny part of the component, which is the merging logic, but not the actual combinations of events that can happen during the fetching of tiles from the backends (top sites, suggestions service, popular sites). Mocks are used extensively due to the lack of fakes, and because the interfaces are really big. It's somewhat painful to read, but alternatives are not better. The tests surface one bug which is not addressed here, left more a follow-up patch and represented with a TODO. Popular Sites fetching is still not covered by these tests, and another TODO is added for this purpose. BUG=619584 Committed: https://crrev.com/451ce6c31e4a2643271bc29e68a103109069fb38 Cr-Commit-Position: refs/heads/master@{#439335}

Patch Set 1 #

Total comments: 12

Patch Set 2 : Minor improvements. #

Patch Set 3 : Various improvements. #

Patch Set 4 : Various improvements. #

Total comments: 12

Patch Set 5 : Addressed comments. #

Patch Set 6 : Addressed more comments and reverted to fixtures. #

Unified diffs Side-by-side diffs Delta from patch set Stats (+415 lines, -5 lines) Patch
M components/ntp_tiles/most_visited_sites.cc View 1 2 3 4 5 1 chunk +2 lines, -0 lines 0 comments Download
M components/ntp_tiles/most_visited_sites_unittest.cc View 1 2 3 4 5 6 chunks +413 lines, -5 lines 0 comments Download

Depends on Patchset:

Dependent Patchsets:

Messages

Total messages: 28 (16 generated)
mastiz
Quite painful, but better than no tests :-)
4 years ago (2016-12-15 16:29:40 UTC) #2
mastiz
Redirecting to sfiera@ since treib@ is OOO.
4 years ago (2016-12-16 09:55:27 UTC) #7
sfiera
Overall I think this is a great improvement. https://codereview.chromium.org/2579813002/diff/60001/components/ntp_tiles/most_visited_sites.h File components/ntp_tiles/most_visited_sites.h (right): https://codereview.chromium.org/2579813002/diff/60001/components/ntp_tiles/most_visited_sites.h#newcode118 components/ntp_tiles/most_visited_sites.h:118: static ...
4 years ago (2016-12-16 11:01:21 UTC) #12
mastiz
PTAL, thanks! https://codereview.chromium.org/2579813002/diff/60001/components/ntp_tiles/most_visited_sites.h File components/ntp_tiles/most_visited_sites.h (right): https://codereview.chromium.org/2579813002/diff/60001/components/ntp_tiles/most_visited_sites.h#newcode118 components/ntp_tiles/most_visited_sites.h:118: static void RegisterProfilePrefs(PrefRegistrySimple* registry); On 2016/12/16 11:01:21, ...
4 years ago (2016-12-16 12:01:05 UTC) #15
sfiera
https://codereview.chromium.org/2579813002/diff/60001/components/ntp_tiles/most_visited_sites.h File components/ntp_tiles/most_visited_sites.h (right): https://codereview.chromium.org/2579813002/diff/60001/components/ntp_tiles/most_visited_sites.h#newcode118 components/ntp_tiles/most_visited_sites.h:118: static void RegisterProfilePrefs(PrefRegistrySimple* registry); On 2016/12/16 12:01:04, mastiz wrote: ...
4 years ago (2016-12-16 13:05:29 UTC) #16
mastiz
Thanks! https://codereview.chromium.org/2579813002/diff/60001/components/ntp_tiles/most_visited_sites.h File components/ntp_tiles/most_visited_sites.h (right): https://codereview.chromium.org/2579813002/diff/60001/components/ntp_tiles/most_visited_sites.h#newcode118 components/ntp_tiles/most_visited_sites.h:118: static void RegisterProfilePrefs(PrefRegistrySimple* registry); On 2016/12/16 13:05:29, sfiera ...
4 years ago (2016-12-16 13:47:15 UTC) #17
sfiera
LGTM, thanks!
4 years ago (2016-12-16 13:54:36 UTC) #18
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/2579813002/100001
4 years ago (2016-12-17 07:25:33 UTC) #20
commit-bot: I haz the power
Committed patchset #6 (id:100001)
4 years ago (2016-12-17 08:13:48 UTC) #23
commit-bot: I haz the power
Patchset 6 (id:??) landed as https://crrev.com/451ce6c31e4a2643271bc29e68a103109069fb38 Cr-Commit-Position: refs/heads/master@{#439335}
4 years ago (2016-12-17 08:16:31 UTC) #25
Marc Treib
I had started to review this last Thu; sending out the comments for completeness' sake. ...
4 years ago (2016-12-19 09:11:51 UTC) #27
mastiz
3 years, 11 months ago (2017-01-09 10:40:59 UTC) #28
Message was sent while issue was closed.
Just for completeness' sake.

https://codereview.chromium.org/2579813002/diff/1/components/ntp_tiles/most_v...
File components/ntp_tiles/most_visited_sites.cc (right):

https://codereview.chromium.org/2579813002/diff/1/components/ntp_tiles/most_v...
components/ntp_tiles/most_visited_sites.cc:21: #include
"components/prefs/pref_registry_simple.h"
On 2016/12/19 09:11:50, Marc Treib (OOO until Jan 12) wrote:
> Nice! Once we do the same for PopularSites, we can probably remove the
> dependency on components/pref_registry :)

sfiera@ raised some concerns so I reverted this change :-/

https://codereview.chromium.org/2579813002/diff/1/components/ntp_tiles/most_v...
File components/ntp_tiles/most_visited_sites_unittest.cc (right):

https://codereview.chromium.org/2579813002/diff/1/components/ntp_tiles/most_v...
components/ntp_tiles/most_visited_sites_unittest.cc:203:
base::WrapUnique(mock_popular_sites_),
On 2016/12/19 09:11:50, Marc Treib (OOO until Jan 12) wrote:
> Hm, IMO this makes ownership kinda hard to understand. I usually prefer the
> pattern:
> auto ptr = MakeUnique<..>();
> Class* raw_ptr = ptr.get();
> DoTheThing(std::move(ptr));
> 
> WDYT?
> Could that work here?

The main reason for this was to avoid the need for a unique_ptr with
MostVisitedSites. This will change soon anyway, so I'll do as you suggest in a
future patch.

https://codereview.chromium.org/2579813002/diff/1/components/ntp_tiles/most_v...
components/ntp_tiles/most_visited_sites_unittest.cc:205: /*supervisor=*/{}) {
On 2016/12/19 09:11:50, Marc Treib (OOO until Jan 12) wrote:
> nullptr?

Obsolete (done).

https://codereview.chromium.org/2579813002/diff/1/components/ntp_tiles/most_v...
components/ntp_tiles/most_visited_sites_unittest.cc:206:
MostVisitedSites::RegisterProfilePrefs(pref_service_.registry());
On 2016/12/19 09:11:50, Marc Treib (OOO until Jan 12) wrote:
> I think it'd be best to instantiate MostVisitedSites *after* we have
registered
> its prefs.

Will address in a future patch, probably in the form of SetUpTestCase().

https://codereview.chromium.org/2579813002/diff/1/components/ntp_tiles/most_v...
components/ntp_tiles/most_visited_sites_unittest.cc:214:
.WillRepeatedly(ReturnRef(empty_popular_sites_vector_));
On 2016/12/19 09:11:50, Marc Treib (OOO until Jan 12) wrote:
> Is this a case for ON_CALL(...).WillByDefault?

I think not: setting a default could (in the future) interfere with other
expectations with PopularSites::sites(). IIUC WillByDefault is used to avoid
boilerplate when there's multiple expectations. See
http://stackoverflow.com/questions/13933475/gmock-setting-default-actions-on-...

https://codereview.chromium.org/2579813002/diff/1/components/ntp_tiles/most_v...
components/ntp_tiles/most_visited_sites_unittest.cc:255:
EXPECT_CALL(mock_suggestions_service_, AddCallback(_));
On 2016/12/19 09:11:50, Marc Treib (OOO until Jan 12) wrote:
> Here the InSequence might be a bit too strong: It doesn't really matter which
of
> the two above is called first. Or am I missing something?

Obsolete.

Powered by Google App Engine
This is Rietveld 408576698