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

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

Issue 99423007: [SafeBrowsing] Reset malware indicator on page nav start. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Update to use NavEntry extra data Created 7 years 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 | Annotate | Revision Log
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"
(...skipping 30 matching lines...) Expand all
41 using ::testing::Pointee; 41 using ::testing::Pointee;
42 using ::testing::Return; 42 using ::testing::Return;
43 using ::testing::SaveArg; 43 using ::testing::SaveArg;
44 using ::testing::SetArgumentPointee; 44 using ::testing::SetArgumentPointee;
45 using ::testing::StrictMock; 45 using ::testing::StrictMock;
46 using content::BrowserThread; 46 using content::BrowserThread;
47 using content::RenderViewHostTester; 47 using content::RenderViewHostTester;
48 using content::WebContents; 48 using content::WebContents;
49 49
50 namespace { 50 namespace {
51
51 const bool kFalse = false; 52 const bool kFalse = false;
52 const bool kTrue = true; 53 const bool kTrue = true;
Greg Billock 2013/12/13 21:10:55 What's going with this?
mattm 2013/12/14 00:09:49 I guess it's so ExpectPreClassificationChecks can
Greg Billock 2013/12/14 18:35:34 ok
53 } 54
55 } // namespace
54 56
55 namespace safe_browsing { 57 namespace safe_browsing {
56 namespace { 58 namespace {
57 // This matcher verifies that the client computed verdict 59 // This matcher verifies that the client computed verdict
58 // (ClientPhishingRequest) which is passed to SendClientReportPhishingRequest 60 // (ClientPhishingRequest) which is passed to SendClientReportPhishingRequest
59 // has the expected fields set. Note: we can't simply compare the protocol 61 // has the expected fields set. Note: we can't simply compare the protocol
60 // buffer strings because the BrowserFeatureExtractor might add features to the 62 // buffer strings because the BrowserFeatureExtractor might add features to the
61 // verdict object before calling SendClientReportPhishingRequest. 63 // verdict object before calling SendClientReportPhishingRequest.
62 MATCHER_P(PartiallyEqualVerdict, other, "") { 64 MATCHER_P(PartiallyEqualVerdict, other, "") {
63 return (other.url() == arg.url() && 65 return (other.url() == arg.url() &&
(...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after
362 resource.url = url; 364 resource.url = url;
363 resource.original_url = url; 365 resource.original_url = url;
364 resource.is_subresource = false; 366 resource.is_subresource = false;
365 resource.threat_type = SB_THREAT_TYPE_URL_MALWARE; 367 resource.threat_type = SB_THREAT_TYPE_URL_MALWARE;
366 resource.callback = base::Bind(&EmptyUrlCheckCallback); 368 resource.callback = base::Bind(&EmptyUrlCheckCallback);
367 resource.render_process_host_id = pending_rvh()->GetProcess()->GetID(); 369 resource.render_process_host_id = pending_rvh()->GetProcess()->GetID();
368 resource.render_view_id = pending_rvh()->GetRoutingID(); 370 resource.render_view_id = pending_rvh()->GetRoutingID();
369 csd_host_->OnSafeBrowsingMatch(resource); 371 csd_host_->OnSafeBrowsingMatch(resource);
370 csd_host_->OnSafeBrowsingHit(resource); 372 csd_host_->OnSafeBrowsingHit(resource);
371 resource.callback.Reset(); 373 resource.callback.Reset();
372 374
mattm 2013/12/14 00:09:49 test DidPageReceiveSafeBrowsingMatch() before comm
Greg Billock 2013/12/14 18:35:34 Done.
373 // LoadURL created a navigation entry, now simulate the RenderView sending 375 // LoadURL created a navigation entry, now simulate the RenderView sending
374 // a notification that it actually navigated. 376 // a notification that it actually navigated.
375 content::WebContentsTester::For(web_contents())->CommitPendingNavigation(); 377 content::WebContentsTester::For(web_contents())->CommitPendingNavigation();
376 378
377 ASSERT_TRUE(csd_host_->DidPageReceiveSafeBrowsingMatch()); 379 ASSERT_TRUE(csd_host_->DidPageReceiveSafeBrowsingMatch());
mattm 2013/12/14 00:09:49 Add tests of DidPageReceiveSafeBrowsingMatch() for
mattm 2013/12/14 00:12:28 Also test of getting a match during a pending navi
Greg Billock 2013/12/14 18:35:34 Done.
Greg Billock 2013/12/14 18:35:34 Done.
378 ASSERT_TRUE(csd_host_->DidShowSBInterstitial()); 380 ASSERT_TRUE(csd_host_->DidShowSBInterstitial());
379 TestUnsafeResourceCopied(resource); 381 TestUnsafeResourceCopied(resource);
380 } 382 }
381 383
382 void CheckIPUrlEqual(const std::vector<IPUrlInfo>& expect, 384 void CheckIPUrlEqual(const std::vector<IPUrlInfo>& expect,
383 const std::vector<IPUrlInfo>& result) { 385 const std::vector<IPUrlInfo>& result) {
384 ASSERT_EQ(expect.size(), result.size()); 386 ASSERT_EQ(expect.size(), result.size());
385 387
386 for (unsigned int i = 0; i < expect.size(); ++i) { 388 for (unsigned int i = 0; i < expect.size(); ++i) {
387 EXPECT_EQ(expect[i].url, result[i].url); 389 EXPECT_EQ(expect[i].url, result[i].url);
(...skipping 748 matching lines...) Expand 10 before | Expand all | Expand 10 after
1136 EXPECT_TRUE(Mock::VerifyAndClear(csd_host_.get())); 1138 EXPECT_TRUE(Mock::VerifyAndClear(csd_host_.get()));
1137 EXPECT_TRUE(Mock::VerifyAndClear(ui_manager_.get())); 1139 EXPECT_TRUE(Mock::VerifyAndClear(ui_manager_.get()));
1138 EXPECT_EQ(url, resource.url); 1140 EXPECT_EQ(url, resource.url);
1139 EXPECT_EQ(url, resource.original_url); 1141 EXPECT_EQ(url, resource.original_url);
1140 resource.callback.Reset(); 1142 resource.callback.Reset();
1141 msg = process()->sink().GetFirstMessageMatching( 1143 msg = process()->sink().GetFirstMessageMatching(
1142 SafeBrowsingMsg_StartPhishingDetection::ID); 1144 SafeBrowsingMsg_StartPhishingDetection::ID);
1143 ASSERT_FALSE(msg); 1145 ASSERT_FALSE(msg);
1144 } 1146 }
1145 } // namespace safe_browsing 1147 } // namespace safe_browsing
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698