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

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

Issue 284103003: Domain Reliability: Don't use error code unless request failed (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 6 years, 7 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
« no previous file with comments | « components/domain_reliability/monitor.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 <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
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
OLDNEW
« no previous file with comments | « components/domain_reliability/monitor.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698