blob: 87647a4fdd5ceb37976aa640115b49e32ceb7e93 [file] [log] [blame]
Sebastian Jansson98b07e92018-09-27 13:47:01 +02001/*
2 * Copyright 2018 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 "test/scenario/scenario.h"
12#include "test/gtest.h"
13namespace webrtc {
14namespace test {
15TEST(ScenarioTest, StartsAndStopsWithoutErrors) {
16 Scenario s;
17 CallClientConfig call_client_config;
18 call_client_config.transport.rates.start_rate = DataRate::kbps(300);
19 auto* alice = s.CreateClient("alice", call_client_config);
20 auto* bob = s.CreateClient("bob", call_client_config);
21 NetworkNodeConfig network_config;
22 auto alice_net = s.CreateSimulationNode(network_config);
23 auto bob_net = s.CreateSimulationNode(network_config);
24
25 VideoStreamConfig video_stream_config;
26 s.CreateVideoStream(alice, {alice_net}, bob, {bob_net}, video_stream_config);
27 s.CreateVideoStream(bob, {bob_net}, alice, {alice_net}, video_stream_config);
28
29 AudioStreamConfig audio_stream_config;
Sebastian Jansson82858412018-10-11 19:48:05 +020030 audio_stream_config.encoder.min_rate = DataRate::kbps(6);
31 audio_stream_config.encoder.max_rate = DataRate::kbps(64);
32 audio_stream_config.encoder.allocate_bitrate = true;
33 audio_stream_config.stream.in_bandwidth_estimation = false;
Sebastian Jansson98b07e92018-09-27 13:47:01 +020034 s.CreateAudioStream(alice, {alice_net}, bob, {bob_net}, audio_stream_config);
35 s.CreateAudioStream(bob, {bob_net}, alice, {alice_net}, audio_stream_config);
36
37 CrossTrafficConfig cross_traffic_config;
38 s.CreateCrossTraffic({alice_net}, cross_traffic_config);
39
40 bool packet_received = false;
41 s.NetworkDelayedAction({alice_net, bob_net}, 100,
42 [&packet_received] { packet_received = true; });
43 bool bitrate_changed = false;
44 s.Every(TimeDelta::ms(10), [alice, bob, &bitrate_changed] {
45 if (alice->GetStats().send_bandwidth_bps != 300000 &&
46 bob->GetStats().send_bandwidth_bps != 300000)
47 bitrate_changed = true;
48 });
49 s.RunUntil(TimeDelta::seconds(2), TimeDelta::ms(5),
50 [&bitrate_changed, &packet_received] {
51 return packet_received && bitrate_changed;
52 });
53 EXPECT_TRUE(packet_received);
54 EXPECT_TRUE(bitrate_changed);
55}
56} // namespace test
57} // namespace webrtc