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

Side by Side Diff: chrome/browser/safe_browsing/certificate_reporting_service_browsertest.cc

Issue 2916383005: Fix flaky CertificateReportingServiceBrowserTest.DontSendOldReports test (Closed)
Patch Set: Created 3 years, 6 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 | « no previous file | 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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 "chrome/browser/safe_browsing/certificate_reporting_service.h" 5 #include "chrome/browser/safe_browsing/certificate_reporting_service.h"
6 6
7 #include "base/base_switches.h" 7 #include "base/base_switches.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/macros.h" 9 #include "base/macros.h"
10 #include "base/test/histogram_tester.h" 10 #include "base/test/histogram_tester.h"
(...skipping 370 matching lines...) Expand 10 before | Expand all | Expand 10 after
381 ReportExpectation::Failed({{"report1", RetryStatus::NOT_RETRIED}})); 381 ReportExpectation::Failed({{"report1", RetryStatus::NOT_RETRIED}}));
382 382
383 // Queued report should now be successfully sent. 383 // Queued report should now be successfully sent.
384 test_helper()->SetFailureMode(certificate_reporting_test_utils:: 384 test_helper()->SetFailureMode(certificate_reporting_test_utils::
385 ReportSendingResult::REPORTS_SUCCESSFUL); 385 ReportSendingResult::REPORTS_SUCCESSFUL);
386 SendPendingReports(); 386 SendPendingReports();
387 test_helper()->WaitForRequestsDestroyed( 387 test_helper()->WaitForRequestsDestroyed(
388 ReportExpectation::Successful({{"report1", RetryStatus::RETRIED}})); 388 ReportExpectation::Successful({{"report1", RetryStatus::RETRIED}}));
389 } 389 }
390 390
391 // Failing on some Win and Mac buildbots. See crbug.com/719138.
392 #if defined(OS_WIN) || defined(OS_MACOSX)
393 #define MAYBE_DontSendOldReports DISABLED_DontSendOldReports
394 #else
395 #define MAYBE_DontSendOldReports DontSendOldReports
396 #endif
397 // CertificateReportingService should ignore reports older than the report TTL. 391 // CertificateReportingService should ignore reports older than the report TTL.
398 IN_PROC_BROWSER_TEST_F(CertificateReportingServiceBrowserTest, 392 IN_PROC_BROWSER_TEST_F(CertificateReportingServiceBrowserTest,
399 MAYBE_DontSendOldReports) { 393 DontSendOldReports) {
400 SetExpectedHistogramCountOnTeardown(5); 394 SetExpectedHistogramCountOnTeardown(5);
401 395
402 base::SimpleTestClock* clock = new base::SimpleTestClock(); 396 base::SimpleTestClock* clock = new base::SimpleTestClock();
403 base::Time reference_time = base::Time::Now(); 397 base::Time reference_time = base::Time::Now();
404 clock->SetNow(reference_time); 398 clock->SetNow(reference_time);
405 factory()->SetClockForTesting(std::unique_ptr<base::Clock>(clock)); 399 factory()->SetClockForTesting(std::unique_ptr<base::Clock>(clock));
406 400
407 // The service should ignore reports older than 24 hours. 401 // The service should ignore reports older than 24 hours.
408 factory()->SetQueuedReportTTLForTesting(base::TimeDelta::FromHours(24)); 402 factory()->SetQueuedReportTTLForTesting(base::TimeDelta::FromHours(24));
409 403
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
449 test_helper()->WaitForRequestsDestroyed( 443 test_helper()->WaitForRequestsDestroyed(
450 ReportExpectation::Failed({{"report2", RetryStatus::RETRIED}})); 444 ReportExpectation::Failed({{"report2", RetryStatus::RETRIED}}));
451 445
452 // Advance the clock 20 hours again so that report2 is 25 hours old and is 446 // Advance the clock 20 hours again so that report2 is 25 hours old and is
453 // older than max age (24 hours). 447 // older than max age (24 hours).
454 clock->Advance(base::TimeDelta::FromHours(20)); 448 clock->Advance(base::TimeDelta::FromHours(20));
455 449
456 // Send pending reports. report2 should be discarded since it's too old. No 450 // Send pending reports. report2 should be discarded since it's too old. No
457 // other reports remain. If any report is sent, test teardown will catch it. 451 // other reports remain. If any report is sent, test teardown will catch it.
458 SendPendingReports(); 452 SendPendingReports();
453
454 // Let all reports succeed and send a single report. This is to make sure
455 // that any (incorrectly) pending reports are dropped before the test tear
456 // down.
457 test_helper()->SetFailureMode(certificate_reporting_test_utils::
458 ReportSendingResult::REPORTS_SUCCESSFUL);
459 SendReport("report3");
460 test_helper()->WaitForRequestsDestroyed(
461 ReportExpectation::Successful({{"report3", RetryStatus::NOT_RETRIED}}));
459 } 462 }
460 463
461 // CertificateReportingService should drop old reports from its pending report 464 // CertificateReportingService should drop old reports from its pending report
462 // queue, if the queue is full. 465 // queue, if the queue is full.
463 IN_PROC_BROWSER_TEST_F(CertificateReportingServiceBrowserTest, 466 IN_PROC_BROWSER_TEST_F(CertificateReportingServiceBrowserTest,
464 DropOldReportsFromQueue) { 467 DropOldReportsFromQueue) {
465 SetExpectedHistogramCountOnTeardown(7); 468 SetExpectedHistogramCountOnTeardown(7);
466 469
467 base::SimpleTestClock* clock = new base::SimpleTestClock(); 470 base::SimpleTestClock* clock = new base::SimpleTestClock();
468 base::Time reference_time = base::Time::Now(); 471 base::Time reference_time = base::Time::Now();
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
613 test_helper()->WaitForRequestsCreated( 616 test_helper()->WaitForRequestsCreated(
614 ReportExpectation::Delayed({{"report1", RetryStatus::NOT_RETRIED}})); 617 ReportExpectation::Delayed({{"report1", RetryStatus::NOT_RETRIED}}));
615 618
616 // Resume the delayed report and wait for it to complete. 619 // Resume the delayed report and wait for it to complete.
617 test_helper()->ResumeDelayedRequest(); 620 test_helper()->ResumeDelayedRequest();
618 test_helper()->WaitForRequestsDestroyed( 621 test_helper()->WaitForRequestsDestroyed(
619 ReportExpectation::Delayed({{"report1", RetryStatus::NOT_RETRIED}})); 622 ReportExpectation::Delayed({{"report1", RetryStatus::NOT_RETRIED}}));
620 } 623 }
621 624
622 } // namespace safe_browsing 625 } // namespace safe_browsing
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698