Index: remoting/protocol/audio_pump_unittest.cc |
diff --git a/remoting/protocol/audio_pump_unittest.cc b/remoting/protocol/audio_pump_unittest.cc |
index 806cd0a7ece8e36fabfd5cf353487952526ef0d1..b6f0c1eab9a2e1e4312b24c12a890886dd8b7ffd 100644 |
--- a/remoting/protocol/audio_pump_unittest.cc |
+++ b/remoting/protocol/audio_pump_unittest.cc |
@@ -27,9 +27,13 @@ namespace protocol { |
namespace { |
// Creates a dummy packet with 1k data |
-std::unique_ptr<AudioPacket> MakeAudioPacket() { |
+std::unique_ptr<AudioPacket> MakeAudioPacket(int channel_count = 2) { |
std::unique_ptr<AudioPacket> packet(new AudioPacket); |
- packet->add_data()->resize(1000); |
+ packet->add_data()->resize(1024); |
+ packet->set_encoding(AudioPacket::ENCODING_RAW); |
+ packet->set_sampling_rate(AudioPacket::SAMPLING_RATE_44100); |
+ packet->set_bytes_per_sample(AudioPacket::BYTES_PER_SAMPLE_2); |
+ packet->set_channels(static_cast<AudioPacket::Channels>(channel_count)); |
return packet; |
} |
@@ -42,6 +46,8 @@ class FakeAudioEncoder : public AudioEncoder { |
std::unique_ptr<AudioPacket> Encode( |
std::unique_ptr<AudioPacket> packet) override { |
+ EXPECT_TRUE(!!packet); |
+ EXPECT_LE(packet->channels(), 2); |
return packet; |
} |
int GetBitrate() override { return 160000; } |
@@ -127,5 +133,24 @@ TEST_F(AudioPumpTest, BufferSizeLimit) { |
EXPECT_EQ(num_sent_packets + 1, sent_packets_.size()); |
} |
+TEST_F(AudioPumpTest, DownmixAudioPacket) { |
+ base::RunLoop().RunUntilIdle(); |
joedow
2017/05/26 16:01:51
Please add a comment here to note why this is need
Hzj_jie
2017/05/26 20:08:04
Done.
|
+ ASSERT_TRUE(source_->callback()); |
+ |
+ // Randomly generate several audio packets with different channel counts. |
joedow
2017/05/26 16:01:51
nit: This isn't random if you define a static list
Hzj_jie
2017/05/26 20:08:03
Done.
|
+ static const int kChannels[] = { |
+ 8, 6, 2, 1, 8, 8, 8, 8, 6, 6, 6, 6, 2, |
+ }; |
joedow
2017/05/26 16:01:51
Would it make sense to use the enum names here ins
Hzj_jie
2017/05/26 20:08:04
Done.
|
+ |
+ for (size_t i = 0; i < arraysize(kChannels); i++) { |
+ source_->callback().Run(MakeAudioPacket(kChannels[i])); |
+ base::RunLoop().RunUntilIdle(); |
joedow
2017/05/26 16:01:51
Please add comments (as in the test above) to expl
Hzj_jie
2017/05/26 20:08:04
Done.
|
+ done_closures_.front().Run(); |
+ base::RunLoop().RunUntilIdle(); |
+ } |
+ |
+ EXPECT_EQ(sent_packets_.size(), arraysize(kChannels)); |
+} |
+ |
} // namespace protocol |
} // namespace remoting |