Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(251)

Unified Diff: trace_event/trace_config_unittest.cc

Issue 2045303002: Update to Chromium //base at Chromium commit 3e81715e6d3a4324362635aea46ce1f1a163cca1. (Closed) Base URL: https://chromium.googlesource.com/external/github.com/domokit/base@master
Patch Set: Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « trace_event/trace_config.cc ('k') | trace_event/trace_event.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: trace_event/trace_config_unittest.cc
diff --git a/trace_event/trace_config_unittest.cc b/trace_event/trace_config_unittest.cc
index a2a3703ea3aaa05a1f525a5f04d0c0560331498b..7d8881da3e1338c4a9d438df4edc4b4da2df9b23 100644
--- a/trace_event/trace_config_unittest.cc
+++ b/trace_event/trace_config_unittest.cc
@@ -2,6 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#include "base/trace_event/memory_dump_manager.h"
#include "base/trace_event/trace_config.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -19,6 +20,44 @@ const char kDefaultTraceConfigString[] =
"\"record_mode\":\"record-until-full\""
"}";
+const char kMemoryDumpTraceConfigString[] =
+ "{"
+ "\"enable_argument_filter\":false,"
+ "\"enable_sampling\":false,"
+ "\"enable_systrace\":false,"
+ "\"included_categories\":["
+ "\"disabled-by-default-memory-infra\""
+ "],"
+ "\"memory_dump_config\":{"
+ "\"triggers\":["
+ "{"
+ "\"mode\":\"light\","
+ "\"periodic_interval_ms\":200"
+ "},"
+ "{"
+ "\"mode\":\"detailed\","
+ "\"periodic_interval_ms\":2000"
+ "}"
+ "]"
+ "},"
+ "\"record_mode\":\"record-until-full\""
+ "}";
+
+const char kTraceConfigStringWithEmptyTriggers[] =
+ "{"
+ "\"enable_argument_filter\":false,"
+ "\"enable_sampling\":false,"
+ "\"enable_systrace\":false,"
+ "\"included_categories\":["
+ "\"disabled-by-default-memory-infra\""
+ "],"
+ "\"memory_dump_config\":{"
+ "\"triggers\":["
+ "]"
+ "},"
+ "\"record_mode\":\"record-until-full\""
+ "}";
+
} // namespace
TEST(TraceConfigTest, TraceConfigFromValidLegacyFormat) {
@@ -488,5 +527,34 @@ TEST(TraceConfigTest, SetTraceOptionValues) {
EXPECT_TRUE(tc.IsSystraceEnabled());
}
+TEST(TraceConfigTest, TraceConfigFromMemoryConfigString) {
+ TraceConfig tc(kMemoryDumpTraceConfigString);
+ EXPECT_STREQ(kMemoryDumpTraceConfigString, tc.ToString().c_str());
+ EXPECT_TRUE(tc.IsCategoryGroupEnabled(MemoryDumpManager::kTraceCategory));
+ EXPECT_EQ(2u, tc.memory_dump_config_.size());
+
+ EXPECT_EQ(200u, tc.memory_dump_config_[0].periodic_interval_ms);
+ EXPECT_EQ(MemoryDumpArgs::LevelOfDetail::LOW,
+ tc.memory_dump_config_[0].level_of_detail);
+
+ EXPECT_EQ(2000u, tc.memory_dump_config_[1].periodic_interval_ms);
+ EXPECT_EQ(MemoryDumpArgs::LevelOfDetail::HIGH,
+ tc.memory_dump_config_[1].level_of_detail);
+}
+
+TEST(TraceConfigTest, EmptyMemoryDumpConfigTest) {
+ // Empty trigger list should also be specified when converting back to string.
+ TraceConfig tc(kTraceConfigStringWithEmptyTriggers);
+ EXPECT_STREQ(kTraceConfigStringWithEmptyTriggers, tc.ToString().c_str());
+ EXPECT_EQ(0u, tc.memory_dump_config_.size());
+}
+
+TEST(TraceConfigTest, LegacyStringToMemoryDumpConfig) {
+ TraceConfig tc(MemoryDumpManager::kTraceCategory, "");
+ EXPECT_TRUE(tc.IsCategoryGroupEnabled(MemoryDumpManager::kTraceCategory));
+ EXPECT_NE(std::string::npos, tc.ToString().find("memory_dump_config"));
+ EXPECT_EQ(2u, tc.memory_dump_config_.size());
+}
+
} // namespace trace_event
} // namespace base
« no previous file with comments | « trace_event/trace_config.cc ('k') | trace_event/trace_event.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698