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

Side by Side 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: 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2014 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.
4
5 #include "android_webview/browser/command_line_helper.h"
6
7 #include "base/command_line.h"
8 #include "base/feature_list.h"
9 #include "base/files/file_path.h"
10 #include "content/public/common/content_switches.h"
11 #include "testing/gtest/include/gtest/gtest.h"
12
13 using testing::Test;
14 using base::CommandLine;
15
16 const base::Feature kSomeSpecialFeature{"SomeSpecialFeature",
17 base::FEATURE_DISABLED_BY_DEFAULT};
18 const base::Feature kTestFeature{"TestFeature",
19 base::FEATURE_DISABLED_BY_DEFAULT};
20
21 class CommandLineHelperTest : public Test {
22 public:
23 CommandLineHelperTest() {}
24
25 void AddFeatureAndVerify(CommandLine& command_line,
26 const std::string& enabled_expected,
27 const std::string& disabled_expected) {
28 CommandLineHelper::AddEnabledFeature(command_line,
29 kSomeSpecialFeature.name);
30 EXPECT_EQ(enabled_expected,
31 command_line.GetSwitchValueASCII(switches::kEnableFeatures));
32 EXPECT_EQ(disabled_expected,
33 command_line.GetSwitchValueASCII(switches::kDisableFeatures));
34 }
35 };
36
37 TEST_F(CommandLineHelperTest, AddWithEmptyCommandLine) {
38 CommandLine command_line(CommandLine::NO_PROGRAM);
39 AddFeatureAndVerify(command_line, "SomeSpecialFeature", "");
40 }
41
42 TEST_F(CommandLineHelperTest, AddWithNoEnabledFeatures) {
43 const CommandLine::CharType* argv[] = {FILE_PATH_LITERAL("program")};
44 CommandLine command_line(arraysize(argv), argv);
45 AddFeatureAndVerify(command_line, "SomeSpecialFeature", "");
46 }
47
48 TEST_F(CommandLineHelperTest, AddWithEnabledTestFeature) {
49 const CommandLine::CharType* argv[] = {
50 FILE_PATH_LITERAL("program"),
51 FILE_PATH_LITERAL("--enable-features=TestFeature")};
52 CommandLine command_line(arraysize(argv), argv);
53 AddFeatureAndVerify(command_line, "TestFeature,SomeSpecialFeature", "");
54 }
55
56 TEST_F(CommandLineHelperTest, AddWithEnabledSomeSpecialFeature) {
57 const CommandLine::CharType* argv[] = {
58 FILE_PATH_LITERAL("program"),
59 FILE_PATH_LITERAL("--enable-features=SomeSpecialFeature,TestFeature")};
60 CommandLine command_line(arraysize(argv), argv);
61 AddFeatureAndVerify(command_line, "SomeSpecialFeature,TestFeature", "");
62 }
63
64 TEST_F(CommandLineHelperTest, AddWithDisabledSomeSpecialFeature) {
65 const CommandLine::CharType* argv[] = {
66 FILE_PATH_LITERAL("program"),
67 FILE_PATH_LITERAL("--disable-features=SomeSpecialFeature")};
68 CommandLine command_line(arraysize(argv), argv);
69 AddFeatureAndVerify(command_line, "", "SomeSpecialFeature");
70 }
71
72 TEST_F(CommandLineHelperTest, AddWithDisabledTestFeature) {
73 const CommandLine::CharType* argv[] = {
74 FILE_PATH_LITERAL("program"),
75 FILE_PATH_LITERAL("--disable-features=TestFeature")};
76 CommandLine command_line(arraysize(argv), argv);
77 AddFeatureAndVerify(command_line, "SomeSpecialFeature", "TestFeature");
78 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698