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

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

Issue 6713084: Move the rest of the renderer->browser messages that belong in content. Also do a bunch of cleanup: (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 9 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 <algorithm> 5 #include <algorithm>
6 6
7 #include "chrome/browser/safe_browsing/malware_details.h" 7 #include "chrome/browser/safe_browsing/malware_details.h"
8 #include "chrome/browser/safe_browsing/report.pb.h" 8 #include "chrome/browser/safe_browsing/report.pb.h"
9 #include "chrome/common/render_messages.h" 9 #include "chrome/common/safebrowsing_messages.h"
10 #include "chrome/common/render_messages_params.h"
11 #include "content/browser/browser_thread.h" 10 #include "content/browser/browser_thread.h"
12 #include "content/browser/renderer_host/test_render_view_host.h" 11 #include "content/browser/renderer_host/test_render_view_host.h"
13 #include "content/browser/tab_contents/navigation_entry.h" 12 #include "content/browser/tab_contents/navigation_entry.h"
14 #include "content/browser/tab_contents/test_tab_contents.h" 13 #include "content/browser/tab_contents/test_tab_contents.h"
15 14
16 static const char* kOriginalLandingURL = "http://www.originallandingpage.com/"; 15 static const char* kOriginalLandingURL = "http://www.originallandingpage.com/";
17 static const char* kLandingURL = "http://www.landingpage.com/"; 16 static const char* kLandingURL = "http://www.landingpage.com/";
18 static const char* kMalwareURL = "http://www.malware.com/"; 17 static const char* kMalwareURL = "http://www.malware.com/";
19 static const char* kHttpsURL = "https://www.url.com/"; 18 static const char* kHttpsURL = "https://www.url.com/";
20 static const char* kDOMChildURL = "http://www.domparent.com/"; 19 static const char* kDOMChildURL = "http://www.domparent.com/";
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
167 TEST_F(MalwareDetailsTest, MalwareDOMDetails) { 166 TEST_F(MalwareDetailsTest, MalwareDOMDetails) {
168 controller().LoadURL(GURL(kLandingURL), GURL(), PageTransition::TYPED); 167 controller().LoadURL(GURL(kLandingURL), GURL(), PageTransition::TYPED);
169 168
170 SafeBrowsingService::UnsafeResource resource; 169 SafeBrowsingService::UnsafeResource resource;
171 InitResource(&resource, ResourceType::SUB_RESOURCE, GURL(kMalwareURL)); 170 InitResource(&resource, ResourceType::SUB_RESOURCE, GURL(kMalwareURL));
172 171
173 scoped_refptr<MalwareDetails> report = MalwareDetails::NewMalwareDetails( 172 scoped_refptr<MalwareDetails> report = MalwareDetails::NewMalwareDetails(
174 contents(), resource); 173 contents(), resource);
175 174
176 // Send a message from the DOM, with 2 nodes, a parent and a child. 175 // Send a message from the DOM, with 2 nodes, a parent and a child.
177 ViewHostMsg_MalwareDOMDetails_Params params; 176 std::vector<SafeBrowsingHostMsg_MalwareDOMDetails_Node> params;
178 ViewHostMsg_MalwareDOMDetails_Node child_node; 177 SafeBrowsingHostMsg_MalwareDOMDetails_Node child_node;
179 child_node.url = GURL(kDOMChildURL); 178 child_node.url = GURL(kDOMChildURL);
180 child_node.tag_name = "iframe"; 179 child_node.tag_name = "iframe";
181 child_node.parent = GURL(kDOMParentURL); 180 child_node.parent = GURL(kDOMParentURL);
182 params.nodes.push_back(child_node); 181 params.push_back(child_node);
183 ViewHostMsg_MalwareDOMDetails_Node parent_node; 182 SafeBrowsingHostMsg_MalwareDOMDetails_Node parent_node;
184 parent_node.url = GURL(kDOMParentURL); 183 parent_node.url = GURL(kDOMParentURL);
185 parent_node.children.push_back(GURL(kDOMChildURL)); 184 parent_node.children.push_back(GURL(kDOMChildURL));
186 params.nodes.push_back(parent_node); 185 params.push_back(parent_node);
187 report->OnReceivedMalwareDOMDetails(params); 186 report->OnReceivedMalwareDOMDetails(params);
188 187
189 MessageLoop::current()->RunAllPending(); 188 MessageLoop::current()->RunAllPending();
190 189
191 scoped_ptr<const std::string> serialized(report->GetSerializedReport()); 190 scoped_ptr<const std::string> serialized(report->GetSerializedReport());
192 ClientMalwareReportRequest actual; 191 ClientMalwareReportRequest actual;
193 actual.ParseFromString(*serialized); 192 actual.ParseFromString(*serialized);
194 193
195 ClientMalwareReportRequest expected; 194 ClientMalwareReportRequest expected;
196 expected.set_malware_url(kMalwareURL); 195 expected.set_malware_url(kMalwareURL);
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
284 pb_resource->set_url(kFirstRedirectURL); 283 pb_resource->set_url(kFirstRedirectURL);
285 pb_resource->set_parent_id(1); 284 pb_resource->set_parent_id(1);
286 285
287 pb_resource = expected.add_resources(); 286 pb_resource = expected.add_resources();
288 pb_resource->set_id(4); 287 pb_resource->set_id(4);
289 pb_resource->set_url(kSecondRedirectURL); 288 pb_resource->set_url(kSecondRedirectURL);
290 pb_resource->set_parent_id(3); 289 pb_resource->set_parent_id(3);
291 290
292 VerifyResults(actual, expected); 291 VerifyResults(actual, expected);
293 } 292 }
OLDNEW
« no previous file with comments | « chrome/browser/safe_browsing/malware_details.cc ('k') | chrome/browser/safe_browsing/safe_browsing_blocking_page_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698