| OLD | NEW |
| 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 Loading... |
| 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 } |
| OLD | NEW |