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

Unified Diff: base/debug/crash_logging_unittest.cc

Issue 2708883006: Add possibility to ignore unregistered crash keys. Use this from WebView (Closed)
Patch Set: Created 3 years, 10 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 | « base/debug/crash_logging.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/debug/crash_logging_unittest.cc
diff --git a/base/debug/crash_logging_unittest.cc b/base/debug/crash_logging_unittest.cc
index 5197c03e272ccdec2dd38457ffa115bd59786ca5..1b8203ad66429bf330d91526963e6d2a49415643 100644
--- a/base/debug/crash_logging_unittest.cc
+++ b/base/debug/crash_logging_unittest.cc
@@ -183,3 +183,29 @@ TEST_F(CrashLoggingTest, ChunkRounding) {
base::debug::CrashKey key = { "round", 12 };
EXPECT_EQ(3u, base::debug::InitCrashKeys(&key, 1, 5));
}
+
+TEST_F(CrashLoggingTest, IgnoreUnregisteredKeys) {
+ base::debug::CrashKey key1 = {"first", 10};
+ base::debug::CrashKey key2 = {"second", 10};
+ base::debug::CrashKey key3 = {"third", 10};
+ base::debug::CrashKey unregistered_key = {"unreg", 10};
+ base::debug::CrashKey keys[] = {key1, key2, key3};
+ std::map<std::string, std::string>& values = *key_values_;
+
+ size_t num_keys = base::debug::InitCrashKeys(
+ keys, arraysize(keys), 10, true /* ignore_unregistered_keys */);
+
+ EXPECT_EQ(3u, num_keys);
+
+ base::debug::SetCrashKeyValue(key1.key_name, "foo");
+ base::debug::SetCrashKeyValue(key2.key_name, "bar");
+ base::debug::SetCrashKeyValue(unregistered_key.key_name, "baro");
+ EXPECT_EQ(2u, values.size());
+ EXPECT_EQ("foo", values[key1.key_name]);
+ EXPECT_EQ("bar", values[key2.key_name]);
+ EXPECT_TRUE(values.end() == values.find(unregistered_key.key_name));
+
+ base::debug::SetCrashKeyValue(key3.key_name, "yup");
+ EXPECT_EQ(3u, values.size());
+ EXPECT_EQ("yup", values[key3.key_name]);
+}
« no previous file with comments | « base/debug/crash_logging.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698