OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/test/chromedriver/performance_logger.h" | 5 #include "chrome/test/chromedriver/performance_logger.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
| 9 #include <memory> |
| 10 #include <utility> |
| 11 |
9 #include "base/compiler_specific.h" | 12 #include "base/compiler_specific.h" |
10 #include "base/format_macros.h" | 13 #include "base/format_macros.h" |
11 #include "base/json/json_reader.h" | 14 #include "base/json/json_reader.h" |
12 #include "base/memory/scoped_vector.h" | 15 #include "base/memory/scoped_vector.h" |
13 #include "base/time/time.h" | 16 #include "base/time/time.h" |
14 #include "base/values.h" | 17 #include "base/values.h" |
15 #include "chrome/test/chromedriver/chrome/devtools_client_impl.h" | 18 #include "chrome/test/chromedriver/chrome/devtools_client_impl.h" |
16 #include "chrome/test/chromedriver/chrome/log.h" | 19 #include "chrome/test/chromedriver/chrome/log.h" |
17 #include "chrome/test/chromedriver/chrome/status.h" | 20 #include "chrome/test/chromedriver/chrome/status.h" |
18 #include "chrome/test/chromedriver/chrome/stub_devtools_client.h" | 21 #include "chrome/test/chromedriver/chrome/stub_devtools_client.h" |
(...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
308 FakeLog log; | 311 FakeLog log; |
309 Session session("test"); | 312 Session session("test"); |
310 PerfLoggingPrefs prefs; | 313 PerfLoggingPrefs prefs; |
311 prefs.trace_categories = "benchmark,blink.console"; | 314 prefs.trace_categories = "benchmark,blink.console"; |
312 PerformanceLogger logger(&log, &session, prefs); | 315 PerformanceLogger logger(&log, &session, prefs); |
313 | 316 |
314 client.AddListener(&logger); | 317 client.AddListener(&logger); |
315 logger.OnConnected(&client); | 318 logger.OnConnected(&client); |
316 base::DictionaryValue params; | 319 base::DictionaryValue params; |
317 base::ListValue* trace_events = new base::ListValue(); | 320 base::ListValue* trace_events = new base::ListValue(); |
318 base::DictionaryValue* event1 = new base::DictionaryValue(); | 321 std::unique_ptr<base::DictionaryValue> event1(new base::DictionaryValue()); |
319 event1->SetString("cat", "foo"); | 322 event1->SetString("cat", "foo"); |
320 trace_events->Append(event1); | 323 trace_events->Append(event1->CreateDeepCopy()); |
321 base::DictionaryValue* event2 = new base::DictionaryValue(); | 324 std::unique_ptr<base::DictionaryValue> event2(new base::DictionaryValue()); |
322 event2->SetString("cat", "bar"); | 325 event2->SetString("cat", "bar"); |
323 trace_events->Append(event2); | 326 trace_events->Append(event2->CreateDeepCopy()); |
324 params.Set("value", trace_events); | 327 params.Set("value", trace_events); |
325 ASSERT_EQ(kOk, client.TriggerEvent("Tracing.dataCollected", params).code()); | 328 ASSERT_EQ(kOk, client.TriggerEvent("Tracing.dataCollected", params).code()); |
326 | 329 |
327 ASSERT_EQ(2u, log.GetEntries().size()); | 330 ASSERT_EQ(2u, log.GetEntries().size()); |
328 ValidateLogEntry(log.GetEntries()[0], | 331 ValidateLogEntry(log.GetEntries()[0], |
329 DevToolsClientImpl::kBrowserwideDevToolsClientId, | 332 DevToolsClientImpl::kBrowserwideDevToolsClientId, |
330 "Tracing.dataCollected", *event1); | 333 "Tracing.dataCollected", *event1); |
331 ValidateLogEntry(log.GetEntries()[1], | 334 ValidateLogEntry(log.GetEntries()[1], |
332 DevToolsClientImpl::kBrowserwideDevToolsClientId, | 335 DevToolsClientImpl::kBrowserwideDevToolsClientId, |
333 "Tracing.dataCollected", *event2); | 336 "Tracing.dataCollected", *event2); |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
377 std::string webview; | 380 std::string webview; |
378 EXPECT_TRUE(message->GetString("webview", &webview)); | 381 EXPECT_TRUE(message->GetString("webview", &webview)); |
379 EXPECT_EQ(DevToolsClientImpl::kBrowserwideDevToolsClientId, webview); | 382 EXPECT_EQ(DevToolsClientImpl::kBrowserwideDevToolsClientId, webview); |
380 std::string method; | 383 std::string method; |
381 EXPECT_TRUE(message->GetString("message.method", &method)); | 384 EXPECT_TRUE(message->GetString("message.method", &method)); |
382 EXPECT_EQ("Tracing.bufferUsage", method); | 385 EXPECT_EQ("Tracing.bufferUsage", method); |
383 base::DictionaryValue* actual_params; | 386 base::DictionaryValue* actual_params; |
384 EXPECT_TRUE(message->GetDictionary("message.params", &actual_params)); | 387 EXPECT_TRUE(message->GetDictionary("message.params", &actual_params)); |
385 EXPECT_TRUE(actual_params->HasKey("error")); | 388 EXPECT_TRUE(actual_params->HasKey("error")); |
386 } | 389 } |
OLD | NEW |