| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "base/feature_list.h" | 5 #include "base/feature_list.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 #include <utility> | 10 #include <utility> |
| (...skipping 375 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 386 RegisterFeatureListInstance(std::move(feature_list)); | 386 RegisterFeatureListInstance(std::move(feature_list)); |
| 387 | 387 |
| 388 std::string enable_features; | 388 std::string enable_features; |
| 389 std::string disable_features; | 389 std::string disable_features; |
| 390 FeatureList::GetInstance()->GetFeatureOverrides(&enable_features, | 390 FeatureList::GetInstance()->GetFeatureOverrides(&enable_features, |
| 391 &disable_features); | 391 &disable_features); |
| 392 EXPECT_EQ("*OffByDefault<Trial,A,X", SortFeatureListString(enable_features)); | 392 EXPECT_EQ("*OffByDefault<Trial,A,X", SortFeatureListString(enable_features)); |
| 393 EXPECT_EQ("D", SortFeatureListString(disable_features)); | 393 EXPECT_EQ("D", SortFeatureListString(disable_features)); |
| 394 } | 394 } |
| 395 | 395 |
| 396 TEST_F(FeatureListTest, GetFieldTrial) { |
| 397 ClearFeatureListInstance(); |
| 398 FieldTrialList field_trial_list(nullptr); |
| 399 FieldTrial* trial = FieldTrialList::CreateFieldTrial("Trial", "Group"); |
| 400 std::unique_ptr<FeatureList> feature_list(new FeatureList); |
| 401 feature_list->RegisterFieldTrialOverride( |
| 402 kFeatureOnByDefaultName, FeatureList::OVERRIDE_USE_DEFAULT, trial); |
| 403 RegisterFeatureListInstance(std::move(feature_list)); |
| 404 |
| 405 EXPECT_EQ(trial, FeatureList::GetFieldTrial(kFeatureOnByDefault)); |
| 406 EXPECT_EQ(nullptr, FeatureList::GetFieldTrial(kFeatureOffByDefault)); |
| 407 } |
| 408 |
| 396 TEST_F(FeatureListTest, InitializeFromCommandLine_WithFieldTrials) { | 409 TEST_F(FeatureListTest, InitializeFromCommandLine_WithFieldTrials) { |
| 397 ClearFeatureListInstance(); | 410 ClearFeatureListInstance(); |
| 398 FieldTrialList field_trial_list(nullptr); | 411 FieldTrialList field_trial_list(nullptr); |
| 399 FieldTrialList::CreateFieldTrial("Trial", "Group"); | 412 FieldTrialList::CreateFieldTrial("Trial", "Group"); |
| 400 std::unique_ptr<FeatureList> feature_list(new FeatureList); | 413 std::unique_ptr<FeatureList> feature_list(new FeatureList); |
| 401 feature_list->InitializeFromCommandLine("A,OffByDefault<Trial,X", "D"); | 414 feature_list->InitializeFromCommandLine("A,OffByDefault<Trial,X", "D"); |
| 402 RegisterFeatureListInstance(std::move(feature_list)); | 415 RegisterFeatureListInstance(std::move(feature_list)); |
| 403 | 416 |
| 404 EXPECT_FALSE(FieldTrialList::IsTrialActive("Trial")); | 417 EXPECT_FALSE(FieldTrialList::IsTrialActive("Trial")); |
| 405 EXPECT_TRUE(FeatureList::IsEnabled(kFeatureOffByDefault)); | 418 EXPECT_TRUE(FeatureList::IsEnabled(kFeatureOffByDefault)); |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 438 EXPECT_FALSE(FeatureList::IsEnabled(kFeatureOnByDefault)); | 451 EXPECT_FALSE(FeatureList::IsEnabled(kFeatureOnByDefault)); |
| 439 EXPECT_FALSE(FeatureList::IsEnabled(kFeatureOffByDefault)); | 452 EXPECT_FALSE(FeatureList::IsEnabled(kFeatureOffByDefault)); |
| 440 | 453 |
| 441 // Do not initialize from commandline if we have already. | 454 // Do not initialize from commandline if we have already. |
| 442 FeatureList::InitializeInstance(kFeatureOffByDefaultName, ""); | 455 FeatureList::InitializeInstance(kFeatureOffByDefaultName, ""); |
| 443 EXPECT_FALSE(FeatureList::IsEnabled(kFeatureOnByDefault)); | 456 EXPECT_FALSE(FeatureList::IsEnabled(kFeatureOnByDefault)); |
| 444 EXPECT_FALSE(FeatureList::IsEnabled(kFeatureOffByDefault)); | 457 EXPECT_FALSE(FeatureList::IsEnabled(kFeatureOffByDefault)); |
| 445 } | 458 } |
| 446 | 459 |
| 447 } // namespace base | 460 } // namespace base |
| OLD | NEW |