| 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 <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <map> | 9 #include <map> |
| 10 #include <memory> | 10 #include <memory> |
| (...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 262 // this unittest will fail if someone tries to add an invalid config to the | 262 // this unittest will fail if someone tries to add an invalid config to the |
| 263 // source tree. | 263 // source tree. |
| 264 monitor_.AddBakedInConfigs(); | 264 monitor_.AddBakedInConfigs(); |
| 265 | 265 |
| 266 // Count the number of baked-in configs. | 266 // Count the number of baked-in configs. |
| 267 size_t num_baked_in_configs = 0; | 267 size_t num_baked_in_configs = 0; |
| 268 for (const char* const* p = kBakedInJsonConfigs; *p; ++p) | 268 for (const char* const* p = kBakedInJsonConfigs; *p; ++p) |
| 269 ++num_baked_in_configs; | 269 ++num_baked_in_configs; |
| 270 | 270 |
| 271 // Also count the Google configs stored in abbreviated form. | 271 // Also count the Google configs stored in abbreviated form. |
| 272 std::vector<DomainReliabilityConfig*> google_configs; | 272 std::vector<std::unique_ptr<DomainReliabilityConfig>> google_configs; |
| 273 GetAllGoogleConfigs(&google_configs); | 273 GetAllGoogleConfigs(&google_configs); |
| 274 size_t num_google_configs = google_configs.size(); | 274 size_t num_google_configs = google_configs.size(); |
| 275 base::STLDeleteElements(&google_configs); | |
| 276 | 275 |
| 277 // The monitor should have contexts for all of the baked-in configs. | 276 // The monitor should have contexts for all of the baked-in configs. |
| 278 EXPECT_EQ(num_baked_in_configs + num_google_configs, | 277 EXPECT_EQ(num_baked_in_configs + num_google_configs, |
| 279 monitor_.contexts_size_for_testing()); | 278 monitor_.contexts_size_for_testing()); |
| 280 } | 279 } |
| 281 | 280 |
| 282 TEST_F(DomainReliabilityMonitorTest, ClearBeacons) { | 281 TEST_F(DomainReliabilityMonitorTest, ClearBeacons) { |
| 283 DomainReliabilityContext* context = CreateAndAddContext(); | 282 DomainReliabilityContext* context = CreateAndAddContext(); |
| 284 | 283 |
| 285 // Initially the monitor should have just the test context, with no beacons. | 284 // Initially the monitor should have just the test context, with no beacons. |
| (...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 430 request.status = net::URLRequestStatus::FromError(net::ERR_CONNECTION_RESET); | 429 request.status = net::URLRequestStatus::FromError(net::ERR_CONNECTION_RESET); |
| 431 OnRequestLegComplete(request); | 430 OnRequestLegComplete(request); |
| 432 | 431 |
| 433 EXPECT_EQ(1u, CountQueuedBeacons(context1)); | 432 EXPECT_EQ(1u, CountQueuedBeacons(context1)); |
| 434 EXPECT_EQ(0u, CountQueuedBeacons(context2)); | 433 EXPECT_EQ(0u, CountQueuedBeacons(context2)); |
| 435 } | 434 } |
| 436 | 435 |
| 437 } // namespace | 436 } // namespace |
| 438 | 437 |
| 439 } // namespace domain_reliability | 438 } // namespace domain_reliability |
| OLD | NEW |