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 297 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
308 monitor_.ClearBrowsingData(CLEAR_BEACONS); | 308 monitor_.ClearBrowsingData(CLEAR_BEACONS); |
309 | 309 |
310 // Make sure the beacon was cleared, but not the contexts. | 310 // Make sure the beacon was cleared, but not the contexts. |
311 EXPECT_EQ(1u, monitor_.contexts_size_for_testing()); | 311 EXPECT_EQ(1u, monitor_.contexts_size_for_testing()); |
312 EXPECT_EQ(0u, CountPendingBeacons(kAlwaysReportIndex)); | 312 EXPECT_EQ(0u, CountPendingBeacons(kAlwaysReportIndex)); |
313 EXPECT_TRUE(CheckRequestCounts(kAlwaysReportIndex, 0u, 0u)); | 313 EXPECT_TRUE(CheckRequestCounts(kAlwaysReportIndex, 0u, 0u)); |
314 EXPECT_EQ(0u, CountPendingBeacons(kNeverReportIndex)); | 314 EXPECT_EQ(0u, CountPendingBeacons(kNeverReportIndex)); |
315 EXPECT_TRUE(CheckRequestCounts(kNeverReportIndex, 0u, 0u)); | 315 EXPECT_TRUE(CheckRequestCounts(kNeverReportIndex, 0u, 0u)); |
316 } | 316 } |
317 | 317 |
318 | |
319 TEST_F(DomainReliabilityMonitorTest, ClearContexts) { | 318 TEST_F(DomainReliabilityMonitorTest, ClearContexts) { |
320 // Initially the monitor should have just the test context. | 319 // Initially the monitor should have just the test context. |
321 EXPECT_EQ(1u, monitor_.contexts_size_for_testing()); | 320 EXPECT_EQ(1u, monitor_.contexts_size_for_testing()); |
322 | 321 |
323 monitor_.ClearBrowsingData(CLEAR_CONTEXTS); | 322 monitor_.ClearBrowsingData(CLEAR_CONTEXTS); |
324 | 323 |
325 // Clearing contexts should leave the monitor with none. | 324 // Clearing contexts should leave the monitor with none. |
326 EXPECT_EQ(0u, monitor_.contexts_size_for_testing()); | 325 EXPECT_EQ(0u, monitor_.contexts_size_for_testing()); |
327 } | 326 } |
328 | 327 |
| 328 TEST_F(DomainReliabilityMonitorTest, IgnoreSuccessError) { |
| 329 RequestInfo request = MakeRequestInfo(); |
| 330 request.url = GURL("http://example/always_report"); |
| 331 request.status.set_error(net::ERR_QUIC_PROTOCOL_ERROR); |
| 332 OnRequestLegComplete(request); |
| 333 |
| 334 EXPECT_EQ(1u, CountPendingBeacons(kAlwaysReportIndex)); |
| 335 EXPECT_TRUE(CheckRequestCounts(kAlwaysReportIndex, 1u, 0u)); |
| 336 |
| 337 BeaconVector beacons; |
| 338 context_->GetQueuedDataForTesting(kAlwaysReportIndex, &beacons, NULL, NULL); |
| 339 EXPECT_EQ(net::OK, beacons[0].chrome_error); |
| 340 } |
| 341 |
329 } // namespace | 342 } // namespace |
330 | 343 |
331 } // namespace domain_reliability | 344 } // namespace domain_reliability |
OLD | NEW |