OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 // Unit tests for the SafeBrowsing storage system. | 5 // Unit tests for the SafeBrowsing storage system. |
6 | 6 |
7 #include "chrome/browser/safe_browsing/safe_browsing_database.h" | 7 #include "chrome/browser/safe_browsing/safe_browsing_database.h" |
8 | 8 |
9 #include <stddef.h> | 9 #include <stddef.h> |
10 | 10 |
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
209 return BuildChunk(chunk_number, ChunkData::ADD, ChunkData::FULL_32B, | 209 return BuildChunk(chunk_number, ChunkData::ADD, ChunkData::FULL_32B, |
210 &full_hash, sizeof(full_hash), std::vector<int>()); | 210 &full_hash, sizeof(full_hash), std::vector<int>()); |
211 } | 211 } |
212 | 212 |
213 // Prevent DCHECK from killing tests. | 213 // Prevent DCHECK from killing tests. |
214 // TODO(shess): Pawel disputes the use of this, so the test which uses | 214 // TODO(shess): Pawel disputes the use of this, so the test which uses |
215 // it is DISABLED. http://crbug.com/56448 | 215 // it is DISABLED. http://crbug.com/56448 |
216 class ScopedLogMessageIgnorer { | 216 class ScopedLogMessageIgnorer { |
217 public: | 217 public: |
218 ScopedLogMessageIgnorer() { | 218 ScopedLogMessageIgnorer() { |
219 logging::SetLogMessageHandler(&LogMessageIgnorer); | 219 logging::PushLogMessageHandler(LogMessageIgnorer); |
220 } | 220 } |
221 ~ScopedLogMessageIgnorer() { | 221 ~ScopedLogMessageIgnorer() { |
222 // TODO(shess): Would be better to verify whether anyone else | 222 // TODO(shess): Would be better to verify whether anyone else |
223 // changed it, and then restore it to the previous value. | 223 // changed it, and then restore it to the previous value. |
224 logging::SetLogMessageHandler(NULL); | 224 logging::PopLogMessageHandler(LogMessageIgnorer); |
225 } | 225 } |
226 | 226 |
227 private: | 227 private: |
228 static bool LogMessageIgnorer(int severity, const char* file, int line, | 228 static bool LogMessageIgnorer(int severity, const char* file, int line, |
229 size_t message_start, const std::string& str) { | 229 size_t message_start, const std::string& str) { |
230 // Intercept FATAL, strip the stack backtrace, and log it without | 230 // Intercept FATAL, strip the stack backtrace, and log it without |
231 // the crash part. | 231 // the crash part. |
232 if (severity == logging::LOG_FATAL) { | 232 if (severity == logging::LOG_FATAL) { |
233 size_t newline = str.find('\n'); | 233 size_t newline = str.find('\n'); |
234 if (newline != std::string::npos) { | 234 if (newline != std::string::npos) { |
(...skipping 2133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2368 ASSERT_EQ(1U, prefix_hits.size()); | 2368 ASSERT_EQ(1U, prefix_hits.size()); |
2369 EXPECT_EQ(SBPrefixForString(kExampleCollision), prefix_hits[0]); | 2369 EXPECT_EQ(SBPrefixForString(kExampleCollision), prefix_hits[0]); |
2370 EXPECT_TRUE(cache_hits.empty()); | 2370 EXPECT_TRUE(cache_hits.empty()); |
2371 | 2371 |
2372 // This prefix collides, but no full hash match. | 2372 // This prefix collides, but no full hash match. |
2373 EXPECT_FALSE(database_->ContainsBrowseUrl( | 2373 EXPECT_FALSE(database_->ContainsBrowseUrl( |
2374 GURL(std::string("http://") + kExampleFine), &prefix_hits, &cache_hits)); | 2374 GURL(std::string("http://") + kExampleFine), &prefix_hits, &cache_hits)); |
2375 } | 2375 } |
2376 | 2376 |
2377 } // namespace safe_browsing | 2377 } // namespace safe_browsing |
OLD | NEW |