Commit 5ddf602e authored by Thomas Guilbert's avatar Thomas Guilbert Committed by Commit Bot

Fix video-raf test flakiness

Despite hand coded test values, the difference between
base::TimeTicks::Now() and the Document's origin time can result in times
aligned with a 5 microseconds clock. This is a test failure, because we
don't know whether or not the time values were successfully clamped.

This CL uses the reference monotonic time instead of
base::TimeTicks::Now() when initializing the test values, which
guarantees deterministic results.

Bug: 1057319
Change-Id: I26ee485545a75ba25bc2e9187e78f032fce767e6
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2083737Reviewed-by: default avatarDale Curtis <dalecurtis@chromium.org>
Commit-Queue: Thomas Guilbert <tguilbert@chromium.org>
Auto-Submit: Thomas Guilbert <tguilbert@chromium.org>
Cr-Commit-Position: refs/heads/master@{#746147}
parent 0acf80f1
...@@ -58,13 +58,12 @@ class MockFunction : public ScriptFunction { ...@@ -58,13 +58,12 @@ class MockFunction : public ScriptFunction {
class MetadataHelper { class MetadataHelper {
public: public:
static VideoFramePresentationMetadata* GetDefaultMedatada() { static VideoFramePresentationMetadata* GetDefaultMedatada() {
InitializeFields(); DCHECK(initialized);
return &metadata_; return &metadata_;
} }
static std::unique_ptr<VideoFramePresentationMetadata> CopyDefaultMedatada() { static std::unique_ptr<VideoFramePresentationMetadata> CopyDefaultMedatada() {
InitializeFields(); DCHECK(initialized);
auto copy = std::make_unique<VideoFramePresentationMetadata>(); auto copy = std::make_unique<VideoFramePresentationMetadata>();
copy->presented_frames = metadata_.presented_frames; copy->presented_frames = metadata_.presented_frames;
...@@ -78,8 +77,7 @@ class MetadataHelper { ...@@ -78,8 +77,7 @@ class MetadataHelper {
return copy; return copy;
} }
private: static void InitializeFields(base::TimeTicks now) {
static void InitializeFields() {
if (initialized) if (initialized)
return; return;
...@@ -87,7 +85,6 @@ class MetadataHelper { ...@@ -87,7 +85,6 @@ class MetadataHelper {
// tell whether or not the implementation clamped their values. Therefore, // tell whether or not the implementation clamped their values. Therefore,
// we manually set the values for a deterministic test, and make sure we // we manually set the values for a deterministic test, and make sure we
// have sub-microsecond resolution for those values. // have sub-microsecond resolution for those values.
base::TimeTicks now = base::TimeTicks::Now();
metadata_.presented_frames = 42; metadata_.presented_frames = 42;
metadata_.presentation_time = metadata_.presentation_time =
...@@ -111,6 +108,7 @@ class MetadataHelper { ...@@ -111,6 +108,7 @@ class MetadataHelper {
initialized = true; initialized = true;
} }
private:
static bool initialized; static bool initialized;
static VideoFramePresentationMetadata metadata_; static VideoFramePresentationMetadata metadata_;
}; };
...@@ -344,6 +342,7 @@ TEST_F(VideoRequestAnimationFrameImplTest, ...@@ -344,6 +342,7 @@ TEST_F(VideoRequestAnimationFrameImplTest,
TEST_F(VideoRequestAnimationFrameImplTest, VerifyParameters) { TEST_F(VideoRequestAnimationFrameImplTest, VerifyParameters) {
auto timing = GetDocument().Loader()->GetTiming(); auto timing = GetDocument().Loader()->GetTiming();
MetadataHelper::InitializeFields(timing.ReferenceMonotonicTime());
auto* callback = auto* callback =
MakeGarbageCollected<VideoRafParameterVerifierCallback>(timing); MakeGarbageCollected<VideoRafParameterVerifierCallback>(timing);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment