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

Unified Diff: chrome/browser/safe_browsing/safe_browsing_database_unittest.cc

Issue 6268: Port some more parts of browser/... (Closed) Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: '' Created 12 years, 2 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/safe_browsing/safe_browsing_database_impl_unittest.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/safe_browsing/safe_browsing_database_unittest.cc
===================================================================
--- chrome/browser/safe_browsing/safe_browsing_database_unittest.cc (revision 3500)
+++ chrome/browser/safe_browsing/safe_browsing_database_unittest.cc (working copy)
@@ -63,7 +63,8 @@
SafeBrowsingDatabase* SetupTestDatabase() {
std::wstring filename = GetTestDatabaseName();
- DeleteFile(filename.c_str()); // In case it existed from a previous run.
+ // In case it existed from a previous run.
+ file_util::Delete(filename, false);
SafeBrowsingDatabase* database = SafeBrowsingDatabase::Create();
database->SetSynchronous();
@@ -73,7 +74,7 @@
}
void TearDownTestDatabase(SafeBrowsingDatabase* database) {
- DeleteFile(GetTestDatabaseName().c_str());
+ file_util::Delete(GetTestDatabaseName(), false);
delete database;
}
@@ -141,7 +142,7 @@
// Make sure they were added correctly.
std::vector<SBListChunkRanges> lists;
database->GetListsInfo(&lists);
- EXPECT_EQ(lists.size(), 1);
+ EXPECT_EQ(lists.size(), 1U);
EXPECT_EQ(lists[0].name, "goog-malware");
EXPECT_EQ(lists[0].adds, "1-3");
EXPECT_TRUE(lists[0].subs.empty());
@@ -154,7 +155,7 @@
&matching_list, &prefix_hits,
&full_hashes, now));
EXPECT_EQ(prefix_hits[0], Sha256Prefix("www.evil.com/phishing.html"));
- EXPECT_EQ(prefix_hits.size(), 1);
+ EXPECT_EQ(prefix_hits.size(), 1U);
EXPECT_TRUE(database->ContainsUrl(GURL("http://www.evil.com/malware.html"),
&matching_list, &prefix_hits,
@@ -183,7 +184,7 @@
EXPECT_FALSE(database->ContainsUrl(GURL("http://www.evil.com/"),
&matching_list, &prefix_hits,
&full_hashes, now));
- EXPECT_EQ(prefix_hits.size(), 0);
+ EXPECT_EQ(prefix_hits.size(), 0U);
EXPECT_FALSE(database->ContainsUrl(GURL("http://www.evil.com/robots.txt"),
&matching_list, &prefix_hits,
@@ -211,12 +212,12 @@
&matching_list, &prefix_hits,
&full_hashes, now));
EXPECT_EQ(prefix_hits[0], Sha256Prefix("www.evil.com/phishing.html"));
- EXPECT_EQ(prefix_hits.size(), 1);
+ EXPECT_EQ(prefix_hits.size(), 1U);
EXPECT_FALSE(database->ContainsUrl(GURL("http://www.evil.com/notevil1.html"),
&matching_list, &prefix_hits,
&full_hashes, now));
- EXPECT_EQ(prefix_hits.size(), 0);
+ EXPECT_EQ(prefix_hits.size(), 0U);
EXPECT_TRUE(database->ContainsUrl(GURL("http://www.evil.com/notevil2.html"),
&matching_list, &prefix_hits,
@@ -231,7 +232,7 @@
&full_hashes, now));
database->GetListsInfo(&lists);
- EXPECT_EQ(lists.size(), 1);
+ EXPECT_EQ(lists.size(), 1U);
EXPECT_EQ(lists[0].name, "goog-malware");
EXPECT_EQ(lists[0].subs, "4");
@@ -252,7 +253,7 @@
&full_hashes, now));
database->GetListsInfo(&lists);
- EXPECT_EQ(lists.size(), 1);
+ EXPECT_EQ(lists.size(), 1U);
EXPECT_EQ(lists[0].name, "goog-malware");
EXPECT_EQ(lists[0].adds, "1,3");
EXPECT_EQ(lists[0].subs, "4");
@@ -283,7 +284,7 @@
database->UpdateFinished();
database->GetListsInfo(&lists);
- EXPECT_EQ(lists.size(), 1);
+ EXPECT_EQ(lists.size(), 1U);
EXPECT_EQ(lists[0].name, "goog-malware");
EXPECT_EQ(lists[0].adds, "1,3");
EXPECT_EQ(lists[0].subs, "");
@@ -461,15 +462,22 @@
}
void PrintStat(const wchar_t* name) {
+#if defined(OS_WIN)
int value = StatsTable::current()->GetCounterValue(name);
- std::wstring out = StringPrintf(L"%ls %d\r\n", name, value);
- OutputDebugStringW(out.c_str());
+ LOG(INFO) << StringPrintf(L"%ls %d", name, value);
+#else
+ // TODO(port): Enable when StatsTable is ported.
+ NOTIMPLEMENTED();
+#endif
}
std::wstring GetFullSBDataPath(const std::wstring& path) {
std::wstring full_path;
CHECK(PathService::Get(base::DIR_SOURCE_ROOT, &full_path));
- file_util::AppendToPath(&full_path, L"chrome\\test\\data\\safe_browsing");
+ file_util::AppendToPath(&full_path, L"chrome");
+ file_util::AppendToPath(&full_path, L"test");
+ file_util::AppendToPath(&full_path, L"data");
+ file_util::AppendToPath(&full_path, L"safe_browsing");
file_util::AppendToPath(&full_path, path);
CHECK(file_util::PathExists(full_path));
return full_path;
@@ -489,7 +497,8 @@
PathService::Get(base::DIR_TEMP, &filename);
filename.push_back(file_util::kPathSeparator);
filename.append(L"SafeBrowsingTestDatabase");
- DeleteFile(filename.c_str()); // In case it existed from a previous run.
+ // In case it existed from a previous run.
+ file_util::Delete(filename, false);
if (!initial_db.empty()) {
std::wstring full_initial_db = GetFullSBDataPath(initial_db);
@@ -515,16 +524,16 @@
CHECK(metric->GetIOCounters(&after));
- OutputDebugStringA(StringPrintf("I/O Read Bytes: %d\r\n",
- after.ReadTransferCount - before.ReadTransferCount).c_str());
- OutputDebugStringA(StringPrintf("I/O Write Bytes: %d\r\n",
- after.WriteTransferCount - before.WriteTransferCount).c_str());
- OutputDebugStringA(StringPrintf("I/O Reads: %d\r\n",
- after.ReadOperationCount - before.ReadOperationCount).c_str());
- OutputDebugStringA(StringPrintf("I/O Writes: %d\r\n",
- after.WriteOperationCount - before.WriteOperationCount).c_str());
- OutputDebugStringA(StringPrintf("Finished in %d ms\r\n",
- (Time::Now() - before_time).InMilliseconds()).c_str());
+ LOG(INFO) << StringPrintf("I/O Read Bytes: %d",
+ after.ReadTransferCount - before.ReadTransferCount);
+ LOG(INFO) << StringPrintf("I/O Write Bytes: %d",
+ after.WriteTransferCount - before.WriteTransferCount);
+ LOG(INFO) << StringPrintf("I/O Reads: %d",
+ after.ReadOperationCount - before.ReadOperationCount);
+ LOG(INFO) << StringPrintf("I/O Writes: %d",
+ after.WriteOperationCount - before.WriteOperationCount);
+ LOG(INFO) << StringPrintf("Finished in %d ms",
+ (Time::Now() - before_time).InMilliseconds());
PrintStat(L"c:SB.HostSelect");
PrintStat(L"c:SB.HostSelectForBloomFilter");
@@ -605,6 +614,28 @@
PeformUpdate(initial_db, chunks, deletes);
}
+namespace {
+
+const wchar_t* GetOldSafeBrowsingPath() {
+ std::wstring path = L"old";
+ file_util::AppendToPath(&path, L"SafeBrowsing");
+ return path.c_str();
+}
+
+const wchar_t* GetOldResponsePath() {
+ std::wstring path = L"old";
+ file_util::AppendToPath(&path, L"response");
+ return path.c_str();
+}
+
+const wchar_t* GetOldUpdatesPath() {
+ std::wstring path = L"old";
+ file_util::AppendToPath(&path, L"updates");
+ return path.c_str();
+}
+
+} // namespace
+
// Counts the IO needed for the initial update of a database.
// test\data\safe_browsing\download_update.py was used to fetch the add/sub
// chunks that are read, in order to get repeatable runs.
@@ -612,23 +643,36 @@
UpdateDatabase(L"", L"", L"initial");
}
+// TODO(port): For now on Linux the test below would fail with error below:
+// [1004/201323:FATAL:browser/safe_browsing/safe_browsing_database_impl.cc(712)]
+// Check failed: false.
+//
// Counts the IO needed to update a month old database.
// The data files were generated by running "..\download_update.py postdata"
// in the "safe_browsing\old" directory.
TEST(SafeBrowsingDatabase, DISABLED_DatabaseOldIO) {
- UpdateDatabase(L"old\\SafeBrowsing", L"old\\response", L"old\\updates");
+ UpdateDatabase(GetOldSafeBrowsingPath(), GetOldResponsePath(),
+ GetOldUpdatesPath());
}
+// TODO(port): For now on Linux the test below would fail with error below:
+// [1004/201323:FATAL:browser/safe_browsing/safe_browsing_database_impl.cc(712)]
+// Check failed: false.
+//
// Like DatabaseOldIO but only the deletes.
TEST(SafeBrowsingDatabase, DISABLED_DatabaseOldDeletesIO) {
- UpdateDatabase(L"old\\SafeBrowsing", L"old\\response", L"");
+ UpdateDatabase(GetOldSafeBrowsingPath(), GetOldResponsePath(), L"");
}
// Like DatabaseOldIO but only the updates.
TEST(SafeBrowsingDatabase, DISABLED_DatabaseOldUpdatesIO) {
- UpdateDatabase(L"old\\SafeBrowsing", L"", L"old\\updates");
+ UpdateDatabase(GetOldSafeBrowsingPath(), L"", GetOldUpdatesPath());
}
+// TODO(port): For now on Linux the test below would fail with error below:
+// [1004/201323:FATAL:browser/safe_browsing/safe_browsing_database_impl.cc(712)]
+// Check failed: false.
+//
// Does a a lot of addel's on very large chunks.
TEST(SafeBrowsingDatabase, DISABLED_DatabaseOldLotsofDeletesIO) {
std::vector<ChunksInfo> chunks;
@@ -638,5 +682,5 @@
del.list_name = "goog-malware-shavar";
del.chunk_del.push_back(ChunkRange(3539, 3579));
deletes->push_back(del);
- PeformUpdate(L"old\\SafeBrowsing", chunks, deletes);
+ PeformUpdate(GetOldSafeBrowsingPath(), chunks, deletes);
}
« no previous file with comments | « chrome/browser/safe_browsing/safe_browsing_database_impl_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698