mirror of
https://github.com/mollyim/webrtc.git
synced 2025-05-12 21:30:45 +01:00
Use ScopedFieldTrials in FieldTrialsTest
Resetting the global state between runs was previously handled by a RAII type, but the semantics of that type changed to remove this behavior in [1]. [1] https://webrtc-review.googlesource.com/c/src/+/276269 Bug: webrtc:14731, webrtc:14705 Change-Id: I8425cb71f49ea000434d500e0b3978324e4c3195 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/285782 Commit-Queue: Emil Lundmark <lndmrk@webrtc.org> Reviewed-by: Harald Alvestrand <hta@webrtc.org> Cr-Commit-Position: refs/heads/main@{#38800}
This commit is contained in:
parent
8b4a81fb55
commit
2e3069bf07
2 changed files with 6 additions and 6 deletions
|
@ -1367,6 +1367,7 @@ if (rtc_include_tests) {
|
|||
"../rtc_base/containers:flat_set",
|
||||
"../rtc_base/task_utils:repeating_task",
|
||||
"../system_wrappers:field_trial",
|
||||
"../test:field_trial",
|
||||
"../test:fileutils",
|
||||
"../test:rtc_expect_death",
|
||||
"../test:test_support",
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
#include "api/transport/field_trial_based_config.h"
|
||||
#include "rtc_base/containers/flat_set.h"
|
||||
#include "system_wrappers/include/field_trial.h"
|
||||
#include "test/field_trial.h"
|
||||
#include "test/gmock.h"
|
||||
#include "test/gtest.h"
|
||||
|
||||
|
@ -29,7 +30,7 @@ namespace {
|
|||
|
||||
using ::testing::NotNull;
|
||||
using ::webrtc::field_trial::FieldTrialsAllowedInScopeForTesting;
|
||||
using ::webrtc::field_trial::InitFieldTrialsFromString;
|
||||
using ::webrtc::test::ScopedFieldTrials;
|
||||
|
||||
TEST(FieldTrialsTest, EmptyStringHasNoEffect) {
|
||||
FieldTrialsAllowedInScopeForTesting k({"MyCoolTrial"});
|
||||
|
@ -54,8 +55,7 @@ TEST(FieldTrialsTest, EnabledDisabledMustBeFirstInValue) {
|
|||
|
||||
TEST(FieldTrialsTest, FieldTrialsDoesNotReadGlobalString) {
|
||||
FieldTrialsAllowedInScopeForTesting k({"MyCoolTrial", "MyUncoolTrial"});
|
||||
static constexpr char s[] = "MyCoolTrial/Enabled/MyUncoolTrial/Disabled/";
|
||||
InitFieldTrialsFromString(s);
|
||||
ScopedFieldTrials g("MyCoolTrial/Enabled/MyUncoolTrial/Disabled/");
|
||||
FieldTrials f("");
|
||||
f.RegisterKeysForTesting({"MyCoolTrial", "MyUncoolTrial"});
|
||||
|
||||
|
@ -72,7 +72,7 @@ TEST(FieldTrialsTest, FieldTrialsWritesGlobalString) {
|
|||
|
||||
TEST(FieldTrialsTest, FieldTrialsRestoresGlobalStringAfterDestruction) {
|
||||
static constexpr char s[] = "SomeString/Enabled/";
|
||||
InitFieldTrialsFromString(s);
|
||||
ScopedFieldTrials g(s);
|
||||
{
|
||||
FieldTrials f("SomeOtherString/Enabled/");
|
||||
EXPECT_STREQ(webrtc::field_trial::GetFieldTrialString(),
|
||||
|
@ -140,8 +140,7 @@ TEST(FieldTrialsTest, GlobalAndNonGlobalFieldTrialsAreDisjoint) {
|
|||
|
||||
TEST(FieldTrialsTest, FieldTrialBasedConfigReadsGlobalString) {
|
||||
FieldTrialsAllowedInScopeForTesting k({"MyCoolTrial", "MyUncoolTrial"});
|
||||
static constexpr char s[] = "MyCoolTrial/Enabled/MyUncoolTrial/Disabled/";
|
||||
InitFieldTrialsFromString(s);
|
||||
ScopedFieldTrials g("MyCoolTrial/Enabled/MyUncoolTrial/Disabled/");
|
||||
FieldTrialBasedConfig f;
|
||||
f.RegisterKeysForTesting({"MyCoolTrial", "MyUncoolTrial"});
|
||||
|
||||
|
|
Loading…
Reference in a new issue