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

Side by Side Diff: media/cast/audio_sender/audio_sender_unittest.cc

Issue 178073004: Cast: IPC from browser to renderer to send packet events from transport to cast library. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed hubbe's comments Created 6 years, 10 months 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 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/bind_helpers.h" 6 #include "base/bind_helpers.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/base/media.h" 9 #include "media/base/media.h"
10 #include "media/cast/audio_sender/audio_sender.h" 10 #include "media/cast/audio_sender/audio_sender.h"
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 audio_config_.bitrate = kDefaultAudioEncoderBitrate; 77 audio_config_.bitrate = kDefaultAudioEncoderBitrate;
78 audio_config_.rtp_config.payload_type = 127; 78 audio_config_.rtp_config.payload_type = 127;
79 79
80 transport::CastTransportConfig transport_config; 80 transport::CastTransportConfig transport_config;
81 transport_config.audio_rtp_config.payload_type = 127; 81 transport_config.audio_rtp_config.payload_type = 127;
82 transport_config.audio_channels = 2; 82 transport_config.audio_channels = 2;
83 transport_sender_.reset(new transport::CastTransportSenderImpl( 83 transport_sender_.reset(new transport::CastTransportSenderImpl(
84 testing_clock_, 84 testing_clock_,
85 transport_config, 85 transport_config,
86 base::Bind(&UpdateCastTransportStatus), 86 base::Bind(&UpdateCastTransportStatus),
87 base::Bind(&IgnoreRawEvents),
87 task_runner_, 88 task_runner_,
88 &transport_)); 89 &transport_));
89 audio_sender_.reset(new AudioSender( 90 audio_sender_.reset(new AudioSender(
90 cast_environment_, audio_config_, transport_sender_.get())); 91 cast_environment_, audio_config_, transport_sender_.get()));
91 task_runner_->RunTasks(); 92 task_runner_->RunTasks();
92 } 93 }
93 94
94 virtual ~AudioSenderTest() {} 95 virtual ~AudioSenderTest() {}
95 96
96 static void UpdateCastTransportStatus(transport::CastTransportStatus status) { 97 static void UpdateCastTransportStatus(transport::CastTransportStatus status) {
97 EXPECT_EQ(status, transport::TRANSPORT_INITIALIZED); 98 EXPECT_EQ(status, transport::TRANSPORT_INITIALIZED);
98 } 99 }
99 100
101 static void IgnoreRawEvents(const std::vector<PacketEvent>& packet_events) {
102 // Do nothing, we don't care about logging in this test.
hubbe 2014/02/26 01:01:07 Is there *anything* we can add here to make it act
imcheng 2014/02/26 10:08:26 Not really. Logging is disabled in this test, so t
103 }
104
100 base::SimpleTestTickClock* testing_clock_; // Owned by CastEnvironment. 105 base::SimpleTestTickClock* testing_clock_; // Owned by CastEnvironment.
101 TestPacketSender transport_; 106 TestPacketSender transport_;
102 scoped_ptr<transport::CastTransportSenderImpl> transport_sender_; 107 scoped_ptr<transport::CastTransportSenderImpl> transport_sender_;
103 scoped_refptr<test::FakeSingleThreadTaskRunner> task_runner_; 108 scoped_refptr<test::FakeSingleThreadTaskRunner> task_runner_;
104 scoped_ptr<AudioSender> audio_sender_; 109 scoped_ptr<AudioSender> audio_sender_;
105 scoped_refptr<CastEnvironment> cast_environment_; 110 scoped_refptr<CastEnvironment> cast_environment_;
106 AudioSenderConfig audio_config_; 111 AudioSenderConfig audio_config_;
107 }; 112 };
108 113
109 TEST_F(AudioSenderTest, Encode20ms) { 114 TEST_F(AudioSenderTest, Encode20ms) {
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
148 base::TimeDelta max_rtcp_timeout = 153 base::TimeDelta max_rtcp_timeout =
149 base::TimeDelta::FromMilliseconds(1 + kDefaultRtcpIntervalMs * 3 / 2); 154 base::TimeDelta::FromMilliseconds(1 + kDefaultRtcpIntervalMs * 3 / 2);
150 testing_clock_->Advance(max_rtcp_timeout); 155 testing_clock_->Advance(max_rtcp_timeout);
151 task_runner_->RunTasks(); 156 task_runner_->RunTasks();
152 EXPECT_GE(transport_.number_of_rtp_packets(), 1); 157 EXPECT_GE(transport_.number_of_rtp_packets(), 1);
153 EXPECT_EQ(transport_.number_of_rtcp_packets(), 1); 158 EXPECT_EQ(transport_.number_of_rtcp_packets(), 1);
154 } 159 }
155 160
156 } // namespace cast 161 } // namespace cast
157 } // namespace media 162 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698