1 /*
2  *  Copyright 2019 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 "rtc_base/experiments/stable_target_rate_experiment.h"
12 
13 #include "test/field_trial.h"
14 #include "test/gtest.h"
15 
16 namespace webrtc {
17 
TEST(StableBweExperimentTest,Default)18 TEST(StableBweExperimentTest, Default) {
19   StableTargetRateExperiment config =
20       StableTargetRateExperiment::ParseFromFieldTrials();
21   EXPECT_FALSE(config.IsEnabled());
22   EXPECT_EQ(config.GetVideoHysteresisFactor(), 1.0);
23   EXPECT_EQ(config.GetScreenshareHysteresisFactor(), 1.35);
24 }
25 
TEST(StableBweExperimentTest,EnabledNoHysteresis)26 TEST(StableBweExperimentTest, EnabledNoHysteresis) {
27   webrtc::test::ScopedFieldTrials field_trials(
28       "WebRTC-StableTargetRate/enabled:true/");
29 
30   StableTargetRateExperiment config =
31       StableTargetRateExperiment::ParseFromFieldTrials();
32   EXPECT_TRUE(config.IsEnabled());
33   EXPECT_EQ(config.GetVideoHysteresisFactor(), 1.0);
34   EXPECT_EQ(config.GetScreenshareHysteresisFactor(), 1.35);
35 }
36 
TEST(StableBweExperimentTest,EnabledWithHysteresis)37 TEST(StableBweExperimentTest, EnabledWithHysteresis) {
38   webrtc::test::ScopedFieldTrials field_trials(
39       "WebRTC-StableTargetRate/"
40       "enabled:true,"
41       "video_hysteresis_factor:1.1,"
42       "screenshare_hysteresis_factor:1.2/");
43 
44   StableTargetRateExperiment config =
45       StableTargetRateExperiment::ParseFromFieldTrials();
46   EXPECT_TRUE(config.IsEnabled());
47   EXPECT_EQ(config.GetVideoHysteresisFactor(), 1.1);
48   EXPECT_EQ(config.GetScreenshareHysteresisFactor(), 1.2);
49 }
50 
TEST(StableBweExperimentTest,OnNoHysteresisPropagatesVideoRateHystersis)51 TEST(StableBweExperimentTest, OnNoHysteresisPropagatesVideoRateHystersis) {
52   webrtc::test::ScopedFieldTrials field_trials(
53       "WebRTC-StableTargetRate/enabled:true/"
54       "WebRTC-VideoRateControl/video_hysteresis:1.3,"
55       "screenshare_hysteresis:1.4/");
56 
57   StableTargetRateExperiment config =
58       StableTargetRateExperiment::ParseFromFieldTrials();
59   EXPECT_TRUE(config.IsEnabled());
60   EXPECT_EQ(config.GetVideoHysteresisFactor(), 1.3);
61   EXPECT_EQ(config.GetScreenshareHysteresisFactor(), 1.4);
62 }
63 
TEST(StableBweExperimentTest,HysteresisOverrideVideoRateHystersis)64 TEST(StableBweExperimentTest, HysteresisOverrideVideoRateHystersis) {
65   webrtc::test::ScopedFieldTrials field_trials(
66       "WebRTC-StableTargetRate/"
67       "enabled:true,"
68       "video_hysteresis_factor:1.1,"
69       "screenshare_hysteresis_factor:1.2/"
70       "WebRTC-VideoRateControl/video_hysteresis:1.3,"
71       "screenshare_hysteresis:1.4/");
72 
73   StableTargetRateExperiment config =
74       StableTargetRateExperiment::ParseFromFieldTrials();
75   EXPECT_TRUE(config.IsEnabled());
76   EXPECT_EQ(config.GetVideoHysteresisFactor(), 1.1);
77   EXPECT_EQ(config.GetScreenshareHysteresisFactor(), 1.2);
78 }
79 
80 }  // namespace webrtc
81