Chromium Code Reviews| Index: media/filters/audio_clock_unittest.cc |
| diff --git a/media/filters/audio_clock_unittest.cc b/media/filters/audio_clock_unittest.cc |
| index f34f21f4438cd5b98d2c42b82632ae4020916e9f..436ded99f00c3793d320d72012a4b4c9b185aef9 100644 |
| --- a/media/filters/audio_clock_unittest.cc |
| +++ b/media/filters/audio_clock_unittest.cc |
| @@ -39,6 +39,11 @@ class AudioClockTest : public testing::Test { |
| milliseconds)).InMilliseconds(); |
| } |
| + int WallTimeForTimestampInMilliseconds(int timestamp_ms) { |
| + return clock_.WallTimeForTimestamp(base::TimeDelta::FromMilliseconds( |
| + timestamp_ms)).InMilliseconds(); |
| + } |
| + |
| int ContiguousAudioDataBufferedInDays() { |
| return clock_.contiguous_audio_data_buffered().InDays(); |
| } |
| @@ -287,6 +292,7 @@ TEST_F(AudioClockTest, TimestampSinceLastWriting) { |
| WroteAudio(10, 10, 40, 0.5); |
| WroteAudio(10, 10, 40, 2.0); |
| EXPECT_EQ(0, FrontTimestampInMilliseconds()); |
| + EXPECT_EQ(3500, BackTimestampInMilliseconds()); |
| EXPECT_EQ(0, ContiguousAudioDataBufferedInMilliseconds()); |
| // Simulate passing 2000ms of initial delay in the audio hardware. |
| @@ -314,6 +320,36 @@ TEST_F(AudioClockTest, TimestampSinceLastWriting) { |
| EXPECT_EQ(3500, TimestampSinceLastWritingInMilliseconds(6000)); |
| } |
| +TEST_F(AudioClockTest, WallTimeForTimestamp) { |
| + // Construct an audio clock with the following representation: |
| + // |
| + // +------------+---------+------------+-----------+------------+-----------+ |
|
DaleCurtis
2014/09/20 00:17:12
As discussed, this diagram is wrong, here's a fixe
scherkus (not reviewing)
2014/09/22 18:34:12
Done.
|
| + // | 10 silence | 10 @ 1x | 10 silence | 10 @ 0.5x | 10 silence | 10 @ 2.0x | |
| + // +------------+---------+------------+-----------+------------+-----------+ |
| + // Media: 0 1000 1000 1500 1500 3500 |
| + // Wall: 2000 3000 4000 5000 6000 7000 |
| + WroteAudio(10, 10, 60, 1.0); |
| + WroteAudio(0, 10, 60, 1.0); |
| + WroteAudio(10, 10, 60, 0.5); |
| + WroteAudio(0, 10, 60, 0.5); |
| + WroteAudio(10, 10, 60, 2.0); |
| + EXPECT_EQ(0, FrontTimestampInMilliseconds()); |
| + EXPECT_EQ(3500, BackTimestampInMilliseconds()); |
| + EXPECT_EQ(0, ContiguousAudioDataBufferedInMilliseconds()); |
| + |
| + // Media timestamp zero has to wait for silence to pass. |
| + EXPECT_EQ(2000, WallTimeForTimestampInMilliseconds(0)); |
| + |
| + // From then on out it's simply adding up the number of frames and taking |
| + // silence into account. |
| + EXPECT_EQ(2500, WallTimeForTimestampInMilliseconds(500)); |
| + EXPECT_EQ(3000, WallTimeForTimestampInMilliseconds(1000)); |
| + EXPECT_EQ(4500, WallTimeForTimestampInMilliseconds(1250)); |
| + EXPECT_EQ(5000, WallTimeForTimestampInMilliseconds(1500)); |
| + EXPECT_EQ(6500, WallTimeForTimestampInMilliseconds(2500)); |
| + EXPECT_EQ(7000, WallTimeForTimestampInMilliseconds(3500)); |
| +} |
| + |
| TEST_F(AudioClockTest, SupportsYearsWorthOfAudioData) { |
| // Use number of frames that would be likely to overflow 32-bit integer math. |
| const int huge_amount_of_frames = std::numeric_limits<int>::max(); |