Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(273)

Side by Side Diff: chrome/browser/safe_browsing/test_safe_browsing_service.cc

Issue 2675063002: Browser tests for using the new SafeBrowsing protocol (v4) (Closed)
Patch Set: Nit: Add comments in tests Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2016 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2016 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/test_safe_browsing_service.h" 5 #include "chrome/browser/safe_browsing/test_safe_browsing_service.h"
6 6
7 #include "base/strings/string_util.h" 7 #include "base/strings/string_util.h"
8 #include "chrome/browser/safe_browsing/download_protection_service.h" 8 #include "chrome/browser/safe_browsing/download_protection_service.h"
9 #include "chrome/browser/safe_browsing/ping_manager.h" 9 #include "chrome/browser/safe_browsing/ping_manager.h"
10 #include "chrome/browser/safe_browsing/ui_manager.h" 10 #include "chrome/browser/safe_browsing/ui_manager.h"
11 #include "components/safe_browsing_db/database_manager.h" 11 #include "components/safe_browsing_db/database_manager.h"
12 #include "components/safe_browsing_db/test_database_manager.h" 12 #include "components/safe_browsing_db/test_database_manager.h"
13 #include "components/safe_browsing_db/v4_feature_list.h"
13 14
14 namespace safe_browsing { 15 namespace safe_browsing {
15 16
16 // TestSafeBrowsingService functions: 17 // TestSafeBrowsingService functions:
17 TestSafeBrowsingService::TestSafeBrowsingService() 18 TestSafeBrowsingService::TestSafeBrowsingService(
18 : protocol_manager_delegate_disabled_(false), 19 V4FeatureList::V4UsageStatus v4_usage_status)
20 : SafeBrowsingService(v4_usage_status),
21 protocol_manager_delegate_disabled_(false),
19 serialized_download_report_(base::EmptyString()) {} 22 serialized_download_report_(base::EmptyString()) {}
20 23
21 TestSafeBrowsingService::~TestSafeBrowsingService() {} 24 TestSafeBrowsingService::~TestSafeBrowsingService() {}
22 25
23 SafeBrowsingProtocolConfig TestSafeBrowsingService::GetProtocolConfig() const { 26 SafeBrowsingProtocolConfig TestSafeBrowsingService::GetProtocolConfig() const {
24 if (protocol_config_) 27 if (protocol_config_)
25 return *protocol_config_; 28 return *protocol_config_;
26 return SafeBrowsingService::GetProtocolConfig(); 29 return SafeBrowsingService::GetProtocolConfig();
27 } 30 }
28 31
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 SafeBrowsingProtocolConfig* protocol_config) { 86 SafeBrowsingProtocolConfig* protocol_config) {
84 protocol_config_.reset(protocol_config); 87 protocol_config_.reset(protocol_config);
85 } 88 }
86 89
87 void TestSafeBrowsingService::SetV4ProtocolConfig( 90 void TestSafeBrowsingService::SetV4ProtocolConfig(
88 V4ProtocolConfig* v4_protocol_config) { 91 V4ProtocolConfig* v4_protocol_config) {
89 v4_protocol_config_.reset(v4_protocol_config); 92 v4_protocol_config_.reset(v4_protocol_config);
90 } 93 }
91 94
92 // TestSafeBrowsingServiceFactory functions: 95 // TestSafeBrowsingServiceFactory functions:
93 TestSafeBrowsingServiceFactory::TestSafeBrowsingServiceFactory() 96 TestSafeBrowsingServiceFactory::TestSafeBrowsingServiceFactory(
94 : test_safe_browsing_service_(nullptr), test_protocol_config_(nullptr) {} 97 V4FeatureList::V4UsageStatus v4_usage_status)
98 : test_safe_browsing_service_(nullptr),
99 test_protocol_config_(nullptr),
100 v4_usage_status_(v4_usage_status) {}
95 101
96 TestSafeBrowsingServiceFactory::~TestSafeBrowsingServiceFactory() {} 102 TestSafeBrowsingServiceFactory::~TestSafeBrowsingServiceFactory() {}
97 103
98 SafeBrowsingService* 104 SafeBrowsingService*
99 TestSafeBrowsingServiceFactory::CreateSafeBrowsingService() { 105 TestSafeBrowsingServiceFactory::CreateSafeBrowsingService() {
100 // Instantiate TestSafeBrowsingService. 106 // Instantiate TestSafeBrowsingService.
101 test_safe_browsing_service_ = new TestSafeBrowsingService(); 107 test_safe_browsing_service_ = new TestSafeBrowsingService(v4_usage_status_);
102 // Plug-in test member clases accordingly. 108 // Plug-in test member clases accordingly.
103 if (test_ui_manager_) 109 if (test_ui_manager_)
104 test_safe_browsing_service_->SetUIManager(test_ui_manager_.get()); 110 test_safe_browsing_service_->SetUIManager(test_ui_manager_.get());
105 if (test_database_manager_) { 111 if (test_database_manager_) {
106 test_safe_browsing_service_->SetDatabaseManager( 112 test_safe_browsing_service_->SetDatabaseManager(
107 test_database_manager_.get()); 113 test_database_manager_.get());
108 } 114 }
109 if (test_protocol_config_) 115 if (test_protocol_config_)
110 test_safe_browsing_service_->SetProtocolConfig(test_protocol_config_); 116 test_safe_browsing_service_->SetProtocolConfig(test_protocol_config_);
111 return test_safe_browsing_service_; 117 return test_safe_browsing_service_;
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
148 const std::string& serialized) { 154 const std::string& serialized) {
149 details_.push_back(serialized); 155 details_.push_back(serialized);
150 } 156 }
151 157
152 std::list<std::string>* TestSafeBrowsingUIManager::GetThreatDetails() { 158 std::list<std::string>* TestSafeBrowsingUIManager::GetThreatDetails() {
153 return &details_; 159 return &details_;
154 } 160 }
155 161
156 TestSafeBrowsingUIManager::~TestSafeBrowsingUIManager() {} 162 TestSafeBrowsingUIManager::~TestSafeBrowsingUIManager() {}
157 } // namespace safe_browsing 163 } // namespace safe_browsing
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698