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

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

Issue 443523003: Remove TraceOptions string based constructor. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 6 years, 4 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/debug/trace_event_impl.cc ('k') | components/tracing/child_trace_message_filter.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/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 2980 matching lines...) Expand 10 before | Expand all | Expand 10 after
2991 filter1.Merge(filter2); 2991 filter1.Merge(filter2);
2992 EXPECT_EQ(2u, filter1.GetSyntheticDelayValues().size()); 2992 EXPECT_EQ(2u, filter1.GetSyntheticDelayValues().size());
2993 } 2993 }
2994 2994
2995 TEST_F(TraceEventTestFixture, SyntheticDelayConfigurationToString) { 2995 TEST_F(TraceEventTestFixture, SyntheticDelayConfigurationToString) {
2996 const char config[] = "DELAY(test.Delay;16;oneshot)"; 2996 const char config[] = "DELAY(test.Delay;16;oneshot)";
2997 CategoryFilter filter(config); 2997 CategoryFilter filter(config);
2998 EXPECT_EQ(config, filter.ToString()); 2998 EXPECT_EQ(config, filter.ToString());
2999 } 2999 }
3000 3000
3001 TEST(TraceOptionsTest, DISABLED_TraceOptionsFromString) { 3001 TEST(TraceOptionsTest, TraceOptionsFromString) {
3002 TraceOptions options = TraceOptions("record-until-full"); 3002 TraceOptions options;
3003 EXPECT_TRUE(options.SetFromString("record-until-full"));
3003 EXPECT_EQ(RECORD_UNTIL_FULL, options.record_mode); 3004 EXPECT_EQ(RECORD_UNTIL_FULL, options.record_mode);
3004 EXPECT_FALSE(options.enable_sampling); 3005 EXPECT_FALSE(options.enable_sampling);
3005 EXPECT_FALSE(options.enable_systrace); 3006 EXPECT_FALSE(options.enable_systrace);
3006 3007
3007 options = TraceOptions(RECORD_CONTINUOUSLY); 3008 EXPECT_TRUE(options.SetFromString("record-continuously"));
3008 EXPECT_EQ(RECORD_CONTINUOUSLY, options.record_mode); 3009 EXPECT_EQ(RECORD_CONTINUOUSLY, options.record_mode);
3009 EXPECT_FALSE(options.enable_sampling); 3010 EXPECT_FALSE(options.enable_sampling);
3010 EXPECT_FALSE(options.enable_systrace); 3011 EXPECT_FALSE(options.enable_systrace);
3011 3012
3012 options = TraceOptions("trace-to-console"); 3013 EXPECT_TRUE(options.SetFromString("trace-to-console"));
3013 EXPECT_EQ(ECHO_TO_CONSOLE, options.record_mode); 3014 EXPECT_EQ(ECHO_TO_CONSOLE, options.record_mode);
3014 EXPECT_FALSE(options.enable_sampling); 3015 EXPECT_FALSE(options.enable_sampling);
3015 EXPECT_FALSE(options.enable_systrace); 3016 EXPECT_FALSE(options.enable_systrace);
3016 3017
3017 options = TraceOptions("record-as-much-as-possible"); 3018 EXPECT_TRUE(options.SetFromString("record-as-much-as-possible"));
3018 EXPECT_EQ(RECORD_AS_MUCH_AS_POSSIBLE, options.record_mode); 3019 EXPECT_EQ(RECORD_AS_MUCH_AS_POSSIBLE, options.record_mode);
3019 EXPECT_FALSE(options.enable_sampling); 3020 EXPECT_FALSE(options.enable_sampling);
3020 EXPECT_FALSE(options.enable_systrace); 3021 EXPECT_FALSE(options.enable_systrace);
3021 3022
3022 options = TraceOptions("record-until-full, enable-sampling"); 3023 EXPECT_TRUE(options.SetFromString("record-until-full, enable-sampling"));
3023 EXPECT_EQ(RECORD_UNTIL_FULL, options.record_mode); 3024 EXPECT_EQ(RECORD_UNTIL_FULL, options.record_mode);
3024 EXPECT_TRUE(options.enable_sampling); 3025 EXPECT_TRUE(options.enable_sampling);
3025 EXPECT_FALSE(options.enable_systrace); 3026 EXPECT_FALSE(options.enable_systrace);
3026 3027
3027 options = TraceOptions("enable-systrace,record-continuously"); 3028 EXPECT_TRUE(options.SetFromString("enable-systrace,record-continuously"));
3028 EXPECT_EQ(RECORD_CONTINUOUSLY, options.record_mode); 3029 EXPECT_EQ(RECORD_CONTINUOUSLY, options.record_mode);
3029 EXPECT_FALSE(options.enable_sampling); 3030 EXPECT_FALSE(options.enable_sampling);
3030 EXPECT_TRUE(options.enable_systrace); 3031 EXPECT_TRUE(options.enable_systrace);
3031 3032
3032 options = TraceOptions("enable-systrace, trace-to-console,enable-sampling"); 3033 EXPECT_TRUE(options.SetFromString(
3034 "enable-systrace, trace-to-console,enable-sampling"));
3033 EXPECT_EQ(ECHO_TO_CONSOLE, options.record_mode); 3035 EXPECT_EQ(ECHO_TO_CONSOLE, options.record_mode);
3034 EXPECT_TRUE(options.enable_sampling); 3036 EXPECT_TRUE(options.enable_sampling);
3035 EXPECT_TRUE(options.enable_systrace); 3037 EXPECT_TRUE(options.enable_systrace);
3036 3038
3037 options = 3039 EXPECT_TRUE(options.SetFromString(
3038 TraceOptions("record-continuously,record-until-full,trace-to-console"); 3040 "record-continuously,record-until-full,trace-to-console"));
3039 EXPECT_EQ(ECHO_TO_CONSOLE, options.record_mode); 3041 EXPECT_EQ(ECHO_TO_CONSOLE, options.record_mode);
3040 EXPECT_FALSE(options.enable_systrace); 3042 EXPECT_FALSE(options.enable_systrace);
3041 EXPECT_FALSE(options.enable_sampling); 3043 EXPECT_FALSE(options.enable_sampling);
3042 3044
3043 options = TraceOptions(""); 3045 EXPECT_TRUE(options.SetFromString(""));
3044 EXPECT_EQ(RECORD_UNTIL_FULL, options.record_mode); 3046 EXPECT_EQ(RECORD_UNTIL_FULL, options.record_mode);
3045 EXPECT_FALSE(options.enable_systrace); 3047 EXPECT_FALSE(options.enable_systrace);
3046 EXPECT_FALSE(options.enable_sampling); 3048 EXPECT_FALSE(options.enable_sampling);
3047 3049
3048 #if GTEST_HAS_EXCEPTIONS 3050 EXPECT_FALSE(options.SetFromString("foo-bar-baz"));
3049 EXPECT_THROW(TraceOptions("foo-bar-baz"), int);
3050 #endif
3051 } 3051 }
3052 3052
3053 TEST(TraceOptionsTest, TraceOptionsToString) { 3053 TEST(TraceOptionsTest, TraceOptionsToString) {
3054 // Test that we can intialize TraceOptions from a string got from 3054 // Test that we can intialize TraceOptions from a string got from
3055 // TraceOptions.ToString() method to get a same TraceOptions. 3055 // TraceOptions.ToString() method to get a same TraceOptions.
3056 TraceRecordMode modes[] = {RECORD_UNTIL_FULL, 3056 TraceRecordMode modes[] = {RECORD_UNTIL_FULL,
3057 RECORD_CONTINUOUSLY, 3057 RECORD_CONTINUOUSLY,
3058 ECHO_TO_CONSOLE, 3058 ECHO_TO_CONSOLE,
3059 RECORD_AS_MUCH_AS_POSSIBLE}; 3059 RECORD_AS_MUCH_AS_POSSIBLE};
3060 bool enable_sampling_options[] = {true, false}; 3060 bool enable_sampling_options[] = {true, false};
3061 bool enable_systrace_options[] = {true, false}; 3061 bool enable_systrace_options[] = {true, false};
3062 3062
3063 for (int i = 0; i < 4; ++i) { 3063 for (int i = 0; i < 4; ++i) {
3064 for (int j = 0; j < 2; ++j) { 3064 for (int j = 0; j < 2; ++j) {
3065 for (int k = 0; k < 2; ++k) { 3065 for (int k = 0; k < 2; ++k) {
3066 TraceOptions original_option = TraceOptions(modes[i]); 3066 TraceOptions original_option = TraceOptions(modes[i]);
3067 original_option.enable_sampling = enable_sampling_options[j]; 3067 original_option.enable_sampling = enable_sampling_options[j];
3068 original_option.enable_systrace = enable_systrace_options[k]; 3068 original_option.enable_systrace = enable_systrace_options[k];
3069 TraceOptions new_options = TraceOptions(original_option.ToString()); 3069 TraceOptions new_options;
3070 EXPECT_TRUE(new_options.SetFromString(original_option.ToString()));
3070 EXPECT_EQ(original_option.record_mode, new_options.record_mode); 3071 EXPECT_EQ(original_option.record_mode, new_options.record_mode);
3071 EXPECT_EQ(original_option.enable_sampling, new_options.enable_sampling); 3072 EXPECT_EQ(original_option.enable_sampling, new_options.enable_sampling);
3072 EXPECT_EQ(original_option.enable_systrace, new_options.enable_systrace); 3073 EXPECT_EQ(original_option.enable_systrace, new_options.enable_systrace);
3073 } 3074 }
3074 } 3075 }
3075 } 3076 }
3076 } 3077 }
3077 3078
3078 3079
3079 } // namespace debug 3080 } // namespace debug
3080 } // namespace base 3081 } // namespace base
OLDNEW
« no previous file with comments | « base/debug/trace_event_impl.cc ('k') | components/tracing/child_trace_message_filter.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698