New issue
Advanced search Search tips

Issue 694312 link

Starred by 1 user

Issue metadata

Status: Fixed
Owner:
Closed: Mar 2017
EstimatedDays: ----
NextAction: ----
OS: ----
Pri: 2
Type: Bug

Blocked on:
issue 700811

Blocking:
issue 699980



Sign in to add a comment

Make FaviconDriver/Handler more testable

Project Member Reported by mastiz@chromium.org, Feb 20 2017

Issue description

The current tests do whitebox-testing of many internal methods. The goal is to make sure public APIs have test coverage, and that requirements are reflected in tests.

This is most notably helpful when extending the classes with new features, which is planned, to avoid regressions.

 
Project Member

Comment 2 by bugdroid1@chromium.org, Feb 22 2017

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/d7bd35142ea07f588ba2decdd4c184d68e34d35a

commit d7bd35142ea07f588ba2decdd4c184d68e34d35a
Author: mastiz <mastiz@chromium.org>
Date: Wed Feb 22 10:42:42 2017

Split FaviconService and FaviconServiceImpl

Many existing tests inject test doubles by subclassing from
FaviconServiceImpl, or simply inject a null service and implement
special-handling in the production code.

In this patch, some simple cases are migrated to non-partial mocks.
Follow-up patches will address the more advanced cases.

BUG= 694312 

