| 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 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 53 std::string output_none = network_event_log::GetAsString( | 53 std::string output_none = network_event_log::GetAsString( |
| 54 network_event_log::OLDEST_FIRST, 0); | 54 network_event_log::OLDEST_FIRST, 0); |
| 55 EXPECT_EQ("No Log Entries.", output_none); | 55 EXPECT_EQ("No Log Entries.", output_none); |
| 56 | 56 |
| 57 network_event_log::AddEntry("module1", "event1", "description1"); | 57 network_event_log::AddEntry("module1", "event1", "description1"); |
| 58 network_event_log::AddEntry("module2", "event2", "description2"); | 58 network_event_log::AddEntry("module2", "event2", "description2"); |
| 59 network_event_log::AddEntry("module3", "event3", "description3"); | 59 network_event_log::AddEntry("module3", "event3", "description3"); |
| 60 network_event_log::AddEntry("module3", "event3", "description3"); | 60 network_event_log::AddEntry("module3", "event3", "description3"); |
| 61 | 61 |
| 62 const std::string expected_output_oldest_first( | 62 const std::string expected_output_oldest_first( |
| 63 "module1.event1: description1\n" | 63 "module1:event1: description1\n" |
| 64 "module2.event2: description2\n" | 64 "module2:event2: description2\n" |
| 65 "module3.event3: description3 (2)\n"); | 65 "module3:event3: description3 (2)\n"); |
| 66 std::string output_oldest_first = network_event_log::GetAsString( | 66 std::string output_oldest_first = network_event_log::GetAsString( |
| 67 network_event_log::OLDEST_FIRST, 0); | 67 network_event_log::OLDEST_FIRST, 0); |
| 68 output_oldest_first = SkipTime(output_oldest_first); | 68 output_oldest_first = SkipTime(output_oldest_first); |
| 69 EXPECT_EQ(expected_output_oldest_first, output_oldest_first); | 69 EXPECT_EQ(expected_output_oldest_first, output_oldest_first); |
| 70 | 70 |
| 71 const std::string expected_output_oldest_first_short( | 71 const std::string expected_output_oldest_first_short( |
| 72 "module2.event2: description2\n" | 72 "module2:event2: description2\n" |
| 73 "module3.event3: description3 (2)\n"); | 73 "module3:event3: description3 (2)\n"); |
| 74 std::string output_oldest_first_short = network_event_log::GetAsString( | 74 std::string output_oldest_first_short = network_event_log::GetAsString( |
| 75 network_event_log::OLDEST_FIRST, 2); | 75 network_event_log::OLDEST_FIRST, 2); |
| 76 output_oldest_first_short = SkipTime(output_oldest_first_short); | 76 output_oldest_first_short = SkipTime(output_oldest_first_short); |
| 77 EXPECT_EQ(expected_output_oldest_first_short, output_oldest_first_short); | 77 EXPECT_EQ(expected_output_oldest_first_short, output_oldest_first_short); |
| 78 | 78 |
| 79 const std::string expected_output_newest_first( | 79 const std::string expected_output_newest_first( |
| 80 "module3.event3: description3 (2)\n" | 80 "module3:event3: description3 (2)\n" |
| 81 "module2.event2: description2\n" | 81 "module2:event2: description2\n" |
| 82 "module1.event1: description1\n"); | 82 "module1:event1: description1\n"); |
| 83 std::string output_newest_first = network_event_log::GetAsString( | 83 std::string output_newest_first = network_event_log::GetAsString( |
| 84 network_event_log::NEWEST_FIRST, 0); | 84 network_event_log::NEWEST_FIRST, 0); |
| 85 output_newest_first = SkipTime(output_newest_first); | 85 output_newest_first = SkipTime(output_newest_first); |
| 86 EXPECT_EQ(expected_output_newest_first, output_newest_first); | 86 EXPECT_EQ(expected_output_newest_first, output_newest_first); |
| 87 | 87 |
| 88 const std::string expected_output_newest_first_short( | 88 const std::string expected_output_newest_first_short( |
| 89 "module3.event3: description3 (2)\n" | 89 "module3:event3: description3 (2)\n" |
| 90 "module2.event2: description2\n"); | 90 "module2:event2: description2\n"); |
| 91 std::string output_newest_first_short = network_event_log::GetAsString( | 91 std::string output_newest_first_short = network_event_log::GetAsString( |
| 92 network_event_log::NEWEST_FIRST, 2); | 92 network_event_log::NEWEST_FIRST, 2); |
| 93 output_newest_first_short = SkipTime(output_newest_first_short); | 93 output_newest_first_short = SkipTime(output_newest_first_short); |
| 94 EXPECT_EQ(expected_output_newest_first_short, output_newest_first_short); | 94 EXPECT_EQ(expected_output_newest_first_short, output_newest_first_short); |
| 95 } | 95 } |
| 96 | 96 |
| 97 TEST_F(NetworkEventLogTest, TestMaxNetworkEvents) { | 97 TEST_F(NetworkEventLogTest, TestMaxNetworkEvents) { |
| 98 const size_t entries_to_add = | 98 const size_t entries_to_add = |
| 99 network_event_log::kMaxNetworkEventLogEntries + 3; | 99 network_event_log::kMaxNetworkEventLogEntries + 3; |
| 100 for (size_t i = 0; i < entries_to_add; ++i) | 100 for (size_t i = 0; i < entries_to_add; ++i) |
| 101 network_event_log::AddEntry("test", StringPrintf("event_%"PRIuS, i), ""); | 101 network_event_log::AddEntry("test", StringPrintf("event_%"PRIuS, i), ""); |
| 102 | 102 |
| 103 std::string output = GetAsString(network_event_log::OLDEST_FIRST, 0); | 103 std::string output = GetAsString(network_event_log::OLDEST_FIRST, 0); |
| 104 size_t output_lines = CountLines(output); | 104 size_t output_lines = CountLines(output); |
| 105 EXPECT_EQ(network_event_log::kMaxNetworkEventLogEntries, output_lines); | 105 EXPECT_EQ(network_event_log::kMaxNetworkEventLogEntries, output_lines); |
| 106 } | 106 } |
| 107 | 107 |
| 108 } // namespace chromeos | 108 } // namespace chromeos |
| OLD | NEW |