| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 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 | 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 "chrome/browser/sync_file_system/logger.h" | 5 #include "chrome/browser/sync_file_system/logger.h" |
| 6 #include "testing/gtest/include/gtest/gtest.h" | 6 #include "testing/gtest/include/gtest/gtest.h" |
| 7 | 7 |
| 8 using drive::EventLogger; | 8 using drive::EventLogger; |
| 9 | 9 |
| 10 namespace sync_file_system { | 10 namespace sync_file_system { |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 bool ContainsString(std::string contains_string, EventLogger::Event event) { | 21 bool ContainsString(std::string contains_string, EventLogger::Event event) { |
| 22 return event.what.find(contains_string) != std::string::npos; | 22 return event.what.find(contains_string) != std::string::npos; |
| 23 } | 23 } |
| 24 | 24 |
| 25 } // namespace | 25 } // namespace |
| 26 | 26 |
| 27 class LoggerTest : public testing::Test { | 27 class LoggerTest : public testing::Test { |
| 28 public: | 28 public: |
| 29 LoggerTest() {} | 29 LoggerTest() {} |
| 30 | 30 |
| 31 virtual void SetUp() OVERRIDE { | 31 virtual void SetUp() override { |
| 32 logging::SetMinLogLevel(logging::LOG_INFO); | 32 logging::SetMinLogLevel(logging::LOG_INFO); |
| 33 util::ClearLog(); | 33 util::ClearLog(); |
| 34 } | 34 } |
| 35 | 35 |
| 36 private: | 36 private: |
| 37 DISALLOW_COPY_AND_ASSIGN(LoggerTest); | 37 DISALLOW_COPY_AND_ASSIGN(LoggerTest); |
| 38 }; | 38 }; |
| 39 | 39 |
| 40 TEST_F(LoggerTest, GetLogHistory) { | 40 TEST_F(LoggerTest, GetLogHistory) { |
| 41 LogSampleEvents(); | 41 LogSampleEvents(); |
| 42 | 42 |
| 43 const std::vector<EventLogger::Event> log = util::GetLogHistory(); | 43 const std::vector<EventLogger::Event> log = util::GetLogHistory(); |
| 44 ASSERT_EQ(3u, log.size()); | 44 ASSERT_EQ(3u, log.size()); |
| 45 EXPECT_TRUE(ContainsString("Info test message", log[0])); | 45 EXPECT_TRUE(ContainsString("Info test message", log[0])); |
| 46 EXPECT_TRUE(ContainsString("Warning test message", log[1])); | 46 EXPECT_TRUE(ContainsString("Warning test message", log[1])); |
| 47 EXPECT_TRUE(ContainsString("Error test message", log[2])); | 47 EXPECT_TRUE(ContainsString("Error test message", log[2])); |
| 48 } | 48 } |
| 49 | 49 |
| 50 TEST_F(LoggerTest, ClearLog) { | 50 TEST_F(LoggerTest, ClearLog) { |
| 51 LogSampleEvents(); | 51 LogSampleEvents(); |
| 52 EXPECT_EQ(3u, util::GetLogHistory().size()); | 52 EXPECT_EQ(3u, util::GetLogHistory().size()); |
| 53 | 53 |
| 54 util::ClearLog(); | 54 util::ClearLog(); |
| 55 EXPECT_EQ(0u, util::GetLogHistory().size()); | 55 EXPECT_EQ(0u, util::GetLogHistory().size()); |
| 56 } | 56 } |
| 57 | 57 |
| 58 | 58 |
| 59 } // namespace sync_file_system | 59 } // namespace sync_file_system |
| OLD | NEW |