Make PDFExtensionClipboardTest more reliable.
Prior to https://crrev.com/802829, PDFExtensionClipboardTest used polling to detect clipboard changes. As such, test cases took the following steps and there was no alternative: A1) Fire asynchronous input event. A2) Poll the clipboard repeatedly for changes. This has an inherently race risk, as (A1) can potentially finish before (A2) starts. With the straight-forward ClipboardMonitor replacement in https://crrev.com/802829, the test cases do less work by not polling, but the race risk remains: B1) Fire asynchronous input event. B2) Start monitoring for clipboard changes. B3) Wait until the clipboard changes. Since the tests are no longer polling, it is now possible to improve reliability by reordering the steps: C1) Start monitoring for clipboard changes. C2) Fire asynchronous input event. C3) Wait until the clipboard changes. To do this, change CheckClipboard() and CheckSelectionClipboard() to take an additional base::OnceClosure for the input event action. Then run the closure at the appropriate time. Also update remaining comments that still mention polling. Bug: 1121446 Change-Id: I2a29ef1ef3b08cf7567318d098f5b527ec9f53bb Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2391582 Commit-Queue: Lei Zhang <thestig@chromium.org> Reviewed-by:K. Moon <kmoon@chromium.org> Cr-Commit-Position: refs/heads/master@{#804378}
Showing
Please register or sign in to comment