| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 <string> | 5 #include <string> |
| 6 #include <vector> | 6 #include <vector> |
| 7 | 7 |
| 8 #include "base/memory/ref_counted.h" | 8 #include "base/memory/ref_counted.h" |
| 9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
| 10 #include "chrome/browser/safe_browsing/database_manager.h" | 10 #include "chrome/browser/safe_browsing/database_manager.h" |
| (...skipping 21 matching lines...) Expand all Loading... |
| 32 virtual SafeBrowsingService* CreateSafeBrowsingService() OVERRIDE { | 32 virtual SafeBrowsingService* CreateSafeBrowsingService() OVERRIDE { |
| 33 return new FakeSafeBrowsingService(); | 33 return new FakeSafeBrowsingService(); |
| 34 } | 34 } |
| 35 }; | 35 }; |
| 36 | 36 |
| 37 } // namespace | 37 } // namespace |
| 38 | 38 |
| 39 class SafeBrowsingDatabaseManagerTest : public PlatformTest { | 39 class SafeBrowsingDatabaseManagerTest : public PlatformTest { |
| 40 public: | 40 public: |
| 41 | 41 |
| 42 virtual void SetUp() { | 42 virtual void SetUp() OVERRIDE { |
| 43 PlatformTest::SetUp(); | 43 PlatformTest::SetUp(); |
| 44 SafeBrowsingService::RegisterFactory(&factory_); | 44 SafeBrowsingService::RegisterFactory(&factory_); |
| 45 } | 45 } |
| 46 |
| 47 virtual void TearDown() OVERRIDE { |
| 48 SafeBrowsingService::RegisterFactory(NULL); |
| 49 PlatformTest::TearDown(); |
| 50 } |
| 51 |
| 46 bool RunSBHashTest(const safe_browsing_util::ListType list_type, | 52 bool RunSBHashTest(const safe_browsing_util::ListType list_type, |
| 47 const std::vector<SBThreatType>& expected_threats, | 53 const std::vector<SBThreatType>& expected_threats, |
| 48 const std::string& result_list); | 54 const std::string& result_list); |
| 49 | 55 |
| 50 private: | 56 private: |
| 51 TestBrowserThreadBundle thread_bundle_; | 57 TestBrowserThreadBundle thread_bundle_; |
| 52 TestSafeBrowsingServiceFactory factory_; | 58 TestSafeBrowsingServiceFactory factory_; |
| 53 }; | 59 }; |
| 54 | 60 |
| 55 bool SafeBrowsingDatabaseManagerTest::RunSBHashTest( | 61 bool SafeBrowsingDatabaseManagerTest::RunSBHashTest( |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 98 std::vector<SBThreatType> multiple_threats; | 104 std::vector<SBThreatType> multiple_threats; |
| 99 multiple_threats.push_back(SB_THREAT_TYPE_URL_MALWARE); | 105 multiple_threats.push_back(SB_THREAT_TYPE_URL_MALWARE); |
| 100 multiple_threats.push_back(SB_THREAT_TYPE_URL_PHISHING); | 106 multiple_threats.push_back(SB_THREAT_TYPE_URL_PHISHING); |
| 101 EXPECT_FALSE(RunSBHashTest(safe_browsing_util::MALWARE, | 107 EXPECT_FALSE(RunSBHashTest(safe_browsing_util::MALWARE, |
| 102 multiple_threats, | 108 multiple_threats, |
| 103 safe_browsing_util::kBinUrlList)); | 109 safe_browsing_util::kBinUrlList)); |
| 104 EXPECT_TRUE(RunSBHashTest(safe_browsing_util::MALWARE, | 110 EXPECT_TRUE(RunSBHashTest(safe_browsing_util::MALWARE, |
| 105 multiple_threats, | 111 multiple_threats, |
| 106 safe_browsing_util::kMalwareList)); | 112 safe_browsing_util::kMalwareList)); |
| 107 } | 113 } |
| OLD | NEW |