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 "rtc_base/experiments/normalize_simulcast_size_experiment.h"
12 
13 #include "test/field_trial.h"
14 #include "test/gtest.h"
15 
16 namespace webrtc {
17 
TEST(NormalizeSimulcastSizeExperimentTest,GetExponent)18 TEST(NormalizeSimulcastSizeExperimentTest, GetExponent) {
19   webrtc::test::ScopedFieldTrials field_trials(
20       "WebRTC-NormalizeSimulcastResolution/Enabled-2/");
21   EXPECT_EQ(2, NormalizeSimulcastSizeExperiment::GetBase2Exponent());
22 }
23 
TEST(NormalizeSimulcastSizeExperimentTest,GetExponentWithTwoParameters)24 TEST(NormalizeSimulcastSizeExperimentTest, GetExponentWithTwoParameters) {
25   webrtc::test::ScopedFieldTrials field_trials(
26       "WebRTC-NormalizeSimulcastResolution/Enabled-3-4/");
27   EXPECT_EQ(3, NormalizeSimulcastSizeExperiment::GetBase2Exponent());
28 }
29 
TEST(NormalizeSimulcastSizeExperimentTest,GetExponentFailsIfNotEnabled)30 TEST(NormalizeSimulcastSizeExperimentTest, GetExponentFailsIfNotEnabled) {
31   webrtc::test::ScopedFieldTrials field_trials(
32       "WebRTC-NormalizeSimulcastResolution/Disabled/");
33   EXPECT_FALSE(NormalizeSimulcastSizeExperiment::GetBase2Exponent());
34 }
35 
TEST(NormalizeSimulcastSizeExperimentTest,GetExponentFailsForInvalidFieldTrial)36 TEST(NormalizeSimulcastSizeExperimentTest,
37      GetExponentFailsForInvalidFieldTrial) {
38   webrtc::test::ScopedFieldTrials field_trials(
39       "WebRTC-NormalizeSimulcastResolution/Enabled-invalid/");
40   EXPECT_FALSE(NormalizeSimulcastSizeExperiment::GetBase2Exponent());
41 }
42 
TEST(NormalizeSimulcastSizeExperimentTest,GetExponentFailsForNegativeOutOfBoundValue)43 TEST(NormalizeSimulcastSizeExperimentTest,
44      GetExponentFailsForNegativeOutOfBoundValue) {
45   // Supported range: [0, 5].
46   webrtc::test::ScopedFieldTrials field_trials(
47       "WebRTC-NormalizeSimulcastResolution/Enabled--1/");
48   EXPECT_FALSE(NormalizeSimulcastSizeExperiment::GetBase2Exponent());
49 }
50 
TEST(NormalizeSimulcastSizeExperimentTest,GetExponentFailsForPositiveOutOfBoundValue)51 TEST(NormalizeSimulcastSizeExperimentTest,
52      GetExponentFailsForPositiveOutOfBoundValue) {
53   // Supported range: [0, 5].
54   webrtc::test::ScopedFieldTrials field_trials(
55       "WebRTC-NormalizeSimulcastResolution/Enabled-6/");
56   EXPECT_FALSE(NormalizeSimulcastSizeExperiment::GetBase2Exponent());
57 }
58 
59 }  // namespace webrtc
60