[M77][LCP] Test: mock swap-time request for text and image

TextPaintTimingDetector(LTP) and ImagePaintTimingDetector (LIP) both
use ChromeClient to register callbacks in their implementation.
However, ChromeClient is an external component, which needs to
be decoupled in the test.

The initial design bypasses the callback in test. Specifically, LIP
bypasses it by having a control flag to direct the callback to a
local callback queue, and LTP simply just ignores the callback logic.
Either approach did not achieve a comprehensive coverage.

The new design in this CL uses a mocking approach for decoupling. As
ChromeClient was called to register callbacks, the new design
inserts an interface between LTP&LIP and ChromeClient. When testing
LTP&LIP, the interface is mocked with a local callback queue.
So the external component can be removed from the unit test.

Compared to an earlier attempt crrev.com/c/1701058 where two callbacks
were combined, this approach allows for separate callback-queueing
for Image/TextPaintTimingDetector, LargestContentfulPaintDetector
and other paint timing components in unit test. This way, future
change in LTP wouldn't affect the unit-test in LIP via ChromeClient
and vice versa. In addition, LargestContentfulPaintCalculator can
thus keep being capable of controlling the order of text callback and
image callback. As ChromeClient is shared with other paint metrics
(FP, FCP, FMP), the tests of LTP and LIP would couple with these
metrics if ChromeClient is not well separated.

As an extra benefit, this change will make it possible to combine
two callbacks by implementing the callback-manager interface in
a different way. The combination will then provide a hook to the
time when "both LIP and LTP callbacks have been invoked". This
hook would make it easy to solve crbug.com/982307.

This CL doesn't change the unit-tests expectations.

Bug: 982307, 987984

(cherry picked from commit ea0b582f983386251a62a463c2470cff7782fb5c)

Change-Id: I8d58a9676b1b350c630f076c530b54f2d7c6ab04
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1722449
Reviewed-by: Steve Kobes <[email protected]>
Commit-Queue: Liquan (Max) Gu <[email protected]>
Cr-Original-Commit-Position: refs/heads/master@{#682923}
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1748601
Reviewed-by: Nicolás Peña Moreno <[email protected]>
Cr-Commit-Position: refs/branch-heads/3865@{#331}
Cr-Branched-From: 0cdcc6158160790658d1f033d3db873603250124-refs/heads/master@{#681094}
11 files changed