OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 // Note: this test tests LOG_V and LOG_E since all other logs are expressed | 5 // Note: this test tests LOG_V and LOG_E since all other logs are expressed |
6 // in forms of them. LOG is also tested for good measure. | 6 // in forms of them. LOG is also tested for good measure. |
7 // Also note that we are only allowed to call InitLogging() twice so the test | 7 // Also note that we are only allowed to call InitLogging() twice so the test |
8 // cases are more dense than normal. | 8 // cases are more dense than normal. |
9 | 9 |
10 // The following include must be first in this file. It ensures that | 10 // The following include must be first in this file. It ensures that |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
43 } | 43 } |
44 | 44 |
45 static bool ContainsString(const std::string& original, | 45 static bool ContainsString(const std::string& original, |
46 const char* string_to_match) { | 46 const char* string_to_match) { |
47 return original.find(string_to_match) != std::string::npos; | 47 return original.find(string_to_match) != std::string::npos; |
48 } | 48 } |
49 | 49 |
50 static bool Initialize(int verbosity_level) { | 50 static bool Initialize(int verbosity_level) { |
51 if (verbosity_level != kDefaultVerbosity) { | 51 if (verbosity_level != kDefaultVerbosity) { |
52 // Update the command line with specified verbosity level for this file. | 52 // Update the command line with specified verbosity level for this file. |
53 CommandLine* command_line = CommandLine::ForCurrentProcess(); | 53 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); |
54 std::ostringstream value_stream; | 54 std::ostringstream value_stream; |
55 value_stream << "logging_unittest=" << verbosity_level; | 55 value_stream << "logging_unittest=" << verbosity_level; |
56 const std::string& value = value_stream.str(); | 56 const std::string& value = value_stream.str(); |
57 command_line->AppendSwitchASCII("vmodule", value); | 57 command_line->AppendSwitchASCII("vmodule", value); |
58 } | 58 } |
59 | 59 |
60 // The command line flags are parsed here and the log file name is set. | 60 // The command line flags are parsed here and the log file name is set. |
61 logging::LoggingSettings settings; | 61 logging::LoggingSettings settings; |
62 settings.logging_dest = logging::LOG_TO_FILE; | 62 settings.logging_dest = logging::LOG_TO_FILE; |
63 settings.log_file = log_file_name; | 63 settings.log_file = log_file_name; |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
152 EXPECT_TRUE(ContainsString(contents_of_file, | 152 EXPECT_TRUE(ContainsString(contents_of_file, |
153 AsString(rtc::LS_WARNING))); | 153 AsString(rtc::LS_WARNING))); |
154 EXPECT_TRUE(ContainsString(contents_of_file, AsString(rtc::LS_INFO))); | 154 EXPECT_TRUE(ContainsString(contents_of_file, AsString(rtc::LS_INFO))); |
155 // LOG_E | 155 // LOG_E |
156 EXPECT_TRUE(ContainsString(contents_of_file, strerror(kFakeError))); | 156 EXPECT_TRUE(ContainsString(contents_of_file, strerror(kFakeError))); |
157 EXPECT_TRUE(ContainsString(contents_of_file, | 157 EXPECT_TRUE(ContainsString(contents_of_file, |
158 AsString(rtc::LS_VERBOSE))); | 158 AsString(rtc::LS_VERBOSE))); |
159 EXPECT_TRUE(ContainsString(contents_of_file, | 159 EXPECT_TRUE(ContainsString(contents_of_file, |
160 AsString(rtc::LS_SENSITIVE))); | 160 AsString(rtc::LS_SENSITIVE))); |
161 } | 161 } |
OLD | NEW |