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

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

Issue 2829163004: Remove uses of base::hash_map from //chrome (Closed)
Patch Set: Downloads back Created 3 years, 5 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
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 <stdint.h> 5 #include <stdint.h>
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/macros.h" 10 #include "base/macros.h"
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after
263 EXPECT_EQ(expected_pb.referrer_url(), report_pb.referrer_url()); 263 EXPECT_EQ(expected_pb.referrer_url(), report_pb.referrer_url());
264 EXPECT_EQ(expected_pb.did_proceed(), report_pb.did_proceed()); 264 EXPECT_EQ(expected_pb.did_proceed(), report_pb.did_proceed());
265 EXPECT_EQ(expected_pb.has_repeat_visit(), report_pb.has_repeat_visit()); 265 EXPECT_EQ(expected_pb.has_repeat_visit(), report_pb.has_repeat_visit());
266 if (expected_pb.has_repeat_visit() && report_pb.has_repeat_visit()) { 266 if (expected_pb.has_repeat_visit() && report_pb.has_repeat_visit()) {
267 EXPECT_EQ(expected_pb.repeat_visit(), report_pb.repeat_visit()); 267 EXPECT_EQ(expected_pb.repeat_visit(), report_pb.repeat_visit());
268 } 268 }
269 269
270 ASSERT_EQ(expected_pb.resources_size(), report_pb.resources_size()); 270 ASSERT_EQ(expected_pb.resources_size(), report_pb.resources_size());
271 // Put the actual resources in a map, then iterate over the expected 271 // Put the actual resources in a map, then iterate over the expected
272 // resources, making sure each exists and is equal. 272 // resources, making sure each exists and is equal.
273 base::hash_map<int, const ClientSafeBrowsingReportRequest::Resource*> 273 std::map<int, const ClientSafeBrowsingReportRequest::Resource*>
274 actual_resource_map; 274 actual_resource_map;
275 for (const ClientSafeBrowsingReportRequest::Resource& resource : 275 for (const ClientSafeBrowsingReportRequest::Resource& resource :
276 report_pb.resources()) { 276 report_pb.resources()) {
277 actual_resource_map[resource.id()] = &resource; 277 actual_resource_map[resource.id()] = &resource;
278 } 278 }
279 // Make sure no resources disappeared when moving them to a map (IDs should 279 // Make sure no resources disappeared when moving them to a map (IDs should
280 // be unique). 280 // be unique).
281 ASSERT_EQ(expected_pb.resources_size(), 281 ASSERT_EQ(expected_pb.resources_size(),
282 static_cast<int>(actual_resource_map.size())); 282 static_cast<int>(actual_resource_map.size()));
283 for (const ClientSafeBrowsingReportRequest::Resource& expected_resource : 283 for (const ClientSafeBrowsingReportRequest::Resource& expected_resource :
284 expected_pb.resources()) { 284 expected_pb.resources()) {
285 ASSERT_TRUE(actual_resource_map.count(expected_resource.id()) > 0); 285 ASSERT_TRUE(actual_resource_map.count(expected_resource.id()) > 0);
286 VerifyResource(*actual_resource_map[expected_resource.id()], 286 VerifyResource(*actual_resource_map[expected_resource.id()],
287 expected_resource); 287 expected_resource);
288 } 288 }
289 289
290 ASSERT_EQ(expected_pb.dom_size(), report_pb.dom_size()); 290 ASSERT_EQ(expected_pb.dom_size(), report_pb.dom_size());
291 // Put the actual elements in a map, then iterate over the expected 291 // Put the actual elements in a map, then iterate over the expected
292 // elements, making sure each exists and is equal. 292 // elements, making sure each exists and is equal.
293 base::hash_map<int, const HTMLElement*> actual_dom_map; 293 std::map<int, const HTMLElement*> actual_dom_map;
294 for (const HTMLElement& element : report_pb.dom()) { 294 for (const HTMLElement& element : report_pb.dom()) {
295 actual_dom_map[element.id()] = &element; 295 actual_dom_map[element.id()] = &element;
296 } 296 }
297 // Make sure no elements disappeared when moving them to a map (IDs should 297 // Make sure no elements disappeared when moving them to a map (IDs should
298 // be unique). 298 // be unique).
299 ASSERT_EQ(expected_pb.dom_size(), static_cast<int>(actual_dom_map.size())); 299 ASSERT_EQ(expected_pb.dom_size(), static_cast<int>(actual_dom_map.size()));
300 for (const HTMLElement& expected_element : expected_pb.dom()) { 300 for (const HTMLElement& expected_element : expected_pb.dom()) {
301 ASSERT_TRUE(actual_dom_map.count(expected_element.id()) > 0); 301 ASSERT_TRUE(actual_dom_map.count(expected_element.id()) > 0);
302 VerifyElement(*actual_dom_map[expected_element.id()], expected_element); 302 VerifyElement(*actual_dom_map[expected_element.id()], expected_element);
303 } 303 }
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
345 EXPECT_EQ(expected.response().remote_ip(), resource.response().remote_ip()); 345 EXPECT_EQ(expected.response().remote_ip(), resource.response().remote_ip());
346 } 346 }
347 347
348 void VerifyElement(const HTMLElement& element, const HTMLElement& expected) { 348 void VerifyElement(const HTMLElement& element, const HTMLElement& expected) {
349 EXPECT_EQ(expected.id(), element.id()); 349 EXPECT_EQ(expected.id(), element.id());
350 EXPECT_EQ(expected.tag(), element.tag()); 350 EXPECT_EQ(expected.tag(), element.tag());
351 EXPECT_EQ(expected.resource_id(), element.resource_id()); 351 EXPECT_EQ(expected.resource_id(), element.resource_id());
352 EXPECT_THAT(element.child_ids(), 352 EXPECT_THAT(element.child_ids(),
353 UnorderedPointwise(Eq(), expected.child_ids())); 353 UnorderedPointwise(Eq(), expected.child_ids()));
354 ASSERT_EQ(expected.attribute_size(), element.attribute_size()); 354 ASSERT_EQ(expected.attribute_size(), element.attribute_size());
355 base::hash_map<std::string, std::string> actual_attributes_map; 355 std::map<std::string, std::string> actual_attributes_map;
356 for (const HTMLElement::Attribute& attribute : element.attribute()) { 356 for (const HTMLElement::Attribute& attribute : element.attribute()) {
357 actual_attributes_map[attribute.name()] = attribute.value(); 357 actual_attributes_map[attribute.name()] = attribute.value();
358 } 358 }
359 ASSERT_EQ(expected.attribute_size(), 359 ASSERT_EQ(expected.attribute_size(),
360 static_cast<int>(actual_attributes_map.size())); 360 static_cast<int>(actual_attributes_map.size()));
361 for (const HTMLElement::Attribute& expected_attribute : 361 for (const HTMLElement::Attribute& expected_attribute :
362 expected.attribute()) { 362 expected.attribute()) {
363 ASSERT_TRUE(actual_attributes_map.count(expected_attribute.name()) > 0); 363 ASSERT_TRUE(actual_attributes_map.count(expected_attribute.name()) > 0);
364 EXPECT_EQ(expected_attribute.value(), 364 EXPECT_EQ(expected_attribute.value(),
365 actual_attributes_map[expected_attribute.name()]); 365 actual_attributes_map[expected_attribute.name()]);
(...skipping 997 matching lines...) Expand 10 before | Expand all | Expand 10 after
1363 pb_resource->set_parent_id(3); 1363 pb_resource->set_parent_id(3);
1364 pb_resource->set_url(kSecondRedirectURL); 1364 pb_resource->set_url(kSecondRedirectURL);
1365 pb_resource = expected.add_resources(); 1365 pb_resource = expected.add_resources();
1366 pb_resource->set_id(3); 1366 pb_resource->set_id(3);
1367 pb_resource->set_url(kFirstRedirectURL); 1367 pb_resource->set_url(kFirstRedirectURL);
1368 1368
1369 VerifyResults(actual, expected); 1369 VerifyResults(actual, expected);
1370 } 1370 }
1371 1371
1372 } // namespace safe_browsing 1372 } // namespace safe_browsing
OLDNEW
« no previous file with comments | « chrome/browser/safe_browsing/safe_browsing_service_browsertest.cc ('k') | chrome/browser/site_details.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698