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 2590 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2601 } | 2601 } |
2602 for (size_t i = 0; i < num_chunks; ++i) | 2602 for (size_t i = 0; i < num_chunks; ++i) |
2603 buffer->ReturnChunk(i, scoped_ptr<TraceBufferChunk>(chunks[i])); | 2603 buffer->ReturnChunk(i, scoped_ptr<TraceBufferChunk>(chunks[i])); |
2604 | 2604 |
2605 for (size_t i = 0; i < num_chunks; ++i) | 2605 for (size_t i = 0; i < num_chunks; ++i) |
2606 EXPECT_TRUE(chunks[i] == buffer->NextChunk()); | 2606 EXPECT_TRUE(chunks[i] == buffer->NextChunk()); |
2607 EXPECT_FALSE(buffer->NextChunk()); | 2607 EXPECT_FALSE(buffer->NextChunk()); |
2608 TraceLog::GetInstance()->SetDisabled(); | 2608 TraceLog::GetInstance()->SetDisabled(); |
2609 } | 2609 } |
2610 | 2610 |
| 2611 TEST_F(TraceEventTestFixture, TraceRecordAsMuchAsPossibleMode) { |
| 2612 TraceLog::GetInstance()->SetEnabled(CategoryFilter("*"), |
| 2613 TraceLog::RECORDING_MODE, |
| 2614 TraceOptions(RECORD_AS_MUCH_AS_POSSIBLE)); |
| 2615 TraceBuffer* buffer = TraceLog::GetInstance()->trace_buffer(); |
| 2616 EXPECT_EQ(512000000UL, buffer->Capacity()); |
| 2617 TraceLog::GetInstance()->SetDisabled(); |
| 2618 } |
| 2619 |
2611 // Test the category filter. | 2620 // Test the category filter. |
2612 TEST_F(TraceEventTestFixture, CategoryFilter) { | 2621 TEST_F(TraceEventTestFixture, CategoryFilter) { |
2613 // Using the default filter. | 2622 // Using the default filter. |
2614 CategoryFilter default_cf = CategoryFilter( | 2623 CategoryFilter default_cf = CategoryFilter( |
2615 CategoryFilter::kDefaultCategoryFilterString); | 2624 CategoryFilter::kDefaultCategoryFilterString); |
2616 std::string category_filter_str = default_cf.ToString(); | 2625 std::string category_filter_str = default_cf.ToString(); |
2617 EXPECT_STREQ("-*Debug,-*Test", category_filter_str.c_str()); | 2626 EXPECT_STREQ("-*Debug,-*Test", category_filter_str.c_str()); |
2618 EXPECT_TRUE(default_cf.IsCategoryGroupEnabled("not-excluded-category")); | 2627 EXPECT_TRUE(default_cf.IsCategoryGroupEnabled("not-excluded-category")); |
2619 EXPECT_FALSE( | 2628 EXPECT_FALSE( |
2620 default_cf.IsCategoryGroupEnabled("disabled-by-default-category")); | 2629 default_cf.IsCategoryGroupEnabled("disabled-by-default-category")); |
(...skipping 383 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3004 options = TraceOptions(RECORD_CONTINUOUSLY); | 3013 options = TraceOptions(RECORD_CONTINUOUSLY); |
3005 EXPECT_EQ(RECORD_CONTINUOUSLY, options.record_mode); | 3014 EXPECT_EQ(RECORD_CONTINUOUSLY, options.record_mode); |
3006 EXPECT_FALSE(options.enable_sampling); | 3015 EXPECT_FALSE(options.enable_sampling); |
3007 EXPECT_FALSE(options.enable_systrace); | 3016 EXPECT_FALSE(options.enable_systrace); |
3008 | 3017 |
3009 options = TraceOptions("trace-to-console"); | 3018 options = TraceOptions("trace-to-console"); |
3010 EXPECT_EQ(ECHO_TO_CONSOLE, options.record_mode); | 3019 EXPECT_EQ(ECHO_TO_CONSOLE, options.record_mode); |
3011 EXPECT_FALSE(options.enable_sampling); | 3020 EXPECT_FALSE(options.enable_sampling); |
3012 EXPECT_FALSE(options.enable_systrace); | 3021 EXPECT_FALSE(options.enable_systrace); |
3013 | 3022 |
| 3023 options = TraceOptions("record-as-much-as-possible"); |
| 3024 EXPECT_EQ(RECORD_AS_MUCH_AS_POSSIBLE, options.record_mode); |
| 3025 EXPECT_FALSE(options.enable_sampling); |
| 3026 EXPECT_FALSE(options.enable_systrace); |
| 3027 |
3014 options = TraceOptions("record-until-full, enable-sampling"); | 3028 options = TraceOptions("record-until-full, enable-sampling"); |
3015 EXPECT_EQ(RECORD_UNTIL_FULL, options.record_mode); | 3029 EXPECT_EQ(RECORD_UNTIL_FULL, options.record_mode); |
3016 EXPECT_TRUE(options.enable_sampling); | 3030 EXPECT_TRUE(options.enable_sampling); |
3017 EXPECT_FALSE(options.enable_systrace); | 3031 EXPECT_FALSE(options.enable_systrace); |
3018 | 3032 |
3019 options = TraceOptions("enable-systrace,record-continuously"); | 3033 options = TraceOptions("enable-systrace,record-continuously"); |
3020 EXPECT_EQ(RECORD_CONTINUOUSLY, options.record_mode); | 3034 EXPECT_EQ(RECORD_CONTINUOUSLY, options.record_mode); |
3021 EXPECT_FALSE(options.enable_sampling); | 3035 EXPECT_FALSE(options.enable_sampling); |
3022 EXPECT_TRUE(options.enable_systrace); | 3036 EXPECT_TRUE(options.enable_systrace); |
3023 | 3037 |
(...skipping 14 matching lines...) Expand all Loading... |
3038 EXPECT_FALSE(options.enable_sampling); | 3052 EXPECT_FALSE(options.enable_sampling); |
3039 | 3053 |
3040 #if GTEST_HAS_EXCEPTIONS | 3054 #if GTEST_HAS_EXCEPTIONS |
3041 EXPECT_THROW(TraceOptions("foo-bar-baz"), int); | 3055 EXPECT_THROW(TraceOptions("foo-bar-baz"), int); |
3042 #endif | 3056 #endif |
3043 } | 3057 } |
3044 | 3058 |
3045 TEST(TraceOptionsTest, TraceOptionsToString) { | 3059 TEST(TraceOptionsTest, TraceOptionsToString) { |
3046 // Test that we can intialize TraceOptions from a string got from | 3060 // Test that we can intialize TraceOptions from a string got from |
3047 // TraceOptions.ToString() method to get a same TraceOptions. | 3061 // TraceOptions.ToString() method to get a same TraceOptions. |
3048 TraceRecordMode modes[] = { | 3062 TraceRecordMode modes[] = {RECORD_UNTIL_FULL, |
3049 RECORD_UNTIL_FULL, RECORD_CONTINUOUSLY, ECHO_TO_CONSOLE}; | 3063 RECORD_CONTINUOUSLY, |
| 3064 ECHO_TO_CONSOLE, |
| 3065 RECORD_AS_MUCH_AS_POSSIBLE}; |
3050 bool enable_sampling_options[] = {true, false}; | 3066 bool enable_sampling_options[] = {true, false}; |
3051 bool enable_systrace_options[] = {true, false}; | 3067 bool enable_systrace_options[] = {true, false}; |
3052 | 3068 |
3053 for (int i = 0; i < 3; ++i) { | 3069 for (int i = 0; i < 4; ++i) { |
3054 for (int j = 0; j < 2; ++j) { | 3070 for (int j = 0; j < 2; ++j) { |
3055 for (int k = 0; k < 2; ++k) { | 3071 for (int k = 0; k < 2; ++k) { |
3056 TraceOptions original_option = TraceOptions(modes[i]); | 3072 TraceOptions original_option = TraceOptions(modes[i]); |
3057 original_option.enable_sampling = enable_sampling_options[j]; | 3073 original_option.enable_sampling = enable_sampling_options[j]; |
3058 original_option.enable_systrace = enable_systrace_options[k]; | 3074 original_option.enable_systrace = enable_systrace_options[k]; |
3059 TraceOptions new_options = TraceOptions(original_option.ToString()); | 3075 TraceOptions new_options = TraceOptions(original_option.ToString()); |
3060 EXPECT_EQ(original_option.record_mode, new_options.record_mode); | 3076 EXPECT_EQ(original_option.record_mode, new_options.record_mode); |
3061 EXPECT_EQ(original_option.enable_sampling, new_options.enable_sampling); | 3077 EXPECT_EQ(original_option.enable_sampling, new_options.enable_sampling); |
3062 EXPECT_EQ(original_option.enable_systrace, new_options.enable_systrace); | 3078 EXPECT_EQ(original_option.enable_systrace, new_options.enable_systrace); |
3063 } | 3079 } |
3064 } | 3080 } |
3065 } | 3081 } |
3066 } | 3082 } |
3067 | 3083 |
3068 | 3084 |
3069 } // namespace debug | 3085 } // namespace debug |
3070 } // namespace base | 3086 } // namespace base |
OLD | NEW |