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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « base/debug/crash_logging.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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/debug/crash_logging.h" 5 #include "base/debug/crash_logging.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <map> 9 #include <map>
10 #include <string> 10 #include <string>
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
176 EXPECT_EQ("wor", results[2]); 176 EXPECT_EQ("wor", results[2]);
177 EXPECT_EQ("ld", results[3]); 177 EXPECT_EQ("ld", results[3]);
178 } 178 }
179 179
180 TEST_F(CrashLoggingTest, ChunkRounding) { 180 TEST_F(CrashLoggingTest, ChunkRounding) {
181 // If max_length=12 and max_chunk_length=5, there should be 3 chunks, 181 // If max_length=12 and max_chunk_length=5, there should be 3 chunks,
182 // not 2. 182 // not 2.
183 base::debug::CrashKey key = { "round", 12 }; 183 base::debug::CrashKey key = { "round", 12 };
184 EXPECT_EQ(3u, base::debug::InitCrashKeys(&key, 1, 5)); 184 EXPECT_EQ(3u, base::debug::InitCrashKeys(&key, 1, 5));
185 } 185 }
186
187 TEST_F(CrashLoggingTest, IgnoreUnregisteredKeys) {
188 base::debug::CrashKey key1 = {"first", 10};
189 base::debug::CrashKey key2 = {"second", 10};
190 base::debug::CrashKey key3 = {"third", 10};
191 base::debug::CrashKey unregistered_key = {"unreg", 10};
192 base::debug::CrashKey keys[] = {key1, key2, key3};
193 std::map<std::string, std::string>& values = *key_values_;
194
195 size_t num_keys = base::debug::InitCrashKeys(
196 keys, arraysize(keys), 10, true /* ignore_unregistered_keys */);
197
198 EXPECT_EQ(3u, num_keys);
199
200 base::debug::SetCrashKeyValue(key1.key_name, "foo");
201 base::debug::SetCrashKeyValue(key2.key_name, "bar");
202 base::debug::SetCrashKeyValue(unregistered_key.key_name, "baro");
203 EXPECT_EQ(2u, values.size());
204 EXPECT_EQ("foo", values[key1.key_name]);
205 EXPECT_EQ("bar", values[key2.key_name]);
206 EXPECT_TRUE(values.end() == values.find(unregistered_key.key_name));
207
208 base::debug::SetCrashKeyValue(key3.key_name, "yup");
209 EXPECT_EQ(3u, values.size());
210 EXPECT_EQ("yup", values[key3.key_name]);
211 }
OLDNEW
« 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