Sebastian Jansson | 98b07e9 | 2018-09-27 13:47:01 +0200 | [diff] [blame] | 1 | /* |
| 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" |
| 13 | namespace webrtc { |
| 14 | namespace test { |
| 15 | TEST(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); |
Sebastian Jansson | 800e121 | 2018-10-22 11:49:03 +0200 | [diff] [blame] | 24 | auto route = s.CreateRoutes(alice, {alice_net}, bob, {bob_net}); |
Sebastian Jansson | 98b07e9 | 2018-09-27 13:47:01 +0200 | [diff] [blame] | 25 | |
| 26 | VideoStreamConfig video_stream_config; |
Sebastian Jansson | 800e121 | 2018-10-22 11:49:03 +0200 | [diff] [blame] | 27 | s.CreateVideoStream(route->forward(), video_stream_config); |
| 28 | s.CreateVideoStream(route->reverse(), video_stream_config); |
Sebastian Jansson | 98b07e9 | 2018-09-27 13:47:01 +0200 | [diff] [blame] | 29 | |
| 30 | AudioStreamConfig audio_stream_config; |
Sebastian Jansson | 8285841 | 2018-10-11 19:48:05 +0200 | [diff] [blame] | 31 | audio_stream_config.encoder.min_rate = DataRate::kbps(6); |
| 32 | audio_stream_config.encoder.max_rate = DataRate::kbps(64); |
| 33 | audio_stream_config.encoder.allocate_bitrate = true; |
| 34 | audio_stream_config.stream.in_bandwidth_estimation = false; |
Sebastian Jansson | 800e121 | 2018-10-22 11:49:03 +0200 | [diff] [blame] | 35 | s.CreateAudioStream(route->forward(), audio_stream_config); |
| 36 | s.CreateAudioStream(route->reverse(), audio_stream_config); |
Sebastian Jansson | 98b07e9 | 2018-09-27 13:47:01 +0200 | [diff] [blame] | 37 | |
| 38 | CrossTrafficConfig cross_traffic_config; |
| 39 | s.CreateCrossTraffic({alice_net}, cross_traffic_config); |
| 40 | |
| 41 | bool packet_received = false; |
| 42 | s.NetworkDelayedAction({alice_net, bob_net}, 100, |
| 43 | [&packet_received] { packet_received = true; }); |
| 44 | bool bitrate_changed = false; |
| 45 | s.Every(TimeDelta::ms(10), [alice, bob, &bitrate_changed] { |
| 46 | if (alice->GetStats().send_bandwidth_bps != 300000 && |
| 47 | bob->GetStats().send_bandwidth_bps != 300000) |
| 48 | bitrate_changed = true; |
| 49 | }); |
| 50 | s.RunUntil(TimeDelta::seconds(2), TimeDelta::ms(5), |
| 51 | [&bitrate_changed, &packet_received] { |
| 52 | return packet_received && bitrate_changed; |
| 53 | }); |
| 54 | EXPECT_TRUE(packet_received); |
| 55 | EXPECT_TRUE(bitrate_changed); |
| 56 | } |
| 57 | } // namespace test |
| 58 | } // namespace webrtc |