Chromium Code Reviews| Index: webrtc/voice_engine/test/auto_test/voe_conference_test.cc |
| diff --git a/webrtc/voice_engine/test/auto_test/voe_conference_test.cc b/webrtc/voice_engine/test/auto_test/voe_conference_test.cc |
| index 20a74b46b0880147edae791ffc36161b5be8fae6..ce6332a82b6a7712114e86adf9612e1e136eaef2 100644 |
| --- a/webrtc/voice_engine/test/auto_test/voe_conference_test.cc |
| +++ b/webrtc/voice_engine/test/auto_test/voe_conference_test.cc |
| @@ -14,6 +14,7 @@ |
| #include "webrtc/base/format_macros.h" |
| #include "webrtc/base/timeutils.h" |
| #include "webrtc/system_wrappers/interface/sleep.h" |
| +#include "webrtc/test/testsupport/fileutils.h" |
| #include "webrtc/voice_engine/test/auto_test/fakes/conference_transport.h" |
| namespace { |
| @@ -22,6 +23,10 @@ namespace { |
| static bool IsNear(int ref, int comp, int error) { |
| return (ref - comp <= error) && (comp - ref >= -error); |
| } |
| + static const std::string kInputFileName = |
| + webrtc::test::ResourcePath("audio_coding/testfile32kHz", "pcm"); |
| + static const webrtc::FileFormats kInputFormat = |
| + webrtc::kFileFormatPcm32kHzFile; |
| } |
| namespace voetest { |
| @@ -42,8 +47,8 @@ TEST(VoeConferenceTest, RttAndStartNtpTime) { |
| ConferenceTransport trans; |
| trans.SetRtt(kRttMs); |
| - unsigned int id_1 = trans.AddStream(); |
| - unsigned int id_2 = trans.AddStream(); |
| + unsigned int id_1 = trans.AddStream(kInputFileName, kInputFormat); |
| + unsigned int id_2 = trans.AddStream(kInputFileName, kInputFormat); |
| EXPECT_TRUE(trans.StartPlayout(id_1)); |
| // Start NTP time is the time when a stream is played out, rather than |
| @@ -105,4 +110,58 @@ TEST(VoeConferenceTest, RttAndStartNtpTime) { |
| } |
| } |
| } |
| + |
| + |
| +TEST(VoeConferenceTest, ReceivedPackets) { |
| + const int kPackets = 50; |
| + const int kPacketDurationMs = 20; // Correspond to Opus. |
| + |
| + const std::string silence_file = |
|
phoglund
2015/08/10 08:43:28
Extract this to a helper method CreateTempSilenceF
minyue-webrtc
2015/08/10 09:30:22
ok, will do.
|
| + webrtc::test::TempFilename(webrtc::test::OutputPath(), "silence"); |
| + FILE* fid = fopen(silence_file.c_str(), "wb"); |
| + int temp = 0; |
| + for (int i = 0; i < 32000; i++) { |
| + // Write 1 second, but it does not matter since the file will be looped. |
| + fwrite(&temp, 2, 1, fid); |
| + } |
| + fclose(fid); |
| + |
| + { |
| + ConferenceTransport trans; |
| + // Add silence to stream 0, so that it will be filtered out. |
| + unsigned int id_0 = trans.AddStream(silence_file, kInputFormat); |
| + unsigned int id_1 = trans.AddStream(kInputFileName, kInputFormat); |
| + unsigned int id_2 = trans.AddStream(kInputFileName, kInputFormat); |
| + unsigned int id_3 = trans.AddStream(kInputFileName, kInputFormat); |
| + |
| + EXPECT_TRUE(trans.StartPlayout(id_0)); |
| + EXPECT_TRUE(trans.StartPlayout(id_1)); |
| + EXPECT_TRUE(trans.StartPlayout(id_2)); |
| + EXPECT_TRUE(trans.StartPlayout(id_3)); |
| + |
| + webrtc::SleepMs(kPacketDurationMs * kPackets); |
| + |
| + webrtc::CallStatistics stats_0; |
| + webrtc::CallStatistics stats_1; |
| + webrtc::CallStatistics stats_2; |
| + webrtc::CallStatistics stats_3; |
| + EXPECT_TRUE(trans.GetReceiverStatistics(id_0, &stats_0)); |
| + EXPECT_TRUE(trans.GetReceiverStatistics(id_1, &stats_1)); |
| + EXPECT_TRUE(trans.GetReceiverStatistics(id_2, &stats_2)); |
| + EXPECT_TRUE(trans.GetReceiverStatistics(id_3, &stats_3)); |
| + |
| + // We expect stream 0 to be filtered out totally, but since it may join the |
| + // call earlier than other streams and the beginning packets might have got |
| + // through. So we only expect |packetsReceived| to be close to zero. |
| + EXPECT_NEAR(stats_0.packetsReceived, 0, 2); |
| + // We expect |packetsReceived| to match |kPackets|, but the actual value |
| + // depends on the sleep timer. So we allow a small off from |kPackets|. |
| + EXPECT_NEAR(stats_1.packetsReceived, kPackets, 2); |
| + EXPECT_NEAR(stats_2.packetsReceived, kPackets, 2); |
| + EXPECT_NEAR(stats_3.packetsReceived, kPackets, 2); |
| + } |
| + |
| + remove(silence_file.c_str()); |
| +} |
| + |
| } // namespace voetest |