| 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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 44 virtual ~MockClientSideDetectionService() {}; | 44 virtual ~MockClientSideDetectionService() {}; |
| 45 | 45 |
| 46 MOCK_CONST_METHOD1(IsBadIpAddress, bool(const std::string&)); | 46 MOCK_CONST_METHOD1(IsBadIpAddress, bool(const std::string&)); |
| 47 }; | 47 }; |
| 48 } // namespace | 48 } // namespace |
| 49 | 49 |
| 50 class BrowserFeatureExtractorTest : public ChromeRenderViewHostTestHarness { | 50 class BrowserFeatureExtractorTest : public ChromeRenderViewHostTestHarness { |
| 51 protected: | 51 protected: |
| 52 virtual void SetUp() { | 52 virtual void SetUp() { |
| 53 ChromeRenderViewHostTestHarness::SetUp(); | 53 ChromeRenderViewHostTestHarness::SetUp(); |
| 54 profile()->CreateHistoryService(true /* delete_file */, false /* no_db */); | 54 ASSERT_TRUE(profile()->CreateHistoryService( |
| 55 true /* delete_file */, false /* no_db */)); |
| 55 service_.reset(new StrictMock<MockClientSideDetectionService>()); | 56 service_.reset(new StrictMock<MockClientSideDetectionService>()); |
| 56 extractor_.reset( | 57 extractor_.reset( |
| 57 new BrowserFeatureExtractor(web_contents(), service_.get())); | 58 new BrowserFeatureExtractor(web_contents(), service_.get())); |
| 58 num_pending_ = 0; | 59 num_pending_ = 0; |
| 59 browse_info_.reset(new BrowseInfo); | 60 browse_info_.reset(new BrowseInfo); |
| 60 } | 61 } |
| 61 | 62 |
| 62 virtual void TearDown() { | 63 virtual void TearDown() { |
| 63 extractor_.reset(); | 64 extractor_.reset(); |
| 64 profile()->DestroyHistoryService(); | 65 profile()->DestroyHistoryService(); |
| (...skipping 504 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 569 EXPECT_TRUE(hosts.find("evil.com") != hosts.end()); | 570 EXPECT_TRUE(hosts.find("evil.com") != hosts.end()); |
| 570 feature_name = base::StringPrintf("%s%s", features::kBadIpFetch, | 571 feature_name = base::StringPrintf("%s%s", features::kBadIpFetch, |
| 571 "92.92.92.92"); | 572 "92.92.92.92"); |
| 572 EXPECT_TRUE(features.count(feature_name)); | 573 EXPECT_TRUE(features.count(feature_name)); |
| 573 hosts = features[feature_name]; | 574 hosts = features[feature_name]; |
| 574 EXPECT_EQ(2U, hosts.size()); | 575 EXPECT_EQ(2U, hosts.size()); |
| 575 EXPECT_TRUE(hosts.find("bad.com") != hosts.end()); | 576 EXPECT_TRUE(hosts.find("bad.com") != hosts.end()); |
| 576 EXPECT_TRUE(hosts.find("evil.com") != hosts.end()); | 577 EXPECT_TRUE(hosts.find("evil.com") != hosts.end()); |
| 577 } | 578 } |
| 578 } // namespace safe_browsing | 579 } // namespace safe_browsing |
| OLD | NEW |