| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include <stddef.h> | 5 #include <stddef.h> |
| 6 #include <stdint.h> | 6 #include <stdint.h> |
| 7 | 7 |
| 8 #include <cmath> | 8 #include <cmath> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 66 | 66 |
| 67 DISALLOW_COPY_AND_ASSIGN(TickGenerator); | 67 DISALLOW_COPY_AND_ASSIGN(TickGenerator); |
| 68 }; | 68 }; |
| 69 | 69 |
| 70 class VideoRendererAlgorithmTest : public testing::Test { | 70 class VideoRendererAlgorithmTest : public testing::Test { |
| 71 public: | 71 public: |
| 72 VideoRendererAlgorithmTest() | 72 VideoRendererAlgorithmTest() |
| 73 : tick_clock_(new base::SimpleTestTickClock()), | 73 : tick_clock_(new base::SimpleTestTickClock()), |
| 74 algorithm_(base::Bind(&WallClockTimeSource::GetWallClockTimes, | 74 algorithm_(base::Bind(&WallClockTimeSource::GetWallClockTimes, |
| 75 base::Unretained(&time_source_)), | 75 base::Unretained(&time_source_)), |
| 76 make_scoped_refptr(new MediaLog())) { | 76 &media_log_) { |
| 77 // Always start the TickClock at a non-zero value since null values have | 77 // Always start the TickClock at a non-zero value since null values have |
| 78 // special connotations. | 78 // special connotations. |
| 79 tick_clock_->Advance(base::TimeDelta::FromMicroseconds(10000)); | 79 tick_clock_->Advance(base::TimeDelta::FromMicroseconds(10000)); |
| 80 time_source_.set_tick_clock_for_testing(tick_clock_.get()); | 80 time_source_.set_tick_clock_for_testing(tick_clock_.get()); |
| 81 } | 81 } |
| 82 ~VideoRendererAlgorithmTest() override {} | 82 ~VideoRendererAlgorithmTest() override {} |
| 83 | 83 |
| 84 scoped_refptr<VideoFrame> CreateFrame(base::TimeDelta timestamp) { | 84 scoped_refptr<VideoFrame> CreateFrame(base::TimeDelta timestamp) { |
| 85 const gfx::Size natural_size(8, 8); | 85 const gfx::Size natural_size(8, 8); |
| 86 return frame_pool_.CreateFrame(PIXEL_FORMAT_YV12, natural_size, | 86 return frame_pool_.CreateFrame(PIXEL_FORMAT_YV12, natural_size, |
| (...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 324 | 324 |
| 325 size_t EffectiveFramesQueued() { | 325 size_t EffectiveFramesQueued() { |
| 326 const size_t expected_frames_queued = algorithm_.effective_frames_queued(); | 326 const size_t expected_frames_queued = algorithm_.effective_frames_queued(); |
| 327 // These values should always be in sync. | 327 // These values should always be in sync. |
| 328 algorithm_.UpdateEffectiveFramesQueued(); | 328 algorithm_.UpdateEffectiveFramesQueued(); |
| 329 EXPECT_EQ(expected_frames_queued, algorithm_.effective_frames_queued()); | 329 EXPECT_EQ(expected_frames_queued, algorithm_.effective_frames_queued()); |
| 330 return expected_frames_queued; | 330 return expected_frames_queued; |
| 331 } | 331 } |
| 332 | 332 |
| 333 protected: | 333 protected: |
| 334 MediaLog media_log_; |
| 334 VideoFramePool frame_pool_; | 335 VideoFramePool frame_pool_; |
| 335 std::unique_ptr<base::SimpleTestTickClock> tick_clock_; | 336 std::unique_ptr<base::SimpleTestTickClock> tick_clock_; |
| 336 WallClockTimeSource time_source_; | 337 WallClockTimeSource time_source_; |
| 337 VideoRendererAlgorithm algorithm_; | 338 VideoRendererAlgorithm algorithm_; |
| 338 | 339 |
| 339 private: | 340 private: |
| 340 DISALLOW_COPY_AND_ASSIGN(VideoRendererAlgorithmTest); | 341 DISALLOW_COPY_AND_ASSIGN(VideoRendererAlgorithmTest); |
| 341 }; | 342 }; |
| 342 | 343 |
| 343 TEST_F(VideoRendererAlgorithmTest, Empty) { | 344 TEST_F(VideoRendererAlgorithmTest, Empty) { |
| (...skipping 1223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1567 ASSERT_TRUE(is_using_cadence()); | 1568 ASSERT_TRUE(is_using_cadence()); |
| 1568 | 1569 |
| 1569 // Finally the last frame. | 1570 // Finally the last frame. |
| 1570 rendered_frame = RenderAndStep(&tg, &frames_dropped); | 1571 rendered_frame = RenderAndStep(&tg, &frames_dropped); |
| 1571 EXPECT_EQ(1u, frames_queued()); | 1572 EXPECT_EQ(1u, frames_queued()); |
| 1572 EXPECT_EQ(tg.interval(12), rendered_frame->timestamp()); | 1573 EXPECT_EQ(tg.interval(12), rendered_frame->timestamp()); |
| 1573 ASSERT_TRUE(is_using_cadence()); | 1574 ASSERT_TRUE(is_using_cadence()); |
| 1574 } | 1575 } |
| 1575 | 1576 |
| 1576 } // namespace media | 1577 } // namespace media |
| OLD | NEW |