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

Side by Side Diff: webrtc/audio/test/audio_stats_test.cc

Issue 3008273002: Replace voe_conference_test. (Closed)
Patch Set: rebase Created 3 years, 3 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
(Empty)
1 /*
2 * Copyright (c) 2017 The WebRTC project authors. All Rights Reserved.
3 *
4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree.
9 */
10
11 #include "webrtc/audio/test/audio_end_to_end_test.h"
12 #include "webrtc/system_wrappers/include/sleep.h"
13 #include "webrtc/test/gtest.h"
14
15 namespace webrtc {
16 namespace test {
17 namespace {
18
19 bool IsNear(int reference, int v) {
20 // Margin is 10%.
21 int error = reference / 10 + 1;
kwiberg-webrtc 2017/09/13 14:20:26 const?
the sun 2017/09/13 14:53:33 Done.
22 return std::abs(reference - v) <= error;
23 }
24
25 class NoLossTest : public AudioEndToEndTest {
26 public:
27 const int kTestDurationMs = 8000;
28 const int kBytesSent = 69351;
29 const int32_t kPacketsSent = 400;
30 const int64_t kRttMs = 100;
kwiberg-webrtc 2017/09/13 14:20:26 static constexpr? Or maybe just constexpr, if you
the sun 2017/09/13 14:53:32 constexpr on its own yields compiler errors: ../.
kwiberg-webrtc 2017/09/14 01:26:40 Yeah, that. You could use the enum hack (which got
31
32 NoLossTest() = default;
33
34 FakeNetworkPipe::Config GetNetworkPipeConfig() const override {
35 FakeNetworkPipe::Config pipe_config;
36 pipe_config.queue_delay_ms = kRttMs / 2;
37 return pipe_config;
38 }
39
40 void PerformTest() override {
41 SleepMs(kTestDurationMs);
42 send_audio_device()->StopRecording();
43 AudioEndToEndTest::PerformTest();
44 }
45
46 void OnStreamsStopped() override {
47 AudioSendStream::Stats send_stats = send_stream()->GetStats();
48 EXPECT_PRED2(IsNear, kBytesSent, send_stats.bytes_sent);
49 EXPECT_PRED2(IsNear, kPacketsSent, send_stats.packets_sent);
50 EXPECT_EQ(0, send_stats.packets_lost);
51 EXPECT_EQ(0.0f, send_stats.fraction_lost);
52 EXPECT_EQ("OPUS", send_stats.codec_name);
kwiberg-webrtc 2017/09/13 14:20:26 Should this comparison be case-insensitive? SDP co
the sun 2017/09/13 14:53:33 Changing it to lower case, here and in call_test.c
53 // send_stats.jitter_ms
54 EXPECT_PRED2(IsNear, kRttMs, send_stats.rtt_ms);
55 // Send level is 0 because it is cleared in TransmitMixer::StopSend().
56 EXPECT_EQ(0, send_stats.audio_level);
57 // send_stats.total_input_energy
58 // send_stats.total_input_duration
59 EXPECT_EQ(-1.0f, send_stats.aec_quality_min);
60 EXPECT_EQ(-1, send_stats.echo_delay_median_ms);
61 EXPECT_EQ(-1, send_stats.echo_delay_std_ms);
62 EXPECT_EQ(-100, send_stats.echo_return_loss);
63 EXPECT_EQ(-100, send_stats.echo_return_loss_enhancement);
64 EXPECT_EQ(0.0f, send_stats.residual_echo_likelihood);
65 EXPECT_EQ(0.0f, send_stats.residual_echo_likelihood_recent_max);
66 EXPECT_EQ(false, send_stats.typing_noise_detected);
67
68 AudioReceiveStream::Stats recv_stats = receive_stream()->GetStats();
69 EXPECT_PRED2(IsNear, kBytesSent, recv_stats.bytes_rcvd);
70 EXPECT_PRED2(IsNear, kPacketsSent, recv_stats.packets_rcvd);
71 EXPECT_EQ(0u, recv_stats.packets_lost);
72 EXPECT_EQ(0.0f, recv_stats.fraction_lost);
73 EXPECT_EQ("OPUS", send_stats.codec_name);
74 // recv_stats.jitter_ms
75 // recv_stats.jitter_buffer_ms
76 EXPECT_EQ(20u, recv_stats.jitter_buffer_preferred_ms);
77 // recv_stats.delay_estimate_ms
78 // Receive level is 0 because it is cleared in Channel::StopPlayout().
79 EXPECT_EQ(0, recv_stats.audio_level);
80 // recv_stats.total_output_energy
81 // recv_stats.total_samples_received
82 // recv_stats.total_output_duration
83 // recv_stats.concealed_samples
84 // recv_stats.expand_rate
85 // recv_stats.speech_expand_rate
86 EXPECT_EQ(0.0, recv_stats.secondary_decoded_rate);
87 EXPECT_EQ(0.0, recv_stats.secondary_discarded_rate);
88 EXPECT_EQ(0.0, recv_stats.accelerate_rate);
89 EXPECT_EQ(0.0, recv_stats.preemptive_expand_rate);
90 EXPECT_EQ(0, recv_stats.decoding_calls_to_silence_generator);
91 // recv_stats.decoding_calls_to_neteq
92 // recv_stats.decoding_normal
93 // recv_stats.decoding_plc
94 EXPECT_EQ(0, recv_stats.decoding_cng);
95 // recv_stats.decoding_plc_cng
96 // recv_stats.decoding_muted_output
97 // Capture start time is -1 because we do not have an associated send stream
98 // on the receiver side.
99 EXPECT_EQ(-1, recv_stats.capture_start_ntp_time_ms);
100
101 // Match these stats between caller and receiver.
102 EXPECT_EQ(send_stats.local_ssrc, recv_stats.remote_ssrc);
103 EXPECT_EQ(*send_stats.codec_payload_type, *recv_stats.codec_payload_type);
104 EXPECT_EQ(send_stats.ext_seqnum,
105 static_cast<int32_t>(recv_stats.ext_seqnum));
kwiberg-webrtc 2017/09/13 14:20:26 static_cast is dangerous. Can you convert both of
the sun 2017/09/13 14:53:33 Done.
106 }
107 };
108 } // namespace
109
110 using AudioStatsTest = CallTest;
111
112 TEST_F(AudioStatsTest, NoLoss) {
113 NoLossTest test;
114 RunBaseTest(&test);
115 }
116
117 } // namespace test
118 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698