diff options
-rw-r--r-- | base/command_line_unittest.cc | 20 | ||||
-rw-r--r-- | base/i18n/build_utf8_validator_tables.cc | 6 | ||||
-rw-r--r-- | base/logging.cc | 2 | ||||
-rw-r--r-- | base/process/process_util_unittest.cc | 57 | ||||
-rw-r--r-- | base/test/test_suite.cc | 25 | ||||
-rw-r--r-- | base/test/test_timeouts.cc | 6 | ||||
-rw-r--r-- | base/tracked_objects.cc | 4 |
7 files changed, 65 insertions, 55 deletions
diff --git a/base/command_line_unittest.cc b/base/command_line_unittest.cc index 8fdd605..e395c856 100644 --- a/base/command_line_unittest.cc +++ b/base/command_line_unittest.cc @@ -11,7 +11,7 @@ #include "base/strings/utf_string_conversions.h" #include "testing/gtest/include/gtest/gtest.h" -using base::FilePath; +namespace base { // To test Windows quoting behavior, we use a string that has some backslashes // and quotes. @@ -200,15 +200,11 @@ TEST(CommandLineTest, GetArgumentsString) { cl.AppendArg(kFifthArgName); #if defined(OS_WIN) - CommandLine::StringType expected_first_arg( - base::UTF8ToUTF16(kFirstArgName)); - CommandLine::StringType expected_second_arg( - base::UTF8ToUTF16(kSecondArgName)); - CommandLine::StringType expected_third_arg( - base::UTF8ToUTF16(kThirdArgName)); - CommandLine::StringType expected_fourth_arg( - base::UTF8ToUTF16(kFourthArgName)); - CommandLine::StringType expected_fifth_arg(base::UTF8ToUTF16(kFifthArgName)); + CommandLine::StringType expected_first_arg(UTF8ToUTF16(kFirstArgName)); + CommandLine::StringType expected_second_arg(UTF8ToUTF16(kSecondArgName)); + CommandLine::StringType expected_third_arg(UTF8ToUTF16(kThirdArgName)); + CommandLine::StringType expected_fourth_arg(UTF8ToUTF16(kFourthArgName)); + CommandLine::StringType expected_fifth_arg(UTF8ToUTF16(kFifthArgName)); #elif defined(OS_POSIX) CommandLine::StringType expected_first_arg(kFirstArgName); CommandLine::StringType expected_second_arg(kSecondArgName); @@ -368,7 +364,7 @@ TEST(CommandLineTest, ProgramQuotes) { EXPECT_EQ(L"\"Program Path\"", cmd_string); // Check the optional quoting of placeholders in programs. - CommandLine cl_quote_placeholder(base::FilePath(L"%1")); + CommandLine cl_quote_placeholder(FilePath(L"%1")); EXPECT_EQ(L"%1", cl_quote_placeholder.GetCommandLineString()); EXPECT_EQ(L"\"%1\"", cl_quote_placeholder.GetCommandLineStringWithPlaceholders()); @@ -382,3 +378,5 @@ TEST(CommandLineTest, Init) { CommandLine* current = CommandLine::ForCurrentProcess(); EXPECT_EQ(initial, current); } + +} // namespace base diff --git a/base/i18n/build_utf8_validator_tables.cc b/base/i18n/build_utf8_validator_tables.cc index 45fc6cb..647c8d6 100644 --- a/base/i18n/build_utf8_validator_tables.cc +++ b/base/i18n/build_utf8_validator_tables.cc @@ -425,16 +425,16 @@ void PrintStates(const std::vector<State>& states, FILE* stream) { } // namespace int main(int argc, char* argv[]) { - CommandLine::Init(argc, argv); + base::CommandLine::Init(argc, argv); logging::LoggingSettings settings; settings.logging_dest = logging::LOG_TO_SYSTEM_DEBUG_LOG; logging::InitLogging(settings); - if (CommandLine::ForCurrentProcess()->HasSwitch("help")) { + if (base::CommandLine::ForCurrentProcess()->HasSwitch("help")) { fwrite(kHelpText, 1, arraysize(kHelpText), stdout); exit(EXIT_SUCCESS); } base::FilePath filename = - CommandLine::ForCurrentProcess()->GetSwitchValuePath("output"); + base::CommandLine::ForCurrentProcess()->GetSwitchValuePath("output"); FILE* output = stdout; if (!filename.empty()) { diff --git a/base/logging.cc b/base/logging.cc index 150a408..f3601ee 100644 --- a/base/logging.cc +++ b/base/logging.cc @@ -359,7 +359,7 @@ bool BaseInitLoggingImpl(const LoggingSettings& settings) { // Can log only to the system debug log. CHECK_EQ(settings.logging_dest & ~LOG_TO_SYSTEM_DEBUG_LOG, 0); #endif - CommandLine* command_line = CommandLine::ForCurrentProcess(); + base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); // Don't bother initializing g_vlog_info unless we use one of the // vlog switches. if (command_line->HasSwitch(switches::kV) || diff --git a/base/process/process_util_unittest.cc b/base/process/process_util_unittest.cc index c282733..a5de9fe 100644 --- a/base/process/process_util_unittest.cc +++ b/base/process/process_util_unittest.cc @@ -325,7 +325,7 @@ TEST_F(ProcessUtilTest, GetAppOutput) { expected += "\r\n"; FilePath cmd(L"cmd.exe"); - CommandLine cmd_line(cmd); + base::CommandLine cmd_line(cmd); cmd_line.AppendArg("/c"); cmd_line.AppendArg("echo " + message + ""); std::string output; @@ -333,7 +333,7 @@ TEST_F(ProcessUtilTest, GetAppOutput) { EXPECT_EQ(expected, output); // Let's make sure stderr is ignored. - CommandLine other_cmd_line(cmd); + base::CommandLine other_cmd_line(cmd); other_cmd_line.AppendArg("/c"); // http://msdn.microsoft.com/library/cc772622.aspx cmd_line.AppendArg("echo " + message + " >&2"); @@ -356,7 +356,7 @@ static const char kEventToTriggerHandleSwitch[] = "event-to-trigger-handle"; MULTIPROCESS_TEST_MAIN(TriggerEventChildProcess) { std::string handle_value_string = - CommandLine::ForCurrentProcess()->GetSwitchValueASCII( + base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII( kEventToTriggerHandleSwitch); CHECK(!handle_value_string.empty()); @@ -386,7 +386,7 @@ TEST_F(ProcessUtilTest, InheritSpecifiedHandles) { base::LaunchOptions options; options.handles_to_inherit = &handles_to_inherit; - CommandLine cmd_line = MakeCmdLine("TriggerEventChildProcess"); + base::CommandLine cmd_line = MakeCmdLine("TriggerEventChildProcess"); cmd_line.AppendSwitchASCII(kEventToTriggerHandleSwitch, base::Uint64ToString(reinterpret_cast<uint64>(event.handle()))); @@ -711,27 +711,29 @@ TEST_F(ProcessUtilTest, GetAppOutput) { argv.push_back("-c"); argv.push_back("exit 0"); - EXPECT_TRUE(base::GetAppOutput(CommandLine(argv), &output)); + EXPECT_TRUE(base::GetAppOutput(base::CommandLine(argv), &output)); EXPECT_STREQ("", output.c_str()); argv[2] = "exit 1"; - EXPECT_FALSE(base::GetAppOutput(CommandLine(argv), &output)); + EXPECT_FALSE(base::GetAppOutput(base::CommandLine(argv), &output)); EXPECT_STREQ("", output.c_str()); argv[2] = "echo foobar42"; - EXPECT_TRUE(base::GetAppOutput(CommandLine(argv), &output)); + EXPECT_TRUE(base::GetAppOutput(base::CommandLine(argv), &output)); EXPECT_STREQ("foobar42\n", output.c_str()); #else - EXPECT_TRUE(base::GetAppOutput(CommandLine(FilePath("true")), &output)); + EXPECT_TRUE(base::GetAppOutput(base::CommandLine(FilePath("true")), + &output)); EXPECT_STREQ("", output.c_str()); - EXPECT_FALSE(base::GetAppOutput(CommandLine(FilePath("false")), &output)); + EXPECT_FALSE(base::GetAppOutput(base::CommandLine(FilePath("false")), + &output)); std::vector<std::string> argv; argv.push_back("/bin/echo"); argv.push_back("-n"); argv.push_back("foobar42"); - EXPECT_TRUE(base::GetAppOutput(CommandLine(argv), &output)); + EXPECT_TRUE(base::GetAppOutput(base::CommandLine(argv), &output)); EXPECT_STREQ("foobar42", output.c_str()); #endif // defined(OS_ANDROID) } @@ -755,34 +757,39 @@ TEST_F(ProcessUtilTest, MAYBE_GetAppOutputRestricted) { // need absolute paths). argv.push_back("exit 0"); // argv[2]; equivalent to "true" std::string output = "abc"; - EXPECT_TRUE(base::GetAppOutputRestricted(CommandLine(argv), &output, 100)); + EXPECT_TRUE(base::GetAppOutputRestricted(base::CommandLine(argv), &output, + 100)); EXPECT_STREQ("", output.c_str()); argv[2] = "exit 1"; // equivalent to "false" output = "before"; - EXPECT_FALSE(base::GetAppOutputRestricted(CommandLine(argv), - &output, 100)); + EXPECT_FALSE(base::GetAppOutputRestricted(base::CommandLine(argv), &output, + 100)); EXPECT_STREQ("", output.c_str()); // Amount of output exactly equal to space allowed. argv[2] = "echo 123456789"; // (the sh built-in doesn't take "-n") output.clear(); - EXPECT_TRUE(base::GetAppOutputRestricted(CommandLine(argv), &output, 10)); + EXPECT_TRUE(base::GetAppOutputRestricted(base::CommandLine(argv), &output, + 10)); EXPECT_STREQ("123456789\n", output.c_str()); // Amount of output greater than space allowed. output.clear(); - EXPECT_TRUE(base::GetAppOutputRestricted(CommandLine(argv), &output, 5)); + EXPECT_TRUE(base::GetAppOutputRestricted(base::CommandLine(argv), &output, + 5)); EXPECT_STREQ("12345", output.c_str()); // Amount of output less than space allowed. output.clear(); - EXPECT_TRUE(base::GetAppOutputRestricted(CommandLine(argv), &output, 15)); + EXPECT_TRUE(base::GetAppOutputRestricted(base::CommandLine(argv), &output, + 15)); EXPECT_STREQ("123456789\n", output.c_str()); // Zero space allowed. output = "abc"; - EXPECT_TRUE(base::GetAppOutputRestricted(CommandLine(argv), &output, 0)); + EXPECT_TRUE(base::GetAppOutputRestricted(base::CommandLine(argv), &output, + 0)); EXPECT_STREQ("", output.c_str()); } @@ -797,11 +804,13 @@ TEST_F(ProcessUtilTest, GetAppOutputRestrictedSIGPIPE) { argv.push_back("-c"); #if defined(OS_ANDROID) argv.push_back("while echo 12345678901234567890; do :; done"); - EXPECT_TRUE(base::GetAppOutputRestricted(CommandLine(argv), &output, 10)); + EXPECT_TRUE(base::GetAppOutputRestricted(base::CommandLine(argv), &output, + 10)); EXPECT_STREQ("1234567890", output.c_str()); #else argv.push_back("yes"); - EXPECT_TRUE(base::GetAppOutputRestricted(CommandLine(argv), &output, 10)); + EXPECT_TRUE(base::GetAppOutputRestricted(base::CommandLine(argv), &output, + 10)); EXPECT_STREQ("y\ny\ny\ny\ny\n", output.c_str()); #endif } @@ -827,14 +836,16 @@ TEST_F(ProcessUtilTest, MAYBE_GetAppOutputRestrictedNoZombies) { // 10.5) times with an output buffer big enough to capture all output. for (int i = 0; i < 300; i++) { std::string output; - EXPECT_TRUE(base::GetAppOutputRestricted(CommandLine(argv), &output, 100)); + EXPECT_TRUE(base::GetAppOutputRestricted(base::CommandLine(argv), &output, + 100)); EXPECT_STREQ("123456789012345678901234567890\n", output.c_str()); } // Ditto, but with an output buffer too small to capture all output. for (int i = 0; i < 300; i++) { std::string output; - EXPECT_TRUE(base::GetAppOutputRestricted(CommandLine(argv), &output, 10)); + EXPECT_TRUE(base::GetAppOutputRestricted(base::CommandLine(argv), &output, + 10)); EXPECT_STREQ("1234567890", output.c_str()); } } @@ -847,7 +858,7 @@ TEST_F(ProcessUtilTest, GetAppOutputWithExitCode) { argv.push_back(std::string(kShellPath)); // argv[0] argv.push_back("-c"); // argv[1] argv.push_back("echo foo"); // argv[2]; - EXPECT_TRUE(base::GetAppOutputWithExitCode(CommandLine(argv), &output, + EXPECT_TRUE(base::GetAppOutputWithExitCode(base::CommandLine(argv), &output, &exit_code)); EXPECT_STREQ("foo\n", output.c_str()); EXPECT_EQ(exit_code, 0); @@ -856,7 +867,7 @@ TEST_F(ProcessUtilTest, GetAppOutputWithExitCode) { // code. output.clear(); argv[2] = "echo foo; exit 2"; - EXPECT_TRUE(base::GetAppOutputWithExitCode(CommandLine(argv), &output, + EXPECT_TRUE(base::GetAppOutputWithExitCode(base::CommandLine(argv), &output, &exit_code)); EXPECT_STREQ("foo\n", output.c_str()); EXPECT_EQ(exit_code, 2); diff --git a/base/test/test_suite.cc b/base/test/test_suite.cc index 206507bb..a6fc201 100644 --- a/base/test/test_suite.cc +++ b/base/test/test_suite.cc @@ -58,19 +58,19 @@ class MaybeTestDisabler : public testing::EmptyTestEventListener { class TestClientInitializer : public testing::EmptyTestEventListener { public: TestClientInitializer() - : old_command_line_(CommandLine::NO_PROGRAM) { + : old_command_line_(base::CommandLine::NO_PROGRAM) { } virtual void OnTestStart(const testing::TestInfo& test_info) override { - old_command_line_ = *CommandLine::ForCurrentProcess(); + old_command_line_ = *base::CommandLine::ForCurrentProcess(); } virtual void OnTestEnd(const testing::TestInfo& test_info) override { - *CommandLine::ForCurrentProcess() = old_command_line_; + *base::CommandLine::ForCurrentProcess() = old_command_line_; } private: - CommandLine old_command_line_; + base::CommandLine old_command_line_; DISALLOW_COPY_AND_ASSIGN(TestClientInitializer); }; @@ -108,11 +108,11 @@ TestSuite::TestSuite(int argc, char** argv, bool create_at_exit_manager) TestSuite::~TestSuite() { if (initialized_command_line_) - CommandLine::Reset(); + base::CommandLine::Reset(); } void TestSuite::InitializeFromCommandLine(int argc, char** argv) { - initialized_command_line_ = CommandLine::Init(argc, argv); + initialized_command_line_ = base::CommandLine::Init(argc, argv); testing::InitGoogleTest(&argc, argv); testing::InitGoogleMock(&argc, argv); @@ -124,7 +124,7 @@ void TestSuite::InitializeFromCommandLine(int argc, char** argv) { #if defined(OS_WIN) void TestSuite::InitializeFromCommandLine(int argc, wchar_t** argv) { // Windows CommandLine::Init ignores argv anyway. - initialized_command_line_ = CommandLine::Init(argc, NULL); + initialized_command_line_ = base::CommandLine::Init(argc, NULL); testing::InitGoogleTest(&argc, argv); testing::InitGoogleMock(&argc, argv); } @@ -174,13 +174,13 @@ void TestSuite::ResetCommandLine() { #if !defined(OS_IOS) void TestSuite::AddTestLauncherResultPrinter() { // Only add the custom printer if requested. - if (!CommandLine::ForCurrentProcess()->HasSwitch( + if (!base::CommandLine::ForCurrentProcess()->HasSwitch( switches::kTestLauncherOutput)) { return; } - FilePath output_path(CommandLine::ForCurrentProcess()->GetSwitchValuePath( - switches::kTestLauncherOutput)); + FilePath output_path(base::CommandLine::ForCurrentProcess()-> + GetSwitchValuePath(switches::kTestLauncherOutput)); // Do not add the result printer if output path already exists. It's an // indicator there is a process printing to that file, and we're likely @@ -212,7 +212,7 @@ int TestSuite::Run() { Initialize(); std::string client_func = - CommandLine::ForCurrentProcess()->GetSwitchValueASCII( + base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII( switches::kTestChildProcess); // Check to see if we are being run as a client process. @@ -315,7 +315,8 @@ void TestSuite::Initialize() { // In some cases, we do not want to see standard error dialogs. if (!base::debug::BeingDebugged() && - !CommandLine::ForCurrentProcess()->HasSwitch("show-error-dialogs")) { + !base::CommandLine::ForCurrentProcess()->HasSwitch( + "show-error-dialogs")) { SuppressErrorDialogs(); base::debug::SetSuppressDebugUI(true); logging::SetLogAssertHandler(UnitTestAssertHandler); diff --git a/base/test/test_timeouts.cc b/base/test/test_timeouts.cc index c84cd38..66ae85e 100644 --- a/base/test/test_timeouts.cc +++ b/base/test/test_timeouts.cc @@ -41,9 +41,9 @@ const int kAlmostInfiniteTimeoutMs = 100000000; // by kTimeoutMultiplier. void InitializeTimeout(const char* switch_name, int min_value, int* value) { DCHECK(value); - if (CommandLine::ForCurrentProcess()->HasSwitch(switch_name)) { - std::string string_value( - CommandLine::ForCurrentProcess()->GetSwitchValueASCII(switch_name)); + if (base::CommandLine::ForCurrentProcess()->HasSwitch(switch_name)) { + std::string string_value(base::CommandLine::ForCurrentProcess()-> + GetSwitchValueASCII(switch_name)); int timeout; base::StringToInt(string_value, &timeout); *value = std::max(*value, timeout); diff --git a/base/tracked_objects.cc b/base/tracked_objects.cc index 5e30762..4320509 100644 --- a/base/tracked_objects.cc +++ b/base/tracked_objects.cc @@ -76,10 +76,10 @@ inline bool IsProfilerTimingEnabled() { base::subtle::Atomic32 current_timing_enabled = base::subtle::NoBarrier_Load(&g_profiler_timing_enabled); if (current_timing_enabled == UNDEFINED_TIMING) { - if (!CommandLine::InitializedForCurrentProcess()) + if (!base::CommandLine::InitializedForCurrentProcess()) return true; current_timing_enabled = - (CommandLine::ForCurrentProcess()->GetSwitchValueASCII( + (base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII( switches::kProfilerTiming) == switches::kProfilerTimingDisabledValue) ? DISABLED_TIMING |