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

Side by Side Diff: media/cast/audio_receiver/audio_receiver_unittest.cc

Issue 34623008: Change to calculate the real NTP in TimeTicks. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed flaky test Created 7 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
« no previous file with comments | « base/time/time.cc ('k') | media/cast/cast_defines.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "base/bind.h" 5 #include "base/bind.h"
6 #include "base/memory/ref_counted.h" 6 #include "base/memory/ref_counted.h"
7 #include "base/memory/scoped_ptr.h" 7 #include "base/memory/scoped_ptr.h"
8 #include "base/test/simple_test_tick_clock.h" 8 #include "base/test/simple_test_tick_clock.h"
9 #include "media/cast/audio_receiver/audio_receiver.h" 9 #include "media/cast/audio_receiver/audio_receiver.h"
10 #include "media/cast/cast_defines.h" 10 #include "media/cast/cast_defines.h"
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 base::Bind(&TestAudioEncoderCallback::DeliverEncodedAudioFrame, 125 base::Bind(&TestAudioEncoderCallback::DeliverEncodedAudioFrame,
126 test_audio_encoder_callback_.get()); 126 test_audio_encoder_callback_.get());
127 127
128 receiver_->GetEncodedAudioFrame(frame_encoded_callback); 128 receiver_->GetEncodedAudioFrame(frame_encoded_callback);
129 task_runner_->RunTasks(); 129 task_runner_->RunTasks();
130 EXPECT_EQ(1, test_audio_encoder_callback_->number_times_called()); 130 EXPECT_EQ(1, test_audio_encoder_callback_->number_times_called());
131 } 131 }
132 132
133 TEST_F(AudioReceiverTest, MultiplePendingGetCalls) { 133 TEST_F(AudioReceiverTest, MultiplePendingGetCalls) {
134 Configure(true); 134 Configure(true);
135 EXPECT_CALL(mock_transport_, SendRtcpPacket(testing::_)).Times(2); 135 EXPECT_CALL(mock_transport_, SendRtcpPacket(testing::_)).WillRepeatedly(
136 testing::Return(true));
136 137
137 AudioFrameEncodedCallback frame_encoded_callback = 138 AudioFrameEncodedCallback frame_encoded_callback =
138 base::Bind(&TestAudioEncoderCallback::DeliverEncodedAudioFrame, 139 base::Bind(&TestAudioEncoderCallback::DeliverEncodedAudioFrame,
139 test_audio_encoder_callback_.get()); 140 test_audio_encoder_callback_.get());
140 141
141 receiver_->GetEncodedAudioFrame(frame_encoded_callback); 142 receiver_->GetEncodedAudioFrame(frame_encoded_callback);
142 143
143 receiver_->IncomingParsedRtpPacket(payload_.data(), payload_.size(), 144 receiver_->IncomingParsedRtpPacket(payload_.data(), payload_.size(),
144 rtp_header_); 145 rtp_header_);
145 146
146 EncodedAudioFrame audio_frame; 147 EncodedAudioFrame audio_frame;
147 base::TimeTicks playout_time; 148 base::TimeTicks playout_time;
148 test_audio_encoder_callback_->SetExpectedResult(0, testing_clock_.NowTicks()); 149 test_audio_encoder_callback_->SetExpectedResult(0, testing_clock_.NowTicks());
149 150
150 task_runner_->RunTasks(); 151 task_runner_->RunTasks();
151 EXPECT_EQ(1, test_audio_encoder_callback_->number_times_called()); 152 EXPECT_EQ(1, test_audio_encoder_callback_->number_times_called());
152 153
153 TestRtcpPacketBuilder rtcp_packet; 154 TestRtcpPacketBuilder rtcp_packet;
154 155
155 uint32 ntp_high; 156 uint32 ntp_high;
156 uint32 ntp_low; 157 uint32 ntp_low;
157 ConvertTimeToNtp(testing_clock_.NowTicks(), &ntp_high, &ntp_low); 158 ConvertTimeTicksToNtp(testing_clock_.NowTicks(), &ntp_high, &ntp_low);
158 rtcp_packet.AddSrWithNtp(audio_config_.feedback_ssrc, ntp_high, ntp_low, 159 rtcp_packet.AddSrWithNtp(audio_config_.feedback_ssrc, ntp_high, ntp_low,
159 rtp_header_.webrtc.header.timestamp); 160 rtp_header_.webrtc.header.timestamp);
160 161
161 testing_clock_.Advance(base::TimeDelta::FromMilliseconds(20)); 162 testing_clock_.Advance(base::TimeDelta::FromMilliseconds(20));
162 163
163 receiver_->IncomingPacket(rtcp_packet.Packet(), rtcp_packet.Length(), 164 receiver_->IncomingPacket(rtcp_packet.Packet(), rtcp_packet.Length(),
164 base::Bind(AudioReceiverTest::DummyDeletePacket, rtcp_packet.Packet())); 165 base::Bind(AudioReceiverTest::DummyDeletePacket, rtcp_packet.Packet()));
165 166
166 // Make sure that we are not continuous and that the RTP timestamp represent a 167 // Make sure that we are not continuous and that the RTP timestamp represent a
167 // time in the future. 168 // time in the future.
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
203 task_runner_->RunTasks(); 204 task_runner_->RunTasks();
204 EXPECT_EQ(3, test_audio_encoder_callback_->number_times_called()); 205 EXPECT_EQ(3, test_audio_encoder_callback_->number_times_called());
205 } 206 }
206 207
207 // TODO(mikhal): Add encoded frames. 208 // TODO(mikhal): Add encoded frames.
208 TEST_F(AudioReceiverTest, GetRawFrame) { 209 TEST_F(AudioReceiverTest, GetRawFrame) {
209 } 210 }
210 211
211 } // namespace cast 212 } // namespace cast
212 } // namespace media 213 } // namespace media
OLDNEW
« no previous file with comments | « base/time/time.cc ('k') | media/cast/cast_defines.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698