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

Unified Diff: extensions/common/features/simple_feature_unittest.cc

Issue 801603002: Add support for command line switches to Features, and as proof that it works, (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: test fixes Created 6 years 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « extensions/common/features/simple_feature.cc ('k') | extensions/common/manifest_constants.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
« no previous file with comments | « extensions/common/features/simple_feature.cc ('k') | extensions/common/manifest_constants.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698