xref: /aosp_15_r20/external/webrtc/test/field_trial.h (revision d9f758449e529ab9291ac668be2861e7a55c2422)
1 /*
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 
11 #ifndef TEST_FIELD_TRIAL_H_
12 #define TEST_FIELD_TRIAL_H_
13 
14 #include <string>
15 
16 #include "absl/strings/string_view.h"
17 
18 namespace webrtc {
19 namespace test {
20 
21 // This class is used to override field-trial configs within specific tests.
22 // After this class goes out of scope previous field trials will be restored.
23 class ScopedFieldTrials {
24  public:
25   explicit ScopedFieldTrials(absl::string_view config);
26   ScopedFieldTrials(const ScopedFieldTrials&) = delete;
27   ScopedFieldTrials& operator=(const ScopedFieldTrials&) = delete;
28   ~ScopedFieldTrials();
29 
30  private:
31   std::string current_field_trials_;
32   const char* previous_field_trials_;
33 };
34 
35 }  // namespace test
36 }  // namespace webrtc
37 
38 #endif  // TEST_FIELD_TRIAL_H_
39