| 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 #include "chrome/browser/safe_browsing/browser_feature_extractor.h" | 5 #include "chrome/browser/safe_browsing/browser_feature_extractor.h" |
| 6 | 6 |
| 7 #include <map> | 7 #include <map> |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 62 | 62 |
| 63 class MockClientSideDetectionHost : public ClientSideDetectionHost { | 63 class MockClientSideDetectionHost : public ClientSideDetectionHost { |
| 64 public: | 64 public: |
| 65 MockClientSideDetectionHost( | 65 MockClientSideDetectionHost( |
| 66 content::WebContents* tab, | 66 content::WebContents* tab, |
| 67 SafeBrowsingDatabaseManager* database_manager) | 67 SafeBrowsingDatabaseManager* database_manager) |
| 68 : ClientSideDetectionHost(tab) { | 68 : ClientSideDetectionHost(tab) { |
| 69 set_safe_browsing_managers(NULL, database_manager); | 69 set_safe_browsing_managers(NULL, database_manager); |
| 70 } | 70 } |
| 71 | 71 |
| 72 virtual ~MockClientSideDetectionHost() {}; | 72 virtual ~MockClientSideDetectionHost() {} |
| 73 | 73 |
| 74 MOCK_METHOD1(IsBadIpAddress, bool(const std::string&)); | 74 MOCK_METHOD1(IsBadIpAddress, bool(const std::string&)); |
| 75 }; | 75 }; |
| 76 } // namespace | 76 } // namespace |
| 77 | 77 |
| 78 class BrowserFeatureExtractorTest : public ChromeRenderViewHostTestHarness { | 78 class BrowserFeatureExtractorTest : public ChromeRenderViewHostTestHarness { |
| 79 protected: | 79 protected: |
| 80 virtual void SetUp() { | 80 virtual void SetUp() { |
| 81 ChromeRenderViewHostTestHarness::SetUp(); | 81 ChromeRenderViewHostTestHarness::SetUp(); |
| 82 ASSERT_TRUE(profile()->CreateHistoryService( | 82 ASSERT_TRUE(profile()->CreateHistoryService( |
| (...skipping 562 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 645 // First ip is good but all the others are bad. | 645 // First ip is good but all the others are bad. |
| 646 EXPECT_CALL(*db_manager_, MatchMalwareIP(ip)).WillOnce(Return(i > 0)); | 646 EXPECT_CALL(*db_manager_, MatchMalwareIP(ip)).WillOnce(Return(i > 0)); |
| 647 } | 647 } |
| 648 | 648 |
| 649 ExtractMalwareFeatures(&request); | 649 ExtractMalwareFeatures(&request); |
| 650 // The number of IP matched url we store is capped at 5 IPs per request. | 650 // The number of IP matched url we store is capped at 5 IPs per request. |
| 651 EXPECT_EQ(5, request.bad_ip_url_info_size()); | 651 EXPECT_EQ(5, request.bad_ip_url_info_size()); |
| 652 } | 652 } |
| 653 | 653 |
| 654 } // namespace safe_browsing | 654 } // namespace safe_browsing |
| OLD | NEW |