OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/json/json_reader.h" | 5 #include "base/json/json_reader.h" |
6 #include "base/trace_event/trace_config.h" | 6 #include "base/trace_event/trace_config.h" |
7 #include "base/values.h" | 7 #include "base/values.h" |
8 #include "content/browser/devtools/protocol/tracing_handler.h" | 8 #include "content/browser/devtools/protocol/tracing_handler.h" |
9 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
10 | 10 |
11 namespace content { | 11 namespace content { |
12 namespace devtools { | 12 namespace devtools { |
13 namespace tracing { | 13 namespace tracing { |
14 | 14 |
15 namespace { | 15 namespace { |
16 | 16 |
17 const char kCustomTraceConfigString[] = | 17 const char kCustomTraceConfigString[] = |
18 "{" | 18 "{" |
19 "\"enable_argument_filter\":true," | 19 "\"enable_argument_filter\":true," |
20 "\"enable_sampling\":true," | 20 "\"enable_sampling\":true," |
21 "\"enable_systrace\":true," | 21 "\"enable_systrace\":true," |
22 "\"excluded_categories\":[\"excluded\",\"exc_pattern*\"]," | 22 "\"excluded_categories\":[\"excluded\",\"exc_pattern*\"]," |
23 "\"included_categories\":[\"included\"," | 23 "\"included_categories\":[\"included\"," |
24 "\"inc_pattern*\"," | 24 "\"inc_pattern*\"," |
25 "\"disabled-by-default-cc\"," | 25 "\"disabled-by-default-cc\"," |
26 "\"disabled-by-default-memory-infra\"]," | 26 "\"disabled-by-default-memory-infra\"]," |
27 "\"memory_dump_config\":{" | 27 "\"memory_dump_config\":{" |
| 28 "\"heap_profiler_options\":{" |
| 29 "\"breakdown_threshold_bytes\":10240" |
| 30 "}," |
28 "\"triggers\":[" | 31 "\"triggers\":[" |
29 "{\"mode\":\"light\",\"periodic_interval_ms\":50}," | 32 "{\"mode\":\"light\",\"periodic_interval_ms\":50}," |
30 "{\"mode\":\"detailed\",\"periodic_interval_ms\":1000}" | 33 "{\"mode\":\"detailed\",\"periodic_interval_ms\":1000}" |
31 "]" | 34 "]" |
32 "}," | 35 "}," |
33 "\"record_mode\":\"record-continuously\"," | 36 "\"record_mode\":\"record-continuously\"," |
34 "\"synthetic_delays\":[\"test.Delay1;16\",\"test.Delay2;32\"]" | 37 "\"synthetic_delays\":[\"test.Delay1;16\",\"test.Delay2;32\"]" |
35 "}"; | 38 "}"; |
36 | 39 |
37 const char kCustomTraceConfigStringDevToolsStyle[] = | 40 const char kCustomTraceConfigStringDevToolsStyle[] = |
38 "{" | 41 "{" |
39 "\"enableArgumentFilter\":true," | 42 "\"enableArgumentFilter\":true," |
40 "\"enableSampling\":true," | 43 "\"enableSampling\":true," |
41 "\"enableSystrace\":true," | 44 "\"enableSystrace\":true," |
42 "\"excludedCategories\":[\"excluded\",\"exc_pattern*\"]," | 45 "\"excludedCategories\":[\"excluded\",\"exc_pattern*\"]," |
43 "\"includedCategories\":[\"included\"," | 46 "\"includedCategories\":[\"included\"," |
44 "\"inc_pattern*\"," | 47 "\"inc_pattern*\"," |
45 "\"disabled-by-default-cc\"," | 48 "\"disabled-by-default-cc\"," |
46 "\"disabled-by-default-memory-infra\"]," | 49 "\"disabled-by-default-memory-infra\"]," |
47 "\"memoryDumpConfig\":{" | 50 "\"memoryDumpConfig\":{" |
| 51 "\"heap_profiler_options\":{" |
| 52 "\"breakdown_threshold_bytes\":10240" |
| 53 "}," |
48 "\"triggers\":[" | 54 "\"triggers\":[" |
49 "{\"mode\":\"light\",\"periodicIntervalMs\":50}," | 55 "{\"mode\":\"light\",\"periodicIntervalMs\":50}," |
50 "{\"mode\":\"detailed\",\"periodicIntervalMs\":1000}" | 56 "{\"mode\":\"detailed\",\"periodicIntervalMs\":1000}" |
51 "]" | 57 "]" |
52 "}," | 58 "}," |
53 "\"recordMode\":\"recordContinuously\"," | 59 "\"recordMode\":\"recordContinuously\"," |
54 "\"synthetic_delays\":[\"test.Delay1;16\",\"test.Delay2;32\"]" | 60 "\"synthetic_delays\":[\"test.Delay1;16\",\"test.Delay2;32\"]" |
55 "}"; | 61 "}"; |
56 | 62 |
57 } | 63 } |
58 | 64 |
59 TEST(TracingHandlerTest, GetTraceConfigFromDevToolsConfig) { | 65 TEST(TracingHandlerTest, GetTraceConfigFromDevToolsConfig) { |
60 std::unique_ptr<base::Value> value = | 66 std::unique_ptr<base::Value> value = |
61 base::JSONReader::Read(kCustomTraceConfigStringDevToolsStyle); | 67 base::JSONReader::Read(kCustomTraceConfigStringDevToolsStyle); |
62 std::unique_ptr<base::DictionaryValue> devtools_style_dict( | 68 std::unique_ptr<base::DictionaryValue> devtools_style_dict( |
63 static_cast<base::DictionaryValue*>(value.release())); | 69 static_cast<base::DictionaryValue*>(value.release())); |
64 | 70 |
65 base::trace_event::TraceConfig trace_config = | 71 base::trace_event::TraceConfig trace_config = |
66 TracingHandler::GetTraceConfigFromDevToolsConfig(*devtools_style_dict); | 72 TracingHandler::GetTraceConfigFromDevToolsConfig(*devtools_style_dict); |
67 | 73 |
68 EXPECT_STREQ(kCustomTraceConfigString, trace_config.ToString().c_str()); | 74 EXPECT_STREQ(kCustomTraceConfigString, trace_config.ToString().c_str()); |
69 } | 75 } |
70 | 76 |
71 } // namespace tracing | 77 } // namespace tracing |
72 } // namespace devtools | 78 } // namespace devtools |
73 } // namespace content | 79 } // namespace content |
OLD | NEW |