commit | 3557f59a6a549483829b1b97f599fe70e1496afe | [log] [tgz] |
---|---|---|
author | Liquan(Max) Gu <[email protected]> | Mon Aug 12 19:59:14 2019 |
committer | Nicolás Peña Moreno <[email protected]> | Mon Aug 12 19:59:14 2019 |
tree | a0c919d1178c4b1fbae413a8af634a12a92149df | |
parent | 10cb520bc1f4beaf79af75c07ad170348bbd6a51 [diff] |
[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}
Chromium is an open-source browser project that aims to build a safer, faster, and more stable way for all users to experience the web.
The project's web site is https://www.chromium.org.
Documentation in the source is rooted in docs/README.md.
Learn how to Get Around the Chromium Source Code Directory Structure .