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

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

Issue 2041583003: [tracing] Introduce "allowed_dump_modes" for memory dump config (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@background_config
Patch Set: Change mode to int. Created 4 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
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 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 "\"allowed_dump_modes\":[\"background\",\"light\",\"detailed\"],"
28 "\"triggers\":[" 29 "\"triggers\":["
29 "{\"mode\":\"light\",\"periodic_interval_ms\":50}," 30 "{\"mode\":\"light\",\"periodic_interval_ms\":50},"
30 "{\"mode\":\"detailed\",\"periodic_interval_ms\":1000}" 31 "{\"mode\":\"detailed\",\"periodic_interval_ms\":1000}"
31 "]" 32 "]"
32 "}," 33 "},"
33 "\"record_mode\":\"record-continuously\"," 34 "\"record_mode\":\"record-continuously\","
34 "\"synthetic_delays\":[\"test.Delay1;16\",\"test.Delay2;32\"]" 35 "\"synthetic_delays\":[\"test.Delay1;16\",\"test.Delay2;32\"]"
35 "}"; 36 "}";
36 37
37 const char kCustomTraceConfigStringDevToolsStyle[] = 38 const char kCustomTraceConfigStringDevToolsStyle[] =
38 "{" 39 "{"
39 "\"enableArgumentFilter\":true," 40 "\"enableArgumentFilter\":true,"
40 "\"enableSampling\":true," 41 "\"enableSampling\":true,"
41 "\"enableSystrace\":true," 42 "\"enableSystrace\":true,"
42 "\"excludedCategories\":[\"excluded\",\"exc_pattern*\"]," 43 "\"excludedCategories\":[\"excluded\",\"exc_pattern*\"],"
43 "\"includedCategories\":[\"included\"," 44 "\"includedCategories\":[\"included\","
44 "\"inc_pattern*\"," 45 "\"inc_pattern*\","
45 "\"disabled-by-default-cc\"," 46 "\"disabled-by-default-cc\","
46 "\"disabled-by-default-memory-infra\"]," 47 "\"disabled-by-default-memory-infra\"],"
47 "\"memoryDumpConfig\":{" 48 "\"memoryDumpConfig\":{"
49 "\"allowed_dump_modes\":[\"background\",\"light\",\"detailed\"],"
48 "\"triggers\":[" 50 "\"triggers\":["
49 "{\"mode\":\"light\",\"periodicIntervalMs\":50}," 51 "{\"mode\":\"light\",\"periodicIntervalMs\":50},"
50 "{\"mode\":\"detailed\",\"periodicIntervalMs\":1000}" 52 "{\"mode\":\"detailed\",\"periodicIntervalMs\":1000}"
51 "]" 53 "]"
52 "}," 54 "},"
53 "\"recordMode\":\"recordContinuously\"," 55 "\"recordMode\":\"recordContinuously\","
54 "\"synthetic_delays\":[\"test.Delay1;16\",\"test.Delay2;32\"]" 56 "\"synthetic_delays\":[\"test.Delay1;16\",\"test.Delay2;32\"]"
55 "}"; 57 "}";
56 58
57 } 59 }
58 60
59 TEST(TracingHandlerTest, GetTraceConfigFromDevToolsConfig) { 61 TEST(TracingHandlerTest, GetTraceConfigFromDevToolsConfig) {
60 std::unique_ptr<base::Value> value = 62 std::unique_ptr<base::Value> value =
61 base::JSONReader::Read(kCustomTraceConfigStringDevToolsStyle); 63 base::JSONReader::Read(kCustomTraceConfigStringDevToolsStyle);
62 std::unique_ptr<base::DictionaryValue> devtools_style_dict( 64 std::unique_ptr<base::DictionaryValue> devtools_style_dict(
63 static_cast<base::DictionaryValue*>(value.release())); 65 static_cast<base::DictionaryValue*>(value.release()));
64 66
65 base::trace_event::TraceConfig trace_config = 67 base::trace_event::TraceConfig trace_config =
66 TracingHandler::GetTraceConfigFromDevToolsConfig(*devtools_style_dict); 68 TracingHandler::GetTraceConfigFromDevToolsConfig(*devtools_style_dict);
67 69
68 EXPECT_STREQ(kCustomTraceConfigString, trace_config.ToString().c_str()); 70 EXPECT_STREQ(kCustomTraceConfigString, trace_config.ToString().c_str());
69 } 71 }
70 72
71 } // namespace tracing 73 } // namespace tracing
72 } // namespace devtools 74 } // namespace devtools
73 } // namespace content 75 } // namespace content
OLDNEW
« no previous file with comments | « base/trace_event/trace_config_unittest.cc ('k') | content/browser/tracing/background_tracing_manager_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698