New issue
Advanced search Search tips

Issue 615784 link

Starred by 1 user

Issue metadata

Status: Available
Owner: ----
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: ----
Pri: 3
Type: Task



Sign in to add a comment

Make autofill::form_util mockable

Project Member Reported by vabr@chromium.org, May 30 2016

Issue description

The utilities defined in components/autofill/content/renderer/form_autofill_util.h are a bunch of static functions. As such, they are not mockable in tests, i.e., one cannot inject alternative versions for testing without modifying the production code as well.

A particular case was in https://codereview.chromium.org/2009823003/, where a test was needed that PasswordAutofillAgent::DidFinishDocumentLoad did call a function from the form_util namespace.

One way to solve this would be by having a FormUtil class with the current static functions as virtual methods. This class could be then reimplemented for tests to provide mocked versions of those functions. The thing to decide would be: how to vend the instance of FormUtil. It could be owned by AutofillAgent, or be a singleton. In the latter case, we would probably still end up with some testing provisions in the production code (to allow swapping the singleton for a mocked instance), but at least that would be limited to that single purpose.
 

Comment 1 by ma...@chromium.org, May 30 2016

Cc: tmartino@chromium.org
Totally agreed. 

Adding tmartino@ since he's touching autofill_agent and might find himself wanting to do something similar for his tests.

Comment 2 by vabr@chromium.org, Jun 6 2016

Labels: -refactoring Hotlist-Refactoring
Project Member

Comment 3 by sheriffbot@chromium.org, Jun 6 2017

Labels: Hotlist-Recharge-Cold
Status: Untriaged (was: Available)
This issue has been Available for over a year. If it's no longer important or seems unlikely to be fixed, please consider closing it out. If it is important, please re-triage the issue.

Sorry for the inconvenience if the bug really should have been left as Available. If you change it back, also remove the "Hotlist-Recharge-Cold" label.

For more details visit https://www.chromium.org/issue-tracking/autotriage - Your friendly Sheriffbot

Comment 4 by vabr@chromium.org, Jun 7 2017

Labels: -Type-Bug -Hotlist-Recharge-Cold Hotlist-TechnicalDebt Type-Task
Status: Available (was: Untriaged)

Comment 5 by ma...@chromium.org, May 1 2018

Status: Untriaged (was: Available)
Status: Available (was: Untriaged)

Sign in to add a comment