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 "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.h" | 10 #include "base/message_loop.h" |
(...skipping 1094 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1105 // Start an update. The insert will fail due to corruption. | 1105 // Start an update. The insert will fail due to corruption. |
1106 EXPECT_TRUE(database_->UpdateStarted(&lists)); | 1106 EXPECT_TRUE(database_->UpdateStarted(&lists)); |
1107 database_->InsertChunks(safe_browsing_util::kMalwareList, chunks); | 1107 database_->InsertChunks(safe_browsing_util::kMalwareList, chunks); |
1108 database_->UpdateFinished(true); | 1108 database_->UpdateFinished(true); |
1109 | 1109 |
1110 // Database file still exists until the corruption handler has run. | 1110 // Database file still exists until the corruption handler has run. |
1111 EXPECT_TRUE(file_util::PathExists(database_filename_)); | 1111 EXPECT_TRUE(file_util::PathExists(database_filename_)); |
1112 | 1112 |
1113 // Flush through the corruption-handler task. | 1113 // Flush through the corruption-handler task. |
1114 VLOG(1) << "Expect failed check on: SafeBrowsing database reset"; | 1114 VLOG(1) << "Expect failed check on: SafeBrowsing database reset"; |
1115 MessageLoop::current()->RunAllPending(); | 1115 MessageLoop::current()->RunUntilIdle(); |
1116 } | 1116 } |
1117 | 1117 |
1118 // Database file should not exist. | 1118 // Database file should not exist. |
1119 EXPECT_FALSE(file_util::PathExists(database_filename_)); | 1119 EXPECT_FALSE(file_util::PathExists(database_filename_)); |
1120 | 1120 |
1121 // Run the update again successfully. | 1121 // Run the update again successfully. |
1122 EXPECT_TRUE(database_->UpdateStarted(&lists)); | 1122 EXPECT_TRUE(database_->UpdateStarted(&lists)); |
1123 database_->InsertChunks(safe_browsing_util::kMalwareList, chunks); | 1123 database_->InsertChunks(safe_browsing_util::kMalwareList, chunks); |
1124 database_->UpdateFinished(true); | 1124 database_->UpdateFinished(true); |
1125 EXPECT_TRUE(file_util::PathExists(database_filename_)); | 1125 EXPECT_TRUE(file_util::PathExists(database_filename_)); |
(...skipping 512 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1638 ASSERT_FALSE(file_util::PathExists(filter_file)); | 1638 ASSERT_FALSE(file_util::PathExists(filter_file)); |
1639 database_.reset(new SafeBrowsingDatabaseNew); | 1639 database_.reset(new SafeBrowsingDatabaseNew); |
1640 database_->Init(database_filename_); | 1640 database_->Init(database_filename_); |
1641 EXPECT_FALSE(database_->ContainsBrowseUrl( | 1641 EXPECT_FALSE(database_->ContainsBrowseUrl( |
1642 GURL("http://www.evil.com/malware.html"), | 1642 GURL("http://www.evil.com/malware.html"), |
1643 &matching_list, &prefix_hits, &full_hashes, now)); | 1643 &matching_list, &prefix_hits, &full_hashes, now)); |
1644 EXPECT_FALSE(database_->ContainsBrowseUrl( | 1644 EXPECT_FALSE(database_->ContainsBrowseUrl( |
1645 GURL("http://www.good.com/goodware.html"), | 1645 GURL("http://www.good.com/goodware.html"), |
1646 &matching_list, &prefix_hits, &full_hashes, now)); | 1646 &matching_list, &prefix_hits, &full_hashes, now)); |
1647 } | 1647 } |
OLD | NEW |