Cast: Stop logging kVideoFrameSentToEncoder and rename a couple events.
[chromium-blink-merge.git] / chrome / common / extensions / feature_switch_unittest.cc
blobd7a2906a3be2c9eef0c416ce5b577ca0f11c76eb
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "extensions/common/feature_switch.h"
7 #include "base/command_line.h"
8 #include "base/memory/scoped_ptr.h"
9 #include "testing/gtest/include/gtest/gtest.h"
11 using extensions::FeatureSwitch;
13 namespace {
15 const char kSwitchName[] = "test-switch";
17 template<FeatureSwitch::DefaultValue T>
18 class FeatureSwitchTest : public testing::Test {
19 public:
20 FeatureSwitchTest()
21 : command_line_(CommandLine::NO_PROGRAM),
22 feature_(&command_line_, kSwitchName, T) {
24 protected:
25 CommandLine command_line_;
26 FeatureSwitch feature_;
29 typedef FeatureSwitchTest<FeatureSwitch::DEFAULT_DISABLED>
30 FeatureSwitchDisabledTest;
31 typedef FeatureSwitchTest<FeatureSwitch::DEFAULT_ENABLED>
32 FeatureSwitchEnabledTest;
34 } // namespace
36 TEST_F(FeatureSwitchDisabledTest, NoSwitchValue) {
37 EXPECT_FALSE(feature_.IsEnabled());
40 TEST_F(FeatureSwitchDisabledTest, FalseSwitchValue) {
41 command_line_.AppendSwitchASCII(kSwitchName, "0");
42 EXPECT_FALSE(feature_.IsEnabled());
45 TEST_F(FeatureSwitchDisabledTest, GibberishSwitchValue) {
46 command_line_.AppendSwitchASCII(kSwitchName, "monkey");
47 EXPECT_FALSE(feature_.IsEnabled());
50 TEST_F(FeatureSwitchDisabledTest, Override) {
52 FeatureSwitch::ScopedOverride override(&feature_, false);
53 EXPECT_FALSE(feature_.IsEnabled());
55 EXPECT_FALSE(feature_.IsEnabled());
58 FeatureSwitch::ScopedOverride override(&feature_, true);
59 EXPECT_TRUE(feature_.IsEnabled());
61 EXPECT_FALSE(feature_.IsEnabled());
64 TEST_F(FeatureSwitchDisabledTest, TrueSwitchValue) {
65 command_line_.AppendSwitchASCII(kSwitchName, "1");
66 EXPECT_TRUE(feature_.IsEnabled());
69 FeatureSwitch::ScopedOverride override(&feature_, false);
70 EXPECT_FALSE(feature_.IsEnabled());
72 EXPECT_TRUE(feature_.IsEnabled());
75 FeatureSwitch::ScopedOverride override(&feature_, true);
76 EXPECT_TRUE(feature_.IsEnabled());
78 EXPECT_TRUE(feature_.IsEnabled());
81 TEST_F(FeatureSwitchDisabledTest, TrimSwitchValue) {
82 command_line_.AppendSwitchASCII(kSwitchName, " \t 1\n ");
83 EXPECT_TRUE(feature_.IsEnabled());
86 TEST_F(FeatureSwitchEnabledTest, NoSwitchValue) {
87 EXPECT_TRUE(feature_.IsEnabled());
90 TEST_F(FeatureSwitchEnabledTest, TrueSwitchValue) {
91 command_line_.AppendSwitchASCII(kSwitchName, "1");
92 EXPECT_TRUE(feature_.IsEnabled());
95 TEST_F(FeatureSwitchEnabledTest, GibberishSwitchValue) {
96 command_line_.AppendSwitchASCII(kSwitchName, "monkey");
97 EXPECT_TRUE(feature_.IsEnabled());
100 TEST_F(FeatureSwitchEnabledTest, Override) {
102 FeatureSwitch::ScopedOverride override(&feature_, true);
103 EXPECT_TRUE(feature_.IsEnabled());
105 EXPECT_TRUE(feature_.IsEnabled());
108 FeatureSwitch::ScopedOverride override(&feature_, false);
109 EXPECT_FALSE(feature_.IsEnabled());
111 EXPECT_TRUE(feature_.IsEnabled());
114 TEST_F(FeatureSwitchEnabledTest, FalseSwitchValue) {
115 command_line_.AppendSwitchASCII(kSwitchName, "0");
116 EXPECT_FALSE(feature_.IsEnabled());
119 FeatureSwitch::ScopedOverride override(&feature_, true);
120 EXPECT_TRUE(feature_.IsEnabled());
122 EXPECT_FALSE(feature_.IsEnabled());
125 FeatureSwitch::ScopedOverride override(&feature_, false);
126 EXPECT_FALSE(feature_.IsEnabled());
128 EXPECT_FALSE(feature_.IsEnabled());
131 TEST_F(FeatureSwitchEnabledTest, TrimSwitchValue) {
132 command_line_.AppendSwitchASCII(kSwitchName, "\t\t 0 \n");
133 EXPECT_FALSE(feature_.IsEnabled());