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

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

Issue 2675063002: Browser tests for using the new SafeBrowsing protocol (v4) (Closed)
Patch Set: shess@'s review 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 #ifndef CHROME_BROWSER_SAFE_BROWSING_TEST_SAFE_BROWSING_SERVICE_H_ 5 #ifndef CHROME_BROWSER_SAFE_BROWSING_TEST_SAFE_BROWSING_SERVICE_H_
6 #define CHROME_BROWSER_SAFE_BROWSING_TEST_SAFE_BROWSING_SERVICE_H_ 6 #define CHROME_BROWSER_SAFE_BROWSING_TEST_SAFE_BROWSING_SERVICE_H_
7 7
8 #include "chrome/browser/safe_browsing/safe_browsing_service.h" 8 #include "chrome/browser/safe_browsing/safe_browsing_service.h"
9 9
10 #include "chrome/browser/safe_browsing/protocol_manager.h" 10 #include "chrome/browser/safe_browsing/protocol_manager.h"
(...skipping 22 matching lines...) Expand all
33 // (3) Register TestSafeBrowsingServiceFactory 33 // (3) Register TestSafeBrowsingServiceFactory
34 // SafeBrowsingService::RegisterFactory(test_sb_factory_); 34 // SafeBrowsingService::RegisterFactory(test_sb_factory_);
35 // (4) InProcessBrowserTest::SetUp() or other base class SetUp() function must 35 // (4) InProcessBrowserTest::SetUp() or other base class SetUp() function must
36 // be called at last. 36 // be called at last.
37 // * When overriding TearDown(): 37 // * When overriding TearDown():
38 // Call base class TearDown() first then call 38 // Call base class TearDown() first then call
39 // SafeBrowsingService::RegisterFactory(nullptr) to unregister 39 // SafeBrowsingService::RegisterFactory(nullptr) to unregister
40 // test_sb_factory_. 40 // test_sb_factory_.
41 class TestSafeBrowsingService : public SafeBrowsingService { 41 class TestSafeBrowsingService : public SafeBrowsingService {
42 public: 42 public:
43 TestSafeBrowsingService(); 43 explicit TestSafeBrowsingService(V4UsageStatus v4_usage_status);
44 // SafeBrowsingService overrides 44 // SafeBrowsingService overrides
45 SafeBrowsingProtocolConfig GetProtocolConfig() const override; 45 SafeBrowsingProtocolConfig GetProtocolConfig() const override;
46 V4ProtocolConfig GetV4ProtocolConfig() const override; 46 V4ProtocolConfig GetV4ProtocolConfig() const override;
47 47
48 std::string serilized_download_report(); 48 std::string serilized_download_report();
49 void ClearDownloadReport(); 49 void ClearDownloadReport();
50 50
51 // In browser tests, the following setters must be called before 51 // In browser tests, the following setters must be called before
52 // SafeBrowsingService::Initialize(). 52 // SafeBrowsingService::Initialize().
53 // The preferable way to use these setters is by calling corresponding 53 // The preferable way to use these setters is by calling corresponding
(...skipping 19 matching lines...) Expand all
73 bool protocol_manager_delegate_disabled_; 73 bool protocol_manager_delegate_disabled_;
74 std::unique_ptr<SafeBrowsingProtocolConfig> protocol_config_; 74 std::unique_ptr<SafeBrowsingProtocolConfig> protocol_config_;
75 std::unique_ptr<V4ProtocolConfig> v4_protocol_config_; 75 std::unique_ptr<V4ProtocolConfig> v4_protocol_config_;
76 std::string serialized_download_report_; 76 std::string serialized_download_report_;
77 77
78 DISALLOW_COPY_AND_ASSIGN(TestSafeBrowsingService); 78 DISALLOW_COPY_AND_ASSIGN(TestSafeBrowsingService);
79 }; 79 };
80 80
81 class TestSafeBrowsingServiceFactory : public SafeBrowsingServiceFactory { 81 class TestSafeBrowsingServiceFactory : public SafeBrowsingServiceFactory {
82 public: 82 public:
83 TestSafeBrowsingServiceFactory(); 83 explicit TestSafeBrowsingServiceFactory(
84 V4UsageStatus v4_usage_status = V4UsageStatus::V4_DISABLED);
84 ~TestSafeBrowsingServiceFactory() override; 85 ~TestSafeBrowsingServiceFactory() override;
85 86
86 // Creates test safe browsing service, and configures test UI manager, 87 // Creates test safe browsing service, and configures test UI manager,
87 // database manager and so on. 88 // database manager and so on.
88 SafeBrowsingService* CreateSafeBrowsingService() override; 89 SafeBrowsingService* CreateSafeBrowsingService() override;
89 90
90 TestSafeBrowsingService* test_safe_browsing_service(); 91 TestSafeBrowsingService* test_safe_browsing_service();
91 92
92 // Test UI manager, database manager and protocol config need to be set before 93 // Test UI manager, database manager and protocol config need to be set before
93 // SafeBrowsingService::Initialize() is called. 94 // SafeBrowsingService::Initialize() is called.
94 void SetTestUIManager(TestSafeBrowsingUIManager* ui_manager); 95 void SetTestUIManager(TestSafeBrowsingUIManager* ui_manager);
95 void SetTestDatabaseManager( 96 void SetTestDatabaseManager(
96 TestSafeBrowsingDatabaseManager* database_manager); 97 TestSafeBrowsingDatabaseManager* database_manager);
97 void SetTestProtocolConfig(const SafeBrowsingProtocolConfig& protocol_config); 98 void SetTestProtocolConfig(const SafeBrowsingProtocolConfig& protocol_config);
98 99
99 private: 100 private:
100 TestSafeBrowsingService* test_safe_browsing_service_; 101 TestSafeBrowsingService* test_safe_browsing_service_;
101 scoped_refptr<TestSafeBrowsingDatabaseManager> test_database_manager_; 102 scoped_refptr<TestSafeBrowsingDatabaseManager> test_database_manager_;
102 scoped_refptr<TestSafeBrowsingUIManager> test_ui_manager_; 103 scoped_refptr<TestSafeBrowsingUIManager> test_ui_manager_;
103 SafeBrowsingProtocolConfig* test_protocol_config_; 104 SafeBrowsingProtocolConfig* test_protocol_config_;
105 V4UsageStatus v4_usage_status_;
104 106
105 DISALLOW_COPY_AND_ASSIGN(TestSafeBrowsingServiceFactory); 107 DISALLOW_COPY_AND_ASSIGN(TestSafeBrowsingServiceFactory);
106 }; 108 };
107 109
108 // This is an implemenation of SafeBrowsingUIManager without actually 110 // This is an implemenation of SafeBrowsingUIManager without actually
109 // sending report to safe browsing backend. Safe browsing reports are 111 // sending report to safe browsing backend. Safe browsing reports are
110 // stored in strings for easy verification. 112 // stored in strings for easy verification.
111 class TestSafeBrowsingUIManager : public SafeBrowsingUIManager { 113 class TestSafeBrowsingUIManager : public SafeBrowsingUIManager {
112 public: 114 public:
113 TestSafeBrowsingUIManager(); 115 TestSafeBrowsingUIManager();
114 explicit TestSafeBrowsingUIManager( 116 explicit TestSafeBrowsingUIManager(
115 const scoped_refptr<SafeBrowsingService>& service); 117 const scoped_refptr<SafeBrowsingService>& service);
116 void SendSerializedThreatDetails(const std::string& serialized) override; 118 void SendSerializedThreatDetails(const std::string& serialized) override;
117 void SetSafeBrowsingService(SafeBrowsingService* sb_service); 119 void SetSafeBrowsingService(SafeBrowsingService* sb_service);
118 std::list<std::string>* GetThreatDetails(); 120 std::list<std::string>* GetThreatDetails();
119 121
120 protected: 122 protected:
121 ~TestSafeBrowsingUIManager() override; 123 ~TestSafeBrowsingUIManager() override;
122 std::list<std::string> details_; 124 std::list<std::string> details_;
123 125
124 DISALLOW_COPY_AND_ASSIGN(TestSafeBrowsingUIManager); 126 DISALLOW_COPY_AND_ASSIGN(TestSafeBrowsingUIManager);
125 }; 127 };
126 128
127 } // namespace safe_browsing 129 } // namespace safe_browsing
128 130
129 #endif // CHROME_BROWSER_SAFE_BROWSING_TEST_SAFE_BROWSING_SERVICE_H_ 131 #endif // CHROME_BROWSER_SAFE_BROWSING_TEST_SAFE_BROWSING_SERVICE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698