field_trial.h 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839
  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. #ifndef TEST_FIELD_TRIAL_H_
  11. #define TEST_FIELD_TRIAL_H_
  12. #include <map>
  13. #include <string>
  14. namespace webrtc {
  15. namespace test {
  16. // TODO(jonasolsson): remove once all internal usages are gone.
  17. void ValidateFieldTrialsStringOrDie(const std::string&);
  18. // This class is used to override field-trial configs within specific tests.
  19. // After this class goes out of scope previous field trials will be restored.
  20. class ScopedFieldTrials {
  21. public:
  22. explicit ScopedFieldTrials(const std::string& config);
  23. ScopedFieldTrials(const ScopedFieldTrials&) = delete;
  24. ScopedFieldTrials& operator=(const ScopedFieldTrials&) = delete;
  25. ~ScopedFieldTrials();
  26. private:
  27. std::string current_field_trials_;
  28. const char* previous_field_trials_;
  29. };
  30. } // namespace test
  31. } // namespace webrtc
  32. #endif // TEST_FIELD_TRIAL_H_