Review-Url: https://codereview.chromium.org/2698473004
Cr-Commit-Position: refs/heads/master@{#451982}

[modify] https://crrev.com/d7bd35142ea07f588ba2decdd4c184d68e34d35a/chrome/browser/favicon/favicon_service_factory.cc
[modify] https://crrev.com/d7bd35142ea07f588ba2decdd4c184d68e34d35a/chrome/browser/ui/cocoa/history_menu_bridge_unittest.mm
[modify] https://crrev.com/d7bd35142ea07f588ba2decdd4c184d68e34d35a/components/favicon/content/BUILD.gn
[modify] https://crrev.com/d7bd35142ea07f588ba2decdd4c184d68e34d35a/components/favicon/content/content_favicon_driver_unittest.cc
[modify] https://crrev.com/d7bd35142ea07f588ba2decdd4c184d68e34d35a/components/favicon/core/BUILD.gn
[modify] https://crrev.com/d7bd35142ea07f588ba2decdd4c184d68e34d35a/components/favicon/core/DEPS
[modify] https://crrev.com/d7bd35142ea07f588ba2decdd4c184d68e34d35a/components/favicon/core/favicon_service.cc
[modify] https://crrev.com/d7bd35142ea07f588ba2decdd4c184d68e34d35a/components/favicon/core/favicon_service.h
[add] https://crrev.com/d7bd35142ea07f588ba2decdd4c184d68e34d35a/components/favicon/core/favicon_service_impl.cc
[add] https://crrev.com/d7bd35142ea07f588ba2decdd4c184d68e34d35a/components/favicon/core/favicon_service_impl.h
[add] https://crrev.com/d7bd35142ea07f588ba2decdd4c184d68e34d35a/components/favicon/core/favicon_service_impl_unittest.cc
[modify] https://crrev.com/d7bd35142ea07f588ba2decdd4c184d68e34d35a/components/favicon/core/large_icon_service.h
[modify] https://crrev.com/d7bd35142ea07f588ba2decdd4c184d68e34d35a/components/favicon/core/large_icon_service_unittest.cc
[add] https://crrev.com/d7bd35142ea07f588ba2decdd4c184d68e34d35a/components/favicon/core/test/BUILD.gn
[add] https://crrev.com/d7bd35142ea07f588ba2decdd4c184d68e34d35a/components/favicon/core/test/mock_favicon_service.cc
[add] https://crrev.com/d7bd35142ea07f588ba2decdd4c184d68e34d35a/components/favicon/core/test/mock_favicon_service.h
[modify] https://crrev.com/d7bd35142ea07f588ba2decdd4c184d68e34d35a/components/history/core/browser/history_service.h
[modify] https://crrev.com/d7bd35142ea07f588ba2decdd4c184d68e34d35a/components/ntp_tiles/icon_cacher_impl_unittest.cc
[modify] https://crrev.com/d7bd35142ea07f588ba2decdd4c184d68e34d35a/ios/chrome/app/spotlight/BUILD.gn
[modify] https://crrev.com/d7bd35142ea07f588ba2decdd4c184d68e34d35a/ios/chrome/app/spotlight/spotlight_manager_unittest.mm
[modify] https://crrev.com/d7bd35142ea07f588ba2decdd4c184d68e34d35a/ios/chrome/browser/favicon/favicon_service_factory.cc
[modify] https://crrev.com/d7bd35142ea07f588ba2decdd4c184d68e34d35a/ios/chrome/browser/ui/history/BUILD.gn
[modify] https://crrev.com/d7bd35142ea07f588ba2decdd4c184d68e34d35a/ios/chrome/browser/ui/history/favicon_view_provider_unittest.mm
[modify] https://crrev.com/d7bd35142ea07f588ba2decdd4c184d68e34d35a/ios/chrome/browser/ui/reading_list/BUILD.gn
[modify] https://crrev.com/d7bd35142ea07f588ba2decdd4c184d68e34d35a/ios/chrome/browser/ui/reading_list/reading_list_collection_view_controller_unittest.mm
[modify] https://crrev.com/d7bd35142ea07f588ba2decdd4c184d68e34d35a/ios/chrome/browser/ui/reading_list/reading_list_coordinator_unittest.mm

Project Member

Comment 3 by bugdroid1@chromium.org, Feb 28 2017

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/ba3a4d8ad97649db9ce47979a18f93fd07b0499e

commit ba3a4d8ad97649db9ce47979a18f93fd07b0499e
Author: mastiz <mastiz@chromium.org>
Date: Tue Feb 28 20:05:00 2017

Improve test coverage for ContentFaviconDriver

We need this prior to adding new features to the class hierarchy, most
notably the support for multiple favicons of the same type (i.e. for
different resolutions).

The main issue with the former tests is that they don't exercise the
public API, but instead parts of the implementation.

In order to do this, TestWebContents must be extended with basic
support for testing DownloadImage().

BUG= 694312 

Review-Url: https://codereview.chromium.org/2697803003
Cr-Commit-Position: refs/heads/master@{#453680}

[modify] https://crrev.com/ba3a4d8ad97649db9ce47979a18f93fd07b0499e/components/favicon/content/content_favicon_driver_unittest.cc
[modify] https://crrev.com/ba3a4d8ad97649db9ce47979a18f93fd07b0499e/content/public/test/web_contents_tester.h
[modify] https://crrev.com/ba3a4d8ad97649db9ce47979a18f93fd07b0499e/content/test/test_web_contents.cc
[modify] https://crrev.com/ba3a4d8ad97649db9ce47979a18f93fd07b0499e/content/test/test_web_contents.h

Project Member

Comment 4 by bugdroid1@chromium.org, Mar 1 2017

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/16aeb9f7c312208faf699a2aaa1c9792546b59e8

commit 16aeb9f7c312208faf699a2aaa1c9792546b59e8
Author: mastiz <mastiz@chromium.org>
Date: Wed Mar 01 08:33:23 2017

Avoid cyclic dependency FaviconHandler<-->FaviconDriverImpl

This patch reduces the exposed public API and introduces a delegate
instead of a hardwired dependency such that FaviconHandler is more
testable and has clear semantics.

BUG= 694312 

Review-Url: https://codereview.chromium.org/2691933004
Cr-Commit-Position: refs/heads/master@{#453882}

[modify] https://crrev.com/16aeb9f7c312208faf699a2aaa1c9792546b59e8/components/favicon/content/content_favicon_driver.cc
[modify] https://crrev.com/16aeb9f7c312208faf699a2aaa1c9792546b59e8/components/favicon/content/content_favicon_driver.h
[modify] https://crrev.com/16aeb9f7c312208faf699a2aaa1c9792546b59e8/components/favicon/core/favicon_driver.h
[modify] https://crrev.com/16aeb9f7c312208faf699a2aaa1c9792546b59e8/components/favicon/core/favicon_driver_impl.cc
[modify] https://crrev.com/16aeb9f7c312208faf699a2aaa1c9792546b59e8/components/favicon/core/favicon_driver_impl.h
[modify] https://crrev.com/16aeb9f7c312208faf699a2aaa1c9792546b59e8/components/favicon/core/favicon_handler.cc
[modify] https://crrev.com/16aeb9f7c312208faf699a2aaa1c9792546b59e8/components/favicon/core/favicon_handler.h
[modify] https://crrev.com/16aeb9f7c312208faf699a2aaa1c9792546b59e8/components/favicon/core/favicon_handler_unittest.cc
[modify] https://crrev.com/16aeb9f7c312208faf699a2aaa1c9792546b59e8/components/favicon/ios/web_favicon_driver.h
[modify] https://crrev.com/16aeb9f7c312208faf699a2aaa1c9792546b59e8/components/favicon/ios/web_favicon_driver.mm

Blocking: 699980

Comment 7 by mastiz@chromium.org, Mar 13 2017

Blockedon: 700811
Project Member

Comment 8 by bugdroid1@chromium.org, Mar 20 2017

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/36c9189e71036d65209df554c9ddc96be6f78869

commit 36c9189e71036d65209df554c9ddc96be6f78869
Author: mastiz <mastiz@chromium.org>
Date: Mon Mar 20 16:34:12 2017

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}

[modify] https://crrev.com/36c9189e71036d65209df554c9ddc96be6f78869/components/favicon/core/BUILD.gn
[modify] https://crrev.com/36c9189e71036d65209df554c9ddc96be6f78869/components/favicon/core/favicon_handler.cc
[modify] https://crrev.com/36c9189e71036d65209df554c9ddc96be6f78869/components/favicon/core/favicon_handler.h
[modify] https://crrev.com/36c9189e71036d65209df554c9ddc96be6f78869/components/favicon/core/favicon_handler_unittest.cc

Comment 9 by mastiz@chromium.org, Mar 31 2017

Status: Fixed (was: Assigned)
Project Member

Comment 10 by bugdroid1@chromium.org, Apr 6 2017

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/441188cddd4de0849944aac1dd1779b391bedb69

commit 441188cddd4de0849944aac1dd1779b391bedb69
Author: mastiz <mastiz@chromium.org>
Date: Thu Apr 06 09:01:40 2017

Add FaviconHandler test for UpdateFaviconMappingsAndFetch()

Addresses a minor TODO introduced during the review of
https://codereview.chromium.org/2703603002

The idea is to have dedicated tests to verify
UpdateFaviconMappingsAndFetch(), and avoid repeated verifications in
other tests.

BUG= 694312 

Review-Url: https://codereview.chromium.org/2797143002
Cr-Commit-Position: refs/heads/master@{#462399}

[modify] https://crrev.com/441188cddd4de0849944aac1dd1779b391bedb69/components/favicon/core/favicon_handler_unittest.cc

Sign in to add a comment