Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(222)

Side by Side Diff: base/feature_list_unittest.cc

Issue 2138923002: Updating FeatureList default initialization pattern (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@2785
Patch Set: Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « base/feature_list.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
OLDNEW
« no previous file with comments | « base/feature_list.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698