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