blob: 96842012c6c1344f7cfa46b5a50266b0d2df60bf [file] [log] [blame]
andresp@webrtc.org60015d22014-05-16 09:39:51 +00001/*
2 * Copyright (c) 2014 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
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020011#include "test/field_trial.h"
andresp@webrtc.org60015d22014-05-16 09:39:51 +000012
13#include <algorithm>
andresp@webrtc.org60015d22014-05-16 09:39:51 +000014#include <cstdio>
15#include <cstdlib>
16#include <map>
17#include <string>
18
Mirko Bonadeif3db00f2021-08-23 17:39:58 +020019#include "rtc_base/checks.h"
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020020#include "system_wrappers/include/field_trial.h"
andresp@webrtc.org60015d22014-05-16 09:39:51 +000021
22namespace webrtc {
andresp@webrtc.org60015d22014-05-16 09:39:51 +000023namespace test {
Jonas Olsson5b2eda42019-06-11 14:29:40 +020024void ValidateFieldTrialsStringOrDie(const std::string&) {}
pbos19492f12015-07-07 08:22:27 -070025
26ScopedFieldTrials::ScopedFieldTrials(const std::string& config)
Yves Gerey665174f2018-06-19 15:03:05 +020027 : previous_field_trials_(webrtc::field_trial::GetFieldTrialString()) {
Mirko Bonadeif3db00f2021-08-23 17:39:58 +020028 RTC_CHECK(webrtc::field_trial::FieldTrialsStringIsValid(config.c_str()))
29 << "Invalid field trials string: " << config;
phoglund37ebcf02016-01-08 05:04:57 -080030 current_field_trials_ = config;
Bjorn Tereliusedab3012018-01-31 17:23:40 +010031 webrtc::field_trial::InitFieldTrialsFromString(current_field_trials_.c_str());
pbos19492f12015-07-07 08:22:27 -070032}
33
34ScopedFieldTrials::~ScopedFieldTrials() {
Mirko Bonadeif3db00f2021-08-23 17:39:58 +020035 RTC_CHECK(
36 webrtc::field_trial::FieldTrialsStringIsValid(previous_field_trials_))
37 << "Invalid field trials string: " << previous_field_trials_;
phoglund37ebcf02016-01-08 05:04:57 -080038 webrtc::field_trial::InitFieldTrialsFromString(previous_field_trials_);
pbos19492f12015-07-07 08:22:27 -070039}
40
andresp@webrtc.org60015d22014-05-16 09:39:51 +000041} // namespace test
42} // namespace webrtc