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 "base/debug/trace_event_unittest.h" | |
6 | |
7 #include <math.h> | 5 #include <math.h> |
8 #include <cstdlib> | 6 #include <cstdlib> |
9 | 7 |
10 #include "base/bind.h" | 8 #include "base/bind.h" |
11 #include "base/command_line.h" | 9 #include "base/command_line.h" |
12 #include "base/debug/trace_event.h" | |
13 #include "base/debug/trace_event_synthetic_delay.h" | |
14 #include "base/json/json_reader.h" | 10 #include "base/json/json_reader.h" |
15 #include "base/json/json_writer.h" | 11 #include "base/json/json_writer.h" |
16 #include "base/memory/ref_counted_memory.h" | 12 #include "base/memory/ref_counted_memory.h" |
17 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
18 #include "base/memory/singleton.h" | 14 #include "base/memory/singleton.h" |
19 #include "base/process/process_handle.h" | 15 #include "base/process/process_handle.h" |
20 #include "base/strings/stringprintf.h" | 16 #include "base/strings/stringprintf.h" |
21 #include "base/synchronization/waitable_event.h" | 17 #include "base/synchronization/waitable_event.h" |
22 #include "base/threading/platform_thread.h" | 18 #include "base/threading/platform_thread.h" |
23 #include "base/threading/thread.h" | 19 #include "base/threading/thread.h" |
24 #include "base/time/time.h" | 20 #include "base/time/time.h" |
| 21 #include "base/trace_event/trace_event.h" |
| 22 #include "base/trace_event/trace_event_synthetic_delay.h" |
25 #include "base/values.h" | 23 #include "base/values.h" |
26 #include "testing/gmock/include/gmock/gmock.h" | 24 #include "testing/gmock/include/gmock/gmock.h" |
27 #include "testing/gtest/include/gtest/gtest.h" | 25 #include "testing/gtest/include/gtest/gtest.h" |
28 | 26 |
29 namespace base { | 27 namespace base { |
30 namespace debug { | 28 namespace debug { |
31 | 29 |
32 namespace { | 30 namespace { |
33 | 31 |
34 enum CompareOp { | 32 enum CompareOp { |
(...skipping 829 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
864 EXPECT_FALSE(results[-1][-1]); | 862 EXPECT_FALSE(results[-1][-1]); |
865 for (int thread = 0; thread < num_threads; thread++) { | 863 for (int thread = 0; thread < num_threads; thread++) { |
866 for (int event = 0; event < num_events; event++) { | 864 for (int event = 0; event < num_events; event++) { |
867 EXPECT_TRUE(results[thread][event]); | 865 EXPECT_TRUE(results[thread][event]); |
868 } | 866 } |
869 } | 867 } |
870 } | 868 } |
871 | 869 |
872 } // namespace | 870 } // namespace |
873 | 871 |
874 void HighResSleepForTraceTest(base::TimeDelta elapsed) { | |
875 base::TimeTicks end_time = base::TimeTicks::HighResNow() + elapsed; | |
876 do { | |
877 base::PlatformThread::Sleep(base::TimeDelta::FromMilliseconds(1)); | |
878 } while (base::TimeTicks::HighResNow() < end_time); | |
879 } | |
880 | |
881 // Simple Test for emitting data and validating it was received. | 872 // Simple Test for emitting data and validating it was received. |
882 TEST_F(TraceEventTestFixture, DataCaptured) { | 873 TEST_F(TraceEventTestFixture, DataCaptured) { |
883 TraceLog::GetInstance()->SetEnabled( | 874 TraceLog::GetInstance()->SetEnabled( |
884 CategoryFilter("*"), | 875 CategoryFilter("*"), |
885 TraceLog::RECORDING_MODE, | 876 TraceLog::RECORDING_MODE, |
886 TraceOptions()); | 877 TraceOptions()); |
887 | 878 |
888 TraceWithAllMacroVariants(NULL); | 879 TraceWithAllMacroVariants(NULL); |
889 | 880 |
890 EndTraceAndFlush(); | 881 EndTraceAndFlush(); |
(...skipping 2193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3084 EXPECT_EQ(original_option.enable_sampling, new_options.enable_sampling); | 3075 EXPECT_EQ(original_option.enable_sampling, new_options.enable_sampling); |
3085 EXPECT_EQ(original_option.enable_systrace, new_options.enable_systrace); | 3076 EXPECT_EQ(original_option.enable_systrace, new_options.enable_systrace); |
3086 } | 3077 } |
3087 } | 3078 } |
3088 } | 3079 } |
3089 } | 3080 } |
3090 | 3081 |
3091 | 3082 |
3092 } // namespace debug | 3083 } // namespace debug |
3093 } // namespace base | 3084 } // namespace base |
OLD | NEW |