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

Side by Side Diff: base/debug/trace_event_unittest.cc

Issue 98953002: Configure synthetic delays through TraceLog (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixed test failure on ios_dbg_simulator Created 6 years, 11 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 | Annotate | Revision Log
« no previous file with comments | « base/debug/trace_event_synthetic_delay_unittest.cc ('k') | no next file » | 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/debug/trace_event_unittest.h" 5 #include "base/debug/trace_event_unittest.h"
6 6
7 #include <cstdlib> 7 #include <cstdlib>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
11 #include "base/debug/trace_event.h" 11 #include "base/debug/trace_event.h"
12 #include "base/debug/trace_event_synthetic_delay.h"
12 #include "base/json/json_reader.h" 13 #include "base/json/json_reader.h"
13 #include "base/json/json_writer.h" 14 #include "base/json/json_writer.h"
14 #include "base/memory/ref_counted_memory.h" 15 #include "base/memory/ref_counted_memory.h"
15 #include "base/memory/scoped_ptr.h" 16 #include "base/memory/scoped_ptr.h"
16 #include "base/memory/singleton.h" 17 #include "base/memory/singleton.h"
17 #include "base/process/process_handle.h" 18 #include "base/process/process_handle.h"
18 #include "base/strings/stringprintf.h" 19 #include "base/strings/stringprintf.h"
19 #include "base/synchronization/waitable_event.h" 20 #include "base/synchronization/waitable_event.h"
20 #include "base/threading/platform_thread.h" 21 #include "base/threading/platform_thread.h"
21 #include "base/threading/thread.h" 22 #include "base/threading/thread.h"
(...skipping 2605 matching lines...) Expand 10 before | Expand all | Expand 10 after
2627 const DictionaryValue* item; 2628 const DictionaryValue* item;
2628 EXPECT_TRUE(trace_parsed_.GetDictionary(i, &item)); 2629 EXPECT_TRUE(trace_parsed_.GetDictionary(i, &item));
2629 double timestamp; 2630 double timestamp;
2630 EXPECT_TRUE(item->GetDouble("ts", &timestamp)); 2631 EXPECT_TRUE(item->GetDouble("ts", &timestamp));
2631 EXPECT_GE(timestamp, last_timestamp); 2632 EXPECT_GE(timestamp, last_timestamp);
2632 EXPECT_LE(timestamp, end_time); 2633 EXPECT_LE(timestamp, end_time);
2633 last_timestamp = timestamp; 2634 last_timestamp = timestamp;
2634 } 2635 }
2635 } 2636 }
2636 2637
2638 TEST_F(TraceEventTestFixture, ConfigureSyntheticDelays) {
2639 BeginSpecificTrace("DELAY(test.Delay;0.05)");
2640
2641 base::TimeTicks start = base::TimeTicks::Now();
2642 {
2643 TRACE_EVENT_SYNTHETIC_DELAY("test.Delay");
2644 }
2645 base::TimeDelta duration = base::TimeTicks::Now() - start;
2646 EXPECT_GE(duration.InMilliseconds(), 50);
2647
2648 EndTraceAndFlush();
2649 }
2650
2651 TEST_F(TraceEventTestFixture, BadSyntheticDelayConfigurations) {
2652 const char* configs[] = {
2653 "",
2654 "DELAY(",
2655 "DELAY(;",
2656 "DELAY(;)",
2657 "DELAY(test.Delay)",
2658 "DELAY(test.Delay;)"
2659 };
2660 for (size_t i = 0; i < arraysize(configs); i++) {
2661 BeginSpecificTrace(configs[i]);
2662 EndTraceAndFlush();
2663 CategoryFilter filter = TraceLog::GetInstance()->GetCurrentCategoryFilter();
2664 EXPECT_EQ(0u, filter.GetSyntheticDelayValues().size());
2665 }
2666 }
2667
2668 TEST_F(TraceEventTestFixture, SyntheticDelayConfigurationMerging) {
2669 CategoryFilter filter1("DELAY(test.Delay1;16)");
2670 CategoryFilter filter2("DELAY(test.Delay2;32)");
2671 filter1.Merge(filter2);
2672 EXPECT_EQ(2u, filter1.GetSyntheticDelayValues().size());
2673 }
2674
2675 TEST_F(TraceEventTestFixture, SyntheticDelayConfigurationToString) {
2676 const char config[] = "DELAY(test.Delay;16;oneshot)";
2677 CategoryFilter filter(config);
2678 EXPECT_EQ(config, filter.ToString());
2679 }
2680
2637 } // namespace debug 2681 } // namespace debug
2638 } // namespace base 2682 } // namespace base
OLDNEW
« no previous file with comments | « base/debug/trace_event_synthetic_delay_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698