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 550 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
561 EXPECT_EQ(RECORD_AS_MUCH_AS_POSSIBLE, tc.GetTraceRecordMode()); | 561 EXPECT_EQ(RECORD_AS_MUCH_AS_POSSIBLE, tc.GetTraceRecordMode()); |
562 | 562 |
563 tc.EnableSampling(); | 563 tc.EnableSampling(); |
564 EXPECT_TRUE(tc.IsSamplingEnabled()); | 564 EXPECT_TRUE(tc.IsSamplingEnabled()); |
565 | 565 |
566 tc.EnableSystrace(); | 566 tc.EnableSystrace(); |
567 EXPECT_TRUE(tc.IsSystraceEnabled()); | 567 EXPECT_TRUE(tc.IsSystraceEnabled()); |
568 } | 568 } |
569 | 569 |
570 TEST(TraceConfigTest, TraceConfigFromMemoryConfigString) { | 570 TEST(TraceConfigTest, TraceConfigFromMemoryConfigString) { |
571 std::string tc_str = | 571 std::string tc_str1 = |
572 TraceConfigMemoryTestUtil::GetTraceConfig_PeriodicTriggers(200, 2000); | 572 TraceConfigMemoryTestUtil::GetTraceConfig_PeriodicTriggers(200, 2000); |
573 TraceConfig tc(tc_str); | 573 TraceConfig tc1(tc_str1); |
574 EXPECT_EQ(tc_str, tc.ToString()); | 574 EXPECT_EQ(tc_str1, tc1.ToString()); |
575 EXPECT_TRUE(tc.IsCategoryGroupEnabled(MemoryDumpManager::kTraceCategory)); | 575 EXPECT_TRUE(tc1.IsCategoryGroupEnabled(MemoryDumpManager::kTraceCategory)); |
576 ASSERT_EQ(2u, tc.memory_dump_config_.triggers.size()); | 576 ASSERT_EQ(2u, tc1.memory_dump_config_.triggers.size()); |
577 | 577 |
578 EXPECT_EQ(200u, tc.memory_dump_config_.triggers[0].periodic_interval_ms); | 578 EXPECT_EQ(200u, tc1.memory_dump_config_.triggers[0].periodic_interval_ms); |
579 EXPECT_EQ(MemoryDumpLevelOfDetail::LIGHT, | 579 EXPECT_EQ(MemoryDumpLevelOfDetail::LIGHT, |
580 tc.memory_dump_config_.triggers[0].level_of_detail); | 580 tc1.memory_dump_config_.triggers[0].level_of_detail); |
581 | 581 |
582 EXPECT_EQ(2000u, tc.memory_dump_config_.triggers[1].periodic_interval_ms); | 582 EXPECT_EQ(2000u, tc1.memory_dump_config_.triggers[1].periodic_interval_ms); |
583 EXPECT_EQ(MemoryDumpLevelOfDetail::DETAILED, | 583 EXPECT_EQ(MemoryDumpLevelOfDetail::DETAILED, |
584 tc.memory_dump_config_.triggers[1].level_of_detail); | 584 tc1.memory_dump_config_.triggers[1].level_of_detail); |
585 EXPECT_EQ(2048u, tc.memory_dump_config_.heap_profiler_options. | 585 EXPECT_EQ( |
586 breakdown_threshold_bytes); | 586 2048u, |
| 587 tc1.memory_dump_config_.heap_profiler_options.breakdown_threshold_bytes); |
| 588 |
| 589 std::string tc_str2 = |
| 590 TraceConfigMemoryTestUtil::GetTraceConfig_BackgroundTrigger(); |
| 591 TraceConfig tc2(tc_str2); |
| 592 EXPECT_EQ(tc_str2, tc2.ToString()); |
| 593 EXPECT_TRUE(tc2.IsCategoryGroupEnabled(MemoryDumpManager::kTraceCategory)); |
| 594 ASSERT_EQ(1u, tc2.memory_dump_config_.triggers.size()); |
| 595 EXPECT_EQ(1u, tc2.memory_dump_config_.triggers[0].periodic_interval_ms); |
| 596 EXPECT_EQ(MemoryDumpLevelOfDetail::BACKGROUND, |
| 597 tc2.memory_dump_config_.triggers[0].level_of_detail); |
587 } | 598 } |
588 | 599 |
589 TEST(TraceConfigTest, EmptyMemoryDumpConfigTest) { | 600 TEST(TraceConfigTest, EmptyMemoryDumpConfigTest) { |
590 // Empty trigger list should also be specified when converting back to string. | 601 // Empty trigger list should also be specified when converting back to string. |
591 TraceConfig tc(TraceConfigMemoryTestUtil::GetTraceConfig_EmptyTriggers()); | 602 TraceConfig tc(TraceConfigMemoryTestUtil::GetTraceConfig_EmptyTriggers()); |
592 EXPECT_EQ(TraceConfigMemoryTestUtil::GetTraceConfig_EmptyTriggers(), | 603 EXPECT_EQ(TraceConfigMemoryTestUtil::GetTraceConfig_EmptyTriggers(), |
593 tc.ToString()); | 604 tc.ToString()); |
594 EXPECT_EQ(0u, tc.memory_dump_config_.triggers.size()); | 605 EXPECT_EQ(0u, tc.memory_dump_config_.triggers.size()); |
595 EXPECT_EQ(TraceConfig::MemoryDumpConfig::HeapProfiler | 606 EXPECT_EQ(TraceConfig::MemoryDumpConfig::HeapProfiler |
596 ::kDefaultBreakdownThresholdBytes, | 607 ::kDefaultBreakdownThresholdBytes, |
597 tc.memory_dump_config_.heap_profiler_options | 608 tc.memory_dump_config_.heap_profiler_options |
598 .breakdown_threshold_bytes); | 609 .breakdown_threshold_bytes); |
599 } | 610 } |
600 | 611 |
601 TEST(TraceConfigTest, LegacyStringToMemoryDumpConfig) { | 612 TEST(TraceConfigTest, LegacyStringToMemoryDumpConfig) { |
602 TraceConfig tc(MemoryDumpManager::kTraceCategory, ""); | 613 TraceConfig tc(MemoryDumpManager::kTraceCategory, ""); |
603 EXPECT_TRUE(tc.IsCategoryGroupEnabled(MemoryDumpManager::kTraceCategory)); | 614 EXPECT_TRUE(tc.IsCategoryGroupEnabled(MemoryDumpManager::kTraceCategory)); |
604 EXPECT_NE(std::string::npos, tc.ToString().find("memory_dump_config")); | 615 EXPECT_NE(std::string::npos, tc.ToString().find("memory_dump_config")); |
605 EXPECT_EQ(2u, tc.memory_dump_config_.triggers.size()); | 616 EXPECT_EQ(2u, tc.memory_dump_config_.triggers.size()); |
606 EXPECT_EQ(TraceConfig::MemoryDumpConfig::HeapProfiler | 617 EXPECT_EQ(TraceConfig::MemoryDumpConfig::HeapProfiler |
607 ::kDefaultBreakdownThresholdBytes, | 618 ::kDefaultBreakdownThresholdBytes, |
608 tc.memory_dump_config_.heap_profiler_options | 619 tc.memory_dump_config_.heap_profiler_options |
609 .breakdown_threshold_bytes); | 620 .breakdown_threshold_bytes); |
610 } | 621 } |
611 | 622 |
612 } // namespace trace_event | 623 } // namespace trace_event |
613 } // namespace base | 624 } // namespace base |
OLD | NEW |