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

Side by Side Diff: base/trace_event/trace_options_unittest.cc

Issue 1165673002: [Startup Tracing] Hook up TraceConfig and remove CategoryFilter & TraceOptions (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 5 years, 6 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/trace_event/trace_options.cc ('k') | chrome/browser/lifetime/application_lifetime.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "base/trace_event/trace_options.h"
6 #include "testing/gtest/include/gtest/gtest.h"
7
8 namespace base {
9 namespace trace_event {
10
11 TEST(TraceOptionsTest, TraceOptionsFromString) {
12 TraceOptions options;
13 EXPECT_TRUE(options.SetFromString("record-until-full"));
14 EXPECT_EQ(RECORD_UNTIL_FULL, options.record_mode);
15 EXPECT_FALSE(options.enable_sampling);
16 EXPECT_FALSE(options.enable_systrace);
17
18 EXPECT_TRUE(options.SetFromString("record-continuously"));
19 EXPECT_EQ(RECORD_CONTINUOUSLY, options.record_mode);
20 EXPECT_FALSE(options.enable_sampling);
21 EXPECT_FALSE(options.enable_systrace);
22
23 EXPECT_TRUE(options.SetFromString("trace-to-console"));
24 EXPECT_EQ(ECHO_TO_CONSOLE, options.record_mode);
25 EXPECT_FALSE(options.enable_sampling);
26 EXPECT_FALSE(options.enable_systrace);
27
28 EXPECT_TRUE(options.SetFromString("record-as-much-as-possible"));
29 EXPECT_EQ(RECORD_AS_MUCH_AS_POSSIBLE, options.record_mode);
30 EXPECT_FALSE(options.enable_sampling);
31 EXPECT_FALSE(options.enable_systrace);
32
33 EXPECT_TRUE(options.SetFromString("record-until-full, enable-sampling"));
34 EXPECT_EQ(RECORD_UNTIL_FULL, options.record_mode);
35 EXPECT_TRUE(options.enable_sampling);
36 EXPECT_FALSE(options.enable_systrace);
37
38 EXPECT_TRUE(options.SetFromString("enable-systrace,record-continuously"));
39 EXPECT_EQ(RECORD_CONTINUOUSLY, options.record_mode);
40 EXPECT_FALSE(options.enable_sampling);
41 EXPECT_TRUE(options.enable_systrace);
42
43 EXPECT_TRUE(options.SetFromString(
44 "enable-systrace, trace-to-console,enable-sampling"));
45 EXPECT_EQ(ECHO_TO_CONSOLE, options.record_mode);
46 EXPECT_TRUE(options.enable_sampling);
47 EXPECT_TRUE(options.enable_systrace);
48
49 EXPECT_TRUE(options.SetFromString(
50 "record-continuously,record-until-full,trace-to-console"));
51 EXPECT_EQ(ECHO_TO_CONSOLE, options.record_mode);
52 EXPECT_FALSE(options.enable_systrace);
53 EXPECT_FALSE(options.enable_sampling);
54
55 EXPECT_TRUE(options.SetFromString(""));
56 EXPECT_EQ(RECORD_UNTIL_FULL, options.record_mode);
57 EXPECT_FALSE(options.enable_systrace);
58 EXPECT_FALSE(options.enable_sampling);
59
60 EXPECT_FALSE(options.SetFromString("foo-bar-baz"));
61 }
62
63 TEST(TraceOptionsTest, TraceOptionsToString) {
64 // Test that we can intialize TraceOptions from a string got from
65 // TraceOptions.ToString() method to get a same TraceOptions.
66 TraceRecordMode modes[] = {RECORD_UNTIL_FULL,
67 RECORD_CONTINUOUSLY,
68 ECHO_TO_CONSOLE,
69 RECORD_AS_MUCH_AS_POSSIBLE};
70 bool enable_sampling_options[] = {true, false};
71 bool enable_systrace_options[] = {true, false};
72
73 for (int i = 0; i < 4; ++i) {
74 for (int j = 0; j < 2; ++j) {
75 for (int k = 0; k < 2; ++k) {
76 TraceOptions original_option = TraceOptions(modes[i]);
77 original_option.enable_sampling = enable_sampling_options[j];
78 original_option.enable_systrace = enable_systrace_options[k];
79 TraceOptions new_options;
80 EXPECT_TRUE(new_options.SetFromString(original_option.ToString()));
81 EXPECT_EQ(original_option.record_mode, new_options.record_mode);
82 EXPECT_EQ(original_option.enable_sampling, new_options.enable_sampling);
83 EXPECT_EQ(original_option.enable_systrace, new_options.enable_systrace);
84 }
85 }
86 }
87 }
88
89 } // namespace trace_event
90 } // namespace base
OLDNEW
« no previous file with comments | « base/trace_event/trace_options.cc ('k') | chrome/browser/lifetime/application_lifetime.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698