OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 2013 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 "chrome/browser/sync_file_system/logger.h" | |
6 #include "testing/gtest/include/gtest/gtest.h" | |
7 | |
8 using google_apis::EventLogger; | |
9 | |
10 namespace sync_file_system { | |
11 | |
12 namespace { | |
13 | |
14 // Logs one event at each supported LogSeverity level. | |
15 void LogSampleEvents() { | |
16 util::Log(logging::LOG_INFO, "Info test message"); | |
17 util::Log(logging::LOG_WARNING, "Warning info message"); | |
18 util::Log(logging::LOG_ERROR, "Error info message"); | |
nhiroki
2013/05/22 09:18:24
Can you define these messages as constant? For exa
calvinlo
2013/05/23 10:00:15
Per discussion, it seems like this is not worth do
| |
19 } | |
20 | |
21 } // namespace | |
22 | |
23 class LoggerTest : public testing::Test { | |
24 public: | |
25 LoggerTest() {} | |
26 | |
27 virtual void SetUp() OVERRIDE { | |
28 util::ClearLog(); | |
29 } | |
30 | |
31 protected: | |
32 DISALLOW_COPY_AND_ASSIGN(LoggerTest); | |
33 }; | |
34 | |
35 TEST_F(LoggerTest, TestLogSeverityLevels) { | |
36 // Check that all messages are logged when log LogSeverity is set to INFO. | |
37 logging::SetMinLogLevel(logging::LOG_INFO); | |
38 LogSampleEvents(); | |
39 | |
40 const std::vector<EventLogger::Event> log = util::GetLogHistory(); | |
41 ASSERT_EQ(3u, log.size()); | |
42 ASSERT_EQ("[Info] Info test message", log[0].what); | |
43 ASSERT_EQ("[Warning] Warning info message", log[1].what); | |
44 ASSERT_EQ("[Error] Error info message", log[2].what); | |
nhiroki
2013/05/22 09:18:24
How about adding ClearLog() test?
util::ClearLog(
calvinlo
2013/05/23 10:00:15
Done.
| |
45 } | |
46 | |
47 TEST_F(LoggerTest, TestMinLogSeverityLevels) { | |
48 // Check that all messages are logged when log LogSeverity is set to INFO. | |
nhiroki
2013/05/22 09:18:24
Can you update this comment?
calvinlo
2013/05/23 10:00:15
Done. Sorry, lazy copy and paste.
| |
49 logging::SetMinLogLevel(logging::LOG_ERROR); | |
50 LogSampleEvents(); | |
51 | |
52 const std::vector<EventLogger::Event> log = util::GetLogHistory(); | |
53 ASSERT_EQ(1u, log.size()); | |
54 ASSERT_EQ("[Error] Error info message", log[0].what); | |
55 } | |
56 | |
57 } // namespace sync_file_system | |
OLD | NEW |