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 <map> | 7 #include <map> |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
11 #include "testing/gtest/include/gtest/gtest.h" | 11 #include "testing/gtest/include/gtest/gtest.h" |
12 | 12 |
13 namespace { | 13 namespace { |
14 | 14 |
15 std::map<std::string, std::string>* key_values_ = NULL; | 15 std::map<std::string, std::string>* key_values_ = NULL; |
16 | 16 |
17 } // namespace | 17 } // namespace |
18 | 18 |
19 class CrashLoggingTest : public testing::Test { | 19 class CrashLoggingTest : public testing::Test { |
20 public: | 20 public: |
21 virtual void SetUp() { | 21 void SetUp() override { |
22 key_values_ = new std::map<std::string, std::string>; | 22 key_values_ = new std::map<std::string, std::string>; |
23 base::debug::SetCrashKeyReportingFunctions( | 23 base::debug::SetCrashKeyReportingFunctions( |
24 &CrashLoggingTest::SetKeyValue, | 24 &CrashLoggingTest::SetKeyValue, |
25 &CrashLoggingTest::ClearKeyValue); | 25 &CrashLoggingTest::ClearKeyValue); |
26 } | 26 } |
27 | 27 |
28 virtual void TearDown() { | 28 void TearDown() override { |
29 base::debug::ResetCrashLoggingForTesting(); | 29 base::debug::ResetCrashLoggingForTesting(); |
30 | 30 |
31 delete key_values_; | 31 delete key_values_; |
32 key_values_ = NULL; | 32 key_values_ = NULL; |
33 } | 33 } |
34 | 34 |
35 private: | 35 private: |
36 static void SetKeyValue(const base::StringPiece& key, | 36 static void SetKeyValue(const base::StringPiece& key, |
37 const base::StringPiece& value) { | 37 const base::StringPiece& value) { |
38 (*key_values_)[key.as_string()] = value.as_string(); | 38 (*key_values_)[key.as_string()] = value.as_string(); |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
173 EXPECT_EQ("wor", results[2]); | 173 EXPECT_EQ("wor", results[2]); |
174 EXPECT_EQ("ld", results[3]); | 174 EXPECT_EQ("ld", results[3]); |
175 } | 175 } |
176 | 176 |
177 TEST_F(CrashLoggingTest, ChunkRounding) { | 177 TEST_F(CrashLoggingTest, ChunkRounding) { |
178 // If max_length=12 and max_chunk_length=5, there should be 3 chunks, | 178 // If max_length=12 and max_chunk_length=5, there should be 3 chunks, |
179 // not 2. | 179 // not 2. |
180 base::debug::CrashKey key = { "round", 12 }; | 180 base::debug::CrashKey key = { "round", 12 }; |
181 EXPECT_EQ(3u, base::debug::InitCrashKeys(&key, 1, 5)); | 181 EXPECT_EQ(3u, base::debug::InitCrashKeys(&key, 1, 5)); |
182 } | 182 } |
OLD | NEW |