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

Side by Side Diff: components/domain_reliability/monitor_unittest.cc

Issue 2421383003: Add operator==(const GURL&, const StringPiece&) to gurl.h (Closed)
Patch Set: remove comment Created 4 years, 2 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "components/domain_reliability/monitor.h" 5 #include "components/domain_reliability/monitor.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <map> 9 #include <map>
10 #include <memory> 10 #include <memory>
(...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after
319 CreateAndAddContextForOrigin(origin2, false); 319 CreateAndAddContextForOrigin(origin2, false);
320 request = MakeRequestInfo(); 320 request = MakeRequestInfo();
321 request.url = origin2; 321 request.url = origin2;
322 request.status = 322 request.status =
323 net::URLRequestStatus::FromError(net::ERR_CONNECTION_RESET); 323 net::URLRequestStatus::FromError(net::ERR_CONNECTION_RESET);
324 OnRequestLegComplete(request); 324 OnRequestLegComplete(request);
325 325
326 // Delete the beacons for |origin1|. 326 // Delete the beacons for |origin1|.
327 monitor_.ClearBrowsingData( 327 monitor_.ClearBrowsingData(
328 CLEAR_BEACONS, 328 CLEAR_BEACONS,
329 base::Bind(&GURL::operator==, base::Unretained(&origin1))); 329 base::Bind(static_cast<bool (*)(const GURL&, const GURL&)>(operator==),
330 origin1));
330 331
331 // Beacons for |context1| were cleared. Beacons for |context2| and 332 // Beacons for |context1| were cleared. Beacons for |context2| and
332 // the contexts themselves were not. 333 // the contexts themselves were not.
333 EXPECT_EQ(2u, monitor_.contexts_size_for_testing()); 334 EXPECT_EQ(2u, monitor_.contexts_size_for_testing());
334 EXPECT_EQ(0u, CountQueuedBeacons(context1)); 335 EXPECT_EQ(0u, CountQueuedBeacons(context1));
335 EXPECT_EQ(1u, CountQueuedBeacons(context2)); 336 EXPECT_EQ(1u, CountQueuedBeacons(context2));
336 } 337 }
337 338
338 TEST_F(DomainReliabilityMonitorTest, ClearContexts) { 339 TEST_F(DomainReliabilityMonitorTest, ClearContexts) {
339 CreateAndAddContext(); 340 CreateAndAddContext();
(...skipping 13 matching lines...) Expand all
353 GURL origin2("http://example.org/"); 354 GURL origin2("http://example.org/");
354 355
355 CreateAndAddContextForOrigin(origin1, false); 356 CreateAndAddContextForOrigin(origin1, false);
356 CreateAndAddContextForOrigin(origin2, false); 357 CreateAndAddContextForOrigin(origin2, false);
357 358
358 EXPECT_EQ(2u, monitor_.contexts_size_for_testing()); 359 EXPECT_EQ(2u, monitor_.contexts_size_for_testing());
359 360
360 // Delete the contexts for |origin1|. 361 // Delete the contexts for |origin1|.
361 monitor_.ClearBrowsingData( 362 monitor_.ClearBrowsingData(
362 CLEAR_CONTEXTS, 363 CLEAR_CONTEXTS,
363 base::Bind(&GURL::operator==, base::Unretained(&origin1))); 364 base::Bind(static_cast<bool (*)(const GURL&, const GURL&)>(operator==),
365 origin1));
364 366
365 // Only one of the contexts should have been deleted. 367 // Only one of the contexts should have been deleted.
366 EXPECT_EQ(1u, monitor_.contexts_size_for_testing()); 368 EXPECT_EQ(1u, monitor_.contexts_size_for_testing());
367 } 369 }
368 370
369 TEST_F(DomainReliabilityMonitorTest, WildcardMatchesSelf) { 371 TEST_F(DomainReliabilityMonitorTest, WildcardMatchesSelf) {
370 DomainReliabilityContext* context = 372 DomainReliabilityContext* context =
371 CreateAndAddContextForOrigin(GURL("https://wildcard/"), true); 373 CreateAndAddContextForOrigin(GURL("https://wildcard/"), true);
372 374
373 RequestInfo request = MakeRequestInfo(); 375 RequestInfo request = MakeRequestInfo();
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
429 request.status = net::URLRequestStatus::FromError(net::ERR_CONNECTION_RESET); 431 request.status = net::URLRequestStatus::FromError(net::ERR_CONNECTION_RESET);
430 OnRequestLegComplete(request); 432 OnRequestLegComplete(request);
431 433
432 EXPECT_EQ(1u, CountQueuedBeacons(context1)); 434 EXPECT_EQ(1u, CountQueuedBeacons(context1));
433 EXPECT_EQ(0u, CountQueuedBeacons(context2)); 435 EXPECT_EQ(0u, CountQueuedBeacons(context2));
434 } 436 }
435 437
436 } // namespace 438 } // namespace
437 439
438 } // namespace domain_reliability 440 } // namespace domain_reliability
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698