| 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/stringprintf.h" | 8 #include "base/stringprintf.h" |
| 9 #include "base/synchronization/waitable_event.h" | 9 #include "base/synchronization/waitable_event.h" |
| 10 #include "chrome/browser/safe_browsing/browser_feature_extractor.h" | 10 #include "chrome/browser/safe_browsing/browser_feature_extractor.h" |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 67 other.feature_map_size() == arg.feature_map_size()); | 67 other.feature_map_size() == arg.feature_map_size()); |
| 68 } | 68 } |
| 69 | 69 |
| 70 // Test that the callback is NULL when the verdict is not phishing. | 70 // Test that the callback is NULL when the verdict is not phishing. |
| 71 MATCHER(CallbackIsNull, "") { | 71 MATCHER(CallbackIsNull, "") { |
| 72 return arg.is_null(); | 72 return arg.is_null(); |
| 73 } | 73 } |
| 74 | 74 |
| 75 ACTION(QuitUIMessageLoop) { | 75 ACTION(QuitUIMessageLoop) { |
| 76 EXPECT_TRUE(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 76 EXPECT_TRUE(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 77 MessageLoopForUI::current()->Quit(); | 77 base::MessageLoopForUI::current()->Quit(); |
| 78 } | 78 } |
| 79 | 79 |
| 80 // It's kind of insane that InvokeArgument doesn't work with callbacks, but it | 80 // It's kind of insane that InvokeArgument doesn't work with callbacks, but it |
| 81 // doesn't seem like it. | 81 // doesn't seem like it. |
| 82 ACTION_TEMPLATE(InvokeCallbackArgument, | 82 ACTION_TEMPLATE(InvokeCallbackArgument, |
| 83 HAS_1_TEMPLATE_PARAMS(int, k), | 83 HAS_1_TEMPLATE_PARAMS(int, k), |
| 84 AND_2_VALUE_PARAMS(p0, p1)) { | 84 AND_2_VALUE_PARAMS(p0, p1)) { |
| 85 ::std::tr1::get<k>(args).Run(p0, p1); | 85 ::std::tr1::get<k>(args).Run(p0, p1); |
| 86 } | 86 } |
| 87 | 87 |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 170 MOCK_METHOD2(ExtractMalwareFeatures, | 170 MOCK_METHOD2(ExtractMalwareFeatures, |
| 171 void(const BrowseInfo* info, | 171 void(const BrowseInfo* info, |
| 172 ClientMalwareRequest*)); | 172 ClientMalwareRequest*)); |
| 173 }; | 173 }; |
| 174 | 174 |
| 175 // Helper function which quits the UI message loop from the IO message loop. | 175 // Helper function which quits the UI message loop from the IO message loop. |
| 176 void QuitUIMessageLoopFromIO() { | 176 void QuitUIMessageLoopFromIO() { |
| 177 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 177 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 178 BrowserThread::PostTask(BrowserThread::UI, | 178 BrowserThread::PostTask(BrowserThread::UI, |
| 179 FROM_HERE, | 179 FROM_HERE, |
| 180 MessageLoop::QuitClosure()); | 180 base::MessageLoop::QuitClosure()); |
| 181 } | 181 } |
| 182 } // namespace | 182 } // namespace |
| 183 | 183 |
| 184 class ClientSideDetectionHostTest : public ChromeRenderViewHostTestHarness { | 184 class ClientSideDetectionHostTest : public ChromeRenderViewHostTestHarness { |
| 185 public: | 185 public: |
| 186 typedef SafeBrowsingUIManager::UnsafeResource UnsafeResource; | 186 typedef SafeBrowsingUIManager::UnsafeResource UnsafeResource; |
| 187 | 187 |
| 188 virtual void SetUp() { | 188 virtual void SetUp() { |
| 189 // Set custom profile object so that we can mock calls to IsOffTheRecord. | 189 // Set custom profile object so that we can mock calls to IsOffTheRecord. |
| 190 // This needs to happen before we call the parent SetUp() function. We use | 190 // This needs to happen before we call the parent SetUp() function. We use |
| (...skipping 24 matching lines...) Expand all Loading... |
| 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_, database_manager_); | 218 csd_host_->set_safe_browsing_managers(ui_manager_, database_manager_); |
| 219 // We need to create this here since we don't call | 219 // We need to create this here since we don't call |
| 220 // DidNavigateMainFramePostCommit in this test. | 220 // DidNavigateMainFramePostCommit in this test. |
| 221 csd_host_->browse_info_.reset(new BrowseInfo); | 221 csd_host_->browse_info_.reset(new BrowseInfo); |
| 222 } | 222 } |
| 223 | 223 |
| 224 static void RunAllPendingOnIO(base::WaitableEvent* event) { | 224 static void RunAllPendingOnIO(base::WaitableEvent* event) { |
| 225 MessageLoop::current()->RunUntilIdle(); | 225 base::MessageLoop::current()->RunUntilIdle(); |
| 226 event->Signal(); | 226 event->Signal(); |
| 227 } | 227 } |
| 228 | 228 |
| 229 virtual void TearDown() { | 229 virtual void TearDown() { |
| 230 // Delete the host object on the UI thread and release the | 230 // Delete the host object on the UI thread and release the |
| 231 // SafeBrowsingService. | 231 // SafeBrowsingService. |
| 232 BrowserThread::DeleteSoon(BrowserThread::UI, FROM_HERE, | 232 BrowserThread::DeleteSoon(BrowserThread::UI, FROM_HERE, |
| 233 csd_host_.release()); | 233 csd_host_.release()); |
| 234 database_manager_ = NULL; | 234 database_manager_ = NULL; |
| 235 ui_manager_ = NULL; | 235 ui_manager_ = NULL; |
| (...skipping 23 matching lines...) Expand all Loading... |
| 259 return csd_host_->browse_info_.get(); | 259 return csd_host_->browse_info_.get(); |
| 260 } | 260 } |
| 261 | 261 |
| 262 void FlushIOMessageLoop() { | 262 void FlushIOMessageLoop() { |
| 263 // If there was a message posted on the IO thread to display the | 263 // If there was a message posted on the IO thread to display the |
| 264 // interstitial page we know that it would have been posted before | 264 // interstitial page we know that it would have been posted before |
| 265 // we put the quit message there. | 265 // we put the quit message there. |
| 266 BrowserThread::PostTask(BrowserThread::IO, | 266 BrowserThread::PostTask(BrowserThread::IO, |
| 267 FROM_HERE, | 267 FROM_HERE, |
| 268 base::Bind(&QuitUIMessageLoopFromIO)); | 268 base::Bind(&QuitUIMessageLoopFromIO)); |
| 269 MessageLoop::current()->Run(); | 269 base::MessageLoop::current()->Run(); |
| 270 } | 270 } |
| 271 | 271 |
| 272 void ExpectPreClassificationChecks(const GURL& url, | 272 void ExpectPreClassificationChecks(const GURL& url, |
| 273 const bool* is_private, | 273 const bool* is_private, |
| 274 const bool* is_incognito, | 274 const bool* is_incognito, |
| 275 const bool* match_csd_whitelist, | 275 const bool* match_csd_whitelist, |
| 276 const bool* get_valid_cached_result, | 276 const bool* get_valid_cached_result, |
| 277 const bool* is_in_cache, | 277 const bool* is_in_cache, |
| 278 const bool* over_report_limit) { | 278 const bool* over_report_limit) { |
| 279 if (is_private) { | 279 if (is_private) { |
| (...skipping 19 matching lines...) Expand all Loading... |
| 299 if (over_report_limit) { | 299 if (over_report_limit) { |
| 300 EXPECT_CALL(*csd_service_, OverPhishingReportLimit()) | 300 EXPECT_CALL(*csd_service_, OverPhishingReportLimit()) |
| 301 .WillOnce(Return(*over_report_limit)); | 301 .WillOnce(Return(*over_report_limit)); |
| 302 } | 302 } |
| 303 } | 303 } |
| 304 | 304 |
| 305 void WaitAndCheckPreClassificationChecks() { | 305 void WaitAndCheckPreClassificationChecks() { |
| 306 // Wait for CheckCsdWhitelist to be called if at all. | 306 // Wait for CheckCsdWhitelist to be called if at all. |
| 307 FlushIOMessageLoop(); | 307 FlushIOMessageLoop(); |
| 308 // Checks for CheckCache() to be called if at all. | 308 // Checks for CheckCache() to be called if at all. |
| 309 MessageLoop::current()->RunUntilIdle(); | 309 base::MessageLoop::current()->RunUntilIdle(); |
| 310 EXPECT_TRUE(Mock::VerifyAndClear(csd_service_.get())); | 310 EXPECT_TRUE(Mock::VerifyAndClear(csd_service_.get())); |
| 311 EXPECT_TRUE(Mock::VerifyAndClear(ui_manager_.get())); | 311 EXPECT_TRUE(Mock::VerifyAndClear(ui_manager_.get())); |
| 312 EXPECT_TRUE(Mock::VerifyAndClear(database_manager_.get())); | 312 EXPECT_TRUE(Mock::VerifyAndClear(database_manager_.get())); |
| 313 EXPECT_TRUE(Mock::VerifyAndClear(mock_profile_)); | 313 EXPECT_TRUE(Mock::VerifyAndClear(mock_profile_)); |
| 314 } | 314 } |
| 315 | 315 |
| 316 void SetFeatureExtractor(BrowserFeatureExtractor* extractor) { | 316 void SetFeatureExtractor(BrowserFeatureExtractor* extractor) { |
| 317 csd_host_->feature_extractor_.reset(extractor); | 317 csd_host_->feature_extractor_.reset(extractor); |
| 318 } | 318 } |
| 319 | 319 |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 396 SendClientReportPhishingRequest( | 396 SendClientReportPhishingRequest( |
| 397 Pointee(PartiallyEqualVerdict(verdict)), _)) | 397 Pointee(PartiallyEqualVerdict(verdict)), _)) |
| 398 .WillOnce(SaveArg<1>(&cb)); | 398 .WillOnce(SaveArg<1>(&cb)); |
| 399 OnPhishingDetectionDone(verdict.SerializeAsString()); | 399 OnPhishingDetectionDone(verdict.SerializeAsString()); |
| 400 EXPECT_TRUE(Mock::VerifyAndClear(csd_service_.get())); | 400 EXPECT_TRUE(Mock::VerifyAndClear(csd_service_.get())); |
| 401 ASSERT_FALSE(cb.is_null()); | 401 ASSERT_FALSE(cb.is_null()); |
| 402 | 402 |
| 403 // Make sure DoDisplayBlockingPage is not going to be called. | 403 // Make sure DoDisplayBlockingPage is not going to be called. |
| 404 EXPECT_CALL(*ui_manager_, DoDisplayBlockingPage(_)).Times(0); | 404 EXPECT_CALL(*ui_manager_, DoDisplayBlockingPage(_)).Times(0); |
| 405 cb.Run(GURL(verdict.url()), false); | 405 cb.Run(GURL(verdict.url()), false); |
| 406 MessageLoop::current()->RunUntilIdle(); | 406 base::MessageLoop::current()->RunUntilIdle(); |
| 407 EXPECT_TRUE(Mock::VerifyAndClear(ui_manager_.get())); | 407 EXPECT_TRUE(Mock::VerifyAndClear(ui_manager_.get())); |
| 408 } | 408 } |
| 409 | 409 |
| 410 TEST_F(ClientSideDetectionHostTest, OnPhishingDetectionDoneDisabled) { | 410 TEST_F(ClientSideDetectionHostTest, OnPhishingDetectionDoneDisabled) { |
| 411 // Case 2: client thinks the page is phishing and so does the server but | 411 // Case 2: client thinks the page is phishing and so does the server but |
| 412 // showing the interstitial is disabled => no interstitial is shown. | 412 // showing the interstitial is disabled => no interstitial is shown. |
| 413 MockBrowserFeatureExtractor* mock_extractor = new MockBrowserFeatureExtractor( | 413 MockBrowserFeatureExtractor* mock_extractor = new MockBrowserFeatureExtractor( |
| 414 web_contents(), | 414 web_contents(), |
| 415 csd_service_.get()); | 415 csd_service_.get()); |
| 416 SetFeatureExtractor(mock_extractor); // The host class takes ownership. | 416 SetFeatureExtractor(mock_extractor); // The host class takes ownership. |
| (...skipping 11 matching lines...) Expand all Loading... |
| 428 SendClientReportPhishingRequest( | 428 SendClientReportPhishingRequest( |
| 429 Pointee(PartiallyEqualVerdict(verdict)), _)) | 429 Pointee(PartiallyEqualVerdict(verdict)), _)) |
| 430 .WillOnce(SaveArg<1>(&cb)); | 430 .WillOnce(SaveArg<1>(&cb)); |
| 431 OnPhishingDetectionDone(verdict.SerializeAsString()); | 431 OnPhishingDetectionDone(verdict.SerializeAsString()); |
| 432 EXPECT_TRUE(Mock::VerifyAndClear(csd_service_.get())); | 432 EXPECT_TRUE(Mock::VerifyAndClear(csd_service_.get())); |
| 433 ASSERT_FALSE(cb.is_null()); | 433 ASSERT_FALSE(cb.is_null()); |
| 434 | 434 |
| 435 // Make sure DoDisplayBlockingPage is not going to be called. | 435 // Make sure DoDisplayBlockingPage is not going to be called. |
| 436 EXPECT_CALL(*ui_manager_, DoDisplayBlockingPage(_)).Times(0); | 436 EXPECT_CALL(*ui_manager_, DoDisplayBlockingPage(_)).Times(0); |
| 437 cb.Run(GURL(verdict.url()), false); | 437 cb.Run(GURL(verdict.url()), false); |
| 438 MessageLoop::current()->RunUntilIdle(); | 438 base::MessageLoop::current()->RunUntilIdle(); |
| 439 EXPECT_TRUE(Mock::VerifyAndClear(ui_manager_.get())); | 439 EXPECT_TRUE(Mock::VerifyAndClear(ui_manager_.get())); |
| 440 } | 440 } |
| 441 | 441 |
| 442 TEST_F(ClientSideDetectionHostTest, OnPhishingDetectionDoneShowInterstitial) { | 442 TEST_F(ClientSideDetectionHostTest, OnPhishingDetectionDoneShowInterstitial) { |
| 443 // Case 3: client thinks the page is phishing and so does the server. | 443 // Case 3: client thinks the page is phishing and so does the server. |
| 444 // We show an interstitial. | 444 // We show an interstitial. |
| 445 MockBrowserFeatureExtractor* mock_extractor = new MockBrowserFeatureExtractor( | 445 MockBrowserFeatureExtractor* mock_extractor = new MockBrowserFeatureExtractor( |
| 446 web_contents(), | 446 web_contents(), |
| 447 csd_service_.get()); | 447 csd_service_.get()); |
| 448 SetFeatureExtractor(mock_extractor); // The host class takes ownership. | 448 SetFeatureExtractor(mock_extractor); // The host class takes ownership. |
| (...skipping 14 matching lines...) Expand all Loading... |
| 463 .WillOnce(SaveArg<1>(&cb)); | 463 .WillOnce(SaveArg<1>(&cb)); |
| 464 OnPhishingDetectionDone(verdict.SerializeAsString()); | 464 OnPhishingDetectionDone(verdict.SerializeAsString()); |
| 465 EXPECT_TRUE(Mock::VerifyAndClear(csd_service_.get())); | 465 EXPECT_TRUE(Mock::VerifyAndClear(csd_service_.get())); |
| 466 ASSERT_FALSE(cb.is_null()); | 466 ASSERT_FALSE(cb.is_null()); |
| 467 | 467 |
| 468 UnsafeResource resource; | 468 UnsafeResource resource; |
| 469 EXPECT_CALL(*ui_manager_, DoDisplayBlockingPage(_)) | 469 EXPECT_CALL(*ui_manager_, DoDisplayBlockingPage(_)) |
| 470 .WillOnce(SaveArg<0>(&resource)); | 470 .WillOnce(SaveArg<0>(&resource)); |
| 471 cb.Run(phishing_url, true); | 471 cb.Run(phishing_url, true); |
| 472 | 472 |
| 473 MessageLoop::current()->RunUntilIdle(); | 473 base::MessageLoop::current()->RunUntilIdle(); |
| 474 EXPECT_TRUE(Mock::VerifyAndClear(ui_manager_.get())); | 474 EXPECT_TRUE(Mock::VerifyAndClear(ui_manager_.get())); |
| 475 EXPECT_EQ(phishing_url, resource.url); | 475 EXPECT_EQ(phishing_url, resource.url); |
| 476 EXPECT_EQ(phishing_url, resource.original_url); | 476 EXPECT_EQ(phishing_url, resource.original_url); |
| 477 EXPECT_FALSE(resource.is_subresource); | 477 EXPECT_FALSE(resource.is_subresource); |
| 478 EXPECT_EQ(SB_THREAT_TYPE_CLIENT_SIDE_PHISHING_URL, resource.threat_type); | 478 EXPECT_EQ(SB_THREAT_TYPE_CLIENT_SIDE_PHISHING_URL, resource.threat_type); |
| 479 EXPECT_EQ(web_contents()->GetRenderProcessHost()->GetID(), | 479 EXPECT_EQ(web_contents()->GetRenderProcessHost()->GetID(), |
| 480 resource.render_process_host_id); | 480 resource.render_process_host_id); |
| 481 EXPECT_EQ(web_contents()->GetRenderViewHost()->GetRoutingID(), | 481 EXPECT_EQ(web_contents()->GetRenderViewHost()->GetRoutingID(), |
| 482 resource.render_view_id); | 482 resource.render_view_id); |
| 483 | 483 |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 541 EXPECT_CALL(*csd_service_, | 541 EXPECT_CALL(*csd_service_, |
| 542 SendClientReportPhishingRequest( | 542 SendClientReportPhishingRequest( |
| 543 Pointee(PartiallyEqualVerdict(verdict)), _)) | 543 Pointee(PartiallyEqualVerdict(verdict)), _)) |
| 544 .WillOnce(DoAll(DeleteArg<0>(), | 544 .WillOnce(DoAll(DeleteArg<0>(), |
| 545 SaveArg<1>(&cb_other), | 545 SaveArg<1>(&cb_other), |
| 546 QuitUIMessageLoop())); | 546 QuitUIMessageLoop())); |
| 547 std::vector<GURL> redirect_chain; | 547 std::vector<GURL> redirect_chain; |
| 548 redirect_chain.push_back(other_phishing_url); | 548 redirect_chain.push_back(other_phishing_url); |
| 549 SetRedirectChain(redirect_chain); | 549 SetRedirectChain(redirect_chain); |
| 550 OnPhishingDetectionDone(verdict.SerializeAsString()); | 550 OnPhishingDetectionDone(verdict.SerializeAsString()); |
| 551 MessageLoop::current()->Run(); | 551 base::MessageLoop::current()->Run(); |
| 552 EXPECT_TRUE(Mock::VerifyAndClear(csd_service_.get())); | 552 EXPECT_TRUE(Mock::VerifyAndClear(csd_service_.get())); |
| 553 ASSERT_FALSE(cb_other.is_null()); | 553 ASSERT_FALSE(cb_other.is_null()); |
| 554 | 554 |
| 555 // We expect that the interstitial is shown for the second phishing URL and | 555 // We expect that the interstitial is shown for the second phishing URL and |
| 556 // not for the first phishing URL. | 556 // not for the first phishing URL. |
| 557 UnsafeResource resource; | 557 UnsafeResource resource; |
| 558 EXPECT_CALL(*ui_manager_, DoDisplayBlockingPage(_)) | 558 EXPECT_CALL(*ui_manager_, DoDisplayBlockingPage(_)) |
| 559 .WillOnce(SaveArg<0>(&resource)); | 559 .WillOnce(SaveArg<0>(&resource)); |
| 560 | 560 |
| 561 cb.Run(phishing_url, true); // Should have no effect. | 561 cb.Run(phishing_url, true); // Should have no effect. |
| 562 cb_other.Run(other_phishing_url, true); // Should show interstitial. | 562 cb_other.Run(other_phishing_url, true); // Should show interstitial. |
| 563 | 563 |
| 564 MessageLoop::current()->RunUntilIdle(); | 564 base::MessageLoop::current()->RunUntilIdle(); |
| 565 EXPECT_TRUE(Mock::VerifyAndClear(ui_manager_.get())); | 565 EXPECT_TRUE(Mock::VerifyAndClear(ui_manager_.get())); |
| 566 EXPECT_EQ(other_phishing_url, resource.url); | 566 EXPECT_EQ(other_phishing_url, resource.url); |
| 567 EXPECT_EQ(other_phishing_url, resource.original_url); | 567 EXPECT_EQ(other_phishing_url, resource.original_url); |
| 568 EXPECT_FALSE(resource.is_subresource); | 568 EXPECT_FALSE(resource.is_subresource); |
| 569 EXPECT_EQ(SB_THREAT_TYPE_CLIENT_SIDE_PHISHING_URL, resource.threat_type); | 569 EXPECT_EQ(SB_THREAT_TYPE_CLIENT_SIDE_PHISHING_URL, resource.threat_type); |
| 570 EXPECT_EQ(web_contents()->GetRenderProcessHost()->GetID(), | 570 EXPECT_EQ(web_contents()->GetRenderProcessHost()->GetID(), |
| 571 resource.render_process_host_id); | 571 resource.render_process_host_id); |
| 572 EXPECT_EQ(web_contents()->GetRenderViewHost()->GetRoutingID(), | 572 EXPECT_EQ(web_contents()->GetRenderViewHost()->GetRoutingID(), |
| 573 resource.render_view_id); | 573 resource.render_view_id); |
| 574 | 574 |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 620 SetUnsafeResourceToCurrent(); | 620 SetUnsafeResourceToCurrent(); |
| 621 | 621 |
| 622 EXPECT_CALL(*csd_service_, | 622 EXPECT_CALL(*csd_service_, |
| 623 SendClientReportPhishingRequest( | 623 SendClientReportPhishingRequest( |
| 624 Pointee(PartiallyEqualVerdict(verdict)), CallbackIsNull())) | 624 Pointee(PartiallyEqualVerdict(verdict)), CallbackIsNull())) |
| 625 .WillOnce(DoAll(DeleteArg<0>(), QuitUIMessageLoop())); | 625 .WillOnce(DoAll(DeleteArg<0>(), QuitUIMessageLoop())); |
| 626 std::vector<GURL> redirect_chain; | 626 std::vector<GURL> redirect_chain; |
| 627 redirect_chain.push_back(url); | 627 redirect_chain.push_back(url); |
| 628 SetRedirectChain(redirect_chain); | 628 SetRedirectChain(redirect_chain); |
| 629 OnPhishingDetectionDone(verdict.SerializeAsString()); | 629 OnPhishingDetectionDone(verdict.SerializeAsString()); |
| 630 MessageLoop::current()->Run(); | 630 base::MessageLoop::current()->Run(); |
| 631 EXPECT_TRUE(Mock::VerifyAndClear(csd_service_.get())); | 631 EXPECT_TRUE(Mock::VerifyAndClear(csd_service_.get())); |
| 632 } | 632 } |
| 633 | 633 |
| 634 TEST_F(ClientSideDetectionHostTest, UpdateIPHostMap) { | 634 TEST_F(ClientSideDetectionHostTest, UpdateIPHostMap) { |
| 635 BrowseInfo* browse_info = GetBrowseInfo(); | 635 BrowseInfo* browse_info = GetBrowseInfo(); |
| 636 | 636 |
| 637 // Empty IP or host are skipped | 637 // Empty IP or host are skipped |
| 638 UpdateIPHostMap("250.10.10.10", std::string()); | 638 UpdateIPHostMap("250.10.10.10", std::string()); |
| 639 ASSERT_EQ(0U, browse_info->ips.size()); | 639 ASSERT_EQ(0U, browse_info->ips.size()); |
| 640 UpdateIPHostMap(std::string(), "google.com/"); | 640 UpdateIPHostMap(std::string(), "google.com/"); |
| (...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 947 NULL); | 947 NULL); |
| 948 | 948 |
| 949 UnsafeResource resource; | 949 UnsafeResource resource; |
| 950 EXPECT_CALL(*ui_manager_, DoDisplayBlockingPage(_)) | 950 EXPECT_CALL(*ui_manager_, DoDisplayBlockingPage(_)) |
| 951 .WillOnce(SaveArg<0>(&resource)); | 951 .WillOnce(SaveArg<0>(&resource)); |
| 952 | 952 |
| 953 NavigateAndCommit(url); | 953 NavigateAndCommit(url); |
| 954 // Wait for CheckCsdWhitelist to be called on the IO thread. | 954 // Wait for CheckCsdWhitelist to be called on the IO thread. |
| 955 FlushIOMessageLoop(); | 955 FlushIOMessageLoop(); |
| 956 // Wait for CheckCache() to be called on the UI thread. | 956 // Wait for CheckCache() to be called on the UI thread. |
| 957 MessageLoop::current()->RunUntilIdle(); | 957 base::MessageLoop::current()->RunUntilIdle(); |
| 958 // Now we check that all expected functions were indeed called on the two | 958 // Now we check that all expected functions were indeed called on the two |
| 959 // service objects. | 959 // service objects. |
| 960 EXPECT_TRUE(Mock::VerifyAndClear(csd_service_.get())); | 960 EXPECT_TRUE(Mock::VerifyAndClear(csd_service_.get())); |
| 961 EXPECT_TRUE(Mock::VerifyAndClear(ui_manager_.get())); | 961 EXPECT_TRUE(Mock::VerifyAndClear(ui_manager_.get())); |
| 962 EXPECT_EQ(url, resource.url); | 962 EXPECT_EQ(url, resource.url); |
| 963 EXPECT_EQ(url, resource.original_url); | 963 EXPECT_EQ(url, resource.original_url); |
| 964 resource.callback.Reset(); | 964 resource.callback.Reset(); |
| 965 msg = process()->sink().GetFirstMessageMatching( | 965 msg = process()->sink().GetFirstMessageMatching( |
| 966 SafeBrowsingMsg_StartPhishingDetection::ID); | 966 SafeBrowsingMsg_StartPhishingDetection::ID); |
| 967 ASSERT_FALSE(msg); | 967 ASSERT_FALSE(msg); |
| 968 } | 968 } |
| 969 | 969 |
| 970 } // namespace safe_browsing | 970 } // namespace safe_browsing |
| OLD | NEW |