| 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 #include "chromeos/network/network_event_log.h" | 5 #include "chromeos/network/network_event_log.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
| 10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 103 std::string output_newest_first_short = GetLogString(NEWEST_FIRST, 2); | 103 std::string output_newest_first_short = GetLogString(NEWEST_FIRST, 2); |
| 104 EXPECT_EQ(expected_output_newest_first_short, output_newest_first_short); | 104 EXPECT_EQ(expected_output_newest_first_short, output_newest_first_short); |
| 105 } | 105 } |
| 106 | 106 |
| 107 TEST_F(NetworkEventLogTest, TestMaxNetworkEvents) { | 107 TEST_F(NetworkEventLogTest, TestMaxNetworkEvents) { |
| 108 const size_t max_entries = network_event_log::internal::GetMaxLogEntries(); | 108 const size_t max_entries = network_event_log::internal::GetMaxLogEntries(); |
| 109 const size_t entries_to_add = max_entries + 3; | 109 const size_t entries_to_add = max_entries + 3; |
| 110 for (size_t i = 0; i < entries_to_add; ++i) { | 110 for (size_t i = 0; i < entries_to_add; ++i) { |
| 111 network_event_log::internal::AddEntry( | 111 network_event_log::internal::AddEntry( |
| 112 "test", 1, LOG_LEVEL_EVENT, | 112 "test", 1, LOG_LEVEL_EVENT, |
| 113 base::StringPrintf("event_%"PRIuS, i), ""); | 113 base::StringPrintf("event_%" PRIuS, i), ""); |
| 114 } | 114 } |
| 115 std::string output = GetLogString(OLDEST_FIRST, 0); | 115 std::string output = GetLogString(OLDEST_FIRST, 0); |
| 116 size_t output_lines = CountLines(output); | 116 size_t output_lines = CountLines(output); |
| 117 EXPECT_EQ(max_entries, output_lines); | 117 EXPECT_EQ(max_entries, output_lines); |
| 118 } | 118 } |
| 119 | 119 |
| 120 TEST_F(NetworkEventLogTest, TestStringFormat) { | 120 TEST_F(NetworkEventLogTest, TestStringFormat) { |
| 121 network_event_log::internal::AddEntry( | 121 network_event_log::internal::AddEntry( |
| 122 "file", 0, LOG_LEVEL_ERROR, "event0", "description"); | 122 "file", 0, LOG_LEVEL_ERROR, "event0", "description"); |
| 123 EXPECT_EQ("file:0 event0\n", network_event_log::GetAsString( | 123 EXPECT_EQ("file:0 event0\n", network_event_log::GetAsString( |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 235 AddTestEvent(LOG_LEVEL_ERROR, "error3"); | 235 AddTestEvent(LOG_LEVEL_ERROR, "error3"); |
| 236 AddTestEvent(LOG_LEVEL_ERROR, "error4"); | 236 AddTestEvent(LOG_LEVEL_ERROR, "error4"); |
| 237 AddTestEvent(LOG_LEVEL_EVENT, "event5"); | 237 AddTestEvent(LOG_LEVEL_EVENT, "event5"); |
| 238 AddTestEvent(LOG_LEVEL_EVENT, "event6"); | 238 AddTestEvent(LOG_LEVEL_EVENT, "event6"); |
| 239 EXPECT_EQ("error3\nerror4\nevent5\nevent6\n", network_event_log::GetAsString( | 239 EXPECT_EQ("error3\nerror4\nevent5\nevent6\n", network_event_log::GetAsString( |
| 240 OLDEST_FIRST, "", LOG_LEVEL_DEBUG, 0)); | 240 OLDEST_FIRST, "", LOG_LEVEL_DEBUG, 0)); |
| 241 } | 241 } |
| 242 | 242 |
| 243 } // namespace network_event_log | 243 } // namespace network_event_log |
| 244 } // namespace chromeos | 244 } // namespace chromeos |
| OLD | NEW |