OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 <stddef.h> | 5 #include <stddef.h> |
6 | 6 |
7 #include "base/json/json_reader.h" | 7 #include "base/json/json_reader.h" |
8 #include "base/macros.h" | 8 #include "base/macros.h" |
9 #include "base/trace_event/memory_dump_manager.h" | 9 #include "base/trace_event/memory_dump_manager.h" |
10 #include "base/trace_event/trace_config.h" | 10 #include "base/trace_event/trace_config.h" |
(...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
285 // Passing in empty dictionary will not result in default trace config. | 285 // Passing in empty dictionary will not result in default trace config. |
286 DictionaryValue dict; | 286 DictionaryValue dict; |
287 TraceConfig tc(dict); | 287 TraceConfig tc(dict); |
288 EXPECT_STRNE(kDefaultTraceConfigString, tc.ToString().c_str()); | 288 EXPECT_STRNE(kDefaultTraceConfigString, tc.ToString().c_str()); |
289 EXPECT_EQ(RECORD_UNTIL_FULL, tc.GetTraceRecordMode()); | 289 EXPECT_EQ(RECORD_UNTIL_FULL, tc.GetTraceRecordMode()); |
290 EXPECT_FALSE(tc.IsSamplingEnabled()); | 290 EXPECT_FALSE(tc.IsSamplingEnabled()); |
291 EXPECT_FALSE(tc.IsSystraceEnabled()); | 291 EXPECT_FALSE(tc.IsSystraceEnabled()); |
292 EXPECT_FALSE(tc.IsArgumentFilterEnabled()); | 292 EXPECT_FALSE(tc.IsArgumentFilterEnabled()); |
293 EXPECT_STREQ("", tc.ToCategoryFilterString().c_str()); | 293 EXPECT_STREQ("", tc.ToCategoryFilterString().c_str()); |
294 | 294 |
295 scoped_ptr<Value> default_value(JSONReader::Read(kDefaultTraceConfigString)); | 295 std::unique_ptr<Value> default_value( |
| 296 JSONReader::Read(kDefaultTraceConfigString)); |
296 DCHECK(default_value); | 297 DCHECK(default_value); |
297 const DictionaryValue* default_dict = nullptr; | 298 const DictionaryValue* default_dict = nullptr; |
298 bool is_dict = default_value->GetAsDictionary(&default_dict); | 299 bool is_dict = default_value->GetAsDictionary(&default_dict); |
299 DCHECK(is_dict); | 300 DCHECK(is_dict); |
300 TraceConfig default_tc(*default_dict); | 301 TraceConfig default_tc(*default_dict); |
301 EXPECT_STREQ(kDefaultTraceConfigString, default_tc.ToString().c_str()); | 302 EXPECT_STREQ(kDefaultTraceConfigString, default_tc.ToString().c_str()); |
302 EXPECT_EQ(RECORD_UNTIL_FULL, default_tc.GetTraceRecordMode()); | 303 EXPECT_EQ(RECORD_UNTIL_FULL, default_tc.GetTraceRecordMode()); |
303 EXPECT_FALSE(default_tc.IsSamplingEnabled()); | 304 EXPECT_FALSE(default_tc.IsSamplingEnabled()); |
304 EXPECT_FALSE(default_tc.IsSystraceEnabled()); | 305 EXPECT_FALSE(default_tc.IsSystraceEnabled()); |
305 EXPECT_FALSE(default_tc.IsArgumentFilterEnabled()); | 306 EXPECT_FALSE(default_tc.IsArgumentFilterEnabled()); |
306 EXPECT_STREQ("-*Debug,-*Test", default_tc.ToCategoryFilterString().c_str()); | 307 EXPECT_STREQ("-*Debug,-*Test", default_tc.ToCategoryFilterString().c_str()); |
307 | 308 |
308 scoped_ptr<Value> custom_value(JSONReader::Read(kCustomTraceConfigString)); | 309 std::unique_ptr<Value> custom_value( |
| 310 JSONReader::Read(kCustomTraceConfigString)); |
309 DCHECK(custom_value); | 311 DCHECK(custom_value); |
310 const DictionaryValue* custom_dict = nullptr; | 312 const DictionaryValue* custom_dict = nullptr; |
311 is_dict = custom_value->GetAsDictionary(&custom_dict); | 313 is_dict = custom_value->GetAsDictionary(&custom_dict); |
312 DCHECK(is_dict); | 314 DCHECK(is_dict); |
313 TraceConfig custom_tc(*custom_dict); | 315 TraceConfig custom_tc(*custom_dict); |
314 EXPECT_STREQ(kCustomTraceConfigString, custom_tc.ToString().c_str()); | 316 EXPECT_STREQ(kCustomTraceConfigString, custom_tc.ToString().c_str()); |
315 EXPECT_EQ(RECORD_CONTINUOUSLY, custom_tc.GetTraceRecordMode()); | 317 EXPECT_EQ(RECORD_CONTINUOUSLY, custom_tc.GetTraceRecordMode()); |
316 EXPECT_TRUE(custom_tc.IsSamplingEnabled()); | 318 EXPECT_TRUE(custom_tc.IsSamplingEnabled()); |
317 EXPECT_TRUE(custom_tc.IsSystraceEnabled()); | 319 EXPECT_TRUE(custom_tc.IsSystraceEnabled()); |
318 EXPECT_TRUE(custom_tc.IsArgumentFilterEnabled()); | 320 EXPECT_TRUE(custom_tc.IsArgumentFilterEnabled()); |
(...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
589 | 591 |
590 TEST(TraceConfigTest, LegacyStringToMemoryDumpConfig) { | 592 TEST(TraceConfigTest, LegacyStringToMemoryDumpConfig) { |
591 TraceConfig tc(MemoryDumpManager::kTraceCategory, ""); | 593 TraceConfig tc(MemoryDumpManager::kTraceCategory, ""); |
592 EXPECT_TRUE(tc.IsCategoryGroupEnabled(MemoryDumpManager::kTraceCategory)); | 594 EXPECT_TRUE(tc.IsCategoryGroupEnabled(MemoryDumpManager::kTraceCategory)); |
593 EXPECT_NE(std::string::npos, tc.ToString().find("memory_dump_config")); | 595 EXPECT_NE(std::string::npos, tc.ToString().find("memory_dump_config")); |
594 EXPECT_EQ(2u, tc.memory_dump_config_.size()); | 596 EXPECT_EQ(2u, tc.memory_dump_config_.size()); |
595 } | 597 } |
596 | 598 |
597 } // namespace trace_event | 599 } // namespace trace_event |
598 } // namespace base | 600 } // namespace base |
OLD | NEW |