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 "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" |
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
194 ClientMalwareRequest*, | 194 ClientMalwareRequest*, |
195 const BrowserFeatureExtractor::MalwareDoneCallback&)); | 195 const BrowserFeatureExtractor::MalwareDoneCallback&)); |
196 }; | 196 }; |
197 | 197 |
198 } // namespace | 198 } // namespace |
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 virtual 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 // Only used for initializing mock objects. |
210 SafeBrowsingService* sb_service = | 210 SafeBrowsingService* sb_service = |
211 SafeBrowsingService::CreateSafeBrowsingService(); | 211 SafeBrowsingService::CreateSafeBrowsingService(); |
212 database_manager_ = | 212 database_manager_ = |
213 new StrictMock<MockSafeBrowsingDatabaseManager>(sb_service); | 213 new StrictMock<MockSafeBrowsingDatabaseManager>(sb_service); |
214 ui_manager_ = new StrictMock<MockSafeBrowsingUIManager>(sb_service); | 214 ui_manager_ = new StrictMock<MockSafeBrowsingUIManager>(sb_service); |
215 csd_host_.reset(safe_browsing::ClientSideDetectionHost::Create( | 215 csd_host_.reset(safe_browsing::ClientSideDetectionHost::Create( |
216 web_contents())); | 216 web_contents())); |
217 csd_host_->set_client_side_detection_service(csd_service_.get()); | 217 csd_host_->set_client_side_detection_service(csd_service_.get()); |
218 csd_host_->set_safe_browsing_managers(ui_manager_.get(), | 218 csd_host_->set_safe_browsing_managers(ui_manager_.get(), |
219 database_manager_.get()); | 219 database_manager_.get()); |
220 // We need to create this here since we don't call DidStopLanding in | 220 // We need to create this here since we don't call DidStopLanding in |
221 // this test. | 221 // this test. |
222 csd_host_->browse_info_.reset(new BrowseInfo); | 222 csd_host_->browse_info_.reset(new BrowseInfo); |
223 } | 223 } |
224 | 224 |
225 virtual void TearDown() override { | 225 void TearDown() override { |
226 // Delete the host object on the UI thread and release the | 226 // Delete the host object on the UI thread and release the |
227 // SafeBrowsingService. | 227 // SafeBrowsingService. |
228 BrowserThread::DeleteSoon(BrowserThread::UI, FROM_HERE, | 228 BrowserThread::DeleteSoon(BrowserThread::UI, FROM_HERE, |
229 csd_host_.release()); | 229 csd_host_.release()); |
230 database_manager_ = NULL; | 230 database_manager_ = NULL; |
231 ui_manager_ = NULL; | 231 ui_manager_ = NULL; |
232 base::RunLoop().RunUntilIdle(); | 232 base::RunLoop().RunUntilIdle(); |
233 ChromeRenderViewHostTestHarness::TearDown(); | 233 ChromeRenderViewHostTestHarness::TearDown(); |
234 } | 234 } |
235 | 235 |
(...skipping 907 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1143 EXPECT_EQ(url, resource.url); | 1143 EXPECT_EQ(url, resource.url); |
1144 EXPECT_EQ(url, resource.original_url); | 1144 EXPECT_EQ(url, resource.original_url); |
1145 | 1145 |
1146 ExpectStartPhishingDetection(NULL); | 1146 ExpectStartPhishingDetection(NULL); |
1147 | 1147 |
1148 // Showing a phishing warning will invalidate all the weak pointers which | 1148 // Showing a phishing warning will invalidate all the weak pointers which |
1149 // means we will not extract malware features. | 1149 // means we will not extract malware features. |
1150 ExpectShouldClassifyForMalwareResult(false); | 1150 ExpectShouldClassifyForMalwareResult(false); |
1151 } | 1151 } |
1152 } // namespace safe_browsing | 1152 } // namespace safe_browsing |
OLD | NEW |