Chromium Code Reviews| Index: content/browser/media/capture/video_capture_oracle_unittest.cc |
| diff --git a/content/browser/media/capture/video_capture_oracle_unittest.cc b/content/browser/media/capture/video_capture_oracle_unittest.cc |
| index dff8e97de7fec39c7f3e0f56f2c33c7f50ab5e1b..7e11e4f37715c04a70ff374eae9e6498e36e62e4 100644 |
| --- a/content/browser/media/capture/video_capture_oracle_unittest.cc |
| +++ b/content/browser/media/capture/video_capture_oracle_unittest.cc |
| @@ -4,9 +4,15 @@ |
| #include "content/browser/media/capture/video_capture_oracle.h" |
| +#include <cstdlib> |
| +#include <utility> |
| +#include <vector> |
| + |
| +#include "base/logging.h" |
| #include "base/strings/stringprintf.h" |
| #include "base/time/time.h" |
| #include "testing/gtest/include/gtest/gtest.h" |
| +#include "ui/gfx/geometry/rect.h" |
| namespace content { |
| namespace { |
| @@ -33,10 +39,10 @@ void SteadyStateNoSampleAndAdvance(base::TimeDelta vsync, |
| ASSERT_FALSE(sampler->IsOverdueForSamplingAt(*t)); |
| } |
| -void TimeTicksFromString(const char* string, base::TimeTicks* t) { |
| +base::TimeTicks InitialTestTimeTicks() { |
| base::Time time; |
| - ASSERT_TRUE(base::Time::FromString(string, &time)); |
| - *t = base::TimeTicks::UnixEpoch() + (time - base::Time::UnixEpoch()); |
| + CHECK(base::Time::FromString("Sat, 23 Mar 2013 1:21:08 GMT", &time)); |
| + return base::TimeTicks::UnixEpoch() + (time - base::Time::UnixEpoch()); |
| } |
| void TestRedundantCaptureStrategy(base::TimeDelta capture_period, |
| @@ -53,10 +59,10 @@ void TestRedundantCaptureStrategy(base::TimeDelta capture_period, |
| sampler->RecordSample(); |
| ASSERT_FALSE(sampler->HasUnrecordedEvent()); |
| - // After more than one capture period has passed without considering an event, |
| - // we should repeatedly be overdue for sampling. However, once the redundant |
| - // capture goal is achieved, we should no longer be overdue for sampling. |
| - *t += capture_period * 4; |
| + // After more than 250 ms has passed without considering an event, we should |
| + // repeatedly be overdue for sampling. However, once the redundant capture |
| + // goal is achieved, we should no longer be overdue for sampling. |
| + *t += base::TimeDelta::FromMilliseconds(250); |
| for (int i = 0; i < redundant_capture_goal; i++) { |
| SCOPED_TRACE(base::StringPrintf("Iteration %d", i)); |
| ASSERT_FALSE(sampler->HasUnrecordedEvent()); |
| @@ -77,8 +83,7 @@ TEST(SmoothEventSamplerTest, Sample60HertzAt30Hertz) { |
| const base::TimeDelta vsync = base::TimeDelta::FromSeconds(1) / 60; |
| SmoothEventSampler sampler(capture_period, true, redundant_capture_goal); |
| - base::TimeTicks t; |
| - TimeTicksFromString("Sat, 23 Mar 2013 1:21:08 GMT", &t); |
| + base::TimeTicks t = InitialTestTimeTicks(); |
| TestRedundantCaptureStrategy(capture_period, redundant_capture_goal, |
| &sampler, &t); |
| @@ -117,8 +122,7 @@ TEST(SmoothEventSamplerTest, Sample50HertzAt30Hertz) { |
| const base::TimeDelta vsync = base::TimeDelta::FromSeconds(1) / 50; |
| SmoothEventSampler sampler(capture_period, true, redundant_capture_goal); |
| - base::TimeTicks t; |
| - TimeTicksFromString("Sat, 23 Mar 2013 1:21:08 GMT", &t); |
| + base::TimeTicks t = InitialTestTimeTicks(); |
| TestRedundantCaptureStrategy(capture_period, redundant_capture_goal, |
| &sampler, &t); |
| @@ -163,8 +167,7 @@ TEST(SmoothEventSamplerTest, Sample75HertzAt30Hertz) { |
| const base::TimeDelta vsync = base::TimeDelta::FromSeconds(1) / 75; |
| SmoothEventSampler sampler(capture_period, true, redundant_capture_goal); |
| - base::TimeTicks t; |
| - TimeTicksFromString("Sat, 23 Mar 2013 1:21:08 GMT", &t); |
| + base::TimeTicks t = InitialTestTimeTicks(); |
| TestRedundantCaptureStrategy(capture_period, redundant_capture_goal, |
| &sampler, &t); |
| @@ -213,8 +216,7 @@ TEST(SmoothEventSamplerTest, Sample30HertzAt30Hertz) { |
| const base::TimeDelta vsync = base::TimeDelta::FromSeconds(1) / 30; |
| SmoothEventSampler sampler(capture_period, true, redundant_capture_goal); |
| - base::TimeTicks t; |
| - TimeTicksFromString("Sat, 23 Mar 2013 1:21:08 GMT", &t); |
| + base::TimeTicks t = InitialTestTimeTicks(); |
| TestRedundantCaptureStrategy(capture_period, redundant_capture_goal, |
| &sampler, &t); |
| @@ -249,8 +251,7 @@ TEST(SmoothEventSamplerTest, Sample24HertzAt30Hertz) { |
| const base::TimeDelta vsync = base::TimeDelta::FromSeconds(1) / 24; |
| SmoothEventSampler sampler(capture_period, true, redundant_capture_goal); |
| - base::TimeTicks t; |
| - TimeTicksFromString("Sat, 23 Mar 2013 1:21:08 GMT", &t); |
| + base::TimeTicks t = InitialTestTimeTicks(); |
| TestRedundantCaptureStrategy(capture_period, redundant_capture_goal, |
| &sampler, &t); |
| @@ -283,8 +284,7 @@ TEST(SmoothEventSamplerTest, DoubleDrawAtOneTimeStillDirties) { |
| const base::TimeDelta overdue_period = base::TimeDelta::FromSeconds(1); |
| SmoothEventSampler sampler(capture_period, true, 1); |
| - base::TimeTicks t; |
| - TimeTicksFromString("Sat, 23 Mar 2013 1:21:08 GMT", &t); |
| + base::TimeTicks t = InitialTestTimeTicks(); |
| ASSERT_TRUE(sampler.AddEventAndConsiderSampling(t)); |
| sampler.RecordSample(); |
| @@ -308,8 +308,7 @@ TEST(SmoothEventSamplerTest, FallbackToPollingIfUpdatesUnreliable) { |
| SmoothEventSampler should_not_poll(timer_interval, true, 1); |
| SmoothEventSampler should_poll(timer_interval, false, 1); |
| - base::TimeTicks t; |
| - TimeTicksFromString("Sat, 23 Mar 2013 1:21:08 GMT", &t); |
| + base::TimeTicks t = InitialTestTimeTicks(); |
| // Do one round of the "happy case" where an event was received and |
| // RecordSample() was called by the client. |
| @@ -318,8 +317,11 @@ TEST(SmoothEventSamplerTest, FallbackToPollingIfUpdatesUnreliable) { |
| should_not_poll.RecordSample(); |
| should_poll.RecordSample(); |
| - // One time period ahead, neither sampler says we're overdue. |
| - for (int i = 0; i < 3; i++) { |
| + // For the following time period, before 250 ms has elapsed, neither sampler |
| + // says we're overdue. |
| + const int non_overdue_intervals = static_cast<int>( |
| + base::TimeDelta::FromMilliseconds(250) / timer_interval); |
| + for (int i = 0; i < non_overdue_intervals; i++) { |
| t += timer_interval; |
| ASSERT_FALSE(should_not_poll.IsOverdueForSamplingAt(t)) |
| << "Sampled last event; should not be dirty."; |
| @@ -330,7 +332,7 @@ TEST(SmoothEventSamplerTest, FallbackToPollingIfUpdatesUnreliable) { |
| // Next time period ahead, both samplers say we're overdue. The non-polling |
| // sampler is returning true here because it has been configured to allow one |
| // redundant capture. |
| - t += timer_interval; |
| + t += timer_interval; // Step past the 250 ms threshold. |
| ASSERT_TRUE(should_not_poll.IsOverdueForSamplingAt(t)) |
| << "Sampled last event; is dirty one time only to meet redundancy goal."; |
| ASSERT_TRUE(should_poll.IsOverdueForSamplingAt(t)) |
| @@ -364,8 +366,7 @@ struct DataPoint { |
| void ReplayCheckingSamplerDecisions(const DataPoint* data_points, |
| size_t num_data_points, |
| SmoothEventSampler* sampler) { |
| - base::TimeTicks t; |
| - TimeTicksFromString("Sat, 23 Mar 2013 1:21:08 GMT", &t); |
| + base::TimeTicks t = InitialTestTimeTicks(); |
| for (size_t i = 0; i < num_data_points; ++i) { |
| t += base::TimeDelta::FromMicroseconds( |
| static_cast<int64>(data_points[i].increment_ms * 1000)); |
| @@ -483,5 +484,380 @@ TEST(SmoothEventSamplerTest, DrawingAt60FpsWith60HzVsyncSampledAt30Hertz) { |
| ReplayCheckingSamplerDecisions(data_points, arraysize(data_points), &sampler); |
| } |
|
ncarter (slow)
2014/07/26 00:57:57
As I look through these I think we're missing a te
miu
2014/07/28 21:54:12
Yes. This code was all originally written back wh
|
| +// A test scenario for AnimatedContentSamplerTest. |
| +struct Scenario { |
| + base::TimeDelta vsync_interval; // Compositor's update rate. |
| + base::TimeDelta min_capture_period; // Maximum capture rate. |
| + base::TimeDelta content_period; // Animating content frame rate. |
| + |
| + Scenario(base::TimeDelta v, base::TimeDelta m, base::TimeDelta c) |
| + : vsync_interval(v), min_capture_period(m), content_period(c) {} |
| +}; |
| + |
| +// Value printer for Scenario. |
| +::std::ostream& operator<<(::std::ostream& os, const Scenario& s) { |
| + return os << "{ vsync_interval=" << s.vsync_interval.InMicroseconds() |
| + << ", min_capture_period=" << s.min_capture_period.InMicroseconds() |
| + << ", content_period=" << s.content_period.InMicroseconds() |
| + << " }"; |
| +} |
| + |
| +class AnimatedContentSamplerTest : public ::testing::TestWithParam<Scenario> { |
| + public: |
| + AnimatedContentSamplerTest() |
| + : count_dropped_frames_(0), count_sampled_frames_(0) {} |
| + |
| + virtual void SetUp() OVERRIDE { |
| + const base::TimeDelta since_epoch = |
| + InitialTestTimeTicks() - base::TimeTicks::UnixEpoch(); |
| + srand(static_cast<unsigned int>(since_epoch.InMicroseconds())); |
| + sampler_.reset(new AnimatedContentSampler(GetParam().min_capture_period)); |
| + } |
| + |
| + protected: |
| + typedef std::pair<gfx::Rect, base::TimeTicks> Event; |
| + |
| + AnimatedContentSampler* sampler() const { |
| + return sampler_.get(); |
| + } |
| + |
| + std::vector<Event> GenerateEventSequence(base::TimeTicks begin, |
| + base::TimeTicks end, |
| + bool include_content_frame_events, |
| + bool include_random_events) { |
| + DCHECK(GetParam().content_period >= GetParam().vsync_interval); |
| + base::TimeTicks next_content_time = begin - GetParam().content_period; |
| + std::vector<Event> events; |
| + for (base::TimeTicks compositor_time = begin; compositor_time < end; |
| + compositor_time += GetParam().vsync_interval) { |
| + if (include_content_frame_events && next_content_time < compositor_time) { |
| + events.push_back(Event(GetContentDamageRect(), compositor_time)); |
| + next_content_time += GetParam().content_period; |
| + } else if (include_random_events && GetRandomInRange(0, 5) == 0) { |
| + events.push_back(Event(GetRandomDamageRect(), compositor_time)); |
| + } |
| + } |
| + |
| + return events; |
| + } |
| + |
| + void ResetFrameCounters() { |
| + count_dropped_frames_ = 0; |
| + count_sampled_frames_ = 0; |
| + } |
| + |
| + // Keep track what the sampler is proposing, and call RecordSample() if it |
| + // proposes sampling |event|. |
| + void ClientDoesWhatSamplerProposes(const Event& event) { |
| + if (sampler_->next_frame_timestamp().is_null()) { |
| + if (event.first == GetContentDamageRect()) |
| + ++count_dropped_frames_; |
| + } else { |
| + EXPECT_EQ(GetContentDamageRect(), event.first); |
| + sampler_->RecordSample(sampler_->next_frame_timestamp()); |
| + ++count_sampled_frames_; |
| + } |
| + } |
| + |
| + // RecordSample() is not called, but for testing, keep track of what the |
| + // sampler is proposing for |event|. |
| + void ClientCannotSampleFrame(const Event& event) { |
| + if (sampler_->next_frame_timestamp().is_null()) { |
| + if (event.first == GetContentDamageRect()) |
| + ++count_dropped_frames_; |
| + } else { |
| + EXPECT_EQ(GetContentDamageRect(), event.first); |
| + ++count_sampled_frames_; |
| + } |
| + } |
| + |
| + void ExpectFrameDropRatioIsCorrect() { |
| + const double content_framerate = |
| + 1000000.0 / GetParam().content_period.InMicroseconds(); |
| + const double capture_framerate = |
| + 1000000.0 / GetParam().min_capture_period.InMicroseconds(); |
| + const double expected_drop_rate = std::max( |
| + 0.0, (content_framerate - capture_framerate) / capture_framerate); |
| + const double actual_drop_rate = |
| + static_cast<double>(count_dropped_frames_) / count_sampled_frames_; |
| + EXPECT_NEAR(expected_drop_rate, actual_drop_rate, 0.01); |
| + } |
| + |
| + static int GetRandomInRange(int begin, int end) { |
| + const int len = end - begin; |
| + const int rand_offset = (len == 0) ? 0 : (rand() % (end - begin)); |
| + return begin + rand_offset; |
| + } |
| + |
| + static gfx::Rect GetRandomDamageRect() { |
| + return gfx::Rect(0, 0, GetRandomInRange(1, 600), GetRandomInRange(1, 600)); |
| + } |
| + |
| + static gfx::Rect GetContentDamageRect() { |
| + // This must be distinct from anything GetRandomDamageRect() could return. |
| + return gfx::Rect(0, 0, 1280, 720); |
| + } |
| + |
| + private: |
| + scoped_ptr<AnimatedContentSampler> sampler_; |
| + |
| + // These counters only include the frames with the desired content. |
| + int count_dropped_frames_; |
| + int count_sampled_frames_; |
| +}; |
| + |
| +// Tests that the implementation locks in/out of frames containing stable |
| +// animated content, whether or not random events are also simultaneously |
| +// present. |
| +TEST_P(AnimatedContentSamplerTest, LocksIntoMajorityAnimatedContent) { |
| + // |begin| refers to the start of an event sequence in terms of the |
| + // Compositor's clock. |
| + base::TimeTicks begin = InitialTestTimeTicks(); |
| + |
| + // Provide three minutes of random events and expect no lock-in. |
| + EXPECT_TRUE(sampler()->next_frame_timestamp().is_null()); |
| + base::TimeTicks end = begin + base::TimeDelta::FromMinutes(3); |
| + std::vector<Event> events = GenerateEventSequence(begin, end, false, true); |
| + for (std::vector<Event>::const_iterator i = events.begin(); i != events.end(); |
| + ++i) { |
| + EXPECT_FALSE(sampler()->ConsiderPresentationEvent(i->first, i->second)); |
| + EXPECT_TRUE(sampler()->next_frame_timestamp().is_null()); |
| + sampler()->RecordSample(i->second); |
| + } |
| + begin = end; |
| + |
| + // Provide content frame events with some random events mixed-in, and expect |
| + // the sampler to lock-in once 1000 ms has elapsed, and also to remain in a |
| + // continuous lock-in 1250 ms after that. |
| + end = begin + base::TimeDelta::FromSeconds(10); |
| + events = GenerateEventSequence(begin, end, true, true); |
| + bool is_locked_in = false; |
| + ResetFrameCounters(); |
| + for (std::vector<Event>::const_iterator i = events.begin(); i != events.end(); |
| + ++i) { |
| + const base::TimeDelta elapsed = i->second - events.begin()->second; |
| + if (elapsed < base::TimeDelta::FromMilliseconds(1000)) { |
| + EXPECT_FALSE(sampler()->ConsiderPresentationEvent(i->first, i->second)); |
| + sampler()->RecordSample(i->second); |
| + } else { |
| + if (sampler()->ConsiderPresentationEvent(i->first, i->second)) { |
| + is_locked_in = true; |
| + ClientDoesWhatSamplerProposes(*i); |
| + } else { |
| + if (elapsed > base::TimeDelta::FromMilliseconds(1250)) |
| + EXPECT_FALSE(is_locked_in); |
| + EXPECT_TRUE(sampler()->next_frame_timestamp().is_null()); |
| + sampler()->RecordSample(i->second); |
| + } |
| + } |
| + } |
| + EXPECT_TRUE(is_locked_in); |
| + ExpectFrameDropRatioIsCorrect(); |
| + begin = end; |
| + |
| + // Continue providing content frame events without random events mixed-in and |
| + // expect the lock-in to hold. |
| + end = begin + base::TimeDelta::FromSeconds(30); |
| + events = GenerateEventSequence(begin, end, true, false); |
| + ResetFrameCounters(); |
| + for (std::vector<Event>::const_iterator i = events.begin(); i != events.end(); |
| + ++i) { |
| + EXPECT_TRUE(sampler()->ConsiderPresentationEvent(i->first, i->second)); |
| + ClientDoesWhatSamplerProposes(*i); |
| + } |
| + ExpectFrameDropRatioIsCorrect(); |
| + begin = end; |
| + |
| + // Continue providing content frame events and expect the lock-in to hold. |
| + // RecordSample() is only sometimes called, which simulates the capture |
| + // pipeline experiencing back pressure. |
| + end = begin + base::TimeDelta::FromSeconds(30); |
| + events = GenerateEventSequence(begin, end, true, false); |
| + ResetFrameCounters(); |
| + for (std::vector<Event>::const_iterator i = events.begin(); i != events.end(); |
| + ++i) { |
| + EXPECT_TRUE(sampler()->ConsiderPresentationEvent(i->first, i->second)); |
| + if (GetRandomInRange(0, 2) == 0) |
| + ClientCannotSampleFrame(*i); |
| + else |
| + ClientDoesWhatSamplerProposes(*i); |
| + } |
| + ExpectFrameDropRatioIsCorrect(); |
| + begin = end; |
| + |
| + // Provide a half-second of random events only, and expect the lock-in to be |
| + // broken. |
| + end = begin + base::TimeDelta::FromMilliseconds(500); |
| + events = GenerateEventSequence(begin, end, false, true); |
| + is_locked_in = true; |
| + for (std::vector<Event>::const_iterator i = events.begin(); i != events.end(); |
| + ++i) { |
| + if (sampler()->ConsiderPresentationEvent(i->first, i->second)) { |
| + EXPECT_TRUE(is_locked_in); |
| + ClientDoesWhatSamplerProposes(*i); |
| + } else { |
| + is_locked_in = false; |
| + EXPECT_TRUE(sampler()->next_frame_timestamp().is_null()); |
| + sampler()->RecordSample(i->second); |
| + } |
| + } |
| + EXPECT_FALSE(is_locked_in); |
| + begin = end; |
| + |
| + // Now, go back to providing content frame events, and expect the sampler to |
| + // lock-in once again. |
| + end = begin + base::TimeDelta::FromSeconds(10); |
| + events = GenerateEventSequence(begin, end, true, false); |
| + for (std::vector<Event>::const_iterator i = events.begin(); i != events.end(); |
| + ++i) { |
| + const base::TimeDelta elapsed = i->second - events.begin()->second; |
| + if (elapsed < base::TimeDelta::FromMilliseconds(1000)) { |
| + EXPECT_FALSE(sampler()->ConsiderPresentationEvent(i->first, i->second)); |
| + sampler()->RecordSample(i->second); |
| + } else { |
| + if (sampler()->ConsiderPresentationEvent(i->first, i->second)) { |
| + is_locked_in = true; |
| + ClientDoesWhatSamplerProposes(*i); |
| + } else { |
| + if (elapsed > base::TimeDelta::FromMilliseconds(1250)) |
| + EXPECT_FALSE(is_locked_in); |
| + EXPECT_TRUE(sampler()->next_frame_timestamp().is_null()); |
| + sampler()->RecordSample(i->second); |
| + } |
| + } |
| + } |
| + EXPECT_TRUE(is_locked_in); |
| + begin = end; |
| +} |
| + |
| +// Tests that the frame timestamps are smooth; meaning, that when run through a |
| +// simulated compositor, each frame is held displayed for the right number of |
| +// v-sync intervals. |
| +TEST_P(AnimatedContentSamplerTest, FrameTimestampsAreSmooth) { |
| + // Generate 30 seconds of animated content events, run the events through |
| + // AnimatedContentSampler, and record all frame timestamps being proposed |
| + // once lock-in is continuous. |
| + base::TimeTicks begin = InitialTestTimeTicks(); |
| + std::vector<Event> events = GenerateEventSequence( |
| + begin, |
| + begin + base::TimeDelta::FromSeconds(30), |
| + true, |
| + false); |
| + typedef std::vector<base::TimeTicks> Timestamps; |
| + Timestamps frame_timestamps; |
| + for (std::vector<Event>::const_iterator i = events.begin(); i != events.end(); |
| + ++i) { |
| + if (sampler()->ConsiderPresentationEvent(i->first, i->second)) { |
| + if (!sampler()->next_frame_timestamp().is_null()) { |
| + frame_timestamps.push_back(sampler()->next_frame_timestamp()); |
| + sampler()->RecordSample(sampler()->next_frame_timestamp()); |
| + } |
| + } else { |
| + frame_timestamps.clear(); // Reset until continuous lock-in. |
| + } |
| + } |
| + ASSERT_LE(2u, frame_timestamps.size()); |
| + |
| + // Iterate through the |frame_timestamps|, building a histogram counting the |
| + // number of times each frame was displayed k times. For example, 10 frames |
| + // of 30 Hz content on a 60 Hz v-sync interval should result in |
| + // display_counts[2] == 10. Quit early if any one frame was obviously |
| + // repeated too many times. |
| + const int64 max_expected_repeats_per_frame = 1 + |
| + std::max(GetParam().min_capture_period, GetParam().content_period) / |
| + GetParam().vsync_interval; |
| + std::vector<size_t> display_counts(max_expected_repeats_per_frame + 1, 0); |
| + base::TimeTicks last_present_time = frame_timestamps.front(); |
| + for (Timestamps::const_iterator i = frame_timestamps.begin() + 1; |
| + i != frame_timestamps.end(); ++i) { |
| + const size_t num_vsync_intervals = static_cast<size_t>( |
| + (*i - last_present_time) / GetParam().vsync_interval); |
| + ASSERT_LT(0u, num_vsync_intervals); |
| + ASSERT_GT(display_counts.size(), num_vsync_intervals); // Quit early. |
| + ++display_counts[num_vsync_intervals]; |
| + last_present_time += num_vsync_intervals * GetParam().vsync_interval; |
| + } |
| + |
| + // Analyze the histogram for an expected result pattern. If the frame |
| + // timestamps are smooth, there should only be one or two buckets with |
| + // non-zero counts and they should be next to each other. Because the clock |
| + // precision for the event_times provided to the sampler is very granular |
| + // (i.e., the vsync_interval), it's okay if other buckets have a tiny "stray" |
| + // count in this test. |
| + size_t highest_count = 0; |
| + size_t second_highest_count = 0; |
| + for (size_t repeats = 1; repeats < display_counts.size(); ++repeats) { |
| + DVLOG(1) << "display_counts[" << repeats << "] is " |
| + << display_counts[repeats]; |
| + if (display_counts[repeats] >= highest_count) { |
| + second_highest_count = highest_count; |
| + highest_count = display_counts[repeats]; |
| + } else if (display_counts[repeats] > second_highest_count) { |
| + second_highest_count = display_counts[repeats]; |
| + } |
| + } |
| + size_t stray_count_remaining = |
| + (frame_timestamps.size() - 1) - (highest_count + second_highest_count); |
| + // Expect no more than 0.5% of frames fall outside the two main buckets. |
| + EXPECT_GT(frame_timestamps.size() * 5 / 1000, stray_count_remaining); |
| + for (size_t repeats = 1; repeats < display_counts.size() - 1; ++repeats) { |
| + if (display_counts[repeats] == highest_count) { |
| + EXPECT_EQ(second_highest_count, display_counts[repeats + 1]); |
| + ++repeats; |
| + } else if (display_counts[repeats] == second_highest_count) { |
| + EXPECT_EQ(highest_count, display_counts[repeats + 1]); |
| + ++repeats; |
| + } else { |
| + EXPECT_GE(stray_count_remaining, display_counts[repeats]); |
| + stray_count_remaining -= display_counts[repeats]; |
| + } |
| + } |
| +} |
| + |
| +base::TimeDelta FpsAsPeriod(int frame_rate) { |
| + return base::TimeDelta::FromSeconds(1) / frame_rate; |
| +} |
| + |
| +INSTANTIATE_TEST_CASE_P( |
| + , |
| + AnimatedContentSamplerTest, |
| + ::testing::Values( |
| + // Typical frame rate content: Compositor runs at 60 Hz, capture at 30 |
| + // Hz, and content video animates at 30, 25, or 24 Hz. |
| + Scenario(FpsAsPeriod(60), FpsAsPeriod(30), FpsAsPeriod(30)), |
| + Scenario(FpsAsPeriod(60), FpsAsPeriod(30), FpsAsPeriod(25)), |
| + Scenario(FpsAsPeriod(60), FpsAsPeriod(30), FpsAsPeriod(24)), |
| + |
| + // High frame rate content that leverages the Compositor's |
| + // capabilities, but capture is still at 30 Hz. |
| + Scenario(FpsAsPeriod(60), FpsAsPeriod(30), FpsAsPeriod(60)), |
| + Scenario(FpsAsPeriod(60), FpsAsPeriod(30), FpsAsPeriod(50)), |
| + Scenario(FpsAsPeriod(60), FpsAsPeriod(30), FpsAsPeriod(48)), |
| + |
| + // High frame rate content that leverages the Compositor's |
| + // capabilities, and capture is also a buttery 60 Hz. |
| + Scenario(FpsAsPeriod(60), FpsAsPeriod(60), FpsAsPeriod(60)), |
| + Scenario(FpsAsPeriod(60), FpsAsPeriod(60), FpsAsPeriod(50)), |
| + Scenario(FpsAsPeriod(60), FpsAsPeriod(60), FpsAsPeriod(48)), |
| + |
| + // On some platforms, the Compositor runs at 50 Hz. |
| + Scenario(FpsAsPeriod(50), FpsAsPeriod(30), FpsAsPeriod(30)), |
| + Scenario(FpsAsPeriod(50), FpsAsPeriod(30), FpsAsPeriod(25)), |
| + Scenario(FpsAsPeriod(50), FpsAsPeriod(30), FpsAsPeriod(24)), |
| + Scenario(FpsAsPeriod(50), FpsAsPeriod(30), FpsAsPeriod(50)), |
| + Scenario(FpsAsPeriod(50), FpsAsPeriod(30), FpsAsPeriod(48)), |
| + |
| + // Stable, but non-standard content frame rates. |
| + Scenario(FpsAsPeriod(60), FpsAsPeriod(30), FpsAsPeriod(16)), |
| + Scenario(FpsAsPeriod(60), FpsAsPeriod(30), FpsAsPeriod(20)), |
| + Scenario(FpsAsPeriod(60), FpsAsPeriod(30), FpsAsPeriod(23)), |
| + Scenario(FpsAsPeriod(60), FpsAsPeriod(30), FpsAsPeriod(26)), |
| + Scenario(FpsAsPeriod(60), FpsAsPeriod(30), FpsAsPeriod(27)), |
| + Scenario(FpsAsPeriod(60), FpsAsPeriod(30), FpsAsPeriod(28)), |
| + Scenario(FpsAsPeriod(60), FpsAsPeriod(30), FpsAsPeriod(29)), |
| + Scenario(FpsAsPeriod(60), FpsAsPeriod(30), FpsAsPeriod(31)), |
| + Scenario(FpsAsPeriod(60), FpsAsPeriod(30), FpsAsPeriod(32)), |
| + Scenario(FpsAsPeriod(60), FpsAsPeriod(30), FpsAsPeriod(33)))); |
| + |
|
ncarter (slow)
2014/07/26 00:57:58
Given how the oracle in practice drives both sampl
miu
2014/07/28 21:54:12
Good point. I'll work on adding this.
miu
2014/07/31 01:25:32
Done.
|
| } // namespace |
| } // namespace content |