OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 <stddef.h> | 5 #include <stddef.h> |
6 | 6 |
7 #include "base/macros.h" | 7 #include "base/macros.h" |
8 #include "base/values.h" | 8 #include "base/values.h" |
9 #include "chrome/test/chromedriver/capabilities.h" | 9 #include "chrome/test/chromedriver/capabilities.h" |
10 #include "chrome/test/chromedriver/chrome/devtools_event_listener.h" | 10 #include "chrome/test/chromedriver/chrome/devtools_event_listener.h" |
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
161 ASSERT_TRUE(entry.empty()); | 161 ASSERT_TRUE(entry.empty()); |
162 | 162 |
163 log.AddEntry(Log::kInfo, "info message"); | 163 log.AddEntry(Log::kInfo, "info message"); |
164 log.AddEntry(Log::kError, "first error message"); | 164 log.AddEntry(Log::kError, "first error message"); |
165 log.AddEntry(Log::kDebug, "debug message"); | 165 log.AddEntry(Log::kDebug, "debug message"); |
166 log.AddEntry(Log::kError, "second error message"); | 166 log.AddEntry(Log::kError, "second error message"); |
167 | 167 |
168 entry = log.GetFirstErrorMessage(); | 168 entry = log.GetFirstErrorMessage(); |
169 ASSERT_EQ("first error message", entry); | 169 ASSERT_EQ("first error message", entry); |
170 } | 170 } |
| 171 |
| 172 TEST(Logging, GetLotsOfLogs) { |
| 173 WebDriverLog log(WebDriverLog::kBrowserType, Log::kAll); |
| 174 std::string entry; |
| 175 for (size_t i = 0; i < WebDriverLog::kMaxReturnedEntries + 1; i++) |
| 176 log.AddEntry(Log::kError, "info message"); |
| 177 std::unique_ptr<base::ListValue> entries = log.GetAndClearEntries(); |
| 178 ASSERT_EQ(WebDriverLog::kMaxReturnedEntries, entries->GetSize()); |
| 179 entries = log.GetAndClearEntries(); |
| 180 ASSERT_EQ(1u, entries->GetSize()); |
| 181 entries = log.GetAndClearEntries(); |
| 182 ASSERT_EQ(0u, entries->GetSize()); |
| 183 } |
OLD | NEW |