Index: extensions/common/features/simple_feature_unittest.cc |
diff --git a/extensions/common/features/simple_feature_unittest.cc b/extensions/common/features/simple_feature_unittest.cc |
index 40e1e2a6cfaa684b7b1608508dde9f6462fd7203..9f723fab0663d23e8a49bad83c792fcf0e0039f1 100644 |
--- a/extensions/common/features/simple_feature_unittest.cc |
+++ b/extensions/common/features/simple_feature_unittest.cc |
@@ -6,6 +6,7 @@ |
#include <string> |
+#include "base/command_line.h" |
#include "base/values.h" |
#include "extensions/common/manifest.h" |
#include "extensions/common/value_builder.h" |
@@ -37,6 +38,21 @@ bool LocationIsAvailable(SimpleFeature::Location feature_location, |
return availability_result == Feature::IS_AVAILABLE; |
} |
+class ScopedCommandLineSwitch { |
+ public: |
+ explicit ScopedCommandLineSwitch(const std::string& arg) |
+ : original_command_line_(*base::CommandLine::ForCurrentProcess()) { |
+ base::CommandLine::ForCurrentProcess()->AppendSwitch(arg); |
+ } |
+ |
+ ~ScopedCommandLineSwitch() { |
+ *base::CommandLine::ForCurrentProcess() = original_command_line_; |
+ } |
+ |
+ private: |
+ base::CommandLine original_command_line_; |
+}; |
+ |
} // namespace |
TEST(SimpleFeatureTest, IsAvailableNullCase) { |
@@ -649,4 +665,38 @@ TEST(SimpleFeatureTest, Inheritance) { |
EXPECT_EQ(3, feature.max_manifest_version()); |
} |
+TEST(SimpleFeatureTest, CommandLineSwitch) { |
+ SimpleFeature feature; |
+ feature.set_command_line_switch("laser-beams"); |
+ { |
+ EXPECT_EQ(Feature::MISSING_COMMAND_LINE_SWITCH, |
+ feature.IsAvailableToEnvironment().result()); |
+ } |
+ { |
+ ScopedCommandLineSwitch scoped_switch("laser-beams"); |
+ EXPECT_EQ(Feature::MISSING_COMMAND_LINE_SWITCH, |
+ feature.IsAvailableToEnvironment().result()); |
+ } |
+ { |
+ ScopedCommandLineSwitch scoped_switch("enable-laser-beams"); |
+ EXPECT_EQ(Feature::IS_AVAILABLE, |
+ feature.IsAvailableToEnvironment().result()); |
+ } |
+ { |
+ ScopedCommandLineSwitch scoped_switch("disable-laser-beams"); |
+ EXPECT_EQ(Feature::MISSING_COMMAND_LINE_SWITCH, |
+ feature.IsAvailableToEnvironment().result()); |
+ } |
+ { |
+ ScopedCommandLineSwitch scoped_switch("laser-beams=1"); |
+ EXPECT_EQ(Feature::IS_AVAILABLE, |
+ feature.IsAvailableToEnvironment().result()); |
+ } |
+ { |
+ ScopedCommandLineSwitch scoped_switch("laser-beams=0"); |
+ EXPECT_EQ(Feature::MISSING_COMMAND_LINE_SWITCH, |
+ feature.IsAvailableToEnvironment().result()); |
+ } |
+} |
+ |
} // namespace extensions |