forked from chromium/chromium
-
Notifications
You must be signed in to change notification settings - Fork 0
/
command_line_helper_unittest.cc
76 lines (64 loc) · 2.91 KB
/
command_line_helper_unittest.cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
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");
}