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