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 354 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
365 RegisterFeatureListInstance(std::move(feature_list)); | 365 RegisterFeatureListInstance(std::move(feature_list)); |
366 | 366 |
367 std::string enable_features; | 367 std::string enable_features; |
368 std::string disable_features; | 368 std::string disable_features; |
369 FeatureList::GetInstance()->GetFeatureOverrides(&enable_features, | 369 FeatureList::GetInstance()->GetFeatureOverrides(&enable_features, |
370 &disable_features); | 370 &disable_features); |
371 EXPECT_EQ("A,OffByDefault<Trial,X", SortFeatureListString(enable_features)); | 371 EXPECT_EQ("A,OffByDefault<Trial,X", SortFeatureListString(enable_features)); |
372 EXPECT_EQ("D", SortFeatureListString(disable_features)); | 372 EXPECT_EQ("D", SortFeatureListString(disable_features)); |
373 } | 373 } |
374 | 374 |
| 375 TEST_F(FeatureListTest, GetFeatureOverrides_UseDefault) { |
| 376 ClearFeatureListInstance(); |
| 377 FieldTrialList field_trial_list(nullptr); |
| 378 scoped_ptr<FeatureList> feature_list(new FeatureList); |
| 379 feature_list->InitializeFromCommandLine("A,X", "D"); |
| 380 |
| 381 FieldTrial* trial = FieldTrialList::CreateFieldTrial("Trial", "Group"); |
| 382 feature_list->RegisterFieldTrialOverride( |
| 383 kFeatureOffByDefaultName, FeatureList::OVERRIDE_USE_DEFAULT, trial); |
| 384 |
| 385 RegisterFeatureListInstance(std::move(feature_list)); |
| 386 |
| 387 std::string enable_features; |
| 388 std::string disable_features; |
| 389 FeatureList::GetInstance()->GetFeatureOverrides(&enable_features, |
| 390 &disable_features); |
| 391 EXPECT_EQ("*OffByDefault<Trial,A,X", SortFeatureListString(enable_features)); |
| 392 EXPECT_EQ("D", SortFeatureListString(disable_features)); |
| 393 } |
| 394 |
375 TEST_F(FeatureListTest, InitializeFromCommandLine_WithFieldTrials) { | 395 TEST_F(FeatureListTest, InitializeFromCommandLine_WithFieldTrials) { |
376 ClearFeatureListInstance(); | 396 ClearFeatureListInstance(); |
377 FieldTrialList field_trial_list(nullptr); | 397 FieldTrialList field_trial_list(nullptr); |
378 FieldTrialList::CreateFieldTrial("Trial", "Group"); | 398 FieldTrialList::CreateFieldTrial("Trial", "Group"); |
379 scoped_ptr<FeatureList> feature_list(new FeatureList); | 399 scoped_ptr<FeatureList> feature_list(new FeatureList); |
380 feature_list->InitializeFromCommandLine("A,OffByDefault<Trial,X", "D"); | 400 feature_list->InitializeFromCommandLine("A,OffByDefault<Trial,X", "D"); |
381 RegisterFeatureListInstance(std::move(feature_list)); | 401 RegisterFeatureListInstance(std::move(feature_list)); |
382 | 402 |
383 EXPECT_FALSE(FieldTrialList::IsTrialActive("Trial")); | 403 EXPECT_FALSE(FieldTrialList::IsTrialActive("Trial")); |
384 EXPECT_TRUE(FeatureList::IsEnabled(kFeatureOffByDefault)); | 404 EXPECT_TRUE(FeatureList::IsEnabled(kFeatureOffByDefault)); |
385 EXPECT_TRUE(FieldTrialList::IsTrialActive("Trial")); | 405 EXPECT_TRUE(FieldTrialList::IsTrialActive("Trial")); |
386 } | 406 } |
387 | 407 |
| 408 TEST_F(FeatureListTest, InitializeFromCommandLine_UseDefault) { |
| 409 ClearFeatureListInstance(); |
| 410 FieldTrialList field_trial_list(nullptr); |
| 411 FieldTrialList::CreateFieldTrial("T1", "Group"); |
| 412 FieldTrialList::CreateFieldTrial("T2", "Group"); |
| 413 scoped_ptr<FeatureList> feature_list(new FeatureList); |
| 414 feature_list->InitializeFromCommandLine( |
| 415 "A,*OffByDefault<T1,*OnByDefault<T2,X", "D"); |
| 416 RegisterFeatureListInstance(std::move(feature_list)); |
| 417 |
| 418 EXPECT_FALSE(FieldTrialList::IsTrialActive("T1")); |
| 419 EXPECT_FALSE(FeatureList::IsEnabled(kFeatureOffByDefault)); |
| 420 EXPECT_TRUE(FieldTrialList::IsTrialActive("T1")); |
| 421 |
| 422 EXPECT_FALSE(FieldTrialList::IsTrialActive("T2")); |
| 423 EXPECT_TRUE(FeatureList::IsEnabled(kFeatureOnByDefault)); |
| 424 EXPECT_TRUE(FieldTrialList::IsTrialActive("T2")); |
| 425 } |
| 426 |
388 } // namespace base | 427 } // namespace base |
OLD | NEW |