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 "base/trace_event/memory_dump_manager.h" | 5 #include "base/trace_event/memory_dump_manager.h" |
6 #include "base/trace_event/trace_config.h" | 6 #include "base/trace_event/trace_config.h" |
7 #include "base/trace_event/trace_config_memory_test_util.h" | 7 #include "base/trace_event/trace_config_memory_test_util.h" |
8 #include "testing/gtest/include/gtest/gtest.h" | 8 #include "testing/gtest/include/gtest/gtest.h" |
9 | 9 |
10 namespace base { | 10 namespace base { |
(...skipping 430 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
441 EXPECT_FALSE(tc.IsCategoryGroupEnabled("excluded")); | 441 EXPECT_FALSE(tc.IsCategoryGroupEnabled("excluded")); |
442 | 442 |
443 // Enabled a disabled- category and also including makes all categories to | 443 // Enabled a disabled- category and also including makes all categories to |
444 // be traced require including. | 444 // be traced require including. |
445 tc = TraceConfig("disabled-by-default-cc,included", ""); | 445 tc = TraceConfig("disabled-by-default-cc,included", ""); |
446 EXPECT_STREQ("included,disabled-by-default-cc", | 446 EXPECT_STREQ("included,disabled-by-default-cc", |
447 tc.ToCategoryFilterString().c_str()); | 447 tc.ToCategoryFilterString().c_str()); |
448 EXPECT_TRUE(tc.IsCategoryGroupEnabled("disabled-by-default-cc")); | 448 EXPECT_TRUE(tc.IsCategoryGroupEnabled("disabled-by-default-cc")); |
449 EXPECT_TRUE(tc.IsCategoryGroupEnabled("included")); | 449 EXPECT_TRUE(tc.IsCategoryGroupEnabled("included")); |
450 EXPECT_FALSE(tc.IsCategoryGroupEnabled("other_included")); | 450 EXPECT_FALSE(tc.IsCategoryGroupEnabled("other_included")); |
| 451 |
| 452 // Excluding categories won't enable disabled-by-default ones with the |
| 453 // excluded category is also present in the group. |
| 454 tc = TraceConfig("-excluded", ""); |
| 455 EXPECT_STREQ("-excluded", tc.ToCategoryFilterString().c_str()); |
| 456 EXPECT_FALSE(tc.IsCategoryGroupEnabled("excluded,disabled-by-default-cc")); |
451 } | 457 } |
452 | 458 |
453 TEST(TraceConfigTest, IsEmptyOrContainsLeadingOrTrailingWhitespace) { | 459 TEST(TraceConfigTest, IsEmptyOrContainsLeadingOrTrailingWhitespace) { |
454 // Test that IsEmptyOrContainsLeadingOrTrailingWhitespace actually catches | 460 // Test that IsEmptyOrContainsLeadingOrTrailingWhitespace actually catches |
455 // categories that are explicitly forbidden. | 461 // categories that are explicitly forbidden. |
456 // This method is called in a DCHECK to assert that we don't have these types | 462 // This method is called in a DCHECK to assert that we don't have these types |
457 // of strings as categories. | 463 // of strings as categories. |
458 EXPECT_TRUE(TraceConfig::IsEmptyOrContainsLeadingOrTrailingWhitespace( | 464 EXPECT_TRUE(TraceConfig::IsEmptyOrContainsLeadingOrTrailingWhitespace( |
459 " bad_category ")); | 465 " bad_category ")); |
460 EXPECT_TRUE(TraceConfig::IsEmptyOrContainsLeadingOrTrailingWhitespace( | 466 EXPECT_TRUE(TraceConfig::IsEmptyOrContainsLeadingOrTrailingWhitespace( |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
516 | 522 |
517 TEST(TraceConfigTest, LegacyStringToMemoryDumpConfig) { | 523 TEST(TraceConfigTest, LegacyStringToMemoryDumpConfig) { |
518 TraceConfig tc(MemoryDumpManager::kTraceCategory, ""); | 524 TraceConfig tc(MemoryDumpManager::kTraceCategory, ""); |
519 EXPECT_TRUE(tc.IsCategoryGroupEnabled(MemoryDumpManager::kTraceCategory)); | 525 EXPECT_TRUE(tc.IsCategoryGroupEnabled(MemoryDumpManager::kTraceCategory)); |
520 EXPECT_NE(std::string::npos, tc.ToString().find("memory_dump_config")); | 526 EXPECT_NE(std::string::npos, tc.ToString().find("memory_dump_config")); |
521 EXPECT_EQ(2u, tc.memory_dump_config_.size()); | 527 EXPECT_EQ(2u, tc.memory_dump_config_.size()); |
522 } | 528 } |
523 | 529 |
524 } // namespace trace_event | 530 } // namespace trace_event |
525 } // namespace base | 531 } // namespace base |
OLD | NEW |