| 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 439 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 450 FeatureList::InitializeInstance("", kFeatureOnByDefaultName); | 450 FeatureList::InitializeInstance("", kFeatureOnByDefaultName); |
| 451 EXPECT_FALSE(FeatureList::IsEnabled(kFeatureOnByDefault)); | 451 EXPECT_FALSE(FeatureList::IsEnabled(kFeatureOnByDefault)); |
| 452 EXPECT_FALSE(FeatureList::IsEnabled(kFeatureOffByDefault)); | 452 EXPECT_FALSE(FeatureList::IsEnabled(kFeatureOffByDefault)); |
| 453 | 453 |
| 454 // Do not initialize from commandline if we have already. | 454 // Do not initialize from commandline if we have already. |
| 455 FeatureList::InitializeInstance(kFeatureOffByDefaultName, ""); | 455 FeatureList::InitializeInstance(kFeatureOffByDefaultName, ""); |
| 456 EXPECT_FALSE(FeatureList::IsEnabled(kFeatureOnByDefault)); | 456 EXPECT_FALSE(FeatureList::IsEnabled(kFeatureOnByDefault)); |
| 457 EXPECT_FALSE(FeatureList::IsEnabled(kFeatureOffByDefault)); | 457 EXPECT_FALSE(FeatureList::IsEnabled(kFeatureOffByDefault)); |
| 458 } | 458 } |
| 459 | 459 |
| 460 TEST_F(FeatureListTest, UninitializedInstance_IsEnabledReturnsFalse) { |
| 461 ClearFeatureListInstance(); |
| 462 // This test case simulates the calling pattern found in code which does not |
| 463 // explicitly initialize the features list. |
| 464 // All IsEnabled() calls should return the default value in this scenario. |
| 465 EXPECT_EQ(nullptr, FeatureList::GetInstance()); |
| 466 EXPECT_TRUE(FeatureList::IsEnabled(kFeatureOnByDefault)); |
| 467 EXPECT_EQ(nullptr, FeatureList::GetInstance()); |
| 468 EXPECT_FALSE(FeatureList::IsEnabled(kFeatureOffByDefault)); |
| 469 } |
| 470 |
| 460 } // namespace base | 471 } // namespace base |
| OLD | NEW |