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

Side by Side Diff: android_webview/browser/command_line_helper_unittest.cc

Issue 2520053002: [Merge M-55] Disable Web Payments in WebView (Closed)
Patch Set: Created 4 years, 1 month 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
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "android_webview/browser/command_line_helper.h" 5 #include "android_webview/browser/command_line_helper.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/feature_list.h" 8 #include "base/feature_list.h"
9 #include "base/files/file_path.h" 9 #include "base/files/file_path.h"
10 #include "content/public/common/content_switches.h" 10 #include "content/public/common/content_switches.h"
11 #include "testing/gtest/include/gtest/gtest.h" 11 #include "testing/gtest/include/gtest/gtest.h"
12 12
13 using testing::Test; 13 using testing::Test;
14 using base::CommandLine; 14 using base::CommandLine;
15 15
16 const base::Feature kSomeSpecialFeature{"SomeSpecialFeature", 16 const base::Feature kSomeSpecialFeature{"SomeSpecialFeature",
17 base::FEATURE_DISABLED_BY_DEFAULT}; 17 base::FEATURE_DISABLED_BY_DEFAULT};
18 18
19 class CommandLineHelperTest : public Test { 19 class CommandLineHelperTest : public Test {
20 public: 20 public:
21 CommandLineHelperTest() {} 21 CommandLineHelperTest() {}
22 22
23 void AddFeatureAndVerify(CommandLine& command_line, 23 void EnableFeatureAndVerify(CommandLine& command_line,
24 const std::string& enabled_expected, 24 const std::string& enabled_expected,
25 const std::string& disabled_expected) { 25 const std::string& disabled_expected) {
26 CommandLineHelper::AddEnabledFeature(command_line, 26 CommandLineHelper::AddEnabledFeature(command_line,
27 kSomeSpecialFeature.name); 27 kSomeSpecialFeature.name);
28 Verify(command_line, enabled_expected, disabled_expected);
29 }
30
31 void DisableFeatureAndVerify(CommandLine& command_line,
32 const std::string& enabled_expected,
33 const std::string& disabled_expected) {
34 CommandLineHelper::AddDisabledFeature(command_line,
35 kSomeSpecialFeature.name);
36 Verify(command_line, enabled_expected, disabled_expected);
37 }
38
39 void Verify(const CommandLine& command_line,
40 const std::string& enabled_expected,
41 const std::string& disabled_expected) {
28 EXPECT_EQ(enabled_expected, 42 EXPECT_EQ(enabled_expected,
29 command_line.GetSwitchValueASCII(switches::kEnableFeatures)); 43 command_line.GetSwitchValueASCII(switches::kEnableFeatures));
30 EXPECT_EQ(disabled_expected, 44 EXPECT_EQ(disabled_expected,
31 command_line.GetSwitchValueASCII(switches::kDisableFeatures)); 45 command_line.GetSwitchValueASCII(switches::kDisableFeatures));
32 } 46 }
33 }; 47 };
34 48
35 TEST_F(CommandLineHelperTest, AddWithEmptyCommandLine) { 49 TEST_F(CommandLineHelperTest, EnableForEmptyCommandLine) {
36 CommandLine command_line(CommandLine::NO_PROGRAM); 50 CommandLine command_line(CommandLine::NO_PROGRAM);
37 AddFeatureAndVerify(command_line, "SomeSpecialFeature", ""); 51 EnableFeatureAndVerify(command_line, "SomeSpecialFeature", "");
38 } 52 }
39 53
40 TEST_F(CommandLineHelperTest, AddWithNoEnabledFeatures) { 54 TEST_F(CommandLineHelperTest, EnableForNoEnabledFeatures) {
41 const CommandLine::CharType* argv[] = {FILE_PATH_LITERAL("program")}; 55 const CommandLine::CharType* argv[] = {FILE_PATH_LITERAL("program")};
42 CommandLine command_line(arraysize(argv), argv); 56 CommandLine command_line(arraysize(argv), argv);
43 AddFeatureAndVerify(command_line, "SomeSpecialFeature", ""); 57 EnableFeatureAndVerify(command_line, "SomeSpecialFeature", "");
44 } 58 }
45 59
46 TEST_F(CommandLineHelperTest, AddWithEnabledTestFeature) { 60 TEST_F(CommandLineHelperTest, EnableForEnabledTestFeature) {
47 const CommandLine::CharType* argv[] = { 61 const CommandLine::CharType* argv[] = {
48 FILE_PATH_LITERAL("program"), 62 FILE_PATH_LITERAL("program"),
49 FILE_PATH_LITERAL("--enable-features=TestFeature")}; 63 FILE_PATH_LITERAL("--enable-features=TestFeature")};
50 CommandLine command_line(arraysize(argv), argv); 64 CommandLine command_line(arraysize(argv), argv);
51 AddFeatureAndVerify(command_line, "TestFeature,SomeSpecialFeature", ""); 65 EnableFeatureAndVerify(command_line, "TestFeature,SomeSpecialFeature", "");
52 } 66 }
53 67
54 TEST_F(CommandLineHelperTest, AddWithEnabledSomeSpecialFeature) { 68 TEST_F(CommandLineHelperTest, EnableForEnabledSomeSpecialFeature) {
55 const CommandLine::CharType* argv[] = { 69 const CommandLine::CharType* argv[] = {
56 FILE_PATH_LITERAL("program"), 70 FILE_PATH_LITERAL("program"),
57 FILE_PATH_LITERAL("--enable-features=SomeSpecialFeature,TestFeature")}; 71 FILE_PATH_LITERAL("--enable-features=SomeSpecialFeature,TestFeature")};
58 CommandLine command_line(arraysize(argv), argv); 72 CommandLine command_line(arraysize(argv), argv);
59 AddFeatureAndVerify(command_line, "SomeSpecialFeature,TestFeature", ""); 73 EnableFeatureAndVerify(command_line, "SomeSpecialFeature,TestFeature", "");
60 } 74 }
61 75
62 TEST_F(CommandLineHelperTest, AddWithDisabledSomeSpecialFeature) { 76 TEST_F(CommandLineHelperTest, EnableForDisabledSomeSpecialFeature) {
63 const CommandLine::CharType* argv[] = { 77 const CommandLine::CharType* argv[] = {
64 FILE_PATH_LITERAL("program"), 78 FILE_PATH_LITERAL("program"),
65 FILE_PATH_LITERAL("--disable-features=SomeSpecialFeature")}; 79 FILE_PATH_LITERAL("--disable-features=SomeSpecialFeature")};
66 CommandLine command_line(arraysize(argv), argv); 80 CommandLine command_line(arraysize(argv), argv);
67 AddFeatureAndVerify(command_line, "", "SomeSpecialFeature"); 81 EnableFeatureAndVerify(command_line, "", "SomeSpecialFeature");
68 } 82 }
69 83
70 TEST_F(CommandLineHelperTest, AddWithDisabledTestFeature) { 84 TEST_F(CommandLineHelperTest, EnableForDisabledTestFeature) {
71 const CommandLine::CharType* argv[] = { 85 const CommandLine::CharType* argv[] = {
72 FILE_PATH_LITERAL("program"), 86 FILE_PATH_LITERAL("program"),
73 FILE_PATH_LITERAL("--disable-features=TestFeature")}; 87 FILE_PATH_LITERAL("--disable-features=TestFeature")};
74 CommandLine command_line(arraysize(argv), argv); 88 CommandLine command_line(arraysize(argv), argv);
75 AddFeatureAndVerify(command_line, "SomeSpecialFeature", "TestFeature"); 89 EnableFeatureAndVerify(command_line, "SomeSpecialFeature", "TestFeature");
76 } 90 }
91
92 TEST_F(CommandLineHelperTest, DisableForEmptyCommandLine) {
93 CommandLine command_line(CommandLine::NO_PROGRAM);
94 DisableFeatureAndVerify(command_line, "", "SomeSpecialFeature");
95 }
96
97 TEST_F(CommandLineHelperTest, DisableForNoDisabledFeatures) {
98 const CommandLine::CharType* argv[] = {FILE_PATH_LITERAL("program")};
99 CommandLine command_line(arraysize(argv), argv);
100 DisableFeatureAndVerify(command_line, "", "SomeSpecialFeature");
101 }
102
103 TEST_F(CommandLineHelperTest, DisableForDisabledTestFeature) {
104 const CommandLine::CharType* argv[] = {
105 FILE_PATH_LITERAL("program"),
106 FILE_PATH_LITERAL("--disable-features=TestFeature")};
107 CommandLine command_line(arraysize(argv), argv);
108 DisableFeatureAndVerify(command_line, "", "TestFeature,SomeSpecialFeature");
109 }
110
111 TEST_F(CommandLineHelperTest, DisableForDisabledSomeSpecialFeature) {
112 const CommandLine::CharType* argv[] = {
113 FILE_PATH_LITERAL("program"),
114 FILE_PATH_LITERAL("--disable-features=SomeSpecialFeature,TestFeature")};
115 CommandLine command_line(arraysize(argv), argv);
116 DisableFeatureAndVerify(command_line, "", "SomeSpecialFeature,TestFeature");
117 }
118
119 TEST_F(CommandLineHelperTest, DisableForEnabledSomeSpecialFeature) {
120 const CommandLine::CharType* argv[] = {
121 FILE_PATH_LITERAL("program"),
122 FILE_PATH_LITERAL("--enable-features=SomeSpecialFeature")};
123 CommandLine command_line(arraysize(argv), argv);
124 DisableFeatureAndVerify(command_line, "SomeSpecialFeature", "");
125 }
126
127 TEST_F(CommandLineHelperTest, DisableForEnabledTestFeature) {
128 const CommandLine::CharType* argv[] = {
129 FILE_PATH_LITERAL("program"),
130 FILE_PATH_LITERAL("--enable-features=TestFeature")};
131 CommandLine command_line(arraysize(argv), argv);
132 DisableFeatureAndVerify(command_line, "TestFeature", "SomeSpecialFeature");
133 }
OLDNEW
« 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