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