| 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" | 5 #include "base/debug/trace_event_unittest.h" |
| 6 | 6 |
| 7 #include <math.h> | 7 #include <math.h> |
| 8 #include <cstdlib> | 8 #include <cstdlib> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 2992 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3003 filter1.Merge(filter2); | 3003 filter1.Merge(filter2); |
| 3004 EXPECT_EQ(2u, filter1.GetSyntheticDelayValues().size()); | 3004 EXPECT_EQ(2u, filter1.GetSyntheticDelayValues().size()); |
| 3005 } | 3005 } |
| 3006 | 3006 |
| 3007 TEST_F(TraceEventTestFixture, SyntheticDelayConfigurationToString) { | 3007 TEST_F(TraceEventTestFixture, SyntheticDelayConfigurationToString) { |
| 3008 const char config[] = "DELAY(test.Delay;16;oneshot)"; | 3008 const char config[] = "DELAY(test.Delay;16;oneshot)"; |
| 3009 CategoryFilter filter(config); | 3009 CategoryFilter filter(config); |
| 3010 EXPECT_EQ(config, filter.ToString()); | 3010 EXPECT_EQ(config, filter.ToString()); |
| 3011 } | 3011 } |
| 3012 | 3012 |
| 3013 TEST_F(TraceEventTestFixture, AddCustomTraceEvent) { |
| 3014 TraceLog* const tracer = TraceLog::GetInstance(); |
| 3015 // Make sure old events are flushed. |
| 3016 EndTraceAndFlush(); |
| 3017 EXPECT_EQ(0u, tracer->GetEventsSize()); |
| 3018 const unsigned char* category_group_enabled = |
| 3019 TRACE_EVENT_API_GET_CATEGORY_GROUP_ENABLED("Java"); |
| 3020 |
| 3021 { |
| 3022 BeginTrace(); |
| 3023 EXPECT_TRUE(TraceLog::IsCategoryGroupEnabledForRecordingMode( |
| 3024 category_group_enabled)); |
| 3025 TraceEventHandle handle = tracer->AddCustomTraceEvent( |
| 3026 TRACE_EVENT_PHASE_BEGIN, category_group_enabled, "name1", 0, |
| 3027 base::TimeTicks::Now()); |
| 3028 size_t num_events = tracer->GetEventsSize(); |
| 3029 EXPECT_GT(num_events, 1u); |
| 3030 const TraceEvent* event1 = tracer->GetEventByHandle(handle); |
| 3031 ASSERT_TRUE(event1); |
| 3032 EXPECT_STREQ("name1", event1->name()); |
| 3033 EXPECT_TRUE(event1->parameter_copy_storage() != NULL); |
| 3034 EXPECT_GT(event1->parameter_copy_storage()->size(), 0u); |
| 3035 EndTraceAndFlush(); |
| 3036 } |
| 3037 } |
| 3038 |
| 3013 TEST(TraceOptionsTest, TraceOptionsFromString) { | 3039 TEST(TraceOptionsTest, TraceOptionsFromString) { |
| 3014 TraceOptions options; | 3040 TraceOptions options; |
| 3015 EXPECT_TRUE(options.SetFromString("record-until-full")); | 3041 EXPECT_TRUE(options.SetFromString("record-until-full")); |
| 3016 EXPECT_EQ(RECORD_UNTIL_FULL, options.record_mode); | 3042 EXPECT_EQ(RECORD_UNTIL_FULL, options.record_mode); |
| 3017 EXPECT_FALSE(options.enable_sampling); | 3043 EXPECT_FALSE(options.enable_sampling); |
| 3018 EXPECT_FALSE(options.enable_systrace); | 3044 EXPECT_FALSE(options.enable_systrace); |
| 3019 | 3045 |
| 3020 EXPECT_TRUE(options.SetFromString("record-continuously")); | 3046 EXPECT_TRUE(options.SetFromString("record-continuously")); |
| 3021 EXPECT_EQ(RECORD_CONTINUOUSLY, options.record_mode); | 3047 EXPECT_EQ(RECORD_CONTINUOUSLY, options.record_mode); |
| 3022 EXPECT_FALSE(options.enable_sampling); | 3048 EXPECT_FALSE(options.enable_sampling); |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3081 TraceOptions new_options; | 3107 TraceOptions new_options; |
| 3082 EXPECT_TRUE(new_options.SetFromString(original_option.ToString())); | 3108 EXPECT_TRUE(new_options.SetFromString(original_option.ToString())); |
| 3083 EXPECT_EQ(original_option.record_mode, new_options.record_mode); | 3109 EXPECT_EQ(original_option.record_mode, new_options.record_mode); |
| 3084 EXPECT_EQ(original_option.enable_sampling, new_options.enable_sampling); | 3110 EXPECT_EQ(original_option.enable_sampling, new_options.enable_sampling); |
| 3085 EXPECT_EQ(original_option.enable_systrace, new_options.enable_systrace); | 3111 EXPECT_EQ(original_option.enable_systrace, new_options.enable_systrace); |
| 3086 } | 3112 } |
| 3087 } | 3113 } |
| 3088 } | 3114 } |
| 3089 } | 3115 } |
| 3090 | 3116 |
| 3091 | |
| 3092 } // namespace debug | 3117 } // namespace debug |
| 3093 } // namespace base | 3118 } // namespace base |
| OLD | NEW |