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

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

Issue 8799015: Revert 113006 - Make TestTabContents::TestDidNavigate not take a ViewHostMsg_FrameNavigate_Params... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 9 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "chrome/browser/safe_browsing/browser_feature_extractor.h" 5 #include "chrome/browser/safe_browsing/browser_feature_extractor.h"
6 6
7 #include <map> 7 #include <map>
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
11 #include "base/memory/scoped_ptr.h" 11 #include "base/memory/scoped_ptr.h"
12 #include "base/message_loop.h" 12 #include "base/message_loop.h"
13 #include "base/stringprintf.h" 13 #include "base/stringprintf.h"
14 #include "base/time.h" 14 #include "base/time.h"
15 #include "chrome/browser/history/history.h" 15 #include "chrome/browser/history/history.h"
16 #include "chrome/browser/history/history_backend.h" 16 #include "chrome/browser/history/history_backend.h"
17 #include "chrome/browser/profiles/profile.h" 17 #include "chrome/browser/profiles/profile.h"
18 #include "chrome/browser/safe_browsing/browser_features.h" 18 #include "chrome/browser/safe_browsing/browser_features.h"
19 #include "chrome/browser/safe_browsing/client_side_detection_service.h" 19 #include "chrome/browser/safe_browsing/client_side_detection_service.h"
20 #include "chrome/common/safe_browsing/csd.pb.h" 20 #include "chrome/common/safe_browsing/csd.pb.h"
21 #include "chrome/test/base/chrome_render_view_host_test_harness.h" 21 #include "chrome/test/base/chrome_render_view_host_test_harness.h"
22 #include "chrome/test/base/testing_profile.h" 22 #include "chrome/test/base/testing_profile.h"
23 #include "content/browser/tab_contents/tab_contents.h" 23 #include "content/browser/tab_contents/tab_contents.h"
24 #include "content/browser/tab_contents/test_tab_contents.h" 24 #include "content/browser/tab_contents/test_tab_contents.h"
25 #include "content/common/view_messages.h"
25 #include "content/public/common/page_transition_types.h" 26 #include "content/public/common/page_transition_types.h"
26 #include "content/public/common/referrer.h"
27 #include "content/test/test_browser_thread.h" 27 #include "content/test/test_browser_thread.h"
28 #include "googleurl/src/gurl.h" 28 #include "googleurl/src/gurl.h"
29 #include "testing/gmock/include/gmock/gmock.h" 29 #include "testing/gmock/include/gmock/gmock.h"
30 #include "testing/gtest/include/gtest/gtest.h" 30 #include "testing/gtest/include/gtest/gtest.h"
31 #include "third_party/WebKit/Source/WebKit/chromium/public/WebReferrerPolicy.h"
32 31
33 using ::testing::Return; 32 using ::testing::Return;
34 using ::testing::StrictMock; 33 using ::testing::StrictMock;
35 using content::BrowserThread; 34 using content::BrowserThread;
36 35
37 namespace safe_browsing { 36 namespace safe_browsing {
38 namespace { 37 namespace {
39 class MockClientSideDetectionService : public ClientSideDetectionService { 38 class MockClientSideDetectionService : public ClientSideDetectionService {
40 public: 39 public:
41 MockClientSideDetectionService() : ClientSideDetectionService(NULL) {} 40 MockClientSideDetectionService() : ClientSideDetectionService(NULL) {}
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 // This is similar to NavigateAndCommit that is in test_tab_contents, but 90 // This is similar to NavigateAndCommit that is in test_tab_contents, but
92 // allows us to specify the referrer and page_transition_type. 91 // allows us to specify the referrer and page_transition_type.
93 void NavigateAndCommit(const GURL& url, 92 void NavigateAndCommit(const GURL& url,
94 const GURL& referrer, 93 const GURL& referrer,
95 content::PageTransition type) { 94 content::PageTransition type) {
96 contents()->controller().LoadURL( 95 contents()->controller().LoadURL(
97 url, content::Referrer(referrer, WebKit::WebReferrerPolicyDefault), 96 url, content::Referrer(referrer, WebKit::WebReferrerPolicyDefault),
98 type, std::string()); 97 type, std::string());
99 98
100 static int page_id = 0; 99 static int page_id = 0;
100 ViewHostMsg_FrameNavigate_Params params;
101 InitNavigateParams(&params, ++page_id, url, type);
102 params.referrer =
103 content::Referrer(referrer, WebKit::WebReferrerPolicyDefault);
104
101 RenderViewHost* rvh = contents()->pending_rvh(); 105 RenderViewHost* rvh = contents()->pending_rvh();
102 if (!rvh) { 106 if (!rvh) {
103 rvh = contents()->render_view_host(); 107 rvh = contents()->render_view_host();
104 } 108 }
105 contents()->ProceedWithCrossSiteNavigation(); 109 contents()->ProceedWithCrossSiteNavigation();
106 contents()->TestDidNavigateWithReferrer( 110 contents()->TestDidNavigate(rvh, params);
107 rvh, ++page_id, url,
108 content::Referrer(referrer, WebKit::WebReferrerPolicyDefault), type);
109 } 111 }
110 112
111 bool ExtractFeatures(ClientPhishingRequest* request) { 113 bool ExtractFeatures(ClientPhishingRequest* request) {
112 StartExtractFeatures(request); 114 StartExtractFeatures(request);
113 MessageLoop::current()->Run(); 115 MessageLoop::current()->Run();
114 EXPECT_EQ(1U, success_.count(request)); 116 EXPECT_EQ(1U, success_.count(request));
115 return success_.count(request) ? success_[request] : false; 117 return success_.count(request) ? success_[request] : false;
116 } 118 }
117 119
118 void StartExtractFeatures(ClientPhishingRequest* request) { 120 void StartExtractFeatures(ClientPhishingRequest* request) {
(...skipping 378 matching lines...) Expand 10 before | Expand all | Expand 10 after
497 EXPECT_TRUE(features.count(StringPrintf("%s%s", 499 EXPECT_TRUE(features.count(StringPrintf("%s%s",
498 features::kSafeBrowsingMaliciousUrl, 500 features::kSafeBrowsingMaliciousUrl,
499 "http://www.malware.com/"))); 501 "http://www.malware.com/")));
500 EXPECT_TRUE(features.count(StringPrintf("%s%s", 502 EXPECT_TRUE(features.count(StringPrintf("%s%s",
501 features::kSafeBrowsingOriginalUrl, 503 features::kSafeBrowsingOriginalUrl,
502 "http://www.good.com/"))); 504 "http://www.good.com/")));
503 EXPECT_DOUBLE_EQ(1.0, features[features::kSafeBrowsingIsSubresource]); 505 EXPECT_DOUBLE_EQ(1.0, features[features::kSafeBrowsingIsSubresource]);
504 EXPECT_DOUBLE_EQ(2.0, features[features::kSafeBrowsingThreatType]); 506 EXPECT_DOUBLE_EQ(2.0, features[features::kSafeBrowsingThreatType]);
505 } 507 }
506 } // namespace safe_browsing 508 } // namespace safe_browsing
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698