summaryrefslogtreecommitdiffstats
path: root/chrome/browser/safe_browsing
diff options
context:
space:
mode:
authortc@google.com <tc@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-09-17 18:16:01 +0000
committertc@google.com <tc@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-09-17 18:16:01 +0000
commit954bc8a57743da5092b218285b4b8f14239235dd (patch)
tree32976cb1f0b7a534b8d4f44fec2e91dd146c1d74 /chrome/browser/safe_browsing
parent22514d70ddb3ce5a3eb99cd022f909d5d7298793 (diff)
downloadchromium_src-954bc8a57743da5092b218285b4b8f14239235dd.zip
chromium_src-954bc8a57743da5092b218285b4b8f14239235dd.tar.gz
chromium_src-954bc8a57743da5092b218285b4b8f14239235dd.tar.bz2
Include chrome SConscript.unit_tests in Linux build.
BUG=2335 Original patch by phajdan.jr@gmail.com in http://codereview.chromium.org/2891 R=mark,sgk Review URL: http://codereview.chromium.org/2939 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@2319 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/safe_browsing')
-rw-r--r--chrome/browser/safe_browsing/chunk_range_unittest.cc20
-rw-r--r--chrome/browser/safe_browsing/protocol_parser_unittest.cc64
-rw-r--r--chrome/browser/safe_browsing/safe_browsing_util_unittest.cc10
3 files changed, 42 insertions, 52 deletions
diff --git a/chrome/browser/safe_browsing/chunk_range_unittest.cc b/chrome/browser/safe_browsing/chunk_range_unittest.cc
index bc409aa..e467dfd 100644
--- a/chrome/browser/safe_browsing/chunk_range_unittest.cc
+++ b/chrome/browser/safe_browsing/chunk_range_unittest.cc
@@ -48,7 +48,7 @@ TEST(SafeBrowsingChunkRangeTest, TestChunksToRanges) {
chunks.push_back(4);
chunks.push_back(7);
ChunksToRanges(chunks, &ranges);
- EXPECT_EQ(ranges.size(), 2);
+ EXPECT_EQ(ranges.size(), static_cast<size_t>(2));
EXPECT_EQ(ranges[0].start(), 1);
EXPECT_EQ(ranges[0].stop(), 4);
EXPECT_EQ(ranges[1].start(), 7);
@@ -67,7 +67,7 @@ TEST(SafeBrowsingChunkRangeTest, TestChunksToRanges) {
chunks.push_back(9);
chunks.push_back(10);
ChunksToRanges(chunks, &ranges);
- EXPECT_EQ(ranges.size(), 1);
+ EXPECT_EQ(ranges.size(), static_cast<size_t>(1));
EXPECT_EQ(ranges[0].start(), 3);
EXPECT_EQ(ranges[0].stop(), 10);
@@ -84,7 +84,7 @@ TEST(SafeBrowsingChunkRangeTest, TestChunksToRanges) {
chunks.push_back(15);
chunks.push_back(17);
ChunksToRanges(chunks, &ranges);
- EXPECT_EQ(ranges.size(), 8);
+ EXPECT_EQ(ranges.size(), static_cast<size_t>(8));
chunks.clear();
ranges.clear();
@@ -92,7 +92,7 @@ TEST(SafeBrowsingChunkRangeTest, TestChunksToRanges) {
// Test a single chunk number.
chunks.push_back(17);
ChunksToRanges(chunks, &ranges);
- EXPECT_EQ(ranges.size(), 1);
+ EXPECT_EQ(ranges.size(), static_cast<size_t>(1));
EXPECT_EQ(ranges[0].start(), 17);
EXPECT_EQ(ranges[0].stop(), 17);
@@ -110,7 +110,7 @@ TEST(SafeBrowsingChunkRangeTest, TestChunksToRanges) {
chunks.push_back(7);
chunks.push_back(7);
ChunksToRanges(chunks, &ranges);
- EXPECT_EQ(ranges.size(), 2);
+ EXPECT_EQ(ranges.size(), static_cast<size_t>(2));
EXPECT_EQ(ranges[0].start(), 1);
EXPECT_EQ(ranges[0].stop(), 3);
EXPECT_EQ(ranges[1].start(), 7);
@@ -123,7 +123,7 @@ TEST(SafeBrowsingChunkRangeTest, TestStringToRanges) {
std::string input = "1-100,398,415,1138-2001,2019";
EXPECT_TRUE(StringToRanges(input, &ranges));
- EXPECT_EQ(ranges.size(), 5);
+ EXPECT_EQ(ranges.size(), static_cast<size_t>(5));
EXPECT_EQ(ranges[0].start(), 1);
EXPECT_EQ(ranges[0].stop(), 100);
EXPECT_EQ(ranges[1].start(), 398);
@@ -135,13 +135,13 @@ TEST(SafeBrowsingChunkRangeTest, TestStringToRanges) {
input = "1,2,3,4,5,6,7";
EXPECT_TRUE(StringToRanges(input, &ranges));
- EXPECT_EQ(ranges.size(), 7);
+ EXPECT_EQ(ranges.size(), static_cast<size_t>(7));
ranges.clear();
input = "300-3001";
EXPECT_TRUE(StringToRanges(input, &ranges));
- EXPECT_EQ(ranges.size(), 1);
+ EXPECT_EQ(ranges.size(), static_cast<size_t>(1));
EXPECT_EQ(ranges[0].start(), 300);
EXPECT_EQ(ranges[0].stop(), 3001);
@@ -149,7 +149,7 @@ TEST(SafeBrowsingChunkRangeTest, TestStringToRanges) {
input = "17";
EXPECT_TRUE(StringToRanges(input, &ranges));
- EXPECT_EQ(ranges.size(), 1);
+ EXPECT_EQ(ranges.size(), static_cast<size_t>(1));
EXPECT_EQ(ranges[0].start(), 17);
EXPECT_EQ(ranges[0].stop(), 17);
@@ -168,7 +168,7 @@ TEST(SafeBrowsingChunkRangeTest, TestRangesToChunks) {
std::vector<int> chunks;
RangesToChunks(ranges, &chunks);
- EXPECT_EQ(chunks.size(), 5);
+ EXPECT_EQ(chunks.size(), static_cast<size_t>(5));
EXPECT_EQ(chunks[0], 1);
EXPECT_EQ(chunks[1], 2);
EXPECT_EQ(chunks[2], 3);
diff --git a/chrome/browser/safe_browsing/protocol_parser_unittest.cc b/chrome/browser/safe_browsing/protocol_parser_unittest.cc
index a6d16d5..b05af83 100644
--- a/chrome/browser/safe_browsing/protocol_parser_unittest.cc
+++ b/chrome/browser/safe_browsing/protocol_parser_unittest.cc
@@ -7,7 +7,6 @@
#include "base/hash_tables.h"
#include "base/logging.h"
#include "base/string_util.h"
-#include "base/win_util.h"
#include "chrome/browser/safe_browsing/protocol_parser.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -26,9 +25,9 @@ TEST(SafeBrowsingProtocolParsingTest, TestAddChunk) {
"", "", &re_key, &chunks);
EXPECT_TRUE(result);
EXPECT_FALSE(re_key);
- EXPECT_EQ(chunks.size(), 1);
+ EXPECT_EQ(chunks.size(), static_cast<size_t>(1));
EXPECT_EQ(chunks[0].chunk_number, 1);
- EXPECT_EQ(chunks[0].hosts.size(), 3);
+ EXPECT_EQ(chunks[0].hosts.size(), static_cast<size_t>(3));
EXPECT_EQ(chunks[0].hosts[0].host, 0x61616161);
SBEntry* entry = chunks[0].hosts[0].entry;
@@ -76,9 +75,9 @@ TEST(SafeBrowsingProtocolParsingTest, TestAddFullChunk) {
"", "", &re_key, &chunks);
EXPECT_TRUE(result);
EXPECT_FALSE(re_key);
- EXPECT_EQ(chunks.size(), 1);
+ EXPECT_EQ(chunks.size(), static_cast<size_t>(1));
EXPECT_EQ(chunks[0].chunk_number, 1);
- EXPECT_EQ(chunks[0].hosts.size(), 1);
+ EXPECT_EQ(chunks[0].hosts.size(), static_cast<size_t>(1));
EXPECT_EQ(chunks[0].hosts[0].host, 0x61616161);
SBEntry* entry = chunks[0].hosts[0].entry;
@@ -106,9 +105,9 @@ TEST(SafeBrowsingProtocolParsingTest, TestAddChunks) {
"", "", &re_key, &chunks);
EXPECT_TRUE(result);
EXPECT_FALSE(re_key);
- EXPECT_EQ(chunks.size(), 2);
+ EXPECT_EQ(chunks.size(), static_cast<size_t>(2));
EXPECT_EQ(chunks[0].chunk_number, 1);
- EXPECT_EQ(chunks[0].hosts.size(), 3);
+ EXPECT_EQ(chunks[0].hosts.size(), static_cast<size_t>(3));
EXPECT_EQ(chunks[0].hosts[0].host, 0x61616161);
SBEntry* entry = chunks[0].hosts[0].entry;
@@ -132,7 +131,7 @@ TEST(SafeBrowsingProtocolParsingTest, TestAddChunks) {
EXPECT_EQ(chunks[1].chunk_number, 2);
- EXPECT_EQ(chunks[1].hosts.size(), 1);
+ EXPECT_EQ(chunks[1].hosts.size(), static_cast<size_t>(1));
EXPECT_EQ(chunks[1].hosts[0].host, 0x35353535);
entry = chunks[1].hosts[0].entry;
@@ -164,10 +163,10 @@ TEST(SafeBrowsingProtocolParsingTest, TestAddBigChunk) {
"", "", &re_key, &chunks);
EXPECT_TRUE(result);
EXPECT_FALSE(re_key);
- EXPECT_EQ(chunks.size(), 1);
+ EXPECT_EQ(chunks.size(), static_cast<size_t>(1));
EXPECT_EQ(chunks[0].chunk_number, 1);
- EXPECT_EQ(chunks[0].hosts.size(), 1);
+ EXPECT_EQ(chunks[0].hosts.size(), static_cast<size_t>(1));
const SBChunkHost& host = chunks[0].hosts[0];
EXPECT_EQ(host.host, 0x61616161);
@@ -192,9 +191,9 @@ TEST(SafeBrowsingProtocolParsingTest, TestSubChunk) {
"", "", &re_key, &chunks);
EXPECT_TRUE(result);
EXPECT_FALSE(re_key);
- EXPECT_EQ(chunks.size(), 1);
+ EXPECT_EQ(chunks.size(), static_cast<size_t>(1));
EXPECT_EQ(chunks[0].chunk_number, 9);
- EXPECT_EQ(chunks[0].hosts.size(), 3);
+ EXPECT_EQ(chunks[0].hosts.size(), static_cast<size_t>(3));
EXPECT_EQ(chunks[0].hosts[0].host, 0x61616161);
SBEntry* entry = chunks[0].hosts[0].entry;
@@ -250,9 +249,9 @@ TEST(SafeBrowsingProtocolParsingTest, TestSubFullChunk) {
"", "", &re_key, &chunks);
EXPECT_TRUE(result);
EXPECT_FALSE(re_key);
- EXPECT_EQ(chunks.size(), 1);
+ EXPECT_EQ(chunks.size(), static_cast<size_t>(1));
EXPECT_EQ(chunks[0].chunk_number, 1);
- EXPECT_EQ(chunks[0].hosts.size(), 1);
+ EXPECT_EQ(chunks[0].hosts.size(), static_cast<size_t>(1));
EXPECT_EQ(chunks[0].hosts[0].host, 0x61616161);
SBEntry* entry = chunks[0].hosts[0].entry;
@@ -286,15 +285,15 @@ TEST(SafeBrowsingProtocolParsingTest, TestChunkDelete) {
EXPECT_FALSE(re_key);
EXPECT_FALSE(reset);
EXPECT_EQ(next_query_sec, 1700);
- EXPECT_EQ(deletes.size(), 2);
+ EXPECT_EQ(deletes.size(), static_cast<size_t>(2));
- EXPECT_EQ(deletes[0].chunk_del.size(), 4);
+ EXPECT_EQ(deletes[0].chunk_del.size(), static_cast<size_t>(4));
EXPECT_TRUE(deletes[0].chunk_del[0] == ChunkRange(1, 7));
EXPECT_TRUE(deletes[0].chunk_del[1] == ChunkRange(43, 597));
EXPECT_TRUE(deletes[0].chunk_del[2] == ChunkRange(44444));
EXPECT_TRUE(deletes[0].chunk_del[3] == ChunkRange(99999));
- EXPECT_EQ(deletes[1].chunk_del.size(), 3);
+ EXPECT_EQ(deletes[1].chunk_del.size(), static_cast<size_t>(3));
EXPECT_TRUE(deletes[1].chunk_del[0] == ChunkRange(21, 27));
EXPECT_TRUE(deletes[1].chunk_del[1] == ChunkRange(42));
EXPECT_TRUE(deletes[1].chunk_del[2] == ChunkRange(171717));
@@ -333,7 +332,7 @@ TEST(SafeBrowsingProtocolParsingTest, TestRedirects) {
EXPECT_FALSE(re_key);
EXPECT_FALSE(reset);
- EXPECT_EQ(urls.size(), 4);
+ EXPECT_EQ(urls.size(), static_cast<size_t>(4));
EXPECT_EQ(urls[0].url,
"cache.googlevideo.com/safebrowsing/rd/goog-malware-shavar_s_1");
EXPECT_EQ(urls[1].url,
@@ -369,7 +368,7 @@ TEST(SafeBrowsingProtocolParsingTest, TestRedirectsWithMac) {
EXPECT_FALSE(re_key);
EXPECT_FALSE(reset);
- EXPECT_EQ(urls.size(), 2);
+ EXPECT_EQ(urls.size(), static_cast<size_t>(2));
EXPECT_EQ(urls[0].url,
"s.ytimg.com/safebrowsing/rd/goog-phish-shavar_s_6501-6505:6501-6505");
EXPECT_EQ(urls[0].mac, "pcY6iVeT9-CBQ3fdAF0rpnKjR1Y=");
@@ -415,7 +414,7 @@ TEST(SafeBrowsingProtocolParsingTest, TestGetHash) {
&full_hashes);
EXPECT_FALSE(re_key);
- EXPECT_EQ(full_hashes.size(), 3);
+ EXPECT_EQ(full_hashes.size(), static_cast<size_t>(3));
EXPECT_EQ(memcmp(&full_hashes[0].hash,
"00112233445566778899aabbccddeeff",
sizeof(SBFullHash)), 0);
@@ -441,7 +440,7 @@ TEST(SafeBrowsingProtocolParsingTest, TestGetHash) {
&full_hashes);
EXPECT_FALSE(re_key);
- EXPECT_EQ(full_hashes.size(), 3);
+ EXPECT_EQ(full_hashes.size(), static_cast<size_t>(3));
EXPECT_EQ(memcmp(&full_hashes[0].hash,
"00112233445566778899aabbccddeeff",
sizeof(SBFullHash)), 0);
@@ -456,12 +455,9 @@ TEST(SafeBrowsingProtocolParsingTest, TestGetHash) {
EXPECT_EQ(full_hashes[2].list_name, "goog-malware-shavar");
}
+// TODO(port): Enable when we have ported VerifyMAC in safe_browsing_util.cc.
+#if defined(OS_WIN)
TEST(SafeBrowsingProtocolParsingTest, TestGetHashWithMac) {
- // TODO(paulg): Bug: http://b/1084719, skip this test on Windows 2000 until
- // this bug is fixed.
- if (win_util::GetWinVersion() <= win_util::WINVERSION_2000)
- return;
-
const unsigned char get_hash[] = {
0x32, 0x56, 0x74, 0x6f, 0x6b, 0x36, 0x64, 0x41,
0x51, 0x72, 0x65, 0x51, 0x62, 0x38, 0x51, 0x68,
@@ -493,9 +489,10 @@ TEST(SafeBrowsingProtocolParsingTest, TestGetHashWithMac) {
&re_key,
&full_hashes));
EXPECT_FALSE(re_key);
- EXPECT_EQ(full_hashes.size(), 1);
+ EXPECT_EQ(full_hashes.size(), static_cast<size_t>(1));
EXPECT_EQ(memcmp(hash_result, &full_hashes[0].hash, sizeof(SBFullHash)), 0);
}
+#endif // defined(OS_WIN)
TEST(SafeBrowsingProtocolParsingTest, TestFormatHash) {
@@ -558,12 +555,9 @@ TEST(SafeBrowsingProtocolParsingTest, TestReset) {
EXPECT_TRUE(reset);
}
+// TODO(port): Enable when we have ported VerifyMAC in safe_browsing_util.cc.
+#if defined(OS_WIN)
TEST(SafeBrowsingProtocolParsingTest, TestVerifyUpdateMac) {
- // TODO(paulg): Bug: http://b/1084719, skip this test on Windows 2000 until
- // this bug is fixed.
- if (win_util::GetWinVersion() <= win_util::WINVERSION_2000)
- return;
-
SafeBrowsingProtocolParser parser;
const std::string update =
@@ -599,11 +593,6 @@ TEST(SafeBrowsingProtocolParsingTest, TestVerifyUpdateMac) {
}
TEST(SafeBrowsingProtocolParsingTest, TestVerifyChunkMac) {
- // TODO(paulg): Bug: http://b/1084719, skip this test on Windows 2000 until
- // this bug is fixed.
- if (win_util::GetWinVersion() <= win_util::WINVERSION_2000)
- return;
-
SafeBrowsingProtocolParser parser;
const unsigned char chunk[] = {
@@ -626,3 +615,4 @@ TEST(SafeBrowsingProtocolParsingTest, TestVerifyChunkMac) {
safe_browsing_util::FreeChunks(&chunks);
}
+#endif // defined(OS_WIN)
diff --git a/chrome/browser/safe_browsing/safe_browsing_util_unittest.cc b/chrome/browser/safe_browsing/safe_browsing_util_unittest.cc
index 9cb1167..2486117 100644
--- a/chrome/browser/safe_browsing/safe_browsing_util_unittest.cc
+++ b/chrome/browser/safe_browsing/safe_browsing_util_unittest.cc
@@ -37,8 +37,8 @@ TEST(SafeBrowsingUtilTest, UrlParsing) {
GURL url("http://a.b.c/1/2.html?param=1");
safe_browsing_util::GenerateHostsToCheck(url, &hosts);
safe_browsing_util::GeneratePathsToCheck(url, &paths);
- EXPECT_EQ(hosts.size(), 2);
- EXPECT_EQ(paths.size(), 4);
+ EXPECT_EQ(hosts.size(), static_cast<size_t>(2));
+ EXPECT_EQ(paths.size(), static_cast<size_t>(4));
EXPECT_EQ(hosts[0], "b.c");
EXPECT_EQ(hosts[1], "a.b.c");
@@ -50,8 +50,8 @@ TEST(SafeBrowsingUtilTest, UrlParsing) {
url = GURL("http://a.b.c.d.e.f.g/1.html");
safe_browsing_util::GenerateHostsToCheck(url, &hosts);
safe_browsing_util::GeneratePathsToCheck(url, &paths);
- EXPECT_EQ(hosts.size(), 5);
- EXPECT_EQ(paths.size(), 2);
+ EXPECT_EQ(hosts.size(), static_cast<size_t>(5));
+ EXPECT_EQ(paths.size(), static_cast<size_t>(2));
EXPECT_EQ(hosts[0], "f.g");
EXPECT_EQ(hosts[1], "e.f.g");
EXPECT_EQ(hosts[2], "d.e.f.g");
@@ -62,7 +62,7 @@ TEST(SafeBrowsingUtilTest, UrlParsing) {
url = GURL("http://a.b/saw-cgi/eBayISAPI.dll/");
safe_browsing_util::GeneratePathsToCheck(url, &paths);
- EXPECT_EQ(paths.size(), 3);
+ EXPECT_EQ(paths.size(), static_cast<size_t>(3));
EXPECT_TRUE(VectorContains(paths, "/saw-cgi/eBayISAPI.dll/"));
EXPECT_TRUE(VectorContains(paths, "/saw-cgi/"));
EXPECT_TRUE(VectorContains(paths, "/"));