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 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
61 const double hertz_; | 61 const double hertz_; |
62 const double microseconds_per_tick_; | 62 const double microseconds_per_tick_; |
63 base::TimeTicks base_time_; | 63 base::TimeTicks base_time_; |
64 | 64 |
65 DISALLOW_COPY_AND_ASSIGN(TickGenerator); | 65 DISALLOW_COPY_AND_ASSIGN(TickGenerator); |
66 }; | 66 }; |
67 | 67 |
68 class VideoRendererAlgorithmTest : public testing::Test { | 68 class VideoRendererAlgorithmTest : public testing::Test { |
69 public: | 69 public: |
70 VideoRendererAlgorithmTest() | 70 VideoRendererAlgorithmTest() |
71 : tick_clock_(new base::SimpleTestTickClock()), | 71 // Always start the TickClock at a non-zero value since null values have |
| 72 // special connotations. |
| 73 : tick_clock_(new base::SimpleTestTickClock( |
| 74 base::TimeTicks() + base::TimeDelta::FromMicroseconds(10000))), |
72 algorithm_(base::Bind(&WallClockTimeSource::GetWallClockTimes, | 75 algorithm_(base::Bind(&WallClockTimeSource::GetWallClockTimes, |
73 base::Unretained(&time_source_))) { | 76 base::Unretained(&time_source_))) { |
74 // Always start the TickClock at a non-zero value since null values have | |
75 // special connotations. | |
76 tick_clock_->Advance(base::TimeDelta::FromMicroseconds(10000)); | |
77 time_source_.set_tick_clock_for_testing(tick_clock_.get()); | 77 time_source_.set_tick_clock_for_testing(tick_clock_.get()); |
78 } | 78 } |
79 ~VideoRendererAlgorithmTest() override {} | 79 ~VideoRendererAlgorithmTest() override {} |
80 | 80 |
81 scoped_refptr<VideoFrame> CreateFrame(base::TimeDelta timestamp) { | 81 scoped_refptr<VideoFrame> CreateFrame(base::TimeDelta timestamp) { |
82 const gfx::Size natural_size(8, 8); | 82 const gfx::Size natural_size(8, 8); |
83 return frame_pool_.CreateFrame(PIXEL_FORMAT_YV12, natural_size, | 83 return frame_pool_.CreateFrame(PIXEL_FORMAT_YV12, natural_size, |
84 gfx::Rect(natural_size), natural_size, | 84 gfx::Rect(natural_size), natural_size, |
85 timestamp); | 85 timestamp); |
86 } | 86 } |
(...skipping 1301 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1388 ASSERT_TRUE(is_using_cadence()); | 1388 ASSERT_TRUE(is_using_cadence()); |
1389 | 1389 |
1390 // Finally the last frame. | 1390 // Finally the last frame. |
1391 rendered_frame = RenderAndStep(&tg, &frames_dropped); | 1391 rendered_frame = RenderAndStep(&tg, &frames_dropped); |
1392 EXPECT_EQ(1u, frames_queued()); | 1392 EXPECT_EQ(1u, frames_queued()); |
1393 EXPECT_EQ(tg.interval(12), rendered_frame->timestamp()); | 1393 EXPECT_EQ(tg.interval(12), rendered_frame->timestamp()); |
1394 ASSERT_TRUE(is_using_cadence()); | 1394 ASSERT_TRUE(is_using_cadence()); |
1395 } | 1395 } |
1396 | 1396 |
1397 } // namespace media | 1397 } // namespace media |
OLD | NEW |