Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(113)

Side by Side Diff: media/renderers/audio_renderer_impl_unittest.cc

Issue 2425463002: Improve HTMLMediaElement::currentTime() (Closed)
Patch Set: Merge Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "media/renderers/audio_renderer_impl.h" 5 #include "media/renderers/audio_renderer_impl.h"
6 6
7 #include <memory> 7 #include <memory>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 730 matching lines...) Expand 10 before | Expand all | Expand 10 after
741 tick_clock_->Advance(kConsumptionDuration * 2); 741 tick_clock_->Advance(kConsumptionDuration * 2);
742 EXPECT_EQ(timestamp_helper.GetTimestamp(), CurrentMediaTime()); 742 EXPECT_EQ(timestamp_helper.GetTimestamp(), CurrentMediaTime());
743 743
744 // Consume some more audio data. 744 // Consume some more audio data.
745 EXPECT_TRUE(ConsumeBufferedData(frames_to_consume)); 745 EXPECT_TRUE(ConsumeBufferedData(frames_to_consume));
746 746
747 // Stop ticking, the media time should be clamped to what's been rendered. 747 // Stop ticking, the media time should be clamped to what's been rendered.
748 StopTicking(); 748 StopTicking();
749 EXPECT_EQ(timestamp_helper.GetTimestamp(), CurrentMediaTime()); 749 EXPECT_EQ(timestamp_helper.GetTimestamp(), CurrentMediaTime());
750 tick_clock_->Advance(kConsumptionDuration * 2); 750 tick_clock_->Advance(kConsumptionDuration * 2);
751 751 timestamp_helper.AddFrames(frames_to_consume.value);
752 // TODO(chcunningham): Uncomment the AddFrames() call below. AudioClock should
753 // be expected to advance time through the last rendered buffer's samples, but
754 // we've currently capped it to not advance time after ticking stops as a
755 // short term workaround for messy blink code. See longterm solution at
756 // http://crrev.com/2425463002.
757 // timestamp_helper.AddFrames(frames_to_consume.value);
758 EXPECT_EQ(timestamp_helper.GetTimestamp(), CurrentMediaTime()); 752 EXPECT_EQ(timestamp_helper.GetTimestamp(), CurrentMediaTime());
759 } 753 }
760 754
761 TEST_F(AudioRendererImplTest, RenderingDelayedForEarlyStartTime) { 755 TEST_F(AudioRendererImplTest, RenderingDelayedForEarlyStartTime) {
762 Initialize(); 756 Initialize();
763 757
764 // Choose a first timestamp a few buffers into the future, which ends halfway 758 // Choose a first timestamp a few buffers into the future, which ends halfway
765 // through the desired output buffer; this allows for maximum test coverage. 759 // through the desired output buffer; this allows for maximum test coverage.
766 const double kBuffers = 4.5; 760 const double kBuffers = 4.5;
767 const base::TimeDelta first_timestamp = 761 const base::TimeDelta first_timestamp =
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after
1026 // Advance far enough that we shouldn't be clamped to current time (tested 1020 // Advance far enough that we shouldn't be clamped to current time (tested
1027 // already above). 1021 // already above).
1028 tick_clock_->Advance(kOneSecond); 1022 tick_clock_->Advance(kOneSecond);
1029 EXPECT_EQ( 1023 EXPECT_EQ(
1030 current_time + timestamp_helper.GetFrameDuration(frames_to_consume.value), 1024 current_time + timestamp_helper.GetFrameDuration(frames_to_consume.value),
1031 CurrentMediaWallClockTime(&is_time_moving)); 1025 CurrentMediaWallClockTime(&is_time_moving));
1032 EXPECT_TRUE(is_time_moving); 1026 EXPECT_TRUE(is_time_moving);
1033 } 1027 }
1034 1028
1035 } // namespace media 1029 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698