| OLD | NEW |
| 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 <map> | 7 #include <map> |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 332 TEST_F(DomainReliabilityMonitorTest, ClearContexts) { | 332 TEST_F(DomainReliabilityMonitorTest, ClearContexts) { |
| 333 // Initially the monitor should have just the test context. | 333 // Initially the monitor should have just the test context. |
| 334 EXPECT_EQ(1u, monitor_.contexts_size_for_testing()); | 334 EXPECT_EQ(1u, monitor_.contexts_size_for_testing()); |
| 335 | 335 |
| 336 monitor_.ClearBrowsingData(CLEAR_CONTEXTS); | 336 monitor_.ClearBrowsingData(CLEAR_CONTEXTS); |
| 337 | 337 |
| 338 // Clearing contexts should leave the monitor with none. | 338 // Clearing contexts should leave the monitor with none. |
| 339 EXPECT_EQ(0u, monitor_.contexts_size_for_testing()); | 339 EXPECT_EQ(0u, monitor_.contexts_size_for_testing()); |
| 340 } | 340 } |
| 341 | 341 |
| 342 // TODO(davidben): When https://crbug.com/490311 is resolved, this test can be | |
| 343 // removed. | |
| 344 TEST_F(DomainReliabilityMonitorTest, IgnoreSuccessError) { | |
| 345 RequestInfo request = MakeRequestInfo(); | |
| 346 request.url = GURL("http://example/always_report"); | |
| 347 request.status = net::URLRequestStatus(net::URLRequestStatus::SUCCESS, | |
| 348 net::ERR_QUIC_PROTOCOL_ERROR); | |
| 349 OnRequestLegComplete(request); | |
| 350 | |
| 351 BeaconVector beacons; | |
| 352 context_->GetQueuedBeaconsForTesting(&beacons); | |
| 353 EXPECT_EQ(1u, beacons.size()); | |
| 354 EXPECT_EQ(net::OK, beacons[0].chrome_error); | |
| 355 | |
| 356 EXPECT_TRUE(CheckRequestCounts(kAlwaysReportIndex, 1u, 0u)); | |
| 357 } | |
| 358 | |
| 359 TEST_F(DomainReliabilityMonitorTest, WildcardMatchesSelf) { | 342 TEST_F(DomainReliabilityMonitorTest, WildcardMatchesSelf) { |
| 360 DomainReliabilityContext* context = CreateAndAddContext("*.wildcard"); | 343 DomainReliabilityContext* context = CreateAndAddContext("*.wildcard"); |
| 361 | 344 |
| 362 RequestInfo request = MakeRequestInfo(); | 345 RequestInfo request = MakeRequestInfo(); |
| 363 request.url = GURL("http://wildcard/always_report"); | 346 request.url = GURL("http://wildcard/always_report"); |
| 364 OnRequestLegComplete(request); | 347 OnRequestLegComplete(request); |
| 365 EXPECT_TRUE(CheckRequestCounts(context, kAlwaysReportIndex, 1u, 0u)); | 348 EXPECT_TRUE(CheckRequestCounts(context, kAlwaysReportIndex, 1u, 0u)); |
| 366 } | 349 } |
| 367 | 350 |
| 368 TEST_F(DomainReliabilityMonitorTest, WildcardMatchesSubdomain) { | 351 TEST_F(DomainReliabilityMonitorTest, WildcardMatchesSubdomain) { |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 416 request.url = GURL("http://test.wildcard/always_report"); | 399 request.url = GURL("http://test.wildcard/always_report"); |
| 417 OnRequestLegComplete(request); | 400 OnRequestLegComplete(request); |
| 418 | 401 |
| 419 EXPECT_TRUE(CheckRequestCounts(context1, kAlwaysReportIndex, 1u, 0u)); | 402 EXPECT_TRUE(CheckRequestCounts(context1, kAlwaysReportIndex, 1u, 0u)); |
| 420 EXPECT_TRUE(CheckRequestCounts(context2, kAlwaysReportIndex, 0u, 0u)); | 403 EXPECT_TRUE(CheckRequestCounts(context2, kAlwaysReportIndex, 0u, 0u)); |
| 421 } | 404 } |
| 422 | 405 |
| 423 } // namespace | 406 } // namespace |
| 424 | 407 |
| 425 } // namespace domain_reliability | 408 } // namespace domain_reliability |
| OLD | NEW |