blob: f6819486eb0f06344f671d62edc79ef9e514d2f2 [file] [log] [blame]
Jonas Olsson5b2eda42019-06-11 12:29:401/*
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#include "system_wrappers/include/field_trial.h"
11
12#include "rtc_base/checks.h"
13#include "test/gtest.h"
14
15namespace webrtc {
16namespace field_trial {
17#if GTEST_HAS_DEATH_TEST && RTC_DCHECK_IS_ON && !defined(WEBRTC_ANDROID) && \
18 !defined(WEBRTC_EXCLUDE_FIELD_TRIAL_DEFAULT)
19TEST(FieldTrialValidationTest, AcceptsValidInputs) {
20 InitFieldTrialsFromString("");
21 InitFieldTrialsFromString("Audio/Enabled/");
22 InitFieldTrialsFromString("Audio/Enabled/Video/Disabled/");
23
24 // Duplicate trials with the same value is fine
25 InitFieldTrialsFromString("Audio/Enabled/Audio/Enabled/");
26 InitFieldTrialsFromString("Audio/Enabled/B/C/Audio/Enabled/");
27}
28
29TEST(FieldTrialValidationTest, RejectsBadInputs) {
30 // Bad delimiters
31 EXPECT_DEATH(InitFieldTrialsFromString("Audio/EnabledVideo/Disabled/"),
32 "Invalid field trials string:");
33 EXPECT_DEATH(InitFieldTrialsFromString("Audio/Enabled//Video/Disabled/"),
34 "Invalid field trials string:");
35 EXPECT_DEATH(InitFieldTrialsFromString("/Audio/Enabled/Video/Disabled/"),
36 "Invalid field trials string:");
37 EXPECT_DEATH(InitFieldTrialsFromString("Audio/Enabled/Video/Disabled"),
38 "Invalid field trials string:");
39 EXPECT_DEATH(
40 InitFieldTrialsFromString("Audio/Enabled/Video/Disabled/garbage"),
41 "Invalid field trials string:");
42
43 // Duplicate trials with different values is not fine
44 EXPECT_DEATH(InitFieldTrialsFromString("Audio/Enabled/Audio/Disabled/"),
45 "Invalid field trials string:");
46 EXPECT_DEATH(InitFieldTrialsFromString("Audio/Enabled/B/C/Audio/Disabled/"),
47 "Invalid field trials string:");
48}
49#endif // GTEST_HAS_DEATH_TEST && RTC_DCHECK_IS_ON && !defined(WEBRTC_ANDROID)
50 // && !defined(WEBRTC_EXCLUDE_FIELD_TRIAL_DEFAULT)
51
52} // namespace field_trial
53} // namespace webrtc