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

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

Issue 13145003: Rewrite std::string("") to std::string(), Linux edition. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Ugh Created 7 years, 8 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) 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 <map> 5 #include <map>
6 #include <queue> 6 #include <queue>
7 #include <string> 7 #include <string>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/callback.h" 10 #include "base/callback.h"
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after
245 // The model fetch failed. 245 // The model fetch failed.
246 SetModelFetchResponse("blamodel", false /* failure */); 246 SetModelFetchResponse("blamodel", false /* failure */);
247 EXPECT_CALL(service, EndFetchModel( 247 EXPECT_CALL(service, EndFetchModel(
248 ClientSideDetectionService::MODEL_FETCH_FAILED)) 248 ClientSideDetectionService::MODEL_FETCH_FAILED))
249 .WillOnce(QuitCurrentMessageLoop()); 249 .WillOnce(QuitCurrentMessageLoop());
250 service.StartFetchModel(); 250 service.StartFetchModel();
251 msg_loop_.Run(); // EndFetchModel will quit the message loop. 251 msg_loop_.Run(); // EndFetchModel will quit the message loop.
252 Mock::VerifyAndClearExpectations(&service); 252 Mock::VerifyAndClearExpectations(&service);
253 253
254 // Empty model file. 254 // Empty model file.
255 SetModelFetchResponse("", true /* success */); 255 SetModelFetchResponse(std::string(), true /* success */);
256 EXPECT_CALL(service, EndFetchModel( 256 EXPECT_CALL(service, EndFetchModel(ClientSideDetectionService::MODEL_EMPTY))
257 ClientSideDetectionService::MODEL_EMPTY))
258 .WillOnce(QuitCurrentMessageLoop()); 257 .WillOnce(QuitCurrentMessageLoop());
259 service.StartFetchModel(); 258 service.StartFetchModel();
260 msg_loop_.Run(); // EndFetchModel will quit the message loop. 259 msg_loop_.Run(); // EndFetchModel will quit the message loop.
261 Mock::VerifyAndClearExpectations(&service); 260 Mock::VerifyAndClearExpectations(&service);
262 261
263 // Model is too large. 262 // Model is too large.
264 SetModelFetchResponse( 263 SetModelFetchResponse(
265 std::string(ClientSideDetectionService::kMaxModelSizeBytes + 1, 'x'), 264 std::string(ClientSideDetectionService::kMaxModelSizeBytes + 1, 'x'),
266 true /* success */); 265 true /* success */);
267 EXPECT_CALL(service, EndFetchModel( 266 EXPECT_CALL(service, EndFetchModel(
(...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after
569 // IPv4 prefix match (/15) for ::ffff:192.1.128.0. 568 // IPv4 prefix match (/15) for ::ffff:192.1.128.0.
570 subnet = model.add_bad_subnet(); 569 subnet = model.add_bad_subnet();
571 subnet->set_prefix(crypto::SHA256HashString(std::string( 570 subnet->set_prefix(crypto::SHA256HashString(std::string(
572 "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xff\xff\xc0\x01\x80\x00", 16))); 571 "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xff\xff\xc0\x01\x80\x00", 16)));
573 subnet->set_size(113); 572 subnet->set_size(113);
574 573
575 csd_service_.reset(ClientSideDetectionService::Create(NULL)); 574 csd_service_.reset(ClientSideDetectionService::Create(NULL));
576 ClientSideDetectionService::SetBadSubnets( 575 ClientSideDetectionService::SetBadSubnets(
577 model, &(csd_service_->bad_subnets_)); 576 model, &(csd_service_->bad_subnets_));
578 EXPECT_FALSE(csd_service_->IsBadIpAddress("blabla")); 577 EXPECT_FALSE(csd_service_->IsBadIpAddress("blabla"));
579 EXPECT_FALSE(csd_service_->IsBadIpAddress("")); 578 EXPECT_FALSE(csd_service_->IsBadIpAddress(std::string()));
580 579
581 EXPECT_TRUE(csd_service_->IsBadIpAddress( 580 EXPECT_TRUE(csd_service_->IsBadIpAddress(
582 "2620:0:1000:3103:21a:a0ff:fe10:786e")); 581 "2620:0:1000:3103:21a:a0ff:fe10:786e"));
583 EXPECT_FALSE(csd_service_->IsBadIpAddress( 582 EXPECT_FALSE(csd_service_->IsBadIpAddress(
584 "2620:0:1000:3103:21a:a0ff:fe10:786f")); 583 "2620:0:1000:3103:21a:a0ff:fe10:786f"));
585 584
586 EXPECT_TRUE(csd_service_->IsBadIpAddress("fe80::21a:a0ff:fe10:786e")); 585 EXPECT_TRUE(csd_service_->IsBadIpAddress("fe80::21a:a0ff:fe10:786e"));
587 EXPECT_TRUE(csd_service_->IsBadIpAddress("fe80::31a:a0ff:fe10:786e")); 586 EXPECT_TRUE(csd_service_->IsBadIpAddress("fe80::31a:a0ff:fe10:786e"));
588 EXPECT_TRUE(csd_service_->IsBadIpAddress("fe80::21a:a0ff:fe10:786f")); 587 EXPECT_TRUE(csd_service_->IsBadIpAddress("fe80::21a:a0ff:fe10:786f"));
589 EXPECT_FALSE(csd_service_->IsBadIpAddress("fe81::21a:a0ff:fe10:786e")); 588 EXPECT_FALSE(csd_service_->IsBadIpAddress("fe81::21a:a0ff:fe10:786e"));
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
711 EXPECT_CALL(*service, ScheduleFetchModel(_)) 710 EXPECT_CALL(*service, ScheduleFetchModel(_))
712 .WillOnce(Invoke(service, &MockClientSideDetectionService::Schedule)); 711 .WillOnce(Invoke(service, &MockClientSideDetectionService::Schedule));
713 EXPECT_CALL(*service, EndFetchModel( 712 EXPECT_CALL(*service, EndFetchModel(
714 ClientSideDetectionService::MODEL_NOT_CHANGED)) 713 ClientSideDetectionService::MODEL_NOT_CHANGED))
715 .WillOnce(Invoke(service, &MockClientSideDetectionService::Disable)); 714 .WillOnce(Invoke(service, &MockClientSideDetectionService::Disable));
716 csd_service_->SetEnabledAndRefreshState(true); 715 csd_service_->SetEnabledAndRefreshState(true);
717 EXPECT_FALSE(SendClientReportPhishingRequest(GURL("http://a.com/"), 0.4f)); 716 EXPECT_FALSE(SendClientReportPhishingRequest(GURL("http://a.com/"), 0.4f));
718 Mock::VerifyAndClearExpectations(service); 717 Mock::VerifyAndClearExpectations(service);
719 } 718 }
720 } // namespace safe_browsing 719 } // namespace safe_browsing
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698