Index: content/browser/renderer_host/media/web_contents_video_capture_device_unittest.cc |
diff --git a/content/browser/renderer_host/media/web_contents_video_capture_device_unittest.cc b/content/browser/renderer_host/media/web_contents_video_capture_device_unittest.cc |
index 7d027b0a1bb93531374983aeb09dda20c4ce641c..e23e14cf3d8a55de5fdd27ff83fd726eb3b9bdad 100644 |
--- a/content/browser/renderer_host/media/web_contents_video_capture_device_unittest.cc |
+++ b/content/browser/renderer_host/media/web_contents_video_capture_device_unittest.cc |
@@ -723,16 +723,18 @@ TEST_F(WebContentsVideoCaptureDeviceTest, BadFramesGoodFrames) { |
// 60Hz sampled at 30Hz should produce 30Hz. |
TEST(SmoothEventSamplerTest, Sample60HertzAt30Hertz) { |
- SmoothEventSampler sampler(base::TimeDelta::FromSeconds(1) / 30, true); |
+ SmoothEventSampler sampler(base::TimeDelta::FromSeconds(1) / 30, true, 200); |
const base::TimeDelta vsync = base::TimeDelta::FromSeconds(1) / 60; |
base::Time t; |
ASSERT_TRUE(base::Time::FromString("Sat, 23 Mar 2013 1:21:08 GMT", &t)); |
- ASSERT_TRUE(sampler.IsOverdueForSamplingAt(t)) |
- << "First timer event should sample."; |
- sampler.RecordSample(); |
- ASSERT_TRUE(sampler.IsOverdueForSamplingAt(t)) |
- << "Should always be overdue until first paint."; |
+ for (int i = 0; i < 200; i++) { |
+ ASSERT_TRUE(sampler.IsOverdueForSamplingAt(t)) |
+ << "Should sample until redundant capture goal is hit"; |
+ sampler.RecordSample(); |
+ } |
+ ASSERT_FALSE(sampler.IsOverdueForSamplingAt(t)) |
+ << "Should not be overdue once redundant capture goal achieved."; |
// Steady state, we should capture every other vsync, indefinitely. |
for (int i = 0; i < 100; i++) { |
@@ -772,16 +774,20 @@ TEST(SmoothEventSamplerTest, Sample60HertzAt30Hertz) { |
// 50Hz sampled at 30Hz should produce 25Hz. |
TEST(SmoothEventSamplerTest, Sample50HertzAt30Hertz) { |
- SmoothEventSampler sampler(base::TimeDelta::FromSeconds(1) / 30, true); |
+ SmoothEventSampler sampler(base::TimeDelta::FromSeconds(1) / 30, true, 2); |
const base::TimeDelta vsync = base::TimeDelta::FromSeconds(1) / 50; |
base::Time t; |
ASSERT_TRUE(base::Time::FromString("Sat, 23 Mar 2013 1:21:08 GMT", &t)); |
- ASSERT_TRUE(sampler.IsOverdueForSamplingAt(t)) |
- << "First timer event should sample."; |
- sampler.RecordSample(); |
- ASSERT_TRUE(sampler.IsOverdueForSamplingAt(t)) |
- << "Should always be overdue until first paint."; |
+ for (int i = 0; i < 2; i++) { |
+ ASSERT_TRUE(sampler.IsOverdueForSamplingAt(t)) |
+ << "Should sample until redundant capture goal is hit"; |
+ sampler.RecordSample(); |
+ } |
+ ASSERT_FALSE(sampler.IsOverdueForSamplingAt(t)) |
+ << "Should not be overdue once redundant capture goal achieved."; |
+ |
+ |
// Steady state, we should capture every other vsync, indefinitely. |
for (int i = 0; i < 100; i++) { |
@@ -821,16 +827,18 @@ TEST(SmoothEventSamplerTest, Sample50HertzAt30Hertz) { |
// 30Hz sampled at 30Hz should produce 30Hz. |
TEST(SmoothEventSamplerTest, Sample30HertzAt30Hertz) { |
- SmoothEventSampler sampler(base::TimeDelta::FromSeconds(1) / 30, true); |
+ SmoothEventSampler sampler(base::TimeDelta::FromSeconds(1) / 30, true, 3); |
const base::TimeDelta vsync = base::TimeDelta::FromSeconds(1) / 30; |
base::Time t; |
ASSERT_TRUE(base::Time::FromString("Sat, 23 Mar 2013 1:21:08 GMT", &t)); |
- ASSERT_TRUE(sampler.IsOverdueForSamplingAt(t)) |
- << "First timer event should sample."; |
- sampler.RecordSample(); |
- ASSERT_TRUE(sampler.IsOverdueForSamplingAt(t)) |
- << "Should always be overdue until first paint."; |
+ for (int i = 0; i < 3; i++) { |
+ ASSERT_TRUE(sampler.IsOverdueForSamplingAt(t)) |
+ << "Should sample until redundant capture goal is hit"; |
+ sampler.RecordSample(); |
+ } |
+ ASSERT_FALSE(sampler.IsOverdueForSamplingAt(t)) |
+ << "Should not be overdue once redundant capture goal achieved."; |
// Steady state, we should capture every vsync, indefinitely. |
for (int i = 0; i < 200; i++) { |
@@ -862,16 +870,18 @@ TEST(SmoothEventSamplerTest, Sample30HertzAt30Hertz) { |
// 24Hz sampled at 30Hz should produce 24Hz. |
TEST(SmoothEventSamplerTest, Sample24HertzAt30Hertz) { |
- SmoothEventSampler sampler(base::TimeDelta::FromSeconds(1) / 30, true); |
+ SmoothEventSampler sampler(base::TimeDelta::FromSeconds(1) / 30, true, 333); |
const base::TimeDelta vsync = base::TimeDelta::FromSeconds(1) / 24; |
base::Time t; |
ASSERT_TRUE(base::Time::FromString("Sat, 23 Mar 2013 1:21:08 GMT", &t)); |
- ASSERT_TRUE(sampler.IsOverdueForSamplingAt(t)) |
- << "First timer event should sample."; |
- sampler.RecordSample(); |
- ASSERT_TRUE(sampler.IsOverdueForSamplingAt(t)) |
- << "Should always be overdue until first paint."; |
+ for (int i = 0; i < 333; i++) { |
+ ASSERT_TRUE(sampler.IsOverdueForSamplingAt(t)) |
+ << "Should sample until redundant capture goal is hit"; |
+ sampler.RecordSample(); |
+ } |
+ ASSERT_FALSE(sampler.IsOverdueForSamplingAt(t)) |
+ << "Should not be overdue once redundant capture goal achieved."; |
// Steady state, we should capture every vsync, indefinitely. |
for (int i = 0; i < 200; i++) { |
@@ -902,7 +912,7 @@ TEST(SmoothEventSamplerTest, Sample24HertzAt30Hertz) { |
} |
TEST(SmoothEventSamplerTest, DoubleDrawAtOneTimeStillDirties) { |
- SmoothEventSampler sampler(base::TimeDelta::FromSeconds(1) / 30, true); |
+ SmoothEventSampler sampler(base::TimeDelta::FromSeconds(1) / 30, true, 1); |
const base::TimeDelta overdue_period = base::TimeDelta::FromSeconds(1); |
base::Time t; |
@@ -926,8 +936,8 @@ TEST(SmoothEventSamplerTest, DoubleDrawAtOneTimeStillDirties) { |
TEST(SmoothEventSamplerTest, FallbackToPollingIfUpdatesUnreliable) { |
const base::TimeDelta timer_interval = base::TimeDelta::FromSeconds(1) / 30; |
- SmoothEventSampler should_not_poll(timer_interval, true); |
- SmoothEventSampler should_poll(timer_interval, false); |
+ SmoothEventSampler should_not_poll(timer_interval, true, 1); |
+ SmoothEventSampler should_poll(timer_interval, false, 1); |
base::Time t; |
ASSERT_TRUE(base::Time::FromString("Sat, 23 Mar 2013 1:21:08 GMT", &t)); |