blob: 97285d391459f2cfc8c3afc665b381c8151f7cc1 [file] [log] [blame]
/*
* Copyright 2018 The WebRTC project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
* tree. An additional intellectual property rights grant can be found
* in the file PATENTS. All contributing project authors may
* be found in the AUTHORS file in the root of the source tree.
*/
#include "test/scenario/scenario.h"
#include "test/gtest.h"
namespace webrtc {
namespace test {
TEST(ScenarioTest, StartsAndStopsWithoutErrors) {
Scenario s;
CallClientConfig call_client_config;
call_client_config.transport.rates.start_rate = DataRate::kbps(300);
auto* alice = s.CreateClient("alice", call_client_config);
auto* bob = s.CreateClient("bob", call_client_config);
NetworkNodeConfig network_config;
auto alice_net = s.CreateSimulationNode(network_config);
auto bob_net = s.CreateSimulationNode(network_config);
auto route = s.CreateRoutes(alice, {alice_net}, bob, {bob_net});
VideoStreamConfig video_stream_config;
s.CreateVideoStream(route->forward(), video_stream_config);
s.CreateVideoStream(route->reverse(), video_stream_config);
AudioStreamConfig audio_stream_config;
audio_stream_config.encoder.min_rate = DataRate::kbps(6);
audio_stream_config.encoder.max_rate = DataRate::kbps(64);
audio_stream_config.encoder.allocate_bitrate = true;
audio_stream_config.stream.in_bandwidth_estimation = false;
s.CreateAudioStream(route->forward(), audio_stream_config);
s.CreateAudioStream(route->reverse(), audio_stream_config);
CrossTrafficConfig cross_traffic_config;
s.CreateCrossTraffic({alice_net}, cross_traffic_config);
bool packet_received = false;
s.NetworkDelayedAction({alice_net, bob_net}, 100,
[&packet_received] { packet_received = true; });
bool bitrate_changed = false;
s.Every(TimeDelta::ms(10), [alice, bob, &bitrate_changed] {
if (alice->GetStats().send_bandwidth_bps != 300000 &&
bob->GetStats().send_bandwidth_bps != 300000)
bitrate_changed = true;
});
s.RunUntil(TimeDelta::seconds(2), TimeDelta::ms(5),
[&bitrate_changed, &packet_received] {
return packet_received && bitrate_changed;
});
EXPECT_TRUE(packet_received);
EXPECT_TRUE(bitrate_changed);
}
} // namespace test
} // namespace webrtc