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

Unified Diff: android_webview/browser/command_line_helper_unittest.cc

Issue 2396803002: [Android WebView] Add functionality to enable features and enable the spellcheck feature. (Closed)
Patch Set: fix compile Created 4 years, 2 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « android_webview/browser/command_line_helper.cc ('k') | android_webview/lib/main/aw_main_delegate.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: android_webview/browser/command_line_helper_unittest.cc
diff --git a/android_webview/browser/command_line_helper_unittest.cc b/android_webview/browser/command_line_helper_unittest.cc
new file mode 100644
index 0000000000000000000000000000000000000000..4df2e3983ca25e7ed226df9734a01b40c6644561
--- /dev/null
+++ b/android_webview/browser/command_line_helper_unittest.cc
@@ -0,0 +1,76 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "android_webview/browser/command_line_helper.h"
+
+#include "base/command_line.h"
+#include "base/feature_list.h"
+#include "base/files/file_path.h"
+#include "content/public/common/content_switches.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+using testing::Test;
+using base::CommandLine;
+
+const base::Feature kSomeSpecialFeature{"SomeSpecialFeature",
+ base::FEATURE_DISABLED_BY_DEFAULT};
+
+class CommandLineHelperTest : public Test {
+ public:
+ CommandLineHelperTest() {}
+
+ void AddFeatureAndVerify(CommandLine& command_line,
+ const std::string& enabled_expected,
+ const std::string& disabled_expected) {
+ CommandLineHelper::AddEnabledFeature(command_line,
+ kSomeSpecialFeature.name);
+ EXPECT_EQ(enabled_expected,
+ command_line.GetSwitchValueASCII(switches::kEnableFeatures));
+ EXPECT_EQ(disabled_expected,
+ command_line.GetSwitchValueASCII(switches::kDisableFeatures));
+ }
+};
+
+TEST_F(CommandLineHelperTest, AddWithEmptyCommandLine) {
+ CommandLine command_line(CommandLine::NO_PROGRAM);
+ AddFeatureAndVerify(command_line, "SomeSpecialFeature", "");
+}
+
+TEST_F(CommandLineHelperTest, AddWithNoEnabledFeatures) {
+ const CommandLine::CharType* argv[] = {FILE_PATH_LITERAL("program")};
+ CommandLine command_line(arraysize(argv), argv);
+ AddFeatureAndVerify(command_line, "SomeSpecialFeature", "");
+}
+
+TEST_F(CommandLineHelperTest, AddWithEnabledTestFeature) {
+ const CommandLine::CharType* argv[] = {
+ FILE_PATH_LITERAL("program"),
+ FILE_PATH_LITERAL("--enable-features=TestFeature")};
+ CommandLine command_line(arraysize(argv), argv);
+ AddFeatureAndVerify(command_line, "TestFeature,SomeSpecialFeature", "");
+}
+
+TEST_F(CommandLineHelperTest, AddWithEnabledSomeSpecialFeature) {
+ const CommandLine::CharType* argv[] = {
+ FILE_PATH_LITERAL("program"),
+ FILE_PATH_LITERAL("--enable-features=SomeSpecialFeature,TestFeature")};
+ CommandLine command_line(arraysize(argv), argv);
+ AddFeatureAndVerify(command_line, "SomeSpecialFeature,TestFeature", "");
+}
+
+TEST_F(CommandLineHelperTest, AddWithDisabledSomeSpecialFeature) {
+ const CommandLine::CharType* argv[] = {
+ FILE_PATH_LITERAL("program"),
+ FILE_PATH_LITERAL("--disable-features=SomeSpecialFeature")};
+ CommandLine command_line(arraysize(argv), argv);
+ AddFeatureAndVerify(command_line, "", "SomeSpecialFeature");
+}
+
+TEST_F(CommandLineHelperTest, AddWithDisabledTestFeature) {
+ const CommandLine::CharType* argv[] = {
+ FILE_PATH_LITERAL("program"),
+ FILE_PATH_LITERAL("--disable-features=TestFeature")};
+ CommandLine command_line(arraysize(argv), argv);
+ AddFeatureAndVerify(command_line, "SomeSpecialFeature", "TestFeature");
+}
« no previous file with comments | « android_webview/browser/command_line_helper.cc ('k') | android_webview/lib/main/aw_main_delegate.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698