Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(12)

Side by Side Diff: base/test/trace_event_analyzer_unittest.cc

Issue 596103002: Fix more disabled MSVC warnings, base/ edition. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Review comment Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « base/test/launcher/test_results_tracker.cc ('k') | base/threading/platform_thread_win.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "base/bind.h" 5 #include "base/bind.h"
6 #include "base/debug/trace_event_unittest.h" 6 #include "base/debug/trace_event_unittest.h"
7 #include "base/synchronization/waitable_event.h" 7 #include "base/synchronization/waitable_event.h"
8 #include "base/test/trace_event_analyzer.h" 8 #include "base/test/trace_event_analyzer.h"
9 #include "testing/gmock/include/gmock/gmock.h" 9 #include "testing/gmock/include/gmock/gmock.h"
10 #include "testing/gtest/include/gtest/gtest.h" 10 #include "testing/gtest/include/gtest/gtest.h"
(...skipping 381 matching lines...) Expand 10 before | Expand all | Expand 10 after
392 EXPECT_STREQ("no match", found[0]->name.c_str()); 392 EXPECT_STREQ("no match", found[0]->name.c_str());
393 } 393 }
394 394
395 // Test that duration queries work. 395 // Test that duration queries work.
396 TEST_F(TraceEventAnalyzerTest, BeginEndDuration) { 396 TEST_F(TraceEventAnalyzerTest, BeginEndDuration) {
397 ManualSetUp(); 397 ManualSetUp();
398 398
399 const base::TimeDelta kSleepTime = base::TimeDelta::FromMilliseconds(200); 399 const base::TimeDelta kSleepTime = base::TimeDelta::FromMilliseconds(200);
400 // We will search for events that have a duration of greater than 90% of the 400 // We will search for events that have a duration of greater than 90% of the
401 // sleep time, so that there is no flakiness. 401 // sleep time, so that there is no flakiness.
402 int duration_cutoff_us = (kSleepTime.InMicroseconds() * 9) / 10; 402 int64 duration_cutoff_us = (kSleepTime.InMicroseconds() * 9) / 10;
403 403
404 BeginTracing(); 404 BeginTracing();
405 { 405 {
406 TRACE_EVENT_BEGIN0("cat1", "name1"); // found by duration query 406 TRACE_EVENT_BEGIN0("cat1", "name1"); // found by duration query
407 TRACE_EVENT_BEGIN0("noise", "name2"); // not searched for, just noise 407 TRACE_EVENT_BEGIN0("noise", "name2"); // not searched for, just noise
408 { 408 {
409 TRACE_EVENT_BEGIN0("cat2", "name3"); // found by duration query 409 TRACE_EVENT_BEGIN0("cat2", "name3"); // found by duration query
410 // next event not searched for, just noise 410 // next event not searched for, just noise
411 TRACE_EVENT_INSTANT0("noise", "name4", TRACE_EVENT_SCOPE_THREAD); 411 TRACE_EVENT_INSTANT0("noise", "name4", TRACE_EVENT_SCOPE_THREAD);
412 base::debug::HighResSleepForTraceTest(kSleepTime); 412 base::debug::HighResSleepForTraceTest(kSleepTime);
413 TRACE_EVENT_BEGIN0("cat2", "name5"); // not found (duration too short) 413 TRACE_EVENT_BEGIN0("cat2", "name5"); // not found (duration too short)
414 TRACE_EVENT_END0("cat2", "name5"); // not found (duration too short) 414 TRACE_EVENT_END0("cat2", "name5"); // not found (duration too short)
415 TRACE_EVENT_END0("cat2", "name3"); // found by duration query 415 TRACE_EVENT_END0("cat2", "name3"); // found by duration query
416 } 416 }
417 TRACE_EVENT_END0("noise", "name2"); // not searched for, just noise 417 TRACE_EVENT_END0("noise", "name2"); // not searched for, just noise
418 TRACE_EVENT_END0("cat1", "name1"); // found by duration query 418 TRACE_EVENT_END0("cat1", "name1"); // found by duration query
419 } 419 }
420 EndTracing(); 420 EndTracing();
421 421
422 scoped_ptr<TraceAnalyzer> 422 scoped_ptr<TraceAnalyzer>
423 analyzer(TraceAnalyzer::Create(output_.json_output)); 423 analyzer(TraceAnalyzer::Create(output_.json_output));
424 ASSERT_TRUE(analyzer.get()); 424 ASSERT_TRUE(analyzer.get());
425 analyzer->AssociateBeginEndEvents(); 425 analyzer->AssociateBeginEndEvents();
426 426
427 TraceEventVector found; 427 TraceEventVector found;
428 analyzer->FindEvents( 428 analyzer->FindEvents(
429 Query::MatchBeginWithEnd() && 429 Query::MatchBeginWithEnd() &&
430 Query::EventDuration() > Query::Int(duration_cutoff_us) && 430 Query::EventDuration() >
431 Query::Int(static_cast<int>(duration_cutoff_us)) &&
431 (Query::EventCategory() == Query::String("cat1") || 432 (Query::EventCategory() == Query::String("cat1") ||
432 Query::EventCategory() == Query::String("cat2") || 433 Query::EventCategory() == Query::String("cat2") ||
433 Query::EventCategory() == Query::String("cat3")), 434 Query::EventCategory() == Query::String("cat3")),
434 &found); 435 &found);
435 ASSERT_EQ(2u, found.size()); 436 ASSERT_EQ(2u, found.size());
436 EXPECT_STREQ("name1", found[0]->name.c_str()); 437 EXPECT_STREQ("name1", found[0]->name.c_str());
437 EXPECT_STREQ("name3", found[1]->name.c_str()); 438 EXPECT_STREQ("name3", found[1]->name.c_str());
438 } 439 }
439 440
440 // Test that duration queries work. 441 // Test that duration queries work.
441 TEST_F(TraceEventAnalyzerTest, CompleteDuration) { 442 TEST_F(TraceEventAnalyzerTest, CompleteDuration) {
442 ManualSetUp(); 443 ManualSetUp();
443 444
444 const base::TimeDelta kSleepTime = base::TimeDelta::FromMilliseconds(200); 445 const base::TimeDelta kSleepTime = base::TimeDelta::FromMilliseconds(200);
445 // We will search for events that have a duration of greater than 90% of the 446 // We will search for events that have a duration of greater than 90% of the
446 // sleep time, so that there is no flakiness. 447 // sleep time, so that there is no flakiness.
447 int duration_cutoff_us = (kSleepTime.InMicroseconds() * 9) / 10; 448 int64 duration_cutoff_us = (kSleepTime.InMicroseconds() * 9) / 10;
448 449
449 BeginTracing(); 450 BeginTracing();
450 { 451 {
451 TRACE_EVENT0("cat1", "name1"); // found by duration query 452 TRACE_EVENT0("cat1", "name1"); // found by duration query
452 TRACE_EVENT0("noise", "name2"); // not searched for, just noise 453 TRACE_EVENT0("noise", "name2"); // not searched for, just noise
453 { 454 {
454 TRACE_EVENT0("cat2", "name3"); // found by duration query 455 TRACE_EVENT0("cat2", "name3"); // found by duration query
455 // next event not searched for, just noise 456 // next event not searched for, just noise
456 TRACE_EVENT_INSTANT0("noise", "name4", TRACE_EVENT_SCOPE_THREAD); 457 TRACE_EVENT_INSTANT0("noise", "name4", TRACE_EVENT_SCOPE_THREAD);
457 base::debug::HighResSleepForTraceTest(kSleepTime); 458 base::debug::HighResSleepForTraceTest(kSleepTime);
458 TRACE_EVENT0("cat2", "name5"); // not found (duration too short) 459 TRACE_EVENT0("cat2", "name5"); // not found (duration too short)
459 } 460 }
460 } 461 }
461 EndTracing(); 462 EndTracing();
462 463
463 scoped_ptr<TraceAnalyzer> 464 scoped_ptr<TraceAnalyzer>
464 analyzer(TraceAnalyzer::Create(output_.json_output)); 465 analyzer(TraceAnalyzer::Create(output_.json_output));
465 ASSERT_TRUE(analyzer.get()); 466 ASSERT_TRUE(analyzer.get());
466 analyzer->AssociateBeginEndEvents(); 467 analyzer->AssociateBeginEndEvents();
467 468
468 TraceEventVector found; 469 TraceEventVector found;
469 analyzer->FindEvents( 470 analyzer->FindEvents(
470 Query::EventCompleteDuration() > Query::Int(duration_cutoff_us) && 471 Query::EventCompleteDuration() >
472 Query::Int(static_cast<int>(duration_cutoff_us)) &&
471 (Query::EventCategory() == Query::String("cat1") || 473 (Query::EventCategory() == Query::String("cat1") ||
472 Query::EventCategory() == Query::String("cat2") || 474 Query::EventCategory() == Query::String("cat2") ||
473 Query::EventCategory() == Query::String("cat3")), 475 Query::EventCategory() == Query::String("cat3")),
474 &found); 476 &found);
475 ASSERT_EQ(2u, found.size()); 477 ASSERT_EQ(2u, found.size());
476 EXPECT_STREQ("name1", found[0]->name.c_str()); 478 EXPECT_STREQ("name1", found[0]->name.c_str());
477 EXPECT_STREQ("name3", found[1]->name.c_str()); 479 EXPECT_STREQ("name3", found[1]->name.c_str());
478 } 480 }
479 481
480 // Test AssociateBeginEndEvents 482 // Test AssociateBeginEndEvents
(...skipping 403 matching lines...) Expand 10 before | Expand all | Expand 10 after
884 EXPECT_EQ(num_events, CountMatches(event_ptrs, Query::Bool(true))); 886 EXPECT_EQ(num_events, CountMatches(event_ptrs, Query::Bool(true)));
885 EXPECT_EQ(num_events - 1, CountMatches(event_ptrs, Query::Bool(true), 887 EXPECT_EQ(num_events - 1, CountMatches(event_ptrs, Query::Bool(true),
886 1, num_events)); 888 1, num_events));
887 EXPECT_EQ(1u, CountMatches(event_ptrs, query_one)); 889 EXPECT_EQ(1u, CountMatches(event_ptrs, query_one));
888 EXPECT_EQ(num_events - 1, CountMatches(event_ptrs, !query_one)); 890 EXPECT_EQ(num_events - 1, CountMatches(event_ptrs, !query_one));
889 EXPECT_EQ(num_named, CountMatches(event_ptrs, query_named)); 891 EXPECT_EQ(num_named, CountMatches(event_ptrs, query_named));
890 } 892 }
891 893
892 894
893 } // namespace trace_analyzer 895 } // namespace trace_analyzer
OLDNEW
« no previous file with comments | « base/test/launcher/test_results_tracker.cc ('k') | base/threading/platform_thread_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698