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

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

Issue 1110723002: Split to SafeBrowsingDatabaseManager into Local* and Remote*. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Respond to review. Tweak comments and list initializer. Created 5 years, 7 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) 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 "base/files/file_path.h" 5 #include "base/files/file_path.h"
6 #include "base/memory/ref_counted.h" 6 #include "base/memory/ref_counted.h"
7 #include "base/memory/scoped_ptr.h" 7 #include "base/memory/scoped_ptr.h"
8 #include "base/run_loop.h" 8 #include "base/run_loop.h"
9 #include "base/strings/stringprintf.h" 9 #include "base/strings/stringprintf.h"
10 #include "base/synchronization/waitable_event.h" 10 #include "base/synchronization/waitable_event.h"
11 #include "chrome/browser/safe_browsing/browser_feature_extractor.h" 11 #include "chrome/browser/safe_browsing/browser_feature_extractor.h"
12 #include "chrome/browser/safe_browsing/client_side_detection_host.h" 12 #include "chrome/browser/safe_browsing/client_side_detection_host.h"
13 #include "chrome/browser/safe_browsing/client_side_detection_service.h" 13 #include "chrome/browser/safe_browsing/client_side_detection_service.h"
14 #include "chrome/browser/safe_browsing/database_manager.h" 14 #include "chrome/browser/safe_browsing/database_manager.h"
15 #include "chrome/browser/safe_browsing/safe_browsing_service.h" 15 #include "chrome/browser/safe_browsing/safe_browsing_service.h"
16 #include "chrome/browser/safe_browsing/test_database_manager.h"
16 #include "chrome/browser/safe_browsing/ui_manager.h" 17 #include "chrome/browser/safe_browsing/ui_manager.h"
17 #include "chrome/common/chrome_switches.h" 18 #include "chrome/common/chrome_switches.h"
18 #include "chrome/common/safe_browsing/csd.pb.h" 19 #include "chrome/common/safe_browsing/csd.pb.h"
19 #include "chrome/common/safe_browsing/safebrowsing_messages.h" 20 #include "chrome/common/safe_browsing/safebrowsing_messages.h"
20 #include "chrome/test/base/chrome_render_view_host_test_harness.h" 21 #include "chrome/test/base/chrome_render_view_host_test_harness.h"
21 #include "chrome/test/base/testing_profile.h" 22 #include "chrome/test/base/testing_profile.h"
22 #include "content/public/browser/navigation_entry.h" 23 #include "content/public/browser/navigation_entry.h"
23 #include "content/public/browser/web_contents.h" 24 #include "content/public/browser/web_contents.h"
24 #include "content/public/test/mock_render_process_host.h" 25 #include "content/public/test/mock_render_process_host.h"
25 #include "content/public/test/test_browser_thread.h" 26 #include "content/public/test/test_browser_thread.h"
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
145 callback.Run(false); 146 callback.Run(false);
146 } 147 }
147 148
148 protected: 149 protected:
149 virtual ~MockSafeBrowsingUIManager() { } 150 virtual ~MockSafeBrowsingUIManager() { }
150 151
151 private: 152 private:
152 DISALLOW_COPY_AND_ASSIGN(MockSafeBrowsingUIManager); 153 DISALLOW_COPY_AND_ASSIGN(MockSafeBrowsingUIManager);
153 }; 154 };
154 155
155 class MockSafeBrowsingDatabaseManager : public SafeBrowsingDatabaseManager { 156 class MockSafeBrowsingDatabaseManager : public TestSafeBrowsingDatabaseManager {
156 public: 157 public:
157 explicit MockSafeBrowsingDatabaseManager(SafeBrowsingService* service) 158 MockSafeBrowsingDatabaseManager() {}
158 : SafeBrowsingDatabaseManager(service) { }
159 159
160 MOCK_METHOD1(MatchCsdWhitelistUrl, bool(const GURL&)); 160 MOCK_METHOD1(MatchCsdWhitelistUrl, bool(const GURL&));
161 MOCK_METHOD1(MatchMalwareIP, bool(const std::string& ip_address)); 161 MOCK_METHOD1(MatchMalwareIP, bool(const std::string& ip_address));
162 MOCK_METHOD0(IsMalwareKillSwitchOn, bool()); 162 MOCK_METHOD0(IsMalwareKillSwitchOn, bool());
163 163
164 protected: 164 protected:
165 virtual ~MockSafeBrowsingDatabaseManager() {} 165 virtual ~MockSafeBrowsingDatabaseManager() {}
166 166
167 private: 167 private:
168 DISALLOW_COPY_AND_ASSIGN(MockSafeBrowsingDatabaseManager); 168 DISALLOW_COPY_AND_ASSIGN(MockSafeBrowsingDatabaseManager);
(...skipping 30 matching lines...) Expand all
199 199
200 class ClientSideDetectionHostTest : public ChromeRenderViewHostTestHarness { 200 class ClientSideDetectionHostTest : public ChromeRenderViewHostTestHarness {
201 public: 201 public:
202 typedef SafeBrowsingUIManager::UnsafeResource UnsafeResource; 202 typedef SafeBrowsingUIManager::UnsafeResource UnsafeResource;
203 203
204 void SetUp() override { 204 void SetUp() override {
205 ChromeRenderViewHostTestHarness::SetUp(); 205 ChromeRenderViewHostTestHarness::SetUp();
206 206
207 // Inject service classes. 207 // Inject service classes.
208 csd_service_.reset(new StrictMock<MockClientSideDetectionService>()); 208 csd_service_.reset(new StrictMock<MockClientSideDetectionService>());
209 // Only used for initializing mock objects. 209 database_manager_ = new StrictMock<MockSafeBrowsingDatabaseManager>();
210 SafeBrowsingService* sb_service = 210 ui_manager_ = new StrictMock<MockSafeBrowsingUIManager>(
211 SafeBrowsingService::CreateSafeBrowsingService(); 211 SafeBrowsingService::CreateSafeBrowsingService());
212 database_manager_ =
213 new StrictMock<MockSafeBrowsingDatabaseManager>(sb_service);
214 ui_manager_ = new StrictMock<MockSafeBrowsingUIManager>(sb_service);
215 csd_host_.reset(safe_browsing::ClientSideDetectionHost::Create( 212 csd_host_.reset(safe_browsing::ClientSideDetectionHost::Create(
216 web_contents())); 213 web_contents()));
217 csd_host_->set_client_side_detection_service(csd_service_.get()); 214 csd_host_->set_client_side_detection_service(csd_service_.get());
218 csd_host_->set_safe_browsing_managers(ui_manager_.get(), 215 csd_host_->set_safe_browsing_managers(ui_manager_.get(),
219 database_manager_.get()); 216 database_manager_.get());
220 // We need to create this here since we don't call DidStopLanding in 217 // We need to create this here since we don't call DidStopLanding in
221 // this test. 218 // this test.
222 csd_host_->browse_info_.reset(new BrowseInfo); 219 csd_host_->browse_info_.reset(new BrowseInfo);
223 } 220 }
224 221
(...skipping 916 matching lines...) Expand 10 before | Expand all | Expand 10 after
1141 EXPECT_EQ(url, resource.url); 1138 EXPECT_EQ(url, resource.url);
1142 EXPECT_EQ(url, resource.original_url); 1139 EXPECT_EQ(url, resource.original_url);
1143 1140
1144 ExpectStartPhishingDetection(NULL); 1141 ExpectStartPhishingDetection(NULL);
1145 1142
1146 // Showing a phishing warning will invalidate all the weak pointers which 1143 // Showing a phishing warning will invalidate all the weak pointers which
1147 // means we will not extract malware features. 1144 // means we will not extract malware features.
1148 ExpectShouldClassifyForMalwareResult(false); 1145 ExpectShouldClassifyForMalwareResult(false);
1149 } 1146 }
1150 } // namespace safe_browsing 1147 } // namespace safe_browsing
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698