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

Side by Side Diff: content/browser/devtools/protocol/tracing_handler_unittest.cc

Issue 2542853002: [tracing] Introduce config to setup memory-infra peak detection (Closed)
Patch Set: Fixes. Created 4 years 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
OLDNEW
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 protocol { 12 namespace protocol {
13 13
14 namespace { 14 namespace {
15 15
16 const char kCustomTraceConfigString[] = 16 const char kCustomTraceConfigString[] =
17 "{" 17 "{"
18 "\"enable_argument_filter\":true," 18 "\"enable_argument_filter\":true,"
19 "\"enable_systrace\":true," 19 "\"enable_systrace\":true,"
20 "\"excluded_categories\":[\"excluded\",\"exc_pattern*\"]," 20 "\"excluded_categories\":[\"excluded\",\"exc_pattern*\"],"
21 "\"included_categories\":[\"included\"," 21 "\"included_categories\":[\"included\","
22 "\"inc_pattern*\"," 22 "\"inc_pattern*\","
23 "\"disabled-by-default-cc\"," 23 "\"disabled-by-default-cc\","
24 "\"disabled-by-default-memory-infra\"]," 24 "\"disabled-by-default-memory-infra\"],"
25 "\"memory_dump_config\":{" 25 "\"memory_dump_config\":{"
26 "\"allowed_dump_modes\":[\"background\",\"light\",\"detailed\"]," 26 "\"allowed_dump_modes\":[\"background\",\"light\",\"detailed\"],"
27 "\"triggers\":[" 27 "\"triggers\":["
28 "{\"mode\":\"light\",\"periodic_interval_ms\":50}," 28 "{"
29 "{\"mode\":\"detailed\",\"periodic_interval_ms\":1000}" 29 "\"min_time_between_dumps_ms\":50,"
30 "]" 30 "\"mode\":\"light\","
31 "\"type\":\"periodic_interval\""
32 "},"
33 "{"
34 "\"min_time_between_dumps_ms\":1000,"
35 "\"mode\":\"detailed\","
36 "\"type\":\"periodic_interval\""
37 "}"
38 "]"
31 "}," 39 "},"
32 "\"record_mode\":\"record-continuously\"," 40 "\"record_mode\":\"record-continuously\","
33 "\"synthetic_delays\":[\"test.Delay1;16\",\"test.Delay2;32\"]" 41 "\"synthetic_delays\":[\"test.Delay1;16\",\"test.Delay2;32\"]"
34 "}"; 42 "}";
35 43
36 const char kCustomTraceConfigStringDevToolsStyle[] = 44 const char kCustomTraceConfigStringDevToolsStyle[] =
37 "{" 45 "{"
38 "\"enableArgumentFilter\":true," 46 "\"enableArgumentFilter\":true,"
39 "\"enableSystrace\":true," 47 "\"enableSystrace\":true,"
40 "\"excludedCategories\":[\"excluded\",\"exc_pattern*\"]," 48 "\"excludedCategories\":[\"excluded\",\"exc_pattern*\"],"
41 "\"includedCategories\":[\"included\"," 49 "\"includedCategories\":[\"included\","
42 "\"inc_pattern*\"," 50 "\"inc_pattern*\","
43 "\"disabled-by-default-cc\"," 51 "\"disabled-by-default-cc\","
44 "\"disabled-by-default-memory-infra\"]," 52 "\"disabled-by-default-memory-infra\"],"
45 "\"memoryDumpConfig\":{" 53 "\"memoryDumpConfig\":{"
46 "\"allowed_dump_modes\":[\"background\",\"light\",\"detailed\"]," 54 "\"allowedDumpModes\":[\"background\",\"light\",\"detailed\"],"
47 "\"triggers\":[" 55 "\"triggers\":["
48 "{\"mode\":\"light\",\"periodicIntervalMs\":50}," 56 "{"
49 "{\"mode\":\"detailed\",\"periodicIntervalMs\":1000}" 57 "\"minTimeBetweenDumpsMs\":50,"
50 "]" 58 "\"mode\":\"light\","
59 "\"type\":\"periodic_interval\""
60 "},"
61 "{"
62 "\"minTimeBetweenDumpsMs\":1000,"
63 "\"mode\":\"detailed\","
64 "\"type\":\"periodic_interval\""
65 "}"
66 "]"
51 "}," 67 "},"
52 "\"recordMode\":\"recordContinuously\"," 68 "\"recordMode\":\"recordContinuously\","
53 "\"synthetic_delays\":[\"test.Delay1;16\",\"test.Delay2;32\"]" 69 "\"synthetic_delays\":[\"test.Delay1;16\",\"test.Delay2;32\"]"
54 "}"; 70 "}";
55 71
56 } // namespace 72 } // namespace
57 73
58 TEST(TracingHandlerTest, GetTraceConfigFromDevToolsConfig) { 74 TEST(TracingHandlerTest, GetTraceConfigFromDevToolsConfig) {
59 std::unique_ptr<base::Value> value = 75 std::unique_ptr<base::Value> value =
60 base::JSONReader::Read(kCustomTraceConfigStringDevToolsStyle); 76 base::JSONReader::Read(kCustomTraceConfigStringDevToolsStyle);
61 std::unique_ptr<base::DictionaryValue> devtools_style_dict( 77 std::unique_ptr<base::DictionaryValue> devtools_style_dict(
62 static_cast<base::DictionaryValue*>(value.release())); 78 static_cast<base::DictionaryValue*>(value.release()));
63 79
64 base::trace_event::TraceConfig trace_config = 80 base::trace_event::TraceConfig trace_config =
65 TracingHandler::GetTraceConfigFromDevToolsConfig(*devtools_style_dict); 81 TracingHandler::GetTraceConfigFromDevToolsConfig(*devtools_style_dict);
66 82
67 EXPECT_STREQ(kCustomTraceConfigString, trace_config.ToString().c_str()); 83 EXPECT_STREQ(kCustomTraceConfigString, trace_config.ToString().c_str());
68 } 84 }
69 85
70 } // namespace protocol 86 } // namespace protocol
71 } // namespace content 87 } // namespace content
OLDNEW
« base/trace_event/trace_config_memory_test_util.h ('K') | « base/trace_event/trace_config_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698