blob: 305f8660ccd744e9e7f563d8f33e2bfdc24c8ce3 [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;
30 s.CreateAudioStream(alice, {alice_net}, bob, {bob_net}, audio_stream_config);
31 s.CreateAudioStream(bob, {bob_net}, alice, {alice_net}, audio_stream_config);
32
33 CrossTrafficConfig cross_traffic_config;
34 s.CreateCrossTraffic({alice_net}, cross_traffic_config);
35
36 bool packet_received = false;
37 s.NetworkDelayedAction({alice_net, bob_net}, 100,
38 [&packet_received] { packet_received = true; });
39 bool bitrate_changed = false;
40 s.Every(TimeDelta::ms(10), [alice, bob, &bitrate_changed] {
41 if (alice->GetStats().send_bandwidth_bps != 300000 &&
42 bob->GetStats().send_bandwidth_bps != 300000)
43 bitrate_changed = true;
44 });
45 s.RunUntil(TimeDelta::seconds(2), TimeDelta::ms(5),
46 [&bitrate_changed, &packet_received] {
47 return packet_received && bitrate_changed;
48 });
49 EXPECT_TRUE(packet_received);
50 EXPECT_TRUE(bitrate_changed);
51}
52} // namespace test
53} // namespace webrtc