| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #include <algorithm> | 5 #include <algorithm> |
| 6 | 6 |
| 7 #include "base/strings/stringprintf.h" | 7 #include "base/strings/stringprintf.h" |
| 8 #include "chrome/browser/safe_browsing/safe_browsing_util.h" | 8 #include "chrome/browser/safe_browsing/safe_browsing_util.h" |
| 9 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
| 10 #include "url/gurl.h" | 10 #include "url/gurl.h" |
| (...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 270 | 270 |
| 271 EXPECT_EQ(tests[i].expected_canonicalized_hostname, | 271 EXPECT_EQ(tests[i].expected_canonicalized_hostname, |
| 272 canonicalized_hostname); | 272 canonicalized_hostname); |
| 273 EXPECT_EQ(tests[i].expected_canonicalized_path, | 273 EXPECT_EQ(tests[i].expected_canonicalized_path, |
| 274 canonicalized_path); | 274 canonicalized_path); |
| 275 EXPECT_EQ(tests[i].expected_canonicalized_query, | 275 EXPECT_EQ(tests[i].expected_canonicalized_query, |
| 276 canonicalized_query); | 276 canonicalized_query); |
| 277 } | 277 } |
| 278 } | 278 } |
| 279 | 279 |
| 280 TEST(SafeBrowsingUtilTest, GetUrlHashIndex) { | |
| 281 GURL url("http://www.evil.com/phish.html"); | |
| 282 SBFullHashResult full_hash; | |
| 283 full_hash.hash = SBFullHashForString(url.host() + url.path()); | |
| 284 std::vector<SBFullHashResult> full_hashes; | |
| 285 full_hashes.push_back(full_hash); | |
| 286 | |
| 287 EXPECT_EQ(safe_browsing_util::GetUrlHashIndex(url, full_hashes), 0); | |
| 288 | |
| 289 url = GURL("http://www.evil.com/okay_path.html"); | |
| 290 EXPECT_EQ(safe_browsing_util::GetUrlHashIndex(url, full_hashes), -1); | |
| 291 } | |
| 292 | |
| 293 TEST(SafeBrowsingUtilTest, ListIdListNameConversion) { | 280 TEST(SafeBrowsingUtilTest, ListIdListNameConversion) { |
| 294 std::string list_name; | 281 std::string list_name; |
| 295 EXPECT_FALSE(safe_browsing_util::GetListName(safe_browsing_util::INVALID, | 282 EXPECT_FALSE(safe_browsing_util::GetListName(safe_browsing_util::INVALID, |
| 296 &list_name)); | 283 &list_name)); |
| 297 EXPECT_TRUE(safe_browsing_util::GetListName(safe_browsing_util::MALWARE, | 284 EXPECT_TRUE(safe_browsing_util::GetListName(safe_browsing_util::MALWARE, |
| 298 &list_name)); | 285 &list_name)); |
| 299 EXPECT_EQ(list_name, std::string(safe_browsing_util::kMalwareList)); | 286 EXPECT_EQ(list_name, std::string(safe_browsing_util::kMalwareList)); |
| 300 EXPECT_EQ(safe_browsing_util::MALWARE, | 287 EXPECT_EQ(safe_browsing_util::MALWARE, |
| 301 safe_browsing_util::GetListId(list_name)); | 288 safe_browsing_util::GetListId(list_name)); |
| 302 | 289 |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 343 EXPECT_FALSE(SBFullHashEqual(kHash2, kHash1)); | 330 EXPECT_FALSE(SBFullHashEqual(kHash2, kHash1)); |
| 344 | 331 |
| 345 EXPECT_FALSE(SBFullHashLess(kHash1, kHash2)); | 332 EXPECT_FALSE(SBFullHashLess(kHash1, kHash2)); |
| 346 EXPECT_TRUE(SBFullHashLess(kHash2, kHash1)); | 333 EXPECT_TRUE(SBFullHashLess(kHash2, kHash1)); |
| 347 | 334 |
| 348 EXPECT_FALSE(SBFullHashLess(kHash1, kHash1)); | 335 EXPECT_FALSE(SBFullHashLess(kHash1, kHash1)); |
| 349 EXPECT_FALSE(SBFullHashLess(kHash2, kHash2)); | 336 EXPECT_FALSE(SBFullHashLess(kHash2, kHash2)); |
| 350 } | 337 } |
| 351 | 338 |
| 352 } // namespace | 339 } // namespace |
| OLD | NEW |