| 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 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 71 } | 71 } |
| 72 | 72 |
| 73 virtual ~MockClientSideDetectionHost() {} | 73 virtual ~MockClientSideDetectionHost() {} |
| 74 | 74 |
| 75 MOCK_METHOD1(IsBadIpAddress, bool(const std::string&)); | 75 MOCK_METHOD1(IsBadIpAddress, bool(const std::string&)); |
| 76 }; | 76 }; |
| 77 } // namespace | 77 } // namespace |
| 78 | 78 |
| 79 class BrowserFeatureExtractorTest : public ChromeRenderViewHostTestHarness { | 79 class BrowserFeatureExtractorTest : public ChromeRenderViewHostTestHarness { |
| 80 protected: | 80 protected: |
| 81 virtual void SetUp() { | 81 void SetUp() override { |
| 82 ChromeRenderViewHostTestHarness::SetUp(); | 82 ChromeRenderViewHostTestHarness::SetUp(); |
| 83 ASSERT_TRUE(profile()->CreateHistoryService( | 83 ASSERT_TRUE(profile()->CreateHistoryService( |
| 84 true /* delete_file */, false /* no_db */)); | 84 true /* delete_file */, false /* no_db */)); |
| 85 | 85 |
| 86 db_manager_ = new StrictMock<MockSafeBrowsingDatabaseManager>( | 86 db_manager_ = new StrictMock<MockSafeBrowsingDatabaseManager>( |
| 87 SafeBrowsingService::CreateSafeBrowsingService()); | 87 SafeBrowsingService::CreateSafeBrowsingService()); |
| 88 host_.reset(new StrictMock<MockClientSideDetectionHost>( | 88 host_.reset(new StrictMock<MockClientSideDetectionHost>( |
| 89 web_contents(), db_manager_.get())); | 89 web_contents(), db_manager_.get())); |
| 90 extractor_.reset( | 90 extractor_.reset( |
| 91 new BrowserFeatureExtractor(web_contents(), host_.get())); | 91 new BrowserFeatureExtractor(web_contents(), host_.get())); |
| 92 num_pending_ = 0; | 92 num_pending_ = 0; |
| 93 browse_info_.reset(new BrowseInfo); | 93 browse_info_.reset(new BrowseInfo); |
| 94 } | 94 } |
| 95 | 95 |
| 96 virtual void TearDown() { | 96 void TearDown() override { |
| 97 extractor_.reset(); | 97 extractor_.reset(); |
| 98 host_.reset(); | 98 host_.reset(); |
| 99 db_manager_ = NULL; | 99 db_manager_ = NULL; |
| 100 profile()->DestroyHistoryService(); | 100 profile()->DestroyHistoryService(); |
| 101 ChromeRenderViewHostTestHarness::TearDown(); | 101 ChromeRenderViewHostTestHarness::TearDown(); |
| 102 ASSERT_EQ(0, num_pending_); | 102 ASSERT_EQ(0, num_pending_); |
| 103 } | 103 } |
| 104 | 104 |
| 105 HistoryService* history_service() { | 105 HistoryService* history_service() { |
| 106 return HistoryServiceFactory::GetForProfile(profile(), | 106 return HistoryServiceFactory::GetForProfile(profile(), |
| (...skipping 543 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 650 // First ip is good but all the others are bad. | 650 // First ip is good but all the others are bad. |
| 651 EXPECT_CALL(*db_manager_, MatchMalwareIP(ip)).WillOnce(Return(i > 0)); | 651 EXPECT_CALL(*db_manager_, MatchMalwareIP(ip)).WillOnce(Return(i > 0)); |
| 652 } | 652 } |
| 653 | 653 |
| 654 ExtractMalwareFeatures(&request); | 654 ExtractMalwareFeatures(&request); |
| 655 // The number of IP matched url we store is capped at 5 IPs per request. | 655 // The number of IP matched url we store is capped at 5 IPs per request. |
| 656 EXPECT_EQ(5, request.bad_ip_url_info_size()); | 656 EXPECT_EQ(5, request.bad_ip_url_info_size()); |
| 657 } | 657 } |
| 658 | 658 |
| 659 } // namespace safe_browsing | 659 } // namespace safe_browsing |
| OLD | NEW |