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