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

Side by Side Diff: chrome/browser/safe_browsing/safe_browsing_database_unittest.cc

Issue 136683004: Removes MessageLoop::TYPE_XXX where possible (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: resolve merge Created 6 years, 11 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 | Annotate | Revision Log
OLDNEW
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 "base/file_util.h" 7 #include "base/file_util.h"
8 #include "base/files/scoped_temp_dir.h" 8 #include "base/files/scoped_temp_dir.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/message_loop/message_loop.h" 10 #include "base/message_loop/message_loop.h"
(...skipping 377 matching lines...) Expand 10 before | Expand all | Expand 10 after
388 EXPECT_TRUE(lists[0].name == safe_browsing_util::kMalwareList); 388 EXPECT_TRUE(lists[0].name == safe_browsing_util::kMalwareList);
389 EXPECT_EQ(lists[0].adds, "1-3"); 389 EXPECT_EQ(lists[0].adds, "1-3");
390 EXPECT_EQ(lists[0].subs, "7"); 390 EXPECT_EQ(lists[0].subs, "7");
391 EXPECT_TRUE(lists[1].name == safe_browsing_util::kPhishingList); 391 EXPECT_TRUE(lists[1].name == safe_browsing_util::kPhishingList);
392 EXPECT_EQ(lists[1].adds, "47"); 392 EXPECT_EQ(lists[1].adds, "47");
393 EXPECT_EQ(lists[1].subs, "200-201"); 393 EXPECT_EQ(lists[1].subs, "200-201");
394 } 394 }
395 395
396 TEST_F(SafeBrowsingDatabaseTest, ListNameForBrowseAndDownload) { 396 TEST_F(SafeBrowsingDatabaseTest, ListNameForBrowseAndDownload) {
397 database_.reset(); 397 database_.reset();
398 base::MessageLoop loop(base::MessageLoop::TYPE_DEFAULT); 398 base::MessageLoop loop;
399 SafeBrowsingStoreFile* browse_store = new SafeBrowsingStoreFile(); 399 SafeBrowsingStoreFile* browse_store = new SafeBrowsingStoreFile();
400 SafeBrowsingStoreFile* download_store = new SafeBrowsingStoreFile(); 400 SafeBrowsingStoreFile* download_store = new SafeBrowsingStoreFile();
401 SafeBrowsingStoreFile* csd_whitelist_store = new SafeBrowsingStoreFile(); 401 SafeBrowsingStoreFile* csd_whitelist_store = new SafeBrowsingStoreFile();
402 SafeBrowsingStoreFile* download_whitelist_store = new SafeBrowsingStoreFile(); 402 SafeBrowsingStoreFile* download_whitelist_store = new SafeBrowsingStoreFile();
403 SafeBrowsingStoreFile* extension_blacklist_store = 403 SafeBrowsingStoreFile* extension_blacklist_store =
404 new SafeBrowsingStoreFile(); 404 new SafeBrowsingStoreFile();
405 SafeBrowsingStoreFile* ip_blacklist_store = new SafeBrowsingStoreFile(); 405 SafeBrowsingStoreFile* ip_blacklist_store = new SafeBrowsingStoreFile();
406 database_.reset(new SafeBrowsingDatabaseNew(browse_store, 406 database_.reset(new SafeBrowsingDatabaseNew(browse_store,
407 download_store, 407 download_store,
408 csd_whitelist_store, 408 csd_whitelist_store,
(...skipping 707 matching lines...) Expand 10 before | Expand all | Expand 10 after
1116 1116
1117 // Test that corrupt databases are appropriately handled, even if the 1117 // Test that corrupt databases are appropriately handled, even if the
1118 // corruption is detected in the midst of the update. 1118 // corruption is detected in the midst of the update.
1119 // TODO(shess): Disabled until ScopedLogMessageIgnorer resolved. 1119 // TODO(shess): Disabled until ScopedLogMessageIgnorer resolved.
1120 // http://crbug.com/56448 1120 // http://crbug.com/56448
1121 TEST_F(SafeBrowsingDatabaseTest, DISABLED_FileCorruptionHandling) { 1121 TEST_F(SafeBrowsingDatabaseTest, DISABLED_FileCorruptionHandling) {
1122 // Re-create the database in a captive message loop so that we can 1122 // Re-create the database in a captive message loop so that we can
1123 // influence task-posting. Database specifically needs to the 1123 // influence task-posting. Database specifically needs to the
1124 // file-backed. 1124 // file-backed.
1125 database_.reset(); 1125 database_.reset();
1126 base::MessageLoop loop(base::MessageLoop::TYPE_DEFAULT); 1126 base::MessageLoop loop;
1127 SafeBrowsingStoreFile* store = new SafeBrowsingStoreFile(); 1127 SafeBrowsingStoreFile* store = new SafeBrowsingStoreFile();
1128 database_.reset(new SafeBrowsingDatabaseNew(store, NULL, NULL, NULL, NULL, 1128 database_.reset(new SafeBrowsingDatabaseNew(store, NULL, NULL, NULL, NULL,
1129 NULL, NULL)); 1129 NULL, NULL));
1130 database_->Init(database_filename_); 1130 database_->Init(database_filename_);
1131 1131
1132 // This will cause an empty database to be created. 1132 // This will cause an empty database to be created.
1133 std::vector<SBListChunkRanges> lists; 1133 std::vector<SBListChunkRanges> lists;
1134 EXPECT_TRUE(database_->UpdateStarted(&lists)); 1134 EXPECT_TRUE(database_->UpdateStarted(&lists));
1135 database_->UpdateFinished(true); 1135 database_->UpdateFinished(true);
1136 1136
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
1185 database_->InsertChunks(safe_browsing_util::kMalwareList, chunks); 1185 database_->InsertChunks(safe_browsing_util::kMalwareList, chunks);
1186 database_->UpdateFinished(true); 1186 database_->UpdateFinished(true);
1187 EXPECT_TRUE(base::PathExists(database_filename_)); 1187 EXPECT_TRUE(base::PathExists(database_filename_));
1188 1188
1189 database_.reset(); 1189 database_.reset();
1190 } 1190 }
1191 1191
1192 // Checks database reading and writing. 1192 // Checks database reading and writing.
1193 TEST_F(SafeBrowsingDatabaseTest, ContainsDownloadUrl) { 1193 TEST_F(SafeBrowsingDatabaseTest, ContainsDownloadUrl) {
1194 database_.reset(); 1194 database_.reset();
1195 base::MessageLoop loop(base::MessageLoop::TYPE_DEFAULT); 1195 base::MessageLoop loop;
1196 SafeBrowsingStoreFile* browse_store = new SafeBrowsingStoreFile(); 1196 SafeBrowsingStoreFile* browse_store = new SafeBrowsingStoreFile();
1197 SafeBrowsingStoreFile* download_store = new SafeBrowsingStoreFile(); 1197 SafeBrowsingStoreFile* download_store = new SafeBrowsingStoreFile();
1198 SafeBrowsingStoreFile* csd_whitelist_store = new SafeBrowsingStoreFile(); 1198 SafeBrowsingStoreFile* csd_whitelist_store = new SafeBrowsingStoreFile();
1199 database_.reset(new SafeBrowsingDatabaseNew(browse_store, 1199 database_.reset(new SafeBrowsingDatabaseNew(browse_store,
1200 download_store, 1200 download_store,
1201 csd_whitelist_store, 1201 csd_whitelist_store,
1202 NULL, 1202 NULL,
1203 NULL, 1203 NULL,
1204 NULL, 1204 NULL,
1205 NULL)); 1205 NULL));
(...skipping 619 matching lines...) Expand 10 before | Expand all | Expand 10 after
1825 EXPECT_FALSE(database_->ContainsMalwareIP("192.1.124.0")); 1825 EXPECT_FALSE(database_->ContainsMalwareIP("192.1.124.0"));
1826 1826
1827 EXPECT_FALSE(database_->ContainsMalwareIP("192.1.127.255")); 1827 EXPECT_FALSE(database_->ContainsMalwareIP("192.1.127.255"));
1828 EXPECT_TRUE(database_->ContainsMalwareIP("192.1.128.0")); 1828 EXPECT_TRUE(database_->ContainsMalwareIP("192.1.128.0"));
1829 EXPECT_TRUE(database_->ContainsMalwareIP("::ffff:192.1.128.1")); 1829 EXPECT_TRUE(database_->ContainsMalwareIP("::ffff:192.1.128.1"));
1830 EXPECT_TRUE(database_->ContainsMalwareIP("192.1.128.255")); 1830 EXPECT_TRUE(database_->ContainsMalwareIP("192.1.128.255"));
1831 EXPECT_TRUE(database_->ContainsMalwareIP("192.1.255.0")); 1831 EXPECT_TRUE(database_->ContainsMalwareIP("192.1.255.0"));
1832 EXPECT_TRUE(database_->ContainsMalwareIP("192.1.255.255")); 1832 EXPECT_TRUE(database_->ContainsMalwareIP("192.1.255.255"));
1833 EXPECT_FALSE(database_->ContainsMalwareIP("192.2.0.0")); 1833 EXPECT_FALSE(database_->ContainsMalwareIP("192.2.0.0"));
1834 } 1834 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698